summaryrefslogtreecommitdiff
path: root/CMake/FindFreeImage.cmake
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2024-11-14 19:35:45 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2024-11-14 19:35:45 +0100
commitdf5520aa2dae5b3ce7abf8733dcdd152898af163 (patch)
tree00d3047bfb14f682bfb5a21010c731ed649bfed7 /CMake/FindFreeImage.cmake
parentdf247efec654e512242e4f4f1b0212034f9e01fe (diff)
parentec3c0f6f6e7153fa797dc57a0e95779cbc63a23b (diff)
Merge branch 'release/debian/1_5.3.0GA-1'debian/1_5.3.0GA-1
Diffstat (limited to 'CMake/FindFreeImage.cmake')
-rw-r--r--CMake/FindFreeImage.cmake58
1 files changed, 43 insertions, 15 deletions
diff --git a/CMake/FindFreeImage.cmake b/CMake/FindFreeImage.cmake
index 6073916..58afdac 100644
--- a/CMake/FindFreeImage.cmake
+++ b/CMake/FindFreeImage.cmake
@@ -11,22 +11,21 @@
# XTrackCAD specific directory tree is assumed
#
-if (WIN32)
+if(WIN32)
+ # Folders for x86/x64
+ set( FREEIMAGEBASEDIR "$ENV{XTCEXTERNALROOT}/${XTRKCAD_ARCH_SUBDIR}/FreeImage" )
find_path( FREEIMAGE_INCLUDE_PATH FreeImage.h
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/FreeImage
+ PATHS ${FREEIMAGEBASEDIR}
DOC "The directory where FreeImage.h resides")
find_library( FREEIMAGE_LIBRARY
NAMES FreeImage freeimage
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/FreeImage
+ PATHS ${FREEIMAGEBASEDIR}
DOC "The FreeImage library")
find_file( FREEIMAGE_SHAREDLIB
NAMES freeimage.DLL
- PATHS
- $ENV{XTCEXTERNALROOT}/x86/FreeImage
+ PATHS ${FREEIMAGEBASEDIR}
)
-else (WIN32)
+else()
find_path( FREEIMAGE_INCLUDE_PATH FreeImage.h
/usr/include
/usr/local/include
@@ -43,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()