Browse Source

Merge branch 'main' of github.com:libigl/libigl [ci skip]

Alec Jacobson 2 years ago
parent
commit
67b406d60d

+ 12 - 13
.github/workflows/continuous.yml

@@ -20,19 +20,14 @@ jobs:
   ####################
   ####################
 
 
   Unix:
   Unix:
-    name: ${{ matrix.name }} (${{ matrix.config }}, ${{ fromJSON('["HeaderOnly", "Static"]')[matrix.static == 'ON'] }})
+    name: ${{ matrix.os }} ${{ fromJSON('["Header-Only", "Static"]')[matrix.build-params.static == 'ON'] }} ${{ matrix.build-params.tutorials == 'ON' && 'tutorial' || ''}} ${{ matrix.build-params.tests == 'ON' && 'tests' || ''}} ${{ matrix.config }}
     runs-on: ${{ matrix.os }}
     runs-on: ${{ matrix.os }}
     strategy:
     strategy:
       fail-fast: false
       fail-fast: false
       matrix:
       matrix:
         os: [ubuntu-20.04, macos-latest]
         os: [ubuntu-20.04, macos-latest]
         config: [Release]
         config: [Release]
-        static: [ON, OFF]
-        include:
-          - os: macos-latest
-            name: macOS
-          - os: ubuntu-20.04
-            name: Linux
+        build-params: [ {static:  ON, tutorials:  ON, tests:  ON }, {static: OFF, tutorials: OFF, tests:  ON }, {static: OFF, tutorials:  ON, tests: OFF }]
     env:
     env:
       IGL_NUM_THREADS: 1  # See https://github.com/libigl/libigl/pull/996
       IGL_NUM_THREADS: 1  # See https://github.com/libigl/libigl/pull/996
     steps:
     steps:
@@ -62,7 +57,7 @@ jobs:
         uses: actions/cache@v2
         uses: actions/cache@v2
         with:
         with:
           path: ~/.ccache
           path: ~/.ccache
-          key: ${{ runner.os }}-${{ matrix.config }}-${{ matrix.static }}-cache
+          key: ${{ runner.os }}-${{ matrix.config }}-${{ matrix.build-params.static }}-cache
 
 
       - name: Prepare ccache
       - name: Prepare ccache
         run: |
         run: |
@@ -76,7 +71,9 @@ jobs:
           cmake .. \
           cmake .. \
             -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
             -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
             -DCMAKE_BUILD_TYPE=${{ matrix.config }} \
             -DCMAKE_BUILD_TYPE=${{ matrix.config }} \
-            -DLIBIGL_USE_STATIC_LIBRARY=${{ matrix.static }} \
+            -DLIBIGL_USE_STATIC_LIBRARY=${{ matrix.build-params.static }} \
+            -DLIBIGL_BUILD_TUTORIALS=${{ matrix.build-params.tutorials }} \
+            -DLIBIGL_BUILD_TESTS=${{ matrix.build-params.tests }} \
             -DLIBIGL_COPYLEFT_CGAL=ON
             -DLIBIGL_COPYLEFT_CGAL=ON
 
 
       - name: Build
       - name: Build
@@ -90,13 +87,13 @@ jobs:
   ####################
   ####################
 
 
   Windows:
   Windows:
-    name: Windows (${{ matrix.config }}, ${{ fromJSON('["HeaderOnly", "Static"]')[matrix.static == 'ON'] }})
+    name: Windows ${{ fromJSON('["Header-Only", "Static"]')[matrix.build-params.static == 'ON'] }} ${{ matrix.build-params.tutorials == 'ON' && 'tutorial' || ''}} ${{ matrix.build-params.tests == 'ON' && 'tests' || ''}} ${{ matrix.config }}
     runs-on: windows-2022
     runs-on: windows-2022
     strategy:
     strategy:
       fail-fast: false
       fail-fast: false
       matrix:
       matrix:
         config: [Release]
         config: [Release]
-        static: [ON, OFF]
+        build-params: [ {static:  ON, tutorials:  ON, tests:  ON }, {static: OFF, tutorials: OFF, tests:  ON }, {static: OFF, tutorials:  ON, tests: OFF }]
     steps:
     steps:
       - name: Checkout repository
       - name: Checkout repository
         uses: actions/checkout@v1
         uses: actions/checkout@v1
@@ -115,7 +112,7 @@ jobs:
         uses: actions/cache@v2
         uses: actions/cache@v2
         with:
         with:
           path: ${{ env.appdata }}\Mozilla\sccache
           path: ${{ env.appdata }}\Mozilla\sccache
