-
Notifications
You must be signed in to change notification settings - Fork 84
/
CMakeLists.txt
83 lines (70 loc) · 2.85 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
cmake_minimum_required(VERSION 3.18...3.22)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(DEEPTIME_VERSION "0.0.0" CACHE STRING "The version without commit offset. Defaults to 0.0.0")
set(DEEPTIME_VERSION_INFO "0.0.0" CACHE STRING "The full version. Defaults to 0.0.0")
set(DEEPTIME_BUILD_CPP_TESTS OFF CACHE BOOL "Whether to build the c++ unit tests")
if(DEFINED PROJECT_NAME)
set(DEEPTIME_IS_SUBPROJECT ON)
endif()
project(deeptime LANGUAGES C CXX VERSION ${DEEPTIME_VERSION})
set(DEEPTIME_ROOT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}")
message(STATUS "Got deeptime version ${DEEPTIME_VERSION}")
message(STATUS "Got deeptime full version ${DEEPTIME_VERSION_INFO}")
message(STATUS "Building tests: ${DEEPTIME_BUILD_CPP_TESTS}")
include(GNUInstallDirs)
if(SKBUILD)
# Scikit-Build does not add your site-packages to the search path
# automatically, so we need to add it _or_ the pybind11 specific directory
# here.
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c
"import pybind11; print(pybind11.get_cmake_dir())"
OUTPUT_VARIABLE _tmp_dir
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT)
list(APPEND CMAKE_PREFIX_PATH "${_tmp_dir}")
else()
execute_process(
COMMAND "${PYTHON_EXECUTABLE}" -c
"import skbuild; from pathlib import Path; print(str((Path(skbuild.__file__).parents[0] / 'resources' / 'cmake').absolute()))"
OUTPUT_VARIABLE _tmp_dir
OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ECHO STDOUT
)
list(APPEND CMAKE_MODULE_PATH "${_tmp_dir}")
endif()
find_package(OpenMP 4)
if(OpenMP_FOUND)
add_definitions(-DUSE_OPENMP)
endif()
if(MSVC)
add_compile_options(/W3 /EHsc /bigobj /permissive- /std:c++17)
endif()
find_package(Python COMPONENTS Development NumPy)
find_package(pybind11 CONFIG REQUIRED)
function(register_pybind_module name)
cmake_parse_arguments(PARSE_ARGV 1 ARG "" "" "")
pybind11_add_module(${name} ${ARG_UNPARSED_ARGUMENTS})
target_link_libraries(${name} PUBLIC deeptime::deeptime)
if (OpenMP_FOUND)
target_link_libraries(${name} PUBLIC OpenMP::OpenMP_CXX)
endif()
file(RELATIVE_PATH REL_PATH "${DEEPTIME_ROOT_DIRECTORY}/deeptime" "${CMAKE_CURRENT_LIST_DIR}")
install(TARGETS ${name} DESTINATION ${REL_PATH})
if(NOT SKBUILD)
set_target_properties(${name} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
endif()
endfunction()
add_subdirectory(deeptime/src)
add_subdirectory(deeptime/numeric)
add_subdirectory(deeptime/data)
add_subdirectory(deeptime/covariance/util/covar_c)
add_subdirectory(deeptime/clustering)
add_subdirectory(deeptime/basis)
add_subdirectory(deeptime/markov)
add_subdirectory(deeptime/plots)
if (NOT SKBUILD)
add_subdirectory(examples/clustering_custom_metric)
endif()
if(DEEPTIME_BUILD_CPP_TESTS)
add_subdirectory(tests)
endif()