Skip to content

Commit

Permalink
CMake: fix cryptopp support, and some tidying in check_cxx_source_com…
Browse files Browse the repository at this point in the history
…piles() of other packages
  • Loading branch information
rouault committed Dec 11, 2021
1 parent 1ee278d commit 0903baf
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
3 changes: 1 addition & 2 deletions cmake/helpers/CheckDependentLibraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ gdal_check_package(MSSQL_ODBC "MSSQL ODBC driver to enable bulk copy" CAN_DISABL
gdal_check_package(MySQL "MySQL" CAN_DISABLE)

# basic libraries
find_package(Boost)
gdal_check_package(CURL "Enable drivers to use web API" CAN_DISABLE)

gdal_check_package(Iconv "Character set recoding (used in GDAL portability library)" CAN_DISABLE)
Expand Down Expand Up @@ -161,7 +160,7 @@ find_package(OpenSSL COMPONENTS Crypto SSL)
if(OPENSSL_FOUND)
set(HAVE_OPENSSL ON CACHE INTERNAL "")
endif()
gdal_check_package(CryptoPP "Use crypto++ library for CPL.")
gdal_check_package(CryptoPP "Use crypto++ library for CPL." CAN_DISABLE)
option(CRYPTOPPL_USE_ONLY_CRYPTODLL_ALG "Use Only cryptoDLL alg. only work on dynamic DLL" OFF)

find_package(PROJ 6.0 REQUIRED)
Expand Down
4 changes: 3 additions & 1 deletion cmake/modules/packages/FindCryptoPP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ if(CRYPTOPP_INCLUDE_DIR)
endif()
endif()

if(CRYPTOPP_INCLUDE_DIR AND CRYPTOPP_LIBRARY)
if(CRYPTOPP_INCLUDE_DIR AND CRYPTOPP_LIBRARY AND NOT DEFINED CRYPTOPP_TEST_KNOWNBUG)
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_LIBRARIES ${CRYPTOPP_LIBRARY})
set(CMAKE_REQUIRED_INCLUDES ${CRYPTOPP_INCLUDE_DIR})
# Catch issue with clang++ (https://groups.google.com/forum/#!topic/cryptopp-users/DfWHy3bT0KI)
check_cxx_source_compiles("#include <cryptopp/osrng.h>
int main(int argc, char** argv) { CryptoPP::AES::Encryption oEnc; return 0; }" CRYPTOPP_TEST_KNOWNBUG)
Expand Down
6 changes: 2 additions & 4 deletions cmake/modules/packages/FindFileGDB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ if(FileGDB_INCLUDE_DIR)

find_library(FileGDB_LIBRARY NAMES FileGDBAPI PATHS "${FileGDB_ROOT}/lib" "${FileGDB_ROOT}/lib64")
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_LIBRARIES ${FileGDB_LIBRARY})
set(CMAKE_REQUIRED_INCLUDES ${FileGDB_INCLUDE_DIR})
cmake_push_check_state(RESET)
check_cxx_source_compiles("#include <FileGDBAPI.h>\nusing namespace FileGDBAPI;\n
int main() { Geodatabase oDB; std::wstring osStr; ::OpenGeodatabase(osStr, oDB); return 0; }" TEST_FileGDB_COMPILE)
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_LIBRARIES)
cmake_pop_check_state()
if(NOT TEST_FileGDB_COMPILE)
set(FileGDB_FOUND FALSE)
endif()
Expand Down
6 changes: 2 additions & 4 deletions cmake/modules/packages/FindSQLite3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ if(SQLite3_INCLUDE_DIR)
endif()

if(SQLite3_INCLUDE_DIR AND SQLite3_LIBRARY)
cmake_push_check_state(RESET)
# check column metadata
if( ${SQLite3_LIBRARY} MATCHES "libsqlite3.a" AND PC_SQLITE3_STATIC_LDFLAGS)
set(CMAKE_REQUIRED_LIBRARIES ${PC_SQLITE3_STATIC_LDFLAGS})
Expand All @@ -93,10 +94,7 @@ if(SQLite3_INCLUDE_DIR AND SQLite3_LIBRARY)
return sqlite3_auto_extension ((void (*)(void)) 0);
}")
check_cxx_source_compiles("${SQLITE3_AUTO_EXTENSION_CHECK}" SQLite3_HAS_NON_DEPRECATED_AUTO_EXTENSION)
unset(CMAKE_REQUIRED_FLAGS)

unset(CMAKE_REQUIRED_LIBRARIES)
unset(CMAKE_REQUIRED_INCLUDES)
cmake_pop_check_state()
endif()
mark_as_advanced(SQLite3_LIBRARY SQLite3_INCLUDE_DIR SQLite3_HAS_COLUMN_METADATA SQLite3_HAS_RTREE)

Expand Down
6 changes: 3 additions & 3 deletions port/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,10 @@ if (GDAL_USE_LIBXML2)
gdal_add_private_link_libraries(LibXml2::LibXml2)
endif ()

if (HAVE_CRYPTPP)
if (GDAL_USE_CRYPTOPP)
target_compile_definitions(cpl PRIVATE -DHAVE_CRYPTOPP)
target_include_directories(cpl PRIVATE $<TARGET_PROPERTY:CRYPTPP::CRYPTPP,INTERFACE_INCLUDE_DIRECTORIES>)
gdal_add_private_link_libraries(CRYPTPP::CRYPTPP)
target_include_directories(cpl PRIVATE $<TARGET_PROPERTY:CRYPTOPP::CRYPTOPP,INTERFACE_INCLUDE_DIRECTORIES>)
gdal_add_private_link_libraries(CRYPTOPP::CRYPTOPP)
endif ()

if (TARGET OpenSSL::Crypto)
Expand Down

0 comments on commit 0903baf

Please sign in to comment.