Skip to content
Snippets Groups Projects
Commit 0972cda2 authored by Raphael Defosseux's avatar Raphael Defosseux
Browse files

chore(build): properly defining debug compile options

parent cf820740
No related branches found
No related tags found
1 merge request!40chore(ci): testing ubuntu build in release mode
Pipeline #42766 passed
...@@ -5,7 +5,7 @@ project(Flexric VERSION 0.0.1 LANGUAGES C) ...@@ -5,7 +5,7 @@ project(Flexric VERSION 0.0.1 LANGUAGES C)
set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD 11)
### ###
### Reduce compile time ### Reduce compile time
### ###
# use ccache if available # use ccache if available
...@@ -48,11 +48,13 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) ...@@ -48,11 +48,13 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif() endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release") if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_compile_options("-march=native;-flto") add_compile_options("-march=native;-flto")
elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options("-D_FORTIFY_SOURCE=3")
endif() endif()
######## ########
### SANITIZER ### SANITIZER
######## ########
#https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110157 #https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110157
...@@ -74,7 +76,7 @@ endif() ...@@ -74,7 +76,7 @@ endif()
######## ########
### Compiler ### Compiler
######## ########
...@@ -82,11 +84,11 @@ if (CMAKE_C_COMPILER_ID STREQUAL "Clang") ...@@ -82,11 +84,11 @@ if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
# using Clang # using Clang
add_compile_options("-fblocks;") add_compile_options("-fblocks;")
add_link_options("-lBlocksRuntime;") add_link_options("-lBlocksRuntime;")
if(${SANITIZER} STREQUAL "ADDRESS") if(${SANITIZER} STREQUAL "ADDRESS")
message(FATAL_ERROR "ASan not supported by CLANG as FlexRIC uses blocks e.g., defer. Use gcc or unselect the sanitizer") message(FATAL_ERROR "ASan not supported by CLANG as FlexRIC uses blocks e.g., defer. Use gcc or unselect the sanitizer")
endif() endif()
# using GCC # using GCC
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
# sudo update-alternatives --config gcc # sudo update-alternatives --config gcc
...@@ -119,7 +121,7 @@ if(CPP_CHECK) ...@@ -119,7 +121,7 @@ if(CPP_CHECK)
endif() endif()
######## ########
### Clang Tidy ### Clang Tidy
####### #######
option(Clang_Tidy "Clang Tidy" OFF) option(Clang_Tidy "Clang Tidy" OFF)
if(Clang_Tidy) if(Clang_Tidy)
...@@ -127,14 +129,14 @@ if(Clang_Tidy) ...@@ -127,14 +129,14 @@ if(Clang_Tidy)
endif() endif()
######## ########
### NUM_THREADS ### NUM_THREADS
######## ########
set(NUM_THREADS_RIC "2" CACHE STRING "Number of threads in the RIC's task manager") set(NUM_THREADS_RIC "2" CACHE STRING "Number of threads in the RIC's task manager")
######## ########
### xApp ### xApp
######## ########
set(XAPP_DB "SQLITE3_XAPP" CACHE STRING "xApp DB") set(XAPP_DB "SQLITE3_XAPP" CACHE STRING "xApp DB")
set_property(CACHE XAPP_DB PROPERTY STRINGS "SQLITE3_XAPP" "NONE_XAPP") set_property(CACHE XAPP_DB PROPERTY STRINGS "SQLITE3_XAPP" "NONE_XAPP")
...@@ -143,7 +145,7 @@ message(STATUS "Selected xApp DB : ${XAPP_DB}") ...@@ -143,7 +145,7 @@ message(STATUS "Selected xApp DB : ${XAPP_DB}")
set(XAPP_DB_DIR "/tmp/" CACHE STRING "The xApp DB write directory") set(XAPP_DB_DIR "/tmp/" CACHE STRING "The xApp DB write directory")
if(NOT XAPP_DB_DIR MATCHES "/$") if(NOT XAPP_DB_DIR MATCHES "/$")
message(FATAL_ERROR "xApp directory path needs to terminate in one / char") message(FATAL_ERROR "xApp directory path needs to terminate in one / char")
endif() endif()
if(NOT EXISTS ${XAPP_DB_DIR}) if(NOT EXISTS ${XAPP_DB_DIR})
message(FATAL_ERROR "Selected XAPP_DB_DIR does not exist. Please create it or change path") message(FATAL_ERROR "Selected XAPP_DB_DIR does not exist. Please create it or change path")
...@@ -155,7 +157,7 @@ option(XAPP_MULTILANGUAGE "xApp Multilanguage" ON) ...@@ -155,7 +157,7 @@ option(XAPP_MULTILANGUAGE "xApp Multilanguage" ON)
message(STATUS "xApp multilanguage support e.g., python : ${XAPP_MULTILANGUAGE}") message(STATUS "xApp multilanguage support e.g., python : ${XAPP_MULTILANGUAGE}")
######## ########
### Coverage ### Coverage
######## ########
option(CODE_COVERAGE "Code coverage" OFF) option(CODE_COVERAGE "Code coverage" OFF)
...@@ -168,7 +170,7 @@ if(CODE_COVERAGE) ...@@ -168,7 +170,7 @@ if(CODE_COVERAGE)
endif() endif()
######## ########
### Profiler ### Profiler
######## ########
option(CODE_PROFILER "Code Profiler" OFF) option(CODE_PROFILER "Code Profiler" OFF)
...@@ -197,11 +199,7 @@ endif() ...@@ -197,11 +199,7 @@ endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(BUILDING_LIBRARY STREQUAL "STATIC") if(BUILDING_LIBRARY STREQUAL "STATIC")
if(CMAKE_BUILD_TYPE STREQUAL "Release") add_compile_options("-W;-Wall;-Wextra;-g;-Wno-unused-result;-Warray-bounds;-Wempty-body;-fstack-protector-strong;-fstack-clash-protection;-D_GLIBCXX_ASSERTIONS") #-fopt-info -fhardened
add_compile_options("-W;-Wall;-Wextra;-g;-Wno-unused-result;-Warray-bounds;-Wempty-body;-fstack-protector-strong;-fstack-clash-protection;-D_GLIBCXX_ASSERTIONS") #-fopt-info -fhardened
else()
add_compile_options("-W;-Wall;-Wextra;-g;-Wno-unused-result;-Warray-bounds;-Wempty-body;-fstack-protector-strong;-fstack-clash-protection;-D_FORTIFY_SOURCE=3;-D_GLIBCXX_ASSERTIONS") #-fopt-info -fhardened
endif()
elseif(BUILDING_LIBRARY STREQUAL "DYNAMIC") elseif(BUILDING_LIBRARY STREQUAL "DYNAMIC")
# -fPIC flag # -fPIC flag
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
...@@ -212,7 +210,7 @@ endif() ...@@ -212,7 +210,7 @@ endif()
####### #######
## E2AP encoding and versioning ## E2AP encoding and versioning
####### #######
set(E2AP_ENCODING "ASN" CACHE STRING "The E2AP encoding to use") set(E2AP_ENCODING "ASN" CACHE STRING "The E2AP encoding to use")
...@@ -224,25 +222,25 @@ set_property(CACHE E2AP_VERSION PROPERTY STRINGS "E2AP_V1" "E2AP_V2" "E2AP_V3") ...@@ -224,25 +222,25 @@ set_property(CACHE E2AP_VERSION PROPERTY STRINGS "E2AP_V1" "E2AP_V2" "E2AP_V3")
message(STATUS "Selected E2AP_VERSION: ${E2AP_VERSION}") message(STATUS "Selected E2AP_VERSION: ${E2AP_VERSION}")
if(E2AP_VERSION STREQUAL "E2AP_V1") if(E2AP_VERSION STREQUAL "E2AP_V1")
add_library(e2ap_ran_func_obj OBJECT add_library(e2ap_ran_func_obj OBJECT
src/lib/e2ap/v1_01/e2ap_types/common/e2ap_ran_function.c ) src/lib/e2ap/v1_01/e2ap_types/common/e2ap_ran_function.c )
add_library(e2ap_plmn_obj OBJECT add_library(e2ap_plmn_obj OBJECT
src/lib/e2ap/v1_01/e2ap_types/common/e2ap_plmn.c ) src/lib/e2ap/v1_01/e2ap_types/common/e2ap_plmn.c )
add_library(e2ap_global_node_id_obj OBJECT add_library(e2ap_global_node_id_obj OBJECT
src/lib/e2ap/v1_01/e2ap_types/common/e2ap_global_node_id.c ) src/lib/e2ap/v1_01/e2ap_types/common/e2ap_global_node_id.c )
elseif(E2AP_VERSION STREQUAL "E2AP_V2") elseif(E2AP_VERSION STREQUAL "E2AP_V2")
add_library(e2ap_ran_func_obj OBJECT add_library(e2ap_ran_func_obj OBJECT
src/lib/e2ap/v2_03/e2ap_types/common/e2ap_ran_function.c ) src/lib/e2ap/v2_03/e2ap_types/common/e2ap_ran_function.c )
add_library(e2ap_plmn_obj OBJECT add_library(e2ap_plmn_obj OBJECT
src/lib/e2ap/v2_03/e2ap_types/common/e2ap_plmn.c ) src/lib/e2ap/v2_03/e2ap_types/common/e2ap_plmn.c )
add_library(e2ap_global_node_id_obj OBJECT add_library(e2ap_global_node_id_obj OBJECT
src/lib/e2ap/v2_03/e2ap_types/common/e2ap_global_node_id.c ) src/lib/e2ap/v2_03/e2ap_types/common/e2ap_global_node_id.c )
elseif(E2AP_VERSION STREQUAL "E2AP_V3") elseif(E2AP_VERSION STREQUAL "E2AP_V3")
add_library(e2ap_ran_func_obj OBJECT add_library(e2ap_ran_func_obj OBJECT
src/lib/e2ap/v3_01/e2ap_types/common/e2ap_ran_function.c ) src/lib/e2ap/v3_01/e2ap_types/common/e2ap_ran_function.c )
add_library(e2ap_plmn_obj OBJECT add_library(e2ap_plmn_obj OBJECT
src/lib/e2ap/v3_01/e2ap_types/common/e2ap_plmn.c ) src/lib/e2ap/v3_01/e2ap_types/common/e2ap_plmn.c )
add_library(e2ap_global_node_id_obj OBJECT add_library(e2ap_global_node_id_obj OBJECT
src/lib/e2ap/v3_01/e2ap_types/common/e2ap_global_node_id.c ) src/lib/e2ap/v3_01/e2ap_types/common/e2ap_global_node_id.c )
else() else()
message(FATAL_ERROR "E2AP Unknown version selected") message(FATAL_ERROR "E2AP Unknown version selected")
...@@ -252,7 +250,7 @@ target_compile_options(e2ap_ran_func_obj PRIVATE -fPIC -fvisibility=hidden) ...@@ -252,7 +250,7 @@ target_compile_options(e2ap_ran_func_obj PRIVATE -fPIC -fvisibility=hidden)
####### #######
## Service Models ## Service Models
####### #######
add_definitions(-DSERVICE_MODEL_DIR_PATH="${SM_DIR_PATH}/") add_definitions(-DSERVICE_MODEL_DIR_PATH="${SM_DIR_PATH}/")
...@@ -297,7 +295,7 @@ set_property(CACHE SM_ENCODING_GTP PROPERTY STRINGS "PLAIN") ...@@ -297,7 +295,7 @@ set_property(CACHE SM_ENCODING_GTP PROPERTY STRINGS "PLAIN")
message(STATUS "Selected GTP SM_ENCODING: ${SM_ENCODING_GTP}") message(STATUS "Selected GTP SM_ENCODING: ${SM_ENCODING_GTP}")
######## ########
### Flatbuffer ### Flatbuffer
######## ########
set(FlatCC_INCLUDE_DIR "" CACHE STRING "The Flatbuffers include directory") set(FlatCC_INCLUDE_DIR "" CACHE STRING "The Flatbuffers include directory")
set(FlatCC_LIB_DIR "" CACHE STRING "The Flatbuffers lib directory") set(FlatCC_LIB_DIR "" CACHE STRING "The Flatbuffers lib directory")
...@@ -305,7 +303,7 @@ set(FlatCC_LIB_DIR "" CACHE STRING "The Flatbuffers lib directory") ...@@ -305,7 +303,7 @@ set(FlatCC_LIB_DIR "" CACHE STRING "The Flatbuffers lib directory")
if(E2AP_ENCODING STREQUAL "FLATBUFFERS") if(E2AP_ENCODING STREQUAL "FLATBUFFERS")
find_library(FlatCC find_library(FlatCC
NAMES flatccrt_d NAMES flatccrt_d
HINTS ${FlatCC_LIB_DIR} HINTS ${FlatCC_LIB_DIR}
#"~/workspace/flatcc/lib/" #"~/workspace/flatcc/lib/"
) )
endif() endif()
...@@ -352,7 +350,7 @@ install(TARGETS rc_sm DESTINATION ${CMAKE_INSTALL_LIBDIR}/flexric) ...@@ -352,7 +350,7 @@ install(TARGETS rc_sm DESTINATION ${CMAKE_INSTALL_LIBDIR}/flexric)
install(FILES flexric.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/flexric) install(FILES flexric.conf DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/flexric)
### ###
# CTest # CTest
### ###
set(CTEST_PARALLEL_LEVEL 4) set(CTEST_PARALLEL_LEVEL 4)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment