Skip to content

Commit bf18781

Browse files
committed
Use CMake to find the Python interpreter to use when running scripts
This makes it easier to control which interpreter is used, rather than always using python3 from PATH.
1 parent 174120f commit bf18781

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ option(BN_ALLOW_STUBS "Allow generating and linking against stubs if a Binary Ni
99
option(BN_REF_COUNT_DEBUG "Add extra debugging checks for RefCountObject leaks" OFF)
1010
mark_as_advanced(BN_REF_COUNT_DEBUG)
1111

12+
find_package(Python3 3.10 COMPONENTS Interpreter REQUIRED)
13+
1214
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
1315
if (MSVC)
1416
message(FATAL_ERROR "Binary Ninja is 64-bit only (try -G \"${CMAKE_GENERATOR} Win64\")")

arch/x86/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@ cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
22

33
project(arch_x86)
44

5+
find_package(Python3 COMPONENTS Interpreter REQUIRED)
6+
57
OPTION(BUILD_SHARED_LIBS "Build shared libraries" OFF)
68
OPTION(YASM_BUILD_TESTS "Enable building of tests" OFF)
79
add_subdirectory(yasm)
810

911
set(XED_CONFIGURE_ARGS --no-encoder just-gen)
1012
if(WIN32)
1113
execute_process(COMMAND ${CMAKE_COMMAND} -E env OS=Windows_NT PYTHONPATH=${PROJECT_SOURCE_DIR}/mbuild
12-
py -3 ${PROJECT_SOURCE_DIR}/xed/mfile.py ${XED_CONFIGURE_ARGS}
14+
${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/xed/mfile.py ${XED_CONFIGURE_ARGS}
1315
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
1416
else()
15-
execute_process(COMMAND python3 ${PROJECT_SOURCE_DIR}/xed/mfile.py ${XED_CONFIGURE_ARGS}
17+
execute_process(COMMAND ${Python3_EXECUTABLE} ${PROJECT_SOURCE_DIR}/xed/mfile.py ${XED_CONFIGURE_ARGS}
1618
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
1719
endif()
1820

0 commit comments

Comments
 (0)