11cmake_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
58option (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 ()
1317endmacro ()
1418
15- set_from_environment (Skyrim64Path )
1619set_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
1956if (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
3471project (
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} )
84121else ()
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
91128find_path (SIMPLEINI_INCLUDE_DIRS "ConvertUTF.c" )
92129
@@ -145,7 +182,7 @@ target_include_directories(
145182target_link_libraries (
146183 ${PROJECT_NAME }
147184 PRIVATE
148- CommonLibSSE::CommonLibSSE
185+ ${CommonLibName} ::${CommonLibName}
149186)
150187
151188target_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-
208244endif ()
209245
210246# ---- Post build ----
211247
212248if (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 ()
226262endif ()
0 commit comments