There are 4 libs linked already and want to link a new library if FLAG is ON.
target_link_libraries (lib1 lib2 lib3 lib4 ${CMAKE_DL_LIBS})
I want it to be something like
target_link_libraries (lib1 lib2 lib3 lib4 if(FLAG) lib5 endif() ${CMAKE_DL_LIBS})
Is there anyway to implement this in cmakelists.txt?
Simply use multiple
target_link_library
commands.E.g. the following could be used to add a lib for unix targets
Alternatively you could use a list containing the libs to include
In theory you could also use generator expressions, but imho this would make for the least readable alternative