cmake target_link_libraries causes compiler error in target

256 Views Asked by At

I would like to use Open3d in LAMMPS. Open3D details how to find the pre-installed Open3D package using cmake.

Using the above, I have written a cmake file that I believe LAMMPS uses during its build stage to find packages and link them. Curiously, the line

target_link_libraries(lammps PRIVATE Open3D::Open3D)

appears to cause the compiler to find errors in the LAMMPS src code, i.e.,

/home/USER/lammps/src/fmtlib_format.cpp:58:51: error: duplicate explicit instantiation of ‘struct fmt::v7_lmp::detail::basic_data<void>’ [-fpermissive]
   58 | template struct FMT_INSTANTIATION_DEF_API detail::basic_data<void>;

If I comment the target_link_libraries statement, the code compiles just fine (but doesn't link to Open3D). Apologies for being unable to provide a MWE as I do not know how to replicate this behaviour in a simple manner. Could you please explain to me why the target_link_libraries command causes the compiler to find errors in the LAMMPS src code and provide a solution to prevent this from occuring? If relevant I am using Clion 2021.1.2 and

CMAKE_CXX_COMPILER_VERSION = 9.3.0
CMAKE_CXX_STANDARD = 11
CMAKE_VERSION = 3.19.2
0

There are 0 best solutions below