[cmake] unify common options

This commit is contained in:
Armin Novak 2023-12-21 09:27:19 +01:00 committed by akallabeth
parent 0245c877b6
commit a7decba8c2
17 changed files with 60 additions and 176 deletions

View File

@ -21,17 +21,14 @@
cmake_minimum_required(VERSION 3.13)
cmake_policy(SET CMP0091 NEW)
project(FreeRDP C)
project(FreeRDP
LANGUAGES C
)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
# Default to release build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE)
endif()
add_custom_target(fuzzers
COMMENT "Build fuzzers"
)
@ -48,10 +45,6 @@ if(NOT DEFINED FREERDP_VENDOR)
set(FREERDP_VENDOR 1)
endif()
option(CMAKE_COLOR_MAKEFILE "colorful CMake makefile" ON)
option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON)
if (NOT WIN32 AND NOT ANDROID)
if (APPLE)
set(OPT_DEFAULT_VAL OFF)
@ -63,7 +56,7 @@ endif()
# Include our extra modules
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/)
include(PreventInSourceBuilds)
include(CommonConfigOptions)
if((CMAKE_SYSTEM_NAME MATCHES "WindowsStore") AND (CMAKE_SYSTEM_VERSION MATCHES "10.0"))
set(UWP 1)
@ -92,24 +85,16 @@ include(ShowCMakeVars)
include(ConfigOptions)
include(FeatureSummary)
include(CheckCCompilerFlag)
include(GNUInstallDirsWrapper)
include(CMakePackageConfigHelpers)
include(InstallFreeRDPMan)
include(GetGitRevisionDescription)
include(SetFreeRDPCMakeInstallDir)
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
if (supported)
option(CMAKE_INTERPROCEDURAL_OPTIMIZATION "Enable LTO linking" TRUE)
endif()
# Soname versioning
set(BUILD_NUMBER 0)
if ($ENV{BUILD_NUMBER})
set(BUILD_NUMBER $ENV{BUILD_NUMBER})
endif()
set(WITH_LIBRARY_VERSIONING "ON")
set(VERSION_REGEX "^(.*)([0-9]+)\\.([0-9]+)\\.([0-9]+)-?(.*)")
set(RAW_VERSION_STRING "3.0.1-dev0")
@ -208,12 +193,6 @@ endif(CMAKE_CROSSCOMPILING)
# Turn on solution folders (2.8.4+)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(LIB_DEFAULT ON)
if (IOS)
set(LIB_DEFAULT OFF)
endif()
option(BUILD_SHARED_LIBS "Build shared libraries" ${LIB_DEFAULT})
option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF)
if(BUILD_TESTING)
@ -234,9 +213,6 @@ if(FREEBSD)
find_library(EPOLLSHIM_LIBS NAMES epoll-shim libepoll-shim HINTS /usr/local/lib)
endif()
# Configure MSVC Runtime
include(MSVCRuntime)
# Enable 64bit file support on linux and FreeBSD.
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" OR FREEBSD)
add_definitions("-D_FILE_OFFSET_BITS=64")
@ -467,8 +443,6 @@ endif(APPLE)
# Android
if(ANDROID)
set(WITH_LIBRARY_VERSIONING "OFF")
set_property( GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ${ANDROID_LIBRARY_USE_LIB64_PATHS} )
if (${ANDROID_ABI} STREQUAL "armeabi")
@ -745,9 +719,6 @@ else()
set(FREERDP_PROXY_PLUGINDIR "${PROXY_PLUGINDIR}")
endif()
# RPATH configuration
include(ConfigureRPATH)
if (BUILD_SHARED_LIBS)
set(CMAKE_MACOSX_RPATH ON)
endif()

View File

@ -11,3 +11,4 @@ set (WITH_KRB5 OFF CACHE BOOL "Kerberos support")
set (WITH_CLIENT_SDL OFF CACHE BOOL "SDL client")
set (WITH_SERVER OFF CACHE BOOL "ci default")
set (WITH_X11 OFF CACHE BOOL "ci default")
set (WITH_LIBRARY_VERSIONING OFF CACHE BOOL "ci default")

View File

@ -11,3 +11,4 @@ set (WITH_KRB5 OFF CACHE BOOL "Kerberos support")
set (WITH_CLIENT_SDL OFF CACHE BOOL "SDL client")
set (WITH_FFMPEG OFF CACHE BOOL "SDL client")
set (WITH_SWSCALE OFF CACHE BOOL "SDL client")
set (BUILD_SHARED_LIBS OFF CACHE BOOL "SDL client")

View File

