forked from CSS342-C-W23/assignment-3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
72 lines (59 loc) · 2.01 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
cmake_minimum_required(VERSION 3.10)
project(css342_homework)
# https://stackoverflow.com/questions/66340703/how-to-force-cmake-to-use-the-new-version-of-cmp0077-allow-options-to-be-set-fr
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_FLAGS "-DDEBUG -g -O0")
# path to static library
Set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
# path to library
Set(CMAKE_LIBRARY_PATH ${CMAKE_SOURCE_DIR}/src)
# path to executable
Set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
# disable pthread on Windows
# https://github.com/google/googletest/issues/1051
# https://gist.github.com/kylemanna/d386526abafce0eea22b
find_package(Thread QUIET)
if(CMAKE_THREAD_LIBS_INIT)
set(gtest_disable_pthreads OFF)
else()
message(STATUS "Disabling pthread in Google Test")
set(gtest_disable_pthreads ON)
endif()
# we use this to get code coverage
if (UNIX AND RUN_COV)
message("coverage flag set")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
endif ()
# set up google test
include(ext_dependencies/googletest/googletest.cmake)
fetch_googletest(
${PROJECT_SOURCE_DIR}/ext_dependencies/googletest
${LIBRARY_OUTPUT_PATH}/ext_dependencies/googletest
)
include (CTest)
# testing targets
add_custom_target(function_tests COMMAND env GTEST_COLOR=1 ${CMAKE_CTEST_COMMAND} -V -R _test)
add_custom_target(mem_tests COMMAND env GTEST_COLOR=1 ${CMAKE_CTEST_COMMAND} --test-action memcheck)
add_subdirectory(src)
add_subdirectory(test)
# code coverage, only run on Linux (e.g. during Github Action)
if (UNIX AND RUN_COV)
message("coverage flag set")
include(ext_dependencies/coverage/CodeCoverage.cmake)
append_coverage_compiler_flags()
setup_target_for_coverage_lcov(
NAME
coverage_check
EXECUTABLE
${PROJECT_NAME}_unit_test
EXCLUDE
"${PROJECT_SOURCE_DIR}/lib/*"
"${PROJECT_SOURCE_DIR}/ext_dependencies/*"
"${PROJECT_SOURCE_DIR}/build/*"
"${PROJECT_SOURCE_DIR}/build/*"
"${PROJECT_SOURCE_DIR}/src/main.cpp"
LCOV_ARGS
"--no-external"
)
endif ()