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

Suggested structure for library creation not compatible with unit testing #372

Open
mattbaker-digital opened this issue Jan 30, 2025 · 0 comments

Comments

@mattbaker-digital
Copy link
Contributor

mattbaker-digital commented Jan 30, 2025

librarymanager/creating.rstsuggests placing library related source code in the src directory. In the example, HelloWorld.cpp would typically contain definitions for forward declarations in HelloWorld.h. If you attempt to run unit tests on any of the definitions in the separate source file, it will fail with linker errors (undefined reference to ... because files in the src directory are not compiled when running unit tests by default.

To overcome this issue, you would have to enable test_build_src which, according to advanced/unit-testing/structure/shared-code.rst, is not recommended.

It would seem that a better option is to place the files in the lib directory inside a module specific directory:

    ├── examples
    │   └── echo
    ├── lib
    │   └── HelloWorld
    │       ├── HelloWorld.h
    │       └── HelloWorld.cpp
    ├── library.json
    ├── src
    │   └── main.cpp
    └── test
        └── test_hello_world.cpp

Based on limited testing, the HelloWorld files must be in a sub-directory of lib, otherwise they wont be found by the Library Dependency Finder.

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