Skip to content

Add top level project guard - #456

Merged
Sapd merged 2 commits into
Sapd:masterfrom
billtran1632001:top-level-project-guard
Jan 11, 2026
Merged

Sapd merged 2 commits into
Sapd:masterfrom
billtran1632001:top-level-project-guard

Conversation

@billtran1632001

Copy link
Copy Markdown
Contributor

Since the recommended way to use the headsetcontrol library is as a subdirectory. Some configuring steps should be disabled. This PR adds a top level project guard to disable some configuring steps that are unnecessary when using as a subdirectory or with FetchContent.

This leverages PROJECT_IS_TOP_LEVEL variable, which is available since CMake's 3.21. With older version, we fall back to check whether CMAKE_SOURCE_DIR is equal to PROJECT_SOURCE_DIR.

Potential problem: In this patch I also put the build CLI executable step and generating udev rules step behind the guard. Should generating udev contents also be available through API and let the library consumers handle it themselves? Or the generating udev rules step should not be put behind the guard?

@Sapd

Sapd commented Jan 10, 2026

Copy link
Copy Markdown
Owner

I think the logic is inverted if I see it right.

Currently with this changes:

  • Building HeadsetControl standalone -> CLI, tests, install, CPack are disabled
  • Using as subdirectory → CLI, tests, install, CPack are enabled

So the NOTs have to be removed. Or does it have a specific reason it's this way?

In this patch I also put the build CLI executable step and generating udev rules step behind the guard. Should generating udev contents also be available through API and let the library consumers handle it themselves? Or the generating udev rules step should not be put behind the guard?

I think it can be as-is for now. We can also later in theory add it into the library

Add top level project guard to disable some configuring steps that are unnecessary when using as a subdirectory/fetch_content
@billtran1632001

Copy link
Copy Markdown
Contributor Author

I think the logic is inverted if I see it right.

You're right! Should have not written anything while lacking sleep. 😅

On MSVC, it requires getopt from vcpkg
@sonarqubecloud

Copy link
Copy Markdown

@Sapd
Sapd merged commit 620e69f into Sapd:master Jan 11, 2026
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants