diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -983,6 +983,17 @@ set_target_properties(${name} PROPERTIES FOLDER "Examples") endmacro(add_llvm_example name) +macro(add_llvm_example_library name) + if( NOT LLVM_BUILD_EXAMPLES ) + set(EXCLUDE_FROM_ALL ON) + endif() + add_llvm_library (${name} ${ARGN}) + if( LLVM_BUILD_EXAMPLES ) + install(TARGETS ${name} RUNTIME DESTINATION examples) + endif() + set_target_properties(${name} PROPERTIES FOLDER "Examples") +endmacro(add_llvm_example_library name) + # This is a macro that is used to create targets for executables that are needed # for development, but that are not intended to be installed by default. macro(add_llvm_utility name) diff --git a/llvm/examples/IRTransforms/CMakeLists.txt b/llvm/examples/IRTransforms/CMakeLists.txt --- a/llvm/examples/IRTransforms/CMakeLists.txt +++ b/llvm/examples/IRTransforms/CMakeLists.txt @@ -4,7 +4,7 @@ Support ) -add_llvm_library(ExampleIRTransforms +add_llvm_example_library(ExampleIRTransforms InitializePasses.cpp SimplifyCFG.cpp