[cmake] refactor configuration

* Split common stuff to reusable files
* Disable INTERPROCEDURAL_OPTIMIZATION for SDL2/3 resource targets
This commit is contained in:
akallabeth
2024-11-12 09:36:25 +01:00
parent 2bb75c195b
commit 0ae7c4b52d
19 changed files with 181 additions and 277 deletions

View File

@@ -199,48 +199,9 @@ if(BUILD_TESTING_INTERNAL)
add_compile_definitions(BUILD_TESTING_INTERNAL) add_compile_definitions(BUILD_TESTING_INTERNAL)
elseif(BUILD_TESTING) elseif(BUILD_TESTING)
set(EXPORT_ALL_SYMBOLS OFF CACHE BOOL "testing default" FORCE) set(EXPORT_ALL_SYMBOLS OFF CACHE BOOL "testing default" FORCE)
else()
option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF)
endif() endif()
if(EXPORT_ALL_SYMBOLS) include(ExportAllSymbols)
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_compile_definitions(EXPORT_ALL_SYMBOLS)
endif(EXPORT_ALL_SYMBOLS)
# Compiler-specific flags
if(CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "i686")
check_symbol_exists(__x86_64__ "" IS_X86_64)
if(IS_X86_64)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=i686")
endif()
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
if(NOT EXPORT_ALL_SYMBOLS)
message(STATUS "GCC default symbol visibility: hidden")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
endif()
check_c_compiler_flag(-Wimplicit-function-declaration Wimplicit-function-declaration)
if(Wimplicit-function-declaration)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wimplicit-function-declaration")
endif()
if(NOT OPENBSD)
check_c_compiler_flag(-Wredundant-decls Wredundant-decls)
if(Wredundant-decls)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wredundant-decls")
endif()
endif()
add_compile_definitions("$<$<CONFIG:Release>:NDEBUG>")
add_compile_definitions("$<$<CONFIG:MinSizeRel>:NDEBUG>")
add_compile_options("$<$<CONFIG:RelWithDebInfo>:-g>")
add_compile_options("$<$<CONFIG:Debug>:-g>")
endif()
set(THREAD_PREFER_PTHREAD_FLAG TRUE) set(THREAD_PREFER_PTHREAD_FLAG TRUE)
@@ -248,99 +209,6 @@ if(NOT IOS)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
endif() endif()
# Enable address sanitizer, where supported and when required
if(CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_REQUIRED_LINK_OPTIONS_SAVED ${CMAKE_REQUIRED_LINK_OPTIONS})
file(WRITE ${PROJECT_BINARY_DIR}/foo.txt "")
if(WITH_SANITIZE_ADDRESS)
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "-fsanitize=address")
check_c_compiler_flag("-fsanitize=address" fsanitize-address)
check_c_compiler_flag("-fsanitize-blacklist=${PROJECT_BINARY_DIR}/foo.txt" fsanitize-blacklist)
check_c_compiler_flag("-fsanitize-address-use-after-scope" fsanitize-address-use-after-scope)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
if(fsanitize-blacklist)
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/scripts/blacklist-address-sanitizer.txt"
)
endif(fsanitize-blacklist)
if(fsanitize-address-use-after-scope)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-address-use-after-scope")
endif(fsanitize-address-use-after-scope)
elseif(WITH_SANITIZE_MEMORY)
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "-fsanitize=memory")
check_c_compiler_flag("-fsanitize=memory" fsanitize-memory)
check_c_compiler_flag("-fsanitize-blacklist=${PROJECT_BINARY_DIR}/foo.txt" fsanitize-blacklist)
check_c_compiler_flag("-fsanitize-memory-use-after-dtor" fsanitize-memory-use-after-dtor)
check_c_compiler_flag("-fsanitize-memory-track-origins" fsanitize-memory-track-origins)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=memory")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=memory")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory")
if(fsanitize-blacklist)
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/scripts/blacklist-memory-sanitizer.txt"
)
endif(fsanitize-blacklist)
if(fsanitize-memory-use-after-dtor)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-memory-use-after-dtor")
endif(fsanitize-memory-use-after-dtor)
if(fsanitize-memory-track-origins)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize-memory-track-origins")
endif(fsanitize-memory-track-origins)
elseif(WITH_SANITIZE_THREAD)
list(APPEND CMAKE_REQUIRED_LINK_OPTIONS "-fsanitize=thread")
check_c_compiler_flag("-fsanitize=thread" fsanitize-thread)
check_c_compiler_flag("-fsanitize-blacklist=${PROJECT_BINARY_DIR}/foo.txt" fsanitize-blacklist)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread")
if(fsanitize-blacklist)
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/scripts/blacklist-thread-sanitizer.txt"
)
endif(fsanitize-blacklist)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=thread")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread")
endif()
file(REMOVE ${PROJECT_BINARY_DIR}/foo.txt)
set(CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS_SAVED})
option(WITH_NO_UNDEFINED "compile with -Wl,--no-undefined" OFF)
if(WITH_NO_UNDEFINED)
check_c_compiler_flag(-Wl,--no-undefined no-undefined)
if(no-undefined)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
endif()
endif()
endif()
if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
add_compile_options("$<$<CONFIG:Release>:/Zi>")
add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE)
endif()
if(ANDROID)
# workaround for https://github.com/android-ndk/ndk/issues/243
string(REPLACE "-g " "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
endif()
if(WIN32) if(WIN32)
add_compile_definitions(UNICODE _UNICODE) add_compile_definitions(UNICODE _UNICODE)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS) add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
@@ -451,12 +319,6 @@ if(ANDROID)
endif(WITH_GPROF) endif(WITH_GPROF)
endif() endif()
if(WITH_VALGRIND_MEMCHECK)
check_include_files(valgrind/memcheck.h FREERDP_HAVE_VALGRIND_MEMCHECK_H)
else()
unset(FREERDP_HAVE_VALGRIND_MEMCHECK_H CACHE)
endif()
if(UNIX OR CYGWIN) if(UNIX OR CYGWIN)
set(WAYLAND_FEATURE_TYPE "RECOMMENDED") set(WAYLAND_FEATURE_TYPE "RECOMMENDED")
else() else()
@@ -639,15 +501,6 @@ else()
set(FREERDP_PROXY_PLUGINDIR "${PROXY_PLUGINDIR}") set(FREERDP_PROXY_PLUGINDIR "${PROXY_PLUGINDIR}")
endif() endif()
# Android profiling
if(ANDROID)
if(WITH_GPROF)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg")
set(PROFILER_LIBRARIES "${FREERDP_EXTERNAL_PROFILER_PATH}/obj/local/${ANDROID_ABI}/libandroid-ndk-profiler.a")
include_directories(SYSTEM "${FREERDP_EXTERNAL_PROFILER_PATH}")
endif()
endif()
# Unit Tests # Unit Tests
include(CTest) include(CTest)

