From 07b793fbcbc0f85d76cfef7bbedef82216344271 Mon Sep 17 00:00:00 2001 From: Jose Luis Rivero Date: Wed, 30 Dec 2020 04:32:58 +0100 Subject: [PATCH] Generate valid visibility macros by avoiding hyphens (#135) Signed-off-by: Jose Luis Rivero Signed-off-by: Louise Poubel --- cmake/IgnUtils.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake/IgnUtils.cmake b/cmake/IgnUtils.cmake index 7fa50221..e40ad141 100644 --- a/cmake/IgnUtils.cmake +++ b/cmake/IgnUtils.cmake @@ -1103,6 +1103,8 @@ function(ign_add_component component_name) # Create an upper case version of the component name, to be used as an export # base name. string(TOUPPER ${component_name} component_name_upper) + # hyphen is not supported as macro name, replace it by underscore + string(REPLACE "-" "_" component_name_upper ${component_name_upper}) #------------------------------------ # Create the target for this component, and configure it to be installed @@ -1349,6 +1351,14 @@ macro(_ign_add_library_or_component) _ign_add_library_or_component_arg_error(EXPORT_BASE) endif() + # check that export_base has no invalid symbols + string(REPLACE "-" "_" export_base_replaced ${export_base}) + if(NOT ${export_base} STREQUAL ${export_base_replaced}) + message(FATAL_ERROR + "export_base has a hyphen which is not" + "supported by macros used for visibility") + endif() + #------------------------------------ # Create the library target