From 83acd70f41c3efd45783000521c936c23f3d0042 Mon Sep 17 00:00:00 2001 From: Albin Johansson Date: Fri, 14 Jul 2023 19:43:36 +0200 Subject: [PATCH] General cleanup of old stuff --- .github/workflows/ci.yml | 209 +++------------------------- CMakeLists.txt | 102 +++++++++----- Doxyfile | 4 +- README.md | 53 ++----- cmake/FindSDL2.cmake | 173 ----------------------- cmake/FindSDL2_image.cmake | 102 -------------- cmake/FindSDL2_mixer.cmake | 101 -------------- cmake/FindSDL2_ttf.cmake | 99 ------------- cmake/centurion.cmake | 73 ---------- test/CMakeLists.txt | 6 +- test/unit-tests/CMakeLists.txt | 246 +++------------------------------ vcpkg.json | 4 +- 12 files changed, 125 insertions(+), 1047 deletions(-) delete mode 100644 cmake/FindSDL2.cmake delete mode 100644 cmake/FindSDL2_image.cmake delete mode 100644 cmake/FindSDL2_mixer.cmake delete mode 100644 cmake/FindSDL2_ttf.cmake delete mode 100644 cmake/centurion.cmake diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79b936647..66840cd59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,10 +23,6 @@ jobs: brew install cmake brew install ninja brew install glfw - brew install sdl2 - brew install sdl2_image - brew install sdl2_mixer - brew install sdl2_ttf - name: Restore Vcpkg artifacts id: restore-vcpkg-artifacts @@ -54,35 +50,20 @@ jobs: cmake .. -GNinja \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_CXX_STANDARD=${{matrix.CPP_VERSION}} \ - -DBUILD_TESTS=ON \ - -DBUILD_EXAMPLES=ON \ - -DTREAT_WARNINGS_AS_ERRORS=ON + -DCEN_USE_SYSTEM_DEPS=OFF \ + -DCEN_USE_SDL_IMAGE=OFF \ + -DCEN_USE_SDL_MIXER=OFF \ + -DCEN_USE_SDL_TTF=OFF \ + -DCEN_BUILD_TESTS=OFF \ + -DCEN_BUILD_EXAMPLES=OFF \ + -DCEN_TREAT_WARNINGS_AS_ERRORS=ON - name: Compile run: ninja -C build - - name: Run unit tests - working-directory: ./build/test/unit-tests - run: ./centurion-tests - - - name: Run mock tests - working-directory: ./build/test/mocked-tests - run: ./centurion-mocks - ubuntu: runs-on: ubuntu-latest if: contains(github.event.head_commit.message, '[skip-ci]') == false - strategy: - fail-fast: false - matrix: - SDL_VERSION: [ 2.0.20, 2.0.22, 2.24.0, 2.26.0 ] - TTF_VERSION: [ 2.20.2 ] - IMG_VERSION: [ 2.6.3 ] - MIX_VERSION: [ 2.6.3 ] - CPP_VERSION: [ 20 ] - include: - - { SDL_VERSION: 2.26.0, TTF_VERSION: 2.20.2, IMG_VERSION: 2.6.3, MIX_VERSION: 2.6.3, CPP_VERSION: 17 } - - { SDL_VERSION: 2.26.0, TTF_VERSION: 2.20.2, IMG_VERSION: 2.6.3, MIX_VERSION: 2.6.3, CPP_VERSION: 23 } env: VCPKG_ROOT: ${{github.workspace}}/vcpkg VCPKG_DEFAULT_BINARY_CACHE: ${{github.workspace}}/vcpkg/bincache @@ -149,95 +130,6 @@ jobs: sudo ./vcpkg/vcpkg integrate install mkdir ${{env.VCPKG_DEFAULT_BINARY_CACHE}} - - name: Restore SDL2 - id: restore-sdl2 - uses: actions/cache@v3 - with: - path: SDL2-${{matrix.SDL_VERSION}} - key: SDL2-${{matrix.SDL_VERSION}} - - - name: Build SDL2 - if: steps.restore-sdl2.outputs.cache-hit != 'true' - run: | - wget https://www.libsdl.org/release/SDL2-${{matrix.SDL_VERSION}}.tar.gz - tar -xf SDL2-${{matrix.SDL_VERSION}}.tar.gz - rm -rf SDL2-${{matrix.SDL_VERSION}}.tar.gz - cd SDL2-${{matrix.SDL_VERSION}} - ./configure - make -j $(nproc) - - - name: Install SDL2 - run: | - cd SDL2-${{matrix.SDL_VERSION}} - sudo make install - - - name: Restore SDL2_image - id: restore-sdl2-image - uses: actions/cache@v3 - with: - path: SDL_image-release-${{ matrix.IMG_VERSION }} - key: SDL_image-${{ matrix.IMG_VERSION }} - - - name: Build SDL2_image - if: steps.restore-sdl2-image.outputs.cache-hit != 'true' - run: | - wget https://github.com/libsdl-org/SDL_image/archive/refs/tags/release-${{ matrix.IMG_VERSION }}.tar.gz - tar -xf release-${{ matrix.IMG_VERSION }}.tar.gz - rm -rf release-${{ matrix.IMG_VERSION }}.tar.gz - cd SDL_image-release-${{ matrix.IMG_VERSION }} - ./configure - make -j $(nproc) - - - name: Install SDL2_image - run: | - cd SDL_image-release-${{ matrix.IMG_VERSION }} - sudo make install - - - name: Restore SDL2_mixer - id: restore-sdl2-mixer - uses: actions/cache@v3 - with: - path: SDL_mixer-release-${{ matrix.MIX_VERSION }} - key: SDL2_mixer-${{ matrix.MIX_VERSION }} - - - name: Build SDL2_mixer - if: steps.restore-sdl2-mixer.outputs.cache-hit != 'true' - run: | - wget https://github.com/libsdl-org/SDL_mixer/archive/refs/tags/release-${{ matrix.MIX_VERSION }}.tar.gz - tar -xf release-${{ matrix.MIX_VERSION }}.tar.gz - rm -rf release-${{ matrix.MIX_VERSION }}.tar.gz - cd SDL_mixer-release-${{ matrix.MIX_VERSION }} - ./configure - make -j $(nproc) - - - name: Install SDL2_mixer - run: | - cd SDL_mixer-release-${{ matrix.MIX_VERSION }} - sudo make install - - - name: Restore SDL2_ttf - id: restore-sdl2-ttf - uses: actions/cache@v3 - with: - path: SDL_ttf-release-${{ matrix.TTF_VERSION }} - key: SDL2_ttf-${{ matrix.TTF_VERSION }} - - - name: Build SDL2_ttf - if: steps.restore-sdl2-ttf.outputs.cache-hit != 'true' - run: | - wget https://github.com/libsdl-org/SDL_ttf/archive/refs/tags/release-${{ matrix.TTF_VERSION }}.tar.gz - tar -xf release-${{ matrix.TTF_VERSION }}.tar.gz - rm -rf release-${{ matrix.TTF_VERSION }}.tar.gz - cd SDL_ttf-release-${{ matrix.TTF_VERSION }} - ./autogen.sh - ./configure --disable-harfbuzz-builtin --disable-freetype-builtin --without-x - make -j $(nproc) - - - name: Install SDL2_ttf - run: | - cd SDL_ttf-release-${{ matrix.TTF_VERSION }} - sudo make install - - name: Emulate video device run: | /sbin/start-stop-daemon --start \ @@ -253,43 +145,20 @@ jobs: cmake .. -GNinja \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_CXX_STANDARD=${{matrix.CPP_VERSION}} \ - -DBUILD_TESTS=ON \ - -DBUILD_EXAMPLES=ON \ - -DINCLUDE_AUDIO_TESTS=OFF \ - -DTREAT_WARNINGS_AS_ERRORS=ON + -DCEN_USE_SYSTEM_DEPS=OFF \ + -DCEN_USE_SDL_IMAGE=OFF \ + -DCEN_USE_SDL_MIXER=OFF \ + -DCEN_USE_SDL_TTF=OFF \ + -DCEN_BUILD_TESTS=OFF \ + -DCEN_BUILD_EXAMPLES=OFF \ + -DCEN_TREAT_WARNINGS_AS_ERRORS=ON - name: Compile run: ninja -C build - - name: Run mocked tests - working-directory: ./build/test/mocked-tests - run: ./centurion-mocks - - - name: Run unit tests - working-directory: ./build/test/unit-tests - run: ./centurion-tests - windows: runs-on: windows-latest if: contains(github.event.head_commit.message, '[skip-ci]') == false - strategy: - fail-fast: false - matrix: - SDL_VERSION: [ 2.24.0, 2.26.0 ] - TTF_VERSION: [ 2.0.18, 2.20.1 ] - IMG_VERSION: [ 2.0.5, 2.6.2 ] - MIX_VERSION: [ 2.6.3 ] - CPP_VERSION: [ 20 ] - include: - - { SDL_VERSION: 2.0.10, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 17 } - - { SDL_VERSION: 2.0.12, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 17 } - - { SDL_VERSION: 2.0.14, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 17 } - - { SDL_VERSION: 2.0.16, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 17 } - - { SDL_VERSION: 2.0.18, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 17 } - - { SDL_VERSION: 2.0.20, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 17 } - - { SDL_VERSION: 2.0.22, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 17 } - - { SDL_VERSION: 2.24.0, TTF_VERSION: 2.0.18, IMG_VERSION: 2.0.5, MIX_VERSION: 2.6.3, CPP_VERSION: 20 } - - { SDL_VERSION: 2.26.0, TTF_VERSION: 2.20.1, IMG_VERSION: 2.6.2, MIX_VERSION: 2.6.3, CPP_VERSION: 23 } env: VCPKG_ROOT: ${{github.workspace}}/vcpkg steps: @@ -327,54 +196,20 @@ jobs: .\vcpkg\bootstrap-vcpkg.bat -disableMetrics .\vcpkg\vcpkg integrate install - - name: Download SDL2 - uses: albin-johansson/download-sdl2@latest - with: - version: ${{matrix.SDL_VERSION}} - sources_destination: . - binaries_destination: bin - - - name: Download SDL2_image - uses: albin-johansson/download-sdl2-image@latest - with: - version: ${{matrix.IMG_VERSION}} - sources_destination: . - binaries_destination: bin - - - name: Download SDL2_ttf - uses: albin-johansson/download-sdl2-ttf@latest - with: - version: ${{matrix.TTF_VERSION}} - sources_destination: . - binaries_destination: bin - - - name: Download SDL2_mixer - uses: albin-johansson/download-sdl2-mixer@latest - with: - version: ${{matrix.MIX_VERSION}} - sources_destination: . - binaries_destination: bin - - name: Generate build files - env: - SDL2DIR: ${{github.workspace}}/SDL2-${{matrix.SDL_VERSION}} - SDL2IMAGEDIR: ${{github.workspace}}/SDL2_image-${{matrix.IMG_VERSION}} - SDL2MIXERDIR: ${{github.workspace}}/SDL2_mixer-${{matrix.MIX_VERSION}} - SDL2TTFDIR: ${{github.workspace}}/SDL2_ttf-${{matrix.TTF_VERSION}} run: | mkdir build cd build cmake .. -GNinja ` -DCMAKE_BUILD_TYPE=Debug ` -DCMAKE_CXX_STANDARD=${{matrix.CPP_VERSION}} ` - -DBUILD_TESTS=ON ` - -DBUILD_EXAMPLES=ON ` - -DTREAT_WARNINGS_AS_ERRORS=ON + -DCEN_USE_SYSTEM_DEPS=OFF ` + -DCEN_USE_SDL_IMAGE=OFF ` + -DCEN_USE_SDL_MIXER=OFF ` + -DCEN_USE_SDL_TTF=OFF ` + -DCEN_BUILD_TESTS=OFF ` + -DCEN_BUILD_EXAMPLES=OFF ` + -DCEN_TREAT_WARNINGS_AS_ERRORS=ON - name: Compile - run: ninja -C build - - - name: Run mocked tests - shell: cmd - working-directory: ./build/test/mocked-tests - run: centurion-mocks \ No newline at end of file + run: ninja -C build \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index b9a70c5eb..ac8db7343 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,53 +5,87 @@ if (DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) endif () project(centurion - VERSION 7.3.0 + VERSION 8.0.0 HOMEPAGE_URL "https://github.com/albin-johansson/centurion" LANGUAGES CXX) -if ("${CMAKE_CXX_STANDARD}" STREQUAL "") - set(CMAKE_CXX_STANDARD 17) -endif () - -set(CXX_STANDARD_REQUIRED ON) -set(CXX_EXTENSIONS OFF) -set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") - -# Build options -option(BUILD_TESTS "Build the test suite" OFF) -option(BUILD_EXAMPLES "Build the examples" OFF) -option(INCLUDE_AUDIO_TESTS "Test audio components" ON) -option(TREAT_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF) - -include(cmake/centurion.cmake) +# Build configuration +option(CEN_USE_SYSTEM_DEPS "Use SDL libraries installed on system" ON) +option(CEN_USE_SDL_IMAGE "Enable APIs dependent on the SDL_image library" OFF) +option(CEN_USE_SDL_MIXER "Enable APIs dependent on the SDL_mixer library" OFF) +option(CEN_USE_SDL_TTF "Enable APIs dependent on the SDL_ttf library" OFF) +option(CEN_BUILD_EXAMPLES "Build the examples" OFF) +option(CEN_BUILD_TESTS "Build the test suite" OFF) +option(CEN_INCLUDE_AUDIO_TESTS "Test audio components" ON) +option(CEN_TREAT_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF) # Directories set(CEN_ROOT_DIR "${PROJECT_SOURCE_DIR}") -set(CEN_RESOURCES_DIR "${PROJECT_SOURCE_DIR}/test/resources") -set(CEN_SOURCE_DIR "${PROJECT_SOURCE_DIR}/src") -set(CEN_BINARIES_DIR "${PROJECT_SOURCE_DIR}/bin") +set(CEN_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/src") set(CEN_EXTERNAL_DIR "${PROJECT_SOURCE_DIR}/external") -# Target names -set(CENTURION_LIB_TARGET libcenturion) -set(CENTURION_TEST_TARGET centurion-tests) -set(CENTURION_MOCK_TARGET centurion-mocks) +function(cen_prepare_target target) + set_target_properties(${target} + PROPERTIES + CXX_STANDARD_REQUIRED ON + CXX_EXTENSIONS OFF + ) + + if (CEN_USE_SDL_IMAGE MATCHES OFF) + target_compile_definitions(${target} PRIVATE CENTURION_NO_SDL_IMAGE) + endif () + + if (CEN_USE_SDL_MIXER MATCHES OFF) + target_compile_definitions(${target} PRIVATE CENTURION_NO_SDL_MIXER) + endif () -# System dependencies -find_package(SDL2 REQUIRED) -find_package(SDL2_image REQUIRED) -find_package(SDL2_mixer REQUIRED) -find_package(SDL2_ttf REQUIRED) + if (CEN_USE_SDL_TTF MATCHES OFF) + target_compile_definitions(${target} PRIVATE CENTURION_NO_SDL_TTF) + endif () -if (BUILD_TESTS) - # Vcpkg test dependencies + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + target_compile_options(${target} + PRIVATE + /EHsc + /MP + /W4 + /Zc:preprocessor # Enable conforming preprocessor + /Zc:__cplusplus # Force MSVC to use __cplusplus macro with correct value + /wd4996 # Disable deprecation warnings + ) + + if (CEN_TREAT_WARNINGS_AS_ERRORS MATCHES ON) + target_compile_options(${target} PRIVATE /WX) + endif () + else () + target_compile_options(${target} PRIVATE + -Wall + -Wextra + -Wpedantic + -Wconversion + -Wno-deprecated + -Wno-deprecated-declarations + -Wno-format-security + ) + + if (CEN_TREAT_WARNINGS_AS_ERRORS MATCHES ON) + target_compile_options(${target} PRIVATE -Werror) + endif () + endif () +endfunction() + +if (CEN_USE_SYSTEM_DEPS MATCHES ON) + # TODO +else () + add_subdirectory(external/SDL) +endif () + +if (CEN_BUILD_TESTS MATCHES ON) find_package(GTest CONFIG REQUIRED) find_package(cereal CONFIG REQUIRED) find_package(GLEW REQUIRED) - - add_subdirectory(test) + # add_subdirectory(test) endif () -if (BUILD_EXAMPLES) - add_subdirectory(examples) +if (CEN_BUILD_EXAMPLES MATCHES ON) endif () \ No newline at end of file diff --git a/Doxyfile b/Doxyfile index 48f3eb7dc..5b4cca7e9 100644 --- a/Doxyfile +++ b/Doxyfile @@ -48,13 +48,13 @@ PROJECT_NAME = Centurion # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 7.3.0 +PROJECT_NUMBER = 8.0.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a # quick idea about the purpose of the project. Keep the description short. -PROJECT_BRIEF = "A modern C++ wrapper library for SDL2" +PROJECT_BRIEF = "A modern C++ wrapper library for SDL3" # With the PROJECT_LOGO tag one can specify a logo or an icon that is included # in the documentation. The maximum height of the logo should not exceed 55 diff --git a/README.md b/README.md index d8f26a5ec..6c45621c7 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,13 @@ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![version](https://img.shields.io/github/v/release/albin-johansson/centurion)](https://github.com/albin-johansson/centurion/releases) -[![doxygen](https://img.shields.io/badge/doxygen-stable-blue)](https://albin-johansson.github.io/centurion/) [![CI](https://github.com/albin-johansson/centurion/actions/workflows/ci.yml/badge.svg)](https://github.com/albin-johansson/centurion/actions/workflows/ci.yml) ## Introduction -Centurion is a modern C++ wrapper library for SDL2 designed to improve type-safety, memory safety and overall +Centurion is a modern C++ wrapper library for SDL3 designed to improve type-safety, memory safety and overall ease-of-use. The general aim of Centurion is to serve as an easy-to-use and intuitive alternative to raw SDL2, by -providing the same features whilst being safer and easier to use. However, there are also aspects of the library that -have no direct counterparts in SDL. +providing the same features while being safer and easier to use. ```C++ #include @@ -45,55 +43,24 @@ int main(int argc, char* argv[]) } ``` -## Not Just a Wrapper Library - -Centurion is not just a wrapper library. A lot of effort has been put into improving the SDL APIs by utilising the full -power of modern C++17 and C++20. Which has led to APIs that are far more expressive and intuitive to use, compared to -plain C. - -## Features - -The following is a (non-exhaustive) list of the features of Centurion. - -* Window management -* Hardware-accelerated rendering (with basic support for OpenGL and Vulkan) -* TrueType font handling -* System events -* Keyboard input -* Mouse input -* Game controller and joystick input -* Force feedback -* Sound effects -* Music -* System information about platform, CPU, RAM, screen, battery, clipboard, counters, locale, etc. -* Filesystem information -* Cursor management -* Multi-threading utilities -* Message boxes -* Compiler information - -Additionally, many Centurion components feature serialization support based on the Cereal API, string conversions, -streaming support, etc. The library can be used with either C++17 or C++20, and will use appropriate facilities -depending on the language version used. For example, the library will make use of `std::format`, if it is available. - ## Dependencies -The following table shows the supported versions of SDL2 and its extension libraries. Only the core SDL library is +The following table shows the supported versions of SDL3 and its extension libraries. Only the core SDL library is mandatory. The extension libraries can be disabled at compile-time, by defining any of `CENTURION_NO_SDL_IMAGE` , `CENTURION_NO_SDL_MIXER` or `CENTURION_NO_SDL_TTF`, respectively. -| Dependency | Source | Supported versions | -|-----------------------|---------------------------------------------------------------------------------|--------------------| -| SDL2 | [www.libsdl.org](https://www.libsdl.org/download-2.0.php) | 2.0.10 ... 2.26 | -| SDL2_image (Optional) | [www.libsdl.org/projects/SDL_image](https://www.libsdl.org/projects/SDL_image/) | 2.0.5 ... 2.6 | -| SDL2_mixer (Optional) | [www.libsdl.org/projects/SDL_mixer](https://www.libsdl.org/projects/SDL_mixer/) | 2.0.4 ... 2.6 | -| SDL2_ttf (Optional) | [www.libsdl.org/projects/SDL_ttf](https://www.libsdl.org/projects/SDL_ttf/) | 2.0.15 ... 2.20 | +| Dependency | Source | Supported versions | +|-----------------------|-------------------------------------------------------------------------------------|--------------------| +| SDL3 | [github.com/libsdl-org/SDL](https://github.com/libsdl-org/SDL/releases) | 3.0.0 | +| SDL3_image (Optional) | [github.com/libsdl-org/SDL_image](https://github.com/libsdl-org/SDL_image/releases) | 3.0.0 | +| SDL3_mixer (Optional) | [github.com/libsdl-org/SDL_mixer](https://github.com/libsdl-org/SDL_mixer/releases) | 3.0.0 | +| SDL3_ttf (Optional) | [github.com/libsdl-org/SDL_ttf](https://github.com/libsdl-org/SDL_ttf/releases) | 3.0.0 | ## Installation The library is distributed as a header-only library, which can be found in the `src` directory. Just download the headers include them in your project, and the library it's ready to be used. You will of course also need to install -SDL2. +SDL3. ## Documentation diff --git a/cmake/FindSDL2.cmake b/cmake/FindSDL2.cmake deleted file mode 100644 index 1cdfdaa80..000000000 --- a/cmake/FindSDL2.cmake +++ /dev/null @@ -1,173 +0,0 @@ - -# This module defines -# SDL2_LIBRARY, the name of the library to link against -# SDL2_FOUND, if false, do not try to link to SDL2 -# SDL2_INCLUDE_DIR, where to find SDL.h -# -# This module responds to the the flag: -# SDL2_BUILDING_LIBRARY -# If this is defined, then no SDL2main will be linked in because -# only applications need main(). -# Otherwise, it is assumed you are building an application and this -# module will attempt to locate and set the the proper link flags -# as part of the returned SDL2_LIBRARY variable. -# -# Don't forget to include SDLmain.h and SDLmain.m your project for the -# OS X framework based version. (Other versions link to -lSDL2main which -# this module will try to find on your behalf.) Also for OS X, this -# module will automatically add the -framework Cocoa on your behalf. -# -# -# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration -# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library -# (SDL2.dll, libsdl2.so, SDL2.framework, etc). -# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again. -# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value -# as appropriate. These values are used to generate the final SDL2_LIBRARY -# variable, but when these values are unset, SDL2_LIBRARY does not get created. -# -# -# $SDL2DIR is an environment variable that would -# correspond to the ./configure --prefix=$SDL2DIR -# used in building SDL2. -# l.e.galup 9-20-02 -# -# Modified by Eric Wing. -# Added code to assist with automated building by using environmental variables -# and providing a more controlled/consistent search behavior. -# Added new modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). -# Also corrected the header search path to follow "proper" SDL guidelines. -# Added a search for SDL2main which is needed by some platforms. -# Added a search for threads which is needed by some platforms. -# Added needed compile switches for MinGW. -# -# On OSX, this will prefer the Framework version (if found) over others. -# People will have to manually change the cache values of -# SDL2_LIBRARY to override this selection or set the CMake environment -# CMAKE_INCLUDE_PATH to modify the search paths. -# -# Note that the header path has changed from SDL2/SDL.h to just SDL.h -# This needed to change because "proper" SDL convention -# is #include "SDL.h", not . This is done for portability -# reasons because not all systems place things in SDL2/ (see FreeBSD). - -#============================================================================= -# Copyright 2003-2009 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# message("") - -SET(SDL2_SEARCH_PATHS - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt - ${SDL2_PATH} - ) - -FIND_PATH(SDL2_INCLUDE_DIR SDL.h - HINTS - $ENV{SDL2DIR} - PATH_SUFFIXES include/SDL2 include - PATHS ${SDL2_SEARCH_PATHS} - ) - -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(PATH_SUFFIXES lib64 lib/x64 lib) -else() - set(PATH_SUFFIXES lib/x86 lib) -endif() - -FIND_LIBRARY(SDL2_LIBRARY_TEMP - NAMES SDL2 - HINTS - $ENV{SDL2DIR} - PATH_SUFFIXES ${PATH_SUFFIXES} - PATHS ${SDL2_SEARCH_PATHS} - ) - -IF(NOT SDL2_BUILDING_LIBRARY) - IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") - # Non-OS X framework versions expect you to also dynamically link to - # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms - # seem to provide SDL2main for compatibility even though they don't - # necessarily need it. - FIND_LIBRARY(SDL2MAIN_LIBRARY - NAMES SDL2main - HINTS - $ENV{SDL2DIR} - PATH_SUFFIXES ${PATH_SUFFIXES} - PATHS ${SDL2_SEARCH_PATHS} - ) - ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework") -ENDIF(NOT SDL2_BUILDING_LIBRARY) - -# SDL2 may require threads on your system. -# The Apple build may not need an explicit flag because one of the -# frameworks may already provide it. -# But for non-OSX systems, I will use the CMake Threads package. -IF(NOT APPLE) - FIND_PACKAGE(Threads) -ENDIF(NOT APPLE) - -# MinGW needs an additional link flag, -mwindows -# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -mwindows -IF(MINGW) - SET(MINGW32_LIBRARY mingw32 "-mwindows" CACHE STRING "mwindows for MinGW") -ENDIF(MINGW) - -IF(SDL2_LIBRARY_TEMP) - # For SDL2main - IF(NOT SDL2_BUILDING_LIBRARY) - IF(SDL2MAIN_LIBRARY) - SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP}) - ENDIF(SDL2MAIN_LIBRARY) - ENDIF(NOT SDL2_BUILDING_LIBRARY) - - # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa. - # CMake doesn't display the -framework Cocoa string in the UI even - # though it actually is there if I modify a pre-used variable. - # I think it has something to do with the CACHE STRING. - # So I use a temporary variable until the end so I can set the - # "real" variable in one-shot. - IF(APPLE) - SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa") - ENDIF(APPLE) - - # For threads, as mentioned Apple doesn't need this. - # In fact, there seems to be a problem if I used the Threads package - # and try using this line, so I'm just skipping it entirely for OS X. - IF(NOT APPLE) - SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT}) - ENDIF(NOT APPLE) - - # For MinGW library - IF(MINGW) - SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP}) - ENDIF(MINGW) - - # Set the final string here so the GUI reflects the final state. - SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found") - # Set the temp variable to INTERNAL so it is not seen in the CMake GUI - SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "") -ENDIF(SDL2_LIBRARY_TEMP) - -# message("") - -INCLUDE(FindPackageHandleStandardArgs) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR) diff --git a/cmake/FindSDL2_image.cmake b/cmake/FindSDL2_image.cmake deleted file mode 100644 index 591c1e6b0..000000000 --- a/cmake/FindSDL2_image.cmake +++ /dev/null @@ -1,102 +0,0 @@ -# Locate SDL_image library -# -# This module defines: -# -# :: -# -# SDL2_IMAGE_LIBRARIES, the name of the library to link against -# SDL2_IMAGE_INCLUDE_DIRS, where to find the headers -# SDL2_IMAGE_FOUND, if false, do not try to link against -# SDL2_IMAGE_VERSION_STRING - human-readable string containing the version of SDL_image -# -# -# -# For backward compatibility the following variables are also set: -# -# :: -# -# SDLIMAGE_LIBRARY (same value as SDL2_IMAGE_LIBRARIES) -# SDLIMAGE_INCLUDE_DIR (same value as SDL2_IMAGE_INCLUDE_DIRS) -# SDLIMAGE_FOUND (same value as SDL2_IMAGE_FOUND) -# -# -# -# $SDLDIR is an environment variable that would correspond to the -# ./configure --prefix=$SDLDIR used in building SDL. -# -# Created by Eric Wing. This was influenced by the FindSDL.cmake -# module, but with modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). - -#============================================================================= -# Copyright 2005-2009 Kitware, Inc. -# Copyright 2012 Benjamin Eikel -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -find_path(SDL2_IMAGE_INCLUDE_DIR SDL_image.h - HINTS - C:/ - ENV SDL2IMAGEDIR - ENV SDL2DIR - PATH_SUFFIXES SDL2 - # path suffixes to search inside ENV{SDLDIR} - include/SDL2 include - PATHS ${SDL2_IMAGE_PATH} - ) - -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(VC_LIB_PATH_SUFFIX lib/x64) -else() - set(VC_LIB_PATH_SUFFIX lib/x86) -endif() - -find_library(SDL2_IMAGE_LIBRARY - NAMES SDL2_image - HINTS - C:/SDL_image - ENV SDL2IMAGEDIR - ENV SDL2DIR - PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} - PATHS ${SDL2_IMAGE_PATH} - ) - -if(SDL2_IMAGE_INCLUDE_DIR AND EXISTS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h") - file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_IMAGE_INCLUDE_DIR}/SDL_image.h" SDL2_IMAGE_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+[0-9]+$") - string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_MAJOR "${SDL2_IMAGE_VERSION_MAJOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_MINOR "${SDL2_IMAGE_VERSION_MINOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_IMAGE_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_IMAGE_VERSION_PATCH "${SDL2_IMAGE_VERSION_PATCH_LINE}") - set(SDL2_IMAGE_VERSION_STRING ${SDL2_IMAGE_VERSION_MAJOR}.${SDL2_IMAGE_VERSION_MINOR}.${SDL2_IMAGE_VERSION_PATCH}) - unset(SDL2_IMAGE_VERSION_MAJOR_LINE) - unset(SDL2_IMAGE_VERSION_MINOR_LINE) - unset(SDL2_IMAGE_VERSION_PATCH_LINE) - unset(SDL2_IMAGE_VERSION_MAJOR) - unset(SDL2_IMAGE_VERSION_MINOR) - unset(SDL2_IMAGE_VERSION_PATCH) -endif() - -set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY}) -set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR}) - -include(FindPackageHandleStandardArgs) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_image - REQUIRED_VARS SDL2_IMAGE_LIBRARIES SDL2_IMAGE_INCLUDE_DIRS - VERSION_VAR SDL2_IMAGE_VERSION_STRING) - -# for backward compatibility -set(SDLIMAGE_LIBRARY ${SDL2_IMAGE_LIBRARIES}) -set(SDLIMAGE_INCLUDE_DIR ${SDL2_IMAGE_INCLUDE_DIRS}) -set(SDLIMAGE_FOUND ${SDL2_IMAGE_FOUND}) - -mark_as_advanced(SDL2_IMAGE_LIBRARY SDL2_IMAGE_INCLUDE_DIR) diff --git a/cmake/FindSDL2_mixer.cmake b/cmake/FindSDL2_mixer.cmake deleted file mode 100644 index f3fc4f9b7..000000000 --- a/cmake/FindSDL2_mixer.cmake +++ /dev/null @@ -1,101 +0,0 @@ -# Locate SDL_MIXER library -# -# This module defines: -# -# :: -# -# SDL2_MIXER_LIBRARIES, the name of the library to link against -# SDL2_MIXER_INCLUDE_DIRS, where to find the headers -# SDL2_MIXER_FOUND, if false, do not try to link against -# SDL2_MIXER_VERSION_STRING - human-readable string containing the version of SDL_MIXER -# -# -# -# For backward compatibility the following variables are also set: -# -# :: -# -# SDLMIXER_LIBRARY (same value as SDL2_MIXER_LIBRARIES) -# SDLMIXER_INCLUDE_DIR (same value as SDL2_MIXER_INCLUDE_DIRS) -# SDLMIXER_FOUND (same value as SDL2_MIXER_FOUND) -# -# -# -# $SDLDIR is an environment variable that would correspond to the -# ./configure --prefix=$SDLDIR used in building SDL. -# -# Created by Eric Wing. This was influenced by the FindSDL.cmake -# module, but with modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). - -#============================================================================= -# Copyright 2005-2009 Kitware, Inc. -# Copyright 2012 Benjamin Eikel -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -find_path(SDL2_MIXER_INCLUDE_DIR SDL_mixer.h - HINTS - ENV SDL2MIXERDIR - ENV SDL2DIR - PATH_SUFFIXES SDL2 - # path suffixes to search inside ENV{SDLDIR} - include/SDL2 include - PATHS ${SDL2_MIXER_PATH} - ) - -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(VC_LIB_PATH_SUFFIX lib/x64) -else() - set(VC_LIB_PATH_SUFFIX lib/x86) -endif() - -find_library(SDL2_MIXER_LIBRARY - NAMES SDL2_mixer - HINTS - C:/SDL_mixer - ENV SDL2MIXERDIR - ENV SDL2DIR - PATH_SUFFIXES lib bin ${VC_LIB_PATH_SUFFIX} - PATHS ${SDL2_MIXER_PATH} - ) - -if(SDL2_MIXER_INCLUDE_DIR AND EXISTS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h") - file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+[0-9]+$") - string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_MAJOR "${SDL2_MIXER_VERSION_MAJOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_MINOR "${SDL2_MIXER_VERSION_MINOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_PATCH "${SDL2_MIXER_VERSION_PATCH_LINE}") - set(SDL2_MIXER_VERSION_STRING ${SDL2_MIXER_VERSION_MAJOR}.${SDL2_MIXER_VERSION_MINOR}.${SDL2_MIXER_VERSION_PATCH}) - unset(SDL2_MIXER_VERSION_MAJOR_LINE) - unset(SDL2_MIXER_VERSION_MINOR_LINE) - unset(SDL2_MIXER_VERSION_PATCH_LINE) - unset(SDL2_MIXER_VERSION_MAJOR) - unset(SDL2_MIXER_VERSION_MINOR) - unset(SDL2_MIXER_VERSION_PATCH) -endif() - -set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY}) -set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_INCLUDE_DIR}) - -include(FindPackageHandleStandardArgs) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_mixer - REQUIRED_VARS SDL2_MIXER_LIBRARIES SDL2_MIXER_INCLUDE_DIRS - VERSION_VAR SDL2_MIXER_VERSION_STRING) - -# for backward compatibility -set(SDLMIXER_LIBRARY ${SDL2_MIXER_LIBRARIES}) -set(SDLMIXER_INCLUDE_DIR ${SDL2_MIXER_INCLUDE_DIRS}) -set(SDLMIXER_FOUND ${SDL2_MIXER_FOUND}) - -mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR) diff --git a/cmake/FindSDL2_ttf.cmake b/cmake/FindSDL2_ttf.cmake deleted file mode 100644 index 4b0774dd7..000000000 --- a/cmake/FindSDL2_ttf.cmake +++ /dev/null @@ -1,99 +0,0 @@ -# Locate SDL_ttf library -# -# This module defines: -# -# :: -# -# SDL2_TTF_LIBRARIES, the name of the library to link against -# SDL2_TTF_INCLUDE_DIRS, where to find the headers -# SDL2_TTF_FOUND, if false, do not try to link against -# SDL2_TTF_VERSION_STRING - human-readable string containing the version of SDL_ttf -# -# -# -# For backward compatibility the following variables are also set: -# -# :: -# -# SDLTTF_LIBRARY (same value as SDL2_TTF_LIBRARIES) -# SDLTTF_INCLUDE_DIR (same value as SDL2_TTF_INCLUDE_DIRS) -# SDLTTF_FOUND (same value as SDL2_TTF_FOUND) -# -# -# -# $SDLDIR is an environment variable that would correspond to the -# ./configure --prefix=$SDLDIR used in building SDL. -# -# Created by Eric Wing. This was influenced by the FindSDL.cmake -# module, but with modifications to recognize OS X frameworks and -# additional Unix paths (FreeBSD, etc). - -#============================================================================= -# Copyright 2005-2009 Kitware, Inc. -# Copyright 2012 Benjamin Eikel -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -find_path(SDL2_TTF_INCLUDE_DIR SDL_ttf.h - HINTS - C:/SDL_ttf - ENV SDL2TTFDIR - ENV SDL2DIR - PATH_SUFFIXES SDL2 - # path suffixes to search inside ENV{SDLDIR} - include/SDL2 include - PATHS ${SDL2_TTF_PATH} - ) - -if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set(VC_LIB_PATH_SUFFIX lib/x64) -else () - set(VC_LIB_PATH_SUFFIX lib/x86) -endif () - -find_library(SDL2_TTF_LIBRARY - NAMES SDL2_ttf - HINTS - ENV SDL2TTFDIR - ENV SDL2DIR - PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX} - PATHS ${SDL2_TTF_PATH} - ) - -if (SDL2_TTF_INCLUDE_DIR AND EXISTS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h") - file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+[0-9]+$") - file(STRINGS "${SDL2_TTF_INCLUDE_DIR}/SDL_ttf.h" SDL2_TTF_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+[0-9]+$") - string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_MAJOR "${SDL2_TTF_VERSION_MAJOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_TTF_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_MINOR "${SDL2_TTF_VERSION_MINOR_LINE}") - string(REGEX REPLACE "^#define[ \t]+SDL_TTF_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_TTF_VERSION_PATCH "${SDL2_TTF_VERSION_PATCH_LINE}") - set(SDL2_TTF_VERSION_STRING ${SDL2_TTF_VERSION_MAJOR}.${SDL2_TTF_VERSION_MINOR}.${SDL2_TTF_VERSION_PATCH}) - unset(SDL2_TTF_VERSION_MAJOR_LINE) - unset(SDL2_TTF_VERSION_MINOR_LINE) - unset(SDL2_TTF_VERSION_PATCH_LINE) - unset(SDL2_TTF_VERSION_MAJOR) - unset(SDL2_TTF_VERSION_MINOR) - unset(SDL2_TTF_VERSION_PATCH) -endif () - -set(SDL2_TTF_LIBRARIES ${SDL2_TTF_LIBRARY}) -set(SDL2_TTF_INCLUDE_DIRS ${SDL2_TTF_INCLUDE_DIR}) - -include(FindPackageHandleStandardArgs) - -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_ttf - REQUIRED_VARS SDL2_TTF_LIBRARIES SDL2_TTF_INCLUDE_DIRS - VERSION_VAR SDL2_TTF_VERSION_STRING) - -# for backward compatibility -set(SDLTTF_LIBRARY ${SDL2_TTF_LIBRARIES}) -set(SDLTTF_INCLUDE_DIR ${SDL2_TTF_INCLUDE_DIRS}) -set(SDLTTF_FOUND ${SDL2_TTF_FOUND}) diff --git a/cmake/centurion.cmake b/cmake/centurion.cmake deleted file mode 100644 index 81eafc905..000000000 --- a/cmake/centurion.cmake +++ /dev/null @@ -1,73 +0,0 @@ - -# Creates an interface library target for a header-only library. -# name: the name of the library target. -# includeDirectory: the path of the directory that contains the headers of the library. -# sources: the headers associated with the library. -function(cen_add_header_only_lib name includeDirectory sources) - add_library(${name} INTERFACE) - target_sources(${name} INTERFACE ${sources}) - target_include_directories(${name} SYSTEM INTERFACE ${includeDirectory}) -endfunction() - -# Copies a directory. -# target: the associated target. -# from: the directory that will be copied. -# to: the target destination of the copied directory. -function(cen_copy_directory_post_build target from to) - add_custom_command( - TARGET ${target} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory - ${from} - ${to}) -endfunction() - -function(cen_include_sdl_headers target) - target_include_directories(${target} - SYSTEM PRIVATE - ${SDL2_INCLUDE_DIR} - ${SDL2_IMAGE_INCLUDE_DIRS} - ${SDL2_TTF_INCLUDE_DIRS} - ${SDL2_MIXER_INCLUDE_DIRS}) -endfunction() - -function(cen_link_sdl_libs target) - target_link_libraries(${target} - PRIVATE - ${SDL2_LIBRARY} - ${SDL2_IMAGE_LIBRARIES} - ${SDL2_TTF_LIBRARIES} - ${SDL2_MIXER_LIBRARIES}) -endfunction() - -function(cen_set_basic_compiler_options target) - if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - target_compile_options(${target} PRIVATE - /EHsc - /MP - /W4 - /wd4996 # Disable deprecation warnings - /Zc:preprocessor # Enable conforming preprocessor - /Zc:__cplusplus # Force MSVC to use __cplusplus macro with correct value - ) - - if (TREAT_WARNINGS_AS_ERRORS MATCHES ON) - target_compile_options(${target} PRIVATE /WX) - endif () - elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU|AppleClang") - target_compile_options(${target} PRIVATE - -Wall - -Wextra - -Wpedantic - -Wconversion - -Wno-deprecated - -Wno-deprecated-declarations - -Wno-format-security - -Wno-gnu-zero-variadic-macro-arguments - ) - - if (TREAT_WARNINGS_AS_ERRORS MATCHES ON) - target_compile_options(${target} PRIVATE -Werror) - endif () - endif () -endfunction() \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 463084970..71025ec6d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,8 +1,6 @@ -cmake_minimum_required(VERSION 3.15) - -project(centurion-test CXX) +project(centurion-test LANGUAGES CXX) enable_testing() add_subdirectory(unit-tests) -add_subdirectory(mocked-tests) +#add_subdirectory(mocked-tests) diff --git a/test/unit-tests/CMakeLists.txt b/test/unit-tests/CMakeLists.txt index 29c952972..c0864ea86 100644 --- a/test/unit-tests/CMakeLists.txt +++ b/test/unit-tests/CMakeLists.txt @@ -1,241 +1,35 @@ -cmake_minimum_required(VERSION 3.15) +project(centurion-test-unit-tests LANGUAGES CXX) -project(centurion-test-unit-tests) +file(GLOB_RECURSE CENTURION_UNIT_TEST_FILES + CONFIGURE_DEPENDS + ${PROJECT_SOURCE_DIR}/*.hpp + ${PROJECT_SOURCE_DIR}/*.cpp + ) -set(SOURCE_FILES - serialization_utils.hpp +add_executable(centurion-tests ${CENTURION_UNIT_TEST_FILES}) - typed_test_macros.hpp - test_main.cpp +cen_prepare_target(centurion-tests) - concurrency/condition_test.cpp - concurrency/lock_status_test.cpp - concurrency/mutex_test.cpp - concurrency/scoped_lock_test.cpp - concurrency/semaphore_test.cpp - concurrency/thread_priority_test.cpp - concurrency/thread_test.cpp - concurrency/try_lock_test.cpp - - common/exception_test.cpp - common/features_test.cpp - common/log_category_test.cpp - common/log_priority_test.cpp - common/log_test.cpp - common/result_test.cpp - common/sdl_string_test.cpp - common/to_underlying_test.cpp - common/version_test.cpp - - detail/address_of_test.cpp - detail/clamp_test.cpp - detail/from_string_test.cpp - detail/max_test.cpp - detail/min_test.cpp - detail/owner_handle_api_test.cpp - - system/endian/endian_test.cpp - - event/event_base_test.cpp - event/event_dispatcher_test.cpp - event/event_handler_test.cpp - event/event_handler_type_check_test.cpp - event/event_type_test.cpp - - event/audio/audio_device_event_test.cpp - - event/controller/controller_axis_event_test.cpp - event/controller/controller_button_event_test.cpp - event/controller/controller_device_event_test.cpp - event/controller/controller_sensor_event_test.cpp - event/controller/controller_touchpad_event_test.cpp - - event/misc/display_event_id_test.cpp - event/misc/display_event_test.cpp - - event/gesture/dollar_gesture_event_test.cpp - event/gesture/multi_gesture_event_test.cpp - - event/joystick/joy_axis_event_test.cpp - event/joystick/joy_ball_event_test.cpp - event/joystick/joy_button_event_test.cpp - event/joystick/joy_device_event_test.cpp - event/joystick/joy_hat_event_test.cpp - event/joystick/joy_hat_position_test.cpp - - event/misc/drop_event_test.cpp - event/misc/keyboard_event_test.cpp - event/misc/quit_event_test.cpp - event/misc/sensor_event_test.cpp - event/misc/touch_finger_event_test.cpp - event/misc/user_event_test.cpp - - event/mouse/mouse_button_event_test.cpp - event/mouse/mouse_motion_event_test.cpp - event/mouse/mouse_wheel_direction_test.cpp - event/mouse/mouse_wheel_event_test.cpp - - event/text/text_editing_event_test.cpp - event/text/text_input_event_test.cpp - - event/window/window_event_id_test.cpp - event/window/window_event_test.cpp - - filesystem/base_path_test.cpp - filesystem/file_mode_test.cpp - filesystem/file_test.cpp - filesystem/file_type_test.cpp - filesystem/preferred_path_test.cpp - filesystem/seek_mode_test.cpp - - text/font/font_bundle_test.cpp - text/font/font_cache_test.cpp - text/font/font_hint_test.cpp - text/font/font_test.cpp - - input/button_state_test.cpp - - input/controller/controller_axis_test.cpp - input/controller/controller_bind_type_test.cpp - input/controller/controller_button_test.cpp - input/controller/controller_mapping_result_test.cpp - input/controller/controller_test.cpp - input/controller/controller_type_test.cpp - - input/joystick/hat_state_test.cpp - input/joystick/joystick_power_test.cpp - input/joystick/joystick_test.cpp - input/joystick/joystick_type_test.cpp - - input/keyboard/key_code_tests.cpp - input/keyboard/key_modifier_test.cpp - input/keyboard/keyboard_test.cpp - input/keyboard/scan_code_tests.cpp - - input/mouse/cursor_test.cpp - input/mouse/mouse_button_test.cpp - input/mouse/mouse_test.cpp - input/mouse/system_cursor_test.cpp - - input/sensor/sensor_test.cpp - input/sensor/sensor_type_test.cpp - - input/touch/touch_device_type_test.cpp - input/touch/touch_test.cpp - - common/math/area_test.cpp - common/math/rect_test.cpp - common/math/point_test.cpp - common/math/vector3_test.cpp - - common/memory/simd_block_test.cpp - - message-box/mb_button_flags_test.cpp - message-box/mb_button_order_test.cpp - message-box/mb_color_scheme.cpp - message-box/mb_color_type_test.cpp - message-box/mb_type_test.cpp - message-box/message_box_test.cpp - - video/pixels/palette_test.cpp - video/pixels/pixel_format_info_test.cpp - video/pixels/pixel_format_test.cpp - - system/power/battery_test.cpp - system/power/power_state_test.cpp - - video/render/graphics_drivers_test.cpp - video/render/renderer_handle_test.cpp - video/render/renderer_test.cpp - - video/render/texture/scale_mode_test.cpp - video/render/texture/texture_access_test.cpp - video/render/texture/texture_handle_test.cpp - video/render/texture/texture_test.cpp - - system/clipboard_test.cpp - system/counter_test.cpp - system/platform_id_test.cpp - system/platform_test.cpp - system/ram_test.cpp - system/shared_object_test.cpp - - system/locale/locale_test.cpp - - text/unicode/unicode_string_test.cpp - - video/color_test.cpp - - video/blend-mode/blend_factor_test.cpp - video/blend-mode/blend_mode_test.cpp - video/blend-mode/blend_op_test.cpp - - video/display/display_mode_test.cpp - video/display/display_test.cpp - video/display/orientation_test.cpp - - video/opengl/gl_attribute_test.cpp - video/opengl/gl_swap_interval_test.cpp - - video/surface/surface_handle_test.cpp - video/surface/surface_test.cpp - - video/window/flash_op_test.cpp - video/window/window_flags_test.cpp - video/window/window_test.cpp - video/window/window_handle_test.cpp - ) - -if (INCLUDE_AUDIO_TESTS) - list(APPEND - SOURCE_FILES - audio/fade_status_test.cpp - audio/music_test.cpp - audio/music_type_test.cpp - audio/sound_effect_test.cpp - ) -endif () - -add_executable(${CENTURION_TEST_TARGET} ${SOURCE_FILES}) - -target_include_directories(${CENTURION_TEST_TARGET} +target_include_directories(centurion-tests PRIVATE ${PROJECT_SOURCE_DIR} - ${CEN_SOURCE_DIR} + ${CEN_INCLUDE_DIR} ) -cen_include_sdl_headers(${CENTURION_TEST_TARGET}) - -cen_link_sdl_libs(${CENTURION_TEST_TARGET}) - -target_link_libraries(${CENTURION_TEST_TARGET} +target_link_libraries(centurion-tests PRIVATE + SDL3::SDL3 cereal::cereal GLEW::GLEW GTest::gtest ) -cen_set_basic_compiler_options(${CENTURION_TEST_TARGET}) - -if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - target_compile_options(${CENTURION_TEST_TARGET} - PRIVATE - /wd4834 # Disable [[nodiscard]] warnings - ) - -elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU|AppleClang") - target_compile_options(${CENTURION_TEST_TARGET} - PRIVATE - -Wno-unused-result - ) -endif () - -if (INCLUDE_AUDIO_TESTS) - target_compile_definitions(${CENTURION_TEST_TARGET} PRIVATE CENTURION_INCLUDE_AUDIO_TESTS) +if (CEN_INCLUDE_AUDIO_TESTS MATCHES ON) + target_compile_definitions(centurion-tests PRIVATE CENTURION_INCLUDE_AUDIO_TESTS) endif () -target_precompile_headers(${CENTURION_TEST_TARGET} PRIVATE - +target_precompile_headers(centurion-tests PRIVATE + @@ -250,12 +44,10 @@ target_precompile_headers(${CENTURION_TEST_TARGET} PRIVATE ) -add_test(NAME ${CENTURION_TEST_TARGET} COMMAND ${CENTURION_TEST_TARGET}) +add_test(NAME centurion-tests COMMAND centurion-tests) -cen_copy_directory_post_build(${CENTURION_TEST_TARGET} - ${CEN_RESOURCES_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/resources) +file(COPY ${CEN_RESOURCES_DIR} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/resources) if (WIN32) - cen_copy_directory_post_build(${CENTURION_TEST_TARGET} ${CEN_BINARIES_DIR} ${CMAKE_CURRENT_BINARY_DIR}) + file(COPY ${CEN_BINARIES_DIR} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) endif () \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json index e4fa5d7e3..8110d3617 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,9 +1,9 @@ { "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", "name": "centurion", - "description": "A modern C++ wrapper library for SDL2", + "description": "A modern C++ wrapper library for SDL3", "license": "MIT", - "version-semver": "7.3.0", + "version-semver": "8.0.0", "maintainers": [ "albin-johansson" ],