project_files/hwc/CMakeLists.txt
author koda
Sun, 11 Nov 2012 19:11:47 +0100
branchwebgl
changeset 8035 68ec3138c16d
parent 8029 7ba43d7e54e7
child 8038 625b628d55f3
permissions -rw-r--r--
comments and runtime list of files to convert and compile
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8004
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     1
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
     2
#only Clang is supported
8004
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     3
if(CLANG)
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     4
    set(clang_executable ${CLANG})
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     5
else()
8023
7de85783b823 better clang search
koda
parents: 8008
diff changeset
     6
    find_program(clang_executable
7de85783b823 better clang search
koda
parents: 8008
diff changeset
     7
        NAMES clang-mp-3.2 clang-mp-3.1 clang-mp-3.0 clang
7de85783b823 better clang search
koda
parents: 8008
diff changeset
     8
        PATHS /opt/local/bin /usr/local/bin /usr/bin)
8004
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
     9
endif()
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    10
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    11
if (clang_executable)
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    12
    exec_program(${clang_executable} ARGS "-v" OUTPUT_VARIABLE clang_version_full)
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    13
    string(REGEX MATCH "[0-9]+\\.[0-9]+" clang_version_long "${clang_version_full}")
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    14
    string(REGEX REPLACE "([0-9]+\\.[0-9]+)" "\\1" clang_version "${clang_version_long}")
8008
2ed42786aca7 search for more clang names
koda
parents: 8006
diff changeset
    15
    #TODO: check version >= 3.0
8004
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    16
    message(STATUS "Found CLANG: ${clang_executable} (version ${clang_version})")
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    17
else()
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    18
    message(FATAL_ERROR "No LLVM/Clang compiler found (required for engine_c target)")
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    19
endif()
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    20
8006
7ca007615b88 no globs, sources not yet generated
koda
parents: 8004
diff changeset
    21
set(CMAKE_C_COMPILER ${clang_executable})
7ca007615b88 no globs, sources not yet generated
koda
parents: 8004
diff changeset
    22
8004
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    23
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    24
#the usual set of dependencies
8029
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    25
find_package(OPENGL REQUIRED)
8004
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    26
find_package(GLEW REQUIRED)
8029
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    27
find_package(SDL REQUIRED)
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    28
find_package(SDL_mixer REQUIRED)
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    29
find_package(SDL_net REQUIRED)
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    30
find_package(SDL_image REQUIRED)
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    31
find_package(SDL_ttf REQUIRED)
8004
da4c6db6ea6b correct includes and clang detection
koda
parents: 7999
diff changeset
    32
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    33
#compile our rtl implementation
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    34
include_directories("${GLEW_INCLUDE_PATH}")
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    35
include_directories(rtl)
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    36
add_subdirectory(rtl)
7999
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    37
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    38
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    39
configure_file(${hedgewars_SOURCE_DIR}/hedgewars/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    40
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    41
#get the list of pas files that are going to be converted and compiled
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    42
file(GLOB engine_sources_pas "${hedgewars_SOURCE_DIR}/hedgewars/*.pas")
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    43
#TODO: temporary until cmake can configure itself accordingly
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    44
list(REMOVE_ITEM engine_sources_pas "${hedgewars_SOURCE_DIR}/hedgewars/uWeb.pas")
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    45
list(REMOVE_ITEM engine_sources_pas "${hedgewars_SOURCE_DIR}/hedgewars/uVideoRec.pas")
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    46
list(REMOVE_ITEM engine_sources_pas "${hedgewars_SOURCE_DIR}/hedgewars/uTouch.pas")
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    47
list(REMOVE_ITEM engine_sources_pas "${hedgewars_SOURCE_DIR}/hedgewars/PNGh.pas")
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    48
list(REMOVE_ITEM engine_sources_pas "${hedgewars_SOURCE_DIR}/hedgewars/pas2cSystem.pas")
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    49
list(REMOVE_ITEM engine_sources_pas "${hedgewars_SOURCE_DIR}/hedgewars/pas2cRedo.pas")
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    50
list(REMOVE_ITEM engine_sources_pas "${hedgewars_SOURCE_DIR}/hedgewars/hwLibrary.pas")
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    51
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    52
foreach(sourcefile ${engine_sources_pas})
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    53
    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
    54
    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
    55
endforeach()
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    56
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    57
#invoke pas2c on our pas files
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    58
add_custom_command(OUTPUT ${engine_sources}
7999
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    59
        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
    60
        ARGS -n "hwengine"
8006
7ca007615b88 no globs, sources not yet generated
koda
parents: 8004
diff changeset
    61
             -i "${hedgewars_SOURCE_DIR}/hedgewars"
7ca007615b88 no globs, sources not yet generated
koda
parents: 8004
diff changeset
    62
             -o "${CMAKE_CURRENT_BINARY_DIR}"
7ca007615b88 no globs, sources not yet generated
koda
parents: 8004
diff changeset
    63
             -a "${CMAKE_CURRENT_BINARY_DIR}"
7999
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    64
        DEPENDS pas2c
8006
7ca007615b88 no globs, sources not yet generated
koda
parents: 8004
diff changeset
    65
    )
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    66
add_custom_target(engine_c DEPENDS ${engine_sources})
7999
bb503cd46516 add a few cmakefiles for c engine and rtl
koda
parents:
diff changeset
    67
8006
7ca007615b88 no globs, sources not yet generated
koda
parents: 8004
diff changeset
    68
8035
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    69
#compile the c files
68ec3138c16d comments and runtime list of files to convert and compile
koda
parents: 8029
diff changeset
    70
add_executable(hwengine WIN32 ${engine_sources})
8029
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    71
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    72
target_link_libraries(hwengine  fpcrtl
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    73
                                ${LUA_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    74
                                ${OPENGL_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    75
                                ${SDL_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    76
                                ${SDLMIXER_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    77
                                ${SDLNET_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    78
                                ${SDLIMAGE_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    79
                                ${SDLTTF_LIBRARY}
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    80
                            )
7ba43d7e54e7 cmake linking for engine in c
koda
parents: 8023
diff changeset
    81