Strange target dependency on custom target when using file extension .cpp as part of target name
When having a project setup like with CMakeLists.txt
cmake_minimum_required(VERSION 3.8)
project(myproject)
add_library(${PROJECT_NAME} a.cpp)
include(addon.txt)
add_custom_target(Ext.${PROJECT_NAME} COMMAND ${CMAKE_COMMAND} -E echo "HELLO_WORLD" DEPENDS ${PROJECT_NAME})
and addon.txt
add_custom_target(${PROJECT_NAME}.cpp)
add_custom_target(Ext.${PROJECT_NAME}.cpp COMMAND ${CMAKE_COMMAND} -E echo "HELLO_WORLD" DEPENDS ${PROJECT_NAME}.cpp)
Then the Ext.myproject
target is having the following target references in the build.ninja file:
build Ext.myproject: phony CMakeFiles/Ext.myproject.cpp myproject.cpp
instead of
build Ext.myproject: phony CMakeFiles/Ext.myproject libmyproject.a
Moving the include(addon.txt)
to after the custom target definition or prefixing the target name in the addon.txt results in the correct build.ninja file. But the question is why the above scenario is not working correctly?
Edited by MvdHurk