mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
(and similar mixed modes) This is duplicating some of the work in swift_llvm_config, and should probably be refactored back there at some point, but for now this gets unit tests building in Xcode when the build configurations for LLVM and Swift aren't the same. Swift SVN r24257
40 lines
1.3 KiB
CMake
40 lines
1.3 KiB
CMake
add_custom_target(SwiftUnitTests)
|
|
|
|
set_target_properties(SwiftUnitTests PROPERTIES FOLDER "Tests")
|
|
|
|
function(add_swift_unittest test_dirname)
|
|
add_unittest(SwiftUnitTests ${test_dirname} ${ARGN})
|
|
|
|
if(SWIFT_BUILT_STANDALONE AND NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".")
|
|
# Replace target references with full paths, so that we use LLVM's
|
|
# build configuration rather than Swift's.
|
|
get_target_property(libnames ${test_dirname} LINK_LIBRARIES)
|
|
|
|
set(new_libnames)
|
|
foreach(dep ${libnames})
|
|
if("${dep}" MATCHES "^(LLVM|Clang|gtest)")
|
|
list(APPEND new_libnames "${LLVM_LIBRARY_OUTPUT_INTDIR}/lib${dep}.a")
|
|
else()
|
|
list(APPEND new_libnames "${dep}")
|
|
endif()
|
|
endforeach()
|
|
|
|
set_property(TARGET ${test_dirname} PROPERTY LINK_LIBRARIES ${new_libnames})
|
|
swift_llvm_config(${test_dirname} support)
|
|
endif()
|
|
|
|
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
|
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
|
|
LINK_FLAGS " -Xlinker -rpath -Xlinker ${SWIFT_LIBRARY_OUTPUT_INTDIR}/swift/macosx")
|
|
endif()
|
|
endfunction()
|
|
|
|
# FIXME: cross-compile runtime unittests.
|
|
file(GLOB entries *)
|
|
foreach(entry ${entries})
|
|
if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt)
|
|
add_subdirectory(${entry})
|
|
endif()
|
|
endforeach()
|
|
|