-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
77 lines (66 loc) · 3.09 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
cmake_minimum_required (VERSION 2.8.9)
project(cmp5)
#-------------------------------------------------------------------------------
#set up compiler flags and executable names
#set(CMAKE_CXX_FLAGS "-fPIC") #or -fPIE
if (${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
#set up compiler flags for Clang
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2") #support C++11 for std::, optimize
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2 -s") #optimize, strip binary
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
#check for G++ 4.7+
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE G++_VERSION)
if (G++_VERSION VERSION_LESS 4.7)
message(SEND_ERROR "You need at least G++ 4.7 to compile cmp5!")
endif()
#set up compiler flags for GCC
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2") #support C++11 for std::, optimize
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2 -s") #optimize, strip binary
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES "MSVC")
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") #multi-processor compilation
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") #multi-processor compilation
endif()
#-------------------------------------------------------------------------------
#define basic sources and headers
set(TARGET_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/bwt_codec.h
${CMAKE_CURRENT_SOURCE_DIR}/src/codec.h
${CMAKE_CURRENT_SOURCE_DIR}/src/compressor.h
${CMAKE_CURRENT_SOURCE_DIR}/src/delta_codec.h
${CMAKE_CURRENT_SOURCE_DIR}/src/huffman_codec.h
${CMAKE_CURRENT_SOURCE_DIR}/src/huffman_codes.h
${CMAKE_CURRENT_SOURCE_DIR}/src/lzss_codec.h
${CMAKE_CURRENT_SOURCE_DIR}/src/mtf1_codec.h
${CMAKE_CURRENT_SOURCE_DIR}/src/rgb2planes_codec.h
${CMAKE_CURRENT_SOURCE_DIR}/src/rle0_codec.h
${CMAKE_CURRENT_SOURCE_DIR}/sais/sais.hxx
${CMAKE_CURRENT_SOURCE_DIR}/src/tools.h
)
set(TARGET_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/bwt_codec.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/cmp5.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/codec.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/compressor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/delta_codec.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/huffman_codec.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/huffman_codes.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/lzss_codec.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/mtf1_codec.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/rgb2planes_codec.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/rle0_codec.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/tools.cpp
)
#-------------------------------------------------------------------------------
#set up build directories
set(dir ${CMAKE_CURRENT_SOURCE_DIR})
set(EXECUTABLE_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
set(LIBRARY_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
#-------------------------------------------------------------------------------
#define target
add_executable(cmp5 ${TARGET_SOURCES} ${TARGET_HEADERS})
if (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
target_link_libraries (cmp5 stdc++fs)
endif()