View File

@@ -26,5 +26,5 @@ else()
target_link_libraries(sdl2_client_res ${SDL2_LIBRARIES}) target_link_libraries(sdl2_client_res ${SDL2_LIBRARIES})
endif() endif()
set_property(TARGET sdl2_client_res PROPERTY POSITION_INDEPENDENT_CODE ON) set_target_properties(sdl2_client_res PROPERTIES POSITION_INDEPENDENT_CODE ON INTERPROCEDURAL_OPTIMIZATION OFF)
target_link_libraries(sdl2_client_res sdl-common-client-res) target_link_libraries(sdl2_client_res sdl-common-client-res)

View File

@@ -26,4 +26,4 @@ endif()
target_link_libraries(sdl3_client_res sdl-common-client-res) target_link_libraries(sdl3_client_res sdl-common-client-res)
set_property(TARGET sdl3_client_res PROPERTY POSITION_INDEPENDENT_CODE ON) set_target_properties(sdl3_client_res PROPERTIES POSITION_INDEPENDENT_CODE ON INTERPROCEDURAL_OPTIMIZATION OFF)

View File

@@ -1,4 +1,5 @@
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
include(CommonCompilerFlags)
macro(checkCXXFlag FLAG) macro(checkCXXFlag FLAG)
check_cxx_compiler_flag("${FLAG}" CXXFLAG${FLAG}) check_cxx_compiler_flag("${FLAG}" CXXFLAG${FLAG})
@@ -9,9 +10,6 @@ macro(checkCXXFlag FLAG)
endif() endif()
endmacro() endmacro()
option(ENABLE_WARNING_VERBOSE "enable -Weveryting (and some exceptions) for compile" OFF)
option(ENABLE_WARNING_ERROR "enable -Werror for compile" OFF)
if(ENABLE_WARNING_VERBOSE) if(ENABLE_WARNING_VERBOSE)
if(MSVC) if(MSVC)
# Remove previous warning definitions, # Remove previous warning definitions,
@@ -21,57 +19,37 @@ if(ENABLE_WARNING_VERBOSE)
) )
string(REGEX REPLACE "(^| )[/-]W[ ]*[1-9]" " " "${flags_var_to_scrub}" "${${flags_var_to_scrub}}") string(REGEX REPLACE "(^| )[/-]W[ ]*[1-9]" " " "${flags_var_to_scrub}" "${${flags_var_to_scrub}}")
endforeach() endforeach()
set(C_WARNING_FLAGS /W4 /wo4324)
else() else()
set(C_WARNING_FLAGS list(
-Weverything APPEND
-Wall COMMON_COMPILER_FLAGS
-Wpedantic -Wno-declaration-after-statement
-Wno-padded -Wno-ctad-maybe-unsupported
-Wno-switch-enum -Wno-c++98-compat
-Wno-cast-align -Wno-c++98-compat-pedantic
-Wno-declaration-after-statement -Wno-pre-c++17-compat
-Wno-unsafe-buffer-usage -Wno-exit-time-destructors
-Wno-reserved-identifier -Wno-gnu-zero-variadic-macro-arguments
-Wno-covered-switch-default
-Wno-disabled-macro-expansion
-Wno-ctad-maybe-unsupported
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-pre-c++17-compat
-Wno-exit-time-destructors
-Wno-gnu-zero-variadic-macro-arguments
) )
endif() endif()
foreach(FLAG ${C_WARNING_FLAGS})
checkcxxflag(${FLAG})
endforeach()
endif() endif()
if(ENABLE_WARNING_ERROR) foreach(FLAG ${COMMON_COMPILER_FLAGS})
checkcxxflag(-Werror) checkcxxflag(${FLAG})
endif() endforeach()
checkcxxflag(-fno-omit-frame-pointer)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=.>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=.>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fdebug-prefix-map=${CMAKE_BINARY_DIR}=./build>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fmacro-prefix-map=${CMAKE_BINARY_DIR}=./build>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-ffile-prefix-map=${CMAKE_BINARY_DIR}=./build>)
endif()
endif()
# https://stackoverflow.com/questions/4913922/possible-problems-with-nominmax-on-visual-c # https://stackoverflow.com/questions/4913922/possible-problems-with-nominmax-on-visual-c
if(WIN32) if(WIN32)
add_compile_definitions($<$<COMPILE_LANGUAGE:CXX>:NOMINMAX>) add_compile_definitions($<$<COMPILE_LANGUAGE:CXX>:NOMINMAX>)
endif() endif()
if(MSVC)
add_compile_options(/Gd)
add_compile_options("$<$<CONFIG:Debug>:/Zi>")
add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE)
endif()
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "default CXXFLAGS") set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "default CXXFLAGS")
message("Using CXXFLAGS ${CMAKE_CXX_FLAGS}") message("Using CXXFLAGS ${CMAKE_CXX_FLAGS}")
message("Using CXXFLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}") message("Using CXXFLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}")

