2020-10-01 18:59:18 +08:00
|
|
|
# Copyright 2020 Google LLC
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
2022-01-28 17:38:27 +08:00
|
|
|
# https://www.apache.org/licenses/LICENSE-2.0
|
2020-10-01 18:59:18 +08:00
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2020-10-17 00:15:11 +08:00
|
|
|
cmake_minimum_required(VERSION 3.12)
|
2020-10-01 18:59:18 +08:00
|
|
|
|
|
|
|
project(GDALSandbox CXX C)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
|
|
|
|
set(SAPI_ROOT "" CACHE PATH "Path to the Sandboxed API source tree")
|
2020-10-06 02:01:15 +08:00
|
|
|
set(ENABLE_TESTS OFF CACHE BOOL "Enable GDAL sandbox tests")
|
|
|
|
set(GDAL_HEADER_PREFIX "/usr/local/include" CACHE PATH "Prefix of the path to gdal.h")
|
|
|
|
set(LIBGDAL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/lib" CACHE PATH "Prefix of the path to libgdal.a")
|
|
|
|
set(LIBPROJ_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/lib" CACHE PATH "Prefix of the path to libproj.a")
|
2020-10-01 18:59:18 +08:00
|
|
|
|
|
|
|
add_subdirectory("${SAPI_ROOT}"
|
|
|
|
"${CMAKE_BINARY_DIR}/sandboxed-api-build"
|
|
|
|
EXCLUDE_FROM_ALL)
|
|
|
|
|
|
|
|
add_library(libgdal STATIC IMPORTED)
|
2020-10-19 23:08:03 +08:00
|
|
|
set_property(TARGET libgdal PROPERTY IMPORTED_LOCATION
|
2020-10-06 02:01:15 +08:00
|
|
|
"${LIBGDAL_PREFIX}/libgdal.a")
|
2020-10-01 18:59:18 +08:00
|
|
|
|
2020-10-06 02:01:15 +08:00
|
|
|
add_library(libproj STATIC IMPORTED)
|
|
|
|
set_property(TARGET libproj PROPERTY IMPORTED_LOCATION
|
|
|
|
"${LIBPROJ_PREFIX}/libproj.a")
|
2020-10-01 18:59:18 +08:00
|
|
|
|
|
|
|
target_link_libraries(libgdal INTERFACE
|
2020-10-19 23:08:03 +08:00
|
|
|
crypto
|
|
|
|
expat
|
2020-10-06 02:01:15 +08:00
|
|
|
jpeg
|
|
|
|
libproj
|
2020-10-19 23:08:03 +08:00
|
|
|
sqlite3
|
|
|
|
tiff
|
|
|
|
z
|
|
|
|
pthread
|
|
|
|
m
|
|
|
|
rt
|
|
|
|
dl
|
2020-10-06 02:01:15 +08:00
|
|
|
curl
|
|
|
|
)
|
2020-10-01 18:59:18 +08:00
|
|
|
|
|
|
|
add_sapi_library(gdal_sapi
|
2020-10-19 23:08:03 +08:00
|
|
|
FUNCTIONS
|
|
|
|
GDALOpen
|
|
|
|
GDALAllRegister
|
|
|
|
GDALGetDatasetDriver
|
2020-10-01 18:59:18 +08:00
|
|
|
GDALCreate
|
|
|
|
GDALGetDriverByName
|
2020-10-19 23:08:03 +08:00
|
|
|
GDALGetRasterBand
|
2020-10-01 18:59:18 +08:00
|
|
|
GDALSetRasterColorInterpretation
|
2020-10-19 23:08:03 +08:00
|
|
|
GDALSetProjection
|
|
|
|
GDALSetGeoTransform
|
|
|
|
GDALSetRasterNoDataValue
|
|
|
|
GDALRasterIO
|
2020-10-01 18:59:18 +08:00
|
|
|
GDALClose
|
|
|
|
|
2020-10-06 02:01:15 +08:00
|
|
|
INPUTS "${GDAL_HEADER_PREFIX}/gdal.h"
|
2020-10-01 18:59:18 +08:00
|
|
|
LIBRARY libgdal
|
2020-10-15 23:13:11 +08:00
|
|
|
LIBRARY_NAME Gdal
|
2020-10-19 23:08:03 +08:00
|
|
|
|
2020-10-01 18:59:18 +08:00
|
|
|
NAMESPACE "gdal::sandbox"
|
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories(gdal_sapi INTERFACE
|
|
|
|
"${PROJECT_BINARY_DIR}"
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(data_retriever STATIC
|
|
|
|
get_raster_data.h get_raster_data.cc
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(data_retriever
|
|
|
|
libgdal
|
|
|
|
)
|
|
|
|
|
2020-10-14 04:03:04 +08:00
|
|
|
add_library(utils STATIC
|
|
|
|
utils.h utils.cc
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(utils PUBLIC
|
|
|
|
sapi::sapi
|
2021-01-14 01:25:25 +08:00
|
|
|
sapi::temp_file
|
|
|
|
sapi::fileops
|
2020-10-14 04:03:04 +08:00
|
|
|
sandbox2::util
|
2021-01-14 01:25:25 +08:00
|
|
|
sapi::file_base
|
2020-10-14 04:03:04 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
add_library(gtiff_converter STATIC
|
|
|
|
gtiff_converter.h gtiff_converter.cc
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(gtiff_converter PUBLIC
|
|
|
|
data_retriever
|
|
|
|
gdal_sapi
|
|
|
|
sapi::sapi
|
|
|
|
)
|
|
|
|
|
2020-10-01 18:59:18 +08:00
|
|
|
add_executable(raster_to_gtiff
|
|
|
|
raster_to_gtiff.cc
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(raster_to_gtiff
|
|
|
|
data_retriever
|
2020-10-14 04:03:04 +08:00
|
|
|
utils
|
|
|
|
gtiff_converter
|
2020-10-01 18:59:18 +08:00
|
|
|
)
|
|
|
|
|
2020-10-06 02:01:15 +08:00
|
|
|
if (ENABLE_TESTS)
|
2020-10-17 00:15:11 +08:00
|
|
|
include(GoogleTest)
|
|
|
|
enable_testing()
|
|
|
|
|
2020-10-06 02:01:15 +08:00
|
|
|
add_executable(tests tests.cc)
|
|
|
|
target_link_libraries(tests PRIVATE
|
|
|
|
data_retriever
|
2020-10-14 04:03:04 +08:00
|
|
|
gtiff_converter
|
|
|
|
utils
|
2020-10-19 23:08:03 +08:00
|
|
|
gtest
|
2020-10-17 00:15:11 +08:00
|
|
|
gtest_main
|
2021-01-14 01:25:25 +08:00
|
|
|
sapi::testing
|
|
|
|
sapi::file_base
|
2020-10-17 00:15:11 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
gtest_discover_tests(tests PROPERTIES
|
|
|
|
ENVIRONMENT "TEST_TMPDIR=/tmp/"
|
|
|
|
ENVIRONMENT "TEST_SRCDIR=${PROJECT_SOURCE_DIR}"
|
2020-10-06 02:01:15 +08:00
|
|
|
)
|
2020-10-17 00:15:11 +08:00
|
|
|
|
2020-10-06 02:01:15 +08:00
|
|
|
endif()
|