Skip to content

Commit

Permalink
SE/AE refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
powerof3 committed Apr 17, 2022
1 parent 3ef4be8 commit 9f9d13d
Show file tree
Hide file tree
Showing 17 changed files with 384 additions and 263 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
build/
build*/
/.vs
71 changes: 56 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
cmake_minimum_required(VERSION 3.20)
set(NAME "po3_SimpleActivateSKSE")
set(VERSION 1.3.0)
set(AE_VERSION 1)

# ---- Options ----

option(COPY_BUILD "Copy the build output to the Skyrim directory." TRUE)
option(BUILD_SKYRIMAE "Build for Skyrim AE" OFF)

# ---- Cache build vars ----

Expand All @@ -12,9 +16,41 @@ macro(set_from_environment VARIABLE)
endif ()
endmacro()

set_from_environment(Skyrim64Path)
set_from_environment(VCPKG_ROOT)
set_from_environment(CommonLibSSEPath)

macro(find_commonlib_path)
if (CommonLibName AND NOT ${CommonLibName} STREQUAL "")
# Check extern
find_path(CommonLibPath
include/REL/Relocation.h
PATHS extern/${CommonLibName})
if (${CommonLibPath} STREQUAL "CommonLibPath-NOTFOUND")
#Check path
set_from_environment(${CommonLibName}Path)
set(CommonLibPath ${${CommonLibName}Path})
endif()
endif()
endmacro()

set_from_environment(VCPKG_ROOT)
if(BUILD_SKYRIMAE)
add_compile_definitions(SKYRIM_AE)
set(CommonLibName "CommonLibSSE")
set_from_environment(SkyrimAEPath)
set(SkyrimPath ${SkyrimAEPath})
set(SkyrimVersion "Skyrim AE")
set(VERSION ${VERSION}.${AE_VERSION})
else()
set(CommonLibName "CommonLibSSE")
set_from_environment(Skyrim64Path)
set(SkyrimPath ${Skyrim64Path})
set(SkyrimVersion "Skyrim SSE")
endif()
find_commonlib_path()
message(
STATUS
"Building for ${SkyrimVersion} at ${SkyrimPath} with ${CommonLibName} at ${CommonLibPath}."
)

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

project(
po3_SimpleActivateSKSE
VERSION 1.2.1
${NAME}
VERSION ${VERSION}
LANGUAGES CXX
)

Expand Down Expand Up @@ -64,6 +100,12 @@ add_compile_definitions(
SKSE_SUPPORT_XBYAK
)

if (BUILD_SKYRIMAE)
add_compile_definitions(
SKYRIM_SUPPORT_AE
)
endif()

