CMAKE_<lang>_VISIBILITY_PRESET is ignored with GCC 4.1
When compiling with GCC 4.1, it's not possible to affect symbol visibility using CMAKE_<lang>_VISIBILITY_PRESET
or <lang>_VISIBILITY_PRESET
. It appears this is due to a version check in Compiler/GNU.cmake
:
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.2)
set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
endif()
I'm not precisely sure when GCC added support for -fvisibility=...
, but I've used it successfully with GCC 4.1. I'm working around this by adding -fvisibility=...
using add_compile_options()
.
Tested with CMake 3.4.3, but observed that this is unchanged in CMake 3.6.