GenerateExportHeader: Add option to specify custom content
This commit is contained in:
parent
4bbfea1751
commit
843402b04a
|
@ -0,0 +1,6 @@
|
||||||
|
GenerateExportHeader-custom-content
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
* The :module:`GenerateExportHeader` module learned a new
|
||||||
|
``CUSTOM_CONTENT_FROM_VARIABLE`` option to specify a variable
|
||||||
|
containing custom content for inclusion in the generated header.
|
|
@ -20,6 +20,7 @@
|
||||||
# [NO_DEPRECATED_MACRO_NAME <no_deprecated_macro_name>]
|
# [NO_DEPRECATED_MACRO_NAME <no_deprecated_macro_name>]
|
||||||
# [DEFINE_NO_DEPRECATED]
|
# [DEFINE_NO_DEPRECATED]
|
||||||
# [PREFIX_NAME <prefix_name>]
|
# [PREFIX_NAME <prefix_name>]
|
||||||
|
# [CUSTOM_CONTENT_FROM_VARIABLE <variable>]
|
||||||
# )
|
# )
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
@ -60,8 +61,10 @@
|
||||||
# The CMake fragment will generate a file in the
|
# The CMake fragment will generate a file in the
|
||||||
# ``${CMAKE_CURRENT_BINARY_DIR}`` called ``somelib_export.h`` containing the
|
# ``${CMAKE_CURRENT_BINARY_DIR}`` called ``somelib_export.h`` containing the
|
||||||
# macros ``SOMELIB_EXPORT``, ``SOMELIB_NO_EXPORT``, ``SOMELIB_DEPRECATED``,
|
# macros ``SOMELIB_EXPORT``, ``SOMELIB_NO_EXPORT``, ``SOMELIB_DEPRECATED``,
|
||||||
# ``SOMELIB_DEPRECATED_EXPORT`` and ``SOMELIB_DEPRECATED_NO_EXPORT``. The
|
# ``SOMELIB_DEPRECATED_EXPORT`` and ``SOMELIB_DEPRECATED_NO_EXPORT``.
|
||||||
# resulting file should be installed with other headers in the library.
|
# They will be followed by content taken from the variable specified by
|
||||||
|
# the ``CUSTOM_CONTENT_FROM_VARIABLE`` option, if any.
|
||||||
|
# The resulting file should be installed with other headers in the library.
|
||||||
#
|
#
|
||||||
# The ``BASE_NAME`` argument can be used to override the file name and the
|
# The ``BASE_NAME`` argument can be used to override the file name and the
|
||||||
# names used for the macros:
|
# names used for the macros:
|
||||||
|
@ -288,7 +291,7 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY)
|
||||||
set(options DEFINE_NO_DEPRECATED)
|
set(options DEFINE_NO_DEPRECATED)
|
||||||
set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME
|
set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME
|
||||||
DEPRECATED_MACRO_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE
|
DEPRECATED_MACRO_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE
|
||||||
NO_DEPRECATED_MACRO_NAME)
|
NO_DEPRECATED_MACRO_NAME CUSTOM_CONTENT_FROM_VARIABLE)
|
||||||
set(multiValueArgs)
|
set(multiValueArgs)
|
||||||
|
|
||||||
cmake_parse_arguments(_GEH "${options}" "${oneValueArgs}" "${multiValueArgs}"
|
cmake_parse_arguments(_GEH "${options}" "${oneValueArgs}" "${multiValueArgs}"
|
||||||
|
@ -361,6 +364,14 @@ macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY)
|
||||||
endif()
|
endif()
|
||||||
string(MAKE_C_IDENTIFIER ${EXPORT_IMPORT_CONDITION} EXPORT_IMPORT_CONDITION)
|
string(MAKE_C_IDENTIFIER ${EXPORT_IMPORT_CONDITION} EXPORT_IMPORT_CONDITION)
|
||||||
|
|
||||||
|
if(_GEH_CUSTOM_CONTENT_FROM_VARIABLE)
|
||||||
|
if(DEFINED "${_GEH_CUSTOM_CONTENT_FROM_VARIABLE}")
|
||||||
|
set(CUSTOM_CONTENT "${${_GEH_CUSTOM_CONTENT_FROM_VARIABLE}}")
|
||||||
|
else()
|
||||||
|
set(CUSTOM_CONTENT "")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
configure_file("${_GENERATE_EXPORT_HEADER_MODULE_DIR}/exportheader.cmake.in"
|
configure_file("${_GENERATE_EXPORT_HEADER_MODULE_DIR}/exportheader.cmake.in"
|
||||||
"${EXPORT_FILE_NAME}" @ONLY)
|
"${EXPORT_FILE_NAME}" @ONLY)
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
|
@ -38,5 +38,5 @@
|
||||||
# define @NO_DEPRECATED_MACRO_NAME@
|
# define @NO_DEPRECATED_MACRO_NAME@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
@CUSTOM_CONTENT@
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,9 +25,12 @@ add_library(shared_variant SHARED ${lib_SRCS})
|
||||||
set_target_properties(shared_variant PROPERTIES DEFINE_SYMBOL SHARED_VARIANT_MAKEDLL)
|
set_target_properties(shared_variant PROPERTIES DEFINE_SYMBOL SHARED_VARIANT_MAKEDLL)
|
||||||
add_library(static_variant ${lib_SRCS})
|
add_library(static_variant ${lib_SRCS})
|
||||||
|
|
||||||
|
set(MY_CUSTOM_CONTENT "#define MY_CUSTOM_CONTENT_ADDED")
|
||||||
|
|
||||||
generate_export_header(shared_variant
|
generate_export_header(shared_variant
|
||||||
BASE_NAME libshared_and_static
|
BASE_NAME libshared_and_static
|
||||||
PREFIX_NAME MYPREFIX_
|
PREFIX_NAME MYPREFIX_
|
||||||
|
CUSTOM_CONTENT_FROM_VARIABLE MY_CUSTOM_CONTENT
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE)
|
set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
|
|
||||||
#include "libshared_and_static.h"
|
#include "libshared_and_static.h"
|
||||||
|
|
||||||
|
#ifndef MY_CUSTOM_CONTENT_ADDED
|
||||||
|
# error "MY_CUSTOM_CONTENT_ADDED not defined!"
|
||||||
|
#endif
|
||||||
|
|
||||||
int LibsharedAndStatic::libshared_and_static() const
|
int LibsharedAndStatic::libshared_and_static() const
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue