Skip to content

Commit

Permalink
Statically link the VCRuntime
Browse files Browse the repository at this point in the history
  • Loading branch information
vkedwardli committed Jan 11, 2025
1 parent 17f5435 commit b88e3d8
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.10.2)
cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW)

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
Expand Down Expand Up @@ -245,6 +246,7 @@ if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /ZW)
endif()
target_compile_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:Release>:/Zi>")
set_property(TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_link_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:Release>:/DEBUG>")
target_link_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:Release>:/OPT:REF>")
target_link_options(${PROJECT_NAME} PRIVATE "$<$<CONFIG:Release>:/OPT:ICF>")
Expand Down Expand Up @@ -458,6 +460,12 @@ if(USE_VULKAN)
option(ENABLE_HLSL "Enables HLSL input support" OFF)
option(ENABLE_PCH "Enables Precompiled header" OFF)
add_subdirectory(core/deps/glslang EXCLUDE_FROM_ALL)
if(MSVC)
set_property(TARGET glslang-default-resource-limits PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_property(TARGET MachineIndependent PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_property(TARGET GenericCodeGen PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_property(TARGET SPIRV PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
add_library(glslang::glslang-default-resource-limits ALIAS glslang-default-resource-limits)
add_library(glslang::SPIRV ALIAS SPIRV)
endif()
Expand Down Expand Up @@ -687,6 +695,9 @@ target_sources(${PROJECT_NAME} PRIVATE
core/deps/chdpsr/cdipsr.h)

add_subdirectory(core/deps/nowide EXCLUDE_FROM_ALL)
if(MSVC)
set_property(TARGET nowide PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE nowide::nowide)

if(NOT MINIUPNP_FOUND)
Expand All @@ -698,6 +709,10 @@ if(NOT MINIUPNP_FOUND)
option(UPNPC_BUILD_SAMPLE "Build sample executables" OFF)
option(UPNPC_NO_INSTALL "Disable installation" ON)
add_subdirectory(core/deps/miniupnpc)
if(MSVC)
set_property(TARGET miniupnpc-private PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set_property(TARGET libminiupnpc-static PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
if(WINDOWS_STORE)
get_target_property(miniupnpc-private-defs miniupnpc-private INTERFACE_COMPILE_DEFINITIONS)
list(REMOVE_ITEM miniupnpc-private-defs "_WIN32_WINNT=0x0501")
Expand Down Expand Up @@ -853,6 +868,9 @@ if(USE_DISCORD AND NOT LIBRETRO)
endif()

cmrc_add_resource_library(flycast-resources ALIAS flycast::res NAMESPACE flycast)
if(MSVC)
set_property(TARGET flycast-resources PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE flycast::res)

if(LIBRETRO)
Expand Down Expand Up @@ -1941,7 +1959,7 @@ if(NOT LIBRETRO)
if(NOT BUILD_TESTING AND ("x86" IN_LIST ARCHITECTURE OR "x86_64" IN_LIST ARCHITECTURE))
target_include_directories(${PROJECT_NAME} PRIVATE core/deps/Spout/SPOUTSDK/SpoutGL)
target_include_directories(${PROJECT_NAME} PRIVATE core/deps/Spout/SPOUTSDK/SpoutDirectX/SpoutDX)
SET(SPOUT_BUILD_CMT OFF CACHE BOOL "For Visual Studio - build /MT to link runtime libraries" FORCE)
SET(SPOUT_BUILD_CMT ON CACHE BOOL "For Visual Studio - build /MT to link runtime libraries" FORCE)
SET(SPOUT_BUILD_SPOUTDX ON CACHE BOOL "Build SpoutDX DirectX11 support library" FORCE)
SET(SPOUT_BUILD_LIBRARY OFF CACHE BOOL "Build C-compatible cross compiler library" FORCE)
SET(SKIP_INSTALL_ALL ON CACHE BOOL "Install headers and libraries" FORCE)
Expand Down

0 comments on commit b88e3d8

Please sign in to comment.