File: catch2-fix.patch

package info (click to toggle)
highs 1.12.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,592 kB
  • sloc: cpp: 133,006; ansic: 12,649; python: 4,167; f90: 1,113; cs: 974; lisp: 151; makefile: 60; perl: 46; sh: 38
file content (156 lines) | stat: -rw-r--r-- 5,328 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
Description: Fix build issues due to removal of vendored catch2.hpp
Author: Shengqi Chen <harry@debian.org>
Forwarded: not-needed
Last-Update: 2025-03-16
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- /dev/null
+++ b/check/catch.hpp
@@ -0,0 +1,6 @@
+// debian fix for this project using obsolete "catch2.hpp"
+
+#ifndef _DEBIAN_CATCH2_HPP
+#define _DEBIAN_CATCH2_HPP
+#include <catch2/catch_test_macros.hpp>
+#endif
--- a/check/CMakeLists.txt
+++ b/check/CMakeLists.txt
@@ -16,9 +16,8 @@
 
 if ((NOT FAST_BUILD OR ALL_TESTS) AND NOT (BUILD_EXTRA_UNIT_ONLY))
   # prepare Catch library
-  set(CATCH_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/extern)
-  add_library(Catch INTERFACE)
-  target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
+  find_package(Catch2 3 REQUIRED)
+  include(Catch)
 
   configure_file(${PROJECT_SOURCE_DIR}/check/HCheckConfig.h.in ${HIGHS_BINARY_DIR}/HCheckConfig.h)
 
@@ -106,6 +105,7 @@
   endif()
 
   add_executable(unit_tests ${TEST_SOURCES})
+  target_include_directories(unit_tests PRIVATE ${HIGHS_SOURCE_DIR}/extern)
 
   set_target_properties(unit_tests PROPERTIES UNITY_BUILD OFF)
 
@@ -115,7 +115,7 @@
   endif()
 
   if (FAST_BUILD)
-    target_link_libraries(unit_tests highs Catch)
+    target_link_libraries(unit_tests highs Catch2::Catch2WithMain)
 
     if (CUPDLP_GPU)
         if (WIN32)
@@ -127,7 +127,7 @@
         set_target_properties(unit_tests PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
     endif()
   else()
-    target_link_libraries(unit_tests libhighs Catch)
+    target_link_libraries(unit_tests libhighs Catch2::Catch2WithMain)
   endif()
 
   include(GNUInstallDirs)
@@ -156,24 +156,7 @@
 
   # Check whether test executable builds OK.
   if (NOT HIGHS_COVERAGE)
-    add_test(NAME unit-test-build
-            COMMAND ${CMAKE_COMMAND}
-                    --build ${HIGHS_BINARY_DIR}
-                    --target unit_tests
-                    #  --config ${CMAKE_BUILD_TYPE}
-            )
-
-    # Avoid that several build jobs try to concurretly build.
-    set_tests_properties(unit-test-build
-                        PROPERTIES
-                        RESOURCE_LOCK unittestbin)
-
-    # create a binary running all the tests in the executable
-    add_test(NAME unit_tests_all COMMAND unit_tests --success)
-    set_tests_properties(unit_tests_all
-                        PROPERTIES
-                        DEPENDS unit-test-build)
-    set_tests_properties(unit_tests_all PROPERTIES TIMEOUT 10000) 
+    catch_discover_tests(unit_tests)
   else()
     add_test(NAME unit_tests_all COMMAND unit_tests --success)
     set_tests_properties(unit_tests_all PROPERTIES TIMEOUT 10000) 
@@ -499,10 +482,8 @@
 
 if (BUILD_EXTRA_UNIT_TESTS AND BUILD_EXTRA_UNIT_ONLY)
     # prepare Catch library
-    set(CATCH_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/extern)
-    add_library(Catch INTERFACE)
-    target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
-
+    find_package(Catch2 3 REQUIRED)
+    include(Catch)
 
     list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/check/highs-unit-tests")
     message(STATUS "${PROJECT_SOURCE_DIR}/check/highs-unit-tests")
@@ -512,31 +493,15 @@
     message(STATUS ${TEST_SOURCES})
 
     add_executable(unit_tests_extra ${TEST_SOURCES})
-    target_link_libraries(unit_tests_extra Catch)
+    target_link_libraries(unit_tests_extra Catch2::Catch2WithMain)
+    target_include_directories(unit_tests_extra PRIVATE ${HIGHS_SOURCE_DIR}/extern)
 
     if (BUILD_CXX)
         configure_file(${PROJECT_SOURCE_DIR}/check/HCheckConfig.h.in ${HIGHS_BINARY_DIR}/HCheckConfig.h)
         target_link_libraries(unit_tests_extra highs)
     endif()
 
-    add_test(NAME unit-test-extra-build
-          COMMAND ${CMAKE_COMMAND}
-                  --build ${HIGHS_BINARY_DIR}
-                  --target unit_tests_extra
-                  #  --config ${CMAKE_BUILD_TYPE}
-          )
-
-    # Avoid that several build jobs try to concurretly build.
-    set_tests_properties(unit-test-extra-build
-                        PROPERTIES
-                        RESOURCE_LOCK unittestbin)
-
-    # create a binary running all the tests in the executable
-    add_test(NAME unit_tests_extra COMMAND unit_tests_extra --success)
-    set_tests_properties(unit_tests_extra
-                        PROPERTIES
-                        DEPENDS unit-test-extra-build)
-    set_tests_properties(unit_tests_extra PROPERTIES TIMEOUT 10000) 
+    catch_discover_tests(unit_tests_extra)
 
     if (CUPDLP_GPU)
         set_target_properties(unit_tests_extra PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
--- a/check/TestMain.cpp
+++ b/check/TestMain.cpp
@@ -2,5 +2,3 @@
 // generate a main method for the tests. Define tests in a separate cpp file
 // with only the include below. Do not define CATCH_CONFIG_MAIN anywhere else.
 // See correct-print-options in TestSetup.cpp.
-#define CATCH_CONFIG_MAIN
-#include "catch.hpp"
--- a/check/TestHighsHash.cpp
+++ b/check/TestHighsHash.cpp
@@ -1,4 +1,5 @@
 #include <numeric>
+#include <algorithm>
 
 #include "HCheckConfig.h"
 #include "catch.hpp"
--- a/app/HighsRuntimeOptions.h
+++ b/app/HighsRuntimeOptions.h
@@ -14,7 +14,7 @@
 
 #include <cassert>
 
-#include "CLI11.hpp"
+#include <CLI/CLI.hpp>
 #include "HConfig.h"
 #include "io/HighsIO.h"
 #include "io/LoadOptions.h"