Skip to content

Commit e7f86fb

Browse files
committed
Add an option to force static VC runtime
1 parent d266203 commit e7f86fb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

source/compiler/CMakeLists.txt

+11
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)
@@ -163,6 +165,15 @@ if(MSVC)
163165
${PROJECT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/pawncc.pdb
164166
${PROJECT_BINARY_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/pawndisasm.pdb
165167
DESTINATION bin)
168+
# Force static runtime library
169+
if(FORCE_STATIC_VCRT)
170+
target_compile_options(pawnc PRIVATE
171+
$<$<OR:$<CONFIG:Release>,$<CONFIG:MinSizeRel>>:/MT>
172+
$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:/MTd>)
173+
target_compile_options(pawncc PRIVATE
174+
$<$<OR:$<CONFIG:Release>,$<CONFIG:MinSizeRel>>:/MT>
175+
$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:/MTd>)
176+
endif()
166177
endif()
167178

168179
# Generate targets for running compiler tests

0 commit comments

Comments
 (0)