Skip to content

Commit

Permalink
Merge pull request #430 from ess-dmsc/issue_302
Browse files Browse the repository at this point in the history
Issue 302: add pkgconfig back
  • Loading branch information
jkotan authored Dec 11, 2019
2 parents 52965de + 774d89d commit e0dd0bf
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.0.0)
project(h5cpp
LANGUAGES CXX C
VERSION 0.3.1
VERSION 0.3.2
)

#=============================================================================
Expand Down
3 changes: 2 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ project = "h5cpp"
coverage_os = "centos7-release"

images = [
'centos7-release': [
/* 'centos7-release': [
'name': 'essdmscdm/centos7-build-node:4.0.0',
'cmake': 'CC=/usr/lib64/mpich-3.2/bin/mpicc CXX=/usr/lib64/mpich-3.2/bin/mpicxx cmake3',
'sh': '/usr/bin/scl enable devtoolset-6 -- /bin/bash -e',
'cmake_flags': '-DCOV=1 -DWITH_MPI=1 -DCONAN_FILE=conanfile_ess_mpi.txt -DCMAKE_BUILD_TYPE=Release'
],
*/
'debian9-release': [
'name': 'essdmscdm/debian9-build-node:3.0.0',
'cmake': 'cmake',
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ cmake -DCMAKE_INSTALL_PREFIX=/home/user1/some/path ..
```
and accordingly, when building the client program:
```bash
cmake -Dh5cpp_DIR=/home/user1/some/path/lib/cmake/h5cpp-0.3.1 path/to/your/source
cmake -Dh5cpp_DIR=/home/user1/some/path/lib/cmake/h5cpp-0.3.2 path/to/your/source
```
where version number may vary.

Expand Down
11 changes: 6 additions & 5 deletions cmake/ConanSetup.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
find_program(CONAN NAMES conan PATHS ${CONAN_PATH})
if(CONAN MATCHES CONAN-NOTFOUND)
find_program(CONAN_EXEC NAMES conan PATHS ${CONAN_PATH})
if(CONAN_EXEC MATCHES CONAN_EXEC-NOTFOUND)
message(FATAL_ERROR "Could not find conan executable to install dependencies ${CONAN_PATH}")
else()
message(STATUS "Found conan: ${CONAN}")
message(STATUS "Found conan: ${CONAN_EXEC}")

#need to add the directory to the path
get_filename_component(CONAN_EXEC_PATH ${CONAN} DIRECTORY)
get_filename_component(CONAN_EXEC_PATH ${CONAN_EXEC} DIRECTORY)
message(STATUS "Conan executable found in: ${CONAN_EXEC_PATH}")
set(ENV{PATH} "$ENV{PATH}:${CONAN_EXEC_PATH}")
endif()

Expand Down
4 changes: 2 additions & 2 deletions doc/design/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
# built documents.
#
# The short X.Y version.
version = u'0.3.1'
version = u'0.3.2'
# The full version, including alpha/beta/rc tags.
release = u'0.3.1'
release = u'0.3.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
6 changes: 3 additions & 3 deletions doc/source/users_guide/installing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ and for Ubuntu (Bionic)
$ wget http://repos.pni-hdri.de/bionic-pni-hdri.list
Similarly, proceed for Buster, Jessie, Cosmic or Xenial.
Similarly, proceed for Buster, Jessie, Eoan, Disco or Cosmic.
Once you have downloaded the file use

.. code-block:: bash
Expand All @@ -140,7 +140,7 @@ to update your package list and

.. code-block:: bash
$ apt-get install libh5cpp0.1.3 libh5cpp0.1.3-dbg libh5cpp0.1.3-doc libh5cpp0.1.3-dev
$ apt-get install libh5cpp0.3.2 libh5cpp0.3.2-dbg libh5cpp0.3.2-doc libh5cpp0.3.2-dev
to install the library of v0.1.3. Dependencies will be resolved automatically so you can
to install the library of v0.3.2. Dependencies will be resolved automatically so you can
start with working right after the installation has finished.
6 changes: 3 additions & 3 deletions doc/source/users_guide/using.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Using *h5cpp* with :program:`cmake`

*h5cpp* not only uses *CMake* as a build system but also provides
a *CMake* package which makes using the library with *CMake* quite simple.
The *CMake* package is installed below :file:`PREFIX/lib/cmake/h5cpp-0.3.1`
The *CMake* package is installed below :file:`PREFIX/lib/cmake/h5cpp-0.3.2`
where :envvar:`PREFIX` expands to the installation prefix used in the
inital cmake call of the installation procedure.

Expand Down Expand Up @@ -41,7 +41,7 @@ the following :file:`CMakeLists.txt` fiel is sufficient
cmake_minimum_required(VERSION 3.5.0)
project(h5cpp_test
LANGUAGES C CXX
VERSION 0.3.1)
VERSION 0.3.2)
set(CMAKE_CXX_STANDARD 11)
find_package(h5cpp REQUIRED)
Expand All @@ -56,7 +56,7 @@ You can build the code with
h5cpp_test:$ mkdir build
h5cpp_test:$ cd build
h5cpp_test:$ cmake -Dh5cpp_DIR=<INSTALLPREFIX>/lib/cmake/h5cpp-0.3.1 ../
h5cpp_test:$ cmake -Dh5cpp_DIR=<INSTALLPREFIX>/lib/cmake/h5cpp-0.3.2 ../
h5cpp_test:$ make
The cmake variable :envvar:`h5cpp_DIR` tells :program:`cmake` where to look
Expand Down
90 changes: 89 additions & 1 deletion src/h5cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ endif()

target_include_directories(h5cpp
PRIVATE ${PROJECT_SOURCE_DIR}/src
PRIVATE ${HDF5_INCLUDE_DIRS}
PUBLIC ${HDF5_INCLUDE_DIRS}
PUBLIC ${MPI_CXX_INCLUDE_PATH}
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
Expand Down Expand Up @@ -98,5 +98,93 @@ install(EXPORT h5cpp_targets
DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}
COMPONENT development)

# =============================================================================
# Build the pkg-config file
#
# basically the target provides all the information required to link against
# it via all the INTERFACE properties.
# =============================================================================
function(GET_LIBRARY_NAME LIB)

message(STATUS "Dealing with library ${LIB}")
if(TARGET "${LIB}")
#set(LIBTMP $<TARGET_FILE:LIB>)
get_property(LIBTMP TARGET ${LIB} PROPERTY IMPORTED_LOCATION)
else()
set(LIBTMP "${LIB}")
endif()

get_filename_component(LIBNAME "${LIBTMP}" NAME_WE)
get_filename_component(LIBPATH "${LIBTMP}" DIRECTORY)

string(REPLACE "${CMAKE_SHARED_LIBRARY_PREFIX}" "" LIBNAME "${LIBNAME}")
string(REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}" "" LIBNAME "${LIBNAME}")
message("Found: ${LIBNAME} in ${LIBPATH}")

if(DEFINED PKG_CONFIG_LIBS)
list(APPEND PKG_CONFIG_LIBS "${LIBNAME}")
set(PKG_CONFIG_LIBS ${PKG_CONFIG_LIBS} PARENT_SCOPE)
else()
set(PKG_CONFIG_LIBS "${LIBNAME}" PARENT_SCOPE)
endif()

if(DEFINED PKG_CONFIG_LIBDIRS)
list(APPEND PKG_CONFIG_LIBDIRS "${LIBPATH}")
set(PKG_CONFIG_LIBDIRS ${PKG_CONFIG_LIBDIRS} PARENT_SCOPE)
else()
set(PKG_CONFIG_LIBDIRS "${LIBPATH}" PARENT_SCOPE)
endif()

endfunction(GET_LIBRARY_NAME)

if(${CONAN} MATCHES "DISABLE")

get_target_property(LIBRARIES h5cpp INTERFACE_LINK_LIBRARIES)
get_target_property(DEFINITIONS h5cpp INTERFACE_COMPILE_DEFINITIONS)
get_target_property(INCLUDE_DIRS h5cpp INTERFACE_INCLUDE_DIRECTORIES)

foreach(LIB ${LIBRARIES})
GET_LIBRARY_NAME("${LIB}")
endforeach()

foreach(LIB ${HDF5_LIBRARIES})
GET_LIBRARY_NAME("${LIB}")
endforeach()

list(REMOVE_DUPLICATES PKG_CONFIG_LIBS)
list(REMOVE_DUPLICATES PKG_CONFIG_LIBDIRS)

set(PKG_CONFIG_LINKFLAGS)
foreach(DIR ${PKG_CONFIG_LIBDIRS})
set(PKG_CONFIG_LINKFLAGS "${PKG_CONFIG_LINKFLAGS} -L${DIR}")
endforeach()
foreach(LIB ${PKG_CONFIG_LIBS})
set(PKG_CONFIG_LINKFLAGS "${PKG_CONFIG_LINKFLAGS} -l${LIB}")
endforeach()

set(PKG_CONFIG_CFLAGS)

foreach(DEF ${DEFINITIONS})
if(NOT (DEF MATCHES ".*NOTFOUND"))
set(PKG_CONFIG_CFLAGS "${PKG_CONFIG_CFLAGS} -D${DEF}")
endif()
endforeach()
foreach(INCDIR ${INCLUDE_DIRS})
if(NOT (INCDIR MATCHES "\\$<.*"))
set(PKG_CONFIG_CFLAGS "${PKG_CONFIG_CFLAGS} -I${INCDIR}")
endif()
endforeach()


message("Linke libraries: ${PKG_CONFIG_LIBS}")
message("Library paths: ${PKG_CONFIG_LINKFLAGS}")


configure_file(h5cpp.pc.in h5cpp.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/h5cpp.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT development)

endif()


6 changes: 6 additions & 0 deletions src/h5cpp/h5cpp.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Name: H5CPP
Description: C++ wrapper for the HDF5 C-API
Version: @PROJECT_VERSION@
Requires:
Cflags: -I@CMAKE_INSTALL_FULL_INCLUDEDIR@ @PKG_CONFIG_CFLAGS@
Libs: -L@CMAKE_INSTALL_FULL_LIBDIR@ -lh5cpp @PKG_CONFIG_LINKFLAGS@

0 comments on commit e0dd0bf

Please sign in to comment.