try_compile: Add test for bad call error cases

Add a RunCMake.try_compile test to cover cases of bad invocation of the
try_compile command.
This commit is contained in:
Brad King 2013-05-15 15:19:20 -04:00
parent 5377ac4289
commit b680824a5f
32 changed files with 80 additions and 0 deletions

View File

@ -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)

View File

@ -0,0 +1 @@
1

View File

@ -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\)

View File

@ -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)

View File

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

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,4 @@
CMake Error at NoArgs.cmake:1 \(try_compile\):
try_compile unknown error.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1 @@
try_compile()

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,4 @@
CMake Error at NoCopyFile.cmake:1 \(try_compile\):
COPY_FILE specified but there is no variable
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1,2 @@
try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c
COPY_FILE)

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,4 @@
CMake Error at NoLinkLibraries.cmake:1 \(try_compile\):
LINK_LIBRARIES specified but there is no content
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1,2 @@
try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c
LINK_LIBRARIES)

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,4 @@
CMake Error at NoOutputVariable.cmake:1 \(try_compile\):
OUTPUT_VARIABLE specified but there is no variable
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1,2 @@
try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c
OUTPUT_VARIABLE)

View File

@ -0,0 +1,4 @@
CMake Error at NonSourceCompileDefinitions.cmake:1 \(try_compile\):
COMPILE_FLAGS specified on a srcdir type TRY_COMPILE
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1,2 @@
try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/proj
TestProject COMPILE_DEFINITIONS DEF)

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,4 @@
CMake Error at NonSourceCopyFile.cmake:1 \(try_compile\):
COPY_FILE specified on a srcdir type TRY_COMPILE
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1,2 @@
try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/proj
TestProject COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/result)

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,4 @@
CMake Error at OneArg.cmake:1 \(try_compile\):
try_compile unknown error.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1 @@
try_compile(RESULT)

View File

@ -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)

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,4 @@
CMake Error at TwoArgs.cmake:1 \(try_compile\):
try_compile unknown error.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1 @@
try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR})

View File

@ -0,0 +1,2 @@
cmake_minimum_required(VERSION 2.8.10)
project(TestProject NONE)

View File

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