@ -13,12 +13,8 @@ message("project ${PROJECT_NAME} is using version ${PROJECT_VERSION}")
cmake_policy(SET CMP0026 OLD)
cmake_policy(SET CMP0045 OLD)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE)
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/)
include(PreventInSourceBuilds)
include(CommonConfigOptions)
find_library(FOUNDATION_LIBRARY Foundation REQUIRED)
find_library(COCOA_LIBRARY Cocoa REQUIRED)

View File

@ -11,7 +11,7 @@ project(MacFreeRDP
message("project ${PROJECT_NAME} is using version ${PROJECT_VERSION}")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/)
include(PreventInSourceBuilds)
include(CommonConfigOptions)
# Import libraries
find_library(FOUNDATION_LIBRARY Foundation REQUIRED)

View File

@ -33,32 +33,16 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
option(CMAKE_COLOR_MAKEFILE "colorful CMake makefile" ON)
option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/)
include(PreventInSourceBuilds)
include(CommonConfigOptions)
include(ConfigureFreeRDP)
include(GNUInstallDirsWrapper)
# RPATH configuration
include(ConfigureRPATH)
option(WITH_DEBUG_SDL_EVENTS "[dangerous, not for release builds!] Debug SDL events" OFF)
option(WITH_DEBUG_SDL_KBD_EVENTS "[dangerous, not for release builds!] Debug SDL keyboard events" OFF)
option(WITH_WIN_CONSOLE "Build ${PROJECT_NAME} with console support" ON)
option(WITH_SDL_LINK_SHARED "link SDL dynamic or static" ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE)
endif()
# Configure MSVC Runtime
include(MSVCRuntime)
if(WITH_WIN_CONSOLE)
set(WIN32_GUI_FLAG "")
else()

View File

@ -32,26 +32,11 @@ set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
option(CMAKE_COLOR_MAKEFILE "colorful CMake makefile" ON)
option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/)
include(PreventInSourceBuilds)
include(MSVCRuntime)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE)
endif()
include(CommonConfigOptions)
include(ConfigureFreeRDP)
include(GNUInstallDirsWrapper)
# RPATH configuration
include(ConfigureRPATH)
set(SRCS
tf_channels.c
tf_channels.h

View File

@ -32,24 +32,11 @@ set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
option(CMAKE_COLOR_MAKEFILE "colorful CMake makefile" ON)
option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/)
include(PreventInSourceBuilds)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE)
endif()
include(CommonConfigOptions)
include(ConfigureFreeRDP)
include(GNUInstallDirsWrapper)
# RPATH configuration
include(ConfigureRPATH)
find_package(X11 REQUIRED)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../resources)

View File

@ -27,12 +27,8 @@ project(iFreeRDP
message("project ${PROJECT_NAME} is using version ${PROJECT_VERSION}")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE)
endif()
list(APPEND CMAKE_MODULE_PATH ${PROJECT_CURRENT_SOURCE_DIR}/../../cmake/)
include(PreventInSourceBuilds)
include(CommonConfigOptions)
set(MODULE_NAME "iFreeRDP")
set(MODULE_PREFIX "IFREERDP_CLIENT")

View File

@ -0,0 +1,27 @@
option(CMAKE_COLOR_MAKEFILE "colorful CMake makefile" ON)
option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON)
option(WITH_LIBRARY_VERSIONING "Use library version triplet" ON)
option(WITH_BINARY_VERSIONING "Use binary versioning" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
# TODO: The detection does not properly work
#
#include(CheckIPOSupported)
#check_ipo_supported(RESULT supported OUTPUT error)
#if (NOT supported)
# message(WARNING "LTO not supported, got ${error}")
#endif()
option(CMAKE_INTERPROCEDURAL_OPTIMIZATION "build with link time optimization" OFF)
# Default to release build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default")
endif()
include(PreventInSourceBuilds)
include(GNUInstallDirsWrapper)
include(MSVCRuntime)
include(ConfigureRPATH)

View File

@ -31,27 +31,9 @@ if (NOT FREERDP_UNIFIED_BUILD)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
if (supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
option(CMAKE_COLOR_MAKEFILE "colorful CMake makefile" ON)
option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON)
set(WINPR_VERSION_MAJOR 3)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF)
option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF)
option(BUILD_TESTING "Build library unit tests" ON)
option(WITH_LIBRARY_VERSIONING "Use library version triplet" ON)
# Default to release build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE)
endif()
if(CMAKE_COMPILER_IS_GNUCC)
if(NOT EXPORT_ALL_SYMBOLS)
@ -65,7 +47,7 @@ endif()
# Include our extra modules
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/)
include(PreventInSourceBuilds)
include(CommonConfigOptions)
# Include cmake modules
include(CheckIncludeFiles)
@ -77,7 +59,6 @@ include(TestBigEndian)
include(CheckCmakeCompat)
include(FindFeature)
include(CheckCCompilerFlag)
include(GNUInstallDirsWrapper)
include(CMakePackageConfigHelpers)
include (SetFreeRDPCMakeInstallDir)

