1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -203,6 +203,9 @@
boolean_number(WITH_TURBOJPEG)
option(WITH_FUZZ "Build fuzz targets" FALSE)
+option(ENABLE_TESTS "Enable testing targets" FALSE)
+boolean_number(ENABLE_TESTS)
+
macro(report_option var desc)
if(${var})
message(STATUS "${desc} enabled (${var} = ${${var}})")
@@ -646,6 +649,7 @@
LINK_FLAGS "${TJMAPFLAG}${TJMAPFILE}")
endif()
+if(ENABLE_TESTS)
add_executable(tjunittest tjunittest.c tjutil.c md5/md5.c md5/md5hl.c)
target_link_libraries(tjunittest turbojpeg)
@@ -657,6 +661,7 @@
add_executable(tjexample tjexample.c)
target_link_libraries(tjexample turbojpeg)
+endif()
endif()
if(ENABLE_STATIC)
@@ -668,7 +673,7 @@
if(NOT MSVC)
set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg)
endif()
-
+if(ENABLE_TESTS)
add_executable(tjunittest-static tjunittest.c tjutil.c md5/md5.c
md5/md5hl.c)
target_link_libraries(tjunittest-static turbojpeg-static)
@@ -678,6 +683,7 @@
if(UNIX)
target_link_libraries(tjbench-static m)
endif()
+endif()
endif()
endif()
@@ -692,6 +698,7 @@
set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c)
endif()
+if(ENABLE_TESTS)
if(ENABLE_STATIC)
add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c
${CJPEG_BMP_SOURCES})
@@ -711,11 +718,12 @@
add_executable(rdjpgcom rdjpgcom.c)
add_executable(wrjpgcom wrjpgcom.c)
-
+endif()
###############################################################################
# TESTS
###############################################################################
+if(ENABLE_TESTS)
if(WITH_FUZZ)
add_subdirectory(fuzz)
@@ -1431,7 +1439,7 @@
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tjbenchtest)
endif()
endif()
-
+endif()
###############################################################################
# INSTALLATION
@@ -1446,8 +1454,10 @@
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+if(ENABLE_TESTS)
install(TARGETS tjbench
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+endif()
if(NOT CMAKE_VERSION VERSION_LESS "3.1" AND MSVC AND
CMAKE_C_LINKER_SUPPORTS_PDB)
install(FILES "$<TARGET_PDB_FILE:turbojpeg>"
@@ -1464,8 +1474,10 @@
else()
set(DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
+ if(ENABLE_TESTS)
install(PROGRAMS ${DIR}/tjbench-static${EXE}
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME tjbench${EXE})
+ endif()
endif()
endif()
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg.h
@@ -1476,6 +1488,7 @@
install(TARGETS jpeg-static EXPORT ${CMAKE_PROJECT_NAME}Targets
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+if(ENABLE_TESTS)
if(NOT ENABLE_SHARED)
if(MSVC_IDE OR XCODE)
set(DIR "${CMAKE_CURRENT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}")
@@ -1490,8 +1503,11 @@
DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME jpegtran${EXE})
endif()
endif()
+endif()
+if(ENABLE_TESTS)
install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+endif()
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.ijg
${CMAKE_CURRENT_SOURCE_DIR}/README.md ${CMAKE_CURRENT_SOURCE_DIR}/example.txt
|