Browse Source

Merge pull request #701 from jdumas/cgal

Continuous Integration for CGAL on Windows

Former-commit-id: 17093cad7701337618af4b3a2b6545130157a629
Daniele Panozzo 7 years ago
parent
commit
4d8c581746

+ 10 - 5
.appveyor.yml

@@ -1,5 +1,5 @@
 version: 1.0.{build}
-os: Visual Studio 2015
+os: Visual Studio 2017
 test: off
 clone_folder: C:\projects\libigl
 branches:
@@ -7,17 +7,22 @@ branches:
     - master
     - alecjacobson
     - cmake
+    - cgal
 install:
   - git submodule update --init --recursive
   - cinstall: python
 build_script:
   - echo Running cmake...
-  - cd c:\projects\libigl\tutorial
+  - cd c:\projects\libigl
+  - cd external
   - mkdir build
   - cd build
-  - cmake -D "LIBIGL_USE_STATIC_LIBRARY=ON" -D "LIBIGL_WITH_ANTTWEAKBAR=OFF" -G "Visual Studio 14 2015 Win64" ../
-#  - cmake -G "Visual Studio 14 2015 Win64" ../
+  - cmake -G "Visual Studio 15 2017 Win64" -T "host=x64" ..
+  - msbuild %MSBuildOptions% libigl_external.sln
+  - cd ../../tutorial
+  - mkdir build
+  - cd build
+  - cmake -D "LIBIGL_USE_STATIC_LIBRARY=ON" -D "LIBIGL_WITH_ANTTWEAKBAR=OFF" -D "BOOST_ROOT=../external/boost/" -G "Visual Studio 15 2017 Win64" ../
   - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
-#  - set MSBuildOptions=/v:m /p:Configuration=Release /logger:%MSBuildLogger%
   - set MSBuildOptions=/v:m /p:Configuration=Debug /logger:%MSBuildLogger%
   - msbuild %MSBuildOptions% libigl_tutorials.sln

+ 15 - 11
include/igl/combine.cpp

@@ -1,17 +1,17 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2016 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// This Source Code Form is subject to the terms of the Mozilla Public License 
-// v. 2.0. If a copy of the MPL was not distributed with this file, You can 
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
 // obtain one at http://mozilla.org/MPL/2.0/.
 #include "combine.h"
 #include <cassert>
 
 template <
-  typename DerivedVV, 
-  typename DerivedFF, 
-  typename DerivedV, 
+  typename DerivedVV,
+  typename DerivedFF,
+  typename DerivedV,
   typename DerivedF,
   typename DerivedVsizes,
   typename DerivedFsizes>
