1 foreach(c ${LLVM_TARGETS_TO_BUILD}) 2 set(TARGETS_BUILT "${TARGETS_BUILT} ${c}") 3 endforeach(c) 4 set(TARGETS_TO_BUILD ${TARGETS_BUILT}) 5 6 # FIXME: This won't work for project files, we need to use a --param. 7 set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib/${CMAKE_CFG_INTDIR}") 8 set(SHLIBEXT "${LTDL_SHLIB_EXT}") 9 10 set(SHLIBDIR "${LLVM_BINARY_DIR}/lib/${CMAKE_CFG_INTDIR}") 11 12 if(BUILD_SHARED_LIBS) 13 set(LLVM_SHARED_LIBS_ENABLED "1") 14 else() 15 set(LLVM_SHARED_LIBS_ENABLED "0") 16 endif(BUILD_SHARED_LIBS) 17 18 if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") 19 set(SHLIBPATH_VAR "DYLD_LIBRARY_PATH") 20 else() # Default for all other unix like systems. 21 # CMake hardcodes the library locaction using rpath. 22 # Therefore LD_LIBRARY_PATH is not required to run binaries in the 23 # build dir. We pass it anyways. 24 set(SHLIBPATH_VAR "LD_LIBRARY_PATH") 25 endif() 26 27 include(FindPythonInterp) 28 if(PYTHONINTERP_FOUND) 29 set(LIT_ARGS "${LLVM_LIT_ARGS}") 30 separate_arguments(LIT_ARGS) 31 32 get_directory_property(DEFINITIONS COMPILE_DEFINITIONS) 33 foreach(DEF ${DEFINITIONS}) 34 set(DEFS "${DEFS} -D${DEF}") 35 endforeach() 36 get_directory_property(INC_DIRS INCLUDE_DIRECTORIES) 37 foreach(INC_DIR ${INC_DIRS}) 38 set(IDIRS "${IDIRS} -I${INC_DIR}") 39 endforeach() 40 41 if( MSVC ) 42 # The compiler's path may contain white space. Wrap it: 43 string(REPLACE "<CMAKE_CXX_COMPILER>" "\\\"${CMAKE_CXX_COMPILER}\\\"" TEST_COMPILE_CXX_CMD ${CMAKE_CXX_COMPILE_OBJECT}) 44 # Eliminate continuation lines from NMake flow. PR9680 45 string(REPLACE "@<<\n" " " TEST_COMPILE_CXX_CMD ${TEST_COMPILE_CXX_CMD}) 46 string(REPLACE "\n<<" " " TEST_COMPILE_CXX_CMD ${TEST_COMPILE_CXX_CMD}) 47 else() 48 string(REPLACE "<CMAKE_CXX_COMPILER>" "${CMAKE_CXX_COMPILER}" TEST_COMPILE_CXX_CMD ${CMAKE_CXX_COMPILE_OBJECT}) 49 endif() 50 51 string(REPLACE "<DEFINES>" "${DEFS}" TEST_COMPILE_CXX_CMD ${TEST_COMPILE_CXX_CMD}) 52 string(REPLACE "<FLAGS>" "${CMAKE_CXX_FLAGS}" TEST_COMPILE_CXX_CMD ${TEST_COMPILE_CXX_CMD}) 53 if (MSVC) # PR9680 54 # Eliminate MSVC equivalent of -o 55 string(REPLACE "/Fo<OBJECT>" "" TEST_COMPILE_CXX_CMD ${TEST_COMPILE_CXX_CMD}) 56 # Eliminate "how to rename program database" argument 57 string(REPLACE "/Fd<TARGET_PDB>" "" TEST_COMPILE_CXX_CMD ${TEST_COMPILE_CXX_CMD}) 58 else() 59 string(REPLACE "-o" "" TEST_COMPILE_CXX_CMD ${TEST_COMPILE_CXX_CMD}) 60 endif(MSVC) 61 string(REGEX REPLACE "<[^>]+>" "" TEST_COMPILE_CXX_CMD ${TEST_COMPILE_CXX_CMD}) 62 set(TEST_COMPILE_CXX_CMD "${TEST_COMPILE_CXX_CMD} ${IDIRS}") 63 if(NOT MSVC) 64 set(TEST_COMPILE_CXX_CMD "${TEST_COMPILE_CXX_CMD} -x c++") 65 # MSVC already has /TP to indicate a C++ source file 66 endif() 67 configure_file( 68 ${CMAKE_CURRENT_SOURCE_DIR}/site.exp.in 69 ${CMAKE_CURRENT_BINARY_DIR}/site.exp) 70 71 MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/Unit) 72 73 # Configuration-time: See Unit/lit.site.cfg.in 74 set(LLVM_BUILD_MODE "%(build_mode)s") 75 76 set(LLVM_SOURCE_DIR ${LLVM_MAIN_SRC_DIR}) 77 set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR}) 78 set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s") 79 set(LLVMGCCDIR "") 80 set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE}) 81 set(ENABLE_SHARED ${LLVM_SHARED_LIBS_ENABLED}) 82 set(SHLIBPATH_VAR ${SHLIBPATH_VAR}) 83 84 if(LLVM_ENABLE_ASSERTIONS AND NOT MSVC_IDE) 85 set(ENABLE_ASSERTIONS "1") 86 else() 87 set(ENABLE_ASSERTIONS "0") 88 endif() 89 90 configure_file( 91 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in 92 ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg 93 @ONLY) 94 configure_file( 95 ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in 96 ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg 97 @ONLY) 98 99 add_custom_target(check 100 COMMAND ${PYTHON_EXECUTABLE} 101 ${LLVM_SOURCE_DIR}/utils/lit/lit.py 102 --param llvm_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg 103 --param llvm_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg 104 --param build_config=${CMAKE_CFG_INTDIR} 105 --param build_mode=${RUNTIME_BUILD_MODE} 106 ${LIT_ARGS} 107 ${CMAKE_CURRENT_BINARY_DIR} 108 COMMENT "Running LLVM regression tests") 109 set_target_properties(check PROPERTIES FOLDER "Tests") 110 111 add_custom_target(check.deps) 112 add_dependencies(check check.deps) 113 add_dependencies(check.deps 114 UnitTests 115 BugpointPasses LLVMHello 116 llc lli llvm-ar llvm-as llvm-dis llvm-extract 117 llvm-ld llvm-link llvm-mc llvm-nm llvm-objdump macho-dump opt 118 FileCheck count not) 119 set_target_properties(check.deps PROPERTIES FOLDER "Tests") 120 121 endif() 122