Skip to content

Commit

Permalink
Only export public symbols on non-windows platforms (#1998)
Browse files Browse the repository at this point in the history
* Refs 11751. Using --version-script to only export symbols containing eprosima.

Signed-off-by: Miguel Company <miguelcompany@eProsima.com>

* Refs 11751. Also exporting the MD5 class.

Signed-off-by: Miguel Company <miguelcompany@eProsima.com>

* Refs 11751. Add more exported symbols.

Signed-off-by: Miguel Company <miguelcompany@eProsima.com>

* Refs 11751. Check support for linker option.

Signed-off-by: Miguel Company <miguelcompany@eProsima.com>

* Refs 11751. Pass the linker flags using a well-known cmake variable

Signed-off-by: Barro <miguelbarro@eprosima.com>

* Revert "Refs 11751. Pass the linker flags using a well-known cmake variable"

This reverts commit 8ec1fec.

Signed-off-by: Barro <miguelbarro@eprosima.com>

Co-authored-by: Barro <miguelbarro@eprosima.com>
  • Loading branch information
MiguelCompany and Barro authored Dec 20, 2021
1 parent 8a067dc commit 2a655a2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

include(CheckCXXSourceCompiles)

# Set source files

if(WIN32)
Expand Down Expand Up @@ -503,6 +505,17 @@ if(MSVC OR MSVC_IDE)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
set_target_properties(${PROJECT_NAME} PROPERTIES VS_WINRT_COMPONENT "true")
endif()
elseif(BUILD_SHARED_LIBS)
set(VERSION_SCRIPT_SUPPORT_FLAGS -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libfastrtps.version)
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} ${VERSION_SCRIPT_SUPPORT_FLAGS})
CHECK_CXX_SOURCE_COMPILES("int main(int, char**){return 0;}" HAS_VERSION_SCRIPT_SUPPORT)
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
unset(OLD_CMAKE_REQUIRED_FLAGS)
if(HAS_VERSION_SCRIPT_SUPPORT)
message(STATUS "Using linker version script to select exported symbols")
target_link_options(${PROJECT_NAME} ${PRIVACY} ${VERSION_SCRIPT_SUPPORT_FLAGS})
endif()
endif()

###############################################################################
Expand Down
4 changes: 4 additions & 0 deletions src/cpp/libfastrtps.version
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CODEABI_1.0 {
global: *eprosima*;*MD5*;*dds*;
local: *;
};

0 comments on commit 2a655a2

Please sign in to comment.