Skip to content

Commit

Permalink
Add package config file generation for find_package
Browse files Browse the repository at this point in the history
(without package config version file)
  • Loading branch information
apekar-swi committed Aug 28, 2019
1 parent 1e91c50 commit 9f5ae9e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CMake/HippoMocksConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@PACKAGE_INIT@

if(NOT TARGET HippoMocks::HippoMocks)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")

include(${CMAKE_CURRENT_LIST_DIR}/HippoMocksTargets.cmake)
endif()
28 changes: 26 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,29 @@ project(HippoMocks)
add_subdirectory(HippoMocks)
add_subdirectory(HippoMocksTest)

install(FILES ${PROJECT_SOURCE_DIR}/HippoMocks/hippomocks.h
DESTINATION include/)
include(CMakePackageConfigHelpers)

set(HIPPOMOCKS_CMAKE_CONFIG_DESTINATION "cmake/")

configure_package_config_file(
${CMAKE_CURRENT_LIST_DIR}/CMake/HippoMocksConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/HippoMocksConfig.cmake
INSTALL_DESTINATION
${HIPPOMOCKS_CMAKE_CONFIG_DESTINATION}
)

install(
EXPORT
HippoMocksTargets
NAMESPACE
HippoMocks::
DESTINATION
${HIPPOMOCKS_CMAKE_CONFIG_DESTINATION}
)

install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/HippoMocksConfig.cmake"
DESTINATION
${HIPPOMOCKS_CMAKE_CONFIG_DESTINATION}
)
14 changes: 13 additions & 1 deletion HippoMocks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@

add_library(HippoMocks INTERFACE)
target_include_directories(HippoMocks INTERFACE .)
target_include_directories(HippoMocks INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include>)
if (NOT WIN32)
target_compile_options(HippoMocks
INTERFACE
-Wall -Wextra -pedantic -Wno-long-long -std=c++11
)
endif()

install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/hippomocks.h
DESTINATION include/)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/detail
DESTINATION include)

install(
TARGETS
HippoMocks
EXPORT
HippoMocksTargets
DESTINATION
./
)

0 comments on commit 9f5ae9e

Please sign in to comment.