aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-09-20 08:37:41 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-09-20 13:11:44 -0400
commit27428e7e64ca8686eb1e3dc5f91dcd1596decac4 (patch)
treea80b172b514f00467f484fc0adbdf0f1f71e6a2b
parent75d0fbad52bf40bf2eb501f3a36694422ff08b03 (diff)
downloadstasis-27428e7e64ca8686eb1e3dc5f91dcd1596decac4.tar.gz
Add option to define _FORTIFY_SOURCE=1
-rw-r--r--CMakeLists.txt9
1 files changed, 6 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index abb700c..caed929 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.15)
project(STASIS C)
include(GNUInstallDirs)
-set(nix_cflags -Wall -Wextra -fPIC)
+set(nix_cflags -Wall -Wextra -fPIC -D_GNU_SOURCE)
set(win_cflags /Wall)
set(CMAKE_C_STANDARD 99)
find_package(LibXml2)
@@ -11,13 +11,16 @@ link_libraries(CURL::libcurl)
link_libraries(LibXml2::LibXml2)
include_directories(${LIBXML2_INCLUDE_DIR})
+option(FORTIFY_SOURCE OFF)
+if (FORTIFY_SOURCE)
+ set(nix_cflags ${nix_cflags} -O -D_FORTIFY_SOURCE=1)
+endif ()
+
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- message("gnu options")
add_compile_options(${nix_cflags})
elseif (CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(${nix_cflags})
elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
- message("microsoft visual c options")
add_compile_options(${win_cflags})
endif()