title: Is it possible to force CMake to reorder arguments when calling the linker?
body: <p>I have a strange behavior where CMake is not able to link any executable if dynamic linking is required. g++ is not able to find any of the symbols defined in the libraries.</p>
  
  <p>I found out it might have to do with the order of the arguments CMake passes to g++ when linking.</p>
  
  <p>Here is the verbose output of the build process (which fails linking):</p>
  
  <pre><code>[ 50%] Building CXX object CMakeFiles/chargen.dir/test.cpp.obj
  g++ -std=c++11   -o CMakeFiles/test.dir/test.cpp.obj -c /f/test/test.cpp
  [100%] Linking CXX executable mytest
  
  /usr/bin/cmake -E cmake_link_script CMakeFiles/test.dir/link.txt --verbose=1
  g++   -std=c++11   -lSDL2 CMakeFiles/test.dir/test.cpp.obj  -o mytest
  </code></pre>
  
  <p>Indeed if I try to link using that command I get undefined references, however if I compile with the library flags at the end:</p>
  
  <pre><code>g++   -std=c++11 CMakeFiles/test.dir/test.cpp.obj  -o mytest -lSDL2 
  </code></pre>
  
  <p>it runs just fine. How can I force CMake to use that order of arguments instead?</p>
  
  <p>The contents of the CMakeLists.txt:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.6)
  
  project(mytest)
  
  set(COMPILER_PATH "/usr/bin/")
  set(CMAKE_MAKE_PROGRAM "make")
  set(CMAKE_C_COMPILER   "gcc")
  set(CMAKE_CXX_COMPILER "g++")
  
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lSDL2")
  set(SOURCE_FILES test.cpp)
  add_executable(mytest ${SOURCE_FILES})
  </code></pre>