-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
66 lines (55 loc) · 1.92 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
cmake_minimum_required(VERSION 2.8)
project(BFArchive C CXX)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(BIGFIX_COMPILE_OPTIONS -Wall -Werror -fcolor-diagnostics)
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(BIGFIX_COMPILE_OPTIONS -Wall -Werror)
else()
set(BIGFIX_COMPILE_OPTIONS /W3 /WX /DUNICODE /D_UNICODE)
endif()
if(WIN32)
SET(BIGFIX_COMPILE ${BIGFIX_COMPILE_OPTIONS})
SET(BIGFIX_COMPILE_TEST ${BIGFIX_COMPILE_OPTIONS} /Od)
else()
SET(BIGFIX_COMPILE ${BIGFIX_COMPILE_OPTIONS} -O3)
SET(BIGFIX_COMPILE_TEST ${BIGFIX_COMPILE_OPTIONS} -O0)
if (${COVERAGE})
LIST(APPEND BIGFIX_COMPILE_TEST -coverage)
LIST(APPEND BIGFIX_LINK_TEST -coverage)
endif()
endif()
# Statically link the CRT on Windows. There's got to be a better way to do this.
if(MSVC)
foreach(flag
CMAKE_C_FLAGS CMAKE_CXX_FLAGS
CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO)
string(REPLACE "/MD" "/MT" ${flag} "${${flag}}")
endforeach()
endif(MSVC)
add_subdirectory(External/zlib)
add_subdirectory(External/gtest)
add_subdirectory(Library)
add_subdirectory(Test)
if(WIN32)
set(BFARCHIVE_SOURCES Source/Version.rc Source/WindowsMain.cpp)
else()
set(BFARCHIVE_SOURCES Source/UnixMain.cpp)
endif()
list(APPEND BFARCHIVE_SOURCES
Source/ArchiveCreator.cpp
Source/ArchiveExtractor.cpp
Source/ArchiveLister.cpp
Source/Main.cpp
)
add_executable(bfarchive ${BFARCHIVE_SOURCES})
target_compile_options(bfarchive PRIVATE ${BIGFIX_COMPILE})
target_link_libraries(bfarchive bigfix)
if(WIN32)
set_target_properties(bfarchive PROPERTIES OUTPUT_NAME BFArchive)
endif()
add_executable(bfarchive_testing ${BFARCHIVE_SOURCES})
target_compile_options(bfarchive_testing PRIVATE ${BIGFIX_COMPILE_TEST})
target_link_libraries(bfarchive_testing bigfix_testing ${BIGFIX_LINK_TEST})