Skip to content

Commit 0ed860a

Browse files
committed
Add FIREBASE_PYTHON_EXECUTABLE cmake cache var
1 parent d57360f commit 0ed860a

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@ option(
7272
ON
7373
)
7474

75+
# Find a Python interpreter using the best available mechanism.
76+
if(${CMAKE_VERSION} VERSION_LESS "3.12")
77+
include(FindPythonInterp)
78+
set(DEFAULT_FIREBASE_PYTHON_EXECUTABLE "${PYTHON_EXECUTABLE}")
79+
else()
80+
find_package(Python3 COMPONENTS Interpreter)
81+
set(DEFAULT_FIREBASE_PYTHON_EXECUTABLE "${Python3_EXECUTABLE}")
82+
endif()
83+
84+
set(
85+
FIREBASE_PYTHON_EXECUTABLE
86+
"${DEFAULT_FIREBASE_PYTHON_EXECUTABLE}"
87+
CACHE FILEPATH
88+
"The Python interpreter to use"
89+
)
7590

7691
list(INSERT CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake)
7792
include(compiler_setup)

Firestore/Protos/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
include(FindPythonInterp)
16-
1715
# Generate output in-place. So long as the build is idempotent this helps
1816
# verify that the protoc-generated output isn't changing.
1917
set(OUTPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
@@ -200,7 +198,7 @@ if(FIREBASE_IOS_PROTOC_GENERATE_SOURCES)
200198
COMMENT "Generating nanopb sources"
201199
OUTPUT ${NANOPB_GENERATED_SOURCES}
202200
COMMAND
203-
${PYTHON_EXECUTABLE}
201+
${FIREBASE_PYTHON_EXECUTABLE}
204202
${CMAKE_CURRENT_SOURCE_DIR}/build_protos.py
205203
--nanopb
206204
--protoc=$<TARGET_FILE:protoc>
@@ -232,7 +230,7 @@ if(FIREBASE_IOS_PROTOC_GENERATE_SOURCES)
232230
COMMENT "Generating C++ protobuf sources"
233231
OUTPUT ${PROTOBUF_CPP_GENERATED_SOURCES}
234232
COMMAND
235-
${PYTHON_EXECUTABLE}
233+
${FIREBASE_PYTHON_EXECUTABLE}
236234
${CMAKE_CURRENT_SOURCE_DIR}/build_protos.py
237235
--cpp
238236
--protoc=$<TARGET_FILE:protoc>

Firestore/core/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
include(CheckSymbolExists)
1616
include(CheckIncludeFiles)
17-
include(FindPythonInterp)
1817

1918

2019
## firestore_util
@@ -286,7 +285,7 @@ add_custom_command(
286285
OUTPUT
287286
${GRPC_ROOT_CERTIFICATE_SOURCES}
288287
COMMAND
289-
${PYTHON_EXECUTABLE} ${FIREBASE_SOURCE_DIR}/scripts/binary_to_array.py
288+
${FIREBASE_PYTHON_EXECUTABLE} ${FIREBASE_SOURCE_DIR}/scripts/binary_to_array.py
290289
--output_header=${OUTPUT_DIR}/grpc_root_certificates_generated.h
291290
--output_source=${OUTPUT_DIR}/grpc_root_certificates_generated.cc
292291
--cpp_namespace=firebase::firestore::remote

0 commit comments

Comments
 (0)