Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #11103
Closed
Open
Issue created Dec 13, 2021 by Administrator@rootContributor

[BUG][cpp-restsdk] include folder structure in installed client does not match build folder structure

Created by: mvistein

Description

The new cmake installation feature introduced in #10660 provides a very nice feature to install the generated client into the system and increases usability. However, the folder structure of the installed client doest not match the stucture of the generated source, so including is tricky.

All tests have been performed under Windows, so Unix enivonments may behave differently.

openapi-generator version

Current master branch

OpenAPI declaration file content or url

n/a

Generation Details

An example client is generated, named TestClient.

Using the cmake install command and having defined CMAKE_INSTALL_PREFIX, the following folder structure is created:

  • CMAKE_INSTALL_PREFIX
    • lib
      • ...
    • include
      • TestClient
        • api
          • ...
        • model
          • ...
      • ApiClient.h
      • ...

When using the generated and installed client in an application, it can be included using

target_link_libraries(testproject TestClient)

which correctly links the library, but also add the folder CMAKE_INSTALL_PREFIX/include to the include path. So relevant headers can be included in code by using #include <TestClient/ApiClient.h> etc. The installed headers internally however do not know about the TestClient subfolder and thus fail to compile.

Related issues/PRs
  • #10660
Suggest a fix

The quick&dirty solution is to add the CMAKE_INSTALL_PREFIX/include/TestClient folder to the include folder. This however has one mayor drawback: The include path is "polluted", i.e. no second OpenAPI client can be used due to collisions with ApiClient.h, Object.h etc.

My suggesion is to change the generator to create the TestClient folder already in the generated source folder and use "absolute" paths throughout the generated code, including the TestClient portion.

I think I could try to create a pull request for this, however I would like to get the opinion of other developers whether this approach is desirable.

Assignee
Assign to
Time tracking