2

I'm currently developing a fairly large library dependent on other libraries (Eigen, Catch2, and Kokkos), and use CMake for building and linking everything. Because so much is going on, it's difficult to use a MWE here or give a lot of detail, but there's currently an error in compilation within a precompiled version of Catch2 and CMake won't show me where it's coming from in my library. Once CMake starts compiling my code, I eventually end up with

[ 59%] Building CXX object CMakeFiles/RunTests.dir/tests/Test_File.cpp.o
/home/jovyan/installs/CATCH2/include/catch2/benchmark/catch_constructor.hpp(62): error: invalid type conversion

1 error detected in the compilation of "/home/jovyan/.../tests/Test_File.cpp".
make[2]: *** [CMakeFiles/RunTests.dir/build.make:121: CMakeFiles/RunTests.dir/tests/Test_File.cpp.o] Error 2
make[1]: *** [CMakeFiles/Makefile2:140: CMakeFiles/RunTests.dir/all] Error 2
make: *** [Makefile:149: all] Error 2

The file in question being compiled (here called Test_File.cpp) is not unique-- if I remove this test, any other file that includes Catch2/catch_all.hpp will fail compilation as well with this same problem, or at least the other few files that I've tried have done so.

How do I get CMake to tell me what file this is coming from on my side?

EDIT: For reference, this code compiles when I use g++. Right now, I'm trying to ensure that the code also works on the GPU, so I'm compiling it with the nvcc wrapper provided in Kokkos. As such, I can't really figure out how to make this independent of the external libraries. I'll keep trying to make an MRE, but obviously the problem is some interplay between my library and Kokkos/Catch2.

Danny
  • 31
  • 2
  • 1
    "How do I get CMake to tell me what file this is coming from on my side?" - CMake already tells you that the error is triggered when your file `Test_File.cpp` is compiled. Neither CMake nor compiler knows about the **primary reason** of the error: is it the header `catch_constructor.hpp` which is wrong by itself, or is it some of your libraries defines a macro or a type which confuses Catch2. This part is expected to be performed by you. As for [mre], steps for its creation are applicable for your case too: Try to eliminate unrelated libraries from your project and check whether error remains. – Tsyvarev Jun 01 '22 at 21:07
  • Thanks for the quick reply. I added some context in the post why I don't think I'll be able to make a MRE, but I know that it's not because `catch_constructor.hpp` is wrong. Something that *calls* the function in `catch_constructor.hpp` is wrong, but I'm trying to find out which one. Just that one line makes it impossible to find which one is throwing that error-- I don't understand why CMake isn't displaying what lines of code *call* the functions in `catch_constructor.hpp`. I'm certain that I'm defining something that confuses Catch2, but I can't find what. – Danny Jun 01 '22 at 21:48
  • 1
    "I don't understand why CMake isn't displaying what lines of code ..." - Why do you blame CMake in that? CMake isn't a built tool, it just calls a compiler for compile you source file. It is compiler who could show a line or not. If you run `make V=1` then it shows you exact command line which is executed. You could run that command line alone for trigger the very same error without any CMake intervention. – Tsyvarev Jun 01 '22 at 22:04
  • I suppose you're correct-- I don't really mean to "blame" cmake. However, `make V=1` doesn't solve the problem, only tells me what command it invoked to compile. I'm looking for any plausible ideas as to why the compiler isn't displaying how it gets to this error, or how to display what particular line in my library is triggering it. – Danny Jun 01 '22 at 22:29

0 Answers0