-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
59 lines (47 loc) · 2.07 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
cmake_minimum_required (VERSION 2.8)
project (cuhksz-cpp-lib)
option(TESTING "Enable testing with googletest" ON) # TODO off if release version
option(SAMPLES "Compile samples" ON)
option(COVERAGE "Enable coverage test for codecov" OFF)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W4 -wd4244 -wd4267 -wd4800 -wd4068 -wd4458 -WX -MP")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Zi -Od")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ox")
add_definitions(-DUNICODE -D_UNICODE)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wfloat-equal -Werror -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
endif()
if(COVERAGE)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/external)
include(CodeCoverage)
setup_target_for_coverage(${PROJECT_NAME}_coverage test_all coverage)
endif()
aux_source_directory(./src/random RANDOM_SRC)
aux_source_directory(./src/math_utils MATHUTILS_SRC)
aux_source_directory(./src/json JSON_SRC)
aux_source_directory(./src/network NETWORK_SRC)
aux_source_directory(./src/graph GRAPH_SRC)
aux_source_directory(./src/geometry GEOMETRY_SRC)
aux_source_directory(./src/base64 BASE64_SRC)
aux_source_directory(./src/algorithm ALGORITHM_SRC)
aux_source_directory(./src/string_utils STRINGUTILS_SRC)
include_directories(./src/include)
add_library(cuhkszlib STATIC ${RANDOM_SRC} ${MATHUTILS_SRC} ${JSON_SRC} ${NETWORK_SRC} ${GRAPH_SRC} ${GEOMETRY_SRC} ${BASE64_SRC} ${ALGORITHM_SRC} ${STRINGUTILS_SRC})
if(TESTING)
enable_testing()
option(BUILD_GTEST "Builds the googletest subproject" ON)
option(BUILD_GMOCK "Builds the googlemock subproject" OFF)
if(MSVC)
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." ON)
endif()
add_subdirectory(./external/gtest/)
include_directories(./external/gtest/googletest/include)
add_subdirectory(./tests)
add_test (NAME TestAll COMMAND test_all)
endif()
if(SAMPLES)
add_subdirectory(./samples)
endif()