-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merging static libs with MSVC does not work. #36
Comments
As the comment on line 59 says, lib.exe accepts a list of static libs to produce a merged static lib. Line 66 sets the list of sub-libraries as a flag for producing Documentation on lib.exe: |
I understood that far but I can not see where the merging is actually done, i.e., where |
I have fixed it on our fork using the following # Now the easy part for MSVC and for MAC
if(MSVC)
# lib.exe does the merging of libraries just need to conver the list into string
foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})
set(flags "")
foreach(lib ${libfiles_${CONFIG_TYPE}})
set(flags "${flags} ${lib}")
endforeach()
string(TOUPPER "STATIC_LIBRARY_FLAGS_${CONFIG_TYPE}" PROPNAME)
set_target_properties(${outlib} PROPERTIES ${PROPNAME} "${flags}")
endforeach()
+ find_program(MSVC_LIB_TOOL lib.exe)
+ if(NOT MSVC_LIB_TOOL)
+ message(FATAL_ERROR "LIB.EXE not found. fmil can not merge static libs.")
+ endif()
+ get_target_property(outfile ${outlib} LOCATION)
+ add_custom_command(TARGET ${outlib} POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E remove ${outfile}
+ COMMAND ${MSVC_LIB_TOOL} /OUT:${outfile} ${libfiles}
+ )
elseif(APPLE) You should update it accordingly. |
At the beginning of the function: Cmake should convert this to a call to lib.exe when compiling with MSVC. The libs to be merged are later added as flags. It's tested with generator = |
I have to ask, why is that approach chosen? To me it sounds unconventional (even on top of merging static libs), confusing and brittle. I am still not sure how it is supposed to work that way.
I am testing with Visual Studio 2019 Win64. Is the use of the merged library tested? The library will be built anyway but it does not contain any of the libraries that were supposed to be merged. Does
show the symbols from the sublibs? For me it does not. |
FMIL tries to merge static libs with the function merge_static_libs. However this does not seem to work with MSVC.
I am trying to debug the issue but looking at the code responsible for merging libs with MSVC
fmi-library/Config.cmake/mergestaticlibs.cmake
Lines 57 to 69 in fc8d2eb
I can not see anything relevant to actually merging the libraries.
Is there something else that does the merging? If so where is it located so we can continue debugging.
The text was updated successfully, but these errors were encountered: