-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
85 lines (73 loc) · 3.13 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
84
85
# ##############################################################################
# CMake settings
cmake_minimum_required(VERSION 3.10.0)
set(CMAKE_COLOR_MAKEFILE ON)
# set path to additional CMake modules
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# ##############################################################################
# Project and version
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "0")
set(CPACK_PACKAGE_VERSION_PATCH "3")
set(COMPLETE_VERSION
${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
)
project(gdal-grass VERSION ${COMPLETE_VERSION})
include(CTest)
# ##############################################################################
# Dependencies and flags
find_package(GDAL REQUIRED)
find_package(GRASS REQUIRED)
find_package(PostgreSQL)
find_package(PROJ)
if(NOT AUTOLOAD_DIR)
exec_program(
${GDAL_CONFIG} ARGS
--prefix
OUTPUT_VARIABLE GDALPREFIX)
set(AUTOLOAD_DIR ${GDALPREFIX}/lib/gdalplugins)
if(NOT AUTOLOAD_DIR)
message(FATAL_ERROR "Could not set GDAL plugin path")
endif()
endif()
message(
STATUS "Using ${AUTOLOAD_DIR} as GDAL shared library autoload directory")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -DUSE_CPL -DGRASS_GISBASE=\\\"${GRASS_GISBASE}\\\"")
# ##############################################################################
# Build
set(GLIB_SOURCES grass.cpp)
set(OLIB_SOURCES ogrgrassdriver.cpp ogrgrassdatasource.cpp ogrgrasslayer.cpp ogrgrass.h)
add_library(gdal_grass SHARED ${GLIB_SOURCES})
set_target_properties(gdal_grass PROPERTIES PREFIX "")
set_target_properties(gdal_grass PROPERTIES OUTPUT_NAME "gdal_GRASS")
set_target_properties(gdal_grass PROPERTIES INSTALL_RPATH "${GRASS_GISBASE}/lib")
target_include_directories(
gdal_grass PRIVATE ${CMAKE_SOURCE_DIR} ${GDAL_INCLUDE_DIR} ${PostgreSQL_INCLUDE_DIRS}
${GRASS_INCLUDE} ${PROJ_INCLUDE_DIRS})
target_link_libraries(gdal_grass PUBLIC ${GDAL_LIBRARY} ${G_LIBS})
install(TARGETS gdal_grass DESTINATION ${AUTOLOAD_DIR})
add_library(ogr_grass SHARED ${OLIB_SOURCES})
set_target_properties(ogr_grass PROPERTIES PREFIX "")
set_target_properties(ogr_grass PROPERTIES OUTPUT_NAME "ogr_GRASS")
set_target_properties(ogr_grass PROPERTIES INSTALL_RPATH "${GRASS_GISBASE}/lib")
target_include_directories(
ogr_grass PRIVATE ${CMAKE_SOURCE_DIR} ${GDAL_INCLUDE_DIR} ${PostgreSQL_INCLUDE_DIRS}
${GRASS_INCLUDE} ${PROJ_INCLUDE_DIRS})
target_link_libraries(ogr_grass PUBLIC ${GDAL_LIBRARY} ${G_LIBS})
install(TARGETS ogr_grass DESTINATION ${AUTOLOAD_DIR})
# ##############################################################################
# Tests
if (Python_LOOKUP_VERSION)
set(Python_FIND_STRATEGY VERSION)
find_package(Python ${Python_LOOKUP_VERSION} EXACT COMPONENTS Interpreter Development NumPy)
else ()
set(Python_FIND_STRATEGY LOCATION)
find_package(Python 3.11 COMPONENTS Interpreter Development NumPy)
endif ()
if (BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/autotest")
add_subdirectory(autotest)
endif ()