[CMake] Add LLVM_BUILD_INSTRUMENTED option to enable building with -fprofile-instr...
authorChris Bieneman <beanz@apple.com>
Thu, 10 Dec 2015 21:19:07 +0000 (21:19 +0000)
committerChris Bieneman <beanz@apple.com>
Thu, 10 Dec 2015 21:19:07 +0000 (21:19 +0000)
This is the first step in supporting PGO data generation via CMake. I've marked the option as advanced and experimental until it is fleshed out further.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255298 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/HandleLLVMOptions.cmake

index 6c3109c4de76ff48fe8dbb823645402a78c2b324..f4ac6d7a73fd282b65b1f0278b73bbc0c495bad1 100644 (file)
@@ -587,6 +587,14 @@ if(LLVM_ENABLE_EH AND NOT LLVM_ENABLE_RTTI)
   message(FATAL_ERROR "Exception handling requires RTTI. You must set LLVM_ENABLE_RTTI to ON")
 endif()
 
   message(FATAL_ERROR "Exception handling requires RTTI. You must set LLVM_ENABLE_RTTI to ON")
 endif()
 
+option(LLVM_BUILD_INSTRUMENTED "Build LLVM and tools with PGO instrumentation (experimental)" Off)
+mark_as_advanced(LLVM_BUILD_INSTRUMENTED)
+append_if(LLVM_BUILD_INSTRUMENTED "-fprofile-instr-generate"
+  CMAKE_CXX_FLAGS
+  CMAKE_C_FLAGS
+  CMAKE_EXE_LINKER_FLAGS
+  CMAKE_SHARED_LINKER_FLAGS)
+
 # Plugin support
 # FIXME: Make this configurable.
 if(WIN32 OR CYGWIN)
 # Plugin support
 # FIXME: Make this configurable.
 if(WIN32 OR CYGWIN)