CMakeLists
CMakeLists
include (cmake/Version.cmake)
include (cmake/Package.cmake)
set (libs)
if (UNIX)
if (NOT APPLE)
set (CMAKE_POSITION_INDEPENDENT_CODE TRUE)
endif()
# For config.h, detect the libraries, functions, etc.
include (CheckIncludeFiles)
include (CheckLibraryExists)
include (CheckFunctionExists)
include (CheckTypeSize)
include (CheckIncludeFileCXX)
include (CheckSymbolExists)
include (CheckCSourceCompiles)
include (FindPkgConfig)
check_c_source_compiles (
"#include <arpa/inet.h>\n int main() { inet_aton (0, 0); }"
HAVE_INET_ATON_ADV)
set (CMAKE_REQUIRED_LIBRARIES)
if (HAVE_INET_ATON_ADV)
# Override the previous fail.
set (HAVE_INET_ATON 1)
else()
message (FATAL_ERROR "Missing library: curl")
endif()
if (APPLE)
set (CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS} -
DGTEST_USE_OWN_TR1_TUPLE=1")
else() # not-apple
# FreeBSD uses /usr/local for anything not part of base
# Also package avahi-libdns puts dns_sd.h a bit deeper
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set (CMAKE_REQUIRED_INCLUDES
"${CMAKE_REQUIRED_INCLUDES};/usr/local/include;/usr/local/include/avahi-compat-
libdns_sd")
set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -L/usr/local/lib")
include_directories("/usr/local/include" "/usr/local/include/avahi-
compat-libdns_sd")
link_directories("/usr/local/lib")
endif()
check_include_files ("${XKBlib};X11/extensions/dpms.h"
HAVE_X11_EXTENSIONS_DPMS_H)
check_include_files ("X11/extensions/Xinerama.h"
HAVE_X11_EXTENSIONS_XINERAMA_H)
check_include_files ("${XKBlib};X11/extensions/XKBstr.h"
HAVE_X11_EXTENSIONS_XKBSTR_H)
check_include_files ("X11/extensions/XKB.h" HAVE_XKB_EXTENSION)
check_include_files ("X11/extensions/XTest.h" HAVE_X11_EXTENSIONS_XTEST_H)
check_include_files ("${XKBlib}" HAVE_X11_XKBLIB_H)
check_include_files ("X11/extensions/XInput2.h" HAVE_XI2)
check_include_files ("dns_sd.h" HAVE_DNSSD)
if (NOT HAVE_X11_EXTENSIONS_XTEST_H)
message (FATAL_ERROR "Missing header: X11/extensions/XTest.h")
endif()
if (NOT HAVE_X11_XKBLIB_H)
message (FATAL_ERROR "Missing header: " ${XKBlib})
endif()
if (HAVE_ICE)
endif()
if (HAVE_Xtst)
else()
endif()
if (HAVE_Xext)
list (APPEND libs Xext)
endif()
if (HAVE_Xinerama)
list (APPEND libs Xinerama)
else (HAVE_Xinerama)
if (HAVE_X11_EXTENSIONS_XINERAMA_H)
set (HAVE_X11_EXTENSIONS_XINERAMA_H 0)
message (WARNING "Old Xinerama implementation detected, disabled")
endif()
endif()
if (HAVE_Xrandr)
list (APPEND libs Xrandr)
endif()
endif()
# For config.h, set some static values; it may be a good idea to make
# these values dynamic for non-standard UNIX compilers.
set (ACCEPT_TYPE_ARG3 socklen_t)
set (HAVE_CXX_BOOL 1)
set (HAVE_CXX_CASTS 1)
set (HAVE_CXX_EXCEPTIONS 1)
set (HAVE_CXX_MUTABLE 1)
set (HAVE_CXX_STDLIB 1)
set (SELECT_TYPE_ARG1 int)
set (SELECT_TYPE_ARG234 " (fd_set *)")
set (SELECT_TYPE_ARG5 " (struct timeval *)")
set (STDC_HEADERS 1)
set (TIME_WITH_SYS_TIME 1)
set (HAVE_SOCKLEN_T 1)
if (APPLE)
add_definitions (-DWINAPI_CARBON=1 -D_THREAD_SAFE)
else()
add_definitions (-DWINAPI_XWINDOWS=1)
endif()
add_definitions (
/DSYSAPI_WIN32=1
/DWINAPI_MSWINDOWS=1
/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 # tr1 is used from gtest
and gmock
/DWIN32
/D_WINDOWS
/D_CRT_SECURE_NO_WARNINGS
/DBARRIER_VERSION=\"${BARRIER_VERSION}\"
/D_XKEYCHECK_H
)
endif()
include_directories("${CMAKE_SOURCE_DIR}/ext/gulrak-filesystem/include")
#
# OpenSSL
#
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set (OPENSSL_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/ext/openssl/windows)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (OPENSSL_ROOT "${OPENSSL_ROOT}/x64")
else()
set (OPENSSL_ROOT "${OPENSSL_ROOT}/x86")
endif()
set (OPENSSL_LIBS
${OPENSSL_ROOT}/lib/libssl.a
${OPENSSL_ROOT}/lib/libcrypto.a
)
elseif (IS_DIRECTORY /opt/local AND PORT_PROGRAM)
# macports
set (OPENSSL_ROOT /opt/local)
set (OPENSSL_LIBS
${OPENSSL_ROOT}/lib/libssl.a
${OPENSSL_ROOT}/lib/libcrypto.a
z
)
elseif (IS_DIRECTORY /usr/local/opt/openssl AND BREW_PROGRAM)
# brew
set (OPENSSL_ROOT /usr/local/opt/openssl)
set (OPENSSL_LIBS
${OPENSSL_ROOT}/lib/libssl.a
${OPENSSL_ROOT}/lib/libcrypto.a
)
elseif (IS_DIRECTORY /opt/homebrew/opt/openssl AND BREW_PROGRAM)
# brew
set (OPENSSL_ROOT /opt/homebrew/opt/openssl)
set (OPENSSL_LIBS
${OPENSSL_ROOT}/lib/libssl.a
${OPENSSL_ROOT}/lib/libcrypto.a
)
endif()
#
# Configure_file... but for directories, recursively.
#
macro (configure_files srcDir destDir)
message (STATUS "Configuring directory ${destDir}")
make_directory (${destDir})
if (${BARRIER_BUILD_INSTALLER})
#
# macOS app Bundle
#
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (CMAKE_INSTALL_RPATH
"@loader_path/../Libraries;@loader_path/../Frameworks")
set (BARRIER_BUNDLE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dist/macos/bundle)
set (BARRIER_BUNDLE_DIR ${CMAKE_BINARY_DIR}/bundle)
set (BARRIER_BUNDLE_APP_DIR ${BARRIER_BUNDLE_DIR}/Barrier.app)
set (BARRIER_BUNDLE_BINARY_DIR ${BARRIER_BUNDLE_APP_DIR}/Contents/MacOS)
add_custom_target(Barrier_MacOS ALL
bash build_dist.sh
DEPENDS barrier barriers barrierc
WORKING_DIRECTORY ${BARRIER_BUNDLE_DIR})
endif()
#
# Windows installer
#
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set (BARRIER_WIX_VERSION "${BARRIER_VERSION_MAJOR}.$
{BARRIER_VERSION_MINOR}.${BARRIER_VERSION_PATCH}")
message (STATUS "Configuring the wix installer")
configure_files (${CMAKE_CURRENT_SOURCE_DIR}/dist/wix
${CMAKE_BINARY_DIR}/installer-wix)
message (STATUS "Configuring the inno installer")
configure_files (${CMAKE_CURRENT_SOURCE_DIR}/dist/inno $
{CMAKE_BINARY_DIR}/installer-inno)
endif()
#
# Linux installation
#
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
configure_files (${CMAKE_CURRENT_SOURCE_DIR}/dist/rpm ${CMAKE_BINARY_DIR}/rpm)
install(FILES res/barrier.svg DESTINATION share/icons/hicolor/scalable/apps)
if("${VERSION_MAJOR}" STREQUAL "2")
install(FILES res/barrier2.desktop DESTINATION share/applications)
else()
install(FILES res/barrier.desktop DESTINATION share/applications)
endif()
endif()
else()
message (STATUS "NOT configuring the installer")
endif()
enable_testing()
add_subdirectory (src)