-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
106 changed files
with
5,389 additions
and
14,234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,6 @@ | |
|
||
cmake_minimum_required(VERSION 3.9) | ||
|
||
if(POLICY CMP0068) | ||
cmake_policy(SET CMP0068 NEW) | ||
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) | ||
endif() | ||
|
||
# Add path for custom cheetah modules. | ||
set(CMAKE_MODULE_PATH | ||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake" | ||
|
@@ -17,15 +12,13 @@ set(CMAKE_MODULE_PATH | |
# Check if cheetah is built as a standalone project. | ||
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR CHEETAH_STANDALONE_BUILD) | ||
project(Cheetah CXX C) | ||
set(CHEETAH_STANDALONE_BUILD TRUE) | ||
set_property(GLOBAL PROPERTY USE_FOLDERS ON) | ||
|
||
set(PACKAGE_NAME Cheetah) | ||
set(PACKAGE_VERSION 10.0.1) | ||
set(PACKAGE_VERSION 12.0.0) | ||
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") | ||
set(PACKAGE_BUGREPORT "[email protected]") | ||
|
||
# Find the LLVM sources and simulate LLVM CMake options. | ||
include(HandleOutOfTreeLLVM) | ||
endif() | ||
|
||
# Require out of source build. | ||
|
@@ -35,6 +28,18 @@ MACRO_ENSURE_OUT_OF_SOURCE_BUILD( | |
build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." | ||
) | ||
|
||
# Option to build cheetah into separate directories per target. | ||
# Defaults to true. | ||
option(CHEETAH_DIRECTORY_PER_TARGET "Build cheetah into a separate directory per target." ON) | ||
if (LLVM_ENABLE_PER_TARGET_RUNTIME_DIR) | ||
set(CHEETAH_ENABLE_PER_TARGET_RUNTIME_DIR ${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR}) | ||
else() | ||
set(CHEETAH_ENABLE_PER_TARGET_RUNTIME_DIR ${CHEETAH_DIRECTORY_PER_TARGET}) | ||
endif() | ||
|
||
include(base-config-ix) | ||
include(CheetahUtils) | ||
|
||
#=============================================================================== | ||
# Setup CMake Options | ||
#=============================================================================== | ||
|
@@ -47,26 +52,11 @@ option(CHEETAH_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) | |
option(CHEETAH_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF) | ||
|
||
option(CHEETAH_INCLUDE_TESTS "Generate build targets for the cheetah unit tests." ${LLVM_INCLUDE_TESTS}) | ||
set(CHEETAH_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING | ||
"Define suffix of library directory name (32/64)") | ||
option(CHEETAH_INSTALL_LIBRARY "Install the cheetah library." ON) | ||
set(CHEETAH_TARGET_TRIPLE "" CACHE STRING "Target triple for cross compiling.") | ||
set(CHEETAH_GCC_TOOLCHAIN "" CACHE PATH "GCC toolchain for cross compiling.") | ||
set(CHEETAH_SYSROOT "" CACHE PATH "Sysroot for cross compiling.") | ||
|
||
option(CHEETAH_ENABLE_SHARED "Build cheetah as a shared library." ON) | ||
option(CHEETAH_ENABLE_STATIC "Build cheetah as a static library." ON) | ||
option(CHEETAH_ENABLE_BITCODE_ABI "Build cheetah ABI as LLVM bitcode." ON) | ||
|
||
cmake_dependent_option(CHEETAH_INSTALL_STATIC_LIBRARY | ||
"Install the static cheetah library." ON | ||
"CHEETAH_ENABLE_STATIC;CHEETAH_INSTALL_LIBRARY" OFF) | ||
cmake_dependent_option(CHEETAH_INSTALL_SHARED_LIBRARY | ||
"Install the shared cheetah library." ON | ||
"CHEETAH_ENABLE_SHARED;CHEETAH_INSTALL_LIBRARY" OFF) | ||
cmake_dependent_option(CHEETAH_INSTALL_BITCODE_ABI | ||
"Install the cheetah ABI LLVM bitcode." ON | ||
"CHEETAH_ENABLE_BITCODE_ABI;CHEETAH_INSTALL_LIBRARY" OFF) | ||
option(CHEETAH_ENABLE_ASAN "Build cheetah with ASan support." ON) | ||
|
||
set(CHEETAH_ABI_VERSION "1" CACHE STRING "ABI version of cheetah. Defaults to 1.") | ||
|
||
|
@@ -78,67 +68,65 @@ endif() | |
|
||
# Default minimum OSX version to support, if | ||
# CMAKE_OSX_DEPLOYMENT_TARGET is not specified | ||
set(CHEETAH_MIN_OSX_VERSION 10.14) | ||
set(DEFAULT_CHEETAH_MIN_OSX_VERSION 10.14) | ||
|
||
#=============================================================================== | ||
# Configure System | ||
#=============================================================================== | ||
|
||
set(CHEETAH_COMPILER ${CMAKE_CXX_COMPILER}) | ||
set(CHEETAH_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
set(CHEETAH_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
if (LLVM_LIBRARY_OUTPUT_INTDIR AND PACKAGE_VERSION) | ||
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION | ||
${PACKAGE_VERSION}) | ||
# Setup the paths where cheetah runtime and headers should be stored. | ||
set(CHEETAH_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}) | ||
set(CHEETAH_INSTALL_PREFIX lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}) | ||
|
||
if (NOT APPLE) | ||
set(CHEETAH_LIBRARY_DIR ${CHEETAH_OUTPUT_DIR}/lib/${LLVM_DEFAULT_TARGET_TRIPLE}) | ||
set(CHEETAH_LIBRARY_INSTALL_DIR ${CHEETAH_INSTALL_PREFIX}/lib/${LLVM_DEFAULT_TARGET_TRIPLE}) | ||
if (CHEETAH_LIBDIR_SUFFIX) | ||
string(APPEND CHEETAH_LIBRARY_DIR /${CHEETAH_LIBDIR_SUFFIX}) | ||
string(APPEND CHEETAH_LIBRARY_INSTALL_DIR /${CHEETAH_LIBDIR_SUFFIX}) | ||
endif() | ||
else() | ||
if(NOT DEFINED CHEETAH_OS_DIR) | ||
string(TOLOWER ${CMAKE_SYSTEM_NAME} CHEETAH_OS_DIR) | ||
if (CHEETAH_STANDALONE_BUILD) | ||
load_llvm_config() | ||
if (TARGET intrinsics_gen) | ||
# Loading the llvm config causes this target to be imported so place it | ||
# under the appropriate folder in an IDE. | ||
set_target_properties(intrinsics_gen PROPERTIES FOLDER "Cheetah Misc") | ||
endif() | ||
|
||
find_package(Python3 COMPONENTS Interpreter) | ||
if(NOT Python3_Interpreter_FOUND) | ||
message(WARNING "Python3 not found, using python2 as a fallback") | ||
find_package(Python2 COMPONENTS Interpreter REQUIRED) | ||
if(Python2_VERSION VERSION_LESS 2.7) | ||
message(SEND_ERROR "Python 2.7 or newer is required") | ||
endif() | ||
set(CHEETAH_LIBRARY_DIR ${CHEETAH_OUTPUT_DIR}/lib/${CHEETAH_OS_DIR}) | ||
set(CHEETAH_LIBRARY_INSTALL_DIR ${CHEETAH_INSTALL_PREFIX}/lib/${CHEETAH_OS_DIR}) | ||
|
||
# Treat python2 as python3 | ||
add_executable(Python3::Interpreter IMPORTED) | ||
set_target_properties(Python3::Interpreter PROPERTIES | ||
IMPORTED_LOCATION ${Python2_EXECUTABLE}) | ||
set(Python3_EXECUTABLE ${Python2_EXECUTABLE}) | ||
endif() | ||
|
||
set(CHEETAH_HEADER_DIR ${CHEETAH_OUTPUT_DIR}/include) | ||
set(CHEETAH_HEADER_INSTALL_DIR ${CHEETAH_INSTALL_PREFIX}/include) | ||
else() | ||
set(CHEETAH_OUTPUT_DIR ${CHEETAH_BINARY_DIR} CACHE PATH | ||
"Path where built cheetah library should be stored.") | ||
set(CHEETAH_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH | ||
"Path where built cheetah library should be installed.") | ||
set(CHEETAH_LIBRARY_DIR ${CHEETAH_OUTPUT_DIR}/lib${CHEETAH_LIBDIR_SUFFIX}) | ||
set(CHEETAH_LIBRARY_INSTALL_DIR ${CHEETAH_INSTALL_PREFIX}/lib${CHEETAH_LIBDIR_SUFFIX}) | ||
|
||
set(CHEETAH_HEADER_DIR ${CHEETAH_OUTPUT_DIR}/include) | ||
set(CHEETAH_HEADER_INSTALL_DIR ${CHEETAH_INSTALL_PREFIX}/include) | ||
# Ensure that fat libraries are built correctly on Darwin | ||
if(APPLE) | ||
include(UseLibtool) | ||
endif() | ||
|
||
# Define default arguments to lit. | ||
set(LIT_ARGS_DEFAULT "-sv") | ||
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") | ||
set(LLVM_LIT_OUTPUT_DIR "${CHEETAH_EXEC_OUTPUT_DIR}") | ||
endif() | ||
|
||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CHEETAH_LIBRARY_DIR}) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CHEETAH_LIBRARY_DIR}) | ||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CHEETAH_LIBRARY_DIR}) | ||
construct_cheetah_default_triple() | ||
if ("${CHEETAH_DEFAULT_TARGET_TRIPLE}" MATCHES ".*hf$") | ||
if (${CHEETAH_DEFAULT_TARGET_ARCH} MATCHES "^arm") | ||
set(CHEETAH_DEFAULT_TARGET_ARCH "armhf") | ||
endif() | ||
endif() | ||
|
||
set(CHEETAH_C_FLAGS "") | ||
set(CHEETAH_CXX_FLAGS "") | ||
set(CHEETAH_COMPILE_FLAGS "") | ||
set(CHEETAH_COMPILE_DEFS "") | ||
set(CHEETAH_LINK_FLAGS "") | ||
set(CHEETAH_LIBRARIES "") | ||
set(CHEETAH_COMMON_LIBS "") | ||
|
||
if (APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET) | ||
list(APPEND CHEETAH_COMPILE_FLAGS -mmacosx-version-min=${CHEETAH_MIN_OSX_VERSION}) | ||
list(APPEND CHEETAH_LINK_FLAGS -mmacosx-version-min=${CHEETAH_MIN_OSX_VERSION}) | ||
endif() | ||
option(CHEETAH_EXTERNALIZE_DEBUGINFO | ||
"Generate dSYM files and strip executables and libraries (Darwin Only)" OFF) | ||
|
||
# Include macros for adding and removing cheetah flags. | ||
include(HandleCheetahFlags) | ||
|
@@ -147,34 +135,9 @@ include(HandleCheetahFlags) | |
# Setup Compiler Flags | ||
#=============================================================================== | ||
|
||
# Configure target flags | ||
if(CHEETAH_TARGET_TRIPLE) | ||
add_target_flags("--target=${CHEETAH_TARGET_TRIPLE}") | ||
elseif(CMAKE_CXX_COMPILER_TARGET) | ||
set(CHEETAH_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}") | ||
endif() | ||
if(CHEETAH_SYSROOT) | ||
add_target_flags("--sysroot=${CHEETAH_SYSROOT}") | ||
elseif(CMAKE_SYSROOT) | ||
set(CHEETAH_SYSROOT "${CMAKE_SYSROOT}") | ||
endif() | ||
if(CHEETAH_GCC_TOOLCHAIN) | ||
add_target_flags("--gcc-toolchain=${CHEETAH_GCC_TOOLCHAIN}") | ||
elseif(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) | ||
set(CHEETAH_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}") | ||
endif() | ||
|
||
if (CHEETAH_TARGET_TRIPLE) | ||
set(TARGET_TRIPLE "${CHEETAH_TARGET_TRIPLE}") | ||
endif() | ||
|
||
# Configure compiler. | ||
include(config-ix) | ||
|
||
if (APPLE AND CHEETAH_HAS_APP_EXTENSION) | ||
list(APPEND CHEETAH_LINK_FLAGS "-fapplication-extension") | ||
endif() | ||
|
||
if (CHEETAH_USE_COMPILER_RT) | ||
list(APPEND CHEETAH_LINK_FLAGS "--rtlib=compiler-rt") | ||
endif() | ||
|
@@ -206,6 +169,8 @@ string(REPLACE ";" " " CHEETAH_CXX_FLAGS "${CHEETAH_CXX_FLAGS}") | |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CHEETAH_CXX_FLAGS}") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CHEETAH_C_FLAGS}") | ||
|
||
include(AddCheetah) | ||
|
||
#=============================================================================== | ||
# Setup Source Code | ||
#=============================================================================== | ||
|
Oops, something went wrong.