Skip to content

Commit

Permalink
Use cmake properties for symbol visibility and PIC.
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys authored and NikolajBjorner committed Aug 2, 2022
1 parent 886c3ab commit b361226
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
22 changes: 0 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,6 @@ endif()
option(Z3_BUILD_LIBZ3_SHARED "Build libz3 as a shared library if true, otherwise build a static library" ON)


################################################################################
# Symbol visibility
################################################################################
if (NOT MSVC)
z3_add_cxx_flag("-fvisibility=hidden" REQUIRED)
z3_add_cxx_flag("-fvisibility-inlines-hidden" REQUIRED)
endif()

################################################################################
# Tracing
################################################################################
Expand All @@ -364,20 +356,6 @@ else()
list(APPEND Z3_COMPONENT_CXX_DEFINES $<$<CONFIG:Debug>:_TRACE>)
endif()

################################################################################
# Position independent code
################################################################################
# This is required because code built in the components will end up in a shared
# library.

# Avoid adding -fPIC compiler switch if we compile with MSVC (which does not
# support the flag) or if we target Windows, which generally does not use
# position independent code for native code shared libraries (DLLs).
if (NOT (MSVC OR MINGW OR WIN32))
z3_add_cxx_flag("-fPIC" REQUIRED)
endif()


################################################################################
# Link time optimization
################################################################################
Expand Down
6 changes: 6 additions & 0 deletions cmake/z3_add_component.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ macro(z3_add_component component_name)
foreach (flag ${Z3_COMPONENT_CXX_FLAGS})
target_compile_options(${component_name} PRIVATE ${flag})
endforeach()
set_target_properties(${component_name} PROPERTIES
# Position independent code needed in shared libraries
POSITION_INDEPENDENT_CODE ON
# Symbol visibility
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON)

# It's unfortunate that we have to manage dependencies ourselves.
#
Expand Down

0 comments on commit b361226

Please sign in to comment.