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

Cura 8640 PyQt6 upgrade #134

Merged
merged 66 commits into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
b86c38f
Only use sip to generate source files
Feb 23, 2022
02c7347
Find SIP on the system.
Feb 24, 2022
b6e681d
Added CMake function add_sip_module
Feb 24, 2022
ba6b5a6
Dressed down the pyproject.toml.in file some more
Feb 24, 2022
d16dc55
Renamed the main sip defintion file to reflect the module_name
Feb 24, 2022
3799ae7
Use the new CMake module add_sip_module
Feb 24, 2022
5316234
Link Arcus against protobuf target
jellespijker Feb 24, 2022
b3202a2
Use the CMAKE_SOURCE_DIR for including the SIPMacros
jellespijker Feb 24, 2022
8f71558
Add the current bin directory to the PYTHONPATH
jellespijker Feb 24, 2022
e173335
Make sure the extension is so on UNIX and pyd on Windows
jellespijker Feb 24, 2022
7c1edb3
Merge remote-tracking branch 'origin/CURA-7924_sip_cmake_build' into …
jellespijker Feb 24, 2022
4ba57f2
Use OS specific seperator for the PYTHONPATH
Feb 24, 2022
337d180
Setting the PYTHONPATH with the CMAKE_COMMAND
Feb 24, 2022
c61b68a
Changes needed for Windows compilation.
rburema Feb 24, 2022
5751f92
Nescesary for proper functioning .pyd on Windows.
rburema Feb 24, 2022
ea70846
This wasn't producng a proper dynamic library, not even on Windows.
rburema Feb 24, 2022
50bc179
Always include SIPMacros when find_package(SIP) is called
Feb 25, 2022
104968b
Moved CMakeBuilder to CMake build module location
Feb 25, 2022
12d420d
Added a install_sip_module to SIP CMake build module
Feb 25, 2022
b1325c9
Use the actual Python defined SO ABI extension
Feb 25, 2022
95a2a26
Make user cpp sources optional
Feb 25, 2022
287c7e5
If the sip build is not pre-set it should be here.
rburema Feb 25, 2022
ee282bd
Revert "Make user cpp sources optional"
rburema Feb 25, 2022
2aa1e48
Revert "Use the actual Python defined SO ABI extension"
rburema Feb 25, 2022
0c62785
Remove redundant sanitize_list macro
Feb 25, 2022
b991cc7
Sip 6 can handle enum class.
rburema Feb 25, 2022
83dffa4
Merge pull request #131 from Ultimaker/CURA-7924_sip_cmake_build
nallath Feb 28, 2022
1ffcc3d
Added StandardProjectSettings module
Mar 3, 2022
12fdb07
use arguments for function use_rpaths
Mar 4, 2022
cc167f1
escape dollar sign on ORIGIN rpath
Mar 4, 2022
de5ce6b
allways full RPATH
Mar 4, 2022
7376d78
set rpath for sip_<interface_target> target
Mar 4, 2022
805bcec
Revert "set rpath for sip_<interface_target> target"
jellespijker Mar 4, 2022
2deab5c
transfer rpath properties to sip_target
Mar 4, 2022
c34fbe4
Fixed setting of multiple paths
Mar 4, 2022
bdfc059
Added Linux AppImage paths
Mar 4, 2022
6014174
Sync SIPMAcros.cmake with Savitar
Mar 4, 2022
4dffd0c
Revert "Sync SIPMAcros.cmake with Savitar"
jellespijker Mar 4, 2022
12acc2d
Added relative rpath to lib from site-packages
jellespijker Mar 4, 2022
3c724a6
Also use relative rpath from loader
jellespijker Mar 8, 2022
58a94a0
Also add the ../Resources/lib/
Mar 8, 2022
659796e
Bumped up version and so version to 5
Mar 14, 2022
e6d6b6f
Allow usage of Conan
Mar 29, 2022
5d1d390
Set PYTHONPATH with cmake variable
Mar 31, 2022
053d794
Set PYTHONPATH with cmake variable
Apr 4, 2022
20dd9d0
Mimic find package variables Python
Apr 4, 2022
2f408d6
Also use PYTHONPATH when generating for the first time
Apr 4, 2022
26dbff7
Allow defining local site-package install path
Apr 5, 2022
766f634
Bump up minimum supported CMake version
jellespijker Apr 12, 2022
045fed6
Bump up minimum supported CMake version
jellespijker Apr 12, 2022
7350da2
Removed CPack support
jellespijker Apr 12, 2022
4ba8dda
Removed protobuf Module compatibility workaround
jellespijker Apr 12, 2022
2be1f55
Removed obsolete Export Header
jellespijker Apr 12, 2022
845b021
Revert "Removed obsolete Export Header"
jellespijker Apr 13, 2022
c8aed1b
Remove Example
jellespijker Apr 13, 2022
e583bb8
Review suggestion implemented
jellespijker Apr 13, 2022
9a89a3b
Remove obsolete jenkins file
jellespijker Apr 13, 2022
b42fae3
Add cmake-build to gitignore
jellespijker Apr 13, 2022
8504b4f
We don't use mingw anymore
jellespijker Apr 13, 2022
7373fbf
codestyle change on assure_out_of_source_builds
jellespijker Apr 13, 2022
6b1b7c2
Using BUILD_SHARED_LIBS flag instead of BUILD_STATIC
jellespijker Apr 13, 2022
24199a7
Remove CICD
jellespijker Apr 13, 2022
740514d
Fix wrong function call assure_out_of_source_builds
jellespijker Apr 14, 2022
55ac188
Use Python_VERSION for Cpython site-packages
Apr 14, 2022
6636816
Allow static build of the Python Module
Apr 14, 2022
a69cd0f
Allow in source builds
Apr 14, 2022
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
58 changes: 0 additions & 58 deletions .github/workflows/cicd-mingw64.yml

