########################################################################
set(_macros
+ ${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_add_test.cmake
${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake
${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_invoke_autopilot.cmake
- ${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_setup_target.cmake
- ${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_query_git_information.cmake
- ${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_add_test.cmake
${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_pickup_tests.cmake
+ ${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_query_git_information.cmake
+ ${CMAKE_SOURCE_DIR}/cmake/macros/macro_deal_ii_setup_target.cmake
+ ${CMAKE_SOURCE_DIR}/cmake/macros/macro_shell_escape_option_groups.cmake
)
file(COPY ${_macros}
DESTINATION ${CMAKE_BINARY_DIR}/${DEAL_II_SHARE_RELDIR}/macros
separate_arguments(_compile_options UNIX_COMMAND
"${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
)
+ shell_escape_option_groups(_compile_options)
target_compile_options(${_target} PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:${_compile_options}>
)
separate_arguments(_link_options UNIX_COMMAND
"${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
)
+ shell_escape_option_groups(_link_options)
target_link_options(${_target} PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:${_link_options}>
)
separate_arguments(_compile_options UNIX_COMMAND
"${${_feature}_CXX_FLAGS} ${${_feature}_CXX_FLAGS_${_build}}"
)
+ shell_escape_option_groups(_compile_options)
if(NOT "${_compile_options}" STREQUAL "")
message(STATUS " COMPILE_OPTIONS: ${_compile_options}")
target_compile_options(${_interface_target} INTERFACE $<$<COMPILE_LANGUAGE:CXX>:${_compile_options}>)
separate_arguments(_link_options UNIX_COMMAND
"${${_feature}_LINKER_FLAGS} ${${_feature}_LINKER_FLAGS_${_build}}"
)
+ shell_escape_option_groups(_link_options)
if(NOT "${_link_options}" STREQUAL "")
message(STATUS " LINK_OPTIONS: ${_link_options}")
target_link_options(${_interface_target} INTERFACE $<$<COMPILE_LANGUAGE:CXX>:${_link_options}>)
separate_arguments(_compile_options UNIX_COMMAND
"${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
)
+ shell_escape_option_groups(_compile_options)
target_compile_options(${_target} PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:${_compile_options}>
)
separate_arguments(_link_options UNIX_COMMAND
"${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
)
+ shell_escape_option_groups(_link_options)
target_link_options(${_target} PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:${_link_options}>
)
separate_arguments(_compile_options UNIX_COMMAND
"${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
)
+ shell_escape_option_groups(_compile_options)
target_compile_options(${_target} PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:${_compile_options}>
)
separate_arguments(_link_options UNIX_COMMAND
"${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
)
+ shell_escape_option_groups(_link_options)
target_link_options(${_target} PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:${_link_options}>
)
foreach(_property ${_properties})
get_target_property(_value ${_target} ${_property})
if(NOT "${_value}" MATCHES "-NOTFOUND" AND NOT "${_value}" STREQUAL "")
- string(REPLACE ";" " " _value "${_value}")
+ string(REPLACE ";" "," _value "${_value}") # workaround: we cannot use ";"
list(APPEND _messages " ${_property}: ${_value}")
endif()
endforeach()
--- /dev/null
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2023 - 2023 by the deal.II authors
+##
+## This file is part of the deal.II library.
+##
+## The deal.II library is free software; you can use it, redistribute
+## it, and/or modify it under the terms of the GNU Lesser General
+## Public License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+## The full text of the license can be found in the file LICENSE.md at
+## the top level directory of deal.II.
+##
+## ---------------------------------------------------------------------
+
+#
+# Shell escape known option groups such as -Xlinker [...], or
+# -Xcudafe [...] so that the toggle parameter (-Xlinker) does not get
+# deduplicated by CMake.
+#
+# Prerequisite: variable must be the name of a _list_ variable containing
+# compile or link options.
+#
+# Usage:
+# shell_escape_option_groups(variable)
+#
+
+macro(shell_escape_option_groups _variable)
+ #
+ # We have to capture simple option groups of the form
+ # "-Xlinker --as-needed"
+ # but also multiple escape sequences such as
+ # "-Xlinker -rpath -Xlinker /path".
+ # If we happen to escape the latter in the following form:
+ # "SHELL:-Xlinker -rpath" "SHELL:-Xlinker /path" then the first statement
+ # "SHELL:-Xlinker -rpath" might still get deduplicated...
+ #
+ # Let's play this game only over the two options groups above in order to
+ # keep the regex sane.
+ #
+
+ # Matches: "-Xlinker;[option]" and replaces it with "SHELL:-Xlinker [option]"
+ string(REGEX REPLACE
+ "(-Xcudafe|-Xlinker);([^;]+)"
+ "SHELL:\\1 \\2" ${_variable} "${${_variable}}"
+ )
+ # Matches: "SHELL:-Xlinker [option1];SHELL:-Xlinker [option2]" and replaces
+ # it with "SHELL:-Xlinker [option1] -Xlinker [option2]"
+ string(REGEX REPLACE
+ "SHELL:(-Xcudafe [^;]+|-Xlinker [^;]+);SHELL:(-Xcudafe [^;]+|-Xlinker [^;]+)"
+ "SHELL:\\1 \\2" ${_variable} "${${_variable}}"
+ )
+endmacro()