From 1b8507e21f70def818827ae55008c90a0dfc70b0 Mon Sep 17 00:00:00 2001 From: bailwillharr Date: Sat, 3 Sep 2022 00:02:09 +0100 Subject: [PATCH] Change stuff --- CMakeLists.txt | 23 +++++++++-------------- config.h.in | 2 +- include/components/camera.hpp | 4 +++- include/components/component.hpp | 4 +++- include/components/custom.hpp | 4 +++- include/components/mesh_renderer.hpp | 4 +++- include/components/text_ui_renderer.hpp | 4 +++- include/components/transform.hpp | 4 +++- include/export.h | 13 +++++++++++++ include/input.hpp | 4 +++- include/object.hpp | 4 +++- include/resource_manager.hpp | 4 +++- include/resources/font.hpp | 4 +++- include/resources/mesh.hpp | 4 +++- include/resources/resource.hpp | 4 +++- include/resources/shader.hpp | 4 +++- include/resources/texture.hpp | 4 +++- include/sceneroot.hpp | 4 +++- include/window.hpp | 6 ++++-- 19 files changed, 72 insertions(+), 32 deletions(-) create mode 100644 include/export.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d7703e..265ebb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.4) # options @@ -32,6 +32,8 @@ add_library(${PROJECT_NAME} SHARED # PUBLIC API + "include/export.h" + "include/log.hpp" "include/window.hpp" @@ -59,16 +61,18 @@ add_library(${PROJECT_NAME} SHARED "include/resource_manager.hpp" - ) +) # compiling options: +target_compile_definitions(${PROJECT_NAME} PRIVATE DEFINITIONS "ENGINE_EXPORTS") + set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) if (MSVC) target_compile_options(${PROJECT_NAME} PRIVATE /W3) - target_compile_options(${PROJECT_NAME} PRIVATE /M3) + target_compile_options(${PROJECT_NAME} PRIVATE /MP) endif() target_include_directories(${PROJECT_NAME} PUBLIC include) @@ -76,7 +80,7 @@ target_include_directories(${PROJECT_NAME} PRIVATE src) # Pass some project information into the source code configure_file(config.h.in config.h) -target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) # libraries: @@ -94,11 +98,6 @@ add_subdirectory(dependencies/SDL) target_include_directories(${PROJECT_NAME} PUBLIC dependencies/SDL/include) target_link_libraries(${PROJECT_NAME} PUBLIC SDL2::SDL2) target_link_libraries(${PROJECT_NAME} PUBLIC SDL2::SDL2main) -# copy over SDL2 library: -add_custom_command( - TARGET ${PROJECT_NAME} PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ $) # GLM: add_subdirectory(dependencies/glm) @@ -124,19 +123,15 @@ add_subdirectory(dependencies/spdlog) target_link_libraries(${PROJECT_NAME} PUBLIC spdlog) target_include_directories(${PROJECT_NAME} PUBLIC dependencies/spdlog/include) - - # freetype set(BUILD_SHARED_LIBS ON) add_subdirectory(dependencies/freetype) target_link_libraries(${PROJECT_NAME} PRIVATE freetype) target_include_directories(${PROJECT_NAME} PRIVATE dependencies/freetype/include) -set(BUILD_SHARED_LIBS OFF) # stb target_include_directories(${PROJECT_NAME} PRIVATE dependencies/stb) -# public API: - +# public API: \ No newline at end of file diff --git a/config.h.in b/config.h.in index 8d03266..797c5ba 100644 --- a/config.h.in +++ b/config.h.in @@ -1,3 +1,3 @@ #pragma once -#define SDLTEST_VERSION @PROJECT_VERSION@ +#define ENGINE_VERSION @PROJECT_VERSION@ diff --git a/include/components/camera.hpp b/include/components/camera.hpp index c85a3d9..8c7d9f8 100644 --- a/include/components/camera.hpp +++ b/include/components/camera.hpp @@ -1,5 +1,7 @@ #pragma once +#include "export.h" + #include "component.hpp" #include "object.hpp" @@ -11,7 +13,7 @@ namespace components { -class Camera : public Component { +class DECLSPEC Camera : public Component { public: Camera(Object* parent); diff --git a/include/components/component.hpp b/include/components/component.hpp index f5e7f84..cf0ea36 100644 --- a/include/components/component.hpp +++ b/include/components/component.hpp @@ -1,11 +1,13 @@ #pragma once +#include "export.h" + class Object; class Window; class Input; class ResourceManager; -class Component { +class DECLSPEC Component { public: diff --git a/include/components/custom.hpp b/include/components/custom.hpp index b669ed8..505d9d5 100644 --- a/include/components/custom.hpp +++ b/include/components/custom.hpp @@ -1,12 +1,14 @@ #pragma once +#include "export.h" + #include "component.hpp" #include namespace components { - class CustomComponent : public Component { + class DECLSPEC CustomComponent : public Component { public: CustomComponent(Object* parent); diff --git a/include/components/mesh_renderer.hpp b/include/components/mesh_renderer.hpp index 89d11c9..8ad9aff 100644 --- a/include/components/mesh_renderer.hpp +++ b/include/components/mesh_renderer.hpp @@ -1,5 +1,7 @@ #pragma once +#include "export.h" + #include "component.hpp" #include "resources/shader.hpp" @@ -12,7 +14,7 @@ namespace components { -class Renderer : public Component { +class DECLSPEC Renderer : public Component { public: Renderer(Object*); diff --git a/include/components/text_ui_renderer.hpp b/include/components/text_ui_renderer.hpp index cb7cdd3..b2ac461 100644 --- a/include/components/text_ui_renderer.hpp +++ b/include/components/text_ui_renderer.hpp @@ -1,5 +1,7 @@ #pragma once +#include "export.h" + #include "component.hpp" #include "resources/font.hpp" @@ -9,7 +11,7 @@ namespace components { -class UI : public Component { +class DECLSPEC UI : public Component { public: UI(Object*); diff --git a/include/components/transform.hpp b/include/components/transform.hpp index 1bd0c33..7aeed1c 100644 --- a/include/components/transform.hpp +++ b/include/components/transform.hpp @@ -1,5 +1,7 @@ #pragma once +#include "export.h" + #include "component.hpp" #include @@ -12,7 +14,7 @@ namespace components { -class Transform : public Component { +class DECLSPEC Transform : public Component { // Scale, rotate (XYZ), translate diff --git a/include/export.h b/include/export.h new file mode 100644 index 0000000..7cfe1d1 --- /dev/null +++ b/include/export.h @@ -0,0 +1,13 @@ +#pragma once + +#ifndef DECLSPEC +# ifdef _MSC_VER +# ifdef ENGINE_EXPORTS +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC __declspec(dllimport) +# endif +# else +# define DECLSPEC +# endif +#endif \ No newline at end of file diff --git a/include/input.hpp b/include/input.hpp index 2ec66af..378178f 100644 --- a/include/input.hpp +++ b/include/input.hpp @@ -1,5 +1,7 @@ #pragma once +#include "export.h" + #include "inputs/mouse.hpp" #include "inputs/keyboard.hpp" @@ -17,7 +19,7 @@ enum class InputDevice : int { }; // This class should be used to get platform/input-device independent input -class Input { +class DECLSPEC Input { public: diff --git a/include/object.hpp b/include/object.hpp index 3c6d06d..33edca8 100644 --- a/include/object.hpp +++ b/include/object.hpp @@ -1,5 +1,7 @@ #pragma once +#include "export.h" + #include #include @@ -31,7 +33,7 @@ struct GameIO { // This object lives until it is deleted by its parent(s) or finally when the "Scene" is destroyed. // Therefore it is safe to return raw pointers -class Object { +class DECLSPEC Object { public: Object(std::string name, Object* parent, SceneRoot& root, struct GameIO things); diff --git a/include/resource_manager.hpp b/include/resource_manager.hpp index 6a2bd8a..155345d 100644 --- a/include/resource_manager.hpp +++ b/include/resource_manager.hpp @@ -1,5 +1,7 @@ #pragma once +#include "export.h" + #include "resources/resource.hpp" #include @@ -7,7 +9,7 @@ // Doesn't own resources, only holds weak_ptrs -class ResourceManager { +class DECLSPEC ResourceManager { public: ResourceManager(); diff --git a/include/resources/font.hpp b/include/resources/font.hpp index a93a960..dd3747a 100644 --- a/include/resources/font.hpp +++ b/include/resources/font.hpp @@ -1,5 +1,7 @@ #pragma once +#include "export.h" + #include "resource.hpp" #include @@ -10,7 +12,7 @@ namespace resources { -class Font : public Resource { +class DECLSPEC Font : public Resource { public: diff --git a/include/resources/mesh.hpp b/include/resources/mesh.hpp index 8df7012..330ddae 100644 --- a/include/resources/mesh.hpp +++ b/include/resources/mesh.hpp @@ -1,5 +1,7 @@ #pragma once +#include "export.h" + #include "resource.hpp" #include "resources/shader.hpp" @@ -20,7 +22,7 @@ struct Vertex { namespace resources { -class Mesh : public Resource { +class DECLSPEC Mesh : public Resource { public: Mesh(const std::vector& vertices); diff --git a/include/resources/resource.hpp b/include/resources/resource.hpp index 09ed37b..878d1a6 100644 --- a/include/resources/resource.hpp +++ b/include/resources/resource.hpp @@ -1,9 +1,11 @@ #pragma once +#include "export.h" + #include #include -class Resource { +class DECLSPEC Resource { public: Resource(const std::filesystem::path& resPath, const std::string& type); diff --git a/include/resources/shader.hpp b/include/resources/shader.hpp index 1ac8c65..4ea89c5 100644 --- a/include/resources/shader.hpp +++ b/include/resources/shader.hpp @@ -1,5 +1,7 @@ #pragma once +#include "export.h" + #include "resource.hpp" #include @@ -11,7 +13,7 @@ namespace resources { -class Shader : public Resource { +class DECLSPEC Shader : public Resource { public: Shader(const std::filesystem::path& resPath); diff --git a/include/resources/texture.hpp b/include/resources/texture.hpp index 988b98e..dbcb996 100644 --- a/include/resources/texture.hpp +++ b/include/resources/texture.hpp @@ -1,12 +1,14 @@ #pragma once +#include "export.h" + #include "resource.hpp" #include namespace resources { -class Texture : public Resource { +class DECLSPEC Texture : public Resource { private: diff --git a/include/sceneroot.hpp b/include/sceneroot.hpp index dcb6814..aa37be7 100644 --- a/include/sceneroot.hpp +++ b/include/sceneroot.hpp @@ -1,11 +1,13 @@ #pragma once +#include "export.h" + #include "object.hpp" #include // Holds everything you would expect to find in a game scene -class SceneRoot : public Object { +class DECLSPEC SceneRoot : public Object { public: // create a new empty scene diff --git a/include/window.hpp b/include/window.hpp index 3373314..ef6181b 100644 --- a/include/window.hpp +++ b/include/window.hpp @@ -1,5 +1,7 @@ #pragma once +#include "export.h" + #include "inputs/keyboard.hpp" #include "inputs/mouse.hpp" @@ -12,9 +14,9 @@ #include #include -extern const uint64_t BILLION; +DECLSPEC extern const uint64_t BILLION; -class Window { +class DECLSPEC Window { public: Window(const std::string& title);