comparison cmake/FindD.cmake @ 402:e67ce7c21758

gdc & 64 bit changes
author Eldar Insafutdinov
date Thu, 17 Mar 2011 19:45:42 +0000
parents d2f48c4cb3e3
children 8564ab82ea42
comparison
equal deleted inserted replaced
395:d757b8b1ca75 402:e67ce7c21758
1 ##-------------------------------------------- 1 ##--------------------------------------------
2 ## Variables. 2 ## Variables.
3 ##-------------------------------------------- 3 ##--------------------------------------------
4 4
5 ## Find D compiler and parse its version. 5 ## Find D compiler and parse its version.
6 find_program(DC NAMES dmd ldc) 6 find_program(DC NAMES dmd ldc gdmd)
7 if (DC) 7 if (DC)
8 get_filename_component(dc_path ${DC} PATH) 8 get_filename_component(dc_path ${DC} PATH)
9 if("${dc_path}" STREQUAL ${CMAKE_BINARY_DIR}) 9 if("${dc_path}" STREQUAL ${CMAKE_BINARY_DIR})
10 get_filename_component(DC ${DC} NAME) 10 get_filename_component(DC ${DC} NAME)
11 endif("${dc_path}" STREQUAL ${CMAKE_BINARY_DIR}) 11 endif("${dc_path}" STREQUAL ${CMAKE_BINARY_DIR})
12 exec_program(${DC} ARGS "" OUTPUT_VARIABLE d_output) 12 exec_program(${DC} ARGS "" OUTPUT_VARIABLE d_output)
13 string(REGEX MATCH "Digital Mars D Compiler v[0-9]\\.[0-9]+" dmd_version "${d_output}") 13 string(REGEX MATCH "Digital Mars D Compiler v[0-9]\\.[0-9]+" dmd_version "${d_output}")
14 if (dmd_version) 14 if (dmd_version)
15 set(D_IS_MARS true) 15 set(D_IS_MARS true)
16 set(D_IS_DMD true) 16 set(D_IS_DMD true)
17 set(D_COMPILER_NAME "Digital Mars D Compiler") 17 set(D_COMPILER_NAME "Digital Mars D Compiler")
18 string(REGEX REPLACE "Digital Mars D Compiler v([0-9])\\.[0-9]+" "\\1" D_VERSION "${dmd_version}") 18 string(REGEX REPLACE "Digital Mars D Compiler v([0-9])\\.[0-9]+" "\\1" D_VERSION "${dmd_version}")
19 string(REGEX REPLACE "Digital Mars D Compiler v[0-9]\\.([0-9]+)" "\\1" D_FRONTEND "${dmd_version}") 19 string(REGEX REPLACE "Digital Mars D Compiler v[0-9]\\.([0-9]+)" "\\1" D_FRONTEND "${dmd_version}")
20 else (dmd_version) 20 else (dmd_version)
21 string(REGEX MATCH "LLVM-based D Compiler" is_ldc "${d_output}") 21 string(REGEX MATCH "LLVM-based D Compiler" is_ldc "${d_output}")
22 if (is_ldc) 22 if (is_ldc)
23 exec_program(${DC} ARGS "--version" OUTPUT_VARIABLE d_output) 23 exec_program(${DC} ARGS "--version" OUTPUT_VARIABLE d_output)
24 string(REGEX MATCH "based on DMD v[0-9]\\.[0-9]+" ldc_version "${d_output}") 24 string(REGEX MATCH "based on DMD v[0-9]\\.[0-9]+" ldc_version "${d_output}")
31 string(REGEX REPLACE "based on DMD v[0-9]\\.([0-9]+)" "\\1" D_FRONTEND "${ldc_version}") 31 string(REGEX REPLACE "based on DMD v[0-9]\\.([0-9]+)" "\\1" D_FRONTEND "${ldc_version}")
32 else(ldc_version) 32 else(ldc_version)
33 message(FATAL_ERROR "LDC compiler found, but the version can not be processed") 33 message(FATAL_ERROR "LDC compiler found, but the version can not be processed")
34 endif(ldc_version) 34 endif(ldc_version)
35 else (is_ldc) 35 else (is_ldc)
36 message(FATAL_ERROR "D compiler is not found") 36 string(REGEX MATCH "gdc" is_gdc "${d_output}")
37 endif(is_ldc) 37 if(is_gdc)
38 set(D_COMPILER_NAME "GDC-based D Compiler")
39 set(D_VERSION 2)
40 else(is_gdc)
41 message(FATAL_ERROR "D compiler is not found")
42 endif(is_gdc)
43 endif(is_ldc)
38 endif(dmd_version) 44 endif(dmd_version)
39 message(STATUS "D compiler found -- ${D_COMPILER_NAME} v${D_VERSION}.${D_FRONTEND}") 45 message(STATUS "D compiler found -- ${D_COMPILER_NAME} v${D_VERSION}.${D_FRONTEND}")
40 else (DC) 46 else (DC)
41 message(FATAL_ERROR "D compliler is not found") 47 message(FATAL_ERROR "D compliler is not found")
42 endif (DC) 48 endif (DC)