Switched to cmake
This commit is contained in:
62
ecs-lua/CMakeLists.txt
Normal file
62
ecs-lua/CMakeLists.txt
Normal file
@@ -0,0 +1,62 @@
|
||||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||
|
||||
project(ecs-lua
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
include(../cmake/CPM.cmake)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME PackageProject.cmake
|
||||
GITHUB_REPOSITORY TheLartians/PackageProject.cmake
|
||||
VERSION 1.3
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME lua
|
||||
GITHUB_REPOSITORY lua/lua
|
||||
VERSION 5.2.3
|
||||
DOWNLOAD_ONLY YES
|
||||
)
|
||||
|
||||
if (lua_ADDED)
|
||||
# lua has no CMake support, so we create our own target
|
||||
|
||||
FILE(GLOB lua_sources ${lua_SOURCE_DIR}/*.c)
|
||||
add_library(lua STATIC ${lua_sources})
|
||||
|
||||
target_include_directories(lua
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${lua_SOURCE_DIR}>
|
||||
)
|
||||
endif()
|
||||
|
||||
CPMAddPackage(
|
||||
NAME sol2
|
||||
GIT_REPOSITORY https://github.com/ThePhD/sol2
|
||||
VERSION 3.2.0
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
|
||||
file(GLOB_RECURSE sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
|
||||
|
||||
add_library(${PROJECT_NAME} ${headers} ${sources})
|
||||
|
||||
# being a cross-platform target, we enforce standards conformance on MSVC
|
||||
target_compile_options(${PROJECT_NAME} PUBLIC "$<$<BOOL:${MSVC}>:/permissive->")
|
||||
|
||||
# Link dependencies (if required)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC ecs ecs-serial lua sol2)
|
||||
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES
|
||||
CXX_STANDARD 20
|
||||
OUTPUT_NAME "${PROJECT_NAME}"
|
||||
)
|
||||
|
||||
string(TOLOWER ${PROJECT_NAME}/version.h VERSION_HEADER_LOCATION)
|
||||
|
||||
target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
|
||||
)
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "sol.hpp"
|
||||
#include "sol/sol.hpp"
|
||||
#include "ecs.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
#include "ecs.h"
|
||||
|
||||
#ifdef _OPTIONAL_ECS_SERIAL
|
||||
// #ifdef _OPTIONAL_ECS_SERIAL
|
||||
#include "ecs-serial.h"
|
||||
#endif
|
||||
// #endif
|
||||
|
||||
namespace sol {
|
||||
template<>
|
||||
@@ -109,7 +109,8 @@ namespace ecs::lua {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _OPTIONAL_ECS_SERIAL
|
||||
// @todo We need to make this a cmake flag
|
||||
// #ifdef _OPTIONAL_ECS_SERIAL
|
||||
auto serialize = [map, name] (std::ostream& os, ecs::Component* component) {
|
||||
LuaComponent* wrapper = (LuaComponent*)component;
|
||||
|
||||
@@ -194,7 +195,7 @@ namespace ecs::lua {
|
||||
};
|
||||
|
||||
ecs::serial::register_component_custom(id, serialize, deserialize, create);
|
||||
#endif
|
||||
// #endif
|
||||
|
||||
sol::table component = lua.create_table();
|
||||
component["_id"] = id;
|
||||
|
||||
Reference in New Issue
Block a user