Jiang Bian Jiang Bian - 1 year ago 163
C Question

How to copy directory from source tree to binary tree?

Copying directory from source tree to binary tree. For example: How to copy www to bin folder.

│ └─www


Answer Source

With CMake 2.8, use the file(COPY ...) command.

With older CMake versions, this macro copies files from one directory to another. If you don't want to substitute variables in the copied files, change the configure_file @ONLY argument.

# Copy files from source directory to destination directory, substituting any
# variables.  Create destination directory if it does not exist.

macro(configure_files srcDir destDir)
    message(STATUS "Configuring directory ${destDir}")

    file(GLOB templateFiles RELATIVE ${srcDir} ${srcDir}/*)
    foreach(templateFile ${templateFiles})
        set(srcTemplatePath ${srcDir}/${templateFile})
        if(NOT IS_DIRECTORY ${srcTemplatePath})
            message(STATUS "Configuring file ${templateFile}")
        endif(NOT IS_DIRECTORY ${srcTemplatePath})
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download