in 3.18.0rc4 set_source_files_properties and TARGET_DIRECTORY does not achieve different properties (Visual Studio generator)
Hello Kitware,
I am trying to compile the same file (main.c) in C and in C++. Sounds like the perfect candidate for 3.18's new TARGET_DIRECTORY feature! I am building 2 executables here (main_from_c and main_from_cpp) from the same main.c file.
Here's the CMakeLists.txt:
add_executable(main_from_c main.c)
set_source_files_properties(main.c TARGET_DIRECTORY main_from_c PROPERTIES LANGUAGE C)
add_executable(main_from_cpp main.c)
set_source_files_properties(main.c TARGET_DIRECTORY main_from_cpp PROPERTIES LANGUAGE CXX)
Here's main.c (just in case):
#ifdef __cplusplus
#include <cstdio>
#else
#include <stdio.h>
#endif
int main(void)
{
#ifdef __cplusplus
(void)printf("hello from C++\n");
#else
(void)printf("hello from C\n");
#endif
}
This is what I would have hoped to see generated in Visual Studio (using 16.6.3): in the 2 projects generated, each of them containing main.c, main.c is compiled as C in main_from_c and main.c is compiled as C++ in main_from_cpp.
What I actually see is main.c compiles as C++ in both of them. It looks like "the last set_source_file_properties wins" to me.
Best Regards, Andrei Porumb