Skip to content

Commit

Permalink
Standardize cmakelists, submodule path
Browse files Browse the repository at this point in the history
  • Loading branch information
powerof3 committed Oct 4, 2022
1 parent 9cb524e commit 73c85b3
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 73 deletions.
11 changes: 4 additions & 7 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "extern/CommonLibSSE"]
path = extern/CommonLibSSE
url = https://github.com/Ryan-rsm-McKenzie/CommonLibSSE
[submodule "external/CommonLibSSE"]
path = external/CommonLibSSE
url = https://github.com/powerof3/CommonLibSSE.git
[submodule "external/CommonLibVR"]
path = external/CommonLibVR
url = https://github.com/alandtse/CommonLibVR.git
url = https://github.com/powerof3/CommonLibSSE
[submodule "extern/CommonLibVR"]
path = extern/CommonLibVR
url = https://github.com/alandtse/CommonLibVR
83 changes: 22 additions & 61 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ macro(find_commonlib_path)
# Check extern
find_path(CommonLibPath
include/REL/Relocation.h
PATHS external/${CommonLibName})
PATHS extern/${CommonLibName})
if (${CommonLibPath} STREQUAL "CommonLibPath-NOTFOUND")
#Check path
set_from_environment(${CommonLibName}Path)
Expand All @@ -35,13 +35,15 @@ endmacro()
set_from_environment(VCPKG_ROOT)
if(BUILD_SKYRIMAE)
add_compile_definitions(SKYRIM_AE)
add_compile_definitions(SKYRIM_SUPPORT_AE)
set(CommonLibName "CommonLibSSE")
set_from_environment(SkyrimAEPath)
set(SkyrimPath ${SkyrimAEPath})
set(SkyrimVersion "Skyrim AE")
set(VERSION ${VERSION}.${AE_VERSION})
elseif(BUILD_SKYRIMVR)
add_compile_definitions(SKYRIMVR)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
set(CommonLibName "CommonLibVR")
set_from_environment(SkyrimVRPath)
set(SkyrimPath ${SkyrimVRPath})
Expand Down Expand Up @@ -70,6 +72,7 @@ else ()
endif ()

set(Boost_USE_STATIC_RUNTIME OFF CACHE BOOL "")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STRING "")

# ---- Project ----

Expand Down Expand Up @@ -106,17 +109,7 @@ add_compile_definitions(
SKSE_SUPPORT_XBYAK
)

if (BUILD_SKYRIMAE)
add_compile_definitions(
SKYRIM_SUPPORT_AE
)
endif()

if (MSVC)
add_compile_definitions(
_UNICODE
)

if (NOT ${CMAKE_GENERATOR} STREQUAL "Ninja")
add_compile_options(
/MP # Build with Multiple Processes
Expand All @@ -128,7 +121,6 @@ set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF)

set(Boost_USE_STATIC_LIBS ON)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STRING "")

# ---- Dependencies ----

