Add new comment

I'm building the DNG SDK

I'm building the DNG SDK using cmake and this CMakeLists.txt. This creates a static library, on Windows, Linux and macos.

cmake_minimum_required(VERSION 3.15)
project(dng)
 
INCLUDE_DIRECTORIES( ${JPEG_INCLUDE_DIR} )
ADD_DEFINITIONS( ${JPEG_DEFINITIONS} )
 
INCLUDE_DIRECTORIES( ${ZLIB_INCLUDE_DIR} )
ADD_DEFINITIONS( ${ZLIB_DEFINITIONS} )
INCLUDE_DIRECTORIES( ${JXL_INCLUDE_DIR} )
ADD_DEFINITIONS( ${JXL_DEFINITIONS} )
INCLUDE_DIRECTORIES( ${XMP_INCLUDE_DIR} )
ADD_DEFINITIONS( ${XMP_DEFINITIONS} )
 
FILE(GLOB SRCFILES ${CMAKE_CURRENT_SOURCE_DIR}/dng_sdk/source/*.cpp)
FILE(GLOB HFILES ${CMAKE_CURRENT_SOURCE_DIR}/dng_sdk/source/*.h)
ADD_LIBRARY(dng-sdk STATIC ${SRCFILES})
 
TARGET_INCLUDE_DIRECTORIES( dng-sdk INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/source )
SET_TARGET_PROPERTIES(dng-sdk PROPERTIES PUBLIC_HEADER "${HFILES}")
 
set_property(TARGET dng-sdk PROPERTY CXX_STANDARD 17)
 
TARGET_COMPILE_DEFINITIONS( dng-sdk PUBLIC
                            -DqDNGThreadSafe=0
                            -DqDNG64Bit=1
                            -DqDNGDebug=0                      # do not compile debug code
                            -DqDNGValidateTarget=0             # do not build dng_validate-binary
                            -DqDNGUseLibJPEG=1                 # use libjpeg
                            -DqDNGXMPFiles=0 -DqDNGXMPDocOps=0 # build minimal XMP-set
                            -DqDNGUseStdInt=1                  # Must be set to 1, else do not compile under Linux.
)
 
# Check processor endianness (todo: not sure bigEndian platforms are set correctly)
INCLUDE(TestBigEndian)
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
IF(NOT IS_BIG_ENDIAN)
    TARGET_COMPILE_DEFINITIONS( dng-sdk PUBLIC -DqDNGLittleEndian=1)
ENDIF(NOT IS_BIG_ENDIAN)
 
IF (WIN32)
    if(MSVC)
        TARGET_COMPILE_OPTIONS( dng-sdk PRIVATE /GR /EHsc)
    else()
        TARGET_COMPILE_OPTIONS( dng-sdk PRIVATE -fexceptions)
    endif()
    TARGET_COMPILE_DEFINITIONS( dng-sdk PRIVATE -DqWinOS=1 -DqMacOS=0 -DqLinux=0 -DWIN_ENV -DWIN32 -D_WINDOWS)
ELSEIF (APPLE)
    TARGET_COMPILE_OPTIONS( dng-sdk PRIVATE -fexceptions )
    TARGET_COMPILE_DEFINITIONS( dng-sdk PRIVATE -DqWinOS=0 -DqMacOS=1 -DqLinux=0 -DMAC_ENV)
ELSE()
    TARGET_COMPILE_OPTIONS( dng-sdk PRIVATE -fexceptions -fPIE)
    TARGET_COMPILE_DEFINITIONS( dng-sdk PRIVATE -DqWinOS=0 -DqMacOS=0 -DqLinux=1 -DUNIX_ENV)
ENDIF()
 
install(TARGETS dng-sdk DESTINATION lib PUBLIC_HEADER DESTINATION include)