diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8b63ece..61f0731 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,14 @@ on: pull_request: branches: [ master ] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + pull-requests: write + # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: Windows: @@ -24,13 +32,12 @@ jobs: steps: - name: "Set Build Type" id: build_type + shell: pwsh run: | if ("${{ github.ref }}".StartsWith("refs/tags/")) { - echo "BUILD_TYPE::Release"; - echo "::set-output name=BUILD_TYPE::Release"; + echo "BUILD_TYPE=Release" >> $env:GITHUB_OUTPUT } else { - echo "BUILD_TYPE::Debug"; - echo "::set-output name=BUILD_TYPE::Debug"; + echo "BUILD_TYPE=Debug" >> $env:GITHUB_OUTPUT } if ("${{ matrix.arch }}" -eq "x64") { @@ -50,7 +57,7 @@ jobs: # uses: ammaraskar/msvc-problem-matcher@master # Install latest CMake - - uses: lukka/get-cmake@latest + - uses: lukka/get-cmake@v3.31.6 # Restore from cache the previously built ports - name: Restore artifacts, or setup vcpkg @@ -66,6 +73,7 @@ jobs: - name: 'Run CMake' uses: lukka/run-cmake@v10 + continue-on-error: false with: configurePreset: 'windows-msvc-vs17' buildPreset: ${{ startsWith(github.ref, 'refs/tags/') && 'windows-msvc-vs17-release' || 'windows-msvc-vs17' }} @@ -108,23 +116,21 @@ jobs: working-directory: "${{ github.workspace }}/../../_temp/windows/" - name: Release if: startsWith(github.ref, 'refs/tags/') - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: draft: true - files: "D:/a/_temp/windows/libsimple-windows-${{ matrix.arch }}.zip" - # files: "${{ github.workspace }}/../../_temp/windows/libsimple-windows-${{ matrix.arch }}.zip" + files: "${{ github.workspace }}/../../_temp/windows/libsimple-windows-${{ matrix.arch }}.zip" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BUILD_TYPE: ${{ github.ref_type == 'tag' && 'Release' || 'Debug' }} Linux: runs-on: ${{ matrix.os }} strategy: fail-fast: true matrix: - include: - - os: ubuntu-20.04 - - os: ubuntu-22.04-arm - - os: ubuntu-latest + os: [ubuntu-20.04, ubuntu-22.04-arm, ubuntu-latest] + timeout-minutes: 60 steps: - name: "Release Build Type" if: startsWith(github.ref, 'refs/tags/') @@ -167,7 +173,7 @@ jobs: - name: 'Run CMake' uses: lukka/run-cmake@v10 - if: startsWith(github.ref, 'refs/tags/') != true + continue-on-error: false with: configurePreset: 'ninja-vcpkg-coverage' buildPreset: 'ninja-vcpkg-coverage' @@ -243,7 +249,7 @@ jobs: working-directory: "${{ github.workspace }}/build" - name: Release without changelog if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.os != 'ubuntu-latest' }} - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: draft: true files: ${{ github.workspace }}/build/libsimple-linux-${{ matrix.os }}.zip @@ -259,6 +265,13 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Build Summary + if: always() + run: | + echo "## Build Summary" >> $GITHUB_STEP_SUMMARY + echo "- Build Type: ${{ env.BUILD_TYPE }}" >> $GITHUB_STEP_SUMMARY + echo "- OS: ${{ runner.os }}" >> $GITHUB_STEP_SUMMARY + MacOS: runs-on: macos-latest needs: Linux @@ -348,4 +361,5 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: build-iOS + if: success() run: ./build-ios.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index bb6430e..3fdf35f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,8 +34,8 @@ if(BUILD_SQLITE3) set(SQLITE_INSTALL_DIR ${SQLITE_ROOT}) set(SQLITE_INCLUDE_DIR ${SQLITE_INSTALL_DIR}/include) set(SQLITE_LIB_DIR ${SQLITE_INSTALL_DIR}/lib) - if (NOT IOS) - option(SQLITE_ENABLE_FTS5 "enables full text searches version 5" ON) + if (MSVC OR (UNIX AND NOT IOS)) + option(SQLITE_ENABLE_FTS5 "enables full text searches version 5" ON) option(BUILD_SHELL "build SQLite3 shell application" ON) add_subdirectory(contrib/sqlite3) endif() diff --git a/CMakePresets.json b/CMakePresets.json index 4501372..1ffae37 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -65,6 +65,10 @@ "CMAKE_INSTALL_PREFIX": { "type": "PATH", "value": "${sourceDir}/../../_temp/macos/install" + }, + "BUILD_SHELL": { + "type": "BOOL", + "value": "OFF" } } }, @@ -81,9 +85,21 @@ "type": "FILEPATH", "value": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake" }, + "BUILD_SHELL": { + "type": "BOOL", + "value": "OFF" + }, "BUILD_TESTING": { "type": "BOOL", "value": "OFF" + }, + "BUILD_SQLITE3": { + "type": "BOOL", + "value": "ON" + }, + "SQLITE_ENABLE_FTS5": { + "type": "BOOL", + "value": "ON" } }, "condition": { diff --git a/contrib/CMakeRC.cmake b/contrib/CMakeRC.cmake index 5cad705..1a6c3b8 100644 --- a/contrib/CMakeRC.cmake +++ b/contrib/CMakeRC.cmake @@ -34,7 +34,7 @@ endif() set(_version 2.0.0) -cmake_minimum_required(VERSION 3.3) +cmake_minimum_required(VERSION 3.19) include(CMakeParseArguments) if(COMMAND cmrc_add_resource_library) diff --git a/contrib/ios.toolchain.cmake b/contrib/ios.toolchain.cmake index edf5a10..0fbd671 100644 --- a/contrib/ios.toolchain.cmake +++ b/contrib/ios.toolchain.cmake @@ -129,7 +129,7 @@ # command. # -cmake_minimum_required(VERSION 3.8.0) +cmake_minimum_required(VERSION 3.19) # CMake invokes the toolchain file twice during the first build, but only once during subsequent rebuilds. if(IOS_TOOLCHAIN_HAS_RUN) diff --git a/contrib/sqlite3/CMakeLists.txt b/contrib/sqlite3/CMakeLists.txt index 0a16bf4..8edef82 100644 --- a/contrib/sqlite3/CMakeLists.txt +++ b/contrib/sqlite3/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.19) project(SQLite3 VERSION 3.31.1 LANGUAGES C diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt index 34e780f..d0301ec 100644 --- a/examples/cpp/CMakeLists.txt +++ b/examples/cpp/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.19) project(simple_cpp_example) include_directories(${SQLITE3_HEADERS_DIR}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0c23eee..bfc3ab3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.19) project(simple CXX) if(SIMPLE_WITH_JIEBA) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e3e1e82..1f52d2b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.19) project(simple_tests) # https://github.com/maps-gpu/MAPS/issues/7#issuecomment-418200278 @@ -8,13 +8,20 @@ cmake_policy(SET CMP0057 NEW) set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/src) # Download and unpack googletest at configure time +set(GTEST_CMAKE_ARGS + "-DCMAKE_POLICY_DEFAULT_CMP0048=NEW" +) configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) -execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" ${GTEST_CMAKE_ARGS} . RESULT_VARIABLE result WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) if(result) message(FATAL_ERROR "CMake step for googletest failed: ${result}") endif() + +# Set policy version minimum before adding googletest +set(CMAKE_POLICY_VERSION_MINIMUM "3.5" CACHE STRING "Minimum CMake policy version" FORCE) + execute_process(COMMAND ${CMAKE_COMMAND} --build . RESULT_VARIABLE result WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download ) @@ -32,13 +39,6 @@ add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src ${CMAKE_CURRENT_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL) -# The gtest/gtest_main targets carry header search path -# dependencies automatically when using CMake 2.8.11 or -# later. Otherwise we have to add them here ourselves. -if (CMAKE_VERSION VERSION_LESS 2.8.11) - include_directories("${gtest_SOURCE_DIR}/include") -endif() - include_directories(${SIMPLE_HEADERS_DIR}) include_directories(${SQLITE3_HEADERS_DIR}) set(SOURCE_FILES main.cpp pinyin_test.cc tokenizer_test.cc) diff --git a/test/CMakeLists.txt.in b/test/CMakeLists.txt.in index ad17f66..ab7d9df 100644 --- a/test/CMakeLists.txt.in +++ b/test/CMakeLists.txt.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.19) cmake_policy(SET CMP0057 NEW) project(googletest-download NONE)