[cmake] unify compiler settings
move settings to cmake/CompilerFlags.cmake and cmake/CXXCompilerFlags.cmake
This commit is contained in:
parent
4216aa60a4
commit
4a2d0f96e3
143
CMakeLists.txt
143
CMakeLists.txt
@ -200,48 +200,9 @@ if(BUILD_TESTING_INTERNAL)
|
||||
add_compile_definitions(BUILD_TESTING_INTERNAL)
|
||||
elseif(BUILD_TESTING)
|
||||
set(EXPORT_ALL_SYMBOLS OFF CACHE BOOL "testing default" FORCE)
|
||||
else()
|
||||
option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF)
|
||||
endif()
|
||||
|
||||
if (EXPORT_ALL_SYMBOLS)
|
||||
# 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()
|
||||
include(ExportAllSymbols)
|
||||
|
||||
set(THREAD_PREFER_PTHREAD_FLAG TRUE)
|
||||
|
||||
@ -249,92 +210,6 @@ if(NOT IOS)
|
||||
find_package(Threads REQUIRED)
|
||||
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})
|
||||
|
||||
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)
|
||||
add_compile_definitions(UNICODE _UNICODE)
|
||||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
|
||||
@ -443,12 +318,6 @@ if(ANDROID)
|
||||
endif(WITH_GPROF)
|
||||
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)
|
||||
set(WAYLAND_FEATURE_TYPE "RECOMMENDED")
|
||||
else()
|
||||
@ -628,16 +497,6 @@ else()
|
||||
set(FREERDP_PROXY_PLUGINDIR "${PROXY_PLUGINDIR}")
|
||||
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
|
||||
|
||||
include(CTest)
|
||||
|
@ -4,10 +4,9 @@ function(CFlagsToVar NAME CFG)
|
||||
string(REPLACE "${CMAKE_SOURCE_DIR}" "<src dir>" C_FLAGS "${C_FLAGS}")
|
||||
string(REPLACE "${CMAKE_BINARY_DIR}" "<build dir>" C_FLAGS "${C_FLAGS}")
|
||||
|
||||
string(APPEND C_FLAGS " ${CMAKE_C_FLAGS_${UCFG}}")
|
||||
string(APPEND C_FLAGS " ${CMAKE_C_FLAGS_${UCFG}}")
|
||||
|
||||
string(REPLACE "\$" "\\\$" C_FLAGS "${C_FLAGS}")
|
||||
string(REPLACE "\"" "\\\"" C_FLAGS "${C_FLAGS}")
|
||||
set(${NAME} ${C_FLAGS} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(CommonCompilerFlags)
|
||||
|
||||
macro (checkCXXFlag FLAG)
|
||||
check_cxx_compiler_flag("${FLAG}" CXXFLAG${FLAG})
|
||||
@ -9,9 +10,6 @@ macro (checkCXXFlag FLAG)
|
||||
endif()
|
||||
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 (MSVC)
|
||||
# Remove previous warning definitions,
|
||||
@ -25,24 +23,9 @@ if (ENABLE_WARNING_VERBOSE)
|
||||
string (REGEX REPLACE "(^| )[/-]W[ ]*[1-9]" " "
|
||||
"${flags_var_to_scrub}" "${${flags_var_to_scrub}}")
|
||||
endforeach()
|
||||
|
||||
set(C_WARNING_FLAGS
|
||||
/W4
|
||||
/wo4324
|
||||
)
|
||||
else()
|
||||
set(C_WARNING_FLAGS
|
||||
-Weverything
|
||||
-Wall
|
||||
-Wpedantic
|
||||
-Wno-padded
|
||||
-Wno-switch-enum
|
||||
-Wno-cast-align
|
||||
list(APPEND COMMON_COMPILER_FLAGS
|
||||
-Wno-declaration-after-statement
|
||||
-Wno-unsafe-buffer-usage
|
||||
-Wno-reserved-identifier
|
||||
-Wno-covered-switch-default
|
||||
-Wno-disabled-macro-expansion
|
||||
-Wno-ctad-maybe-unsupported
|
||||
-Wno-c++98-compat
|
||||
-Wno-c++98-compat-pedantic
|
||||
@ -51,18 +34,11 @@ if (ENABLE_WARNING_VERBOSE)
|
||||
-Wno-gnu-zero-variadic-macro-arguments
|
||||
)
|
||||
endif()
|
||||
|
||||
foreach(FLAG ${C_WARNING_FLAGS})
|
||||
CheckCXXFlag(${FLAG})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
||||
if (ENABLE_WARNING_ERROR)
|
||||
CheckCXXFlag(-Werror)
|
||||
endif()
|
||||
|
||||
CheckCXXFlag(-fno-omit-frame-pointer)
|
||||
foreach(FLAG ${COMMON_COMPILER_FLAGS})
|
||||
CheckCXXFlag(${FLAG})
|
||||
endforeach()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=.>)
|
||||
@ -78,6 +54,13 @@ if (WIN32)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-DNOMINMAX>)
|
||||
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")
|
||||
message("Using CXXFLAGS ${CMAKE_CXX_FLAGS}")
|
||||
message("Using CXXFLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
|
28
cmake/CheckAndSetFlag.cmake
Normal file
28
cmake/CheckAndSetFlag.cmake
Normal 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()
|
@ -36,6 +36,7 @@ function(cleaning_configure_file RSRC RDST)
|
||||
configure_file(${SRC} ${DST} ${ARGN})
|
||||
|
||||
string(SHA256 DST_HASH "${DST}")
|
||||
string(SUBSTRING "${DST_HASH}" 0 8 DST_HASH)
|
||||
if (NOT TARGET ct-${DST_HASH})
|
||||
add_custom_target(ct-${DST_HASH} ALL
|
||||
COMMAND ${CMAKE_COMMAND} "-E" "make_directory" "${DST_DIR}"
|
||||
|
50
cmake/CommonCompilerFlags.cmake
Normal file
50
cmake/CommonCompilerFlags.cmake
Normal file
@ -0,0 +1,50 @@
|
||||
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")
|
||||
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()
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
include(CheckCCompilerFlag)
|
||||
include(CommonCompilerFlags)
|
||||
|
||||
macro (checkCFlag FLAG)
|
||||
CHECK_C_COMPILER_FLAG("${FLAG}" CFLAG${FLAG})
|
||||
@ -9,9 +10,6 @@ macro (checkCFlag FLAG)
|
||||
endif()
|
||||
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 (MSVC)
|
||||
# Remove previous warning definitions,
|
||||
@ -25,47 +23,31 @@ if (ENABLE_WARNING_VERBOSE)
|
||||
string (REGEX REPLACE "(^| )[/-]W[ ]*[1-9]" " "
|
||||
"${flags_var_to_scrub}" "${${flags_var_to_scrub}}")
|
||||
endforeach()
|
||||
|
||||
set(C_WARNING_FLAGS
|
||||
/W4
|
||||
/wo4324
|
||||
)
|
||||
else()
|
||||
set(C_WARNING_FLAGS
|
||||
-Weverything
|
||||
-Wall
|
||||
-Wpedantic
|
||||
-Wno-padded
|
||||
-Wno-switch-enum
|
||||
-Wno-cast-align
|
||||
list(APPEND COMMON_COMPILER_FLAGS
|
||||
-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()
|
||||
|
||||
foreach(FLAG ${C_WARNING_FLAGS})
|
||||
CheckCFlag(${FLAG})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if (ENABLE_WARNING_ERROR)
|
||||
CheckCFlag(-Werror)
|
||||
endif()
|
||||
list(APPEND COMMON_COMPILER_FLAGS
|
||||
-Wimplicit-function-declaration
|
||||
)
|
||||
|
||||
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")
|
||||
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>)
|
||||
# Android profiling
|
||||
if(ANDROID)
|
||||
if(WITH_GPROF)
|
||||
CheckAndSetFlag(-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()
|
||||
|
||||
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "default CFLAGS")
|
||||
|
42
cmake/CompilerSanitizerOptions.cmake
Normal file
42
cmake/CompilerSanitizerOptions.cmake
Normal file
@ -0,0 +1,42 @@
|
||||
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()
|
||||
|
||||
|
@ -31,16 +31,7 @@ option(WITH_JPEG "Use JPEG decoding." OFF)
|
||||
|
||||
include(CompilerDetect)
|
||||
|
||||
if(NOT 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(WIN32)
|
||||
if(NOT UWP)
|
||||
option(WITH_MEDIA_FOUNDATION "Enable H264 media foundation decoder." OFF)
|
||||
endif()
|
||||
|
13
cmake/ExportAllSymbols.cmake
Normal file
13
cmake/ExportAllSymbols.cmake
Normal file
@ -0,0 +1,13 @@
|
||||
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()
|
||||
|
||||
|
@ -32,15 +32,9 @@ if (NOT FREERDP_UNIFIED_BUILD)
|
||||
set(CMAKE_C_EXTENSIONS ON)
|
||||
|
||||
set(WINPR_VERSION_MAJOR 3)
|
||||
option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF)
|
||||
option(BUILD_TESTING_INTERNAL "Build library unit tests" ON)
|
||||
|
||||
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()
|
||||
include(ExportAllSymbols)
|
||||
else()
|
||||
set(WINPR_VERSION_MAJOR ${FREERDP_VERSION_MAJOR})
|
||||
endif()
|
||||
|
@ -1 +0,0 @@
|
||||
fun:RAND*
|
@ -31,15 +31,9 @@ if (NOT FREERDP_UNIFIED_BUILD)
|
||||
set(CMAKE_C_STANDARD_REQUIRED 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)
|
||||
|
||||
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()
|
||||
include(ExportAllSymbols)
|
||||
endif()
|
||||
|
||||
option(UWAC_FORCE_STATIC_BUILD "Force UWAC to be build as static libary (recommended)" OFF)
|
||||
|
@ -39,19 +39,7 @@ if (NOT FREERDP_UNIFIED_BUILD)
|
||||
endif()
|
||||
|
||||
# Default to build shared libs
|
||||
option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF)
|
||||
|
||||
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()
|
||||
include(ExportAllSymbols)
|
||||
if(WITH_DEBUG_ALL)
|
||||
message(WARNING "WITH_DEBUG_ALL=ON, the build will be slow and might leak sensitive information, do not use with release builds!")
|
||||
set(DEFAULT_DEBUG_OPTION "ON" CACHE INTERNAL "debug default")
|
||||
|
Loading…
Reference in New Issue
Block a user