diff --git a/cmake/optional.cmake b/cmake/optional.cmake index a4c247d39f..730e510c07 100644 --- a/cmake/optional.cmake +++ b/cmake/optional.cmake @@ -325,36 +325,48 @@ else() endif() # Check for HDF5 libraries -find_package(HDF5 QUIET COMPONENTS C) -if(HDF5_FOUND) - include_directories(${HDF5_INCLUDE_DIR}) # for older versions of cmake - include_directories(${HDF5_INCLUDE_DIRS}) # for newer cmake - message("-- Found HDF5 version: ${HDF5_VERSION}") - if (HDF5_VERSION VERSION_GREATER 1.12 OR HDF5_VERSION VERSION_EQUAL 1.12) - message(" Enforcing API macro mapping to HDF5 version 1.10.") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DH5_USE_110_API") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DH5_USE_110_API") - endif() - message(" Found HDF5 libraries: ${HDF5_LIBRARIES}") - if(VERBOSE) - message(STATUS ${HDF5_INCLUDE_DIRS} ${HDF5_INCLUDE_DIR}) +option(WITH_HDF5 "Compile with HDF5 enabled" ON) +if(WITH_HDF5) + find_package(HDF5 QUIET COMPONENTS C) + if(HDF5_FOUND) + include_directories(${HDF5_INCLUDE_DIR}) # for older versions of cmake + include_directories(${HDF5_INCLUDE_DIRS}) # for newer cmake + message("-- Found HDF5 version: ${HDF5_VERSION}") + if (HDF5_VERSION VERSION_GREATER 1.12 OR HDF5_VERSION VERSION_EQUAL 1.12) + message(" Enforcing API macro mapping to HDF5 version 1.10.") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DH5_USE_110_API") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DH5_USE_110_API") + endif() + message(" Found HDF5 libraries: ${HDF5_LIBRARIES}") + if(VERBOSE) + message(STATUS ${HDF5_INCLUDE_DIRS} ${HDF5_INCLUDE_DIR}) + endif() + else() + message("${BoldCyan} X No HDF5 C libraries found. Excluding hdf5printer and hdf5reader from GAMBIT configuration.${ColourReset}") + set(itch "${itch}" "hdf5printer" "hdf5reader") endif() else() - message("${BoldCyan} X No HDF5 C libraries found. Excluding hdf5printer and hdf5reader from GAMBIT configuration.${ColourReset}") + message("${BoldCyan} X HDF5 is disabled. Excluding hdf5printer and hdf5reader from GAMBIT configuration. Use -DWITH_MPI=ON to enable HDF5. ${ColourReset}") set(itch "${itch}" "hdf5printer" "hdf5reader") endif() # Check for SQLite libraries -find_package(SQLite3 QUIET COMPONENTS C) -if(SQLite3_FOUND) - include_directories(${SQLite3_INCLUDE_DIRS}) - message("-- Found SQLite3 libraries: ${SQLite3_LIBRARIES}") - if(VERBOSE) - message(STATUS ${SQLite3_INCLUDE_DIRS}) +option(WITH_SQLite3 "Compile with SQLite3 enabled" ON) +if(WITH_SQLite3) + find_package(SQLite3 QUIET COMPONENTS C) + if(SQLite3_FOUND) + include_directories(${SQLite3_INCLUDE_DIRS}) + message("-- Found SQLite3 libraries: ${SQLite3_LIBRARIES}") + if(VERBOSE) + message(STATUS ${SQLite3_INCLUDE_DIRS}) + endif() + else() + message("${BoldCyan} X No SQLite C libraries found. Excluding sqliteprinter and sqlitereader from GAMBIT configuration.${ColourReset}") + message(" Backends depending on SQLite3 (e.g. Contur) will be deactivated.") + set(itch "${itch}" "sqliteprinter" "sqlitereader") endif() else() - message("${BoldCyan} X No SQLite C libraries found. Excluding sqliteprinter and sqlitereader from GAMBIT configuration.${ColourReset}") - message(" Backends depending on SQLite3 (e.g. Contur) will be deactivated.") + message("${BoldCyan} X SQLite3 is disabled. Excluding sqliteprinter and sqlitereader from GAMBIT configuration. Use -DWITH_SQLite3=ON to enable SQLite3. ${ColourReset}") set(itch "${itch}" "sqliteprinter" "sqlitereader") endif()