@@ -30,6 +30,7 @@ option(BUILD_TESTS "Build test suite" OFF)
3030option (BUILD_COVERAGE "Build with coverage" OFF )
3131option (WITH_LUA "Build with Lua support" ON )
3232option (WITH_LUAJIT "Build with LuaJIT support" OFF )
33+ option (WITH_PROJ "Build with Projection support" ON )
3334
3435if (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR )
3536 message (FATAL_ERROR "In-source builds are not allowed, please use a separate build directory like `mkdir build && cd build && cmake ..`" )
@@ -57,8 +58,6 @@ option(EXTERNAL_PROTOZERO "Do not use the bundled protozero" OFF)
5758option (EXTERNAL_FMT "Do not use the bundled fmt" OFF )
5859option (EXTERNAL_CLI11 "Do not use the bundled CLI11" OFF )
5960
60- set (USE_PROJ_LIB "auto" CACHE STRING "Which version of PROJ API to use: ('4', '6', 'off', or 'auto')" )
61-
6261if (NOT WIN32 AND NOT APPLE )
6362 # No need for this path, just a workaround to make cmake work on all systems.
6463 # Without this we need the PostgreSQL server libraries installed.
@@ -222,42 +221,18 @@ find_package(OpenCV QUIET OPTIONAL_COMPONENTS core imgcodecs imgproc)
222221
223222set (LIBS ${Boost_LIBRARIES} ${PostgreSQL_LIBRARY} ${OSMIUM_LIBRARIES} )
224223
225- if (USE_PROJ_LIB STREQUAL "off" )
226- message (STATUS "Proj library disabled (because USE_PROJ_LIB is set to 'off')." )
227- else ()
228- find_path (PROJ4_INCLUDE_DIR proj_api.h)
229- if (PROJ4_INCLUDE_DIR AND NOT USE_PROJ_LIB STREQUAL "6" )
230- message (STATUS "Found proj_api.h" )
231- find_library (PROJ_LIBRARY NAMES proj)
232- message (STATUS "Found Proj [API 4] ${PROJ_LIBRARY} " )
233- add_definitions (-DHAVE_GENERIC_PROJ=4)
234- set (HAVE_PROJ4 1)
224+ if (WITH_PROJ)
225+ find_path (PROJ6_INCLUDE_DIR proj.h)
226+ find_library (PROJ_LIBRARY NAMES proj)
227+ if (PROJ_LIBRARY)
228+ message (STATUS "Found Proj ${PROJ_LIBRARY} " )
229+ add_definitions (-DHAVE_GENERIC_PROJ=6)
230+ set (HAVE_PROJ6 1)
235231 list (APPEND LIBS ${PROJ_LIBRARY} )
236- include_directories (SYSTEM ${PROJ4_INCLUDE_DIR} )
237- elseif (NOT USE_PROJ_LIB STREQUAL "4" )
238- find_path (PROJ6_INCLUDE_DIR proj.h)
239- find_library (PROJ_LIBRARY NAMES proj)
240- if (PROJ_LIBRARY)
241- message (STATUS "Found Proj [API 6] ${PROJ_LIBRARY} " )
242- add_definitions (-DHAVE_GENERIC_PROJ=6)
243- set (HAVE_PROJ6 1)
244- list (APPEND LIBS ${PROJ_LIBRARY} )
245- include_directories (SYSTEM ${PROJ6_INCLUDE_DIR} )
246- else ()
247- message (STATUS "Proj library not found." )
248- message (STATUS " Only Mercartor and WGS84 projections will be available." )
249- endif ()
232+ include_directories (SYSTEM ${PROJ6_INCLUDE_DIR} )
250233 endif ()
251234endif ()
252235
253- if (USE_PROJ_LIB STREQUAL "4" AND NOT HAVE_PROJ4)
254- message (FATAL_ERROR "USE_PROJ_LIB was set to '4', but PROJ version 4 API not found" )
255- endif ()
256-
257- if (USE_PROJ_LIB STREQUAL "6" AND NOT HAVE_PROJ6)
258- message (FATAL_ERROR "USE_PROJ_LIB was set to '6', but PROJ version 6 API not found" )
259- endif ()
260-
261236if (LUAJIT_FOUND)
262237 list (APPEND LIBS ${LUAJIT_LIBRARIES} )
263238elseif (LUA_FOUND)
0 commit comments