Compiles, not run yet.
This commit is contained in:
parent
9dfe0faa56
commit
01697f9df4
@ -1,6 +1,14 @@
|
||||
cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
|
||||
project(BillySheet LANGUAGES CXX C)
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
set(PRECOMPILE_HEADERS
|
||||
include/gui.hpp
|
||||
include/gui_data.hpp
|
||||
include/window.hpp
|
||||
)
|
||||
|
||||
set(SOURCE_HEADERS
|
||||
include/imgui/imconfig.h
|
||||
include/imgui/imgui.h
|
||||
@ -8,6 +16,9 @@ set(SOURCE_HEADERS
|
||||
include/imgui/imgui_impl_opengl3.h
|
||||
include/imgui/imgui_impl_opengl3_loader.h
|
||||
include/imgui/imgui_internal.h
|
||||
include/imgui/imstb_rectpack.h
|
||||
include/imgui/imstb_textedit.h
|
||||
include/imgui/imstb_truetype.h
|
||||
include/gui.hpp
|
||||
include/gui_data.hpp
|
||||
include/window.hpp)
|
||||
@ -28,6 +39,17 @@ set(SOURCES
|
||||
${SOURCE_HEADERS}
|
||||
${SOURCE_FILES})
|
||||
|
||||
find_program(CCACHE_FOUND ccache)
|
||||
if (CCACHE_FOUND)
|
||||
message(STATUS "ccache found !")
|
||||
set_property(GLOBAL PROPERTY C_COMPILER_LAUNCHER ccache)
|
||||
set_property(GLOBAL PROPERTY C_LINKER_LAUNCHER ccache)
|
||||
set_property(GLOBAL PROPERTY CXX_COMPILER_LAUNCHER ccache)
|
||||
set_property(GLOBAL PROPERTY CXX_LINKER_LAUNCHER ccache)
|
||||
else ()
|
||||
message(STATUS "ccache not found")
|
||||
endif ()
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
||||
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
|
||||
option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
|
||||
@ -44,19 +66,66 @@ option(SPDLOG_NO_TLS "prevent spdlog from using thread local storage" ON)
|
||||
option(SPDLOG_NO_ATOMIC_LEVELS "prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently" ON)
|
||||
add_subdirectory(external/spdlog)
|
||||
|
||||
set(COMPILE_FLAGS
|
||||
-pipe
|
||||
-march=skylake # change to native or your architecture.
|
||||
-mtune=skylake # same as above
|
||||
-mrdseed # be careful about this, this is linked to the x86 architecture.
|
||||
-mrdrnd # same as above
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
-pedantic
|
||||
-ffunction-sections
|
||||
-fdata-sections
|
||||
-fuse-ld=gold
|
||||
-funroll-loops
|
||||
-fdevirtualize-at-ltrans
|
||||
-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free
|
||||
)
|
||||
set(LINKER_OPTIONS
|
||||
-Wl,--sort-common,--as-needed,--gc-sections,--strip-all
|
||||
-fuse-ld=gold
|
||||
-fdevirtualize-at-ltrans
|
||||
)
|
||||
|
||||
set(LINKER_FLAGS
|
||||
jemalloc
|
||||
)
|
||||
|
||||
add_executable(BillySheet ${SOURCES})
|
||||
|
||||
target_include_directories(BillySheet PRIVATE include)
|
||||
target_include_directories(BillySheet PRIVATE include include/imgui)
|
||||
|
||||
set_target_properties(BillySheet spdlog glfw PROPERTIES
|
||||
set_target_properties(BillySheet spdlog PROPERTIES
|
||||
CXX_STANDARD 17
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
CXX_EXTENSIONS OFF
|
||||
INTERPROCEDURAL_OPTIMIZATION ON
|
||||
UNITY_BUILD ON)
|
||||
target_precompile_headers(BillySheet PRIVATE ${SOURCE_HEADERS})
|
||||
# UNITY_BUILD ON
|
||||
)
|
||||
set_target_properties(glfw PROPERTIES
|
||||
C_STANDARD 11
|
||||
C_STANDARD_REQUIRED ON
|
||||
C_EXTENSIONS OFF
|
||||
INTERPROCEDURAL_OPTIMIZATION ON
|
||||
# UNITY_BUILD ON
|
||||
)
|
||||
|
||||
#target_precompile_headers(BillySheet PRIVATE ${PRECOMPILE_HEADERS})
|
||||
target_compile_definitions(BillySheet PRIVATE
|
||||
$<$<CONFIG:Debug>:_GLIBCXX_DEBUG>
|
||||
$<$<CONFIG:Debug>:SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG>
|
||||
$<$<CONFIG:Release>:SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_ERROR>)
|
||||
target_link_libraries(BillySheet glfw spdlog)
|
||||
|
||||
target_compile_options(spdlog PRIVATE ${COMPILE_FLAGS})
|
||||
target_compile_options(glfw PRIVATE ${COMPILE_FLAGS})
|
||||
target_compile_options(BillySheet PRIVATE ${COMPILE_FLAGS})
|
||||
|
||||
target_link_options(spdlog PRIVATE ${LINKER_OPTIONS})
|
||||
target_link_options(glfw PRIVATE ${LINKER_OPTIONS})
|
||||
target_link_options(BillySheet PRIVATE ${LINKER_OPTIONS})
|
||||
|
||||
target_link_libraries(spdlog PRIVATE ${LINKER_FLAGS})
|
||||
target_link_libraries(glfw PRIVATE ${LINKER_FLAGS})
|
||||
target_link_libraries(BillySheet glfw spdlog OpenGL::OpenGL ${LINKER_FLAGS})
|
||||
|
@ -2,6 +2,12 @@
|
||||
This project is about to digitally control your character sheet from the book "La Forteresse du Chaudron Noir" from Bob Lennon.
|
||||
|
||||
## External dependencies
|
||||
All dependencies are inside the "external" directory. The followings are inside:
|
||||
Some dependencies are inside the "external" directory. The followings are inside:
|
||||
- GLFW: windowing
|
||||
- Spdlog: logging the app.
|
||||
|
||||
The others are:
|
||||
- jemalloc
|
||||
- ccache
|
||||
- the gold linker
|
||||
- OpenGL
|
||||
|
@ -9,8 +9,6 @@ namespace gui {
|
||||
public:
|
||||
Gui() = delete;
|
||||
|
||||
|
||||
|
||||
~Gui() noexcept;
|
||||
};
|
||||
}
|
||||
|
@ -1,13 +1,18 @@
|
||||
#ifndef BILLYSHEET_GUI_DATA_HPP
|
||||
#define BILLYSHEET_GUI_DATA_HPP
|
||||
|
||||
#include "window.hpp"
|
||||
|
||||
namespace gui {
|
||||
class GuiData final {
|
||||
private:
|
||||
// GLFWwindow *window{ nullptr };
|
||||
Window &window;
|
||||
|
||||
public:
|
||||
GuiData() = delete;
|
||||
|
||||
explicit GuiData(Window &wwindow) : window(wwindow) {}
|
||||
|
||||
~GuiData() noexcept = default;
|
||||
};
|
||||
}
|
||||
|
@ -1,5 +1 @@
|
||||
//
|
||||
// Created by postaron on 08/01/2022.
|
||||
//
|
||||
|
||||
#include "gui_data.hpp"
|
||||
|
@ -1,8 +1,13 @@
|
||||
#include <stdexcept>
|
||||
#include "window.hpp"
|
||||
#include <stdexcept>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
static void glfwErrorCallback(int error, const char *message) {
|
||||
spdlog::error("Error code {}: {}", error, message);
|
||||
}
|
||||
|
||||
gui::Window::Window() {
|
||||
glfwSetErrorCallback(nullptr);
|
||||
glfwSetErrorCallback(glfwErrorCallback);
|
||||
if (glfwInit() == GLFW_FALSE) {
|
||||
throw std::runtime_error("GLFW init failed.");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user