mirror of
https://github.com/enduro2d/enduro2d-bootstrap.git
synced 2025-12-13 03:31:18 +07:00
cmake template
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
build/*
|
||||||
|
CMakeLists.txt.user
|
||||||
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "modules/enduro2d"]
|
||||||
|
path = modules/enduro2d
|
||||||
|
url = https://github.com/enduro2d/enduro2d
|
||||||
61
CMakeLists.txt
Normal file
61
CMakeLists.txt
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.9.2 FATAL_ERROR)
|
||||||
|
project(enduro2d-bootstrap)
|
||||||
|
|
||||||
|
#
|
||||||
|
# linking mode
|
||||||
|
#
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
option(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC runtime library DLL" OFF)
|
||||||
|
if(NOT USE_MSVC_RUNTIME_LIBRARY_DLL)
|
||||||
|
foreach(flag CMAKE_C_FLAGS
|
||||||
|
CMAKE_C_FLAGS_DEBUG
|
||||||
|
CMAKE_C_FLAGS_RELEASE
|
||||||
|
CMAKE_C_FLAGS_MINSIZEREL
|
||||||
|
CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||||
|
CMAKE_CXX_FLAGS
|
||||||
|
CMAKE_CXX_FLAGS_DEBUG
|
||||||
|
CMAKE_CXX_FLAGS_RELEASE
|
||||||
|
CMAKE_CXX_FLAGS_MINSIZEREL
|
||||||
|
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||||
|
if(${flag} MATCHES "/MD")
|
||||||
|
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
|
||||||
|
endif()
|
||||||
|
if(${flag} MATCHES "/MDd")
|
||||||
|
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# include enduro2d
|
||||||
|
#
|
||||||
|
|
||||||
|
set(E2D_BUILD_SAMPLES OFF CACHE BOOL "" FORCE)
|
||||||
|
set(E2D_BUILD_UNTESTS OFF CACHE BOOL "" FORCE)
|
||||||
|
add_subdirectory(modules/enduro2d)
|
||||||
|
|
||||||
|
#
|
||||||
|
# project sources
|
||||||
|
#
|
||||||
|
|
||||||
|
file(GLOB_RECURSE PROJECT_SOURCES
|
||||||
|
sources/*.*)
|
||||||
|
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES
|
||||||
|
${PROJECT_SOURCES})
|
||||||
|
|
||||||
|
#
|
||||||
|
# project executable
|
||||||
|
#
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME}
|
||||||
|
${PROJECT_SOURCES})
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
${E2D_LIBRARIES})
|
||||||
|
target_include_directories(${PROJECT_NAME}
|
||||||
|
PRIVATE ${E2D_INCLUDE_DIRS})
|
||||||
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||||
|
CXX_STANDARD 14
|
||||||
|
CXX_STANDARD_REQUIRED YES
|
||||||
|
CXX_EXTENSIONS NO)
|
||||||
1
modules/enduro2d
Submodule
1
modules/enduro2d
Submodule
Submodule modules/enduro2d added at 433578975d
10
scripts/build_all.bat
Normal file
10
scripts/build_all.bat
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
@echo off
|
||||||
|
set SCRIPT_DIR=%~dp0%
|
||||||
|
%SCRIPT_DIR%\build_debug.bat || goto :error
|
||||||
|
%SCRIPT_DIR%\build_release.bat || goto :error
|
||||||
|
|
||||||
|
goto :EOF
|
||||||
|
|
||||||
|
:error
|
||||||
|
echo Failed with error #%errorlevel%.
|
||||||
|
exit /b %errorlevel%
|
||||||
5
scripts/build_all.sh
Executable file
5
scripts/build_all.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
SCRIPT_DIR=`dirname "$BASH_SOURCE"`
|
||||||
|
$SCRIPT_DIR/build_debug.sh
|
||||||
|
$SCRIPT_DIR/build_release.sh
|
||||||
9
scripts/build_clear.bat
Normal file
9
scripts/build_clear.bat
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
@echo off
|
||||||
|
set BUILD_DIR=%~dp0%\..\build
|
||||||
|
rmdir /s /q %BUILD_DIR% || goto :error
|
||||||
|
|
||||||
|
goto :EOF
|
||||||
|
|
||||||
|
:error
|
||||||
|
echo Failed with error #%errorlevel%.
|
||||||
|
exit /b %errorlevel%
|
||||||
4
scripts/build_clear.sh
Executable file
4
scripts/build_clear.sh
Executable file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
BUILD_DIR=`dirname "$BASH_SOURCE"`/../build
|
||||||
|
rm -rf $BUILD_DIR
|
||||||
13
scripts/build_debug.bat
Normal file
13
scripts/build_debug.bat
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
@echo off
|
||||||
|
set BUILD_DIR=%~dp0%\..\build
|
||||||
|
mkdir %BUILD_DIR%\debug || goto :error
|
||||||
|
cd %BUILD_DIR%\debug || goto :error
|
||||||
|
cmake ../.. || goto :error
|
||||||
|
cmake --build . --config Debug || goto :error
|
||||||
|
cd ..\.. || goto :error
|
||||||
|
|
||||||
|
goto :EOF
|
||||||
|
|
||||||
|
:error
|
||||||
|
echo Failed with error #%errorlevel%.
|
||||||
|
exit /b %errorlevel%
|
||||||
8
scripts/build_debug.sh
Executable file
8
scripts/build_debug.sh
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
BUILD_DIR=`dirname "$BASH_SOURCE"`/../build
|
||||||
|
mkdir -p $BUILD_DIR/debug
|
||||||
|
cd $BUILD_DIR/debug
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Debug ../..
|
||||||
|
cmake --build . -- -j8
|
||||||
|
cd ../..
|
||||||
13
scripts/build_release.bat
Normal file
13
scripts/build_release.bat
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
@echo off
|
||||||
|
set BUILD_DIR=%~dp0%\..\build
|
||||||
|
mkdir %BUILD_DIR%\release || goto :error
|
||||||
|
cd %BUILD_DIR%\release || goto :error
|
||||||
|
cmake ../.. || goto :error
|
||||||
|
cmake --build . --config Release || goto :error
|
||||||
|
cd ..\.. || goto :error
|
||||||
|
|
||||||
|
goto :EOF
|
||||||
|
|
||||||
|
:error
|
||||||
|
echo Failed with error #%errorlevel%.
|
||||||
|
exit /b %errorlevel%
|
||||||
8
scripts/build_release.sh
Executable file
8
scripts/build_release.sh
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
BUILD_DIR=`dirname "$BASH_SOURCE"`/../build
|
||||||
|
mkdir -p $BUILD_DIR/release
|
||||||
|
cd $BUILD_DIR/release
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Release ../..
|
||||||
|
cmake --build . -- -j8
|
||||||
|
cd ../..
|
||||||
12
scripts/gen_msvc2017_project.bat
Normal file
12
scripts/gen_msvc2017_project.bat
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
@echo off
|
||||||
|
set BUILD_DIR=%~dp0%\..\build
|
||||||
|
mkdir %BUILD_DIR%\msvc2017 || goto :error
|
||||||
|
cd %BUILD_DIR%\msvc2017 || goto :error
|
||||||
|
cmake -G "Visual Studio 15 2017" ..\.. || goto :error
|
||||||
|
start enduro2d-bootstrap.sln || goto :error
|
||||||
|
|
||||||
|
goto :EOF
|
||||||
|
|
||||||
|
:error
|
||||||
|
echo Failed with error #%errorlevel%.
|
||||||
|
exit /b %errorlevel%
|
||||||
7
scripts/gen_xcode_project.sh
Executable file
7
scripts/gen_xcode_project.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
BUILD_DIR=`dirname "$BASH_SOURCE"`/../build
|
||||||
|
mkdir -p $BUILD_DIR/xcode
|
||||||
|
cd $BUILD_DIR/xcode
|
||||||
|
cmake -G Xcode ../..
|
||||||
|
open enduro2d-bootstrap.xcodeproj
|
||||||
26
sources/main.cpp
Normal file
26
sources/main.cpp
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018 Matvey Cherevko
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include <enduro2d/enduro2d.hpp>
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
int e2d_main() {
|
||||||
|
input& i = modules::initialize<input>();
|
||||||
|
debug& d = modules::initialize<debug>();
|
||||||
|
window& w = modules::initialize<window>(
|
||||||
|
v2u{640, 480}, "Enduro2D", true, false);
|
||||||
|
|
||||||
|
d.add_sink<debug_console_sink>();
|
||||||
|
w.register_event_listener<window_input_source>(i);
|
||||||
|
|
||||||
|
const keyboard& k = i.keyboard();
|
||||||
|
while ( !w.should_close() && !k.is_key_just_released(keyboard_key::escape) ) {
|
||||||
|
i.frame_tick();
|
||||||
|
w.swap_buffers();
|
||||||
|
window::frame_tick();
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user