Hi, I'm not sure if this is actually a bug but I've been relying on the OBJECT library[1] feature as a convenient way of having source code in multiple directories be put into a shared library. I now have a need to hide the symbols in my libraries but I've found that using OBJECT libraries means that setting the CXX_VISIBILITY_PRESET and VISIBILITY_INLINES_HIDDEN on the final resulting shared library and/or constituent OBJECT libraries does absolutely nothing.
Here's an example. I've kept everything in a single directory for simplicity but the real world use case would be that ``fooX`` and ``barX`` OBJECT libraries are defined in a sub directory. ``` project(objlibtest) cmake_minimum_required(VERSION 3.0) add_library(fooX OBJECT foo.cpp) add_library(barX OBJECT bar.cpp) add_library(result SHARED $<TARGET_OBJECTS:fooX> $<TARGET_OBJECTS:barX>) set_target_properties(result fooX barX PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN 1) ``` If you watch the build (``make VERBOSE=1``) you'll see that neither ``-fvisibility=hidden`` nor ``-fvisibility-inlines-hidden`` get passed to the compiler. If the CMakeLists.txt file is like this ``` project(objlibtest) cmake_minimum_required(VERSION 3.0) add_library(result SHARED foo.cpp bar.cpp) set_target_properties(result PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN 1) ``` then setting ``-fvisibility=hidden`` and ``-fvisibility-inlines-hidden`` get passed. Is this a bug or it intentional? If the only purpose of OBJECT libraries is to provide a convenient way to group source files in other directories then this seems like a bug. [1] http://www.cmake.org/Wiki/CMake/Tutorials/Object_Library Thanks, Dan. -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake