11cmake_minimum_required (VERSION 3.22 )
22
33option (MV_UNITY_BUILD "Combine target source files into batches for faster compilation" OFF )
4+ option (MV_IML_USE_SYSTEM_FREEIMAGE "Use local freeimage installation instead of building it" OFF )
45
56# -----------------------------------------------------------------------------
67# ImageLoader Plugin
78# -----------------------------------------------------------------------------
89set (PROJECT "ImageLoaderPlugin" )
9- PROJECT (${PROJECT} )
10+ PROJECT (${PROJECT} C CXX )
1011
1112# -----------------------------------------------------------------------------
1213# CMake Options
@@ -16,43 +17,51 @@ set(CMAKE_AUTORCC ON)
1617set (CMAKE_AUTOUIC ON )
1718set (CMAKE_CXX_STANDARD_REQUIRED ON )
1819
19- if (MSVC )
20+ if (CMAKE_CXX_COMPILER_ID STREQUAL " MSVC" )
2021 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DWIN32 /EHsc /MP /permissive- /Zc:__cplusplus" )
2122 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd" )
2223 set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MD" )
2324 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD" )
24- endif (MSVC )
25-
26- include (FetchContent )
25+ endif ()
2726
2827# -----------------------------------------------------------------------------
2928# Dependencies
3029# -----------------------------------------------------------------------------
3130find_package (Qt6 COMPONENTS Widgets WebEngineWidgets Concurrent REQUIRED )
3231find_package (ManiVault COMPONENTS Core PointData ImageData CONFIG QUIET )
3332
34- FetchContent_Declare (
35- FreeImage
36- GIT_REPOSITORY https://github.com/biovault/FreeImage
37- GIT_TAG 2fcb6ca6d3d4dd36f7be82368275dcce918227fa # master as of 19-11-2024, version 3.18.0 with cmake files
38- )
39-
40- FetchContent_MakeAvailable (FreeImage)
41-
42- set_target_properties (FreeImage FreeImageLib LibJPEG LibJXR LibOpenJPEG LibPNG LibRaw LibTIFF4 LibWebP OpenEXR ZLibFreeImage
43- PROPERTIES
44- FOLDER LoaderPlugins/Dependencies/ImageLoaderPlugin
45- )
46-
47- # Do not build static library
48- set_target_properties (FreeImageLib PROPERTIES EXCLUDE_FROM_ALL ON )
49-
50- # Remove /permissive- for OpenEXR and FreeImage
51- if (MSVC )
52- target_compile_options (OpenEXR PRIVATE /permissive )
53- target_compile_options (FreeImage PRIVATE /permissive )
54- target_compile_options (FreeImageLib PRIVATE /permissive ) # we don't need the static library, but just in case someone does build it
55- endif (MSVC )
33+ if (MV_IML_USE_SYSTEM_FREEIMAGE)
34+ set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} /cmake)
35+ find_package (FreeImage REQUIRED )
36+ else ()
37+ include (FetchContent )
38+
39+ FetchContent_Declare (
40+ FreeImage
41+ GIT_REPOSITORY https://github.com/biovault/FreeImage
42+ GIT_TAG v3.19.0 # version 3.19.0.1, freeimage + cmake files + some updated modules
43+ )
44+
45+ FetchContent_MakeAvailable (FreeImage)
46+
47+ get_target_property (FreeImageVersion FreeImageLib VERSION )
48+ message (STATUS "FreeImage Version: ${FreeImageVersion} " )
49+
50+ set_target_properties (FreeImage FreeImageLib LibJPEG LibJXR LibOpenJPEG LibPNG LibRaw LibTIFF4 LibWebP OpenEXR ZLibFreeImage
51+ PROPERTIES
52+ FOLDER LoaderPlugins/Dependencies/ImageLoaderPlugin
53+ )
54+
55+ # Do not build static library
56+ set_target_properties (FreeImageLib PROPERTIES EXCLUDE_FROM_ALL ON )
57+
58+ # Remove /permissive- for OpenEXR and FreeImage
59+ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
60+ target_compile_options (OpenEXR PRIVATE /permissive )
61+ target_compile_options (FreeImage PRIVATE /permissive )
62+ target_compile_options (FreeImageLib PRIVATE /permissive ) # we don't need the static library, but just in case someone does build it
63+ endif ()
64+ endif ()
5665
5766# -----------------------------------------------------------------------------
5867# Source files
@@ -200,7 +209,7 @@ set_target_properties(${PROJECT}
200209# Miscellaneous
201210# -----------------------------------------------------------------------------
202211# Automatically set the debug environment (command + working directory) for MSVC
203- if (MSVC )
212+ if (CMAKE_CXX_COMPILER_ID STREQUAL " MSVC" )
204213 set_property (TARGET ${PROJECT} PROPERTY VS_DEBUGGER_WORKING_DIRECTORY $<IF :$<CONFIG :DEBUG >,${ManiVault_INSTALL_DIR} /Debug ,$<IF :$<CONFIG :RELWITHDEBINFO >,${ManiVault_INSTALL_DIR} /RelWithDebInfo ,${ManiVault_INSTALL_DIR} /Release >>)
205214 set_property (TARGET ${PROJECT} PROPERTY VS_DEBUGGER_COMMAND $<IF :$<CONFIG :DEBUG >,"${ManiVault_INSTALL_DIR} /Debug /ManiVault Studio .exe ",$<IF :$<CONFIG :RELWITHDEBINFO >,"${ManiVault_INSTALL_DIR} /RelWithDebInfo /ManiVault Studio .exe ","${ManiVault_INSTALL_DIR} /Release /ManiVault Studio .exe ">>)
206215endif ()
0 commit comments