Let say I have a library ProjectA where I defined a custom target build-tests in my CMakefile to build my tests such that I can do make test afterwards. (see CMake & CTest : make test doesn't build tests).
Then, I have a second library ProjectB that depends on ProjectA. I use git submodule such that I can do add_subdirectory(ProjectA) in ProjectB's CMakefile. The problem is that, I would like to do same thing: define a custom target build-tests to build the tests of ProjectB but I cannot because it has already been defined in ProjectA...
My problem is similar to How to handle a transitive dependency conflict using Git submodules and CMake? and CMake and using git-submodule for dependence projects but they can define one target to avoid this while I would like to be able to do make build-tests in ProjectA AND in ProjectB.
So, is there a way to define a custom target locally to a cmake project for example ? or is there a clever way to do what I would like to do ? (which seems quite natural)