* Mathieu Malaterre <[email protected]> [2022-11-29 16:06]:
% cat CMakeLists.txt
cmake_minimum_required(VERSION 3.12.1 FATAL_ERROR)
project(p)

add_library(foo foo.cpp)

set(defs "-D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS")
target_compile_definitions(foo PRIVATE ${defs})

This does not work the way you expect. List items are separated by
semicolon (not whitespace) when stored in a variable [1].

For example,

    set(args "a b c")
    foo(a b c)
    bar(${args})

will call foo() with three arguments "a", "b", "c", but bar() with
one argument "a b c".

If you want ${args} to be treated as a list, you either need to
replace spaces by semicolons,

set(args "a;b;c")

or let set() implicitly concatenate multiple value arguments into a
single list:

set(args "a" "b" "c")
set(args a b c)


Cheers
Timo


[1] https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#lists

--
⢀⣴⠾⠻⢶⣦⠀   ╭────────────────────────────────────────────────────╮
⣾⠁⢠⠒⠀⣿⡁   │ Timo Röhling                                       │
⢿⡄⠘⠷⠚⠋⠀   │ 9B03 EBB9 8300 DF97 C2B1  23BF CC8C 6BDD 1403 F4CA │
⠈⠳⣄⠀⠀⠀⠀   ╰────────────────────────────────────────────────────╯

Attachment: signature.asc
Description: PGP signature

Reply via email to