From 0f2f25f0afa8e1bcea50004a4e33b2fe0a0a3224 Mon Sep 17 00:00:00 2001 From: nihui Date: Thu, 14 Apr 2022 10:35:22 +0800 Subject: [PATCH] pnnx static msvc crt option --- tools/pnnx/CMakeLists.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/pnnx/CMakeLists.txt b/tools/pnnx/CMakeLists.txt index 74884561a..2e927833c 100644 --- a/tools/pnnx/CMakeLists.txt +++ b/tools/pnnx/CMakeLists.txt @@ -2,7 +2,20 @@ project(pnnx) cmake_minimum_required(VERSION 3.12) if(POLICY CMP0074) - cmake_policy(SET CMP0074 NEW) + cmake_policy(SET CMP0074 NEW) +endif() + +if(NOT CMAKE_VERSION VERSION_LESS "3.15") + # enable CMAKE_MSVC_RUNTIME_LIBRARY + cmake_policy(SET CMP0091 NEW) +endif() + +if(MSVC AND NOT CMAKE_VERSION VERSION_LESS "3.15") + option(PNNX_BUILD_WITH_STATIC_CRT "Enables use of statically linked CRT for statically linked ncnn" OFF) + if(PNNX_BUILD_WITH_STATIC_CRT) + # cmake before version 3.15 not work + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + endif() endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")