Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ if(KREPEL_INSTALL_TARGETS_FILE)
RENAME "krepel.cmake")
endif()

kr_post_config()
include(kr_create_target_pullRuntimeBinaries)
# Note: KREPEL_BINARY_PULL_PATH is created within kr_setup.
kr_create_target_pullRuntimeBinaries("${KREPEL_DIR}/bin" ${KREPEL_BINARY_PULL_PATH})
18 changes: 0 additions & 18 deletions build/CMake/kr_client_copy_dlls.cmake

This file was deleted.

13 changes: 13 additions & 0 deletions build/CMake/kr_create_target_pullRuntimeBinaries.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

# kr_create_target_pullRuntimeBinaries(./bin ../output/binary_files ${somewhere_else}/binaries)
function(kr_create_target_pullRuntimeBinaries PULL_DESTINATION)
set(PULL_PATH ${ARGN})

# Set up the "pull binaries" script
configure_file("${KREPEL_DIR}/build/CMake/pullRuntimeBinaries.cmake.in" "${CMAKE_BINARY_DIR}/pullRuntimeBinaries.cmake" @ONLY)

add_custom_target(pullRuntimeBinaries ALL
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/pullRuntimeBinaries.cmake"
COMMENT "Pulling external binaries (.dll, .pdb, ...) from the toolbox.")

endfunction()
2 changes: 1 addition & 1 deletion build/CMake/kr_set_pch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function(kr_set_pch TARGET_NAME PCH_H)
if(NOT EXISTS "${PCH_CPP}")
file(WRITE "${PCH_CPP}"
"// This file was automatically generated by the krepel build system.\n"
"// This file is empty on purpose."
"// This file is empty on purpose.\n"
"// It is used to create the precompield header file (.pch).\n"
"// Do not add anything to this file, your changes will be lost!\n"
"// Do not check it into your VCS.\n")
Expand Down
12 changes: 0 additions & 12 deletions build/CMake/kr_setup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ macro(kr_setup)
unset(KREPEL_VERSION_CATCH CACHE)
endif()

add_custom_target(pullRuntimeBinaries ALL
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_BINARY_DIR}/pullRuntimeBinaries.cmake"
COMMENT "Pulling external binaries (.dll, .pdb, ...) from the toolbox.")

# Use at least C++11
set(CMAKE_CXX_STANDARD 11)

Expand All @@ -51,11 +47,3 @@ macro(kr_setup)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG} "${CMAKE_SOURCE_DIR}/lib")
endforeach()
endmacro()

function(kr_post_config)
# Set up the "pull binaries" script
set(PULL_PATH ${KREPEL_BINARY_PULL_PATH})
set(PULL_DESTINATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
configure_file("${KREPEL_DIR}/build/CMake/pullRuntimeBinaries.cmake.in" "${CMAKE_BINARY_DIR}/pullRuntimeBinaries.cmake" @ONLY)
endfunction()

44 changes: 24 additions & 20 deletions build/CMake/platforms/Windows.cmake
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
# Windows specific settings.

if(MSVC)
# Enable multi-threaded compilation.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
add_compile_options(
# Enable multi-threaded compilation.
#"/MP"

# Treat warnings as errors.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
# Treat warnings as errors.
"/WX"

# Disable RTTI.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
# Disable RTTI.
"/GR-"

# Use fast floating point model.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
# Use fast floating point model.
"/fp:fast"

# Enable floating point exceptions.
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:except")
# Enable floating point exceptions.
#"/fp:except"
)

# Enable debugging local variables in optimized code.
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Zo")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /Zo")
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /Zo")
set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /Zo")


# Enable debugging local variables in optimized code.
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Zo")

set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /INCREMENTAL:NO")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /INCREMENTAL:NO")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /INCREMENTAL:NO")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /INCREMENTAL:NO")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /INCREMENTAL:NO")

set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /OPT:REF")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /OPT:REF")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /OPT:REF")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /OPT:REF")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /OPT:REF")

set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /OPT:ICF")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /OPT:ICF")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /OPT:ICF")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} /OPT:ICF")
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /OPT:ICF")

