Get error when generating dictionary

Dear experts

When I tried to generate the dictionary of std::vector<TVector2> I got the error while compiling, here is what I did:
vector_of_TVector2_LinkDef.h:

#ifdef __CLING__
#pragma link C++ class std::vector<TVector2>+;
#endif

in CMakeLists.txt, add this line:

ROOT_GENERATE_DICTIONARY(${CMAKE_CURRENT_SOURCE_DIR}/src/vector_of_TVector2 ${ROOT_ROOT}/include/TVector2.h LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/src/vector_of_TVector2_LinkDef.h)

add_library(Analyzer ${ROOT_DICTS}
                ${CMAKE_CURRENT_SOURCE_DIR}/src/dummy.cxx
                ${CMAKE_CURRENT_SOURCE_DIR}/src/dummy.hxx
                ${CMAKE_CURRENT_SOURCE_DIR}/src/vector_of_TVector2.cxx
)

When I compile I got this error:

make[2]: *** No rule to make target `../src/vector_of_TVector2.hxx', needed by `dict/vector_of_TVector2_Dict.cxx'.  Stop.
make[2]: *** Waiting for unfinished jobs....
[ 10%] Generating ../src/vector_of_TVector2.cxx, libvector_of_TVector2_rdict.pcm, libvector_of_TVector2.rootmap
make[1]: *** [CMakeFiles/Analyzer.dir/all] Error 2
make: *** [all] Error 2

What should I do?

Hello,

I am not sure what causes this error, but I would not use as target name in ROOT_GENERATE_DICTIONARY,

${CMAKE_CURRENT_SOURCE_DIR}/src/vector_of_TVector2

just follow examples used in root and call it something else , e.g. G__vector_of_TVector2

Lorenzo

Thank you for the answer! What do you mean “target”? there is no file named vector_of_TVector2 in my source dir though

The target is just what cmake will build and it does not need to reflect a file.
You can see the examples in the root, for example

And see what is used as first value passed in ROOT_GENERATE_DICTIONARY