summaryrefslogtreecommitdiff
path: root/CMake
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2024-07-03 10:19:30 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2024-07-03 10:19:30 +0200
commita14a7a0ccc9de76aeab0b2e4bbf58f1a79deedc2 (patch)
treee469179df67a0e0db49161a43cbf8076a189f6f4 /CMake
parent5d2c2b27a6323e2666378b986129b2a7c2c39e5c (diff)
New upstream version 5.3.0GAupstream/5.3.0GAupstream
Diffstat (limited to 'CMake')
-rw-r--r--CMake/CMakeDefaults.cmake22
-rw-r--r--CMake/FindCMocka.cmake5
-rw-r--r--CMake/FindFreeImage.cmake74
-rw-r--r--CMake/FindGTKUnixPrint.cmake7
-rw-r--r--CMake/FindInkscape.cmake47
-rw-r--r--CMake/FindLibzip.cmake105
-rw-r--r--CMake/FindMiniXML.cmake121
-rw-r--r--CMake/FindPandoc.cmake2
-rw-r--r--CMake/FindZlib.cmake70
9 files changed, 268 insertions, 185 deletions
diff --git a/CMake/CMakeDefaults.cmake b/CMake/CMakeDefaults.cmake
new file mode 100644
index 0000000..4f143f8
--- /dev/null
+++ b/CMake/CMakeDefaults.cmake
@@ -0,0 +1,22 @@
+# Always include srcdir and builddir in include path
+# This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in
+# about every subdir
+# since cmake 2.4.0
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+# Put the include dirs which are in the source or build tree
+# before all other include dirs, so the headers in the sources
+# are prefered over the already installed ones
+# since cmake 2.4.1
+set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
+
+# Use colored output
+# since cmake 2.4.0
+set(CMAKE_COLOR_MAKEFILE ON)
+
+# Use folders to organize targets
+set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+
+#
+# Print Installing but not Up-to-date messages
+set(CMAKE_INSTALL_MESSAGE LAZY)
diff --git a/CMake/FindCMocka.cmake b/CMake/FindCMocka.cmake
index 6a5484e..79ebeb8 100644
--- a/CMake/FindCMocka.cmake
+++ b/CMake/FindCMocka.cmake
@@ -21,9 +21,8 @@
#=============================================================================
#
-
-set (CMOCKA_ROOT_DIR
- "../../external/x86/cmocka")
+set(CMOCKA_ROOT_DIR
+ "$ENV{XTCEXTERNALROOT}/${XTRKCAD_ARCH_SUBDIR}/cmocka")
find_path(CMOCKA_INCLUDE_DIR
NAMES
diff --git a/CMake/FindFreeImage.cmake b/CMake/FindFreeImage.cmake
index b24f98d..58afdac 100644
--- a/CMake/FindFreeImage.cmake
+++ b/CMake/FindFreeImage.cmake
@@ -11,40 +11,21 @@
# XTrackCAD specific directory tree is assumed
#
-if (WIN32)
+if(WIN32)
# Folders for x86/x64
- if (WIN64)
+ set( FREEIMAGEBASEDIR "$ENV{XTCEXTERNALROOT}/${XTRKCAD_ARCH_SUBDIR}/FreeImage" )
find_path( FREEIMAGE_INCLUDE_PATH FreeImage.h
- PATHS
- $ENV{XTCEXTERNALROOT}/x64/FreeImage
+ PATHS ${FREEIMAGEBASEDIR}
DOC "The directory where FreeImage.h resides")
find_library( FREEIMAGE_LIBRARY
NAMES FreeImage freeimage
- PATHS
- $ENV{XTCEXTERNALROOT}/x64/FreeImage
+ PATHS ${FREEIMAGEBASEDIR}
DOC "The FreeImage library")
find_file( FREEIMAGE_SHAREDLIB
NAMES freeimage.DLL
- PATHS
- $ENV{XTCEXTERNALROOT}/x64/FreeImage
+ PATHS ${FREEIMAGEBASEDIR}
)
- else (WIN64)
- find_path( FREEIMAGE_INCLUDE_PATH FreeImage.h
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/FreeImage
- DOC "The directory where FreeImage.h resides")
- find_library( FREEIMAGE_LIBRARY
- NAMES FreeImage freeimage
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/FreeImage
- DOC "The FreeImage library")
- find_file( FREEIMAGE_SHAREDLIB
- NAMES freeimage.DLL
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/FreeImage
- )
- endif (WIN64)
-else (WIN32)
+else()
find_path( FREEIMAGE_INCLUDE_PATH FreeImage.h
/usr/include
/usr/local/include
@@ -61,16 +42,45 @@ else (WIN32)
/sw/lib
/opt/local/lib
DOC "The FreeImage library")
-endif (WIN32)
+endif()
+include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( FreeImage
- DEFAULT_MSG
+ REQUIRED_VARS
FREEIMAGE_LIBRARY
FREEIMAGE_INCLUDE_PATH
)
-mark_as_advanced(
- FREEIMAGE_FOUND
- FREEIMAGE_LIBRARY
- FREEIMAGE_INCLUDE_PATH
- FREEIMAGE_SHAREDLIB)
+if(FreeImage_FOUND)
+ mark_as_advanced(
+ FREEIMAGE_FOUND
+ FREEIMAGE_LIBRARY
+ FREEIMAGE_INCLUDE_PATH
+ FREEIMAGE_SHAREDLIB
+ )
+endif()
+
+if(FreeImage_FOUND AND NOT TARGET FreeImage::FreeImage)
+ add_library(FreeImage::FreeImage UNKNOWN IMPORTED)
+ set_property(TARGET FreeImage::FreeImage PROPERTY IMPORTED_LOCATION ${FREEIMAGE_LIBRARY})
+ target_include_directories(FreeImage::FreeImage INTERFACE ${FREEIMAGE_INCLUDE_PATH})
+
+ set(FreeImage_VERSION_MAJOR)
+ set(FreeImage_VERSION_MINOR)
+ set(FreeImage_VERSION_PATCH)
+ file(READ "${FREEIMAGE_INCLUDE_PATH}/FreeImage.h" _FreeImage_H_CONTENTS)
+
+ string(REGEX MATCH "#define[ \t]+FREEIMAGE_MAJOR_VERSION[ \t]+[0-9]+" FreeImage_VERSION_MAJOR "${_FreeImage_H_CONTENTS}")
+ string(REGEX MATCH "[0-9]+$" FreeImage_VERSION_MAJOR ${FreeImage_VERSION_MAJOR})
+
+ string(REGEX MATCH "#define[ \t]+FREEIMAGE_MINOR_VERSION[ \t]+[0-9]+" FreeImage_VERSION_MINOR "${_FreeImage_H_CONTENTS}")
+ string(REGEX MATCH "[0-9]+$" FreeImage_VERSION_MINOR ${FreeImage_VERSION_MINOR})
+
+ string(REGEX MATCH "#define[ \t]+FREEIMAGE_RELEASE_SERIAL[ \t]+[0-9]+" FreeImage_VERSION_PATCH
+ "${_FreeImage_H_CONTENTS}")
+ string(REGEX MATCH "[0-9]+$" FreeImage_VERSION_PATCH ${FreeImage_VERSION_PATCH})
+
+ set(FreeImage_VERSION "${FreeImage_VERSION_MAJOR}.${FreeImage_VERSION_MINOR}.${FreeImage_VERSION_PATCH}"
+ CACHE STRING
+ "Version number of FreeImage")
+endif()
diff --git a/CMake/FindGTKUnixPrint.cmake b/CMake/FindGTKUnixPrint.cmake
index 06bc548..dd9baab 100644
--- a/CMake/FindGTKUnixPrint.cmake
+++ b/CMake/FindGTKUnixPrint.cmake
@@ -46,4 +46,9 @@ if (GTK_UNIX_PRINT_VERSION)
endif ()
include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK_UNIX_PRINT DEFAULT_MSG GTK_UNIX_PRINT_INCLUDE_DIRS GTK_UNIX_PRINT_LIBRARIES VERSION_OK)
+find_package_handle_standard_args(GTKUnixPrint
+ DEFAULT_MSG
+ GTK_UNIX_PRINT_INCLUDE_DIRS
+ GTK_UNIX_PRINT_LIBRARIES
+ VERSION_OK
+)
diff --git a/CMake/FindInkscape.cmake b/CMake/FindInkscape.cmake
new file mode 100644
index 0000000..0ed7034
--- /dev/null
+++ b/CMake/FindInkscape.cmake
@@ -0,0 +1,47 @@
+
+# Try to find the Inkscape command-line SVG rasterizer
+# Once done this will define
+#
+# Inkscape_FOUND
+# Inkscape_EXECUTABLE Where to find Inkscape
+# Inkscape_VERSION The Inkscape version number
+# Inkscape_EXPORT Option to specify the destination file
+# Inkscape_GUI Option to disable the GUI if needed
+#
+# Module is from https://github.com/arx/ArxLibertatis
+
+find_program(
+ Inkscape_EXECUTABLE
+ NAMES inkscape
+ HINTS "C:/Program Files/Inkscape/bin"
+ DOC "Inkscape command-line SVG rasterizer"
+)
+
+execute_process(COMMAND ${Inkscape_EXECUTABLE} "--version" OUTPUT_VARIABLE _Inkscape_VERSION ERROR_QUIET)
+STRING(REGEX MATCH "[1-9]\.[0-9\+\.[0-9]+" _Inkscape_VERSION ${_Inkscape_VERSION})
+
+set(Inkscape_VERSION ${_Inkscape_VERSION} CACHE STRING "Inkscape Version")
+
+execute_process(COMMAND ${Inkscape_EXECUTABLE} "--help" OUTPUT_VARIABLE _Inkscape_HELP ERROR_QUIET)
+
+if(_Inkscape_HELP MATCHES "--without-gui")
+ set(Inkscape_GUI "--without-gui" CACHE STRING "Inkscape option to disable the GUI if needed")
+endif()
+
+if(NOT DEFINED Inkscape_EXPORT)
+ foreach(option IN ITEMS "--export-filename=" "--export-file=" "--export-png=")
+ if(_Inkscape_HELP MATCHES "${option}")
+ set(Inkscape_EXPORT "${option}" CACHE STRING "Inkscape option to specify the export filename")
+ break()
+ endif()
+ endforeach()
+ if(NOT DEFINED Inkscape_EXPORT)
+ message(WARNING "Could not determine Inkscape export file option, assuming -o")
+ set(Inkscape_EXPORT "-o " CACHE STRING "Inkscape option to specify the export filename")
+ endif()
+endif()
+
+# handle the QUIETLY and REQUIRED arguments and set Inkscape_FOUND to TRUE if
+# all listed variables are TRUE
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Inkscape REQUIRED_VARS Inkscape_EXECUTABLE) \ No newline at end of file
diff --git a/CMake/FindLibzip.cmake b/CMake/FindLibzip.cmake
index 004a88d..8838a86 100644
--- a/CMake/FindLibzip.cmake
+++ b/CMake/FindLibzip.cmake
@@ -4,50 +4,26 @@
# LIBZIP_INCLUDE_DIR_ZIP
# LIBZIP_INCLUDE_DIR_ZIPCONF
# LIBZIP_LIBRARY
+# LIBZIP_VERSION
+#
+# Target Libzip::Libzip is exported
#
# There is no default installation for libzip on Windows so a
# XTrackCAD specific directory tree is assumed
#
if(WIN32)
- # Folders for x86/x64
- if (WIN64)
- find_path( LIBZIP_INCLUDE_DIR_ZIP zip.h
- PATHS
- $ENV{XTCEXTERNALROOT}/x64/libzip
- DOC "The directory where zip.h resides")
- find_path( LIBZIP_INCLUDE_DIR_ZIPCONF zipconf.h
- PATHS
- $ENV{XTCEXTERNALROOT}/x64/libzip
- DOC "The directory where zip.h resides")
- find_library( LIBZIP_LIBRARY
- NAMES zip Zip
- PATHS
- $ENV{XTCEXTERNALROOT}/x64/libzip
- DOC "The libzip library")
- find_file( LIBZIP_SHAREDLIB
- NAMES zip.dll Zip.dll
- PATHS
- $ENV{XTCEXTERNALROOT}/x64/libzip)
- else (WIN64)
- find_path( LIBZIP_INCLUDE_DIR_ZIP zip.h
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/libzip
+ set(LIBZIPBASEDIR "$ENV{XTCEXTERNALROOT}/${XTRKCAD_ARCH_SUBDIR}/libzip" )
+ find_path( LIBZIP_INCLUDE_DIR_ZIP zip.h
+ PATHS ${LIBZIPBASEDIR} "${LIBZIPBASEDIR}/include"
DOC "The directory where zip.h resides")
- find_path( LIBZIP_INCLUDE_DIR_ZIPCONF zipconf.h
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/libzip
+ find_path( LIBZIP_INCLUDE_DIR_ZIPCONF zipconf.h
+ PATHS ${LIBZIPBASEDIR} "${LIBZIPBASEDIR}/include"
DOC "The directory where zip.h resides")
- find_library( LIBZIP_LIBRARY
- NAMES zip Zip
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/libzip
+ find_library( LIBZIP_LIBRARY
+ NAMES zip Zip
+ PATHS ${LIBZIPBASEDIR} "${LIBZIPBASEDIR}/lib"
DOC "The libzip library")
- find_file( LIBZIP_SHAREDLIB
- NAMES zip.dll Zip.dll
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/libzip)
- endif (WIN64)
else(WIN32)
find_package(PkgConfig)
pkg_check_modules(PC_LIBZIP QUIET libzip)
@@ -60,28 +36,51 @@ else(WIN32)
NAMES zipconf.h
HINTS ${PC_LIBZIP_INCLUDE_DIRS})
-if(UNIX AND NOT APPLE)
- find_library(LIBZIP_LIBRARY
- NAMES libzip.a zip)
-else(UNIX AND NOT APPLE)
- find_library(LIBZIP_LIBRARY
- NAMES zip)
-endif(UNIX AND NOT APPLE)
+ if(UNIX AND NOT APPLE)
+ find_library(LIBZIP_LIBRARY
+ NAMES libzip.a zip
+ PATHS
+ /usr/lib64
+ /usr/lib
+ /usr/local/lib64
+ /usr/local/lib
+ /sw/lib
+ /opt/local/lib
+ ${CMAKE_CURRENT_SOURCE_DIR}/app/tools/lib/linux
+ )
+ else()
+ find_library(LIBZIP_LIBRARY
+ NAMES zip)
+ endif()
endif(WIN32)
include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(
- LIBZIP DEFAULT_MSG
- LIBZIP_LIBRARY LIBZIP_INCLUDE_DIR_ZIP LIBZIP_INCLUDE_DIR_ZIPCONF)
+find_package_handle_standard_args(
+ Libzip
+ REQUIRED_VARS
+ LIBZIP_LIBRARY LIBZIP_INCLUDE_DIR_ZIP LIBZIP_INCLUDE_DIR_ZIPCONF
+)
+
+if(Libzip_FOUND)
+ mark_as_advanced(
+ LIBZIP_LIBRARY
+ LIBZIP_INCLUDE_DIR_ZIP
+ LIBZIP_INCLUDE_DIR_ZIPCONF
+ )
+endif()
set(LIBZIP_VERSION 0)
-if (LIBZIP_INCLUDE_DIR_ZIPCONF)
- FILE(READ "${LIBZIP_INCLUDE_DIR_ZIPCONF}/zipconf.h" _LIBZIP_VERSION_CONTENTS)
- if (_LIBZIP_VERSION_CONTENTS)
- STRING(REGEX REPLACE ".*#define LIBZIP_VERSION \"([0-9a-z.]+)\".*" "\\1" LIBZIP_VERSION "${_LIBZIP_VERSION_CONTENTS}")
- endif ()
-endif ()
+if(Libzip_FOUND AND NOT TARGET Libzip::Libzip)
+ add_library(Libzip::Libzip UNKNOWN IMPORTED)
+ set_property(TARGET Libzip::Libzip PROPERTY IMPORTED_LOCATION ${LIBZIP_LIBRARY})
+ target_include_directories(Libzip::Libzip INTERFACE ${LIBZIP_INCLUDE_DIR_ZIP})
-set(LIBZIP_VERSION ${LIBZIP_VERSION} CACHE STRING "Version number of libzip")
-mark_as_advanced(LIBZIP_LIBRARY LIBZIP_INCLUDE_DIR_ZIP LIBZIP_INCLUDE_DIR_ZIPCONF LIBZIP_SHAREDLIB)
+ if (LIBZIP_INCLUDE_DIR_ZIPCONF)
+ file(READ "${LIBZIP_INCLUDE_DIR_ZIPCONF}/zipconf.h" _LIBZIP_VERSION_CONTENTS)
+ if (_LIBZIP_VERSION_CONTENTS)
+ string(REGEX REPLACE ".*#define LIBZIP_VERSION \"([0-9a-z.]+)\".*" "\\1" LIBZIP_VERSION "${_LIBZIP_VERSION_CONTENTS}")
+ endif ()
+ endif ()
+ set(LIBZIP_VERSION ${LIBZIP_VERSION} CACHE STRING "Version number of libzip")
+endif()
diff --git a/CMake/FindMiniXML.cmake b/CMake/FindMiniXML.cmake
index 927430d..cded8d4 100644
--- a/CMake/FindMiniXML.cmake
+++ b/CMake/FindMiniXML.cmake
@@ -5,72 +5,50 @@
# MINIXML_FOUND
# MINIXML_INCLUDE_PATH
# MINIXML_LIBRARY
-# MINIXML_SHAREDLIB (Win32 only)
#
-# There is no default installation for mini-xml on Windows so a
+# There is no default installation for minixml on Windows so a
# XTrackCAD specific directory tree is assumed
-#
+# Windows build uses the static library for minixml
if (WIN32)
- # Folders for x86/x64
- if (WIN64)
- find_path( MINIXML_INCLUDE_PATH mxml.h
- PATHS
- $ENV{XTCEXTERNALROOT}/x64/mxml
- DOC "The directory where mxml.h resides")
- find_library( MINIXML_LIBRARY
- NAMES mxml1
- PATHS
- $ENV{XTCEXTERNALROOT}/x64/mxml
- DOC "The Mini XML shared library")
- find_file( MINIXML_SHAREDLIB
- NAMES mxml1.DLL
- PATHS
- $ENV{XTCEXTERNALROOT}/x64/mxml
- DOC "The Mini XML DLL" )
- find_library( MINIXML_STATIC_LIBRARY
- NAMES mxmlstat.lib
- PATHS
- $ENV{XTCEXTERNALROOT}/x64/mxml
- DOC "The Mini XML static library")
- else (WIN64)
+ set(MXMLBASEDIR "$ENV{XTCEXTERNALROOT}/${XTRKCAD_ARCH_SUBDIR}/mxml" )
find_path( MINIXML_INCLUDE_PATH mxml.h
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/mxml
+ PATHS ${MXMLBASEDIR}
DOC "The directory where mxml.h resides")
find_library( MINIXML_LIBRARY
- NAMES mxml1
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/mxml
- DOC "The Mini XML shared library")
- find_file( MINIXML_SHAREDLIB
- NAMES mxml1.DLL
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/mxml
- DOC "The Mini XML DLL" )
- find_library( MINIXML_STATIC_LIBRARY
NAMES mxmlstat.lib
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/mxml
+ PATHS ${MXMLBASEDIR}
DOC "The Mini XML static library")
- endif (WIN64)
-else (WIN32)
+else ()
find_path( MINIXML_INCLUDE_PATH mxml.h
/usr/include
/usr/local/include
/sw/include
/opt/local/include
DOC "The directory where mxml.h resides")
- find_library( MINIXML_LIBRARY
- NAMES mxml1 mxml
- PATHS
- /usr/lib64
- /usr/lib
- /usr/local/lib64
- /usr/local/lib
- /sw/lib
- /opt/local/lib
- DOC "The Mini XML library")
+ if(UNIX AND NOT APPLE)
+ find_library( MINIXML_LIBRARY
+ NAMES libmxml.a mxml1 mxml
+ PATHS
+ /usr/lib64
+ /usr/lib
+ /usr/local/lib64
+ /usr/local/lib
+ /sw/lib
+ /opt/local/lib
+ DOC "The Mini XML library")
+ else()
+ find_library( MINIXML_LIBRARY
+ NAMES mxml1 mxml
+ PATHS
+ /usr/lib64
+ /usr/lib
+ /usr/local/lib64
+ /usr/local/lib
+ /sw/lib
+ /opt/local/lib
+ DOC "The Mini XML library")
+ endif()
find_library( MINIXML_STATIC_LIBRARY
NAMES libmxml.a
PATHS
@@ -83,15 +61,38 @@ else (WIN32)
DOC "The Mini XML static library")
endif (WIN32)
-find_package_handle_standard_args( MiniXML
- DEFAULT_MSG
+include(FindPackageHandleStandardArgs)
+
+find_package_handle_standard_args(
+ MiniXML
+ REQUIRED_VARS
+ MINIXML_LIBRARY
+ MINIXML_INCLUDE_PATH
+)
+
+if(MiniXML_FOUND)
+ mark_as_advanced(
+ MINIXML_FOUND
MINIXML_LIBRARY
MINIXML_INCLUDE_PATH
-)
+ )
+endif()
-mark_as_advanced(
- MINIXML_FOUND
- MINIXML_LIBRARY
- MINIXML_SHAREDLIB
- MINIXML_STATIC_LIBRARY
-MINIXML_INCLUDE_PATH)
+if (MiniXML_FOUND AND NOT TARGET MiniXML::MiniXML)
+ add_library(MiniXML::mxml UNKNOWN IMPORTED)
+ set_property(TARGET MiniXML::mxml PROPERTY IMPORTED_LOCATION ${MINIXML_LIBRARY})
+ target_include_directories(MiniXML::mxml INTERFACE ${MINIXML_INCLUDE_PATH})
+
+ set(MXML_VERSION_MAJOR)
+ set(MXML_VERSION_MINOR)
+ file(READ "${MINIXML_INCLUDE_PATH}/mxml.h" _mxml_H_CONTENTS)
+
+ string(REGEX MATCH "#[ \t]*define[ \t]+MXML_MAJOR_VERSION[ \t]+[0-9]+" MXML_VERSION_MAJOR "${_mxml_H_CONTENTS}")
+ string(REGEX MATCH "[0-9]+$" MXML_VERSION_MAJOR ${MXML_VERSION_MAJOR})
+
+ string(REGEX MATCH "#[ \t]*define[ \t]+MXML_MINOR_VERSION[ \t]+[0-9]+" MXML_VERSION_MINOR "${_mxml_H_CONTENTS}")
+ string(REGEX MATCH "[0-9]+$" MXML_VERSION_MINOR ${MXML_VERSION_MINOR})
+ set(MiniXML_VERSION "${MXML_VERSION_MAJOR}.${MXML_VERSION_MINOR}"
+ CACHE STRING
+ "Version number of MiniXML")
+endif()
diff --git a/CMake/FindPandoc.cmake b/CMake/FindPandoc.cmake
index 1a076ff..c5ea5ed 100644
--- a/CMake/FindPandoc.cmake
+++ b/CMake/FindPandoc.cmake
@@ -13,6 +13,6 @@ find_program(PANDOC_EXECUTABLE
NAMES pandoc
DOC "Pandoc - a universal document converter")
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pandoc REQUIRED_VARS PANDOC_EXECUTABLE)
+find_package_handle_standard_args(Pandoc REQUIRED_VARS PANDOC_EXECUTABLE)
mark_as_advanced(PANDOC_EXECUTABLE) \ No newline at end of file
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()