Hi,
I am currently unable to add a static c library (among other c++ targets) with add_subdirectory as cmake seems to set /TP (c++ mode) causing the compile to fail, even when explicitly setting LANGUAGE and LINKER_LANGUAGE to c.
If i run cmake directly in the folder of the c project /TP is not set.
To fix this i have now manually added the compile flag /TC.
C Lib
file(GLOB fooSources CONFIGURE_DEPENDS src/**.c)
file(GLOB fooHeaders CONFIGURE_DEPENDS include/**.h)
add_library(foo STATIC ${fooSources} ${fooHeaders})
target_include_directories(foo PUBLIC include)
set_target_properties(foo PROPERTIES LANGUAGE C LINKER_LANGUAGE C)
target_compile_options(foo PRIVATE /TC)
C++ lib
file(GLOB barSources CONFIGURE_DEPENDS src/**.cpp)
file(GLOB barHeaders CONFIGURE_DEPENDS include/bar/**.hpp )
add_library(bar SHARED ${barSources} ${barHeaders})
target_include_directories(bar PUBLIC include/bar)
I am using cmake 3.16.4 with the Ninja Generator and Visual Studio 2010.