From 30d68924fc58533f8a8a12e281efdc691d638cb9 Mon Sep 17 00:00:00 2001 From: a-maurice Date: Tue, 29 Nov 2022 16:47:47 -0800 Subject: [PATCH] Use find_program to get python in cmake (#546) * Use find_program to get python in cmake * Update build_linux.yml * Revert "Update build_linux.yml" This reverts commit 82bd9f41dc62a79931e4424d5846d46d67eb1117. --- CMakeLists.txt | 6 ++++++ cmake/build_aar.cmake | 2 +- cmake/firebase_swig.cmake | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0536f1fc..ac052bed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,6 +146,12 @@ else() set(DESKTOP OFF) endif() +# Define the Python executable before including the subprojects +find_program(FIREBASE_PYTHON_EXECUTABLE + NAMES python3 python + REQUIRED +) + include(FindPkgConfig) include(android_dependencies) include(build_universal) diff --git a/cmake/build_aar.cmake b/cmake/build_aar.cmake index 6f06ca98..2cf20853 100644 --- a/cmake/build_aar.cmake +++ b/cmake/build_aar.cmake @@ -45,7 +45,7 @@ function(build_aar LIBRARY_NAME LIBRARY_TARGET PROGUARD_TARGET add_custom_command( OUTPUT "${OUTPUT_AAR}" - COMMAND python "${FIREBASE_SOURCE_DIR}/aar_builder/build_aar.py" + COMMAND ${FIREBASE_PYTHON_EXECUTABLE} "${FIREBASE_SOURCE_DIR}/aar_builder/build_aar.py" "--output_file=${OUTPUT_AAR}" "--library_file=$" "--architecture=${ANDROID_ABI}" diff --git a/cmake/firebase_swig.cmake b/cmake/firebase_swig.cmake index 3556bfaf..db69bc9e 100644 --- a/cmake/firebase_swig.cmake +++ b/cmake/firebase_swig.cmake @@ -202,13 +202,13 @@ macro(firebase_swig_add_library name) OUTPUT ${UNITY_SWIG_CS_FIX_FILE} DEPENDS ${UNITY_SWIG_CS_GEN_FILE} COMMAND - python + ${FIREBASE_PYTHON_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/../swig_commenter.py --input=\"${all_cpp_header_files}\" --output=\"${UNITY_SWIG_CS_GEN_FILE}\" --namespace_prefix=\"Firebase\" COMMAND - python + ${FIREBASE_PYTHON_EXECUTABLE} ${FIREBASE_SWIG_FIX_PY} --language=csharp --in_file=\"${UNITY_SWIG_CS_GEN_FILE}\" @@ -233,7 +233,7 @@ macro(firebase_swig_add_library name) OUTPUT ${UNITY_SWIG_CPP_FIX_FILE} DEPENDS ${UNITY_SWIG_CPP_GEN_FILE} COMMAND - python + ${FIREBASE_PYTHON_EXECUTABLE} ${FIREBASE_SWIG_FIX_PY} --language=cpp --in_file=\"${UNITY_SWIG_CPP_GEN_FILE}\"