Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ endif()

set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules")

if(CMAKE_CROSSCOMPILING)
set(not_crosscompiling OFF)
else()
set(not_crosscompiling ON)
endif()

option(BUILD_IDLCXX "Build IDL preprocessor" ${not_crosscompiling})

# Make it easy to enable MSVC, Clang's/gcc's analyzers
set(ANALYZER "" CACHE STRING "Analyzer to enable on the build.")
if(ANALYZER)
Expand Down
2 changes: 2 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#
set(CMAKE_INSTALL_EXAMPLESDIR "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/examples")

include("${CMAKE_SOURCE_DIR}/src/idlcxx/Generate.cmake")

install(
FILES helloworld/publisher.cpp
helloworld/subscriber.cpp
Expand Down
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
#
# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
#
add_subdirectory(idlcxx)
if (BUILD_IDLCXX)
add_subdirectory(idlcxx)
endif()
add_subdirectory(ddscxx)
28 changes: 25 additions & 3 deletions src/idlcxx/Generate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,28 @@ function(IDLCXX_GENERATE)
cmake_parse_arguments(
IDLCXX "" "${one_value_keywords}" "${multi_value_keywords}" "" ${ARGN})

if (CMAKE_CROSSCOMPILING)
find_program(_idlc_executable idlc NO_CMAKE_FIND_ROOT_PATH REQUIRED)
find_library(_idlcxx_shared_lib cycloneddsidlcxx NO_CMAKE_FIND_ROOT_PATH REQUIRED)

if (_idlc_executable)
set(_idlc_depends "")
else()
message(FATAL_ERROR "Cannot find idlc executable")
endif()

if (_idlcxx_shared_lib)
set(_idlcxx_depends "")
else()
message(FATAL_ERROR "Cannot find idlcxx shared library")
endif()
else()
set(_idlc_executable CycloneDDS::idlc)
set(_idlc_depends CycloneDDS::idlc)
set(_idlcxx_shared_lib "$<TARGET_FILE:CycloneDDS-CXX::idlcxx>")
set(_idlcxx_depends CycloneDDS-CXX::idlcxx)
endif()

if(NOT IDLCXX_TARGET AND NOT IDLCXX_FILES)
# assume deprecated invocation: TARGET FILE [FILE..]
list(GET IDLCXX_UNPARSED_ARGUMENTS 0 IDLCXX_TARGET)
Expand Down Expand Up @@ -55,9 +77,9 @@ function(IDLCXX_GENERATE)
list(APPEND _headers "${_header}")
add_custom_command(
OUTPUT "${_header}"
COMMAND CycloneDDS::idlc
ARGS -l $<TARGET_FILE:CycloneDDS-CXX::idlcxx> ${IDLCXX_ARGS} ${_file}
DEPENDS ${_files} CycloneDDS::idlc CycloneDDS-CXX::idlcxx)
COMMAND ${_idlc_executable}
ARGS -l ${_idlcxx_shared_lib} ${IDLCXX_ARGS} ${_file}
DEPENDS ${_files} ${_idlc_depends} ${_idlcxx_depends})
endforeach()

add_custom_target("${_target}_generate" DEPENDS ${_headers})
Expand Down