cmake creates Windows binary with UNIX like SOVERSION
Under openSUSE/Leap 15.4 I cross-compiled a small C++ application for Windows and found that it is not executable like this after a transfer to a Windows system, because it takes care of the SOVERSION target property in a unix-like way by appending the version to the executable name, e.g. app.exe-<version>
and creates a symlink to this file with a name without version.
When creating a Windows application, using app-<version>.exe
would be better here as the symlink is not usable on Windows and the binary has an incompatible extension.
How to reproduce:
sudo zypper ar http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Leap_15.4/windows%3Amingw%3Awin32.repo
sudo zypper install mingw32-cross-gcc-c++ cmake p7zip-full
cmake --version
cmake version 3.25.0
mkdir ~/test
cd test
wget https://gitlab.kitware.com/cmake/cmake/uploads/4db4dafd4dde76017c3ec9fb36ff9584/cmake-test.7z
7za x cmake-test.7z
cmake -DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX:PATH=/usr/i686-w64-mingw32/sys-root/mingw \
-DCMAKE_INSTALL_LIBDIR:PATH=/usr/i686-w64-mingw32/sys-root/mingw/lib \
-DBIN_INSTALL_DIR=/usr/i686-w64-mingw32/sys-root/mingw/bin \
-DINCLUDE_INSTALL_DIR:PATH=/usr/i686-w64-mingw32/sys-root/mingw/include \
-DLIB_INSTALL_DIR:PATH=/usr/i686-w64-mingw32/sys-root/mingw/lib \
-DSHARE_INSTALL_DIR:PATH=/usr/i686-w64-mingw32/sys-root/mingw/share \
-DSYSCONF_INSTALL_DIR:PATH=/usr/i686-w64-mingw32/sys-root/mingw/etc \
-DSHARE_INSTALL_PREFIX:PATH=/usr/i686-w64-mingw32/sys-root/mingw/share \
-DBUILD_SHARED_LIBS:BOOL=ON
-DCMAKE_C_COMPILER=/usr/bin/i686-w64-mingw32-gcc \
-DCMAKE_CXX_COMPILER=/usr/bin/i686-w64-mingw32-g++ \
-DCMAKE_RC_COMPILER=/usr/bin/i686-w64-mingw32-windres \
-DCMAKE_FIND_ROOT_PATH=/usr/i686-w64-mingw32/sys-root/mingw \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
-B build-test/ \
.
cmake --build build-test
ls -l build-test
lrwxrwxrwx 1 users users 20 9. Jan 16:51 exampleapp.exe -> exampleapp.exe-3.1.1
-rwxr-xr-x 1 users users 107722 9. Jan 16:51 exampleapp.exe-3.1.1
Edited by rhabacker