Skip to content
Open
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
27 changes: 10 additions & 17 deletions sharedlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,24 @@ endif()
set(CDJPEG_COMPILE_FLAGS
"-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}")

set(CJPEG_PNG_SOURCES "")
if(PNG_SUPPORTED)
set(CDJPEG_COMPILE_FLAGS "${CDJPEG_COMPILE_FLAGS} -DPNG_SUPPORTED")
set(CJPEG_PNG_SOURCES ../rdpng.c)
endif()

# Compile a separate version of these source files with 12-bit and 16-bit data
# precision.
add_library(cjpeg12 OBJECT ../rdgif.c ../rdppm.c)
add_library(cjpeg12 OBJECT ../rdgif.c ../rdppm.c ${CJPEG_PNG_SOURCES})
set_property(TARGET cjpeg12 PROPERTY COMPILE_FLAGS
"-DBITS_IN_JSAMPLE=12 -DGIF_SUPPORTED -DPPM_SUPPORTED")
add_library(cjpeg16 OBJECT ../rdgif.c ../rdppm.c)
add_library(cjpeg16 OBJECT ../rdgif.c ../rdppm.c ${CJPEG_PNG_SOURCES})
set_property(TARGET cjpeg16 PROPERTY COMPILE_FLAGS
"-DBITS_IN_JSAMPLE=16 -DGIF_SUPPORTED -DPPM_SUPPORTED")
add_executable(cjpeg ../cjpeg.c ../cdjpeg.c ../rdbmp.c ../rdgif.c ../rdppm.c
../rdjpeg.c
../rdswitch.c ../rdtarga.c $<TARGET_OBJECTS:cjpeg12>
../rdswitch.c ../rdtarga.c ${CJPEG_PNG_SOURCES}
$<TARGET_OBJECTS:cjpeg12>
$<TARGET_OBJECTS:cjpeg16>)
set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS ${CDJPEG_COMPILE_FLAGS})
target_link_libraries(cjpeg jpeg)
Expand All @@ -114,20 +121,6 @@ set_property(TARGET djpeg16 PROPERTY COMPILE_FLAGS
"-DBITS_IN_JSAMPLE=16 -DPPM_SUPPORTED")

if(PNG_SUPPORTED)
report_option(PNG_SUPPORTED "PNG reading support")
set(COMPILE_FLAGS "${COMPILE_FLAGS} -DPNG_SUPPORTED")
set(CJPEG_BMP_SOURCES ${CJPEG_BMP_SOURCES} ../rdpng.c)
endif()

if(PNG_SUPPORTED)
# to avoid finding static library from CMake cache
unset(PNG_LIBRARY CACHE)
unset(PNG_LIBRARY_RELEASE CACHE)
unset(PNG_LIBRARY_DEBUG CACHE)
unset(ZLIB_LIBRARY CACHE)
unset(ZLIB_LIBRARY_RELEASE CACHE)
unset(ZLIB_LIBRARY_DEBUG CACHE)

find_package(PNG 1.6 REQUIRED)
find_package(ZLIB REQUIRED)
target_include_directories(cjpeg PUBLIC ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
Expand Down