View File

@@ -0,0 +1,28 @@
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
macro(CheckAndSetFlag FLAG)
if(FLAG)
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
unset(C_FLAG)
unset(CXX_FLAG)
if("C" IN_LIST languages)
check_c_compiler_flag("${FLAG}" C_FLAG)
if(C_FLAG)
string(APPEND CMAKE_C_FLAGS " ${FLAG}")
endif()
endif()
if("CXX" IN_LIST languages)
check_cxx_compiler_flag("${FLAG}" CXX_FLAG)
if(CXX_FLAG)
string(APPEND CMAKE_CXX_FLAGS " ${FLAG}")
endif()
endif()
if(NOT C_FLAG AND NOT CXX_FLAG)
message(WARNING "compiler does not support ${FLAG}")
endif()
endif()
endmacro()

View File

@@ -60,6 +60,7 @@ function(cleaning_configure_file RSRC RDST)
# Create a target to recreate the configuration file if something changes. # Create a target to recreate the configuration file if something changes.
string(SHA256 DST_HASH "${DST}") string(SHA256 DST_HASH "${DST}")
string(SUBSTRING "${DST_HASH}" 0 8 DST_HASH)
if(NOT TARGET ct-${DST_HASH}) if(NOT TARGET ct-${DST_HASH})
add_custom_target( add_custom_target(
ct-${DST_HASH} COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${DST_DIR}" ct-${DST_HASH} COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${DST_DIR}"

View File

@@ -0,0 +1,46 @@
include(CheckAndSetFlag)
option(ENABLE_WARNING_VERBOSE "enable -Weveryting (and some exceptions) for compile" OFF)
option(ENABLE_WARNING_ERROR "enable -Werror for compile" OFF)
set(COMMON_COMPILER_FLAGS "")
if(ENABLE_WARNING_VERBOSE)
if(MSVC)
list(APPEND COMMON_COMPILER_FLAGS /W4 /wo4324)
else()
list(
APPEND
COMMON_COMPILER_FLAGS
-Weverything
-Wall
-Wpedantic
-Wno-padded
-Wno-switch-enum
-Wno-cast-align
-Wno-unsafe-buffer-usage
-Wno-reserved-identifier
-Wno-covered-switch-default
-Wno-disabled-macro-expansion
)
endif()
endif()
if(ENABLE_WARNING_ERROR)
list(APPEND COMMON_COMPILER_FLAGS -Werror)
endif()
list(APPEND COMMON_COMPILER_FLAGS -fno-omit-frame-pointer -Wredundant-decls)
include(ExportAllSymbols)
include(CompilerSanitizerOptions)
if(CMAKE_C_COMPILER_ID MATCHES ".*Clang.*" OR (CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION
VERSION_GREATER_EQUAL 10)
)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=.>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=.>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fdebug-prefix-map=${CMAKE_BINARY_DIR}=./build>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fmacro-prefix-map=${CMAKE_BINARY_DIR}=./build>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-ffile-prefix-map=${CMAKE_BINARY_DIR}=./build>)
endif()

View File

@@ -1,4 +1,5 @@
include(CheckCCompilerFlag) include(CheckCCompilerFlag)
include(CommonCompilerFlags)
macro(checkCFlag FLAG) macro(checkCFlag FLAG)
check_c_compiler_flag("${FLAG}" CFLAG${FLAG}) check_c_compiler_flag("${FLAG}" CFLAG${FLAG})
@@ -9,9 +10,6 @@ macro(checkCFlag FLAG)
endif() endif()
endmacro() endmacro()
option(ENABLE_WARNING_VERBOSE "enable -Weveryting (and some exceptions) for compile" OFF)
option(ENABLE_WARNING_ERROR "enable -Werror for compile" OFF)
if(ENABLE_WARNING_VERBOSE) if(ENABLE_WARNING_VERBOSE)
if(MSVC) if(MSVC)
# Remove previous warning definitions, # Remove previous warning definitions,
@@ -21,45 +19,25 @@ if(ENABLE_WARNING_VERBOSE)
) )
string(REGEX REPLACE "(^| )[/-]W[ ]*[1-9]" " " "${flags_var_to_scrub}" "${${flags_var_to_scrub}}") string(REGEX REPLACE "(^| )[/-]W[ ]*[1-9]" " " "${flags_var_to_scrub}" "${${flags_var_to_scrub}}")
endforeach() endforeach()
set(C_WARNING_FLAGS /W4 /wo4324)
else() else()
set(C_WARNING_FLAGS list(APPEND COMMON_COMPILER_FLAGS -Wno-declaration-after-statement -Wno-pre-c11-compat
-Weverything -Wno-gnu-zero-variadic-macro-arguments
-Wall
-Wpedantic
-Wno-padded
-Wno-switch-enum
-Wno-cast-align
-Wno-declaration-after-statement
-Wno-unsafe-buffer-usage
-Wno-reserved-identifier
-Wno-covered-switch-default
-Wno-disabled-macro-expansion
-Wno-pre-c11-compat
-Wno-gnu-zero-variadic-macro-arguments
) )
endif() endif()
foreach(FLAG ${C_WARNING_FLAGS})
checkcflag(${FLAG})
endforeach()
endif() endif()
if(ENABLE_WARNING_ERROR) list(APPEND COMMON_COMPILER_FLAGS -Wimplicit-function-declaration)
checkcflag(-Werror)
endif()
checkcflag(-fno-omit-frame-pointer) foreach(FLAG ${COMMON_COMPILER_FLAGS})
checkcflag(${FLAG})
endforeach()
if(CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "GNU") # Android profiling
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10) if(ANDROID)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=.>) if(WITH_GPROF)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=.>) checkandsetflag(-pg)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.>) set(PROFILER_LIBRARIES "${FREERDP_EXTERNAL_PROFILER_PATH}/obj/local/${ANDROID_ABI}/libandroid-ndk-profiler.a")
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fdebug-prefix-map=${CMAKE_BINARY_DIR}=./build>) include_directories(SYSTEM "${FREERDP_EXTERNAL_PROFILER_PATH}")
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fmacro-prefix-map=${CMAKE_BINARY_DIR}=./build>)
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-ffile-prefix-map=${CMAKE_BINARY_DIR}=./build>)
endif() endif()
endif() endif()

