hedgewars/CMakeLists.txt
changeset 2406 2e757b32991e
parent 2404 8281eea32196
child 2413 d921d13a8546
equal deleted inserted replaced
2405:3b8607ac32c6 2406:2e757b32991e
     3 find_package(SDL REQUIRED)
     3 find_package(SDL REQUIRED)
     4 find_package(SDL_image REQUIRED)
     4 find_package(SDL_image REQUIRED)
     5 find_package(SDL_net REQUIRED)
     5 find_package(SDL_net REQUIRED)
     6 find_package(SDL_ttf REQUIRED)
     6 find_package(SDL_ttf REQUIRED)
     7 
     7 
       
     8 
       
     9 #SOURCE AND PROGRAMS SECTION 
     8 set(fpc_tryexe fpc)
    10 set(fpc_tryexe fpc)
     9 set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwengine.pas)
    11 set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwengine.pas)
    10 
    12 
    11 set(engine_sources
    13 set(engine_sources
    12 	${hwengine_project}
    14 	${hwengine_project}
    66 
    68 
    67 if (${testnoexecstack})
    69 if (${testnoexecstack})
    68 set (noexecstack_flags "")
    70 set (noexecstack_flags "")
    69 endif (${testnoexecstack})
    71 endif (${testnoexecstack})
    70 
    72 
       
    73 
       
    74 #PASCAL DETECTION SECTION
       
    75 string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}")
       
    76 
       
    77 if (fpc_version)
       
    78 	string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}")
       
    79 	string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}")
       
    80 	string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}")
       
    81 	math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
       
    82 	if (fpc_ver LESS "020200")
       
    83 		message(FATAL_ERROR "Minimum required version of FreePascal is 2.2.0")
       
    84 	else()
       
    85 		set(pascal_compiler ${fpc_executable})
       
    86 	endif ()
       
    87 endif (fpc_version)
       
    88 
       
    89 if (NOT pascal_compiler)
       
    90 	message(FATAL_ERROR "No Pascal compiler found!")
       
    91 endif (NOT pascal_compiler)
       
    92 
       
    93 
       
    94 #PASCAL FLAG SECTION
       
    95 set(pascal_compiler_flags ${noexecstack_flags} "-B" "-FE../bin" "-Fl../bin/" "-Cs2000000" "-vwi" "-fPIC" ${hwengine_project})
       
    96 
       
    97 if(OPTIMIZATIONS)
       
    98 	set(pascal_compiler_flags "-O2" "-Xs" "-Nu" ${pascal_compiler_flags})
       
    99 	if(APPLE AND NOT universal_build)
       
   100 		set(pascal_compiler_flags "-CfSSE2" ${pascal_compiler_flags})	#instruction set for ppc is 7400
       
   101 	endif()			
       
   102 else(OPTIMIZATIONS)
       
   103 	set(pascal_compiler_flags "-O-" "-gl" "-dDEBUGFILE" "-pg" "-va" ${pascal_compiler_flags})
       
   104 endif(OPTIMIZATIONS)
       
   105 
       
   106 if(LOWRES)
       
   107 	set(pascal_compiler_flags "-dLOWRES" ${pascal_compiler_flags} ${hwengine_project})
       
   108 endif(LOWRES)
       
   109 
       
   110 #special handling of MSVC compiler (no static linking)
       
   111 if(MSVC)
       
   112 	set(pascal_compiler_flags "-dMSVC" ${pascal_compiler_flags})
       
   113 endif(MSVC)
       
   114 
       
   115 
       
   116 #DEPENDECIES AND EXECUTABLES SECTION
    71 IF(APPLE)
   117 IF(APPLE)
    72 #let's build sdlmain, which is absent from the framework
   118 #let's build sdlmain, which is absent from the framework
    73 	set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
   119 	set(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
    74 	include_directories(${SDL_INCLUDE_DIR})
   120 	include_directories(${SDL_INCLUDE_DIR})
    75 	link_libraries(${SDL_LIBRARY})
   121 	link_libraries(${SDL_LIBRARY})
    76 
   122 
    77 	add_library (SDLmain STATIC SDLMain.m)
   123 	add_library (SDLmain STATIC SDLMain.m)
    78 	set(engine_sources SDLmain ${engine_sources})
   124 	set(engine_sources SDLmain ${engine_sources})
    79 ENDIF(APPLE)
   125 ENDIF(APPLE)
    80 
       
    81 string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" fpc_version "${fpc_output}")
       
    82 
       
    83 if (fpc_version)
       
    84 	string(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" fpc_vers_major "${fpc_version}")
       
    85 	string(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" fpc_vers_minor "${fpc_version}")
       
    86 	string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" fpc_vers_patch "${fpc_version}")
       
    87 	math(EXPR fpc_ver "${fpc_vers_major}*10000 + ${fpc_vers_minor}*100 + ${fpc_vers_patch}")
       
    88 	if (fpc_ver LESS "020200")
       
    89 		message(STATUS "Minimum required version of FreePascal is 2.2.0")
       
    90 	else (fpc_ver LESS "020200")
       
    91 		set(pascal_compiler ${fpc_executable})
       
    92 		if(NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE MATCHES "Release")
       
    93 			set(pascal_compiler_flags ${noexecstack_flags} "-B" "-FE../bin" "-Fl../bin/" "-Cs2000000" "-vwi" "-O2" "-Xs" ${hwengine_project})
       
    94 		else()
       
    95 			set(pascal_compiler_flags ${noexecstack_flags} "-B" "-FE../bin" "-Fl../bin/" "-Cs2000000" "-vwi" "-O-" "-gl" "-dDEBUGFILE" ${hwengine_project})
       
    96 		endif()
       
    97 		if(LOWRES)
       
    98 			set(pascal_compiler_flags "-dLOWRES" ${pascal_compiler_flags} ${hwengine_project})
       
    99 		endif(LOWRES)
       
   100 	endif (fpc_ver LESS "020200")
       
   101 endif (fpc_version)
       
   102 
       
   103 if (NOT pascal_compiler)
       
   104 	message(FATAL_ERROR "No Pascal compiler found!")
       
   105 endif (NOT pascal_compiler)
       
   106 
       
   107 #special handling of MSVC compiler (no static linking)
       
   108 if(MSVC)
       
   109 	set(pascal_compiler_flags "-dMSVC" ${pascal_compiler_flags})
       
   110 endif(MSVC)
       
   111 
   126 
   112 IF(NOT APPLE OR NOT universal_build)
   127 IF(NOT APPLE OR NOT universal_build)
   113 #here is the standard command for any system
   128 #here is the standard command for any system
   114 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}"
   129 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}"
   115 		COMMAND "${pascal_compiler}"
   130 		COMMAND "${pascal_compiler}"
   119 		)
   134 		)
   120 ELSE()
   135 ELSE()
   121 #these are the two dependencies for building a universal binary on Mac OS X
   136 #these are the two dependencies for building a universal binary on Mac OS X
   122 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.386"
   137 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.386"
   123 		COMMAND "ppc386" 
   138 		COMMAND "ppc386" 
   124 		ARGS ${pascal_compiler_flags} -ohwengine.386
   139 		ARGS ${pascal_compiler_flags} -ohwengine.386 -CfSSE2
   125 		MAIN_DEPENDENCY ${hwengine_project}
   140 		MAIN_DEPENDENCY ${hwengine_project}
   126 		DEPENDS openalbridge ${engine_sources}
   141 		DEPENDS openalbridge ${engine_sources}
   127 		)
   142 		)
   128 add_custom_target(hwengine.386 ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386")
   143 add_custom_target(hwengine.386 ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.386")
   129 
   144