Adding CMake again :)
This commit is contained in:
parent
cb4274bb1c
commit
2dc8050ce3
10 changed files with 384 additions and 0 deletions
42
CMakeLists.txt
Normal file
42
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# ------------------------------------------------------------
|
||||
#
|
||||
# Spectre main Cmake config
|
||||
#
|
||||
# ------------------------------------------------------------
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
|
||||
|
||||
# set the project name
|
||||
project(Spectre
|
||||
VERSION 0.0.1
|
||||
DESCRIPTION ""
|
||||
HOMEPAGE_URL "")
|
||||
|
||||
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake" )
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# Compiler
|
||||
# -------------------------------
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
if (MSVC)
|
||||
add_definitions("/EHsc -D_CRT_SECURE_NO_WARNINGS")
|
||||
|
||||
# Staticly link with MSVCR
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
||||
endif (MSVC)
|
||||
|
||||
|
||||
# Variables
|
||||
# -------------------------------
|
||||
|
||||
# Include engine
|
||||
include(engine.cmake)
|
||||
|
||||
# Include examples
|
||||
add_subdirectory(examples)
|
||||
7
cmake/Macros.cmake
Normal file
7
cmake/Macros.cmake
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
function(spectre_example NAME)
|
||||
add_executable(example_${NAME} ${ARGN})
|
||||
target_link_libraries(example_${NAME} PRIVATE Spectre)
|
||||
set_target_properties(example_${NAME} PROPERTIES VS_GLOBAL_IgnoreImportLibrary "true")
|
||||
#set_target_properties(${NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
|
||||
endfunction()
|
||||
31
cmake/SpectreConfig.cmake.in
Normal file
31
cmake/SpectreConfig.cmake.in
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# This script provides the spectre as an import target
|
||||
# ----------------------------------------------------------
|
||||
#
|
||||
# Use find_package() so cmake will find spectre:
|
||||
#
|
||||
# find_package(spectre) # No specific version
|
||||
# find_package(spectre REQUIRED) # No specific version, but the library must be found.
|
||||
# find_package(spectre 0.1) # any 0.1.x, but the library is optional.
|
||||
# find_package(spectre 0.1.0) # 0.1.0 or greater, but the library is optional.
|
||||
#
|
||||
# Then you just link your target with spectre:
|
||||
#
|
||||
# target_link_libraries( ${PROGRAM_EXE} PUBLIC spectre )
|
||||
#
|
||||
# if you do not specify REQUIRED. you must check the variable spectre_FOUND
|
||||
# and and only link to it if it's defined:
|
||||
#
|
||||
# if (spectre_FOUND)
|
||||
# ...
|
||||
# target_link_libraries( ${PROGRAM_EXE} PUBLIC spectre )
|
||||
# ..
|
||||
# endif()
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
find_package(OpenGL)
|
||||
|
||||
set_and_check( SPECTRE_ASSETS "@PACKAGE_ASSETS_DIR@" )
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/SpectreTargets.cmake")
|
||||
check_required_components(Spectre)
|
||||
224
engine.cmake
Normal file
224
engine.cmake
Normal file
|
|
@ -0,0 +1,224 @@
|
|||
# ------------------------------------------------------------
|
||||
#
|
||||
# Engine library build config
|
||||
#
|
||||
# ------------------------------------------------------------
|
||||
|
||||
# Source
|
||||
# ------------------------------------------------------------
|
||||
|
||||
set( ENGINE_SRC
|
||||
# Core
|
||||
source/Core/String.cpp
|
||||
|
||||
# System
|
||||
source/System/ByteOrder.cpp
|
||||
source/System/Event.cpp
|
||||
source/System/EventListener.cpp
|
||||
source/System/File.cpp
|
||||
source/System/Log.cpp
|
||||
source/System/MessageHandler.cpp
|
||||
source/System/MessageQueue.cpp
|
||||
source/System/Path.cpp
|
||||
source/System/Stopwatch.cpp
|
||||
|
||||
# Platform
|
||||
source/Platform/PlatformApplication.cpp
|
||||
source/Platform/PlatformDisplay.cpp
|
||||
|
||||
# Math
|
||||
source/Math/Color.cpp
|
||||
source/Math/Logarithm.cpp
|
||||
source/Math/Time.cpp
|
||||
source/Math/Transform.cpp
|
||||
source/Math/Math.cpp
|
||||
|
||||
# Input
|
||||
source/Input/InputDevice.cpp
|
||||
source/Input/InputModule.cpp
|
||||
source/Input/Keyboard.cpp
|
||||
source/Input/Mouse.cpp
|
||||
|
||||
# Display
|
||||
source/Display/Display.cpp
|
||||
source/Display/DisplayDescription.cpp
|
||||
source/Display/DisplayMode.cpp
|
||||
source/Display/GLContext.cpp
|
||||
|
||||
# GfxDriver
|
||||
source/GfxDriver/ShaderProgram.cpp
|
||||
|
||||
# Graphics
|
||||
source/Graphics/BatchRenderer2D.cpp
|
||||
source/Graphics/DefaultRenderer2D.cpp
|
||||
source/Graphics/Renderable2D.cpp
|
||||
source/Graphics/Renderer2D.cpp
|
||||
source/Graphics/RenderState.cpp
|
||||
source/Graphics/Sprite.cpp
|
||||
source/Graphics/Text.cpp
|
||||
source/Graphics/Texture.cpp
|
||||
source/Graphics/Transformable.cpp
|
||||
source/Graphics/Vertex2D.cpp
|
||||
source/Graphics/Graphics.cpp
|
||||
|
||||
# Graphics - Font
|
||||
source/Graphics/Font/Engine/FreeTypeEngine.cpp
|
||||
source/Graphics/Font/Engine/FreeTypeError.cpp
|
||||
source/Graphics/Font/Engine/FreeTypeLib.cpp
|
||||
source/Graphics/Font/FontDescription.cpp
|
||||
source/Graphics/Font.cpp
|
||||
|
||||
# Graphics - Image
|
||||
source/Graphics/Image/IcoFormat.cpp
|
||||
source/Graphics/ImageLoader.cpp
|
||||
source/Graphics/PixelFormat.cpp
|
||||
source/Graphics/Image.cpp
|
||||
|
||||
# Graphics - GL
|
||||
source/Graphics/GL/glad.c
|
||||
source/Graphics/GL/CheckError.cpp
|
||||
|
||||
# Scene
|
||||
source/Scene/Camera2D.cpp
|
||||
|
||||
# Game
|
||||
source/Game/FPSCounter.cpp
|
||||
source/Game/GameTime.cpp
|
||||
source/Game.cpp
|
||||
)
|
||||
|
||||
set(ENGINE_GFXDRIVER_OPENGL_SRC
|
||||
source/GfxDriver/OpenGL/OpenGLDrv.cpp
|
||||
source/GfxDriver/OpenGL/OpenGLShaderProgram.cpp
|
||||
)
|
||||
|
||||
set(ENGINE_PLATFORM_WIN32_SRC
|
||||
source/Platform/Win32/Win32Application.cpp
|
||||
source/Platform/Win32/Win32Display.cpp
|
||||
source/Platform/Win32/Win32GLContext.cpp
|
||||
source/Platform/Win32/Win32Input.cpp
|
||||
source/Platform/Win32/Win32Internal.cpp
|
||||
source/Platform/Win32/Win32Keyboard.cpp
|
||||
source/Platform/Win32/Win32Misc.cpp
|
||||
source/Platform/Win32/Win32Mouse.cpp
|
||||
source/Platform/Win32/Win32EventQueue.cpp
|
||||
source/Platform/Win32/Win32System.cpp
|
||||
source/Platform/Win32/glad_wgl.c
|
||||
)
|
||||
|
||||
set(ENGINE_PLATFORM_UNIX_SRC
|
||||
source/Platform/X11/Xlib.cpp
|
||||
source/Platform/X11/UnixApplication.cpp
|
||||
source/Platform/X11/X11Display.cpp
|
||||
source/Platform/X11/GLXContext.cpp
|
||||
source/Platform/X11/X11Input.cpp
|
||||
source/Platform/X11/X11Keyboard.cpp
|
||||
source/Platform/X11/X11Mouse.cpp
|
||||
source/Platform/X11/X11EventQueue.cpp
|
||||
source/Platform/X11/X11WindowEventHandler.cpp
|
||||
source/Platform/X11/UnixMisc.cpp
|
||||
source/Platform/X11/UnixSystem.cpp
|
||||
source/Platform/X11/glad_glx.c
|
||||
)
|
||||
|
||||
|
||||
# Library
|
||||
# ------------------------------------------------------------
|
||||
|
||||
add_library( Spectre STATIC ${ENGINE_SRC} )
|
||||
target_include_directories(Spectre
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_LIST_DIR}/source
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
target_compile_options(Spectre PRIVATE "-DSPECTRE_PLATFORM_WIN=1")
|
||||
else()
|
||||
target_compile_options(Spectre PRIVATE "-DSPECTRE_PLATFORM_UNIX=1")
|
||||
endif()
|
||||
|
||||
|
||||
# Dependancies
|
||||
# ------------------------------------------------------------
|
||||
|
||||
# Select platform.
|
||||
if (WIN32)
|
||||
target_sources(Spectre PRIVATE ${ENGINE_PLATFORM_WIN32_SRC})
|
||||
else()
|
||||
target_sources(Spectre PRIVATE ${ENGINE_PLATFORM_UNIX_SRC})
|
||||
endif (WIN32)
|
||||
|
||||
# Select graphics API
|
||||
|
||||
# Only OpenGL Driver for now
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_sources(Spectre PRIVATE ${ENGINE_GFXDRIVER_OPENGL_SRC})
|
||||
target_link_libraries(Spectre PRIVATE OpenGL::GL)
|
||||
|
||||
# FreeType
|
||||
add_subdirectory(vendor/FreeType2)
|
||||
target_sources(Spectre PRIVATE $<TARGET_OBJECTS:freetype>)
|
||||
target_include_directories(Spectre PRIVATE $<TARGET_PROPERTY:freetype,INTERFACE_INCLUDE_DIRECTORIES>)
|
||||
|
||||
# STB
|
||||
target_include_directories(Spectre PRIVATE ${CMAKE_CURRENT_LIST_DIR}/vendor/stb/include)
|
||||
|
||||
# Install
|
||||
# ------------------------------------------------------------
|
||||
|
||||
# Includes
|
||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/Spectre TYPE INCLUDE)
|
||||
|
||||
# Assets
|
||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/assets DESTINATION ${CMAKE_INSTALL_DATADIR})
|
||||
|
||||
|
||||
# Install - CMake targets
|
||||
# ------------------------------------------------------------
|
||||
|
||||
install(TARGETS Spectre
|
||||
EXPORT SpectreTargets
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
|
||||
install(EXPORT SpectreTargets
|
||||
FILE SpectreTargets.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Spectre
|
||||
)
|
||||
|
||||
# Build directory target
|
||||
export(EXPORT SpectreTargets
|
||||
FILE "${CMAKE_CURRENT_BINARY_DIR}/SpectreTargets.cmake"
|
||||
)
|
||||
|
||||
# CMake config
|
||||
# ------------------------------------------------------------
|
||||
|
||||
# Version
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(SpectreConfigVersion.cmake COMPATIBILITY SameMajorVersion)
|
||||
|
||||
set (ASSETS_DIR ${CMAKE_INSTALL_DATADIR}/assets)
|
||||
configure_package_config_file(cmake/SpectreConfig.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmake/SpectreConfig.cmake
|
||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Spectre
|
||||
PATH_VARS ASSETS_DIR)
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/SpectreConfig.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/SpectreConfigVersion.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Spectre)
|
||||
|
||||
# CMake config - build directory
|
||||
# ------------------------------------------------------------
|
||||
set (ASSETS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/assets)
|
||||
configure_package_config_file(cmake/SpectreConfig.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/SpectreConfig.cmake
|
||||
INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
|
||||
INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PATH_VARS ASSETS_DIR)
|
||||
7
examples/CMakeLists.txt
Normal file
7
examples/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
include("Macros")
|
||||
|
||||
add_subdirectory(display)
|
||||
add_subdirectory(events)
|
||||
add_subdirectory(input)
|
||||
add_subdirectory(text)
|
||||
12
examples/display/CMakeLists.txt
Normal file
12
examples/display/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
#find_package(Spectre REQUIRED)
|
||||
|
||||
set (SOURCE
|
||||
DisplayExample.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
spectre_example(display
|
||||
main.cpp
|
||||
DisplayExample.cpp
|
||||
)
|
||||
7
examples/events/CMakeLists.txt
Normal file
7
examples/events/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
#find_package(Spectre REQUIRED)
|
||||
|
||||
spectre_example(events
|
||||
main.cpp
|
||||
EventsExample.cpp
|
||||
)
|
||||
7
examples/input/CMakeLists.txt
Normal file
7
examples/input/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
#find_package(Spectre REQUIRED)
|
||||
|
||||
spectre_example(input
|
||||
main.cpp
|
||||
InputExample.cpp
|
||||
)
|
||||
7
examples/text/CMakeLists.txt
Normal file
7
examples/text/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
#find_package(Spectre REQUIRED)
|
||||
|
||||
spectre_example(text
|
||||
main.cpp
|
||||
Game.cpp
|
||||
)
|
||||
40
vendor/FreeType2/CMakeLists.txt
vendored
Normal file
40
vendor/FreeType2/CMakeLists.txt
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# ------------------------------------------------------------
|
||||
#
|
||||
# Spectre FreeType config
|
||||
#
|
||||
# ------------------------------------------------------------
|
||||
|
||||
set(FT2_SOURCE
|
||||
src/autofit/autofit.c
|
||||
src/base/ftbase.c
|
||||
src/base/ftbbox.c
|
||||
src/base/ftbdf.c
|
||||
src/base/ftbitmap.c
|
||||
src/base/ftcid.c
|
||||
src/base/ftfstype.c
|
||||
src/base/ftgasp.c
|
||||
src/base/ftglyph.c
|
||||
src/base/ftgxval.c
|
||||
src/base/ftinit.c
|
||||
src/base/ftmm.c
|
||||
src/base/ftotval.c
|
||||
src/base/ftpatent.c
|
||||
src/base/ftpfr.c
|
||||
src/base/ftstroke.c
|
||||
src/base/ftsynth.c
|
||||
src/base/ftsystem.c
|
||||
src/base/fttype1.c
|
||||
src/base/ftwinfnt.c
|
||||
src/cff/cff.c
|
||||
src/psaux/psaux.c
|
||||
src/pshinter/pshinter.c
|
||||
src/psnames/psnames.c
|
||||
src/raster/raster.c
|
||||
src/sfnt/sfnt.c
|
||||
src/smooth/smooth.c
|
||||
src/truetype/truetype.c
|
||||
)
|
||||
|
||||
add_library( freetype OBJECT ${FT2_SOURCE} )
|
||||
target_include_directories(freetype PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
target_compile_definitions(freetype PRIVATE FT2_BUILD_LIBRARY)
|
||||
Loading…
Add table
Add a link
Reference in a new issue