View File

@@ -0,0 +1,48 @@
include(CMakeDependentOption)
cmake_dependent_option(
WITH_VALGRIND_MEMCHECK "Compile with valgrind helpers." OFF
"NOT WITH_SANITIZE_ADDRESS; NOT WITH_SANITIZE_MEMORY; NOT WITH_SANITIZE_THREAD" OFF
)
cmake_dependent_option(
WITH_SANITIZE_ADDRESS "Compile with gcc/clang address sanitizer." OFF
"NOT WITH_VALGRIND_MEMCHECK; NOT WITH_SANITIZE_MEMORY; NOT WITH_SANITIZE_THREAD" OFF
)
cmake_dependent_option(
WITH_SANITIZE_MEMORY "Compile with gcc/clang memory sanitizer." OFF
"NOT WITH_VALGRIND_MEMCHECK; NOT WITH_SANITIZE_ADDRESS; NOT WITH_SANITIZE_THREAD" OFF
)
cmake_dependent_option(
WITH_SANITIZE_THREAD "Compile with gcc/clang thread sanitizer." OFF
"NOT WITH_VALGRIND_MEMCHECK; NOT WITH_SANITIZE_ADDRESS; NOT WITH_SANITIZE_MEMORY" OFF
)
if(WITH_VALGRIND_MEMCHECK)
check_include_files(valgrind/memcheck.h FREERDP_HAVE_VALGRIND_MEMCHECK_H)
else()
unset(FREERDP_HAVE_VALGRIND_MEMCHECK_H CACHE)
endif()
# Enable address sanitizer, where supported and when required
if(CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_REQUIRED_LINK_OPTIONS_SAVED ${CMAKE_REQUIRED_LINK_OPTIONS})
file(WRITE ${PROJECT_BINARY_DIR}/foo.txt "")
if(WITH_SANITIZE_ADDRESS)
add_compile_options(-fsanitize=address)
add_compile_options(-fsanitize-address-use-after-scope)
add_link_options(-fsanitize=address)
elseif(WITH_SANITIZE_MEMORY)
add_compile_options(-fsanitize=memory)
add_compile_options(-fsanitize-memory-use-after-dtor)
add_compile_options(-fsanitize-memory-track-origins)
add_link_options(-fsanitize=memory)
elseif(WITH_SANITIZE_THREAD)
add_compile_options(-fsanitize=thread)
add_link_options(-fsanitize=thread)
endif()
option(WITH_NO_UNDEFINED "Add -Wl,--no-undefined" OFF)
if(WITH_NO_UNDEFINED)
add_link_options(-Wl,--no-undefined)
endif()
endif()

