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

Commit 2ecab59

Browse files
committed
Add some options to cmake
1 parent bc8f8be commit 2ecab59

File tree

1 file changed

+47
-32
lines changed

1 file changed

+47
-32
lines changed

CMakeLists.txt

+47-32
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ project ( libjpeg C )
88
cmake_minimum_required ( VERSION 2.8 )
99
include ( cmake/dist.cmake )
1010

11+
OPTION(BUILD_STATIC OFF)
12+
OPTION(BUILD_EXECUTABLES ON)
13+
OPTION(BUILD_TESTS ON)
14+
1115
include ( CheckIncludeFile )
1216
check_include_file ( stddef.h HAVE_STDDEF_H )
1317
check_include_file ( stdlib.h HAVE_STDLIB_H )
@@ -31,42 +35,53 @@ set ( SRC jmemnobs.c jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolo
3135
jidctflt.c jidctfst.c jidctint.c jquant1.c jquant2.c jutils.c jmemmgr.c cderror.h
3236
cdjpeg.h jdct.h jinclude.h jmemsys.h jpegint.h jversion.h transupp.h )
3337

34-
add_library ( jpeg ${SRC} ${HEADERS} )
38+
if ( BUILD_STATIC )
39+
add_library ( jpeg STATIC ${SRC} ${HEADERS} )
40+
else ()
41+
add_library ( jpeg ${SRC} ${HEADERS} )
42+
endif()
43+
44+
if ( BUILD_EXECUTABLES )
45+
add_executable ( cjpeg cdjpeg.c cjpeg.c rdbmp.c rdgif.c rdppm.c rdrle.c rdtarga.c
46+
rdswitch.c )
47+
add_executable ( djpeg cdjpeg.c djpeg.c wrbmp.c wrgif.c wrppm.c wrrle.c wrtarga.c
48+
rdcolmap.c )
49+
add_executable ( jpegtran jpegtran.c cdjpeg.c rdswitch.c transupp.c )
50+
add_executable ( rdjpgcom rdjpgcom.c )
51+
add_executable ( wrjpgcom wrjpgcom.c )
52+
target_link_libraries ( cjpeg jpeg )
53+
target_link_libraries ( djpeg jpeg )
54+
target_link_libraries ( jpegtran jpeg )
55+
endif ()
3556

36-
add_executable ( cjpeg cdjpeg.c cjpeg.c rdbmp.c rdgif.c rdppm.c rdrle.c rdtarga.c
37-
rdswitch.c )
38-
add_executable ( djpeg cdjpeg.c djpeg.c wrbmp.c wrgif.c wrppm.c wrrle.c wrtarga.c
39-
rdcolmap.c )
40-
add_executable ( jpegtran jpegtran.c cdjpeg.c rdswitch.c transupp.c )
41-
add_executable ( rdjpgcom rdjpgcom.c )
42-
add_executable ( wrjpgcom wrjpgcom.c )
43-
target_link_libraries ( cjpeg jpeg )
44-
target_link_libraries ( djpeg jpeg )
45-
target_link_libraries ( jpegtran jpeg )
57+
if ( BUILD_EXECUTABLES )
58+
install_executable ( cjpeg djpeg jpegtran rdjpgcom wrjpgcom )
59+
endif ()
4660

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

53-
# tests
54-
enable_testing ( )
55-
macro ( mytest name target args input output )
56-
get_target_property ( _cmdpath ${target} LOCATION )
57-
add_test ( ${name} ${CMAKE_COMMAND} "-DCOMMAND=${_cmdpath} ${args}" "-DINPUT=${input}"
58-
"-DOUTPUT=${output}" -P ${CMAKE_CURRENT_SOURCE_DIR}/jpeg_test.cmake )
59-
endmacro ( )
60-
set ( _src "${CMAKE_CURRENT_SOURCE_DIR}" )
61-
mytest ( t1 djpeg "-dct int -ppm -outfile testout.ppm ${_src}/testorig.jpg" "${_src}/testimg.ppm"
62-
testout.ppm )
63-
mytest ( t2 djpeg "-dct int -bmp -colors 256 -outfile testout.bmp ${_src}/testorig.jpg"
64-
${_src}/testimg.bmp testout.bmp )
65-
mytest ( t3 cjpeg "-dct int -outfile testout.jpg ${_src}/testimg.ppm" ${_src}/testimg.jpg
66-
testout.jpg )
67-
mytest ( t4 djpeg "-dct int -ppm -outfile testoutp.ppm ${_src}/testprog.jpg" ${_src}/testimg.ppm
68-
testoutp.ppm )
69-
mytest ( t5 cjpeg "-dct int -progressive -opt -outfile testoutp.jpg ${_src}/testimg.ppm"
70-
${_src}/testimgp.jpg testoutp.jpg )
71-
mytest ( t6 jpegtran "-outfile testoutt.jpg ${_src}/testprog.jpg" ${_src}/testorig.jpg
72-
testoutt.jpg )
66+
if ( BUILD_TESTS )
67+
# tests
68+
enable_testing ( )
69+
macro ( mytest name target args input output )
70+
get_target_property ( _cmdpath ${target} LOCATION )
71+
add_test ( ${name} ${CMAKE_COMMAND} "-DCOMMAND=${_cmdpath} ${args}" "-DINPUT=${input}"
72+
"-DOUTPUT=${output}" -P ${CMAKE_CURRENT_SOURCE_DIR}/jpeg_test.cmake )
73+
endmacro ( )
74+
set ( _src "${CMAKE_CURRENT_SOURCE_DIR}" )
75+
mytest ( t1 djpeg "-dct int -ppm -outfile testout.ppm ${_src}/testorig.jpg" "${_src}/testimg.ppm"
76+
testout.ppm )
77+
mytest ( t2 djpeg "-dct int -bmp -colors 256 -outfile testout.bmp ${_src}/testorig.jpg"
78+
${_src}/testimg.bmp testout.bmp )
79+
mytest ( t3 cjpeg "-dct int -outfile testout.jpg ${_src}/testimg.ppm" ${_src}/testimg.jpg
80+
testout.jpg )
81+
mytest ( t4 djpeg "-dct int -ppm -outfile testoutp.ppm ${_src}/testprog.jpg" ${_src}/testimg.ppm
82+
testoutp.ppm )
83+
mytest ( t5 cjpeg "-dct int -progressive -opt -outfile testoutp.jpg ${_src}/testimg.ppm"
84+
${_src}/testimgp.jpg testoutp.jpg )
85+
mytest ( t6 jpegtran "-outfile testoutt.jpg ${_src}/testprog.jpg" ${_src}/testorig.jpg
86+
testoutt.jpg )
87+
endif ()

0 commit comments

Comments
 (0)