misc: experimental configure script

Type: make
Change-Id: Iaeb9d22eec9a7a763b63899814a44e78c8050f1f
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7dfd76a..96d373a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -64,6 +64,7 @@
 
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${VPP_RUNTIME_DIR})
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${VPP_LIBRARY_DIR})
+set(VPP_BINARY_DIR ${CMAKE_BINARY_DIR}/CMakeFiles)
 
 if (CMAKE_BUILD_TYPE)
   set(CMAKE_C_FLAGS "-g -fPIC -Werror -Wall ${CMAKE_C_FLAGS}")
@@ -151,8 +152,7 @@
 
 include_directories (
 	${CMAKE_SOURCE_DIR}
-	${CMAKE_BINARY_DIR}
-	${CMAKE_BINARY_DIR}/include
+	${VPP_BINARY_DIR}
 )
 set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "vpp")
 
@@ -185,7 +185,7 @@
 endif()
 
 foreach(DIR ${SUBDIRS})
-  add_subdirectory(${DIR})
+  add_subdirectory(${DIR} ${VPP_BINARY_DIR}/${DIR})
 endforeach()
 
 ##############################################################################
@@ -207,6 +207,36 @@
 endif()
 
 ##############################################################################
+# custom targets
+##############################################################################
+
+add_custom_target(run
+  COMMAND ./${VPP_RUNTIME_DIR}/vpp -c startup.conf
+  COMMENT "Starting VPP..."
+  USES_TERMINAL
+)
+
+add_custom_target(debug
+  COMMAND gdb --args ./${VPP_RUNTIME_DIR}/vpp -c startup.conf
+  COMMENT "Starting VPP in the debugger..."
+  USES_TERMINAL
+)
+
+add_custom_target(menu
+  COMMAND ccmake ${CMAKE_BINARY_DIR}
+  COMMENT "Starting Configuration TUI..."
+  USES_TERMINAL
+)
+
+add_custom_target(compdb
+  COMMAND ninja -C ${CMAKE_BINARY_DIR} -t compdb |
+          ${CMAKE_SOURCE_DIR}/scripts/compdb_cleanup.py >
+	  ${CMAKE_BINARY_DIR}/compile_commands.json
+  COMMENT "Generating compile_commands.json"
+  USES_TERMINAL
+)
+
+##############################################################################
 # print configuration
 ##############################################################################
 message(STATUS "Configuration:")