View File

@ -33,11 +33,19 @@ project(proxy-bitmap-filter-plugin
message("project ${PROJECT_NAME} is using version ${PROJECT_VERSION}")
project(proxy-bitmap-filter-plugin
VERSION ${FREERDP_DEFAULT_PROJECT_VERSION}
LANGUAGES CXX
)
message("project ${PROJECT_NAME} is using version ${PROJECT_VERSION}")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../cmake/)
include(CommonConfigOptions)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(MSVCRuntime)
add_library(${PROJECT_NAME} SHARED
bitmap-filter.cpp
)

View File

@ -37,13 +37,8 @@ set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
if (supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
include(MSVCRuntime)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../cmake/)
include(CommonConfigOptions)
add_library(${PROJECT_NAME} SHARED
cap_main.c

View File

@ -33,17 +33,12 @@ project(proxy-demo-plugin
message("project ${PROJECT_NAME} is using version ${PROJECT_VERSION}")
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
if (supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../cmake/)
include(CommonConfigOptions)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(MSVCRuntime)
add_library(${PROJECT_NAME} SHARED
demo.cpp
)

View File

@ -32,17 +32,12 @@ project(proxy-dyn-channel-dump-plugin
message("project ${PROJECT_NAME} is using version ${PROJECT_VERSION}")
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
if (supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../../cmake/)
include(CommonConfigOptions)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(MSVCRuntime)
add_library(${PROJECT_NAME} SHARED
dyn-channel-dump.cpp
)

View File

@ -31,20 +31,8 @@ if (NOT FREERDP_UNIFIED_BUILD)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
if (supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
option(CMAKE_COLOR_MAKEFILE "colorful CMake makefile" ON)
option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF)
option(BUILD_TESTING "Build library unit tests" ON)
option(WITH_LIBRARY_VERSIONING "Use library version triplet" ON)
if(CMAKE_COMPILER_IS_GNUCC)
if(NOT EXPORT_ALL_SYMBOLS)
@ -59,17 +47,10 @@ option(UWAC_HAVE_PIXMAN_REGION "Use PIXMAN or FreeRDP for region calculations" "
# Include our extra modules
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/)
include(PreventInSourceBuilds)
include(CommonConfigOptions)
# Check for cmake compatibility (enable/disable features)
include(FindFeature)
include(SetFreeRDPCMakeInstallDir)
include(CMakePackageConfigHelpers)
include(GNUInstallDirsWrapper)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE)
endif()
if (UWAC_FORCE_STATIC_BUILD)
set(BUILD_SHARED_LIBS OFF)

View File

@ -28,19 +28,10 @@ if (NOT FREERDP_UNIFIED_BUILD)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
include(CheckIPOSupported)
check_ipo_supported(RESULT supported OUTPUT error)
if (supported)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
option(CMAKE_COLOR_MAKEFILE "colorful CMake makefile" ON)
option(CMAKE_VERBOSE_MAKEFILE "verbose CMake makefile" ON)
option(CMAKE_POSITION_INDEPENDENT_CODE "build with position independent code (-fPIC or -fPIE)" ON)
option(WITH_LIBRARY_VERSIONING "Use library version triplet" ON)
include(CommonConfigOptions)
include(ConfigOptions)
# Default to build shared libs
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF)
if (EXPORT_ALL_SYMBOLS)
@ -54,8 +45,6 @@ if (NOT FREERDP_UNIFIED_BUILD)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
endif()
endif()
include(MSVCRuntime)
endif()
set(DEFAULT_DEBUG_OPTION OFF)
@ -127,14 +116,11 @@ include(CheckSymbolExists)
include(CheckStructHasMember)
include(TestBigEndian)
include(PreventInSourceBuilds)
# Check for cmake compatibility (enable/disable features)
include(CheckCmakeCompat)
include(FindFeature)
include(FeatureSummary)
include(CheckCCompilerFlag)
include(GNUInstallDirsWrapper)
include(InstallFreeRDPMan)
include(SetFreeRDPCMakeInstallDir)
include(CMakePackageConfigHelpers)
@ -325,11 +311,6 @@ if (WITH_PKCS11)
add_definitions("-DWITH_PKCS11")
endif()
# Default to release build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default" FORCE)
endif()
if(BUILD_SHARED_LIBS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINPR_DLL")
endif()