From 25b21020606f5e49c676f9ec3399204e113bfdca Mon Sep 17 00:00:00 2001 From: Sergiu Deitsch Date: Sun, 15 May 2022 22:25:37 +0200 Subject: [PATCH] cmake: provide optional metis support Report METIS availability through an additional Partition meta component. --- .github/workflows/linux.yml | 20 +++++-- .github/workflows/macos.yml | 36 ++++++++++-- .github/workflows/windows.yml | 97 ++++++++++++++++++++++++++----- .gitignore | 1 + CHOLMOD/Partition/cholmod_metis.c | 9 --- CMakeLists.txt | 51 +++++++++++----- cmake/FindMETIS.cmake | 70 +++++++++++++++++----- 7 files changed, 221 insertions(+), 63 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index c9ff9cff8..bd8e3f857 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: build: - name: ${{matrix.os}}-GCC-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.gpu}} + name: ${{matrix.os}}-GCC-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.gpu}}-${{matrix.metis}} runs-on: ${{matrix.os}} defaults: run: @@ -22,6 +22,11 @@ jobs: lib: [shared, static] components: [minimal, lgpl, gpl] gpu: [no-cuda, cuda] + metis: [no-metis, metis] + exclude: + # METIS is only usable if CHOLMOD is compiled + - components: minimal + metis: metis steps: - uses: actions/checkout@v2 @@ -44,13 +49,18 @@ jobs: gfortran \ libblas-dev \ liblapack-dev \ - libmetis-dev \ libomp-dev \ libtbb-dev \ ninja-build \ nvidia-cuda-toolkit \ wget + - name: Setup METIS Dependencies + if: ${{matrix.metis == 'metis'}} + run: | + sudo apt-get install -y \ + libmetis-dev \ + - name: Setup CUDA Dependencies if: ${{matrix.gpu == 'cuda'}} run: | @@ -71,8 +81,8 @@ jobs: uses: actions/cache@v2 with: path: ${{env.CCACHE_DIR}} - key: ${{matrix.os}}-ccache-${{github.run_id}} - restore-keys: ${{matrix.os}}-ccache- + key: ${{matrix.os}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.gpu}}-${{matrix.metis}}-ccache-${{github.run_id}} + restore-keys: ${{matrix.os}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.gpu}}-${{matrix.metis}}-ccache- - name: Configure run: | @@ -82,9 +92,11 @@ jobs: -DCMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=ccache \ -DCMAKE_Fortran_COMPILER_LAUNCHER:FILEPATH=ccache \ -DCMAKE_INSTALL_PREFIX:PATH=./install \ + -DCMAKE_REQUIRE_FIND_PACKAGE_METIS=${{matrix.metis == 'metis'}} \ -DWITH_CUDA=${{matrix.gpu == 'cuda'}} \ -DWITH_GPL=${{matrix.components == 'gpl'}} \ -DWITH_LGPL=${{contains(matrix.components, 'gpl')}} \ + -DWITH_METIS=${{matrix.metis == 'metis'}} \ -G Ninja - name: Build diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index aab488d9b..0f9ff7996 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -4,25 +4,39 @@ on: [push, pull_request] jobs: build: - name: AppleClang-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}} + name: AppleClang-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.metis}} runs-on: macos-latest defaults: run: shell: bash + env: + CCACHE_DIR: ${{github.workspace}}/ccache strategy: fail-fast: true matrix: build_type: [Release, Debug] lib: [shared, static] components: [minimal, lgpl, gpl] + metis: [no-metis, metis] + exclude: + # METIS is only usable if CHOLMOD is compiled + - components: minimal + metis: metis steps: - uses: actions/checkout@v2 - - name: Setup Ninja - uses: ashutoshvarma/setup-ninja@master - with: - version: 1.10.0 + - name: Setup Dependencies + run: >- + brew install + ccache + metis + ninja + + - name: Setup METIS Dependencies + if: ${{matrix.metis == 'metis'}} + run: | + brew install metis - name: Setup Environment if: ${{matrix.build_type == 'Release'}} @@ -30,13 +44,25 @@ jobs: echo 'CFLAGS=-flto' >> $GITHUB_ENV echo 'CXXFLAGS=-flto' >> $GITHUB_ENV + - name: Cache Build + id: cache-build + uses: actions/cache@v2 + with: + path: ${{env.CCACHE_DIR}} + key: ${{runner.os}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.gpu}}-${{matrix.metis}}-ccache-${{github.run_id}} + restore-keys: ${{runner.os}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.gpu}}-${{matrix.metis}}-ccache- + - name: Configure run: | cmake -S . -B build_${{matrix.build_type}}/ \ -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} \ + -DCMAKE_C_COMPILER_LAUNCHER:FILEPATH=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=ccache \ -DCMAKE_INSTALL_PREFIX:PATH=./install \ + -DCMAKE_REQUIRE_FIND_PACKAGE_METIS=${{matrix.metis == 'metis'}} \ -DWITH_GPL=${{matrix.components == 'gpl'}} \ -DWITH_LGPL=${{contains(matrix.components, 'gpl')}} \ + -DWITH_METIS=${{matrix.metis == 'metis'}} \ -G Ninja - name: Build diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 4b97c7c3c..5e5f9c761 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: build-mingw: - name: ${{matrix.sys}}-${{matrix.env}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}} + name: ${{matrix.sys}}-${{matrix.env}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.metis}} runs-on: windows-latest defaults: run: @@ -18,6 +18,11 @@ jobs: sys: [mingw32, mingw64] lib: [shared, static] components: [minimal, lgpl, gpl] + metis: [no-metis, metis] + exclude: + # METIS is only usable if CHOLMOD is compiled + - components: minimal + metis: metis include: - sys: mingw32 env: i686 @@ -26,7 +31,9 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: msys2/setup-msys2@v2 + + - name: Setup Dependencies + uses: msys2/setup-msys2@v2 with: msystem: ${{matrix.sys}} install: >- @@ -36,13 +43,18 @@ jobs: mingw-w64-${{matrix.env}}-gcc-fortran mingw-w64-${{matrix.env}}-intel-tbb mingw-w64-${{matrix.env}}-lapack - mingw-w64-${{matrix.env}}-metis mingw-w64-${{matrix.env}}-ninja mingw-w64-${{matrix.env}}-openblas mingw-w64-${{matrix.env}}-openmp unzip wget + - name: Setup METIS Dependencies + if: ${{matrix.metis == 'metis'}} + run: >- + pacman --noconfirm -S + mingw-w64-${{matrix.env}}-metis + - name: Setup Environment if: ${{matrix.build_type == 'Release'}} run: | @@ -54,8 +66,8 @@ jobs: uses: actions/cache@v2 with: path: ${{env.CCACHE_DIR}} - key: ${{runner.os}}-${{matrix.sys}}-${{matrix.env}}-ccache-${{github.run_id}} - restore-keys: ${{runner.os}}-${{matrix.sys}}-${{matrix.env}}-ccache- + key: ${{runner.os}}-${{matrix.sys}}-${{matrix.env}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.metis}}-ccache-${{github.run_id}} + restore-keys: ${{runner.os}}-${{matrix.sys}}-${{matrix.env}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.metis}}-ccache- - name: Configure env: @@ -68,8 +80,10 @@ jobs: -DCMAKE_CXX_COMPILER_LAUNCHER:FILEPATH=ccache \ -DCMAKE_Fortran_COMPILER_LAUNCHER:FILEPATH=ccache \ -DCMAKE_INSTALL_PREFIX:PATH=./install \ + -DCMAKE_REQUIRE_FIND_PACKAGE_METIS=${{matrix.metis == 'metis'}} \ -DWITH_GPL=${{matrix.components == 'gpl'}} \ -DWITH_LGPL=${{contains(matrix.components, 'gpl')}} \ + -DWITH_METIS=${{matrix.metis == 'metis'}} \ -G Ninja - name: Build @@ -84,10 +98,11 @@ jobs: --target install build-msvc: - name: ${{matrix.msvc}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}} + name: ${{matrix.msvc}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.metis}} runs-on: ${{matrix.os}} env: CCACHE_DIR: ${{github.workspace}}/ccache + CL: /MP defaults: run: shell: powershell @@ -99,6 +114,11 @@ jobs: sys: [mingw64] lib: [shared, static] components: [minimal, lgpl, gpl] + metis: [no-metis, metis] + exclude: + # METIS is only usable if CHOLMOD is compiled + - components: minimal + metis: metis include: - sys: mingw64 env: x86_64 @@ -123,7 +143,8 @@ jobs: with: version: 1.10.0 - - uses: msys2/setup-msys2@v2 + - name: Setup MSYS2 + uses: msys2/setup-msys2@v2 with: msystem: ${{matrix.sys}} path-type: inherit @@ -132,6 +153,15 @@ jobs: mingw-w64-${{matrix.env}}-ccache mingw-w64-${{matrix.env}}-gcc-fortran + - name: Cache LAPACK + id: cache-lapack + uses: actions/cache@v2 + with: + path: | + ${{env.CCACHE_DIR}} + ${{github.workspace}}/install + key: ${{runner.os}}-lapack-3.10 + - name: Download LAPACK if: steps.cache-lapack.outputs.cache-hit != 'true' shell: msys2 {0} @@ -155,14 +185,40 @@ jobs: --config ${{matrix.build_type}} \ --target install - - name: Cache LAPACK - id: cache-lapack + - name: Cache METIS + if: matrix.metis == 'metis' + id: cache-metis uses: actions/cache@v2 with: - path: | - ${{env.CCACHE_DIR}} - ${{github.workspace}}/install - key: ${{runner.os}}-lapack-3.10 + path: metis/ + key: ${{runner.os}}-metis-5.1.1 + + - name: Download METIS + if: matrix.metis == 'metis' && steps.cache-metis.outputs.cache-hit != 'true' + run: | + (New-Object System.Net.WebClient).DownloadFile("https://github.com/KarypisLab/METIS/archive/refs/tags/v5.1.1-DistDGL-v0.5.zip", "v5.1.1-DistDGL-v0.5.zip"); + (New-Object System.Net.WebClient).DownloadFile("https://github.com/KarypisLab/GKlib/archive/refs/tags/METIS-v5.1.1-DistDGL-0.5.zip", "v5.1.1-DistDGL-v0.5-GKlib.zip"); + 7z x v5.1.1-DistDGL-v0.5.zip; + 7z x v5.1.1-DistDGL-v0.5-GKlib.zip; + + - name: Build METIS + if: matrix.metis == 'metis' && steps.cache-metis.outputs.cache-hit != 'true' + run: | + Push-Location METIS-5.1.1-DistDGL-v0.5 + Copy-Item ${{github.workspace}}/GKlib-METIS-v5.1.1-DistDGL-0.5/* -Destination GKlib/ -Recurse + New-Item -ItemType directory -Path build + Copy-Item include -Destination build/xinclude -Recurse + (Get-Content CMakeLists.txt) -Replace 'MSVC', 'FALSE' | Set-Content CMakeLists.txt + (Get-Content include/metis.h) -Replace '//#define', '#define' | Set-Content build/xinclude/metis.h + Pop-Location + + cmake -S METIS-5.1.1-DistDGL-v0.5 -B build-metis ` + -A x64 ` + -DBUILD_SHARED_LIBS=OFF ` + -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/metis ` + -DMETIS_INSTALL:BOOL=ON ` + -G "${{matrix.generator}}" + cmake --build build-metis --target install - name: Setup MSYS2 Environment shell: msys2 {0} @@ -172,7 +228,7 @@ jobs: - name: Setup Environment run: | echo "${{github.workspace}}/install/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo "VERSION_SUFFIX=$(git describe --tags)-${{matrix.marker}}-${{matrix.system}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append + echo "VERSION_SUFFIX=$(git describe --tags)-${{matrix.marker}}-${{matrix.system}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}-${{matrix.metis}}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - name: Configure run: | @@ -180,11 +236,14 @@ jobs: -A x64 ` -DBLAS_blas_LIBRARY=${{github.workspace}}/install/lib/libblas.lib ` -DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} ` - -DCMAKE_INSTALL_PREFIX:PATH=${{github.workspace}}/install-suitesparse ` + -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install-suitesparse ` + -DCMAKE_PREFIX_PATH=${{github.workspace}}/metis ` + -DCMAKE_REQUIRE_FIND_PACKAGE_METIS=${{matrix.metis == 'metis'}} ` -DLAPACK_lapack_LIBRARY=${{github.workspace}}/install/lib/liblapack.lib ` -DWITH_FORTRAN=OFF ` -DWITH_GPL=${{matrix.components == 'gpl'}} ` -DWITH_LGPL=${{contains(matrix.components, 'gpl')}} ` + -DWITH_METIS=${{matrix.metis == 'metis'}} ` -G "${{matrix.generator}}" - name: Build @@ -203,6 +262,14 @@ jobs: New-Item -ItemType "directory" -Path "${{github.workspace}}/deploy" Copy-Item -Path "${{github.workspace}}/install/*" -Destination "${{github.workspace}}/deploy/" -Recurse -Force Copy-Item -Path "${{github.workspace}}/install-suitesparse/*" -Destination "${{github.workspace}}/deploy/" -Recurse -Force + + - name: Prepare METIS Deployment + if: matrix.metis == 'metis' + run: | + Copy-Item -Path "${{github.workspace}}/metis/*" -Destination "${{github.workspace}}/deploy/" -Recurse -Force + + - name: Generate Archive + run: | Compress-Archive -Path "${{github.workspace}}/deploy/*" -Destination "SuiteSparse-${{env.VERSION_SUFFIX}}.zip" - uses: actions/upload-artifact@v2 diff --git a/.gitignore b/.gitignore index 742a578d6..165bd8026 100644 --- a/.gitignore +++ b/.gitignore @@ -218,3 +218,4 @@ ssget/files/ss_index_old.mat ssget/files/ssstats_old.csv /build*/ +*.orig diff --git a/CHOLMOD/Partition/cholmod_metis.c b/CHOLMOD/Partition/cholmod_metis.c index 96881c514..6acb4001f 100644 --- a/CHOLMOD/Partition/cholmod_metis.c +++ b/CHOLMOD/Partition/cholmod_metis.c @@ -53,16 +53,7 @@ #include "cholmod_internal.h" -#if defined(WIN32) && defined(_WINDLL) -#ifdef _MSC_VER -# pragma push_macro("_WINDLL") -# undef _WINDLL -#endif -#endif #include "metis.h" -#ifdef _MSC_VER -# pragma pop_macro("_WINDLL") -#endif #include "cholmod_partition.h" #include "cholmod_cholesky.h" diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e8a82b31..154ca7b8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,6 +103,7 @@ endif (WITH_FORTRAN) check_c_compiler_flag (-Qstd=c99 HAVE_QSTD_C99) if (NOT WITH_METIS) + # FIXME Does not work with a find module set (CMAKE_FIND_PACKAGE_DISABLE_METIS ON) endif (NOT WITH_METIS) @@ -126,6 +127,10 @@ function (check_options) # Map PARTITION to WITH_METIS if (_OPT STREQUAL PARTITION) set (_OPT_NAME METIS) + + if (NOT METIS_FOUND) + set (WITH_METIS OFF) + endif (NOT METIS_FOUND) else (_OPT STREQUAL PARTITION) set (_OPT_NAME ${_OPT}) endif (_OPT STREQUAL PARTITION) @@ -336,20 +341,17 @@ if (WITH_CHOLMOD) #CHOLMOD/Supernodal/t_cholmod_super_solve.c ) - if (NOT METIS_FOUND) + if (NOT WITH_METIS OR NOT METIS_FOUND) set_property (SOURCE CHOLMOD/Check/cholmod_check.c - CHOLMOD/Cholesky/cholmod_analyze.c CHOLMOD/Partition/cholmod_camd.c CHOLMOD/Partition/cholmod_ccolamd.c CHOLMOD/Partition/cholmod_csymamd.c CHOLMOD/Partition/cholmod_m.c CHOLMOD/Partition/cholmod_metis.c CHOLMOD/Partition/cholmod_nesdis.c - SPQR/Source/spqr_1colamd.cpp - SPQR/Source/spqr_analyze.cpp APPEND PROPERTY COMPILE_DEFINITIONS NPARTITION) - endif (NOT METIS_FOUND) + endif (NOT WITH_METIS OR NOT METIS_FOUND) configure_file (CHOLMOD/Include/cholmod_config.h.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CHOLMOD/Include/cholmod_config.h) @@ -722,12 +724,13 @@ if (WITH_CHOLMOD) target_compile_definitions (cholmod PRIVATE _GNU_SOURCE) endif (HAVE_FEENABLEEXCEPT) - if (METIS_FOUND) - target_include_directories (cholmod SYSTEM PRIVATE ${METIS_INCLUDE_DIRS}) - target_include_directories (cholmod SYSTEM PRIVATE - $) - target_link_libraries (cholmod PRIVATE ${METIS_LIBRARIES}) - endif (METIS_FOUND) + if (WITH_METIS AND METIS_FOUND) + target_link_libraries (cholmod PRIVATE METIS::METIS) + + add_library (cholmod_partition INTERFACE) + add_library (SuiteSparse::Partition ALIAS cholmod_partition) + target_link_libraries (cholmod_partition INTERFACE cholmod) + endif (WITH_METIS AND METIS_FOUND) target_link_libraries (cholmod PRIVATE BLAS::BLAS @@ -1375,6 +1378,10 @@ set_property (TARGET suitesparseconfig PROPERTY INSTALL_DESTINATION if (TARGET cholmod) list (APPEND _SuiteSparse_TARGETS cholmod) + + if (TARGET cholmod_partition) + list (APPEND _SuiteSparse_TARGETS cholmod_partition) + endif (TARGET cholmod_partition) endif (TARGET cholmod) if (TARGET spqr) @@ -1395,6 +1402,11 @@ if (TARGET gpuqrengine) endif (TARGET gpuqrengine) foreach (_target ${_SuiteSparse_TARGETS}) + if (_target STREQUAL cholmod_partition) + # cholmod_partition is meta library that does provide its own headers. + continue () + endif (_target STREQUAL cholmod_partition) + get_property (_alias TARGET ${_target} PROPERTY NAME_ALIAS) string (TOUPPER "${_target}" _upper_target) @@ -1463,6 +1475,13 @@ install (FILES DESTINATION ${SuiteSparse_CMake_INSTALLDIR} COMPONENT Development) +if (TARGET SuiteSparse::Partition) + install (FILES + cmake/FindMETIS.cmake + DESTINATION ${SuiteSparse_CMake_INSTALLDIR} + COMPONENT Development) +endif (TARGET SuiteSparse::Partition) + set_component_version (amd 2.4.6) set_component_version (btf 1.2.6) set_component_version (camd 2.4.6) @@ -1507,6 +1526,10 @@ if (TARGET cholmod) set_target_properties (cholmod PROPERTIES EXPORT_NAME CHOLMOD) endif (TARGET cholmod) +if (TARGET cholmod_partition) + set_target_properties (cholmod_partition PROPERTIES EXPORT_NAME Partition) +endif (TARGET cholmod_partition) + if (TARGET spqr) set_target_properties (spqr PROPERTIES EXPORT_NAME SPQR) endif (TARGET spqr) @@ -1722,7 +1745,7 @@ if (BUILD_CXSPARSE) add_subdirectory (CXSparse) endif (BUILD_CXSPARSE) -if (WIN32) +if (MSVC) foreach (bin IN LISTS SuiteSparse_BIN_TARGETS) install (CODE " @@ -1731,7 +1754,7 @@ fixup_bundle (\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/${b " COMPONENT Runtime) endforeach (bin) -endif (WIN32) +endif (MSVC) add_feature_info (CUDA WITH_CUDA "GPU accelerated CHOLMOD using CUDA") add_feature_info (GPL WITH_GPL "GNU GPL modules") @@ -1741,7 +1764,7 @@ add_feature_info (Check WITH_CHECK "Check module") add_feature_info (Cholesky WITH_CHOLESKY "Cholesky module") add_feature_info (Fortran WITH_FORTRAN "Fortran compilation") add_feature_info (MatrixOps WITH_MATRIXOPS "MatrixOps module") -add_feature_info (Partition WITH_METIS "Partition module") +add_feature_info (Partition "WITH_METIS AND METIS_FOUND" "Partition module") add_feature_info (Print WITH_PRINT "Additional diagnostic messages") add_feature_info (Supernodal WITH_SUPERNODAL "Supernodal module") add_feature_info (Threading WITH_TBB "Parallelization using Intel Threading Building Blocks") diff --git a/cmake/FindMETIS.cmake b/cmake/FindMETIS.cmake index 8532843e0..294fdf6f4 100644 --- a/cmake/FindMETIS.cmake +++ b/cmake/FindMETIS.cmake @@ -1,16 +1,5 @@ -# Module for locating METIS. # -# Read-only variables: -# METIS_FOUND -# Indicates whether the library has been found. -# -# METIS_INCLUDE_DIRS -# Specifies METIS' include directory. -# -# METIS_LIBRARIES -# Specifies METIS libraries that should be passed to target_link_libararies. -# -# Copyright (c) 2016, 2021 Sergiu Deitsch +# Copyright (c) 2022 Sergiu Deitsch # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -29,6 +18,25 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +# +#[=======================================================================[.rst: +Module for locating METIS +========================= + +Read-only variables: + +``METIS_FOUND`` + Indicates whether the library has been found. + +``METIS_VERSION`` + Indicates library version. + +Targets +------- + +``METIS::METIS`` + Specifies targets that should be passed to target_link_libararies. +]=======================================================================] include (FindPackageHandleStandardArgs) @@ -44,8 +52,8 @@ find_library (METIS_LIBRARY_RELEASE NAMES metis if (METIS_LIBRARY_RELEASE) if (METIS_LIBRARY_DEBUG) - set (METIS_LIBRARY debug ${METIS_LIBRARY_RELEASE} optimized - ${METIS_LIBRARY_DEBUG} CACHE STRING "METIS library") + set (METIS_LIBRARY debug ${METIS_LIBRARY_DEBUG} optimized + ${METIS_LIBRARY_RELEASE} CACHE STRING "METIS library") else (METIS_LIBRARY_DEBUG) set (METIS_LIBRARY ${METIS_LIBRARY_RELEASE} CACHE FILEPATH "METIS library") endif (METIS_LIBRARY_DEBUG) @@ -73,8 +81,38 @@ endif (EXISTS ${_METIS_VERSION_HEADER}) mark_as_advanced (METIS_INCLUDE_DIR METIS_LIBRARY_DEBUG METIS_LIBRARY_RELEASE METIS_LIBRARY) -set (METIS_INCLUDE_DIRS ${METIS_INCLUDE_DIR}) -set (METIS_LIBRARIES ${METIS_LIBRARY}) +if (NOT TARGET METIS::METIS) + if (METIS_INCLUDE_DIR OR METIS_LIBRARY) + add_library (METIS::METIS IMPORTED UNKNOWN) + endif (METIS_INCLUDE_DIR OR METIS_LIBRARY) +endif (NOT TARGET METIS::METIS) + +if (METIS_INCLUDE_DIR) + set_property (TARGET METIS::METIS PROPERTY INTERFACE_INCLUDE_DIRECTORIES + ${METIS_INCLUDE_DIR}) +endif (METIS_INCLUDE_DIR) + +if (METIS_LIBRARY_RELEASE) + set_property (TARGET METIS::METIS PROPERTY IMPORTED_LOCATION_RELEASE + ${METIS_LIBRARY_RELEASE}) + set_property (TARGET METIS::METIS APPEND PROPERTY IMPORTED_CONFIGURATIONS + RELEASE) +endif (METIS_LIBRARY_RELEASE) + +if (METIS_LIBRARY_DEBUG) + set_property (TARGET METIS::METIS PROPERTY IMPORTED_LOCATION_DEBUG + ${METIS_LIBRARY_DEBUG}) + set_property (TARGET METIS::METIS APPEND PROPERTY IMPORTED_CONFIGURATIONS + DEBUG) +endif (METIS_LIBRARY_DEBUG) + +if (METIS_INCLUDE_DIR) + set (METIS_INCLUDE_DIRS ${METIS_INCLUDE_DIR}) +endif (METIS_INCLUDE_DIR) + +if (METIS_LIBRARY) + set (METIS_LIBRARIES ${METIS_LIBRARY}) +endif (METIS_LIBRARY) find_package_handle_standard_args (METIS REQUIRED_VARS METIS_INCLUDE_DIR METIS_LIBRARY VERSION_VAR METIS_VERSION)