Skip to content

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

@mvistein

Description

@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
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions