cmake: Compiler-specific whole-archive macro

pull/593/head
Gleb Mazovetskiy 4 years ago
parent 93fe84aea8
commit 8737453498

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

@ -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)

@ -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)

@ -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)
Loading…
Cancel
Save