用于 OpenDDS 项目的 cmake
cmake for OpenDDS Project
寻找标准 CMakelist 来构建 OpenDDS 应用程序(简单 Publisher/Subscriber)。我熟悉教程,使用 MPC 构建示例时一切 运行 都很好。我需要用 cmake 构建我的项目。我正在使用 OpenDDS 3.9。
我尝试为此处的 Stockquote 示例创建一个 CMakelist:
http://opendds.org/about/articles/Article-Intro.html
我的 CMakelist 如下所示:
cmake_minimum_required (VERSION 3.3.0)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
project (publisher)
set(DDS_ROOT_DIR "home/ubuntu/OpenDDS-3.9")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
include_directories (${DDS_ROOT_DIR} "${DDS_ROOT_DIR}/ACE_wrappers" "${DDS_ROOT_DIR}/ACE_wrappers/TAO" ${CMAKE_SOURCE_DIR})
file (GLOB_RECURSE PUBLISHER_SRC *.cpp)
file (GLOB_RECURSE IDL_SRC ${CMAKE_SOURCE_DIR} *.cpp)
add_executable (${PROJECT_NAME} ${PUBLISHER_SRC} ${IDL_SRC})
project (subscriber)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
include_directories (${DDS_ROOT_DIR} "${DDS_ROOT_DIR}/ACE_wrappers" "${DDS_ROOT_DIR}/ACE_wrappers/TAO" ${CMAKE_SOURCE_DIR})
file (GLOB_RECURSE SUBSCRIBER_SRC *.cpp)
file (GLOB_RECURSE IDL_SRC ${CMAKE_SOURCE_DIR} *.cpp)
add_executable (${PROJECT_NAME} ${SUBSCRIBER_SRC} ${IDL_SRC})
# Adding DDS link_libraries
if (WIN32)
file (GLOB OpenDDS_LIBS "${DDS_ROOT_DIR}/lib/*d.dll")
foreach (i ${OpenDDS_LIBS})
get_filename_component (BASE_NAME_DLL ${i} NAME_WE)
add_library (${BASE_NAME_DLL} SHARED IMPORTED)
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_LOCATION "${DDS_ROOT_DIR}/lib/${BASE_NAME_DLL}.dll")
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_IMPLIB "${DDS_ROOT_DIR}/lib/${BASE_NAME_DLL}.lib")
target_link_libraries (${PROJECT_NAME} ${BASE_NAME_DLL})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${BASE_NAME_DLL}> $<TARGET_FILE_DIR:${PROJECT_NAME}>)
endforeach()
file (GLOB OpenDDS_LIBS "${DDS_ROOT_DIR}/ACE_wrappers/lib/*d.dll")
foreach (i ${OpenDDS_LIBS})
get_filename_component (BASE_NAME_DLL ${i} NAME_WE)
add_library (${BASE_NAME_DLL} SHARED IMPORTED)
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_LOCATION "${DDS_ROOT_DIR}/ACE_wrappers/lib/${BASE_NAME_DLL}.dll")
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_IMPLIB "${DDS_ROOT_DIR}/ACE_wrappers/lib/${BASE_NAME_DLL}.lib")
target_link_libraries (${PROJECT_NAME} ${BASE_NAME_DLL})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${BASE_NAME_DLL}> $<TARGET_FILE_DIR:${PROJECT_NAME}>)
endforeach ()
elseif (UNIX)
file (GLOB OpenDDS_LIBS "${DDS_ROOT_DIR}/lib/*.so")
foreach (i ${OpenDDS_LIBS})
get_filename_component (BASE_NAME_DLL ${i} NAME_WE)
add_library (${BASE_NAME_DLL} SHARED IMPORTED)
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_LOCATION "${DDS_ROOT_DIR}/lib/${BASE_NAME_DLL}.so")
target_link_libraries (${PROJECT_NAME} ${BASE_NAME_DLL})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${BASE_NAME_DLL}> $<TARGET_FILE_DIR:${PROJECT_NAME}>)
endforeach()
file (GLOB OpenDDS_LIBS "${DDS_ROOT_DIR}/ACE_wrappers/lib/*.so")
foreach (i ${OpenDDS_LIBS})
get_filename_component (BASE_NAME_DLL ${i} NAME_WE)
add_library (${BASE_NAME_DLL} SHARED IMPORTED)
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_LOCATION "${DDS_ROOT_DIR}/ACE_wrappers/lib/${BASE_NAME_DLL}.so")
target_link_libraries (${PROJECT_NAME} ${BASE_NAME_DLL})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${BASE_NAME_DLL}> $<TARGET_FILE_DIR:${PROJECT_NAME}>)
endforeach ()
endif ()
我从 WTeam 博客中获得了添加 DDS Link 库部分。 http://www.wteam.it/index.php/articles/the-hla-series/9-article/15-first-opendds-program
目前,如果我使用 cmake --build:
,我会收到此错误消息
/usr/local/include/dds/DCPS/DataWriterImpl_T.h: In instantiation of ‘void
OpenDDS::DCPS::DataWriterImpl_T::init(DDS::Topic_ptr,
OpenDDS::DCPS::TopicImpl*, const DDS::DataWriterQos&,
DDS::DataWriterListener_ptr, const StatusMask&,
OpenDDS::DCPS::DomainParticipantImpl*, OpenDDS::DCPS::PublisherImpl*,
DDS::DataWriter_ptr) [with MessageType = Messenger::Message;
DDS::Topic_ptr = DDS::Topic*; DDS::DataWriterListener_ptr =
DDS::DataWriterListener*; DDS::StatusMask = unsigned int;
DDS::DataWriter_ptr = DDS::DataWriter*]’:
/usr/local/include/dds/DCPS/FilterEvaluator.h:142:10: required from
here /usr/local/include/dds/DCPS/DataWriterImpl_T.h:317:50: error:
incomplete type
‘OpenDDS::DCPS::DataWriterImpl_T::MarshalTraitsType
{aka OpenDDS::DCPS::MarshalTraits}’ used in nested
name specifier
if (MarshalTraitsType::gen_is_bounded_size()) {
^ /usr/local/include/dds/DCPS/DataWriterImpl_T.h:323:54: error:
incomplete type
‘OpenDDS::DCPS::DataWriterImpl_T::MarshalTraitsType
{aka OpenDDS::DCPS::MarshalTraits}’ used in nested
name specifier
if (MarshalTraitsType::gen_is_bounded_key_size()) {
^ /usr/local/include/dds/DCPS/DataWriterImpl_T.h: In instantiation of
‘DDS::ReturnCode_t
OpenDDS::DCPS::DataWriterImpl_T::enable_specific() [with
MessageType = Messenger::Message; DDS::ReturnCode_t = int]’:
/usr/local/include/dds/DCPS/FilterEvaluator.h:142:10: required from
here /usr/local/include/dds/DCPS/DataWriterImpl_T.h:338:51: error:
incomplete type
‘OpenDDS::DCPS::DataWriterImpl_T::MarshalTraitsType
{aka OpenDDS::DCPS::MarshalTraits}’ used in nested
name specifier
if (MarshalTraitsType::gen_is_bounded_size ())
^
有没有人知道哪里出了问题或有用于 OpenDDS 应用程序的标准 CMake?非常感谢您的帮助。
干杯,
马塞尔
该网站上的示例项目与 OpenDDS 捆绑在 'examples/DCPS' 文件夹下。它包含一个有效的构建脚本、说明等。
OpenDDS 3.14 将支持 cmake,请参阅 https://github.com/objectcomputing/OpenDDS/tree/master/tests/cmake_integration 使用 cmake 进行单元测试。
寻找标准 CMakelist 来构建 OpenDDS 应用程序(简单 Publisher/Subscriber)。我熟悉教程,使用 MPC 构建示例时一切 运行 都很好。我需要用 cmake 构建我的项目。我正在使用 OpenDDS 3.9。
我尝试为此处的 Stockquote 示例创建一个 CMakelist: http://opendds.org/about/articles/Article-Intro.html
我的 CMakelist 如下所示:
cmake_minimum_required (VERSION 3.3.0)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
project (publisher)
set(DDS_ROOT_DIR "home/ubuntu/OpenDDS-3.9")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
include_directories (${DDS_ROOT_DIR} "${DDS_ROOT_DIR}/ACE_wrappers" "${DDS_ROOT_DIR}/ACE_wrappers/TAO" ${CMAKE_SOURCE_DIR})
file (GLOB_RECURSE PUBLISHER_SRC *.cpp)
file (GLOB_RECURSE IDL_SRC ${CMAKE_SOURCE_DIR} *.cpp)
add_executable (${PROJECT_NAME} ${PUBLISHER_SRC} ${IDL_SRC})
project (subscriber)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/bin)
include_directories (${DDS_ROOT_DIR} "${DDS_ROOT_DIR}/ACE_wrappers" "${DDS_ROOT_DIR}/ACE_wrappers/TAO" ${CMAKE_SOURCE_DIR})
file (GLOB_RECURSE SUBSCRIBER_SRC *.cpp)
file (GLOB_RECURSE IDL_SRC ${CMAKE_SOURCE_DIR} *.cpp)
add_executable (${PROJECT_NAME} ${SUBSCRIBER_SRC} ${IDL_SRC})
# Adding DDS link_libraries
if (WIN32)
file (GLOB OpenDDS_LIBS "${DDS_ROOT_DIR}/lib/*d.dll")
foreach (i ${OpenDDS_LIBS})
get_filename_component (BASE_NAME_DLL ${i} NAME_WE)
add_library (${BASE_NAME_DLL} SHARED IMPORTED)
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_LOCATION "${DDS_ROOT_DIR}/lib/${BASE_NAME_DLL}.dll")
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_IMPLIB "${DDS_ROOT_DIR}/lib/${BASE_NAME_DLL}.lib")
target_link_libraries (${PROJECT_NAME} ${BASE_NAME_DLL})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${BASE_NAME_DLL}> $<TARGET_FILE_DIR:${PROJECT_NAME}>)
endforeach()
file (GLOB OpenDDS_LIBS "${DDS_ROOT_DIR}/ACE_wrappers/lib/*d.dll")
foreach (i ${OpenDDS_LIBS})
get_filename_component (BASE_NAME_DLL ${i} NAME_WE)
add_library (${BASE_NAME_DLL} SHARED IMPORTED)
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_LOCATION "${DDS_ROOT_DIR}/ACE_wrappers/lib/${BASE_NAME_DLL}.dll")
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_IMPLIB "${DDS_ROOT_DIR}/ACE_wrappers/lib/${BASE_NAME_DLL}.lib")
target_link_libraries (${PROJECT_NAME} ${BASE_NAME_DLL})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${BASE_NAME_DLL}> $<TARGET_FILE_DIR:${PROJECT_NAME}>)
endforeach ()
elseif (UNIX)
file (GLOB OpenDDS_LIBS "${DDS_ROOT_DIR}/lib/*.so")
foreach (i ${OpenDDS_LIBS})
get_filename_component (BASE_NAME_DLL ${i} NAME_WE)
add_library (${BASE_NAME_DLL} SHARED IMPORTED)
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_LOCATION "${DDS_ROOT_DIR}/lib/${BASE_NAME_DLL}.so")
target_link_libraries (${PROJECT_NAME} ${BASE_NAME_DLL})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${BASE_NAME_DLL}> $<TARGET_FILE_DIR:${PROJECT_NAME}>)
endforeach()
file (GLOB OpenDDS_LIBS "${DDS_ROOT_DIR}/ACE_wrappers/lib/*.so")
foreach (i ${OpenDDS_LIBS})
get_filename_component (BASE_NAME_DLL ${i} NAME_WE)
add_library (${BASE_NAME_DLL} SHARED IMPORTED)
set_property (TARGET ${BASE_NAME_DLL} PROPERTY IMPORTED_LOCATION "${DDS_ROOT_DIR}/ACE_wrappers/lib/${BASE_NAME_DLL}.so")
target_link_libraries (${PROJECT_NAME} ${BASE_NAME_DLL})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${BASE_NAME_DLL}> $<TARGET_FILE_DIR:${PROJECT_NAME}>)
endforeach ()
endif ()
我从 WTeam 博客中获得了添加 DDS Link 库部分。 http://www.wteam.it/index.php/articles/the-hla-series/9-article/15-first-opendds-program
目前,如果我使用 cmake --build:
,我会收到此错误消息/usr/local/include/dds/DCPS/DataWriterImpl_T.h: In instantiation of ‘void OpenDDS::DCPS::DataWriterImpl_T::init(DDS::Topic_ptr, OpenDDS::DCPS::TopicImpl*, const DDS::DataWriterQos&, DDS::DataWriterListener_ptr, const StatusMask&, OpenDDS::DCPS::DomainParticipantImpl*, OpenDDS::DCPS::PublisherImpl*, DDS::DataWriter_ptr) [with MessageType = Messenger::Message; DDS::Topic_ptr = DDS::Topic*; DDS::DataWriterListener_ptr = DDS::DataWriterListener*; DDS::StatusMask = unsigned int; DDS::DataWriter_ptr = DDS::DataWriter*]’: /usr/local/include/dds/DCPS/FilterEvaluator.h:142:10: required from here /usr/local/include/dds/DCPS/DataWriterImpl_T.h:317:50: error: incomplete type ‘OpenDDS::DCPS::DataWriterImpl_T::MarshalTraitsType {aka OpenDDS::DCPS::MarshalTraits}’ used in nested name specifier if (MarshalTraitsType::gen_is_bounded_size()) { ^ /usr/local/include/dds/DCPS/DataWriterImpl_T.h:323:54: error: incomplete type ‘OpenDDS::DCPS::DataWriterImpl_T::MarshalTraitsType {aka OpenDDS::DCPS::MarshalTraits}’ used in nested name specifier if (MarshalTraitsType::gen_is_bounded_key_size()) { ^ /usr/local/include/dds/DCPS/DataWriterImpl_T.h: In instantiation of ‘DDS::ReturnCode_t OpenDDS::DCPS::DataWriterImpl_T::enable_specific() [with MessageType = Messenger::Message; DDS::ReturnCode_t = int]’: /usr/local/include/dds/DCPS/FilterEvaluator.h:142:10: required from here /usr/local/include/dds/DCPS/DataWriterImpl_T.h:338:51: error: incomplete type ‘OpenDDS::DCPS::DataWriterImpl_T::MarshalTraitsType {aka OpenDDS::DCPS::MarshalTraits}’ used in nested name specifier if (MarshalTraitsType::gen_is_bounded_size ()) ^
有没有人知道哪里出了问题或有用于 OpenDDS 应用程序的标准 CMake?非常感谢您的帮助。
干杯, 马塞尔
该网站上的示例项目与 OpenDDS 捆绑在 'examples/DCPS' 文件夹下。它包含一个有效的构建脚本、说明等。
OpenDDS 3.14 将支持 cmake,请参阅 https://github.com/objectcomputing/OpenDDS/tree/master/tests/cmake_integration 使用 cmake 进行单元测试。