[cmake-developers] [CMake 0015556]: CMAKE_<lang>_VISIBILITY_PRESET not used when compiling static libraries
Mantis Bug Tracker
mantis at public.kitware.com
Wed May 6 06:11:37 EDT 2015
The following issue has been SUBMITTED.
======================================================================
http://www.cmake.org/Bug/view.php?id=15556
======================================================================
Reported By: Kjell Irgens
Assigned To:
======================================================================
Project: CMake
Issue ID: 15556
Category: CMake
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 2015-05-06 06:11 EDT
Last Modified: 2015-05-06 06:11 EDT
======================================================================
Summary: CMAKE_<lang>_VISIBILITY_PRESET not used when
compiling static libraries
Description:
When compiling a STATIC library the -fvisibility=hidden compiler flag is not set
to gcc when compiling.
Why is this a problem? I am linking the resulting static library into another
SHARED library, and I want the symbols defined in the link library to be hidden,
which is why I used CMAKE_CPP_VISIBILITY_PRESET in the first place.
https://gcc.gnu.org/wiki/Visibility
"In your build system (Makefile etc), you will probably wish to add the
-fvisibility=hidden and -fvisibility-inlines-hidden options to the command line
arguments of every GCC invocation"
The workaround is to add -fvisibility=HIDDEN as to COMPILE_FLAGS.
Steps to Reproduce:
set (CMAKE_C_VISIBILITY_PRESET hidden)
add_library (mplug STATIC test.c)
make VERBOSE=1
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2015-05-06 06:11 Kjell Irgens New Issue
======================================================================
More information about the cmake-developers
mailing list