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
16 changes: 5 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,14 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
# Package definition
#

set(PACKAGE_VERSION_MAJOR "0")
set(PACKAGE_VERSION_MINOR "0")
set(PACKAGE_VERSION_PATCH "0")
set(PACKAGE_VERSION_TWEAK "1")
set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}.${PACKAGE_VERSION_TWEAK}")
set(PACKAGE_SHORT_NAME "engine")
set(PACKAGE_FULL_NAME "${PACKAGE_SHORT_NAME} v${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")
project("${PACKAGE_SHORT_NAME}" VERSION "${PACKAGE_VERSION}")
project(engine)

#
# Package configuration
#

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

include(GNUInstallDirs)

include(SetupPackageOptions)
include(SetupBuildConfig)
include(SetupOutputDirectories)
Expand All @@ -30,4 +21,7 @@ include(SetupCompiler)
# Modules
#

# add_subdirectory(path/to/module)
# add_subdirectory(path/to/module)
add_subdirectory(src/runtime/foundation)
add_subdirectory(src/runtime/main)
add_subdirectory(src/launcher)
6 changes: 3 additions & 3 deletions cmake/Compiler/msvc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ endif()
string(REPLACE ";" " " MSVC_DEBUG_FLAGS "${MSVC_DEBUG_FLAGS}")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVC_DEFAULT_FLAGS}" CACHE INTERNAL "" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MSVC_DEBUG_FLAGS}" CACHE INTERNAL "" FORCE)
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${MSVC_OPTIMIZED_FLAGS}" CACHE INTERNAL "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MSVC_OPTIMIZED_FLAGS} /Oy" CACHE INTERNAL "" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /DNRELEASE ${MSVC_DEBUG_FLAGS}" CACHE INTERNAL "" FORCE)
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /D_DEBUG /D_PROFILE /DNRELEASE ${MSVC_OPTIMIZED_FLAGS}" CACHE INTERNAL "" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /DNDEBUG /DRELEASE ${MSVC_OPTIMIZED_FLAGS} /Oy" CACHE INTERNAL "" FORCE)

set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG:FULL" CACHE INTERNAL "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DEBUG:FULL" CACHE INTERNAL "" FORCE)
Expand Down
2 changes: 1 addition & 1 deletion cmake/SetupCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ else()
endif()

# Set compiler-independent options
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(BUILD_SHARED)
Expand Down
30 changes: 30 additions & 0 deletions src/launcher/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
project(launcher)

# Define all source files here
set(PROJECT_SRC
src/main.cpp
)

# Create shared or static library as per the global settings
if(WIN32)
add_executable(launcher WIN32 ${PROJECT_SRC})
else()
add_executable(launcher ${PROJECT_SRC})
endif()
# Specify the include directories to the compiler
target_include_directories(main
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/launcher/>
$<INSTALL_INTERFACE:include>
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/>)

# Specify dependent libraries to the linker
target_link_libraries(launcher
PUBLIC
foundation
main
)

# Create virtual folders inside Visual Studio and XCode
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${PROJECT_SRC})
11 changes: 11 additions & 0 deletions src/launcher/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "main.h"
#include "logging.h"

extern int main(int argc, char **argv)
{
(void)(argc);
(void)(argv);
LOGV("-- Launcher started {%d,%p}\n", argc, argv);
getchar();
return 0;
}
34 changes: 34 additions & 0 deletions src/runtime/foundation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
project(foundation)

# Define all source files here
set(PROJECT_SRC
include/foundation/platform.h
include/foundation/logging.h
include/foundation/platform/win32/minimal_win32.h
src/dummy.cpp
src/logging.cpp
)

# Create shared or static library as per the global settings
if (BUILD_SHARED)
add_library(foundation SHARED ${PROJECT_SRC})
else ()
add_library(foundation STATIC ${PROJECT_SRC})
endif ()

# Specify the include directories to the compiler
target_include_directories(foundation
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/foundation/>
$<INSTALL_INTERFACE:include>
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/>)

# Specify dependent libraries to the linker
#target_link_libraries(foundation
#PUBLIC
# third-party
#)

# Create virtual folders inside Visual Studio and XCode
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${PROJECT_SRC})
46 changes: 46 additions & 0 deletions src/runtime/foundation/include/foundation/logging.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#pragma once

#ifdef _MSC_VER
// Disable warnings that we don't have control over
// since external libraries bring them.
#pragma warning(push)
//#pragma warning(disable : 4514 4710 4820)
// Disable C4514: unreferenced inline function has been removed
#pragma warning(disable: 4514)
// Disable C4710: `f()` function not inlined
#pragma warning(disable: 4710)
// Disable C4820: x bytes padding added after data member xy
#pragma warning(disable : 4820)
#endif
#include <chrono>
#include <stdio.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#ifdef _DEBUG
#define LOG(fmt) \
{ \
auto currtime = std::chrono::system_clock::now(); \
auto time = std::chrono::system_clock::to_time_t(currtime); \
auto rtime = std::chrono::system_clock::from_time_t(time); \
int usec = std::chrono::duration_cast<std::chrono::duration<int, std::micro>>(currtime - rtime).count(); \
char timefmt[32] = {}; \
strftime(timefmt, sizeof(timefmt), "%Y-%m-%dT%H:%M:%S", localtime(&time)); \
fprintf_s(stdout, "-- [%s.%d] [%s:%ld %s]: %s", timefmt, usec, __FILE__, __LINE__, __FUNCTION__, fmt); \
}
#define LOGV(fmt, ...) \
{ \
auto currtime = std::chrono::system_clock::now(); \
auto time = std::chrono::system_clock::to_time_t(currtime); \
auto rtime = std::chrono::system_clock::from_time_t(time); \
int usec = std::chrono::duration_cast<std::chrono::duration<int, std::micro>>(currtime - rtime).count(); \
char timefmt[32] = {}; \
strftime(timefmt, sizeof(timefmt), "%Y-%m-%dT%H:%M:%S", localtime(&time)); \
fprintf_s(stdout, "-- [%s.%d] [%s:%ld %s]: ", timefmt, usec, __FILE__, __LINE__, __FUNCTION__); \
fprintf_s(stdout, fmt, ##__VA_ARGS__); \
}
#else
#define LOG(fmt)
#define LOGV(fmt, ...)
#endif
7 changes: 7 additions & 0 deletions src/runtime/foundation/include/foundation/platform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#if defined _WIN32
#include "platform/win32/minimal_win32.h"
#else
#error Platform not supported.
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#pragma once

#define WIN32_LEAN_AND_MEAN
#define WIN32_EXTRA_LEAN

#define NOIME
#define NOWINRES
#define NOGDICAPMASKS
#define NOVIRTUALKEYCODES
#define NOWINMESSAGES
#define NOWINSTYLES
#define NOSYSMETRICS
#define NOMENUS
#define NOICONS
#define NOKEYSTATES
#define NOSYSCOMMANDS
#define NORASTEROPS
#define NOSHOWWINDOW
#define OEMRESOURCE
#define NOATOM
#define NOCLIPBOARD
#define NOCOLOR
#define NOCTLMGR
#define NODRAWTEXT
#define NOGDI
#define NOUSER
#define NOMB
#define NOMEMMGR
#define NOMETAFILE
#define NOMINMAX
#define NOMSG
#define NOOPENFILE
#define NOSCROLL
#define NOSERVICE
#define NOSOUND
#define NOTEXTMETRIC
#define NOWH
#define NOWINOFFSETS
#define NOCOMM
#define NOKANJI
#define NOHELP
#define NOPROFILER
#define NODEFERWINDOWPOS
#define NOMCX
#define NOIME
#define NOPROXYSTUB
#define NOIMAGE
#define NO
#define NOTAPE

#ifdef _MSC_VER
// Disable warnings that we don't have direct control over...
#pragma warning(push)
// Disable C5039: `TpSetCallbackCleanupGroup`: pointer or reference to
// potentially throwing function passed to extern C function under
// -EHc. Undefined behavior may occur if this function throws an
// exception.
#pragma warning(disable : 5039)
#endif
#include <windows.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif

4 changes: 4 additions & 0 deletions src/runtime/foundation/src/dummy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
void dummy()
{

}
Empty file.
42 changes: 42 additions & 0 deletions src/runtime/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
project(main)

# Define all source files here
set(PROJECT_SRC
include/main/main.h
)
if(WIN32)
set(PROJECT_SRC ${PROJECT_SRC} src/main_win32.cpp)
elseif(APPLE)
set(PROJECT_SRC ${PROJECT_SRC} src/main_mac.cpp)
elseif(UNIX)
set(PROJECT_SRC ${PROJECT_SRC} src/main_linux.cpp)
else()
set(PROJECT_SRC ${PROJECT_SRC} src/main_generic.cpp)
endif()


# Create shared or static library as per the global settings
#if (BUILD_SHARED)
# add_library(main SHARED ${PROJECT_SRC})
#else ()
# TODO: For some reason we can only link libmain statically
# Let's investigate why
add_library(main STATIC ${PROJECT_SRC})
#endif ()

# Specify the include directories to the compiler
target_include_directories(main
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/main/>
$<INSTALL_INTERFACE:include>
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/>)

# Specify dependent libraries to the linker
target_link_libraries(main
PUBLIC
foundation
)

# Create virtual folders inside Visual Studio and XCode
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${PROJECT_SRC})
10 changes: 10 additions & 0 deletions src/runtime/main/include/main/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

/**
* @brief This function should be implemented by the application
* that includes this header.
* @param argc the number of commandline arguments
* @param argv the array of commandline arguments in strings
* @return errorcode
*/
extern int main(int argc, char **argv);
18 changes: 18 additions & 0 deletions src/runtime/main/src/main_generic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "main.h"
#include "logging.h"

static int _main(int argc, char **argv)
{
(void)(argc);
(void)(argv);
LOG("\n");
return main(argc, argv);
}

int main(int argc, char** argv)
{
(void)(argc);
(void)(argv);
LOG("\n");
return _main(argc, argv);
}
18 changes: 18 additions & 0 deletions src/runtime/main/src/main_linux.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "main.h"
#include "logging.h"

static int _main(int argc, char **argv)
{
(void)(argc);
(void)(argv);
LOG("\n");
return main(argc, argv);
}

int main(int argc, char** argv)
{
(void)(argc);
(void)(argv);
LOG("\n");
return _main(argc, argv);
}
18 changes: 18 additions & 0 deletions src/runtime/main/src/main_mac.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "main.h"
#include "logging.h"

static int _main(int argc, char **argv)
{
(void)(argc);
(void)(argv);
LOG("\n");
return main(argc, argv);
}

int main(int argc, char** argv)
{
(void)(argc);
(void)(argv);
LOG("\n");
return _main(argc, argv);
}
Loading