set(CMAKE_ENABLE_EXPORTS 1) set(FOO 2) set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES FOO) try_compile(RESULT_VAR ${CMAKE_CURRENT_BINARY_DIR}/CMP0137-build ${CMAKE_CURRENT_SOURCE_DIR}/CMP0137 TestCMP0137) include(${CMAKE_CURRENT_BINARY_DIR}/CMP0137-build/info.cmake OPTIONAL) message(STATUS "Enabling CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES") set(CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES 1) try_compile(RESULT_VAR ${CMAKE_CURRENT_BINARY_DIR}/CMP0137-build2 ${CMAKE_CURRENT_SOURCE_DIR}/CMP0137 TestCMP0137) include(${CMAKE_CURRENT_BINARY_DIR}/CMP0137-build2/info.cmake OPTIONAL)