MSVC Flag /TP is set on a C target when added as a subdirectory

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.

Is there a call to the project command in the top-level CMakeLists.txt fold or one of the parent CMakeLists.txt files?

Maybe project is called in a way that enables only the CXX language.

Thankyou for your quick response. Making sure all files had a lowercase file ending (.c instead of .C) etc. seems to have fixed the problem.