hedgewars/CMakeLists.txt
changeset 220 d79eaeaf969d
parent 196 993cf173218b
child 226 be2e08b0109f
equal deleted inserted replaced
219:73a2bf84d0e6 220:d79eaeaf969d
     1 set(dcc32_tryexe dcc32.exe)
     1 set(dcc32_tryexe dcc132.exe)
     2 set(fpc_tryexe fpc)
     2 set(fpc_tryexe fpc)
     3 set(hwengine_project "hwengine.dpr")
     3 set(hwengine_project "hwengine.dpr")
       
     4 
       
     5 set(engine_sources
       
     6 	${hwengine_project}
       
     7 	SDLh.pas
       
     8 	uAI.pas
       
     9 	uAIActions.pas
       
    10 	uAIAmmoTests.pas
       
    11 	uAIMisc.pas
       
    12 	uAIThinkStack.pas
       
    13 	uCollisions.pas
       
    14 	uConsole.pas
       
    15 	uConsts.pas
       
    16 	uGame.pas
       
    17 	uGears.pas
       
    18 	uIO.pas
       
    19 	uKeys.pas
       
    20 	uLand.pas
       
    21 	uLandGraphics.pas
       
    22 	uLandObjects.pas
       
    23 	uLandTemplates.pas
       
    24 	uLocale.pas
       
    25 	uMisc.pas
       
    26 	uRandom.pas
       
    27 	uSound.pas
       
    28 	uStore.pas
       
    29 	uTeams.pas
       
    30 	uWorld.pas
       
    31 	CCHandlers.inc
       
    32 	GSHandlers.inc
       
    33 	HHHandlers.inc
       
    34 	options.inc
       
    35 	tunsetborder.inc
       
    36 	)
     4 
    37 
     5 find_program(dcc32_executable ${dcc32_tryexe})
    38 find_program(dcc32_executable ${dcc32_tryexe})
     6 find_program(fpc_executable ${fpc_tryexe})
    39 find_program(fpc_executable ${fpc_tryexe})
     7 
    40 
     8 if (dcc32_executable)
    41 if (dcc32_executable)
    14 endif (fpc_executable)
    47 endif (fpc_executable)
    15 
    48 
    16 string(REGEX MATCH "[0-9]+\\.[0-9]+" dcc32version "${dcc32_output}")
    49 string(REGEX MATCH "[0-9]+\\.[0-9]+" dcc32version "${dcc32_output}")
    17 if (dcc32version)
    50 if (dcc32version)
    18 	set(pascal_compiler ${dcc32_executable})
    51 	set(pascal_compiler ${dcc32_executable})
    19 	set(pascal_compiler_flags "-B" "-W" ${hwengine_project})
    52 	set(pascal_compiler_flags "-B" "-W" "-E${EXECUTABLE_OUTPUT_PATH}" ${hwengine_project})
    20 else (dcc32version)
    53 else (dcc32version)
    21 	string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}")
    54 	string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}")
    22 	if (fpc_version)
    55 	if (fpc_version)
    23 		string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}")
    56 		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}")
    57 		string(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}")
    26 		math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
    59 		math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
    27 		if (fpc_ver LESS "010904")
    60 		if (fpc_ver LESS "010904")
    28 			message("Minimum required version of FreePascal is 1.9.4")
    61 			message("Minimum required version of FreePascal is 1.9.4")
    29 		else (fpc_ver LESS "010904")
    62 		else (fpc_ver LESS "010904")
    30 			set(pascal_compiler ${fpc_executable})
    63 			set(pascal_compiler ${fpc_executable})
    31 			set(pascal_compiler_flags "-B" "-Sd" "-Xs" "-OG" "-O2" "-Cs2000000" ${hwengine_project})
    64 			set(pascal_compiler_flags "-B" "-Sd" "-Xs" "-OG" "-O2" "-FE${EXECUTABLE_OUTPUT_PATH}" "-Cs2000000" ${hwengine_project})
    32 		endif (fpc_ver LESS "010904")
    65 		endif (fpc_ver LESS "010904")
    33 	endif (fpc_version)
    66 	endif (fpc_version)
    34 endif (dcc32version)
    67 endif (dcc32version)
    35 
    68 
    36 if (NOT pascal_compiler)
    69 if (NOT pascal_compiler)
    37 	message(FATAL_ERROR "No Pascal compiler found!")
    70 	message(FATAL_ERROR "No Pascal compiler found!")
    38 endif (NOT pascal_compiler)
    71 endif (NOT pascal_compiler)
    39 
    72 
    40 add_custom_target(hwengine ALL COMMAND "${pascal_compiler}" ${pascal_compiler_flags})
    73 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}"
       
    74                   COMMAND "${pascal_compiler}" 
       
    75                   ARGS ${pascal_compiler_flags}
       
    76                   MAIN_DEPENDENCY ${hwengine_project}
       
    77                   DEPENDS ${engine_sources}
       
    78                   )
       
    79                    
       
    80 add_custom_target(hwengine ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}")
    41 
    81 
    42 install(PROGRAMS "hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION bin)
    82 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION bin)