set_target_properties(intrinsics_gen PROPERTIES FOLDER "Compiler-RT Misc")
endif()
- # Find Python interpreter.
- include(FindPythonInterp)
- if(NOT PYTHONINTERP_FOUND)
- message(FATAL_ERROR "
- Unable to find Python interpreter required testing. Please install Python
- or specify the PYTHON_EXECUTABLE CMake variable.")
+ if(CMAKE_VERSION VERSION_LESS 3.12)
+ # Find Python interpreter.
+ include(FindPythonInterp)
+ if(NOT PYTHONINTERP_FOUND)
+ message(FATAL_ERROR "
+ Unable to find Python interpreter required testing. Please install Python
+ or specify the PYTHON_EXECUTABLE CMake variable.")
+ endif()
+
+ add_executable(Python3::Interpreter IMPORTED)
+ set_target_properties(Python3::Interpreter PROPERTIES
+ IMPORTED_LOCATION ${PYTHON_EXECUTABLE})
+ set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
+ else()
+ find_package(Python3 COMPONENTS Interpreter)
+ if(NOT Python3_Interpreter_FOUND)
+ message(WARNING "Python3 not found, using python2 as a fallback")
+ find_package(Python2 COMPONENTS Interpreter REQUIRED)
+ if(Python2_VERSION VERSION_LESS 2.7)
+ message(SEND_ERROR "Python 2.7 or newer is required")
+ endif()
+
+ # Treat python2 as python3
+ add_executable(Python3::Interpreter IMPORTED)
+ set_target_properties(Python3::Interpreter PROPERTIES
+ IMPORTED_LOCATION ${Python2_EXECUTABLE})
+ set(Python3_EXECUTABLE ${Python2_EXECUTABLE})
+ endif()
endif()
# Ensure that fat libraries are built correctly on Darwin
list(APPEND extra_args "--extra" ${arg})
endforeach()
add_custom_command(OUTPUT ${stamp}
- COMMAND ${PYTHON_EXECUTABLE}
+ COMMAND ${Python3_EXECUTABLE}
${SANITIZER_GEN_DYNAMIC_LIST} ${extra_args} $<TARGET_FILE:${target_name}>
--nm-executable "${SANITIZER_NM}" -o $<TARGET_FILE:${target_name}>.syms
COMMAND ${CMAKE_COMMAND} -E touch ${stamp}
list(APPEND args "$<TARGET_FILE:${arg}>")
endforeach()
add_custom_command(OUTPUT ${vers}
- COMMAND ${PYTHON_EXECUTABLE}
+ COMMAND ${Python3_EXECUTABLE}
${SANITIZER_GEN_DYNAMIC_LIST} --version-list ${args}
--nm-executable "${SANITIZER_NM}" -o ${vers}
DEPENDS ${SANITIZER_GEN_DYNAMIC_LIST} ${ARG_EXTRA} ${ARG_LIBS}
if(CMAKE_HOST_UNIX AND NOT OS_NAME MATCHES "OpenBSD")
add_custom_target(SanitizerLintCheck
COMMAND env LLVM_CHECKOUT=${LLVM_MAIN_SRC_DIR} SILENT=1 TMPDIR=
- PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
+ PYTHON_EXECUTABLE=${Python3_EXECUTABLE}
COMPILER_RT=${COMPILER_RT_SOURCE_DIR}
${SANITIZER_LINT_SCRIPT}
DEPENDS ${SANITIZER_LINT_SCRIPT}
set_default("gold_executable", "@GOLD_EXECUTABLE@")
set_default("clang", "@COMPILER_RT_RESOLVED_TEST_COMPILER@")
set_default("compiler_id", "@COMPILER_RT_TEST_COMPILER_ID@")
-set_default("python_executable", "@PYTHON_EXECUTABLE@")
+set_default("python_executable", "@Python3_EXECUTABLE@")
set_default("compiler_rt_debug", @COMPILER_RT_DEBUG_PYBOOL@)
set_default("compiler_rt_intercept_libdispatch", @COMPILER_RT_INTERCEPT_LIBDISPATCH_PYBOOL@)
set_default("compiler_rt_libdir", "@COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR@")