mirror of
https://github.com/luau-lang/luau.git
synced 2025-04-01 17:30:53 +01:00
Merge 9eb4ee69fe
into 6b33251b89
This commit is contained in:
commit
4dd83c9c27
1 changed files with 39 additions and 10 deletions
|
@ -12,6 +12,8 @@ option(LUAU_BUILD_WEB "Build Web module" OFF)
|
|||
option(LUAU_WERROR "Warnings as errors" OFF)
|
||||
option(LUAU_STATIC_CRT "Link with the static CRT (/MT)" OFF)
|
||||
option(LUAU_EXTERN_C "Use extern C for all APIs" OFF)
|
||||
option(LUAU_EXPORT_DLL "Exports to DLL" OFF)
|
||||
|
||||
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
|
@ -25,13 +27,24 @@ project(Luau LANGUAGES CXX C)
|
|||
add_library(Luau.Common INTERFACE)
|
||||
add_library(Luau.CLI.lib STATIC)
|
||||
add_library(Luau.Ast STATIC)
|
||||
add_library(Luau.Compiler STATIC)
|
||||
add_library(Luau.Config STATIC)
|
||||
add_library(Luau.Analysis STATIC)
|
||||
add_library(Luau.EqSat STATIC)
|
||||
add_library(Luau.CodeGen STATIC)
|
||||
add_library(Luau.VM STATIC)
|
||||
add_library(isocline STATIC)
|
||||
|
||||
if(LUAU_EXPORT_DLL)
|
||||
add_library(Luau.Compiler SHARED)
|
||||
add_library(Luau.Config SHARED)
|
||||
add_library(Luau.Analysis SHARED)
|
||||
add_library(Luau.EqSat SHARED)
|
||||
add_library(Luau.CodeGen SHARED)
|
||||
add_library(Luau.VM SHARED)
|
||||
add_library(isocline SHARED)
|
||||
else()
|
||||
add_library(Luau.Compiler STATIC)
|
||||
add_library(Luau.Config STATIC)
|
||||
add_library(Luau.Analysis STATIC)
|
||||
add_library(Luau.EqSat STATIC)
|
||||
add_library(Luau.CodeGen STATIC)
|
||||
add_library(Luau.VM STATIC)
|
||||
add_library(isocline STATIC)
|
||||
endif()
|
||||
|
||||
if(LUAU_BUILD_CLI)
|
||||
add_executable(Luau.Repl.CLI)
|
||||
|
@ -161,9 +174,25 @@ if(LUAU_EXTERN_C)
|
|||
# enable extern "C" for VM (lua.h, lualib.h) and Compiler (luacode.h) to make Luau friendlier to use from non-C++ languages
|
||||
# note that we enable LUA_USE_LONGJMP=1 as well; otherwise functions like luaL_error will throw C++ exceptions, which can't be done from extern "C" functions
|
||||
target_compile_definitions(Luau.VM PUBLIC LUA_USE_LONGJMP=1)
|
||||
target_compile_definitions(Luau.VM PUBLIC LUA_API=extern\"C\")
|
||||
target_compile_definitions(Luau.Compiler PUBLIC LUACODE_API=extern\"C\")
|
||||
target_compile_definitions(Luau.CodeGen PUBLIC LUACODEGEN_API=extern\"C\")
|
||||
|
||||
if(LUAU_EXPORT_DLL)
|
||||
if(MSVC)
|
||||
target_compile_definitions(Luau.VM PUBLIC "LUA_API=extern \"C\" __declspec(dllexport)")
|
||||
target_compile_definitions(Luau.Compiler PUBLIC "LUACODE_API=extern \"C\" __declspec(dllexport)")
|
||||
target_compile_definitions(Luau.CodeGen PUBLIC "LUACODEGEN_API=extern \"C\" __declspec(dllexport)")
|
||||
else()
|
||||
# GCC/Clang
|
||||
target_compile_definitions(Luau.VM PUBLIC "LUA_API=extern \"C\" __attribute__((visibility(\"default\")))")
|
||||
target_compile_definitions(Luau.Compiler PUBLIC "LUACODE_API=extern \"C\" __attribute__((visibility(\"default\")))")
|
||||
target_compile_definitions(Luau.CodeGen PUBLIC "LUACODEGEN_API=extern \"C\" __attribute__((visibility(\"default\")))")
|
||||
endif()
|
||||
else()
|
||||
# For static builds (or if not exporting) just use extern "C"
|
||||
target_compile_definitions(Luau.VM PUBLIC "LUA_API=extern \"C\"")
|
||||
target_compile_definitions(Luau.Compiler PUBLIC "LUACODE_API=extern \"C\"")
|
||||
target_compile_definitions(Luau.CodeGen PUBLIC "LUACODEGEN_API=extern \"C\"")
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1924)
|
||||
|
|
Loading…
Add table
Reference in a new issue