-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
98 lines (83 loc) · 2.36 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
cmake_minimum_required(VERSION 3.20)
PROJECT(txtz
VERSION 0.9.2
LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 17)
if(NOT DEFINED HISTO_FILENAME1 AND NOT DEFINED HISTO_FILENAME2)
set(HISTO_FILENAME1 "data/de-nachnamen+histo.txt")
set(HISTO_FILENAME2 "data/de-vornamen+histo.txt")
endif()
if(NOT DEFINED MAPBUILDING_ALGO)
set(MAPBUILDING_ALGO "huffman")
endif()
if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -pedantic")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -pedantic -O2")
endif (UNIX)
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall /wd4623 /wd4061 /wd4625 /wd4626 /wd5039 /wd5027 /wd4514 /wd4820 /wd4668 /wd5045 /wd4866 /wd4365 /wd4710 /wd4711")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /Od")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /O2")
endif (MSVC)
include_directories(
PRIVATE
getopt-cpp/include
json/include
glob
PUBLIC
)
add_custom_command(
DEPENDS mapbuilder
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/mappings.cpp
COMMAND mapbuilder --quiet --map-file "${CMAKE_CURRENT_SOURCE_DIR}/src/mappings" --input "${CMAKE_CURRENT_SOURCE_DIR}/${HISTO_FILENAME1}" --input "${CMAKE_CURRENT_SOURCE_DIR}/${HISTO_FILENAME2}"
)
add_custom_target(GenerateMap DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/mappings.cpp)
if(MAPBUILDING_ALGO STREQUAL "huffman")
add_definitions(-DALGO_HUFFMAN)
elseif(MAPBUILDING_ALGO STREQUAL "shannon-fano")
add_definitions(-DALGO_SHANNON_FANO)
else()
endif()
add_executable(txtz
src/txtz-main.cpp
src/txtz.cpp
src/mappings.cpp
src/code.cpp
src/shannon-fano.cpp
src/huffman.cpp
src/util.cpp
)
add_executable(checker
src/checker.cpp
src/txtz.cpp
src/mappings.cpp
src/code.cpp
src/shannon-fano.cpp
src/huffman.cpp
src/util.cpp
)
add_dependencies(txtz GenerateMap)
add_dependencies(checker GenerateMap)
add_executable(mapbuilder
src/mapbuilder.cpp
src/code.cpp
src/shannon-fano.cpp
src/huffman.cpp
src/util.cpp
glob/glob.cpp
)
if(UNIX AND CMAKE_BUILD_TYPE MATCHES Release)
add_custom_command(TARGET txtz
POST_BUILD
COMMAND strip $<TARGET_FILE:txtz>)
add_custom_command(TARGET mapbuilder
POST_BUILD
COMMAND strip $<TARGET_FILE:mapbuilder>)
add_custom_command(TARGET checker
POST_BUILD
COMMAND strip $<TARGET_FILE:checker>)
endif()
install(TARGETS txtz
CONFIGURATIONS Release
RUNTIME DESTINATION "$ENV{HOME}/bin")