From b0dc3155f85bd10263170586e4a319533a0b9684 Mon Sep 17 00:00:00 2001 From: Alexander Vieth Date: Tue, 4 Mar 2025 16:02:52 +0100 Subject: [PATCH 1/8] Update freeimage to 319 --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cc91dc..bcb06ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,11 +34,14 @@ find_package(ManiVault COMPONENTS Core PointData ImageData CONFIG QUIET) FetchContent_Declare( FreeImage GIT_REPOSITORY https://github.com/biovault/FreeImage - GIT_TAG 2fcb6ca6d3d4dd36f7be82368275dcce918227fa # master as of 19-11-2024, version 3.18.0 with cmake files + GIT_TAG db0f4151dd45a7bf98b9dfe9bd81190b523076dd # version 3.19.0 with cmake files ) FetchContent_MakeAvailable(FreeImage) +get_target_property(FreeImageVersion FreeImageLib VERSION) +message(STATUS "FreeImage Version: ${FreeImageVersion}") + set_target_properties(FreeImage FreeImageLib LibJPEG LibJXR LibOpenJPEG LibPNG LibRaw LibTIFF4 LibWebP OpenEXR ZLibFreeImage PROPERTIES FOLDER LoaderPlugins/Dependencies/ImageLoaderPlugin From 3bf1130b616b792dc664a80257fce49577c958e0 Mon Sep 17 00:00:00 2001 From: Alexander Vieth Date: Thu, 22 May 2025 10:23:30 +0200 Subject: [PATCH 2/8] Add languages to cmake file --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bcb06ba..3f19483 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ option(MV_UNITY_BUILD "Combine target source files into batches for faster compi # ImageLoader Plugin # ----------------------------------------------------------------------------- set(PROJECT "ImageLoaderPlugin") -PROJECT(${PROJECT}) +PROJECT(${PROJECT} C CXX) # ----------------------------------------------------------------------------- # CMake Options From d7a37c710c4c7ce91fcf3a2eb0abab714660ce92 Mon Sep 17 00:00:00 2001 From: Alexander Vieth Date: Thu, 22 May 2025 10:23:44 +0200 Subject: [PATCH 3/8] New freeimage version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f19483..7e6215a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ find_package(ManiVault COMPONENTS Core PointData ImageData CONFIG QUIET) FetchContent_Declare( FreeImage GIT_REPOSITORY https://github.com/biovault/FreeImage - GIT_TAG db0f4151dd45a7bf98b9dfe9bd81190b523076dd # version 3.19.0 with cmake files + GIT_TAG 4532197864740ae6dc8331f7d956c0b4dbd7029c # version 3.19.0.1 ) FetchContent_MakeAvailable(FreeImage) From 9a7aaf1d668a4377fb645088f1c6c96b03657aac Mon Sep 17 00:00:00 2001 From: Alexander Vieth Date: Thu, 22 May 2025 10:27:06 +0200 Subject: [PATCH 4/8] Do not be permissive on MSVC --- CMakeLists.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e6215a..ce04457 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,13 +50,6 @@ set_target_properties(FreeImage FreeImageLib LibJPEG LibJXR LibOpenJPEG LibPNG L # Do not build static library set_target_properties(FreeImageLib PROPERTIES EXCLUDE_FROM_ALL ON) -# Remove /permissive- for OpenEXR and FreeImage -if(MSVC) - target_compile_options(OpenEXR PRIVATE /permissive) - target_compile_options(FreeImage PRIVATE /permissive) - target_compile_options(FreeImageLib PRIVATE /permissive) # we don't need the static library, but just in case someone does build it -endif(MSVC) - # ----------------------------------------------------------------------------- # Source files # ----------------------------------------------------------------------------- From c6e3ec94fe1d0ea90962222ddbb9b52533e76017 Mon Sep 17 00:00:00 2001 From: Alexander Vieth Date: Thu, 22 May 2025 10:38:16 +0200 Subject: [PATCH 5/8] Revert "Do not be permissive on MSVC" This reverts commit f8c758aa0991a686eacf10a00b4716fc6d92f9c7. --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce04457..7e6215a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,13 @@ set_target_properties(FreeImage FreeImageLib LibJPEG LibJXR LibOpenJPEG LibPNG L # Do not build static library set_target_properties(FreeImageLib PROPERTIES EXCLUDE_FROM_ALL ON) +# Remove /permissive- for OpenEXR and FreeImage +if(MSVC) + target_compile_options(OpenEXR PRIVATE /permissive) + target_compile_options(FreeImage PRIVATE /permissive) + target_compile_options(FreeImageLib PRIVATE /permissive) # we don't need the static library, but just in case someone does build it +endif(MSVC) + # ----------------------------------------------------------------------------- # Source files # ----------------------------------------------------------------------------- From 95b267b8778973ad446281edbd5eb607ff50c693 Mon Sep 17 00:00:00 2001 From: Alexander Vieth Date: Fri, 23 May 2025 10:52:28 +0200 Subject: [PATCH 6/8] Optionally use system installation of freeimage --- CMakeLists.txt | 60 +++++++++++++++++++++------------------ cmake/FindFreeImage.cmake | 54 +++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 27 deletions(-) create mode 100644 cmake/FindFreeImage.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e6215a..521b08a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.22) option(MV_UNITY_BUILD "Combine target source files into batches for faster compilation" OFF) +option(MV_IML_USE_SYSTEM_FREEIMAGE "Use local freeimage installation instead of building it" OFF) # ----------------------------------------------------------------------------- # ImageLoader Plugin @@ -23,39 +24,44 @@ if(MSVC) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD") endif(MSVC) -include(FetchContent) - # ----------------------------------------------------------------------------- # Dependencies # ----------------------------------------------------------------------------- find_package(Qt6 COMPONENTS Widgets WebEngineWidgets Concurrent REQUIRED) find_package(ManiVault COMPONENTS Core PointData ImageData CONFIG QUIET) -FetchContent_Declare( - FreeImage - GIT_REPOSITORY https://github.com/biovault/FreeImage - GIT_TAG 4532197864740ae6dc8331f7d956c0b4dbd7029c # version 3.19.0.1 -) - -FetchContent_MakeAvailable(FreeImage) - -get_target_property(FreeImageVersion FreeImageLib VERSION) -message(STATUS "FreeImage Version: ${FreeImageVersion}") - -set_target_properties(FreeImage FreeImageLib LibJPEG LibJXR LibOpenJPEG LibPNG LibRaw LibTIFF4 LibWebP OpenEXR ZLibFreeImage - PROPERTIES - FOLDER LoaderPlugins/Dependencies/ImageLoaderPlugin -) - -# Do not build static library -set_target_properties(FreeImageLib PROPERTIES EXCLUDE_FROM_ALL ON) - -# Remove /permissive- for OpenEXR and FreeImage -if(MSVC) - target_compile_options(OpenEXR PRIVATE /permissive) - target_compile_options(FreeImage PRIVATE /permissive) - target_compile_options(FreeImageLib PRIVATE /permissive) # we don't need the static library, but just in case someone does build it -endif(MSVC) +if(MV_IML_USE_SYSTEM_FREEIMAGE) + set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) + find_package(FreeImage REQUIRED) +else() + include(FetchContent) + + FetchContent_Declare( + FreeImage + GIT_REPOSITORY https://github.com/biovault/FreeImage + GIT_TAG 4532197864740ae6dc8331f7d956c0b4dbd7029c # version 3.19.0.1, freeimage + cmake files + some updated modules + ) + + FetchContent_MakeAvailable(FreeImage) + + get_target_property(FreeImageVersion FreeImageLib VERSION) + message(STATUS "FreeImage Version: ${FreeImageVersion}") + + set_target_properties(FreeImage FreeImageLib LibJPEG LibJXR LibOpenJPEG LibPNG LibRaw LibTIFF4 LibWebP OpenEXR ZLibFreeImage + PROPERTIES + FOLDER LoaderPlugins/Dependencies/ImageLoaderPlugin + ) + + # Do not build static library + set_target_properties(FreeImageLib PROPERTIES EXCLUDE_FROM_ALL ON) + + # Remove /permissive- for OpenEXR and FreeImage + if(MSVC) + target_compile_options(OpenEXR PRIVATE /permissive) + target_compile_options(FreeImage PRIVATE /permissive) + target_compile_options(FreeImageLib PRIVATE /permissive) # we don't need the static library, but just in case someone does build it + endif(MSVC) +endif() # ----------------------------------------------------------------------------- # Source files diff --git a/cmake/FindFreeImage.cmake b/cmake/FindFreeImage.cmake new file mode 100644 index 0000000..0f66ab2 --- /dev/null +++ b/cmake/FindFreeImage.cmake @@ -0,0 +1,54 @@ +set(FREEIMAGE_INCLUDE_DIR_HINTS "" CACHE PATH "FreeImage include directory") +set(FREEIMAGE_LIBRARY_DIR_HINTS "" CACHE PATH "FreeImage library directory") + +unset(FREEIMAGE_FOUND) + +if(TARGET FreeImage) + set(FREEIMAGE_FOUND TRUE) + message(STATUS "Found FreeImage") + message(STATUS " Target : FreeImage") +else() + list(APPEND FREEIMAGE_CHECK_INCLUDE_DIRS + ${FREEIMAGE_INCLUDE_DIR_HINTS} + /usr/include + /usr/local/include + /opt/homebrew/include + ) + + list(APPEND FREEIMAGE_CHECK_LIBRARY_DIRS + ${FREEIMAGE_LIBRARY_DIR_HINTS} + /usr/lib + /usr/local/lib + /opt/homebrew/lib + ) + + find_path(FreeImage_INCLUDE_DIRS + NAMES + FreeImage.h + PATHS + ${FREEIMAGE_CHECK_INCLUDE_DIRS}) + ) + + find_library(FreeImage_LIBRARIES + NAMES + freeimage + PATHS + ${FREEIMAGE_CHECK_LIBRARY_DIRS}) + ) + + if(FREEIMAGE_INCLUDE_DIRS AND FREEIMAGE_LIBRARIES) + set(FREEIMAGE_FOUND TRUE) + + add_library(FreeImage INTERFACE IMPORTED) + target_include_directories( + FreeImage INTERFACE ${FREEIMAGE_INCLUDE_DIRS}) + target_link_libraries( + FreeImage INTERFACE ${FREEIMAGE_LIBRARIES}) + + message(STATUS "Found FreeImage") + message(STATUS " Includes : ${FREEIMAGE_INCLUDE_DIRS}") + message(STATUS " Libraries : ${FREEIMAGE_LIBRARIES}") + else() + message(FATAL_ERROR "Could not find FreeImage") + endif() +endif() From 545a46751ff93612421e3990e7a204dd9cf5631a Mon Sep 17 00:00:00 2001 From: Alexander Vieth Date: Fri, 23 May 2025 10:53:02 +0200 Subject: [PATCH 7/8] CMake: be more specific about CMAKE_CXX_COMPILER_ID --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 521b08a..a1bda0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,12 +17,12 @@ set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_CXX_STANDARD_REQUIRED ON) -if(MSVC) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWIN32 /EHsc /MP /permissive- /Zc:__cplusplus") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD") -endif(MSVC) +endif() # ----------------------------------------------------------------------------- # Dependencies @@ -56,11 +56,11 @@ else() set_target_properties(FreeImageLib PROPERTIES EXCLUDE_FROM_ALL ON) # Remove /permissive- for OpenEXR and FreeImage - if(MSVC) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_options(OpenEXR PRIVATE /permissive) target_compile_options(FreeImage PRIVATE /permissive) target_compile_options(FreeImageLib PRIVATE /permissive) # we don't need the static library, but just in case someone does build it - endif(MSVC) + endif() endif() # ----------------------------------------------------------------------------- @@ -209,7 +209,7 @@ set_target_properties(${PROJECT} # Miscellaneous # ----------------------------------------------------------------------------- # Automatically set the debug environment (command + working directory) for MSVC -if(MSVC) +if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set_property(TARGET ${PROJECT} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $,${ManiVault_INSTALL_DIR}/Debug,$,${ManiVault_INSTALL_DIR}/RelWithDebInfo,${ManiVault_INSTALL_DIR}/Release>>) set_property(TARGET ${PROJECT} PROPERTY VS_DEBUGGER_COMMAND $,"${ManiVault_INSTALL_DIR}/Debug/ManiVault Studio.exe",$,"${ManiVault_INSTALL_DIR}/RelWithDebInfo/ManiVault Studio.exe","${ManiVault_INSTALL_DIR}/Release/ManiVault Studio.exe">>) endif() From 8473384e6f03797fa4a398ca288a4a5f96892bb6 Mon Sep 17 00:00:00 2001 From: Alexander Vieth Date: Fri, 4 Jul 2025 12:12:53 +0200 Subject: [PATCH 8/8] use tag --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1bda0c..1aa8ff9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,7 @@ else() FetchContent_Declare( FreeImage GIT_REPOSITORY https://github.com/biovault/FreeImage - GIT_TAG 4532197864740ae6dc8331f7d956c0b4dbd7029c # version 3.19.0.1, freeimage + cmake files + some updated modules + GIT_TAG v3.19.0 # version 3.19.0.1, freeimage + cmake files + some updated modules ) FetchContent_MakeAvailable(FreeImage)