fix: correct dll specs + copy dlls
This commit is contained in:
@ -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/parser.cpp
|
||||||
src/IO/file_manager.cpp
|
src/IO/file_manager.cpp
|
||||||
|
|
||||||
@ -17,6 +19,24 @@ add_library(${ENGINE_TARGET} SHARED
|
|||||||
# src/main.cpp
|
# 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
|
set_target_properties(${ENGINE_TARGET} PROPERTIES
|
||||||
CXX_STANDARD 17
|
CXX_STANDARD 17
|
||||||
CXX_STANDARD_REQUIRED ON
|
CXX_STANDARD_REQUIRED ON
|
||||||
@ -24,8 +44,6 @@ set_target_properties(${ENGINE_TARGET} PROPERTIES
|
|||||||
VISIBILITY_INLINES_HIDDEN YES
|
VISIBILITY_INLINES_HIDDEN YES
|
||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(${ENGINE_TARGET} PRIVATE ENGINE_BUILD_SHARED)
|
|
||||||
|
|
||||||
target_include_directories(${ENGINE_TARGET} PUBLIC
|
target_include_directories(${ENGINE_TARGET} PUBLIC
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/contrib
|
${CMAKE_CURRENT_SOURCE_DIR}/contrib
|
||||||
@ -82,10 +100,3 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
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,9 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
#define GLEW_STATIC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -1,9 +1,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(ENGINE_BUILD_SHARED)
|
// 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)
|
#define ENGINE_API __declspec(dllexport)
|
||||||
#elif defined(_WIN32)
|
#else
|
||||||
#define ENGINE_API __declspec(dllimport)
|
#define ENGINE_API __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define ENGINE_API
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
|
#if defined(ENGINE_BUILD_SHARED)
|
||||||
#define ENGINE_API __attribute__((visibility("default")))
|
#define ENGINE_API __attribute__((visibility("default")))
|
||||||
|
#else
|
||||||
|
#define ENGINE_API
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
@ -8,3 +8,12 @@ set_target_properties(${SANDBOX_TARGET} PROPERTIES
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${SANDBOX_TARGET} PRIVATE ${ENGINE_TARGET})
|
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()
|
||||||
|
Reference in New Issue
Block a user