Skip to content

Commit 2e52ae2

Browse files
committed
build: use export targets for XCTest
This adjusts the build to use the CMake config and export targets to ensure that things are rebuilt when appropriate. This also reduces the use of custom variables.
1 parent fe79779 commit 2e52ae2

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ endif()
2626

2727
option(BUILD_SHARED_LIBS "build shared libraries" ON)
2828

29-
option(FOUNDATION_PATH_TO_XCTEST_BUILD "Path to XCTest build" "")
30-
3129
find_package(CURL CONFIG)
3230
if(CURL_FOUND)
3331
include(CMakeExpandImportedTargets)
@@ -58,6 +56,7 @@ add_subdirectory(uuid)
5856
add_subdirectory(Foundation)
5957
add_subdirectory(Tools)
6058
if(ENABLE_TESTING)
59+
find_package(XCTest CONFIG REQUIRED)
6160
add_subdirectory(TestFoundation)
6261
endif()
6362

TestFoundation/CMakeLists.txt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11

2-
if(CMAKE_VERSION VERSION_LESS 3.16)
3-
set(CMAKE_LINK_LIBRARY_FLAG "-l")
4-
endif()
5-
62
add_subdirectory(xdgTestHelper)
73

84
add_executable(TestFoundation
@@ -112,10 +108,6 @@ target_link_libraries(TestFoundation PRIVATE
112108
Foundation
113109
FoundationNetworking
114110
FoundationXML)
115-
target_include_directories(TestFoundation PRIVATE
116-
${FOUNDATION_PATH_TO_XCTEST_BUILD}/swift)
117-
target_link_directories(TestFoundation PRIVATE
118-
${FOUNDATION_PATH_TO_XCTEST_BUILD})
119111
target_link_libraries(TestFoundation PRIVATE
120112
XCTest)
121113

@@ -179,5 +171,5 @@ add_test(NAME TestFoundation
179171
COMMAND ${CMAKE_BINARY_DIR}/TestFoundation.app/TestFoundation
180172
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/TestFoundation.app)
181173
set_tests_properties(TestFoundation PROPERTIES
182-
ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/TestFoundation.app:${FOUNDATION_PATH_TO_XCTEST_BUILD}:$<TARGET_LINKER_FILE_DIR:dispatch>:$<TARGET_LINKER_FILE_DIR:swiftDispatch>:$<TARGET_LINKER_FILE_DIR:BlocksRuntime>)
174+
ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/TestFoundation.app:$<TARGET_LINKER_FILE_DIR:XCTest>:$<TARGET_LINKER_FILE_DIR:dispatch>:$<TARGET_LINKER_FILE_DIR:swiftDispatch>:$<TARGET_LINKER_FILE_DIR:BlocksRuntime>)
183175

0 commit comments

Comments
 (0)