Преглед на файлове

Merge pull request #477 from mwoehlke-kitware/allow-generated-python-files

Allow compiling/installing generated Python files
Jean-Christophe Fillion-Robin преди 11 години
родител
ревизия
24b9796422
променени са 1 файла, в които са добавени 13 реда и са изтрити 8 реда
  1. 13 8
      CMake/ctkMacroCompilePythonScript.cmake

+ 13 - 8
CMake/ctkMacroCompilePythonScript.cmake

@@ -60,7 +60,11 @@ macro(ctkMacroCompilePythonScript)
       set(file "${file}.py")
     endif()
 
-    set(src "${MY_SOURCE_DIR}/${file}")
+    if(NOT IS_ABSOLUTE ${file})
+      set(src "${MY_SOURCE_DIR}/${file}")
+    else()
+      set(src "${file}")
+    endif()
     set(tgt_file ${file})
     if(IS_ABSOLUTE ${file})
       set(src ${file})
@@ -73,7 +77,11 @@ macro(ctkMacroCompilePythonScript)
   if(DEFINED MY_RESOURCES)
     set(resource_input_files)
     foreach(file ${MY_RESOURCES})
-      set(src "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
+      if(NOT IS_ABSOLUTE ${file})
+        set(src "${MY_SOURCE_DIR}/${file}")
+      else()
+        set(src "${file}")
+      endif()
       set_property(GLOBAL APPEND PROPERTY
       _CTK_${target}_PYTHON_RESOURCES "${src}|${file}|${MY_DESTINATION_DIR}")
     endforeach()
@@ -117,10 +125,7 @@ function(_ctk_add_copy_python_files_target target type)
       list(APPEND copied_files ${tgt})
     endforeach()
     if(entries)
-      add_custom_target(${target_name} ALL
-        DEPENDS
-          ${copied_files}
-          )
+      add_custom_target(${target_name} ALL DEPENDS ${copied_files} ${ARGN})
     endif()
   endif()
 endfunction()
@@ -173,8 +178,8 @@ function(_ctk_add_compile_python_directories_target target)
 endfunction()
 
 function(ctkFunctionAddCompilePythonScriptTargets target)
-  _ctk_add_copy_python_files_target(${target} Script)
-  _ctk_add_copy_python_files_target(${target} Resource)
+  _ctk_add_copy_python_files_target(${target} Script ${ARGN})
+  _ctk_add_copy_python_files_target(${target} Resource ${ARGN})
   _ctk_add_compile_python_directories_target(${target})
 endfunction()