project_files/hwc/CMakeLists.txt
author sheepluva
Thu, 23 Jan 2014 13:56:53 +0100
changeset 10061 b7161f00a6ca
parent 9984 84835d0ceb64
child 10127 7f29a65aa1e4
permissions -rw-r--r--
hide complete IP of other users, when non-admin requests player info. showing the first two parts of the IP was kinda pointless to begin with (what for?) and has recently lead to increased abuse and lobby flooding due to bots collecting/posting IP tracking information
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
9201
bcf2f7798ebb redid FindGLEW in the right way (tm)
koda
parents: 9130
diff changeset
    11
include_directories(${GLEW_INCLUDE_DIR})
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
    12
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/rtl)
9264
21df1a0ec9ed engine links
unc0rr
parents: 9256
diff changeset
    13
include_directories(${PHYSFS_INCLUDE_DIR})
21df1a0ec9ed engine links
unc0rr
parents: 9256
diff changeset
    14
include_directories(${PHYSLAYER_INCLUDE_DIR})
8047
25a4daa6473c cleanup headers, remove -I . from rtl lib to save a few warnings
koda
parents: 8044
diff changeset
    15
add_subdirectory(rtl)
7999
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    16
8044
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    17
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
    18
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    19
#get the list of pas files that are going to be converted and compiled
8044
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    20
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
    21
#TODO: temporary until cmake can configure itself accordingly
8044
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    22
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uWeb.pas")
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    23
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uVideoRec.pas")
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    24
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/uTouch.pas")
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    25
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/PNGh.pas")
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    26
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/pas2cSystem.pas")
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    27
list(REMOVE_ITEM engine_sources_pas "${CMAKE_SOURCE_DIR}/hedgewars/pas2cRedo.pas")
796f2653f21d some CMake cleanup
koda
parents: 8041
diff changeset
    28
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
    29
9259
872dd30deb7b compile hwengine first, so that all other files are compiled too and don't call pas2c again
koda
parents: 9256
diff changeset
    30
#remove and readd hwengine so that it is compiled first, compiling every other file in the process
872dd30deb7b compile hwengine first, so that all other files are compiled too and don't call pas2c again
koda
parents: 9256
diff changeset
    31
list(REMOVE_ITEM engine_sources_pas ${CMAKE_SOURCE_DIR}/hedgewars/hwengine.pas)
872dd30deb7b compile hwengine first, so that all other files are compiled too and don't call pas2c again
koda
parents: 9256
diff changeset
    32
list(APPEND engine_sources_pas ${CMAKE_SOURCE_DIR}/hedgewars/hwengine.pas)
872dd30deb7b compile hwengine first, so that all other files are compiled too and don't call pas2c again
koda
parents: 9256
diff changeset
    33
872dd30deb7b compile hwengine first, so that all other files are compiled too and don't call pas2c again
koda
parents: 9256
diff changeset
    34
#process files .pas -> .c
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    35
foreach(sourcefile ${engine_sources_pas})
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    36
    get_filename_component(sourcename ${sourcefile} NAME_WE) #drops .pas
9256
5a2e94a4c2d0 set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents: 9252
diff changeset
    37
    list(APPEND engine_sources "${CMAKE_CURRENT_BINARY_DIR}/${sourcename}.c")
9978
6199f64d3f8a cosmetics
koda
parents: 9976
diff changeset
    38
endforeach()
9256
5a2e94a4c2d0 set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents: 9252
diff changeset
    39
9978
6199f64d3f8a cosmetics
koda
parents: 9976
diff changeset
    40
#add again files for external functions and for fpcrtl_ functions
6199f64d3f8a cosmetics
koda
parents: 9976
diff changeset
    41
list(APPEND engine_sources_pas ${CMAKE_SOURCE_DIR}/hedgewars/pas2cSystem.pas)
6199f64d3f8a cosmetics
koda
parents: 9976
diff changeset
    42
list(APPEND engine_sources_pas ${CMAKE_SOURCE_DIR}/hedgewars/pas2cRedo.pas)
9976
a9c8f3f11c71 call pas2c on hwengine only
koda
parents: 9267
diff changeset
    43
