add cmake support and fix some header issues

This commit is contained in:
yyc12345 2023-03-01 10:48:50 +08:00
parent fcc9f10064
commit 8724077e97
6 changed files with 81 additions and 6 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@
*.vmo
CodeGen/dest/*.txt
PyCmoOld/
out/
.vscode/

View File

@ -2,6 +2,7 @@
#include <string>
#include <vector>
#include <cstring>
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)); }

View File

@ -1,8 +1,9 @@
#include "VTUtils.hpp"
#if defined(LIBCMO_OS_WIN32)
#define ZLIB_WINAPI
#include <zconf.h>
#endif
#include <zconf.h>
#include "CKGlobals.hpp"
#include <zlib.h>

49
LibCmo/CMakeLists.txt Normal file
View File

@ -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}
)

View File

@ -45,6 +45,7 @@
#include <type_traits>
#include <cinttypes>
#include <cstdint>
#include <initializer_list>
namespace LibCmo {

26
Unvirt/CMakeLists.txt Normal file
View File

@ -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
)