title: CMake Target_Link_Libraries fails
body: <p>I know this topic already has been discussed more than once, but I do not understand what is going wrong. I looked up several websites but none of the provided approaches worked for me.</p>
  
  <p>I want to create a VS solution with CMake which consists of 10 projects. <strong>Each project</strong> has to link <code>myLibrary.lib</code>. </p>
  
  <pre><code>#CMakeLists.txt:
  
  cmake_minimum_required (VERSION 2.8)
  project (Project_Example) 
  
  SET(SRC_DIR_PATH C++)
  
  INCLUDE_DIRECTORIES( "inc" )                          # OK, tested and works
  LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/lib)     # OK, tested and works
  ADD_EXECUTABLE(${BINNAME} ${SRCS})                    # ?No idea?
  TARGET_LINK_LIBRARIES(${BINNAME} myLibrary.lib)       # fails
  
  ADD_SUBDIRECTORY( src/Project_01 )
  IF( TRUE )
  ADD_SUBDIRECTORY( src/Project_02 )
  ADD_SUBDIRECTORY( src/Project_03 )
  ADD_SUBDIRECTORY( src/Project_04 )
  ADD_SUBDIRECTORY( src/Project_05 )
  ADD_SUBDIRECTORY( src/Project_06 )
  ADD_SUBDIRECTORY( src/Project_07 )
  ADD_SUBDIRECTORY( src/Project_08 )
  ADD_SUBDIRECTORY( src/Project_09 )
  ADD_SUBDIRECTORY( src/Project_10 )
  ENDIF()
  </code></pre>
  
  <p>Each Project has its own <code>CMakeLists.txt</code> which looks like:</p>
  
  <pre><code>cmake_minimum_required (VERSION 2.8)
  
  MESSAGE( STATUS "## ${CMAKE_CURRENT_BINARY_DIR} ##" )
  
  IF ( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
    ### Windows ###
    SET( LIB_PROJECT myLibrary )
    SET( LIB_SYSTEM  )
  ELSEIF ( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
    ### Linux ###
    SET( LIB_PROJECT myLibrary dl )
    SET( LIB_SYSTEM /usr/local/lib )
  ENDIF ( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
  
  
  SET( SOURCE_WITHOUT_EXT Project_01 )
  SET( PROJECT_EXAMPLE ${SOURCE_WITHOUT_EXT} )
  
  SET( SOURCE_FILES
    ${SOURCE_WITHOUT_EXT}.cpp
  )
  
  
  FOREACH( Librarys ${LIB_PROJECT} )
    MESSAGE("#### Librarys:${Librarys} next will find ...")
    SET( SHAREDLIB ${SHAREDLIB}-NOTFOUND )
    FIND_LIBRARY ( SHAREDLIB
      NAMES ${Librarys}
      PATHS ${PROJECT_BINARY_DIR}/lib ${LIB_SYSTEM}
      )
    MESSAGE("#### SHAREDLIB:${SHAREDLIB}")
    IF( SHAREDLIB )
      SET( LIBS_ALL ${LIBS_ALL} ${SHAREDLIB} )
      SET( SHAREDLIB ${SHAREDLIB}-NOTFOUND )
    ENDIF()
    MESSAGE("#### ${LIBRARY} found LIBS_ALL${LIBS_ALL}")
  ENDFOREACH( Librarys )
  
  
  ADD_EXECUTABLE( ${PROJECT_EXAMPLE} ${SOURCE_FILES} ) 
  
  TARGET_LINK_LIBRARIES( ${PROJECT_EXAMPLE} ${LIBS_ALL})
  </code></pre>
  
  <p>The CMakeLists from these projects are used since long time and therefore considered to be OK. The Problem occured when integrating all projects to one CMake solution.</p>
  
  <p>The error I'm getting is: `"SHAREDLIB:SHAREDLIB-NOTFOUND"</p>
  
  <p><img src="https://i.stack.imgur.com/aiB7M.png" alt="cmake error, occurs for each project">`</p>
  
  <p>There's also a warning:</p>
  
  <pre><code>CMake Warning (dev) at CMakeLists.txt: (TARGET_LINK_LIBRARIES): 
  Cannot specify link libraries for target "MyLibrary.lib" which is not build by this project.
  
  CMake does not support this but it is used to work accidentally ans is being allowed for compatibility.
  
  Policy CMP0016 is not set: target_link_libraries() reports error if only argument is not a target. Run "cmake --help-policy CMP0016" for policy details. Use the cmake_policy command to set the policy and suppress this warning.
  </code></pre>
  
  <p>So again, I want to add this library to any project in this solution.</p>
  
  <p>My folders are something like:</p>
  
  <pre><code>C++\
       inc\    -&gt; header files
       lib\    -&gt; libraries
       src\    -&gt; sources with 10 different folders of c++ files
  </code></pre>
  
  <p>CMake command is:</p>
  
  <p><code>cmake -G "Visual Studio 10" --build .. -DWIN_64:BOOL=OFF</code></p>
  
  <p>I'm using CMake 2.8 and VS 2010.</p>