From be9aad4a56a0f4cf15a3a39da384d0639ffb1fb8 Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Sun, 25 Apr 2021 20:39:29 +0200 Subject: [PATCH 1/3] Added ability to compile lua as C++ --- CMakeLists.txt | 1 + lua-5.4.2/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5032f51..71c5739 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.1) project(lua LANGUAGES C VERSION 5.4.2) option(LUA_SUPPORT_DL "Support dynamic loading of compiled modules" OFF) +option(LUA_BUILD_AS_CXX "Build lua as C++" OFF) if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME}) set(TOP_LEVEL TRUE) diff --git a/lua-5.4.2/CMakeLists.txt b/lua-5.4.2/CMakeLists.txt index f155311..9b4cc76 100644 --- a/lua-5.4.2/CMakeLists.txt +++ b/lua-5.4.2/CMakeLists.txt @@ -33,6 +33,10 @@ set(LUA_LIB_SRCS "src/linit.c" ) +if(LUA_BUILD_AS_CXX) + SET_SOURCE_FILES_PROPERTIES(${LUA_LIB_SRCS} PROPERTIES LANGUAGE CXX ) +endif() + add_library(lua_static STATIC ${LUA_LIB_SRCS}) set_target_properties(lua_static PROPERTIES OUTPUT_NAME "lua") target_include_directories(lua_static PUBLIC "include") From 045961e7a08b5d579b34b766da914c4964e67aaa Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Mon, 26 Apr 2021 17:02:07 +0200 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Walter Schell <3580170+walterschell@users.noreply.github.com> --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 71c5739..db75d71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ project(lua LANGUAGES C VERSION 5.4.2) option(LUA_SUPPORT_DL "Support dynamic loading of compiled modules" OFF) option(LUA_BUILD_AS_CXX "Build lua as C++" OFF) +enable_language(CXX) if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME}) set(TOP_LEVEL TRUE) From dac88f52b8e492f3d6b09cff4d328ba35b5ec8fd Mon Sep 17 00:00:00 2001 From: Dedmen Miller Date: Mon, 26 Apr 2021 17:37:51 +0200 Subject: [PATCH 3/3] try to fix build --- lua-5.4.2/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua-5.4.2/CMakeLists.txt b/lua-5.4.2/CMakeLists.txt index 9b4cc76..c9a2477 100644 --- a/lua-5.4.2/CMakeLists.txt +++ b/lua-5.4.2/CMakeLists.txt @@ -34,7 +34,7 @@ set(LUA_LIB_SRCS ) if(LUA_BUILD_AS_CXX) - SET_SOURCE_FILES_PROPERTIES(${LUA_LIB_SRCS} PROPERTIES LANGUAGE CXX ) + set_source_files_properties(${LUA_LIB_SRCS} "src/lua.c" "src/luac.c" PROPERTIES LANGUAGE CXX ) endif() add_library(lua_static STATIC ${LUA_LIB_SRCS})