-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
68 lines (56 loc) · 1.73 KB
/
CMakeLists.txt
File metadata and controls
68 lines (56 loc) · 1.73 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
cmake_minimum_required(VERSION 3.22)
project(geoslice VERSION 0.1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include(FetchContent)
option(BUILD_PYTHON "Build Python bindings" ON)
option(BUILD_TESTS "Build tests" ON)
# Core library
add_library(geoslice_core STATIC
src/mmap_reader.cpp
src/geo_transform.cpp
src/window_cache.cpp
)
target_include_directories(geoslice_core PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_options(geoslice_core PRIVATE -O3 -march=native)
# Python bindings
if(BUILD_PYTHON)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
# Fetch pybind11
FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
GIT_TAG v2.11.1
)
FetchContent_MakeAvailable(pybind11)
pybind11_add_module(_geoslice_cpp src/bindings.cpp)
target_link_libraries(_geoslice_cpp PRIVATE geoslice_core)
endif()
# Tests
if(BUILD_TESTS)
enable_testing()
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
)
FetchContent_MakeAvailable(googletest)
add_executable(geoslice_tests
tests/test_mmap_reader.cpp
tests/test_geo_transform.cpp
tests/test_window_cache.cpp
)
target_link_libraries(geoslice_tests PRIVATE geoslice_core GTest::gtest_main)
include(GoogleTest)
gtest_discover_tests(geoslice_tests)
endif()
# Install
install(TARGETS geoslice_core EXPORT geoslice-targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(DIRECTORY include/geoslice DESTINATION include)