saebyn / munkres-cpp

Kuhn-Munkres (Hungarian) Algorithm in C++
http://saebyn.info/2007/05/22/munkres-code-v2/
GNU General Public License v2.0
205 stars 79 forks source link

Tests are broken #31

Open yurivict opened 3 years ago

yurivict commented 3 years ago

First there's this error:

===>  Testing for munkres-cpp-1.0.0.6
CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- Configuring done
-- Generating done
-- Build files have been written to: /disk-samsung/freebsd-ports/math/munkres-cpp/work/.build
ninja: no work to do.
ninja: error: 'googletest/googletest/libgtest.a', needed by 'tests/munkrestest', missing and no known rule to make it

Then I applied this patch to use pre-installed googletest:

--- tests/CMakeLists.txt.orig   2021-09-09 05:45:47 UTC
+++ tests/CMakeLists.txt
@@ -3,6 +3,7 @@ find_package (Boost     COMPONENTS      system      RE
 enable_testing ()

 # Framework for writing tests. 
+if (FALSE)
 ExternalProject_Add (
     googletest
     GIT_REPOSITORY "https://github.com/google/googletest.git"
@@ -23,6 +24,11 @@ set (GTEST_BOTH_LIBRARIES ${GTEST_LIBRARIES} ${GTEST_M

 include_directories (${GTEST_INCLUDE_DIRS})

+endif()
+
+find_package(GTest REQUIRED)
+
+
 # Special flags fo generating code coverage.
 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
 set (CMAKE_SHARED_LINKER_FLAGS "-fprofile-arcs -ftest-coverage")
@@ -52,7 +58,7 @@ set (
     ${PROJECT_SOURCE_DIR}/tests/adapters/boost_matrixtest.cpp
 )
 add_executable (munkrestest EXCLUDE_FROM_ALL ${MunkresCppLib_SOURCES} ${MunkresCppTest_SOURCES})
-target_link_libraries (munkrestest ${GTEST_BOTH_LIBRARIES} gcov pthread)
+target_link_libraries (munkrestest ${GTest} gcov pthread)
 add_custom_target (tests)
 add_dependencies  (tests munkrestest)
 add_dependencies  (munkrestest googletest)

After this it failed:

/disk-samsung/freebsd-ports/math/munkres-cpp/work/munkres-cpp-1.0.0-6-g61086fc/tests/adapters/std_2d_arraytest.cpp:142:58: error: implicit instantiation of undefined template 'std::__1::array<std::__1::array<double, 3>, 3>'
  std::array <std::array <double, dimension>, dimension> test_array{{
                                                         ^
/usr/include/c++/v1/__tuple:219:64: note: template is declared here
template <class _Tp, size_t _Size> struct _LIBCPP_TEMPLATE_VIS array;
                                                               ^

After adding the missing header it broke again:

/disk-samsung/freebsd-ports/math/munkres-cpp/work/munkres-cpp-1.0.0-6-g61086fc/tests/adapters/std_2d_arraytest.cpp:56:46: error: non-type template argument is not a constant expression
  Std2dArrayAdapter<double,test_array.size(),test_array[0].size()> adapter;
                                             ^~~~~~~~~~~~~~~~~~~~