pavelliavonau/cmakeconverter

Self reference on target errors

EdTheC opened this issue · 4 comments

After running the conversion, I am having trouble with all of my projects. Here's an example:
1> [CMake] CMake Error:
1> [CMake] Error evaluating generator expression:
1> [CMake]
1> [CMake] $&lt;TARGET_GENEX_EVAL:CreateDB,$&lt;TARGET_PROPERTY:CreateDB,TARGET_NAME_$<UPPER_CASE:$>>>
1> [CMake]
1> [CMake] Self reference on target "CreateDB".

The corresponding lines in the cmakelists file is:
set_target_properties(${PROJECT_NAME} PROPERTIES
TARGET_NAME_DBGRMT "CreateDB"
TARGET_NAME_DEBUG "CreateDB"
TARGET_NAME_RELEASE "${TARGET_NAME}$ENV{TargetExt}"
TARGET_NAME_RELNOOPT "${TARGET_NAME}$ENV{TargetExt}"
TARGET_NAME_TEMPLATE "${TARGET_NAME}$ENV{TargetExt}"
)

To Reproduce
Just open cmakelists in Visual Studio 2019.

This is the whole cmake file:
CMakeLists.txt

Any help appreciated on this, I'm stuck!

Have you checked already known issues before creating this?
There are only 9.

I tried, but I came up with #57 which appears that it is a bug that is not fixed. I was hoping for a simple solution besides waiting. I was able to guess the solution, and for someone who might stumble across this, simply add
set(TARGET_NAME CreateDB)
into the named cmakelists file for each type of this error. In my case it was TARGET_NAME for my CreateDB project.
But its not clear why this was wrong, it was listed as $(ProjectName) in the vstudio properties.

Possible solution might be replaceing:
TARGET_NAME_RELEASE "${TARGET_NAME}$ENV{TargetExt}"
with
TARGET_NAME_RELEASE "targetName.exe"

it's hard to resolve this variables at CMake like VS does.

bigla commented

I resolved it by putting ${PROJECT_NAME} instead of ${TARGET_NAME}, but I cannot say for sure whether this might help in your constellation.