title: Right way of creating a library, installing it and linking to another project using CMake
body: <p>I have a set of files that I want to make into a library and then use that library in another project. This it how it looks like right now</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8)
  aux_source_directory(. SRC_LIST)
  SET(CMAKE_CXX_FLAGS "-std=c++11 -fopenmp -fPIC")
  add_library (helperlibs lib1.cpp lib2.cpp lib3.cpp lib4.cpp )
  INSTALL(TARGETS helperlibs
          DESTINATION "${HOME}/lib"
          )
  INSTALL(FILES lib1.h lib2.h lib3.h lib4.h helperheader.h
          DESTINATION "${HOME}/include/helperlibs"
          )
  </code></pre>
  
  <p>In this code <code>Lib4</code> depends on <code>Lib1-3</code> and <code>Lib3</code> depends on <code>Lib1-2</code> and <code>Lib2</code> depends on <code>Lib1</code>. Each of these cpp files also depend on a <code>helperheader.h</code> file that contains some definitions and structs.</p>
  
  <p>In my project I have the following CMake file </p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8)
  aux_source_directory(. SRC_LIST)
  SET( CMAKE_CXX_FLAGS "-std=c++11 -fopenmp -fPIC")
  SET(MYINCS ${HOME}/include/helperlibs)
  SET(MYLIBDIR ${HOME}/lib)
  SET(MYLIBS ${MYLIBDIR}/libhelperlibs.a )
  include_directories(${MYINCS})
  add_executable(main main.cpp)
  target_link_libraries(main ${MYLIBS})
  </code></pre>
  
  <p>So what I am wondering if you want to create a static library and link to from a another project using cmake is this the way you should write? </p>