CMake IMPORTED UNKNOWN GLOBAL target
<p>I have hard times understanding CMake's imported libraries. Here is my test structure:</p>

<pre><code>├── binary
│   ├── CMakeLists.txt
│   └── main.cc
├── library
│   ├── CMakeLists.txt
│   ├── lib.cc
│   └── lib.hh
</code></pre>

<p>The library's CMakeLists.txt looks like this:</p>

<pre><code>cmake_minimum_required(VERSION 2.8.1)

project(Library)

add_library(library lib.cc)
target_include_directories(library PUBLIC ${CMAKE_CURRENT_LIST_DIR})
</code></pre>

<p>And the binary's looks like this:</p>

<pre><code>cmake_minimum_required(VERSION 2.8.1)

project(binary)

add_executable(binary main.cc)

find_library(il_default library PATHS "${CMAKE_CURRENT_LIST_DIR}/../library/build/")

add_library(Imported::Library UNKNOWN IMPORTED GLOBAL)
set_property(TARGET Imported::Library PROPERTY IMPORTED_LOCATION ${il_default})
set_property(TARGET Imported::Library PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/../library")

target_link_libraries(binary Imported::Library)
</code></pre>

<p>Build commands:</p>

<pre><code>cmake -Blibrary/build -Hlibrary &amp;&amp; cmake --build library/build
cmake -Bbinary/build -Hbinary &amp;&amp; cmake --build binary/build
</code></pre>

<p>This yields the following error:</p>

<pre><code>CMake Error at CMakeLists.txt:13 (target_link_libraries):
  Target "Imported::Library" of type UNKNOWN_LIBRARY may not be linked into
  another target.  One may link only to STATIC or SHARED libraries, or to
  executables with the ENABLE_EXPORTS property set.
</code></pre>

<p>Removing the <strong>GLOBAL</strong> parameter from the <strong>add_library</strong> command, or replacing <strong>UNKNOWN</strong> with <strong>STATIC</strong> solves the problem. </p>

<p>My question is "Why?". Why can I use an unknown imported library within the current directory but can't make it global?</p>

<p>CMake version is 3.6.0</p>