diff --git a/.github/workflows/jobs.yml b/.github/workflows/jobs.yml index b8853d619..412b8ebdb 100644 --- a/.github/workflows/jobs.yml +++ b/.github/workflows/jobs.yml @@ -25,6 +25,28 @@ jobs: make all make test make package_source + ubuntu_latest_cmake_install: + runs-on: ubuntu-latest + steps: + - name: Clone and check out repository code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + ref: ${{github.event.pull_request.head.ref}} # Branch where changes are implemented. + repository: ${{github.event.pull_request.head.repo.full_name}} # Repo where changes are implemented. + - name: Check commit + run: | + git log -1 + - name: Update OS + run: sudo apt-get update + - name: Install apt-get dependencies + run: sudo apt-get install -y gfortran gcc g++ openmpi-bin libopenmpi-dev libblas-dev liblapack-dev cmake + - name: Run job + run: | + mkdir build + cd build + cmake .. + bash ./tstCMakeInstall.sh ubuntu_latest_autotools: runs-on: ubuntu-latest steps: diff --git a/CHANGES b/CHANGES index a5633f0f1..688b8410d 100644 --- a/CHANGES +++ b/CHANGES @@ -11,9 +11,12 @@ arpack-ng - 3.9.0 * Support for NAG's nagfor Fortran compiler [ Franck Houssen ] +* Test CMake find_package (*.cmake files). * [BUG FIX] autotools: ICB must be checked first (MPI changes compilers). * [BUG FIX] BLAS/LAPACK: allow suffixes in case BLAS/LAPACK can not provide ICB. * [BUG FIX] Compile C programs with ICB. +* arpackmm: command line bug fix. +* arpackmm: restart bug fix. [ Haoyang Liu ] * CMake: minimum required version changed to 3.0 @@ -24,10 +27,6 @@ arpack-ng - 3.9.0 [ Robert Schütz ] * use CMAKE_INSTALL_FULL_ in arpack.pc -[ Franck Houssen ] - * arpackmm: command line bug fix. - * arpackmm: restart bug fix. - -- Sylvestre Ledru Mon, 07 Dec 2020 11:37:40 +0100 arpack-ng - 3.8.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index c7902a472..0a978b72d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,7 @@ function(examples list_name) foreach(l ${${list_name}}) get_filename_component(lwe ${l} NAME_WE) add_executable(${lwe} ${arpackexample_DIR}/${l} ${examples_EXTRA_SRCS}) - target_link_libraries(${lwe} arpack BLAS::BLAS LAPACK::LAPACK ${EXTRA_LDFLAGS}) + target_link_libraries(${lwe} arpack BLAS::BLAS LAPACK::LAPACK ${EXTRA_LDFLAGS}) add_test(NAME "${lwe}_ex" COMMAND ${lwe} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) endforeach() endfunction(examples) @@ -730,7 +730,7 @@ include(GNUInstallDirs) set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix \${prefix}) set(libdir ${CMAKE_INSTALL_FULL_LIBDIR}) -set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR}) +set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) set(PACKAGE_NAME ${PROJECT_NAME}) set(PACKAGE_VERSION ${arpack_ng_VERSION}) set(PACKAGE_URL "https://github.com/opencollab/arpack-ng/") @@ -775,43 +775,45 @@ if (MPI) endif () if(ICB) - install(FILES ICB/arpack.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) - install(FILES ICB/arpack.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) + install(FILES ICB/arpack.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) + install(FILES ICB/arpack.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) if (MPI) - install(FILES ICB/parpack.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) - install(FILES ICB/parpack.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) + install(FILES ICB/parpack.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) + install(FILES ICB/parpack.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) endif() if (ICBEXMM) - install(FILES EXAMPLES/MATRIX_MARKET/arpackSolver.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) + install(FILES EXAMPLES/MATRIX_MARKET/arpackSolver.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) install(FILES "${PROJECT_BINARY_DIR}/EXAMPLES/MATRIX_MARKET/arpackSolver.pc" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endif() endif() -install(FILES debug.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) -install(FILES debugF90.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) +install(FILES debug.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) +install(FILES debugF90.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) if(ICB) - install(FILES ICB/debug_c.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) - install(FILES ICB/debug_c.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) + install(FILES ICB/debug_c.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) + install(FILES ICB/debug_c.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) endif() -install(FILES stat.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) -install(FILES statF90.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) +install(FILES stat.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) +install(FILES statF90.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) if(ICB) - install(FILES ICB/stat_c.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) - install(FILES ICB/stat_c.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) + install(FILES ICB/stat_c.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) + install(FILES ICB/stat_c.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) endif() configure_file(arpackdef.h.in "${PROJECT_BINARY_DIR}/arpackdef.h" @ONLY) -install(FILES "${PROJECT_BINARY_DIR}/arpackdef.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) +install(FILES "${PROJECT_BINARY_DIR}/arpackdef.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) configure_file(arpackicb.h.in "${PROJECT_BINARY_DIR}/arpackicb.h" @ONLY) -install(FILES "${PROJECT_BINARY_DIR}/arpackicb.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack) +install(FILES "${PROJECT_BINARY_DIR}/arpackicb.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng) # Provide find_package for arpack-ng to users. -configure_file(arpack-ng-config.cmake.in "${PROJECT_BINARY_DIR}/arpack-ng-config.cmake" @ONLY) -install(FILES "${PROJECT_BINARY_DIR}/arpack-ng-config.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/arpack-ng) # find_package(arpack-ng) -configure_file(arpack-ng-config-version.cmake.in "${PROJECT_BINARY_DIR}/arpack-ng-config-version.cmake" @ONLY) -install(FILES "${PROJECT_BINARY_DIR}/arpack-ng-config-version.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/arpack-ng) +configure_file(cmake/arpackng-config.cmake.in "${PROJECT_BINARY_DIR}/arpackng-config.cmake" @ONLY) +install(FILES "${PROJECT_BINARY_DIR}/arpackng-config.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/arpack-ng) # find_package(arpackng) +configure_file(cmake/arpackng-config-version.cmake.in "${PROJECT_BINARY_DIR}/arpackng-config-version.cmake" @ONLY) +install(FILES "${PROJECT_BINARY_DIR}/arpackng-config-version.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/arpack-ng) + +configure_file(cmake/tstCMakeInstall.sh.in ${PROJECT_BINARY_DIR}/tstCMakeInstall.sh @ONLY) # Packaging: ease arpack-ng distribution (precompiled binaries and sources tarballs). set(CPACK_VERSION_MAJOR "${arpack_ng_MAJOR_VERSION}") diff --git a/Makefile.am b/Makefile.am index 0610dea2a..84bbf1265 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,6 +25,3 @@ endif EXTRA_DIST = README.md PARPACK_CHANGES CHANGES DOCUMENTS VISUAL_STUDIO \ detect_arpack_bug.m4 CMakeLists.txt - -cmakedir = $(libdir)/cmake/arpack-ng -cmake_DATA = arpack-ng-config.cmake arpack-ng-config-version.cmake diff --git a/PARPACK/SRC/MPI/parpack.pc.in b/PARPACK/SRC/MPI/parpack.pc.in index bbc75c712..3cff6cad4 100644 --- a/PARPACK/SRC/MPI/parpack.pc.in +++ b/PARPACK/SRC/MPI/parpack.pc.in @@ -1,6 +1,6 @@ prefix=@prefix@ -exec_prefix=@exec_prefix@ libdir=@libdir@ +includedir=@includedir@ Name: @PACKAGE_NAME@ Description: Collection of Fortran77 subroutines designed to solve large scale eigenvalue problems @@ -9,3 +9,4 @@ URL: @PACKAGE_URL@ Requires.private: arpack@LIBSUFFIX@ Libs: -L${libdir} -lparpack@LIBSUFFIX@ Libs.private: @PARPACK_PC_LIBS_PRIVATE@ +Cflags: -I${includedir} diff --git a/SRC/arpack.pc.in b/SRC/arpack.pc.in index a5550cebc..1c4883a70 100644 --- a/SRC/arpack.pc.in +++ b/SRC/arpack.pc.in @@ -1,5 +1,4 @@ prefix=@prefix@ -exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ @@ -9,4 +8,4 @@ Version: @PACKAGE_VERSION@ URL: @PACKAGE_URL@ Libs: -L${libdir} -larpack@LIBSUFFIX@ Libs.private: @ARPACK_PC_LIBS_PRIVATE@ -Cflags: -I${includedir}/arpack +Cflags: -I${includedir} diff --git a/arpack-ng-config.cmake.in b/arpack-ng-config.cmake.in deleted file mode 100644 index b8c011b1a..000000000 --- a/arpack-ng-config.cmake.in +++ /dev/null @@ -1,25 +0,0 @@ -# Config file for the arpack-ng package. -# -# To use arpack from CMake, use ARPACK::ARPACK target: -# find_package(arpack-ng) -# add_executable(main main.f) -# target_include_directories(main PRIVATE ARPACK::ARPACK) -# target_link_libraries(main ARPACK::ARPACK) -# -# To use parpack from CMake, use PARPACK::PARPACK target: -# find_package(arpack-ng) -# add_executable(main main.f) -# target_link_libraries(main PARPACK::PARPACK) - -# Create local variables. -set(prefix "@prefix@") -set(exec_prefix "@exec_prefix@") -set(libdir "@libdir@") -set(includedir "@includedir@") - -# Create arpack targets. -add_library(ARPACK::ARPACK INTERFACE IMPORTED) -set_target_properties(ARPACK::ARPACK PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${includedir}/arpack") -set_target_properties(ARPACK::ARPACK PROPERTIES INTERFACE_LINK_LIBRARIES "arpack") -add_library(PARPACK::PARPACK INTERFACE IMPORTED) -set_target_properties(PARPACK::PARPACK PROPERTIES INTERFACE_LINK_LIBRARIES "parpack") diff --git a/arpack-ng-config-version.cmake.in b/cmake/arpackng-config-version.cmake.in similarity index 100% rename from arpack-ng-config-version.cmake.in rename to cmake/arpackng-config-version.cmake.in diff --git a/cmake/arpackng-config.cmake.in b/cmake/arpackng-config.cmake.in new file mode 100644 index 000000000..bf78a7861 --- /dev/null +++ b/cmake/arpackng-config.cmake.in @@ -0,0 +1,28 @@ +# Config file for the arpack-ng package. +# +# To use arpack from CMake, use ARPACK::ARPACK target: +# find_package(arpackng) +# add_executable(main main.f) +# target_include_directories(main INTERFACE ARPACK::ARPACK) +# target_link_libraries(main ARPACK::ARPACK) +# +# To use parpack from CMake, use PARPACK::PARPACK target: +# find_package(arpackng) +# add_executable(main main.f) +# target_include_directories(main INTERFACE PARPACK::PARPACK) +# target_link_libraries(main PARPACK::PARPACK) + +# Create arpack targets. +add_library(ARPACK::ARPACK INTERFACE IMPORTED) +set_target_properties(ARPACK::ARPACK PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/arpack-ng") +set_target_properties(ARPACK::ARPACK PROPERTIES INTERFACE_LINK_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@") +set_target_properties(ARPACK::ARPACK PROPERTIES INTERFACE_LINK_LIBRARIES "arpack") + +# Create parpack targets. +set(MPI "@MPI@") +if (MPI) + add_library(PARPACK::PARPACK INTERFACE IMPORTED) + set_target_properties(PARPACK::PARPACK PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/arpack-ng") + set_target_properties(PARPACK::PARPACK PROPERTIES INTERFACE_LINK_DIRECTORIES "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@") + set_target_properties(PARPACK::PARPACK PROPERTIES INTERFACE_LINK_LIBRARIES "parpack") +endif () diff --git a/cmake/tstCMakeInstall.sh.in b/cmake/tstCMakeInstall.sh.in new file mode 100755 index 000000000..945ef2e89 --- /dev/null +++ b/cmake/tstCMakeInstall.sh.in @@ -0,0 +1,100 @@ +#!/bin/bash -eu +# Testing that find_package works. +# Note: this script must not be added to the test suite as it will change cmake options. + +# 1. Define temporary directory. + +export TMP_DIR="/tmp/tstCMakeInstall" +mkdir -p "${TMP_DIR}" + +# 2. Rerun cmake with prefix, install arpack-ng. +# Note: this script must not be added to the test suite as it will change cmake options. + +export TMP_PREFIX="${TMP_DIR}/local" +cmake -DCMAKE_INSTALL_PREFIX="${TMP_PREFIX}" -DMPI=ON . +make all install + +# 3. Setup environment for find_package to work (what you typically in module-environment files). + +cd "${TMP_DIR}" +export ARCH="$(ls ./local/lib/)" +export PKG_CONFIG_PATH="${TMP_PREFIX}/lib/${ARCH}/pkgconfig" +export arpackng_DIR="${TMP_PREFIX}/lib/${ARCH}/cmake/arpack-ng" + +# 4. Create new cmake project, in temporary directory, with files from arpack-ng. + +mkdir -p tstCMakeInstall +cd tstCMakeInstall + +cp "@PROJECT_SOURCE_DIR@/EXAMPLES/BAND/dnband.f" . +cp "@PROJECT_SOURCE_DIR@/EXAMPLES/BAND/dnbdr1.f" . +cp "@PROJECT_SOURCE_DIR@/EXAMPLES/BAND/dnbdr3.f" . +cp "@PROJECT_SOURCE_DIR@/PARPACK/EXAMPLES/MPI/pdndrv1.f" . +cp "@PROJECT_SOURCE_DIR@/PARPACK/EXAMPLES/MPI/pdndrv3.f" . + +echo "cmake_minimum_required(VERSION 3.0)" > CMakeLists.txt +echo "" >> CMakeLists.txt +echo "project(tstCMakeInstall Fortran)" >> CMakeLists.txt +echo "" >> CMakeLists.txt +echo "find_package(BLAS REQUIRED)" >> CMakeLists.txt +echo "find_package(LAPACK REQUIRED)" >> CMakeLists.txt +echo "find_package(MPI REQUIRED COMPONENTS Fortran)" >> CMakeLists.txt +echo "find_package(arpackng REQUIRED)" >> CMakeLists.txt +echo "" >> CMakeLists.txt +echo "add_executable(dnbdr1 dnband.f dnbdr1.f)" >> CMakeLists.txt +echo "target_include_directories(dnbdr1 INTERFACE BLAS::BLAS)" >> CMakeLists.txt +echo "target_link_libraries(dnbdr1 BLAS::BLAS)" >> CMakeLists.txt +echo "target_include_directories(dnbdr1 INTERFACE LAPACK::LAPACK)" >> CMakeLists.txt +echo "target_link_libraries(dnbdr1 LAPACK::LAPACK)" >> CMakeLists.txt +echo "target_include_directories(dnbdr1 INTERFACE ARPACK::ARPACK)" >> CMakeLists.txt +echo "target_link_libraries(dnbdr1 ARPACK::ARPACK)" >> CMakeLists.txt +echo "" >> CMakeLists.txt +echo "add_executable(pdndrv1 dnband.f pdndrv1.f)" >> CMakeLists.txt +echo "target_include_directories(pdndrv1 INTERFACE BLAS::BLAS)" >> CMakeLists.txt +echo "target_link_libraries(pdndrv1 BLAS::BLAS)" >> CMakeLists.txt +echo "target_include_directories(pdndrv1 INTERFACE LAPACK::LAPACK)" >> CMakeLists.txt +echo "target_link_libraries(pdndrv1 LAPACK::LAPACK)" >> CMakeLists.txt +echo "target_include_directories(pdndrv1 INTERFACE MPI::MPI_Fortran)" >> CMakeLists.txt +echo "target_link_libraries(pdndrv1 MPI::MPI_Fortran)" >> CMakeLists.txt +echo "target_include_directories(pdndrv1 INTERFACE ARPACK::ARPACK)" >> CMakeLists.txt +echo "target_link_libraries(pdndrv1 ARPACK::ARPACK)" >> CMakeLists.txt +echo "target_include_directories(pdndrv1 INTERFACE PARPACK::PARPACK)" >> CMakeLists.txt +echo "target_link_libraries(pdndrv1 PARPACK::PARPACK)" >> CMakeLists.txt +echo "" >> CMakeLists.txt +echo "find_package(PkgConfig REQUIRED)" >> CMakeLists.txt +echo "pkg_check_modules(ARPACK IMPORTED_TARGET REQUIRED arpack)" >> CMakeLists.txt +echo "pkg_check_modules(PARPACK IMPORTED_TARGET REQUIRED parpack)" >> CMakeLists.txt +echo "" >> CMakeLists.txt +echo "add_executable(dnbdr3 dnband.f dnbdr3.f)" >> CMakeLists.txt +echo "target_include_directories(dnbdr3 INTERFACE BLAS::BLAS)" >> CMakeLists.txt +echo "target_link_libraries(dnbdr3 BLAS::BLAS)" >> CMakeLists.txt +echo "target_include_directories(dnbdr3 INTERFACE LAPACK::LAPACK)" >> CMakeLists.txt +echo "target_link_libraries(dnbdr3 LAPACK::LAPACK)" >> CMakeLists.txt +echo "target_include_directories(dnbdr3 INTERFACE PkgConfig::ARPACK)" >> CMakeLists.txt +echo "target_link_libraries(dnbdr3 PkgConfig::ARPACK)" >> CMakeLists.txt +echo "" >> CMakeLists.txt +echo "add_executable(pdndrv3 dnband.f pdndrv3.f)" >> CMakeLists.txt +echo "target_include_directories(pdndrv3 INTERFACE BLAS::BLAS)" >> CMakeLists.txt +echo "target_link_libraries(pdndrv3 BLAS::BLAS)" >> CMakeLists.txt +echo "target_include_directories(pdndrv3 INTERFACE LAPACK::LAPACK)" >> CMakeLists.txt +echo "target_link_libraries(pdndrv3 LAPACK::LAPACK)" >> CMakeLists.txt +echo "target_include_directories(pdndrv3 INTERFACE MPI::MPI_Fortran)" >> CMakeLists.txt +echo "target_link_libraries(pdndrv3 MPI::MPI_Fortran)" >> CMakeLists.txt +echo "target_include_directories(pdndrv3 INTERFACE PkgConfig::ARPACK)" >> CMakeLists.txt +echo "target_link_libraries(pdndrv3 PkgConfig::ARPACK)" >> CMakeLists.txt +echo "target_include_directories(pdndrv3 INTERFACE PkgConfig::PARPACK)" >> CMakeLists.txt +echo "target_link_libraries(pdndrv3 PkgConfig::PARPACK)" >> CMakeLists.txt + +# 5. Build and test this new project with cmake: for this to be possible, find_package must work. + +mkdir -p build +cd build + +cmake .. +make all VERBOSE=1 + +./dnbdr1 +mpirun -n 2 ./pdndrv1 +./dnbdr3 +mpirun -n 2 ./pdndrv3 + diff --git a/configure.ac b/configure.ac index 587bd4f61..661d0406a 100644 --- a/configure.ac +++ b/configure.ac @@ -299,12 +299,11 @@ AC_CONFIG_FILES([ PARPACK/SRC/MPI/parpack$LIBSUFFIX.pc:PARPACK/SRC/MPI/parpack.pc.in ], [], [LIBSUFFIX="$LIBSUFFIX"]) +dnl We do NOT want arpackng*.cmake files to be created: @MPI@ can not be replaced. AC_CONFIG_FILES([ EXAMPLES/MATRIX_MARKET/arpackSolver.pc arpackdef.h arpackicb.h - arpack-ng-config-version.cmake - arpack-ng-config.cmake Makefile ICB/Makefile UTIL/Makefile