X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=cmake%2Fcmake.d%2F01-build_options.cmake;h=72a316142e282aa3a4841ba9303755f2384222b7;hb=e841a7787b2315f068f50d77b04196b7d7ccc17d;hp=36830f1fac8e3b3c9396380969030e362063cb31;hpb=291aa4ef053ba7564759d3a0ba3c027e1ede0eff;p=apps%2Fapp-templates.git diff --git a/cmake/cmake.d/01-build_options.cmake b/cmake/cmake.d/01-build_options.cmake index 36830f1..72a3161 100644 --- a/cmake/cmake.d/01-build_options.cmake +++ b/cmake/cmake.d/01-build_options.cmake @@ -32,7 +32,14 @@ INCLUDE(CheckIncludeFiles) INCLUDE(CheckLibraryExists) INCLUDE(GNUInstallDirs) -set(CMAKE_BUILD_TYPE Debug CACHE STRING "the type of build") +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 RELEASE CACHE STRING "the type of build" FORCE) + endif() +endif() + set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMP0048 1) @@ -79,7 +86,8 @@ 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(TEST_COMPILE_OPTIONS -g -ggdb CACHE STRING "Compilation flags for TEST 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.") foreach(option ${PROFILING_COMPILE_OPTIONS}) @@ -88,6 +96,9 @@ endforeach() foreach(option ${DEBUG_COMPILE_OPTIONS}) add_compile_options($<$:${option}>) endforeach() +foreach(option ${TEST_COMPILE_OPTIONS}) + add_compile_options($<$:${option}>) +endforeach() foreach(option ${COVERAGE_COMPILE_OPTIONS}) add_compile_options($<$:${option}>) endforeach() @@ -114,6 +125,9 @@ IF(HAVE_LIBEFENCE) list (APPEND link_libraries ${libefence_LIBRARIES}) ENDIF(HAVE_LIBEFENCE) ENDIF(CMAKE_BUILD_TYPE MATCHES DEBUG AND USE_EFENCE) +IF(CMAKE_BUILD_TYPE MATCHES COVERAGE) + list (APPEND link_libraries -coverage) +ENDIF(CMAKE_BUILD_TYPE MATCHES COVERAGE) # set default include directories INCLUDE_DIRECTORIES(${EXTRA_INCLUDE_DIRS})