Skip to content

Commit

Permalink
CMake: Use find_package(Python3) (#6675)
Browse files Browse the repository at this point in the history
Fixes the CMake CMP0148 warning at configure time.

find_package(Python3) is supported since CMake 3.12, and DXC requires at
least CMake 3.17
  • Loading branch information
dneto0 authored Jun 20, 2024
1 parent 73d3ccf commit 1f8f796
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ set(TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
include(HandleLLVMOptions)

# Verify that we can find a Python 3 interpreter and force cmake to use it.
find_package(PythonInterp 3 REQUIRED)
find_package(Python3 REQUIRED)

######
# LLVMBuild Integration
Expand Down Expand Up @@ -481,7 +481,7 @@ endif (LLVM_USE_OPROFILE)
message(STATUS "Constructing LLVMBuild project information")

execute_process(
COMMAND ${PYTHON_EXECUTABLE} ${LLVMBUILDTOOL}
COMMAND ${Python3_EXECUTABLE} ${LLVMBUILDTOOL}
--native-target Unknown
--enable-targets "${LLVM_TARGETS_TO_BUILD}"
--enable-optional-components "${LLVMOPTIONALCOMPONENTS}"
Expand Down
6 changes: 3 additions & 3 deletions cmake/modules/AddLLVM.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include(LLVMProcessSources)
include(LLVM-Config)
find_package(Python3 REQUIRED)

function(llvm_update_compile_flags name)
get_property(sources TARGET ${name} PROPERTY SOURCES)
Expand Down Expand Up @@ -107,7 +108,7 @@ function(add_llvm_symbol_exports target_name export_file)
set(native_export_file "${target_name}.def")

add_custom_command(OUTPUT ${native_export_file}
COMMAND ${PYTHON_EXECUTABLE} -c "import sys;print(''.join(['EXPORTS\\n']+sys.stdin.readlines(),))"
COMMAND ${Python3_EXECUTABLE} -c "import sys;print(''.join(['EXPORTS\\n']+sys.stdin.readlines(),))"
< ${export_file} > ${native_export_file}
DEPENDS ${export_file}
VERBATIM
Expand Down Expand Up @@ -867,7 +868,6 @@ function(configure_lit_site_cfg input output)
# SHLIBDIR points the build tree.
string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} SHLIBDIR "${LLVM_SHLIB_OUTPUT_INTDIR}")

set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
# FIXME: "ENABLE_SHARED" doesn't make sense, since it is used just for
# plugins. We may rename it.
if(LLVM_ENABLE_PLUGINS)
Expand Down Expand Up @@ -902,7 +902,7 @@ function(add_lit_target target comment)
list(APPEND LIT_ARGS --param build_mode=${CMAKE_CFG_INTDIR})
endif ()
if (LLVM_MAIN_SRC_DIR)
set (LIT_COMMAND ${PYTHON_EXECUTABLE} ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
set (LIT_COMMAND ${Python3_EXECUTABLE} ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
else()
find_program(LIT_COMMAND llvm-lit)
endif ()
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/HCT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function(add_hlsl_hctgen mode)
endif()

add_custom_command(OUTPUT ${temp_output}
COMMAND ${PYTHON_EXECUTABLE}
COMMAND ${Python3_EXECUTABLE}
${hctgen} ${force_lf}
${mode} --output ${temp_output} ${input_flag}
${format_cmd}
Expand Down
2 changes: 1 addition & 1 deletion tools/clang/lib/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ if ( HLSL_SUPPORT_QUERY_GIT_COMMIT_INFO )
set(GET_GIT_COMMIT_SCRIPT ${PROJECT_SOURCE_DIR}/utils/GetCommitInfo.py)
add_custom_command(
OUTPUT ${GIT_COMMIT_INFO_FILE}
COMMAND ${PYTHON_EXECUTABLE} ${GET_GIT_COMMIT_SCRIPT}
COMMAND ${Python3_EXECUTABLE} ${GET_GIT_COMMIT_SCRIPT}
${PROJECT_SOURCE_DIR} ${GIT_COMMIT_INFO_FILE}
DEPENDS ${GET_GIT_COMMIT_SCRIPT} GIT_COMMIT_INFO_ALWAYS_REBUILD
COMMENT "Collect Git commit info for versioning"
Expand Down
2 changes: 1 addition & 1 deletion utils/version/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ macro(generate_version_include name input_file output_file gen_flags)
add_custom_command(
OUTPUT ${gen_file}
COMMAND echo Generating version
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen_version.py ${gen_flags} > ${gen_file}
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gen_version.py ${gen_flags} > ${gen_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_version.py
)
else ()
Expand Down

0 comments on commit 1f8f796

Please sign in to comment.