annotate pstl/CMakeLists.txt @ 256:7d9b19ec7a62

cbclang output is still wrong
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 18 Aug 2023 18:48:47 +0900
parents 1f2b6ac9f198
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 #===-- CMakeLists.txt ----------------------------------------------------===##
anatofuz
parents:
diff changeset
2 #
anatofuz
parents:
diff changeset
3 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 # See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 #
anatofuz
parents:
diff changeset
7 #===----------------------------------------------------------------------===##
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
8 cmake_minimum_required(VERSION 3.20.0)
150
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 set(PARALLELSTL_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/pstl/internal/pstl_config.h")
anatofuz
parents:
diff changeset
11 file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define _PSTL_VERSION .*$")
anatofuz
parents:
diff changeset
12 string(REGEX REPLACE "#define _PSTL_VERSION (.*)$" "\\1" PARALLELSTL_VERSION_SOURCE "${PARALLELSTL_VERSION_SOURCE}")
anatofuz
parents:
diff changeset
13 math(EXPR VERSION_MAJOR "(${PARALLELSTL_VERSION_SOURCE} / 1000)")
anatofuz
parents:
diff changeset
14 math(EXPR VERSION_MINOR "((${PARALLELSTL_VERSION_SOURCE} % 1000) / 10)")
anatofuz
parents:
diff changeset
15 math(EXPR VERSION_PATCH "(${PARALLELSTL_VERSION_SOURCE} % 10)")
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 project(ParallelSTL VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} LANGUAGES CXX)
anatofuz
parents:
diff changeset
18
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
19 # Must go below project(..)
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
20 include(GNUInstallDirs)
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
21
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
22 set(PSTL_PARALLEL_BACKEND "serial" CACHE STRING "Threading backend to use. Valid choices are 'serial', 'omp', and 'tbb'. The default is 'serial'.")
150
anatofuz
parents:
diff changeset
23 set(PSTL_HIDE_FROM_ABI_PER_TU OFF CACHE BOOL "Whether to constrain ABI-unstable symbols to each translation unit (basically, mark them with C's static keyword).")
anatofuz
parents:
diff changeset
24 set(_PSTL_HIDE_FROM_ABI_PER_TU ${PSTL_HIDE_FROM_ABI_PER_TU}) # For __pstl_config_site
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 if (NOT TBB_DIR)
anatofuz
parents:
diff changeset
27 get_filename_component(PSTL_DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
anatofuz
parents:
diff changeset
28 string(REPLACE pstl tbb TBB_DIR_NAME ${PSTL_DIR_NAME})
anatofuz
parents:
diff changeset
29 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../${TBB_DIR_NAME}/cmake")
anatofuz
parents:
diff changeset
30 get_filename_component(TBB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${TBB_DIR_NAME}/cmake" ABSOLUTE)
anatofuz
parents:
diff changeset
31 endif()
anatofuz
parents:
diff changeset
32 endif()
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 ###############################################################################
anatofuz
parents:
diff changeset
35 # Setup the ParallelSTL library target
anatofuz
parents:
diff changeset
36 ###############################################################################
anatofuz
parents:
diff changeset
37 add_library(ParallelSTL INTERFACE)
anatofuz
parents:
diff changeset
38 add_library(pstl::ParallelSTL ALIAS ParallelSTL)
anatofuz
parents:
diff changeset
39 target_compile_features(ParallelSTL INTERFACE cxx_std_17)
anatofuz
parents:
diff changeset
40
anatofuz
parents:
diff changeset
41 if (PSTL_PARALLEL_BACKEND STREQUAL "serial")
anatofuz
parents:
diff changeset
42 message(STATUS "Parallel STL uses the serial backend")
anatofuz
parents:
diff changeset
43 set(_PSTL_PAR_BACKEND_SERIAL ON)
anatofuz
parents:
diff changeset
44 elseif (PSTL_PARALLEL_BACKEND STREQUAL "tbb")
anatofuz
parents:
diff changeset
45 find_package(TBB 2018 REQUIRED tbb OPTIONAL_COMPONENTS tbbmalloc)
anatofuz
parents:
diff changeset
46 message(STATUS "Parallel STL uses TBB ${TBB_VERSION} (interface version: ${TBB_INTERFACE_VERSION})")
anatofuz
parents:
diff changeset
47 target_link_libraries(ParallelSTL INTERFACE TBB::tbb)
anatofuz
parents:
diff changeset
48 set(_PSTL_PAR_BACKEND_TBB ON)
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
49 elseif (PSTL_PARALLEL_BACKEND STREQUAL "omp")
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
50 message(STATUS "Parallel STL uses the omp backend")
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
51 target_compile_options(ParallelSTL INTERFACE "-fopenmp=libomp")
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
52 set(_PSTL_PAR_BACKEND_OPENMP ON)
150
anatofuz
parents:
diff changeset
53 else()
anatofuz
parents:
diff changeset
54 message(FATAL_ERROR "Requested unknown Parallel STL backend '${PSTL_PARALLEL_BACKEND}'.")
anatofuz
parents:
diff changeset
55 endif()
anatofuz
parents:
diff changeset
56
anatofuz
parents:
diff changeset
57 set(PSTL_GENERATED_HEADERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated_headers")
anatofuz
parents:
diff changeset
58 set(PSTL_CONFIG_SITE_PATH "${PSTL_GENERATED_HEADERS_DIR}/__pstl_config_site")
anatofuz
parents:
diff changeset
59 configure_file("include/__pstl_config_site.in"
anatofuz
parents:
diff changeset
60 "${PSTL_CONFIG_SITE_PATH}"
anatofuz
parents:
diff changeset
61 @ONLY)
anatofuz
parents:
diff changeset
62
anatofuz
parents:
diff changeset
63 target_include_directories(ParallelSTL
anatofuz
parents:
diff changeset
64 INTERFACE
anatofuz
parents:
diff changeset
65 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
anatofuz
parents:
diff changeset
66 $<BUILD_INTERFACE:${PSTL_GENERATED_HEADERS_DIR}>
anatofuz
parents:
diff changeset
67 $<INSTALL_INTERFACE:include>)
anatofuz
parents:
diff changeset
68
anatofuz
parents:
diff changeset
69 ###############################################################################
anatofuz
parents:
diff changeset
70 # Setup tests
anatofuz
parents:
diff changeset
71 ###############################################################################
anatofuz
parents:
diff changeset
72 enable_testing()
anatofuz
parents:
diff changeset
73 add_subdirectory(test)
anatofuz
parents:
diff changeset
74
anatofuz
parents:
diff changeset
75 ###############################################################################
anatofuz
parents:
diff changeset
76 # Install the target and the associated CMake files
anatofuz
parents:
diff changeset
77 ###############################################################################
anatofuz
parents:
diff changeset
78 include(CMakePackageConfigHelpers)
anatofuz
parents:
diff changeset
79 write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake"
anatofuz
parents:
diff changeset
80 COMPATIBILITY ExactVersion)
anatofuz
parents:
diff changeset
81
anatofuz
parents:
diff changeset
82 configure_file(cmake/ParallelSTLConfig.cmake.in
anatofuz
parents:
diff changeset
83 "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfig.cmake"
anatofuz
parents:
diff changeset
84 @ONLY)
anatofuz
parents:
diff changeset
85
anatofuz
parents:
diff changeset
86 install(TARGETS ParallelSTL
anatofuz
parents:
diff changeset
87 EXPORT ParallelSTLTargets)
anatofuz
parents:
diff changeset
88 install(EXPORT ParallelSTLTargets
anatofuz
parents:
diff changeset
89 FILE ParallelSTLTargets.cmake
anatofuz
parents:
diff changeset
90 NAMESPACE pstl::
anatofuz
parents:
diff changeset
91 DESTINATION lib/cmake/ParallelSTL)
anatofuz
parents:
diff changeset
92 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfig.cmake"
anatofuz
parents:
diff changeset
93 "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake"
anatofuz
parents:
diff changeset
94 DESTINATION lib/cmake/ParallelSTL)
anatofuz
parents:
diff changeset
95 install(DIRECTORY include/
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
96 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
221
79ff65ed7e25 LLVM12 Original
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
97 PATTERN "*.in" EXCLUDE)
150
anatofuz
parents:
diff changeset
98 install(FILES "${PSTL_CONFIG_SITE_PATH}"
236
c4bab56944e8 LLVM 16
kono
parents: 221
diff changeset
99 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
150
anatofuz
parents:
diff changeset
100
anatofuz
parents:
diff changeset
101 add_custom_target(install-pstl
anatofuz
parents:
diff changeset
102 COMMAND "${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/cmake_install.cmake" -DCOMPONENT=ParallelSTL)