workflows/release-binaries: Add missing output variable
[llvm-project.git] / bolt / CMakeLists.txt
blob650cac8094dcd7ec2d0ee2a0681ab28695a671a8
1 include(ExternalProject)
3 set(BOLT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
4 set(BOLT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
5 set(CMAKE_CXX_STANDARD 17)
7 set(BOLT_ENABLE_RUNTIME OFF)
8 if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"
9     AND "X86" IN_LIST LLVM_TARGETS_TO_BUILD)
10   set(BOLT_ENABLE_RUNTIME ON)
11 endif()
13 set(BOLT_CLANG_EXE "" CACHE FILEPATH "Path to clang executable for the target \
14 architecture for use in BOLT tests")
15 set(BOLT_LLD_EXE "" CACHE FILEPATH "Path to lld executable for the target \
16 architecture for use in BOLT tests")
18 set(BOLT_INCLUDE_TESTS OFF)
19 if (LLVM_INCLUDE_TESTS)
20   set(BOLT_CLANG_PRESENT OFF)
21   set(BOLT_LLD_PRESENT OFF)
23   if ("clang" IN_LIST LLVM_ENABLE_PROJECTS AND BOLT_CLANG_EXE)
24     message(WARNING "BOLT_CLANG_EXE is set and clang project is enabled. \
25           BOLT_CLANG_EXE will be used for BOLT tests.")
26   endif()
27   if ("clang" IN_LIST LLVM_ENABLE_PROJECTS OR BOLT_CLANG_EXE)
28     set(BOLT_CLANG_PRESENT ON)
29   endif()
31   if ("lld" IN_LIST LLVM_ENABLE_PROJECTS AND BOLT_LLD_EXE)
32     message(WARNING "BOLT_LLD_EXE is set and lld project is enabled. \
33           BOLT_LLD_EXE will be used for BOLT tests.")
34   endif()
35   if ("lld" IN_LIST LLVM_ENABLE_PROJECTS OR BOLT_LLD_EXE)
36     set(BOLT_LLD_PRESENT ON)
37   endif()
39   if (BOLT_CLANG_PRESENT AND BOLT_LLD_PRESENT)
40     set(BOLT_INCLUDE_TESTS ON)
41   else()
42     message(WARNING "Not including BOLT tests since clang or lld is disabled. \
43           Add clang and lld to LLVM_ENABLE_PROJECTS or provide paths to clang \
44           and lld binaries in BOLT_CLANG_EXE and BOLT_LLD_EXE.")
45   endif()
46 endif()
48 if (BOLT_ENABLE_RUNTIME)
49   message(STATUS "Building BOLT runtime libraries for X86")
50   ExternalProject_Add(bolt_rt
51     SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/runtime"
52     STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-stamps
53     BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins
54     CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
55                -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
56                -DCMAKE_BUILD_TYPE=Release
57                -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
58                -DCMAKE_INSTALL_PREFIX=${LLVM_BINARY_DIR}
59                -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
60     BUILD_ALWAYS True
61     )
62   install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/cmake_install.cmake \)"
63     COMPONENT bolt)
64   add_llvm_install_targets(install-bolt_rt
65     DEPENDS bolt_rt bolt
66     COMPONENT bolt)
67 endif()
69 find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.bfd ld.bfd DOC "GNU ld")
71 include_directories(
72   ${CMAKE_CURRENT_SOURCE_DIR}/include
73   ${CMAKE_CURRENT_BINARY_DIR}/include
74   )
76 add_subdirectory(lib)
77 add_subdirectory(tools)
79 if (BOLT_INCLUDE_TESTS)
80   if (EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest/googletest/include/gtest/gtest.h)
81     add_subdirectory(unittests)
82     list(APPEND BOLT_TEST_DEPS BoltUnitTests)
83   endif()
84   add_subdirectory(test)
85 endif()
87 option(BOLT_INCLUDE_DOCS "Generate build targets for the BOLT docs."
88        ${LLVM_INCLUDE_DOCS})
89 if (BOLT_INCLUDE_DOCS)
90   add_subdirectory(docs)
91 endif()
93 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/bolt/RuntimeLibs/RuntimeLibraryVariables.inc.in
94                ${CMAKE_CURRENT_BINARY_DIR}/include/bolt/RuntimeLibs/RuntimeLibraryVariables.inc @ONLY)