mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-04 20:20:54 +00:00
cbaa3597aa
This reverts commitd763c6e5e2
. Adds the patch by @hans from https://github.com/llvm/llvm-project/issues/62719 This patch fixes the Windows build.d763c6e5e2
reverted the reviews D144509 [CMake] Bumps minimum version to 3.20.0. This partly undoes D137724. This change has been discussed on discourse https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193 Note this does not remove work-arounds for older CMake versions, that will be done in followup patches. D150532 [OpenMP] Compile assembly files as ASM, not C Since CMake 3.20, CMake explicitly passes "-x c" (or equivalent) when compiling a file which has been set as having the language C. This behaviour change only takes place if "cmake_minimum_required" is set to 3.20 or newer, or if the policy CMP0119 is set to new. Attempting to compile assembly files with "-x c" fails, however this is workarounded in many cases, as OpenMP overrides this with "-x assembler-with-cpp", however this is only added for non-Windows targets. Thus, after increasing cmake_minimum_required to 3.20, this breaks compiling the GNU assembly for Windows targets; the GNU assembly is used for ARM and AArch64 Windows targets when building with Clang. This patch unbreaks that. D150688 [cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump The build uses other mechanism to select the runtime. Fixes #62719 Reviewed By: #libc, Mordante Differential Revision: https://reviews.llvm.org/D151344
103 lines
4.8 KiB
CMake
103 lines
4.8 KiB
CMake
#===-- CMakeLists.txt ----------------------------------------------------===##
|
|
#
|
|
# 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
|
|
#
|
|
#===----------------------------------------------------------------------===##
|
|
cmake_minimum_required(VERSION 3.20.0)
|
|
|
|
set(PARALLELSTL_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/pstl/internal/pstl_config.h")
|
|
file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define _PSTL_VERSION .*$")
|
|
string(REGEX REPLACE "#define _PSTL_VERSION (.*)$" "\\1" PARALLELSTL_VERSION_SOURCE "${PARALLELSTL_VERSION_SOURCE}")
|
|
math(EXPR VERSION_MAJOR "(${PARALLELSTL_VERSION_SOURCE} / 1000)")
|
|
math(EXPR VERSION_MINOR "((${PARALLELSTL_VERSION_SOURCE} % 1000) / 10)")
|
|
math(EXPR VERSION_PATCH "(${PARALLELSTL_VERSION_SOURCE} % 10)")
|
|
|
|
project(ParallelSTL VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} LANGUAGES CXX)
|
|
|
|
# Must go below project(..)
|
|
include(GNUInstallDirs)
|
|
|
|
set(PSTL_PARALLEL_BACKEND "serial" CACHE STRING "Threading backend to use. Valid choices are 'serial', 'omp', and 'tbb'. The default is 'serial'.")
|
|
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).")
|
|
set(_PSTL_HIDE_FROM_ABI_PER_TU ${PSTL_HIDE_FROM_ABI_PER_TU}) # For __pstl_config_site
|
|
|
|
if (NOT TBB_DIR)
|
|
get_filename_component(PSTL_DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
|
string(REPLACE pstl tbb TBB_DIR_NAME ${PSTL_DIR_NAME})
|
|
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../${TBB_DIR_NAME}/cmake")
|
|
get_filename_component(TBB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../${TBB_DIR_NAME}/cmake" ABSOLUTE)
|
|
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)
|
|
|
|
if (PSTL_PARALLEL_BACKEND STREQUAL "serial")
|
|
message(STATUS "Parallel STL uses the serial backend")
|
|
set(_PSTL_PAR_BACKEND_SERIAL ON)
|
|
elseif (PSTL_PARALLEL_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)
|
|
set(_PSTL_PAR_BACKEND_TBB ON)
|
|
elseif (PSTL_PARALLEL_BACKEND STREQUAL "omp")
|
|
message(STATUS "Parallel STL uses the omp backend")
|
|
target_compile_options(ParallelSTL INTERFACE "-fopenmp=libomp")
|
|
set(_PSTL_PAR_BACKEND_OPENMP ON)
|
|
else()
|
|
message(FATAL_ERROR "Requested unknown Parallel STL backend '${PSTL_PARALLEL_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>)
|
|
|
|
###############################################################################
|
|
# 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"
|
|
COMPATIBILITY ExactVersion)
|
|
|
|
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/
|
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
|
PATTERN "*.in" EXCLUDE)
|
|
install(FILES "${PSTL_CONFIG_SITE_PATH}"
|
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
|
|
|
add_custom_target(install-pstl
|
|
COMMAND "${CMAKE_COMMAND}" -P "${PROJECT_BINARY_DIR}/cmake_install.cmake" -DCOMPONENT=ParallelSTL)
|