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/FindMiniXML.cmake | |
parent | 5d2c2b27a6323e2666378b986129b2a7c2c39e5c (diff) |
New upstream version 5.3.0GAupstream/5.3.0GAupstream
Diffstat (limited to 'CMake/FindMiniXML.cmake')
-rw-r--r-- | CMake/FindMiniXML.cmake | 121 |
1 files changed, 61 insertions, 60 deletions
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()
|