hedgewars/CMakeLists.txt
changeset 4357 a1fcfc341a52
parent 4158 08f4627ad2b3
child 4373 fe0e3903bb9e
--- a/hedgewars/CMakeLists.txt	Wed Nov 17 16:31:30 2010 +0300
+++ b/hedgewars/CMakeLists.txt	Wed Nov 17 17:22:36 2010 +0300
@@ -11,24 +11,24 @@
 #if the headers are not installed, the newer apis won't be activated
 find_file(sdlmixer_h SDL_mixer.h ${SDLMIXER_INCLUDE_DIR})
 if(sdlmixer_h)
-	file(STRINGS ${sdlmixer_h} sdlmixer_version_tmp REGEX "SDL_MIXER_PATCHLEVEL[\t' ']+[0-9]+")
-	string(REGEX MATCH ".([0-9]+)" sdlmixer_version "${sdlmixer_version_tmp}")
+    file(STRINGS ${sdlmixer_h} sdlmixer_version_tmp REGEX "SDL_MIXER_PATCHLEVEL[\t' ']+[0-9]+")
+    string(REGEX MATCH ".([0-9]+)" sdlmixer_version "${sdlmixer_version_tmp}")
 
-	if(sdlmixer_version GREATER 9)
-		message(STATUS "Enabling enhanced SDL_Mixer calls")
-		set(pascal_compiler_flags_cmn "-dSDL_MIXER_NEWER" ${pascal_compiler_flags_cmn})
-	endif()
+    if(sdlmixer_version GREATER 9)
+        message(STATUS "Enabling enhanced SDL_Mixer calls")
+        set(pascal_compiler_flags_cmn "-dSDL_MIXER_NEWER" ${pascal_compiler_flags_cmn})
+    endif()
 endif()
 
 find_file(sdlimage_h SDL_image.h ${SDLIMAGE_INCLUDE_DIR})
 if(sdlimage_h)
-	file(STRINGS ${sdlimage_h} sdlimage_version_tmp REGEX "SDL_IMAGE_PATCHLEVEL[\t' ']+[0-9]+")
-	string(REGEX MATCH ".([0-9]+)" sdlimage_version "${sdlimage_version_tmp}")
+    file(STRINGS ${sdlimage_h} sdlimage_version_tmp REGEX "SDL_IMAGE_PATCHLEVEL[\t' ']+[0-9]+")
+    string(REGEX MATCH ".([0-9]+)" sdlimage_version "${sdlimage_version_tmp}")
 
-	if(sdlimage_version GREATER 7)
-		message(STATUS "Enabling enhanced SDL_Image calls")
-		set(pascal_compiler_flags_cmn "-dSDL_IMAGE_NEWER" ${pascal_compiler_flags_cmn})
-	endif()
+    if(sdlimage_version GREATER 7)
+        message(STATUS "Enabling enhanced SDL_Image calls")
+        set(pascal_compiler_flags_cmn "-dSDL_IMAGE_NEWER" ${pascal_compiler_flags_cmn})
+    endif()
 endif()
 
 #SOURCE AND PROGRAMS SECTION
