Creating and installing .cmake file

Creating and installing a .cmake file that simplifies locating
this library from within a project that uses CMake.

To make use of this .cmake file, the .cmake file must be loaded
in a CMakeLists.txt file, for example through

  find_package(Osmpbf REQUIRED)

Then two variables will be available:

  OSMPBF_INCLUDE_DIRS
  OSMPBF_LIBRARIES

The former variable can be used in a 'include_directories'
statement, the latter one in a 'target_link_libraries' statement.
This commit is contained in:
Thomas Fischer 2016-01-29 08:53:27 +01:00
parent 1283c4a48d
commit eff2cdee64
2 changed files with 5 additions and 0 deletions

View File

@ -17,3 +17,6 @@ SET(INCLUDE_INSTALL "include/osmpbf")
SET(files ${CMAKE_SOURCE_DIR}/include/osmpbf/osmpbf.h ${CMAKE_BINARY_DIR}/src/osmformat.pb.h ${CMAKE_BINARY_DIR}/src/fileformat.pb.h)
INSTALL(FILES ${files} DESTINATION ${INCLUDE_INSTALL})
install(TARGETS osmpbf LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
configure_file("OsmpbfConfig.cmake.in" "OsmpbfConfig.cmake" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/OsmpbfConfig.cmake" DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/cmake/Osmpbf/)

View File

@ -0,0 +1,2 @@
set(OSMPBF_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include/osmpbf")
set(OSMPBF_LIBRARIES "@CMAKE_INSTALL_PREFIX@/lib/libosmpbf.a")