-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
80 lines (59 loc) · 2.12 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
cmake_minimum_required(VERSION 3.8)
project(Automaton CXX)
include(ExternalProject)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" ${CMAKE_SOURCE_DIR}/cmake)
set(EXTERNAL_INSTALL_LOCATION ${Automaton_SOURCE_DIR}/3rdparty)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
find_package(Threads REQUIRED)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Automaton_SOURCE_DIR}/bin)
SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage --coverage")
SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage --coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
if (APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
endif()
SET(CPR_USE_SYSTEM_GTEST ON)
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG main
)
if (APPLE)
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl@1.1" CACHE INTERNAL "")
set(OPENSSL_LIBRARIES "/usr/local/opt/openssl@1.1/lib" CACHE INTERNAL "")
FetchContent_Declare(
cpr_repo
GIT_REPOSITORY https://github.com/libcpr/cpr.git
)
else()
FetchContent_Declare(
cpr_repo
GIT_REPOSITORY https://github.com/libcpr/cpr.git
)
endif()
FetchContent_MakeAvailable(cpr_repo googletest)
include_directories(${EXTERNAL_INSTALL_LOCATION}/include)
link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
include_directories(${CPR_INCLUDE_DIRS})
include(CodeCoverage)
add_custom_target(coverage_report)
function(run_coverage test_sources sources coverage_target target_name coverage_name)
message("INFO test sources ${test_sources}")
set(test_name "${target_name}-test")
message("INFO sources ${sources}")
add_executable(${test_name} ${test_sources} ${sources})
target_link_libraries(
${test_name} gtest_main gtest gmock Threads::Threads cpr curl
)
setup_target_for_coverage(
${coverage_target} ${target_name} ${test_name} ${coverage_name}
)
add_dependencies(coverage_report ${coverage_target})
endfunction()
include_directories(include)
add_subdirectory(src/0-NKA)
add_subdirectory(src/1-DKA)
add_subdirectory(tests)
add_subdirectory(examples)