From 15d86b1f68b65991ac234f18558ddfe7f9df106f Mon Sep 17 00:00:00 2001 From: bjornpiltz Date: Wed, 11 Oct 2023 22:02:28 +0200 Subject: [PATCH 1/4] Enabled CI MSVC build jobs. * Added a build matrix * Installed Qt through jurplel/install-qt-action (allows for caching) --- .github/workflows/jobs.yml | 66 +++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index 100e1ff1..ce579381 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -1,29 +1,45 @@ name: libQGLViewer -on: [push, pull_request] + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + jobs: - buildQt5: - runs-on: ubuntu-latest + build: + strategy: + matrix: + include: + - runner: 'ubuntu-latest' + qtVersion: '6.2.2' + - runner: 'ubuntu-latest' + qtVersion: '5.15.2' +# - runner: 'macOS-11' +# qtVersion: '6.2.2' + - runner: 'windows-2019' + qtVersion: '6.2.2' + qtArch: 'win64_msvc2019_64' + - runner: 'windows-2019' + qtVersion: '5.15.2' + qtArch: 'win64_msvc2019_64' + runs-on: ${{ matrix.runner }} steps: - - name: Check out repository code - uses: actions/checkout@v3 - - name: Install dependencies - run: sudo apt-get install -y build-essential qtbase5-dev libglu1-mesa-dev - - name: Build all + - uses: actions/checkout@v3 + + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: ${{ matrix.qtVersion }} + arch: ${{ matrix.qtArch }} + cache: true + + - name: Install GLU + if: startsWith(matrix.runner, 'ubuntu') + run: sudo apt-get install -y libglu1-mesa-dev + + - name: Build QGLViewer run: | - mkdir build - cd build - cmake .. - make all - buildQt6: - runs-on: ubuntu-latest - steps: - - name: Check out repository code - uses: actions/checkout@v3 - - name: Install dependencies - run: sudo apt-get install -y build-essential qt6-base-dev libglu1-mesa-dev - - name: Build all - run: | - mkdir build - cd build - cmake .. - make all + mkdir build + cmake -B build -S . + cmake --build build --config Release From 0026419fa73b9c69d7e2786756c2f10fb24b3fa8 Mon Sep 17 00:00:00 2001 From: bjornpiltz Date: Wed, 11 Oct 2023 22:33:06 +0200 Subject: [PATCH 2/4] Added NOMINMAX to MSVC builds. Fix MSVC error due to WinDef.h redefining min/max. --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 034e560c..14472cc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,11 @@ add_library(QGLViewer SHARED ${QGLViewer_SRC}) target_include_directories(QGLViewer INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(QGLViewer PRIVATE ${QtLibs} OpenGL::GL OpenGL::GLU) +if(MSVC) + # Avoid a compiler error when using std::min/std::max. + target_compile_definitions(QGLViewer PRIVATE NOMINMAX) +endif() + # Example: animation. set(animation_SRC "${PROJECT_SOURCE_DIR}/examples/animation/animation.cpp" From 20f8aa5a1d9e6ab5f1554b290c27ebe1d858347d Mon Sep 17 00:00:00 2001 From: bjornpiltz Date: Wed, 11 Oct 2023 23:00:59 +0200 Subject: [PATCH 3/4] Added missing CREATE_QGLVIEWER_DLL define. --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14472cc6..afc65b5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,10 @@ if(MSVC) target_compile_definitions(QGLViewer PRIVATE NOMINMAX) endif() +if(WIN32) + target_compile_definitions(QGLViewer PRIVATE CREATE_QGLVIEWER_DLL) +endif() + # Example: animation. set(animation_SRC "${PROJECT_SOURCE_DIR}/examples/animation/animation.cpp" From 944379ef432309527719f0533f02911693801641 Mon Sep 17 00:00:00 2001 From: bjornpiltz Date: Mon, 8 May 2023 10:43:38 +0200 Subject: [PATCH 4/4] Forward declare streaming operators to place them in the right namespace (MSVC fix). --- QGLViewer/VRender/NVector3.h | 2 ++ QGLViewer/VRender/Primitive.h | 1 + QGLViewer/VRender/Vector2.h | 2 ++ QGLViewer/VRender/Vector3.h | 2 ++ 4 files changed, 7 insertions(+) diff --git a/QGLViewer/VRender/NVector3.h b/QGLViewer/VRender/NVector3.h index 40b7f98b..f2d8305b 100644 --- a/QGLViewer/VRender/NVector3.h +++ b/QGLViewer/VRender/NVector3.h @@ -7,6 +7,8 @@ namespace vrender { class Vector3; + class NVector3; + std::ostream& operator<<(std::ostream &out,const NVector3 &u); class NVector3 { diff --git a/QGLViewer/VRender/Primitive.h b/QGLViewer/VRender/Primitive.h index 88ab11d0..bfe31e65 100644 --- a/QGLViewer/VRender/Primitive.h +++ b/QGLViewer/VRender/Primitive.h @@ -21,6 +21,7 @@ namespace vrender { class Feedback3DColor ; class Primitive ; + std::ostream& operator<<(std::ostream&, const Feedback3DColor&) ; #define EPS_SMOOTH_LINE_FACTOR 0.06 /* Lower for better smooth lines. */ diff --git a/QGLViewer/VRender/Vector2.h b/QGLViewer/VRender/Vector2.h index f6aaaf3e..7b9b82a6 100644 --- a/QGLViewer/VRender/Vector2.h +++ b/QGLViewer/VRender/Vector2.h @@ -6,7 +6,9 @@ namespace vrender { + class Vector2; class Vector3; + std::ostream& operator<< (std::ostream&,const Vector2&); class Vector2 { diff --git a/QGLViewer/VRender/Vector3.h b/QGLViewer/VRender/Vector3.h index 32597e8c..f6d50991 100644 --- a/QGLViewer/VRender/Vector3.h +++ b/QGLViewer/VRender/Vector3.h @@ -10,6 +10,8 @@ namespace vrender { class NVector3; + class Vector3; + std::ostream& operator<< (std::ostream&, const Vector3&); class Vector3 {