From e7f86fb06a8ed850141d91b388983e9dd50a2efb Mon Sep 17 00:00:00 2001 From: Stanislav Gromov Date: Sat, 8 May 2021 21:49:35 +0700 Subject: [PATCH] Add an option to force static VC runtime --- source/compiler/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/source/compiler/CMakeLists.txt b/source/compiler/CMakeLists.txt index 5bf31730..d3fc0a62 100644 --- a/source/compiler/CMakeLists.txt +++ b/source/compiler/CMakeLists.txt @@ -12,6 +12,8 @@ set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD}) set(VERSION_STR ${VERSION}) math(EXPR VERSION_INT "${VERSION_MAJOR} << 8 | ${VERSION_MINOR}") +option(FORCE_STATIC_VCRT "Force static VC runtime" ON) + # check for optional include files include(CheckIncludeFile) check_include_file("unistd.h" HAVE_UNISTD_H) @@ -163,6 +165,15 @@ if(MSVC) ${PROJECT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/pawncc.pdb ${PROJECT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/pawndisasm.pdb DESTINATION bin) + # Force static runtime library + if(FORCE_STATIC_VCRT) + target_compile_options(pawnc PRIVATE + $<$,$>:/MT> + $<$,$>:/MTd>) + target_compile_options(pawncc PRIVATE + $<$,$>:/MT> + $<$,$>:/MTd>) + endif() endif() # Generate targets for running compiler tests