Browse Source

Remove the need to list libraries to build in deps/CMakeLists.txt

tamasmeszaros 1 year ago
parent
commit
0fefc13599
3 changed files with 13 additions and 27 deletions
  1. 5 1
      cmake/modules/AddCMakeProject.cmake
  2. 1 0
      deps/+OpenCSG/OpenCSG.cmake
  3. 7 26
      deps/CMakeLists.txt

+ 5 - 1
cmake/modules/AddCMakeProject.cmake

@@ -12,6 +12,11 @@ if (NOT CMAKE_BUILD_TYPE)
     message(STATUS "Forcing CMAKE_BUILD_TYPE to Release as it was not specified.")
 endif ()
 
+# This is a wrapper function around ExternalProject_Add to simplify adding 
+# CMake based external projects. It will forward common build configuration from the parent
+# project and set up multithreaded build for various generators.
+# The function signiture is identical to that of ExternalProject_Add, except that the 
+# BUILD_COMMAND, INSTALL_COMMAND and INSTALL_DIR arguments are ignored. 
 # The value of CMAKE_BUILD_TYPE will be used for building each dependency even if the 
 # generator is multi-config. Use this var to specify build type regardless of the generator. 
 function(add_cmake_project projectname)
@@ -53,7 +58,6 @@ function(add_cmake_project projectname)
     
     ExternalProject_Add(
         dep_${projectname}
-        EXCLUDE_FROM_ALL    ON  # Not built by default, dep_${projectname} needs to be added to ALL target
         INSTALL_DIR         ${${PROJECT_NAME}_DEP_INSTALL_PREFIX}
         DOWNLOAD_DIR        ${${PROJECT_NAME}_DEP_DOWNLOAD_DIR}/${projectname}
         BINARY_DIR          ${CMAKE_CURRENT_BINARY_DIR}/builds/${projectname}

+ 1 - 0
deps/+OpenCSG/OpenCSG.cmake

@@ -1,5 +1,6 @@
 
 add_cmake_project(OpenCSG
+    EXCLUDE_FROM_ALL ON # No need to build this lib by default. Only used in experiment in sandboxes/opencsg
     URL https://github.com/floriankirsch/OpenCSG/archive/refs/tags/opencsg-1-4-2-release.zip
     URL_HASH SHA256=51afe0db79af8386e2027d56d685177135581e0ee82ade9d7f2caff8deab5ec5
     PATCH_COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in ./CMakeLists.txt

+ 7 - 26
deps/CMakeLists.txt

@@ -60,7 +60,7 @@ macro(list_projects result curdir)
   set(dirlist "")
   foreach(child ${children})
     if(IS_DIRECTORY ${curdir}/${child})
-      string(REGEX MATCH "^\\+([a-zA-Z0-9]+)" is_package_dir ${child})
+      string(REGEX MATCH "^\\+([a-zA-Z0-9_]+)" is_package_dir ${child})
       if(is_package_dir AND EXISTS ${curdir}/${child}/${CMAKE_MATCH_1}.cmake) 
         list(APPEND dirlist ${CMAKE_MATCH_1})
       endif()
@@ -127,25 +127,6 @@ list_projects(FOUND_PACKAGES ${CMAKE_CURRENT_LIST_DIR})
 
 dep_message(STATUS "Found external package definitions: ${FOUND_PACKAGES}")
 
-# Current list of all required dependencies for PS (top level)
-set(REQUIRED_PACKAGES
-    Boost
-    Catch2
-    Cereal
-    CURL
-    EXPAT
-    NLopt
-    GLEW
-    TBB
-    Qhull
-    wxWidgets
-    OpenVDB
-    CGAL
-    OCCT
-    ZLIB
-    LibBGCode
-)
-
 set(${PROJECT_NAME}_PLATFORM_PACKAGES "" CACHE STRING "Select packages which are provided by the platform" )
 set(SYSTEM_PROVIDED_PACKAGES OpenGL)
 
@@ -159,7 +140,6 @@ if (UNIX)
     endif ()
 endif ()
 
-
 list(APPEND SYSTEM_PROVIDED_PACKAGES ${${PROJECT_NAME}_PLATFORM_PACKAGES})
 list(REMOVE_DUPLICATES SYSTEM_PROVIDED_PACKAGES)
 
@@ -200,8 +180,11 @@ foreach (pkg ${FOUND_PACKAGES})
 
         if (${pkg} IN_LIST SYSTEM_PROVIDED_PACKAGES)
           check_system_package(${pkg} _checked_list)
-        elseif (${pkg} IN_LIST REQUIRED_PACKAGES)
-          list(APPEND DEPS_TO_BUILD ${pkg})
+        else ()
+          get_target_property(_is_excluded_from_all dep_${pkg} EXCLUDE_FROM_ALL)
+          if (NOT _is_excluded_from_all)
+            list(APPEND DEPS_TO_BUILD ${pkg})
+          endif ()
         endif ()
     endif ()
 endforeach()
@@ -218,9 +201,7 @@ foreach (pkg ${SUPPORTED_PACKAGES})
     elseif(TARGET dep_${deppkg})
       dep_message(STATUS "Mapping dep_${deppkg} => dep_${pkg}")
       add_dependencies(dep_${pkg} dep_${deppkg})
-      if (${pkg} IN_LIST REQUIRED_PACKAGES)
-        list(APPEND _build_list dep_${deppkg})
-      endif ()
+      list(APPEND _build_list dep_${deppkg})
     endif ()
   endforeach()
 endforeach()