Skip to content

Commit b06d96d

Browse files
authored
Move to standalone CMake. (#13)
1 parent becacb9 commit b06d96d

20 files changed

Lines changed: 676 additions & 538 deletions

.gitattributes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto
3+
4+
# Explicitly declare text files you want to always be normalized and converted
5+
# to native line endings on checkout.
6+
*.cpp text eol=crlf
7+
*.h text eol=crlf

.github/workflows/build.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build ESPTK
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
types: [opened, synchronize, reopened]
8+
9+
jobs:
10+
build:
11+
runs-on: windows-2022
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Configure ESPTK build
16+
shell: pwsh
17+
run: |
18+
cmake --preset vs2022-windows "-DCMAKE_INSTALL_PREFIX=install"
19+
20+
- name: Build ESPTK
21+
run: cmake --build vsbuild --config RelWithDebInfo
22+
23+
- name: Install ESPTK
24+
run: cmake --install vsbuild --config RelWithDebInfo
25+
26+
- name: Upload ESPTK artifact
27+
uses: actions/upload-artifact@master
28+
with:
29+
name: esptk
30+
path: ./install

.github/workflows/linting.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Lint ESPTK
2+
3+
on:
4+
push:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Check format
14+
uses: ModOrganizer2/check-formatting-action@master
15+
with:
16+
check-path: "."

.pre-commit-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-merge-conflict
8+
- id: check-case-conflict
9+
- repo: https://github.com/pre-commit/mirrors-clang-format
10+
rev: v19.1.5
11+
hooks:
12+
- id: clang-format
13+
'types_or': [c++, c]
14+
15+
ci:
16+
autofix_commit_msg: "[pre-commit.ci] Auto fixes from pre-commit.com hooks."
17+
autofix_prs: true
18+
autoupdate_commit_msg: "[pre-commit.ci] Pre-commit autoupdate."
19+
autoupdate_schedule: quarterly
20+
submodules: false

CMakeLists.txt

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
cmake_minimum_required(VERSION 3.16)
22

3-
if(DEFINED DEPENDENCIES_DIR)
4-
include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake)
5-
else()
6-
include(${CMAKE_CURRENT_LIST_DIR}/../cmake_common/mo2.cmake)
7-
endif()
3+
include(CMakePackageConfigHelpers)
84

95
project(esptk)
6+
107
add_subdirectory(src)
8+
9+
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in
10+
"${CMAKE_CURRENT_BINARY_DIR}/mo2-esptk-config.cmake"
11+
INSTALL_DESTINATION "lib/cmake/mo2-esptk"
12+
NO_SET_AND_CHECK_MACRO
13+
NO_CHECK_REQUIRED_COMPONENTS_MACRO
14+
)
15+
16+
write_basic_package_version_file(
17+
"${CMAKE_CURRENT_BINARY_DIR}/mo2-esptk-config-version.cmake"
18+
VERSION "1.3.12"
19+
COMPATIBILITY AnyNewerVersion
20+
)
21+
22+
install(FILES
23+
${CMAKE_CURRENT_BINARY_DIR}/mo2-esptk-config.cmake
24+
${CMAKE_CURRENT_BINARY_DIR}/mo2-esptk-config-version.cmake
25+
DESTINATION lib/cmake/mo2-esptk
26+
)

CMakePresets.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"configurePresets": [
3+
{
4+
"errors": {
5+
"deprecated": true
6+
},
7+
"hidden": true,
8+
"name": "cmake-dev",
9+
"warnings": {
10+
"deprecated": true,
11+
"dev": true
12+
}
13+
},
14+
{
15+
"binaryDir": "${sourceDir}/vsbuild",
16+
"architecture": {
17+
"strategy": "set",
18+
"value": "x64"
19+
},
20+
"cacheVariables": {
21+
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4"
22+
},
23+
"generator": "Visual Studio 17 2022",
24+
"inherits": ["cmake-dev"],
25+
"name": "vs2022-windows",
26+
"toolset": "v143"
27+
}
28+
],
29+
"buildPresets": [
30+
{
31+
"name": "vs2022-windows",
32+
"configurePreset": "vs2022-windows"
33+
}
34+
],
35+
"version": 4
36+
}

appveyor.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

