diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-07-03 10:19:30 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2024-07-03 10:19:30 +0200 |
commit | a14a7a0ccc9de76aeab0b2e4bbf58f1a79deedc2 (patch) | |
tree | e469179df67a0e0db49161a43cbf8076a189f6f4 /CMake/FindZlib.cmake | |
parent | 5d2c2b27a6323e2666378b986129b2a7c2c39e5c (diff) |
New upstream version 5.3.0GAupstream/5.3.0GAupstream
Diffstat (limited to 'CMake/FindZlib.cmake')
-rw-r--r-- | CMake/FindZlib.cmake | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/CMake/FindZlib.cmake b/CMake/FindZlib.cmake index 3ad5b6c..e7785b6 100644 --- a/CMake/FindZlib.cmake +++ b/CMake/FindZlib.cmake @@ -1,46 +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)
- # Folders for x86/x64
- if (WIN64)
+ set(ZLIBBASEDIR "$ENV{XTCEXTERNALROOT}/${XTRKCAD_ARCH_SUBDIR}/zlib" )
find_path( ZLIB_INCLUDE_DIR zlib.h
- PATHS
- $ENV{XTCEXTERNALROOT}/x64/zlib
+ PATHS ${ZLIBBASEDIR} "${ZLIBBASEDIR}/include"
DOC "The directory where zlib.h resides")
find_library( ZLIB_LIBRARY
- NAMES zlib Zlib
- PATHS
- $ENV{XTCEXTERNALROOT}/x64/zlib
+ NAMES zlibstatic
+ PATHS ${ZLIBBASEDIR} "${ZLIBBASEDIR}/lib"
DOC "The zlib library")
- find_file( ZLIB_SHAREDLIB
- NAMES zlib.dll Zlib.dll
- PATHS
- $ENV{XTCEXTERNALROOT}/x64/zlib)
- else (WIN64)
- find_path( ZLIB_INCLUDE_DIR zlib.h
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/zlib
- DOC "The directory where zlib.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)
- endif (WIN64)
-else(WIN32)
+else()
find_package(PkgConfig)
pkg_check_modules(PC_ZLIB QUIET zlib)
@@ -50,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()
|