mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-03 21:00:01 -05:00
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:
@@ -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
|
||||
Reference in New Issue
Block a user