Skip to content

批量生成可执行程序

程序中如果有大量可执行程序需要添加,cmake 提供了 macro 指令帮助批量生成。下边这个可以实现每次生成**studyexplorer dicomviewer logviewer**三个可执行程序

macro(DCMTK_ADD_EXECUTABLE PROGRAM)
    include_directories(${KissDicomViewer_INCLUDE_DIRS})
    add_executable(${PROGRAM} ${PROGRAM}.cpp  ${KissDicomViewer_Resource_DIR})
    target_link_libraries(${PROGRAM} KissDicomViewer_sharde)
endmacro()

foreach(SUBDIR studyexplorer dicomviewer logviewer)
  DCMTK_ADD_EXECUTABLE(${SUBDIR})
endforeach()