-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
176 lines (144 loc) · 5.55 KB
/
CMakeLists.txt
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
cmake_minimum_required(VERSION 2.6)
include(CheckCSourceCompiles)
include(CheckCSourceRuns)
project(vncbenchtools)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
if(CMAKE_COMPILER_IS_GNUCC)
# Use the maximum optimization level for release builds
foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
if(${var} MATCHES "-O2")
string(REGEX REPLACE "-O2" "-O3" ${var} "${${var}}")
endif()
endforeach()
endif()
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
set(EFFECTIVE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
message(STATUS "Compiler flags = ${EFFECTIVE_C_FLAGS}")
message(STATUS "Linker flags = ${CMAKE_EXE_LINKER_FLAGS}")
set(ENCODER_OPTIONS
"tight-1.1, tight-1.3.9, turbo-0.4, turbo-0.5, turbo-1.0, turbo-1.1, turbo-h264, tiger-1.1, tiger-1.2, tiger-1.4, h264")
set(ENCODER "" CACHE STRING
"Which Tight/Turbo/Tiger encoder to use (one of ${ENCODER_OPTIONS})")
set(DECODER_OPTIONS
"tight-1.3.9, turbo-0.4, turbo-0.5, turbo-1.0, tiger-1.1, tiger-1.2, tiger-1.4")
set(DECODER "" CACHE STRING
"Which Tight/Turbo/Tiger decoder to use (one of ${DECODER_OPTIONS})")
if(NOT ENCODER)
message(FATAL_ERROR "ENCODER must be set to one of ${ENCODER_OPTIONS}")
endif()
if(NOT DECODER)
message(FATAL_ERROR "DECODER must be set to one of ${DECODER_OPTIONS}")
endif()
message(STATUS "Using ${ENCODER} encoder")
message(STATUS "Using ${DECODER} decoder")
math(EXPR BITS "${CMAKE_SIZEOF_VOID_P} * 8")
message(STATUS "${BITS}-bit build")
set(SOURCES compare-encodings.c misc.c hextile.c zlib.c zrle.c
zrleoutstream.c zrlepalettehelper.c translate.c)
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
set(LINK_LIBRARIES z)
if(ENCODER MATCHES tig* OR DECODER MATCHES tig*)
# Check for libjpeg
find_package(JPEG REQUIRED)
if(ENCODER MATCHES tiger-* OR DECODER MATCHES tiger-*)
# Warn if it doesn't seem to be the accelerated libjpeg that's found
set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES})
set(CMAKE_REQUIRED_FLAGS -I${JPEG_INCLUDE_DIR})
set(JPEG_TEST_SOURCE "\n
#include <stdio.h>\n
#include <jpeglib.h>\n
int main(void) {\n
struct jpeg_compress_struct cinfo;\n
struct jpeg_error_mgr jerr;\n
cinfo.err=jpeg_std_error(&jerr);\n
jpeg_create_compress(&cinfo);\n
cinfo.input_components = 3;\n
jpeg_set_defaults(&cinfo);\n
cinfo.in_color_space = JCS_EXT_RGB;\n
jpeg_default_colorspace(&cinfo);\n
return 0;\n
}")
if(CMAKE_CROSSCOMPILING)
check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
else()
check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
endif()
set(CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_FLAGS)
set(CMAKE_REQUIRED_DEFINITIONS)
if(NOT FOUND_LIBJPEG_TURBO)
message(STATUS "WARNING: You are not using libjpeg-turbo. Performance will suffer.")
endif()
endif()
set(LINK_LIBRARIES ${LINK_LIBRARIES} ${JPEG_LIBRARIES})
include_directories(${JPEG_INCLUDE_DIR})
endif()
if(ENCODER MATCHES turbo-1.1)
add_definitions(-DICE_SUPPORTED)
endif()
if(ENCODER MATCHES turbo-* OR ENCODER MATCHES h264 OR DECODER MATCHES turbo-*)
include(cmakescripts/FindTurboJPEG.cmake)
set(LINK_LIBRARIES ${LINK_LIBRARIES} ${TJPEG_LIBRARY})
include_directories(${TJPEG_INCLUDE_DIR})
endif()
if(ENCODER MATCHES turbo-1.* OR DECODER MATCHES turbo-1.*)
set(LINK_LIBRARIES ${LINK_LIBRARIES} pthread)
endif()
if(ENCODER MATCHES h264)
if(BITS EQUAL 64)
set(DEFAULT_X264_DIR /opt/x264/linux64)
else()
set(DEFAULT_X264_DIR /opt/x264/linux)
endif()
set(X264_DIR ${DEFAULT_X264_DIR} CACHE PATH
"Directory in which libx264 is installed (default: ${DEFAULT_X264_DIR})")
message(STATUS "X264_DIR = ${X264_DIR}")
include_directories(${X264_DIR}/include)
if(ENCODER STREQUAL h264)
include_directories(${CMAKE_SOURCE_DIR}/flv)
add_definitions(-DH264)
set(SOURCES ${SOURCES} flv/flv.c flv/flv_bytestream.c)
endif()
set(LINK_LIBRARIES ${LINK_LIBRARIES} ${X264_DIR}/lib/libx264.a m)
endif()
if(ENCODER MATCHES tiger-*)
file(REMOVE tiger.cxx)
add_custom_command(OUTPUT tiger.cxx
COMMAND ln -fs ${CMAKE_SOURCE_DIR}/${ENCODER}.cxx tiger.cxx)
add_definitions(-DHAVE_VSNPRINTF -DHAVE_SNPRINTF)
include_directories(${CMAKE_SOURCE_DIR}/${ENCODER})
set(SOURCES ${SOURCES} ${CMAKE_BINARY_DIR}/tiger.cxx)
add_subdirectory(${ENCODER})
set(LINK_LIBRARIES tigervnc ${LINK_LIBRARIES})
else()
file(REMOVE tight.c)
add_custom_command(OUTPUT tight.c
COMMAND ln -fs ${CMAKE_SOURCE_DIR}/${ENCODER}.c tight.c)
set(SOURCES ${SOURCES} ${CMAKE_BINARY_DIR}/tight.c)
endif()
if(DECODER MATCHES tiger-*)
file(REMOVE tigerd.cxx)
add_custom_command(OUTPUT tigerd.cxx
COMMAND ln -fs ${CMAKE_SOURCE_DIR}/${DECODER}d.cxx tigerd.cxx)
add_definitions(-DTIGERD -DHAVE_VSNPRINTF -DHAVE_SNPRINTF)
include_directories(${CMAKE_SOURCE_DIR}/${DECODER})
set_source_files_properties(compare-encodings.c PROPERTIES
OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/tigerd.cxx
LANGUAGE CXX)
if(NOT DECODER STREQUAL ENCODER)
add_subdirectory(${DECODER})
endif()
set(LINK_LIBRARIES tigervnc ${LINK_LIBRARIES})
else()
file(REMOVE tightd.c)
add_custom_command(OUTPUT tightd.c
COMMAND ln -fs ${CMAKE_SOURCE_DIR}/${DECODER}d.c tightd.c)
set(DEPENDENCIES tightd.c)
set_source_files_properties(compare-encodings.c PROPERTIES
OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/tightd.c)
endif()
add_executable(compare-encodings ${SOURCES})
target_link_libraries(compare-encodings ${LINK_LIBRARIES})