Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
235 changes: 197 additions & 38 deletions Build/Cmake/RefIccMAXConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,51 +1,210 @@
# - Find RefIccMAX
# Find the native RefIccMAX headers and libraries.
###############################################################
#
# REFICCMAX_FOUND - True if RefIccMAX found.
# REFICCMAX_INCLUDE_DIRS - where to find kdb.h, etc.
# REFICCMAX_LIBRARIES - List of libraries when using RefIccMAX.
# Copyright (©) 2026 International Color Consortium.
# All rights reserved.
# https://color.org
#
# REFICCMAX_VERSION - The version of openicc (x.y.z)
# REFICCMAX_VERSION_MAJOR - The major version of openicc (x)
# REFICCMAX_VERSION_MINOR - The minor version of openicc (y)
# REFICCMAX_VERSION_MICRO - The patch version of openicc (z)
#
# Intent: iccDEV RefIccMAXConfig.cmake.in
#
# Last Updated: 12-JAN-2026 2300Z by David Hoyt
#
#
###############################################################
# RefIccMAX CMake Config File
# Provides modern IMPORTED targets for ICC color management libraries
#
# Usage:
# find_package(RefIccMAX CONFIG REQUIRED)
# target_link_libraries(myapp PRIVATE IccProfLib2 IccXML2)
#
# Modern targets (recommended):
# IccProfLib2 - Core ICC profile library (shared if available, else static)
# IccXML2 - XML serialization library (shared if available, else static)
# IccProfLib2-static - Static version of IccProfLib2
# IccXML2-static - Static version of IccXML2
#
# Legacy variables (for backward compatibility):
# REFICCMAX_FOUND - True if RefIccMAX found
# REFICCMAX_INCLUDE_DIRS - Include directories
# REFICCMAX_LIBRARIES - Libraries to link
# REFICCMAX_VERSION - Version string (x.y.z.w)
###############################################################
# Version information
set(REFICCMAX_VERSION_MAJOR @REFICCMAX_MAJOR_VERSION@)
set(REFICCMAX_VERSION_MINOR @REFICCMAX_MINOR_VERSION@)
set(REFICCMAX_VERSION_MICRO @REFICCMAX_MICRO_VERSION@)
set(REFICCMAX_VERSION_PATCH @REFICCMAX_PATCH_VERSION@)
set(REFICCMAX_VERSION @REFICCMAX_VERSION@)

