forked from pyre/pyre
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
139 lines (117 loc) · 3.4 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# -*- cmake -*-
#
# michael a.g. aïvázis
# orthologue
# (c) 1998-2020 all rights reserved
#
# cmake setup
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
# policies
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif(POLICY CMP0048)
cmake_policy(SET CMP0060 NEW)
if (POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif(POLICY CMP0074)
if (POLICY CMP0076)
cmake_policy(SET CMP0076 NEW)
endif(POLICY CMP0076)
# options
option(WITH_CUDA "enable support for CUDA" OFF)
# adjust the include path
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/.cmake)
# get support
include(pyre_init)
include(pyre_journal)
include(pyre_pyre)
include(pyre_merlin)
include(pyre_cuda)
include(pyre_mpi)
include(pyre_gsl)
include(pyre_postgres)
# ask git for the pyre version
pyre_getVersion()
# set up the project
project(PYRE VERSION ${REPO_MAJOR}.${REPO_MINOR}.${REPO_MICRO} LANGUAGES CXX C)
# hmmmm
include(GNUInstallDirs)
# programs
find_program(BASH_PROGRAM bash)
# packages
# gsl
find_package(GSL)
# mpi
find_package(MPI)
# postgres
find_package(PostgreSQL)
# python
find_package(Python3 COMPONENTS Interpreter Development NumPy)
# for building bindings
set(PYBIND11_CPP_STANDARD -std=c++17)
set(PYBIND11_PYTHON_VERSION ${Python3_VERSION})
find_package(pybind11)
# pybind11 pre-2.5 C++17 compilation is broken under Clang
# see https://github.com/pybind/pybind11/issues/1604#issuecomment-443385783
if(pybind11_VERSION VERSION_LESS 2.5 AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(pybind11::module INTERFACE -fsized-deallocation)
endif()
# set up cmake
pyre_cmakeInit()
# set up c++
pyre_cxxInit()
# set up python
pyre_pythonInit()
# initialize the variables that describe the staging directory layout
pyre_stagingInit()
# initialize the variables that describe the install directory layout
pyre_destinationInit()
find_package(Filesystem REQUIRED)
# visit subdirectories
add_subdirectory(packages)
add_subdirectory(lib)
add_subdirectory(extensions)
add_subdirectory(defaults)
add_subdirectory(bin)
# make exports available in binary dir during build
export(EXPORT pyre-targets
NAMESPACE pyre::
)
# install exports to installation prefix
set(PYRE_CMAKE_DIR "share/cmake/pyre" CACHE STRING
"Installation directory for cmake files, relative to install prefix")
install(EXPORT pyre-targets
NAMESPACE pyre::
DESTINATION ${PYRE_CMAKE_DIR}
)
# set up version detection for cmake find_package
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
pyre-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY ExactVersion
)
# install config file for find_package
configure_package_config_file(
${PROJECT_SOURCE_DIR}/.cmake/pyre-config.cmake.in
${PROJECT_BINARY_DIR}/pyre-config.cmake
INSTALL_DESTINATION ${PYRE_CMAKE_DIR})
install(FILES ${PROJECT_BINARY_DIR}/pyre-config.cmake
${PROJECT_BINARY_DIR}/pyre-config-version.cmake
DESTINATION ${PYRE_CMAKE_DIR})
# create aliases matching the exports above
add_library(pyre::pyre ALIAS pyre)
add_library(pyre::journal ALIAS journal)
# if we are building to test
if(BUILD_TESTING)
# get support
include(CTest)
# and my functions
include(pyre_tests)
# initialize the variables that describe the test suite; needed so harnesses can set up the
# working directory correctly
pyre_testInit()
# add the testsuite to the pile
add_subdirectory(tests)
endif()
# end of file