hedgewars/CMakeLists.txt
changeset 3495 a6b4f351d400
parent 3468 c7b80bdbc384
child 3510 23145a950eae
equal deleted inserted replaced
3494:208c5671b202 3495:a6b4f351d400
     9 
     9 
    10 #find which version of SDL_image and SDL_mixer we have (for IMG_Init and Mix_Init)
    10 #find which version of SDL_image and SDL_mixer we have (for IMG_Init and Mix_Init)
    11 #if the headers are not installed, the newer apis won't be activated
    11 #if the headers are not installed, the newer apis won't be activated
    12 find_file(sdlmixer_h SDL_mixer.h ${SDLMIXER_INCLUDE_DIR})
    12 find_file(sdlmixer_h SDL_mixer.h ${SDLMIXER_INCLUDE_DIR})
    13 if(sdlmixer_h)
    13 if(sdlmixer_h)
    14 file(STRINGS ${sdlmixer_h} sdlmixer_version_tmp REGEX "SDL_MIXER_PATCHLEVEL[\t' ']+[0-9]+")
    14 	file(STRINGS ${sdlmixer_h} sdlmixer_version_tmp REGEX "SDL_MIXER_PATCHLEVEL[\t' ']+[0-9]+")
    15 string(REGEX MATCH ".([0-9]+)" sdlmixer_version "${sdlmixer_version_tmp}")
    15 	string(REGEX MATCH ".([0-9]+)" sdlmixer_version "${sdlmixer_version_tmp}")
    16 
    16 
    17 if(sdlmixer_version GREATER 9)
    17 	if(sdlmixer_version GREATER 9)
    18 message(STATUS "Enabling enhanced SDL_Mixer calls")
    18 		message(STATUS "Enabling enhanced SDL_Mixer calls")
    19 set(pascal_compiler_flags_cmn "-dSDL_MIXER_NEWER" ${pascal_compiler_flags_cmn})
    19 		set(pascal_compiler_flags_cmn "-dSDL_MIXER_NEWER" ${pascal_compiler_flags_cmn})
    20 endif()
    20 	endif()
    21 endif()
    21 endif()
    22 
    22 
    23 find_file(sdlimage_h SDL_image.h ${SDLIMAGE_INCLUDE_DIR})
    23 find_file(sdlimage_h SDL_image.h ${SDLIMAGE_INCLUDE_DIR})
    24 if(sdlimage_h)
    24 if(sdlimage_h)
    25 file(STRINGS ${sdlimage_h} sdlimage_version_tmp REGEX "SDL_IMAGE_PATCHLEVEL[\t' ']+[0-9]+")
    25 	file(STRINGS ${sdlimage_h} sdlimage_version_tmp REGEX "SDL_IMAGE_PATCHLEVEL[\t' ']+[0-9]+")
    26 string(REGEX MATCH ".([0-9]+)" sdlimage_version "${sdlimage_version_tmp}")
    26 	string(REGEX MATCH ".([0-9]+)" sdlimage_version "${sdlimage_version_tmp}")
    27 
    27 
    28 if(sdlimage_version GREATER 7)
    28 	if(sdlimage_version GREATER 7)
    29 message(STATUS "Enabling enhanced SDL_Image calls")
    29 		message(STATUS "Enabling enhanced SDL_Image calls")
    30 set(pascal_compiler_flags_cmn "-dSDL_IMAGE_NEWER" ${pascal_compiler_flags_cmn})
    30 		set(pascal_compiler_flags_cmn "-dSDL_IMAGE_NEWER" ${pascal_compiler_flags_cmn})
    31 endif()
    31 	endif()
    32 endif()
    32 endif()
    33 
    33 
    34 #SOURCE AND PROGRAMS SECTION 
    34 #SOURCE AND PROGRAMS SECTION 
    35 set(fpc_tryexe fpc)
    35 set(fpc_tryexe fpc)
    36 set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwengine.pas)
    36 set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwengine.pas)
    75 	HHHandlers.inc
    75 	HHHandlers.inc
    76 	SinTable.inc
    76 	SinTable.inc
    77 	options.inc
    77 	options.inc
    78 	${CMAKE_CURRENT_BINARY_DIR}/config.inc
    78 	${CMAKE_CURRENT_BINARY_DIR}/config.inc
    79 	)
    79 	)
       
    80 
       
    81 if(BUILD_ENGINE_LIBRARY)
       
    82 	message(STATUS "Engine will be built as library (experimental)")
       
    83 	set(hwengine_project ${hedgewars_SOURCE_DIR}/hedgewars/hwLibrary.pas)
       
    84 	set(engine_sources ${hwengine_project} PascalExports.pas ${engine_sources})
       
    85 	set(pascal_compiler_flags_cmn "-dHWLIBRARY" "-k-no_order_inits" ${pascal_compiler_flags_cmn})
       
    86 endif(BUILD_ENGINE_LIBRARY)
       
    87 
    80 
    88 
    81 find_program(fpc_executable ${fpc_tryexe})
    89 find_program(fpc_executable ${fpc_tryexe})
    82 
    90 
    83 if(fpc_executable)
    91 if(fpc_executable)
    84 	 exec_program(${fpc_executable} ARGS "-h" OUTPUT_VARIABLE fpc_output)
    92 	 exec_program(${fpc_executable} ARGS "-h" OUTPUT_VARIABLE fpc_output)
   131 set(pascal_compiler ${fpc_executable})
   139 set(pascal_compiler ${fpc_executable})
   132 set(pascal_compiler_flags ${noexecstack_flags} ${pascal_compiler_flags_cmn} ${hwengine_project})
   140 set(pascal_compiler_flags ${noexecstack_flags} ${pascal_compiler_flags_cmn} ${hwengine_project})
   133 
   141 
   134 
   142 
   135 #DEPENDECIES AND EXECUTABLES SECTION
   143 #DEPENDECIES AND EXECUTABLES SECTION
   136 IF(NOT APPLE)
   144 IF(NOT APPLE OR BUILD_ENGINE_LIBRARY)
   137 #here is the standard command for any system
   145 	#here is the command for standard executables or for shared library
   138 	add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}"
   146 	add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}"
   139 		COMMAND "${pascal_compiler}"
   147 		COMMAND "${pascal_compiler}"
   140 		ARGS ${pascal_compiler_flags}
   148 		ARGS ${pascal_compiler_flags}
   141 		MAIN_DEPENDENCY ${hwengine_project}
   149 		MAIN_DEPENDENCY ${hwengine_project}
   142 		DEPENDS ${engine_sources}
   150 		DEPENDS ${engine_sources}
   143 		)
   151 		)
   144 ELSE()
   152 ELSE()
   145 	#let's build sdlmain, which is absent from the framework
   153 	#let's build sdlmain, which is absent from the framework
   146 	find_package(SDL REQUIRED)
   154 	find_package(SDL REQUIRED)
   147 
   155 
   148 #	set(CMAKE_OSX_ARCHITECTURES "x86_64;i386;ppc7400")
       
   149 	set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
   156 	set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
   150 	include_directories(${SDL_INCLUDE_DIR})
   157 	include_directories(${SDL_INCLUDE_DIR})
   151 
   158 
   152 	add_library (SDLmain STATIC SDLMain.m)
   159 	add_library (SDLmain STATIC SDLMain.m)
   153 
   160