Skip to content
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

Merged
merged 8 commits into from
Oct 23, 2023
15 changes: 11 additions & 4 deletions bondcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
Tobias-Fischer marked this conversation as resolved.
Show resolved Hide resolved

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
add_definitions(-DNOMINMAX)
mjcarroll marked this conversation as resolved.
Show resolved Hide resolved

find_package(ament_cmake REQUIRED)
find_package(bond REQUIRED)
Expand All @@ -16,10 +19,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)

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?

Copy link

@traversaro traversaro Mar 28, 2022

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.

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)

Choose a reason for hiding this comment

The 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?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

endif()

add_library(${PROJECT_NAME}
SHARED
Expand Down