Files
CMake/Tests/RunCMake/ParseImplicitLinkInfo/Inspect.cmake
T
Brad King 805a40b668 Optionally exclude implicit link libraries via environment
CMake detects libraries that the compiler driver implicitly passes to
the linker, and stores them in `CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES`
for use in constructing mixed-language link lines.  Some compiler driver
flags add implicitly linked libraries that should not be used during
mixed-language linking because they are handled by similar flags passed
to the other language's compiler driver.  Add an environment variable
that users can set to avoid undesired implicit link libraries in such
scenarios.

Follow the pattern from commit 023de565d3 (Optionally exclude implicit
link directories via environment, 2023-05-25, v3.27.0-rc1~54^2).

Fixes: #26911
2025-05-05 12:12:44 -04:00

21 lines
478 B
CMake

enable_language(C)
set(info "")
foreach(var
CMAKE_SYSTEM_NAME
CMAKE_C_COMPILER
CMAKE_C_COMPILER_ID
CMAKE_C_COMPILER_VERSION
CMAKE_C_COMPILER_LINKER
CMAKE_C_COMPILER_LINKER_ID
CMAKE_C_COMPILER_LINKER_VERSION
CMAKE_C_IMPLICIT_LINK_LIBRARIES
CMAKE_C_IMPLICIT_LINK_DIRECTORIES
)
if(DEFINED ${var})
string(APPEND info "set(${var} \"${${var}}\")\n")
endif()
endforeach()
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}")