Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add package config file generation for find_package #106

Open
wants to merge 1 commit into
base: cpp11
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
35 changes: 32 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,39 @@
cmake_minimum_required(VERSION 3.0)

enable_testing()

project(HippoMocks)

include(CTest)

add_subdirectory(HippoMocks)
add_subdirectory(HippoMocksTest)
if (BUILD_TESTING)
add_subdirectory(HippoMocksTest)
endif()

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 ${PROJECT_SOURCE_DIR}/HippoMocks/hippomocks.h
DESTINATION include/)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/HippoMocksConfig.cmake"
DESTINATION
${HIPPOMOCKS_CMAKE_CONFIG_DESTINATION}
)
21 changes: 14 additions & 7 deletions HippoMocks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@

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

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
./
)
8 changes: 8 additions & 0 deletions HippoMocksTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ set(SOURCES
add_executable(HippoMocksTest64
${SOURCES}
)

if (NOT WIN32)
target_compile_options(HippoMocksTest64
PRIVATE
-Wall -Wextra -pedantic -Wno-long-long
)
endif()

target_link_libraries(HippoMocksTest64
PRIVATE
HippoMocks
Expand Down