mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-30 22:51:38 +00:00
Use FindPython3 (#7055)
This commit is contained in:
@@ -538,26 +538,23 @@ endfunction()
|
|||||||
|
|
||||||
# Look if we have python 3.5 installed so that we can run the generate code
|
# Look if we have python 3.5 installed so that we can run the generate code
|
||||||
# python script after flatc is built.
|
# python script after flatc is built.
|
||||||
find_package(PythonInterp 3.5)
|
find_package(Python3 3.5 COMPONENTS Interpreter)
|
||||||
|
|
||||||
if(PYTHONINTERP_FOUND AND
|
if(Python3_Interpreter_FOUND)
|
||||||
# Skip doing this if the MSVC version is below VS 12.
|
set(GENERATION_OPTS --flatc "${FLATBUFFERS_FLATC_EXECUTABLE}")
|
||||||
# https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
|
|
||||||
(NOT MSVC OR MSVC_VERSION GREATER 1800))
|
|
||||||
set(GENERATION_SCRIPT ${PYTHON_EXECUTABLE} scripts/generate_code.py)
|
|
||||||
if(FLATBUFFERS_BUILD_LEGACY)
|
if(FLATBUFFERS_BUILD_LEGACY)
|
||||||
# Need to set --cpp-std c++-0x options
|
# Need to set --cpp-std c++-0x options
|
||||||
set(GENERATION_SCRIPT ${GENERATION_SCRIPT} --cpp-0x)
|
set(GENERATION_OPTS ${GENERATION_OPTS}--cpp-0x)
|
||||||
endif()
|
endif()
|
||||||
if(FLATBUFFERS_SKIP_MONSTER_EXTRA)
|
if(FLATBUFFERS_SKIP_MONSTER_EXTRA)
|
||||||
set(GENERATION_SCRIPT ${GENERATION_SCRIPT} --skip-monster-extra)
|
set(GENERATION_OPTS ${GENERATION_OPTS} --skip-monster-extra)
|
||||||
endif()
|
endif()
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET flatc
|
TARGET flatc
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND ${GENERATION_SCRIPT} --flatc "${FLATBUFFERS_FLATC_EXECUTABLE}"
|
COMMAND ${Python3_EXECUTABLE} scripts/generate_code.py ${GENERATION_OPTS}
|
||||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||||
COMMENT "Running ${GENERATION_SCRIPT}..."
|
COMMENT "Running scripts/generate_code.py..."
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
else()
|
else()
|
||||||
message("No Python3 interpreter found! Unable to generate files automatically.")
|
message("No Python3 interpreter found! Unable to generate files automatically.")
|
||||||
|
|||||||
Reference in New Issue
Block a user