aminya / aminya/project_options

dynamic_project_options:

Open
#239 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
CMake
Stars
373
Forks
54
Avg merge
2h 59m
Merged PRs (30d)
8

Description

Either something is fundamentally broken with dynamic_project_options or I'm sorely misunderstanding how to use it.

My understanding of the intent is as follows:

  • Create an option called OPT_${option_name} that is configurable afterward running CMake (e.g. through ccmake).
  • Use the option named OPT_${option_name} if it is specified (usually through the cmake command line).
  • Else pick either the developer or user value for that value, which is determined based on whether ENABLE_DEVELOPER_MODE is toggled.

What am I seeing in the error?

This is the sample CMake file I used, which is just a slightly modified version of the example one in the dynamic project options file.

CMakeLists.txt

If I invoke it like this:

cmake -S . -B ./build -G Ninja -DOPT_GCC_WARNINGS="-Wdouble-conversion"

I'd expect there to be an option called OPT_GCC_WARNINGS with that given value (and a user default of "-WBaz" based on the lack of developer options being enabled).

If I invoke it without the OPT_GCC_WARNINGS on the command line, I would expect there to be no option available (based on the cmake_dependent_option use in DynamicProjectOptions), but that a hidden one be populated with the value "-WBaz". Instead, I find an option called OPT_GCC_WARNINGS that has the value OFF.

I suspect that either I misunderstand how to use this tool properly, or that this worked at one point but some subtle CMake variable creation behavior changed recently and broke it (and maybe I'm the only one to use this dynamic macro?).

I'm happy to help test this out further. I was hoping to just submit a PR, but I'm really stuck on this so I don't have a solution yet.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached CMakeLists.txt and reproduce both commands using the dynamic_project_options or DynamicProjectOptions entry point. Inspect its use of cmake_dependent_option and compare the command-line OPT_GCC_WARNINGS case with the default case. Done means the option and hidden default behave as described for developer mode disabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.