[libcxx-commits] [pstl] r368284 - [pstl] Add a __pstl_config_site header to record the CMake configuration

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 8 05:43:05 PDT 2019


Author: ldionne
Date: Thu Aug  8 05:43:04 2019
New Revision: 368284

URL: http://llvm.org/viewvc/llvm-project?rev=368284&view=rev
Log:
[pstl] Add a __pstl_config_site header to record the CMake configuration

This commit adds a __pstl_config_site header that contains the value of
macros specified at CMake configuration time. It works similarly to
libc++'s __config_site header, except we always include it as a separate
file instead of concatenating it to the main configuration header.

It is necessary to thread the includes for that header into libc++'s
lit configuration, otherwise we'd be requiring an installation step
prior to running the test suite.

Added:
    pstl/trunk/include/__pstl_config_site.in
Modified:
    pstl/trunk/CMakeLists.txt
    pstl/trunk/include/pstl/internal/pstl_config.h

Modified: pstl/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/CMakeLists.txt?rev=368284&r1=368283&r2=368284&view=diff
==============================================================================
--- pstl/trunk/CMakeLists.txt (original)
+++ pstl/trunk/CMakeLists.txt Thu Aug  8 05:43:04 2019
@@ -35,19 +35,26 @@ target_compile_features(ParallelSTL INTE
 
 if (PARALLELSTL_BACKEND STREQUAL "serial")
     message(STATUS "Parallel STL uses the serial backend")
-    target_compile_definitions(ParallelSTL INTERFACE -D_PSTL_PAR_BACKEND_SERIAL)
+    set(_PSTL_PAR_BACKEND_SERIAL ON)
 elseif (PARALLELSTL_BACKEND STREQUAL "tbb")
     find_package(TBB 2018 REQUIRED tbb OPTIONAL_COMPONENTS tbbmalloc)
     message(STATUS "Parallel STL uses TBB ${TBB_VERSION} (interface version: ${TBB_INTERFACE_VERSION})")
     target_link_libraries(ParallelSTL INTERFACE TBB::tbb)
-    target_compile_definitions(ParallelSTL INTERFACE -D_PSTL_PAR_BACKEND_TBB)
+    set(_PSTL_PAR_BACKEND_TBB ON)
 else()
     message(FATAL_ERROR "Requested unknown Parallel STL backend '${PARALLELSTL_BACKEND}'.")
 endif()
 
+set(PSTL_GENERATED_HEADERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated_headers")
+set(PSTL_CONFIG_SITE_PATH "${PSTL_GENERATED_HEADERS_DIR}/__pstl_config_site")
+configure_file("include/__pstl_config_site.in"
+               "${PSTL_CONFIG_SITE_PATH}"
+               @ONLY)
+
 target_include_directories(ParallelSTL
     INTERFACE
     $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+    $<BUILD_INTERFACE:${PSTL_GENERATED_HEADERS_DIR}>
     $<INSTALL_INTERFACE:include>)
 
 ###############################################################################
@@ -78,6 +85,8 @@ install(FILES "${CMAKE_CURRENT_BINARY_DI
         DESTINATION lib/cmake/ParallelSTL)
 install(DIRECTORY include/
         DESTINATION include)
+install(FILES "${PSTL_CONFIG_SITE_PATH}"
+        DESTINATION include)
 
 add_custom_target(install-pstl
                   COMMAND "${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/cmake_install.cmake" -DCOMPONENT=ParallelSTL)

Added: pstl/trunk/include/__pstl_config_site.in
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/__pstl_config_site.in?rev=368284&view=auto
==============================================================================
--- pstl/trunk/include/__pstl_config_site.in (added)
+++ pstl/trunk/include/__pstl_config_site.in Thu Aug  8 05:43:04 2019
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __PSTL_CONFIG_SITE
+#define __PSTL_CONFIG_SITE
+
+#cmakedefine _PSTL_PAR_BACKEND_SERIAL
+#cmakedefine _PSTL_PAR_BACKEND_TBB
+
+#endif // __PSTL_CONFIG_SITE

Modified: pstl/trunk/include/pstl/internal/pstl_config.h
URL: http://llvm.org/viewvc/llvm-project/pstl/trunk/include/pstl/internal/pstl_config.h?rev=368284&r1=368283&r2=368284&view=diff
==============================================================================
--- pstl/trunk/include/pstl/internal/pstl_config.h (original)
+++ pstl/trunk/include/pstl/internal/pstl_config.h Thu Aug  8 05:43:04 2019
@@ -10,6 +10,8 @@
 #ifndef _PSTL_CONFIG_H
 #define _PSTL_CONFIG_H
 
+#include <__pstl_config_site>
+
 // The version is XYYZ, where X is major, YY is minor, and Z is patch (i.e. X.YY.Z)
 #define _PSTL_VERSION 10000
 #define _PSTL_VERSION_MAJOR (_PSTL_VERSION / 1000)




More information about the libcxx-commits mailing list