Skip to content

Commit

Permalink
refactor(cmake): scope symbol visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed Jan 1, 2025
1 parent 1742a20 commit 7e0297b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
11 changes: 3 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ option(saucer_desktop "Enable support for the desktop module" ON)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)

# --------------------------------------------------------------------------------------------------------
# Setup library
# --------------------------------------------------------------------------------------------------------
Expand All @@ -39,8 +35,10 @@ endif()
# Export header
# --------------------------------------------------------------------------------------------------------

include("cmake/hide.cmake")
include("cmake/export.cmake")

saucer_bindings_hide_symbols(${PROJECT_NAME})
saucer_bindings_export(${PROJECT_NAME} "SAUCER_EXPORT")

# --------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -82,10 +80,7 @@ CPMFindPackage(
NAME saucer
VERSION 5.0.0
GIT_REPOSITORY "https://github.com/saucer/saucer"
OPTIONS "saucer_static OFF"
"CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON"
"CMAKE_VISIBILITY_INLINES_HIDDEN OFF"
"CMAKE_CXX_VISIBILITY_PRESET default"
OPTIONS "saucer_static OFF" "CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON"
)

target_link_libraries(${PROJECT_NAME} PUBLIC saucer::saucer)
Expand Down
3 changes: 3 additions & 0 deletions cmake/hide.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function(saucer_bindings_hide_symbols NAME)
set_target_properties(${NAME} PROPERTIES C_VISIBILITY_PRESET hidden CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON WINDOWS_EXPORT_ALL_SYMBOLS OFF)
endfunction()
2 changes: 2 additions & 0 deletions cmake/module.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
function(saucer_bindings_add_module NAME MACRO)
message(STATUS "[saucer-bindings] Adding module: ${NAME}")

saucer_bindings_hide_symbols(${NAME})
saucer_bindings_export(${NAME} ${MACRO})

get_target_property(priv_includes saucer::bindings INCLUDE_DIRECTORIES)

target_link_libraries(${NAME} PUBLIC saucer::bindings)
Expand Down

0 comments on commit 7e0297b

Please sign in to comment.