In my CMakeLists.txt I want to create a binary named foo and a library named libfoo(.a|.so).
So I have tried using the following code:
add_executable(foo ${BIN_SRC})
add_library(foo ${LIB_SRC})
But unfortunately the code above fails with the error message:
Make Error at CMakeLists.txt:156 (add_library):
add_library cannot create target "foo" because another target with
the same name already exists. The existing target is an executable created
It is abovious that I have 2 targets named foo in my CMakeLists.txt which is causing the error. I could e.g. fix the bug using:
add_library(libfoo ${LIB_SRC})
But then my library gets named liblibfoo(.a|.so) which is not what I want!?