Expand All @@ -137,7 +129,7 @@ if (DEFINED CommonLibPath AND NOT ${CommonLibPath} STREQUAL "" AND IS_DIRECTORY
else ()
message(
FATAL_ERROR
"Variable ${CommonLibName}Path is not set."
"Variable ${CommonLibName}Path is not set or in extern/."
)
endif()

Expand Down Expand Up @@ -189,7 +181,7 @@ target_include_directories(
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include
${CommonLibPath}/x64/Release
${SRELL_INCLUDE_DIRS}
)


Expand All @@ -200,43 +192,24 @@ target_link_libraries(
frozen::frozen
)

target_precompile_headers(
${PROJECT_NAME}
PRIVATE
include/PCH.h
)

if (MSVC)
target_compile_options(
${PROJECT_NAME}
PRIVATE
/sdl # Enable Additional Security Checks
/utf-8 # Set Source and Executable character sets to UTF-8
/Zi # Debug Information Format

/permissive- # Standards conformance

/Zc:alignedNew # C++17 over-aligned allocation
/Zc:auto # Deduce Variable Type
/Zc:char8_t
/Zc:__cplusplus # Enable updated __cplusplus macro
/Zc:externC
/Zc:externConstexpr # Enable extern constexpr variables
/Zc:forScope # Force Conformance in for Loop Scope
/Zc:hiddenFriend
/Zc:implicitNoexcept # Implicit Exception Specifiers
/Zc:lambda
/Zc:noexceptTypes # C++17 noexcept rules
/Zc:preprocessor # Enable preprocessor conformance mode
/Zc:referenceBinding # Enforce reference binding rules
/Zc:rvalueCast # Enforce type conversion rules
/Zc:sizedDealloc # Enable Global Sized Deallocation Functions
/Zc:strictStrings # Disable string literal type conversion
/Zc:ternary # Enforce conditional operator rules
/Zc:threadSafeInit # Thread-safe Local Static Initialization
/Zc:tlsGuards
/Zc:trigraphs # Trigraphs Substitution
/Zc:wchar_t # wchar_t Is Native Type

/external:anglebrackets
/external:W0

/W4 # Warning level
/WX # Warning level (warnings are errors)
/sdl # Enable Additional Security Checks
/utf-8 # Set Source and Executable character sets to UTF-8
/Zi # Debug Information Format

/permissive- # Standards conformance
/Zc:preprocessor # Enable preprocessor conformance mode

/wd4200 # nonstandard extension used : zero-sized array in struct/union

"$<$<CONFIG:DEBUG>:>"
"$<$<CONFIG:RELEASE>:/Zc:inline;/JMC-;/Ob3>"
Expand All @@ -245,32 +218,20 @@ if (MSVC)
target_link_options(
${PROJECT_NAME}
PRIVATE
/WX # Treat Linker Warnings as Errors

"$<$<CONFIG:DEBUG>:/INCREMENTAL;/OPT:NOREF;/OPT:NOICF>"
"$<$<CONFIG:RELEASE>:/INCREMENTAL:NO;/OPT:REF;/OPT:ICF;/DEBUG:FULL>"
)

# fix a warning with /Ob2 being overridden with /Ob3
string(REPLACE "/Ob2" "/Ob3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")

endif ()

target_precompile_headers(
${PROJECT_NAME}
PRIVATE
include/PCH.h
)

# ---- Post build ----

if (COPY_BUILD)
if (DEFINED SkyrimPath)
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
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/
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${PROJECT_NAME}> ${SkyrimPath}/SKSE/Plugins/
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_PDB_FILE:${PROJECT_NAME}> ${SkyrimPath}/SKSE/Plugins/
)
else ()
message(
Expand Down
6 changes: 3 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "STRING",
"value": "$env{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake"
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
},
"hidden": true,
Expand Down Expand Up @@ -98,7 +98,7 @@
},
{
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4 /WX $penv{CXXFLAGS}"
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4 /external:anglebrackets /external:W0 $penv{CXXFLAGS}"
},
"generator": "Visual Studio 17 2022",
"inherits": [
Expand All @@ -125,7 +125,7 @@
},
{
"cacheVariables": {
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4 /WX $penv{CXXFLAGS}"
"CMAKE_CXX_FLAGS": "/EHsc /MP /W4 /external:anglebrackets /external:W0 $penv{CXXFLAGS}"
},
"generator": "Visual Studio 17 2022",
"inherits": [
Expand Down
1 change: 1 addition & 0 deletions extern/CommonLibSSE
Submodule CommonLibSSE added at 774a96
1 change: 1 addition & 0 deletions extern/CommonLibVR
Submodule CommonLibVR added at 486a75
1 change: 0 additions & 1 deletion external/CommonLibSSE
Submodule CommonLibSSE deleted from 20212b
1 change: 0 additions & 1 deletion external/CommonLibVR
Submodule CommonLibVR deleted from 3b265e

0 comments on commit 73c85b3

Please sign in to comment.