diff options
-rw-r--r-- | .github/workflows/build-windows.bat | 3 | ||||
-rw-r--r-- | .github/workflows/cmake.yml | 53 | ||||
-rw-r--r-- | CMakeLists.txt | 17 | ||||
-rw-r--r-- | compat/arch.hpp | 1 | ||||
-rw-r--r-- | compat/format.hpp | 10 | ||||
-rw-r--r-- | compat/fpu.hpp | 1 | ||||
-rw-r--r-- | external/CMakeLists.txt | 47 | ||||
m--------- | external/sdl2 | 0 | ||||
-rw-r--r-- | serialize/json-helper.cpp | 2 | ||||
-rw-r--r-- | serialize/world-reader.cpp | 5 | ||||
-rw-r--r-- | serialize/world-writer.cpp | 7 | ||||
-rw-r--r-- | test/CMakeLists.txt | 10 | ||||
-rw-r--r-- | test/app.hpp | 11 | ||||
-rw-r--r-- | userconfig-runner@Darwin-Clang.cmake | 49 | ||||
-rw-r--r-- | userconfig-runner@Linux-GNU.cmake | 35 |
15 files changed, 225 insertions, 26 deletions
diff --git a/.github/workflows/build-windows.bat b/.github/workflows/build-windows.bat new file mode 100644 index 00000000..4571683e --- /dev/null +++ b/.github/workflows/build-windows.bat @@ -0,0 +1,3 @@ +set path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\CMake\bin;C:\Program Files\Git\cmd;%GITHUB_WORKSPACE%/ninja-build +"C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat" >nul && %* +exit /b %ERRORLEVEL% diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 00000000..b603e0fb --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,53 @@ +name: CMake + +on: + push: + branches: [ master ] + tags: + - '*' + pull_request: + branches: [ master ] + +env: + BUILD_TYPE: RELEASE + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-22.04, windows-latest, macos-12] + include: + - os: ubuntu-22.04 + cmake: /usr/bin/env CC=gcc-12 CXX=g++-12 cmake + - os: macos-12 + cmake: /usr/bin/env CC="$(brew --prefix llvm@14)/bin/clang" CXX="$(brew --prefix llvm@14)/bin/clang++" cmake + - os: windows-latest + cmake: .\.github\workflows\build-windows.bat cmake + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - uses: abdes/gha-setup-ninja@master + with: + version: 1.11.1 + if: matrix.os != 'ubuntu-22.04' + + - name: Install Linux Dependencies + run: sudo /bin/sh -c 'set -e; apt update; apt install libopencv-dev libgl-dev g++-12 ninja-build' + if: matrix.os == 'ubuntu-22.04' + + - name: Configure + run: ${{matrix.cmake}} -G "Ninja" -S ${{github.workspace}}/ -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + + - name: Build + run: ${{matrix.cmake}} --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target install + +# - name: Upload build +# uses: actions/upload-artifact@v2.2.4 +# with: +# name: buildoutput +# path: ${{github.workspace}}/build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e1b8117..3e25051c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ function(fm_load_userconfig) else() set(_fm_username "$ENV{USER}") endif() - set(_fm_userconfig "userconfig-${_fm_username}@${CMAKE_CXX_COMPILER_ID}.cmake") + set(_fm_userconfig "userconfig-${_fm_username}@${CMAKE_SYSTEM_NAME}-${CMAKE_CXX_COMPILER_ID}.cmake") if(EXISTS "${CMAKE_SOURCE_DIR}/${_fm_userconfig}") message(STATUS "Loading user config '${_fm_userconfig}'") include("${CMAKE_SOURCE_DIR}/${_fm_userconfig}" NO_POLICY_SCOPE) @@ -78,6 +78,11 @@ function(fm_load_userconfig) endif() endfunction() +if(NOT "$ENV{FLOORMAT_NO_USERCONFIG}" AND NOT FLOORMAT_NO_USERCONFIG) + fm_load_userconfig() + string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE) +endif() + if(WIN32) add_definitions(-D_CRT_SECURE_NO_WARNINGS -DNOMINMAX -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0) if(NOT MSVC) @@ -108,21 +113,15 @@ else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-cxa-atexit") endif() -if(CMAKE_CXX_COMPILER_ID MATCHES "Clang$") +if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL "13.3" OR + CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL "13.0") add_compile_options(-Wno-reserved-macro-identifier) endif() -cmake_policy(SET CMP0063 NEW) - set_directory_properties(PROPERTIES CORRADE_USE_PEDANTIC_FLAGS OFF) set_directory_properties(PROPERTIES CORRADE_CXX_STANDARD ${CMAKE_CXX_STANDARD}) set_directory_properties(PROPERTIES INTERFACE_CORRADE_CXX_STANDARD ${CMAKE_CXX_STANDARD}) -if(NOT "$ENV{FLOORMAT_NO_USERCONFIG}" AND NOT FLOORMAT_NO_USERCONFIG) - fm_load_userconfig() - string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE) -endif() - add_subdirectory(external) if(MSVC) diff --git a/compat/arch.hpp b/compat/arch.hpp index 0b58b65a..a60f673e 100644 --- a/compat/arch.hpp +++ b/compat/arch.hpp @@ -42,4 +42,3 @@ # define FLOORMAT_ARCH_FPU_MASK # include <xmmintrin.h> #endif - diff --git a/compat/format.hpp b/compat/format.hpp index 0ebb3e18..dbf86e1e 100644 --- a/compat/format.hpp +++ b/compat/format.hpp @@ -2,8 +2,8 @@ #include <fmt/core.h> #include <fmt/compile.h> +#ifndef _MSC_VER namespace floormat::detail::fmt { - template<std::size_t N> struct fmt_string final { static constexpr std::size_t size = N; @@ -15,16 +15,20 @@ struct fmt_string final { data[i] = arr[i]; } }; - } // namespace floormat::detail::fmt +#endif namespace floormat { -template<detail::fmt::fmt_string s> +#ifndef _MSC_VER +template<::floormat::detail::fmt::fmt_string s> consteval auto operator""_cf() noexcept { return FMT_COMPILE(s.data); } +#else +using namespace fmt::literals; +#endif template<std::size_t N, typename Fmt, typename... Xs> std::size_t snformat(char(&buf)[N], Fmt&& fmt, Xs&&... args) diff --git a/compat/fpu.hpp b/compat/fpu.hpp index 1b3776f9..9433648a 100644 --- a/compat/fpu.hpp +++ b/compat/fpu.hpp @@ -1,5 +1,6 @@ #pragma once #include "arch.hpp" +#include <cfenv> #ifdef __MINGW32__ extern "C" __declspec(dllimport) unsigned __cdecl _controlfp(unsigned, unsigned); diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 45e5728b..70667e2b 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -61,6 +61,10 @@ if(FLOORMAT_SUBMODULE-DEPENDENCIES) MAGNUM_BUILD_TESTS OFF MAGNUM_BUILD_DEPRECATED ON + MAGNUM_WITH_WINDOWLESSWGLAPPLICATION OFF + MAGNUM_WITH_WINDOWLESSGLXAPPLICATION OFF + MAGNUM_WITH_WINDOWLESSCGLAPPLICATION OFF + MAGNUM_WITH_ANYIMAGECONVERTER ON MAGNUM_WITH_ANYIMAGEIMPORTER ON MAGNUM_WITH_DISTANCEFIELDCONVERTER ON @@ -79,7 +83,6 @@ if(FLOORMAT_SUBMODULE-DEPENDENCIES) MAGNUM_WITH_TGAIMAGECONVERTER ON MAGNUM_WITH_TGAIMPORTER ON MAGNUM_WITH_WEBPIMPORTER OFF - MAGNUM_WITH_WINDOWLESSWGLAPPLICATION ON MAGNUM_WITH_DDSIMPORTER ON MAGNUM_WITH_GLTFIMPORTER ON @@ -141,22 +144,52 @@ if(FLOORMAT_SUBMODULE-DEPENDENCIES) SDL_WASAPI OFF SDL_XINPUT OFF ) - if(NOT WIN32) - set(MAGNUM_WITH_WINDOWLESSWGLAPPLICATION OFF) + if(WIN32) + sets(BOOL MAGNUM_WITH_WINDOWLESSWGLAPPLICATION ON) + elseif(APPLE) + sets(BOOL MAGNUM_WITH_WINDOWLESSCGLAPPLICATION ON) + else() + sets(BOOL MAGNUM_WITH_WINDOWLESSGLXAPPLICATION ON) endif() endif() fm_run_hook(fm-userconfig-external-pre) +set(fm-quiet-message 0) + +function(message) + if(fm-quiet-message) + list(GET ARGV 0 MessageType) + if(MessageType STREQUAL FATAL_ERROR OR + MessageType STREQUAL SEND_ERROR OR + MessageType STREQUAL WARNING OR + MessageType STREQUAL AUTHOR_WARNING) + list(REMOVE_AT ARGV 0) + _message(${MessageType} "${ARGV}") + endif() + else() + _message("${ARGV}") + endif() +endfunction() + if(FLOORMAT_SUBMODULE-DEPENDENCIES) sets(PATH IMGUI_DIR "${CMAKE_CURRENT_SOURCE_DIR}/imgui") + + function(fm_add_sdl) + unset(CMAKE_C_VISIBILITY_PRESET) + unset(CMAKE_VISIBILITY_INLINES_HIDDEN) + add_subdirectory(sdl2) + endfunction() + + set(fm-quiet-message 1) add_subdirectory(json) - add_subdirectory(sdl2) add_subdirectory(corrade) + fm_add_sdl() add_subdirectory(magnum) add_subdirectory(magnum-plugins) add_subdirectory(magnum-integration) add_subdirectory(fmt) + set(fm-quiet-message 0) endif() if(FLOORMAT_SUBMODULE-DEPENDENCIES) @@ -167,6 +200,7 @@ endif() fm_run_hook(fm-userconfig-external) +set(fm-quiet-message 1) find_package(SDL2 QUIET REQUIRED) find_package(Corrade QUIET REQUIRED) find_package(ImGui QUIET REQUIRED) @@ -177,5 +211,10 @@ find_package(MagnumIntegration QUIET REQUIRED ImGui) if(NOT FLOORMAT_SUBMODULE-DEPENDENCIES) find_package(fmt QUIET REQUIRED) endif() +set(fm-quiet-message 0) + +function(message) + _message("${ARGV}") +endfunction() fm_run_hook(fm-userconfig-external-post) diff --git a/external/sdl2 b/external/sdl2 -Subproject b095df7f5cc0f32f8b90cca10e509204ec742ae +Subproject 29cafa9c94e4db6dadfae43aece9fb2edcac121 diff --git a/serialize/json-helper.cpp b/serialize/json-helper.cpp index 538bcdcb..5504ff52 100644 --- a/serialize/json-helper.cpp +++ b/serialize/json-helper.cpp @@ -8,7 +8,7 @@ static T open_stream(StringView filename) { T s; s.exceptions(s.exceptions() | std::ios::failbit | std::ios::badbit); - s.open(filename, mode); + s.open(filename.data(), mode); return s; } diff --git a/serialize/world-reader.cpp b/serialize/world-reader.cpp index e55ea059..615aba0d 100644 --- a/serialize/world-reader.cpp +++ b/serialize/world-reader.cpp @@ -118,10 +118,11 @@ world world::deserialize(StringView filename) { char errbuf[128]; constexpr auto strerror = []<std::size_t N> (char (&buf)[N]) -> const char* { + buf[0] = '\0'; #ifndef _WIN32 - ::strerror_r(errno, buf, std::size(buf)); + (void)::strerror_r(errno, buf, std::size(buf)); #else - ::strerror_s(buf, std::size(buf), errno); + (void)::strerror_s(buf, std::size(buf), errno); #endif return buf; }; diff --git a/serialize/world-writer.cpp b/serialize/world-writer.cpp index c33947dc..7e89c508 100644 --- a/serialize/world-writer.cpp +++ b/serialize/world-writer.cpp @@ -12,8 +12,6 @@ #include <Corrade/Containers/StringView.h> #include <Corrade/Utility/Path.h> -namespace Path = Corrade::Utility::Path; - namespace floormat::Serialize { struct interned_atlas final { @@ -256,10 +254,11 @@ void world::serialize(StringView filename) collect(true); char errbuf[128]; constexpr auto strerror = []<std::size_t N> (char (&buf)[N]) -> const char* { + buf[0] = '\0'; #ifndef _WIN32 - ::strerror_r(errno, buf, std::size(buf)); + (void)::strerror_r(errno, buf, std::size(buf)); #else - ::strerror_s(buf, std::size(buf), errno); + (void)::strerror_s(buf, std::size(buf), errno); #endif return buf; }; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0ef13ac6..0f5ca85d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,7 +4,15 @@ file(GLOB sources "*.cpp" CONFIGURE_ARGS) file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/test") link_libraries(${PROJECT_NAME}) -link_libraries(Magnum::WindowlessWglApplication Magnum::Trade) +link_libraries(Magnum::Trade) + +if(APPLE) + link_libraries(Magnum::WindowlessCglApplication) +elseif(WIN32) + link_libraries(Magnum::WindowlessWglApplication) +else() + link_libraries(Magnum::WindowlessGlxApplication) +endif() add_executable(${self} "${sources}" "../loader/loader-impl.cpp") install(TARGETS ${self} RUNTIME DESTINATION bin) diff --git a/test/app.hpp b/test/app.hpp index 31df8a35..c9bcfcee 100644 --- a/test/app.hpp +++ b/test/app.hpp @@ -1,8 +1,17 @@ #pragma once #include <Magnum/Magnum.h> #include <Magnum/Platform/WindowlessWglApplication.h> + +#ifdef __APPLE__ +#define FM_APPLICATION Platform::WindowlessCglApplication +#elif defined _WIN32 +#define FM_APPLICATION Platform::WindowlessWglApplication +#else +#define FM_APPLICATION Platform::WindowlessGlxApplication +#endif + namespace floormat { -struct floormat final : Platform::WindowlessWglApplication // NOLINT(cppcoreguidelines-virtual-class-destructor) +struct floormat final : private FM_APPLICATION { explicit floormat(const Arguments& arguments); ~floormat(); diff --git a/userconfig-runner@Darwin-Clang.cmake b/userconfig-runner@Darwin-Clang.cmake new file mode 100644 index 00000000..7f526b9a --- /dev/null +++ b/userconfig-runner@Darwin-Clang.cmake @@ -0,0 +1,49 @@ +sets(BOOL FLOORMAT_PRECOMPILED-HEADERS OFF) + +add_link_options(-framework IOKit) + +# for building submodule dependencies +function(fm-userconfig-external-pre) + add_compile_options(-Wno-deprecated -Wno-unused-but-set-variable) +endfunction() + +# for floormat sources only +function(fm-userconfig-src) + add_compile_options( + -Wall -Wextra -Wpedantic -Wno-old-style-cast -Wno-padded -Weverything + ) + add_compile_options( + -Wno-c++98-compat + -Wno-c++20-compat + -Wno-c++98-compat-pedantic + -Wno-logical-op-parentheses + -Wno-undefined-func-template + -Wno-switch-enum + -Wno-covered-switch-default + -Wno-old-style-cast + -Wno-global-constructors + -Wno-exit-time-destructors + -Wno-implicit-int-float-conversion + -Wno-shadow-field-in-constructor + -Wno-shadow + -Wno-ctad-maybe-unsupported + -Wno-documentation-unknown-command + -Wno-documentation + -Wno-ignored-attributes + -Wno-reserved-identifier + -Wno-zero-length-array + ) + add_compile_options( + #-Werror + -Wno-error=float-equal + #-Wno-error=comma + -Wno-error=unused-parameter + -Wno-error=unused-private-field + -Wno-error=unused-variable + -Wno-error=unused-function + -Wno-error=unused-member-function + -Wno-error=unused-macros + -Wno-error=alloca + -Wno-error=double-promotion + ) +endfunction() diff --git a/userconfig-runner@Linux-GNU.cmake b/userconfig-runner@Linux-GNU.cmake new file mode 100644 index 00000000..fb149324 --- /dev/null +++ b/userconfig-runner@Linux-GNU.cmake @@ -0,0 +1,35 @@ +sets(BOOL FLOORMAT_PRECOMPILED-HEADERS OFF) + +# for floormat sources only +function(fm-userconfig-src) + add_compile_options( + -Wall -Wextra -Wpedantic -Wno-old-style-cast -Wno-padded + ) + add_compile_options( + -Wall + -Wextra + -Wpedantic + #-Weverything + -Wno-c++20-compat + -Wno-switch-enum + #-Wno-old-style-cast + #-Wno-shadow + -Wno-ctad-maybe-unsupported + -Wno-ignored-attributes + ) + add_compile_options( + #-Werror + -Wno-error=float-equal + #-Wno-error=comma + -Wno-error=unused-parameter + -Wno-error=unused-variable + -Wno-error=unused-function + -Wno-error=unused-macros + #-Wno-error=alloca + -Wno-error=double-promotion + -Wno-error=restrict + -Wno-error=unused-but-set-variable + -Wno-error=subobject-linkage + -Wno-error=array-bounds + ) +endfunction() |