Skip to content

No way to disable cmake options after they've been cached #3586

@stevenengler

Description

@stevenengler

The setup script has flags like --werror, --test, --extra-tests, and --use-perf-timers which enable associated CMake options (SHADOW_TEST, SHADOW_WERROR, etc). The setup script sets these with:

if args.do_test: cmake_cmd.extend(["-D", "SHADOW_TEST=ON"])
if args.do_werror: cmake_cmd.extend(["-D", "SHADOW_WERROR=ON"])
[...]

The problem is that if you don't set these, then CMake will use whatever option is cached from the last build. For example:

$ ./setup build
[...]
-- SHADOW_TEST=OFF
-- SHADOW_WERROR=OFF
-- SHADOW_EXTRA_TESTS=
-- SHADOW_USE_PERF_TIMERS=OFF
$ ./setup build --test --werror
[...]
-- SHADOW_TEST=ON
-- SHADOW_WERROR=ON
-- SHADOW_EXTRA_TESTS=
-- SHADOW_USE_PERF_TIMERS=OFF
$ ./setup build
[...]
-- SHADOW_TEST=ON
-- SHADOW_WERROR=ON
-- SHADOW_EXTRA_TESTS=
-- SHADOW_USE_PERF_TIMERS=OFF

Notice how in the first ./setup build some of the options are "OFF", but in the last ./setup build some of the options are "ON".

I think this is standard CMake behaviour, but I find it unexpected and confusing. Instead, if the ./setup flags aren't specified, I think we should explicitly set them to "OFF". For example with:

if args.do_test:
    cmake_cmd.extend(["-D", "SHADOW_TEST=ON"])
else:
    cmake_cmd.extend(["-D", "SHADOW_TEST=OFF"])

@sporksmith @robgjansen Do either of you depend on the existing behaviour, or have opinions about changing it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: MaintenanceRefactoring, cleanup, documenation, or process improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions