How to tell CMake to link executable against library?
<p>My source tree is </p>

<ul>
<li>CMakeLists.txt

<ul>
<li>Demo

<ul>
<li>CMakeLists.txt</li>
<li>source, headers.</li>
</ul></li>
<li>Library

<ul>
<li>CMakeLists.txt</li>
<li>source, headers. </li>
</ul></li>
</ul></li>
</ul>

<p>So Demo is the executable which is done with add_executable()
and Library is obviously the library. How can those 2 be linked together?</p>

<p>Because right now I am using target_link_libraries(Demo Library) but I am getting Error: LNK2019 which I think is caused by not linking successfully. </p>

<p>Any ideas?</p>

<p>Thanks.</p>

<p>edit: On root CMakeLists.txt those 2 are added as -> add_subdirectory(Library) add_subdirectory(Demo). </p>

<p>edit2:<br>
  <strong>Demo CMakeLists</strong> </p>

<pre><code>add_executable(Demo ${Headers}
                    ${Source})

target_link_libraries(Demo ${blahblah}
                           ${Library})
</code></pre>

<p><strong>Library CMakeLists</strong></p>

<pre><code>add_library(Library blahblah.cpp
                    blahblah.h
                    foo.cpp
                    foo.h)
</code></pre>