Skip to content

Commit

Permalink
[JMT] Look for zlib and szip
Browse files Browse the repository at this point in the history
  • Loading branch information
Juan Manzanero committed Mar 17, 2024
1 parent 4a147aa commit 32fbd3e
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 2 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ if(WITH_HSL)
target_compile_definitions(lion INTERFACE WITH_HSL)
endif()


target_link_libraries(lion INTERFACE ipopt blaslapack tinyxml2 fortran_libraries cppad hdf5)
target_link_libraries(lion INTERFACE ipopt blaslapack tinyxml2 fortran_libraries cppad hdf5 ZLIB::ZLIB SZIP::SZIP)

# Create a lion header only
add_library(header_only INTERFACE)
Expand Down
129 changes: 129 additions & 0 deletions cmake/FindSZIP.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#
# Copyright by The HDF Group.
# All rights reserved.
#
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
#########################################################################

# - Derived from the FindTiff.cmake and FindJPEG.cmake that is included with cmake
# FindSZIP

# Find the native SZIP includes and library

# Imported targets
##################

# This module defines the following :prop_tgt:`IMPORTED` targets:
#
# SZIP::SZIP
# The SZIP library, if found.
#
# Result variables
###################

# This module will set the following variables in your project:

# SZIP_FOUND, true if the SZIP headers and libraries were found.
# SZIP_INCLUDE_DIR, the directory containing the SZIP headers.
# SZIP_INCLUDE_DIRS, the directory containing the SZIP headers.
# SZIP_LIBRARIES, libraries to link against to use SZIP.

# Cache variables
#################

# The following variables may also be set:

# SZIP_LIBRARY, where to find the SZIP library.
# SZIP_LIBRARY_DEBUG - Debug version of SZIP library
# SZIP_LIBRARY_RELEASE - Release Version of SZIP library

# message (STATUS "Finding SZIP library and headers..." )
#########################################################################


find_path(SZIP_INCLUDE_DIR szlib.h)

set(szip_names ${SZIP_NAMES} sz szip szip-static libsz libszip libszip-static)
foreach(name ${szip_names})
list (APPEND szip_names_debug "${name}d")
endforeach()

if(NOT SZIP_LIBRARY)
find_library(SZIP_LIBRARY_RELEASE NAMES ${szip_names})
find_library(SZIP_LIBRARY_DEBUG NAMES ${szip_names_debug})
include(SelectLibraryConfigurations)
select_library_configurations(SZIP)
mark_as_advanced(SZIP_LIBRARY_RELEASE SZIP_LIBRARY_DEBUG)
endif()
unset(szip_names)
unset(szip_names_debug)

if(SZIP_INCLUDE_DIR AND EXISTS "${SZIP_INCLUDE_DIR}/SZconfig.h")
file(STRINGS "${SZIP_INCLUDE_DIR}/SZconfig.h" szip_version_str
REGEX "^#define[\t ]+SZIP_PACKAGE_VERSION[\t ]+.*")

string(REGEX REPLACE "^#define[\t ]+SZIP_PACKAGE_VERSION[\t ]+([0-9]+).*"
"\\1" SZIP_VERSION "${szip_version_str}")
unset(szip_version_str)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(SZIP
REQUIRED_VARS SZIP_LIBRARY SZIP_INCLUDE_DIR
VERSION_VAR SZIP_VERSION)

if(SZIP_FOUND)
set(SZIP_LIBRARIES ${SZIP_LIBRARY})
set(SZIP_INCLUDE_DIRS "${SZIP_INCLUDE_DIR}")

if(NOT TARGET SZIP::SZIP)
add_library(SZIP::SZIP UNKNOWN IMPORTED)
if(SZIP_INCLUDE_DIRS)
set_target_properties(SZIP::SZIP PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SZIP_INCLUDE_DIRS}")
endif()
if(EXISTS "${SZIP_LIBRARY}")
set_target_properties(SZIP::SZIP PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${SZIP_LIBRARY}")
endif()
if(EXISTS "${SZIP_LIBRARY_RELEASE}")
set_property(TARGET SZIP::SZIP APPEND PROPERTY
IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(SZIP::SZIP PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
IMPORTED_LOCATION_RELEASE "${SZIP_LIBRARY_RELEASE}")
endif()
if(EXISTS "${SZIP_LIBRARY_DEBUG}")
set_property(TARGET SZIP::SZIP APPEND PROPERTY
IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(SZIP::SZIP PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LOCATION_DEBUG "${SZIP_LIBRARY_DEBUG}")
endif()
endif()
endif()

mark_as_advanced(SZIP_LIBRARY SZIP_INCLUDE_DIR)

# Report the results.
if (NOT SZIP_FOUND)
set (SZIP_DIR_MESSAGE
"SZip was not found. Make sure SZIP_LIBRARY and SZIP_INCLUDE_DIR are set or set the SZIP_INSTALL environment variable."
)
if (NOT SZIP_FIND_QUIETLY)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0")
message (VERBOSE "${SZIP_DIR_MESSAGE}")
endif ()
else ()
if (SZIP_FIND_REQUIRED)
message (FATAL_ERROR "SZip was NOT found and is Required by this project")
endif ()
endif ()
endif ()
4 changes: 4 additions & 0 deletions cmake/Findhdf5.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ if (NOT hdf5_FOUND)
find_library(HDF5_CPP_LIBRARY NAMES hdf5_cpp PATHS ${CMAKE_BINARY_DIR}/lion/thirdparty/lib HINTS ${CMAKE_BINARY_DIR}/lion/thirdparty/lib NO_DEFAULT_PATH)
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 (HDF5_INCLUDE_DIR AND HDF5_LIBRARY)
set(hdf5_FOUND YES)
Expand Down Expand Up @@ -58,6 +60,8 @@ if (NOT hdf5_FOUND)
"$<BUILD_INTERFACE:${HDF5_LIBRARY}>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_LIBDIR}/${HDF5_LIB_NAME}>")

target_link_libraries(hdf5 INTERFACE ZLIB::ZLIB SZIP::SZIP)


foreach(t ${HDF5_LIB_ALL_FILES})
install(FILES "${t}" TYPE LIB)
Expand Down

0 comments on commit 32fbd3e

Please sign in to comment.