@@ -36,86 +36,87 @@
 set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwengine.pas)
 
 set(engine_sources
-	${hwengine_project}
-	SDLh.pas
-	uAI.pas
-	uAIActions.pas
-	uAIAmmoTests.pas
-	uAIMisc.pas
-	uAmmos.pas
-	uChat.pas
-	uCollisions.pas
-	uConsole.pas
-	uConsts.pas
-	uFloat.pas
-	uGame.pas
-	uGears.pas
-	uIO.pas
-	uKeys.pas
-	uLand.pas
-	uLandGraphics.pas
-	uLandObjects.pas
-	uLandTemplates.pas
-	uLandTexture.pas
-	uLocale.pas
-	uMisc.pas
-	uMobile.pas
-	uRandom.pas
-	uScript.pas
-	adler32.pas
-	uSound.pas
-	uStats.pas
-	uStore.pas
-	uTeams.pas
-	uVisualGears.pas
-	uWorld.pas
-	CCHandlers.inc
-	GSHandlers.inc
-	VGSHandlers.inc
-	GearDrawing.inc
-	HHHandlers.inc
-	SinTable.inc
-	ArgParsers.inc
-	options.inc
-	${CMAKE_CURRENT_BINARY_DIR}/config.inc
-	)
+    ${hwengine_project}
+    SDLh.pas
+    uAI.pas
+    uAIActions.pas
+    uAIAmmoTests.pas
+    uAIMisc.pas
+    uAmmos.pas
+    uChat.pas
+    uCollisions.pas
+    uConsole.pas
+    uConsts.pas
+    uFloat.pas
+    uGame.pas
+    uGears.pas
+    uIO.pas
+    uKeys.pas
+    uLand.pas
+    uLandGraphics.pas
+    uLandObjects.pas
+    uLandTemplates.pas
+    uLandTexture.pas
+    uLocale.pas
+    uMisc.pas
+    uMobile.pas
+    uRandom.pas
+    uScript.pas
+    adler32.pas
+    uSound.pas
+    uStats.pas
+    uStore.pas
+    uTeams.pas
+    uTypes.pas
+    uVisualGears.pas
+    uWorld.pas
+    CCHandlers.inc
+    GSHandlers.inc
+    VGSHandlers.inc
+    GearDrawing.inc
+    HHHandlers.inc
+    SinTable.inc
+    ArgParsers.inc
+    options.inc
+    ${CMAKE_CURRENT_BINARY_DIR}/config.inc
+    )
 
 if(BUILD_ENGINE_LIBRARY)
-	message(STATUS "Engine will be built as library (experimental)")
-	set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwLibrary.pas)
-	set(engine_sources ${hwengine_project} PascalExports.pas ${engine_sources})
-	set(pascal_compiler_flags_cmn "-dHWLIBRARY" "-k-no_order_inits" "-fPIC" ${pascal_compiler_flags_cmn})
+    message(STATUS "Engine will be built as library (experimental)")
+    set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwLibrary.pas)
+    set(engine_sources ${hwengine_project} PascalExports.pas ${engine_sources})
+    set(pascal_compiler_flags_cmn "-dHWLIBRARY" "-k-no_order_inits" "-fPIC" ${pascal_compiler_flags_cmn})
 endif(BUILD_ENGINE_LIBRARY)
 
 
 find_program(fpc_executable ${fpc_tryexe})
 
 if(fpc_executable)
-	 exec_program(${fpc_executable} ARGS "-iV" OUTPUT_VARIABLE fpc_output)
+    exec_program(${fpc_executable} ARGS "-iV" OUTPUT_VARIABLE fpc_output)
 endif(fpc_executable)
 
 set(noexecstack_flags "-k-z" "-knoexecstack")
 file(WRITE ${EXECUTABLE_OUTPUT_PATH}/checkstack.pas "begin end.")
 
 exec_program(${fpc_executable} ${EXECUTABLE_OUTPUT_PATH}
-	ARGS ${noexecstack_flags} checkstack.pas
-	OUTPUT_VARIABLE noout
-	RETURN_VALUE testnoexecstack
-	)
+    ARGS ${noexecstack_flags} checkstack.pas
+    OUTPUT_VARIABLE noout
+    RETURN_VALUE testnoexecstack
+    )
 
 if(${testnoexecstack})
-	set (noexecstack_flags "")
+    set (noexecstack_flags "")
 endif(${testnoexecstack})
 
 
 if(APPLE)
-	string(REGEX MATCH "[pP][pP][cC]+" powerpc_build "${CMAKE_OSX_ARCHITECTURES}")
-	string(REGEX MATCH "[iI]386+" i386_build "${CMAKE_OSX_ARCHITECTURES}")
-	string(REGEX MATCH "[xX]86_64+" x86_64_build "${CMAKE_OSX_ARCHITECTURES}")
+    string(REGEX MATCH "[pP][pP][cC]+" powerpc_build "${CMAKE_OSX_ARCHITECTURES}")
+    string(REGEX MATCH "[iI]386+" i386_build "${CMAKE_OSX_ARCHITECTURES}")
+    string(REGEX MATCH "[xX]86_64+" x86_64_build "${CMAKE_OSX_ARCHITECTURES}")
 
