diff --git a/Modules/CMakeFindDependencyMacro.cmake b/Modules/CMakeFindDependencyMacro.cmake index 99ffca80cd..73efaae7cd 100644 --- a/Modules/CMakeFindDependencyMacro.cmake +++ b/Modules/CMakeFindDependencyMacro.cmake @@ -31,14 +31,17 @@ macro(find_dependency dep) if (NOT ${dep}_FOUND) set(cmake_fd_version) if (${ARGC} GREATER 1) - if (${ARGV1} STREQUAL EXACT) + if ("${ARGV1}" STREQUAL "") + message(FATAL_ERROR "Invalid arguments to find_dependency. VERSION is empty") + endif() + if ("${ARGV1}" STREQUAL EXACT) message(FATAL_ERROR "Invalid arguments to find_dependency. EXACT may only be specified if a VERSION is specified") endif() set(cmake_fd_version ${ARGV1}) endif() set(cmake_fd_exact_arg) if(${ARGC} GREATER 2) - if (NOT ${ARGV2} STREQUAL EXACT) + if (NOT "${ARGV2}" STREQUAL EXACT) message(FATAL_ERROR "Invalid arguments to find_dependency") endif() set(cmake_fd_exact_arg EXACT) diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt index 6f4fc04119..348f8bb25d 100644 --- a/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt +++ b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:35 \(message\): +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): Invalid arguments to find_dependency. EXACT may only be specified if a VERSION is specified Call Stack \(most recent call first\): diff --git a/Tests/RunCMake/find_dependency/RunCMakeTest.cmake b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake index b85104aa6a..9403136b71 100644 --- a/Tests/RunCMake/find_dependency/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake @@ -1,5 +1,7 @@ include(RunCMake) run_cmake(EXACT-no-version) +run_cmake(empty-version) +run_cmake(empty-arg-3) run_cmake(invalid-arg-3) run_cmake(extra-args) diff --git a/Tests/RunCMake/find_dependency/empty-arg-3-result.txt b/Tests/RunCMake/find_dependency/empty-arg-3-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-arg-3-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt b/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt new file mode 100644 index 0000000000..bf9b02b43c --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): + Invalid arguments to find_dependency +Call Stack \(most recent call first\): + empty-arg-3.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/empty-arg-3.cmake b/Tests/RunCMake/find_dependency/empty-arg-3.cmake new file mode 100644 index 0000000000..b08200a5a5 --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-arg-3.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 1.2 "") diff --git a/Tests/RunCMake/find_dependency/empty-version-result.txt b/Tests/RunCMake/find_dependency/empty-version-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-version-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_dependency/empty-version-stderr.txt b/Tests/RunCMake/find_dependency/empty-version-stderr.txt new file mode 100644 index 0000000000..b5e9f46439 --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-version-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at .*/Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): + Invalid arguments to find_dependency. VERSION is empty +Call Stack \(most recent call first\): + empty-version.cmake:4 \(find_dependency\) + CMakeLists.txt:4 \(include\) diff --git a/Tests/RunCMake/find_dependency/empty-version.cmake b/Tests/RunCMake/find_dependency/empty-version.cmake new file mode 100644 index 0000000000..e6f17cd139 --- /dev/null +++ b/Tests/RunCMake/find_dependency/empty-version.cmake @@ -0,0 +1,4 @@ + +include(CMakeFindDependencyMacro) + +find_dependency(Pack1 "") diff --git a/Tests/RunCMake/find_dependency/extra-args-stderr.txt b/Tests/RunCMake/find_dependency/extra-args-stderr.txt index 1b523807e6..83a7f02661 100644 --- a/Tests/RunCMake/find_dependency/extra-args-stderr.txt +++ b/Tests/RunCMake/find_dependency/extra-args-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:47 \(message\): +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): Invalid arguments to find_dependency Call Stack \(most recent call first\): extra-args.cmake:4 \(find_dependency\) diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt index c36148fade..fee8d5db7a 100644 --- a/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt +++ b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt @@ -1,4 +1,4 @@ -CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:42 \(message\): +CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\): Invalid arguments to find_dependency Call Stack \(most recent call first\): invalid-arg-3.cmake:4 \(find_dependency\)