I was developing a project of mine on Ubuntu 22, with:
$ cmake --version | head -1
cmake version 3.22.1
I noticed there, that there is a link.txt for both of my executables from the project, as well as for many other libraries; from the project’s build folder there, I can count:
build$ find . -name link.txt | wc -l
21
… 21 such link.txt files, after project is fully built.
So, I made a CMake custom command that utilizes this link.txt file (changes few parameters, and repeats linking in POST_BUILD step) and all was good and worked fine. Unfortunately, not for long.
Then I moved the project to Windows 10, MINGW64 shell - and suddenly the above custom command started failing; there I use:
$ /c/Program\ Files/CMake/bin/cmake.exe --version | head -1
cmake version 3.17.5
Looking further, I realized that there are no link.txt generated for my executables, however, there are link.txt for some supporting libraries; there, from the build folder, I can count:
$ find . -name link.txt | wc -l
10
… 10 link.txt files, after project is fully built - a lot fewer than 21 link.txt files for the exact same project building on Ubuntu with cmake 3.22.1
So, what is going on here, why the discrepancy? And how can I persuade CMake 3.17.5 on Windows 10 (or possibly other 3.1x versions) to also output all these link.txt files, especially for my executable, as CMake 3.22.1 on Ubuntu 22 does?
EDIT:
Some more stuff that I found:
link.txt
files seem to be generated by thecmake ../
call- I’ve installed CMake 3.22.1 also on Windows, and no difference in respect to
link.txt
behavior - so the CMake version is not a problem, there is some intrinsic difference between Linux (Unix Makefile) and Windows (MSYS Makefile) setups, I guess - In Windows, in
build/CMakeFiles/${PROJECT_NAME}.dir/
there is only abuild.make
, which has no mentions oflink.txt
, but has the complete linker command line. In Ubuntu, inbuild/CMakeFiles/${PROJECT_NAME}.dir/
there are bothlink.txt
(with the complete linker command line) andbuild.make
(which contains references tolink.txt
, but no complete linker command line).
Why cannot software ever be consistent, for crying out loud?