diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-11-14 19:35:45 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-11-14 19:35:45 +0100 |
commit | df5520aa2dae5b3ce7abf8733dcdd152898af163 (patch) | |
tree | 00d3047bfb14f682bfb5a21010c731ed649bfed7 /CMake/FindZlib.cmake | |
parent | df247efec654e512242e4f4f1b0212034f9e01fe (diff) | |
parent | ec3c0f6f6e7153fa797dc57a0e95779cbc63a23b (diff) |
Merge branch 'release/debian/1_5.3.0GA-1'debian/1_5.3.0GA-1
Diffstat (limited to 'CMake/FindZlib.cmake')
-rw-r--r-- | CMake/FindZlib.cmake | 61 |
1 files changed, 39 insertions, 22 deletions
diff --git a/CMake/FindZlib.cmake b/CMake/FindZlib.cmake index 3305ee3..e7785b6 100644 --- a/CMake/FindZlib.cmake +++ b/CMake/FindZlib.cmake @@ -1,29 +1,23 @@ # Finds zlib.
#
# This module defines:
-# zlib_INCLUDE_DIR_ZIP
-# zlib_INCLUDE_DIR_ZIPCONF
-# zlib_LIBRARY
+# ZLIB_INCLUDE_DIR
+# ZLIB_LIBRARY
#
# There is no default installation for zlib on Windows so a
# XTrackCAD specific directory tree is assumed
#
if(WIN32)
- find_path( ZLIB_INCLUDE_DIR zlib.h
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/zlib
- DOC "The directory where zip.h resides")
- find_library( ZLIB_LIBRARY
- NAMES zlib Zlib
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/zlib
- DOC "The zlib library")
- find_file( ZLIB_SHAREDLIB
- NAMES zlib.dll Zlib.dll
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/zlib)
-else(WIN32)
+ set(ZLIBBASEDIR "$ENV{XTCEXTERNALROOT}/${XTRKCAD_ARCH_SUBDIR}/zlib" )
+ find_path( ZLIB_INCLUDE_DIR zlib.h
+ PATHS ${ZLIBBASEDIR} "${ZLIBBASEDIR}/include"
+ DOC "The directory where zlib.h resides")
+ find_library( ZLIB_LIBRARY
+ NAMES zlibstatic
+ PATHS ${ZLIBBASEDIR} "${ZLIBBASEDIR}/lib"
+ DOC "The zlib library")
+else()
find_package(PkgConfig)
pkg_check_modules(PC_ZLIB QUIET zlib)
@@ -33,11 +27,34 @@ else(WIN32) find_library(ZLIB_LIBRARY
NAMES z)
-endif(WIN32)
+endif()
include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(
- ZLIB DEFAULT_MSG
- ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-mark_as_advanced(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
+find_package_handle_standard_args(
+ Zlib
+ REQUIRED_VARS
+ ZLIB_LIBRARY
+ ZLIB_INCLUDE_DIR
+)
+
+if(Zlib_FOUND)
+ mark_as_advanced(
+ ZLIB_LIBRARY
+ ZLIB_INCLUDE_DIR
+ )
+endif()
+
+if(Zlib_FOUND AND NOT TARGET Zlib::Zlib)
+ add_library(Zlib::Zlib UNKNOWN IMPORTED)
+ set_property(TARGET Zlib::Zlib PROPERTY IMPORTED_LOCATION ${ZLIB_LIBRARY})
+ target_include_directories(Zlib::Zlib INTERFACE ${ZLIB_INCLUDE_DIR})
+
+ if (ZLIB_INCLUDE_DIR)
+ file(READ "${ZLIB_INCLUDE_DIR}/zlib.h" _ZLIB_VERSION_CONTENTS)
+ if (_ZLIB_VERSION_CONTENTS)
+ string(REGEX REPLACE ".*#define ZLIB_VERSION \"([0-9a-z.]+)\".*" "\\1" ZLIB_VERSION "${_ZLIB_VERSION_CONTENTS}")
+ endif ()
+ endif ()
+ set(ZLIB_VERSION ${ZLIB_VERSION} CACHE STRING "Version number of zlib")
+endif()
|