Skip to content

Commit c3c39b7

Browse files
committed
build(msvc): add cmake flag to enable msvc static runtime debug library
ITK-Wasm prefers static build. For native build on windows (msvc), it is necessary to enable/specify the use of static runtime debug library indicated by the /MTd compiler flag. Add a CMAKE flag (default: ON) to enable/disable this compiler flag when msvc is being used for building.
1 parent 4e833dd commit c3c39b7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ endif()
99

1010
set(WebAssemblyInterface_LIBRARIES WebAssemblyInterface)
1111

12+
if(MSVC) #-- Configure MSVC_STATIC_RUNTIME only if using MSVC environment
13+
option(ITKWASM_MSVC_STATIC_RUNTIME_LIBRARY "Link to MSVC's static CRT (/MT and /MTd).
14+
OFF (default) means link to regular, dynamic CRT (/MD and /MDd)." ON)
15+
mark_as_advanced(ITKWASM_MSVC_STATIC_RUNTIME_LIBRARY)
16+
set(ITKWASM_MSVC_STATIC_RUNTIME_LIBRARY_value ${ITK_MSVC_STATIC_RUNTIME_LIBRARY})
17+
if(ITKWASM_MSVC_STATIC_RUNTIME_LIBRARY)
18+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
19+
message(STATUS "Using MSVC's static CRT (/MT and /MTd)")
20+
else()
21+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
22+
message(STATUS "Using MSVC's dynamic CRT (/MD and /MDd)")
23+
endif()
24+
endif()
25+
1226
include(FetchContent)
1327
set(_itk_build_testing ${BUILD_TESTING})
1428
set(BUILD_TESTING OFF)

0 commit comments

Comments
 (0)