-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding CMake dependencies and dds_dcps.idl
- Loading branch information
Showing
5 changed files
with
691 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "rticonnextdds-cmake-utils"] | ||
path = rticonnextdds-cmake-utils | ||
url = https://github.com/rticommunity/rticonnextdds-cmake-utils |
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,2 +1,4 @@ | ||
# dds-datamodels-utils | ||
This repository provides common files to all datamodel repositories, such as CMake files, idl files, etc... | ||
|
||
This repository provides common files to all datamodel repositories, such as | ||
CMake files, idl files, etc... |
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 |
---|---|---|
@@ -0,0 +1,121 @@ | ||
############################################################################### | ||
# (c) 2024 Copyright, Real-Time Innovations, Inc. (RTI) All rights reserved. # | ||
# # | ||
# RTI grants Licensee a license to use, modify, compile, and create # | ||
# derivative works of the software solely for use with RTI Connext DDS. # | ||
# Licensee may redistribute copies of the software provided that all such # | ||
# copies are subject to this license. # | ||
# The software is provided "as is", with no warranty of any type, including # | ||
# any warranty for fitness for any purpose. RTI is under no obligation to # | ||
# maintain or support the software. RTI shall not be liable for any # | ||
# incidental or consequential damages arising out of the use or inability to # | ||
# use the software. # | ||
# # | ||
############################################################################### | ||
|
||
#[[ | ||
connextdds_datamodels_generate_code | ||
----------------------------------- | ||
This function calls rtiddsgen to all IDL files included in the INPUT_FOLDERS. | ||
Then, this function returns the generated files. | ||
Input parameters: | ||
``INPUT_FOLDERS`` (mandatory) | ||
Folder that contains the idl files to process. | ||
``OUTPUT_FOLDER`` (mandatory) | ||
Folder that will contain the generated files. | ||
``LANG`` (optional) | ||
The language that rtiddsgen will generate code for. Default: C++11 | ||
``IGNORE_IDL_NAMES`` (optional) | ||
List of file names (without extension) that will be ignored and, therefore | ||
rtiddsgen will not generate code for. | ||
``IDL_DEPENDENCIES_FOLDERS`` (optional) | ||
Folder that contains dependencies of the IDL files. For example if an IDL | ||
file has an #include "file.idl", this variable should contain the folder | ||
where file.idl is located. | ||
``CODEGEN_EXTRA_ARGS`` (optional) | ||
Additional flags for Codegen. | ||
Output parameters: | ||
``GENERATED_SRC_FILES`` | ||
List of all generated soruce files. The extension of these files depends | ||
on the LANG input parameter. | ||
* How to use it: | ||
connextdds_datamodels_load_dependencies( | ||
RTI_CMAKE_UTILS_BRANCH release/7.2.0 | ||
RTI_CMAKE_UTILS_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}" | ||
DDS_DCPS_DIR "${CMAKE_CURRENT_BINARY_DIR}/dependencies/" | ||
) | ||
]] | ||
|
||
function(connextdds_datamodels_generate_code) | ||
set(_BOOLEANS) | ||
set(_SINGLE_VALUE_ARGS OUTPUT_FOLDER LANG) | ||
set(_MULTI_VALUE_ARGS | ||
INPUT_FOLDERS IGNORE_IDL_NAMES IDL_DEPENDENCIES_FOLDERS CODEGEN_EXTRA_ARGS) | ||
|
||
cmake_parse_arguments(_args | ||
"${_BOOLEANS}" | ||
"${_SINGLE_VALUE_ARGS}" | ||
"${_MULTI_VALUE_ARGS}" | ||
${ARGN} | ||
) | ||
|
||
if(NOT DEFINED _args_INPUT_FOLDERS) | ||
message(FATAL_ERROR "Error in function connextdds_datamodels_generate_code() " | ||
"The mandatory parameter INPUT_FOLDERS is not defined.") | ||
endif() | ||
|
||
if(NOT DEFINED _args_OUTPUT_FOLDER) | ||
message(FATAL_ERROR "Error in function connextdds_datamodels_generate_code() " | ||
"The mandatory parameter OUTPUT_FOLDER is not defined.") | ||
endif() | ||
|
||
if (NOT DEFINED _args_LANG) | ||
set(_args_LANG C++11) | ||
endif() | ||
|
||
include(ConnextDdsCodegen) | ||
|
||
# Get the name of all the idl files under datamodel/idl/ | ||
set(idl_files) | ||
foreach(input_folder in ${_args_INPUT_FOLDERS}) | ||
file(GLOB idl_files_from_folder "${input_folder}/*.idl") | ||
list(APPEND idl_files ${idl_files_from_folder}) | ||
endforeach() | ||
|
||
foreach(input_folder in ${_args_IDL_DEPENDENCIES_FOLDERS}) | ||
file(GLOB idl_files_from_folder "${input_folder}/*.idl") | ||
list(APPEND idl_files ${idl_files_from_folder}) | ||
endforeach() | ||
|
||
cmake_policy(SET CMP0057 NEW) | ||
|
||
# Call codegen to generate code for all IDL files | ||
foreach(idl_file_path IN LISTS idl_files) | ||
get_filename_component(idl_name ${idl_file_path} NAME_WE) | ||
if(NOT idl_name IN_LIST _args_IGNORE_IDL_NAMES) | ||
connextdds_rtiddsgen_run( | ||
IDL_FILE "${idl_file_path}" | ||
LANG ${_args_LANG} | ||
OUTPUT_DIRECTORY "${_args_OUTPUT_FOLDER}" | ||
INCLUDE_DIRS ${_args_IDL_DEPENDENCIES_FOLDERS} | ||
EXTRA_ARGS ${_args_CODEGEN_EXTRA_ARGS} | ||
) | ||
list(APPEND src_files ${${idl_name}_CXX11_SOURCES}) | ||
endif() | ||
endforeach() | ||
|
||
set(GENERATED_SRC_FILES ${src_files} PARENT_SCOPE) | ||
|
||
endfunction() |
Oops, something went wrong.