Hi, I've been trying to implement a feature which would enable building static binaries with cmake, but I've got completely stuck, I hope someone can hint me what's the best way to do this.
What I've done is a 2 stage solution for making static binaries: 1) Telling cmake to prefer picking up ".a"-s when searching for libraries (CMAKE_FIND_LIBRARY_SUFFIXES). This works fine, but referring to file extensions/endings might not be general enough. Making it less platform-dependent would require rewriting the way external libraries are treated: instead of adding them with full path we'd need to add -Lpath -llibname separately. Any other ways for doing this? 2) Telling cmake to use static system libraries. This should work with the target property LINK_SEARCH_END_STATIC which essentially should result in a the system libs linked in statically whenever possible (depending on the platform). Well, it seems that even in fairly straightforward situations (Linux + gcc) I get the a linker error: /usr/bin/ld: cannot find -lgcc_s. Obviously, libgcc_s.a is not available, but by looking at the verbose output, the implicit gcc linker call contains the "-Wl,-Bstatic" argument. This AFAIK is not correct, or more precisely not enough to just tell ld to link statically, gcc also has to know about it (through the "-static" argument). Can anyone confirm this? I'd be grateful for tips on how to fix the issue with 2), but I'm open for other portable (and preferably elegant) solutions. Cheers, -- Szilárd _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
