From fff4eb0244df7578024c653b8563c37a420f925b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=B5=E5=B0=8F=E5=87=A1?= <2672931+whyb@users.noreply.github.com> Date: Tue, 15 Jul 2025 18:48:28 +0800 Subject: [PATCH] CMake: Force enable MSVC multi-processor build (/MP) --- CMakeLists.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 800bf47ca..f72626005 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,11 +44,14 @@ endif() project(ncnn) -if(MSVC AND NOT CMAKE_VERSION VERSION_LESS "3.15") - option(NCNN_BUILD_WITH_STATIC_CRT "Enables use of statically linked CRT for statically linked ncnn" OFF) - if(NCNN_BUILD_WITH_STATIC_CRT) - # cmake before version 3.15 not work - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +if(MSVC) + add_compile_options(/MP) + if(NOT CMAKE_VERSION VERSION_LESS "3.15") + option(NCNN_BUILD_WITH_STATIC_CRT "Enables use of statically linked CRT for statically linked ncnn" OFF) + if(NCNN_BUILD_WITH_STATIC_CRT) + # cmake before version 3.15 not work + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + endif() endif() endif()