a9c8f3f11c71 call pas2c on hwengine only
koda
parents: 9267
diff changeset
    44
9978
6199f64d3f8a cosmetics
koda
parents: 9976
diff changeset
    45
#invoke pas2c on main module, it will call all the others
6199f64d3f8a cosmetics
koda
parents: 9976
diff changeset
    46
add_custom_command(OUTPUT ${engine_sources}
6199f64d3f8a cosmetics
koda
parents: 9976
diff changeset
    47
                   COMMAND "${EXECUTABLE_OUTPUT_PATH}/pas2c${CMAKE_EXECUTABLE_SUFFIX}"
6199f64d3f8a cosmetics
koda
parents: 9976
diff changeset
    48
                   ARGS -n "hwengine"
6199f64d3f8a cosmetics
koda
parents: 9976
diff changeset
    49
                        -i "${CMAKE_SOURCE_DIR}/hedgewars"
6199f64d3f8a cosmetics
koda
parents: 9976
diff changeset
    50
                        -o "${CMAKE_CURRENT_BINARY_DIR}"
6199f64d3f8a cosmetics
koda
parents: 9976
diff changeset
    51
                        -a "${CMAKE_CURRENT_BINARY_DIR}"
9982
24ea101fdc7f '-d' option to pas2c
unc0rr
parents: 9978
diff changeset
    52
                        -d "ENDIAN_LITTLE"
24ea101fdc7f '-d' option to pas2c
unc0rr
parents: 9978
diff changeset
    53
                        -d "DEBUGFILE"
9978
6199f64d3f8a cosmetics
koda
parents: 9976
diff changeset
    54
                   DEPENDS pas2c                     #converter tool
6199f64d3f8a cosmetics
koda
parents: 9976
diff changeset
    55
                           ${engine_sources_pas}     #original pascal file
6199f64d3f8a cosmetics
koda
parents: 9976
diff changeset
    56
                  )
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    57
9256
5a2e94a4c2d0 set one rule per file, only compiles a minimum number of files when one pascal file is modified
koda
parents: 9252
diff changeset
    58
#wrap conversion for all source in this command
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    59
add_custom_target(engine_c DEPENDS ${engine_sources})
7999
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    60
8006
7ca007615b88 no globs, sources not yet generated
koda
parents: 8004
diff changeset
    61
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    62
#compile the c files
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    63
add_executable(hwengine WIN32 ${engine_sources})
8029
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    64
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    65
target_link_libraries(hwengine  fpcrtl
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    66
                                ${LUA_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    67
                                ${OPENGL_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    68
                                ${SDL_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    69
                                ${SDLMIXER_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    70
                                ${SDLNET_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    71
                                ${SDLIMAGE_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    72
                                ${SDLTTF_LIBRARY}
8853
ef59a44a9f08 and now engine in c links too (with more manual intervention as of issue 596)
koda
parents: 8448
diff changeset
    73
                                ${GLEW_LIBRARY}
ef59a44a9f08 and now engine in c links too (with more manual intervention as of issue 596)
koda
parents: 8448
diff changeset
    74
                                physfs
ef59a44a9f08 and now engine in c links too (with more manual intervention as of issue 596)
koda
parents: 8448
diff changeset
    75
                                physlayer
9984
84835d0ceb64 Fixed build failure to a missing math library linked with BUILD_ENGINE_C=1 and clang
Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
parents: 9982
diff changeset
    76
                                m
8038
625b628d55f3 and install it too
koda
parents: 8035
diff changeset
    77
                                #TODO: add other libraries
8029
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    78
                            )
8853
ef59a44a9f08 and now engine in c links too (with more manual intervention as of issue 596)
koda
parents: 8448
diff changeset
    79
if(APPLE)
9130
4f4b71da3559 move sdlmain_osx aside in its own folder so its include path is not contaminated
koda
parents: 8853
diff changeset
    80
    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
    81
endif()
8029
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    82
8332
9333216f2054 fix hwc install and pas2c preprocessing (but not total conversion)
koda
parents: 8108
diff changeset
    83
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
    84