Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 109
add CMake build system support#240
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
e0291e7651427e6bbd1775ac1ecad1c8d34815730f56bd7e4e02479fbd2ef21b1f079c85aa600d4f5f7fa02dd4909ea478e469f27952b6d3f474b3f473efa022e38fccb96f7fFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| name: CMake CI | ||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| jobs: | ||
| build-and-test: | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest, windows-latest] | ||
| qt_version: [5, 6] | ||
| python_version: ["3.8", "3.9", "3.10"] | ||
| fail-fast: false | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
| - name: Set up Python | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: ${{ matrix.python_version }} | ||
Contributor 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. Noticed that you missed the apostrophes here, you need with:
python-version: '${{ matrix.python-version }}'otherwise it won't work. | ||
| - name: Install dependencies (Linux) | ||
| if: runner.os == 'Linux' | ||
| run: | | ||
| sudo apt-get update | ||
| if [ "${{ matrix.qt_version }}" = "5" ]; then | ||
| sudo apt-get install -y qtbase5-dev qtbase5-private-dev qtchooser qt5-qmake qtbase5-dev-tools \ | ||
| libqt5svg5-dev qttools5-dev libqt5xmlpatterns5-dev qtmultimedia5-dev qtdeclarative5-dev \ | ||
| qtwebengine5-dev libqt5webkit5-dev | ||
| echo "QTDIR=/usr/lib/x86_64-linux-gnu/qt5" | tee -a $GITHUB_ENV | ||
| else | ||
| sudo apt-get install -y qt6-base-dev qt6-base-private-dev qt6-5compat-dev qt6-base-dev-tools \ | ||
| libqt6svg6-dev qt6-multimedia-dev qt6-declarative-dev qt6-webengine-dev | ||
| echo "QTDIR=/usr/lib/x86_64-linux-gnu/qt6" | tee -a $GITHUB_ENV | ||
| fi | ||
| - name: Install dependencies (Windows) | ||
| if: runner.os == 'Windows' | ||
| run: | | ||
| if ("${{ matrix.qt_version }}" -eq "5") { | ||
| pip install aqtinstall | ||
| aqt install-qt windows desktop 5.15.2 win64_msvc2019 -m all | ||
| $Qt5Dir = "$env:USERPROFILE\Qt\5.15.2\msvc2019_64" | ||
| echo "Qt5Dir=$Qt5Dir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | ||
| echo "$Qt5Dir\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | ||
| echo "QTDIR=$Qt5Dir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | ||
| } else { | ||
| choco install -y qt6-base-dev qt6-base-private-dev qt6-5compat-dev qt6-base-dev-tools ` | ||
| libqt6svg6-dev qt6-multimedia-dev qt6-declarative-dev qt6-webengine-dev ` | ||
| --params "/InstallationFolder C:/Qt/${{ matrix.qt_version }}" | ||
| echo "C:/Qt/${{ matrix.qt_version }}/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | ||
| echo "QTDIR=C:/Qt/${{ matrix.qt_version }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | ||
| } | ||
| ||
| - name: Configure CMake | ||
| run: | | ||
| cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=./install | ||
| - name: Build project | ||
| run: | | ||
| cmake --build build --parallel --target all install | ||
| - name: Run tests | ||
| run: | | ||
| cd build | ||
| ctest --output-on-failure | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| cmake_minimum_required(VERSION 3.27) | ||
| project(PythonQt LANGUAGES CXX VERSION 3.5.6) | ||
| enable_testing() | ||
| set(CMAKE_CXX_STANDARD 11) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
| find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) | ||
| find_package(Python3 COMPONENTS Development) | ||
| set(PYTHONQT_SUFFIX Qt${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}-Python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}) | ||
| add_subdirectory(generator) | ||
| add_subdirectory(src) | ||
| add_subdirectory(extensions) | ||
| add_subdirectory(tests) | ||
| # add_subdirectory(examples) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| add_subdirectory(PythonQt_QtAll) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| project(QtAll LANGUAGES CXX) | ||
| set(CMAKE_AUTOMOC ON) | ||
| file(GLOB SOURCES *.h *.cpp) | ||
| if(BUILD_SHARED_LIBS) | ||
| add_library(${PROJECT_NAME} SHARED) | ||
| target_compile_definitions(${PROJECT_NAME} PRIVATE PYTHONQT_QTALL_EXPORTS) | ||
| else() | ||
| add_library(${PROJECT_NAME} STATIC) | ||
| target_compile_definitions(${PROJECT_NAME} PUBLIC PYTHONQT_QTALL_STATIC) | ||
| endif() | ||
| target_sources(${PROJECT_NAME} PRIVATE ${SOURCES}) | ||
| target_link_libraries(${PROJECT_NAME} PUBLIC Core) | ||
| target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}) | ||
| list(APPEND QTMODULES Core Gui Svg Sql Network OpenGL Xml XmlPatterns Multimedia Qml Quick UiTools WebEngineWidgets WebKit) | ||
mrbean-bremen marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| find_package(Qt${QT_VERSION_MAJOR} COMPONENTS ${QTMODULES}) | ||
| foreach(QtModule IN LISTS QTMODULES) | ||
| if(NOT TARGET "Qt${QT_VERSION_MAJOR}::${QtModule}") | ||
| continue() | ||
| endif() | ||
| string(TOUPPER ${QtModule} QTMODULE) | ||
| target_sources(${PROJECT_NAME} PRIVATE ${PYTHONQT_WRAPPER_${QTMODULE}_SOURCES}) | ||
| target_link_libraries(${PROJECT_NAME} PUBLIC Qt${QT_VERSION_MAJOR}::${QtModule}) | ||
| target_compile_definitions(${PROJECT_NAME} PRIVATE PYTHONQT_WITH_${QTMODULE}) | ||
| endforeach() | ||
| if(TARGET "Qt${QT_VERSION_MAJOR}::Gui") | ||
| find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets PrintSupport REQUIRED) | ||
| target_link_libraries(${PROJECT_NAME} PUBLIC | ||
| Qt${QT_VERSION_MAJOR}::Widgets | ||
| Qt${QT_VERSION_MAJOR}::PrintSupport | ||
| ) | ||
| endif() | ||
| if(TARGET "Qt${QT_VERSION_MAJOR}::Svg" AND QT_VERSION_MAJOR VERSION_GREATER_EQUAL 6) | ||
| find_package(Qt${QT_VERSION_MAJOR} COMPONENTS SvgWidgets REQUIRED) | ||
| target_link_libraries(${PROJECT_NAME} PUBLIC | ||
| Qt${QT_VERSION_MAJOR}::SvgWidgets | ||
| ) | ||
| endif() | ||
| if(TARGET "Qt${QT_VERSION_MAJOR}::Multimedia") | ||
| find_package(Qt${QT_VERSION_MAJOR} COMPONENTS MultimediaWidgets REQUIRED) | ||
| target_link_libraries(${PROJECT_NAME} PUBLIC | ||
| Qt${QT_VERSION_MAJOR}::MultimediaWidgets | ||
| ) | ||
| endif() | ||
| if(TARGET "Qt${QT_VERSION_MAJOR}::Quick") | ||
| find_package(Qt${QT_VERSION_MAJOR} COMPONENTS QuickWidgets REQUIRED) | ||
| target_link_libraries(${PROJECT_NAME} PUBLIC | ||
| Qt${QT_VERSION_MAJOR}::QuickWidgets | ||
| ) | ||
| endif() | ||
| if(TARGET "Qt${QT_VERSION_MAJOR}::WebKit") | ||
| find_package(Qt${QT_VERSION_MAJOR} COMPONENTS WebKitWidgets REQUIRED) | ||
| target_link_libraries(${PROJECT_NAME} PUBLIC | ||
| Qt${QT_VERSION_MAJOR}::WebKitWidgets | ||
| ) | ||
| endif() | ||
| file(GLOB PUBLIC_HEADER *.h) | ||
| set_target_properties(${PROJECT_NAME} PROPERTIES | ||
| OUTPUT_NAME PythonQt-QtAll-${PYTHONQT_SUFFIX} | ||
| PUBLIC_HEADER "${PUBLIC_HEADER}" | ||
| ) | ||
| if(MSVC) | ||
| target_compile_options(${PROJECT_NAME} PRIVATE "/bigobj") | ||
| elseif(MINGW) | ||
| target_compile_options(${PROJECT_NAME} PRIVATE "-Wa,-mbig-obj") | ||
| endif() | ||
| include(GNUInstallDirs) | ||
| install(TARGETS ${PROJECT_NAME} | ||
| BUNDLE DESTINATION . | ||
| LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
| ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
| RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
| PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
You also need to trigger on pull-request to be able to see it in the PR build.
But you probably know that...
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.
The generator seems to need some changes, the path to the fetched header file is not always correct in different environments