[CMake] How to append a string on list inside a function
cmake.org › pipermail › cmakeSep 27, 2018 · So, by adding a set command using PARENT_SCOPE in your function you canupdate the variable in the parent scope: function(addTest targetName) # create the executable with all the souces add_executable(${targetName} ${ARGN}) list(APPEND allTestsList ${targetName}) *set (allTestsList ${allTestsList} PARENT_SCOPE) * message("inside addTestFunction. allTestsList: "${allTestsList}) endfunction()Le jeu.
list — CMake 3.23.0-rc4 Documentation
https://cmake.org/cmake/help/latest/command/list.htmlIntroduction ¶. The list subcommands APPEND, INSERT, FILTER, PREPEND , POP_BACK, POP_FRONT, REMOVE_AT, REMOVE_ITEM , REMOVE_DUPLICATES, REVERSE and SORT may create new values for the list within the current CMake variable scope. Similar to the set () command, the LIST command creates new variable values in the current scope, even if the list ...
list — CMake 3.23.0-rc4 Documentation
cmake.org › cmake › helpA list in cmake is a ; separated group of strings. To create a list the set command can be used. For example, set (var a b c d e) creates a list with a;b;c;d;e, and set (var "a b c d e") creates a string or a list with one item in it. (Note macro arguments are not variables, and therefore cannot be used in LIST commands.)
Cmake命令之list介绍 - 简书
www.jianshu.com › p › 89fb01752d6f# CMakeLists.txt cmake_minimum_required (VERSION 3.12.2) project (list_cmd_test) set (list_test a b c d) message (">>> TRANSFORM-list: ${list_test}") list (TRANSFORM list_test APPEND Q AT 1 2 OUTPUT_VARIABLE list_test_out) list (TRANSFORM list_test APPEND Q AT 1 2) message (">>> TRANSFORM-AT: ${list_test} --- ${list_test_out}")