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