@@ -23,7 +23,7 @@ IGL_INLINE void igl::combine(
   Eigen::PlainObjectBase<DerivedVsizes> & Vsizes,
   Eigen::PlainObjectBase<DerivedFsizes> & Fsizes)
 {
-  assert(VV.size() == FF.size() && 
+  assert(VV.size() == FF.size() &&
     "Lists of verex lists and face lists should be same size");
   Vsizes.resize(VV.size());
   Fsizes.resize(FF.size());
@@ -66,9 +66,9 @@ IGL_INLINE void igl::combine(
 }
 
 template <
-  typename DerivedVV, 
-  typename DerivedFF, 
-  typename DerivedV, 
+  typename DerivedVV,
+  typename DerivedFF,
+  typename DerivedV,
   typename DerivedF>
 IGL_INLINE void igl::combine(
   const std::vector<DerivedVV> & VV,
@@ -84,4 +84,8 @@ IGL_INLINE void igl::combine(
 // Explicit template instantiation
 template void igl::combine<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<unsigned long, -1, 1, 0, -1, 1>, Eigen::Matrix<unsigned long, -1, 1, 0, -1, 1> >(std::vector<Eigen::Matrix<double, -1, -1, 0, -1, -1>, std::allocator<Eigen::Matrix<double, -1, -1, 0, -1, -1> > > const&, std::vector<Eigen::Matrix<int, -1, -1, 0, -1, -1>, std::allocator<Eigen::Matrix<int, -1, -1, 0, -1, -1> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned long, -1, 1, 0, -1, 1> >&);
 template void igl::combine<Eigen::Matrix<double, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3>, Eigen::Matrix<double, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(std::vector<Eigen::Matrix<double, -1, 3, 1, -1, 3>, std::allocator<Eigen::Matrix<double, -1, 3, 1, -1, 3> > > const&, std::vector<Eigen::Matrix<int, -1, 3, 1, -1, 3>, std::allocator<Eigen::Matrix<int, -1, 3, 1, -1, 3> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&);
+#ifdef WIN32
+template void igl::combine<Eigen::Matrix<double,-1,-1,0,-1,-1>, Eigen::Matrix<int,-1,-1,0,-1,-1>,Eigen::Matrix<double,-1,-1,0,-1,-1>,Eigen::Matrix<int,-1,-1,0,-1,-1>,Eigen::Matrix<unsigned __int64,-1,1,0,-1,1>,Eigen::Matrix<unsigned __int64,-1,1,0,-1,1> >(class std::vector<Eigen::Matrix<double,-1,-1,0,-1,-1>,class std::allocator<Eigen::Matrix<double,-1,-1,0,-1,-1> > > const &,class std::vector<Eigen::Matrix<int,-1,-1,0,-1,-1>,class std::allocator<Eigen::Matrix<int,-1,-1,0,-1,-1> > > const &,Eigen::PlainObjectBase<Eigen::Matrix<double,-1,-1,0,-1,-1> > &,Eigen::PlainObjectBase<Eigen::Matrix<int,-1,-1,0,-1,-1> > &,Eigen::PlainObjectBase<Eigen::Matrix<unsigned __int64,-1,1,0,-1,1> > &,Eigen::PlainObjectBase<Eigen::Matrix<unsigned __int64,-1,1,0,-1,1> > &);
+template void igl::combine<Eigen::Matrix<double,-1,-1,0,-1,-1>, Eigen::Matrix<int,-1,-1,0,-1,-1>,Eigen::Matrix<double,-1,-1,0,-1,-1>,Eigen::Matrix<int,-1,-1,0,-1,-1>,Eigen::Matrix<unsigned __int64,-1,1,0,-1,1>,Eigen::Matrix<unsigned __int64,-1,1,0,-1,1> >(class std::vector<Eigen::Matrix<double,-1,-1,0,-1,-1>,class std::allocator<Eigen::Matrix<double,-1,-1,0,-1,-1> > > const &,class std::vector<Eigen::Matrix<int,-1,-1,0,-1,-1>,class std::allocator<Eigen::Matrix<int,-1,-1,0,-1,-1> > > const &,Eigen::PlainObjectBase<Eigen::Matrix<double,-1,-1,0,-1,-1> > &,Eigen::PlainObjectBase<Eigen::Matrix<int,-1,-1,0,-1,-1> > &,Eigen::PlainObjectBase<Eigen::Matrix<unsigned __int64,-1,1,0,-1,1> > &,Eigen::PlainObjectBase<Eigen::Matrix<unsigned __int64,-1,1,0,-1,1> > &);
+#endif
 #endif

+ 11 - 9
shared/cmake/FindCGAL.cmake

@@ -13,27 +13,27 @@
 # Construct consitent error messages for use below.
 set(CGAL_DIR_DESCRIPTION "directory containing CGALConfig.cmake. This is either the binary directory where CGAL was configured or PREFIX/lib/CGAL for an installation.")
 set(CGAL_DIR_MESSAGE     "CGAL not found.  Set the CGAL_DIR cmake variable or environment variable to the ${CGAL_DIR_DESCRIPTION}")
- 
+
 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
- 
+
 if ( NOT CGAL_DIR )
-  
+
   # Get the system search path as a list.
   if(UNIX)
     string(REGEX MATCHALL "[^:]+" CGAL_DIR_SEARCH1 "$ENV{PATH}")
   else()
     string(REGEX REPLACE "\\\\" "/" CGAL_DIR_SEARCH1 "$ENV{PATH}")
   endif()
-  
+
   string(REGEX REPLACE "/;" ";" CGAL_DIR_SEARCH2 "${CGAL_DIR_SEARCH1}")
 
   # Construct a set of paths relative to the system search path.
   set(CGAL_DIR_SEARCH "")
-  
+
   foreach(dir ${CGAL_DIR_SEARCH2})
-  
+
     set(CGAL_DIR_SEARCH ${CGAL_DIR_SEARCH} ${dir}/../lib/CGAL )
-      
+
   endforeach()
 
 
@@ -41,6 +41,8 @@ if ( NOT CGAL_DIR )
   # Look for an installation or build tree.
   #
   find_path(CGAL_DIR CGALConfig.cmake
+    # Look for CGAL in 'external/' folder
+    "${CMAKE_CURRENT_LIST_DIR}/../../external/cgal/lib/CGAL"
 
     # Look for an environment variable CGAL_DIR.
     $ENV{CGAL_DIR}
@@ -70,11 +72,11 @@ if ( NOT CGAL_DIR )
     # Help the user find it if we cannot.
     DOC "The ${CGAL_DIR_DESCRIPTION}"
   )
-  
+
 endif()
 
 if ( CGAL_DIR )
-  
+
   if ( EXISTS "${CGAL_DIR}/CGALConfig.cmake" )
     include( "${CGAL_DIR}/CGALConfig.cmake" )
     set( CGAL_FOUND TRUE )

+ 26 - 12
shared/cmake/libigl.cmake

@@ -146,25 +146,39 @@ endif()
 if(LIBIGL_WITH_CGAL)
   # CGAL Core is needed for
   # `Exact_predicates_exact_constructions_kernel_with_sqrt`
-  find_package(CGAL REQUIRED COMPONENTS Core)
-  compile_igl_module("cgal")
-  if(WIN32)
-    set(Boost_USE_STATIC_LIBS ON) # Favor static Boost libs on Windows
+  if(EXISTS ${LIBIGL_EXTERNAL}/boost)
+    set(BOOST_ROOT "${LIBIGL_EXTERNAL}/boost")
+  endif()
+  find_package(CGAL COMPONENTS Core)
+  if(CGAL_FOUND)
+    compile_igl_module("cgal")
+    if(WIN32)
+      set(Boost_USE_STATIC_LIBS ON) # Favor static Boost libs on Windows
+    endif()
+    target_include_directories(igl_cgal ${IGL_SCOPE} "${GMP_INCLUDE_DIR}" "${MPFR_INCLUDE_DIR}")
+    find_package(Boost 1.48 REQUIRED thread system)
+    target_include_directories(igl_cgal ${IGL_SCOPE} ${CGAL_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
+    target_link_libraries(igl_cgal ${IGL_SCOPE} CGAL::CGAL CGAL::CGAL_Core ${Boost_LIBRARIES})
+  else()
+    set(LIBIGL_WITH_CGAL OFF CACHE BOOL "" FORCE)
   endif()
-  target_include_directories(igl_cgal ${IGL_SCOPE} "${GMP_INCLUDE_DIR}" "${MPFR_INCLUDE_DIR}")
-  find_package(Boost 1.48 REQUIRED thread system)
-  target_include_directories(igl_cgal ${IGL_SCOPE} ${CGAL_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
-  target_link_libraries(igl_cgal ${IGL_SCOPE} CGAL::CGAL CGAL::CGAL_Core ${Boost_LIBRARIES})
 endif()
 
 # Helper function for `igl_copy_cgal_dll()`
 function(igl_copy_imported_dll src_target dst_target)
   get_target_property(configurations ${src_target} IMPORTED_CONFIGURATIONS)
   foreach(config ${configurations})
-    get_target_property(location ${src_target} IMPORTED_LOCATION_${config})
-    if(EXISTS "${location}" AND location MATCHES "^.*\\.dll$")
-      add_custom_command(TARGET ${dst_target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${location}" $<TARGET_FILE_DIR:${dst_target}>)
-    endif()
+    get_target_property(main_lib ${src_target} IMPORTED_LOCATION_${config})
+    get_target_property(other_libs ${src_target} IMPORTED_LINK_INTERFACE_LIBRARIES_${config})
+    set(locations)
+    list(APPEND locations ${main_lib} ${other_libs})
+    foreach(location ${locations})
+      string(REGEX MATCH "^(.*)\\.[^.]*$" dummy ${location})
+      set(location "${CMAKE_MATCH_1}.dll")
+      if(EXISTS "${location}" AND location MATCHES "^.*\\.dll$")
+        add_custom_command(TARGET ${dst_target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${location}" $<TARGET_FILE_DIR:${dst_target}>)
+      endif()
+    endforeach()
   endforeach()
 endfunction()
 

+ 1 - 0
tutorial/609_Boolean/CMakeLists.txt

@@ -3,3 +3,4 @@ project(609_Boolean)
 
 add_executable(${PROJECT_NAME}_bin main.cpp)
 target_link_libraries(${PROJECT_NAME}_bin igl::core igl::cgal igl::opengl igl::opengl_glfw tutorials)
+igl_copy_cgal_dll(${PROJECT_NAME}_bin)

+ 1 - 0
tutorial/610_CSGTree/CMakeLists.txt

@@ -3,3 +3,4 @@ project(610_CSGTree)
 
 add_executable(${PROJECT_NAME}_bin main.cpp)
 target_link_libraries(${PROJECT_NAME}_bin igl::core igl::cgal igl::opengl igl::opengl_glfw tutorials)
+igl_copy_cgal_dll(${PROJECT_NAME}_bin)

+ 2 - 2
tutorial/CMakeLists.txt

@@ -5,7 +5,7 @@ message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
 
 ### conditionally compile certain modules depending on libraries found on the system
 list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../shared/cmake)
-find_package(CGAL QUIET COMPONENTS Core)
+#find_package(CGAL QUIET COMPONENTS Core)
 find_package(MATLAB QUIET)
 find_package(MOSEK)
 
@@ -14,7 +14,7 @@ option(LIBIGL_USE_STATIC_LIBRARY "Use LibIGL as static library" ON)
 option(LIBIGL_WITH_EMBREE      "Use Embree"         ON)
 
 ### libIGL options: choose your dependencies (by default everything is OFF, in this example we need the viewer)
-option(LIBIGL_WITH_CGAL             "Use CGAL"           "${CGAL_FOUND}")
+option(LIBIGL_WITH_CGAL             "Use CGAL"           ON)
 option(LIBIGL_WITH_CORK             "Use CORK"           OFF)
 option(LIBIGL_WITH_MATLAB           "Use Matlab"         "${MATLAB_FOUND}")
 option(LIBIGL_WITH_MOSEK            "Use MOSEK"          "${MOSEK_FOUND}")