Changeset View
Changeset View
Standalone View
Standalone View
src/CMakeLists.txt
Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | |||||
if(ENABLE_STATIC_LIBSTDCXX) | if(ENABLE_STATIC_LIBSTDCXX) | ||||
add_linker_flag(-static-libstdc++) | add_linker_flag(-static-libstdc++) | ||||
endif() | endif() | ||||
# All windows code is PIC, forcing it on just adds useless compile warnings | # All windows code is PIC, forcing it on just adds useless compile warnings | ||||
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows") | if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows") | ||||
add_compiler_flag(-fPIC) | add_compiler_flag(-fPIC) | ||||
endif() | endif() | ||||
if(ENABLE_HARDENING) | if(ENABLE_HARDENING) | ||||
# Enable stack protection | # Enable stack protection | ||||
add_cxx_compiler_flag(-fstack-protector-all -Wstack-protector) | add_cxx_compiler_flag(-fstack-protector-all -Wstack-protector) | ||||
# Enable some buffer overflow checking | # Enable some buffer overflow checking | ||||
add_compiler_flag(-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2) | add_compiler_flag(-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2) | ||||
# Enable ASLR (these flags are primarily targeting MinGw) | # Enable ASLR (these flags are primarily targeting MinGw) | ||||
add_linker_flag(-Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va) | add_linker_flag(-Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va) | ||||
# Make the relocated sections read-only | # Make the relocated sections read-only | ||||
add_linker_flag(-Wl,-z,relro -Wl,-z,now) | add_linker_flag(-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, | # Unfortunately setting the -pie linker flag this way require CMake >= 3.14, | ||||
# which is not widely distributed at the time of writing. | # which is not widely distributed at the time of writing. | ||||
# FIXME: use the POSITION_INDEPENDENT_CODE property instead | # FIXME: use the POSITION_INDEPENDENT_CODE property instead | ||||
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows") | if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows") | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | ||||
set(Boost_THREADAPI win32) | set(Boost_THREADAPI win32) | ||||
find_package(SHLWAPI REQUIRED) | find_package(SHLWAPI REQUIRED) | ||||
target_link_libraries(util ${SHLWAPI_LIBRARY}) | target_link_libraries(util ${SHLWAPI_LIBRARY}) | ||||
target_include_directories(util PUBLIC ${SHLWAPI_INCLUDE_DIR}) | target_include_directories(util PUBLIC ${SHLWAPI_INCLUDE_DIR}) | ||||
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 | ||||
set(BOOST_PACKAGES_REQUIRED chrono filesystem program_options thread) | set(BOOST_PACKAGES_REQUIRED chrono filesystem program_options thread) | ||||
function(prepend var prefix) | function(prepend var prefix) | ||||
set(listVar "") | set(listVar "") | ||||
▲ Show 20 Lines • Show All 202 Lines • Show Last 20 Lines |