From 770245e9287de01c990605b54d28302c9cac3340 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 7 Feb 2014 15:38:49 +0100 Subject: [PATCH 1/2] add_library: Test invalid GLOBAL INTERFACE signature. This has to be tested separately from the invalid_signature test because target sources are evaluate at a later time, and earlier errors in the invalid_signature test cause early exit. --- Tests/RunCMake/interface_library/RunCMakeTest.cmake | 1 + .../interface_library/global-interface-result.txt | 1 + .../interface_library/global-interface-stderr.txt | 9 +++++++++ Tests/RunCMake/interface_library/global-interface.cmake | 2 ++ Tests/RunCMake/interface_library/invalid_signature.cmake | 2 +- 5 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/interface_library/global-interface-result.txt create mode 100644 Tests/RunCMake/interface_library/global-interface-stderr.txt create mode 100644 Tests/RunCMake/interface_library/global-interface.cmake diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake index 9ca9a77143..3c457c5bac 100644 --- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake @@ -5,5 +5,6 @@ run_cmake(target_commands) run_cmake(no_shared_libs) run_cmake(whitelist) run_cmake(invalid_signature) +run_cmake(global-interface) run_cmake(genex_link) run_cmake(add_dependencies) diff --git a/Tests/RunCMake/interface_library/global-interface-result.txt b/Tests/RunCMake/interface_library/global-interface-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/interface_library/global-interface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/global-interface-stderr.txt b/Tests/RunCMake/interface_library/global-interface-stderr.txt new file mode 100644 index 0000000000..24edd0f898 --- /dev/null +++ b/Tests/RunCMake/interface_library/global-interface-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at global-interface.cmake:2 \(add_library\): + Cannot find source file: + + GLOBAL + + Tried extensions \.c \.C \.c\+\+ \.cc \.cpp \.cxx \.m \.M \.mm \.h \.hh \.h\+\+ \.hm \.hpp + \.hxx \.in \.txx +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/interface_library/global-interface.cmake b/Tests/RunCMake/interface_library/global-interface.cmake new file mode 100644 index 0000000000..d2bfc64ed9 --- /dev/null +++ b/Tests/RunCMake/interface_library/global-interface.cmake @@ -0,0 +1,2 @@ + +add_library(iface GLOBAL INTERFACE) diff --git a/Tests/RunCMake/interface_library/invalid_signature.cmake b/Tests/RunCMake/interface_library/invalid_signature.cmake index 67e3267439..4e53534b28 100644 --- a/Tests/RunCMake/interface_library/invalid_signature.cmake +++ b/Tests/RunCMake/interface_library/invalid_signature.cmake @@ -16,5 +16,5 @@ add_library(iface15 ALIAS INTERFACE) add_library(iface16 INTERFACE INTERFACE) add_library(iface17 INTERFACE EXCLUDE_FROM_ALL) add_library(iface18 EXCLUDE_FROM_ALL INTERFACE) -add_library(iface19 GLOBAL INTERFACE) +# add_library(iface19 GLOBAL INTERFACE) Tested separately add_library(iface20 INTERFACE GLOBAL) From 6d85a6a64c6919c07d983b584bb74f6a29cddac5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 7 Feb 2014 15:31:57 +0100 Subject: [PATCH 2/2] add_library: Issue better diagnostic for INTERFACE GLOBAL signature. --- Source/cmAddLibraryCommand.cxx | 7 +++++++ .../interface_library/invalid_signature-stderr.txt | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index a29f784209..009b1caa43 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -173,6 +173,13 @@ bool cmAddLibraryCommand ++s; importGlobal = true; } + else if(type == cmTarget::INTERFACE_LIBRARY && *s == "GLOBAL") + { + cmOStringStream e; + e << "GLOBAL option may only be used with IMPORTED libraries."; + this->SetError(e.str().c_str()); + return false; + } else { break; diff --git a/Tests/RunCMake/interface_library/invalid_signature-stderr.txt b/Tests/RunCMake/interface_library/invalid_signature-stderr.txt index 701586a8d3..6374b3392b 100644 --- a/Tests/RunCMake/interface_library/invalid_signature-stderr.txt +++ b/Tests/RunCMake/interface_library/invalid_signature-stderr.txt @@ -84,6 +84,6 @@ Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) + CMake Error at invalid_signature.cmake:20 \(add_library\): - add_library INTERFACE library requires no source arguments. + add_library GLOBAL option may only be used with IMPORTED libraries. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\)