From 13c189f903fb652f6eac734d9b2b2f055ec2daa3 Mon Sep 17 00:00:00 2001 From: methylDragon Date: Wed, 4 May 2022 12:53:42 -0700 Subject: [PATCH] Ticktock export headers --- cmake/Export.hh.in | 40 +++++++++++++++++++++++++++++++++++++++- cmake/IgnUtils.cmake | 16 ++++++++++++++-- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/cmake/Export.hh.in b/cmake/Export.hh.in index c20b4836..995d5440 100644 --- a/cmake/Export.hh.in +++ b/cmake/Export.hh.in @@ -53,11 +53,49 @@ #ifndef IGN_DEPRECATED +// TODO(CH3): Remove on ticktock +// NOTE(CH3): This has no docstring since we'll make GZ_DEPRECATED the default +#define IGN_DEPRECATED(version) GZ_DEPRECATED_ALL_VERSIONS +#endif + +#ifndef GZ_DEPRECATED /// For @lib_name@ developers: Use this macro to indicate that a /// function or class has been deprecated and should no longer be used. A /// version should be specified to provide context to the user about when the /// function became deprecated. -#define IGN_DEPRECATED(version) IGN_DEPRECATED_ALL_VERSIONS + +// NOTE(CH3): GZ_DEPRECATED_ALL_VERSIONS can't be ticktocked, it's generated +// On the bright side, it seems to be private +#define GZ_DEPRECATED(version) GZ_DEPRECATED_ALL_VERSIONS +#endif + + +// TICKTOCK IGNITION ======================================================== +// TODO(CH3): Remove on ticktock, supports defining IGNITION macros if we're +// a lib is using GZ_ prefixed export macros +#define _GZ_EXPORT_BASE @_gz_export_base@ +#if _GZ_EXPORT_BASE + + +#ifndef IGNITION_VISIBLE +/// For @lib_name@ developers: Apply this macro to @lib_name@ +/// functions and classes which consumers of this library will need to be able +/// to call from their own programs or libraries. +#define IGNITION_VISIBLE \ + DETAIL_@export_base@_VISIBLE #endif + +#ifndef IGNITION_HIDDEN +/// For @lib_name@ developers: Apply this macro to @lib_name@ +/// functions and classes which must not be used by consumers of this library. +/// By default, this property is applied to all classes and functions which are +/// not tagged with IGNITION_VISIBLE, so this does not +/// generally need to be used. +#define IGNITION_HIDDEN \ + DETAIL_@export_base@_HIDDEN #endif + + +#endif // _GZ_EXPORT_BASE +#endif // @export_base@_EXPORT_HH_ diff --git a/cmake/IgnUtils.cmake b/cmake/IgnUtils.cmake index afc8a76d..4a162346 100644 --- a/cmake/IgnUtils.cmake +++ b/cmake/IgnUtils.cmake @@ -1045,7 +1045,9 @@ function(ign_create_core_library) _ign_add_library_or_component( LIB_NAME ${IGN_LIBRARY_TARGET_NAME} INCLUDE_DIR "${PROJECT_INCLUDE_DIR}" - EXPORT_BASE IGNITION_${IGN_DESIGNATION_UPPER} + + # Using GZ_ is deliberate, Export.hh.in has logic to deal with this + EXPORT_BASE GZ_${IGN_DESIGNATION_UPPER} SOURCES ${sources} ${interface_option}) @@ -1554,7 +1556,7 @@ macro(_ign_add_library_or_component) EXPORT_FILE_NAME ${implementation_file_name} EXPORT_MACRO_NAME DETAIL_${export_base}_VISIBLE NO_EXPORT_MACRO_NAME DETAIL_${export_base}_HIDDEN - DEPRECATED_MACRO_NAME IGN_DEPRECATED_ALL_VERSIONS) + DEPRECATED_MACRO_NAME GZ_DEPRECATED_ALL_VERSIONS) set(install_include_dir "${IGN_INCLUDE_INSTALL_DIR_FULL}/${include_dir}") @@ -1568,6 +1570,16 @@ macro(_ign_add_library_or_component) # Configure the public-facing header for exporting and deprecating. This # header provides commentary for the macros so that developers can know their # purpose. + + # TODO(CH3): Remove this on ticktock + # This is to allow IGNITION_ prefixed export macros to generate in Export.hh + # _gz_export_base is used in Export.hh.in's configuration! + if(${export_base} MATCHES "^GZ_") + set(_gz_export_base 1) + else() + set(_gz_export_base 0) + endif() + configure_file( "${IGNITION_CMAKE_DIR}/Export.hh.in" "${binary_include_dir}/Export.hh")