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

Python Module Check #215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
42 changes: 29 additions & 13 deletions RenderStateNotation/CMakeLists.txt
alexk101 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,40 @@ file(COPY ../.clang-format DESTINATION "${RSN_PARSER_GENERATED_HEADERS_DIR}")

find_package(Python3 REQUIRED)

set(LIBCLANG_INSTALL_CMD ${Python3_EXECUTABLE} -m pip install libclang==16.0.6)
set(JINJA2_INSTALL_CMD ${Python3_EXECUTABLE} -m pip install jinja2)

if(${Python3_VERSION} VERSION_GREATER_EQUAL "3.12")
set(LIBCLANG_INSTALL_CMD ${LIBCLANG_INSTALL_CMD} --break-system-packages)
set(JINJA2_INSTALL_CMD ${JINJA2_INSTALL_CMD} --break-system-packages)
endif()
# Ensure libclang is installed
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "import clang"
RESULT_VARIABLE LIBCLANG_EXISTS
)

execute_process(COMMAND ${LIBCLANG_INSTALL_CMD}
if(NOT LIBCLANG_EXISTS EQUAL "0")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition may be too liberal as there are multiple other options for false value in CMake.
https://cmake.org/cmake/help/latest/command/if.html#constant
It should just be if(NOT LIBCLANG_EXISTS)

set(LIBCLANG_INSTALL_CMD ${Python3_EXECUTABLE} -m pip install libclang==16.0.6)
if(${Python3_VERSION} VERSION_GREATER_EQUAL "3.12")
set(LIBCLANG_INSTALL_CMD ${LIBCLANG_INSTALL_CMD} --break-system-packages)
endif()
execute_process(COMMAND ${LIBCLANG_INSTALL_CMD}
RESULT_VARIABLE PYTHON_PIP_LIBCLANG_RESULT)
if(NOT PYTHON_PIP_LIBCLANG_RESULT EQUAL "0")
message(FATAL_ERROR "Command '${LIBCLANG_INSTALL_CMD}' failed with error code ${PYTHON_PIP_LIBCLANG_RESULT}")
if(NOT PYTHON_PIP_LIBCLANG_RESULT EQUAL "0")
message(FATAL_ERROR "Command '${LIBCLANG_INSTALL_CMD}' failed with error code ${PYTHON_PIP_LIBCLANG_RESULT}")
endif()
endif()

execute_process(COMMAND ${JINJA2_INSTALL_CMD}
# Ensure Jinja2 is installed
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "import jinja2"
RESULT_VARIABLE JINJA_EXISTS
)

if(NOT JINJA_EXISTS EQUAL "0")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

set(JINJA2_INSTALL_CMD ${Python3_EXECUTABLE} -m pip install jinja2)
if(${Python3_VERSION} VERSION_GREATER_EQUAL "3.12")
set(JINJA2_INSTALL_CMD ${JINJA2_INSTALL_CMD} --break-system-packages)
endif()
execute_process(COMMAND ${JINJA2_INSTALL_CMD}
RESULT_VARIABLE PYTHON_PIP_JINJIA_RESULT)
if(NOT PYTHON_PIP_JINJIA_RESULT EQUAL "0")
message(FATAL_ERROR "Command '${JINJA2_INSTALL_CMD}' failed with error code ${PYTHON_PIP_JINJIA_RESULT}")
if(NOT PYTHON_PIP_JINJIA_RESULT EQUAL "0")
message(FATAL_ERROR "Command '${JINJA2_INSTALL_CMD}' failed with error code ${PYTHON_PIP_JINJIA_RESULT}")
endif()
endif()

file(GLOB INCLUDE include/*)
Expand Down