This file was deleted.

13 changes: 0 additions & 13 deletions .github/workflows/cicd.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,4 @@ nbproject/*

# Generated headers
/src/ArcusExport.h
/cmake-build-*
167 changes: 79 additions & 88 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,54 +1,14 @@
project(arcus)
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.20)
include(cmake/StandardProjectSettings.cmake)
assure_out_of_source_builds()

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(GenerateExportHeader)

option(BUILD_PYTHON "Build " ON)
option(BUILD_EXAMPLES "Build the example programs" ON)
option(BUILD_STATIC "Build as a static library" OFF)
option(BUILD_PYTHON "Build Python bindings for this library" ON)

if(WIN32)
option(MSVC_STATIC_RUNTIME "Link the MSVC runtime statically" OFF)
endif()

# We want to have access to protobuf_generate_cpp and other FindProtobuf features.
# However, if ProtobufConfig is used instead, there is a CMake option that controls
# this, which defaults to OFF. We need to force this option to ON instead.
set(protobuf_MODULE_COMPATIBLE ON CACHE INTERNAL "" FORCE)
find_package(Protobuf 3.0.0 REQUIRED)

set(CMAKE_POSITION_INDEPENDENT_CODE ON) #Required if a patch to libArcus needs to be made via templates.

if(BUILD_PYTHON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

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)
set(Python_FIND_FRAMEWORK NEVER)
endif()
find_package(Python ${Python_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development)
message(STATUS "Linking and building ${project_name} against Python ${Python_VERSION}")

find_package(SIP REQUIRED)
if(NOT DEFINED LIB_SUFFIX)
set(LIB_SUFFIX "")
endif()

include_directories(python/ src/ ${SIP_INCLUDE_DIRS} ${Python_INCLUDE_DIRS})
endif()

set(CMAKE_CXX_STANDARD 17)

if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
find_package(Protobuf 3.17.1 REQUIRED)

set(arcus_SRCS
src/Socket.cpp
Expand All @@ -67,58 +27,40 @@ set(arcus_HDRS
${CMAKE_CURRENT_BINARY_DIR}/src/ArcusExport.h
)

set(ARCUS_VERSION 1.1.0)
set(ARCUS_SOVERSION 3)

OPTION(SET_RPATH ON)
set(ARCUS_VERSION 5.0.0)
set(ARCUS_SOVERSION 5)

if(SET_RPATH)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
endif()

if(BUILD_STATIC)
add_library(Arcus STATIC ${arcus_SRCS})
if(NOT WIN32 OR CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(Arcus PRIVATE pthread)
set_target_properties(Arcus PROPERTIES COMPILE_FLAGS -fPIC)
endif()
else()
if(BUILD_SHARED_LIBS)
add_library(Arcus SHARED ${arcus_SRCS})
else()
add_library(Arcus STATIC ${arcus_SRCS})
endif()

if(MSVC_STATIC_RUNTIME)
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD")
endforeach(flag_var)
endif()

if(BUILD_PYTHON)
set(SIP_EXTRA_FILES_DEPEND python/SocketListener.sip python/Types.sip python/PythonMessage.sip python/Error.sip)
set(SIP_EXTRA_SOURCE_FILES python/PythonMessage.cpp)
set(SIP_EXTRA_OPTIONS -g -n PyQt5.sip) # -g means always release the GIL before calling C++ methods. -n PyQt5.sip is required to not get the PyCapsule error
add_sip_python_module(Arcus python/Socket.sip Arcus)
endif()
set_project_standards(Arcus)
use_threads(Arcus)
set_rpath(TARGETS
Arcus
PATHS
"$<$<PLATFORM_ID:Linux>:usr/bin>"
"$<$<PLATFORM_ID:Linux>:usr/bin/lib>"
"$<$<PLATFORM_ID:Darwin>:../lib>"
RELATIVE)

target_include_directories(Arcus PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
${PROTOBUF_INCLUDE_DIR}
)
target_link_libraries(Arcus PUBLIC ${PROTOBUF_LIBRARIES})
target_link_libraries(Arcus PUBLIC protobuf::libprotobuf)

if(WIN32)
add_definitions(-D_WIN32_WINNT=0x0600) # Declare we require Vista or higher, this allows us to use IPv6 functions.
target_compile_definitions(Arcus PRIVATE -D_WIN32_WINNT=0x0600)
jellespijker marked this conversation as resolved.
Show resolved Hide resolved
# Declare we require Vista or higher, this allows us to use IPv6 functions.

target_link_libraries(Arcus PUBLIC Ws2_32)
endif()

if(${CMAKE_BUILD_TYPE})
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
add_definitions(-DARCUS_DEBUG)
endif()
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo")
target_compile_definitions(Arcus PRIVATE -DARCUS_DEBUG)
endif()

set_target_properties(Arcus PROPERTIES
Expand All @@ -138,10 +80,6 @@ generate_export_header(Arcus
# The compiler won't find the generated header otherwise.
include_directories(${CMAKE_BINARY_DIR}/src)

if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

install(TARGETS Arcus
EXPORT Arcus-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
Expand All @@ -163,4 +101,57 @@ install(FILES
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Arcus
)

include(CPackConfig.cmake)
# Create the Python bindings
if(BUILD_PYTHON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

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)
set(Python_FIND_FRAMEWORK NEVER)
endif()
find_package(cpython ${Python_VERSION} QUIET COMPONENTS Interpreter Development)
if(NOT TARGET cpython::cpython)
find_package(Python ${Python_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development)
else()
add_library(Python::Python ALIAS cpython::python)
set(Python_SITEARCH "${CMAKE_INSTALL_PREFIX}/lib/python3.10/site-packages")
jellespijker marked this conversation as resolved.
Show resolved Hide resolved
set(Python_EXECUTABLE ${cpython_PACKAGE_FOLDER_RELEASE}/bin/python3)
set(ENV{PYTHONPATH} ${Python_SITEARCH})
endif()
message(STATUS "Linking and building ${project_name} against Python ${Python_VERSION}")

find_package(SIP REQUIRED 6.5.0)

add_library(pyArcus INTERFACE ${CMAKE_SOURCE_DIR}/python/PythonMessage.cpp)
set_project_standards(pyArcus)
set_rpath(TARGETS
pyArcus
PATHS
"$<$<PLATFORM_ID:Linux>:usr/bin>"
"$<$<PLATFORM_ID:Linux>:usr/bin/lib>"
"$<$<PLATFORM_ID:Darwin>:../lib>"
"$<$<PLATFORM_ID:Darwin>:../Resources/lib/>"
"../../"
RELATIVE)
use_threads(pyArcus)

target_include_directories(pyArcus
INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/python/>
)

target_link_libraries(pyArcus INTERFACE Arcus protobuf::libprotobuf Python::Python)

add_sip_module(pyArcus)
if (DEFINED Python_SITELIB_LOCAL)
install_sip_module(pyArcus ${Python_SITELIB_LOCAL})
else()
install_sip_module(pyArcus)
endif ()
endif()
24 changes: 0 additions & 24 deletions CPackConfig.cmake

This file was deleted.

45 changes: 0 additions & 45 deletions Jenkinsfile

This file was deleted.

13 changes: 13 additions & 0 deletions cmake/CMakeBuilder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from sipbuild import SetuptoolsBuilder


class CMakeBuilder(SetuptoolsBuilder):
def __init__(self, project, **kwargs):
print("Using the CMake builder")
super().__init__(project, **kwargs)

def build(self):
""" Only Generate the source files """
print("Generating the source files")
self._generate_bindings()
self._generate_scripts()
Loading