Skip to content

CMake projects created with special characters generate uncompilable example #288

@jonahgraham

Description

@jonahgraham

Describe the bug

Using any characters that are not legal for C identifiers in the project names causes compiler errors (except (space) which is handled already).

To Reproduce
Steps to reproduce the behavior:

  1. Create a new C/C++ Project
  2. Choose CMake project (the small Hello World example)
  3. Create a project name with - (dashes) in it
  4. Attempt to build project

For example, call the project example-cmake-project and observe that the config.h.in is invalid C code:

#define example-cmake-project_VERSION_MAJOR @example-cmake-project_VERSION_MAJOR@
#define example-cmake-project_VERSION_MINOR @example-cmake-project_VERSION_MINOR@

PR #105 introduced the config.h.in file and it does have special handling for spaces, but needs it for other characters too:

#define ${projectName?replace(" ", "_")}_VERSION_MAJOR @${projectName?replace(" ", "_")}_VERSION_MAJOR@
#define ${projectName?replace(" ", "_")}_VERSION_MINOR @${projectName?replace(" ", "_")}_VERSION_MINOR@

cc: @mbooth101

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildBuild components of CDT, anything to do with running the compiler, using Make, CMake, or any builder

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions