Skip to content

Commit

Permalink
antlr4-runtime: fix dll install (#5759)
Browse files Browse the repository at this point in the history
  • Loading branch information
star-hengxing authored Nov 14, 2024
1 parent 5abec9c commit 64f38c1
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions packages/a/antlr4-runtime/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,28 @@ package("antlr4-runtime")
add_deps("cmake")

on_install(function (package)
local configs = {"-DANTLR_BUILD_CPP_TESTS=OFF", "-DANTLR4_INSTALL=ON"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DANTLR_BUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DANTLR_BUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
if not package:config("shared") then
package:add("defines", "ANTLR4CPP_STATIC")
end

os.cd("runtime/Cpp")
io.replace("CMakeLists.txt", [[set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")]], "", {plain = true})
io.replace("CMakeLists.txt", [[set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")]], "", {plain = true})
io.replace("CMakeLists.txt", "add_subdirectory(runtime)",
"include(GNUInstallDirs)\nadd_subdirectory(runtime)", {plain = true})

local configs = {"-DANTLR_BUILD_CPP_TESTS=OFF", "-DANTLR4_INSTALL=ON"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DANTLR_BUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DANTLR_BUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
if package:is_plat("windows") then
table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
end
import("package.tools.cmake").install(package, configs)
if not package:config("shared") then
package:add("defines", "ANTLR4CPP_STATIC")

if package:is_plat("windows") and package:is_debug() then
local dir = package:installdir(package:config("shared") and "bin" or "lib")
os.vcp(path.join(package:buildir(), "runtime/*.pdb"), dir)
end
end)

Expand Down

0 comments on commit 64f38c1

Please sign in to comment.