-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
75 lines (64 loc) · 2.43 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
# Do not change this version range!
# Doing so can break builds in unexpected ways.
# The manylinux wheel build seem especially sensitive!
cmake_minimum_required(VERSION 3.4...3.18)
project(fwdpy11)
set(CMAKE_CXX_EXTENSIONS OFF)
if(USECPP17)
set(CMAKE_CXX_STANDARD 17)
else()
set(CMAKE_CXX_STANDARD 14)
endif()
message(STATUS "Compiling with C++${CMAKE_CXX_STANDARD} standard.")
if (APPLE)
set(CMAKE_MACOSX_RPATH 1)
endif()
# See https://github.com/pypa/manylinux/issues/1347#issuecomment-1179776736
find_package(Python COMPONENTS Interpreter Development.Module)
find_package(pybind11 CONFIG)
message(STATUS "Found pybind11: ${pybind11_VERSION}")
if(${pybind11_VERSION} VERSION_LESS '2.12.0')
message(FATAL_ERROR "pybind11 version must be >= '2.12.0'")
endif()
add_definitions(-DPYBIND11_VERSION="${pybind11_VERSION}")
find_package(GSL REQUIRED)
option(USE_WEFFCPP "Use -Weffc++ during compilation" OFF)
option(ENABLE_PROFILING "Compile to enable code profiling" OFF)
option(BUILD_PYTHON_UNIT_TESTS "Build C++ modules for unit tests" OFF)
option(BUILD_CPP_UNIT_TESTS "Build C++ unit test suite" OFF)
option(BUILD_CPP_BENCHMARK "Build C++ benchmark program" OFF)
option(DISABLE_LTO "Disable link-time optimization (LTO)" OFF)
option(CMAKE_BUILD "Set to ON when building with cmake. Set to off from, e.g., setup.py." ON)
include_directories(BEFORE
${fwdpy11_SOURCE_DIR}/fwdpy11/headers
${fwdpy11_SOURCE_DIR}/fwdpy11/headers/fwdpp
${fwdpy11_SOURCE_DIR}/lib)
message(STATUS "GSL headers in ${GSL_INCLUDE_DIRS}")
include_directories(BEFORE ${GSL_INCLUDE_DIRS})
if (USE_WEFFCPP)
add_compile_options(-Weffc++)
endif()
if (ENABLE_PROFILING)
add_definitions(-DPYBIND11_NAMESPACE=pybind11)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
if (CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Weffc++ -Woverloaded-virtual -Wold-style-cast -Werror=effc++ -Werror=old-style-cast -Werror=overloaded-virtual -Werror=unused-parameter")
endif()
if (CMAKE_BUILD)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/fwdpy11)
endif()
add_subdirectory(lib)
add_subdirectory(rust)
add_subdirectory(cpp)
if(BUILD_PYTHON_UNIT_TESTS)
add_subdirectory(tests_with_cpp)
endif(BUILD_PYTHON_UNIT_TESTS)
if(BUILD_CPP_UNIT_TESTS)
enable_testing()
add_subdirectory(cpptests)
endif(BUILD_CPP_UNIT_TESTS)
if(BUILD_CPP_BENCHMARK)
enable_testing()
add_subdirectory(cpp_neutral_benchmark)
endif(BUILD_CPP_BENCHMARK)