2019-07-24 21:03:43 +00:00
|
|
|
include(ExternalProject)
|
|
|
|
|
2018-06-22 20:50:07 +00:00
|
|
|
set(BOLT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(BOLT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
2019-06-05 17:32:29 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
2018-06-22 20:50:07 +00:00
|
|
|
|
2021-12-11 05:19:18 +00:00
|
|
|
if (NOT CMAKE_HOST_SYSTEM_NAME MATCHES Linux)
|
|
|
|
message(WARNING "Not building BOLT on unsupported platform")
|
|
|
|
else()
|
|
|
|
set(BOLT_ENABLE_RUNTIME OFF)
|
|
|
|
if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
|
|
|
|
set(BOLT_ENABLE_RUNTIME ON)
|
|
|
|
endif()
|
2019-07-24 21:03:43 +00:00
|
|
|
|
2021-12-11 05:19:18 +00:00
|
|
|
set(BOLT_INCLUDE_TESTS OFF)
|
|
|
|
if (LLVM_INCLUDE_TESTS)
|
|
|
|
string(FIND "${LLVM_ENABLE_PROJECTS}" "clang" POSITION)
|
2021-10-26 19:26:23 +00:00
|
|
|
if (NOT ${POSITION} EQUAL -1)
|
2021-12-11 05:19:18 +00:00
|
|
|
string(FIND "${LLVM_ENABLE_PROJECTS}" "lld" POSITION)
|
|
|
|
if (NOT ${POSITION} EQUAL -1)
|
|
|
|
set(BOLT_INCLUDE_TESTS ON)
|
|
|
|
else()
|
|
|
|
message(WARNING "Not including BOLT tests since lld is disabled")
|
|
|
|
endif()
|
2021-10-26 19:26:23 +00:00
|
|
|
else()
|
2021-12-11 05:19:18 +00:00
|
|
|
message(WARNING "Not including BOLT tests since clang is disabled")
|
2021-10-26 19:26:23 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2021-11-12 02:14:53 +00:00
|
|
|
|
2021-12-11 05:19:18 +00:00
|
|
|
if (BOLT_ENABLE_RUNTIME)
|
|
|
|
message(STATUS "Building BOLT runtime libraries for X86")
|
|
|
|
ExternalProject_Add(bolt_rt
|
|
|
|
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/runtime"
|
|
|
|
STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-stamps
|
|
|
|
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins
|
|
|
|
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
|
|
|
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
|
|
|
-DCMAKE_BUILD_TYPE=Release
|
|
|
|
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
|
|
|
|
-DCMAKE_INSTALL_PREFIX=${LLVM_BINARY_DIR}
|
|
|
|
BUILD_ALWAYS True
|
|
|
|
)
|
|
|
|
install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/cmake_install.cmake \)"
|
2021-12-15 18:16:58 +00:00
|
|
|
COMPONENT bolt)
|
2021-12-11 05:19:18 +00:00
|
|
|
add_llvm_install_targets(install-bolt_rt
|
2021-12-16 02:53:52 +00:00
|
|
|
DEPENDS bolt_rt bolt
|
2021-12-15 18:16:58 +00:00
|
|
|
COMPONENT bolt)
|
2021-12-11 05:19:18 +00:00
|
|
|
endif()
|
2021-10-08 18:47:10 +00:00
|
|
|
|
2021-12-11 05:19:18 +00:00
|
|
|
# Get the current git revision for BOLT.
|
|
|
|
find_program(git_executable NAMES git git.exe git.cmd)
|
|
|
|
if (git_executable)
|
|
|
|
execute_process(COMMAND ${git_executable} rev-parse HEAD
|
|
|
|
WORKING_DIRECTORY ${LLVM_MAIN_SRC_DIR}
|
|
|
|
TIMEOUT 5
|
|
|
|
RESULT_VARIABLE git_result
|
|
|
|
OUTPUT_VARIABLE git_output)
|
|
|
|
if( git_result EQUAL 0 )
|
|
|
|
string(STRIP "${git_output}" git_ref_id)
|
|
|
|
set(BOLT_REVISION "${git_ref_id}")
|
|
|
|
endif()
|
2021-10-26 19:26:23 +00:00
|
|
|
endif()
|
2019-07-24 21:03:43 +00:00
|
|
|
|
2021-12-11 05:19:18 +00:00
|
|
|
# If we can't find a revision, set it to "<unknown>".
|
|
|
|
if (NOT BOLT_REVISION)
|
|
|
|
set(BOLT_REVISION "<unknown>")
|
|
|
|
endif()
|
2019-07-24 21:03:43 +00:00
|
|
|
|
2021-12-11 05:19:18 +00:00
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include/bolt/Utils/BoltRevision.inc.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/include/bolt/Utils/BoltRevision.inc)
|
2021-10-26 19:26:23 +00:00
|
|
|
|
2021-12-11 05:19:18 +00:00
|
|
|
include_directories(
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/include
|
|
|
|
)
|
2021-11-12 02:14:53 +00:00
|
|
|
|
2021-12-11 05:19:18 +00:00
|
|
|
add_subdirectory(lib)
|
|
|
|
add_subdirectory(tools)
|
2021-11-12 02:14:53 +00:00
|
|
|
|
2021-12-11 05:19:18 +00:00
|
|
|
if (BOLT_INCLUDE_TESTS)
|
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|
2021-10-26 19:26:23 +00:00
|
|
|
endif()
|