-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Minimal CMake
By :

Before we wrap up, let’s cover a few small updates we can make to ensure our library is more consistent across different platforms. We can use the now-familiar set_target_properties
command to apply these settings only to our library.
The first two related properties are C_VISIBILITY_PRESET
and VISIBILITY_INLINES_HIDDEN
. We set C_VISIBILITY_PRESET
to hidden
and VISIBILITY_INLINES_HIDDEN
to ON
. This ensures that the symbol visibility behavior between the Visual Studio compiler (MSVC) on Windows and the Clang/GCC compilers on macOS/Linux is the same. This will ensure that, by default, unless symbols are explicitly annotated with MC_GOL_EXPORT
, they will remain hidden. This helps prevent incompatibilities between platforms.
With these settings enabled, if we generate our export header again on macOS or Linux by running cmake -B build
as normal, we’ll see the following:
# ifdef mc_gol_EXPORTS ...