From 9fefb978342f70b3e5f8c8cbbbc92b00baac28f9 Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 16 Aug 2024 09:53:15 +0800 Subject: [PATCH] fix catch2 (#4944) --- packages/c/catch2/xmake.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/c/catch2/xmake.lua b/packages/c/catch2/xmake.lua index a843b9756..1ab9f691a 100644 --- a/packages/c/catch2/xmake.lua +++ b/packages/c/catch2/xmake.lua @@ -58,13 +58,6 @@ package("catch2") link = link.."d" end component:add("links", link) - if package:is_plat("windows") then - if package:has_tool("cxx", "cl") then - component:add("ldflags", "-subsystem:console") - elseif package:has_tool("cxx", "clang", "clangxx") then - component:add("ldflags", "-Wl,/subsystem:console") - end - end end) on_component("lib", function (package, component) @@ -76,6 +69,15 @@ package("catch2") end) on_install(function (package) + if package:is_plat("windows") then + local main_component = package:component("main") + if package:has_tool("cxx", "cl") then + main_component:add("ldflags", "-subsystem:console") + elseif package:has_tool("cxx", "clang", "clangxx") then + main_component:add("ldflags", "-Wl,/subsystem:console") + end + end + if package:version():ge("3.0") then local configs = {"-DCATCH_INSTALL_DOCS=OFF", "-DCATCH_BUILD_TESTING=OFF", "-DCATCH_BUILD_EXAMPLES=OFF"} table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))