Merge pull request #1 from enduro2d/feature/cmake_template

Feature/cmake template
This commit is contained in:
BlackMat MATov
2018-09-28 01:47:06 +03:00
committed by GitHub
17 changed files with 270 additions and 0 deletions

11
.appveyor.yml Normal file
View File

@@ -0,0 +1,11 @@
version: "{build}"
image:
- Visual Studio 2015
- Visual Studio 2017
platform:
- Win32
- x64
build_script:
- git submodule update --init --recursive
- scripts\build_all.bat
test: off

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
build/*
CMakeLists.txt.user

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "modules/enduro2d"]
path = modules/enduro2d
url = https://github.com/enduro2d/enduro2d

77
.travis.yml Normal file
View File

@@ -0,0 +1,77 @@
language: cpp
matrix:
include:
- os: linux
dist: trusty
addons: { apt: { sources: ubuntu-toolchain-r-test, packages: ["xorg-dev", "g++-4.9"] } }
env: MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
- os: linux
dist: trusty
addons: { apt: { sources: ubuntu-toolchain-r-test, packages: ["xorg-dev", "g++-5"] } }
env: MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"
- os: linux
dist: trusty
addons: { apt: { sources: ubuntu-toolchain-r-test, packages: ["xorg-dev", "g++-6"] } }
env: MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"
- os: linux
dist: trusty
addons: { apt: { sources: ubuntu-toolchain-r-test, packages: ["xorg-dev", "g++-7"] } }
env: MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"
- os: linux
dist: trusty
addons: { apt: { sources: ubuntu-toolchain-r-test, packages: ["xorg-dev", "g++-8"] } }
env: MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"
- os: linux
dist: trusty
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-precise-3.6"], packages: ["xorg-dev", "clang-3.6", "g++-5"] } }
env: MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6"
- os: linux
dist: trusty
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-precise-3.7"], packages: ["xorg-dev", "clang-3.7", "g++-5"] } }
env: MATRIX_EVAL="CC=clang-3.7 && CXX=clang++-3.7"
- os: linux
dist: trusty
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-precise-3.8"], packages: ["xorg-dev", "clang-3.8", "g++-5"] } }
env: MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8"
- os: linux
dist: trusty
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-precise-3.9"], packages: ["xorg-dev", "clang-3.9", "g++-5"] } }
env: MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9"
- os: linux
dist: trusty
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-4.0"], packages: ["xorg-dev", "clang-4.0", "g++-5"] } }
env: MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"
- os: linux
dist: trusty
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-5.0"], packages: ["xorg-dev", "clang-5.0", "g++-7"] } }
env: MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"
- os: linux
dist: trusty
addons: { apt: { sources: ["ubuntu-toolchain-r-test", "llvm-toolchain-trusty-6.0"], packages: ["xorg-dev", "clang-6.0", "g++-7"] } }
env: MATRIX_EVAL="CC=clang-6.0 && CXX=clang++-6.0"
- os: osx
osx_image: xcode8.3
compiler: clang
- os: osx
osx_image: xcode9
compiler: clang
- os: osx
osx_image: xcode9.1
compiler: clang
- os: osx
osx_image: xcode9.2
compiler: clang
- os: osx
osx_image: xcode9.3
compiler: clang
- os: osx
osx_image: xcode9.4
compiler: clang
- os: osx
osx_image: xcode10
compiler: clang
before_install:
- eval "${MATRIX_EVAL}"
script:
- git submodule update --init --recursive
- ./scripts/build_all.sh

61
CMakeLists.txt Normal file
View 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

Submodule modules/enduro2d added at 433578975d

10
scripts/build_all.bat Normal file
View 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
View 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
View 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
View 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
View 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
View 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
View 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
View 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 ../..

View 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
View 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
View 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;
}