View File

@@ -26,24 +26,7 @@ option(WITH_JPEG "Use JPEG decoding." OFF)
include(CompilerDetect) include(CompilerDetect)
if(NOT WIN32) if(WIN32)
cmake_dependent_option(
WITH_VALGRIND_MEMCHECK "Compile with valgrind helpers." OFF
"NOT WITH_SANITIZE_ADDRESS; NOT WITH_SANITIZE_MEMORY; NOT WITH_SANITIZE_THREAD" OFF
)
cmake_dependent_option(
WITH_SANITIZE_ADDRESS "Compile with gcc/clang address sanitizer." OFF
"NOT WITH_VALGRIND_MEMCHECK; NOT WITH_SANITIZE_MEMORY; NOT WITH_SANITIZE_THREAD" OFF
)
cmake_dependent_option(
WITH_SANITIZE_MEMORY "Compile with gcc/clang memory sanitizer." OFF
"NOT WITH_VALGRIND_MEMCHECK; NOT WITH_SANITIZE_ADDRESS; NOT WITH_SANITIZE_THREAD" OFF
)
cmake_dependent_option(
WITH_SANITIZE_THREAD "Compile with gcc/clang thread sanitizer." OFF
"NOT WITH_VALGRIND_MEMCHECK; NOT WITH_SANITIZE_ADDRESS; NOT WITH_SANITIZE_MEMORY" OFF
)
else()
if(NOT UWP) if(NOT UWP)
option(WITH_MEDIA_FOUNDATION "Enable H264 media foundation decoder." OFF) option(WITH_MEDIA_FOUNDATION "Enable H264 media foundation decoder." OFF)
endif() endif()

View File

