Skip to content

Commit

Permalink
env: add basic installing support
Browse files Browse the repository at this point in the history
  • Loading branch information
DNKpp committed Oct 6, 2024
1 parent 66263c2 commit c695721
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 12 deletions.
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ include(get_cpm)

project(
mimicpp
LANGUAGES CXX
VERSION 2
LANGUAGES CXX
VERSION 2
DESCRIPTION "A modern and (mostly) macro free mocking-framework"
HOMEPAGE_URL "https://github.com/DNKpp/mimicpp"
)

include(GNUInstallDirs)

add_library(mimicpp INTERFACE)
add_library(mimicpp::mimicpp ALIAS mimicpp)
target_include_directories(
mimicpp
INTERFACE
"include"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)

target_compile_options(
Expand Down Expand Up @@ -70,3 +75,9 @@ if (MIMICPP_ENABLE_AMALGAMATE_HEADERS)
add_subdirectory("tools/amalgamate-headers")

endif()

if(NOT CMAKE_SKIP_INSTALL_RULES)

include(InstallRules)

endif()
47 changes: 47 additions & 0 deletions cmake/InstallRules.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# many thanks to jeremy rifkin, from which I took most of the following code
# https://github.com/jeremy-rifkin/libassert/blob/main/cmake/InstallRules.cmake

include(CMakePackageConfigHelpers)

set(MIMICPP_LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/mimipp")
set(MIMICPP_CMAKE_INSTALL_DIR "${MIMICPP_LIB_INSTALL_DIR}/cmake")
set(MIMICPP_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/mimipp")

write_basic_package_version_file(
"mimicpp-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
ARCH_INDEPENDENT
)

configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/mimicpp-config.cmake.in"
"mimicpp-config.cmake"
INSTALL_DESTINATION "${MIMICPP_CMAKE_INSTALL_DIR}"
)

install(
TARGETS mimicpp
EXPORT mimicpp-targets
PUBLIC_HEADER DESTINATION "${MIMICPP_INCLUDE_INSTALL_DIR}"
)

install(
DIRECTORY "include/"
TYPE INCLUDE
FILES_MATCHING PATTERN "*.hpp"
)

install(
EXPORT mimicpp-targets
FILE mimicpp-targets.cmake
DESTINATION "${MIMICPP_CMAKE_INSTALL_DIR}"
NAMESPACE mimipp::
)

install(
FILES
"${PROJECT_BINARY_DIR}/mimicpp-config.cmake"
"${PROJECT_BINARY_DIR}/mimicpp-version.cmake"
DESTINATION "${MIMICPP_CMAKE_INSTALL_DIR}"
)
10 changes: 5 additions & 5 deletions cmake/mimic++-configuration-options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ OPTION(MIMICPP_CONFIG_EXPERIMENTAL_UNICODE_STR_MATCHER "When enabled, all case-i
if (MIMICPP_CONFIG_EXPERIMENTAL_UNICODE_STR_MATCHER)

CPMAddPackage(
NAME cpp-unicodelib
GITHUB_REPOSITORY yhirose/cpp-unicodelib
GIT_TAG 797b1f0f1592ce13afabf3576f51ef26db5e884d
DOWNLOAD_ONLY YES
SYSTEM YES
NAME cpp-unicodelib
GITHUB_REPOSITORY yhirose/cpp-unicodelib
GIT_TAG 797b1f0f1592ce13afabf3576f51ef26db5e884d
DOWNLOAD_ONLY YES
SYSTEM YES
)

if (cpp-unicodelib_ADDED)
Expand Down
5 changes: 5 additions & 0 deletions cmake/mimicpp-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

set(mimicpp_VERSION "@PROJECT_VERSION@")
include("${CMAKE_CURRENT_LIST_DIR}/mimicpp-targets.cmake")
check_required_components("@PROJECT_NAME@")
9 changes: 5 additions & 4 deletions test/adapter-tests/boost-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ else()
endif()

CPMAddPackage(
NAME Boost
URL ${BOOST_ARCHIVE_URL}
VERSION 1.85.0
SYSTEM YES
NAME Boost
URL ${BOOST_ARCHIVE_URL}
VERSION 1.85.0
EXCLUDE_FROM_ALL YES
SYSTEM YES
)

target_link_libraries(
Expand Down
2 changes: 2 additions & 0 deletions test/adapter-tests/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ CPMAddPackage(
NAME GTest
GITHUB_REPOSITORY "google/googletest"
GIT_TAG "v1.15.2"
EXCLUDE_FROM_ALL YES
SYSTEM YES
OPTIONS
"gtest_force_shared_crt ON"
)
Expand Down

0 comments on commit c695721

Please sign in to comment.