[libcxx-commits] [pstl] r358028 - [pstl][CMake] Install CMake export files
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 9 11:35:56 PDT 2019
Author: ldionne
Date: Tue Apr 9 11:35:56 2019
New Revision: 358028
URL: http://llvm.org/viewvc/llvm-project?rev=358028&view=rev
Log:
[pstl][CMake] Install CMake export files
This allows other projects to depend on PSTL using the classic CMake
find_package protocol.
Modified:
pstl/trunk/CMakeLists.txt
pstl/trunk/cmake/ParallelSTLConfig.cmake.in
Modified: pstl/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/CMakeLists.txt?rev=358028&r1=358027&r2=358028&view=diff
==============================================================================
--- pstl/trunk/CMakeLists.txt (original)
+++ pstl/trunk/CMakeLists.txt Tue Apr 9 11:35:56 2019
@@ -27,6 +27,9 @@ if (NOT TBB_DIR)
endif()
endif()
+###############################################################################
+# Setup the ParallelSTL library target
+###############################################################################
add_library(ParallelSTL INTERFACE)
add_library(pstl::ParallelSTL ALIAS ParallelSTL)
target_compile_features(ParallelSTL INTERFACE cxx_std_17)
@@ -55,19 +58,34 @@ target_include_directories(ParallelSTL
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
+###############################################################################
+# Setup tests
+###############################################################################
+enable_testing()
+add_subdirectory(test)
+
+###############################################################################
+# Install the target and the associated CMake files
+###############################################################################
include(CMakePackageConfigHelpers)
-write_basic_package_version_file(
- ${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake
- VERSION ${PROJECT_VERSION}
- COMPATIBILITY AnyNewerVersion)
-
-configure_file(
- cmake/ParallelSTLConfig.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfig.cmake
- @ONLY)
+write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake"
+ COMPATIBILITY ExactVersion)
-export(TARGETS ParallelSTL NAMESPACE pstl:: FILE ParallelSTLTargets.cmake)
-export(PACKAGE ParallelSTL)
+configure_file(cmake/ParallelSTLConfig.cmake.in
+ "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfig.cmake"
+ @ONLY)
+
+install(TARGETS ParallelSTL
+ EXPORT ParallelSTLTargets)
+install(EXPORT ParallelSTLTargets
+ FILE ParallelSTLTargets.cmake
+ NAMESPACE pstl::
+ DESTINATION lib/cmake/ParallelSTL)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfig.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake"
+ DESTINATION lib/cmake/ParallelSTL)
+install(DIRECTORY include/pstl
+ DESTINATION include)
-enable_testing()
-add_subdirectory(test)
+add_custom_target(install-pstl
+ COMMAND "${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/cmake_install.cmake" -DCOMPONENT=ParallelSTL)
Modified: pstl/trunk/cmake/ParallelSTLConfig.cmake.in
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/cmake/ParallelSTLConfig.cmake.in?rev=358028&r1=358027&r2=358028&view=diff
==============================================================================
--- pstl/trunk/cmake/ParallelSTLConfig.cmake.in (original)
+++ pstl/trunk/cmake/ParallelSTLConfig.cmake.in Tue Apr 9 11:35:56 2019
@@ -10,8 +10,10 @@ include(CMakeFindDependencyMacro)
set(PARALLELSTL_BACKEND "@PARALLELSTL_BACKEND@")
-if(PARALLELSTL_BACKEND STREQUAL "tbb")
- find_dependency(TBB 2018 REQUIRED tbb)
+if (PARALLELSTL_BACKEND STREQUAL "tbb")
+ find_dependency(TBB REQUIRED tbb)
endif()
-include("${CMAKE_CURRENT_LIST_DIR}/ParallelSTLTargets.cmake")
+if (NOT TARGET pstl::ParallelSTL)
+ include("${CMAKE_CURRENT_LIST_DIR}/ParallelSTLTargets.cmake")
+endif()
More information about the libcxx-commits
mailing list