Skip to content

Commit

Permalink
Fixup cmake file issues (ros-visualization#1446)
Browse files Browse the repository at this point in the history
* Generate export headers in devel space
  (otherwise rviz cannot build together with downstream packages in the same devel workspace)
* Don't export src as an include path
  • Loading branch information
v4hn authored and rhaschke committed Nov 21, 2019
1 parent 5805917 commit fac45a7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,14 @@ set(rviz_QT_VERSION ${QTVERSION})
# There is a matching instance of this in the plugin_description.xml.
set(rviz_DEFAULT_PLUGIN_LIBRARY_TARGET_NAME rviz_default_plugin)

set(EXPORT_HEADER_DIR "${CATKIN_DEVEL_PREFIX}/include")

catkin_package(
CFG_EXTRAS
rviz-extras.cmake
INCLUDE_DIRS
src
${EXPORT_HEADER_DIR}
${EIGEN3_INCLUDE_DIRS}
${OGRE_OV_INCLUDE_DIRS}
${OPENGL_INCLUDE_DIR}
Expand Down Expand Up @@ -213,7 +216,7 @@ include_directories(SYSTEM
${TinyXML2_INCLUDE_DIRS}
${urdfdom_headers_INCLUDE_DIRS}
)
include_directories(src ${catkin_INCLUDE_DIRS})
include_directories(src ${EXPORT_HEADER_DIR} ${catkin_INCLUDE_DIRS})

#### If gtk ends up being the best way to get the correct window
#### position under X11, this is how to compile it in.
Expand Down
2 changes: 1 addition & 1 deletion src/python_bindings/sip/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ find_package(python_qt_binding REQUIRED)
include(${python_qt_binding_EXTRAS_DIR}/sip_helper.cmake)

# maintain context for different named target
set(rviz_sip_INCLUDE_DIRS ${rviz_INCLUDE_DIRS} "${PROJECT_SOURCE_DIR}/src" ${catkin_INCLUDE_DIRS} $<TARGET_PROPERTY:rviz,EXPORT_HEADER_DIR>)
set(rviz_sip_INCLUDE_DIRS ${rviz_INCLUDE_DIRS} "${PROJECT_SOURCE_DIR}/src" ${catkin_INCLUDE_DIRS} ${EXPORT_HEADER_DIR})
set(rviz_sip_LIBRARIES ${rviz_LIBRARIES} ${PROJECT_NAME})
set(rviz_sip_LIBRARY_DIRS ${rviz_LIBRARY_DIRS} ${CATKIN_DEVEL_PREFIX}/${CATKIN_PACKAGE_LIB_DESTINATION})
if (MSVC)
Expand Down
8 changes: 4 additions & 4 deletions src/rviz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ add_library(${PROJECT_NAME}
)

include(GenerateExportHeader)
generate_export_header(${PROJECT_NAME} EXPORT_FILE_NAME rviz/${PROJECT_NAME}_export.h)
target_include_directories(${PROJECT_NAME} INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
set_target_properties(${PROJECT_NAME} PROPERTIES EXPORT_HEADER_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(EXPORT_FILE_NAME ${EXPORT_HEADER_DIR}/rviz/${PROJECT_NAME}_export.h)
generate_export_header(${PROJECT_NAME} EXPORT_FILE_NAME ${EXPORT_FILE_NAME})
target_include_directories(${PROJECT_NAME} INTERFACE "$<BUILD_INTERFACE:${EXPORT_HEADER_DIR}>")
if(NOT WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-std=c++11")
endif()
Expand Down Expand Up @@ -179,7 +179,7 @@ install(DIRECTORY ./
FILES_MATCHING PATTERN "*.h")

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/rviz/${PROJECT_NAME}_export.h
${EXPORT_FILE_NAME}
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})

install(TARGETS executable
Expand Down
7 changes: 4 additions & 3 deletions src/rviz/default_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ set(SOURCE_FILES

add_library(${rviz_DEFAULT_PLUGIN_LIBRARY_TARGET_NAME} ${SOURCE_FILES})
include(GenerateExportHeader)
generate_export_header(${rviz_DEFAULT_PLUGIN_LIBRARY_TARGET_NAME} EXPORT_FILE_NAME rviz/default_plugin/${rviz_DEFAULT_PLUGIN_LIBRARY_TARGET_NAME}_export.h)
target_include_directories(${rviz_DEFAULT_PLUGIN_LIBRARY_TARGET_NAME} INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
set(EXPORT_FILE_NAME ${EXPORT_HEADER_DIR}/rviz/default_plugin/${rviz_DEFAULT_PLUGIN_LIBRARY_TARGET_NAME}_export.h)
generate_export_header(${rviz_DEFAULT_PLUGIN_LIBRARY_TARGET_NAME} EXPORT_FILE_NAME ${EXPORT_FILE_NAME})
target_include_directories(${rviz_DEFAULT_PLUGIN_LIBRARY_TARGET_NAME} INTERFACE "$<BUILD_INTERFACE:${EXPORT_HEADER_DIR}>")
if(NOT WIN32)
set_target_properties(${rviz_DEFAULT_PLUGIN_LIBRARY_TARGET_NAME}
PROPERTIES COMPILE_FLAGS "-std=c++11")
Expand All @@ -87,7 +88,7 @@ target_link_libraries(${rviz_DEFAULT_PLUGIN_LIBRARY_TARGET_NAME}
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/rviz/default_plugin/${rviz_DEFAULT_PLUGIN_LIBRARY_TARGET_NAME}_export.h
${EXPORT_FILE_NAME}
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}/default_plugin/)

install(TARGETS ${rviz_DEFAULT_PLUGIN_LIBRARY_TARGET_NAME}
Expand Down

0 comments on commit fac45a7

Please sign in to comment.