Pārlūkot izejas kodu

Allow compiling/installing generated Python files

Modify ctkMacroCompilePythonScript to accept SCRIPTS and/or RESOURCES
that are generated files, rather than requiring them to exist at
configure time. Also, modify ctkFunctionAddCompilePythonScriptTargets to
accept additional arguments that are passed to add_custom_target. (The
second change allows passing e.g. 'DEPENDS <other targets>', which is
required to make the targets depend on other targets which generate the
aforementioned generated files, so that copying of the files will
succeed.)
Matthew Woehlke 11 gadi atpakaļ
vecāks
revīzija
9208de739a
1 mainītis faili ar 13 papildinājumiem un 8 dzēšanām
  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()