Add a RunCMake.try_compile test to cover cases of bad invocation of the try_compile command.
@@ -76,6 +76,7 @@ add_RunCMake_test(if)
add_RunCMake_test(include)
add_RunCMake_test(include_directories)
add_RunCMake_test(list)
+add_RunCMake_test(try_compile)
add_RunCMake_test(CMP0004)
find_package(Qt4 QUIET)
@@ -0,0 +1 @@
+1
@@ -0,0 +1,5 @@
+CMake Error at BadLinkLibraries.cmake:2 \(try_compile\):
+ Only libraries may be used as try_compile IMPORTED LINK_LIBRARIES. Got
+ not_a_library of type UTILITY.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
@@ -0,0 +1,3 @@
+add_custom_target(not_a_library)
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c
+ LINK_LIBRARIES not_a_library)
+cmake_minimum_required(VERSION 2.8)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
@@ -0,0 +1,4 @@
+CMake Error at NoArgs.cmake:1 \(try_compile\):
+ try_compile unknown error.
+try_compile()
+CMake Error at NoCopyFile.cmake:1 \(try_compile\):
+ COPY_FILE specified but there is no variable
@@ -0,0 +1,2 @@
+ COPY_FILE)
+CMake Error at NoLinkLibraries.cmake:1 \(try_compile\):
+ LINK_LIBRARIES specified but there is no content
+ LINK_LIBRARIES)
+CMake Error at NoOutputVariable.cmake:1 \(try_compile\):
+ OUTPUT_VARIABLE specified but there is no variable
+ OUTPUT_VARIABLE)
+CMake Error at NonSourceCompileDefinitions.cmake:1 \(try_compile\):
+ COMPILE_FLAGS specified on a srcdir type TRY_COMPILE
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/proj
+ TestProject COMPILE_DEFINITIONS DEF)
+CMake Error at NonSourceCopyFile.cmake:1 \(try_compile\):
+ COPY_FILE specified on a srcdir type TRY_COMPILE
+ TestProject COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/result)
+CMake Error at OneArg.cmake:1 \(try_compile\):
+try_compile(RESULT)
@@ -0,0 +1,11 @@
+include(RunCMake)
+
+run_cmake(NoArgs)
+run_cmake(OneArg)
+run_cmake(TwoArgs)
+run_cmake(NoCopyFile)
+run_cmake(NoOutputVariable)
+run_cmake(NoLinkLibraries)
+run_cmake(BadLinkLibraries)
+run_cmake(NonSourceCopyFile)
+run_cmake(NonSourceCompileDefinitions)
+CMake Error at TwoArgs.cmake:1 \(try_compile\):
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR})
+cmake_minimum_required(VERSION 2.8.10)
+project(TestProject NONE)
+int main(void) { return 0; }