summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKiritoDv <kiritodev01@gmail.com>2024-05-26 03:49:42 -0600
committerKiritoDv <kiritodev01@gmail.com>2024-05-26 03:49:42 -0600
commit76e90b4ddc9c215132c39ebf8433d5f88813b368 (patch)
treec8ef86036951ac149135635219e1024f3c5656f4
parent0dbee953a2ab68e03405e8e1bc16abcffaf2b5a5 (diff)
Fixed torch compilation on msvc
-rw-r--r--CMakeLists.txt20
-rw-r--r--src/storm/SWrapper.cpp2
2 files changed, 15 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index abfe76b..6e13ce7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,7 +58,7 @@ if (USE_STANDALONE)
add_definitions(-DSTANDALONE)
add_executable(${PROJECT_NAME} ${SRC_DIR})
else()
- add_library(${PROJECT_NAME} SHARED ${SRC_DIR})
+ add_library(${PROJECT_NAME} STATIC ${SRC_DIR})
endif()
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
@@ -71,13 +71,13 @@ else()
$<$<CONFIG:Debug>:
/w;
/Od;
- /MDd
+ /MTd
>
$<$<CONFIG:Release>:
/Oi;
/Gy;
/W3;
- /MD
+ /MT
>
/STACK:16777216
/permissive-;
@@ -89,13 +89,13 @@ else()
elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
target_compile_options(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:
- /MDd
+ /MTd
>
$<$<CONFIG:Release>:
/O2;
/Oi;
/Gy;
- /MD
+ /MT
>
/STACK:16777216
/permissive-;
@@ -139,7 +139,12 @@ endif()
# Fetch Dependencies
-if(EXISTS "/mnt/c/WINDOWS/system32/wsl.exe")
+if(MSVC)
+ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:16777216")
+endif()
+
+if(NOT USE_STANDALONE AND EXISTS "/mnt/c/WINDOWS/system32/wsl.exe")
FetchContent_Declare(
GSL
GIT_REPOSITORY https://github.com/Microsoft/GSL.git
@@ -171,6 +176,9 @@ endif()
# Link YamlCpp
+set(YAML_CPP_BUILD_TOOLS OFF)
+set(YAML_CPP_BUILD_TESTS OFF)
+set(YAML_CPP_DISABLE_UNINSTALL ON)
FetchContent_Declare(
yaml-cpp
GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git
diff --git a/src/storm/SWrapper.cpp b/src/storm/SWrapper.cpp
index 811e31b..00da1de 100644
--- a/src/storm/SWrapper.cpp
+++ b/src/storm/SWrapper.cpp
@@ -56,7 +56,7 @@ bool SWrapper::CreateFile(const std::string& path, std::vector<char> data) {
}
if(!SFileCreateFile(this->hMpq, path.c_str(), theTime, size, 0, MPQ_FILE_COMPRESS, &hFile)){
- throw std::runtime_error("Failed to create file at path " + path + " with error " + std::to_string(GetLastError()));
+ return false;
}
if(!SFileWriteFile(hFile, (void*) raw, size, MPQ_COMPRESSION_ZLIB)){