I have some target_link_libraries :
add_library(x x.cc)
target_link_libraries(x depX1 depX2 depX3)
add_executable(exe exe.cc)
target_link_libraries(exe x ${shared_lib1} ${shared_lib2})
Which results into the exe linking with x and the dependencies of x : depx1, depx2 etc The problem is that the shared_libs are intercalated between x and the dependencies of x and this is not acceptable in g++ 4.6 (it worked in older versions).
How to fix? I need to put the shared libs at the END of the compilation line, just like I specified in the CMakeLists.txt file. So I do not want them intercalated, I want them at the end of the compilation line. Also note that depx1, depx2 depx3 etc have their own dependencies as well so the only thing I want is that the shared libs to appear at the end of the compilation line.
How to do that with cmake? Thanks
--LATER EDIT2-- => SOLVED This can be solved by using an ugly hack:
add_custom_command(TARGET TargetName
PRE_LINK COMMAND ${PROJECT_SOURCE_DIR}/custom_script.sh
ARGS ${PROJECT_BINARY_DIR}/src/TargetName/CMakeFiles/TargetName.dir/link.txt)
where src/TargetName/CMakeFiles/TargetName.dir/link.txt is the link command line CMake produces and custom_script.sh is a script which parses the file and arranges the dynamic link libraries at the end of the compilation line.
--LATER EDIT--
So I understand that with the current CMake and no option to put the shared libraries AT THE END of the compilation line and with g++4.6, everything breaks ! This is awesome !