Changeset View
Changeset View
Standalone View
Standalone View
src/CMakeLists.txt
Show First 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | if(ENABLE_HARDENING) | ||||
# Enable ASLR (these flags are primarily targeting MinGw) | # Enable ASLR (these flags are primarily targeting MinGw) | ||||
add_linker_flags(-Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va) | add_linker_flags(-Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va) | ||||
# Make the relocated sections read-only | # Make the relocated sections read-only | ||||
add_linker_flags(-Wl,-z,relro -Wl,-z,now) | add_linker_flags(-Wl,-z,relro -Wl,-z,now) | ||||
# CMake provides the POSITION_INDEPENDENT_CODE property to set PIC/PIE. | # CMake provides the POSITION_INDEPENDENT_CODE property to set PIC/PIE. | ||||
# Unfortunately setting the -pie linker flag this way require CMake >= 3.14, | |||||
# which is not widely distributed at the time of writing. | |||||
# FIXME: remove the fallback case when cmake >= 3.14 get enforced. | |||||
if(POLICY CMP0083) | |||||
cmake_policy(SET CMP0083 NEW) | cmake_policy(SET CMP0083 NEW) | ||||
include(CheckPIESupported) | include(CheckPIESupported) | ||||
check_pie_supported() | check_pie_supported() | ||||
elseif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows") | |||||
check_linker_flag(PIE_IS_SUPPORTED -pie) | |||||
if(${PIE_IS_SUPPORTED}) | |||||
add_link_options($<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:-pie>) | |||||
endif() | |||||
endif() | |||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | ||||
# MinGw provides its own libssp for stack smashing protection | # MinGw provides its own libssp for stack smashing protection | ||||
link_libraries(ssp) | link_libraries(ssp) | ||||
endif() | endif() | ||||
endif() | endif() | ||||
if(ENABLE_PROFILING MATCHES "gprof") | if(ENABLE_PROFILING MATCHES "gprof") | ||||
▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Lines | |||||
# Target specific configs | # Target specific configs | ||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | ||||
set(Boost_USE_STATIC_LIBS ON) | set(Boost_USE_STATIC_LIBS ON) | ||||
set(Boost_USE_STATIC_RUNTIME ON) | set(Boost_USE_STATIC_RUNTIME ON) | ||||
set(Boost_THREADAPI win32) | set(Boost_THREADAPI win32) | ||||
find_package(SHLWAPI REQUIRED) | find_package(SHLWAPI REQUIRED) | ||||
# We cannot use the imported target here, because cmake will introduce an | target_link_libraries(util SHLWAPI::shlwapi) | ||||
# -isystem compilation directive and cause the build to fail with MinGw. | |||||
# This comes from a couple cmake bugs: | |||||
# - https://gitlab.kitware.com/cmake/cmake/issues/16291 | |||||
# - https://gitlab.kitware.com/cmake/cmake/issues/19095 | |||||
# These issues are solved from cmake 3.14.1. Once this version is enforced, | |||||
# the following can be used: | |||||
# target_link_libraries(util SHLWAPI::shlwapi) | |||||
target_link_libraries(util ${SHLWAPI_LIBRARIES}) | |||||
target_include_directories(util PUBLIC ${SHLWAPI_INCLUDE_DIRS}) | |||||
find_library(WS2_32_LIBRARY NAMES ws2_32) | find_library(WS2_32_LIBRARY NAMES ws2_32) | ||||
target_link_libraries(util ${WS2_32_LIBRARY}) | target_link_libraries(util ${WS2_32_LIBRARY}) | ||||
target_compile_definitions(util PUBLIC BOOST_THREAD_USE_LIB) | target_compile_definitions(util PUBLIC BOOST_THREAD_USE_LIB) | ||||
endif() | endif() | ||||
# Boost packages | # Boost packages | ||||
▲ Show 20 Lines • Show All 287 Lines • Show Last 20 Lines |