Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Add some options to cmake #2

Merged
merged 2 commits into from
Apr 10, 2016
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
79 changes: 47 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ project ( libjpeg C )
cmake_minimum_required ( VERSION 2.8 )
include ( cmake/dist.cmake )

OPTION(BUILD_STATIC OFF)
OPTION(BUILD_EXECUTABLES ON)
OPTION(BUILD_TESTS ON)

include ( CheckIncludeFile )
check_include_file ( stddef.h HAVE_STDDEF_H )
check_include_file ( stdlib.h HAVE_STDLIB_H )
Expand All @@ -31,42 +35,53 @@ set ( SRC jmemnobs.c jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolo
jidctflt.c jidctfst.c jidctint.c jquant1.c jquant2.c jutils.c jmemmgr.c cderror.h
cdjpeg.h jdct.h jinclude.h jmemsys.h jpegint.h jversion.h transupp.h )

add_library ( jpeg ${SRC} ${HEADERS} )
if ( BUILD_STATIC )
add_library ( jpeg STATIC ${SRC} ${HEADERS} )
else ()
add_library ( jpeg ${SRC} ${HEADERS} )
endif()

if ( BUILD_EXECUTABLES )
add_executable ( cjpeg cdjpeg.c cjpeg.c rdbmp.c rdgif.c rdppm.c rdrle.c rdtarga.c
rdswitch.c )
add_executable ( djpeg cdjpeg.c djpeg.c wrbmp.c wrgif.c wrppm.c wrrle.c wrtarga.c
rdcolmap.c )
add_executable ( jpegtran jpegtran.c cdjpeg.c rdswitch.c transupp.c )
add_executable ( rdjpgcom rdjpgcom.c )
add_executable ( wrjpgcom wrjpgcom.c )
target_link_libraries ( cjpeg jpeg )
target_link_libraries ( djpeg jpeg )
target_link_libraries ( jpegtran jpeg )
endif ()

add_executable ( cjpeg cdjpeg.c cjpeg.c rdbmp.c rdgif.c rdppm.c rdrle.c rdtarga.c
rdswitch.c )
add_executable ( djpeg cdjpeg.c djpeg.c wrbmp.c wrgif.c wrppm.c wrrle.c wrtarga.c
rdcolmap.c )
add_executable ( jpegtran jpegtran.c cdjpeg.c rdswitch.c transupp.c )
add_executable ( rdjpgcom rdjpgcom.c )
add_executable ( wrjpgcom wrjpgcom.c )
target_link_libraries ( cjpeg jpeg )
target_link_libraries ( djpeg jpeg )
target_link_libraries ( jpegtran jpeg )
if ( BUILD_EXECUTABLES )
install_executable ( cjpeg djpeg jpegtran rdjpgcom wrjpgcom )
endif ()

install_executable ( cjpeg djpeg jpegtran rdjpgcom wrjpgcom )
install_library ( jpeg )
install_header ( ${HEADERS} )
install_doc ( README install.txt usage.txt wizard.txt example.c libjpeg.txt structure.txt
coderules.txt filelist.txt change.log )

# tests
enable_testing ( )
macro ( mytest name target args input output )
get_target_property ( _cmdpath ${target} LOCATION )
add_test ( ${name} ${CMAKE_COMMAND} "-DCOMMAND=${_cmdpath} ${args}" "-DINPUT=${input}"
"-DOUTPUT=${output}" -P ${CMAKE_CURRENT_SOURCE_DIR}/jpeg_test.cmake )
endmacro ( )
set ( _src "${CMAKE_CURRENT_SOURCE_DIR}" )
mytest ( t1 djpeg "-dct int -ppm -outfile testout.ppm ${_src}/testorig.jpg" "${_src}/testimg.ppm"
testout.ppm )
mytest ( t2 djpeg "-dct int -bmp -colors 256 -outfile testout.bmp ${_src}/testorig.jpg"
${_src}/testimg.bmp testout.bmp )
mytest ( t3 cjpeg "-dct int -outfile testout.jpg ${_src}/testimg.ppm" ${_src}/testimg.jpg
testout.jpg )
mytest ( t4 djpeg "-dct int -ppm -outfile testoutp.ppm ${_src}/testprog.jpg" ${_src}/testimg.ppm
testoutp.ppm )
mytest ( t5 cjpeg "-dct int -progressive -opt -outfile testoutp.jpg ${_src}/testimg.ppm"
${_src}/testimgp.jpg testoutp.jpg )
mytest ( t6 jpegtran "-outfile testoutt.jpg ${_src}/testprog.jpg" ${_src}/testorig.jpg
testoutt.jpg )
if ( BUILD_TESTS )
# tests
enable_testing ( )
macro ( mytest name target args input output )
get_target_property ( _cmdpath ${target} LOCATION )
add_test ( ${name} ${CMAKE_COMMAND} "-DCOMMAND=${_cmdpath} ${args}" "-DINPUT=${input}"
"-DOUTPUT=${output}" -P ${CMAKE_CURRENT_SOURCE_DIR}/jpeg_test.cmake )
endmacro ( )
set ( _src "${CMAKE_CURRENT_SOURCE_DIR}" )
mytest ( t1 djpeg "-dct int -ppm -outfile testout.ppm ${_src}/testorig.jpg" "${_src}/testimg.ppm"
testout.ppm )
mytest ( t2 djpeg "-dct int -bmp -colors 256 -outfile testout.bmp ${_src}/testorig.jpg"
${_src}/testimg.bmp testout.bmp )
mytest ( t3 cjpeg "-dct int -outfile testout.jpg ${_src}/testimg.ppm" ${_src}/testimg.jpg
testout.jpg )
mytest ( t4 djpeg "-dct int -ppm -outfile testoutp.ppm ${_src}/testprog.jpg" ${_src}/testimg.ppm
testoutp.ppm )
mytest ( t5 cjpeg "-dct int -progressive -opt -outfile testoutp.jpg ${_src}/testimg.ppm"
${_src}/testimgp.jpg testoutp.jpg )
mytest ( t6 jpegtran "-outfile testoutt.jpg ${_src}/testprog.jpg" ${_src}/testorig.jpg
testoutt.jpg )
endif ()
6 changes: 3 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ CONFIGFILES= jconfig.cfg jconfig.bcc jconfig.mc6 jconfig.dj jconfig.wat \
jconfig.vms

# Support scripts for configure
CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp missing
CONFIGUREFILES= config.guess config.sub install-sh ltmain.sh depcomp \
missing ar-lib

# Miscellaneous support files
OTHERFILES= jconfig.txt ckconfig.c ansi2knr.c ansi2knr.1 jmemdosa.asm \
libjpeg.map
OTHERFILES= jconfig.txt ckconfig.c jmemdosa.asm libjpeg.map

# Test support files
TESTFILES= testorig.jpg testimg.ppm testimg.bmp testimg.jpg testprog.jpg \
Expand Down
Loading