From d89f397b16f6bbcf029d320e1a1ae2453ce02238 Mon Sep 17 00:00:00 2001 From: Mahder Gebremedhin Date: Tue, 18 Jul 2023 14:28:56 +0200 Subject: [PATCH] Update libxml2 to version 2.11.4. (#1216) * Update libxml2 to version 2.11.4. - This version comes with CMake support and many other fixes and improvements. - It is taken from https://github.com/GNOME/libxml2 - The folders: `doc`, `fuzz`, `m4`, `result`, and `test` are removed to save space since they are not needed. - The required CMake version has been downgraded from 3.18 to 3.15. Ubuntu focal, one of our supported platforms, comes with CMake 3.16 so that is the maximum CMake version we can require right now. The libxml required CMake version was upgraded by https://github.com/GNOME/libxml2/commit/a5bc4605838335dd6bee9374fcb6b4718b2f5a5a in order to use `check_linker_flag` CMake utility function. We do not need that so it is removed and the CMake version is downgraded. - The CMake support allows OMSimulator to move one step closer to complete CMake based build. * Disable iconv for MSVC builds. * Do not add 's' postfix for the static lib. - We are intersted in building only the static library. No shared version. That means there is not going to be any name conflict. So just output the library without any posfix (just libxml2.lib instead of libxml2s.lib). This saves us from having to updated the expected library name in other places. - Debug builds still get the 'd' postfix for now. Perhaps this should be removed as well. * Define LIBXML_STATIC since we are using the static libxml - This will tell libxml2 headers not to add dll direction specifiers (`__declspec(dllimport)` and `__declspec(dllexport)`) * Compile OMTLMSimulator libs with /MD if using MSVC. - This seems to be what is picked by default by cmake. OMTLMSimulator does not need or use CMake right now, however it links to libraries built by CMake (within OMSimulator, e.g., libxml2) which get compiled with /MD. So set it here as well to avoid link time failures. * Libxml2 is no longer needed to be installed after build. - It is built as a static library now even on Windows with MSVC. * Update 3rdParty and OMTLMSimulator to merged versions. --- 3rdParty | 2 +- Makefile | 12 +++++++----- OMTLMSimulator | 2 +- configWinVS.bat | 15 +++++++++------ src/OMSimulatorPython/CMakeLists.txt | 1 - 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/3rdParty b/3rdParty index e2436862f..a38348b91 160000 --- a/3rdParty +++ b/3rdParty @@ -1 +1 @@ -Subproject commit e2436862f5fa8f3f95c9153c904f63a6243cfdc5 +Subproject commit a38348b911f5fd7e26b5d4fe4f7c5b3a75121884 diff --git a/Makefile b/Makefile index d2dcab165..ec790f981 100644 --- a/Makefile +++ b/Makefile @@ -284,14 +284,14 @@ config-libxml2: @echo else config-libxml2: 3rdParty/libxml2/$(INSTALL_DIR)/lib/libxml2.a -3rdParty/libxml2/$(INSTALL_DIR)/lib/libxml2.a: 3rdParty/libxml2/Makefile - $(MAKE) -C 3rdParty/libxml2/ && $(MAKE) -C 3rdParty/libxml2/ install -3rdParty/libxml2/Makefile: +3rdParty/libxml2/$(INSTALL_DIR)/lib/libxml2.a: 3rdParty/libxml2/$(BUILD_DIR)/Makefile + $(MAKE) -C 3rdParty/libxml2/$(BUILD_DIR)/ install +3rdParty/libxml2/$(BUILD_DIR)/Makefile: 3rdParty/libxml2/CMakeLists.txt @echo @echo "# config libxml2" @echo - $(MKDIR) 3rdParty/libxml2/$(INSTALL_DIR) - cd 3rdParty/libxml2 && $(FPIC) ./autogen.sh --prefix="$(ROOT_DIR)/3rdParty/libxml2/$(INSTALL_DIR)" $(DISABLE_SHARED) --without-python --without-zlib --without-lzma $(HOST_CROSS_TRIPLE) + $(MKDIR) 3rdParty/libxml2/$(BUILD_DIR) + cd 3rdParty/libxml2/$(BUILD_DIR) && $(CMAKE) $(CMAKE_TARGET) ../.. -DCMAKE_INSTALL_PREFIX=../../$(INSTALL_DIR) -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_ZLIB=OFF -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_TESTS=OFF endif distclean: @@ -309,6 +309,8 @@ distclean: $(RM) 3rdParty/kinsol/$(INSTALL_DIR) $(RM) 3rdParty/xerces/$(BUILD_DIR) $(RM) 3rdParty/xerces/$(INSTALL_DIR) + $(RM) 3rdParty/libxml2/$(BUILD_DIR) + $(RM) 3rdParty/libxml2/$(INSTALL_DIR) testsuite: @echo diff --git a/OMTLMSimulator b/OMTLMSimulator index 4c19c9a61..e0693c463 160000 --- a/OMTLMSimulator +++ b/OMTLMSimulator @@ -1 +1 @@ -Subproject commit 4c19c9a61d9ba117ec1b9a9dc88c78ca0ad11a4d +Subproject commit e0693c46327b47c94ad5ce8294fad7ef1463b5cd diff --git a/configWinVS.bat b/configWinVS.bat index e3a5a5808..1ecbc283b 100644 --- a/configWinVS.bat +++ b/configWinVS.bat @@ -220,13 +220,16 @@ EXIT /B 0 :: -- config libxml2 ------------------ :libxml2 ECHO # config libxml2 -CD 3rdParty\libxml2 -START /B /WAIT CMD /C "buildWinVS.bat %OMS_VS_TARGET%" +IF EXIST "3rdParty\libxml2\build\win\" RMDIR /S /Q 3rdParty\libxml2\build\win +IF EXIST "3rdParty\libxml2\install\win\" RMDIR /S /Q 3rdParty\libxml2\install\win +MKDIR 3rdParty\libxml2\build\win +CD 3rdParty\libxml2\build\win +cmake.exe -G %OMS_VS_VERSION% ..\.. -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_INSTALL_PREFIX=..\..\install\win -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_PYTHON=OFF -DLIBXML2_WITH_ZLIB=OFF -DLIBXML2_WITH_LZMA=OFF -DLIBXML2_WITH_TESTS=OFF -DLIBXML2_WITH_ICONV=OFF +IF NOT ["%ERRORLEVEL%"]==["0"] GOTO fail +CD ..\..\..\.. +ECHO # build libxml2 +msbuild.exe "3rdParty\libxml2\build\win\INSTALL.vcxproj" /t:Build /p:configuration=Release /maxcpucount IF NOT ["%ERRORLEVEL%"]==["0"] GOTO fail -CD ..\.. -ECHO # copy libxml2 -IF NOT EXIST "install\win\bin" MKDIR install\win\bin -XCOPY /Y /F 3rdParty\libxml2\install\win\bin\libxml2.dll install\win\bin EXIT /B 0 :: -- config libxml2 ------------------ diff --git a/src/OMSimulatorPython/CMakeLists.txt b/src/OMSimulatorPython/CMakeLists.txt index 385b70100..1d9418866 100644 --- a/src/OMSimulatorPython/CMakeLists.txt +++ b/src/OMSimulatorPython/CMakeLists.txt @@ -28,7 +28,6 @@ IF (WIN32 AND MSVC) install(DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin/ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/OMSimulator FILES_MATCHING PATTERN "*imulator*.dll" PATTERN "OMSimulator" EXCLUDE PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ) install(DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin/ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/OMSimulator FILES_MATCHING PATTERN "*boost*mt-1*.dll" PATTERN "OMSimulator" EXCLUDE PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ) install(FILES ${CMAKE_INSTALL_PREFIX}/bin/pthreadVC2.dll DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/OMSimulator PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ) - install(FILES ${CMAKE_INSTALL_PREFIX}/bin/libxml2.dll DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/OMSimulator PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ) ELSEIF (WIN32 AND MINGW) install(FILES OMSimulatorPython3.bat DESTINATION ${CMAKE_INSTALL_PREFIX}/bin PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ) install(FILES OMSimulatorPython3 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ)