Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 05f4ef0

Browse files
authored
Merge pull request #1 from alandtse/master
Enable VR building
2 parents 9dc47d7 + 934833c commit 05f4ef0

7 files changed

Lines changed: 126 additions & 18 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
build/
1+
build*/
22
/.vs

CMakeLists.txt

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
cmake_minimum_required(VERSION 3.20)
2+
set(NAME "po3_BaseObjectSwapper")
3+
set(VERSION 1.1.0)
4+
set(VR_VERSION 1)
25

36
# ---- Options ----
47

58
option(COPY_BUILD "Copy the build output to the Skyrim directory." TRUE)
9+
option(BUILD_SKYRIMVR "Build for Skyrim VR" OFF)
610

711
# ---- Cache build vars ----
812

@@ -12,9 +16,42 @@ macro(set_from_environment VARIABLE)
1216
endif ()
1317
endmacro()
1418

15-
set_from_environment(Skyrim64Path)
1619
set_from_environment(VCPKG_ROOT)
17-
set_from_environment(CommonLibSSEPath)
20+
21+
macro(find_commonlib_path)
22+
if (CommonLibName AND NOT ${CommonLibName} STREQUAL "")
23+
# Check extern
24+
find_path(CommonLibPath
25+
include/REL/Relocation.h
26+
PATHS extern/${CommonLibName})
27+
if (${CommonLibPath} STREQUAL "CommonLibPath-NOTFOUND")
28+
#Check path
29+
set_from_environment(${CommonLibName}Path)
30+
set(CommonLibPath ${${CommonLibName}Path})
31+
endif()
32+
endif()
33+
endmacro()
34+
35+
if(BUILD_SKYRIMVR)
36+
add_compile_definitions(SKYRIMVR)
37+
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
38+
set(CommonLibName "CommonLibVR")
39+
set_from_environment(SkyrimVRPath)
40+
set(SkyrimPath ${SkyrimVRPath})
41+
set(SkyrimVersion "Skyrim VR")
42+
set(VERSION "${VERSION}.${VR_VERSION}")
43+
else()
44+
set(CommonLibName "CommonLibSSE")
45+
set_from_environment(Skyrim64Path)
46+
set(SkyrimPath ${Skyrim64Path})
47+
set(SkyrimVersion "Skyrim SSE")
48+
endif()
49+
find_commonlib_path()
50+
message(
51+
STATUS
52+
"Building for ${SkyrimVersion} at ${SkyrimPath} with ${CommonLibName} at ${CommonLibPath}."
53+
)
54+
1855

1956
if (DEFINED VCPKG_ROOT)
2057
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
@@ -32,8 +69,8 @@ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STR
3269
# ---- Project ----
3370

3471
project(
35-
po3_BaseObjectSwapper
36-
VERSION 1.1.0
72+
${NAME}
73+
VERSION ${VERSION}
3774
LANGUAGES CXX
3875
)
3976

@@ -79,14 +116,14 @@ set(Boost_USE_STATIC_LIBS ON)
79116

80117
# ---- Dependencies ----
81118

82-
if (DEFINED CommonLibSSEPath AND NOT ${CommonLibSSEPath} STREQUAL "" AND IS_DIRECTORY ${CommonLibSSEPath})
83-
add_subdirectory(${CommonLibSSEPath} CommonLibSSE)
119+
if (DEFINED CommonLibPath AND NOT ${CommonLibPath} STREQUAL "" AND IS_DIRECTORY ${CommonLibPath})
120+
add_subdirectory(${CommonLibPath} ${CommonLibName})
84121
else ()
85122
message(
86123
FATAL_ERROR
87-
"Variable CommonLibSSEPath is not set."
124+
"Variable ${CommonLibName}Path is not set or in extern/."
88125
)
89-
endif ()
126+
endif()
90127

91128
find_path(SIMPLEINI_INCLUDE_DIRS "ConvertUTF.c")
92129

@@ -145,7 +182,7 @@ target_include_directories(
145182
target_link_libraries(
146183
${PROJECT_NAME}
147184
PRIVATE
148-
CommonLibSSE::CommonLibSSE
185+
${CommonLibName}::${CommonLibName}
149186
)
150187

151188
target_precompile_headers(
@@ -204,23 +241,22 @@ if (MSVC)
204241
"$<$<CONFIG:DEBUG>:/INCREMENTAL;/OPT:NOREF;/OPT:NOICF>"
205242
"$<$<CONFIG:RELEASE>:/INCREMENTAL:NO;/OPT:REF;/OPT:ICF;/DEBUG:FULL>"
206243
)
207-
208244
endif ()
209245

210246
# ---- Post build ----
211247

212248
if (COPY_BUILD)
213-
if (DEFINED Skyrim64Path)
249+
if (DEFINED SkyrimPath)
214250
add_custom_command(
215251
TARGET ${PROJECT_NAME}
216252
POST_BUILD
217-
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${PROJECT_NAME}> ${Skyrim64Path}/Data/SKSE/Plugins/
218-
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PDB_FILE:${PROJECT_NAME}> ${Skyrim64Path}/Data/SKSE/Plugins/
253+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${PROJECT_NAME}> ${SkyrimPath}/Data/SKSE/Plugins/
254+
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PDB_FILE:${PROJECT_NAME}> ${SkyrimPath}/Data/SKSE/Plugins/
219255
)
220256
else ()
221257
message(
222258
WARNING
223-
"Variable Skyrim64Path is not defined. Skipping post-build copy command."
259+
"Variable ${SkyrimPath} is not defined. Skipping post-build copy command."
224260
)
225261
endif ()
226262
endif ()

CMakePresets.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
"CMAKE_TOOLCHAIN_FILE": {
2424
"type": "STRING",
2525
"value": "$env{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake"
26+
},
27+
"VCPKG_OVERLAY_PORTS": {
28+
"type": "STRING",
29+
"value": "${sourceDir}/cmake/ports/"
2630
}
2731
},
2832
"hidden": true,
@@ -66,6 +70,21 @@
6670
],
6771
"name": "vs2022-windows-vcpkg",
6872
"toolset": "v143"
73+
},
74+
{
75+
"binaryDir": "${sourceDir}/buildvr",
76+
"cacheVariables": {
77+
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4 /WX $penv{CXXFLAGS}",
78+
"BUILD_SKYRIMVR": true
79+
},
80+
"generator": "Visual Studio 17 2022",
81+
"inherits": [
82+
"cmake-dev",
83+
"vcpkg",
84+
"windows"
85+
],
86+
"name": "vs2022-windows-vcpkg-vr",
87+
"toolset": "v143"
6988
}
7089
],
7190
"version": 2

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Base Object Swapper
22

