mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-04 13:19:51 -05:00
506fda1cf0
The set of compile flags used for a target's C and C++ sources is based on the linker language. By default this is always the C++ flags if any C++ sources appear in the target, and otherwise the C flags. Therefore we can define the `COMPILE_LANGUAGE` generator expression in `INCLUDE_DIRECTORIES` to match the selected language. This is not exactly the same as for other generators, but is the best VS and Xcode can do. It is also sufficient for many use cases since the set of include directories for C and C++ is frequently similar but may be distinct from those for other languages like CUDA. Fixes: #17435
22 lines
394 B
C
22 lines
394 B
C
|
|
// Visual Studio allows only one set of flags for C and C++.
|
|
// In a target using C++ we pick the C++ flags even for C sources.
|
|
#ifdef TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE
|
|
#include "cxx_only.h"
|
|
|
|
#ifndef CXX_ONLY_DEFINE
|
|
#error Expected CXX_ONLY_DEFINE
|
|
#endif
|
|
#else
|
|
#include "c_only.h"
|
|
|
|
#ifndef C_ONLY_DEFINE
|
|
#error Expected C_ONLY_DEFINE
|
|
#endif
|
|
#endif
|
|
|
|
int consumer_c()
|
|
{
|
|
return 0;
|
|
}
|