Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small Python-related CMake cleanup #5916

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ if(LIBXML2_XMLLINT_EXECUTABLE)

add_custom_target(createXMLExamples DEPENDS errorlist-xml example-xml)

if(PYTHON_EXECUTABLE)
add_custom_target(checkCWEEntries ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/listErrorsWithoutCWE.py -F ${CMAKE_BINARY_DIR}/errorlist.xml
if(Python_EXECUTABLE)
add_custom_target(checkCWEEntries ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/listErrorsWithoutCWE.py -F ${CMAKE_BINARY_DIR}/errorlist.xml
DEPENDS errorlist-xml)
endif()

Expand Down
4 changes: 3 additions & 1 deletion cmake/clang_tidy.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# TODO: bail out when Python_EXECUTABLE is not set

if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
# clang-tidy and clang need to have the same version when precompiled headers are being used
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand All @@ -24,7 +26,7 @@ if (RUN_CLANG_TIDY_NAMES)
message(STATUS "NPROC=${NPROC}")

# disable all compiler warnings since we are just interested in the tidy ones
add_custom_target(run-clang-tidy ${PYTHON_EXECUTABLE} ${RUN_CLANG_TIDY} -p=${CMAKE_BINARY_DIR} -j ${NPROC} -quiet)
add_custom_target(run-clang-tidy ${Python_EXECUTABLE} ${RUN_CLANG_TIDY} -p=${CMAKE_BINARY_DIR} -j ${NPROC} -quiet)
if (BUILD_GUI)
add_dependencies(run-clang-tidy gui-build-deps)
if (BUILD_TESTS)
Expand Down
11 changes: 7 additions & 4 deletions cmake/findDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,24 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
if (CMAKE_VERSION VERSION_EQUAL "3.12" OR CMAKE_VERSION VERSION_GREATER "3.12")
find_package(Python COMPONENTS Interpreter)
if (NOT Python_Interpreter_FOUND)
message(WARNING "No python interpreter found. Therefore, the match compiler is switched off.")
message(WARNING "No python interpreter found - disabling matchcompiler.")
set(USE_MATCHCOMPILER_OPT "Off")
else()
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
endif()
else()
find_package(PythonInterp 3 QUIET)
if (NOT PYTHONINTERP_FOUND)
set(PYTHONINTERP_FOUND "")
find_package(PythonInterp 2.7 QUIET)
if (NOT PYTHONINTERP_FOUND AND NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
message(WARNING "No python interpreter found. Therefore, the match compiler is switched off.")
message(WARNING "No python interpreter found - disabling matchcompiler.")
set(USE_MATCHCOMPILER_OPT "Off")
endif()
endif()
if (PYTHONINTERP_FOUND)
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
set(Python_VERSION ${PYTHON_VERSION_STRING})
set(Python_Interpreter_FOUND ${PYTHONINTERP_FOUND})
endif()
endif()

if (NOT USE_BUNDLED_TINYXML2)
Expand Down
11 changes: 6 additions & 5 deletions cmake/printInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ message( STATUS "------------------ General configuration for ${PROJECT_NAME} ${
message( STATUS )
message( STATUS "CMake Version = ${CMAKE_VERSION}")
message( STATUS "CMake Generator = ${CMAKE_GENERATOR}")
message( STATUS )
message( STATUS "Compiler = ${CMAKE_CXX_COMPILER_ID}")
message( STATUS "Compiler Version = ${CMAKE_CXX_COMPILER_VERSION}")
message( STATUS "Build type = ${CMAKE_BUILD_TYPE}")
Expand All @@ -19,6 +20,11 @@ message( STATUS "COMPILE_DEFINITIONS (global) = ${DirCompileDefs}" )
get_directory_property( DirCompileOptions DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_OPTIONS )
message( STATUS "COMPILE_OPTIONS (global) = ${DirCompileOptions}" )
message( STATUS )
if (Python_Interpreter_FOUND)
message( STATUS "Python_VERSION = ${Python_VERSION}" )
message( STATUS "Python_EXECUTABLE = ${Python_EXECUTABLE}" )
endif()
message( STATUS )
message( STATUS "---------------------------------------------------------" )
message( STATUS "ANALYZE_MEMORY = ${ANALYZE_MEMORY}" )
message( STATUS "ANALYZE_ADDRESS = ${ANALYZE_ADDRESS}" )
Expand Down Expand Up @@ -67,11 +73,6 @@ endif()
message( STATUS )
message( STATUS "USE_THREADS = ${USE_THREADS}" )
message( STATUS "CMAKE_THREAD_LIBS_INIT = ${CMAKE_THREAD_LIBS_INIT}" )
if (NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
message( STATUS )
message( STATUS "PYTHON_VERSION_STRING = ${PYTHON_VERSION_STRING}" )
message( STATUS "PYTHON_EXECUTABLE = ${PYTHON_EXECUTABLE}" )
endif()
message( STATUS )
message( STATUS "USE_BUNDLED_TINYXML2 = ${USE_BUNDLED_TINYXML2}" )
if (NOT USE_BUNDLED_TINYXML2)
Expand Down
2 changes: 1 addition & 1 deletion lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function(build_src output filename)
endif()
add_custom_command(
OUTPUT ${outfile}
COMMAND ${PYTHON_EXECUTABLE} "${PROJECT_SOURCE_DIR}/tools/matchcompiler.py"
COMMAND ${Python_EXECUTABLE} "${PROJECT_SOURCE_DIR}/tools/matchcompiler.py"
--read-dir="${CMAKE_CURRENT_SOURCE_DIR}"
--prefix="mc_"
--line
Expand Down
Loading