Imported Upstream version 3.25.0
[platform/upstream/cmake.git] / Tests / RunCMake / try_compile / EnvConfig.cmake
1 include(${CMAKE_CURRENT_SOURCE_DIR}/${try_compile_DEFS})
2
3 enable_language(C)
4
5 set(ENV{CMAKE_BUILD_TYPE} "Bad")
6 set(ENV{CMAKE_CONFIGURATION_TYPES} "Bad;Debug")
7
8 add_library(tc_defs INTERFACE IMPORTED)
9 target_compile_definitions(tc_defs INTERFACE "TC_CONFIG_$<UPPER_CASE:$<CONFIG>>")
10
11 try_compile(ENV_CONFIG_RESULT "${try_compile_bindir_or_SOURCES}"
12   ${try_compile_redundant_SOURCES} "${CMAKE_CURRENT_SOURCE_DIR}/EnvConfig.c"
13   COPY_FILE "${CMAKE_CURRENT_BINARY_DIR}/EnvConfig.bin"
14   OUTPUT_VARIABLE tc_output
15   LINK_LIBRARIES tc_defs
16   )
17 if(NOT ENV_CONFIG_RESULT)
18   string(REPLACE "\n" "\n  " tc_output "  ${tc_output}")
19   message(FATAL_ERROR "try_compile failed:\n${tc_output}")
20 endif()