The visibility flags were being added after the component directories were specified, which apparently means those subdirectories don't get the same flags. Also, the flags weren't quoted correctly when defined, and -fvisibility-inlines-hidden is only valid for C++.
Now the flags are defined using cmake/visibility.cmake, mimicking warnings.cmake, and included in the same place in CMakeLists.txt. I've found no regressions from this change, and there's a substantial reduction in the size of the libraries. Signed-off-by: Josh Stone <[email protected]> --- CMakeLists.txt | 7 +------ cmake/visibility.cmake | 5 +++++ 2 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 cmake/visibility.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 73bbc8d..1689b9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ include (cmake/platform.cmake) include (cmake/packages.cmake) include (cmake/cap_arch_def.cmake) include (cmake/c++11.cmake) +include (cmake/visibility.cmake) include (cmake/warnings.cmake) include (cmake/options.cmake) include (cmake/optimization.cmake) @@ -102,12 +103,6 @@ add_dependencies(common libiberty_imp) add_dependencies(libdwarf_imp libelf_imp) endif() -if(CMAKE_COMPILER_IS_GNUCXX) - set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden) - set (CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden) - message(STATUS "Found g++, enabling -fvisibility=hidden") -endif() - if(NOT ${PLATFORM} MATCHES nt) SET_TARGET_PROPERTIES ( common dynElf dynDwarf instructionAPI symtabAPI symLite parseAPI diff --git a/cmake/visibility.cmake b/cmake/visibility.cmake new file mode 100644 index 0000000..c875293 --- /dev/null +++ b/cmake/visibility.cmake @@ -0,0 +1,5 @@ +if(CMAKE_COMPILER_IS_GNUCXX) + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden") + message(STATUS "Found g++, enabling -fvisibility=hidden") +endif() -- 1.8.3.1 _______________________________________________ Dyninst-api mailing list [email protected] https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api
