1# Figure out if we can track VC revisions. 2function(find_first_existing_file out_var) 3 foreach(file ${ARGN}) 4 if(EXISTS "${file}") 5 set(${out_var} "${file}" PARENT_SCOPE) 6 return() 7 endif() 8 endforeach() 9endfunction() 10 11macro(find_first_existing_vc_file out_var path) 12 find_first_existing_file(${out_var} 13 "${path}/.git/logs/HEAD" # Git 14 "${path}/.svn/wc.db" # SVN 1.7 15 "${path}/.svn/entries" # SVN 1.6 16 ) 17endmacro() 18 19find_first_existing_vc_file(llvm_vc "${LLVM_MAIN_SRC_DIR}") 20 21# The VC revision include that we want to generate. 22set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/LLVMLTORevision.h") 23 24set(get_svn_script "${LLVM_MAIN_SRC_DIR}/cmake/modules/GenerateVersionFromCVS.cmake") 25 26if(DEFINED llvm_vc) 27 # Create custom target to generate the VC revision include. 28 add_custom_command(OUTPUT "${version_inc}" 29 DEPENDS "${llvm_vc}" "${get_svn_script}" 30 COMMAND 31 ${CMAKE_COMMAND} "-DSOURCE_DIR=${LLVM_MAIN_SRC_DIR}" 32 "-DNAME=LLVM_REVISION" 33 "-DHEADER_FILE=${version_inc}" 34 -P "${get_svn_script}") 35 36 # Mark the generated header as being generated. 37 set_source_files_properties("${version_inc}" 38 PROPERTIES GENERATED TRUE 39 HEADER_FILE_ONLY TRUE) 40 41 # Tell Version.cpp that it needs to build with -DHAVE_SVN_VERSION_INC. 42 set_source_files_properties(Version.cpp 43 PROPERTIES COMPILE_DEFINITIONS "HAVE_SVN_VERSION_INC") 44else() 45 # Not producing a VC revision include. 46 set(version_inc) 47endif() 48 49 50add_llvm_library(LLVMLTO 51 LTO.cpp 52 LTOModule.cpp 53 LTOCodeGenerator.cpp 54 UpdateCompilerUsed.cpp 55 ThinLTOCodeGenerator.cpp 56 ${version_inc} 57 58 ADDITIONAL_HEADER_DIRS 59 ${LLVM_MAIN_INCLUDE_DIR}/llvm/LTO 60) 61 62add_dependencies(LLVMLTO intrinsics_gen) 63