project_files/hwc/CMakeLists.txt
branchwebgl
changeset 9256 5a2e94a4c2d0
parent 9252 8749053e8109
child 9259 872dd30deb7b
child 9264 21df1a0ec9ed
equal deleted inserted replaced
9254:d5f513019851 9256:5a2e94a4c2d0
    25 list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/pas2cRedo.pas")
    25 list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/pas2cRedo.pas")
    26 list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/hwLibrary.pas")
    26 list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/hwLibrary.pas")
    27 
    27 
    28 foreach(sourcefile ${engine_sources_pas})
    28 foreach(sourcefile ${engine_sources_pas})
    29     get_filename_component(sourcename ${sourcefile} NAME_WE) #drops .pas
    29     get_filename_component(sourcename ${sourcefile} NAME_WE) #drops .pas
    30     set(engine_sources "${CMAKE_CURRENT_BINARY_DIR}/${sourcename}.c" ${engine_sources})
    30     list(APPEND engine_sources "${CMAKE_CURRENT_BINARY_DIR}/${sourcename}.c")
       
    31 
       
    32     #invoke pas2c on each pas files
       
    33     add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${sourcename}.c"
       
    34                        COMMAND "${EXECUTABLE_OUTPUT_PATH}/pas2c${CMAKE_EXECUTABLE_SUFFIX}"
       
    35                        ARGS -n "${sourcename}"
       
    36                             -i "${CMAKE_SOURCE_DIR}/hedgewars"
       
    37                             -o "${CMAKE_CURRENT_BINARY_DIR}"
       
    38                             -a "${CMAKE_CURRENT_BINARY_DIR}"
       
    39                        DEPENDS pas2c                                            #converter tool
       
    40                                ${sourcefile}                                    #original pascal file
       
    41                                ${CMAKE_SOURCE_DIR}/hedgewars/pas2cSystem.pas    #special, external functions
       
    42                                ${CMAKE_SOURCE_DIR}/hedgewars/pas2cRedo.pas      #special, fpcrtl_ functions
       
    43                       )
    31 endforeach()
    44 endforeach()
    32 
    45 
    33 #invoke pas2c on our pas files
    46 #wrap conversion for all source in this command
    34 add_custom_command(OUTPUT ${engine_sources}
       
    35         COMMAND "${EXECUTABLE_OUTPUT_PATH}/pas2c${CMAKE_EXECUTABLE_SUFFIX}"
       
    36         ARGS -n "hwengine"
       
    37              -i "${CMAKE_SOURCE_DIR}/hedgewars"
       
    38              -o "${CMAKE_CURRENT_BINARY_DIR}"
       
    39              -a "${CMAKE_CURRENT_BINARY_DIR}"
       
    40         DEPENDS pas2c
       
    41                 ${engine_sources_pas}
       
    42                 ${CMAKE_SOURCE_DIR}/hedgewars/pas2cSystem.pas
       
    43                 ${CMAKE_SOURCE_DIR}/hedgewars/pas2cRedo.pas
       
    44     )
       
    45 add_custom_target(engine_c DEPENDS ${engine_sources})
    47 add_custom_target(engine_c DEPENDS ${engine_sources})
    46 
    48 
    47 
    49 
    48 #compile the c files
    50 #compile the c files
    49 add_executable(hwengine WIN32 ${engine_sources})
    51 add_executable(hwengine WIN32 ${engine_sources})