Skip to content

Commit

Permalink
Added windows CI
Browse files Browse the repository at this point in the history
  • Loading branch information
5tan committed Aug 1, 2024
1 parent 600a35c commit b5210e3
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 18 deletions.
27 changes: 25 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
run: ctest
6 changes: 5 additions & 1 deletion examples/callbacks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 5 additions & 1 deletion examples/player_async/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 5 additions & 1 deletion examples/player_sync/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
6 changes: 5 additions & 1 deletion examples/qtmidieditor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 5 additions & 1 deletion examples/qtmidiplayer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 6 additions & 2 deletions examples/sequencing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -25,4 +29,4 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
target_link_libraries(sequencing ${ALSA_LIBRARIES})
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
# todo
endif()
endif()
2 changes: 1 addition & 1 deletion include/cxxmidi/output/default.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SOFTWARE.
#include <cxxmidi/output/windows.hpp>
namespace cxxmidi {
namespace output {
typedef output::windows Default;
typedef output::Windows Default;
} // namespace output
} // namespace cxxmidi
#elif __APPLE__ // Mac OS X
Expand Down
16 changes: 9 additions & 7 deletions include/cxxmidi/output/windows.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#include <cxxmidi/output/abstract.hpp>

#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;

Expand Down Expand Up @@ -83,7 +85,7 @@ class Windows : public Output::Abstract {
} // namespace cxxmidi

namespace cxxmidi {
namespace Output {
namespace output {

Windows::Windows() { Initialize(); }

Expand Down Expand Up @@ -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
Expand All @@ -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<WinMidiData *>(api_data_);
midiOutReset(data->outHandle);
midiOutClose(data->outHandle);
_connected = false;
connected_ = false;
}
}

Expand Down Expand Up @@ -262,7 +264,7 @@ void Windows::SendMessage(const std::vector<uint8_t> *msg_) {
}
}

} // namespace Output
} // namespace output
} // namespace cxxmidi

#endif // INCLUDE_CXXMIDI_OUTPUT_WINDOWS_HPP_
6 changes: 5 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ SOFTWARE.

#include <gtest/gtest.h>

#include <array>

#include <cxxmidi/file.hpp>
#include <cxxmidi/note.hpp>

Expand Down

0 comments on commit b5210e3

Please sign in to comment.