Revert r243503 "[libcxx] Cleanup CMake configuration and integrate with LLVM"
This caused clang-format to stop linking on Mac; see PR24306. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@243550 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
|
||||
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
# Rely on llvm-config.
|
||||
set(CONFIG_OUTPUT)
|
||||
find_program(LLVM_CONFIG "llvm-config")
|
||||
if(DEFINED LLVM_PATH)
|
||||
set(LLVM_INCLUDE_DIR ${LLVM_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
|
||||
set(LLVM_PATH ${LLVM_PATH} CACHE PATH "Path to LLVM source tree")
|
||||
set(LLVM_MAIN_SRC_DIR ${LLVM_PATH})
|
||||
set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules")
|
||||
elseif(LLVM_CONFIG)
|
||||
message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
|
||||
set(CONFIG_COMMAND ${LLVM_CONFIG}
|
||||
"--includedir"
|
||||
"--prefix"
|
||||
"--src-root")
|
||||
execute_process(
|
||||
COMMAND ${CONFIG_COMMAND}
|
||||
RESULT_VARIABLE HAD_ERROR
|
||||
OUTPUT_VARIABLE CONFIG_OUTPUT
|
||||
)
|
||||
if(NOT HAD_ERROR)
|
||||
string(REGEX REPLACE
|
||||
"[ \t]*[\r\n]+[ \t]*" ";"
|
||||
CONFIG_OUTPUT ${CONFIG_OUTPUT})
|
||||
else()
|
||||
string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
|
||||
message(STATUS "${CONFIG_COMMAND_STR}")
|
||||
message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
|
||||
endif()
|
||||
|
||||
list(GET CONFIG_OUTPUT 0 INCLUDE_DIR)
|
||||
list(GET CONFIG_OUTPUT 1 LLVM_OBJ_ROOT)
|
||||
list(GET CONFIG_OUTPUT 2 MAIN_SRC_DIR)
|
||||
|
||||
set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
|
||||
set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
|
||||
set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
|
||||
set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/share/llvm/cmake")
|
||||
else()
|
||||
message(FATAL_ERROR "llvm-config not found and LLVM_MAIN_SRC_DIR not defined. "
|
||||
"Reconfigure with -DLLVM_CONFIG=path/to/llvm-config "
|
||||
"or -DLLVM_PATH=path/to/llvm-source-root.")
|
||||
endif()
|
||||
|
||||
if (NOT EXISTS ${LLVM_MAIN_SRC_DIR})
|
||||
message(FATAL_ERROR "Not found: ${LLVM_MAIN_SRC_DIR}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${LLVM_CMAKE_PATH})
|
||||
message(FATAL_ERROR "Not found: ${LLVM_CMAKE_PATH}")
|
||||
endif()
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
|
||||
list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
|
||||
|
||||
|
||||
if(LLVM_LIT)
|
||||
# Define the default arguments to use with 'lit', and an option for the user
|
||||
# to override.
|
||||
set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported")
|
||||
if (MSVC OR XCODE)
|
||||
set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
|
||||
endif()
|
||||
set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
|
||||
|
||||
# On Win32 hosts, provide an option to specify the path to the GnuWin32 tools.
|
||||
if( WIN32 AND NOT CYGWIN )
|
||||
set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools")
|
||||
endif()
|
||||
else()
|
||||
set(LLVM_INCLUDE_TESTS OFF)
|
||||
endif()
|
||||
|
||||
set(LIBCXX_BUILT_STANDALONE 1)
|
||||
else()
|
||||
set(LLVM_MAIN_SRC_DIR "${CMAKE_SOURCE_DIR}" CACHE PATH "Path to LLVM source tree")
|
||||
set(LLVM_LIT "${CMAKE_SOURCE_DIR}/utils/lit/lit.py")
|
||||
endif()
|
@@ -58,21 +58,6 @@ macro(setup_abi_lib abidefines abilib abifiles abidirs)
|
||||
|
||||
endmacro()
|
||||
|
||||
# Setup the default options if LIBCXX_CXX_ABI is not specified.
|
||||
if (NOT LIBCXX_CXX_ABI)
|
||||
if (NOT DEFINED LIBCXX_BUILT_STANDALONE AND
|
||||
IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi")
|
||||
set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
|
||||
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${CMAKE_SOURCE_DIR}/projects/libcxxabi/include")
|
||||
set(LIBCXX_CXX_ABI_INTREE 1)
|
||||
else ()
|
||||
set(LIBCXX_CXX_ABI_LIBNAME "none")
|
||||
endif ()
|
||||
else ()
|
||||
set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}")
|
||||
endif ()
|
||||
|
||||
# Configure based on the selected ABI library.
|
||||
if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++" OR
|
||||
"${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libsupc++")
|
||||
set(_LIBSUPCXX_INCLUDE_FILES
|
||||
|
@@ -1,147 +0,0 @@
|
||||
# HandleLibcxxFlags - A set of macros used to setup the flags used to compile
|
||||
# and link libc++. These macros add flags to the following CMake variables.
|
||||
# - LIBCXX_COMPILE_FLAGS: flags used to compile libc++
|
||||
# - LIBCXX_LINK_FLAGS: flags used to link libc++
|
||||
# - LIBCXX_LIBRARIES: libraries to link libc++ to.
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
unset(add_flag_if_supported)
|
||||
|
||||
# Mangle the name of a compiler flag into a valid CMake identifier.
|
||||
# Ex: --std=c++11 -> STD_EQ_CXX11
|
||||
macro(mangle_name str output)
|
||||
string(STRIP "${str}" strippedStr)
|
||||
string(REGEX REPLACE "^/" "" strippedStr "${strippedStr}")
|
||||
string(REGEX REPLACE "^-+" "" strippedStr "${strippedStr}")
|
||||
string(REGEX REPLACE "-+$" "" strippedStr "${strippedStr}")
|
||||
string(REPLACE "-" "_" strippedStr "${strippedStr}")
|
||||
string(REPLACE "=" "_EQ_" strippedStr "${strippedStr}")
|
||||
string(REPLACE "+" "X" strippedStr "${strippedStr}")
|
||||
string(TOUPPER "${strippedStr}" ${output})
|
||||
endmacro()
|
||||
|
||||
# Remove a list of flags from all CMake variables that affect compile flags.
|
||||
# This can be used to remove unwanted flags specified on the command line
|
||||
# or added in other parts of LLVM's cmake configuration.
|
||||
macro(remove_flags)
|
||||
foreach(var ${ARGN})
|
||||
string(REPLACE "${var}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE "${var}" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string(REPLACE "${var}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
|
||||
string(REPLACE "${var}" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
string(REPLACE "${var}" "" CMAKE_SHARED_MODULE_FLAGS "${CMAKE_SHARED_MODULE_FLAGS}")
|
||||
remove_definitions(${var})
|
||||
endforeach()
|
||||
endmacro(remove_flags)
|
||||
|
||||
# Add a macro definition if condition is true.
|
||||
macro(define_if condition def)
|
||||
if (${condition})
|
||||
add_definitions(${def})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Add a macro definition if condition is not true.
|
||||
macro(define_if_not condition def)
|
||||
if (NOT ${condition})
|
||||
add_definitions(${def})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Add a specified list of flags to both 'LIBCXX_COMPILE_FLAGS' and
|
||||
# 'LIBCXX_LINK_FLAGS'.
|
||||
macro(add_flags)
|
||||
foreach(value ${ARGN})
|
||||
list(APPEND LIBCXX_COMPILE_FLAGS ${value})
|
||||
list(APPEND LIBCXX_LINK_FLAGS ${value})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# If the specified 'condition' is true then add a list of flags to both
|
||||
# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'.
|
||||
macro(add_flags_if condition)
|
||||
if (${condition})
|
||||
add_flags(${ARGN})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Add each flag in the list to LIBCXX_COMPILE_FLAGS and LIBCXX_LINK_FLAGS
|
||||
# if that flag is supported by the current compiler.
|
||||
macro(add_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# Add a list of flags to 'LIBCXX_COMPILE_FLAGS'.
|
||||
macro(add_compile_flags)
|
||||
foreach(f ${ARGN})
|
||||
list(APPEND LIBCXX_COMPILE_FLAGS ${f})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# If 'condition' is true then add the specified list of flags to
|
||||
# 'LIBCXX_COMPILE_FLAGS'
|
||||
macro(add_compile_flags_if condition)
|
||||
if (${condition})
|
||||
add_compile_flags(${ARGN})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# For each specified flag, add that flag to 'LIBCXX_COMPILE_FLAGS' if the
|
||||
# flag is supported by the C++ compiler.
|
||||
macro(add_compile_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("-Werror ${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_compile_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# Add a list of flags to 'LIBCXX_LINK_FLAGS'.
|
||||
macro(add_link_flags)
|
||||
foreach(f ${ARGN})
|
||||
list(APPEND LIBCXX_LINK_FLAGS ${f})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# If 'condition' is true then add the specified list of flags to
|
||||
# 'LIBCXX_LINK_FLAGS'
|
||||
macro(add_link_flags_if condition)
|
||||
if (${condition})
|
||||
add_link_flags(${ARGN})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# For each specified flag, add that flag to 'LIBCXX_LINK_FLAGS' if the
|
||||
# flag is supported by the C++ compiler.
|
||||
macro(add_link_flags_if_supported)
|
||||
foreach(flag ${ARGN})
|
||||
mangle_name("${flag}" flagname)
|
||||
check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG")
|
||||
add_link_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# Add a list of libraries or link flags to 'LIBCXX_LIBRARIES'.
|
||||
macro(add_library_flags)
|
||||
foreach(lib ${ARGN})
|
||||
list(APPEND LIBCXX_LIBRARIES ${lib})
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
# if 'condition' is true then add the specified list of libraries and flags
|
||||
# to 'LIBCXX_LIBRARIES'.
|
||||
macro(add_library_flags_if condition)
|
||||
if(${condition})
|
||||
add_library_flags(${ARGN})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# Turn a comma separated CMake list into a space separated string.
|
||||
macro(split_list listname)
|
||||
string(REPLACE ";" " " ${listname} "${${listname}}")
|
||||
endmacro()
|
@@ -2,7 +2,23 @@ include(CheckLibraryExists)
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
# Check compiler flags
|
||||
|
||||
check_cxx_compiler_flag(-std=c++11 LIBCXX_HAS_STDCXX11_FLAG)
|
||||
check_cxx_compiler_flag(-std=c++1y LIBCXX_HAS_STDCXX1Y_FLAG)
|
||||
check_cxx_compiler_flag(-fPIC LIBCXX_HAS_FPIC_FLAG)
|
||||
check_cxx_compiler_flag(-fno-omit-frame-pointer LIBCXX_HAS_FNO_OMIT_FRAME_POINTER_FLAG)
|
||||
check_cxx_compiler_flag(-nodefaultlibs LIBCXX_HAS_NODEFAULTLIBS_FLAG)
|
||||
check_cxx_compiler_flag(-nostdinc++ LIBCXX_HAS_NOSTDINCXX_FLAG)
|
||||
check_cxx_compiler_flag(-Wall LIBCXX_HAS_WALL_FLAG)
|
||||
check_cxx_compiler_flag(-W LIBCXX_HAS_W_FLAG)
|
||||
check_cxx_compiler_flag(-Wno-unused-parameter LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG)
|
||||
check_cxx_compiler_flag(-Wwrite-strings LIBCXX_HAS_WWRITE_STRINGS_FLAG)
|
||||
check_cxx_compiler_flag(-Wno-long-long LIBCXX_HAS_WNO_LONG_LONG_FLAG)
|
||||
check_cxx_compiler_flag(-pedantic LIBCXX_HAS_PEDANTIC_FLAG)
|
||||
check_cxx_compiler_flag(-Werror LIBCXX_HAS_WERROR_FLAG)
|
||||
check_cxx_compiler_flag(-Wno-error LIBCXX_HAS_WNO_ERROR_FLAG)
|
||||
check_cxx_compiler_flag(-fno-exceptions LIBCXX_HAS_FNO_EXCEPTIONS_FLAG)
|
||||
check_cxx_compiler_flag(-fno-rtti LIBCXX_HAS_FNO_RTTI_FLAG)
|
||||
check_cxx_compiler_flag(-gline-tables-only LIBCXX_HAS_GLINE_TABLES_ONLY_FLAG)
|
||||
check_cxx_compiler_flag(/WX LIBCXX_HAS_WX_FLAG)
|
||||
check_cxx_compiler_flag(/WX- LIBCXX_HAS_NO_WX_FLAG)
|
||||
check_cxx_compiler_flag(/EHsc LIBCXX_HAS_EHSC_FLAG)
|
||||
@@ -10,7 +26,6 @@ check_cxx_compiler_flag(/EHs- LIBCXX_HAS_NO_EHS_FLAG)
|
||||
check_cxx_compiler_flag(/EHa- LIBCXX_HAS_NO_EHA_FLAG)
|
||||
check_cxx_compiler_flag(/GR- LIBCXX_HAS_NO_GR_FLAG)
|
||||
|
||||
|
||||
# Check libraries
|
||||
check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)
|
||||
check_library_exists(c printf "" LIBCXX_HAS_C_LIB)
|
||||
|
Reference in New Issue
Block a user