Skip to content

Commit

Permalink
Add HIDE_SYMBOLS_BY_DEFAULT option (#196)
Browse files Browse the repository at this point in the history
Add HIDE_SYMBOLS_BY_DEFAULT parameter to
ign_configure_build that will hide symbols by default
if they are not explicitly specified as visible.
This parameter is used to set CMAKE_C_VISIBILITY_PRESET
and CMAKE_CXX_VISIBILITY_PRESET.

Signed-off-by: Steve Peters <[email protected]>
  • Loading branch information
scpeters authored Dec 17, 2021
1 parent 5cccde5 commit 3457923
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion cmake/IgnConfigureBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@

#################################################
# Configure the build of the ignition project
# Pass the argument HIDE_SYMBOLS_BY_DEFAULT to configure symbol visibility so
# that symbols are hidden unless explicitly marked as visible.
# Pass the argument QUIT_IF_BUILD_ERRORS to have this macro quit cmake when the
# build_errors
macro(ign_configure_build)

#============================================================================
# Parse the arguments that are passed in
set(options QUIT_IF_BUILD_ERRORS)
set(options HIDE_SYMBOLS_BY_DEFAULT QUIT_IF_BUILD_ERRORS)
set(oneValueArgs)
set(multiValueArgs COMPONENTS)
cmake_parse_arguments(ign_configure_build "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
Expand Down
11 changes: 10 additions & 1 deletion cmake/IgnSetCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,20 @@ endmacro()
# Set up compilation flags for GCC or Clang
macro(ign_setup_gcc_or_clang)

if(ign_configure_build_HIDE_SYMBOLS_BY_DEFAULT)
set(CMAKE_C_VISIBILITY_PRESET "hidden")
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
else()
set(CMAKE_C_VISIBILITY_PRESET "default")
set(CMAKE_CXX_VISIBILITY_PRESET "default")
endif()


ign_filter_valid_compiler_options(
CUSTOM_ALL_FLAGS
-Wall -Wextra -Wno-long-long -Wno-unused-value -Wfloat-equal
-Wshadow -Winit-self -Wswitch-default -Wmissing-include-dirs -pedantic
-fvisibility)
)

# -ggdb3: Produce comprehensive debug information that can be utilized by gdb
set(CUSTOM_DEBUG_FLAGS "-ggdb3")
Expand Down

0 comments on commit 3457923

Please sign in to comment.