How to just pass version number to the linker without creating unnecessary symbolic links
I am cross compiling for windows using mingw, but this is actually not that specific.
If I set version as intended:
project(... VERSION "8.18")
...
add_executable(main main.cpp)
set_target_properties(main PROPERTIES VERSION ${PROJECT_VERSION})
it passes it to the compiler through the -o main.exe-8.18
option and creates unnecessary symbolic link main.exe -> main.exe-8.18
.
I can't set version manually like this:
target_link_options(main PRIVATE "-Wl,--major-image-version=${PROJECT_VERSION_MAJOR},--minor-image-version=${PROJECT_VERSION_MINOR}")
because cmake always adds these flags (defined as CMAKE_GNULD_IMAGE_VERSION
in the Windows-GNU.cmake) to the very end of the linker command and overwriting my manually set ones:
-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>
I want to do this before the install stage and with least lines in the config. Why is it so difficult to get rid of this version suffixed links or/and CMAKE_GNULD_IMAGE_VERSION
flags? I just want to put my version number in the ImageVersion field of the PE executable. Am I asking for too much?