Add a build option to link with the static CRT

This commit is contained in:
Michael Savage 2022-02-06 00:36:14 +02:00
parent e51ff38d19
commit 1ae3f90ad0

View file

@ -12,6 +12,10 @@ option(LUAU_BUILD_TESTS "Build tests" ON)
option(LUAU_BUILD_WEB "Build Web module" OFF)
option(LUAU_WERROR "Warnings as errors" OFF)
if(MSVC)
option(LUAU_STATIC_CRT "Link with the static CRT (/MT)" OFF)
endif()
add_library(Luau.Ast STATIC)
add_library(Luau.Compiler STATIC)
add_library(Luau.Analysis STATIC)
@ -60,6 +64,12 @@ set(LUAU_OPTIONS)
if(MSVC)
list(APPEND LUAU_OPTIONS /D_CRT_SECURE_NO_WARNINGS) # We need to use the portable CRT functions.
list(APPEND LUAU_OPTIONS /MP) # Distribute single project compilation across multiple cores
if(LUAU_STATIC_CRT)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif()
else()
list(APPEND LUAU_OPTIONS -Wall) # All warnings
endif()