Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -17,66 +17,6 @@ endif() endif() -if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - project(lld) - - set(LLD_PATH_TO_LLVM_SOURCE "" CACHE PATH - "Path to LLVM source code. Not necessary if using an installed LLVM.") - set(LLD_PATH_TO_LLVM_BUILD "" CACHE PATH - "Path to the directory where LLVM was built or installed.") - - if (LLD_PATH_TO_LLVM_SOURCE) - if (NOT EXISTS "${LLD_PATH_TO_LLVM_SOURCE}/cmake/config-ix.cmake") - message(FATAL_ERROR "Please set LLD_PATH_TO_LLVM_SOURCE to the root " - "directory of LLVM source code.") - else() - get_filename_component(LLVM_MAIN_SRC_DIR ${LLD_PATH_TO_LLVM_SOURCE} - ABSOLUTE) - list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules") - endif() - endif() - - list(APPEND CMAKE_MODULE_PATH "${LLD_PATH_TO_LLVM_BUILD}/share/llvm/cmake") - - get_filename_component(PATH_TO_LLVM_BUILD ${LLD_PATH_TO_LLVM_BUILD} - ABSOLUTE) - - option(LLVM_INSTALL_TOOLCHAIN_ONLY - "Only include toolchain files in the 'install' target." OFF) - - include(AddLLVM) - include(TableGen) - include("${LLD_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVMConfig.cmake") - include(HandleLLVMOptions) - - set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}") - - set(LLVM_MAIN_INCLUDE_DIR "${LLVM_MAIN_SRC_DIR}/include") - set(LLVM_BINARY_DIR ${CMAKE_BINARY_DIR}) - - set(CMAKE_INCLUDE_CURRENT_DIR ON) - include_directories("${PATH_TO_LLVM_BUILD}/include" - "${LLVM_MAIN_INCLUDE_DIR}") - link_directories("${PATH_TO_LLVM_BUILD}/lib${LLVM_LIBDIR_SUFFIX}") - - if (EXISTS "${LLD_PATH_TO_LLVM_BUILD}/bin/llvm-config${CMAKE_EXECUTABLE_SUFFIX}") - set (PATH_TO_LLVM_CONFIG "${LLD_PATH_TO_LLVM_BUILD}/bin/llvm-config${CMAKE_EXECUTABLE_SUFFIX}") - elseif (EXISTS "${LLD_PATH_TO_LLVM_BUILD}/bin/Debug/llvm-config${CMAKE_EXECUTABLE_SUFFIX}") - # FIXME: This is an utter hack. - set (PATH_TO_LLVM_CONFIG "${LLD_PATH_TO_LLVM_BUILD}/bin/Debug/llvm-config${CMAKE_EXECUTABLE_SUFFIX}") - else() - message(FATAL_ERROR "Please set LLD_PATH_TO_LLVM_BUILD to a directory containing a LLVM build.") - endif() - - exec_program("${PATH_TO_LLVM_CONFIG} --bindir" OUTPUT_VARIABLE LLVM_BINARY_DIR) - set(LLVM_TABLEGEN_EXE "${LLVM_BINARY_DIR}/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX}") - - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}) - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}) - - set(LLD_BUILT_STANDALONE 1) -endif() set(LLD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LLD_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) @@ -224,7 +164,7 @@ add_subdirectory(test) -if (LLVM_INCLUDE_TESTS AND NOT LLD_BUILT_STANDALONE) +if (LLVM_INCLUDE_TESTS) add_subdirectory(unittests) endif() Index: test/CMakeLists.txt =================================================================== --- test/CMakeLists.txt +++ test/CMakeLists.txt @@ -19,66 +19,24 @@ ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg ) -if ( NOT LLD_BUILT_STANDALONE ) - - set(LLD_TEST_DEPS - FileCheck not llvm-nm - lld llvm-config llvm-objdump llvm-readobj yaml2obj obj2yaml - linker-script-test macho-dump llvm-mc - LLDUnitTests - ) - set(LLD_TEST_PARAMS - lld_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - ) - - add_lit_testsuite(check-lld "Running lld test suite" - ${CMAKE_CURRENT_BINARY_DIR} - PARAMS lld_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - lld_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg - DEPENDS ${LLD_TEST_DEPS} - ) - - set_target_properties(check-lld PROPERTIES FOLDER "lld tests") - -else() - - include(FindPythonInterp) - if (PYTHONINTERP_FOUND) - if (LLVM_MAIN_SRC_DIR) - set(LIT "${LLVM_SOURCE_DIR}/utils/lit/lit.py") - else() - set(LIT "${PATH_TO_LLVM_BUILD}/bin/${CMAKE_CFG_INTDIR}/llvm-lit") - # Installed LLVM does not contain ${CMAKE_CFG_INTDIR} in paths. - if (NOT EXISTS ${LIT}) - set(LIT "${PATH_TO_LLVM_BUILD}/bin/llvm-lit") - endif() - endif() - - if (PATH_TO_LLVM_BUILD) - set(LLD_TEST_EXTRA_ARGS "--path=${LLD_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}") - endif() - - set(LIT_ARGS "${LLD_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}") - separate_arguments(LIT_ARGS) - - add_custom_target(lld-test.deps) - set_target_properties(lld-test.deps PROPERTIES FOLDER "lld tests") +set(LLD_TEST_DEPS + FileCheck not llvm-nm + lld llvm-config llvm-objdump llvm-readobj yaml2obj obj2yaml + linker-script-test macho-dump llvm-mc + LLDUnitTests + ) +set(LLD_TEST_PARAMS + lld_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + ) - add_custom_target(check-lld - COMMAND ${PYTHON_EXECUTABLE} - ${LIT} - --param lld_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - --param build_config=${CMAKE_CFG_INTDIR} - --param build_mode=${RUNTIME_BUILD_MODE} - ${LIT_ARGS} - ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Running lld regression tests" - DEPENDS lld-test.deps - ) - set_target_properties(check-lld PROPERTIES FOLDER "lld tests") - endif() +add_lit_testsuite(check-lld "Running lld test suite" + ${CMAKE_CURRENT_BINARY_DIR} + PARAMS lld_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + lld_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg + DEPENDS ${LLD_TEST_DEPS} + ) -endif() +set_target_properties(check-lld PROPERTIES FOLDER "lld tests") # Add a legacy target spelling: lld-test add_custom_target(lld-test)