From 89f97ea878a698ac612a4139eec9f23829903b91 Mon Sep 17 00:00:00 2001 From: Dreaded_X Date: Tue, 30 Nov 2021 04:55:29 +0100 Subject: [PATCH] Fixed compile issues --- ecs-lua/CMakeLists.txt | 4 +++- ecs-lua/include/ecs-lua.h | 1 + ecs-lua/src/ecs-lua.cpp | 3 ++- ecs-serial/include/ecs-serial.h | 2 +- ecs-serial/src/ecs-serial.cpp | 1 - ecs/CMakeLists.txt | 29 +++++++++++++++++++++++++++-- ecs/include/ecs.h | 1 + scripts/generate.py | 2 +- test/include/components.h | 1 + test/src/main.cpp | 5 +++-- 10 files changed, 40 insertions(+), 9 deletions(-) diff --git a/ecs-lua/CMakeLists.txt b/ecs-lua/CMakeLists.txt index d67ec74..398f11a 100644 --- a/ecs-lua/CMakeLists.txt +++ b/ecs-lua/CMakeLists.txt @@ -24,6 +24,7 @@ if (lua_ADDED) FILE(GLOB lua_sources ${lua_SOURCE_DIR}/*.c) add_library(lua STATIC ${lua_sources}) + set_source_files_properties(${lua_sources} PROPERTIES LANGUAGE CXX) target_include_directories(lua PUBLIC @@ -42,6 +43,7 @@ if (sol2_ADDED) add_library(sol2 INTERFACE IMPORTED) target_include_directories(sol2 INTERFACE ${sol2_SOURCE_DIR}/single/include) target_link_libraries(sol2 INTERFACE lua) + target_compile_definitions(sol2 INTERFACE SOL_USING_CXX_LUA=1) endif() file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h") @@ -53,7 +55,7 @@ add_library(${PROJECT_NAME} ${headers} ${sources}) target_compile_options(${PROJECT_NAME} PUBLIC "$<$:/permissive->") # Link dependencies (if required) -target_link_libraries(${PROJECT_NAME} PUBLIC ecs ecs-serial lua sol2) +target_link_libraries(${PROJECT_NAME} PUBLIC ecs ecs-serial sol2) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20 diff --git a/ecs-lua/include/ecs-lua.h b/ecs-lua/include/ecs-lua.h index 1d8d176..bd0cc99 100644 --- a/ecs-lua/include/ecs-lua.h +++ b/ecs-lua/include/ecs-lua.h @@ -1,5 +1,6 @@ #pragma once +#include #include "sol/sol.hpp" #include "ecs.h" diff --git a/ecs-lua/src/ecs-lua.cpp b/ecs-lua/src/ecs-lua.cpp index 0bb730d..251de97 100644 --- a/ecs-lua/src/ecs-lua.cpp +++ b/ecs-lua/src/ecs-lua.cpp @@ -205,7 +205,8 @@ namespace ecs::lua { wrapper->table = lua.create_table(); for (auto [key, type] : map) { - wrapper->table[key] = table[key]; + auto temp = table[key]; + wrapper->table[key] = temp; } return std::make_pair(id, wrapper); diff --git a/ecs-serial/include/ecs-serial.h b/ecs-serial/include/ecs-serial.h index 100b4d5..f25ead2 100644 --- a/ecs-serial/include/ecs-serial.h +++ b/ecs-serial/include/ecs-serial.h @@ -1,6 +1,6 @@ +#pragma once #include #include -#pragma once #include "ecs.h" #include "io/write.h" diff --git a/ecs-serial/src/ecs-serial.cpp b/ecs-serial/src/ecs-serial.cpp index 34b144c..4dc5cdf 100644 --- a/ecs-serial/src/ecs-serial.cpp +++ b/ecs-serial/src/ecs-serial.cpp @@ -1,7 +1,6 @@ #include "ecs-serial.h" #include "ecs.h" -#include #include #include diff --git a/ecs/CMakeLists.txt b/ecs/CMakeLists.txt index 1656c4c..f4e2ab6 100644 --- a/ecs/CMakeLists.txt +++ b/ecs/CMakeLists.txt @@ -27,8 +27,33 @@ if (stduuid_ADDED) find_library(CFLIB CoreFoundation) target_link_libraries(stduuid INTERFACE ${CFLIB}) else() - find_library(LIBUUID_LIBRARIES uuid) - target_link_libraries(stduuid INTERFACE ${LIBUUID_LIBRARIES}) + FIND_PATH(LIBUUID_INCLUDE_DIRS uuid/uuid.h) + FIND_LIBRARY(LIBUUID_LIBRARIES uuid) + + IF (LIBUUID_LIBRARIES AND LIBUUID_INCLUDE_DIRS) + SET(LIBUUID_FOUND 1) + IF (NOT LibUuid_FIND_QUIETLY) + MESSAGE(STATUS "Found libuuid: ${LIBUUID_LIBRARIES}") + ENDIF ( NOT LibUuid_FIND_QUIETLY ) + ELSE (LIBUUID_LIBRARIES AND LIBUUID_INCLUDE_DIRS) + IF (LibUuid_FIND_REQUIRED) + MESSAGE(SEND_ERROR "Could NOT find libuuid") + ELSE (LibUuid_FIND_REQUIRED) + IF (NOT LIBUUID_FIND_QUIETLY) + MESSAGE(STATUS "Could NOT find libuuid") + ENDIF (NOT LIBUUID_FIND_QUIETLY) + ENDIF (LibUuid_FIND_REQUIRED) + ENDIF (LIBUUID_LIBRARIES AND LIBUUID_INCLUDE_DIRS) + + MARK_AS_ADVANCED(LIBUUID_LIBRARIES LIBUUID_INCLUDE_DIRS) + + message("${LIBUUID_LIBRARIES}") + message("${LIBUUID_INCLUDE_DIRS}") + + if (LIBUUID_FOUND) + target_include_directories(stduuid INTERFACE ${LIBUUID_INCLUDE_DIRS}) + target_link_libraries(stduuid INTERFACE ${LIBUUID_LIBRARIES}) + endif() endif() endif() diff --git a/ecs/include/ecs.h b/ecs/include/ecs.h index ede5179..7619f1d 100644 --- a/ecs/include/ecs.h +++ b/ecs/include/ecs.h @@ -7,6 +7,7 @@ #include #include +#define UUID_SYSTEM_GENERATOR #include "uuid.h" namespace ecs { diff --git a/scripts/generate.py b/scripts/generate.py index 5b85aa6..5b0306f 100755 --- a/scripts/generate.py +++ b/scripts/generate.py @@ -72,7 +72,7 @@ def main(argv): output = argv[2] index = clang.cindex.Index.create() - tu = index.parse(filename, ['-x', 'c++', '-std=c++2a', f'-Iecs/include', f'-Ibuild/_deps/stduuid-src/include', '-I/lib/gcc/x86_64-pc-linux-gnu/10.1.0/include']) + tu = index.parse(filename, ['-x', 'c++', '-std=c++20', f'-Iecs/include', f'-Ibuild/_deps/stduuid-src/include', '-I/lib/gcc/x86_64-pc-linux-gnu/11.1.0/include']) components = build_components(tu.cursor, filename) diff --git a/test/include/components.h b/test/include/components.h index c98abb3..25a65e5 100644 --- a/test/include/components.h +++ b/test/include/components.h @@ -1,4 +1,5 @@ #pragma once +#include #include "ecs.h" struct Position : ecs::Component { diff --git a/test/src/main.cpp b/test/src/main.cpp index e5312fb..9c034f5 100644 --- a/test/src/main.cpp +++ b/test/src/main.cpp @@ -2,8 +2,6 @@ #include "ecs-lua.h" #include "ecs-serial.h" -#include -#include #include #include #include @@ -145,6 +143,9 @@ int main(int argc, const char** argv) { // Load entities from disk as a test std::ifstream file("entities", std::ios::in); + if (!file.is_open()) { + std::cerr << "Failed to open: 'entities'!\n"; + } ecs::serial::deserialize_ids(file);