Question about list ordering

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Question about list ordering

Steven Truppe
Hello everyone,

i'm relative new to CMake and i need a function that does change the
order of a list. So for example when i have a list like

set(LIBS_TO_BUILD "BOOST;EIGEN;PYTHON;GLUT;GLFW;NLOHMANNJSON")

i need a function to swap places like

listSwapString("GLUT", "GLFW", ${LIBS_TO_BUILD}).


The base code for the function look like this, but i don't even know how
to get the index of a string inside of a list or how to insert a string
at a certain position and move the other strings to the back.

function(bsListInsertBefore)
     set(options)
     set(oneValueArgs SEARCH INSERT RESULT)
     set(multiValueArgs LIST)
     cmake_parse_arguments(var
         "${options}"
         "${oneValueArgs}"
         "${multiValueArgs}"
         "${ARGN}"
     )
endfunction()


I hope i can count on you, for me as a CMake newbie this is a great
task, i stil have a bit of a problem with the syntax.


best regards,

Steven Truppe

--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org
Reply | Threaded
Open this post in threaded view
|

Re: Question about list ordering

Eric Doenges

The list command is what you want. Specifically, list(GET ...) will return the index of a string in the list, and list(INSERT ...) and list(REMOVE_ITEM ...) or list(REMOVE_AT ...) to insert and remove items.

Am 13.11.19 um 00:56 schrieb Unnamed User:
Hello everyone,

i'm relative new to CMake and i need a function that does change the
order of a list. So for example when i have a list like

set(LIBS_TO_BUILD "BOOST;EIGEN;PYTHON;GLUT;GLFW;NLOHMANNJSON")

i need a function to swap places like

listSwapString("GLUT", "GLFW", ${LIBS_TO_BUILD}).


The base code for the function look like this, but i don't even know how
to get the index of a string inside of a list or how to insert a string
at a certain position and move the other strings to the back.

function(bsListInsertBefore)
    set(options)
    set(oneValueArgs SEARCH INSERT RESULT)
    set(multiValueArgs LIST)
    cmake_parse_arguments(var
        "${options}"
        "${oneValueArgs}"
        "${multiValueArgs}"
        "${ARGN}"
    )
endfunction()


I hope i can count on you, for me as a CMake newbie this is a great
task, i stil have a bit of a problem with the syntax.


best regards,

Steven Truppe

--

Dr. Eric Dönges
Senior Software Engineer

MVTec Software GmbH | Arnulfstr. 205 | 80634 Munich | Germany
[hidden email] | Tel: +49 89 457 695-0 | www.mvtec.com

Find our privacy policy here.

 Sign up for our MVTec Newsletter!

Geschäftsführer: Dr. Wolfgang Eckstein, Dr. Olaf Munkelt
Amtsgericht München HRB 114695

 

MVTec Software GmbH Logo

--

Powered by kitware.com/cmake

Kitware offers various services to support the CMake community. For more information on each offering, please visit https://cmake.org/services

Visit other Kitware open-source projects at https://www.kitware.com/platforms

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

This mailing list is deprecated in favor of https://discourse.cmake.org