-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
84 lines (73 loc) · 3.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
73
74
75
76
77
78
79
80
81
82
83
84
cmake_minimum_required(VERSION 3.14)
project(dynamont)
# Enable OpenMP
find_package(OpenMP REQUIRED)
# GoogleTest requires at least C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Set RPATH to include the Conda environment lib directory
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
# fetch GTest version 1.15.2 from github
include(FetchContent)
FetchContent_Declare(
GTest
URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.tar.gz
)
FetchContent_MakeAvailable(GTest)
# Disable installation of GTest system-wide
set(INSTALL_GTEST OFF CACHE BOOL "Disable GTest installation" FORCE)
# Add the include directory to the search path
include_directories(${PROJECT_SOURCE_DIR}/include)
# Create the first executable dynamont-NT
add_library(NT_library src/cpp/utils.cpp src/cpp/NT.cpp)
add_executable(dynamont-NT src/cpp/NT_main.cpp)
target_link_libraries(dynamont-NT PRIVATE NT_library)
if(OpenMP_CXX_FOUND)
target_link_libraries(dynamont-NT PUBLIC OpenMP::OpenMP_CXX)
endif()
# Include header files for NT_library
target_include_directories(dynamont-NT PRIVATE include)
# Create the second executable dynamont-NTC
add_library(NTC_library src/cpp/utils.cpp src/cpp/NTC.cpp)
add_executable(dynamont-NTC src/cpp/NTC_main.cpp)
# Link NTC_library to dynamont-NTC
target_link_libraries(dynamont-NTC PRIVATE NTC_library)
if(OpenMP_CXX_FOUND)
target_link_libraries(dynamont-NTC PUBLIC OpenMP::OpenMP_CXX)
endif()
# Include header files for NTC_library
target_include_directories(dynamont-NTC PRIVATE include)
# Create the second executable dynamont-NT-banded
add_library(NT_banded_library src/cpp/utils.cpp src/cpp/NT_banded.cpp)
add_executable(dynamont-NT-banded src/cpp/NT_banded_main.cpp)
# Link NT_banded_library to dynamont-NTbanded
target_link_libraries(dynamont-NT-banded PRIVATE NT_banded_library)
if(OpenMP_CXX_FOUND)
target_link_libraries(dynamont-NT-banded PUBLIC OpenMP::OpenMP_CXX)
endif()
# Include header files for NT_banded_library
target_include_directories(dynamont-NT-banded PRIVATE include)
# Create the test executable
# need global variables from dynamont-NTC.cpp
add_executable(test_dynamont test/test.cpp src/cpp/NTC.cpp)
# exclude main from dynamont-NTC.cpp with UNIT_TESTING definition
target_compile_definitions(test_dynamont PRIVATE UNIT_TESTING)
# add GTest
find_package(GTest REQUIRED)
# Link GTest
target_link_libraries(test_dynamont PRIVATE GTest::GTest GTest::Main)
# Link dynamont_lib to the test executable
target_link_libraries(test_dynamont PRIVATE NTC_library)
if(OpenMP_CXX_FOUND)
target_link_libraries(test_dynamont PUBLIC OpenMP::OpenMP_CXX)
endif()
# Include header files for the test target
target_include_directories(test_dynamont PRIVATE include)
# Add the test to CTest
add_test(NAME DynamontTests COMMAND test_dynamont)
# Specify installation location
install(TARGETS dynamont-NT DESTINATION bin)
install(TARGETS dynamont-NTC DESTINATION bin)
install(TARGETS dynamont-NT-banded DESTINATION bin)
install(TARGETS test_dynamont DESTINATION bin)