I've been working on linking to some system libraries in a project I'm building in Linux and I've run into a problem with CMake adding redundant linker arguments.
The simplest case I came down to is this: In the Example/Demo/CMakeLists.txt file add the following lines: target_link_libraries (helloDemo "m" ) target_link_libraries (helloDemo "m" ) target_link_libraries (helloDemo "crypt" "pthread" ) If you turn on verbose makefiles and use the target "Unix Makefiles" the generated command line has this portion: -lm -lcrypt -lpthread -lm -lcrypt -lpthread Essentially, it repeats *all* of the system libraries I specified for every redundant library that's added. Changing CMakeLists.txt to something a bit weirder yields the following: target_link_libraries (helloDemo "m" ) target_link_libraries (helloDemo "m" ) target_link_libraries (helloDemo "crypt" ) target_link_libraries (helloDemo "pthread" ) target_link_libraries (helloDemo "crypt" "pthread" ) -lm -lcrypt -lpthread -lcrypt -lpthread -lm -lcrypt -lpthread -lcrypt -lpthread The real problem with this is that I use things like FindX11 and FindPkgCfg to get generated linking libraries for a bunch of modules on the system. Each of these modules often include some redundant "base" libraries. For each of those, I end up with this increasingly expansive list of libraries when I actually only needed them once. Any ideas? The current workaround I'm using is to generate my own list of the necessary libraries and remove redundancies before adding it to the target. -- Andrew Sayman _______________________________________________ CMake mailing list [email protected] http://www.cmake.org/mailman/listinfo/cmake
