0

I'm trying to use LTO in clang (with cmake): flag -emit-llvm set in compile time, output generated with -c flag, so LLVM bitcode is the result. The problem is, cmake give me result with ".o" suffix, but i need ".bc". I found other codes that used this: set(CMAKE_C_OUTPUT_EXTENSION .bc), but it didn't work.

cmake_minimum_required(VERSION 3.3)
project(cc C)
set(CMAKE_BUILD_TYPE Release)

enable_language(C)

file(GLOB_RECURSE SOURCES "src/*.c")
add_executable(cc ${SOURCES})

if (UNIX)
  target_compile_options(cc PRIVATE "-Weverything")
  target_compile_options(cc PRIVATE "-std=c11")
  target_compile_options(cc PRIVATE "-emit-llvm")

  set(CMAKE_C_FLAGS_RELEASE "-Ofast -DNDEBUG")

  set(CMAKE_C_OUTPUT_EXTENSION ".bc")
endif()
bsz
  • 61
  • 8
  • Global variables are usually affect only on *future* targets. Try to set `CMAKE_C_OUTPUT_EXTENSION` **before** `add_executable`. – Tsyvarev Dec 06 '15 at 16:22
  • I tried before, it didn't work. Now I tried again with cmake 3.4.0, but it still not work. – bsz Dec 06 '15 at 19:55

0 Answers0