Skip to content

Commit

Permalink
[JMT] Add possibility to compile without SZIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Manzanero committed Sep 26, 2024
1 parent 1cf4b9a commit b13cd84
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion cmake/Findhdf5.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions cmake/third-party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion cmake/third-party/hdf5.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b13cd84

Please sign in to comment.