project_files/hwc/CMakeLists.txt
changeset 10015 4feced261c68
parent 9984 84835d0ceb64
child 10127 7f29a65aa1e4
equal deleted inserted replaced
10014:56d2f2d5aad8 10015:4feced261c68
       
     1 #the usual set of dependencies
       
     2 find_package(OpenGL REQUIRED)
       
     3 find_package(GLEW REQUIRED)
       
     4 find_package(SDL REQUIRED)
       
     5 find_package(SDL_mixer REQUIRED)
       
     6 find_package(SDL_net REQUIRED)
       
     7 find_package(SDL_image REQUIRED)
       
     8 find_package(SDL_ttf REQUIRED)
       
     9 
       
    10 #compile our rtl implementation
       
    11 include_directories(${GLEW_INCLUDE_DIR})
       
    12 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/rtl)
       
    13 include_directories(${PHYSFS_INCLUDE_DIR})
       
    14 include_directories(${PHYSLAYER_INCLUDE_DIR})
       
    15 add_subdirectory(rtl)
       
    16 
       
    17 configure_file(${CMAKE_SOURCE_DIR}/hedgewars/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
       
    18 
       
    19 #get the list of pas files that are going to be converted and compiled
       
    20 file(GLOB engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/*.pas")
       
    21 #TODO: temporary until cmake can configure itself accordingly
       
    22 list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uWeb.pas")
       
    23 list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uVideoRec.pas")
       
    24 list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uTouch.pas")
       
    25 list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/PNGh.pas")
       
    26 list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/pas2cSystem.pas")
       
    27 list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/pas2cRedo.pas")
       
    28 list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/hwLibrary.pas")
       
    29 
       
    30 #remove and readd hwengine so that it is compiled first, compiling every other file in the process
       
    31 list(REMOVE_ITEM engine_sources_pas ${CMAKE_SOURCE_DIR}/hedgewars/hwengine.pas)
       
    32 list(APPEND engine_sources_pas ${CMAKE_SOURCE_DIR}/hedgewars/hwengine.pas)
       
    33 
       
    34 #process files .pas -> .c
       
    35 foreach(sourcefile ${engine_sources_pas})
       
    36     get_filename_component(sourcename ${sourcefile} NAME_WE) #drops .pas
       
    37     list(APPEND engine_sources "${CMAKE_CURRENT_BINARY_DIR}/${sourcename}.c")
       
    38 endforeach()
       
    39 
       
    40 #add again files for external functions and for fpcrtl_ functions
       
    41 list(APPEND engine_sources_pas ${CMAKE_SOURCE_DIR}/hedgewars/pas2cSystem.pas)
       
    42 list(APPEND engine_sources_pas ${CMAKE_SOURCE_DIR}/hedgewars/pas2cRedo.pas)
       
    43 
       
    44 
       
    45 #invoke pas2c on main module, it will call all the others
       
    46 add_custom_command(OUTPUT ${engine_sources}
       
    47                    COMMAND "${EXECUTABLE_OUTPUT_PATH}/pas2c${CMAKE_EXECUTABLE_SUFFIX}"
       
    48                    ARGS -n "hwengine"
       
    49                         -i "${CMAKE_SOURCE_DIR}/hedgewars"
       
    50                         -o "${CMAKE_CURRENT_BINARY_DIR}"
       
    51                         -a "${CMAKE_CURRENT_BINARY_DIR}"
       
    52                         -d "ENDIAN_LITTLE"
       
    53                         -d "DEBUGFILE"
       
    54                    DEPENDS pas2c                     #converter tool
       
    55                            ${engine_sources_pas}     #original pascal file
       
    56                   )
       
    57 
       
    58 #wrap conversion for all source in this command
       
    59 add_custom_target(engine_c DEPENDS ${engine_sources})
       
    60 
       
    61 
       
    62 #compile the c files
       
    63 add_executable(hwengine WIN32 ${engine_sources})
       
    64 
       
    65 target_link_libraries(hwengine  fpcrtl
       
    66                                 ${LUA_LIBRARY}
       
    67                                 ${OPENGL_LIBRARY}
       
    68                                 ${SDL_LIBRARY}
       
    69                                 ${SDLMIXER_LIBRARY}
       
    70                                 ${SDLNET_LIBRARY}
       
    71                                 ${SDLIMAGE_LIBRARY}
       
    72                                 ${SDLTTF_LIBRARY}
       
    73                                 ${GLEW_LIBRARY}
       
    74                                 physfs
       
    75                                 physlayer
       
    76                                 m
       
    77                                 #TODO: add other libraries
       
    78                             )
       
    79 if(APPLE)
       
    80     target_link_libraries(hwengine IOKit SDLmain)
       
    81 endif()
       
    82 
       
    83 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_binary_install_dir})
       
    84