Skip to content

Commit f3bcfd5

Browse files
authored
small Python-related CMake cleanup (#5916)
1 parent bef9e73 commit f3bcfd5

5 files changed

Lines changed: 19 additions & 13 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ if(LIBXML2_XMLLINT_EXECUTABLE)
5656

5757
add_custom_target(createXMLExamples DEPENDS errorlist-xml example-xml)
5858

59-
if(PYTHON_EXECUTABLE)
60-
add_custom_target(checkCWEEntries ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/listErrorsWithoutCWE.py -F ${CMAKE_BINARY_DIR}/errorlist.xml
59+
if(Python_EXECUTABLE)
60+
add_custom_target(checkCWEEntries ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/listErrorsWithoutCWE.py -F ${CMAKE_BINARY_DIR}/errorlist.xml
6161
DEPENDS errorlist-xml)
6262
endif()
6363

cmake/clang_tidy.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# TODO: bail out when Python_EXECUTABLE is not set
2+
13
if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
24
# clang-tidy and clang need to have the same version when precompiled headers are being used
35
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
@@ -24,7 +26,7 @@ if (RUN_CLANG_TIDY_NAMES)
2426
message(STATUS "NPROC=${NPROC}")
2527

2628
# disable all compiler warnings since we are just interested in the tidy ones
27-
add_custom_target(run-clang-tidy ${PYTHON_EXECUTABLE} ${RUN_CLANG_TIDY} -p=${CMAKE_BINARY_DIR} -j ${NPROC} -quiet)
29+
add_custom_target(run-clang-tidy ${Python_EXECUTABLE} ${RUN_CLANG_TIDY} -p=${CMAKE_BINARY_DIR} -j ${NPROC} -quiet)
2830
if (BUILD_GUI)
2931
add_dependencies(run-clang-tidy gui-build-deps)
3032
if (BUILD_TESTS)

cmake/findDependencies.cmake

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,24 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
4343
if (CMAKE_VERSION VERSION_EQUAL "3.12" OR CMAKE_VERSION VERSION_GREATER "3.12")
4444
find_package(Python COMPONENTS Interpreter)
4545
if (NOT Python_Interpreter_FOUND)
46-
message(WARNING "No python interpreter found. Therefore, the match compiler is switched off.")
46+
message(WARNING "No python interpreter found - disabling matchcompiler.")
4747
set(USE_MATCHCOMPILER_OPT "Off")
48-
else()
49-
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
5048
endif()
5149
else()
5250
find_package(PythonInterp 3 QUIET)
5351
if (NOT PYTHONINTERP_FOUND)
5452
set(PYTHONINTERP_FOUND "")
5553
find_package(PythonInterp 2.7 QUIET)
5654
if (NOT PYTHONINTERP_FOUND AND NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
57-
message(WARNING "No python interpreter found. Therefore, the match compiler is switched off.")
55+
message(WARNING "No python interpreter found - disabling matchcompiler.")
5856
set(USE_MATCHCOMPILER_OPT "Off")
5957
endif()
6058
endif()
59+
if (PYTHONINTERP_FOUND)
60+
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
61+
set(Python_VERSION ${PYTHON_VERSION_STRING})
62+
set(Python_Interpreter_FOUND ${PYTHONINTERP_FOUND})
63+
endif()
6164
endif()
6265

6366
if (NOT USE_BUNDLED_TINYXML2)

cmake/printInfo.cmake

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ message( STATUS "------------------ General configuration for ${PROJECT_NAME} ${
22
message( STATUS )
33
message( STATUS "CMake Version = ${CMAKE_VERSION}")
44
message( STATUS "CMake Generator = ${CMAKE_GENERATOR}")
5+
message( STATUS )
56
message( STATUS "Compiler = ${CMAKE_CXX_COMPILER_ID}")
67
message( STATUS "Compiler Version = ${CMAKE_CXX_COMPILER_VERSION}")
78
message( STATUS "Build type = ${CMAKE_BUILD_TYPE}")
@@ -19,6 +20,11 @@ message( STATUS "COMPILE_DEFINITIONS (global) = ${DirCompileDefs}" )
1920
get_directory_property( DirCompileOptions DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_OPTIONS )
2021
message( STATUS "COMPILE_OPTIONS (global) = ${DirCompileOptions}" )
2122
message( STATUS )
23+
if (Python_Interpreter_FOUND)
24+
message( STATUS "Python_VERSION = ${Python_VERSION}" )
25+
message( STATUS "Python_EXECUTABLE = ${Python_EXECUTABLE}" )
26+
endif()
27+
message( STATUS )
2228
message( STATUS "---------------------------------------------------------" )
2329
message( STATUS "ANALYZE_MEMORY = ${ANALYZE_MEMORY}" )
2430
message( STATUS "ANALYZE_ADDRESS = ${ANALYZE_ADDRESS}" )
@@ -67,11 +73,6 @@ endif()
6773
message( STATUS )
6874
message( STATUS "USE_THREADS = ${USE_THREADS}" )
6975
message( STATUS "CMAKE_THREAD_LIBS_INIT = ${CMAKE_THREAD_LIBS_INIT}" )
70-
if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
71-
message( STATUS )
72-
message( STATUS "PYTHON_VERSION_STRING = ${PYTHON_VERSION_STRING}" )
73-
message( STATUS "PYTHON_EXECUTABLE = ${PYTHON_EXECUTABLE}" )
74-
endif()
7576
message( STATUS )
7677
message( STATUS "USE_BUNDLED_TINYXML2 = ${USE_BUNDLED_TINYXML2}" )
7778
if (NOT USE_BUNDLED_TINYXML2)

lib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function(build_src output filename)
1515
endif()
1616
add_custom_command(
1717
OUTPUT ${outfile}
18-
COMMAND ${PYTHON_EXECUTABLE} "${PROJECT_SOURCE_DIR}/tools/matchcompiler.py"
18+
COMMAND ${Python_EXECUTABLE} "${PROJECT_SOURCE_DIR}/tools/matchcompiler.py"
1919
--read-dir="${CMAKE_CURRENT_SOURCE_DIR}"
2020
--prefix="mc_"
2121
--line

0 commit comments

Comments
 (0)