Files
cmake/Tests/RunCMake/CheckSourceCompiles/MultipleLanguages.cmake
T
Joseph Snyder 243462fafe try_compile: Tolerate compile features from non-enabled languages
Do not copy the list of enabled languages from the outer generator.
It is populated as languages are enabled inside the test project.

Fixes: #27684
2026-05-26 20:17:27 -04:00

12 lines
339 B
CMake

enable_language (C CXX)
include(CheckSourceCompiles)
add_library(cxx_iface INTERFACE IMPORTED)
target_compile_features(cxx_iface INTERFACE cxx_std_11)
set(CMAKE_REQUIRED_LIBRARIES cxx_iface)
check_source_compiles(C "int main() {return 0;}" SHOULD_BUILD)
if(NOT SHOULD_BUILD)
message(SEND_ERROR "Test fail for valid C source.")
endif()