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

Commit 9cc7ade

Browse files
committed
cmake: replace build, update dist.cmake, add tests
1 parent e97f161 commit 9cc7ade

File tree

5 files changed

+334
-110
lines changed

5 files changed

+334
-110
lines changed

CMakeLists.txt

+114-98
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,118 @@
1-
2-
PROJECT(libjpeg C)
3-
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
4-
INCLUDE(dist.cmake)
5-
6-
# generating config.h file:
7-
MESSAGE("Configure: JPEG - generating jconfig.h:")
8-
INCLUDE(CheckIncludeFile)
9-
10-
CHECK_INCLUDE_FILE(stddef.h HAVE_STDDEF_H)
11-
CHECK_INCLUDE_FILE(stdlib.h HAVE_STDLIB_H)
12-
13-
IF(WIN32)
14-
# This is for jpeg binaries and is #defined in jconfig.h
15-
SET(TWO_FILE_COMMANDLINE true)
16-
ENDIF()
17-
18-
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/jconfig.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/jconfig.h)
19-
20-
MESSAGE("Configure: JPEG - done.")
21-
# end of generating jconfig.h file:
22-
23-
24-
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
25-
26-
IF(MSVC)
27-
SET(CMAKE_DEBUG_POSTFIX "D")
28-
ENDIF()
29-
30-
SET(JPEG_PUBLIC_HDRS
31-
jerror.h
32-
jmorecfg.h
33-
jpeglib.h
34-
${CMAKE_CURRENT_BINARY_DIR}/jconfig.h
35-
)
36-
SET(JPEG_PRIVATE_HDRS
37-
cderror.h
38-
cdjpeg.h
39-
jdct.h
40-
jinclude.h
41-
jmemsys.h
42-
jpegint.h
43-
jversion.h
44-
transupp.h
1+
# Copyright (C) 2007-2012 LuaDist.
2+
# Created by Peter Kapec, David Manura
3+
# Redistribution and use of this file is allowed according to the terms of the MIT license.
4+
# For details see the COPYRIGHT file distributed with LuaDist.
5+
# Please note that the package source code is licensed under its own license.
6+
7+
project(libjpeg C)
8+
cmake_minimum_required(VERSION 2.6)
9+
include(cmake/dist.cmake)
10+
11+
include(CheckIncludeFile)
12+
check_include_file(stddef.h HAVE_STDDEF_H)
13+
check_include_file(stdlib.h HAVE_STDLIB_H)
14+
if(WIN32 AND NOT CYGWIN) #improve? see jconfig.*
15+
set(TWO_FILE_COMMANDLINE true) # jconfig.h
16+
endif()
17+
configure_file(jconfig.h.cmake jconfig.h)
18+
19+
include_directories(${CMAKE_CURRENT_BINARY_DIR}) # jconfig.h
20+
21+
set(HEADERS
22+
jerror.h
23+
jmorecfg.h
24+
jpeglib.h
25+
${CMAKE_CURRENT_BINARY_DIR}/jconfig.h
4526
)
4627

47-
# memmgr back ends: compile only one of these into a working library
48-
# (For now, let's use the mode that requires the image fit into memory.
49-
# This is the recommended mode for Win32 anyway.)
50-
SET(JPEG_systemdependent_SRCS jmemnobs.c)
51-
52-
SET(JPEG_SRCS
53-
jaricom.c jcapimin.c jcapistd.c jcarith.c jccoefct.c jccolor.c
54-
jcdctmgr.c jchuff.c jcinit.c jcmainct.c jcmarker.c jcmaster.c
55-
jcomapi.c jcparam.c jcprepct.c jcsample.c jctrans.c jdapimin.c
56-
jdapistd.c jdarith.c jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c
57-
jddctmgr.c jdhuff.c jdinput.c jdmainct.c jdmarker.c jdmaster.c
58-
jdmerge.c jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c
59-
jfdctfst.c jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c
60-
jquant2.c jutils.c jmemmgr.c)
61-
62-
ADD_LIBRARY(jpeg SHARED ${JPEG_systemdependent_SRCS} ${JPEG_SRCS} ${JPEG_PUBLIC_HDRS} ${JPEG_PRIVATE_HDRS})
63-
#~ SET_TARGET_PROPERTIES(jpeg PROPERTIES VERSION 7.0.0)
64-
#~ SET_TARGET_PROPERTIES(jpeg PROPERTIES SOVERSION 7)
65-
66-
if(WIN32 AND BUILD_SHARED_LIBS)
67-
# We add JPEG_DLL only to building of this target because bad things
68-
# happen if it's enabled on all binary targets owing to the macros
69-
# defined in jmorecfg.h
70-
SET_TARGET_PROPERTIES(jpeg PROPERTIES COMPILE_FLAGS -DJPEG_DLL)
71-
ENDIF()
72-
73-
74-
#~ SET(JPEG_MANPAGES cjpeg.1 djpeg.1 jpegtran.1 rdjpgcom.1 wrjpgcom.1)
75-
76-
ADD_EXECUTABLE(cjpeg cjpeg.c rdppm.c rdgif.c rdtarga.c rdrle.c rdbmp.c rdswitch.c cdjpeg.c)
77-
TARGET_LINK_LIBRARIES(cjpeg jpeg)
78-
79-
ADD_EXECUTABLE(djpeg djpeg.c wrppm.c wrgif.c wrtarga.c wrrle.c wrbmp.c rdcolmap.c cdjpeg.c)
80-
TARGET_LINK_LIBRARIES(djpeg jpeg)
81-
82-
ADD_EXECUTABLE(jpegtran jpegtran.c rdswitch.c cdjpeg.c transupp.c)
83-
TARGET_LINK_LIBRARIES(jpegtran jpeg)
84-
85-
ADD_EXECUTABLE(rdjpgcom rdjpgcom.c)
86-
ADD_EXECUTABLE(wrjpgcom wrjpgcom.c)
87-
28+
set(SRC
29+
jmemnobs.c
30+
jaricom.c
31+
jcapimin.c
32+
jcapistd.c
33+
jcarith.c
34+
jccoefct.c
35+
jccolor.c
36+
jcdctmgr.c
37+
jchuff.c
38+
jcinit.c
39+
jcmainct.c
40+
jcmarker.c
41+
jcmaster.c
42+
jcomapi.c
43+
jcparam.c
44+
jcprepct.c
45+
jcsample.c
46+
jctrans.c
47+
jdapimin.c
48+
jdapistd.c
49+
jdarith.c
50+
jdatadst.c
51+
jdatasrc.c
52+
jdcoefct.c
53+
jdcolor.c
54+
jddctmgr.c
55+
jdhuff.c
56+
jdinput.c
57+
jdmainct.c
58+
jdmarker.c
59+
jdmaster.c
60+
jdmerge.c
61+
jdpostct.c
62+
jdsample.c
63+
jdtrans.c
64+
jerror.c
65+
jfdctflt.c
66+
jfdctfst.c
67+
jfdctint.c
68+
jidctflt.c
69+
jidctfst.c
70+
jidctint.c
71+
jquant1.c
72+
jquant2.c
73+
jutils.c
74+
jmemmgr.c
75+
cderror.h
76+
cdjpeg.h
77+
jdct.h
78+
jinclude.h
79+
jmemsys.h
80+
jpegint.h
81+
jversion.h
82+
transupp.h
83+
)
8884

89-
INSTALL(TARGETS jpeg RUNTIME DESTINATION ${INSTALL_BIN} LIBRARY DESTINATION ${INSTALL_LIB} ARCHIVE DESTINATION ${INSTALL_LIB})
90-
INSTALL(FILES ${JPEG_PUBLIC_HDRS} DESTINATION ${INSTALL_INC})
91-
INSTALL(TARGETS cjpeg djpeg jpegtran rdjpgcom wrjpgcom DESTINATION ${INSTALL_BIN})
85+
add_library(jpeg SHARED ${SRC} ${HEADERS})
86+
87+
add_executable(cjpeg cdjpeg.c cjpeg.c rdbmp.c rdgif.c rdppm.c rdrle.c rdtarga.c rdswitch.c)
88+
add_executable(djpeg cdjpeg.c djpeg.c wrbmp.c wrgif.c wrppm.c wrrle.c wrtarga.c rdcolmap.c)
89+
add_executable(jpegtran jpegtran.c cdjpeg.c rdswitch.c transupp.c)
90+
add_executable(rdjpgcom rdjpgcom.c)
91+
add_executable(wrjpgcom wrjpgcom.c)
92+
target_link_libraries(cjpeg jpeg)
93+
target_link_libraries(djpeg jpeg)
94+
target_link_libraries(jpegtran jpeg)
95+
96+
install_executable(cjpeg djpeg jpegtran rdjpgcom wrjpgcom)
97+
install_library(jpeg)
98+
install_header(${JPEG_HEADERS})
99+
install_doc(
100+
README install.txt usage.txt wizard.txt example.c libjpeg.txt
101+
structure.txt coderules.txt filelist.txt change.log
102+
)
92103

93-
INSTALL(FILES
94-
change.log
95-
coderules.txt
96-
filelist.txt
97-
libjpeg.txt
98-
structure.txt
99-
usage.txt
100-
wizard.txt
101-
README
102-
DESTINATION ${INSTALL_DOC})
104+
# tests
105+
enable_testing()
106+
macro(mytest name target args input output)
107+
get_target_property ( _cmdpath ${target} LOCATION )
108+
add_test(${name} ${CMAKE_COMMAND}
109+
"-DCOMMAND=${_cmdpath} ${args}" "-DINPUT=${input}" "-DOUTPUT=${output}"
110+
-P ${CMAKE_CURRENT_SOURCE_DIR}/jpeg_test.cmake)
111+
endmacro()
112+
set(_src "${CMAKE_CURRENT_SOURCE_DIR}")
113+
mytest(t1 djpeg "-dct int -ppm -outfile testout.ppm ${_src}/testorig.jpg" "${_src}/testimg.ppm" testout.ppm)
114+
mytest(t2 djpeg "-dct int -bmp -colors 256 -outfile testout.bmp ${_src}/testorig.jpg" ${_src}/testimg.bmp testout.bmp)
115+
mytest(t3 cjpeg "-dct int -outfile testout.jpg ${_src}/testimg.ppm" ${_src}/testimg.jpg testout.jpg)
116+
mytest(t4 djpeg "-dct int -ppm -outfile testoutp.ppm ${_src}/testprog.jpg" ${_src}/testimg.ppm testoutp.ppm)
117+
mytest(t5 cjpeg "-dct int -progressive -opt -outfile testoutp.jpg ${_src}/testimg.ppm" ${_src}/testimgp.jpg testoutp.jpg)
118+
mytest(t6 jpegtran "-outfile testoutt.jpg ${_src}/testprog.jpg" ${_src}/testorig.jpg testoutt.jpg)

0 commit comments

Comments
 (0)