Forráskód Böngészése

Fix export of CTKTesting include directories

By leveraging the build system infrastructure and associating a
"target_libraries.cmake" file with CTKTesting, this commit ensures
that the associated directory are automatically exported
in CTKConfig.cmake

To successfully achieve this, the following has been done:
 (1) addition of an empty "target_libraries.cmake"
 (2) fix to DGraph so that the topological path of a standalone vertex
is the vertex itself and not the list of all vertices topologically sorted.
Note that more work would be required to teach DGraph to detect invalid
labels.
 (3) teach ctkFunctionCollectTargetLibraryNames how to handle empty
list of target libraries.
Jean-Christophe Fillion-Robin 11 éve
szülő
commit
613b8207b5

+ 3 - 1
CMake/ctkMacroTargetLibraries.cmake

@@ -151,7 +151,9 @@ function(ctkFunctionCollectTargetLibraryNames target_dir varname)
     endforeach()
   endif()
 
-  list(REMOVE_DUPLICATES target_library_list)
+  if(target_library_list)
+    list(REMOVE_DUPLICATES target_library_list)
+  endif()
   
   # Pass the list of target libraries to the caller
   set(${varname} ${target_library_list} PARENT_SCOPE)

+ 6 - 5
CMakeLists.txt

@@ -763,6 +763,12 @@ ctk_enable_option_raw(CTK_BUILD_EXAMPLES "Build examples for CTK components" OFF
 # Create list of directories corresponding to the enabled targets
 set(target_directories)
 
+# Setup testing environment before Libs are added by simulating
+# the use of 'ctk_lib_option' for CTKTesting library
+set(CTK_LIB_Testing TRUE)
+list(APPEND CTK_LIBS Testing)
+list(APPEND target_directories "${CMAKE_CURRENT_SOURCE_DIR}/Libs/Testing^^CTK_LIB_Testing")
+
 foreach(lib ${CTK_LIBS})
   if(CTK_LIB_${lib})
     ctkMacroAddCtkLibraryOptions(${lib})
@@ -1052,11 +1058,6 @@ set(CMAKE_C_FLAGS ${CTK_C_FLAGS} CACHE STRING "CMake CXX Flags" FORCE)
 set(CTK_EXPORT_HEADER_TEMPLATE "${CTK_SOURCE_DIR}/Libs/ctkExport.h.in")
 
 #-----------------------------------------------------------------------------
-# Setup testing environment before Libs are added
-#
-add_subdirectory(Libs/Testing)
-
-#-----------------------------------------------------------------------------
 # Add CTK library subdirectories
 #
 foreach(lib ${CTK_LIBS})

+ 8 - 0
Libs/Testing/target_libraries.cmake

@@ -0,0 +1,8 @@
+#
+# See CMake/ctkFunctionGetTargetLibraries.cmake
+# 
+# This file should list the libraries required to build the current CTK libraries
+# 
+
+set(target_libraries
+  )

+ 12 - 1
Utilities/DGraph/DGraph.cpp

@@ -268,12 +268,18 @@ int main(int argc, char** argv)
       {
       from = getOrGenerateId(vertexIdToLabel, vertexLabelToId, strings[0]);
       to = getOrGenerateId(vertexIdToLabel, vertexLabelToId, strings[1]);
-
       if (verbose)
         {
         std::cout << "Line='" << line << "', line number " << lineNumber << ", from (" << strings[0] << ", " << from << ") to (" << strings[1] << ", " << to << ")"  << std::endl;
         }
       }
+    else
+      {
+      if (verbose)
+        {
+        std::cout << "Line='" << line << "', line number " << lineNumber << ", from (" << strings[0] << ", " << from << ") to (<null>, " << to << ")"  << std::endl;
+        }
+      }
 
     if (to > -1)
       {
@@ -437,6 +443,11 @@ int main(int argc, char** argv)
     // TODO Make sure label is valid
     std::list<int> out;
     int labelId = vertexLabelToId[label];
+    if (labelId < 1)
+      {
+      std::cout << label;
+      return EXIT_SUCCESS;
+      }
     if (mygraph.topologicalSort(out, labelId))
       {
       std::list<int>::iterator outIterator;