Skip to content

Commit

Permalink
Hide symbols from shared libraries by default and support DLL creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisThrasher committed Feb 19, 2024
1 parent f2f9398 commit 549df46
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,26 @@ endif()

option(BUILD_SHARED_LIBS "Build shared libraries" ON)

include(GenerateExportHeader)
add_library(rsl
src/parameter_validators.cpp
src/random.cpp
)
add_library(rsl::rsl ALIAS rsl)
target_compile_features(rsl PUBLIC cxx_std_17)
target_include_directories(rsl PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
target_include_directories(rsl PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
)
target_link_libraries(rsl PUBLIC
Eigen3::Eigen
fmt::fmt
rclcpp::rclcpp
tcb_span::tcb_span
tl_expected::tl_expected
)
set_target_properties(rsl PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN YES)
generate_export_header(rsl EXPORT_FILE_NAME include/rsl/export.hpp)

add_subdirectory(docs)

Expand All @@ -41,7 +47,7 @@ endif()
include(CMakePackageConfigHelpers)

install(
DIRECTORY include/
DIRECTORY include/ ${PROJECT_BINARY_DIR}/include/
DESTINATION include/rsl
)
install(
Expand Down
3 changes: 2 additions & 1 deletion include/rsl/parameter_validators.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <rsl/algorithm.hpp>
#include <rsl/export.hpp>
#include <rsl/static_string.hpp>
#include <rsl/static_vector.hpp>

Expand Down Expand Up @@ -298,7 +299,7 @@ template <typename T>
/**
* @brief Convert the result of a validator function into a SetParametersResult msg
*/
[[nodiscard]] auto to_parameter_result_msg(tl::expected<void, std::string> const& result)
[[nodiscard]] RSL_EXPORT auto to_parameter_result_msg(tl::expected<void, std::string> const& result)
-> rcl_interfaces::msg::SetParametersResult;

} // namespace rsl
6 changes: 4 additions & 2 deletions include/rsl/random.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <rsl/export.hpp>

#include <Eigen/Geometry>
#include <cassert>
#include <random>
Expand All @@ -22,7 +24,7 @@ namespace rsl {
*
* @return Seeded random number generator
*/
auto rng(std::seed_seq seed_sequence = {}) -> std::mt19937&;
RSL_EXPORT auto rng(std::seed_seq seed_sequence = {}) -> std::mt19937&;

/**
* @brief Get a uniform real number in a given range
Expand Down Expand Up @@ -63,6 +65,6 @@ template <typename IntType>
* @brief Generate a random unit quaternion of doubles
* @return Random unit quaternion
*/
[[nodiscard]] auto random_unit_quaternion() -> Eigen::Quaterniond;
[[nodiscard]] RSL_EXPORT auto random_unit_quaternion() -> Eigen::Quaterniond;

} // namespace rsl

0 comments on commit 549df46

Please sign in to comment.