瀏覽代碼

Fix catch2 v2.x install failures (#5145)

Anthony 1 年之前
父節點
當前提交
9691d528c9
共有 1 個文件被更改,包括 14 次插入7 次删除
  1. 14 7
      packages/c/catch2/xmake.lua

+ 14 - 7
packages/c/catch2/xmake.lua

@@ -67,19 +67,26 @@ package("catch2")
             link = link.."d"
             link = link.."d"
         end
         end
         component:add("links", link)
         component:add("links", link)
-    end)
-
-    on_install(function (package)
-        if package:is_plat("windows") then
-            local main_component = package:component("main")
+        if package:is_plat("windows") and package:version():le("3.0") then
             if package:has_tool("cxx", "cl") then
             if package:has_tool("cxx", "cl") then
-                main_component:add("ldflags", "-subsystem:console")
+                component:add("ldflags", "-subsystem:console")
             elseif package:has_tool("cxx", "clang", "clangxx") then
             elseif package:has_tool("cxx", "clang", "clangxx") then
-                main_component:add("ldflags", "-Wl,/subsystem:console")
+                component:add("ldflags", "-Wl,/subsystem:console")
             end
             end
         end
         end
+    end)
 
 
+    on_install(function (package)
         if package:version():ge("3.0") then
         if package:version():ge("3.0") then
+            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
+
             local configs = {"-DCATCH_INSTALL_DOCS=OFF", "-DCATCH_BUILD_TESTING=OFF", "-DCATCH_BUILD_EXAMPLES=OFF"}
             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"))
             table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
             table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
             table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))