if (MSVC)
if (NOT ${CMAKE_GENERATOR} STREQUAL "Ninja")
add_compile_options(
Expand All @@ -79,14 +121,14 @@ set(Boost_USE_STATIC_LIBS ON)

# ---- Dependencies ----

if (DEFINED CommonLibSSEPath AND NOT ${CommonLibSSEPath} STREQUAL "" AND IS_DIRECTORY ${CommonLibSSEPath})
add_subdirectory(${CommonLibSSEPath} CommonLibSSE)
if (DEFINED CommonLibPath AND NOT ${CommonLibPath} STREQUAL "" AND IS_DIRECTORY ${CommonLibPath})
add_subdirectory(${CommonLibPath} ${CommonLibName})
else ()
message(
FATAL_ERROR
"Variable CommonLibSSEPath is not set."
"Variable ${CommonLibName}Path is not set or in extern/."
)
endif ()
endif()

find_path(SIMPLEINI_INCLUDE_DIRS "ConvertUTF.c")

Expand Down Expand Up @@ -125,7 +167,7 @@ add_library(
target_compile_features(
${PROJECT_NAME}
PRIVATE
cxx_std_20
cxx_std_23
)

target_compile_definitions(
Expand All @@ -145,7 +187,7 @@ target_include_directories(
target_link_libraries(
${PROJECT_NAME}
PRIVATE
CommonLibSSE::CommonLibSSE
${CommonLibName}::${CommonLibName}
)

target_precompile_headers(
Expand Down Expand Up @@ -204,23 +246,22 @@ if (MSVC)
"$<$<CONFIG:DEBUG>:/INCREMENTAL;/OPT:NOREF;/OPT:NOICF>"
"$<$<CONFIG:RELEASE>:/INCREMENTAL:NO;/OPT:REF;/OPT:ICF;/DEBUG:FULL>"
)

endif ()

# ---- Post build ----

if (COPY_BUILD)
if (DEFINED Skyrim64Path)
if (DEFINED SkyrimPath)
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${PROJECT_NAME}> ${Skyrim64Path}/Data/SKSE/Plugins/
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PDB_FILE:${PROJECT_NAME}> ${Skyrim64Path}/Data/SKSE/Plugins/
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${PROJECT_NAME}> ${SkyrimPath}/Data/SKSE/Plugins/
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PDB_FILE:${PROJECT_NAME}> ${SkyrimPath}/Data/SKSE/Plugins/
)
else ()
message(
WARNING
"Variable Skyrim64Path is not defined. Skipping post-build copy command."
"Variable ${SkyrimPath} is not defined. Skipping post-build copy command."
)
endif ()
endif ()
39 changes: 36 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"CMAKE_TOOLCHAIN_FILE": {
"type": "STRING",
"value": "$env{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake"
},
"VCPKG_OVERLAY_PORTS": {
"type": "STRING",
"value": "${sourceDir}/cmake/ports/"
}
},
"hidden": true,
Expand Down Expand Up @@ -52,7 +56,21 @@
"vcpkg",
"windows"
],
"name": "vs2019-windows-vcpkg"
"name": "vs2019-windows-vcpkg-se"
},
{
"binaryDir": "${sourceDir}/buildae",
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4 /external:anglebrackets /external:W0 $penv{CXXFLAGS}",
"BUILD_SKYRIMAE": true
},
"generator": "Visual Studio 16 2019",
"inherits": [
"cmake-dev",
"vcpkg",
"windows"
],
"name": "vs2019-windows-vcpkg-ae"
},
{
"cacheVariables": {
Expand All @@ -64,9 +82,24 @@
"vcpkg",
"windows"
],
"name": "vs2022-windows-vcpkg",
"name": "vs2022-windows-vcpkg-se",
"toolset": "v143"
},
{
"binaryDir": "${sourceDir}/buildae",
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4 /WX $penv{CXXFLAGS}",
"BUILD_SKYRIMAE": true
},
"generator": "Visual Studio 17 2022",
"inherits": [
"cmake-dev",
"vcpkg",
"windows"
],
"name": "vs2022-windows-vcpkg-ae",
"toolset": "v143"
}
],
"version": 2
"version": 3
}
15 changes: 0 additions & 15 deletions CMakeSettings.json

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 powerofthree
Copyright (c) 2021-2022 powerofthree

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 2 additions & 0 deletions ProjectGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def make_cmake():
headers.append(name)
elif name.endswith(SOURCE_TYPES):
sources.append(name)
headers.sort()
sources.sort()

def do_make(a_filename, a_varname, a_files):
out = open("cmake/" + a_filename + ".cmake", "w", encoding="utf-8")
Expand Down
1 change: 1 addition & 0 deletions cmake/headerlist.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
set(headers ${headers}
src/Manager.h
src/PCH.h
src/Settings.h
)
20 changes: 20 additions & 0 deletions cmake/ports/simpleini/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# header-only library
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO powerof3/simpleini
REF 2328c20c7d11d88774f55441367196d8e90db418
SHA512 7069b0c5d0b02b9992096ceb03b855acbfc5fe3715e2337f778bfcf9834251d2a5122d78b492dde4e70b8f2840be34fc2f9bafef9e4709a8d8c3da6bfba7270b
HEAD_REF master
)

# Install codes
set(SIMPLEINI_SOURCE ${SOURCE_PATH}/SimpleIni.h
${SOURCE_PATH}/ConvertUTF.h
${SOURCE_PATH}/ConvertUTF.c
)

file(INSTALL ${SIMPLEINI_SOURCE} DESTINATION ${CURRENT_PACKAGES_DIR}/include)
# Install sample
#file(INSTALL ${SOURCE_PATH}/snippets.cpp DESTINATION ${CURRENT_PACKAGES_DIR}/share/sample)

file(INSTALL ${SOURCE_PATH}/LICENCE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
7 changes: 7 additions & 0 deletions cmake/ports/simpleini/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "simpleini",
"version-string": "4.19",
"port-version": 1,
"description": "Cross-platform C++ library providing a simple API to read and write INI-style configuration files. Fork to allow empty values",
"homepage": "https://github.com/powerof3/simpleini"
}
3 changes: 2 additions & 1 deletion cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
set(sources ${sources}
src/main.cpp
src/Manager.cpp
src/PCH.cpp
src/Settings.cpp
src/main.cpp
)
Loading

0 comments on commit 9f9d13d

Please sign in to comment.