diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 72b784a..7a805db 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -1,79 +1,73 @@ -# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. -# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml -name: CMake on multiple platforms +name: Vcpkg CI -on:: [push] +on: [push] jobs: build: - runs-on: ${{ matrix.os }} - strategy: - # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. fail-fast: false - - # Set up a matrix to run the following 3 configurations: - # 1. - # 2. - # 3. - # - # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. matrix: - os: [ubuntu-latest, windows-latest] - build_type: [Release] - c_compiler: [gcc, clang, cl] - include: - - os: windows-latest - c_compiler: cl - cpp_compiler: cl - - os: ubuntu-latest - c_compiler: gcc - cpp_compiler: g++ - - os: ubuntu-latest - c_compiler: clang - cpp_compiler: clang++ - exclude: - - os: windows-latest - c_compiler: gcc - - os: windows-latest - c_compiler: clang - - os: ubuntu-latest - c_compiler: cl + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + + - name: Cache vcpkg + uses: actions/cache@v4 + with: + path: | + ${{github.workspace}}/vcpkg + !${{github.workspace}}/vcpkg/buildtrees + !${{github.workspace}}/vcpkg/packages + !${{github.workspace}}/vcpkg/downloads + ${{ github.workspace }}/build/bin/Db*.solutions + key: ${{ runner.os }}-vcpkg-${{ hashFiles('**/vcpkg.json') }} + restore-keys: | + ${{ runner.os }}-vcpkg- - - name: Set reusable strings - # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. - id: strings - shell: bash + - name: Install dependencies (Ubuntu) + if: runner.os == 'Linux' run: | - echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + sudo apt-get update + sudo apt-get install -y build-essential cmake ninja-build autoconf automake autoconf-archive + cmake --version + ninja --version + gcc --version + g++ --version - - name: Configure CMake - # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. - # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type - run: > - cmake -B ${{ steps.strings.outputs.build-output-dir }} - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -S ${{ github.workspace }} + - name: Install dependencies (macOS) + if: runner.os == 'macOS' + env: + VCPKG_PYTHON3: $(which python3) + run: | + echo "VCPKG_PYTHON3=$VCPKG_PYTHON3" >> $GITHUB_ENV + brew update + brew install cmake ninja autoconf automake autoconf-archive + cmake --version + ninja --version + clang --version + + - name: Install dependencies (Windows) + if: runner.os == 'Windows' + uses: microsoft/setup-msbuild@v2 - - name: Build prerequisites - run: > - cmake --build ${{ steps.strings.outputs.build-output-dir }} --config Release --target prerequisites + - name: Setup MSVC + if: runner.os == 'Windows' + uses: ilammy/msvc-dev-cmd@v1 - - name: Re-Configure CMake to detect built prerequisites - run: > - cmake -B ${{ steps.strings.outputs.build-output-dir }} + - name: Setup vcpkg + uses: lukka/run-vcpkg@v11 + with: + vcpkgGitCommitId: '3508985146f1b1d248c67ead13f8f54be5b4f5da' + vcpkgJsonGlob: '**/vcpkg.json' + + - name: Configure CMake + run: cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake || cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake - name: Build - # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). - run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + run: cmake --build ${{github.workspace}}/build - - name: Test - working-directory: ${{ steps.strings.outputs.build-output-dir }} - # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest --build-config ${{ matrix.build_type }} + - name: Get number of CPU cores + uses: SimenB/github-actions-cpu-cores@v2 + id: cpu-cores diff --git a/libgen/CMakeLists.txt b/libgen/CMakeLists.txt index 2e3b55c..3192891 100644 --- a/libgen/CMakeLists.txt +++ b/libgen/CMakeLists.txt @@ -10,10 +10,12 @@ set(deplist Boost::filesystem Boost::program_options Boost::serialization - - libjpeg-turbo/libjpeg-turbo - libjpeg-turbo::turbojpeg-static ) +if(NOT OPENMIND_USE_VCPKG) + set(deplist ${deplist} + libjpeg-turbo/libjpeg-turbo + libjpeg-turbo::turbojpeg-static) +endif() if(NOT PNG_FOUND) find_package(PNG) @@ -37,3 +39,10 @@ else() endif() lib(${deplist}) + +if(OPENMIND_USE_VCPKG) + find_package(libjpeg-turbo CONFIG REQUIRED) + target_link_libraries(${this_target} PUBLIC + $,libjpeg-turbo::turbojpeg-static,libjpeg-turbo::turbojpeg> + ) +endif() diff --git a/vcpkg.json b/vcpkg.json index 9547379..bd5a492 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -22,7 +22,9 @@ "boost-thread", "boost-uuid", "leveldb", + "libjpeg-turbo", "libpng", + "opencl", "zlib", { "name": "vcpkg-cmake",