Change default compilation options. 87/16087/3
authorRomain Forlot <romain.forlot@iot.bzh>
Thu, 9 Aug 2018 09:51:05 +0000 (11:51 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Mon, 13 Aug 2018 08:25:29 +0000 (08:25 +0000)
This changes the default build type to RELEASE as it would
be built using Yocto. Debug build should be activated if needed
temporary as the other type: coverage and profiling.

Doing this you are able to detect compilation error that would happens
when building with Yocto and if you need to debug your program you only
need to recompile changing temporary the build type to DEBUG.

Bugs-AGL: SPEC-1644

Change-Id: I1823509a1a48415d3d440dd84d1e43ef48736ebe
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
cmake/cmake.d/01-build_options.cmake
samples.d/config.cmake.sample

index 3be92ba..502b6bd 100644 (file)
@@ -36,7 +36,7 @@ if(NOT CMAKE_BUILD_TYPE)
        if(BUILD_TYPE)
                set(CMAKE_BUILD_TYPE ${BUILD_TYPE} CACHE STRING "the type of build" FORCE)
        else()
-               set(CMAKE_BUILD_TYPE DEBUG CACHE STRING "the type of build" FORCE)
+               set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "the type of build" FORCE)
        endif()
 endif()
 
@@ -86,9 +86,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 -Og -D_FORTIFY_SOURCE=2 CACHE STRING "Compilation flags for DEBUG build type.")
+set(DEBUG_COMPILE_OPTIONS -g -ggdb CACHE STRING "Compilation flags for DEBUG build type.")
 set(COVERAGE_COMPILE_OPTIONS -g --coverage CACHE STRING "Compilation flags for COVERAGE build type.")
-set(RELEASE_COMPILE_OPTIONS -O2 -D_FORTIFY_SOURCE=2 CACHE STRING "Compilation flags for RELEASE build type.")
+set(RELEASE_COMPILE_OPTIONS -O2
+ -pipe
+ -D_FORTIFY_SOURCE=2
+ -fstack-protector-strong
+ -Wformat -Wformat-security
+ -Werror=format-security
+ -feliminate-unused-debug-types
+ -Wl,-O1
+ -Wl,--hash-style=gnu
+ -Wl,--as-needed
+ -fstack-protector-strong
+ -Wl,-z,relro,-z,now CACHE STRING "Compilation flags for RELEASE build type. This is a copy of default Yocto build compile flags.")
 foreach(option ${PROFILING_COMPILE_OPTIONS})
        add_compile_options($<$<CONFIG:PROFILING>:${option}>)
 endforeach()
index b7e60c6..999208a 100644 (file)
@@ -109,17 +109,24 @@ set (PKG_REQUIRED_LIST
 #set(DEBUG_COMPILE_OPTIONS
 # -g
 # -ggdb
-# -Og
-# -D_FORTIFY_SOURCE=2
 # CACHE STRING "Compilation flags for DEBUG build type.")
 #set(CCOV_COMPILE_OPTIONS
 # -g
 # --coverage
 # CACHE STRING "Compilation flags for CCOV build type.")
 #set(RELEASE_COMPILE_OPTIONS
-# -g
 # -O2
+# -pipe
 # -D_FORTIFY_SOURCE=2
+# -fstack-protector-strong
+# -Wformat -Wformat-security
+# -Werror=format-security
+# -feliminate-unused-debug-types
+# -Wl,-O1
+# -Wl,--hash-style=gnu
+# -Wl,--as-needed
+# -fstack-protector-strong
+# -Wl,-z,relro,-z,now
 # CACHE STRING "Compilation flags for RELEASE build type.")
 
 # Location for config.xml.in template file.