Skip to content

Conversation

@TheBill2001
Copy link
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
Copy link
Owner

Sapd commented Jan 10, 2026

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
@TheBill2001 TheBill2001 force-pushed the top-level-project-guard branch from 5f21667 to a72a782 Compare January 10, 2026 12:11
@TheBill2001
Copy link
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

@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