-	if(powerpc_build)
-		set(powerpc_build "powerpc")
-	endif()
+    if(powerpc_build)
+        set(powerpc_build "powerpc")
+    endif()
 endif(APPLE)
 
 
@@ -123,19 +124,19 @@
 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}")
-	message(STATUS "Freepascal version detected: ${fpc_vers_major}.${fpc_vers_minor}")
-	math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
+    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}")
+    message(STATUS "Freepascal version detected: ${fpc_vers_major}.${fpc_vers_minor}")
+    math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
 
-	if(fpc_ver LESS "020200")
-		message(FATAL_ERROR "Minimum required version of FreePascal is 2.2.0")
-	elseif(APPLE AND x86_64_build AND fpc_ver LESS "020400")
-		message(FATAL_ERROR "Minimum required version of FreePascal is 2.4.0 for building 64 bit applications!")
-	endif()
+    if(fpc_ver LESS "020200")
+        message(FATAL_ERROR "Minimum required version of FreePascal is 2.2.0")
+    elseif(APPLE AND x86_64_build AND fpc_ver LESS "020400")
+        message(FATAL_ERROR "Minimum required version of FreePascal is 2.4.0 for building 64 bit applications!")
+    endif()
 else()
-	message(FATAL_ERROR "No Pascal compiler found!")
+    message(FATAL_ERROR "No Pascal compiler found!")
 endif()
 
 set(pascal_compiler ${fpc_executable})
@@ -144,40 +145,40 @@
 
 #DEPENDECIES AND EXECUTABLES SECTION
 IF(NOT APPLE OR BUILD_ENGINE_LIBRARY)
-	#here is the command for standard executables or for shared library
-	add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}"
-		COMMAND "${pascal_compiler}"
-		ARGS ${pascal_compiler_flags}
-		MAIN_DEPENDENCY ${hwengine_project}
-		DEPENDS ${engine_sources}
-		)
+    #here is the command for standard executables or for shared library
+    add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}"
+        COMMAND "${pascal_compiler}"
+        ARGS ${pascal_compiler_flags}
+        MAIN_DEPENDENCY ${hwengine_project}
+        DEPENDS ${engine_sources}
+        )
 ELSE()
-	#let's build sdlmain, which is absent from the framework
-	find_package(SDL REQUIRED)
+    #let's build sdlmain, which is absent from the framework
+    find_package(SDL REQUIRED)
 
-	set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
-	include_directories(${SDL_INCLUDE_DIR})
+    set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
+    include_directories(${SDL_INCLUDE_DIR})
 
-	add_library (SDLmain STATIC SDLMain.m)
+    add_library (SDLmain STATIC SDLMain.m)
 
 
-	#these are the dependencies for building a universal binary on Mac OS X
-	foreach (build_arch ${powerpc_build} ${i386_build} ${x86_64_build})
-		set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}" ${lipo_args_list})
-		add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}"
-			COMMAND "${pascal_compiler}"
-			ARGS ${pascal_compiler_flags} -ohwengine.${build_arch} -P${build_arch}
-			MAIN_DEPENDENCY ${hwengine_project}
-			DEPENDS ${engine_sources} SDLmain lua
-			)
-		add_custom_target(hwengine.${build_arch} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}")
-	endforeach()
+    #these are the dependencies for building a universal binary on Mac OS X
+    foreach (build_arch ${powerpc_build} ${i386_build} ${x86_64_build})
+        set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}" ${lipo_args_list})
+        add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}"
+            COMMAND "${pascal_compiler}"
+            ARGS ${pascal_compiler_flags} -ohwengine.${build_arch} -P${build_arch}
+            MAIN_DEPENDENCY ${hwengine_project}
+            DEPENDS ${engine_sources} SDLmain lua
+            )
+        add_custom_target(hwengine.${build_arch} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}")
+    endforeach()
 
-	add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine"
-		COMMAND "lipo"
-		ARGS ${lipo_args_list} -create -output ${EXECUTABLE_OUTPUT_PATH}/hwengine
-		DEPENDS ${lipo_args_list}
-		)
+    add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine"
+        COMMAND "lipo"
+        ARGS ${lipo_args_list} -create -output ${EXECUTABLE_OUTPUT_PATH}/hwengine
+        DEPENDS ${lipo_args_list}
+        )
 ENDIF()