Skip to content

Commit bff2860

Browse files
committed
Add an option to force static VC runtime
1 parent f5b189f commit bff2860

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

source/compiler/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUILD})
1212
set(VERSION_STR ${VERSION})
1313
math(EXPR VERSION_INT "${VERSION_MAJOR} << 8 | ${VERSION_MINOR}")
1414

15+
option(FORCE_STATIC_VCRT "Force static VC runtime" ON)
16+
1517
# check for optional include files
1618
include(CheckIncludeFile)
1719
check_include_file("unistd.h" HAVE_UNISTD_H)
@@ -162,6 +164,15 @@ if(MSVC)
162164
${PROJECT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/pawncc.pdb
163165
${PROJECT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/pawndisasm.pdb
164166
DESTINATION bin)
167+
# Force static runtime library
168+
if(FORCE_STATIC_VCRT)
169+
target_compile_options(pawnc PRIVATE
170+
$<$<OR:$<CONFIG:Release>,$<CONFIG:MinSizeRel>>:/MT>
171+
$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:/MTd>)
172+
target_compile_options(pawncc PRIVATE
173+
$<$<OR:$<CONFIG:Release>,$<CONFIG:MinSizeRel>>:/MT>
174+
$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:/MTd>)
175+
endif()
165176
endif()
166177

167178
# Generate targets for running compiler tests

0 commit comments

Comments
 (0)