Skip to content

Commit

Permalink
Update ci.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
5tan committed Aug 5, 2024
1 parent fd7db8c commit 85e4278
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 50 deletions.
26 changes: 9 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ jobs:
extra_check:
- ''
include:

- os: windows-latest
compiler: msvc
generator_flag: '-G "Visual Studio 17 2022"'
Expand Down Expand Up @@ -63,27 +62,20 @@ jobs:
if: matrix.os == 'macos-latest'
run: brew install googletest qt6 ninja

- name: Install Qt6 (windows, msvc)
if: matrix.os == 'windows-latest' && matrix.compiler == 'msvc'
- name: Install Qt6 (windows)
if: matrix.os == 'windows-latest'
uses: jurplel/install-qt-action@v4
with:
aqtversion: '==3.1.*'
version: '6.7.1'
host: 'windows'
target: 'desktop'
arch: 'win64_msvc2019_64'
#dir: '${{ github.workspace }}/build/qt6/'
arch: ${{ matrix.compiler == 'msvc' && 'win64_msvc2019_64' || matrix.compiler == 'g++' && 'win64_mingw' }}

- name: Install Qt6 (windows, MinGW)
if: matrix.os == 'windows-latest' && matrix.compiler == 'g++'
uses: jurplel/install-qt-action@v4
- name: Install googletest
uses: cvpkg/[email protected]
with:
aqtversion: '==3.1.*'
version: '6.7.1'
host: 'windows'
target: 'desktop'
arch: 'win64_mingw'
#dir: '${{ github.workspace }}/build/qt6/'
googletest_tag: 'release-1.11.0'

- name: Install clang (linux)
if: matrix.os == 'ubuntu-latest' && matrix.compiler == 'clang++'
Expand All @@ -106,13 +98,13 @@ jobs:
run: sudo apt-get install -y iwyu

- name: Configure CMake
run: cmake -Bbuild . -DCMAKE_CXX_COMPILER="${{matrix.compiler}}" ${{matrix.extra_check_flag}}
run: cmake -Bbuild ${{matrix.generator_flag}}. -DCMAKE_CXX_COMPILER="${{matrix.compiler}}" ${{matrix.extra_check_flag}}

- name: Build
run: cmake --build build

- name: Test
if: matrix.extra_check == '' # && matrix.os != 'windows-latest'
if: matrix.extra_check == '' && matrix.os != 'windows-latest'
run: ctest --test-dir build

# for some reason ctest doesn't work on windows. Execute tests directly:
Expand All @@ -121,4 +113,4 @@ jobs:
# run: ${{ github.workspace }}\build\tests\Debug\tests.exe
# - name: Test (windows, MinGW)
# if: matrix.os == 'windows-latest' && matrix.compiler == 'g++'
# run: ${{ github.workspace }}\build\tests\tests.exe
# run: D:\a\cxxmidi\cxxmidi\build\tests\tests.exe
32 changes: 17 additions & 15 deletions include/cxxmidi/guts/player_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,21 +134,23 @@ PlayerBase::PlayerBase(output::Abstract* output)
}

void PlayerBase::SetupWindowsTimers() {
#ifdef WIN32
static bool once = true;
if (once) {
TIMECAPS tc;
UINT wTimerRes;

if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) == TIMERR_NOERROR) {
wTimerRes =
min(max(tc.wPeriodMin, 1u /* [ms] */), tc.wPeriodMax);
timeBeginPeriod(wTimerRes);
}

once = false;
}
#endif
// #ifdef WIN32
// static bool once = true;
// #ifdef __GNUC__
// using namespace std; // for min/max
// #endif
// if (once) {
// TIMECAPS tc;
// UINT wTimerRes;

// if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) == TIMERR_NOERROR) {
// wTimerRes = min(max(tc.wPeriodMin, 1u /* [ms] */), tc.wPeriodMax);
// timeBeginPeriod(wTimerRes);
// }

// once = false;
// }
// #endif
}

void PlayerBase::SetFile(const File* file) {
Expand Down
3 changes: 1 addition & 2 deletions include/cxxmidi/output/windows/winmm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef INCLUDE_CXXMIDI_OUTPUT_WINDOWS_WINMM_HPP_
#define INCLUDE_CXXMIDI_OUTPUT_WINDOWS_WINMM_HPP_

#include <windows.h>
//
#include <mmsystem.h>
#include <windows.h>

#include <cstdint>
#include <cxxmidi/output/abstract.hpp>
Expand Down
42 changes: 26 additions & 16 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
set(THIS_TARGET "tests")

find_package(Threads REQUIRED)
find_package(GTest QUIET)

if(NOT GTest_FOUND)
# https://google.github.io/googletest/quickstart-cmake.html
cmake_policy(SET CMP0135 NEW)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
find_package(GTest REQUIRED)

# find_package(GTest QUIET)

# if(NOT GTest_FOUND)
# # https://google.github.io/googletest/quickstart-cmake.html
# cmake_policy(SET CMP0135 NEW)
# include(FetchContent)
# FetchContent_Declare(
# googletest
# URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
# )
# # For Windows: Prevent overriding the parent project's compiler/linker settings
# set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# FetchContent_MakeAvailable(googletest)
# endif()


if(DEFINED ENV{GITHUB_ACTIONS} AND DEFINED ENV{GITHUB_WORKSPACE})
set(ARTIFACTS_DIR "$ENV{GITHUB_WORKSPACE}/artifacts")
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(GTest_DIR "${ARTIFACTS_DIR}/googletest/$ENV{googletest_tag}/windows-x64/lib/cmake/GTest")
endif()
endif()

add_executable(${THIS_TARGET}
Expand All @@ -38,9 +48,9 @@ target_link_libraries(${THIS_TARGET}
GTest::gtest_main
Threads::Threads)

if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows" OR CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
target_link_libraries(${THIS_TARGET} winmm)
endif()
# if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows" OR CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
# target_link_libraries(${THIS_TARGET} winmm)
# endif()

include(GoogleTest)
gtest_discover_tests(${THIS_TARGET} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} DISCOVERY_MODE PRE_TEST)
3 changes: 3 additions & 0 deletions tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ SOFTWARE.

#include <gtest/gtest.h>

#include <iostream>

int main(int argc, char **argv) {
std::cout << "gtest init..." << std::endl;
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}

0 comments on commit 85e4278

Please sign in to comment.