build: add set-build-type-* targets to CMake
[vpp.git] / src / CMakeLists.txt
index 3fc72d7..cb05a08 100644 (file)
@@ -110,9 +110,9 @@ string(CONCAT CMAKE_C_FLAGS_GCOV
 string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UC)
 
 
-string(REPLACE ";" " " BUILD_TYPES "${BUILD_TYPES}")
+string(REPLACE ";" " " BUILD_TYPES_STR "${BUILD_TYPES}")
 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
-            HELPSTRING "Build type - valid options are: ${BUILD_TYPES}")
+            HELPSTRING "Build type - valid options are: ${BUILD_TYPES_STR}")
 
 ##############################################################################
 # link time optimizations
@@ -141,6 +141,15 @@ if (VPP_ENABLE_SANITIZE_ADDR)
   set(CMAKE_SHARED_LINKER_FLAGS "-fsanitize=address ${CMAKE_SHARED_LINKER_FLAGS}")
 endif (VPP_ENABLE_SANITIZE_ADDR)
 
+##############################################################################
+# trajectory trace
+##############################################################################
+
+option(VPP_ENABLE_TRAJECTORY_TRACE "Build vpp with trajectory tracing enabled" OFF)
+if(VPP_ENABLE_TRAJECTORY_TRACE)
+  set(CMAKE_C_FLAGS "-DVLIB_BUFFER_TRACE_TRAJECTORY=1 ${CMAKE_C_FLAGS}")
+endif()
+
 ##############################################################################
 # install config
 ##############################################################################
@@ -236,6 +245,14 @@ add_custom_target(compdb
   USES_TERMINAL
 )
 
+foreach(bt ${BUILD_TYPES})
+  add_custom_target(set-build-type-${bt}
+    COMMAND cmake -DCMAKE_BUILD_TYPE:STRING=${bt} .
+    COMMENT "Changing build type to ${bt}"
+    USES_TERMINAL
+  )
+endforeach()
+
 ##############################################################################
 # print configuration
 ##############################################################################