YC Yc.W home Systems · C++ · AI Infrastructure
Developer Tools · Note

CMake-list

Explore all Developer Tools notes →

https://www.visgraf.impa.br/seminar/slides/rodlima_cmake_presentation.pdf

  • Useful to manage long list of elements
  • Elements can be manipulated depending on running platform
    • Useful for source file lists
  • Example:
    set(sources viewer.cpp config.cpp)
    if(WIN32)
    list(APPEND sources viewer_mfc.cpp)
    elseif(UNIX)
    list(APPEND sources viewer_gtk.cpp)
    else()
    message(FATAL_ERROR "Platform not supported")
    endif()
    add_executable(viewer ${sources})
    list(LENGTH sources srclen)
    message("${srclen} source files")
    foreach(src ${sources})
    message("Source: ${src}")
    endforeach()