184
|
1 |
set(dcc32_tryexe dcc32.exe)
|
|
2 |
set(fpc_tryexe fpc)
|
|
3 |
set(hwengine_project "hwengine.dpr")
|
|
4 |
|
|
5 |
find_program(dcc32_executable ${dcc32_tryexe})
|
|
6 |
find_program(fpc_executable ${fpc_tryexe})
|
|
7 |
|
|
8 |
if (dcc32_executable)
|
|
9 |
exec_program(${dcc32_executable} ARGS "--version" OUTPUT_VARIABLE dcc32_output)
|
|
10 |
endif (dcc32_executable)
|
|
11 |
|
|
12 |
if (fpc_executable)
|
|
13 |
exec_program(${fpc_executable} ARGS "-h" OUTPUT_VARIABLE fpc_output)
|
|
14 |
endif (fpc_executable)
|
|
15 |
|
|
16 |
string(REGEX MATCH "[0-9]+\\.[0-9]+" dcc32version "${dcc32_output}")
|
|
17 |
if (dcc32version)
|
|
18 |
set(pascal_compiler ${dcc32_executable})
|
|
19 |
set(pascal_compiler_flags "-B" "-W" ${hwengine_project})
|
|
20 |
else (dcc32version)
|
|
21 |
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}")
|
|
22 |
if (fpc_version)
|
|
23 |
string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}")
|
|
24 |
string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}")
|
|
25 |
string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}")
|
|
26 |
math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
|
|
27 |
if (${fpc_ver} LESS "010906")
|
|
28 |
message("Minimum required version of FreePascal is 2.0.5")
|
|
29 |
else (${fpc_ver} LESS "010906")
|
|
30 |
set(pascal_compiler ${fpc_executable})
|
|
31 |
set(pascal_compiler_flags "-B" "-Sd" "-Xs" "-OG" "-O2" "-Cs2000000" ${hwengine_project})
|
|
32 |
endif (${fpc_ver} LESS "010906")
|
|
33 |
endif (fpc_version)
|
|
34 |
endif (dcc32version)
|
|
35 |
|
|
36 |
if (NOT pascal_compiler)
|
|
37 |
message(FATAL_ERROR "No Pascal compiler found!")
|
|
38 |
endif (NOT pascal_compiler)
|
|
39 |
|
|
40 |
add_custom_target(hwengine ALL COMMAND "${pascal_compiler}" ${pascal_compiler_flags})
|
|
41 |
|
|
42 |
install(PROGRAMS "hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION bin)
|