[CMake] Use target oriented design for bmalloc
[WebKit-https.git] / Source / cmake / WebKitMacros.cmake
index 4aacbd6..6d57ee3 100644 (file)
@@ -333,6 +333,37 @@ function(WEBKIT_MAKE_FORWARDING_HEADERS framework)
     add_dependencies(${framework} ${target_name})
 endfunction()
 
+function(WEBKIT_COPY_FILES target_name)
+    set(options FLATTENED)
+    set(oneValueArgs DESTINATION)
+    set(multiValueArgs FILES)
+    cmake_parse_arguments(opt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+    set(files ${opt_FILES})
+    set(dst_files)
+    foreach (file IN LISTS files)
+        if (IS_ABSOLUTE ${file})
+            set(src_file ${file})
+        else ()
+            set(src_file ${CMAKE_CURRENT_SOURCE_DIR}/${file})
+        endif ()
+        if (opt_FLATTENED)
+            get_filename_component(filename ${file} NAME)
+            set(dst_file ${opt_DESTINATION}/${filename})
+        else ()
+            get_filename_component(file_dir ${file} DIRECTORY)
+            file(MAKE_DIRECTORY ${opt_DESTINATION}/${file_dir})
+            set(dst_file ${opt_DESTINATION}/${file})
+        endif ()
+        add_custom_command(OUTPUT ${dst_file}
+            COMMAND ${CMAKE_COMMAND} -E copy ${src_file} ${dst_file}
+            MAIN_DEPENDENCY ${file}
+            VERBATIM
+        )
+        list(APPEND dst_files ${dst_file})
+    endforeach ()
+    add_custom_target(${target_name} DEPENDS ${dst_files})
+endfunction()
+
 # Helper macros for debugging CMake problems.
 macro(WEBKIT_DEBUG_DUMP_COMMANDS)
     set(CMAKE_VERBOSE_MAKEFILE ON)