generated from DARMA-tasking/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
102 lines (81 loc) · 2.89 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
cmake_minimum_required(VERSION 3.17 FATAL_ERROR)
project(vt-tv VERSION 1.5.0)
# Try to find ccache to speed up compilation
find_program(ccache_binary ccache)
if (ccache_binary)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${ccache_binary}")
endif()
file(
GLOB
HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/*.h
)
set(VT_TV_LIBRARY vt-tv CACHE INTERNAL "" FORCE)
set(VT_TV_LIBRARY_NS vt::lib::vt-tv)
set(
CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/"
)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard to use")
endif()
message(STATUS "CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD}")
option(VT_TV_PYTHON_BINDINGS_ENABLED "Build vt-tv with Python bindings" OFF)
option(VT_TV_OPENMP_ENABLED "Build vt-tv with openMP support" ON)
option(VT_TV_TESTS_ENABLED "Build vt-tv with unit tests" ON)
option(VT_TV_COVERAGE_ENABLED "Build vt-tv with coverage" OFF)
set(VT_TV_N_THREADS "2" CACHE STRING "Number of OpenMP threads to use")
# add -fPIC to all targets (if building with nanobind)
if(VT_TV_PYTHON_BINDINGS_ENABLED)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
option(VT_TV_WERROR_ENABLED "Build vt-tv with warnings as errors" OFF)
include(cmake/load_packages.cmake)
if(APPLE AND NOT CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
add_compile_options(-ffat-lto-objects)
endif()
add_definitions(-DVT_TV_N_THREADS=${VT_TV_N_THREADS})
add_compile_definitions(SRC_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
add_compile_definitions(BUILD_DIR="${CMAKE_BINARY_DIR}")
if(VT_TV_OPENMP_ENABLED)
add_definitions(-DVT_TV_OPENMP_ENABLED=1)
else()
add_definitions(-DVT_TV_OPENMP_ENABLED=0)
endif()
add_custom_target(vt_tv_examples)
if (VT_TV_TESTS_ENABLED)
add_custom_target(vt_tv_tests)
endif()
add_custom_target(vt_tv_apps)
set(PROJECT_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(PROJECT_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(PROJECT_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(PROJECT_EXAMPLE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/examples)
set(PROJECT_APP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/apps)
set(PROJECT_BINDINGS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/bindings)
add_subdirectory(src)
add_subdirectory(examples)
add_subdirectory(apps)
add_subdirectory(bindings)
include(CTest) #adds option BUILD_TESTING (default ON)
message(STATUS "VT_TV_COVERAGE_ENABLED: ${VT_TV_COVERAGE_ENABLED}")
if (VT_TV_COVERAGE_ENABLED)
add_compile_options(-fprofile-arcs -ftest-coverage -O0)
add_link_options(--coverage)
endif()
message(STATUS "VT_TV_TESTS_ENABLED: ${VT_TV_TESTS_ENABLED}")
if (BUILD_TESTING AND VT_TV_TESTS_ENABLED)
set(CTEST_SOURCE_DIRECTORY ${SOURCE_DIR}/src)
add_subdirectory(tests)
endif()
configure_file(
cmake/vtTVConfig.cmake.in
"${PROJECT_BINARY_DIR}/vtTVConfig.cmake" @ONLY
)
install(
FILES "${PROJECT_BINARY_DIR}/vtTVConfig.cmake"
DESTINATION cmake
COMPONENT lib
)