hedgewars/CMakeLists.txt
author unc0rr
Wed, 27 Sep 2006 20:13:29 +0000
changeset 174 0b2c5b22f644
parent 173 004493dd60e4
child 184 f97a7a3dc8f6
permissions -rw-r--r--
Changeable volume

set(dcc32_tryexe dcc32.exe)
set(fpc_tryexe fpc)
set(hwengine_project "hwengine.dpr")

find_program(dcc32_executable ${dcc32_tryexe})
find_program(fpc_executable ${fpc_tryexe})

if (dcc32_executable)
	 exec_program(${dcc32_executable} ARGS "--version" OUTPUT_VARIABLE dcc32_output)
endif (dcc32_executable)

if (fpc_executable)
	 exec_program(${fpc_executable} ARGS "-h" OUTPUT_VARIABLE fpc_output)
endif (fpc_executable)

string(REGEX MATCH "[0-9]+\\.[0-9]+" dcc32version "${dcc32_output}")
if (dcc32version)
	set(pascal_compiler ${dcc32_executable})
	set(pascal_compiler_flags "-B" "-W" ${hwengine_project})
else (dcc32version)
	string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}")
	if (fpc_version)
		string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}")
		string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}")
		string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}")
		math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
		if (${fpc_ver} LESS "010906")
			message("Minimum required version of FreePascal is 2.0.5")
		else (${fpc_ver} LESS "010906")
			set(pascal_compiler ${fpc_executable})
			set(pascal_compiler_flags "-B" "-Sd" "-Xs" "-OG" "-O2" "-Cs2000000" ${hwengine_project})
		endif (${fpc_ver} LESS "010906")
	endif (fpc_version)
endif (dcc32version)

if (NOT pascal_compiler)
	message(FATAL_ERROR "No Pascal compiler found!")
endif (NOT pascal_compiler)

add_custom_target(hwengine ALL COMMAND "${pascal_compiler}" ${pascal_compiler_flags})

install(PROGRAMS "hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION bin)