diff --git a/cmake/Modules/FindDCompiler.cmake b/cmake/Modules/FindDCompiler.cmake index 494ffa80ad..32bbc0bcf6 100644 --- a/cmake/Modules/FindDCompiler.cmake +++ b/cmake/Modules/FindDCompiler.cmake @@ -6,6 +6,8 @@ # D_COMPILER_FOUND - true if a D compiler was found # D_COMPILER - D compiler # D_COMPILER_FLAGS - D compiler flags (could be passed in the DMD environment variable) +# D_COMPILER_ID = {"DigitalMars", "LDMD", "LDC", "GDC"} +# D_COMPILER_VERSION_STRING - String containing the compiler version, e.g. "DMD64 D Compiler v2.070.2" set(D_COMPILER_FOUND "FALSE") @@ -40,11 +42,19 @@ if (D_COMPILER) elseif (__D_COMPILER_NAME STREQUAL "gdc") set(D_COMPILER_ID "GDC") endif() + + # Older versions of ldmd do not have --version cmdline option, but the error message still contains the version info in the first line. + execute_process(COMMAND ${D_COMPILER} --version + OUTPUT_VARIABLE D_COMPILER_VERSION_STRING + ERROR_VARIABLE D_COMPILER_VERSION_STRING + ERROR_QUIET) + string(REGEX MATCH "^[^\r\n:]*" D_COMPILER_VERSION_STRING "${D_COMPILER_VERSION_STRING}") endif() if (D_COMPILER_FOUND) message(STATUS "Found D compiler ${D_COMPILER}, with default flags '${D_COMPILER_FLAGS}'") + message(STATUS "D compiler version: ${D_COMPILER_VERSION_STRING}") else() message(FATAL_ERROR "Did not find D compiler! Try setting the 'DMD' environment variable.") -endif() \ No newline at end of file +endif() diff --git a/driver/ldc-version.cpp.in b/driver/ldc-version.cpp.in index 1b11fb8374..9f9c158c74 100644 --- a/driver/ldc-version.cpp.in +++ b/driver/ldc-version.cpp.in @@ -14,5 +14,6 @@ namespace ldc { const char * const ldc_version = "@LDC_VERSION@"; const char * const dmd_version = "v@DMD_VERSION@"; const char * const llvm_version = "@LLVM_VERSION_STRING@"; +const char * const built_with_Dcompiler_version = "@D_COMPILER_VERSION_STRING@"; } \ No newline at end of file diff --git a/driver/ldc-version.h b/driver/ldc-version.h index 6166e728a0..a1451bc7be 100644 --- a/driver/ldc-version.h +++ b/driver/ldc-version.h @@ -15,6 +15,8 @@ namespace ldc { extern const char *const ldc_version; extern const char *const dmd_version; extern const char *const llvm_version; +extern const char *const built_with_Dcompiler_version; + } #endif diff --git a/driver/main.cpp b/driver/main.cpp index 3c1dc29e2f..3e39f60634 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -121,6 +121,7 @@ void printVersion() { printf("LDC - the LLVM D compiler (%s):\n", global.ldc_version); printf(" based on DMD %s and LLVM %s\n", global.version, global.llvm_version); + printf(" built with %s\n", ldc::built_with_Dcompiler_version); #if defined(__has_feature) #if __has_feature(address_sanitizer) printf(" compiled with address sanitizer enabled\n");