@@ -0,0 +1,11 @@
include(CheckAndSetFlag)
option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF)
if(EXPORT_ALL_SYMBOLS)
add_compile_definitions(EXPORT_ALL_SYMBOLS)
else()
message(STATUS "${} default symbol visibility: hidden")
checkandsetflag(-fvisibility=hidden)
endif()

View File

@@ -1,5 +1,6 @@
#include <stdio.h> #include <stdio.h>
#include <winpr/user.h>
#include <winpr/crypto.h> #include <winpr/crypto.h>
#include <freerdp/settings.h> #include <freerdp/settings.h>

View File

@@ -32,15 +32,9 @@ if(NOT FREERDP_UNIFIED_BUILD)
set(CMAKE_C_EXTENSIONS ON) set(CMAKE_C_EXTENSIONS ON)
set(WINPR_VERSION_MAJOR 3) set(WINPR_VERSION_MAJOR 3)
option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF)
option(BUILD_TESTING_INTERNAL "Build library unit tests" ON) option(BUILD_TESTING_INTERNAL "Build library unit tests" ON)
if(CMAKE_COMPILER_IS_GNUCC) include(ExportAllSymbols)
if(NOT EXPORT_ALL_SYMBOLS)
message(STATUS "GCC default symbol visibility: hidden")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
endif()
endif()
else() else()
set(WINPR_VERSION_MAJOR ${FREERDP_VERSION_MAJOR}) set(WINPR_VERSION_MAJOR ${FREERDP_VERSION_MAJOR})
endif() endif()
@@ -62,7 +56,7 @@ include(CheckCCompilerFlag)
include(CMakePackageConfigHelpers) include(CMakePackageConfigHelpers)
include(SetFreeRDPCMakeInstallDir) include(SetFreeRDPCMakeInstallDir)
option(RDTK_FORCE_STATIC_BUILD "Force RDTK to be built as static library (recommended)" OFF) option(RDTK_FORCE_STATIC_BUILD "Force RDTK to be build as static library (recommended)" OFF)
if(RDTK_FORCE_STATIC_BUILD) if(RDTK_FORCE_STATIC_BUILD)
set(BUILD_SHARED_LIBS OFF) set(BUILD_SHARED_LIBS OFF)
endif() endif()

View File

@@ -1 +0,0 @@
fun:RAND*

View File

@@ -31,18 +31,12 @@ if(NOT FREERDP_UNIFIED_BUILD)
set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON) set(CMAKE_C_EXTENSIONS ON)
option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF)
option(BUILD_TESTING_INTERNAL "Build library unit tests" ON) option(BUILD_TESTING_INTERNAL "Build library unit tests" ON)
if(CMAKE_COMPILER_IS_GNUCC) include(ExportAllSymbols)
if(NOT EXPORT_ALL_SYMBOLS)
message(STATUS "GCC default symbol visibility: hidden")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
endif()
endif()
endif() endif()
option(UWAC_FORCE_STATIC_BUILD "Force UWAC to be built as static library (recommended)" OFF) option(UWAC_FORCE_STATIC_BUILD "Force UWAC to be build as static library (recommended)" OFF)
option(UWAC_HAVE_PIXMAN_REGION "Use PIXMAN or FreeRDP for region calculations" "NOT FREERDP_UNIFIED_BUILD") option(UWAC_HAVE_PIXMAN_REGION "Use PIXMAN or FreeRDP for region calculations" "NOT FREERDP_UNIFIED_BUILD")
# Include our extra modules # Include our extra modules

View File

@@ -39,19 +39,7 @@ if(NOT FREERDP_UNIFIED_BUILD)
endif() endif()
# Default to build shared libs # Default to build shared libs
option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF) include(ExportAllSymbols)
if(EXPORT_ALL_SYMBOLS)
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_compile_definitions(EXPORT_ALL_SYMBOLS)
endif()
if(CMAKE_COMPILER_IS_GNUCC)
if(NOT EXPORT_ALL_SYMBOLS)
message(STATUS "GCC default symbol visibility: hidden")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
endif()
endif()
if(WITH_DEBUG_ALL) if(WITH_DEBUG_ALL)
message( message(
WARNING WARNING

View File

@@ -27,7 +27,9 @@
* Standard Clipboard Formats * Standard Clipboard Formats
*/ */
#ifndef _WIN32 #ifdef _WIN32
#include <winuser.h>
#else
#define MB_OK 0x00000000L #define MB_OK 0x00000000L
#define MB_OKCANCEL 0x00000001L #define MB_OKCANCEL 0x00000001L