寻找标准的CMakelist来构建OpenDDS应用程序(简单发布者/订阅者)。我对这些教程很熟悉,并且使用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链接库部分。 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:实例化为“ 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 =无符号整数;
DDS :: DataWriter_ptr = DDS :: DataWriter *]’:
/usr/local/include/dds/DCPS/FilterEvaluator.h:142:10:需要
此处/usr/local/include/dds/DCPS/DataWriterImpl_T.h:317:50:错误:
不完整的类型
‘OpenDDS :: DCPS :: DataWriterImpl_T :: MarshalTraitsType
{aka OpenDDS :: DCPS :: MarshalTraits}’用于嵌套
名称说明符
如果(MarshalTraitsType :: gen_is_bounded_size()){
^ /usr/local/include/dds/DCPS/DataWriterImpl_T.h:323:54:错误:
不完整的类型
‘OpenDDS :: DCPS :: DataWriterImpl_T :: MarshalTraitsType
{aka OpenDDS :: DCPS :: MarshalTraits}’用于嵌套
名称说明符
如果(MarshalTraitsType :: gen_is_bounded_key_size()){
^ /usr/local/include/dds/DCPS/DataWriterImpl_T.h:在
‘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:需要
此处/usr/local/include/dds/DCPS/DataWriterImpl_T.h:338:51:错误:
不完整的类型
‘OpenDDS :: DCPS :: DataWriterImpl_T :: MarshalTraitsType
{aka OpenDDS :: DCPS :: MarshalTraits}’用于嵌套
名称说明符
如果(MarshalTraitsType :: gen_is_bounded_size())
^
是否有人知道哪里出了问题或对OpenDDS应用程序有标准的CMake?非常感谢您的帮助。
干杯,
马塞尔
最佳答案
OpenDDS 3.14将具有cmake支持,有关使用cmake的单元测试,请参见https://github.com/objectcomputing/OpenDDS/tree/master/tests/cmake_integration。
关于build - OpenDDS项目的cmake,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46650141/