diff --git a/.github/actions/install_sfml/action.yml b/.github/actions/install_sfml/action.yml new file mode 100644 index 0000000..5a9f90d --- /dev/null +++ b/.github/actions/install_sfml/action.yml @@ -0,0 +1,98 @@ +name: "Setup SFML" +description: "Setup SFML" +inputs: + sfml_version: + description: "SFML version" + required: true + used_env: + description: "Environment used with runs-on" + required: true +outputs: + sfml_install_dir: + description: "SFML install path" + value: ${{steps.configure.outputs.sfml_install_dir}} +runs: + using: "composite" + steps: + - name: Install SFML dependencies + shell: cmake -P {0} + run: | + if ("${{ runner.os }}" STREQUAL "Linux") + execute_process(COMMAND sudo apt-get update) + execute_process( + COMMAND sudo apt-get -y install mesa-common-dev libx11-dev libxcursor-dev libsfml-dev libudev-dev libopenal-dev libvorbis-dev libflac-dev libxrandr-dev freeglut3-dev libjpeg-dev libfreetype6-dev libxrandr-dev libglew-dev libsndfile1-dev libopenal-dev libfreetype6-dev + ) + endif() + + - name: Cache SFML install + id: cache + uses: actions/cache@v2 + with: + path: ${{github.workspace}}/SFML + key: SFML-${{inputs.sfml_version}}-${{inputs.used_env}} + + - name: Checkout SFML + if: ${{steps.cache.outputs.cache-hit != 'true'}} + uses: actions/checkout@v2 + with: + repository: SFML/SFML + submodules: recursive + path: SFML_repo + ref: ${{inputs.sfml_version}} + + - name: Install SFML + id: install + if: ${{steps.cache.outputs.cache-hit != 'true'}} + shell: cmake -P {0} + run: | + file(TO_CMAKE_PATH [=[${{github.workspace}}]=] workspace) + message(STATUS "Using host CMake version: ${CMAKE_VERSION}") + message(STATUS "Build SFML") + execute_process( + COMMAND ${CMAKE_COMMAND} + -S "${workspace}/SFML_repo" + -B "${workspace}/SFML_repo/build" + -D CMAKE_CONFIGURATION_TYPES=Release + -D CMAKE_BUILD_TYPE=Release + -D ENABLE_TESTING=OFF + -D SFML_BUILD_EXAMPLES=OFF + -D SFML_BUILD_DOC=OFF + -D SFML_BUILD_FRAMEWORKS=OFF + -D SFML_INSTALL_XCODE_TEMPLATES=OFF + -D SFML_DEPENDENCIES_INSTALL_PREFIX=${workspace}/SFML + -D CMAKE_INSTALL_PREFIX=${workspace}/SFML + -D CMAKE_INSTALL_FRAMEWORK_PREFIX=${workspace}/SFML + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "project configuration failed") + endif() + include(ProcessorCount) + ProcessorCount(N) + execute_process( + COMMAND ${CMAKE_COMMAND} + --build "${workspace}/SFML_repo/build" + --config Release + --parallel ${N} + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "project build failed") + endif() + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${workspace}/SFML") + execute_process( + COMMAND ${CMAKE_COMMAND} + --install "${workspace}/SFML_repo/build" + --prefix "${workspace}/SFML" + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "project installation failed") + endif() + + - name: Configure SFML + id: configure + shell: cmake -P {0} + run: | + file(TO_CMAKE_PATH [=[${{github.workspace}}]=] workspace) + message("::set-output name=sfml_install_dir::${workspace}/SFML") diff --git a/.github/actions/setup_ccache/action.yml b/.github/actions/setup_ccache/action.yml new file mode 100644 index 0000000..10e9f67 --- /dev/null +++ b/.github/actions/setup_ccache/action.yml @@ -0,0 +1,111 @@ +name: "Setup ccache" +description: "Setup ccache" +inputs: + ccache_version: + description: "ccache version" + required: true + used_env: + description: "Environment used with runs-on" + required: true + cache_id: + description: "Cache id unique to the current config" + required: true +outputs: + ccache_binary: + description: "ccache binary path" + value: ${{steps.configure.outputs.ccache_binary}} +runs: + using: "composite" + steps: + - name: Cache ccache + id: cache + uses: actions/cache@v2 + with: + path: ${{github.workspace}}/ccache + key: ccache-${{inputs.ccache_version}}-${{inputs.used_env}} + + - name: Download and install ccache + id: download + if: ${{steps.cache.outputs.cache-hit != 'true'}} + shell: cmake -P {0} + run: | + file(TO_CMAKE_PATH [=[${{github.workspace}}]=] workspace) + message(STATUS "Using host CMake version: ${CMAKE_VERSION}") + set(ccache_url "https://github.com/ccache/ccache/releases/download/v${{inputs.ccache_version}}/ccache-${{inputs.ccache_version}}.tar.gz") + message(STATUS "Download from: ${ccache_url}") + file(DOWNLOAD "${ccache_url}" "${workspace}/ccache.tar.gz" SHOW_PROGRESS) + message(STATUS "Extract") + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf "${workspace}/ccache.tar.gz") + message(STATUS "Build ccache") + execute_process( + COMMAND ${CMAKE_COMMAND} + -S "${workspace}/ccache-${{inputs.ccache_version}}" + -B "${workspace}/ccache-${{inputs.ccache_version}}/build" + -D CMAKE_CONFIGURATION_TYPES=Release + -D CMAKE_BUILD_TYPE=Release + -D ZSTD_FROM_INTERNET=ON + -D REDIS_STORAGE_BACKEND=OFF + -D ENABLE_TESTING=OFF + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "project configuration failed") + endif() + include(ProcessorCount) + ProcessorCount(N) + execute_process( + COMMAND ${CMAKE_COMMAND} + --build "${workspace}/ccache-${{inputs.ccache_version}}/build" + --target ccache + --config Release + --parallel ${N} + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "project build failed") + endif() + execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${workspace}/ccache") + execute_process( + COMMAND ${CMAKE_COMMAND} + --install "${workspace}/ccache-${{inputs.ccache_version}}/build" + --prefix "${workspace}/ccache" + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "project installation failed") + endif() + if(NOT "${{runner.os}}" STREQUAL "Windows") + execute_process(COMMAND chmod +x "${workspace}/ccache/bin/ccache") + endif() + + - name: Configure ccache + id: configure + shell: cmake -P {0} + run: | + file(TO_CMAKE_PATH [=[${{github.workspace}}]=] workspace) + file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_BASEDIR=${workspace}\n") + file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_DIR=${workspace}/.ccache\n") + file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_COMPRESS=true\n") + file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_COMPRESSLEVEL=6\n") + file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_MAXSIZE=400M\n") + set(ccache_binary "${workspace}/ccache/bin/ccache") + message(STATUS "ccache binary: ${ccache_binary}") + message("::set-output name=ccache_binary::${ccache_binary}") + execute_process(COMMAND ${ccache_binary} --zero-stats) + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + + - name: Print ccache config + id: print + shell: cmake -P {0} + run: | + execute_process(COMMAND ${{steps.configure.outputs.ccache_binary}} --version) + execute_process(COMMAND ${{steps.configure.outputs.ccache_binary}} --show-config) + + - name: Cache ccache files + uses: actions/cache@v2 + with: + path: ${{env.CCACHE_DIR}} + key: ccache-cache-${{inputs.cache_id}}-${{steps.configure.outputs.timestamp}} + restore-keys: | + ccache-cache-${{inputs.cache_id}}- diff --git a/.github/actions/setup_cmake/action.yml b/.github/actions/setup_cmake/action.yml new file mode 100644 index 0000000..3013573 --- /dev/null +++ b/.github/actions/setup_cmake/action.yml @@ -0,0 +1,88 @@ +name: "Setup CMake" +description: "Setup CMake" +inputs: + cmake_version: + description: "CMake version" + required: true + used_env: + description: "Environment used with runs-on" + required: true +outputs: + cmake_binary: + description: "CMake binary path" + value: ${{steps.configure.outputs.cmake_binary}} + ctest_binary: + description: "CTest binary path" + value: ${{steps.configure.outputs.ctest_binary}} +runs: + using: "composite" + steps: + - name: Cache CMake + id: cache + uses: actions/cache@v2 + with: + path: ${{github.workspace}}/cmake + key: cmake-${{inputs.cmake_version}}-${{inputs.used_env}} + + - name: Download CMake + id: download + if: ${{steps.cache.outputs.cache-hit != 'true'}} + shell: cmake -P {0} + run: | + file(TO_CMAKE_PATH [=[${{github.workspace}}]=] workspace) + message(STATUS "Using host CMake version: ${CMAKE_VERSION}") + if("${{runner.os}}" STREQUAL "Windows") + set(cmake_suffix "windows-x86_64.zip") + set(cmake_dir "cmake-${{inputs.cmake_version}}-windows-x86_64") + set(cmake_bin_dir "cmake-${{inputs.cmake_version}}-windows-x86_64/bin") + elseif("${{runner.os}}" STREQUAL "Linux") + set(cmake_suffix "linux-x86_64.tar.gz") + set(cmake_dir "cmake-${{inputs.cmake_version}}-linux-x86_64") + set(cmake_bin_dir "cmake-${{inputs.cmake_version}}-linux-x86_64/bin") + elseif("${{runner.os}}" STREQUAL "macOS") + set(cmake_suffix "macos-universal.tar.gz") + set(cmake_dir "cmake-${{inputs.cmake_version}}-macos-universal") + set(cmake_bin_dir "cmake-${{inputs.cmake_version}}-macos-universal/CMake.app/Contents/bin") + endif() + set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${{inputs.cmake_version}}/cmake-${{inputs.cmake_version}}-${cmake_suffix}") + message(STATUS "Download from: ${cmake_url}") + file(DOWNLOAD "${cmake_url}" "${workspace}/cmake.zip" SHOW_PROGRESS) + message(STATUS "Extract") + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf "${workspace}/cmake.zip") + file(COPY "${workspace}/${cmake_dir}" DESTINATION "${workspace}/cmake") + if(NOT "${{runner.os}}" STREQUAL "Windows") + execute_process(COMMAND chmod +x "${workspace}/cmake/${cmake_bin_dir}/cmake") + execute_process(COMMAND chmod +x "${workspace}/cmake/${cmake_bin_dir}/ctest") + endif() + + - name: Configure CMake + id: configure + shell: cmake -P {0} + run: | + file(TO_CMAKE_PATH [=[${{github.workspace}}]=] workspace) + if("${{runner.os}}" STREQUAL "Windows") + set(cmake_bin_dir "cmake-${{inputs.cmake_version}}-windows-x86_64/bin") + elseif("${{runner.os}}" STREQUAL "Linux") + set(cmake_bin_dir "cmake-${{inputs.cmake_version}}-linux-x86_64/bin") + elseif("${{runner.os}}" STREQUAL "macOS") + set(cmake_bin_dir "cmake-${{inputs.cmake_version}}-macos-universal/CMake.app/Contents/bin") + endif() + set(cmake_binary "${workspace}/cmake/${cmake_bin_dir}/cmake") + set(ctest_binary "${workspace}/cmake/${cmake_bin_dir}/ctest") + message(STATUS "CMake binary: ${cmake_binary}") + message("::set-output name=cmake_binary::${cmake_binary}") + message(STATUS "CTest binary: ${ctest_binary}") + message("::set-output name=ctest_binary::${ctest_binary}") + + - name: Print version + id: print + shell: cmake -P {0} + run: | + execute_process(COMMAND ${{steps.configure.outputs.cmake_binary}} --version RESULT_VARIABLE result) + if(NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + execute_process(COMMAND ${{steps.configure.outputs.ctest_binary}} --version RESULT_VARIABLE result) + if(NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 20b1147..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,318 +0,0 @@ -name: build - -on: - - push - - pull_request - -env: - CMAKE_VERSION: 3.19.7 - NINJA_VERSION: 1.10.2 - CCACHE_VERSION: 4.2.1 - -jobs: - build: - name: ${{ matrix.config.name }} - runs-on: ${{ matrix.config.os }} - strategy: - fail-fast: false - matrix: - config: - - { - name: "Windows Latest - MinGW - Debug", - os: windows-latest, - cc: "gcc", - cxx: "g++", - build_type: Debug - } - - { - name: "Windows Latest - MinGW - Release", - os: windows-latest, - cc: "gcc", - cxx: "g++", - build_type: Release - } - - { - name: "Ubuntu Latest - GCC - Debug", - os: ubuntu-latest, - cc: "gcc", - cxx: "g++", - build_type: Debug - } - - { - name: "Ubuntu Latest - GCC - Release", - os: ubuntu-latest, - cc: "gcc", - cxx: "g++", - build_type: Release - } - - { - name: "Ubuntu Latest - Clang - Debug", - os: ubuntu-latest, - cc: "clang", - cxx: "clang++", - build_type: Debug - } - - { - name: "Ubuntu Latest - Clang - Release", - os: ubuntu-latest, - cc: "clang", - cxx: "clang++", - build_type: Release - } - - { - name: "macOS Latest - GCC - Debug", - os: macos-latest, - cc: "gcc", - cxx: "g++", - build_type: Debug - } - - { - name: "macOS Latest - GCC - Release", - os: macos-latest, - cc: "gcc", - cxx: "g++", - build_type: Release - } - - { - name: "macOS Latest - Clang - Debug", - os: macos-latest, - cc: "clang", - cxx: "clang++", - build_type: Debug - } - - { - name: "macOS Latest - Clang - Release", - os: macos-latest, - cc: "clang", - cxx: "clang++", - build_type: Release - } - - steps: - - name: Checkout ImGui-SFML - uses: actions/checkout@v2 - with: - submodules: recursive - path: imgui-sfml - - # Container action is only supported on Linux - - name: Check Clang Format - if: runner.os == 'Linux' - uses: DoozyX/clang-format-lint-action@v0.11 - with: - source: '.' - extensions: 'h,cpp' - - - name: Checkout SFML - uses: actions/checkout@v2 - with: - repository: SFML/SFML - submodules: recursive - path: SFML - ref: 27a4c83ebc724a978e554e77f5f231b887e0bdd9 # This commit is close to 2.5.1 and fixes CMake install paths - - - name: Checkout Dear ImGui - uses: actions/checkout@v2 - with: - repository: ocornut/imgui - submodules: recursive - path: imgui - - - name: Download CMake - id: cmake - shell: cmake -P {0} - run: | - set(cmake_version $ENV{CMAKE_VERSION}) - message(STATUS "Using host CMake version: ${CMAKE_VERSION}") - if ("${{ runner.os }}" STREQUAL "Windows") - set(cmake_suffix "win64-x64.zip") - set(cmake_dir "cmake-${cmake_version}-win64-x64/bin") - elseif ("${{ runner.os }}" STREQUAL "Linux") - set(cmake_suffix "Linux-x86_64.tar.gz") - set(cmake_dir "cmake-${cmake_version}-Linux-x86_64/bin") - elseif ("${{ runner.os }}" STREQUAL "macOS") - set(cmake_suffix "macos-universal.tar.gz") - set(cmake_dir "cmake-${cmake_version}-macos-universal/CMake.app/Contents/bin") - endif() - set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}") - file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip) - file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}/cmake" cmake_binary) - if (NOT "${{ runner.os }}" STREQUAL "Windows") - execute_process(COMMAND chmod +x ${cmake_binary}) - endif() - message("::set-output name=cmake_binary::${cmake_binary}") - - - name: Download Ninja - id: ninja - shell: cmake -P {0} - run: | - set(ninja_version $ENV{NINJA_VERSION}) - message(STATUS "Using host CMake version: ${CMAKE_VERSION}") - if ("${{ runner.os }}" STREQUAL "Windows") - set(ninja_suffix "win.zip") - elseif ("${{ runner.os }}" STREQUAL "Linux") - set(ninja_suffix "linux.zip") - elseif ("${{ runner.os }}" STREQUAL "macOS") - set(ninja_suffix "mac.zip") - endif() - set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}") - file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip) - file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/ninja" ninja_binary) - if (NOT "${{ runner.os }}" STREQUAL "Windows") - execute_process(COMMAND chmod +x ${ninja_binary}) - endif() - message("::set-output name=ninja_binary::${ninja_binary}") - - - name: Download ccache - id: ccache - shell: cmake -P {0} - run: | - set(ccache_url "https://github.com/cristianadam/ccache/releases/download/v$ENV{CCACHE_VERSION}/${{ runner.os }}.tar.xz") - file(DOWNLOAD "${ccache_url}" ./ccache.tar.xz SHOW_PROGRESS) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ccache.tar.xz) - file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/ccache" ccache_binary) - if (NOT "${{ runner.os }}" STREQUAL "Windows") - execute_process(COMMAND chmod +x ${ccache_binary}) - endif() - message("::set-output name=ccache_binary::${ccache_binary}") - - - name: Configure ccache - id: configure_ccache - shell: cmake -P {0} - run: | - file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}" ccache_basedir) - file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_BASEDIR=${ccache_basedir}\n") - file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_DIR=${ccache_basedir}/.ccache\n") - file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_COMPRESS=true\n") - file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_COMPRESSLEVEL=6\n") - file(APPEND "$ENV{GITHUB_ENV}" "CCACHE_MAXSIZE=400M\n") - execute_process(COMMAND ${{ steps.ccache.outputs.ccache_binary }} -p) - execute_process(COMMAND ${{ steps.ccache.outputs.ccache_binary }} -z) - string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) - message("::set-output name=timestamp::${current_date}") - - - name: Cache ccache files - uses: actions/cache@v2 - with: - path: .ccache - key: ${{ matrix.config.name }}-ccache-${{ steps.configure_ccache.outputs.timestamp }} - restore-keys: | - ${{ matrix.config.name }}-ccache- - - - name: Prepare build environment - shell: cmake -P {0} - run: | - file(APPEND "$ENV{GITHUB_ENV}" "CC=${{ matrix.config.cc }}\n") - file(APPEND "$ENV{GITHUB_ENV}" "CXX=${{ matrix.config.cxx }}\n") - if ("${{ runner.os }}" STREQUAL "Linux") - execute_process(COMMAND sudo apt-get update) - execute_process( - COMMAND sudo apt-get -y install mesa-common-dev libx11-dev libxcursor-dev libsfml-dev libudev-dev libopenal-dev libvorbis-dev libflac-dev libxrandr-dev freeglut3-dev libjpeg-dev libfreetype6-dev libxrandr-dev libglew-dev libsndfile1-dev libopenal-dev libfreetype6-dev - ) - endif() - if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") - execute_process( - COMMAND "${{ matrix.config.environment_script }}" && set - OUTPUT_FILE environment_script_output.txt - ) - endif() - file(APPEND "$ENV{GITHUB_PATH}" "$ENV{GITHUB_WORKSPACE}\n") - - - name: Install SFML - id: install_sfml - shell: cmake -P {0} - run: | - if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") - file(STRINGS environment_script_output.txt output_lines) - foreach(line IN LISTS output_lines) - if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") - set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") - endif() - endforeach() - endif() - file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/sfml_install" sfml_install_dir) - execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${sfml_install_dir}) - execute_process( - COMMAND ${{ steps.cmake.outputs.cmake_binary }} - -S $ENV{GITHUB_WORKSPACE}/SFML - -B $ENV{GITHUB_WORKSPACE}/SFML/build - -D CMAKE_CONFIGURATION_TYPES=${{ matrix.config.build_type }} - -D CMAKE_BUILD_TYPE=${{ matrix.config.build_type }} - -G Ninja - -D CMAKE_MAKE_PROGRAM=${{ steps.ninja.outputs.ninja_binary }} - -D CMAKE_C_COMPILER_LAUNCHER=${{ steps.ccache.outputs.ccache_binary }} - -D CMAKE_CXX_COMPILER_LAUNCHER=${{ steps.ccache.outputs.ccache_binary }} - -D CMAKE_INSTALL_PREFIX=${sfml_install_dir} - RESULT_VARIABLE result - ) - if (NOT result EQUAL 0) - message(FATAL_ERROR "SFML configure: Bad exit status") - endif() - execute_process( - COMMAND ${{ steps.cmake.outputs.cmake_binary }} - --build $ENV{GITHUB_WORKSPACE}/SFML/build - --config ${BUILD_TYPE} - --target install - RESULT_VARIABLE result - ) - if (NOT result EQUAL 0) - message(FATAL_ERROR "SFML build: Bad exit status") - endif() - execute_process(COMMAND ${{ steps.ccache.outputs.ccache_binary }} -s) - message("::set-output name=sfml_install_dir::${sfml_install_dir}") - - - name: Configure - shell: cmake -P {0} - run: | - if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") - file(STRINGS environment_script_output.txt output_lines) - foreach(line IN LISTS output_lines) - if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") - set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") - endif() - endforeach() - endif() - execute_process( - COMMAND ${{ steps.cmake.outputs.cmake_binary }} - -S $ENV{GITHUB_WORKSPACE}/imgui-sfml - -B $ENV{GITHUB_WORKSPACE}/imgui-sfml/build - -D CMAKE_CONFIGURATION_TYPES=${{ matrix.config.build_type }} - -D CMAKE_CXX_STANDARD=11 - -D CMAKE_BUILD_TYPE=${{ matrix.config.build_type }} - -G Ninja - -D CMAKE_MAKE_PROGRAM=${{ steps.ninja.outputs.ninja_binary }} - -D CMAKE_C_COMPILER_LAUNCHER=${{ steps.ccache.outputs.ccache_binary }} - -D CMAKE_CXX_COMPILER_LAUNCHER=${{ steps.ccache.outputs.ccache_binary }} - -D CMAKE_PREFIX_PATH=${{ steps.install_sfml.outputs.sfml_install_dir }} - -D SFML_DIR=${{ steps.install_sfml.outputs.sfml_install_dir }} - -D IMGUI_DIR=$ENV{GITHUB_WORKSPACE}/imgui - -D BUILD_SHARED_LIBS=ON - RESULT_VARIABLE result - ) - if (NOT result EQUAL 0) - message(FATAL_ERROR "Bad exit status") - endif() - - - name: Build - shell: cmake -P {0} - run: | - if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x") - file(STRINGS environment_script_output.txt output_lines) - foreach(line IN LISTS output_lines) - if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$") - set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}") - endif() - endforeach() - endif() - execute_process( - COMMAND ${{ steps.cmake.outputs.cmake_binary }} - --build $ENV{GITHUB_WORKSPACE}/imgui-sfml/build - --config ${BUILD_TYPE} - RESULT_VARIABLE result - ) - if (NOT result EQUAL 0) - message(FATAL_ERROR "Build: Bad exit status") - endif() - execute_process(COMMAND ${{ steps.ccache.outputs.ccache_binary }} -s) diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml new file mode 100644 index 0000000..9d18fda --- /dev/null +++ b/.github/workflows/clang-format.yml @@ -0,0 +1,18 @@ +name: clang-format + +on: + - push + - pull_request + +jobs: + format-check: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: DoozyX/clang-format-lint-action@v0.13 + with: + source: '.' + extensions: 'h,cpp' + clangFormatVersion: 13 + style: file diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..f4ee567 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,113 @@ +name: macOS + +on: + - push + - pull_request + +env: + CMAKE_VERSION: 3.22.2 + SFML_VERSION: 2.5.1 + IMGUI_VERSION: 1.87 + +jobs: + build: + name: ${{matrix.config.os}} - Xcode ${{matrix.config.xcode}} - ${{matrix.build_type}} + runs-on: ${{matrix.config.os}} + strategy: + fail-fast: false + matrix: + config: [ + # {os: macos-10.15, xcode: 10.3}, + # {os: macos-10.15, xcode: 11.2.1}, + # {os: macos-10.15, xcode: 11.3.1}, + # {os: macos-10.15, xcode: 11.4.1}, + # {os: macos-10.15, xcode: 11.5}, + # {os: macos-10.15, xcode: 11.6}, + # {os: macos-10.15, xcode: 11.7}, + # {os: macos-10.15, xcode: 12.0.1}, + # {os: macos-10.15, xcode: 12.1}, + # {os: macos-10.15, xcode: 12.1.1}, + # {os: macos-10.15, xcode: 12.2}, + # {os: macos-10.15, xcode: 12.3}, + # {os: macos-10.15, xcode: 12.4}, + # {os: macos-11, xcode: 11.7}, + # {os: macos-11, xcode: 12.4}, + # {os: macos-11, xcode: 12.5.1}, + # {os: macos-11, xcode: 13.0}, + # {os: macos-11, xcode: 13.1}, + # {os: macos-11, xcode: 13.2}, + {os: macos-11, xcode: 13.2.1}, + ] + build_type: [Debug, Release] + + steps: + - name: Checkout ImGui-SFML + uses: actions/checkout@v2 + with: + submodules: recursive + path: imgui-sfml + + - name: Setup build environment + shell: cmake -P {0} + run: | + file(APPEND "$ENV{GITHUB_ENV}" "CMAKE_GENERATOR=Xcode\n") + file(APPEND "$ENV{GITHUB_ENV}" "DEVELOPER_DIR=/Applications/Xcode_${{matrix.config.xcode}}.app/Contents/Developer\n") + + - name: Setup CMake + id: cmake + uses: ./imgui-sfml/.github/actions/setup_cmake + with: + cmake_version: ${{env.CMAKE_VERSION}} + used_env: ${{matrix.config.os}} + + - name: Install SFML + id: sfml + uses: ./imgui-sfml/.github/actions/install_sfml + with: + sfml_version: ${{env.SFML_VERSION}} + used_env: ${{matrix.config.os}} + + - name: Checkout Dear ImGui + uses: actions/checkout@v2 + with: + repository: ocornut/imgui + submodules: recursive + path: imgui + ref: v${{env.IMGUI_VERSION}} + + - name: Configure + shell: cmake -P {0} + run: | + file(TO_CMAKE_PATH [=[${{github.workspace}}]=] workspace) + execute_process( + COMMAND ${{steps.cmake.outputs.cmake_binary}} + -S "${workspace}/imgui-sfml" + -B "${workspace}/imgui-sfml/build" + -D CMAKE_CONFIGURATION_TYPES=${{matrix.build_type}} + -D CMAKE_BUILD_TYPE=${{matrix.build_type}} + -D CMAKE_PREFIX_PATH=${{steps.sfml.outputs.sfml_install_dir}} + -D SFML_DIR=${{steps.sfml.outputs.sfml_install_dir}} + -D IMGUI_DIR=${workspace}/imgui + -D BUILD_SHARED_LIBS=ON + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + + - name: Build + shell: cmake -P {0} + run: | + file(TO_CMAKE_PATH [=[${{github.workspace}}]=] workspace) + include(ProcessorCount) + ProcessorCount(N) + execute_process( + COMMAND ${{steps.cmake.outputs.cmake_binary}} + --build "${workspace}/imgui-sfml/build" + --config ${{matrix.build_type}} + --parallel ${N} + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml new file mode 100644 index 0000000..4de7436 --- /dev/null +++ b/.github/workflows/ubuntu.yml @@ -0,0 +1,117 @@ +name: Ubuntu + +on: + - push + - pull_request + +env: + CMAKE_VERSION: 3.22.2 + CCACHE_VERSION: 4.2.1 + SFML_VERSION: 2.5.1 + IMGUI_VERSION: 1.87 + +jobs: + build: + name: ${{matrix.config.os}} - ${{matrix.config.compiler_name}} - ${{matrix.build_type}} + runs-on: ${{matrix.config.os}} + strategy: + fail-fast: false + matrix: + config: [ + # {os: ubuntu-18.04, compiler_name: gcc-7, c_compiler: gcc-7, cxx_compiler: g++-7}, + # {os: ubuntu-18.04, compiler_name: gcc-9, c_compiler: gcc-9, cxx_compiler: g++-9}, + # {os: ubuntu-18.04, compiler_name: gcc-10, c_compiler: gcc-10, cxx_compiler: g++-10}, + # {os: ubuntu-18.04, compiler_name: clang-9, c_compiler: clang-9, cxx_compiler: clang++-9}, + {os: ubuntu-20.04, compiler_name: gcc-9, c_compiler: gcc-9, cxx_compiler: g++-9}, + # {os: ubuntu-20.04, compiler_name: gcc-10, c_compiler: gcc-10, cxx_compiler: g++-10}, + {os: ubuntu-20.04, compiler_name: clang-10, c_compiler: clang-10, cxx_compiler: clang++-10}, + # {os: ubuntu-20.04, compiler_name: clang-11, c_compiler: clang-11, cxx_compiler: clang++-11}, + # {os: ubuntu-20.04, compiler_name: clang-12, c_compiler: clang-12, cxx_compiler: clang++-12}, + ] + build_type: [Debug, Release] + + steps: + - name: Checkout ImGui-SFML + uses: actions/checkout@v2 + with: + submodules: recursive + path: imgui-sfml + + - name: Setup build environment + shell: cmake -P {0} + run: | + execute_process(COMMAND ${{matrix.config.c_compiler}} --version) + execute_process(COMMAND ${{matrix.config.cxx_compiler}} --version) + file(APPEND "$ENV{GITHUB_ENV}" "CMAKE_GENERATOR=Unix Makefiles\n") + file(APPEND "$ENV{GITHUB_ENV}" "CC=${{matrix.config.c_compiler}}\n") + file(APPEND "$ENV{GITHUB_ENV}" "CXX=${{matrix.config.cxx_compiler}}\n") + + - name: Setup CMake + id: cmake + uses: ./imgui-sfml/.github/actions/setup_cmake + with: + cmake_version: ${{env.CMAKE_VERSION}} + used_env: ${{matrix.config.os}} + + - name: Setup ccache + id: ccache + uses: ./imgui-sfml/.github/actions/setup_ccache + with: + ccache_version: ${{env.CCACHE_VERSION}} + used_env: ${{matrix.config.os}} + cache_id: ${{matrix.config.os}}-${{matrix.config.compiler_name}}-${{matrix.build_type}} + + - name: Install SFML + id: sfml + uses: ./imgui-sfml/.github/actions/install_sfml + with: + sfml_version: ${{env.SFML_VERSION}} + used_env: ${{matrix.config.os}} + + - name: Checkout Dear ImGui + uses: actions/checkout@v2 + with: + repository: ocornut/imgui + submodules: recursive + path: imgui + ref: v${{env.IMGUI_VERSION}} + + - name: Configure + shell: cmake -P {0} + run: | + file(TO_CMAKE_PATH [=[${{github.workspace}}]=] workspace) + execute_process( + COMMAND ${{steps.cmake.outputs.cmake_binary}} + -S "${workspace}/imgui-sfml" + -B "${workspace}/imgui-sfml/build" + -D CMAKE_CONFIGURATION_TYPES=${{matrix.build_type}} + -D CMAKE_BUILD_TYPE=${{matrix.build_type}} + -D CMAKE_C_COMPILER_LAUNCHER=${{steps.ccache.outputs.ccache_binary}} + -D CMAKE_CXX_COMPILER_LAUNCHER=${{steps.ccache.outputs.ccache_binary}} + -D CMAKE_PREFIX_PATH=${{steps.sfml.outputs.sfml_install_dir}} + -D SFML_DIR=${{steps.sfml.outputs.sfml_install_dir}} + -D IMGUI_DIR=${workspace}/imgui + -D BUILD_SHARED_LIBS=ON + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + + - name: Build + shell: cmake -P {0} + run: | + file(TO_CMAKE_PATH [=[${{github.workspace}}]=] workspace) + include(ProcessorCount) + ProcessorCount(N) + execute_process( + COMMAND ${{steps.cmake.outputs.cmake_binary}} + --build "${workspace}/imgui-sfml/build" + --config ${{matrix.build_type}} + --parallel ${N} + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + execute_process(COMMAND ${{steps.ccache.outputs.ccache_binary}} -s) diff --git a/.github/workflows/windows-mingw.yml b/.github/workflows/windows-mingw.yml new file mode 100644 index 0000000..4856536 --- /dev/null +++ b/.github/workflows/windows-mingw.yml @@ -0,0 +1,127 @@ +name: Windows MinGW + +on: + - push + - pull_request + +env: + CMAKE_VERSION: 3.22.2 + CCACHE_VERSION: 4.2.1 + SFML_VERSION: 2.5.1 + IMGUI_VERSION: 1.87 + +jobs: + build: + name: Windows - MinGW - ${{matrix.config.compiler_name}} - ${{matrix.build_type}} + runs-on: ${{matrix.os}} + strategy: + fail-fast: false + matrix: + os: [windows-2022] + config: [ + { + compiler_name: gcc, + c_compiler_path: "C:/msys64/mingw64/bin/gcc.exe", + cxx_compiler_path: "C:/msys64/mingw64/bin/g++.exe" + }, + { + compiler_name: clang, + c_compiler_path: "C:/msys64/mingw64/bin/clang.exe", + cxx_compiler_path: "C:/msys64/mingw64/bin/clang++.exe" + } + ] + build_type: [Debug, Release] + + steps: + - name: Checkout ImGui-SFML + uses: actions/checkout@v2 + with: + submodules: recursive + path: imgui-sfml + + - name: Setup build environment + shell: cmake -P {0} + run: | + execute_process( + COMMAND "C:\msys64\usr\bin\bash" + -lc 'pacman --noconfirm --needed -S mingw-w64-x86_64-${{matrix.config.compiler_name}}' + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + execute_process(COMMAND ${{matrix.config.c_compiler_path}} --version) + execute_process(COMMAND ${{matrix.config.cxx_compiler_path}} --version) + file(APPEND "$ENV{GITHUB_ENV}" "CMAKE_GENERATOR=MinGW Makefiles\n") + file(APPEND "$ENV{GITHUB_ENV}" "CC=${{matrix.config.c_compiler_path}}\n") + file(APPEND "$ENV{GITHUB_ENV}" "CXX=${{matrix.config.cxx_compiler_path}}\n") + + - name: Setup CMake + id: cmake + uses: ./imgui-sfml/.github/actions/setup_cmake + with: + cmake_version: ${{env.CMAKE_VERSION}} + used_env: ${{matrix.os}} + + - name: Setup ccache + id: ccache + uses: ./imgui-sfml/.github/actions/setup_ccache + with: + ccache_version: ${{env.CCACHE_VERSION}} + used_env: ${{matrix.os}} + cache_id: ${{matrix.os}}-mingw-${{matrix.config.compiler_name}}-${{matrix.build_type}} + + - name: Install SFML + id: sfml + uses: ./imgui-sfml/.github/actions/install_sfml + with: + sfml_version: ${{env.SFML_VERSION}} + used_env: ${{matrix.os}}-mingw + + - name: Checkout Dear ImGui + uses: actions/checkout@v2 + with: + repository: ocornut/imgui + submodules: recursive + path: imgui + ref: v${{env.IMGUI_VERSION}} + + - name: Configure + shell: cmake -P {0} + run: | + file(TO_CMAKE_PATH [=[${{github.workspace}}]=] workspace) + execute_process( + COMMAND ${{steps.cmake.outputs.cmake_binary}} + -S "${workspace}/imgui-sfml" + -B "${workspace}/imgui-sfml/build" + -D CMAKE_CONFIGURATION_TYPES=${{matrix.build_type}} + -D CMAKE_BUILD_TYPE=${{matrix.build_type}} + -D CMAKE_C_COMPILER_LAUNCHER=${{steps.ccache.outputs.ccache_binary}} + -D CMAKE_CXX_COMPILER_LAUNCHER=${{steps.ccache.outputs.ccache_binary}} + -D CMAKE_PREFIX_PATH=${{steps.sfml.outputs.sfml_install_dir}} + -D SFML_DIR=${{steps.sfml.outputs.sfml_install_dir}} + -D IMGUI_DIR=${workspace}/imgui + -D BUILD_SHARED_LIBS=ON + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + + - name: Build + shell: cmake -P {0} + run: | + file(TO_CMAKE_PATH [=[${{github.workspace}}]=] workspace) + include(ProcessorCount) + ProcessorCount(N) + execute_process( + COMMAND ${{steps.cmake.outputs.cmake_binary}} + --build "${workspace}/imgui-sfml/build" + --config ${{matrix.build_type}} + --parallel ${N} + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + execute_process(COMMAND ${{steps.ccache.outputs.ccache_binary}} -s) diff --git a/.github/workflows/windows-msvc.yml b/.github/workflows/windows-msvc.yml new file mode 100644 index 0000000..a41385b --- /dev/null +++ b/.github/workflows/windows-msvc.yml @@ -0,0 +1,98 @@ +name: Windows Visual Studio + +on: + - push + - pull_request + +env: + CMAKE_VERSION: 3.22.2 + SFML_VERSION: 2.5.1 + IMGUI_VERSION: 1.87 + +jobs: + build: + name: Windows - ${{matrix.config.generator_short}} - ${{matrix.build_type}} + runs-on: ${{matrix.config.os}} + strategy: + fail-fast: false + matrix: + config: [ + # {os: windows-2017, generator: "Visual Studio 15 2017", generator_short: VS2017, toolset: v141}, + {os: windows-2019, generator: "Visual Studio 16 2019", generator_short: VS2019, toolset: v142}, + # {os: windows-2019, generator: "Visual Studio 16 2019", generator_short: VS2019, toolset: ClangCL}, # SFML 2.5.1 doesn't compile, fixed on branch 2.6.x + {os: windows-2022, generator: "Visual Studio 17 2022", generator_short: VS2022, toolset: v143}, + # {os: windows-2022, generator: "Visual Studio 17 2022", generator_short: VS2022, toolset: ClangCL}, # SFML 2.5.1 doesn't compile, fixed on branch 2.6.x + ] + build_type: [Debug, Release] + + steps: + - name: Checkout ImGui-SFML + uses: actions/checkout@v2 + with: + submodules: recursive + path: imgui-sfml + + - name: Setup build environment + shell: cmake -P {0} + run: | + file(APPEND "$ENV{GITHUB_ENV}" "CMAKE_GENERATOR=${{matrix.config.generator}}\n") + file(APPEND "$ENV{GITHUB_ENV}" "CMAKE_GENERATOR_TOOLSET=${{matrix.config.toolset}}\n") + + - name: Setup CMake + id: cmake + uses: ./imgui-sfml/.github/actions/setup_cmake + with: + cmake_version: ${{env.CMAKE_VERSION}} + used_env: ${{matrix.config.os}} + + - name: Install SFML + id: sfml + uses: ./imgui-sfml/.github/actions/install_sfml + with: + sfml_version: ${{env.SFML_VERSION}} + used_env: ${{matrix.config.os}}-msvc + + - name: Checkout Dear ImGui + uses: actions/checkout@v2 + with: + repository: ocornut/imgui + submodules: recursive + path: imgui + ref: v${{env.IMGUI_VERSION}} + + - name: Configure + shell: cmake -P {0} + run: | + file(TO_CMAKE_PATH [=[${{github.workspace}}]=] workspace) + execute_process( + COMMAND ${{steps.cmake.outputs.cmake_binary}} + -S "${workspace}/imgui-sfml" + -B "${workspace}/imgui-sfml/build" + -D CMAKE_CONFIGURATION_TYPES=${{matrix.build_type}} + -D CMAKE_BUILD_TYPE=${{matrix.build_type}} + -D CMAKE_PREFIX_PATH=${{steps.sfml.outputs.sfml_install_dir}} + -D SFML_DIR=${{steps.sfml.outputs.sfml_install_dir}} + -D IMGUI_DIR=${workspace}/imgui + -D BUILD_SHARED_LIBS=ON + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() + + - name: Build + shell: cmake -P {0} + run: | + file(TO_CMAKE_PATH [=[${{github.workspace}}]=] workspace) + include(ProcessorCount) + ProcessorCount(N) + execute_process( + COMMAND ${{steps.cmake.outputs.cmake_binary}} + --build "${workspace}/imgui-sfml/build" + --config ${{matrix.build_type}} + --parallel ${N} + RESULT_VARIABLE result + ) + if(NOT result EQUAL 0) + message(FATAL_ERROR "Bad exit status") + endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index fad29a6..2a9e512 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -164,6 +164,9 @@ set_target_properties(ImGui-SFML PROPERTIES PUBLIC_HEADER "${IMGUI_SFML_PUBLIC_HEADERS}" ) +# Set minimum required standard +target_compile_features(ImGui-SFML PUBLIC cxx_std_11) + if(IMGUI_SFML_BUILD_EXAMPLES) add_subdirectory(examples) endif() diff --git a/README.md b/README.md index e267e8a..e728060 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ ImGui-SFML v2.5 ======= -[![build Actions Status](https://github.com/eliasdaler/imgui-sfml/workflows/build/badge.svg)](https://github.com/eliasdaler/imgui-sfml/actions) + +[![Ubuntu](https://github.com/eliasdaler/imgui-sfml/actions/workflows/ubuntu.yml/badge.svg?branch=master)](https://github.com/eliasdaler/imgui-sfml/actions/workflows/ubuntu.yml) +[![Windows MinGW](https://github.com/eliasdaler/imgui-sfml/actions/workflows/windows-mingw.yml/badge.svg?branch=master)](https://github.com/eliasdaler/imgui-sfml/actions/workflows/windows-mingw.yml) +[![Windows Visual Studio](https://github.com/eliasdaler/imgui-sfml/actions/workflows/windows-msvc.yml/badge.svg?branch=master)](https://github.com/eliasdaler/imgui-sfml/actions/workflows/windows-msvc.yml) +[![macOS](https://github.com/eliasdaler/imgui-sfml/actions/workflows/macos.yml/badge.svg?branch=master)](https://github.com/eliasdaler/imgui-sfml/actions/workflows/macos.yml) +[![clang-format](https://github.com/eliasdaler/imgui-sfml/actions/workflows/clang-format.yml/badge.svg?branch=master)](https://github.com/eliasdaler/imgui-sfml/actions/workflows/clang-format.yml) Library which allows you to use [Dear ImGui](https://github.com/ocornut/imgui) with [SFML](https://github.com/SFML/SFML)