1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 19:19:56 +00:00

cmake: Compiler-specific whole-archive macro

This commit is contained in:
Gleb Mazovetskiy 2021-01-20 19:19:36 +00:00
parent 93fe84aea8
commit 8737453498
4 changed files with 15 additions and 4 deletions

View file

@ -89,6 +89,7 @@ endif(EXISTS ${PROJECT_SOURCE_DIR}/.git)
# Macros
include(OpenMWMacros)
include(WholeArchive)
# doxygen main page

View file

@ -237,8 +237,8 @@ if(OSG_STATIC)
target_link_libraries(openmw_cs_osg_plugins INTERFACE ${${_plugin_uc}_LIBRARY})
endforeach()
# We use --whole-archive because OSG plugins use registration.
target_link_options(openmw_cs_osg_plugins INTERFACE
-Wl,--whole-archive ${_osg_plugins_static_files} -Wl,--no-whole-archive)
get_whole_archive_options(_opts ${_osg_plugins_static_files})
target_link_options(openmw_cs_osg_plugins INTERFACE ${_opts})
target_link_libraries(openmw-cs openmw_cs_osg_plugins)
endif(OSG_STATIC)

View file

@ -152,8 +152,8 @@ if(OSG_STATIC)
target_link_libraries(openmw_osg_plugins INTERFACE ${${_plugin_uc}_LIBRARY})
endforeach()
# We use --whole-archive because OSG plugins use registration.
target_link_options(openmw_osg_plugins INTERFACE
-Wl,--whole-archive ${_osg_plugins_static_files} -Wl,--no-whole-archive)
get_whole_archive_options(_opts ${_osg_plugins_static_files})
target_link_options(openmw_osg_plugins INTERFACE ${_opts})
target_link_libraries(openmw openmw_osg_plugins)
endif(OSG_STATIC)

10
cmake/WholeArchive.cmake Normal file
View file

@ -0,0 +1,10 @@
macro (get_whole_archive_options OUT_VAR)
# We use --whole-archive because OSG plugins use registration.
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(${OUT_VAR} -Wl,--whole-archive ${ARGN} -Wl,--no-whole-archive)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(${OUT_VAR} -Wl,-all_load ${ARGN} -Wl,-noall_load)
else ()
message(FATAL_ERROR "get_whole_archive_options not implemented for CMAKE_CXX_COMPILER_ID ${CMAKE_CXX_COMPILER_ID}")
endif()
endmacro (whole_archive_options)