Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not defined, but used $(TargetName) in foobar.vcxproj leads to TARGET_NAME_(DEBUG|RELEASE) "...${TARGET_NAME}..." ... To break cyclic dependency CMake error use ${PROJECT_NAME} #97

Open
bigla opened this issue Feb 11, 2020 · 0 comments

Comments

@bigla
Copy link

bigla commented Feb 11, 2020

TL;DR:
I recommend using ${PROJECT_NAME} instead of ${TARGET_NAME} for the TARGET_NAME_(DEBUG|RELEASE) property if $(TargetName) is not defined within the .vcxproj file being converted.

The fully functional (tested with Visual Studio 2015) vcxproj/sln I am working on, contains the following lines [the definition of $(TargetName) is missing from the start (our fault) ]:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  ...
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
  ...
    <Link>
      ...
      <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
      ...

Which is converted to the following lines using the most current version of cmake-converter on the develop branch:

    set_target_properties(${PROJECT_NAME} PROPERTIES
        TARGET_NAME_DEBUG   "$ENV{correctVarA}${TARGET_NAME}$ENV{correctVarB}"
        TARGET_NAME_RELEASE "$ENV{correctVarA}${TARGET_NAME}$ENV{correctVarB}"
    )

This in turn leads to

CMake Error at foobar/CMakeLists.txt:31 (add_executable):
Target 'foobar' OUTPUT_NAME depends on itself.

Suggested fix: Instead of converting an undefined $(TargetName) to ${TARGET_NAME} one might use ${PROJECT_NAME} instead (Which is a working guess that leads to no errors).

I am not too sure if it is a good Idea to "think for the user" but since it works on VisStudio, I think it should work after conversion for cmake too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant