title: CMake: build lib and link it to executable results in undefined reference error
body: <p>I have a cmake setup that is supposed to first build a library and then use this library to create an executable:</p>
  
  <pre><code># build and install the project lib
  add_library(lib${PROJECT_NAME} 
      test.cpp
  )
  install(TARGETS lib${PROJECT_NAME} DESTINATION ${INSTALL_DIR})
  install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${INSTALL_INCLUDE_DIR} FILES_MATCHING PATTERN "*.h*")
  
  
  # link lib and create executable
  add_executable(${PROJECT_NAME} main.cpp)
  target_link_libraries(lib${PROJECT_NAME})
  
  install(TARGETS ${PROJECT_NAME} DESTINATION ${INSTALL_DIR})
  </code></pre>
  
  <p>The lib building part works, but it seems the linking of the lib does not. I am using a simple add method which is implemented in the test.cpp and I get an undefined reference to this method.</p>
  
  <p>What am I missing here? </p>