# Compute installation prefix relative to this file
get_filename_component(REFICCMAX_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(REFICCMAX_PREFIX "${REFICCMAX_CMAKE_DIR}/../../.." ABSOLUTE)

# Find include directory
find_path(REFICCMAX_INCLUDE_DIR
NAMES @TARGET_LIB_ICCPROFLIB@/IccProfLibVer.h
HINTS "${REFICCMAX_PREFIX}/include/@TARGET_INCLUDE_FOLDER@"
PATHS @CMAKE_INSTALL_FULL_INCLUDEDIR@/@TARGET_INCLUDE_FOLDER@
NO_DEFAULT_PATH
)

if(NOT REFICCMAX_INCLUDE_DIR)
# Fallback for system-wide installation
find_path(REFICCMAX_INCLUDE_DIR
NAMES @TARGET_LIB_ICCPROFLIB@/IccProfLibVer.h
PATHS @CMAKE_INSTALL_FULL_INCLUDEDIR@/@TARGET_INCLUDE_FOLDER@
Comment on lines +53 to +56
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fallback find_path for REFICCMAX_INCLUDE_DIR (lines 54-57) will search system-wide paths, but it may find an incompatible version if RefIccMAX is installed system-wide. This could cause version mismatches. Consider adding a VERSION check or making the NO_DEFAULT_PATH behavior stricter to avoid mixing installation locations.

Suggested change
# Fallback for system-wide installation
find_path(REFICCMAX_INCLUDE_DIR
NAMES @TARGET_LIB_ICCPROFLIB@/IccProfLibVer.h
PATHS @CMAKE_INSTALL_FULL_INCLUDEDIR@/@TARGET_INCLUDE_FOLDER@
# Fallback for system-wide installation (restricted to explicit paths)
find_path(REFICCMAX_INCLUDE_DIR
NAMES @TARGET_LIB_ICCPROFLIB@/IccProfLibVer.h
PATHS @CMAKE_INSTALL_FULL_INCLUDEDIR@/@TARGET_INCLUDE_FOLDER@
NO_DEFAULT_PATH

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential True Positive. Testing in Progress.

)
endif()

# Find libraries
find_library(ICCPROFLIB2_LIBRARY
NAMES @TARGET_LIB_ICCPROFLIB@
HINTS "${REFICCMAX_PREFIX}/lib"
PATHS @CMAKE_INSTALL_FULL_LIBDIR@
NO_DEFAULT_PATH
)

find_library(ICCPROFLIB2_LIBRARY_DEBUG
NAMES @TARGET_LIB_ICCPROFLIB@d
HINTS "${REFICCMAX_PREFIX}/debug/lib"
NO_DEFAULT_PATH
)

find_library(ICCPROFLIB2_STATIC_LIBRARY
NAMES @TARGET_LIB_ICCPROFLIB@-static
HINTS "${REFICCMAX_PREFIX}/lib"
PATHS @CMAKE_INSTALL_FULL_LIBDIR@
NO_DEFAULT_PATH
)

# Set path to the header file.
FIND_PATH(REFICCMAX_INCLUDE_DIR
NAMES @TARGET_LIB_ICCPROFLIB@/IccProfLibVer.h
PATHS @CMAKE_INSTALL_FULL_INCLUDEDIR@/@TARGET_INCLUDE_FOLDER@/
find_library(ICCXML2_LIBRARY
NAMES IccXML2
HINTS "${REFICCMAX_PREFIX}/lib"
PATHS @CMAKE_INSTALL_FULL_LIBDIR@
NO_DEFAULT_PATH
)
MARK_AS_ADVANCED(REFICCMAX_INCLUDE_DIR)

find_library(ICCXML2_LIBRARY_DEBUG
NAMES IccXML2d
HINTS "${REFICCMAX_PREFIX}/debug/lib"
NO_DEFAULT_PATH
)

# Set path to the library.
FIND_LIBRARY( REFICCMAX_LIBRARIES
NAMES @TARGET_LIB_ICCPROFLIB@
PATHS @CMAKE_INSTALL_FULL_LIBDIR@/
find_library(ICCXML2_STATIC_LIBRARY
NAMES IccXML2-static
Comment on lines +82 to +95
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The library name "IccXML2" is hardcoded on lines 82, 89, and 95, while the IccProfLib2 searches use the configurable @TARGET_LIB_ICCPROFLIB@ variable (line 62, 69, 75). For consistency and maintainability, consider using a @TARGET_LIB_ICCXML@ variable instead of hardcoding the library name.

Copilot uses AI. Check for mistakes.
HINTS "${REFICCMAX_PREFIX}/lib"
PATHS @CMAKE_INSTALL_FULL_LIBDIR@
NO_DEFAULT_PATH
)
Comment on lines +81 to 99
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IccXML2 library searches (lines 81-99) are missing the PATHS argument with CMAKE_INSTALL_FULL_LIBDIR that the IccProfLib2 searches have (lines 64, 77). This inconsistency means IccXML2 libraries won't be found if the package is installed in a system-wide location but the REFICCMAX_PREFIX calculation doesn't work. Add the PATHS argument for consistency and robustness.

Copilot uses AI. Check for mistakes.
FIND_LIBRARY( REFICCMAX_STATIC_LIBRARY
NAMES @TARGET_LIB_ICCPROFLIB@-static
PATHS @CMAKE_INSTALL_FULL_LIBDIR@/

# Handle find_package() arguments
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(RefIccMAX
REQUIRED_VARS REFICCMAX_INCLUDE_DIR
VERSION_VAR REFICCMAX_VERSION
HANDLE_COMPONENTS
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HANDLE_COMPONENTS option is specified in find_package_handle_standard_args (line 106), but there's no code to actually handle components. This will cause CMake to fail if users specify components like find_package(RefIccMAX COMPONENTS IccProfLib2). Either remove HANDLE_COMPONENTS or implement proper component handling by checking RefIccMAX_FIND_COMPONENTS and setting component-specific FOUND variables.

Suggested change
HANDLE_COMPONENTS

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential True Positive. Testing in Progress.

Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HANDLE_COMPONENTS flag is specified but no components are actually defined or validated. Either remove the HANDLE_COMPONENTS flag if components are not needed, or implement proper component handling by checking for requested components (e.g., IccProfLib2, IccXML2) in the find_package call.

Suggested change
HANDLE_COMPONENTS

Copilot uses AI. Check for mistakes.
)
MARK_AS_ADVANCED(REFICCMAX_STATIC_LIBRARY)
IF(NOT REFICCMAX_LIBRARIES AND REFICCMAX_STATIC_LIBRARY)
SET( REFICCMAX_LIBRARIES ${REFICCMAX_STATIC_LIBRARY}} )
ENDIF()
MARK_AS_ADVANCED(REFICCMAX_LIBRARIES)

# handle the QUIETLY and REQUIRED arguments and set REFICCMAX_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(@TARGET_LIB_ICCPROFLIB@ DEFAULT_MSG REFICCMAX_LIBRARIES REFICCMAX_INCLUDE_DIR)
if(RefIccMAX_FOUND OR REFICCMAX_FOUND)
set(REFICCMAX_FOUND TRUE)
set(REFICCMAX_INCLUDE_DIRS "${REFICCMAX_INCLUDE_DIR}")

# Set up include directories for all subdirectories
# IccXML2 headers need access to IccProfLib2 headers via relative includes
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states "IccXML2 headers need access to IccProfLib2 headers via relative includes" but the actual includes in IccXML files use direct includes like #include "IccProfile.h" without relative paths. The comment should be updated to accurately reflect that IccXML2 headers include IccProfLib2 headers directly, requiring both directories to be in the include path.

Suggested change
# IccXML2 headers need access to IccProfLib2 headers via relative includes
# IccXML2 headers directly include IccProfLib2 headers, so both dirs must be in the include path

Copilot uses AI. Check for mistakes.
set(REFICCMAX_INTERFACE_INCLUDES
"${REFICCMAX_INCLUDE_DIR}"
"${REFICCMAX_INCLUDE_DIR}/IccProfLib2"
"${REFICCMAX_INCLUDE_DIR}/IccXML2"
)

# Create IMPORTED targets

# IccProfLib2 shared library
if(ICCPROFLIB2_LIBRARY AND NOT TARGET IccProfLib2)
add_library(IccProfLib2 SHARED IMPORTED)
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ICCPROFLIB2_LIBRARY is marked as SHARED IMPORTED (line 125), but there's no verification that the library is actually shared. The find_library command finds any library with the given name regardless of type. If a static library is found instead, this will cause a mismatch. Consider using UNKNOWN IMPORTED instead of SHARED IMPORTED and setting the IMPORTED_LINK_INTERFACE_LIBRARIES property appropriately, or verify the library type before creating the target.

Suggested change
add_library(IccProfLib2 SHARED IMPORTED)
add_library(IccProfLib2 UNKNOWN IMPORTED)

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential True Positive. Testing in Progress.

Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The library type is hardcoded as SHARED, but the actual library type should be determined from the library file extension or build configuration. If only static libraries were built, this will create an incorrectly typed IMPORTED target. Consider using UNKNOWN library type or checking the actual library type.

Suggested change
add_library(IccProfLib2 SHARED IMPORTED)
add_library(IccProfLib2 UNKNOWN IMPORTED)

Copilot uses AI. Check for mistakes.
set_target_properties(IccProfLib2 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${REFICCMAX_INTERFACE_INCLUDES}"
IMPORTED_LOCATION "${ICCPROFLIB2_LIBRARY}"
)
if(ICCPROFLIB2_LIBRARY_DEBUG)
set_target_properties(IccProfLib2 PROPERTIES
IMPORTED_LOCATION_DEBUG "${ICCPROFLIB2_LIBRARY_DEBUG}"
)
endif()
list(APPEND REFICCMAX_LIBRARIES IccProfLib2)
endif()

# IccProfLib2 static library
if(ICCPROFLIB2_STATIC_LIBRARY AND NOT TARGET IccProfLib2-static)
add_library(IccProfLib2-static STATIC IMPORTED)
set_target_properties(IccProfLib2-static PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${REFICCMAX_INTERFACE_INCLUDES}"
IMPORTED_LOCATION "${ICCPROFLIB2_STATIC_LIBRARY}"
)
if(NOT TARGET IccProfLib2)
# If no shared library, alias static as main target
add_library(IccProfLib2 ALIAS IccProfLib2-static)
list(APPEND REFICCMAX_LIBRARIES IccProfLib2-static)
endif()
endif()

# IccXML2 shared library
if(ICCXML2_LIBRARY AND NOT TARGET IccXML2)
add_library(IccXML2 SHARED IMPORTED)
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IccXML2 library is marked as SHARED IMPORTED (line 154), but there's no verification that the library is actually shared. The find_library command finds any library with the given name regardless of type. If a static library is found instead, this will cause a mismatch. Consider using UNKNOWN IMPORTED instead of SHARED IMPORTED, or verify the library type before creating the target.

Suggested change
add_library(IccXML2 SHARED IMPORTED)
add_library(IccXML2 UNKNOWN IMPORTED)

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential True Positive. Testing in Progress.

set_target_properties(IccXML2 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${REFICCMAX_INTERFACE_INCLUDES}"
IMPORTED_LOCATION "${ICCXML2_LIBRARY}"
)
if(ICCXML2_LIBRARY_DEBUG)
set_target_properties(IccXML2 PROPERTIES
IMPORTED_LOCATION_DEBUG "${ICCXML2_LIBRARY_DEBUG}"
)
endif()
if(TARGET IccProfLib2)
set_target_properties(IccXML2 PROPERTIES
INTERFACE_LINK_LIBRARIES IccProfLib2
)
Comment on lines +161 to +167
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IccXML2 library's INTERFACE_LINK_LIBRARIES is set to IccProfLib2 (line 166), but there's no check whether IccProfLib2 was found as a shared or static library. If IccProfLib2 is static and IccXML2 is shared, this could cause linking issues. Consider linking to the appropriate variant (IccProfLib2-static if IccXML2 is static, IccProfLib2 if shared) based on which library type was found.

Suggested change
IMPORTED_LOCATION_DEBUG "${ICCXML2_LIBRARY_DEBUG}"
)
endif()
if(TARGET IccProfLib2)
set_target_properties(IccXML2 PROPERTIES
INTERFACE_LINK_LIBRARIES IccProfLib2
)
IMPORTED_LOCATION_DEBUG "${ICC2XML_LIBRARY_DEBUG}"
)
endif()
if(TARGET IccProfLib2)
# Prefer linking against shared IccProfLib2 when available
set_target_properties(IccXML2 PROPERTIES
INTERFACE_LINK_LIBRARIES IccProfLib2
)
elseif(TARGET IccProfLib2-static)
# Fallback: link against static IccProfLib2-static if only static is available
set_target_properties(IccXML2 PROPERTIES
INTERFACE_LINK_LIBRARIES IccProfLib2-static
)

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential True Positive. Testing in Progress.

endif()
Comment on lines +164 to +168
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The INTERFACE_LINK_LIBRARIES is only set if the IccProfLib2 target exists, but IccXML2 likely depends on IccProfLib2 in all cases. If IccProfLib2 doesn't exist but IccProfLib2-static does (and was aliased to IccProfLib2), this dependency won't be properly set. Consider checking for either IccProfLib2 or IccProfLib2-static, or rely on the alias being created.

Copilot uses AI. Check for mistakes.
list(APPEND REFICCMAX_LIBRARIES IccXML2)
endif()

# IccXML2 static library
if(ICCXML2_STATIC_LIBRARY AND NOT TARGET IccXML2-static)
add_library(IccXML2-static STATIC IMPORTED)
set_target_properties(IccXML2-static PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${REFICCMAX_INTERFACE_INCLUDES}"
IMPORTED_LOCATION "${ICCXML2_STATIC_LIBRARY}"
)
if(TARGET IccProfLib2-static)
set_target_properties(IccXML2-static PROPERTIES
INTERFACE_LINK_LIBRARIES IccProfLib2-static
)
endif()
if(NOT TARGET IccXML2)
# If no shared library, alias static as main target
add_library(IccXML2 ALIAS IccXML2-static)
list(APPEND REFICCMAX_LIBRARIES IccXML2-static)
endif()
endif()

# Legacy support - set REFICCMAX_LIBRARIES if not already set
if(NOT REFICCMAX_LIBRARIES)
if(ICCPROFLIB2_LIBRARY)
list(APPEND REFICCMAX_LIBRARIES "${ICCPROFLIB2_LIBRARY}")
elseif(ICCPROFLIB2_STATIC_LIBRARY)
list(APPEND REFICCMAX_LIBRARIES "${ICCPROFLIB2_STATIC_LIBRARY}")
endif()
endif()

Comment on lines +191 to 199
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an inconsistency in REFICCMAX_LIBRARIES values. Earlier sections (lines 135, 148, 169, 187) append CMake target names (e.g., IccProfLib2, IccXML2), while the legacy support section appends raw library paths (ICCPROFLIB2_LIBRARY, ICCPROFLIB2_STATIC_LIBRARY). This mixing of target names and paths in the same variable will confuse consumers. The legacy section should either be removed (since targets are set above) or the logic should be restructured to use only paths for legacy support.

Suggested change
# Legacy support - set REFICCMAX_LIBRARIES if not already set
if(NOT REFICCMAX_LIBRARIES)
if(ICCPROFLIB2_LIBRARY)
list(APPEND REFICCMAX_LIBRARIES "${ICCPROFLIB2_LIBRARY}")
elseif(ICCPROFLIB2_STATIC_LIBRARY)
list(APPEND REFICCMAX_LIBRARIES "${ICCPROFLIB2_STATIC_LIBRARY}")
endif()
endif()

Copilot uses AI. Check for mistakes.
IF (REFICCMAX_FOUND)
SET( REFICCMAX_VERSION_MAJOR @REFICCMAX_MAJOR_VERSION@ )
SET( REFICCMAX_VERSION_MINOR @REFICCMAX_MINOR_VERSION@ )
SET( REFICCMAX_VERSION_MICRO @REFICCMAX_MICRO_VERSION@ )
SET( REFICCMAX_VERSION @REFICCMAX_VERSION@ )
SET( HAVE_REFICCMAX TRUE )
SET( REFICCMAX_INCLUDE_DIRS ${REFICCMAX_INCLUDE_DIR})
ENDIF (REFICCMAX_FOUND)
# Mark variables as advanced
mark_as_advanced(
REFICCMAX_INCLUDE_DIR
ICCPROFLIB2_LIBRARY
ICCPROFLIB2_LIBRARY_DEBUG
ICCPROFLIB2_STATIC_LIBRARY
ICCXML2_LIBRARY
ICCXML2_LIBRARY_DEBUG
ICCXML2_STATIC_LIBRARY
)
endif()
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iccdev",
"version": "2.3.1.1",
"version": "2.3.1.2",
"description": "Developer tools for ICC color profiles",
"builtin-baseline": "af752f21c9d79ba3df9cb0250ce2233933f58486",
"dependencies": [
Expand Down