GenerateExportHeader: Deprecate add_compiler_export_flags function.

This is made obsolete by the CXX_VISIBILITY_PRESET and
VISIBILITY_INLINES_HIDDEN target properties.
This commit is contained in:
Stephen Kelly 2013-09-02 10:57:55 +02:00
parent ce6c7366f7
commit 0f3a66673f
1 changed files with 34 additions and 13 deletions

View File

@ -1,6 +1,5 @@
# - Function for generation of export macros for libraries # - Function for generation of export macros for libraries
# This module provides the function GENERATE_EXPORT_HEADER() and the # This module provides the function GENERATE_EXPORT_HEADER().
# accompanying ADD_COMPILER_EXPORT_FLAGS() function.
# #
# The GENERATE_EXPORT_HEADER function can be used to generate a file suitable # The GENERATE_EXPORT_HEADER function can be used to generate a file suitable
# for preprocessor inclusion which contains EXPORT macros to be used in # for preprocessor inclusion which contains EXPORT macros to be used in
@ -18,20 +17,17 @@
# [PREFIX_NAME <prefix_name>] # [PREFIX_NAME <prefix_name>]
# ) # )
# #
# ADD_COMPILER_EXPORT_FLAGS( [<output_variable>] ) # The target properties CXX_VISIBILITY_PRESET and VISIBILITY_INLINES_HIDDEN
# can be used to add the appropriate compile flags for targets. See the
# documentation of those target properties, and the convenience variables
# CMAKE_CXX_VISIBILITY_PRESET and CMAKE_VISIBILITY_INLINES_HIDDEN.
# #
# By default GENERATE_EXPORT_HEADER() generates macro names in a file name # By default GENERATE_EXPORT_HEADER() generates macro names in a file name
# determined by the name of the library. The ADD_COMPILER_EXPORT_FLAGS function # determined by the name of the library. This means that in the simplest case,
# adds -fvisibility=hidden to CMAKE_CXX_FLAGS if supported, and is a no-op on # users of generate_export_header will be equivalent to:
# Windows which does not need extra compiler flags for exporting support. You
# may optionally pass a single argument to ADD_COMPILER_EXPORT_FLAGS that will
# be populated with the required CXX_FLAGS required to enable visibility support
# for the compiler/architecture in use.
# #
# This means that in the simplest case, users of these functions will be # set(CMAKE_CXX_VISIBILITY_PRESET hidden)
# equivalent to: # set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
#
# add_compiler_export_flags()
# add_library(somelib someclass.cpp) # add_library(somelib someclass.cpp)
# generate_export_header(somelib) # generate_export_header(somelib)
# install(TARGETS somelib DESTINATION ${LIBRARY_INSTALL_DIR}) # install(TARGETS somelib DESTINATION ${LIBRARY_INSTALL_DIR})
@ -128,6 +124,20 @@
# generate_export_header(somelib PREFIX_NAME VTK_) # generate_export_header(somelib PREFIX_NAME VTK_)
# #
# Generates the macros VTK_SOMELIB_EXPORT etc. # Generates the macros VTK_SOMELIB_EXPORT etc.
#
#
# ADD_COMPILER_EXPORT_FLAGS( [<output_variable>] )
#
# The ADD_COMPILER_EXPORT_FLAGS function
# adds -fvisibility=hidden to CMAKE_CXX_FLAGS if supported, and is a no-op on
# Windows which does not need extra compiler flags for exporting support. You
# may optionally pass a single argument to ADD_COMPILER_EXPORT_FLAGS that will
# be populated with the required CXX_FLAGS required to enable visibility support
# for the compiler/architecture in use.
#
# This function is deprecated. Set the target properties CXX_VISIBILITY_PRESET
# and VISIBILITY_INLINES_HIDDEN instead.
#
#============================================================================= #=============================================================================
# Copyright 2011 Stephen Kelly <steveire@gmail.com> # Copyright 2011 Stephen Kelly <steveire@gmail.com>
@ -326,6 +336,17 @@ function(GENERATE_EXPORT_HEADER TARGET_LIBRARY)
endfunction() endfunction()
function(add_compiler_export_flags) function(add_compiler_export_flags)
if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12)
if(CMAKE_WARN_DEPRECATED)
set(messageType WARNING)
endif()
if(CMAKE_ERROR_DEPRECATED)
set(messageType FATAL_ERROR)
endif()
if(messageType)
message(${messageType} "The add_compiler_export_flags function is obsolete. Use the CXX_VISIBILITY_PRESET and VISIBILITY_INLINES_HIDDEN target properties instead.")
endif()
endif()
_test_compiler_hidden_visibility() _test_compiler_hidden_visibility()
_test_compiler_has_deprecated() _test_compiler_has_deprecated()