Skip to content

Commit

Permalink
Refs 11751. Check support for linker option.
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <miguelcompany@eProsima.com>
  • Loading branch information
MiguelCompany committed Oct 6, 2021
1 parent fff2a84 commit 1087e79
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion 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,7 +505,16 @@ if(MSVC OR MSVC_IDE)
set_target_properties(${PROJECT_NAME} PROPERTIES VS_WINRT_COMPONENT "true")
endif()
elseif(BUILD_SHARED_LIBS)
target_link_options(${PROJECT_NAME} ${PRIVACY} -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libfastrtps.version)
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()

if(DEFINED ENV{LIB_FUZZING_ENGINE})
Expand Down

0 comments on commit 1087e79

Please sign in to comment.