From b13cd844f601f4742d335439b7385a6decd93652 Mon Sep 17 00:00:00 2001 From: Juan Manzanero Date: Thu, 26 Sep 2024 22:37:43 +0200 Subject: [PATCH] [JMT] Add possibility to compile without SZIP --- CMakeLists.txt | 6 +++++- cmake/Findhdf5.cmake | 4 +++- cmake/third-party/CMakeLists.txt | 1 + cmake/third-party/hdf5.cmake | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc34238..6385c55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ include(GNUInstallDirs) # Options option(WITH_HSL "Set to the location of the HSL zip file" OFF) +option(WITH_SZIP "Whether HDF5 will be compiled with SZIP or not" OFF) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/thirdparty) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/thirdparty/include) @@ -63,7 +64,10 @@ if(WITH_HSL) target_compile_definitions(lion INTERFACE WITH_HSL) endif() -target_link_libraries(lion INTERFACE ipopt blaslapack tinyxml2 nlohmann_json fortran_libraries cppad hdf5 ZLIB::ZLIB SZIP::SZIP) +target_link_libraries(lion INTERFACE ipopt blaslapack tinyxml2 nlohmann_json fortran_libraries cppad hdf5 ZLIB::ZLIB) +if(WITH_SZIP) + target_link_libraries(lion INTERFACE SZIP::SZIP) +endif() # Create a lion header only add_library(header_only INTERFACE) diff --git a/cmake/Findhdf5.cmake b/cmake/Findhdf5.cmake index 151417a..0aeffd1 100644 --- a/cmake/Findhdf5.cmake +++ b/cmake/Findhdf5.cmake @@ -8,7 +8,9 @@ if (NOT hdf5_FOUND) find_library(HDF5_CPP_HL_LIBRARY NAMES hdf5_hl_cpp PATHS ${CMAKE_BINARY_DIR}/lion/thirdparty/lib HINTS ${CMAKE_BINARY_DIR}/lion/thirdparty/lib NO_DEFAULT_PATH) find_package(ZLIB) - find_package(SZIP) + if (WITH_SZIP) + find_package(SZIP) + endif() if (HDF5_INCLUDE_DIR AND HDF5_LIBRARY) set(hdf5_FOUND YES) diff --git a/cmake/third-party/CMakeLists.txt b/cmake/third-party/CMakeLists.txt index 36ad1f1..75a6ed5 100644 --- a/cmake/third-party/CMakeLists.txt +++ b/cmake/third-party/CMakeLists.txt @@ -15,6 +15,7 @@ set(BUILD_LOGGERCPP ${BUILD_LOGGERCPP}) set(BUILD_CPPAD ${BUILD_CPPAD}) set(BUILD_HDF5 ${BUILD_HDF5}) set(WITH_HSL ${WITH_HSL}) +set(WITH_SZIP ${WITH_SZIP}) set(CMAKE_C_COMPILER ${CMAKE_C_COMPILER}) set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER}) diff --git a/cmake/third-party/hdf5.cmake b/cmake/third-party/hdf5.cmake index cf19e3d..8dc6dee 100644 --- a/cmake/third-party/hdf5.cmake +++ b/cmake/third-party/hdf5.cmake @@ -4,7 +4,7 @@ if ( ${BUILD_HDF5} ) ExternalProject_Add(hdf5 GIT_REPOSITORY https://github.com/HDFGroup/hdf5.git GIT_TAG hdf5-1_14_3 # we use this branch because latest ones require cmake 3.18... - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${THIRD_PARTY_DIR}/lion/thirdparty -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DBUILD_TESTING=No -DBUILD_SHARED_LIBS=No -DBUILD_STATIC_LIBS=Yes -DHDF5_BUILD_CPP_LIB=Yes -DHDF5_ENABLE_Z_LIB_SUPPORT=Yes -DHDF5_ENABLE_SZIP_SUPPORT=Yes + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${THIRD_PARTY_DIR}/lion/thirdparty -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DBUILD_TESTING=No -DBUILD_SHARED_LIBS=No -DBUILD_STATIC_LIBS=Yes -DHDF5_BUILD_CPP_LIB=Yes -DHDF5_ENABLE_Z_LIB_SUPPORT=Yes -DHDF5_ENABLE_SZIP_SUPPORT=${WITH_SZIP} PREFIX "${THIRD_PARTY_DIR}/hdf5" SOURCE_DIR ${THIRD_PARTY_DIR}/hdf5/source BINARY_DIR ${THIRD_PARTY_DIR}/hdf5/build