Use VCPKG in the Github Action (fix)

This commit is contained in:
Corentin Jabot 2021-06-01 13:57:09 +02:00 committed by cor3ntin
parent f56aea4af1
commit 628f01b276
4 changed files with 25 additions and 16 deletions

View File

@ -1,8 +1,13 @@
name: CMake
env:
VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite'
on:
push:
branches: [ main ]
branches:
- '*'
workflow_dispatch:
@ -10,8 +15,6 @@ jobs:
build:
name: "${{ matrix.configurations.name }} | ${{ matrix.cmake-build-type }}"
runs-on: ${{ matrix.configurations.os }}
env:
CONAN_SYSREQUIRES_MODE: enabled
strategy:
fail-fast: false
matrix:
@ -37,20 +40,18 @@ jobs:
if: matrix.configurations.os == 'ubuntu-20.04' || matrix.configurations.os == 'ubuntu-18.04'
run: sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)"
- name: Bootstrap VCPKG
if: matrix.configurations.os == 'ubuntu-20.04' || matrix.configurations.os == 'ubuntu-18.04'
run: $GITHUB_WORKSPACE/vcpkg/bootstrap-vcpkg.sh
- name: Bootstrap VCPKG
if: matrix.configurations.os == 'windows-2019'
run: $GITHUB_WORKSPACE\\bootstrap-vcpkg.bat
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{runner.workspace}}/build
- name: Configure CMake
working-directory: $GITHUB_WORKSPACE
working-directory: ${{runner.workspace}}/build
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
run: cmake -B ${{runner.workspace}}/build -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }}
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }}
- name: Build
working-directory: ${{runner.workspace}}/build

View File

@ -3,6 +3,7 @@ set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/
CACHE STRING "Vcpkg toolchain file")
cmake_minimum_required(VERSION 3.17)
enable_language(CXX)
project(modern_cpp_exercises )
set(CMAKE_CXX_STANDARD 20)
@ -10,6 +11,3 @@ set(CMAKE_CXX_STANDARD 20)
add_subdirectory(lib)
add_subdirectory(src)
add_subdirectory(test)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/assets/maze.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/assets/sprites32.png DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/bin)

View File

@ -1,12 +1,22 @@
file(GLOB_RECURSE sources CONFIGURE_DEPENDS "*.cpp")
add_executable(pacman ${sources})
target_link_libraries(pacman libpacman)
target_link_libraries(pacman PUBLIC libpacman)
if(MSVC)
find_package(sdl2 CONFIG REQUIRED)
target_link_libraries(pacman PUBLIC SDL2::SDL2main)
endif()
set_target_properties(pacman
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
add_custom_command(TARGET pacman POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${PROJECT_SOURCE_DIR}/assets/maze.png
${PROJECT_SOURCE_DIR}/assets/sprites32.png
$<TARGET_FILE_DIR:pacman>)
#target_compile_options(pacman PRIVATE -fsanitize=address) # /MD will be used implicitly
#target_link_directories(pacman PRIVATE "$ENV{ProgramFiles\(x86\)}/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/x64/lib/clang/10.0.0/lib/windows")

View File

@ -1,6 +1,6 @@
#include "Game.hpp"
extern "C" int main([[maybe_unused]] int argc, [[maybe_unused]] char * argv[]) {
int main(int, char**) {
Game game;
game.run();
return 0;