Introduce target property <LANG>_VISIBILITY_PRESET

This is initialized by CMAKE_<LANG>_VISIBILITY_PRESET. The target
property is used as the operand to the -fvisibility= compile option
with GNU compilers and clang.
This commit is contained in:
Stephen Kelly
2013-05-18 12:12:18 +02:00
parent 5361270c6e
commit 0e9f4bc00c
22 changed files with 173 additions and 0 deletions
@@ -141,6 +141,8 @@ endmacro()
include(GenerateExportHeader)
add_subdirectory(visibility_preset)
add_compiler_export_flags()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
@@ -0,0 +1,13 @@
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
if (CMAKE_CXX_FLAGS MATCHES "-fvisibility=hidden")
message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory")
endif()
add_library(visibility_preset SHARED visibility_preset.cpp)
generate_export_header(visibility_preset)
add_executable(visibility_preset_exe main.cpp)
target_link_libraries(visibility_preset_exe visibility_preset)
@@ -0,0 +1,9 @@
#include "visibility_preset.h"
int main()
{
VisibilityPreset vp;
vp.someMethod();
return 0;
}
@@ -0,0 +1,7 @@
#include "visibility_preset.h"
void VisibilityPreset::someMethod()
{
}
@@ -0,0 +1,13 @@
#ifndef VISIBILITY_PRESET_H
#define VISIBILITY_PRESET_H
#include "visibility_preset_export.h"
class VISIBILITY_PRESET_EXPORT VisibilityPreset
{
public:
void someMethod();
};
#endif