summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt115
1 files changed, 77 insertions, 38 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 86038d5..873cc7b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,7 @@ cmake_policy(SET CMP0037 NEW)
project(LibVNCServer)
include(CheckFunctionExists)
+include(CheckSymbolExists)
include(CheckIncludeFile)
include(CheckTypeSize)
include(TestBigEndian)
@@ -34,6 +35,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CM
# all the build configuration switches
option(BUILD_SHARED_LIBS "Build shared libraries" ${UNIX})
option(WITH_ZLIB "Search for the zlib compression library to support additional encodings" ON)
+option(WITH_LZO "Search for the LZO compression library to omit internal miniLZO implementation" ON)
option(WITH_JPEG "Search for the libjpeg compression library to support additional encodings" ON)
option(WITH_PNG "Search for the PNG compression library to support additional encodings" ON)
option(WITH_SDL "Search for the Simple Direct Media Layer library to build an example SDL vnc client" ON)
@@ -55,42 +57,47 @@ if(WITH_ZLIB)
find_package(ZLIB)
endif(WITH_ZLIB)
+if(WITH_LZO)
+ find_package(LZO)
+endif()
if(WITH_JPEG)
find_package(JPEG)
- # Check whether the version of libjpeg we found was libjpeg-turbo and print a
- # warning if not.
- 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(WARNING "*** The libjpeg library you are building against is not libjpeg-turbo. Performance will be reduced. You can obtain libjpeg-turbo from: https://sourceforge.net/projects/libjpeg-turbo/files/ ***")
- endif()
+ if(JPEG_FOUND)
+ # Check whether the version of libjpeg we found was libjpeg-turbo and print a
+ # warning if not.
+ 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(WARNING "*** The libjpeg library you are building against is not libjpeg-turbo. Performance will be reduced. You can obtain libjpeg-turbo from: https://sourceforge.net/projects/libjpeg-turbo/files/ ***")
+ endif()
+ endif(JPEG_FOUND)
endif(WITH_JPEG)
@@ -155,6 +162,11 @@ check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("stddef.h" HAVE_STDDEF_H)
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
+# error out if required headers not found
+if(NOT HAVE_STDINT_H)
+ message(FATAL_ERROR "Could NOT find required header stdint.h")
+endif()
+
check_function_exists(gettimeofday LIBVNCSERVER_HAVE_GETTIMEOFDAY)
check_function_exists(vfork LIBVNCSERVER_HAVE_VFORK)
check_function_exists(vprintf LIBVNCSERVER_HAVE_VPRINTF)
@@ -175,6 +187,9 @@ check_function_exists(strdup LIBVNCSERVER_HAVE_STRDUP)
check_function_exists(strerror LIBVNCSERVER_HAVE_STRERROR)
check_function_exists(strstr LIBVNCSERVER_HAVE_STRSTR)
+check_symbol_exists(htobe64 "endian.h" LIBVNCSERVER_HAVE_HTOBE64)
+check_symbol_exists(OSSwapHostToBigInt64 "libkern/OSByteOrder.h" LIBVNCSERVER_HAVE_OSSWAPHOSTTOBIGINT64)
+
if(Threads_FOUND)
set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} ${CMAKE_THREAD_LIBS_INIT})
endif(Threads_FOUND)
@@ -183,8 +198,15 @@ if(ZLIB_FOUND)
else()
unset(ZLIB_LIBRARIES) # would otherwise contain -NOTFOUND, confusing target_link_libraries()
endif(ZLIB_FOUND)
+if(LZO_FOUND)
+ set(LIBVNCSERVER_HAVE_LZO 1)
+else()
+ unset(LZO_LIBRARIES CACHE) # would otherwise contain -NOTFOUND, confusing target_link_libraries()
+endif()
if(JPEG_FOUND)
set(LIBVNCSERVER_HAVE_LIBJPEG 1)
+else()
+ unset(JPEG_LIBRARIES) # would otherwise confuse target_link_libraries()
endif(JPEG_FOUND)
if(PNG_FOUND)
set(LIBVNCSERVER_HAVE_LIBPNG 1)
@@ -216,9 +238,9 @@ if(LIBVNCSERVER_HAVE_SYS_UIO_H)
endif(LIBVNCSERVER_HAVE_SYS_UIO_H)
-if(WITH_WEBSOCKETS AND LIBVNCSERVER_HAVE_CRYPTO)
+if(WITH_WEBSOCKETS AND LIBVNCSERVER_HAVE_CRYPTO AND (LIBVNCSERVER_HAVE_HTOBE64 OR LIBVNCSERVER_HAVE_OSSWAPHOSTTOBIGINT64))
set(LIBVNCSERVER_WITH_WEBSOCKETS 1)
-endif(WITH_WEBSOCKETS AND LIBVNCSERVER_HAVE_CRYPTO)
+endif()
if(WITH_GCRYPT AND LIBGCRYPT_LIBRARIES)
message(STATUS "Found libgcrypt: ${LIBGCRYPT_LIBRARIES}")
@@ -309,7 +331,6 @@ set(LIBVNCSERVER_SOURCES
${COMMON_DIR}/d3des.c
${COMMON_DIR}/vncauth.c
${LIBVNCSERVER_DIR}/cargs.c
- ${COMMON_DIR}/minilzo.c
${LIBVNCSERVER_DIR}/ultra.c
${LIBVNCSERVER_DIR}/scale.c
)
@@ -320,7 +341,6 @@ set(LIBVNCCLIENT_SOURCES
${LIBVNCCLIENT_DIR}/rfbproto.c
${LIBVNCCLIENT_DIR}/sockets.c
${LIBVNCCLIENT_DIR}/vncviewer.c
- ${COMMON_DIR}/minilzo.c
)
if(JPEG_FOUND)
@@ -380,6 +400,20 @@ if(ZLIB_FOUND)
)
endif(ZLIB_FOUND)
+if(LZO_FOUND)
+ add_definitions(-DLIBVNCSERVER_HAVE_LZO)
+ include_directories(${LZO_INCLUDE_DIR})
+else()
+ set(LIBVNCSERVER_SOURCES
+ ${LIBVNCSERVER_SOURCES}
+ ${COMMON_DIR}/minilzo.c
+ )
+ set(LIBVNCCLIENT_SOURCES
+ ${LIBVNCCLIENT_SOURCES}
+ ${COMMON_DIR}/minilzo.c
+ )
+endif()
+
if(JPEG_FOUND)
add_definitions(-DLIBVNCSERVER_HAVE_LIBJPEG)
include_directories(${JPEG_INCLUDE_DIR})
@@ -426,6 +460,7 @@ endif(WIN32)
target_link_libraries(vncclient
${ADDITIONAL_LIBS}
${ZLIB_LIBRARIES}
+ ${LZO_LIBRARIES}
${JPEG_LIBRARIES}
${GNUTLS_LIBRARIES}
${OPENSSL_LIBRARIES}
@@ -433,6 +468,7 @@ target_link_libraries(vncclient
target_link_libraries(vncserver
${ADDITIONAL_LIBS}
${ZLIB_LIBRARIES}
+ ${LZO_LIBRARIES}
${JPEG_LIBRARIES}
${PNG_LIBRARIES}
${CRYPTO_LIBRARIES}
@@ -454,6 +490,7 @@ set(LIBVNCSERVER_EXAMPLES
pnmshow
pnmshow24
regiontest
+ repeater
rotate
simple
simple15
@@ -617,7 +654,9 @@ function(get_link_libraries OUT TARGET)
endforeach()
list(REMOVE_DUPLICATES RESULT)
string(CONCAT RESULT ${RESULT}) # back to string
- string(REPLACE "-l" " -l" RESULT ${RESULT}) # re-add separators
+ if(RESULT)
+ string(REPLACE "-l" " -l" RESULT ${RESULT}) # re-add separators
+ endif(RESULT)
set(${OUT} ${RESULT} PARENT_SCOPE)
endfunction()