Petr - using:
set(OPT1 ON CACHE BOOL "Set to OFF|ON (default is OFF) to control build
of Bar library" FORCE)
works like a champ!
Jakob - Thanks for the suggestion, but I can't put "add_subdirectory(Bar)"
before setting the variable(s) in Foo's CMakeLists.txt, because cmake
finishes
Ah, nice. Good to know. But then still that cache variable is not created
until *after* it was set by Foo, because it is only created when adding the
Bar subdirectory, which explains the output.
Sincerely,
Jakob
On Fri, May 20, 2016 at 1:18 PM, Petr Kmoch wrote:
> The
The situation already involves a cache variable, though: `option(abc "cmt"
ON)` is just syntactic sugar for `set(abc ON CACHE BOOL "cmt")`.
Petr
On 20 May 2016 at 13:03, Jakob van Bethlehem
wrote:
> You don't have to create a cache variable for this. Put yourself in
You don't have to create a cache variable for this. Put yourself in the
position of CMake;
* While scanning the CMakeLists.txt of Foo CMake encounters the set(OPT1 ON
FORCE) command, which tells CMake to create a *variable* called OPT1 with
value ON
* Then CMake is asked to include Bar
* While
Hi Petr,
Thank you so much. I'll try it when I get in to work this morning.
Doug
On Fri, May 20, 2016 at 5:37 AM, Petr Kmoch wrote:
> Hi Doug,
>
> your syntax for `set()` in Foo is incorrect; you're actually setting a
> non-cache variable OPT1 do the value "ON;FORCE".
>
>
Hi Doug,
your syntax for `set()` in Foo is incorrect; you're actually setting a
non-cache variable OPT1 do the value "ON;FORCE".
You want to set the *cache* variable OPT1, which would be done like this:
set(OPT1 ON CACHE BOOL "Set to OFF|ON (default is OFF) to control build
of Bar library"
CMake (version 3.5.2) surprised me with how it's passing values to
sub-projects, so I was wondering if this is expected behavior. Here's an
example of what I mean. Let's say I have a project Foo in a directory of
the same name. It contains a third-party library called Bar which has a