-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved content of UseMrtAutoTarget to mrt_cmake_modules-extras.
Activate globbing for newer cmake versions so that cmake is run automatically if the glob changes.
- Loading branch information
Johannes Beck
committed
Jan 11, 2019
1 parent
1b90305
commit 606af23
Showing
2 changed files
with
100 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1 @@ | ||
function(add_executable_auto TARGET_NAME) | ||
set(FILE_LIST ${ARGN}) | ||
if(NOT FILE_LIST) | ||
#Given file list empty. Generate a dummy file and use this as target. | ||
#Also warn the user | ||
set(_AUTO_GEN_FILE_NAME_ "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET_NAME}_exec_dummy.cpp") | ||
|
||
file(GENERATE OUTPUT "${_AUTO_GEN_FILE_NAME_}" CONTENT "int main()\n{\n\t#warning \"Used auto generated file for target\"\n}") | ||
set_source_files_properties("${_AUTO_GEN_FILE_NAME_}" PROPERTIES GENERATED TRUE) | ||
list(APPEND FILE_LIST "${_AUTO_GEN_FILE_NAME_}") | ||
message(WARNING "No files specified for target ${TARGET_NAME}.") | ||
endif() | ||
|
||
add_executable(${TARGET_NAME} ${FILE_LIST}) | ||
endfunction() | ||
|
||
function(add_library_auto TARGET_NAME) | ||
set(FILE_LIST ${ARGN}) | ||
if(NOT FILE_LIST) | ||
#Given file list empty. Generate a dummy file and use this as target. | ||
#Also warn the user | ||
set(_AUTO_GEN_FILE_NAME_ "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET_NAME}_lib_dummy.cpp") | ||
file(GENERATE OUTPUT "${_AUTO_GEN_FILE_NAME_}" CONTENT "#warning \"Used auto generated file for target\"\n") | ||
set_source_files_properties("${_AUTO_GEN_FILE_NAME_}" PROPERTIES GENERATED TRUE) | ||
list(APPEND FILE_LIST "${_AUTO_GEN_FILE_NAME_}") | ||
message(WARNING "No files specified for target ${TARGET_NAME}.") | ||
endif() | ||
|
||
add_library(${TARGET_NAME} ${FILE_LIST}) | ||
endfunction() | ||
|
||
#search for subfolders in src | ||
function(glob_folders DIRECTORY_LIST SEARCH_DIRECTORY) | ||
file(GLOB DIRECTORIES RELATIVE ${SEARCH_DIRECTORY} ${SEARCH_DIRECTORY}/[^.]*) | ||
set(_DIRECTORY_LIST_ "") | ||
foreach(SRC_DIR ${DIRECTORIES}) | ||
if(IS_DIRECTORY ${SEARCH_DIRECTORY}/${SRC_DIR}) | ||
list(APPEND _DIRECTORY_LIST_ ${SRC_DIR}) | ||
endif() | ||
endforeach() | ||
set(${DIRECTORY_LIST} ${_DIRECTORY_LIST_} PARENT_SCOPE) | ||
endfunction() | ||
|
||
macro(glob_ros_files excecutable_name extension_name) | ||
file(GLOB ROS_${excecutable_name}_FILES RELATIVE "${CMAKE_CURRENT_LIST_DIR}/${extension_name}" "${extension_name}/*.${extension_name}") | ||
|
||
if (ROS_${excecutable_name}_FILES) | ||
#work around to execute a command wich name is given in a variable | ||
#write a file with the command, include it and delete the file again | ||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/_GLOB_ROS_TEMP_FILE.cmake" "${excecutable_name}( | ||
DIRECTORY ${extension_name} | ||
FILES | ||
${ROS_${excecutable_name}_FILES} | ||
)") | ||
include("${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/_GLOB_ROS_TEMP_FILE.cmake") | ||
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/_GLOB_ROS_TEMP_FILE.cmake") | ||
|
||
set(ROS_GENERATE_MESSAGES True) | ||
endif() | ||
endmacro() | ||
# No longer needed but kept for backwards compatibilty. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters