CMake with Ninja generator deleting output libraries when symlinking
When attempting to build VTK with CMake 3.10.0 and the Ninja generator (part of an Emscripten cross-compilation attempt, should it matter), the resulting build.ninja
contains the following snippet:
#############################################
# Create library symlink lib\libvtkglew-7.1.so
build lib/libvtkglew-7.1.so: CMAKE_SYMLINK_LIBRARY lib/libvtkglew-7.1.so.1
POST_BUILD = cd .
SONAME = lib\libvtkglew-7.1.so.1
This translates to the command:
[2/2] cmd.exe /C ""C:\Program Files\CMake\bin\cmake.exe" -E cmake_symlink_library lib/libvtkglew-7.1.so.1 lib\libvtkglew-7.1.so.1 lib/libvtkglew-7.1.so && cd ."
The implementation of the cmake_symlink_library
command does a purely textual comparison between the arguments to determine if a symlink should happen or if it is a no-op. This comparison between the first and second argument fails because of the backslash/forward slash inconsistency - even though they are the same file. On windows, this results in the library being deleted to "make room" for the new copy.