Skip to content

Commit

Permalink
Merge pull request #406 from robotology/fixWindows
Browse files Browse the repository at this point in the history
Various fixes to enable compilation in Windows against Chocolatey's Gazebo binary
  • Loading branch information
traversaro authored Jan 3, 2019
2 parents 154f236 + 80d749b commit 4e8404c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
19 changes: 14 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Authors: Enrico Mingo, Alessio Rocchi, Mirko Ferrati, Silvio Traversaro, Alessandro Settimi and Francesco Romano
# CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT

cmake_minimum_required(VERSION 2.8.7)
cmake_minimum_required(VERSION 3.5)
PROJECT(GazeboYARPPlugins)

# Project version
Expand All @@ -18,19 +18,28 @@ include(GNUInstallDirs)

# Finding dependencies
find_package(YARP 3.0.101 REQUIRED)
find_package(Boost REQUIRED serialization system)
find_package(Protobuf REQUIRED)
find_package(Gazebo REQUIRED)
if (Gazebo_VERSION_MAJOR LESS 7.0)
message(status "Gazebo version : " ${Gazebo_VERSION_MAJOR}.${Gazebo_VERSION_MINOR}.${Gazebo_VERSION_PATCH})
message(FATAL_ERROR "Your Gazebo version is older than Gazebo 7.0. Gazebo Yarp plugins are supported with gazebo versions >= 7.0. Please update to a newer version")
endif()
find_package(SDFormat REQUIRED)
find_package(OGRE QUIET)

# Custom workaround for chocolatey distributed Gazebo and OGRE
# See https://github.com/ms-iot/ROSOnWindows/issues/48 for the original issue
if(MSVC)
find_package(OGRE REQUIRED CONFIG)
# It is tipically better to use target_include_directories in place of
# global include_directories, but in this case it is more compact to use include_directories
include_directories(${OGRE_Paging_INCLUDE_DIRS})
endif()


# Add Gazebo CXX flags, to support Gazebo 6 reckless dependency on C++11
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GAZEBO_CXX_FLAGS}")

# On Windows, export all symbols by default as *nix
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

# add local cmake scripts
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)

Expand Down
8 changes: 8 additions & 0 deletions cmake/AddGazeboYarpPluginTarget.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,18 @@ endif()
add_library(${GAZEBO_PLUGIN_LIBRARY_NAME} ${LIBRARY_TYPE} ${GAZEBO_PLUGIN_SOURCES} ${GAZEBO_PLUGIN_HEADERS})
target_link_libraries(${GAZEBO_PLUGIN_LIBRARY_NAME} ${GAZEBO_PLUGIN_LINKED_LIBRARIES})


target_include_directories(${GAZEBO_PLUGIN_LIBRARY_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")

if(MSVC)
# On Visual Studio, it is necessary to define this Windows-specific macros
# to get Gazebo headers to compile without problems, for more details
# see https://stackoverflow.com/questions/5971332/redefinition-errors-in-winsock2-h
target_compile_definitions(${GAZEBO_PLUGIN_LIBRARY_NAME} PUBLIC NOMINMAX WIN32_LEAN_AND_MEAN _USE_MATH_DEFINES)
endif()

# Add install target
install(TARGETS ${GAZEBO_PLUGIN_LIBRARY_NAME}
EXPORT GazeboYARPPlugins
Expand Down
3 changes: 2 additions & 1 deletion plugins/depthCamera/src/DepthCameraDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ bool GazeboYarpDepthCameraDriver::getDepthClipPlanes(double& nearPlane, double&
{
nearPlane = m_depthCameraSensorPtr->DepthCamera()->NearClip();
farPlane = m_depthCameraSensorPtr->DepthCamera()->FarClip();
return true;
}
bool GazeboYarpDepthCameraDriver::setDepthClipPlanes(double nearPlane, double farPlane)
{
Expand Down Expand Up @@ -415,7 +416,7 @@ bool GazeboYarpDepthCameraDriver::getDepthImage(depthImageType& depthImage, Stam
m_depthFrameMutex.post();
return true;
}
bool GazeboYarpDepthCameraDriver::getExtrinsicParam(sig::Matrix& extrinsic)
bool GazeboYarpDepthCameraDriver::getExtrinsicParam(yarp::sig::Matrix& extrinsic)
{
extrinsic.resize(4, 4);
extrinsic.zero();
Expand Down
3 changes: 2 additions & 1 deletion thrift/linkattacher/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ set_property(TARGET ${LIBRARY_TARGET_NAME} PROPERTY PUBLIC_HEADER "${LARPC_HEADE

install(TARGETS ${LIBRARY_TARGET_NAME}
EXPORT ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/gazebo)

set_property(GLOBAL APPEND PROPERTY ${PROJECT_NAME}_TARGETS ${LIBRARY_TARGET_NAME})

0 comments on commit 4e8404c

Please sign in to comment.