Skip to content

Commit

Permalink
Ticktock export headers
Browse files Browse the repository at this point in the history
Signed-off-by: methylDragon <[email protected]>
  • Loading branch information
methylDragon committed May 4, 2022
1 parent 2fbea3b commit 5f72b77
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 9 deletions.
40 changes: 39 additions & 1 deletion cmake/Export.hh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 _USING_GZ_EXPORT_BASE @_using_gz_export_base@
#if _USING_GZ_EXPORT_BASE


#ifndef @_ign_export_base@_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 @_ign_export_base@_VISIBLE \
DETAIL_@export_base@_VISIBLE
#endif


#ifndef @_ign_export_base@_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 @_ign_export_base@_VISIBLE, so this does not
/// generally need to be used.
#define @_ign_export_base@_HIDDEN \
DETAIL_@export_base@_HIDDEN
#endif


#endif // _USING_GZ_EXPORT_BASE
#endif // @export_base@_EXPORT_HH_
82 changes: 74 additions & 8 deletions cmake/IgnUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -952,12 +952,58 @@ function(ign_create_core_library)

#------------------------------------
# Create the target for the core library, and configure it to be installed
_ign_add_library_or_component(
LIB_NAME ${PROJECT_LIBRARY_TARGET_NAME}
INCLUDE_DIR "${PROJECT_INCLUDE_DIR}"
EXPORT_BASE IGNITION_${IGN_DESIGNATION_UPPER}
SOURCES ${sources}
${interface_option})

# Support "gz-"
if(${PROJECT_LIBRARY_TARGET_NAME} MATCHES "^gz-")
_ign_add_library_or_component(
LIB_NAME ${PROJECT_LIBRARY_TARGET_NAME}
INCLUDE_DIR "${PROJECT_INCLUDE_DIR}"
EXPORT_BASE GZ_${IGN_DESIGNATION_UPPER}
SOURCES ${sources}
${interface_option})

# For ticktocking: Export an "ignition-" target as well, allowing linking against
# the ignition- prefixed name
# TODO(CH3): To remove on tock
string(REGEX REPLACE "^gz-" "ignition-" IGN_LIBRARY_TARGET_NAME ${PROJECT_LIBRARY_TARGET_NAME})
_ign_add_library_or_component(
LIB_NAME ${IGN_LIBRARY_TARGET_NAME}
INCLUDE_DIR "${PROJECT_INCLUDE_DIR}"

# Using GZ_ is deliberate, Export.hh.in has logic to deal with this
EXPORT_BASE GZ_${IGN_DESIGNATION_UPPER}
SOURCES ${sources}
${interface_option})

target_include_directories(${IGN_LIBRARY_TARGET_NAME}
${property_type}
# This is the publicly installed headers directory.
"$<INSTALL_INTERFACE:${IGN_INCLUDE_INSTALL_DIR_FULL}>"
# This is the in-build version of the core library headers directory.
# Generated headers for the core library get placed here.
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>"
# Generated headers for the core library might also get placed here.
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/core/include>")

#------------------------------------
# Handle cmake and pkgconfig packaging
# TODO(CH3): Remove on tock
string(REGEX REPLACE "^gz-" "ignition-" IGN_PROJECT_NAME_LOWER ${PROJECT_NAME_LOWER})

if(ign_create_core_library_INTERFACE)
set(project_pkgconfig_core_lib) # Intentionally blank
else()
set(project_pkgconfig_core_lib "-l${IGN_PROJECT_NAME_LOWER}")
endif()

else()
_ign_add_library_or_component(
LIB_NAME ${PROJECT_LIBRARY_TARGET_NAME}
INCLUDE_DIR "${PROJECT_INCLUDE_DIR}"
EXPORT_BASE GZ_${IGN_DESIGNATION_UPPER}
SOURCES ${sources}
${interface_option})
endif()

# These generator expressions are necessary for multi-configuration generators
# such as MSVC on Windows. They also ensure that our target exports its
Expand Down Expand Up @@ -1136,10 +1182,18 @@ function(ign_add_component component_name)

#------------------------------------
# Create the target for this component, and configure it to be installed

# Support "gz-"
if(${PROJECT_LIBRARY_TARGET_NAME} MATCHES "^gz-")
set(EXPORT_PREFIX "GZ")
else()
set(EXPORT_PREFIX "IGNITION")
endif()

_ign_add_library_or_component(
LIB_NAME ${component_target_name}
INCLUDE_DIR "${PROJECT_INCLUDE_DIR}/${include_subdir}"
EXPORT_BASE IGNITION_${IGN_DESIGNATION_UPPER}_${component_name_upper}
EXPORT_BASE ${EXPORT_PREFIX}_${IGN_DESIGNATION_UPPER}_${component_name_upper}
SOURCES ${sources}
${interface_option})

Expand Down Expand Up @@ -1424,7 +1478,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}")
Expand All @@ -1438,6 +1492,18 @@ 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()

string(REGEX REPLACE "^GZ_" "IGNITION_" _ign_export_base ${export_base})

configure_file(
"${IGNITION_CMAKE_DIR}/Export.hh.in"
"${binary_include_dir}/Export.hh")
Expand Down

0 comments on commit 5f72b77

Please sign in to comment.