From 481ba89adc9042d0db95929ed137e78862131176 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Sat, 21 Jan 2023 08:01:13 -0500 Subject: [PATCH] Trying to fix windows --- .github/workflows/all-builds.yml | 56 ++++++++++++++----- CMakeLists.txt | 16 ++++-- example-app/CMakeLists.txt | 14 +++-- src/CMakeLists.txt | 1 + src/app/CMakeLists.txt | 94 ++++++++++++++++---------------- src/app/qtkwidget.cpp | 4 -- src/app/qtkwidget.h | 6 -- src/app/toolbox.h | 2 +- src/app/treeview.h | 2 +- src/qtk/CMakeLists.txt | 14 ++--- 10 files changed, 117 insertions(+), 92 deletions(-) diff --git a/.github/workflows/all-builds.yml b/.github/workflows/all-builds.yml index 01ff4ef..21a3d21 100644 --- a/.github/workflows/all-builds.yml +++ b/.github/workflows/all-builds.yml @@ -10,14 +10,15 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] +# os: [ubuntu-latest, windows-latest, macos-latest] + os: [windows-latest] include: - - os: ubuntu-latest - cmake: -DCMAKE_PREFIX_PATH="/home/runner/work/qtk/Qt/6.5.0/gcc_64/" +# - os: ubuntu-latest +# cmake: -DCMAKE_PREFIX_PATH="/home/runner/work/qtk/Qt/6.5.0/gcc_64/" - os: windows-latest cmake: -DCMAKE_PREFIX_PATH="D:/a/qtk/qtk/Qt/6.5.0/mingw81_64/" - - os: macos-latest - cmake: -DCMAKE_PREFIX_PATH="/home/runner/work/qtk/Qt/6.5.0/gcc_64/" +# - os: macos-latest +# cmake: -DCMAKE_PREFIX_PATH="/home/runner/work/qtk/Qt/6.5.0/gcc_64/" runs-on: ${{ matrix.os }} steps: @@ -35,27 +36,43 @@ jobs: args: install pkgconfiglite --checksum e87b5ea3c9142256af60f2d5b917aa63b571e6a0 --checksum-type sha1 - name: Build Qtk + if: matrix.os == 'windows-latest' shell: bash run: | - cmake -B build/ ${{ matrix.cmake }} -DQTK_UPDATE_SUBMODULES=ON - cmake --build build/ -- -j $(nproc) + cmake -B build/ ${{ matrix.cmake }} -DQTK_UPDATE_SUBMODULES=ON -DQTK_DEBUG=OFF + cmake --build build/ --config Release + + - name: Build Qtk + if: matrix.os != 'windows-latest' + shell: bash + run: | + cmake -B build/ ${{ matrix.cmake }} -DQTK_UPDATE_SUBMODULES=ON -DQTK_DEBUG=OFF + cmake --build build/ --config Release -- -j $(nproc) - name: Install Qtk shell: bash run: | - cmake --install build/ + cmake --install build/ --config Release - - uses: actions/upload-artifact@v3 - if: always() - with: - name: qtk-${{ matrix.os }} - path: install/* +# - uses: actions/upload-artifact@v3 +# if: always() +# with: +# name: qtk-${{ matrix.os }} +# path: install/* - name: Package Qtk + if: matrix.os == 'windows-latest' shell: bash run: | cd build/ - cmake --build . --target package -- -j $(nproc) + cmake --build . --target package --config Release + + - name: Package Qtk + if: matrix.os != 'windows-latest' + shell: bash + run: | + cd build/ + cmake --build . --target package --config Release -- -j $(nproc) # - name: Package Qtk Sources # if: matrix.os != 'macos-latest' @@ -104,9 +121,18 @@ jobs: sudo apt install libassimp-dev - name: Build Qtk + if: matrix.os == 'windows-latest' shell: bash run: | - cmake -B build/ ${{ matrix.cmake }} && cmake --build build/ -- -j $(nproc) + cmake -B build/ ${{ matrix.cmake }} -DQTK_DEBUG=OFF + cmake --build build/ --config Release + + - name: Build Qtk + if: matrix.os != 'windows-latest' + shell: bash + run: | + cmake -B build/ ${{ matrix.cmake }} -DQTK_DEBUG=OFF + cmake --build build/ --config Release -- -j $(nproc) # TODO: Enable with tag only when done testing # Release-Qtk: diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fae330..f8b1f2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,12 +22,11 @@ set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -#set(CMAKE_MACOSX_BUNDLE ON) +set(CMAKE_MACOSX_BUNDLE ON) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -if(MSVC) +if(WIN32) set(CMAKE_COMPILE_WARNING_AS_ERROR OFF) - add_compile_options(-warnnotaserror) add_compile_options(/wd4131 /wd4127) endif() @@ -58,6 +57,12 @@ option( OFF ) +if(NOT QTK_DEBUG) + set(CMAKE_BUILD_TYPE Release) +else() + set(CMAKE_BUILD_TYPE Debug) +endif() + set(QT_DIR "$ENV{HOME}/Qt/" CACHE PATH "Path to Qt6") # Qt Designer will look in different locations if WIN / Unix. @@ -116,10 +121,11 @@ if(NOT Qt6_FOUND) endif() # Find Assimp -set(ASSIMP_BUILD_TESTS OFF) +set(ASSIMP_BUILD_TESTS OFF CACHE STRING "Do not build assimp tests." FORCE) if(QTK_UPDATE_SUBMODULES) message(STATUS "[Qtk] Updating submodules...") - set(ASSIMP_INSTALL OFF) + set(ASSIMP_INSTALL OFF CACHE STRING "Use assimp as a submodule." FORCE) + set(ASSIMP_WARNINGS_AS_ERRORS OFF CACHE STRING "No warnings as errors." FORCE) submodule_update("${CMAKE_CURRENT_SOURCE_DIR}/extern/assimp/assimp/") add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/extern/assimp/assimp/") else() diff --git a/example-app/CMakeLists.txt b/example-app/CMakeLists.txt index f708792..05d4284 100644 --- a/example-app/CMakeLists.txt +++ b/example-app/CMakeLists.txt @@ -47,12 +47,14 @@ if(NOT TARGET Qtk::qtk_library) endif() # Print all QTK variables -get_cmake_property(VAR_NAMES VARIABLES) -list(FILTER VAR_NAMES INCLUDE REGEX "^Q[tT][kK]_.*$") -list(SORT VAR_NAMES) -foreach(VAR_NAME ${VAR_NAMES}) - message(STATUS "[Qtk] ${VAR_NAME}=${${VAR_NAME}}") -endforeach() +if (NOT Qtk_IS_TOP_LEVEL) + get_cmake_property(VAR_NAMES VARIABLES) + list(FILTER VAR_NAMES INCLUDE REGEX "^Q[tT][kK]_.*$") + list(SORT VAR_NAMES) + foreach(VAR_NAME ${VAR_NAMES}) + message(STATUS "[Qtk] ${VAR_NAME}=${${VAR_NAME}}") + endforeach() +endif() find_package(Qt6 COMPONENTS Core Widgets OpenGLWidgets REQUIRED) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 50fa8ab..466b6f4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -46,6 +46,7 @@ set(CPACK_PACKAGE_DIRECTORY packages/) set(CPACK_PACKAGE_CONTACT "shaunreed.com") set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/resources/icon.png") set(CPACK_THREADS 0) +set(CPACK_PACKAGE_INSTALL_DIRECTORY "Qtk") # Debian set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_PACKAGE_HOMEPAGE_URL}) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index caa2da4..eec54e1 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -39,13 +39,13 @@ install( ) # Install plugin library to Qt Creator for Designer plugin integration. -install( - TARGETS qtk_plugin_library - EXCLUDE_FROM_ALL - LIBRARY DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" - ARCHIVE DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" - RUNTIME DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" -) +#install( +# TARGETS qtk_plugin_library +# EXCLUDE_FROM_ALL +# LIBRARY DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" +# ARCHIVE DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" +# RUNTIME DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" +#) ################################################################################ # Qtk Widget Collection Plugin @@ -66,13 +66,13 @@ install( RUNTIME DESTINATION bin ) -install( - TARGETS qtk_collection - EXCLUDE_FROM_ALL - LIBRARY DESTINATION "${QTK_PLUGIN_INSTALL_DIR}" - ARCHIVE DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" - RUNTIME DESTINATION "${QTK_PLUGIN_INSTALL_DIR}" -) +#install( +# TARGETS qtk_collection +# EXCLUDE_FROM_ALL +# LIBRARY DESTINATION "${QTK_PLUGIN_INSTALL_DIR}" +# ARCHIVE DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" +# RUNTIME DESTINATION "${QTK_PLUGIN_INSTALL_DIR}" +#) ################################################################################ # Final Qtk Application @@ -123,36 +123,36 @@ qt_generate_deploy_app_script( ) install(SCRIPT ${QTK_DEPLOY_SCRIPT}) -if(WIN32) - get_target_property(_qt6_qmake_location Qt6::qmake IMPORTED_LOCATION) - execute_process( - COMMAND "${_qt6_qmake_location}" -query QT_INSTALL_PREFIX - RESULT_VARIABLE return_code - OUTPUT_VARIABLE qt6_install_prefix - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - file(TO_NATIVE_PATH "${qt6_install_prefix}/bin" qt6_install_prefix) - - if(TARGET Qt6::windeployqt) - add_custom_command( - TARGET qtk_main - POST_BUILD - COMMAND set PATH=%PATH%$${qt6_install_prefix} - COMMAND Qt6::windeployqt --dir "${CMAKE_BINARY_DIR}/windeployqt" "$/$" - ) - install(DIRECTORY "${CMAKE_BINARY_DIR}/windeployqt/" DESTINATION bin) - endif() - - if(MSVC AND TARGET Qt6::qmake) - set(VSUSER_FILE "${CMAKE_CURRENT_BINARY_DIR}/qtk_main.vcxproj.user") - file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/extern/assimp/assimp/bin" assimp_bin) - file(WRITE ${VSUSER_FILE} "\n") - file(APPEND ${VSUSER_FILE} "\n") - file(APPEND ${VSUSER_FILE} " \n") - file(APPEND ${VSUSER_FILE} " Path=$(SolutionDir)\\lib\\$(Configuration);${qt6_install_prefix};${assimp_bin};$(Path)\n") - file(APPEND ${VSUSER_FILE} "$(LocalDebuggerEnvironment)\n") - file(APPEND ${VSUSER_FILE} " WindowsLocalDebugger\n") - file(APPEND ${VSUSER_FILE} " \n") - file(APPEND ${VSUSER_FILE} "\n") - endif() -endif() +#if(WIN32) +# get_target_property(_qt6_qmake_location Qt6::qmake IMPORTED_LOCATION) +# execute_process( +# COMMAND "${_qt6_qmake_location}" -query QT_INSTALL_PREFIX +# RESULT_VARIABLE return_code +# OUTPUT_VARIABLE qt6_install_prefix +# OUTPUT_STRIP_TRAILING_WHITESPACE +# ) +# file(TO_NATIVE_PATH "${qt6_install_prefix}/bin" qt6_install_prefix) +# +# if(TARGET Qt6::windeployqt) +# add_custom_command( +# TARGET qtk_main +# POST_BUILD +# COMMAND set PATH=%PATH%$${qt6_install_prefix} +# COMMAND Qt6::windeployqt --dir "${CMAKE_BINARY_DIR}/windeployqt" "$/$" +# ) +# install(DIRECTORY "${CMAKE_BINARY_DIR}/windeployqt/" DESTINATION bin) +# endif() +# +# if(MSVC AND TARGET Qt6::qmake) +# set(VSUSER_FILE "${CMAKE_CURRENT_BINARY_DIR}/qtk_main.vcxproj.user") +# file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/extern/assimp/assimp/bin" assimp_bin) +# file(WRITE ${VSUSER_FILE} "\n") +# file(APPEND ${VSUSER_FILE} "\n") +# file(APPEND ${VSUSER_FILE} " \n") +# file(APPEND ${VSUSER_FILE} " Path=$(SolutionDir)\\lib\\$(Configuration);${qt6_install_prefix};${assimp_bin};$(Path)\n") +# file(APPEND ${VSUSER_FILE} "$(LocalDebuggerEnvironment)\n") +# file(APPEND ${VSUSER_FILE} " WindowsLocalDebugger\n") +# file(APPEND ${VSUSER_FILE} " \n") +# file(APPEND ${VSUSER_FILE} "\n") +# endif() +#endif() diff --git a/src/app/qtkwidget.cpp b/src/app/qtkwidget.cpp index 7824558..f3f943d 100644 --- a/src/app/qtkwidget.cpp +++ b/src/app/qtkwidget.cpp @@ -42,9 +42,7 @@ QtkWidget::QtkWidget(QWidget * parent, const QString & name, Scene * scene) : // Set the size of the depth bufer for glEnable(GL_DEPTH_TEST) format.setDepthBufferSize(16); // If QTK_DEBUG is set, enable debug context -#ifdef QTK_DEBUG format.setOption(QSurfaceFormat::DebugContext); -#endif setFormat(format); setFocusPolicy(Qt::ClickFocus); } @@ -73,7 +71,6 @@ void QtkWidget::initializeGL() { connect(this, SIGNAL(frameSwapped()), this, SLOT(update())); // Initialize OpenGL debug context -#ifdef QTK_DEBUG mDebugLogger = new QOpenGLDebugLogger(this); if(mDebugLogger->initialize()) { qDebug() << "GL_DEBUG Debug Logger" << mDebugLogger << "\n"; @@ -82,7 +79,6 @@ void QtkWidget::initializeGL() { SLOT(messageLogged(QOpenGLDebugMessage))); mDebugLogger->startLogging(); } -#endif // QTK_DEBUG printContextInformation(); diff --git a/src/app/qtkwidget.h b/src/app/qtkwidget.h index 56ac290..61b980c 100644 --- a/src/app/qtkwidget.h +++ b/src/app/qtkwidget.h @@ -156,7 +156,6 @@ namespace Qtk { */ void update(); -#ifdef QTK_DEBUG /** * Called when the `messageLogged` signal is caught. * See definition of initializeGL() @@ -164,7 +163,6 @@ namespace Qtk { * @param msg The message logged. */ void messageLogged(const QOpenGLDebugMessage & msg); -#endif private: /************************************************************************* @@ -181,20 +179,16 @@ namespace Qtk { */ static void updateCameraInput(); -#ifdef QTK_DEBUG /** * Prints OpenGL context information at start of debug session. */ void printContextInformation(); -#endif /************************************************************************* * Private Members ************************************************************************/ -#ifdef QTK_DEBUG QOpenGLDebugLogger * mDebugLogger; -#endif Qtk::Scene * mScene; Qtk::DebugConsole * mConsole; bool mConsoleActive = false; diff --git a/src/app/toolbox.h b/src/app/toolbox.h index a3c7e1c..601d4d5 100644 --- a/src/app/toolbox.h +++ b/src/app/toolbox.h @@ -18,7 +18,7 @@ namespace Ui { } namespace Qtk { - class QDESIGNER_WIDGET_EXPORT ToolBox : public QDockWidget { + class ToolBox : public QDockWidget { Q_OBJECT public: diff --git a/src/app/treeview.h b/src/app/treeview.h index d1bdba9..6c24211 100644 --- a/src/app/treeview.h +++ b/src/app/treeview.h @@ -22,7 +22,7 @@ namespace Ui { } namespace Qtk { - class QDESIGNER_WIDGET_EXPORT TreeView : public QDockWidget { + class TreeView : public QDockWidget { Q_OBJECT public: diff --git a/src/qtk/CMakeLists.txt b/src/qtk/CMakeLists.txt index e9558c5..4804f3c 100644 --- a/src/qtk/CMakeLists.txt +++ b/src/qtk/CMakeLists.txt @@ -91,10 +91,10 @@ install( ) ## Install qtk_library to Qt Designer to support widget plugins. -install( - TARGETS qtk_library - EXCLUDE_FROM_ALL - LIBRARY DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" - ARCHIVE DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" - RUNTIME DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" -) +#install( +# TARGETS qtk_library +# EXCLUDE_FROM_ALL +# LIBRARY DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" +# ARCHIVE DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" +# RUNTIME DESTINATION "${QTK_PLUGIN_LIBRARY_DIR}" +#)