Skip to content

Commit

Permalink
Fix comments for pull-request #31
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrugman committed Aug 2, 2023
1 parent e0634e8 commit c84d49f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ CMakeCache.txt
CMakeFiles/*
Makefile
cmake_install.cmake
install_manifest.txt
pfs-config.cmake

# Artifacts
lib/*
Expand Down
39 changes: 31 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,39 @@ if (pfs_BUILD_TESTS)
target_link_libraries (unittest PRIVATE pfs)
endif()

# ------------------------------------------------------------------------
# Generate a CMake package configuration file to support find_package()
# ------------------------------------------------------------------------

include(CMakePackageConfigHelpers)
include(GNUInstallDirs) # Sets a default value for CMAKE_INSTALL_LIBDIR

set (pfs_PACKAGE_CONFIG ${CMAKE_PROJECT_NAME}-config.cmake)
set (pfs_PACKAGE_CONFIG_IN ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${pfs_PACKAGE_CONFIG}.in)
set (pfs_PACKAGE_CONFIG_OUT ${CMAKE_CURRENT_BINARY_DIR}/${pfs_PACKAGE_CONFIG})

set (pfs_PACKAGE_INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})

set (pfs_EXPORT_NAME ${CMAKE_PROJECT_NAME}Targets)

configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/${CMAKE_PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
${pfs_PACKAGE_CONFIG_IN}
${pfs_PACKAGE_CONFIG_OUT}
INSTALL_DESTINATION ${pfs_PACKAGE_INSTALL_DESTINATION}
)

install(
TARGETS ${CMAKE_PROJECT_NAME}
EXPORT ${pfs_EXPORT_NAME}
)

install(
EXPORT ${pfs_EXPORT_NAME}
FILE ${pfs_PACKAGE_CONFIG}
DESTINATION ${pfs_PACKAGE_INSTALL_DESTINATION}
)

install(TARGETS ${CMAKE_PROJECT_NAME} EXPORT ${CMAKE_PROJECT_NAME}Targets)
install(EXPORT ${CMAKE_PROJECT_NAME}Targets
FILE ${CMAKE_PROJECT_NAME}-config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
install(
DIRECTORY include/
DESTINATION include
)
install(DIRECTORY include/ DESTINATION include)
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ After that, just use `make` as always.
- Add the contents of `/include` into your include directories.
That's it, you are good to go.

### Use CMake's [`find_package()`](https://cmake.org/cmake/help/latest/command/find_package.html)

After building the project, you can install it locally using `make install`.
In your project's CMake file, you can then add the following snippet, and CMake will handle the rest:
```
find_package(pfs)
include_directories (${pfs_INCLUDE_DIRS})
...
target_link_libraries (<your-target> pfs)
```

CMake generates an `install_manifest.txt` file to track all the created files, this will help you uninstall the library if you need to do so.

## Features

- Parsing system-wide information from files directly under `/procfs`. See `procfs.hpp` for all the supported files.
Expand Down
3 changes: 1 addition & 2 deletions cmake/pfs-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/pfsTargets.cmake")
check_required_components(pfs)
check_required_components(pfs)

0 comments on commit c84d49f

Please sign in to comment.