From 948c7609394958bf617496719e202dc438eff755 Mon Sep 17 00:00:00 2001 From: Tim Clephas Date: Sat, 12 Mar 2022 19:04:42 +0100 Subject: [PATCH] Add support for the ROS build system (#161) --- CMakeLists.txt | 5 +++++ README.md | 9 ++++++++- package.xml | 22 ++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 package.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 381d393..2bea9d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,8 @@ write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake ARCH_INDEPENDENT) if(MAGIC_ENUM_OPT_INSTALL) + include(GNUInstallDirs) + install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Config) @@ -52,4 +54,7 @@ if(MAGIC_ENUM_OPT_INSTALL) export(EXPORT ${PROJECT_NAME}Config NAMESPACE ${PROJECT_NAME}::) + + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/package.xml + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}) endif() diff --git a/README.md b/README.md index ef83e43..9d30373 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ enum class Color { RED = 2, BLUE = 4, GREEN = 8 }; // color_entries[0].first -> Color::RED // color_entries[0].second -> "RED" ``` - + * Enum fusion for multi-level switch/case statements ```cpp @@ -250,6 +250,13 @@ enum class Color { RED = 2, BLUE = 4, GREEN = 8 }; (Note that you must use a supported compiler or specify it with `export CC= `.) +* If you are using [Ros](https://www.ros.org/), you can include this package by adding `magic_enum` to your package.xml and include this package in your workspace. In your CMakeLists.txt add the following: + ```cmake + find_package(magic_enum CONFIG REQUIRED) + ... + target_link_libraries(your_executable magic_enum::magic_enum) + ``` + ## Compiler compatibility * Clang/LLVM >= 5 diff --git a/package.xml b/package.xml new file mode 100644 index 0000000..0d8eb43 --- /dev/null +++ b/package.xml @@ -0,0 +1,22 @@ + + + + + + + magic_enum + 0.7.3 + + Static reflection for enums (to string, from string, iteration) for modern C++, + work with any enum type without any macro or boilerplate code + + + Neargye + MIT + + cmake + + + cmake + +