Files
BlockLua/CMakeLists.txt
2025-10-06 11:47:11 -04:00

57 lines
1.4 KiB
CMake

cmake_minimum_required(VERSION 3.10)
project(BlockLua CXX)
# Export compile_commands.json for VSCode IntelliSense
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Output directories to mirror compile.bat's build folder
set(OUTPUT_DIR ${CMAKE_SOURCE_DIR}/build)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_DIR})
# Global compile options to mirror compile.bat
add_compile_options(
-Wall
-Werror
-m32
-static-libgcc
-static-libstdc++
)
# Include paths
include_directories(
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/inc/tsfuncs
${CMAKE_SOURCE_DIR}/inc/lua
)
# Link directories (for -L.) and libraries from compile.bat
link_directories(
${CMAKE_SOURCE_DIR}
)
# Safe DLL
add_library(BlockLua SHARED src/bllua4.cpp)
# Ensure output name matches compile.bat
set_target_properties(BlockLua PROPERTIES OUTPUT_NAME "BlockLua")
# Linker flags and libraries
if(MSVC)
# Not expected with mingw, but keep placeholder
else()
target_link_libraries(BlockLua PRIVATE psapi lua5.1)
endif()
# Unsafe DLL (with BLLUA_UNSAFE definition)
add_library(BlockLuaUnsafe SHARED src/bllua4.cpp)
set_target_properties(BlockLuaUnsafe PROPERTIES OUTPUT_NAME "BlockLua-Unsafe")
target_compile_definitions(BlockLuaUnsafe PRIVATE BLLUA_UNSAFE)
if(MSVC)
# Not expected with mingw, but keep placeholder
else()
target_link_libraries(BlockLuaUnsafe PRIVATE psapi lua5.1)
endif()