-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix osx and win32 builds #83
Changes from all commits
60788a4
ea45bfb
74ef957
ee4fa82
141dbe1
497ac4f
8a0b831
f8b171a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,14 @@ find_package(rclcpp_lifecycle REQUIRED) | |
find_package(smclib REQUIRED) | ||
find_package(Threads REQUIRED) | ||
|
||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(UUID REQUIRED uuid) | ||
# we have to find the absolute path to uuid as target_link_directories is not available before cmake 3.13 | ||
find_library(uuid_ABS_PATH ${UUID_LIBRARIES} PATHS ${UUID_LIBRARY_DIRS}) | ||
if(UNIX AND NOT APPLE) | ||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(UUID REQUIRED uuid) | ||
# we have to find the absolute path to uuid as target_link_directories is not available before cmake 3.13 | ||
find_library(uuid_ABS_PATH ${UUID_LIBRARIES} PATHS ${UUID_LIBRARY_DIRS}) | ||
elseif(WIN32) | ||
set(uuid_ABS_PATH Rpcrt4.lib) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this really make it work on Windows? Where does Rpcrt4.lib come from? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is a system library: https://docs.microsoft.com/en-us/windows/win32/rpc/developing-32-bit-windows-applications . |
||
endif() | ||
|
||
add_library(${PROJECT_NAME} | ||
SHARED | ||
|
@@ -29,6 +33,10 @@ target_include_directories(${PROJECT_NAME} PUBLIC | |
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include> | ||
${UUID_INCLUDE_DIRS}) | ||
if(WIN32) | ||
target_compile_definitions(${PROJECT_NAME} | ||
PRIVATE "BONDCPP_BUILDING_LIBRARY" "NOMINMAX") | ||
endif() | ||
ament_target_dependencies(${PROJECT_NAME} | ||
bond | ||
rclcpp | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright (c) 2022, Open Source Robotics Foundation, Inc. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are met: | ||
// | ||
// * Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// | ||
// * Redistributions in binary form must reproduce the above copyright | ||
// notice, this list of conditions and the following disclaimer in the | ||
// documentation and/or other materials provided with the distribution. | ||
// | ||
// * Neither the name of the copyright holder nor the names of its | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
// POSSIBILITY OF SUCH DAMAGE. | ||
|
||
#ifndef BONDCPP__VISIBILITY_CONTROL_HPP_ | ||
#define BONDCPP__VISIBILITY_CONTROL_HPP_ | ||
|
||
/*! \file visibility_control.hpp | ||
* \brief Macros for controlling visibilty of exported iterfaces. | ||
* | ||
* This logic was borrowed (then namespaced) from the examples on the gcc wiki: | ||
* https://gcc.gnu.org/wiki/Visibility | ||
*/ | ||
/** | ||
* \def BONDCPP_EXPORT | ||
* \brief Exposes the function with its decorated name in the compiled library object. | ||
*/ | ||
/** | ||
* \def BONDCPP_IMPORT | ||
* \brief On Windows declares a function will be imported from a dll, otherwise it is empty | ||
*/ | ||
/** | ||
* \def BONDCPP_PUBLIC | ||
* \brief Declares symbols and functions will be visible for export. | ||
*/ | ||
/** | ||
* \def BONDCPP_PUBLIC_TYPE | ||
* \brief On Windows, this is a replica of BONDCPP_PUBLIC, otherwise it is empty. | ||
*/ | ||
/** | ||
* \def BONDCPP_LOCAL | ||
* \brief Declares symbols cannot be exported from the dll. | ||
*/ | ||
|
||
#if defined _WIN32 || defined __CYGWIN__ | ||
#ifdef __GNUC__ | ||
#define BONDCPP_EXPORT __attribute__ ((dllexport)) | ||
#define BONDCPP_IMPORT __attribute__ ((dllimport)) | ||
#else | ||
#define BONDCPP_EXPORT __declspec(dllexport) | ||
#define BONDCPP_IMPORT __declspec(dllimport) | ||
#endif | ||
#ifdef BONDCPP_BUILDING_LIBRARY | ||
#define BONDCPP_PUBLIC BONDCPP_EXPORT | ||
#else | ||
#define BONDCPP_PUBLIC BONDCPP_IMPORT | ||
#endif | ||
#define BONDCPP_PUBLIC_TYPE BONDCPP_PUBLIC | ||
#define BONDCPP_LOCAL | ||
#else | ||
#define BONDCPP_EXPORT __attribute__ ((visibility("default"))) | ||
#define BONDCPP_IMPORT | ||
#if __GNUC__ >= 4 | ||
#define BONDCPP_PUBLIC __attribute__ ((visibility("default"))) | ||
#define BONDCPP_LOCAL __attribute__ ((visibility("hidden"))) | ||
#else | ||
#define BONDCPP_PUBLIC | ||
#define BONDCPP_LOCAL | ||
#endif | ||
#define BONDCPP_PUBLIC_TYPE | ||
#endif | ||
|
||
#endif // BONDCPP__VISIBILITY_CONTROL_HPP_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens on macOS? If we are never finding the uuid library, how does it build/link against it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On macOS libuuid header and symbols are provided by the OS SDK/libc, so there is no need to provide additonal header directories or library to link, see gazebosim/gz-cmake#128 and gazebosim/gz-cmake#127 for a similar change on Ignition libraries or https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/uuid_generate.3.html for the macOS docs.