From 8724077e97d5aa574bf0c395038160b1cb3de239 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Wed, 1 Mar 2023 10:48:50 +0800 Subject: [PATCH] add cmake support and fix some header issues --- .gitignore | 1 + LibCmo/CKDefines.hpp | 7 ++----- LibCmo/CKGlobals.cpp | 3 ++- LibCmo/CMakeLists.txt | 49 +++++++++++++++++++++++++++++++++++++++++++ LibCmo/VTUtils.hpp | 1 + Unvirt/CMakeLists.txt | 26 +++++++++++++++++++++++ 6 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 LibCmo/CMakeLists.txt create mode 100644 Unvirt/CMakeLists.txt diff --git a/.gitignore b/.gitignore index b854022..7fb4fbd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.vmo CodeGen/dest/*.txt PyCmoOld/ +out/ .vscode/ diff --git a/LibCmo/CKDefines.hpp b/LibCmo/CKDefines.hpp index f7a01fd..e28b38c 100644 --- a/LibCmo/CKDefines.hpp +++ b/LibCmo/CKDefines.hpp @@ -2,6 +2,7 @@ #include #include +#include namespace LibCmo { namespace CK2 { @@ -150,10 +151,6 @@ namespace LibCmo { struct VxQuaternion { union { - struct { - VxVector axis; - float angle; - }; struct { float x, y, z, w; }; @@ -168,7 +165,7 @@ namespace LibCmo { float m_Data[4][4]; VxMatrix() : m_Data() { - memset(m_Data, 0, sizeof(m_Data)); + std::memset(m_Data, 0, sizeof(m_Data)); m_Data[0][0] = m_Data[1][1] = m_Data[2][2] = m_Data[3][3] = 1.0f; } VxMatrix(float m[4][4]) : m_Data() { std::memcpy(m_Data, m, sizeof(m_Data)); } diff --git a/LibCmo/CKGlobals.cpp b/LibCmo/CKGlobals.cpp index 2d04431..70bf288 100644 --- a/LibCmo/CKGlobals.cpp +++ b/LibCmo/CKGlobals.cpp @@ -1,8 +1,9 @@ #include "VTUtils.hpp" #if defined(LIBCMO_OS_WIN32) #define ZLIB_WINAPI -#include #endif +#include + #include "CKGlobals.hpp" #include diff --git a/LibCmo/CMakeLists.txt b/LibCmo/CMakeLists.txt new file mode 100644 index 0000000..efb0f5a --- /dev/null +++ b/LibCmo/CMakeLists.txt @@ -0,0 +1,49 @@ +cmake_minimum_required(VERSION 3.12) +project(LibCmo LANGUAGES CXX) + +# find packages +find_package(ZLIB REQUIRED) +find_package(Iconv REQUIRED) + +# set standard +set(CMAKE_CXX_STANDARD 20) + +set(libcmo_headers ".") +set(libcmo_sources + CKGlobals.cpp + CKFile.cpp + CKFileReader.cpp + CKFileWriter.cpp + CKMinContext.cpp + CKStateChunk.cpp + VxMemoryMappedFile.cpp + VTEncoding.cpp + VTUtils.cpp +) +set(libcmo_managers_sources + CKManagerImplements/CKBaseManager.cpp +) +set(libcmo_objects_sources + CKObjectImplements/CKObject.cpp +) + +# create static library +add_library(LibCmo +STATIC + ${libcmo_sources} + ${libcmo_managers_sources} + ${libcmo_objects_sources} +) +target_link_libraries(LibCmo +PRIVATE + ${ZLIB_LIBRARIES} + ${Iconv_LIBRARIES} +) +target_include_directories(LibCmo +PUBLIC + ${libcmo_headers} +PRIVATE + ${ZLIB_INCLUDE_DIRS} + ${Iconv_INCLUDE_DIRS} +) + diff --git a/LibCmo/VTUtils.hpp b/LibCmo/VTUtils.hpp index 9dab838..c5c1667 100644 --- a/LibCmo/VTUtils.hpp +++ b/LibCmo/VTUtils.hpp @@ -45,6 +45,7 @@ #include #include #include +#include namespace LibCmo { diff --git a/Unvirt/CMakeLists.txt b/Unvirt/CMakeLists.txt new file mode 100644 index 0000000..ded7d84 --- /dev/null +++ b/Unvirt/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 3.12) +project(Unvirt LANGUAGES CXX) + +# add libcmo +add_subdirectory("../LibCmo" "LibCmo.out") + +# setup sources +set(unvirt_sources + AccessibleValue.cpp + CmdHelper.cpp + StringHelper.cpp + StructFormatter.cpp + TerminalHelper.cpp + Unvirt.cpp +) + +# set languages +set(CMAKE_CXX_STANDARD 20) + +# generate program +add_executable(Unvirt ${unvirt_sources}) +target_link_libraries(Unvirt +PRIVATE + LibCmo +) +