[Pkg-cmake-team] Bug#1025058: sample

Timo Röhling roehling at debian.org
Tue Nov 29 15:50:12 GMT 2022


* Mathieu Malaterre <mathieu.malaterre at gmail.com> [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 │
⠈⠳⣄⠀⠀⠀⠀   ╰────────────────────────────────────────────────────╯
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-cmake-team/attachments/20221129/a6fb4749/attachment.sig>


More information about the Pkg-cmake-team mailing list