forked from benbovy/spherely
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
80 lines (61 loc) · 2.29 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
cmake_minimum_required(VERSION 3.15...3.25)
project(
"${SKBUILD_PROJECT_NAME}"
LANGUAGES CXX
VERSION "${SKBUILD_PROJECT_VERSION}")
set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard to build with")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Dependencies
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/third_party/cmake")
find_package(
Python
COMPONENTS Interpreter Development.Module
REQUIRED)
find_package(pybind11 CONFIG REQUIRED)
# TODO: make it more flexible (non-conda)
set(S2_ROOT_DIR "$ENV{CONDA_PREFIX}")
set(S2GEOGRAPHY_ROOT_DIR "$ENV{CONDA_PREFIX}")
find_package(s2 REQUIRED)
find_package(s2geography REQUIRED)
# Compile definitions and flags
if (MSVC)
# used in s2geometry's CMakeLists.txt but not defined in target
# TODO: move this in FindS2.cmake?
target_compile_definitions(s2 INTERFACE _USE_MATH_DEFINES)
target_compile_definitions(s2 INTERFACE NOMINMAX)
target_compile_options(s2 INTERFACE /J)
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR
CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
(CMAKE_CXX_COMPILER_ID MATCHES "Intel" AND NOT WIN32))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -Wreorder")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-variable -Wunused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconversion -Wold-style-cast -Wsign-conversion")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /MP /bigobj /J")
set(CMAKE_EXE_LINKER_FLAGS /MANIFEST:NO)
endif()
# Build
add_library(spherely MODULE
src/geography.cpp
src/predicates.cpp
src/spherely.cpp
)
target_compile_definitions(spherely
PRIVATE VERSION_INFO=${PROJECT_VERSION})
target_link_libraries(spherely
PRIVATE pybind11::module pybind11::lto pybind11::windows_extras
PUBLIC s2 s2geography
)
pybind11_extension(spherely)
if(NOT MSVC AND NOT ${CMAKE_BUILD_TYPE} MATCHES Debug|RelWithDebInfo)
# Strip unnecessary sections of the binary on Linux/macOS
pybind11_strip(spherely)
endif()
set_target_properties(spherely PROPERTIES CXX_VISIBILITY_PRESET "hidden")
# Install
install(TARGETS spherely LIBRARY DESTINATION .)
# install type annotations
install(FILES src/spherely.pyi DESTINATION .)