Browse Source

Add CMake file to sort targets into folders (#1383)

* Add CMake file to sort targets into folders.

* Do not set FOLDER property on INTERFACE targets.
Jérémie Dumas 6 years ago
parent
commit
ea0515088e
3 changed files with 137 additions and 6 deletions
  1. 8 3
      CMakeLists.txt
  2. 116 0
      cmake/LibiglFolders.cmake
  3. 13 3
      cmake/libigl.cmake

+ 8 - 3
CMakeLists.txt

@@ -5,8 +5,8 @@ option(HUNTER_ENABLED "Enable Hunter package manager support" OFF)
 
 include("cmake/HunterGate.cmake")
 HunterGate(
-    URL "https://github.com/ruslo/hunter/archive/v0.23.171.tar.gz"
-    SHA1 "5d68bcca78eee347239ca5f4d34f4b6c12683154"
+	URL "https://github.com/ruslo/hunter/archive/v0.23.171.tar.gz"
+	SHA1 "5d68bcca78eee347239ca5f4d34f4b6c12683154"
 )
 
 project(libigl)
@@ -45,7 +45,7 @@ option(LIBIGL_WITH_PYTHON            "Use Python"                   OFF)
 ### End
 
 if(${LIBIGL_WITH_PYTHON})
-	MESSAGE(FATAL_ERROR "Python binding are in the process of being redone. Please use the master branch or refer to https://github.com/geometryprocessing/libigl-python-bindings for the developement version or https://anaconda.org/conda-forge/igl for the stable version.")
+	message(FATAL_ERROR "Python binding are in the process of being redone. Please use the master branch or refer to https://github.com/geometryprocessing/libigl-python-bindings for the developement version or https://anaconda.org/conda-forge/igl for the stable version.")
 endif()
 
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
@@ -67,3 +67,8 @@ if(LIBIGL_BUILD_TESTS)
 	enable_testing()
 	add_subdirectory(tests)
 endif()
+
+if(LIBIGL_TOPLEVEL_PROJECT)
+	# Set folders for Visual Studio/Xcode
+	igl_set_folders()
+endif()

+ 116 - 0
cmake/LibiglFolders.cmake

@@ -0,0 +1,116 @@
+# Sort projects inside the solution
+set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+
+function(igl_folder_targets FOLDER_NAME)
+    foreach(target IN ITEMS ${ARGN})
+        if(TARGET ${target})
+            get_target_property(TYPE ${target} TYPE)
+            if(NOT (TYPE STREQUAL "INTERFACE_LIBRARY"))
+                set_target_properties(${target} PROPERTIES FOLDER "${FOLDER_NAME}")
+            endif()
+        endif()
+    endforeach()
+endfunction()
+
+function(igl_set_folders)
+
+igl_folder_targets("ThirdParty/Embree"
+    algorithms
+    embree
+    lexers
+    math
+    simd
+    sys
+    tasking
+)
+
+igl_folder_targets("ThirdParty"
+    CoMISo
+    glad
+    glfw
+    imgui
+    predicates
+    tetgen
+    tinyxml2
+    triangle
+)
+
+igl_folder_targets("Libigl"
+    igl
+    igl_comiso
+    igl_embree
+    igl_opengl
+    igl_opengl_glfw
+    igl_opengl_glfw_imgui
+    igl_png
+    igl_predicates
+    igl_stb_image
+    igl_tetgen
+    igl_triangle
+    igl_xml
+)
+
+igl_folder_targets("Unit Tests"
+    libigl_tests
+)
+
+igl_folder_targets("Tutorials"
+    101_FileIO_bin
+    102_DrawMesh_bin
+    103_Events_bin
+    104_Colors_bin
+    105_Overlays_bin
+    106_ViewerMenu_bin
+    107_MultipleMeshes_bin
+    108_MultipleViews_bin
+    201_Normals_bin
+    202_GaussianCurvature_bin
+    203_CurvatureDirections_bin
+    204_Gradient_bin
+    205_Laplacian_bin
+    206_GeodesicDistance_bin
+    301_Slice_bin
+    302_Sort_bin
+    303_LaplaceEquation_bin
+    304_LinearEqualityConstraints_bin
+    305_QuadraticProgramming_bin
+    306_EigenDecomposition_bin
+    401_BiharmonicDeformation_bin
+    402_PolyharmonicDeformation_bin
+    403_BoundedBiharmonicWeights_bin
+    404_DualQuaternionSkinning_bin
+    405_AsRigidAsPossible_bin
+    406_FastAutomaticSkinningTransformations_bin
+    407_BiharmonicCoordinates_bin
+    501_HarmonicParam_bin
+    502_LSCMParam_bin
+    503_ARAPParam_bin
+    504_NRosyDesign_bin
+    505_MIQ_bin
+    506_FrameField_bin
+    507_Planarization_bin
+    601_Serialization_bin
+    604_Triangle_bin
+    605_Tetgen_bin
+    606_AmbientOcclusion_bin
+    607_ScreenCapture_bin
+    701_Statistics_bin
+    702_WindingNumber_bin
+    703_Decimation_bin
+    704_SignedDistance_bin
+    705_MarchingCubes_bin
+    706_FacetOrientation_bin
+    707_SweptVolume_bin
+    708_Picking_bin
+    709_SLIM_bin
+    710_SCAF_bin
+    711_Subdivision_bin
+    712_DataSmoothing_bin
+    713_ShapeUp_bin
+    714_MarchingTets_bin
+    715_MeshImplicitFunction_bin
+    716_HeatGeodesics_bin
+    718_IterativeClosestPoint_bin
+)
+
+endfunction()

+ 13 - 3
cmake/libigl.cmake

@@ -59,6 +59,9 @@ endif()
 list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
 include(LibiglDownloadExternal)
 
+# Provides igl_set_folders() to set folders for Visual Studio/Xcode
+include(LibiglFolders)
+
 ################################################################################
 ### IGL Common
 ################################################################################
@@ -149,10 +152,14 @@ function(compile_igl_module module_dir)
   endif()
   if(LIBIGL_USE_STATIC_LIBRARY)
     file(GLOB SOURCES_IGL_${module_name}
-      "${LIBIGL_SOURCE_DIR}/igl/${module_dir}/*.cpp")
+      "${LIBIGL_SOURCE_DIR}/igl/${module_dir}/*.cpp"
+      "${LIBIGL_SOURCE_DIR}/igl/${module_dir}/*.h*"
+    )
     if(NOT LIBIGL_WITHOUT_COPYLEFT)
       file(GLOB COPYLEFT_SOURCES_IGL_${module_name}
-        "${LIBIGL_SOURCE_DIR}/igl/copyleft/${module_dir}/*.cpp")
+        "${LIBIGL_SOURCE_DIR}/igl/copyleft/${module_dir}/*.cpp"
+        "${LIBIGL_SOURCE_DIR}/igl/copyleft/${module_dir}/*.h*"
+      )
       list(APPEND SOURCES_IGL_${module_name} ${COPYLEFT_SOURCES_IGL_${module_name}})
     endif()
     add_library(${module_libname} STATIC ${SOURCES_IGL_${module_name}} ${ARGN})
@@ -197,7 +204,10 @@ endfunction()
 if(LIBIGL_USE_STATIC_LIBRARY)
   file(GLOB SOURCES_IGL
     "${LIBIGL_SOURCE_DIR}/igl/*.cpp"
-    "${LIBIGL_SOURCE_DIR}/igl/copyleft/*.cpp")
+    "${LIBIGL_SOURCE_DIR}/igl/*.h*"
+    "${LIBIGL_SOURCE_DIR}/igl/copyleft/*.cpp"
+    "${LIBIGL_SOURCE_DIR}/igl/copyleft/*.h*"
+  )
 endif()
 compile_igl_module("core" ${SOURCES_IGL})