Skip to content

Commit

Permalink
Fixed torch compilation on msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
KiritoDv committed May 26, 2024
1 parent 0dbee95 commit 76e90b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -71,13 +71,13 @@ else()
$<$<CONFIG:Debug>:
/w;
/Od;
/MDd
/MTd
>
$<$<CONFIG:Release>:
/Oi;
/Gy;
/W3;
/MD
/MT
>
/STACK:16777216
/permissive-;
Expand All @@ -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-;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/storm/SWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down

0 comments on commit 76e90b4

Please sign in to comment.