I am working on implementing a client library from swift, utilizing CMake's swift support, and I'm running into issues with interface files. Unlike C/C++, swift interfaces are not declared in source code. From the swift files, the compiler generates both the .so file and a swiftmodule file, which defines the external interface for other targets to include. Working off of the swift cmake examples, I accomplished this as so:
cmake_minimum_required(VERSION 3.15.1)
project(rclswift_common Swift)
find_package(ament_cmake REQUIRED)
add_library(RclSwiftCommon
"swift/Interfaces.swift"
)
set_target_properties(RclSwiftCommon PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_BINARY_DIR})
install(
TARGETS RclSwiftCommon
EXPORT RclSwiftCommon
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)
ament_export_targets(RclSwiftCommon HAS_LIBRARY_TARGET)
ament_package()
The set_target_properties makes sure that the generated swift modules are included with the target. However, when I use ament_export_targets, I get the following error from ament_export_targets:
CMake Error in CMakeLists.txt:
Target "RclSwiftCommon" INTERFACE_INCLUDE_DIRECTORIES property contains
path:
"/home/alex/ros2/build/rclswift_common"
which is prefixed in the build directory.
CMake Generate step failed. Build files cannot be regenerated correctly.
Why won't ament let me include from the build directory, and is there any workaround I can implement to achieve a working setup?
Originally posted by atyshka on ROS Answers with karma: 43 on 2020-07-23
Post score: 0