I developed cross platform software in c++. As I know, Linux .so exported all the symbols by default, well through \"gcc -fvisibility=hidden\" I can set all the
Instead of setting compiler flags directly, you should be using a current CMake version and the
I.e., if you are using C++ you would either call
set(CMAKE_CXX_VISIBILITY_PRESET hidden) to set the property globally, or set_target_properties(MyTarget PROPERTIES CXX_VISIBILITY_PRESET hidden) to limit the setting to a specific library or executable target. If you are using C just replace CXX by C in the aforementioned commands. You may also want to investigate the VISIBLITY_INLINES_HIDDEN property as well.
The documentation for GENERATE_EXPORT_HEADER includes some more tips and examples related to both properties.