-
Notifications
You must be signed in to change notification settings - Fork 11
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
CMake consistency fixes #41
base: master/s-line
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,27 @@ | ||
project(charon NONE) | ||
cmake_minimum_required(VERSION 3.6) #Tested only with 3.6.1 and 3.9.1. | ||
cmake_minimum_required(VERSION 3.18) | ||
|
||
# FIXME: Remove the code for CMake <3.12 once we have switched over completely. | ||
# FindPython3 is a new module since CMake 3.12. It deprecates FindPythonInterp and FindPythonLibs. | ||
if(${CMAKE_VERSION} VERSION_LESS 3.12) | ||
# Use FindPythonInterp and FindPythonLibs for CMake <3.12 | ||
find_package(PythonInterp 3.4 REQUIRED) | ||
|
||
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) | ||
set(Python3_VERSION_MAJOR ${PYTHON_VERSION_MAJOR}) | ||
set(Python3_VERSION_MINOR ${PYTHON_VERSION_MINOR}) | ||
else() | ||
# Use FindPython3 for CMake >=3.12 | ||
find_package(Python3 ${CURA_PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter) | ||
if(NOT DEFINED Python_VERSION) | ||
set(Python_VERSION | ||
3.10 | ||
CACHE STRING "Python Version" FORCE) | ||
message(STATUS "Setting Python version to ${Python_VERSION}. Set Python_VERSION if you want to compile against an other version.") | ||
endif() | ||
if(APPLE) | ||
CoenSchalkwijk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
set(Python_FIND_FRAMEWORK NEVER) | ||
endif() | ||
find_package(Python ${Python_VERSION} EXACT REQUIRED COMPONENTS Interpreter) | ||
message(STATUS "Linking and building ${project_name} against Python ${Python_VERSION}") | ||
if(NOT DEFINED Python_SITELIB_LOCAL) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where/how's this expected to be set now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cura-build sets this variable upon building. The reason is that all other packages are installed to We added this so that from cura-build we could override the installation directory to be consistent so that we would have to make fewer exceptions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since these changes are aimed at changes/requirements from the cura-build, is it stil possible to use this for a cura-build-less build of libCharon? As in: does Team Styx now need to use the cura-build to release/create a new pkg for libCharon? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, that's not our intention. That would be very unworkable for you! If Would it be acceptable if we add documentation to this about that this parameter exists and leave the behaviour as-is, then? |
||
set(Python_SITELIB_LOCAL | ||
"${Python_SITELIB}" | ||
CACHE PATH "Local alternative site-package location to install Cura" FORCE) | ||
endif() | ||
|
||
option(INSTALL_SERVICE "Install the Charon DBus-service" ON) | ||
option(INSTALL_CLIENT "Install the Charon Client library" ON) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the exclusions removed, do these still matter? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I think these could be removed as well then, if they are indeed unused now. I'm not sure why those excludes were removed because this is code for the firmware-side. |
||
|
||
if(EXISTS /etc/debian_version) | ||
set(CHARON_INSTALL_PATH lib${LIB_SUFFIX}/python${Python3_VERSION_MAJOR}/dist-packages) | ||
else() | ||
set(CHARON_INSTALL_PATH lib${LIB_SUFFIX}/python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/site-packages) | ||
endif() | ||
|
||
set(_excludes PATTERN __pycache__ EXCLUDE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer necessary? |
||
if(NOT INSTALL_SERVICE) | ||
set(_excludes ${_excludes} PATTERN "Service" EXCLUDE) | ||
endif() | ||
if(NOT INSTALL_CLIENT) | ||
set(_excludes ${_excludes} PATTERN "Client" EXCLUDE) | ||
endif() | ||
|
||
install(DIRECTORY Charon DESTINATION ${CHARON_INSTALL_PATH} ${_excludes}) | ||
install(DIRECTORY Charon DESTINATION "${Python_SITELIB_LOCAL}") | ||
|
||
if(INSTALL_SERVICE) | ||
install(FILES service/charon.service DESTINATION lib/systemd/system) | ||
|
@@ -59,7 +48,7 @@ endif() | |
|
||
add_test( | ||
NAME pytest-main | ||
COMMAND ${Python3_EXECUTABLE} -m pytest --junitxml=${CMAKE_BINARY_DIR}/junit-pytest-main.xml ${CMAKE_SOURCE_DIR}/tests | ||
COMMAND ${Python_EXECUTABLE} -m pytest --junitxml=${CMAKE_BINARY_DIR}/junit-pytest-main.xml ${CMAKE_SOURCE_DIR}/tests | ||
CoenSchalkwijk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
set_tests_properties(pytest-main PROPERTIES ENVIRONMENT LANG=C) | ||
set_tests_properties(pytest-main PROPERTIES ENVIRONMENT "PYTHONPATH=${_PYTHONPATH}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have 3.7 on the printer, anything above that won't work for firmware.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I'm assuming libCharon needs 3.10 when used with/for Cura?
If so, to be on the safe side: do not use a default value, but require Python_VERSION to be specified instead?
In order to prevent 'silent' mistakes.