Hi, I have been playing with the WINDOWS_EXPORT_ALL_SYMBOLS recently and found the feature very useful. I reused part of the this functionality to emulate the --whole-archive link flag with MSVC. Here is the process I used:
1. Use a POST_BUILD custom command to list the object files linked in the static library (dumpbin /ARCHIVEMEMBERS mylib.lib and write this to a file. 2. Use a cmake script to call cmake -E __create_def and create a header file with #pragma comment(linker, /include:"<symbol"> for every symbol in the generated .def file. 3. Consuming projects including this header file when linking to mylib.lib It seems that it would not be too hard to add this feature to cmake to that it can be done via a target property similar to the WINDOWS_EXPORT_ALL_SYMBOLS. For example: 1. WINDOWS_LINK_WHOLE_ARCHIVE is set on the library 2. CMake catches this and list all the object files into a file and calls itself via cmake -E __create_whole_archive_rsp_file which creates a response file containing a list of /INCLUDE:"<symbolname>" 3. CMake adds this response file to the INTERFACE_LINK_LIBRARIES of the target so that consuming projects automatically link in all the symbols defined in the library. 4. Then cmake would have the handle the installation of this response file, etc. See this for documentation of rsp files: https://msdn.microsoft.com/en-us/library/9xch38h8.aspx This would probably have the side effect of solving https://cmake.org/Bug/view.php?id=13032 which is nice. Most of this is already possible via cmake code but could be made much easier if it was just a property to set on a target. Would it be possible to implement such a feature in CMake? Do you see any problem with the process mentionned above? Is it currently possible to add a response file to the link line via target_link_libraries or via target properties? Thank you -- Guillaume Dumont ========================= dumont.guilla...@gmail.com
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake