-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
58 lines (48 loc) · 1.69 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
cmake_minimum_required(VERSION 3.5)
project(BayeNet)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(SOURCE_FILES
src/BayesianNetwork.cpp
src/Variable.cpp
)
add_library(${PROJECT_NAME} ${SOURCE_FILES})
target_include_directories(${PROJECT_NAME} PRIVATE
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/lib
)
# Locate GTest package
enable_testing()
find_package(GTest REQUIRED)
# Define the test executable for all tests
set(TEST_FILES
test/test_BayesianNetwork.cpp
test/test_Variable.cpp
test/test_main.cpp
)
add_executable(run_test ${TEST_FILES})
target_link_libraries(run_test GTest::GTest GTest::Main ${PROJECT_NAME})
add_test(NAME run_test COMMAND run_test)
# Compiler warnings
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
endif()
# This optional command can set additional test properties
set_tests_properties(run_test
PROPERTIES
PASS_REGULAR_EXPRESSION "Test Passed; All tests passed"
)
add_custom_target(test_verbose
COMMAND ${CMAKE_CTEST_COMMAND} --verbose
DEPENDS run_test
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
add_custom_target(rerun_failed
COMMAND ${CMAKE_CTEST_COMMAND} --rerun-failed --output-on-failure
DEPENDS test_verbose
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})