| 1 |
# CMake4GDAL project is distributed under MIT license. See accompanying file LICENSE.txt. |
| 2 |
|
| 3 |
add_library( |
| 4 |
ogr OBJECT |
| 5 |
ogrgeometryfactory.cpp |
| 6 |
ogrpoint.cpp |
| 7 |
ogrcurve.cpp |
| 8 |
ogrlinestring.cpp |
| 9 |
ogrlinearring.cpp |
| 10 |
ogrpolygon.cpp |
| 11 |
ogrtriangle.cpp |
| 12 |
ogrutils.cpp |
| 13 |
ogrgeomcoordinateprecision.cpp |
| 14 |
ogrgeometry.cpp |
| 15 |
ogrgeometrycollection.cpp |
| 16 |
ogrmultipolygon.cpp |
| 17 |
ogrsurface.cpp |
| 18 |
ogrpolyhedralsurface.cpp |
| 19 |
ogrtriangulatedsurface.cpp |
| 20 |
ogrmultipoint.cpp |
| 21 |
ogrmultilinestring.cpp |
| 22 |
ogrcircularstring.cpp |
| 23 |
ogrcompoundcurve.cpp |
| 24 |
ogrcurvepolygon.cpp |
| 25 |
ogrcurvecollection.cpp |
| 26 |
ogrmulticurve.cpp |
| 27 |
ogrmultisurface.cpp |
| 28 |
ogr_api.cpp |
| 29 |
ogrfeature.cpp |
| 30 |
ogrfeaturedefn.cpp |
| 31 |
ogrfeaturequery.cpp |
| 32 |
ogrfeaturestyle.cpp |
| 33 |
ogrfielddefn.cpp |
| 34 |
ogrspatialreference.cpp |
| 35 |
ogr_srsnode.cpp |
| 36 |
ogr_fromepsg.cpp |
| 37 |
ogrct.cpp |
| 38 |
ogr_srs_cf1.cpp |
| 39 |
ogr_srs_esri.cpp |
| 40 |
ogr_srs_pci.cpp |
| 41 |
ogr_srs_usgs.cpp |
| 42 |
ogr_srs_dict.cpp |
| 43 |
ogr_srs_panorama.cpp |
| 44 |
ogr_srs_ozi.cpp |
| 45 |
ogr_srs_erm.cpp |
| 46 |
swq.cpp |
| 47 |
swq_expr_node.cpp |
| 48 |
swq_parser.cpp |
| 49 |
swq_select.cpp |
| 50 |
swq_op_registrar.cpp |
| 51 |
swq_op_general.cpp |
| 52 |
ogr_srs_xml.cpp |
| 53 |
ograssemblepolygon.cpp |
| 54 |
ogr2gmlgeometry.cpp |
| 55 |
gml2ogrgeometry.cpp |
| 56 |
ogr_expat.cpp |
| 57 |
ogrpgeogeometry.cpp |
| 58 |
ogr_geocoding.cpp |
| 59 |
ogr_schema_override.cpp |
| 60 |
ogrgeomfielddefn.cpp |
| 61 |
ograpispy.cpp |
| 62 |
ogr_xerces.cpp |
| 63 |
ogr_geo_utils.cpp |
| 64 |
ogr_proj_p.cpp |
| 65 |
ogr_wkb.cpp |
| 66 |
ogrvrtgeometrytypes.cpp |
| 67 |
ogr2kmlgeometry.cpp |
| 68 |
ogrlibjsonutils.cpp |
| 69 |
ogrgeojsongeometry.cpp |
| 70 |
ogrgeojsonwriter.cpp |
| 71 |
ogresrijsongeometry.cpp |
| 72 |
ogrmitabspatialref.cpp |
| 73 |
mitab_bounds.cpp |
| 74 |
) |
| 75 |
add_dependencies(ogr generate_gdal_version_h) |
| 76 |
|
| 77 |
set(GDAL_DATA_FILES |
| 78 |
LICENSE.TXT |
| 79 |
${CMAKE_CURRENT_SOURCE_DIR}/data/cubewerx_extra.wkt |
| 80 |
${CMAKE_CURRENT_SOURCE_DIR}/data/ecw_cs.wkt |
| 81 |
${CMAKE_CURRENT_SOURCE_DIR}/data/epsg.wkt |
| 82 |
${CMAKE_CURRENT_SOURCE_DIR}/data/esri_StatePlane_extra.wkt |
| 83 |
${CMAKE_CURRENT_SOURCE_DIR}/data/ozi_datum.csv |
| 84 |
${CMAKE_CURRENT_SOURCE_DIR}/data/ozi_ellips.csv |
| 85 |
${CMAKE_CURRENT_SOURCE_DIR}/data/pci_datum.txt |
| 86 |
${CMAKE_CURRENT_SOURCE_DIR}/data/pci_ellips.txt |
| 87 |
${CMAKE_CURRENT_SOURCE_DIR}/data/stateplane.csv |
| 88 |
${CMAKE_CURRENT_SOURCE_DIR}/data/ogr_fields_override.schema.json |
| 89 |
) |
| 90 |
set_property( |
| 91 |
TARGET ${GDAL_LIB_TARGET_NAME} |
| 92 |
APPEND |
| 93 |
PROPERTY RESOURCE "${GDAL_DATA_FILES}") |
| 94 |
|
| 95 |
include(GdalStandardIncludes) |
| 96 |
gdal_standard_includes(ogr) |
| 97 |
target_compile_options(ogr PRIVATE ${GDAL_CXX_WARNING_FLAGS} ${WFLAG_OLD_STYLE_CAST} ${WFLAG_EFFCXX} ${WFLAG_DOUBLE_PROMOTION}) |
| 98 |
set_property(TARGET ogr PROPERTY POSITION_INDEPENDENT_CODE ${GDAL_OBJECT_LIBRARIES_POSITION_INDEPENDENT_CODE}) |
| 99 |
target_sources(${GDAL_LIB_TARGET_NAME} PRIVATE $<TARGET_OBJECTS:ogr>) |
| 100 |
|
| 101 |
if (HAVE_WFLAG_UNREACHABLE_CODE_AGGRESSIVE) |
| 102 |
target_compile_definitions(ogr PRIVATE HAVE_WFLAG_UNREACHABLE_CODE_AGGRESSIVE) |
| 103 |
endif() |
| 104 |
|
| 105 |
target_compile_definitions(ogr PUBLIC $<$<CONFIG:DEBUG>:GDAL_DEBUG>) |
| 106 |
if (USE_PRECOMPILED_HEADERS) |
| 107 |
target_precompile_headers(ogr REUSE_FROM gdal_priv_header) |
| 108 |
endif() |
| 109 |
|
| 110 |
if (GDAL_USE_ZLIB_INTERNAL) |
| 111 |
gdal_add_vendored_lib(ogr libz) |
| 112 |
endif () |
| 113 |
|
| 114 |
if (GDAL_USE_JSONC_INTERNAL) |
| 115 |
gdal_add_vendored_lib(ogr libjson) |
| 116 |
endif () |
| 117 |
|
| 118 |
gdal_target_link_libraries(ogr PRIVATE PROJ::proj) |
| 119 |
|
| 120 |
# External libs then |
| 121 |
if (GDAL_USE_GEOS) |
| 122 |
target_compile_definitions(ogr PRIVATE -DHAVE_GEOS=1) |
| 123 |
gdal_target_link_libraries(ogr PRIVATE ${GEOS_TARGET}) |
| 124 |
endif () |
| 125 |
|
| 126 |
if (GDAL_USE_SFCGAL) |
| 127 |
target_compile_definitions(ogr PRIVATE -DHAVE_SFCGAL=1) |
| 128 |
gdal_target_link_libraries(ogr PRIVATE SFCGAL::SFCGAL) |
| 129 |
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" SFCGAL_VERSION_MAJOR "${SFCGAL_VERSION_STRING}") |
| 130 |
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" SFCGAL_VERSION_MINOR "${SFCGAL_VERSION_STRING}") |
| 131 |
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" SFCGAL_VERSION_PATCH "${SFCGAL_VERSION_STRING}") |
| 132 |
# work around for SFCGAL 1.3.7 on Ubuntu 20.04/Debian |
| 133 |
if (SFCGAL_VERSION_STRING VERSION_EQUAL "1.3.7") |
| 134 |
if (CMAKE_SYSTEM_NAME MATCHES "Linux") |
| 135 |
message( |
| 136 |
WARNING |
| 137 |
"Detect SFCGAL v1.3.7 on Linux (maybe Ubuntu 20.04?), known as buggy that cause a link error. Trying a workaround" |
| 138 |
) |
| 139 |
find_library(GMPXX_LIBRARY NAMES gmpxx) |
| 140 |
gdal_target_link_libraries(ogr PRIVATE ${GMPXX_LIBRARY}) |
| 141 |
endif () |
| 142 |
endif () |
| 143 |
endif () |
| 144 |
configure_file( |
| 145 |
${CMAKE_CURRENT_SOURCE_DIR}/ogr_sfcgal.h.in |
| 146 |
${CMAKE_CURRENT_BINARY_DIR}/ogr_sfcgal.h |
| 147 |
) |
| 148 |
target_include_directories(ogr PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) |
| 149 |
target_include_directories(ogr PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ogrsf_frmts/gmlutils) |
| 150 |
|
| 151 |
if (NOT GDAL_USE_ZLIB_INTERNAL) |
| 152 |
target_compile_definitions(ogr PRIVATE -DHAVE_ZLIB_H -DHAVE_ZLIB) |
| 153 |
if (MSVC AND NOT ZLIB_IS_STATIC) |
| 154 |
target_compile_definitions(ogr PRIVATE -DZLIB_DLL) |
| 155 |
endif () |
| 156 |
gdal_target_link_libraries(ogr PRIVATE ZLIB::ZLIB) |
| 157 |
endif () |
| 158 |
|
| 159 |
if (GDAL_USE_EXPAT) |
| 160 |
target_compile_definitions(ogr PRIVATE -DHAVE_EXPAT) |
| 161 |
gdal_target_link_libraries(ogr PRIVATE ${EXPAT_TARGET}) |
| 162 |
endif () |
| 163 |
|
| 164 |
if (GDAL_USE_XERCESC) |
| 165 |
target_sources(ogr PRIVATE ogr_xerces_headers.h) |
| 166 |
target_compile_definitions(ogr PRIVATE -DHAVE_XERCES) |
| 167 |
gdal_target_link_libraries(ogr PRIVATE XercesC::XercesC) |
| 168 |
endif () |
| 169 |
|
| 170 |
if (NOT GDAL_USE_JSONC_INTERNAL) |
| 171 |
gdal_target_link_libraries(ogr PRIVATE ${JSONC_TARGET}) |
| 172 |
endif () |
| 173 |
|
| 174 |
include(TargetPublicHeader) |
| 175 |
target_public_header( |
| 176 |
TARGET |
| 177 |
gdal |
| 178 |
HEADERS |
| 179 |
ogr_api.h |
| 180 |
ogr_recordbatch.h |
| 181 |
ogr_core.h |
| 182 |
ogr_feature.h |
| 183 |
ogr_featurestyle.h |
| 184 |
ogr_geocoding.h |
| 185 |
ogr_geometry.h |
| 186 |
ogr_geomcoordinateprecision.h |
| 187 |
ogr_p.h |
| 188 |
ogr_spatialref.h |
| 189 |
ogr_refcountedptr.h |
| 190 |
ogr_swq.h |
| 191 |
ogr_srs_api.h |
| 192 |
ogrsf_frmts/ogrsf_frmts.h) |
| 193 |
|
| 194 |
########################################################### |
| 195 |
# Targets to refresh swq_parser.cpp |
| 196 |
########################################################### |
| 197 |
|
| 198 |
# Those targets need to be run manually each time swq_parser.y |
| 199 |
# is modified. |
| 200 |
# We could of course run them automatically, but that would make building |
| 201 |
# GDAL harder. |
| 202 |
|
| 203 |
# This target checks that swq_parser.y md5sum has not changed |
| 204 |
# If it has, then it should be updated and the generate_swq_parser target |
| 205 |
# should be manually run |
| 206 |
add_custom_target(check_swq_parser_md5 ALL |
| 207 |
COMMAND ${CMAKE_COMMAND} |
| 208 |
"-DIN_FILE=swq_parser.y" |
| 209 |
"-DTARGET=generate_swq_parser" |
| 210 |
"-DEXPECTED_MD5SUM=c3eaca734f3005e73586cc697e481f94" |
| 211 |
"-DFILENAME_CMAKE=${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" |
| 212 |
-P "${PROJECT_SOURCE_DIR}/cmake/helpers/check_md5sum.cmake" |
| 213 |
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
| 214 |
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/swq_parser.y" |
| 215 |
VERBATIM) |
| 216 |
|
| 217 |
find_package(BISON) |
| 218 |
add_custom_target(generate_swq_parser |
| 219 |
COMMAND ${CMAKE_COMMAND} |
| 220 |
"-DBISON_FOUND=${BISON_FOUND}" |
| 221 |
"-DBISON_EXECUTABLE=${BISON_EXECUTABLE}" |
| 222 |
-P "${CMAKE_CURRENT_SOURCE_DIR}/generate_swq_parser.cmake" |
| 223 |
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
| 224 |
VERBATIM) |