-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
executable file
·93 lines (75 loc) · 2.96 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
cmake_minimum_required(VERSION 3.18.0)
project(pressiodemoapps CXX)
#=====================================================================
# versioning
#=====================================================================
file(READ "version.txt" PDA_VERSION)
message("pressiodemoapps version = ${PDA_VERSION}")
#=====================================================================
# we need c++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# test if compiler supports standard
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++17" COMPILER_SUPPORT_CPP17)
if(NOT COMPILER_SUPPORT_CPP17)
message(FATAL_ERROR "Compiler does not support -std=c++17. This is required.")
endif()
# force C++17 for pressio too
set(PRESSIO_ENABLE_CXX17 ON)
#=====================================================================
# guard against in-source builds
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds are not allowed.
Please make a new directory (e.g. build directory) and run CMake from there.")
endif()
# default to release if build type is empty
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "${CMAKE_BUILD_TYPE} is not specified, defaulting to Release.")
set(CMAKE_BUILD_TYPE "Release")
endif()
# convert cmake build type to lower string
string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_tolower)
if( NOT cmake_build_type_tolower STREQUAL "debug"
AND NOT cmake_build_type_tolower STREQUAL "release")
message(FATAL_ERROR "Unknown build type \"${CMAKE_BUILD_TYPE}\".
Allowed values are Debug, Release (case-insensitive).")
endif()
#=====================================================================
if(PRESSIODEMOAPPS_ENABLE_OPENMP)
find_package(OpenMP)
if(NOT OpenMP_CXX_FOUND)
message(FATAL_ERROR "You enabled OpenMP but I cannot find it")
endif()
endif()
if(PRESSIODEMOAPPS_ENABLE_BINDINGS)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/tpls/eigen3)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tpls/pybind11-2.10.4)
if(PRESSIODEMOAPPS_ENABLE_OPENMP)
link_libraries(OpenMP::OpenMP_CXX)
endif()
set(modulename _pressiodemoappsimpl)
pybind11_add_module(${modulename} ${CMAKE_CURRENT_SOURCE_DIR}/src_py/main_binder.cc)
target_compile_definitions(${modulename} PRIVATE MODNAME=${modulename})
target_compile_definitions(${modulename} PRIVATE PRESSIODEMOAPPS_ENABLE_BINDINGS)
if(PRESSIODEMOAPPS_ENABLE_OPENMP)
target_compile_definitions(${modulename} PRIVATE PRESSIODEMOAPPS_ENABLE_OPENMP)
endif()
else()
if(PRESSIODEMOAPPS_ENABLE_OPENMP)
add_compile_definitions(PRESSIODEMOAPPS_ENABLE_OPENMP)
link_libraries(OpenMP::OpenMP_CXX)
endif()
#add_compile_definitions(EIGEN_DONT_PARALLELIZE)
if(PRESSIODEMOAPPS_ENABLE_TESTS)
enable_testing()
add_subdirectory(tests_mesh)
add_subdirectory(tests_cpp)
endif()
if(PRESSIODEMOAPPS_ENABLE_PERF)
add_subdirectory(tests_perf)
endif()
endif()