This repository has been archived by the owner on Nov 28, 2024. It is now read-only.
forked from astro-informatics/sopt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
93 lines (76 loc) · 2.45 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.0)
project(Sopt CXX)
# Location of extra cmake includes for the project
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_files)
# Downloads and installs GreatCMakeCookOff
# It contains a number of cmake recipes
include(LookUp-GreatCMakeCookOff)
# Version and git hash id
include(VersionAndGitRef)
set_version(3.1.0)
get_gitref()
option(tests "Enable testing" on)
option(benchmarks "Enable benchmarking" off)
option(examples "Enable Examples" on)
option(logging "Enable logging" on)
option(regressions "Enable regressions" off)
option(openmp "Enable OpenMP" on)
option(dompi "Enable MPI" on)
option(docs "Build documentation" off)
option(coverage "Build coverage" off)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build Type" FORCE)
endif()
message(STATUS "Building sopt in ${CMAKE_BUILD_TYPE} mode")
if(regressions)
enable_language(C)
endif()
if(tests)
enable_testing()
endif()
# Add c++11 stuff
include(AddCPP11Flags)
include(CheckCXX11Features)
cxx11_feature_check(REQUIRED unique_ptr nullptr override constructor_delegate)
include(compilations)
# search/install dependencies
include(dependencies)
# sets rpath policy explicitly
if(CMAKE_VERSION VERSION_LESS 3.0)
set_property(GLOBAL PROPERTY MACOSX_RPATH ON)
else()
cmake_policy(SET CMP0042 NEW)
endif()
if(SOPT_MPI)
include(DetectIntegerArchitecture)
DetectIntegerArchitecture(SOPT)
endif()
if(tests OR examples)
enable_testing()
endif()
if(tests)
find_package(Catch 2.3.0 EXACT)
include(AddCatchTest)
endif()
if(examples)
include(AddExample)
endif()
if(benchmarks)
set(GBenchmark_GIT_TAG "v1.3.0")
include(AddBenchmark)
endif()
if(regressions)
include(AddRegression)
endif()
if(tests AND coverage)
# Enable code coverage.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
# Build with debugging information to make the output meaningful.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
# Disable optimizations to get the most accurate results.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
endif()
add_subdirectory(cpp)
# Exports all Sopt so other packages can access it
include(export_sopt)