-          key: ${{ runner.os }}-${{ matrix.config }}-${{ matrix.static }}-cache
+          key: ${{ runner.os }}-${{ matrix.config }}-${{ matrix.build-params.static }}-cache
 
 
       - name: Prepare sccache
       - name: Prepare sccache
         run: |
         run: |
@@ -132,8 +129,10 @@ jobs:
           cmake -G Ninja ^
           cmake -G Ninja ^
             -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ^
             -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ^
             -DCMAKE_BUILD_TYPE=${{ matrix.config }} ^
             -DCMAKE_BUILD_TYPE=${{ matrix.config }} ^
-            -DLIBIGL_USE_STATIC_LIBRARY=${{ matrix.static }} ^
+            -DLIBIGL_USE_STATIC_LIBRARY=${{ matrix.build-params.static }} ^
             -DLIBIGL_COPYLEFT_CGAL=ON ^
             -DLIBIGL_COPYLEFT_CGAL=ON ^
+            -DLIBIGL_BUILD_TUTORIALS=${{ matrix.build-params.tutorials }} ^
+            -DLIBIGL_BUILD_TESTS=${{ matrix.build-params.tests }} ^
             -B build ^
             -B build ^
             -S .
             -S .
           cmake --build build -j1
           cmake --build build -j1

+ 30 - 0
cmake/recipes/external/gmp.cmake

@@ -10,6 +10,31 @@ if(WIN32)
 else()
 else()
   message(STATUS "Third-party: creating target 'gmp::gmp'")
   message(STATUS "Third-party: creating target 'gmp::gmp'")
 
 
+  # SERIOUSLY !?! CMAKE and configure use transposed definitions of "build" and
+  # "host"?
+  #
+  # https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_NAME.html#variable:CMAKE_SYSTEM_NAME
+  # https://gcc.gnu.org/onlinedocs/gccint/Configure-Terms.html
+  #
+  # Seems these aren't to be trusted much
+  # https://gitlab.kitware.com/cmake/cmake/-/issues/20989
+  if(APPLE)
+    # https://gmplib.org/list-archives/gmp-discuss/2020-November/006607.html
+    if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
+      set(gmp_BUILD "x86_64-apple-darwin")
+      set(gmp_HOST "arm64-apple-darwin")
+      set(gmp_CFLAGS "--target=arm64-apple-darwin")
+      set(gmp_LDFLAGS "-arch arm64")
+      message(STATUS "GMP Recipe notices building on ${gmp_BUILD} for ${gmp_HOST}")
+    elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" AND CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
+      set(gmp_HOST "x86_64-apple-darwin")
+      set(gmp_BUILD "arm64-apple-darwin")
+      set(gmp_CFLAGS "--target=x86_64-apple-darwin13.0.0")
+      set(gmp_LDFLAGS "")
+      message(STATUS "GMP Recipe notices building on ${gmp_HOST} for ${gmp_BUILD}")
+    endif()
+  endif()
+
   include(FetchContent)
   include(FetchContent)
   include(ProcessorCount)
   include(ProcessorCount)
   ProcessorCount(Ncpu)
   ProcessorCount(Ncpu)
@@ -41,9 +66,14 @@ else()
       curl "https://gmplib.org/repo/gmp/raw-rev/5f32dbc41afc" "|" git apply -v
       curl "https://gmplib.org/repo/gmp/raw-rev/5f32dbc41afc" "|" git apply -v
     ${gmp_ExternalProject_Add_extra_options}
     ${gmp_ExternalProject_Add_extra_options}
     CONFIGURE_COMMAND 
     CONFIGURE_COMMAND 
+     ${CMAKE_COMMAND} -E env
+      CFLAGS=${gmp_CFLAGS}
+     LDFLAGS=${gmp_LDFLAGS}
       ${prefix}/src/gmp/configure 
       ${prefix}/src/gmp/configure 
       --disable-debug --disable-dependency-tracking --enable-cxx --with-pic
       --disable-debug --disable-dependency-tracking --enable-cxx --with-pic
       --prefix=${gmp_INSTALL}
       --prefix=${gmp_INSTALL}
+      --build=${gmp_BUILD}
+      --host=${gmp_HOST}
       --disable-shared
       --disable-shared
     BUILD_COMMAND make -j${Ncpu}
     BUILD_COMMAND make -j${Ncpu}
     INSTALL_COMMAND make -j${Ncpu} install
     INSTALL_COMMAND make -j${Ncpu} install

