cmake_minimum_required ( VERSION 2.6 )
project ( LibVNCServer )
include ( CheckFunctionExists )
include ( CheckIncludeFile )
include ( CheckTypeSize )
include ( TestBigEndian )
include ( CheckCSourceCompiles )
include ( CheckCXXSourceCompiles )
include ( CheckCSourceRuns )
set ( PACKAGE_NAME "LibVNCServer" )
set ( FULL_PACKAGE_NAME "LibVNCServer" )
set ( PACKAGE_VERSION "0.9.10" )
set ( VERSION_MAJOR "0" )
set ( VERSION_MINOR "9" )
set ( VERSION_PATCHLEVEL "10" )
set ( PROJECT_BUGREPORT_PATH "http://sourceforge.net/projects/libvncserver" )
set ( CMAKE_C_FLAGS "-O2 -W -Wall -g" )
set ( LIBVNCSERVER_DIR ${ CMAKE_SOURCE_DIR } /libvncserver )
set ( COMMON_DIR ${ CMAKE_SOURCE_DIR } /common )
set ( LIBVNCCLIENT_DIR ${ CMAKE_SOURCE_DIR } /libvncclient )
set ( LIBVNCSRVTEST_DIR ${ CMAKE_SOURCE_DIR } /examples )
set ( LIBVNCCLITEST_DIR ${ CMAKE_SOURCE_DIR } /client_examples )
include_directories ( ${ CMAKE_SOURCE_DIR } ${ CMAKE_BINARY_DIR } ${ CMAKE_SOURCE_DIR } /libvncserver ${ CMAKE_SOURCE_DIR } /common )
find_package ( ZLIB )
find_package ( JPEG )
find_package ( PNG )
find_package ( SDL )
find_package ( GnuTLS )
find_package ( Threads )
find_package ( X11 )
find_package ( OpenSSL )
find_library ( LIBGCRYPT_LIBRARIES gcrypt )
# 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
i n t main ( void ) { \ n
s t r u c t j p e g _ c o m p r e s s _ s t r u c t c i n f o ; \ n
s t r u c t j p e g _ e r r o r _ m g r j e r r ; \ n
c i n f o . e r r = jpeg_std_error ( &jerr ) ; \ n
jpeg_create_compress ( &cinfo ) ; \ n
c i n f o . i n p u t _ c o m p o n e n t s = 3 ; \ n
jpeg_set_defaults ( &cinfo ) ; \ n
c i n f o . i n _ c o l o r _ s p a c e = J C S _ E X T _ R G B ; \ n
jpeg_default_colorspace ( &cinfo ) ; \ n
r e t u r n 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 ( )
# On systems such as GNU/Linux with glibc, __b64_ntop is defined in a
# separate library, libresolv. On some others, such as FreeBSD, it is
# part of libc itself. We first check if __b64_ntop is found without
# additional libraries, and then try looking for it with libresolv if
# the first test fails.
check_function_exists ( __b64_ntop HAVE_B64_IN_LIBC )
if ( NOT HAVE_B64_IN_LIBC )
set ( CMAKE_REQUIRED_LIBRARIES resolv )
check_function_exists ( __b64_ntop HAVE_B64_IN_LIBRESOLV )
set ( CMAKE_REQUIRED_LIBRARIES )
if ( HAVE_B64_IN_LIBRESOLV )
set ( RESOLV_LIB "resolv" )
endif ( HAVE_B64_IN_LIBRESOLV )
endif ( NOT HAVE_B64_IN_LIBC )
if ( Threads_FOUND )
option ( TIGHTVNC_FILETRANSFER "Enable filetransfer" ON )
endif ( Threads_FOUND )
if ( ZLIB_FOUND )
set ( LIBVNCSERVER_HAVE_LIBZ 1 )
endif ( ZLIB_FOUND )
if ( JPEG_FOUND )
set ( LIBVNCSERVER_HAVE_LIBJPEG 1 )
endif ( JPEG_FOUND )
if ( PNG_FOUND )
set ( LIBVNCSERVER_HAVE_LIBPNG 1 )
endif ( PNG_FOUND )
option ( LIBVNCSERVER_ALLOW24BPP "Allow 24 bpp" ON )
if ( GNUTLS_FOUND )
set ( LIBVNCSERVER_WITH_CLIENT_TLS 1 )
option ( LIBVNCSERVER_WITH_WEBSOCKETS "Build with websockets support (gnutls)" ON )
set ( WEBSOCKET_LIBRARIES ${ RESOLV_LIB } ${ GNUTLS_LIBRARIES } )
set ( WSSRCS ${ LIBVNCSERVER_DIR } /rfbssl_gnutls ${ LIBVNCSERVER_DIR } /rfbcrypto_gnutls )
elseif ( OPENSSL_FOUND )
option ( LIBVNCSERVER_WITH_WEBSOCKETS "Build with websockets support (openssl)" ON )
set ( WEBSOCKET_LIBRARIES ${ RESOLV_LIB } ${ OPENSSL_LIBRARIES } )
set ( WSSRCS ${ LIBVNCSERVER_DIR } /rfbssl_openssl ${ LIBVNCSERVER_DIR } /rfbcrypto_openssl )
else ( )
option ( LIBVNCSERVER_WITH_WEBSOCKETS "Build with websockets support (no ssl)" ON )
set ( WEBSOCKET_LIBRARIES ${ RESOLV_LIB } )
set ( WSSRCS ${ LIBVNCSERVER_DIR } /rfbssl_none.c ${ LIBVNCSERVER_DIR } /rfbcrypto_included.c ${ COMMON_DIR } /md5.c ${ COMMON_DIR } /sha1.c )
endif ( )
if ( LIBGCRYPT_LIBRARIES )
message ( STATUS "Found libgcrypt: ${LIBGCRYPT_LIBRARIES}" )
set ( LIBVNCSERVER_WITH_CLIENT_GCRYPT 1 )
set ( ADDITIONAL_LIBS ${ ADDITIONAL_LIBS } ${ LIBGCRYPT_LIBRARIES } )
endif ( LIBGCRYPT_LIBRARIES )
check_include_file ( "endian.h" LIBVNCSERVER_HAVE_ENDIAN_H )
check_include_file ( "fcntl.h" LIBVNCSERVER_HAVE_FCNTL_H )
check_include_file ( "netinet/in.h" LIBVNCSERVER_HAVE_NETINET_IN_H )
check_include_file ( "sys/endian.h" LIBVNCSERVER_HAVE_SYS_ENDIAN_H )
check_include_file ( "sys/socket.h" LIBVNCSERVER_HAVE_SYS_SOCKET_H )
check_include_file ( "sys/stat.h" LIBVNCSERVER_HAVE_SYS_STAT_H )
check_include_file ( "sys/time.h" LIBVNCSERVER_HAVE_SYS_TIME_H )
check_include_file ( "sys/types.h" LIBVNCSERVER_HAVE_SYS_TYPES_H )
check_include_file ( "sys/wait.h" LIBVNCSERVER_HAVE_SYS_WAIT_H )
check_include_file ( "unistd.h" LIBVNCSERVER_HAVE_UNISTD_H )
# headers needed for check_type_size()
check_include_file ( "arpa/inet.h" HAVE_ARPA_INET_H )
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 )
check_function_exists ( gettimeofday LIBVNCSERVER_HAVE_GETTIMEOFDAY )
if ( CMAKE_USE_PTHREADS_INIT )
set ( LIBVNCSERVER_HAVE_LIBPTHREAD 1 )
endif ( CMAKE_USE_PTHREADS_INIT )
if ( LIBVNCSERVER_HAVE_SYS_SOCKET_H )
# socklen_t
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h" )
endif ( LIBVNCSERVER_HAVE_SYS_SOCKET_H )
if ( HAVE_ARPA_INET_H )
# in_addr_t
list ( APPEND CMAKE_EXTRA_INCLUDE_FILES "arpa/inet.h" )
endif ( HAVE_ARPA_INET_H )
check_type_size ( pid_t LIBVNCSERVER_PID_T )
check_type_size ( size_t LIBVNCSERVER_SIZE_T )
check_type_size ( socklen_t LIBVNCSERVER_SOCKLEN_T )
check_type_size ( in_addr_t LIBVNCSERVER_IN_ADDR_T )
if ( NOT HAVE_LIBVNCSERVER_IN_ADDR_T )
set ( LIBVNCSERVER_NEED_INADDR_T 1 )
endif ( NOT HAVE_LIBVNCSERVER_IN_ADDR_T )
TEST_BIG_ENDIAN ( LIBVNCSERVER_WORDS_BIGENDIAN )
# TODO:
# LIBVNCSERVER_ENOENT_WORKAROUND
# inline
configure_file ( ${ CMAKE_SOURCE_DIR } /rfb/rfbconfig.h.cmake ${ CMAKE_BINARY_DIR } /rfb/rfbconfig.h )
configure_file ( ${ CMAKE_SOURCE_DIR } /rfb/rfbint.h.cmake ${ CMAKE_BINARY_DIR } /rfb/rfbint.h )
set ( LIBVNCSERVER_SOURCES
$ { L I B V N C S E R V E R _ D I R } / m a i n . c
$ { L I B V N C S E R V E R _ D I R } / r f b s e r v e r . c
$ { L I B V N C S E R V E R _ D I R } / r f b r e g i o n . c
$ { L I B V N C S E R V E R _ D I R } / a u t h . c
$ { L I B V N C S E R V E R _ D I R } / s o c k e t s . c
$ { L I B V N C S E R V E R _ D I R } / s t a t s . c
$ { L I B V N C S E R V E R _ D I R } / c o r r e . c
$ { L I B V N C S E R V E R _ D I R } / h e x t i l e . c
$ { L I B V N C S E R V E R _ D I R } / r r e . c
$ { L I B V N C S E R V E R _ D I R } / t r a n s l a t e . c
$ { L I B V N C S E R V E R _ D I R } / c u t p a s t e . c
$ { L I B V N C S E R V E R _ D I R } / h t t p d . c
$ { L I B V N C S E R V E R _ D I R } / c u r s o r . c
$ { L I B V N C S E R V E R _ D I R } / f o n t . c
$ { L I B V N C S E R V E R _ D I R } / d r a w . c
$ { L I B V N C S E R V E R _ D I R } / s e l b o x . c
$ { C O M M O N _ D I R } / d 3 d e s . c
$ { C O M M O N _ D I R } / v n c a u t h . c
$ { L I B V N C S E R V E R _ D I R } / c a r g s . c
$ { C O M M O N _ D I R } / m i n i l z o . c
$ { L I B V N C S E R V E R _ D I R } / u l t r a . c
$ { L I B V N C S E R V E R _ D I R } / s c a l e . c
)
set ( LIBVNCCLIENT_SOURCES
$ { L I B V N C C L I E N T _ D I R } / c u r s o r . c
$ { L I B V N C C L I E N T _ D I R } / l i s t e n . c
$ { L I B V N C C L I E N T _ D I R } / r f b p r o t o . c
$ { L I B V N C C L I E N T _ D I R } / s o c k e t s . c
$ { L I B V N C C L I E N T _ D I R } / v n c v i e w e r . c
$ { C O M M O N _ D I R } / m i n i l z o . c
)
if ( GNUTLS_FOUND )
set ( LIBVNCCLIENT_SOURCES
$ { L I B V N C C L I E N T _ S O U R C E S }
$ { L I B V N C C L I E N T _ D I R } / t l s _ g n u t l s . c
)
elseif ( OPENSSL_FOUND )
set ( LIBVNCCLIENT_SOURCES
$ { L I B V N C C L I E N T _ S O U R C E S }
$ { L I B V N C C L I E N T _ D I R } / t l s _ o p e n s s l . c
)
else ( )
set ( LIBVNCCLIENT_SOURCES
$ { L I B V N C C L I E N T _ S O U R C E S }
$ { L I B V N C C L I E N T _ D I R } / t l s _ n o n e . c
)
endif ( )
if ( ZLIB_FOUND )
add_definitions ( -DLIBVNCSERVER_HAVE_LIBZ )
include_directories ( ${ ZLIB_INCLUDE_DIR } )
set ( LIBVNCSERVER_SOURCES
$ { L I B V N C S E R V E R _ S O U R C E S }
$ { L I B V N C S E R V E R _ D I R } / z l i b . c
$ { L I B V N C S E R V E R _ D I R } / z r l e . c
$ { L I B V N C S E R V E R _ D I R } / z r l e o u t s t r e a m . c
$ { L I B V N C S E R V E R _ D I R } / z r l e p a l e t t e h e l p e r . c
)
endif ( ZLIB_FOUND )
if ( JPEG_FOUND )
add_definitions ( -DLIBVNCSERVER_HAVE_LIBJPEG )
include_directories ( ${ JPEG_INCLUDE_DIR } )
set ( TIGHT_C ${ LIBVNCSERVER_DIR } /tight.c ${ COMMON_DIR } /turbojpeg.c )
endif ( JPEG_FOUND )
if ( PNG_FOUND )
add_definitions ( -DLIBVNCSERVER_HAVE_LIBPNG )
include_directories ( ${ PNG_INCLUDE_DIR } )
set ( TIGHT_C ${ LIBVNCSERVER_DIR } /tight.c ${ COMMON_DIR } /turbojpeg.c )
endif ( PNG_FOUND )
set ( LIBVNCSERVER_SOURCES
$ { L I B V N C S E R V E R _ S O U R C E S }
$ { T I G H T _ C }
)
if ( TIGHTVNC_FILETRANSFER )
set ( LIBVNCSERVER_SOURCES
$ { L I B V N C S E R V E R _ S O U R C E S }
$ { L I B V N C S E R V E R _ D I R } / t i g h t v n c - f i l e t r a n s f e r / r f b t i g h t s e r v e r . c
$ { L I B V N C S E R V E R _ D I R } / t i g h t v n c - f i l e t r a n s f e r / h a n d l e f i l e t r a n s f e r r e q u e s t . c
$ { L I B V N C S E R V E R _ D I R } / t i g h t v n c - f i l e t r a n s f e r / f i l e t r a n s f e r m s g . c
$ { L I B V N C S E R V E R _ D I R } / t i g h t v n c - f i l e t r a n s f e r / f i l e l i s t i n f o . c
)
endif ( TIGHTVNC_FILETRANSFER )
if ( LIBVNCSERVER_WITH_WEBSOCKETS )
add_definitions ( -DLIBVNCSERVER_WITH_WEBSOCKETS )
set ( LIBVNCSERVER_SOURCES
$ { L I B V N C S E R V E R _ S O U R C E S }
$ { L I B V N C S E R V E R _ D I R } / w e b s o c k e t s . c
$ { W S S R C S }
)
endif ( LIBVNCSERVER_WITH_WEBSOCKETS )
add_library ( vncclient SHARED ${ LIBVNCCLIENT_SOURCES } )
add_library ( vncserver SHARED ${ LIBVNCSERVER_SOURCES } )
if ( WIN32 )
set ( ADDITIONAL_LIBS ${ ADDITIONAL_LIBS } ws2_32 )
endif ( WIN32 )
target_link_libraries ( vncclient
$ { A D D I T I O N A L _ L I B S }
$ { Z L I B _ L I B R A R I E S }
$ { J P E G _ L I B R A R I E S }
)
target_link_libraries ( vncserver
$ { A D D I T I O N A L _ L I B S }
$ { Z L I B _ L I B R A R I E S }
$ { J P E G _ L I B R A R I E S }
$ { P N G _ L I B R A R I E S }
$ { W E B S O C K E T _ L I B R A R I E S }
)
SET_TARGET_PROPERTIES ( vncclient vncserver
P R O P E R T I E S S O V E R S I O N " 0 . 0 . 0 "
)
# tests
set ( LIBVNCSERVER_TESTS
b a c k c h a n n e l
c a m e r a
c o l o u r m a p t e s t
e x a m p l e
f o n t s e l
p n m s h o w
p n m s h o w 2 4
r e g i o n t e s t
r o t a t e
s i m p l e
s i m p l e 1 5
s t o r e p a s s w d
v n c e v
)
if ( Threads_FOUND )
set ( LIBVNCSERVER_TESTS
$ { L I B V N C S E R V E R _ T E S T S }
b l o o p t e s t
)
endif ( Threads_FOUND )
if ( TIGHTVNC_FILETRANSFER )
set ( LIBVNCSERVER_TESTS
$ { L I B V N C S E R V E R _ T E S T S }
f i l e t r a n s f e r
)
endif ( TIGHTVNC_FILETRANSFER )
if ( MACOS )
set ( LIBVNCSERVER_TESTS
$ { L I B V N C S E R V E R _ T E S T S }
m a c
)
endif ( MACOS )
set ( LIBVNCCLIENT_TESTS
b a c k c h a n n e l
p p m t e s t
)
if ( SDL_FOUND )
include_directories ( ${ SDL_INCLUDE_DIR } )
set ( LIBVNCCLIENT_TESTS
$ { L I B V N C C L I E N T _ T E S T S }
S D L v n c v i e w e r
)
set ( SDLvncviewer_EXTRA_SOURCES scrap.c )
endif ( SDL_FOUND )
if ( HAVE_FFMPEG )
set ( LIBVNCCLIENT_TESTS
$ { L I B V N C C L I E N T _ T E S T S }
v n c 2 m p g
)
endif ( HAVE_FFMPEG )
file ( MAKE_DIRECTORY ${ CMAKE_BINARY_DIR } /examples )
foreach ( test ${ LIBVNCSERVER_TESTS } )
add_executable ( examples/ ${ test } ${ LIBVNCSRVTEST_DIR } / ${ test } .c )
target_link_libraries ( examples/ ${ test } vncserver ${ CMAKE_THREAD_LIBS_INIT } )
endforeach ( test ${ LIBVNCSERVER_TESTS } )
file ( MAKE_DIRECTORY ${ CMAKE_BINARY_DIR } /client_examples )
foreach ( test ${ LIBVNCCLIENT_TESTS } )
add_executable ( client_examples/ ${ test } ${ LIBVNCCLITEST_DIR } / ${ test } .c ${ LIBVNCCLITEST_DIR } / ${ ${test } _EXTRA_SOURCES} )
target_link_libraries ( client_examples/ ${ test } vncclient ${ CMAKE_THREAD_LIBS_INIT } ${ GNUTLS_LIBRARIES } ${ X11_LIBRARIES } ${ SDL_LIBRARY } ${ FFMPEG_LIBRARIES } )
endforeach ( test ${ LIBVNCCLIENT_TESTS } )
install_targets ( /lib vncserver )
install_targets ( /lib vncclient )
install_files ( /include/rfb FILES
r f b / k e y s y m . h
r f b / r f b . h
r f b / r f b c l i e n t . h
r f b / r f b c o n f i g . h
r f b / r f b i n t . h
r f b / r f b p r o t o . h
r f b / r f b r e g i o n . h
)