-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
50 lines (42 loc) · 1.75 KB
/
Copy pathCMakeLists.txt
File metadata and controls
50 lines (42 loc) · 1.75 KB
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
cmake_minimum_required(VERSION 3.15)
project(SparseDiffPy LANGUAGES C)
add_subdirectory(SparseDiffEngine)
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module NumPy)
# Linux: CMake find_package(BLAS) doesn't set include dirs;
# openblas puts cblas.h in /usr/include/openblas/
if(UNIX AND NOT APPLE)
find_path(OPENBLAS_INCLUDE_DIR cblas.h PATHS /usr/include/openblas /usr/include)
if(OPENBLAS_INCLUDE_DIR)
target_include_directories(dnlp_diff PRIVATE ${OPENBLAS_INCLUDE_DIR})
endif()
endif()
python3_add_library(_sparsediffengine MODULE
sparsediffpy/_bindings/bindings.c
)
# Match the engine's per-config optimization flags so the extension doesn't rely on
# the toolchain's default CMAKE_C_FLAGS_RELEASE.
if(MSVC)
target_compile_options(_sparsediffengine PRIVATE
$<$<CONFIG:Debug>:/Od /Zi>
$<$<CONFIG:Release>:/O2 /DNDEBUG>
$<$<CONFIG:RelWithDebInfo>:/O2 /Zi /DNDEBUG>
$<$<CONFIG:MinSizeRel>:/Os /DNDEBUG>
)
else()
target_compile_options(_sparsediffengine PRIVATE
$<$<CONFIG:Debug>:-g -O0>
$<$<CONFIG:Release>:-O3 -DNDEBUG>
$<$<CONFIG:RelWithDebInfo>:-O2 -g -DNDEBUG>
$<$<CONFIG:MinSizeRel>:-Os -DNDEBUG>
)
endif()
target_include_directories(_sparsediffengine PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/SparseDiffEngine/include
${CMAKE_CURRENT_SOURCE_DIR}/SparseDiffEngine/include/atoms
${CMAKE_CURRENT_SOURCE_DIR}/SparseDiffEngine/include/utils
${CMAKE_CURRENT_SOURCE_DIR}/SparseDiffEngine/include/old-code
${CMAKE_CURRENT_SOURCE_DIR}/SparseDiffEngine/src
${CMAKE_CURRENT_SOURCE_DIR}/sparsediffpy/_bindings
)
target_link_libraries(_sparsediffengine PRIVATE dnlp_diff Python3::NumPy)
install(TARGETS _sparsediffengine DESTINATION sparsediffpy)