Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ set(linyaps-box_ENABLE_CPM
OFF
CACHE BOOL "enable CPM")

set(linyaps-box_HARDENING
ON
CACHE BOOL "enable hardening")

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if(CMAKE_VERSION VERSION_LESS "3.14")
set(linyaps-box_ENABLE_CPM OFF)
message(
Expand All @@ -107,6 +113,17 @@ set(linyaps-box_CPM_LOCAL_PACKAGES_ONLY

# ==============================================================================

if (linyaps-box_HARDENING)
message(STATUS "applying harden settings")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -Wl,-z,relro -Wl,-z,now")
add_compile_options(-fstack-protector-strong)

if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Non-Debug build, enabling FORTIFY_SOURCE")
add_compile_definitions(_FORTIFY_SOURCE=2)
endif()
endif()

set(linyaps-box_LIBRARY linyaps-box)
set(linyaps-box_LIBRARY_SOURCE
# find -regex '\./src/.+\.[ch]\(pp\)?' -type f -printf '%P\n'| sort
Expand Down