From 4190a3e31625b8c3169dde8fdfc6aa04d331576c Mon Sep 17 00:00:00 2001 From: Michael Hirsch Date: Wed, 24 Aug 2022 23:38:58 -0400 Subject: [PATCH] cpack: correct parameters --- CMakeLists.txt | 2 +- cmake/h5fortran.cmake | 8 ++++---- cmake/hdf5.cmake | 10 +++++----- cmake/install.cmake | 3 +-- cmake/options.cmake | 23 +++++++---------------- cmake/zlib.cmake | 10 +++++----- fpm.toml | 2 +- 7 files changed, 24 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 42e2313..df874a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ endif() project(h5fortran LANGUAGES C Fortran -VERSION 4.10.0 +VERSION 4.10.1 ) include(CTest) diff --git a/cmake/h5fortran.cmake b/cmake/h5fortran.cmake index 033424f..3fff47a 100644 --- a/cmake/h5fortran.cmake +++ b/cmake/h5fortran.cmake @@ -1,15 +1,15 @@ include(ExternalProject) -set(h5fortran_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include) +set(h5fortran_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) if(BUILD_SHARED_LIBS) if(WIN32) - set(h5fortran_LIBRARIES ${CMAKE_INSTALL_PREFIX}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}h5fortran${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(h5fortran_LIBRARIES ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}h5fortran${CMAKE_SHARED_LIBRARY_SUFFIX}) else() - set(h5fortran_LIBRARIES ${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}h5fortran${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(h5fortran_LIBRARIES ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}h5fortran${CMAKE_SHARED_LIBRARY_SUFFIX}) endif() else() - set(h5fortran_LIBRARIES ${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}h5fortran${CMAKE_STATIC_LIBRARY_SUFFIX}) + set(h5fortran_LIBRARIES ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}h5fortran${CMAKE_STATIC_LIBRARY_SUFFIX}) endif() set(h5fortran_cmake_args diff --git a/cmake/hdf5.cmake b/cmake/hdf5.cmake index 3cae2b5..57ecb12 100644 --- a/cmake/hdf5.cmake +++ b/cmake/hdf5.cmake @@ -1,7 +1,7 @@ # builds HDF5 library from scratch # note: the use of "lib" vs. CMAKE_*_LIBRARY_PREFIX is deliberate based on HDF5 # across Intel Fortran on Windows (MSVC-like) vs. Gfortran on Windows vs. Linux. - +include(GNUInstallDirs) include(ExternalProject) if(hdf5_parallel) @@ -17,16 +17,16 @@ set(HDF5_LIBRARIES) foreach(_name hdf5_hl_fortran hdf5_hl_f90cstub hdf5_fortran hdf5_f90cstub hdf5_hl hdf5) if(BUILD_SHARED_LIBS) if(WIN32) - list(APPEND HDF5_LIBRARIES ${CMAKE_INSTALL_PREFIX}/bin/lib${_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) + list(APPEND HDF5_LIBRARIES ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/lib${_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) else() - list(APPEND HDF5_LIBRARIES ${CMAKE_INSTALL_PREFIX}/lib/lib${_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) + list(APPEND HDF5_LIBRARIES ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/lib${_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) endif() else() - list(APPEND HDF5_LIBRARIES ${CMAKE_INSTALL_PREFIX}/lib/lib${_name}${CMAKE_STATIC_LIBRARY_SUFFIX}) + list(APPEND HDF5_LIBRARIES ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/lib${_name}${CMAKE_STATIC_LIBRARY_SUFFIX}) endif() endforeach() -set(HDF5_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include) +set(HDF5_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}) # --- Zlib if(NOT TARGET ZLIB::ZLIB) diff --git a/cmake/install.cmake b/cmake/install.cmake index fa93948..e4a942f 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -32,8 +32,7 @@ set(CPACK_PACKAGE_CONTACT "Michael Hirsch") set(CPACK_DEBIAN_PACKAGE_DEPENDS "libhdf5-dev (>=1.10)") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") -set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/package") -set(CPACK_PACKAGE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +set(CPACK_PACKAGE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/package) # not .gitignore as its regex syntax is more advanced than CMake set(CPACK_SOURCE_IGNORE_FILES .git/ .github/ .vscode/ .mypy_cache/ _CPack_Packages/ diff --git a/cmake/options.cmake b/cmake/options.cmake index 58047ff..c167122 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -1,3 +1,5 @@ +include(GNUInstallDirs) + message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION} CMake ${CMAKE_VERSION}") option(ENABLE_COVERAGE "Code coverage tests") @@ -10,32 +12,21 @@ set(CMAKE_TLS_VERIFY true) include(GNUInstallDirs) -if(BUILD_SHARED_LIBS) - if(WIN32 AND CMAKE_VERSION VERSION_LESS 3.21 AND ${PROJECT_NAME}_BUILD_TESTING) - message(STATUS "Windows with shared libs needs CMake >= 3.21 to run tests") - endif() - if(MSVC) - message(WARNING "Intel oneAPI has trouble with shared libs in general on Windows, try - cmake -DBUILD_SHARED_LIBS=off") - endif() +if(BUILD_SHARED_LIBS AND MSVC) + message(WARNING "Intel oneAPI has trouble with shared libs in general on Windows, try + cmake -DBUILD_SHARED_LIBS=off") endif() list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) # Rpath options necessary for shared library install to work correctly in user projects -set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib) -set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib) +set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) +set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH true) # Necessary for shared library with Visual Studio / Windows oneAPI set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS true) -if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - # will not take effect without FORCE - # CMAKE_BINARY_DIR for use from FetchContent - set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR} CACHE PATH "Install top-level directory" FORCE) -endif() - # allow CMAKE_PREFIX_PATH with ~ expand if(CMAKE_PREFIX_PATH) get_filename_component(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ABSOLUTE) diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake index 6879708..e306bc6 100644 --- a/cmake/zlib.cmake +++ b/cmake/zlib.cmake @@ -1,6 +1,6 @@ # build Zlib to ensure compatibility. # We use Zlib 2.x for speed and robustness. - +include(GNUInstallDirs) include(ExternalProject) if(zlib_legacy) @@ -16,15 +16,15 @@ set(ZLIB_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include) if(BUILD_SHARED_LIBS) if(WIN32) - set(ZLIB_LIBRARIES ${CMAKE_INSTALL_PREFIX}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}zlib1${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(ZLIB_LIBRARIES ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}zlib1${CMAKE_SHARED_LIBRARY_SUFFIX}) else() - set(ZLIB_LIBRARIES ${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}z${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(ZLIB_LIBRARIES ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}z${CMAKE_SHARED_LIBRARY_SUFFIX}) endif() else() if(MSVC OR (WIN32 AND zlib_legacy)) - set(ZLIB_LIBRARIES ${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}zlibstatic${CMAKE_STATIC_LIBRARY_SUFFIX}) + set(ZLIB_LIBRARIES ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}zlibstatic${CMAKE_STATIC_LIBRARY_SUFFIX}) else() - set(ZLIB_LIBRARIES ${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}z${CMAKE_STATIC_LIBRARY_SUFFIX}) + set(ZLIB_LIBRARIES ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}z${CMAKE_STATIC_LIBRARY_SUFFIX}) endif() endif() diff --git a/fpm.toml b/fpm.toml index 171e2d6..9cb54d4 100644 --- a/fpm.toml +++ b/fpm.toml @@ -1,7 +1,7 @@ name = "h5fortran" description = "Lightweight object-oriented HDF5 interface" categories = "io" -version = "4.9.0" +version = "4.10.1" [build] auto-tests = false