From 8868b7f69658ee2a21c47b2f8dc078245185c9ea Mon Sep 17 00:00:00 2001 From: 5tan <5tan@users.noreply.github.com> Date: Sun, 4 Aug 2024 08:09:26 +0200 Subject: [PATCH] Update ci.yml --- .github/workflows/ci.yml | 32 ++++++++---------- examples/CMakeLists.txt | 2 +- include/cxxmidi/guts/player_base.hpp | 32 +++++++++--------- include/cxxmidi/output/windows/winmm.hpp | 3 +- tests/CMakeLists.txt | 41 ++++++++++++++---------- tests/main.cpp | 3 ++ 6 files changed, 60 insertions(+), 53 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c669035..f43791b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,6 @@ jobs: extra_check: - '' include: - - os: windows-latest compiler: msvc generator_flag: '-G "Visual Studio 17 2022"' @@ -63,27 +62,24 @@ 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' - 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/' + - name: Build Google Test + if: matrix.os == 'windows-latest' + run: | + curl -LO https://github.com/google/googletest/releases/download/v1.15.2/googletest-1.15.2.tar.gz + tar -xf googletest-1.15.2.tar.gz + cd googletest-1.15.2 + cmake -Bbuild ${{matrix.generator_flag}} . -DCMAKE_CXX_COMPILER="${{matrix.compiler}}" + cmake --build build --target install - - name: Install Qt6 (windows, MinGW) - if: matrix.os == 'windows-latest' && matrix.compiler == 'g++' + - 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_mingw' - #dir: '${{ github.workspace }}/build/qt6/' + arch: ${{ matrix.compiler == 'msvc' && 'win64_msvc2019_64' || matrix.compiler == 'g++' && 'win64_mingw' }} - name: Install clang (linux) if: matrix.os == 'ubuntu-latest' && matrix.compiler == 'clang++' @@ -106,13 +102,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: @@ -121,4 +117,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 \ No newline at end of file + # run: D:\a\cxxmidi\cxxmidi\build\tests\tests.exe \ No newline at end of file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d3b800a..f38fd50 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,5 +1,5 @@ add_subdirectory(callbacks) -# add_subdirectory(qtmidieditor) +add_subdirectory(qtmidieditor) # add_subdirectory(qtmidiplayer) # add_subdirectory(player_async) # add_subdirectory(player_sync) diff --git a/include/cxxmidi/guts/player_base.hpp b/include/cxxmidi/guts/player_base.hpp index 9cc476b..fad4763 100644 --- a/include/cxxmidi/guts/player_base.hpp +++ b/include/cxxmidi/guts/player_base.hpp @@ -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) { diff --git a/include/cxxmidi/output/windows/winmm.hpp b/include/cxxmidi/output/windows/winmm.hpp index 8ac6528..a2aa9a8 100644 --- a/include/cxxmidi/output/windows/winmm.hpp +++ b/include/cxxmidi/output/windows/winmm.hpp @@ -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 -// #include +#include #include #include diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1d0baa6..b8187de 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,20 +1,27 @@ set(THIS_TARGET "tests") +set(GTest_DIR "C:/Program Files (x86)/googletest-distribution/") +set(GTEST_INCLUDE_DIR "D:\\a\\cxxmidi\\cxxmidi\\googletest-1.15.2\\googletest\\include") +set(GTEST_LIBRARY "C:/Program Files (x86)/googletest-distribution/lib/libgtest.a") +set(GTEST_MAIN_LIBRARY "C:/Program Files (x86)/googletest-distribution/libgtest_main.a") + 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) -endif() +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() add_executable(${THIS_TARGET} endianness.cpp @@ -38,9 +45,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) \ No newline at end of file diff --git a/tests/main.cpp b/tests/main.cpp index 51182fa..a67791f 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -22,7 +22,10 @@ SOFTWARE. #include +#include + int main(int argc, char **argv) { + std::cout << "gtest init..." << std::endl; ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }