aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorexctues <alexnamecode@gmail.com>2019-08-03 04:25:40 +0300
committerKirk Shoop <kirk.shoop@gmail.com>2019-08-18 12:50:10 -0700
commit9c9deaf165bef6987c305691dc7c5c6849ae6fcc (patch)
treed8453a5d77c735cdea0d469b7bf938dd6f585561
parentb6300193006fda90fc6dea4f52320a61c8cfe0b7 (diff)
downloadplatform_external_Reactive-Extensions_RxCpp-9c9deaf165bef6987c305691dc7c5c6849ae6fcc.tar.gz
platform_external_Reactive-Extensions_RxCpp-9c9deaf165bef6987c305691dc7c5c6849ae6fcc.tar.bz2
platform_external_Reactive-Extensions_RxCpp-9c9deaf165bef6987c305691dc7c5c6849ae6fcc.zip
make find_package(rxcpp CONFIG) work through exporting TARGETS
Signed-off-by: exctues <alexnamecode@gmail.com>
-rw-r--r--projects/CMake/CMakeLists.txt24
1 files changed, 24 insertions, 0 deletions
diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt
index 3d07447..293f187 100644
--- a/projects/CMake/CMakeLists.txt
+++ b/projects/CMake/CMakeLists.txt
@@ -146,3 +146,27 @@ set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE CACHE BOOL "Don't require all project
install(DIRECTORY ${RXCPP_DIR}/Rx/v2/src/rxcpp/ DESTINATION include/rxcpp
FILES_MATCHING PATTERN "*.hpp")
+
+# Here we are exporting TARGETS so that other projects can import rxcpp
+# just with find_package(rxcpp CONFIG) after rxcpp is installed into system by "make install".
+add_library(rxcpp INTERFACE)
+
+target_include_directories(rxcpp INTERFACE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:include/rxcpp>
+)
+
+install(TARGETS rxcpp EXPORT rxcppConfig)
+install(EXPORT rxcppConfig DESTINATION share/rxcpp/cmake)
+
+# When find_package(rxcpp SOME_VERSION REQUIRED) will be used in third party project
+# where SOME_VERSION is any version incompatible with ${PROJECT_VERSION} then cmake will generate the error.
+# It means you don't need track versions manually.
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file("${PROJECT_BINARY_DIR}/rxcppConfigVersion.cmake"
+ VERSION
+ ${PROJECT_VERSION}
+ COMPATIBILITY
+ AnyNewerVersion
+)
+install(FILES "${PROJECT_BINARY_DIR}/rxcppConfigVersion.cmake" DESTINATION share/rxcpp/cmake)