3-
SKSE plugin and framework that allows swapping base forms at runtime
3+
SKSE/SKSEVR plugin and framework that allows swapping base forms at runtime
4+
[SSE/AE](https://www.nexusmods.com/skyrimspecialedition/mods/60805)
5+
[VR](https://www.nexusmods.com/skyrimspecialedition/mods/61734)
46

57
## Requirements
68
* [CMake](https://cmake.org/)
@@ -13,6 +15,14 @@ SKSE plugin and framework that allows swapping base forms at runtime
1315
* [CommonLibSSE](https://github.com/powerof3/CommonLibSSE/tree/dev)
1416
* You need to build from the powerof3/dev branch
1517
* Add this as as an environment variable `CommonLibSSEPath`
18+
* [CommonLibVR](https://github.com/alandtse/CommonLibVR/tree/vr)
19+
* Add this as as an environment variable `CommonLibVRPath` instead of /external
20+
21+
## User Requirements
22+
* [Address Library for SKSE](https://www.nexusmods.com/skyrimspecialedition/mods/32444)
23+
* Needed for SSE/AE
24+
* [VR Address Library for SKSEVR](https://www.nexusmods.com/skyrimspecialedition/mods/58101)
25+
* Needed for VR
1626

1727
## Register Visual Studio as a Generator
1828
* Open `x64 Native Tools Command Prompt`
@@ -23,7 +33,17 @@ SKSE plugin and framework that allows swapping base forms at runtime
2333
```
2434
git clone https://github.com/powerof3/BaseObjectSwapper.git
2535
cd BaseObjectSwapper
26-
cmake -B build -S .
36+
```
37+
38+
### SSE
39+
```
40+
cmake --preset vs2022-windows-vcpkg
41+
cmake --build build --config Release
42+
```
43+
### VR
44+
```
45+
cmake --preset vs2022-windows-vcpkg-vr
46+
cmake --build buildvr --config Release
2747
```
2848
## License
2949
[MIT](LICENSE)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# header-only library
2+
vcpkg_from_github(
3+
OUT_SOURCE_PATH SOURCE_PATH
4+
REPO alandtse/simpleini
5+
REF 55f28458df411b3573be624a99f9aa54d8977e5f
6+
SHA512 0ea40296b1b9b861fd3ccd9198ae9a7654b16160aad10ebc643c55996445ead683775e4c6fe7e5a241fec37e3be2200c8f8527d4ef0bbaee767f7a45390dfda1
7+
HEAD_REF allow_empty_values
8+
)
9+
10+
# Install codes
11+
set(SIMPLEINI_SOURCE ${SOURCE_PATH}/SimpleIni.h
12+
${SOURCE_PATH}/ConvertUTF.h
13+
${SOURCE_PATH}/ConvertUTF.c
14+
)
15+
16+
file(INSTALL ${SIMPLEINI_SOURCE} DESTINATION ${CURRENT_PACKAGES_DIR}/include)
17+
# Install sample
18+
#file(INSTALL ${SOURCE_PATH}/snippets.cpp DESTINATION ${CURRENT_PACKAGES_DIR}/share/sample)
19+
20+
file(INSTALL ${SOURCE_PATH}/LICENCE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)

cmake/ports/simpleini/vcpkg.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "simpleini",
3+
"version-string": "2021-01-13",
4+
"port-version": 1,
5+
"description": "Cross-platform C++ library providing a simple API to read and write INI-style configuration files. Fork to allow empty values",
6+
"homepage": "https://github.com/alandtse/simpleini"
7+
}

src/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Query(const SKSE::QueryInterface* a
9090
}
9191

9292
const auto ver = a_skse->RuntimeVersion();
93-
if (ver < SKSE::RUNTIME_1_5_39) {
93+
if (ver <
94+
#ifndef SKYRIMVR
95+
SKSE::RUNTIME_1_5_39
96+
#else
97+
SKSE::RUNTIME_VR_1_4_15
98+
#endif
99+
) {
94100
logger::critical(FMT_STRING("Unsupported runtime version {}"), ver.string());
95101
return false;
96102
}

0 commit comments

Comments
 (0)