From 7bfe758f576274df9832c4661285b1e29f318dc8 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Sun, 2 May 2021 13:07:06 +0100 Subject: [PATCH] Apple Xcode specify PATH for custom commands Capture the PATH variable at cmake invoke time and store in the cache. Use the captured PATH variable for the make based build targets custom_swig and QRenderDoc. This fixes the problem on Apple Silicon that the Xcode PATH does not include the default homebrew paths (/opt/homebrew/bin /opt/homebrew/sbin) --- qrenderdoc/CMakeLists.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/qrenderdoc/CMakeLists.txt b/qrenderdoc/CMakeLists.txt index 06463c488..718dd414a 100644 --- a/qrenderdoc/CMakeLists.txt +++ b/qrenderdoc/CMakeLists.txt @@ -135,13 +135,21 @@ if( NOT CMAKE_MAKE_PROGRAM MATCHES "make$" ) endif() endif() +if(APPLE AND CMAKE_GENERATOR STREQUAL "Xcode") + if("${SHELL_CAPTURED_PATH}" STREQUAL "") + set(SHELL_CAPTURED_PATH $ENV{PATH} CACHE STRING "Shell PATH" FORCE) + endif() + message(STATUS "Using custom path for targets custom_swig and QRenderDoc") + set(SET_SYSTEM_PATH_COMMAND ${CMAKE_COMMAND} -E env PATH=${SHELL_CAPTURED_PATH}) +endif() + # Compile our custom SWIG that will do scoped/strong enum classes ExternalProject_Add(custom_swig # using an URL to a zip directly so we don't clone the history etc URL ${RENDERDOC_SWIG_PACKAGE} BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND ./autogen.sh > /dev/null 2>&1 - COMMAND CC=${SWIG_CONFIGURE_CC} CXX=${SWIG_CONFIGURE_CXX} CFLAGS=-fPIC CXXFLAGS=-fPIC ./configure --with-pcre=yes --prefix=${CMAKE_BINARY_DIR} > /dev/null + CONFIGURE_COMMAND ${SET_SYSTEM_PATH_COMMAND} ./autogen.sh > /dev/null 2>&1 + COMMAND CC=${SWIG_CONFIGURE_CC} CXX=${SWIG_CONFIGURE_CXX} CFLAGS=-fPIC CXXFLAGS=-fPIC ${SET_SYSTEM_PATH_COMMAND} ./configure --with-pcre=yes --prefix=${CMAKE_BINARY_DIR} > /dev/null BUILD_COMMAND ${GENERATOR_MAKE} ${GENERATOR_MAKE_PARAMS} > /dev/null 2>&1 INSTALL_COMMAND ${GENERATOR_MAKE} install > /dev/null 2>&1) @@ -312,7 +320,7 @@ if(ENABLE_QRENDERDOC) # which causes CMake to rerun this target every time so that Qt # can do dependency checking and rebuild anything necessary. add_custom_command(OUTPUT QRenderDoc - COMMAND ${QMAKE_QT5_COMMAND} "CMAKE_DIR=${CMAKE_BINARY_DIR}" ${CMAKE_CURRENT_SOURCE_DIR} + COMMAND ${SET_SYSTEM_PATH_COMMAND} ${QMAKE_QT5_COMMAND} "CMAKE_DIR=${CMAKE_BINARY_DIR}" ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${GENERATOR_MAKE} ${GENERATOR_MAKE_PARAMS} DEPENDS RenderDoc.icns) add_custom_target(build-qrenderdoc ALL DEPENDS QRenderDoc DEPENDS renderdoc DEPENDS swig-bindings)