Try to force find_program to still be able to use the env path

This commit is contained in:
Georg Hagen
2025-12-05 14:22:11 +01:00
parent 8405cbc9e1
commit a263068844
2 changed files with 23 additions and 1 deletions

View File

@@ -8,7 +8,8 @@ if ("${PLATFORM}" STREQUAL "OS64" OR "${PLATFORM}" STREQUAL "OS64COMBINED")
set(ENABLE_ARC OFF)
set(DEPLOYMENT_TARGET "14.0")
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/toolchain/ios.toolchain.cmake")
set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF CACHE BOOL "" FORCE)
include(cmake/functions/OverrideFindProgram.cmake)
endif ()
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)

View File

@@ -0,0 +1,21 @@
if(NOT COMMAND _original_find_program)
# Save the original find_program as _original_find_program
macro(_original_find_program)
_find_program(${ARGV})
endmacro()
# Now override find_program
function(find_program)
set(_saved_CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ${CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH})
set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
cmake_parse_arguments(PARSE_ARGV 0 FWD "" "" "")
set(quotedArgs "")
foreach(arg IN LISTS FWD_UNPARSED_ARGUMENTS)
string(APPEND quotedArgs " [===[${arg}]===]")
endforeach()
cmake_language(EVAL CODE "_find_program(${quotedArgs})")
set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ${_saved_CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH})
endfunction()
endif()