duplicate LANGUAGES in project command cause subtle issues
I recently debugged an issue where some software I was working on essentially did this:
PROJECT(MYNAME LANGUAGES CXX CXX)
Listing CXX
twice caused a subtle issue where basically CMAKE_CXX_OUTPUT_EXTENSION
ended up being empty (at least as far as CMake was concerned internally) meaning that source file foo.cpp
would be compiled to object file foo.cpp
instead of foo.cpp.o
. Sometimes the project would actually fully compile, but in hard-to-predict situations the linker would interpret the object file foo.cpp
as a source file (reasonable given the missing extension).
This issue is basically to request that CMake either internally de-duplicate the LANGUAGES
list (i.e. guarantee that this works safely) or emit a CMake error (or at least even a warning) if there are duplicate entries.