try_run: Add test for bad link libraries.

Based off the corresponding try_compile test.
This commit is contained in:
Matt McCormick 2015-01-22 19:13:56 -05:00 committed by Brad King
parent e2b1f0583f
commit 223c5cb70b
7 changed files with 18 additions and 0 deletions

View File

@ -130,6 +130,7 @@ add_RunCMake_test(project)
add_RunCMake_test(return)
add_RunCMake_test(string)
add_RunCMake_test(try_compile)
add_RunCMake_test(try_run)
add_RunCMake_test(set)
add_RunCMake_test(variable_watch)
add_RunCMake_test(CMP0004)

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,5 @@
CMake Error at BadLinkLibraries.cmake:2 \(try_run\):
Only libraries may be used as try_compile or try_run IMPORTED
LINK_LIBRARIES. Got not_a_library of type UTILITY.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1,4 @@
add_custom_target(not_a_library)
try_run(RUN_RESULT COMPILE_RESULT
${CMAKE_CURRENT_BINARY_DIR}/CMakeTmp ${CMAKE_CURRENT_SOURCE_DIR}/src.c
LINK_LIBRARIES not_a_library)

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8.0)
project(${RunCMake_TEST} C)
include(${RunCMake_TEST}.cmake)

View File

@ -0,0 +1,3 @@
include(RunCMake)
run_cmake(BadLinkLibraries)

View File

@ -0,0 +1 @@
int main(void) { return 0; }