pavelliavonau / cmakeconverter

This project aims to facilitate the conversion of Visual Studio to CMake projects.
GNU Affero General Public License v3.0
858 stars 109 forks source link

Self reference on target errors #112

Closed EdTheC closed 4 years ago

EdTheC commented 4 years ago

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] $<TARGET_GENEX_EVAL:CreateDB,$<TARGET_PROPERTY:CreateDB,TARGETNAME$<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!

pavelliavonau commented 4 years ago

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

EdTheC commented 4 years ago

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.

pavelliavonau commented 4 years ago

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 3 years ago

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