else()
message(WARNING "Unknown compiler on Windows.")
endif()
25 changes: 25 additions & 0 deletions build/CMake/project_template/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# EditorConfig settings file.
# Check it out: http://editorconfig.org/
# There is a plugin for visual studio, sublime text 2/3, notepad++, vim, and more

# Editor config plugins will stop searching for any other .editorconfig file
# if the following is set to true
root = true

# Use unix line endings for all files
[*]
# Unix style line endings (\\n)
end_of_line = lf

# Use 2 spaces for indentation
indent_style = space
indent_size = 2

# At least 1 blank line at the end of the file
insert_final_newline = true

# Use UTF-8 as encoding
charset = utf8

# Remove annoying white space at the end of a line
trim_trailing_whitespace = true
9 changes: 9 additions & 0 deletions build/CMake/project_template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Note: To check in binaries or libs, use `git add --force /bin/whatever.dll`.
/bin/
/lib/

# This is the intended place to generate CMake stuff in, i.e. the CMake binary dir.
/workspace/

# Windows thumbnails.
[tT]humbs.[dD][bB]
33 changes: 33 additions & 0 deletions build/CMake/project_template/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

cmake_minimum_required(VERSION 3.2 FATAL_ERROR)

# Name of the entire project.
project("~friendly_name")

find_path(KREPEL_DIR lib/krEngine.lib
PATHS "$ENV{KREPEL_DIR}" "C:/Program Files/krepel" "$ENV{PATH}"
DOC "Path to the krepel installation."
NO_DEFAULT_PATH)

if(NOT EXISTS "${KREPEL_DIR}")
message(FATAL_ERROR "Please specify the path to the krepel installation.")
endif()

set(CMAKE_MODULE_PATH "${~{cmake_name}_DIR}/build/CMake" "${KREPEL_DIR}/build/CMake")
include(kr_setup)
kr_setup()

include(platforms/${CMAKE_SYSTEM_NAME})
include(targets/glew)
include(targets/ezEngine)
include(targets/krepel)


set(~{cmake_name}_DIR "${CMAKE_SOURCE_DIR}" CACHE PATH "Root directory of ~{friendly_name}.")
mark_as_advanced(~{cmake_name}_DIR)

include_directories("code")
add_subdirectory("code")

include(kr_create_target_pullRuntimeBinaries)
kr_create_target_pullRuntimeBinaries("${~{cmake_name}_DIR}/bin" "${KREPEL_DIR}/bin/")
2 changes: 2 additions & 0 deletions build/CMake/project_template/code/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory("~{friendly_name}_launcher")
add_subdirectory("~{friendly_name}")
16 changes: 16 additions & 0 deletions build/CMake/project_template/code/~{friendly_name}/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include(kr_set_pch)
include(kr_mirror_source_tree)

# Source Files
# ============
file(GLOB_RECURSE SOURCES *.h *.inl *.cpp)

# Target Setup
# ============
add_library(~{friendly_name} SHARED ${SOURCES})
target_include_directories(~{friendly_name} PUBLIC ../../code)
target_include_directories(~{friendly_name} PUBLIC ..)
kr_set_pch(~{friendly_name} "pch.h")
kr_mirror_source_tree("${CMAKE_CURRENT_LIST_DIR}" ${SOURCES})

target_link_libraries(~{friendly_name} krEngine)
11 changes: 11 additions & 0 deletions build/CMake/project_template/code/~{friendly_name}/game.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <krEngine/game/defaultMainModule.h>

class ~{friendly_name}_module : public kr::DefaultMainModule
{
public:
~{friendly_name}_module()
{
m_windowDesc.m_Title = "~{friendly_name} - Powered by krepel";
}

} s_mainModule; // <-- Static instance is required.
1 change: 1 addition & 0 deletions build/CMake/project_template/code/~{friendly_name}/pch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <krEngine/pch.h>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(kr_mirror_source_tree)

file(GLOB_RECURSE SOURCES *.h *.inl *.cpp)

add_executable(~{friendly_name}_launcher ${SOURCES})
kr_mirror_source_tree("${CMAKE_CURRENT_LIST_DIR}" ${SOURCES})

target_link_libraries(~{friendly_name}_launcher krEngine)

add_dependencies(~{friendly_name}_launcher ~{friendly_name})
Loading