From 27f112a8310f21a04aea9861ce0b11ecb63dc91d Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Sun, 17 Apr 2016 01:34:16 -0400 Subject: [PATCH] cmake only run libuavcan_dsdlc if there are changes --- CMakeLists.txt | 7 +++++-- libuavcan/CMakeLists.txt | 17 ++++++++++++++--- libuavcan/dsdl_compiler/libuavcan_dsdlc | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04ee3d4d5..bbdda1e74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ set(opts "UAVCAN_USE_CPP03:BOOL:OFF::Use C++03 standard." "UAVCAN_PLATFORM:STRING:generic:generic linux stm32:Platform." "CONTINUOUS_INTEGRATION_BUILD:BOOL:OFF::Disable error redirection and timing tests" + "UAVCAN_CMAKE_VERBOSE:BOOL:OFF::Verbose CMake configure output" ) foreach(_opt ${opts}) # arguments are : delimited @@ -42,7 +43,9 @@ foreach(_opt ${opts}) set(${_name} ${DEFAULT_${_name}}) endif() # create a cache from the variable and force it to set +if(UAVCAN_CMAKE_VERBOSE) message(STATUS "${_name}\t: ${${_name}} : ${_descr}") +endif() set("${_name}" "${${_name}}" CACHE "${_type}" "${_descr}" FORCE) # if an options list is provided for the cache, set it if("${_type}" STREQUAL "STRING" AND NOT "${_options}" STREQUAL "") @@ -72,11 +75,11 @@ add_subdirectory(libuavcan) # drivers if (${UAVCAN_PLATFORM} STREQUAL "linux") - message(STATUS "Adding Linux platform driver") + message(STATUS "Adding UAVCAN Linux platform driver") add_subdirectory(libuavcan_drivers/posix) add_subdirectory(libuavcan_drivers/linux) elseif(${UAVCAN_PLATFORM} STREQUAL "stm32") - message(STATUS "Adding STM32 platform driver") + message(STATUS "Adding UAVCAN STM32 platform driver") add_subdirectory(libuavcan_drivers/posix) add_subdirectory(libuavcan_drivers/stm32/driver) endif() diff --git a/libuavcan/CMakeLists.txt b/libuavcan/CMakeLists.txt index 137732bd1..d5827313b 100644 --- a/libuavcan/CMakeLists.txt +++ b/libuavcan/CMakeLists.txt @@ -14,10 +14,10 @@ endif() string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lower) if (build_type_lower STREQUAL "debug") set(DEBUG_BUILD 1) + message(STATUS "Debug build") else () set(DEBUG_BUILD 0) endif () -message(STATUS "Debug build: ${DEBUG_BUILD}") project(libuavcan) @@ -34,8 +34,19 @@ endif () execute_process(COMMAND ./setup.py build WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dsdl_compiler) set(DSDLC_INPUTS "test/dsdl_test/root_ns_a" "test/dsdl_test/root_ns_b" "${CMAKE_CURRENT_SOURCE_DIR}/../dsdl/uavcan") set(DSDLC_OUTPUT "include/dsdlc_generated") -add_custom_target(libuavcan_dsdlc dsdl_compiler/libuavcan_dsdlc ${DSDLC_INPUTS} -O${DSDLC_OUTPUT} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + +set(DSDLC_INPUT_FILES "") +foreach(DSDLC_INPUT ${DSDLC_INPUTS}) + file(GLOB_RECURSE DSDLC_NEW_INPUT_FILES ${CMAKE_CURRENT_SOURCE_DIR} "${DSDLC_INPUT}/*.uavcan") + set(DSDLC_INPUT_FILES ${DSDLC_INPUT_FILES} ${DSDLC_NEW_INPUT_FILES}) +endforeach(DSDLC_INPUT) +add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/libuavcan_dsdlc_run.stamp + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/dsdl_compiler/libuavcan_dsdlc ${DSDLC_INPUTS} -O${DSDLC_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/libuavcan_dsdlc_run.stamp + DEPENDS ${DSDLC_INPUT_FILES} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Running dsdl compiler") +add_custom_target(libuavcan_dsdlc DEPENDS ${CMAKE_BINARY_DIR}/libuavcan_dsdlc_run.stamp) include_directories(${DSDLC_OUTPUT}) # diff --git a/libuavcan/dsdl_compiler/libuavcan_dsdlc b/libuavcan/dsdl_compiler/libuavcan_dsdlc index a95c1313e..ea23a8fd0 100755 --- a/libuavcan/dsdl_compiler/libuavcan_dsdlc +++ b/libuavcan/dsdl_compiler/libuavcan_dsdlc @@ -16,7 +16,7 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) LOCAL_PYUAVCAN_DIR = os.path.join(SCRIPT_DIR, 'pyuavcan') RUNNING_FROM_SRC_DIR = os.path.isdir(LOCAL_PYUAVCAN_DIR) if RUNNING_FROM_SRC_DIR: - print('Running from the source directory') + #print('Running from the source directory') sys.path.insert(0, SCRIPT_DIR) sys.path.insert(0, LOCAL_PYUAVCAN_DIR)