Fix #4863: skip try_run for LIBCPP_VERSION_OUTPUT during cross compil… (#4876)

* Fix #4863: skip try_run for LIBCPP_VERSION_OUTPUT during cross compilation

Signed-off-by: Hitgirl <hitgirl@Hitgirls-MacBook-Air.local>

* fix #4863: handle cross-compiling in libc++ detection gracefully

Signed-off-by: Hitgirl <hitgirl@Hitgirls-MacBook-Air.local>

* refactor: move cross-compiling check before cached output detection

Signed-off-by: Hitgirl <hitgirl@Hitgirls-MacBook-Air.local>

* refactor: move cross-compiling check before cached output detection

Signed-off-by: Hitgirl <hitgirl@Hitgirls-MacBook-Air.local>

* refactor: move cross-compiling check before cached output detection

Signed-off-by: Hitgirl <hitgirl@Hitgirls-MacBook-Air.local>

---------

Signed-off-by: Hitgirl <hitgirl@Hitgirls-MacBook-Air.local>
Co-authored-by: Hitgirl <hitgirl@Hitgirls-MacBook-Air.local>
This commit is contained in:
hitgirl
2025-08-02 02:23:26 +05:30
committed by GitHub
parent c637a8b453
commit 55abcb5c0f

View File

@@ -68,10 +68,14 @@ string(REGEX REPLACE "[ ]*\n" "; " CXX_VERSION_RESULT "${CXX_VERSION_RESULT}")
message(STATUS "Compiler: ${CXX_VERSION_RESULT}")
# determine used C++ standard library (for debug and support purposes)
if(CMAKE_CROSSCOMPILING)
set(LIBCPP_VERSION_OUTPUT_CACHED "could not be detected due to cross-compiling" CACHE STRING "Detected C++ standard library version")
endif()
if(NOT DEFINED LIBCPP_VERSION_OUTPUT_CACHED)
try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR
"${CMAKE_BINARY_DIR}" SOURCES "${CMAKE_SOURCE_DIR}/cmake/detect_libcpp_version.cpp"
RUN_OUTPUT_VARIABLE LIBCPP_VERSION_OUTPUT COMPILE_OUTPUT_VARIABLE LIBCPP_VERSION_COMPILE_OUTPUT
RUN_OUTPUT_VARIABLE LIBCPP_VERSION_OUTPUT
COMPILE_OUTPUT_VARIABLE LIBCPP_VERSION_COMPILE_OUTPUT
)
if(NOT LIBCPP_VERSION_OUTPUT)
set(LIBCPP_VERSION_OUTPUT "Unknown")