-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
138 lines (116 loc) · 3.85 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
cmake_minimum_required(VERSION 3.20)
project(dng
VERSION 1.7.1
DESCRIPTION "Adobe DNG SDK"
LANGUAGES CXX C
)
set(CMAKE_CXX_STANDARD 11)
find_library(JXL NAMES jxl REQUIRED)
find_library(JXLThreads NAMES jxl_threads REQUIRED)
find_library(JXLCms NAMES jxl_cms REQUIRED)
find_path(JXL_INCLUDE_DIRS jxl/decode.h)
# For static builds libjxl requires -DJXL_STATIC_DEFINE
# This assumes that if BUILD_SHARED_LIBS is not set (making this library static)
# then JXL was also built as a static library.
if (NOT BUILD_SHARED_LIBS)
message("Using static libjxl")
# Find dependencies for static builds as libjxl doesn't provide CMake configs
# to find them automatically.
#
find_library(HWY_LIBRARY NAMES hwy REQUIRED)
find_library(BROTLI_COMMON_LIBRARY NAMES brotlicommon brotlicommon-static REQUIRED)
find_library(BROTLI_DEC_LIBRARY NAMES brotlidec brotlidec-static REQUIRED)
find_library(BROTLI_ENC_LIBRARY NAMES brotlienc brotlienc-static REQUIRED)
find_library(LCMS2_LIBRARY NAMES lcms2 REQUIRED)
set(JPEGXL_DEPENDENCIES
${BROTLI_DEC_LIBRARY}
${BROTLI_ENC_LIBRARY}
${BROTLI_COMMON_LIBRARY}
${LCMS2_LIBRARY}
${HWY_LIBRARY})
endif()
find_package(ZLIB REQUIRED)
if (NOT TARGET XMP::XMPCore)
find_package(XMP CONFIG REQUIRED)
endif()
message("XMP INCLUDE DIR: ${XMP_INCLUDE_DIR}")
get_property(XMP_LIB TARGET XMP::XMPCore PROPERTY LOCATION)
get_property(XMP_FILES_LIB TARGET XMP::XMPFiles PROPERTY LOCATION)
message("XMP CORE Library: ${XMP_LIB}")
message("XMP Files Library: ${XMP_FILES_LIB}")
file(GLOB DNG_SOURCES src/*.cpp)
add_library(dng ${DNG_SOURCES})
target_include_directories(dng PRIVATE ${JXL_INCLUDE_DIRS} ${XMP_INCLUDE_DIR})
target_link_libraries(dng PUBLIC
ZLIB::ZLIB XMP::XMPFiles XMP::XMPCore
${JXL} ${JXLThreads} ${JXLCms}
${JPEGXL_DEPENDENCIES})
target_compile_definitions(dng PUBLIC "-DJXL_STATIC_DEFINE=1")
set(DNG_DEFINITIONS
-DqDNGUseXMP=1
-DqDNGXMPFiles=1
-DqDNGXMPDocOps=0
)
if (APPLE)
if (CMAKE_SYSTEM_NAME MATCHES "iOS")
list(APPEND DNG_DEFINITIONS
-DIOS_ENV=1
-DqiPhone=1
)
else()
list(APPEND DNG_DEFINITIONS
-DMAC_ENV=1
-DqMacOS=1
)
endif()
elseif (ANDROID)
list(APPEND DNG_DEFINITIONS
-DANDROID_ENV=1
-DqAndroid=1
)
elseif (WIN32)
list(APPEND DNG_DEFINITIONS
-DWIN_ENV=1
-DqWinOS=1
)
else()
list(APPEND DNG_DEFINITIONS
-DUNIX_ENV=1
-DqLinux=1
)
endif()
if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
list(APPEND DNG_DEFINITIONS -DqDNGBigEndian=0)
endif()
target_compile_definitions(dng PUBLIC ${DNG_DEFINITIONS})
set(DNG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_include_directories(dng PUBLIC
$<BUILD_INTERFACE:${DNG_INCLUDE_DIRS}>
$<INSTALL_INTERFACE:include/dng>)
# Install targets
file(GLOB DNG_HEADERS src/*.h)
install(TARGETS dng EXPORT DngTargets)
install(FILES ${DNG_HEADERS} DESTINATION include/dng)
install(EXPORT DngTargets FILE DNGTargets.cmake DESTINATION lib/cmake/DNG)
set(DNG_INSTALL_INCLUDE_DIR include/dng)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
# Configure the package
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/DNGConfig.cmake
PATH_VARS DNG_INSTALL_INCLUDE_DIR
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/DNG
)
# Generate version file
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/DNGConfigVersion.cmake
VERSION 1.0.0 # Replace with your actual version
COMPATIBILITY SameMajorVersion
)
# Install the config files
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/DNGConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/DNGConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/DNG
)