Skip to content

Commit

Permalink
export only necessary symbols on Linux and macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
atafra committed Oct 1, 2020
1 parent 4569300 commit 8674c97
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ Thumbs.db

# Generated files
include/OpenImageDenoise/config.h
core/export.linux.map
core/export.macos.map
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Version History
- Fixed compile error when using an old compiler which does not support
OpenMP SIMD
- Added compatibility with oneTBB 2021
- Export only necessary symbols on Linux and macOS

### Changes in v1.2.3:

Expand Down
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ configure_file(
"${PROJECT_SOURCE_DIR}/include/OpenImageDenoise/config.h"
)

# Generate list of symbols to export
configure_file(
"${PROJECT_SOURCE_DIR}/core/export.linux.map.in"
"${PROJECT_SOURCE_DIR}/core/export.linux.map"
)
configure_file(
"${PROJECT_SOURCE_DIR}/core/export.macos.map.in"
"${PROJECT_SOURCE_DIR}/core/export.macos.map"
)

set(OIDN_RESOURCE ${PROJECT_SOURCE_DIR}/common/oidn.rc)

add_subdirectory(common)
Expand Down Expand Up @@ -171,6 +181,16 @@ target_link_libraries(${PROJECT_NAME}
dnnl
)

# Specify list of symbols to export
if(WIN32)
elseif(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS -Wl,-exported_symbols_list,${PROJECT_SOURCE_DIR}/core/export.macos.map)
set_source_files_properties(core/api.cpp PROPERTIES OBJECT_DEPENDS ${PROJECT_SOURCE_DIR}/core/export.macos.map)
else()
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS -Wl,--version-script=${PROJECT_SOURCE_DIR}/core/export.linux.map)
set_source_files_properties(core/api.cpp PROPERTIES OBJECT_DEPENDS ${PROJECT_SOURCE_DIR}/core/export.linux.map)
endif()

message(STATUS "Setting target version ${PROJECT_VERSION}")
set_property(TARGET ${PROJECT_NAME} PROPERTY VERSION ${PROJECT_VERSION})
set_property(TARGET ${PROJECT_NAME} PROPERTY SOVERSION "0")
Expand Down
16 changes: 16 additions & 0 deletions core/export.linux.map.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
global:
oidn*;
_ZN?@OIDN_API_NAMESPACE@oidn*;
_ZN?@OIDN_API_NAMESPACE@?oidn*;
_ZN?@OIDN_API_NAMESPACE@??oidn*;
_ZN?@OIDN_API_NAMESPACE@???oidn*;
_ZN?@OIDN_API_NAMESPACE@????oidn*;
_ZN??@OIDN_API_NAMESPACE@oidn*;
_ZN??@OIDN_API_NAMESPACE@?oidn*;
_ZN??@OIDN_API_NAMESPACE@??oidn*;
_ZN??@OIDN_API_NAMESPACE@???oidn*;
_ZN??@OIDN_API_NAMESPACE@????oidn*;
local:
*;
};
6 changes: 6 additions & 0 deletions core/export.macos.map.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
_oidn*
__ZN?@OIDN_API_NAMESPACE@oidn*
__ZN?@OIDN_API_NAMESPACE@?oidn*
__ZN?@OIDN_API_NAMESPACE@??oidn*
__ZN?@OIDN_API_NAMESPACE@???oidn*
__ZN?@OIDN_API_NAMESPACE@????oidn*

0 comments on commit 8674c97

Please sign in to comment.