-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
121 lines (99 loc) · 2.93 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Set the minimum version of CMake that can be used
cmake_minimum_required(VERSION 3.9)
# Set the project name
project (sdcsim)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake >= 3.24:
cmake_policy(SET CMP0135 NEW)
# fetch latest argparse
include(FetchContent)
FetchContent_Declare(
argparse
GIT_REPOSITORY https://github.com/p-ranav/argparse.git
)
FetchContent_MakeAvailable(argparse)
# added include
include_directories(include)
if(DEFINED ACC_TARGET)
message(STATUS "ACC_TARGET: ${ACC_TARGET}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -acc=${ACC_TARGET} -Minfo=accel -Xcompiler -fopenmp -mp=multicore")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -acc=${ACC_TARGET} -Minfo=accel -Xcompiler -fopenmp -mp=multicore")
if(ACC_TARGET MATCHES "gpu")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -gpu=cc61,debug -cudalib=curand")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -gpu=cc61,fastmath -cudalib=curand")
endif()
# Add an executable
add_executable(sdcsim
src/main.cpp
src/domain.cpp
src/strand.cpp
src/molecule.cpp
src/molecule_gpu.cpp
src/output.cpp
src/assembly.cpp
src/register.cpp
src/svg.cpp
src/nucleotides.cpp
src/error.cpp
)
target_link_libraries(sdcsim argparse)
endif()
if(NOT DEFINED ACC_TARGET)
message(STATUS "CPU only compiler. Use NVHPC compiler If you want compile GPU version. Using ${CMAKE_CXX_COMPILER_ID} compiler.")
# google test
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
add_library(project_lib
src/domain.cpp
src/strand.cpp
src/molecule.cpp
src/molecule_gpu.cpp
src/output.cpp
src/assembly.cpp
src/register.cpp
src/svg.cpp
src/nucleotides.cpp
src/error.cpp
)
# Add an executable
add_executable(sdcsim
src/main.cpp
src/domain.cpp
src/strand.cpp
src/molecule.cpp
src/molecule_gpu.cpp
src/output.cpp
src/assembly.cpp
src/register.cpp
src/svg.cpp
src/nucleotides.cpp
src/error.cpp
)
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
target_link_libraries(sdcsim PUBLIC OpenMP::OpenMP_CXX argparse)
else(OpenMP_CXX_FOUND)
target_link_libraries(sdcsim argparse)
endif()
##############
# Unit Tests
##############
enable_testing()
add_executable(unitTests
test/unit/domain.cpp
test/unit/strand.cpp
test/unit/molecule.cpp
test/unit/assembly.cpp
)
# Standard linking to gtest stuff.
target_link_libraries(unitTests gtest gtest_main)
# Extra linking for the project.
target_link_libraries(unitTests project_lib)
endif()