+ 23 - 2
cmake/recipes/external/mpfr.cmake

@@ -14,6 +14,22 @@ if(WIN32)
 else()
 else()
   message(STATUS "Third-party: creating target 'mpfr::mpfr'")
   message(STATUS "Third-party: creating target 'mpfr::mpfr'")
 
 
+  # Praying this will work the same as gmp
+  if(APPLE)
+    # https://gmplib.org/list-archives/gmp-discuss/2020-November/006607.html
+    if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
+      set(mpfr_BUILD "x86_64-apple-darwin")
+      set(mpfr_HOST "arm64-apple-darwin")
+      set(mpfr_CFLAGS "--target=arm64-apple-darwin")
+      set(mpfr_LDFLAGS "-arch arm64")
+    elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" AND CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
+      set(mpfr_HOST "x86_64-apple-darwin")
+      set(mpfr_BUILD "arm64-apple-darwin")
+      set(mpfr_CFLAGS "--target=x86_64-apple-darwin13.0.0")
+      set(mpfr_LDFLAGS "")
+    endif()
+  endif()
+
   include(FetchContent)
   include(FetchContent)
   include(ProcessorCount)
   include(ProcessorCount)
   ProcessorCount(Ncpu)
   ProcessorCount(Ncpu)
@@ -35,16 +51,21 @@ else()
   ExternalProject_Add(mpfr
   ExternalProject_Add(mpfr
     PREFIX ${prefix}
     PREFIX ${prefix}
     DEPENDS gmp
     DEPENDS gmp
-    URL  https://ftp.gnu.org/gnu/mpfr/mpfr-4.1.0.tar.xz
-    URL_MD5 bdd3d5efba9c17da8d83a35ec552baef
+    URL  https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.0.tar.xz
+    URL_MD5 a25091f337f25830c16d2054d74b5af7
     UPDATE_DISCONNECTED true  # need this to avoid constant rebuild
     UPDATE_DISCONNECTED true  # need this to avoid constant rebuild
     ${mpfr_ExternalProject_Add_extra_options} # avoid constant reconfigure
     ${mpfr_ExternalProject_Add_extra_options} # avoid constant reconfigure
     CONFIGURE_COMMAND 
     CONFIGURE_COMMAND 
+     ${CMAKE_COMMAND} -E env
+      CFLAGS=${gmp_CFLAGS}
+     LDFLAGS=${gmp_LDFLAGS}
       ${prefix}/src/mpfr/configure 
       ${prefix}/src/mpfr/configure 
       --disable-debug --disable-dependency-tracking  --disable-silent-rules --enable-cxx --with-pic
       --disable-debug --disable-dependency-tracking  --disable-silent-rules --enable-cxx --with-pic
       --with-gmp-include=${gmp_INCLUDE_DIR} --with-gmp-lib=${gmp_LIB_DIR}
       --with-gmp-include=${gmp_INCLUDE_DIR} --with-gmp-lib=${gmp_LIB_DIR}
       --disable-shared
       --disable-shared
       --prefix=${mpfr_INSTALL}
       --prefix=${mpfr_INSTALL}
+      --build=${gmp_BUILD}
+      --host=${gmp_HOST}
       --disable-shared
       --disable-shared
     BUILD_COMMAND make -j${Ncpu}
     BUILD_COMMAND make -j${Ncpu}
     INSTALL_COMMAND make -j${Ncpu} install
     INSTALL_COMMAND make -j${Ncpu} install

+ 2 - 1
include/igl/copyleft/comiso/nrosy.cpp

@@ -390,7 +390,8 @@ void igl::copyleft::comiso::NRosyField::solveRoundings()
   gmm::row_matrix< gmm::wsvector< double > > gmm_C(0, n);
   gmm::row_matrix< gmm::wsvector< double > > gmm_C(0, n);
 
 
   COMISO::ConstrainedSolver cs;
   COMISO::ConstrainedSolver cs;
-  cs.solve(gmm_C, gmm_A, x, gmm_b, ids_to_round, 0.0, false, true);
+  cs.solve(gmm_C, gmm_A, x, gmm_b, ids_to_round, 0.0, false);
+
 
 
   // Copy the result back
   // Copy the result back
   for(unsigned i=0; i<F.rows(); ++i)
   for(unsigned i=0; i<F.rows(); ++i)