I wanted arguments and you gave one. So no need to excuse for being blunt this is how it should work.
As you need it for a feature, fine with me. I (think I) need to assure that the development process is not stuck because of this. If chennes solution works, fine, also if it turned out not to be feasible, if somebody tells me how to add fmt as library to the LibPack.
So as long as developer on Windows can continue their work without the need to adapt their build system much, it should be fine.
Concerning the release cycle, when people would start to send in patches to use the fmt library to make changes of existing code, I would like to postpone this to after the next major release.
OK â I now have PR 8508 playing nice with the CI, which means that as far as I am aware it compiles on Windows (MSVC - I didnât test MSYS2), Mac OS, Ubuntu 20.04, and Ubuntu 22.04. It should handle lack of internet connectivity as long as your original cMake run after cloning had connectivity. Itâs probably a little too verbose right now, but we can dial that back once we know itâs working.
ETA: This is a pure cMake solution, no libraries need to be manually added anywhere. My understanding of how the cMake feature works is that it will try to use find_package(fmt) first, and only download and compile the fmt library if it cannot find it.
Yes â the reason we havenât been able to do this sort of thing with more of our 3rd-party dependencies is because it requires at least cMake 3.11, which weâve only recently switched to requiring.
Ok, that has been around for a long time. I thought I saw something in your PR about requiring 3.24 or later. That could be a problem. (No doubt I misunderstood the reference to 3.24. )
Checking for connection to GitHub...
GitHub connection established for FetchContent
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.22621.
CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/ExternalProject.cmake:2786 (message):
error: could not find git for clone of fmt-populate
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.24/Modules/ExternalProject.cmake:4167 (_ep_add_download_command)
CMakeLists.txt:23 (ExternalProject_Add)
-- Configuring incomplete, errors occurred!
See also "D:/Applications/FreeCAD-Build/2023-02-16-Build-0.21.31925/Binary/_deps/fmt-subbuild/CMakeFiles/CMakeOutput.log".
CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/FetchContent.cmake:1589 (message):
CMake step for fmt failed: 1
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.24/Modules/FetchContent.cmake:1741:EVAL:2 (__FetchContent_directPopulate)
C:/Program Files/CMake/share/cmake-3.24/Modules/FetchContent.cmake:1741 (cmake_language)
C:/Program Files/CMake/share/cmake-3.24/Modules/FetchContent.cmake:1955 (FetchContent_Populate)
cMake/FreeCAD_Helpers/SetupLibFmt.cmake:29 (FetchContent_MakeAvailable)
CMakeLists.txt:45 (SetupLibFmt)
Configuring incomplete, errors occurred!
See also "D:/Applications/FreeCAD-Build/2023-02-16-Build-0.21.31925/Binary/CMakeFiles/CMakeOutput.log".
Theyâve refined the feature in 3.24 to add additional options controlling the find_package() calls â I mentioned it uptopic in reference to things that package maintainers might be interested in. I donât think those options are of much use to the general developer.
Ah, the plot thickens. It appears cMake doesnât have any sort of fallback if there is no git executable available. So if we go this route, then people who want to compile, but donât want to install git, will indeed have to resort to using vcpkg to install libfmt. (I presume you donât have git installed? Or do you have some other idea of why it wouldnât be able to find git?)
OK, I just pushed a new commit to that PR that switches from using git to using a direct zip download. GeneFC if you have time, could you try that one and see if it works?
We could also actually detect the presence of git, and switch between the two methods: the downside there is that if a person runs cMake without git, and then again with git, they will get an error because cMake will try to use git fetch on the existing (non-git) directory.
Huh. I have no idea there, this shouldnât touch the GUI. Iâm a little out of date with master, I can rebase and push a new copy. Maybe that will fix it.
Might I ask a silly question: is there a way to use QString::arg() instead of libfmt?
Using QString::arg() is an option and we already do that a lot but itâs not always practical to build a QString first when a std::string is needed. Then libfmt is more than fast & easily creating strings, one of its key features is to replace the latent unsafe variadic C functions like sprintf, printf, ⌠with a type safe equivalent function.
Thank you very much Chris. I really appreciate it.
I wanted to note one thing, which may become relevant:
You solution sets POSITION_INDEPENDENT_CODE (see cMake/FreeCAD_Helpers/SetupLibFmt.cmake)
If FreeCAD Library as LGPL is used as a shared library, then this is necessary.
However, the version that comes with the linux package does not have the POSITION_INDEPENDENT_CODE ON. The author claims it is slightly faster without, as there is one less indirection in the calls.
The reason why I say this is that, if FreeCAD is built as a shared library for other code, the outcome will be different when using the local package from ubuntu and when using the cMake solution (and only the cMake solution will work).
I had to turn that on to get FreeCAD to link on the CI systems â if there is some other option we can use instead, or if we want to make that a user-configurable parameter, that would work.