Cleanup main CMake file

This commit is contained in:
Andrew Nelless 2017-03-08 15:33:35 +00:00
parent adf051a354
commit 7f0f3123c5
1 changed files with 316 additions and 334 deletions

View File

@ -1,4 +1,4 @@
# synergy -- mouse and keyboard sharing utility # Synergy -- mouse and keyboard sharing utility
# Copyright (C) 2012-2016 Symless Ltd. # Copyright (C) 2012-2016 Symless Ltd.
# Copyright (C) 2009 Nick Bolton # Copyright (C) 2009 Nick Bolton
# #
@ -14,10 +14,17 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.4) cmake_minimum_required (VERSION 3.4)
project (synergy C CXX)
# Version number for Synergy option (SYNERGY_BUILD_LEGACY_SERVICE "Build the legacy service (synergyd)" ON)
if(DEFINED ENV{SYNERGY_VERSION_MAJOR})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
# TODO: Eliminate variables not prefixed with SYNERGY_
if (DEFINED ENV{SYNERGY_VERSION_MAJOR})
set (VERSION_MAJOR $ENV{SYNERGY_VERSION_MAJOR}) set (VERSION_MAJOR $ENV{SYNERGY_VERSION_MAJOR})
set (VERSION_MINOR $ENV{SYNERGY_VERSION_MINOR}) set (VERSION_MINOR $ENV{SYNERGY_VERSION_MINOR})
set (VERSION_REV $ENV{SYNERGY_VERSION_PATCH}) set (VERSION_REV $ENV{SYNERGY_VERSION_PATCH})
@ -30,146 +37,125 @@ else()
set (VERSION_STAGE git) set (VERSION_STAGE git)
endif() endif()
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REV}")
set(SYNERGY_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REV}")
# CMake complains if we don't have this. set (SYNERGY_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REV}")
set (VERSION $SYNERGY_VERSION)
message (STATUS "Synergy version is " $SYNERGY_VERSION)
# TODO: Find out why we need these, and remove them
if (COMMAND cmake_policy) if (COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW) cmake_policy (SET CMP0003 NEW)
cmake_policy (SET CMP0005 NEW)
endif() endif()
# We're escaping quotes in the Windows version number, because
# for some reason CMake won't do it at config version 2.4.7
# It seems that this restores the newer behaviour where define
# args are not auto-escaped.
if (COMMAND cmake_policy)
cmake_policy(SET CMP0005 NEW)
endif()
# First, declare project (important for prerequisite checks). # Add headers to source list
project(synergy C CXX)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
# Set some easy to type variables.
set(root_dir ${CMAKE_SOURCE_DIR})
set(cmake_dir ${root_dir}/res)
set(bin_dir ${root_dir}/bin)
set(doc_dir ${root_dir}/doc)
set(doc_dir ${root_dir}/doc)
# Declare libs, so we can use list in linker later. There's probably
# a more elegant way of doing this; with SCons, when you check for the
# lib, it is automatically passed to the linker.
set(libs)
# only include headers as "source" if not unix makefiles,
# which is useful when using an IDE.
if (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles") if (${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
set(SYNERGY_ADD_HEADERS FALSE) set (SYNERGY_ADD_HEADERS FALSE)
else() else()
set(SYNERGY_ADD_HEADERS TRUE) set (SYNERGY_ADD_HEADERS TRUE)
endif() endif()
# Depending on the platform, pass in the required defines.
set (libs)
if (UNIX) if (UNIX)
if (NOT APPLE) if (NOT APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif() endif()
# For config.h, detect the libraries, functions, etc. # For config.h, detect the libraries, functions, etc.
include(CheckIncludeFiles) include (CheckIncludeFiles)
include(CheckLibraryExists) include (CheckLibraryExists)
include(CheckFunctionExists) include (CheckFunctionExists)
include(CheckTypeSize) include (CheckTypeSize)
include(CheckIncludeFileCXX) include (CheckIncludeFileCXX)
include(CheckSymbolExists) include (CheckSymbolExists)
include(CheckCSourceCompiles) include (CheckCSourceCompiles)
check_include_file_cxx(istream HAVE_ISTREAM) check_include_file_cxx (istream HAVE_ISTREAM)
check_include_file_cxx(ostream HAVE_OSTREAM) check_include_file_cxx (ostream HAVE_OSTREAM)
check_include_file_cxx(sstream HAVE_SSTREAM) check_include_file_cxx (sstream HAVE_SSTREAM)
check_include_files(inttypes.h HAVE_INTTYPES_H) check_include_files (inttypes.h HAVE_INTTYPES_H)
check_include_files(locale.h HAVE_LOCALE_H) check_include_files (locale.h HAVE_LOCALE_H)
check_include_files(memory.h HAVE_MEMORY_H) check_include_files (memory.h HAVE_MEMORY_H)
check_include_files(stdlib.h HAVE_STDLIB_H) check_include_files (stdlib.h HAVE_STDLIB_H)
check_include_files(strings.h HAVE_STRINGS_H) check_include_files (strings.h HAVE_STRINGS_H)
check_include_files(string.h HAVE_STRING_H) check_include_files (string.h HAVE_STRING_H)
check_include_files(sys/select.h HAVE_SYS_SELECT_H) check_include_files (sys/select.h HAVE_SYS_SELECT_H)
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H) check_include_files (sys/socket.h HAVE_SYS_SOCKET_H)
check_include_files(sys/stat.h HAVE_SYS_STAT_H) check_include_files (sys/stat.h HAVE_SYS_STAT_H)
check_include_files(sys/time.h HAVE_SYS_TIME_H) check_include_files (sys/time.h HAVE_SYS_TIME_H)
check_include_files(sys/utsname.h HAVE_SYS_UTSNAME_H) check_include_files (sys/utsname.h HAVE_SYS_UTSNAME_H)
check_include_files(unistd.h HAVE_UNISTD_H) check_include_files (unistd.h HAVE_UNISTD_H)
check_include_files(wchar.h HAVE_WCHAR_H) check_include_files (wchar.h HAVE_WCHAR_H)
check_function_exists(getpwuid_r HAVE_GETPWUID_R) check_function_exists (getpwuid_r HAVE_GETPWUID_R)
check_function_exists(gmtime_r HAVE_GMTIME_R) check_function_exists (gmtime_r HAVE_GMTIME_R)
check_function_exists(nanosleep HAVE_NANOSLEEP) check_function_exists (nanosleep HAVE_NANOSLEEP)
check_function_exists(poll HAVE_POLL) check_function_exists (poll HAVE_POLL)
check_function_exists(sigwait HAVE_POSIX_SIGWAIT) check_function_exists (sigwait HAVE_POSIX_SIGWAIT)
check_function_exists(strftime HAVE_STRFTIME) check_function_exists (strftime HAVE_STRFTIME)
check_function_exists(vsnprintf HAVE_VSNPRINTF) check_function_exists (vsnprintf HAVE_VSNPRINTF)
check_function_exists(inet_aton HAVE_INET_ATON) check_function_exists (inet_aton HAVE_INET_ATON)
# For some reason, the check_function_exists macro doesn't detect # For some reason, the check_function_exists macro doesn't detect
# the inet_aton on some pure Unix platforms (e.g. sunos5). So we # the inet_aton on some pure Unix platforms (e.g. sunos5). So we
# need to do a more detailed check and also include some extra libs. # need to do a more detailed check and also include some extra libs.
if (NOT HAVE_INET_ATON) if (NOT HAVE_INET_ATON)
set (CMAKE_REQUIRED_LIBRARIES nsl)
set(CMAKE_REQUIRED_LIBRARIES nsl) check_c_source_compiles (
check_c_source_compiles( "#include <arpa/inet.h>\n int main() { inet_aton (0, 0); }"
"#include <arpa/inet.h>\n int main() { inet_aton(0, 0); }"
HAVE_INET_ATON_ADV) HAVE_INET_ATON_ADV)
set(CMAKE_REQUIRED_LIBRARIES)
set (CMAKE_REQUIRED_LIBRARIES)
if (HAVE_INET_ATON_ADV) if (HAVE_INET_ATON_ADV)
# Override the previous fail. # Override the previous fail.
set(HAVE_INET_ATON 1) set (HAVE_INET_ATON 1)
# Assume that both nsl and socket will be needed, # Assume that both nsl and socket will be needed,
# it seems safe to add socket on the back of nsl, # it seems safe to add socket on the back of nsl,
# since socket only ever needed when nsl is needed. # since socket only ever needed when nsl is needed.
list(APPEND libs nsl socket) list (APPEND libs nsl socket)
endif() endif()
endif() endif()
check_type_size(char SIZEOF_CHAR) check_type_size (char SIZEOF_CHAR)
check_type_size(int SIZEOF_INT) check_type_size (int SIZEOF_INT)
check_type_size(long SIZEOF_LONG) check_type_size (long SIZEOF_LONG)
check_type_size(short SIZEOF_SHORT) check_type_size (short SIZEOF_SHORT)
# pthread is used on both Linux and Mac # pthread is used on both Linux and Mac
check_library_exists("pthread" pthread_create "" HAVE_PTHREAD) check_library_exists ("pthread" pthread_create "" HAVE_PTHREAD)
if (HAVE_PTHREAD) if (HAVE_PTHREAD)
list(APPEND libs pthread) list (APPEND libs pthread)
else() else()
message(FATAL_ERROR "Missing library: pthread") message (FATAL_ERROR "Missing library: pthread")
endif() endif()
# curl is used on both Linux and Mac # curl is used on both Linux and Mac
find_package(CURL) find_package (CURL)
if (CURL_FOUND) if (CURL_FOUND)
list(APPEND libs curl) list (APPEND libs curl)
else() else()
message(FATAL_ERROR "Missing library: curl") message (FATAL_ERROR "Missing library: curl")
endif() endif()
if (APPLE) if (APPLE)
set(CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS} -DGTEST_USE_OWN_TR1_TUPLE=1") set (CMAKE_CXX_FLAGS "--sysroot ${CMAKE_OSX_SYSROOT} ${CMAKE_CXX_FLAGS} -DGTEST_USE_OWN_TR1_TUPLE=1")
find_library(lib_ScreenSaver ScreenSaver) find_library (lib_ScreenSaver ScreenSaver)
find_library(lib_IOKit IOKit) find_library (lib_IOKit IOKit)
find_library(lib_ApplicationServices ApplicationServices) find_library (lib_ApplicationServices ApplicationServices)
find_library(lib_Foundation Foundation) find_library (lib_Foundation Foundation)
find_library(lib_Carbon Carbon) find_library (lib_Carbon Carbon)
list(APPEND libs list (APPEND libs
${lib_ScreenSaver} ${lib_ScreenSaver}
${lib_IOKit} ${lib_IOKit}
${lib_ApplicationServices} ${lib_ApplicationServices}
@ -180,174 +166,163 @@ if (UNIX)
else() # not-apple else() # not-apple
# add include dir for bsd (posix uses /usr/include/) # add include dir for bsd (posix uses /usr/include/)
set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include") set (CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include")
set(XKBlib "X11/Xlib.h;X11/XKBlib.h") set (XKBlib "X11/Xlib.h;X11/XKBlib.h")
set(CMAKE_EXTRA_INCLUDE_FILES "${XKBlib};X11/extensions/Xrandr.h") set (CMAKE_EXTRA_INCLUDE_FILES "${XKBlib};X11/extensions/Xrandr.h")
check_type_size("XRRNotifyEvent" X11_EXTENSIONS_XRANDR_H) check_type_size ("XRRNotifyEvent" X11_EXTENSIONS_XRANDR_H)
set(HAVE_X11_EXTENSIONS_XRANDR_H "${X11_EXTENSIONS_XRANDR_H}") set (HAVE_X11_EXTENSIONS_XRANDR_H "${X11_EXTENSIONS_XRANDR_H}")
set(CMAKE_EXTRA_INCLUDE_FILES) set (CMAKE_EXTRA_INCLUDE_FILES)
check_include_files("${XKBlib};X11/extensions/dpms.h" HAVE_X11_EXTENSIONS_DPMS_H) 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 ("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 ("${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/XKB.h" HAVE_XKB_EXTENSION)
check_include_files("X11/extensions/XTest.h" HAVE_X11_EXTENSIONS_XTEST_H) check_include_files ("X11/extensions/XTest.h" HAVE_X11_EXTENSIONS_XTEST_H)
check_include_files("${XKBlib}" HAVE_X11_XKBLIB_H) check_include_files ("${XKBlib}" HAVE_X11_XKBLIB_H)
check_include_files("X11/extensions/XInput2.h" HAVE_XI2) check_include_files ("X11/extensions/XInput2.h" HAVE_XI2)
if (HAVE_X11_EXTENSIONS_DPMS_H) if (HAVE_X11_EXTENSIONS_DPMS_H)
# Assume that function prototypes declared, when include exists. # Assume that function prototypes declared, when include exists.
set(HAVE_DPMS_PROTOTYPES 1) set (HAVE_DPMS_PROTOTYPES 1)
endif() endif()
if (NOT HAVE_X11_XKBLIB_H) if (NOT HAVE_X11_XKBLIB_H)
message(FATAL_ERROR "Missing header: " ${XKBlib}) message (FATAL_ERROR "Missing header: " ${XKBlib})
endif() endif()
check_library_exists("SM;ICE" IceConnectionNumber "" HAVE_ICE) check_library_exists ("SM;ICE" IceConnectionNumber "" HAVE_ICE)
check_library_exists("Xext;X11" DPMSQueryExtension "" HAVE_Xext) check_library_exists ("Xext;X11" DPMSQueryExtension "" HAVE_Xext)
check_library_exists("Xtst;Xext;X11" XTestQueryExtension "" HAVE_Xtst) check_library_exists ("Xtst;Xext;X11" XTestQueryExtension "" HAVE_Xtst)
check_library_exists("Xinerama" XineramaQueryExtension "" HAVE_Xinerama) check_library_exists ("Xinerama" XineramaQueryExtension "" HAVE_Xinerama)
check_library_exists("Xi" XISelectEvents "" HAVE_Xi) check_library_exists ("Xi" XISelectEvents "" HAVE_Xi)
check_library_exists("Xrandr" XRRQueryExtension "" HAVE_Xrandr) check_library_exists ("Xrandr" XRRQueryExtension "" HAVE_Xrandr)
if (HAVE_ICE) if (HAVE_ICE)
# Assume we have SM if we have ICE. # Assume we have SM if we have ICE.
set(HAVE_SM 1) set (HAVE_SM 1)
list(APPEND libs SM ICE) list (APPEND libs SM ICE)
endif() endif()
if (HAVE_Xtst) if (HAVE_Xtst)
# Xtxt depends on X11. # Xtxt depends on X11.
set(HAVE_X11) set (HAVE_X11)
list(APPEND libs Xtst X11) list (APPEND libs Xtst X11)
else() else()
message(FATAL_ERROR "Missing library: Xtst") message (FATAL_ERROR "Missing library: Xtst")
endif() endif()
if (HAVE_Xext) if (HAVE_Xext)
list(APPEND libs Xext) list (APPEND libs Xext)
endif() endif()
if (HAVE_Xinerama) if (HAVE_Xinerama)
list(APPEND libs Xinerama) list (APPEND libs Xinerama)
else (HAVE_Xinerama) else (HAVE_Xinerama)
if (HAVE_X11_EXTENSIONS_XINERAMA_H) if (HAVE_X11_EXTENSIONS_XINERAMA_H)
set(HAVE_X11_EXTENSIONS_XINERAMA_H 0) set (HAVE_X11_EXTENSIONS_XINERAMA_H 0)
message(WARNING "Old Xinerama implementation detected, disabled") message (WARNING "Old Xinerama implementation detected, disabled")
endif() endif()
endif() endif()
if (HAVE_Xrandr) if (HAVE_Xrandr)
list(APPEND libs Xrandr) list (APPEND libs Xrandr)
endif() endif()
# this was outside of the linux scope, # this was outside of the linux scope,
# not sure why, moving it back inside. # not sure why, moving it back inside.
if(HAVE_Xi) if (HAVE_Xi)
list(APPEND libs Xi) list (APPEND libs Xi)
endif() endif()
endif() endif()
# For config.h, set some static values; it may be a good idea to make # For config.h, set some static values; it may be a good idea to make
# these values dynamic for non-standard UNIX compilers. # these values dynamic for non-standard UNIX compilers.
set(ACCEPT_TYPE_ARG3 socklen_t) set (ACCEPT_TYPE_ARG3 socklen_t)
set(HAVE_CXX_BOOL 1) set (HAVE_CXX_BOOL 1)
set(HAVE_CXX_CASTS 1) set (HAVE_CXX_CASTS 1)
set(HAVE_CXX_EXCEPTIONS 1) set (HAVE_CXX_EXCEPTIONS 1)
set(HAVE_CXX_MUTABLE 1) set (HAVE_CXX_MUTABLE 1)
set(HAVE_CXX_STDLIB 1) set (HAVE_CXX_STDLIB 1)
set(HAVE_PTHREAD_SIGNAL 1) set (HAVE_PTHREAD_SIGNAL 1)
set(SELECT_TYPE_ARG1 int) set (SELECT_TYPE_ARG1 int)
set(SELECT_TYPE_ARG234 "(fd_set *)") set (SELECT_TYPE_ARG234 " (fd_set *)")
set(SELECT_TYPE_ARG5 "(struct timeval *)") set (SELECT_TYPE_ARG5 " (struct timeval *)")
set(STDC_HEADERS 1) set (STDC_HEADERS 1)
set(TIME_WITH_SYS_TIME 1) set (TIME_WITH_SYS_TIME 1)
set(HAVE_SOCKLEN_T 1) set (HAVE_SOCKLEN_T 1)
# For config.h, save the results based on a template (config.h.in). # For config.h, save the results based on a template (config.h.in).
configure_file(res/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/lib/config.h) configure_file (res/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/src/lib/config.h)
add_definitions(-DSYSAPI_UNIX=1 -DHAVE_CONFIG_H) add_definitions (-DSYSAPI_UNIX=1 -DHAVE_CONFIG_H)
if (APPLE) if (APPLE)
add_definitions(-DWINAPI_CARBON=1 -D_THREAD_SAFE) add_definitions (-DWINAPI_CARBON=1 -D_THREAD_SAFE)
else (APPLE) else()
add_definitions(-DWINAPI_XWINDOWS=1) add_definitions (-DWINAPI_XWINDOWS=1)
endif() endif()
else() # not-unix elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /D _BIND_TO_CURRENT_VCLIBS_VERSION=1")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD /O2 /Ob2")
list(APPEND libs Wtsapi32 Userenv Wininet comsuppw Shlwapi) list (APPEND libs Wtsapi32 Userenv Wininet comsuppw Shlwapi)
add_definitions( add_definitions (
/DWIN32 /DWIN32
/D_WINDOWS /D_WINDOWS
/D_CRT_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS
/DVERSION=\"${VERSION}\" /DVERSION=\"${VERSION}\"
/D_XKEYCHECK_H /D_XKEYCHECK_H
) )
if (MSVC_VERSION EQUAL 1600)
set(SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/synergy.sln")
if (EXISTS "${SLN_FILENAME}" )
file(APPEND "${SLN_FILENAME}" "\n# This should be regenerated!\n")
endif()
endif()
endif() endif()
if (WIN32) #
set(OPENSSL_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ext/openssl/windows) # OpenSSL
if(CMAKE_SIZEOF_VOID_P EQUAL 8) #
set(OPENSSL_BASE_DIR "${OPENSSL_BASE_DIR}/x64") 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() else()
set(OPENSSL_BASE_DIR "${OPENSSL_BASE_DIR}/x86") set (OPENSSL_ROOT "${OPENSSL_ROOT}/x86")
endif() endif()
set(OPENSSL_LIBS
${OPENSSL_BASE_DIR}/lib/libeay32.lib set (OPENSSL_LIBS
${OPENSSL_BASE_DIR}/lib/ssleay32.lib ${OPENSSL_ROOT}/lib/libeay32.lib
${OPENSSL_ROOT}/lib/ssleay32.lib
) )
endif()
if (UNIX) elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if (APPLE) set (OPENSSL_ROOT /usr/local/opt/openssl)
set(OPENSSL_BASE_DIR /usr/local/opt/openssl)
set(OPENSSL_LIBS set (OPENSSL_LIBS
${OPENSSL_BASE_DIR}/lib/libssl.a ${OPENSSL_ROOT}/lib/libssl.a
${OPENSSL_BASE_DIR}/lib/libcrypto.a ${OPENSSL_ROOT}/lib/libcrypto.a
) )
else()
set(OPENSSL_LIBS ssl crypto) elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
endif() set (OPENSSL_LIBS ssl crypto)
else()
message (FATAL_ERROR "Couldn't find OpenSSL")
endif() endif()
set(OPENSSL_INCLUDE ${OPENSSL_BASE_DIR}/include) set (OPENSSL_INCLUDE ${OPENSSL_ROOT}/include)
if (WIN32) #
# TODO: consider using /analyze to uncover potential bugs in the source code. # Configure_file... but for directories, recursively.
#
# /MP - use multi cores to compile. macro (configure_files srcDir destDir)
# /D _BIND_TO_CURRENT_VCLIBS_VERSION - TODO: explain why. message (STATUS "Configuring directory ${destDir}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /D _BIND_TO_CURRENT_VCLIBS_VERSION=1")
# /MD - use multi-core libraries.
# /O2 - get the fastest code.
# /Ob2 - expand inline functions (auto-inlining).
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD /O2 /Ob2")
endif()
macro(configure_files srcDir destDir)
message(STATUS "Configuring directory ${destDir}")
make_directory (${destDir}) make_directory (${destDir})
file (GLOB_RECURSE sourceFiles RELATIVE ${srcDir} ${srcDir}/*) file (GLOB_RECURSE sourceFiles RELATIVE ${srcDir} ${srcDir}/*)
@ -359,10 +334,10 @@ macro(configure_files srcDir destDir)
if (IS_DIRECTORY ${sourceFilePath}) if (IS_DIRECTORY ${sourceFilePath})
message (STATUS "Copying directory ${sourceFile}") message (STATUS "Copying directory ${sourceFile}")
make_directory (${destDir/${sourceFile}) make_directory (${destDir/${sourceFile})
else () else()
message (STATUS "Copying file ${sourceFile}") message (STATUS "Copying file ${sourceFile}")
configure_file (${sourceFilePath} ${destDir}/${sourceFile} COPYONLY) configure_file (${sourceFilePath} ${destDir}/${sourceFile} COPYONLY)
endif () endif()
endforeach (sourceFile) endforeach (sourceFile)
foreach (templateFile ${templateFiles}) foreach (templateFile ${templateFiles})
@ -373,18 +348,25 @@ macro(configure_files srcDir destDir)
endforeach (templateFile) endforeach (templateFile)
endmacro (configure_files) endmacro (configure_files)
#
# macOS app Bundle
#
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (CMAKE_INSTALL_RPATH "@loader_path/../Libraries;@loader_path/../Frameworks") set (CMAKE_INSTALL_RPATH "@loader_path/../Libraries;@loader_path/../Frameworks")
set (SYNERGY_BUNDLE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dist/macos/bundle) set (SYNERGY_BUNDLE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/dist/macos/bundle)
set (SYNERGY_BUNDLE_DIR ${CMAKE_BINARY_DIR}/bundle) set (SYNERGY_BUNDLE_DIR ${CMAKE_BINARY_DIR}/bundle)
set (SYNERGY_BUNDLE_APP_DIR ${SYNERGY_BUNDLE_DIR}/Synergy.app) set (SYNERGY_BUNDLE_APP_DIR ${SYNERGY_BUNDLE_DIR}/Synergy.app)
set (SYNERGY_BUNDLE_BINARY_DIR ${SYNERGY_BUNDLE_APP_DIR}/Contents/MacOS) set (SYNERGY_BUNDLE_BINARY_DIR ${SYNERGY_BUNDLE_APP_DIR}/Contents/MacOS)
configure_files (${SYNERGY_BUNDLE_SOURCE_DIR} ${SYNERGY_BUNDLE_DIR}) configure_files (${SYNERGY_BUNDLE_SOURCE_DIR} ${SYNERGY_BUNDLE_DIR})
elseif(WIN32 AND NOT UNIX) endif()
#
# Windows installer
#
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
configure_files (${CMAKE_CURRENT_SOURCE_DIR}/dist/wix ${CMAKE_BINARY_DIR}/installer) configure_files (${CMAKE_CURRENT_SOURCE_DIR}/dist/wix ${CMAKE_BINARY_DIR}/installer)
endif() endif()
option(SYNERGY_BUILD_LEGACY_SERVICE "Build the legacy service (synergyd)" ON) add_subdirectory (src)
add_subdirectory(src)