-
Notifications
You must be signed in to change notification settings - Fork 35
Improve mergestaticlibs #192
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
base: master
Are you sure you want to change the base?
Conversation
else() | ||
# only works with static third-party libs | ||
foreach(libtarget ${libs}) | ||
target_sources(${outlib} PUBLIC $<TARGET_OBJECTS:${libtarget}>) | ||
endforeach() | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this a bit more, and how it solves the Mingw issue in #192?
- Reading the doc it's not clear to me how it's valid that target_sources(...) can accept object files. To me it looks like it expects .c and .h files, and that one should use target_link_libraries(...) with the object files?
- How can we use $<TARGET_OBJECTS:...> if libtarget is not specified as add_library(... OBJECT)? At least I don't see that we specify it as OBJECT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems #192 build failed because it did not have the ls command to list object files
I tried several things including creating an intermediate OBJECT library but it did not work but curiously target_sources worked, so seems I have to dig on the cmake side
else() | ||
# only works with static third-party libs | ||
foreach(libtarget ${libs}) | ||
target_sources(${outlib} PUBLIC $<TARGET_OBJECTS:${libtarget}>) | ||
endforeach() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internal test of the MinGW installation shows that there are some issues, likely expat (and possibly other libs are not merged or found):
Output...
set -eu; \
cd Test/test_installation; \
rm -rf build && mkdir -p build; \
cd build; \
cmake -DFMIL_HOME=/c/<...>/install_mingw_w64 -G "MSYS Makefiles" ..; \
cmake --build .; \
ctest
...
[ 50%] Linking C executable main.exe
C:/<...>/install_mingw_w64/lib/libfmilib.a(fmi_xml_context.c.obj):fmi_xml_context.c:(.text+0xa7): undefined reference to `XML_ParserFree'
C:/<...>/install_mingw_w64/lib/libfmilib.a(fmi_xml_context.c.obj):fmi_xml_context.c:(.text+0x115): undefined reference to `XML_StopParser'
C:/<...>/install_mingw_w64/lib/libfmilib.a(fmi_xml_context.c.obj):fmi_xml_context.c:(.text+0x2d3): undefined reference to `XML_ParserFree'
C:/<...>/install_mingw_w64/lib/libfmilib.a(fmi_xml_context.c.obj):fmi_xml_context.c:(.text+0x2e2): undefined reference to `XML_ParserCreate_MM'
C:/<...>/install_mingw_w64/lib/libfmilib.a(fmi_xml_context.c.obj):fmi_xml_context.c:(.text+0x2fd): undefined reference to `XML_SetUserData'
C:/<...>/install_mingw_w64/lib/libfmilib.a(fmi_xml_context.c.obj):fmi_xml_context.c:(.text+0x313): undefined reference to `XML_SetElementHandler'
C:/<...>/install_mingw_w64/lib/libfmilib.a(fmi_xml_context.c.obj):fmi_xml_context.c:(.text+0x322): undefined reference to `XML_SetCharacterDataHandler'
C:/<...>/install_mingw_w64/lib/libfmilib.a(fmi_xml_context.c.obj):fmi_xml_context.c:(.text+0x396): undefined reference to `XML_Parse'
C:/<...>/install_mingw_w64/lib/libfmilib.a(fmi_xml_context.c.obj):fmi_xml_context.c:(.text+0x426): undefined reference to `XML_GetErrorCode'
C:/<...>/install_mingw_w64/lib/libfmilib.a(fmi_xml_context.c.obj):fmi_xml_context.c:(.text+0x42d): undefined reference to `XML_ErrorString'
C:/<...>/install_mingw_w64/lib/libfmilib.a(fmi_xml_context.c.obj):fmi_xml_context.c:(.text+0x438): undefined reference to `XML_GetCurrentLineNumber'
C:/<...>/install_mingw_w64/lib/libfmilib.a(fmi_xml_context.c.obj):fmi_xml_context.c:(.text+0x476): undefined reference to `XML_ParserFree'
C:/<...>/install_mingw_w64/lib/libfmilib.a(fmi_xml_context.c.obj):fmi_xml_context.c:(.text+0x22b): undefined reference to `XML_StopParser'
C:/<...>/install_mingw_w64/lib/libfmilib.a(unzip.c.obj):unzip.c:(.text+0x1ce5): undefined reference to `inflateEnd'
C:/<...>/install_mingw_w64/lib/libfmilib.a(unzip.c.obj):unzip.c:(.text+0x2b55): undefined reference to `inflateEnd'
C:/<...>/install_mingw_w64/lib/libfmilib.a(unzip.c.obj):unzip.c:(.text+0x2bee): undefined reference to `inflateInit2_'
C:/<...>/install_mingw_w64/lib/libfmilib.a(unzip.c.obj):unzip.c:(.text+0x2e98): undefined reference to `inflate'
C:/<...>/install_mingw_w64/lib/libfmilib.a(unzip.c.obj):unzip.c:(.text+0x2eed): undefined reference to `crc32'
C:/<...>/install_mingw_w64/lib/libfmilib.a(unzip.c.obj):unzip.c:(.text+0x2fb1): undefined reference to `crc32'
C:/<...>/install_mingw_w64/lib/libfmilib.a(unzip.c.obj):unzip.c:(.text+0x3205): undefined reference to `inflateEnd'
collect2.exe: error: ld returned 1 exit status
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you using an external, dynamic expat lib ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Building with bundled expat:
mkdir -p build_mingw_w64
cd build_mingw_w64 && \
cmake -DCMAKE_INSTALL_PREFIX=../install_mingw_w64 \
-DFMILIB_GENERATE_DOXYGEN_DOC=0 \
-DFMILIB_BUILD_WITH_STATIC_RTLIB=0 \
-DFMILIB_BUILD_TESTS=1 \
-DFMILIB_TEST_LOCALE=1 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_FLAGS="-m64" -DCMAKE_CXX_FLAGS="-m64" -DCMAKE_SHARED_LINKER_FLAGS="-m64" -DCMAKE_EXE_LINKER_FLAGS="-m64" \
-G "MSYS Makefiles" \
../.
Use linux part only on linux platforms
Should fix #180