summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Bultel <thierry.bultel@iot.bzh>2018-06-11 16:08:03 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-10-15 18:22:48 +0200
commitcf7eefe88c19481a8ea382207d53d4373b5a4925 (patch)
treeb8d3f7e0ff1b691e92b45e54a5110f012af26758
parent8c96d04a9e68cbcdad1be622f0fd2b4f4d2548a6 (diff)
Added -D_FORTIFY_SOURCE=2 to CFLAGS
Added this option, to match the given ones when building from yocto with bitbake. Also fixed the sample example, and some copy-paste issues on build targets (RELEASE/DEBUG/PROFILING/CCOV). Change-Id: I759305e54d427e6763f32b1a86207fe35add1b3f Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
-rw-r--r--cmake/cmake.d/01-build_options.cmake10
-rw-r--r--samples.d/config.cmake.sample3
2 files changed, 7 insertions, 6 deletions
diff --git a/cmake/cmake.d/01-build_options.cmake b/cmake/cmake.d/01-build_options.cmake
index b55df59..17f1eab 100644
--- a/cmake/cmake.d/01-build_options.cmake
+++ b/cmake/cmake.d/01-build_options.cmake
@@ -59,20 +59,20 @@ endforeach()
# Compilation option depending on CMAKE_BUILD_TYPE
##################################################
set(PROFILING_COMPILE_OPTIONS -g -O0 -pg -Wp,-U_FORTIFY_SOURCE CACHE STRING "Compilation flags for PROFILING build type.")
-set(DEBUG_COMPILE_OPTIONS -g -ggdb -Wp,-U_FORTIFY_SOURCE CACHE STRING "Compilation flags for DEBUG build type.")
+set(DEBUG_COMPILE_OPTIONS -g -ggdb -D_FORTIFY_SOURCE=2 CACHE STRING "Compilation flags for DEBUG build type.")
set(CCOV_COMPILE_OPTIONS -g -O2 --coverage CACHE STRING "Compilation flags for CCOV build type.")
-set(RELEASE_COMPILE_OPTIONS -g -O2 CACHE STRING "Compilation flags for RELEASE build type.")
+set(RELEASE_COMPILE_OPTIONS -g -O2 -D_FORTIFY_SOURCE=2 CACHE STRING "Compilation flags for RELEASE build type.")
foreach(option ${PROFILING_COMPILE_OPTIONS})
add_compile_options($<$<CONFIG:PROFILING>:${option}>)
endforeach()
foreach(option ${DEBUG_COMPILE_OPTIONS})
- add_compile_options($<$<CONFIG:PROFILING>:${option}>)
+ add_compile_options($<$<CONFIG:DEBUG>:${option}>)
endforeach()
foreach(option ${CCOV_COMPILE_OPTIONS})
- add_compile_options($<$<CONFIG:PROFILING>:${option}>)
+ add_compile_options($<$<CONFIG:CCOV>:${option}>)
endforeach()
foreach(option ${RELEASE_COMPILE_OPTIONS})
- add_compile_options($<$<CONFIG:PROFILING>:${option}>)
+ add_compile_options($<$<CONFIG:RELEASE>:${option}>)
endforeach()
# Loop on required package and add options
diff --git a/samples.d/config.cmake.sample b/samples.d/config.cmake.sample
index 3ec9201..b065b4a 100644
--- a/samples.d/config.cmake.sample
+++ b/samples.d/config.cmake.sample
@@ -110,7 +110,7 @@ set (PKG_REQUIRED_LIST
#set(DEBUG_COMPILE_OPTIONS
# -g
# -ggdb
-# -Wp,-U_FORTIFY_SOURCE
+# -D_FORTIFY_SOURCE=2
# CACHE STRING "Compilation flags for DEBUG build type.")
#set(CCOV_COMPILE_OPTIONS
# -g
@@ -120,6 +120,7 @@ set (PKG_REQUIRED_LIST
#set(RELEASE_COMPILE_OPTIONS
# -g
# -O2
+# -D_FORTIFY_SOURCE=2
# CACHE STRING "Compilation flags for RELEASE build type.")
# (BUG!!!) as PKG_CONFIG_PATH does not work [should be an env variable]