hedgewars/CMakeLists.txt
author unc0rr
Wed, 25 Oct 2006 18:03:41 +0000
changeset 203 0ee86f9d9ba6
parent 196 993cf173218b
child 220 d79eaeaf969d
permissions -rw-r--r--
Better crosshair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
     1
set(dcc32_tryexe dcc32.exe)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
     2
set(fpc_tryexe fpc)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
     3
set(hwengine_project "hwengine.dpr")
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
     4
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
     5
find_program(dcc32_executable ${dcc32_tryexe})
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
     6
find_program(fpc_executable ${fpc_tryexe})
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
     7
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
     8
if (dcc32_executable)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
     9
	 exec_program(${dcc32_executable} ARGS "--version" OUTPUT_VARIABLE dcc32_output)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    10
endif (dcc32_executable)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    11
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    12
if (fpc_executable)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    13
	 exec_program(${fpc_executable} ARGS "-h" OUTPUT_VARIABLE fpc_output)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    14
endif (fpc_executable)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    15
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    16
string(REGEX MATCH "[0-9]+\\.[0-9]+" dcc32version "${dcc32_output}")
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    17
if (dcc32version)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    18
	set(pascal_compiler ${dcc32_executable})
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    19
	set(pascal_compiler_flags "-B" "-W" ${hwengine_project})
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    20
else (dcc32version)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    21
	string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}")
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    22
	if (fpc_version)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    23
		string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}")
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    24
		string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}")
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    25
		string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}")
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    26
		math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
196
993cf173218b - Many small fixes
unc0rr
parents: 193
diff changeset
    27
		if (fpc_ver LESS "010904")
993cf173218b - Many small fixes
unc0rr
parents: 193
diff changeset
    28
			message("Minimum required version of FreePascal is 1.9.4")
993cf173218b - Many small fixes
unc0rr
parents: 193
diff changeset
    29
		else (fpc_ver LESS "010904")
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    30
			set(pascal_compiler ${fpc_executable})
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    31
			set(pascal_compiler_flags "-B" "-Sd" "-Xs" "-OG" "-O2" "-Cs2000000" ${hwengine_project})
196
993cf173218b - Many small fixes
unc0rr
parents: 193
diff changeset
    32
		endif (fpc_ver LESS "010904")
184
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    33
	endif (fpc_version)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    34
endif (dcc32version)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    35
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    36
if (NOT pascal_compiler)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    37
	message(FATAL_ERROR "No Pascal compiler found!")
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    38
endif (NOT pascal_compiler)
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    39
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    40
add_custom_target(hwengine ALL COMMAND "${pascal_compiler}" ${pascal_compiler_flags})
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    41
f97a7a3dc8f6 - Update more headers
unc0rr
parents: 173
diff changeset
    42
install(PROGRAMS "hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION bin)