From b5210e39a836d79f7d144b009e49a109e8dbef47 Mon Sep 17 00:00:00 2001 From: 5tan <5tan@users.noreply.github.com> Date: Thu, 1 Aug 2024 09:11:39 +0200 Subject: [PATCH] Added windows CI --- .github/workflows/ci.yml | 27 +++++++++++++++++++++++++-- examples/callbacks/CMakeLists.txt | 6 +++++- examples/player_async/CMakeLists.txt | 6 +++++- examples/player_sync/CMakeLists.txt | 6 +++++- examples/qtmidieditor/CMakeLists.txt | 6 +++++- examples/qtmidiplayer/CMakeLists.txt | 6 +++++- examples/sequencing/CMakeLists.txt | 8 ++++++-- include/cxxmidi/output/default.hpp | 2 +- include/cxxmidi/output/windows.hpp | 16 +++++++++------- tests/CMakeLists.txt | 6 +++++- tests/file.cpp | 2 ++ 11 files changed, 73 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 161fbd2..2dbdad6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,12 @@ jobs: - clang++ extra_check: - '' + gtest_root_flag: + - '' include: + - os: windows-latest + compiler: g++ + gtest_root_flag: "-DGTEST_ROOT=D:/gtest" - os: ubuntu-latest compiler: clazy extra_check: clazy @@ -56,6 +61,21 @@ jobs: if: matrix.os == 'macos-latest' run: brew install googletest qt6 + - name: Install Qt6 (windows) + if: matrix.os == 'windows-latest' + uses: jurplel/install-qt-action@v4 + with: + version: '6.6.0' + host: 'windows' + target: 'desktop' + arch: 'win64_msvc2019_64' + dir: '${{ github.workspace }}/qt6/' + set-env: 'true' + + - name: Install gtest (windows) + if: matrix.os == 'windows-latest' + uses: MarkusJx/googletest-installer@v1.1 + - name: Install clang (linux) if: matrix.os == 'ubuntu-latest' run: sudo apt-get -y install clang @@ -76,9 +96,12 @@ jobs: if: matrix.extra_check == 'iwyu' run: sudo apt-get install -y iwyu + - name: Configure CMake + run: cmake . DCMAKE_CXX_COMPILER="${{ matrix.compiler }}" ${{matrix.extra_check_flag}} ${{matrix.gtest_root_flag}} + - name: Build - run: (mkdir build && cd build && cmake .. -DCMAKE_CXX_COMPILER="${{ matrix.compiler }}" ${{matrix.extra_check_flag}} && make) + run: cmake --build . - name: Test if: matrix.extra_check == '' - run: (cd build && ctest) \ No newline at end of file + run: ctest \ No newline at end of file diff --git a/examples/callbacks/CMakeLists.txt b/examples/callbacks/CMakeLists.txt index c10cdcd..f26f3be 100644 --- a/examples/callbacks/CMakeLists.txt +++ b/examples/callbacks/CMakeLists.txt @@ -8,7 +8,11 @@ endif() add_executable(callbacks main.cpp) -target_compile_options(callbacks PRIVATE -Wall -pedantic -Wextra) +if(MSVC) + target_compile_options(callbacks PRIVATE /W4) +else() + target_compile_options(callbacks PRIVATE -Wall -pedantic -Wextra) +endif() target_compile_features(callbacks PRIVATE cxx_std_17) if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") diff --git a/examples/player_async/CMakeLists.txt b/examples/player_async/CMakeLists.txt index a9c5271..3ac64da 100644 --- a/examples/player_async/CMakeLists.txt +++ b/examples/player_async/CMakeLists.txt @@ -8,7 +8,11 @@ endif() add_executable(player_async main.cpp) -target_compile_options(player_async PRIVATE -Wall -pedantic -Wextra) +if(MSVC) + target_compile_options(player_async PRIVATE /W4) +else() + target_compile_options(player_async PRIVATE -Wall -pedantic -Wextra) +endif() target_compile_features(player_async PRIVATE cxx_std_17) if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") diff --git a/examples/player_sync/CMakeLists.txt b/examples/player_sync/CMakeLists.txt index 2f168d9..19ef383 100644 --- a/examples/player_sync/CMakeLists.txt +++ b/examples/player_sync/CMakeLists.txt @@ -8,7 +8,11 @@ endif() add_executable(player_sync main.cpp) -target_compile_options(player_sync PRIVATE -Wall -pedantic -Wextra) +if(MSVC) + target_compile_options(player_sync PRIVATE /W4) +else() + target_compile_options(player_sync PRIVATE -Wall -pedantic -Wextra) +endif() target_compile_features(player_sync PRIVATE cxx_std_17) diff --git a/examples/qtmidieditor/CMakeLists.txt b/examples/qtmidieditor/CMakeLists.txt index a87ac67..97943ed 100644 --- a/examples/qtmidieditor/CMakeLists.txt +++ b/examples/qtmidieditor/CMakeLists.txt @@ -18,7 +18,11 @@ add_executable(qtmidieditor trackmodel.cpp trackview.cpp) -target_compile_options(qtmidieditor PRIVATE -Wall -pedantic -Wextra) +if(MSVC) + target_compile_options(qtmidieditor PRIVATE /W4) +else() + target_compile_options(qtmidieditor PRIVATE -Wall -pedantic -Wextra) +endif() target_compile_features(qtmidieditor PRIVATE cxx_std_17) if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") diff --git a/examples/qtmidiplayer/CMakeLists.txt b/examples/qtmidiplayer/CMakeLists.txt index e9eb43e..2ad15fd 100644 --- a/examples/qtmidiplayer/CMakeLists.txt +++ b/examples/qtmidiplayer/CMakeLists.txt @@ -14,7 +14,11 @@ add_executable(qtmidiplayer main.cpp mainwindow.cpp) -target_compile_options(qtmidiplayer PRIVATE -Wall -pedantic -Wextra) +if(MSVC) + target_compile_options(qtmidiplayer PRIVATE /W4) +else() + target_compile_options(qtmidiplayer PRIVATE -Wall -pedantic -Wextra) +endif() target_compile_features(qtmidiplayer PRIVATE cxx_std_17) if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") diff --git a/examples/sequencing/CMakeLists.txt b/examples/sequencing/CMakeLists.txt index 45b1880..a771226 100644 --- a/examples/sequencing/CMakeLists.txt +++ b/examples/sequencing/CMakeLists.txt @@ -8,7 +8,11 @@ endif() add_executable(sequencing main.cpp) -target_compile_options(sequencing PRIVATE -Wall -pedantic -Wextra) +if(MSVC) + target_compile_options(sequencing PRIVATE /W4) +else() + target_compile_options(sequencing PRIVATE -Wall -pedantic -Wextra) +endif() target_compile_features(sequencing PRIVATE cxx_std_17) if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") @@ -25,4 +29,4 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") target_link_libraries(sequencing ${ALSA_LIBRARIES}) elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") # todo -endif() \ No newline at end of file +endif() diff --git a/include/cxxmidi/output/default.hpp b/include/cxxmidi/output/default.hpp index 9f8a626..0c31213 100644 --- a/include/cxxmidi/output/default.hpp +++ b/include/cxxmidi/output/default.hpp @@ -27,7 +27,7 @@ SOFTWARE. #include namespace cxxmidi { namespace output { -typedef output::windows Default; +typedef output::Windows Default; } // namespace output } // namespace cxxmidi #elif __APPLE__ // Mac OS X diff --git a/include/cxxmidi/output/windows.hpp b/include/cxxmidi/output/windows.hpp index cce9a26..871d905 100644 --- a/include/cxxmidi/output/windows.hpp +++ b/include/cxxmidi/output/windows.hpp @@ -40,10 +40,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include +#pragma comment(lib, "winmm.lib") + namespace cxxmidi { namespace output { -class Windows : public Output::Abstract { +class Windows : public output::Abstract { static const int RT_SYSEX_BUFFER_SIZE = 1024; static const int RT_SYSEX_BUFFER_COUNT = 4; @@ -83,7 +85,7 @@ class Windows : public Output::Abstract { } // namespace cxxmidi namespace cxxmidi { -namespace Output { +namespace output { Windows::Windows() { Initialize(); } @@ -141,7 +143,7 @@ void Windows::Initialize() { } void Windows::OpenPort(unsigned int portNumber_) { - if (_connected) { + if (connected_) { #ifndef CXXMIDI_QUIET std::cerr << "CxxMidi: a valid connection already exists" << std::endl; #endif @@ -164,15 +166,15 @@ void Windows::OpenPort(unsigned int portNumber_) { std::cerr << "CxxMidi: Windows MM output port init error" << std::endl; #endif - _connected = true; + connected_ = true; } void Windows::ClosePort() { - if (_connected) { + if (connected_) { WinMidiData *data = static_cast(api_data_); midiOutReset(data->outHandle); midiOutClose(data->outHandle); - _connected = false; + connected_ = false; } } @@ -262,7 +264,7 @@ void Windows::SendMessage(const std::vector *msg_) { } } -} // namespace Output +} // namespace output } // namespace cxxmidi #endif // INCLUDE_CXXMIDI_OUTPUT_WINDOWS_HPP_ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 631281f..c618825 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -11,7 +11,11 @@ add_executable(tests other.cpp player_base.cpp) -target_compile_options(tests PRIVATE -Wall -pedantic -Wextra) +if(MSVC) + target_compile_options(tests PRIVATE /W4) +else() + target_compile_options(tests PRIVATE -Wall -pedantic -Wextra) +endif() target_compile_features(tests PRIVATE cxx_std_17) target_link_libraries(tests diff --git a/tests/file.cpp b/tests/file.cpp index b75dceb..f75f455 100644 --- a/tests/file.cpp +++ b/tests/file.cpp @@ -22,6 +22,8 @@ SOFTWARE. #include +#include + #include #include