Dependencies between different-cased targets break on macOS/Windows with Makefiles
Consider the following example.
cmake_minimum_required(VERSION 3.16)
project(QTBUG-84342)
# Create a library target named 'FancyLib'
file(WRITE "${CMAKE_BINARY_DIR}/fancylib.cpp" "int some_func() { return 123; }")
add_library(FancyLib SHARED "${CMAKE_BINARY_DIR}/fancylib.cpp")
# Add a custom target 'fancylib' that just depends on 'FancyLib'
add_custom_target(fancylib)
add_dependencies(fancylib FancyLib)
This breaks on case-insensitive file systems like we have on macOS or Windows with this error message:
make[2]: *** No rule to make target `CMakeFiles/FancyLib.dir/depend'. Stop.
make[1]: *** [CMakeFiles/FancyLib.dir/all] Error 2
make: *** [all] Error 2
With ninja on macOS, the project is properly built, and I can run both, ninja FancyLib
and ninja fancylib
successfully.
On Windows, the project breaks with the "MinGW Makefiles" and "NMake Makefiles" generators. Ninja works fine.
On Linux, the project is properly built with both, the Ninja and the Makefile generator.
Edited by Jörg Bornemann