[CMake] Question about list ordering

Unnamed User workbench at gmx.at
Tue Nov 12 18:56:20 EST 2019


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



More information about the CMake mailing list