cmake/config.cmake.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@PACKAGE_INIT@
2+
3+
include ( "${CMAKE_CURRENT_LIST_DIR}/mo2-esptk-targets.cmake" )
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
#ifndef ESPEXCEPTIONS_H
2-
#define ESPEXCEPTIONS_H
3-
4-
#include <stdexcept>
5-
6-
namespace ESP
7-
{
8-
9-
class InvalidRecordException : public std::runtime_error
10-
{
11-
public:
12-
InvalidRecordException(const std::string& message) : std::runtime_error(message) {}
13-
};
14-
15-
class InvalidFileException : public std::runtime_error
16-
{
17-
public:
18-
InvalidFileException(const std::string& message) : std::runtime_error(message) {}
19-
};
20-
21-
} // namespace ESP
22-
23-
#endif // ESPEXCEPTIONS_H
1+
#ifndef ESPEXCEPTIONS_H
2+
#define ESPEXCEPTIONS_H
3+
4+
#include <stdexcept>
5+
6+
namespace ESP
7+
{
8+
9+
class InvalidRecordException : public std::runtime_error
10+
{
11+
public:
12+
InvalidRecordException(const std::string& message) : std::runtime_error(message) {}
13+
};
14+
15+
class InvalidFileException : public std::runtime_error
16+
{
17+
public:
18+
InvalidFileException(const std::string& message) : std::runtime_error(message) {}
19+
};
20+
21+
} // namespace ESP
22+
23+
#endif // ESPEXCEPTIONS_H
Lines changed: 72 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,72 @@
1-
#ifndef ESPFILE_H
2-
#define ESPFILE_H
3-
4-
#include "record.h"
5-
#include "tes3record.h"
6-
#include <fstream>
7-
#include <set>
8-
#include <string>
9-
10-
namespace ESP
11-
{
12-
13-
class SubRecord;
14-
15-
class File
16-
{
17-
public:
18-
File(const std::string& fileName);
19-
File(const std::wstring& fileName);
20-
21-
Record readRecord();
22-
23-
bool isMaster() const;
24-
bool isLight(bool overlaySupport = false) const;
25-
bool isMedium() const;
26-
bool isOverlay() const;
27-
bool isBlueprint() const;
28-
bool isDummy() const;
29-
uint16_t formVersion() const { return m_MainRecord.formVersion(); };
30-
float headerVersion() const { return m_Header.version; }
31-
std::string author() const { return m_Author; }
32-
std::string description() const { return m_Description; }
33-
std::set<std::string> masters() const { return m_Masters; }
34-
35-
private:
36-
void init();
37-
38-
void onHEDR(const SubRecord& rec);
39-
void onMAST(const SubRecord& rec);
40-
void onCNAM(const SubRecord& rec);
41-
void onSNAM(const SubRecord& rec);
42-
43-
private:
44-
std::ifstream m_File;
45-
46-
struct
47-
{
48-
float version;
49-
int32_t numRecords;
50-
uint32_t nextObjectId;
51-
} m_Header;
52-
53-
struct
54-
{
55-
float version;
56-
uint32_t unknown;
57-
char author[32];
58-
char description[256];
59-
uint32_t numRecords;
60-
} m_TES3Header;
61-
62-
Record m_MainRecord;
63-
64-
std::string m_Author;
65-
std::string m_Description;
66-
67-
std::set<std::string> m_Masters;
68-
};
69-
70-
} // namespace ESP
71-
72-
#endif // ESPFILE_H
1+
#ifndef ESPFILE_H
2+
#define ESPFILE_H
3+
4+
#include "record.h"
5+
#include "tes3record.h"
6+
#include <fstream>
7+
#include <set>
8+
#include <string>
9+
10+
namespace ESP
11+
{
12+
13+
class SubRecord;
14+
15+
class File
16+
{
17+
public:
18+
File(const std::string& fileName);
19+
File(const std::wstring& fileName);
20+
21+
Record readRecord();
22+
23+
bool isMaster() const;
24+
bool isLight(bool overlaySupport = false) const;
25+
bool isMedium() const;
26+
bool isOverlay() const;
27+
bool isBlueprint() const;
28+
bool isDummy() const;
29+
uint16_t formVersion() const { return m_MainRecord.formVersion(); };
30+
float headerVersion() const { return m_Header.version; }
31+
std::string author() const { return m_Author; }
32+
std::string description() const { return m_Description; }
33+
std::set<std::string> masters() const { return m_Masters; }
34+
35+
private:
36+
void init();
37+
38+
void onHEDR(const SubRecord& rec);
39+
void onMAST(const SubRecord& rec);
40+
void onCNAM(const SubRecord& rec);
41+
void onSNAM(const SubRecord& rec);
42+
43+
private:
44+
std::ifstream m_File;
45+
46+
struct
47+
{
48+
float version;
49+
int32_t numRecords;
50+
uint32_t nextObjectId;
51+
} m_Header;
52+
53+
struct
54+
{
55+
float version;
56+
uint32_t unknown;
57+
char author[32];
58+
char description[256];
59+
uint32_t numRecords;
60+
} m_TES3Header;
61+
62+
Record m_MainRecord;
63+
64+
std::string m_Author;
65+
std::string m_Description;
66+
67+
std::set<std::string> m_Masters;
68+
};
69+
70+
} // namespace ESP
71+
72+
#endif // ESPFILE_H

0 commit comments

Comments
 (0)