From e9ee52ccba84cb56fd938fa8fadca7c64e77412e Mon Sep 17 00:00:00 2001 From: Eric Sommerlade Date: Sun, 11 Jun 2023 15:32:43 +0100 Subject: [PATCH 1/3] setting msvc runtime and compiler flag if OCOS_ENABLE_STATIC_LIB is set. --- CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 96a3ea43e..0914af2b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,14 @@ cmake_minimum_required(VERSION 3.25) project(onnxruntime_extensions LANGUAGES C CXX) # set(CMAKE_VERBOSE_MAKEFILE ON) -if(NOT CMAKE_BUILD_TYPE) - message(STATUS "Build type not set - using RelWithDebInfo") - set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose build type: Debug Release RelWithDebInfo." FORCE) -endif() +# if(NOT CMAKE_BUILD_TYPE) +# message(STATUS "Build type not set - using RelWithDebInfo") +# set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose build type: Debug Release RelWithDebInfo." FORCE) +#endif() +if (OCOS_ENABLE_STATIC_LIB) + add_compile_options(/MT$<$:d>) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +endif () function(read_version_file major_var minor_var patch_var) set(version_file ${PROJECT_SOURCE_DIR}/version.txt) From 6f2ef40ba7c613373b47f975702bcfd8f4595755 Mon Sep 17 00:00:00 2001 From: Eric Sommerlade Date: Sun, 11 Jun 2023 15:32:58 +0100 Subject: [PATCH 2/3] only set build type if on win32 --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0914af2b5..843c42765 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.25) project(onnxruntime_extensions LANGUAGES C CXX) # set(CMAKE_VERBOSE_MAKEFILE ON) -# if(NOT CMAKE_BUILD_TYPE) -# message(STATUS "Build type not set - using RelWithDebInfo") -# set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose build type: Debug Release RelWithDebInfo." FORCE) -#endif() +if(NOT WIN32 AND NOT CMAKE_BUILD_TYPE) + message(STATUS "Build type not set - using RelWithDebInfo") + set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose build type: Debug Release RelWithDebInfo." FORCE) +endif() if (OCOS_ENABLE_STATIC_LIB) add_compile_options(/MT$<$:d>) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") From d777b5bfd4acf7ea441248c9c445543f2b14400e Mon Sep 17 00:00:00 2001 From: Eric Sommerlade Date: Sun, 11 Jun 2023 20:28:23 +0100 Subject: [PATCH 3/3] added check for RelWithDebInfo and moved parameter check below option definition and into MSVC block --- CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 843c42765..52f51ba09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,10 +6,6 @@ if(NOT WIN32 AND NOT CMAKE_BUILD_TYPE) message(STATUS "Build type not set - using RelWithDebInfo") set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose build type: Debug Release RelWithDebInfo." FORCE) endif() -if (OCOS_ENABLE_STATIC_LIB) - add_compile_options(/MT$<$:d>) - set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") -endif () function(read_version_file major_var minor_var patch_var) set(version_file ${PROJECT_SOURCE_DIR}/version.txt) @@ -109,6 +105,11 @@ if(NOT CC_OPTIMIZE) endif() if (MSVC) + if (OCOS_ENABLE_STATIC_LIB) + add_compile_options(/MT$<$,$>:d>) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$,$>:Debug>") + endif () + check_cxx_compiler_flag(-sdl HAS_SDL) check_cxx_compiler_flag(-Qspectre HAS_QSPECTRE) if (HAS_QSPECTRE)