handy cmake list macros for inserting items into a list before/after existing items
authorCampbell Barton <ideasman42@gmail.com>
Mon, 16 Jul 2012 08:26:42 +0000 (08:26 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 16 Jul 2012 08:26:42 +0000 (08:26 +0000)
build_files/cmake/macros.cmake

index 3608f41e369e9b751351f0c6c5db95e5d8444a42..bceeb5acc8668d819e9c2e1f9cd5ef14e5a9d593 100644 (file)
 #
 # ***** END GPL LICENSE BLOCK *****
 
+macro(list_insert_after
+       list_id item_check item_add
+       )
+       set(_index)
+       list(FIND ${list_id} "${item_check}" _index)
+       math(EXPR _index "${_index} + 1")
+       list(INSERT ${list_id} "${_index}" ${item_add})
+       unset(_index)
+endmacro()
+
+macro(list_insert_before
+       list_id item_check item_add
+       )
+       set(_index)
+       list(FIND ${list_id} "${item_check}" _index)
+       list(INSERT ${list_id} "${_index}" ${item_add})
+       unset(_index)
+endmacro()
+
 # foo_bar.spam --> foo_barMySuffix.spam
 macro(file_suffix
        file_name_new file_name file_suffix