forked from germasch/psc-orig
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
87 lines (66 loc) · 1.94 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.9)
foreach(policy
CMP0074 # CMake 3.12
)
if(POLICY ${policy})
cmake_policy(SET ${policy} NEW)
endif()
endforeach()
add_subdirectory(src/libmrc)
project(PSC)
include(CTest)
function(psc_option name description default)
set(PSC_USE_${name} ${default} CACHE STRING "${description}")
set_property(CACHE PSC_USE_${name} PROPERTY
STRINGS "ON;TRUE;AUTO;OFF;FALSE"
)
endfunction()
option(USE_CUDA "Build CUDA components" OFF)
option(USE_VPIC "Interface with VPIC" OFF)
option(USE_GTEST_DISCOVER_TESTS "Run tests to discover contained googletest cases" OFF)
psc_option(ADIOS2 "Build with adios2 support" AUTO)
# CUDA
if(USE_CUDA)
list(APPEND CMAKE_CUDA_FLAGS "-std c++14")
enable_language(CUDA)
list(REMOVE_ITEM CMAKE_CUDA_FLAGS "-std c++14")
endif()
find_package(MPI REQUIRED)
add_definitions(-DOMPI_SKIP_MPICXX)
# ADIOS2
if(PSC_USE_ADIOS2 STREQUAL AUTO)
find_package(ADIOS2)
elseif(PSC_USE_ADIOS2)
find_package(ADIOS2 REQUIRED)
endif()
if(ADIOS2_FOUND)
set(PSC_HAVE_ADIOS2 1)
endif()
function(GenerateHeaderConfig)
set(PSC_CONFIG_DEFINES)
foreach(OPT IN LISTS ARGN)
string(APPEND PSC_CONFIG_DEFINES "
/* CMake Option: PSC_USE_${OPT}=${PSC_USE_${OPT}} */
#cmakedefine PSC_HAVE_${OPT}
")
endforeach()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/src/include/PscConfig.h.in
${CMAKE_CURRENT_BINARY_DIR}/src/include/PscConfig.h.in
)
configure_file(
${CMAKE_CURRENT_BINARY_DIR}/src/include/PscConfig.h.in
${CMAKE_CURRENT_BINARY_DIR}/src/include/PscConfig.h
)
endfunction()
# FIXME, unify USE_CUDA, USE_VPIC options / autodetect
# FIXME, mv helpers into separate file
GenerateHeaderConfig(ADIOS2)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src/include)
# FIXME, this seems too ugly to find mrc_config.h
include_directories(${CMAKE_CURRENT_BINARY_DIR}/src/libmrc/include)
add_subdirectory(external)
if (BUILD_TESTING)
include(GoogleTest)
endif()
add_subdirectory(src)