Skip to content

Commit

Permalink
ign_configure_build: param HIDE_SYMBOLS_BY_DEFAULT
Browse files Browse the repository at this point in the history
Add parameter to ign_configure_build that is used to set
CMAKE_C_VISIBILITY_PRESET and CMAKE_CXX_VISIBILITY_PRESET.

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

#################################################
# 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.
# build_errors
# 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
12 changes: 7 additions & 5 deletions cmake/IgnSetCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,20 @@ endmacro()
# Set up compilation flags for GCC or Clang
macro(ign_setup_gcc_or_clang)

option(USE_DEFAULT_VISIBILITY_HIDDEN "Hide symbols by default if they are not explicitly specified as visible" FALSE)
if(USE_DEFAULT_VISIBILITY_HIDDEN)
set(VISIBILITY_FLAG "-fvisibility=hidden")
if(ign_configure_build_HIDE_SYMBOLS_BY_DEFAULT)
set(CMAKE_C_VISIBILITY_PRESET "hidden")
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")
else()
set(VISIBILITY_FLAG "-fvisibility")
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
${VISIBILITY_FLAG})
)

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

0 comments on commit fd38458

Please sign in to comment.