Compare commits
2 Commits
a32222f22f
...
86825103ee
Author | SHA1 | Date | |
---|---|---|---|
86825103ee | |||
3f18601ffc |
@ -1,4 +1,6 @@
|
||||
add_library(${ENGINE_TARGET} SHARED
|
||||
option(ENGINE_BUILD_SHARED "Build the Engine library as a shared library" ON)
|
||||
|
||||
set(SOURCES
|
||||
src/IO/parser.cpp
|
||||
src/IO/file_manager.cpp
|
||||
|
||||
@ -17,6 +19,24 @@ add_library(${ENGINE_TARGET} SHARED
|
||||
# src/main.cpp
|
||||
)
|
||||
|
||||
#if (ENGINE_BUILD_SHARED)
|
||||
# add_library(${ENGINE_TARGET} SHARED ${SOURCES})
|
||||
#else()
|
||||
# add_library(${ENGINE_TARGET} STATIC ${SOURCES})
|
||||
#endif()
|
||||
|
||||
if(ENGINE_BUILD_SHARED)
|
||||
add_library(${ENGINE_TARGET} SHARED ${SOURCES})
|
||||
if(WIN32)
|
||||
target_compile_definitions(${ENGINE_TARGET} PRIVATE ENGINE_BUILD_SHARED ENGINE_EXPORTS)
|
||||
else()
|
||||
target_compile_definitions(${ENGINE_TARGET} PRIVATE ENGINE_BUILD_SHARED)
|
||||
endif()
|
||||
else()
|
||||
add_library(${ENGINE_TARGET} STATIC ${SOURCES})
|
||||
target_compile_definitions(${ENGINE_TARGET} PRIVATE ENGINE_STATIC)
|
||||
endif()
|
||||
|
||||
set_target_properties(${ENGINE_TARGET} PROPERTIES
|
||||
CXX_STANDARD 17
|
||||
CXX_STANDARD_REQUIRED ON
|
||||
@ -24,8 +44,6 @@ set_target_properties(${ENGINE_TARGET} PROPERTIES
|
||||
VISIBILITY_INLINES_HIDDEN YES
|
||||
)
|
||||
|
||||
target_compile_definitions(${ENGINE_TARGET} PRIVATE ENGINE_BUILD_SHARED)
|
||||
|
||||
target_include_directories(${ENGINE_TARGET} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib
|
||||
@ -82,10 +100,3 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ---------- Windows: copy runtime DLLs ----------
|
||||
if (WIN32)
|
||||
add_custom_command(TARGET ${ENGINE_TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
$<TARGET_RUNTIME_DLLS:${ENGINE_TARGET}> $<TARGET_FILE_DIR:${ENGINE_TARGET}>
|
||||
COMMAND_EXPAND_LISTS)
|
||||
endif()
|
||||
|
@ -1,10 +1,8 @@
|
||||
#ifndef WIN32
|
||||
#define GLEW_STATIC
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#include <corecrt_math_defines.h>
|
||||
#endif
|
||||
|
||||
|
@ -1,9 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(_WIN32) && defined(ENGINE_BUILD_SHARED)
|
||||
#define ENGINE_API __declspec(dllexport)
|
||||
#elif defined(_WIN32)
|
||||
#define ENGINE_API __declspec(dllimport)
|
||||
// For static libs, ENGINE_API should be empty.
|
||||
#if defined(_WIN32)
|
||||
#if defined(ENGINE_BUILD_SHARED)
|
||||
#if defined(ENGINE_EXPORTS)
|
||||
#define ENGINE_API __declspec(dllexport)
|
||||
#else
|
||||
#define ENGINE_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define ENGINE_API
|
||||
#endif
|
||||
#else
|
||||
#define ENGINE_API __attribute__((visibility("default")))
|
||||
#if defined(ENGINE_BUILD_SHARED)
|
||||
#define ENGINE_API __attribute__((visibility("default")))
|
||||
#else
|
||||
#define ENGINE_API
|
||||
#endif
|
||||
#endif
|
@ -8,3 +8,12 @@ set_target_properties(${SANDBOX_TARGET} PROPERTIES
|
||||
)
|
||||
|
||||
target_link_libraries(${SANDBOX_TARGET} PRIVATE ${ENGINE_TARGET})
|
||||
|
||||
# --- Copy engine.dll and all dependent DLLs next to sandbox.exe ---
|
||||
if (WIN32)
|
||||
add_custom_command(TARGET ${SANDBOX_TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
$<TARGET_RUNTIME_DLLS:${SANDBOX_TARGET}> $<TARGET_FILE_DIR:${SANDBOX_TARGET}>
|
||||
COMMAND_EXPAND_LISTS
|
||||
)
|
||||
endif()
|
||||
|
@ -35,18 +35,18 @@ public:
|
||||
m_registry.emplace<transform>(cameraEntity, glm::vec3(0.f, 2.f, 2.f));
|
||||
m_registry.emplace<camera>(cameraEntity);
|
||||
|
||||
Object* targetObj = Object::LoadFile("./assets/wizard/wizard.obj");
|
||||
Object* targetObj = Object::LoadFile("./assets/monkey.obj");
|
||||
const auto targetEntity = m_registry.create();
|
||||
m_registry.emplace<transform>(targetEntity, glm::vec3(0.f, 0.0f, 0.f));
|
||||
m_registry.emplace<mesh>(targetEntity, std::shared_ptr<Object>(targetObj));
|
||||
|
||||
Object* grass = Object::LoadFile("./assets/grass_block/grass_block.obj");
|
||||
Object* grass = Object::LoadFile("./assets/cube.obj");
|
||||
const auto cubeEntity = m_registry.create();
|
||||
m_registry.emplace<transform>(cubeEntity, glm::vec3(-1.5f, 0.4f, 0.f));
|
||||
m_registry.emplace<mesh>(cubeEntity, std::shared_ptr<Object>(grass));
|
||||
|
||||
// Cube template (use shared object to avoid reloading 1000 times)
|
||||
std::shared_ptr<Object> cubeObj = std::shared_ptr<Object>(Object::LoadFile("./assets/grass_block/grass_block.obj"));
|
||||
std::shared_ptr<Object> cubeObj = std::shared_ptr<Object>(Object::LoadFile("./assets/cube.obj"));
|
||||
const auto batchEntt = m_registry.create();
|
||||
m_registry.emplace<batch>(batchEntt);
|
||||
m_registry.emplace<mesh>(batchEntt, cubeObj);
|
||||
|
Reference in New Issue
Block a user