diff --git a/CMakeLists.txt b/CMakeLists.txt index e7d5a66..484e76b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,8 +121,14 @@ include(MacroOptionalFindPackage) # Math library check +set(PC_LIBS_PRIVATE "") +set(PC_REQUIRES_PRIVATE "") if(NOT WIN32) FIND_LIBRARY(MATH_LIBRARY m) + if(MATH_LIBRARY) + set(MATH_LIBRARY m) + string(APPEND PC_LIBS_PRIVATE " -lm") + endif() endif() # LCMS version 1 and 2 library check @@ -133,7 +139,11 @@ set(LCMS_FOUND false) if(ENABLE_LCMS) message(STATUS "Check for LCMS2 availability...") - find_package(LCMS2) + find_package(lcms2 CONFIG REQUIRED) + set(LCMS2_FOUND 1) + set(LCMS2_VERSION 2.14) + set(LCMS2_INCLUDE_DIR "") + set(LCMS2_LIBRARIES lcms2::lcms2) if(LCMS2_FOUND AND (LCMS2_VERSION VERSION_EQUAL 2.1 OR LCMS2_VERSION VERSION_GREATER 2.1)) message(STATUS "Found LCMS2 : ${LCMS2_LIBRARIES} ${LCMS2_INCLUDE_DIR}") include_directories(${LCMS2_INCLUDE_DIR}) @@ -141,6 +151,7 @@ if(ENABLE_LCMS) # Flag to compile Little CMS version 2 with LibRaw add_definitions(-DUSE_LCMS2) set(LCMS_SUPPORT_CAN_BE_COMPILED true) + string(APPEND PC_REQUIRES_PRIVATE " lcms2") else() message(STATUS "Check for LCMS availability instead LCMS2...") find_package(LCMS) @@ -168,6 +179,7 @@ find_package(JPEG) # Flag to use zlib with LibRaw DNG deflate codec if(ZLIB_FOUND) add_definitions(-DUSE_ZLIB) + string(APPEND PC_REQUIRES_PRIVATE " zlib") endif() # For registration to libraw_config.h @@ -176,10 +188,11 @@ MACRO_BOOL_TO_01(ZLIB_FOUND LIBRAW_USE_DNGDEFLATECODEC) # JPEG library check find_package(JPEG) if(JPEG_FOUND) - if (${JPEG_VERSION} LESS 80) + if (${JPEG_VERSION} LESS 80 OR NOT CMAKE_REQUIRE_FIND_PACKAGE_JPEG) set(JPEG8_FOUND FALSE) else() set(JPEG8_FOUND TRUE) + string(APPEND PC_REQUIRES_PRIVATE " libjpeg") endif() endif() @@ -216,6 +229,7 @@ if(ENABLE_JASPER) add_definitions(-DUSE_JASPER) include_directories(${JASPER_INCLUDE_DIR}) set(JASPER_SUPPORT_CAN_BE_COMPILED true) + string(APPEND PC_REQUIRES_PRIVATE " jasper") endif() endif() diff --git a/cmake/data/libraw.pc.cmake b/cmake/data/libraw.pc.cmake index aa6ab21..90e0aae 100644 --- a/cmake/data/libraw.pc.cmake +++ b/cmake/data/libraw.pc.cmake @@ -10,3 +10,5 @@ Requires: Version: @RAW_LIB_VERSION_STRING@ Libs: -L${libdir} -lraw Cflags: -I${includedir} -I${includedir}/libraw +Libs.private: @PC_LIBS_PRIVATE@ +Requires.private: @PC_REQUIRES_PRIVATE@ diff --git a/cmake/data/libraw_r.pc.cmake b/cmake/data/libraw_r.pc.cmake index 4fadc36..4215e86 100644 --- a/cmake/data/libraw_r.pc.cmake +++ b/cmake/data/libraw_r.pc.cmake @@ -10,3 +10,5 @@ Requires: Version: @RAW_LIB_VERSION_STRING@ Libs: -L${libdir} -lraw_r Cflags: -I${includedir} -I${includedir}/libraw +Libs.private: @PC_LIBS_PRIVATE@ +Requires.private: @PC_REQUIRES_PRIVATE@ diff --git a/cmake/librawConfig.cmake.in b/cmake/librawConfig.cmake.in index b1b58d8..9b7baac 100644 --- a/cmake/librawConfig.cmake.in +++ b/cmake/librawConfig.cmake.in @@ -13,7 +13,7 @@ endif() if(@LCMS_SUPPORT_CAN_BE_COMPILED@) if(@LCMS2_FOUND@) - find_dependency(LCMS2) + find_dependency(lcms2 CONFIG) elseif(@LCMS_FOUND@) find_dependency(LCMS) endif()