88
99# Macros must be built for the build machine, not the host.
1010include (ExternalProject)
11+
1112if (NOT SwiftTesting_MACRO_MAKE_PROGRAM)
1213 set (SwiftTesting_MACRO_MAKE_PROGRAM ${CMAKE_MAKE_PROGRAM} )
1314endif ()
1415if (NOT SwiftTesting_MACRO_Swift_COMPILER)
1516 set (SwiftTesting_MACRO_Swift_COMPILER ${CMAKE_Swift_COMPILER} )
1617endif ()
18+ if (NOT SwiftTesting_MACRO_Swift_FLAGS)
19+ set (SwiftTesting_MACRO_Swift_FLAGS ${CMAKE_Swift_FLAGS} )
20+ set (SwiftTesting_MACRO_SWIFT_FLAGS_RELEAE ${CMAKE_Swift_FLAGS_RELEAE} )
21+ set (SwiftTesting_MACRO_SWIFT_FLAGS_RELWITHDEBINFO ${CMAKE_Swift_FLAGS_RELWITHDEBINFO} )
22+ endif ()
1723if (NOT SwiftTesting_MACRO_AR)
1824 set (SwiftTesting_MACRO_AR ${CMAKE_AR} )
1925endif ()
@@ -32,10 +38,11 @@ ExternalProject_Add(TestingMacros
3238 PREFIX "tm"
3339 SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR} /TestingMacros"
3440 CMAKE_ARGS
41+ -DCMAKE_MAKE_PROGRAM=${SwiftTesting_MACRO_MAKE_PROGRAM}
3542 -DCMAKE_Swift_COMPILER=${SwiftTesting_MACRO_Swift_COMPILER}
43+ -DCMAKE_Swift_FLAGS=${SwiftTesting_MACRO_Swift_FLAGS}
3644 -DCMAKE_AR=${SwiftTesting_MACRO_AR}
3745 -DCMAKE_RANLIB=${SwiftTesting_MACRO_RANLIB}
38- -DCMAKE_MAKE_PROGRAM=${SwiftTesting_MACRO_MAKE_PROGRAM}
3946 -DSwiftTesting_BuildMacrosAsExecutables=${SwiftTesting_BuildMacrosAsExecutables}
4047 -DSwiftSyntax_DIR=${SwiftSyntax_DIR}
4148 -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>)
@@ -52,14 +59,15 @@ if(NOT SwiftTesting_BuildMacrosAsExecutables)
5259 # TestingMacros uses `ExternalProject` and we cannot directly query the
5360 # properties of its targets here.
5461 if ("${CMAKE_SYSTEM_NAME} " STREQUAL "Darwin" )
55- set (SwiftTesting_TestingMacrosLibraryName "libTestingMacros.dylib" )
62+ install (PROGRAMS "${INSTALL_DIR} /lib/libTestingMacros.dylib"
63+ DESTINATION lib/swift/host/plugins/testing)
5664 elseif ("${CMAKE_SYSTEM_NAME} " STREQUAL "Linux" )
57- set (SwiftTesting_TestingMacrosLibraryName "libTestingMacros.so" )
65+ install (PROGRAMS "${INSTALL_DIR} /lib/libTestingMacros.so"
66+ DESTINATION lib/swift/host/plugins)
67+ elseif ("${CMAKE_SYSTEM_NAME} " STREQUAL "Windows" )
68+ # In Windows toolchain, TestingMacros.dll is installed from seprate CMake
69+ # buikd, just for the macros.
5870 else ()
5971 message (FATAL_ERROR "Unable to determine the library name for TestingMacros based on system name: ${CMAKE_SYSTEM_NAME} " )
6072 endif ()
61-
62- install (PROGRAMS "${INSTALL_DIR} /lib/${SwiftTesting_TestingMacrosLibraryName} "
63- # TODO: Finalize the install path
64- DESTINATION lib/swift/host/plugins)
6573endif ()
0 commit comments