CMake Lists
CMake Lists
# Setup
#
cmake_minimum_required(VERSION 2.8)
if(POLICY CMP0022)
cmake_policy(SET CMP0022 OLD)
endif()
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckTypeSize)
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
include(CheckCSourceRuns)
include(CMakeMacroLibtoolFile)
project(tigervnc)
set(VERSION 1.9.0)
# Installation paths
set(BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin")
set(DATA_DIR "${CMAKE_INSTALL_PREFIX}/share")
set(MAN_DIR "${DATA_DIR}/man")
set(LOCALE_DIR "${DATA_DIR}/locale")
set(DOC_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${CMAKE_PROJECT_NAME}-${VERSION}")
if(WIN32)
set(BIN_DIR "${CMAKE_INSTALL_PREFIX}")
set(DOC_DIR "${CMAKE_INSTALL_PREFIX}")
endif()
if(MSVC)
message(FATAL_ERROR "TigerVNC cannot be built with Visual Studio. Please use
MinGW")
endif()
if(NOT BUILD_TIMESTAMP)
set(BUILD_TIMESTAMP "")
execute_process(COMMAND "date" "+%Y-%m-%d %H:%M" OUTPUT_VARIABLE BUILD_TIMESTAMP)
string(REGEX REPLACE "\n" "" BUILD_TIMESTAMP ${BUILD_TIMESTAMP})
endif()
# Default to optimised builds instead of debug ones. Our code has no bugs ;)
# (CMake makes it fairly easy to toggle this back to Debug if needed)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
message(STATUS "64-bit build")
else()
message(STATUS "32-bit build")
endif()
if(ICONV_FOUND)
# Headers and libraries (copied from licq)
set(GETTEXT_FOUND FALSE)
find_path(GETTEXT_INCLUDE_DIR libintl.h)
if(GETTEXT_INCLUDE_DIR)
set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES})
set(CMAKE_REQUIRED_FLAGS -fno-builtin-dgettext)
check_function_exists(dgettext LIBC_HAS_DGETTEXT)
if(LIBC_HAS_DGETTEXT)
set(GETTEXT_FOUND TRUE)
else()
find_library(LIBINTL_LIBRARY NAMES intl libintl)
if(LIBINTL_LIBRARY)
check_library_exists(${LIBINTL_LIBRARY} "dgettext" ""
LIBINTL_HAS_DGETTEXT)
if(LIBINTL_HAS_DGETTEXT)
set(GETTEXT_LIBRARIES ${LIBINTL_LIBRARY} ${ICONV_LIBRARIES})
set(GETTEXT_FOUND TRUE)
endif()
endif()
endif()
set(CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_FLAGS)
endif()
endif()
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()
include_directories(${JPEG_INCLUDE_DIR})
include(cmake/StaticBuild.cmake)
add_subdirectory(common)
if(WIN32)
add_subdirectory(win)
else()
# No interest in building x related parts on Apple
if(NOT APPLE)
add_subdirectory(unix)
endif()
endif()
if(ENABLE_NLS)
add_subdirectory(po)
endif()
add_subdirectory(tests)
include(cmake/BuildPackages.cmake)
# uninstall
configure_file("${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"cmake_uninstall.cmake" IMMEDIATE @ONLY)