Skip to content

Commit

Permalink
cpack: correct parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Aug 25, 2022
1 parent 2298873 commit 4190a3e
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 34 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ endif()

project(h5fortran
LANGUAGES C Fortran
VERSION 4.10.0
VERSION 4.10.1
)

include(CTest)
Expand Down
8 changes: 4 additions & 4 deletions cmake/h5fortran.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions cmake/hdf5.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions cmake/install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
23 changes: 7 additions & 16 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include(GNUInstallDirs)

message(STATUS "${PROJECT_NAME} ${PROJECT_VERSION} CMake ${CMAKE_VERSION}")

option(ENABLE_COVERAGE "Code coverage tests")
Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions cmake/zlib.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion fpm.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 4190a3e

Please sign in to comment.