project_files/hwc/CMakeLists.txt
author koda
Tue, 04 Jun 2013 23:48:44 +0200
branchwebgl
changeset 9133 a269fe7090a0
parent 9130 4f4b71da3559
child 9201 bcf2f7798ebb
permissions -rw-r--r--
actually everything is CLANG'd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
     1
#the usual set of dependencies
8041
ecb446b9b7d6 fix build
nemo
parents: 8038
diff changeset
     2
find_package(OpenGL REQUIRED)
8004
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     3
find_package(GLEW REQUIRED)
8029
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
     4
find_package(SDL REQUIRED)
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
     5
find_package(SDL_mixer REQUIRED)
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
     6
find_package(SDL_net REQUIRED)
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
     7
find_package(SDL_image REQUIRED)
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
     8
find_package(SDL_ttf REQUIRED)
8004
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     9
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    10
#compile our rtl implementation
8448
14f736ca7eb3 update FindGLEW to use the same variables as in later CMake files and make sure to include its headers before compiling c stuff
koda
parents: 8332
diff changeset
    11
include_directories(${GLEW_INCLUDE_DIRS})
14f736ca7eb3 update FindGLEW to use the same variables as in later CMake files and make sure to include its headers before compiling c stuff
koda
parents: 8332
diff changeset
    12
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/rtl)
8047
25a4daa6473c cleanup headers, remove -I . from rtl lib to save a few warnings
koda
parents: 8044
diff changeset
    13
add_subdirectory(rtl)
7999
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    14
8044
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    15
configure_file(${CMAKE_SOURCE_DIR}/hedgewars/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    16
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    17
#get the list of pas files that are going to be converted and compiled
8044
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    18
file(GLOB engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/*.pas")
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    19
#TODO: temporary until cmake can configure itself accordingly
8044
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    20
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uWeb.pas")
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    21
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uVideoRec.pas")
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    22
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uTouch.pas")
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    23
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/PNGh.pas")
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    24
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/pas2cSystem.pas")
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    25
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/pas2cRedo.pas")
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    26
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/hwLibrary.pas")
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    27
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    28
foreach(sourcefile ${engine_sources_pas})
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    29
    get_filename_component(sourcename ${sourcefile} NAME_WE) #drops .pas
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    30
    set(engine_sources "${CMAKE_CURRENT_BINARY_DIR}/${sourcename}.c" ${engine_sources})
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    31
endforeach()
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    32
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    33
#invoke pas2c on our pas files
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    34
add_custom_command(OUTPUT ${engine_sources}
7999
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    35
        COMMAND "${EXECUTABLE_OUTPUT_PATH}/pas2c${CMAKE_EXECUTABLE_SUFFIX}"
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    36
        ARGS -n "hwengine"
8044
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    37
             -i "${CMAKE_SOURCE_DIR}/hedgewars"
8006
7ca007615b88 no globs, sources not yet generated
koda
parents: 8004
diff changeset
    38
             -o "${CMAKE_CURRENT_BINARY_DIR}"
7ca007615b88 no globs, sources not yet generated
koda
parents: 8004
diff changeset
    39
             -a "${CMAKE_CURRENT_BINARY_DIR}"
7999
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    40
        DEPENDS pas2c
8006
7ca007615b88 no globs, sources not yet generated
koda
parents: 8004
diff changeset
    41
    )
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    42
add_custom_target(engine_c DEPENDS ${engine_sources})
7999
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    43
8006
7ca007615b88 no globs, sources not yet generated
koda
parents: 8004
diff changeset
    44
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    45
#compile the c files
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    46
add_executable(hwengine WIN32 ${engine_sources})
8029
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    47
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    48
target_link_libraries(hwengine  fpcrtl
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    49
                                ${LUA_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    50
                                ${OPENGL_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    51
                                ${SDL_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    52
                                ${SDLMIXER_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    53
                                ${SDLNET_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    54
                                ${SDLIMAGE_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    55
                                ${SDLTTF_LIBRARY}
8853
ef59a44a9f08 and now engine in c links too (with more manual intervention as of issue 596)
koda
parents: 8448
diff changeset
    56
                                ${GLEW_LIBRARY}
ef59a44a9f08 and now engine in c links too (with more manual intervention as of issue 596)
koda
parents: 8448
diff changeset
    57
                                physfs
ef59a44a9f08 and now engine in c links too (with more manual intervention as of issue 596)
koda
parents: 8448
diff changeset
    58
                                physlayer
8038
625b628d55f3 and install it too
koda
parents: 8035
diff changeset
    59
                                #TODO: add other libraries
8029
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    60
                            )
8853
ef59a44a9f08 and now engine in c links too (with more manual intervention as of issue 596)
koda
parents: 8448
diff changeset
    61
if(APPLE)
9130
4f4b71da3559 move sdlmain_osx aside in its own folder so its include path is not contaminated
koda
parents: 8853
diff changeset
    62
    target_link_libraries(hwengine IOKit SDLmain)
8853
ef59a44a9f08 and now engine in c links too (with more manual intervention as of issue 596)
koda
parents: 8448
diff changeset
    63
endif()
8029
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    64
8332
9333216f2054 fix hwc install and pas2c preprocessing (but not total conversion)
koda
parents: 8108
diff changeset
    65
install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hwengine${CMAKE_EXECUTABLE_SUFFIX}" DESTINATION ${target_binary_install_dir})
8038
625b628d55f3 and install it too
koda
parents: 8035
diff changeset
    66