From 2cee801979bfbcb3b0e53f592ce8c779b57cb679 Mon Sep 17 00:00:00 2001 From: vnugent Date: Mon, 6 May 2024 22:02:39 -0400 Subject: Ensure static and dynamic libs get same args --- CMakeLists.txt | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index b2a3e30..8505d8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,11 +227,12 @@ if(NC_DISABLE_INPUT_VALIDATION) list(APPEND NC_PROJ_DEFINTIONS NC_INPUT_VALIDATION_OFF) endif() +set(_NC_COMPILE_OPTS) + #setup flags for windows compilation if(MSVC) - - #global windows cl flags - target_compile_options(${_NC_PROJ_NAME} PRIVATE + + list(APPEND _NC_COMPILE_OPTS /sdl #enable additional security checks /TC #compile as c /GS #buffer security check @@ -248,7 +249,7 @@ if(MSVC) $<$:/WX> #warnings as errors (only for our project) $<$:/Zi> #enable rich debug info $<$:/Zo> - ) + ) #set build macros list(APPEND NC_PROJ_DEFINTIONS @@ -259,13 +260,14 @@ if(MSVC) #configure gcc flags elseif(CMAKE_COMPILER_IS_GNUCC) - target_compile_options(${_NC_PROJ_NAME} PRIVATE -Wextra -fstack-protector) + list(APPEND _NC_COMPILE_OPTS + -Wextra + -fstack-protector + ) #if debug build enable additional debug flags if(build_type STREQUAL "debug") - target_compile_options( - ${_NC_PROJ_NAME} - PRIVATE + list(APPEND _NC_COMPILE_OPTS -g -Og @@ -276,6 +278,9 @@ elseif(CMAKE_COMPILER_IS_GNUCC) endif() endif() +target_compile_options(${_NC_PROJ_NAME} PRIVATE ${_NC_COMPILE_OPTS}) +target_compile_options(${_NC_PROJ_NAME}_static PRIVATE ${_NC_COMPILE_OPTS}) + ############################################# # # Build/link monocypher -- cgit