Skip to content

Commit 824c66a

Browse files
committed
CMake: Improving missing compiler error message
Right now, if you have the new parser enabled and try to configure without an existing Swift compiler, the configuration fails due to a call to 'get_filename_component' with the wrong number of arguments. This is is because the `CMAKE_Swift_COMPILER` is empty and doesn't expand to anything here: ``` get_filename_component(swift_bin_dir ${CMAKE_Swift_COMPILER} DIRECTORY) ``` The current error is not clear about why it failed though. Improving the error message so that other people can look at it and see that it's because the compiler is missing.
1 parent 840ed6a commit 824c66a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,13 @@ if(SWIFT_INCLUDE_TOOLS AND SWIFT_BUILD_SWIFT_SYNTAX)
968968
if(SWIFT_HOST_VARIANT_SDK MATCHES "LINUX|OPENBSD|FREEBSD" AND NOT BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
969969
message(WARNING "Force setting BOOTSTRAPPING=HOSTTOOLS because Swift parser integration is enabled")
970970
set(BOOTSTRAPPING_MODE "HOSTTOOLS")
971+
if(NOT CMAKE_Swift_COMPILER)
972+
message(SEND_ERROR "No Swift compiler found.\n"
973+
"Tell CMake where to find the Swift compiler by setting either the "
974+
"environment variable \"SWIFTC\" or the CMake cache entry "
975+
"CMAKE_Swift_COMPILER to the full path of the compiler, or to the "
976+
"compiler name if it is in the PATH")
977+
endif()
971978
endif()
972979
add_definitions(-DSWIFT_BUILD_SWIFT_SYNTAX)
973980
endif()

0 commit comments

Comments
 (0)