1 cmake_minimum_required(VERSION 3.20.0)
2 include(CheckCXXCompilerFlag)
3 include(CheckIncludeFiles)
4 include(GNUInstallDirs)
6 set(CMAKE_CXX_EXTENSIONS OFF)
7 set(CMAKE_CXX_STANDARD 17)
9 project(libbolt_rt_project)
11 check_include_files(elf.h HAVE_ELF_H)
12 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
13 ${CMAKE_CURRENT_BINARY_DIR}/config.h)
15 add_library(bolt_rt_instr STATIC
17 ${CMAKE_CURRENT_BINARY_DIR}/config.h
19 set_target_properties(bolt_rt_instr PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${LLVM_LIBRARY_DIR}")
20 add_library(bolt_rt_hugify STATIC
22 ${CMAKE_CURRENT_BINARY_DIR}/config.h
24 set_target_properties(bolt_rt_hugify PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${LLVM_LIBRARY_DIR}")
33 if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
34 set(BOLT_RT_FLAGS ${BOLT_RT_FLAGS} "-mno-sse")
36 if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
37 check_cxx_compiler_flag("-mno-outline-atomics" CXX_SUPPORTS_OUTLINE_ATOMICS)
38 if (CXX_SUPPORTS_OUTLINE_ATOMICS)
39 set(BOLT_RT_FLAGS ${BOLT_RT_FLAGS} "-mno-outline-atomics")
43 # Don't let the compiler think it can create calls to standard libs
44 target_compile_options(bolt_rt_instr PRIVATE ${BOLT_RT_FLAGS})
45 target_include_directories(bolt_rt_instr PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
46 target_compile_options(bolt_rt_hugify PRIVATE ${BOLT_RT_FLAGS})
47 target_include_directories(bolt_rt_hugify PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
49 install(TARGETS bolt_rt_instr DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")
50 install(TARGETS bolt_rt_hugify DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")
52 if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*" AND CMAKE_SYSTEM_NAME STREQUAL "Darwin")
53 add_library(bolt_rt_instr_osx STATIC
55 ${CMAKE_CURRENT_BINARY_DIR}/config.h
57 set_target_properties(bolt_rt_instr_osx PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${LLVM_LIBRARY_DIR}")
58 target_include_directories(bolt_rt_instr_osx PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
59 target_compile_options(bolt_rt_instr_osx PRIVATE
60 -target x86_64-apple-darwin19.6.0
62 install(TARGETS bolt_rt_instr_osx DESTINATION "lib${LLVM_LIBDIR_SUFFIX}")