title: CMAKE building static executable instead of using dynamic library
body: <p>My cmake file is </p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8.4)
  project(libtry CXX)
  
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  set(EXE_NAME libtry)
  
  file(GLOB_RECURSE MAIN_SRC_FILES "src/*.cpp")
  add_library (Try SHARED ${MAIN_SRC_FILES})
  
  
  set(SOURCE_FILES main.cpp)
  add_executable(${EXE_NAME} ${SOURCE_FILES})
  target_link_libraries(${EXE_NAME} Try)
  </code></pre>
  
  <p>This file works and creates the two files: a .so file and an executable and it works perfectly. The problem is even after removing the .so file, the executable is working normally which means that the executable is statically linked. </p>
  
  <p>Why this is happening and why cmake is not dynamically using the .so file?</p>
  
  <p><strong>Update</strong>
  The dependencies by running <code>ldd</code> confirms this. Output of ldd is</p>
  
  <pre><code>linux-vdso.so.1 =&gt;  (0x00007fffea5fe000)
  libstdc++.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f3585779000)
  libgcc_s.so.1 =&gt; /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f3585563000)
  libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007f358519c000)
  libm.so.6 =&gt; /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3584e96000)
  /lib64/ld-linux-x86-64.so.2 (0x00007f3585aa7000)
  </code></pre>