diff options
| author | Mike Taves <mwtoews@gmail.com> | 2020-02-20 12:37:37 +1300 |
|---|---|---|
| committer | Kristian Evers <kristianevers@gmail.com> | 2020-02-21 11:23:15 +0100 |
| commit | 3eac8d5694cfd1049f613cc5c638097976244768 (patch) | |
| tree | 58d7a7e56840d4c90338c58d53d698ec8409a383 | |
| parent | 86530f3146ec091c26652e60067088dc3e067fae (diff) | |
| download | PROJ-3eac8d5694cfd1049f613cc5c638097976244768.tar.gz PROJ-3eac8d5694cfd1049f613cc5c638097976244768.zip | |
Switch build configuration logic from DISABLE_TIFF to ENABLE_TIFF
* Autotools interface should be the same, but different ./configure --help
* For CMake, the option should be -DENABLE_TIFF=NO (default is YES)
* Use TIFF_ENABLED and CURL_ENABLED variables, based on option and outcome
* Reword some messages and add hints
* Move -DTIFF_ENABLED and -DCURL_ENABLED from global add_definitions()
to target_compile_definitions(), which is recommended practice
* Minor spelling and style consistency around SQLITE_VERSION check
| -rw-r--r-- | CMakeLists.txt | 33 | ||||
| -rw-r--r-- | configure.ac | 10 | ||||
| -rw-r--r-- | src/lib_proj.cmake | 6 | ||||
| -rw-r--r-- | test/unit/CMakeLists.txt | 3 |
4 files changed, 30 insertions, 22 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b04c933e..be3303dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,26 +127,31 @@ if(NOT SQLITE3_FOUND) message(SEND_ERROR "sqlite3 dependency not found!") endif() -# Would build and run with older versons, but with horrible performance +# Would build and run with older versions, but with horrible performance # See https://github.com/OSGeo/PROJ/issues/1718 -IF("${SQLITE3_VERSION}" VERSION_LESS "3.11") +if("${SQLITE3_VERSION}" VERSION_LESS "3.11") message(SEND_ERROR "sqlite3 >= 3.11 required!") -ENDIF() +endif() ################################################################################ # Check for libtiff ################################################################################ -option(DISABLE_TIFF "Disable TIFF support" OFF) -mark_as_advanced(DISABLE_TIFF) -if(DISABLE_TIFF) - message(WARNING "TIFF support has been disabled and will result in the inability to read some grids") -else() +option(ENABLE_TIFF "Enable TIFF support to read some grids" ON) +mark_as_advanced(ENABLE_TIFF) +set(TIFF_ENABLED FALSE) +if(ENABLE_TIFF) find_package(TIFF REQUIRED) - if(NOT TIFF_FOUND) - message(SEND_ERROR "libtiff dependency not found!") + if(TIFF_FOUND) + set(TIFF_ENABLED TRUE) + else() + message(SEND_ERROR + "libtiff dependency not found! Use ENABLE_TIFF=OFF to force it off") endif() - add_definitions(-DTIFF_ENABLED) +else() + message(WARNING + "TIFF support is not enabled and will result in the inability to read " + "some grids") endif() ################################################################################ @@ -154,12 +159,14 @@ endif() ################################################################################ option(ENABLE_CURL "Enable Curl support" ON) +set(CURL_ENABLED FALSE) if(ENABLE_CURL) find_package(CURL REQUIRED) - if(NOT CURL_FOUND) + if(CURL_FOUND) + set(CURL_ENABLED TRUE) + else() message(SEND_ERROR "curl dependency not found!") endif() - add_definitions(-DCURL_ENABLED) endif() ################################################################################ diff --git a/configure.ac b/configure.ac index 88a5ba55..1759624c 100644 --- a/configure.ac +++ b/configure.ac @@ -238,7 +238,7 @@ dnl --------------------------------------------------------------------------- if test "x$SQLITE3_CFLAGS$SQLITE3_LIBS" = "x" ; then - dnl Would build and run with older versons, but with horrible performance + dnl Would build and run with older versions, but with horrible performance dnl See https://github.com/OSGeo/PROJ/issues/1718 PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= 3.11]) @@ -256,12 +256,10 @@ dnl Check for libtiff dnl --------------------------------------------------------------------------- AC_ARG_ENABLE([tiff], - AS_HELP_STRING([--disable-tiff], - [Disable TIFF support. Strongly discouraged !]), - [enable_tiff=no], - [enable_tiff=yes]) + AS_HELP_STRING([--enable-tiff], + [Enable TIFF support; strongly encouraged to read some grids [default=yes]])) -if test "x$enable_tiff" = "xyes" -o "x$enable_tiff" = ""; then +if test "x$enable_tiff" != "xno" -o "x$enable_tiff" = ""; then if test "x$TIFF_CFLAGS$TIFF_LIBS" = "x" ; then if $PKG_CONFIG libtiff; then PKG_CHECK_MODULES([TIFF], [libtiff]) diff --git a/src/lib_proj.cmake b/src/lib_proj.cmake index 9200baba..e764aeee 100644 --- a/src/lib_proj.cmake +++ b/src/lib_proj.cmake @@ -406,12 +406,14 @@ endif() target_include_directories(${PROJ_CORE_TARGET} PRIVATE ${SQLITE3_INCLUDE_DIR}) target_link_libraries(${PROJ_CORE_TARGET} ${SQLITE3_LIBRARY}) -if(NOT DISABLE_TIFF) +if(TIFF_ENABLED) + target_compile_definitions(${PROJ_CORE_TARGET} PRIVATE -DTIFF_ENABLED) target_include_directories(${PROJ_CORE_TARGET} PRIVATE ${TIFF_INCLUDE_DIR}) target_link_libraries(${PROJ_CORE_TARGET} ${TIFF_LIBRARY}) endif() -if(CURL_FOUND) +if(CURL_ENABLED) + target_compile_definitions(${PROJ_CORE_TARGET} PRIVATE -DCURL_ENABLED) target_include_directories(${PROJ_CORE_TARGET} PRIVATE ${CURL_INCLUDE_DIR}) target_link_libraries(${PROJ_CORE_TARGET} ${CURL_LIBRARY}) endif() diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 845d07e5..cd662865 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -153,8 +153,9 @@ set_property(TEST gie_self_tests add_executable(test_network main.cpp test_network.cpp) -if(CURL_FOUND) +if(CURL_ENABLED) include_directories(${CURL_INCLUDE_DIR}) + target_compile_definitions(test_network PRIVATE -DCURL_ENABLED) target_link_libraries(test_network ${CURL_LIBRARY}) endif() target_link_libraries(test_network |
