Skip to content

Commit

Permalink
Merge pull request #90 from dagar/deps
Browse files Browse the repository at this point in the history
cmake only run libuavcan_dsdlc if there are changes
  • Loading branch information
LorenzMeier committed Apr 17, 2016
2 parents 7ce96d6 + 27f112a commit 986ce57
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 "")
Expand Down Expand Up @@ -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()
Expand Down
17 changes: 14 additions & 3 deletions libuavcan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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})

#
Expand Down
2 changes: 1 addition & 1 deletion libuavcan/dsdl_compiler/libuavcan_dsdlc
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 986ce57

Please sign in to comment.