Skip to content
Merged
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
28 changes: 22 additions & 6 deletions include/flow/core/Core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@
#pragma once

#if defined(_WIN32)
#define FLOW_WINDOWS
#define FLOW_WINDOWS "windows";
#define FLOW_PLATFORM FLOW_WINDOWS
#elif defined(__APPLE__)
#define FLOW_APPLE
#define FLOW_APPLE "macos";
#define FLOW_PLATFORM FLOW_APPLE
#elif defined(__linux__)
#define FLOW_LINUX
#define FLOW_LINUX "linux";
#define FLOW_PLATFORM FLOW_LINUX
#else
#error "Platform unsupported"
#endif

#if defined(__x86_64__) || defined(_M_X64) || defined(__amd64__)
#define FLOW_X86_64
#define FLOW_X86_64 "x86_64";
#define FLOW_ARCH FLOW_X86_64
#elif defined(__i386__) || defined(_M_IX86)
#define FLOW_X86
#define FLOW_X86 "x86";
#define FLOW_ARCH FLOW_X86
#elif defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64)
#define FLOW_ARM
#define FLOW_ARM "arm64";
#define FLOW_ARCH FLOW_ARM
#else
#error "Architecture unsupported"
#endif
Expand All @@ -29,6 +35,16 @@
#define FLOW_CORE_CALL
#endif

#ifdef FLOW_WINDOWS
#ifdef FLOW_CORE_EXPORT
#define FLOW_CORE_API __declspec(dllexport)
#else
#define FLOW_CORE_API __declspec(dllimport)
#endif
#else
#define FLOW_CORE_API
#endif

// clang-format off
#define FLOW_NAMESPACE_BEGIN namespace flow {
#define FLOW_SUBNAMESPACE_BEGIN(nested) namespace flow { namespace nested {
Expand Down
2 changes: 1 addition & 1 deletion include/flow/core/Module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class Module
/**
* @brief The file extension for module metadata files.
*/
static const std::string FileExtension;
static const std::string FLOW_CORE_API FileExtension;

private:
std::unique_ptr<void, HandleUnloader> _handle;
Expand Down
23 changes: 4 additions & 19 deletions src/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ FLOW_NAMESPACE_BEGIN

using namespace zipper;

const std::string Module::FileExtension = "fmod";

struct formatted_error : public std::runtime_error
{
template<typename... Args>
Expand All @@ -45,25 +47,8 @@ struct invalid_argument : public formatted_error

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ModuleMetaData, Name, Version, Author, Description);

const std::string Module::FileExtension = "fmod";

#ifdef FLOW_WINDOWS
constexpr const char* platform = "windows";
#elif defined(FLOW_APPLE)
constexpr const char* platform = "macos";
#else
constexpr const char* platform = "linux";
#endif

#ifdef FLOW_X86_64
constexpr const char* architecture = "x86_64";
#elif defined(FLOW_X86)
constexpr const char* architecture = "x86";
#elif defined(FLOW_ARM)
constexpr const char* architecture = "arm64";
#else
#error "Unsupported architecture"
#endif
constexpr const char* platform = FLOW_PLATFORM;
constexpr const char* architecture = FLOW_ARCH;

#ifdef FLOW_WINDOWS
constexpr const char* library_extension = ".dll";
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ if(MSVC)
endif()

target_link_libraries(${TEST_EXE}
flow-core
flow-core::flow-core
GTest::gtest_main
)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ endif()

add_dependencies(${PROJECT_NAME} flow-core)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(${PROJECT_NAME} PUBLIC flow-core)
target_link_libraries(${PROJECT_NAME} PUBLIC flow-core::flow-core)

include(${CMAKE_SOURCE_DIR}/cmake/FlowModule.cmake)
CreateFlowModule(${PROJECT_NAME})
Expand Down
Loading