File: Helper.cmake

package info (click to toggle)
allegro5 2%3A5.2.10.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,820 kB
  • sloc: ansic: 109,795; cpp: 12,976; objc: 4,592; java: 2,845; python: 2,595; javascript: 1,238; sh: 1,008; makefile: 40; xml: 27; pascal: 24
file content (97 lines) | stat: -rw-r--r-- 3,112 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Conditionally build an example program.  If any of its arguments is the exact
# string "x", do nothing.  Otherwise strip off the "x" prefixes on arguments
# and link to that target.
function(example name)
    # Use cmake_parse_arguments first.
    set(flags CONSOLE)
    set(single_args) # none
    set(accum_args DATA EXTRA_LIBS)
    cmake_parse_arguments(MYOPTS "${flags}" "${single_args}" "${accum_args}"
        ${ARGN})

    # Parse what remains of the argument list manually.
    set(sources)
    set(libs)
    foreach(arg ${MYOPTS_UNPARSED_ARGUMENTS})
        if(arg STREQUAL "x")
            message(STATUS "Not building ${name}")
            return()
        endif()
        if(arg MATCHES "[.]c$")
            list(APPEND sources ${arg})
        elseif(arg MATCHES "[.]cpp$")
            list(APPEND sources ${arg})
        else()
            string(REGEX REPLACE "^x" "" arg ${arg})
            list(APPEND libs ${arg})
        endif()
    endforeach()

    # If no sources are listed assume a single C source file.
    if(NOT sources)
        set(sources "${name}.c")
    endif()

    # Prepend the base libraries.
    if(ANDROID)
        set(libs ${ALLEGRO_LINK_WITH} ${libs})
    else()
        set(libs ${ALLEGRO_LINK_WITH} ${ALLEGRO_MAIN_LINK_WITH} ${libs})
    endif()

    # Popup error messages.
    if(WANT_POPUP_EXAMPLES AND SUPPORT_NATIVE_DIALOG)
        list(APPEND libs ${NATIVE_DIALOG_LINK_WITH})
    endif()

    # Monolith contains all other libraries which were enabled.
    if(WANT_MONOLITH)
        set(libs ${ALLEGRO_MONOLITH_LINK_WITH})
    endif()

    # Append the extra, non-Allegro libraries.
    foreach(lib ${MYOPTS_EXTRA_LIBS})
        list(APPEND libs ${lib})
    endforeach()

    list(REMOVE_DUPLICATES libs)

    if(WIN32)
        if(MYOPTS_CONSOLE)
            # We need stdout and stderr available from cmd.exe,
            # so we must not use WIN32 here.
            set(EXECUTABLE_TYPE)
        else()
            set(EXECUTABLE_TYPE "WIN32")
        endif()
    endif(WIN32)

    if(IPHONE)
        set(EXECUTABLE_TYPE MACOSX_BUNDLE)
    endif(IPHONE)

    if(ANDROID)
        if(MYOPTS_CONSOLE)
            message(STATUS "Not building ${name} - console program")
            return()
        endif()
        add_copy_commands(
            "${CMAKE_CURRENT_SOURCE_DIR}/data"
            "${CMAKE_CURRENT_BINARY_DIR}/${name}.project/app/src/main/assets/data"
            assets
            "${MYOPTS_DATA}"
            )
        add_android_app("${name}" "${sources};${assets}")
    elseif(IPHONE)
        add_our_executable("${name}" SRCS "${sources};${CMAKE_CURRENT_SOURCE_DIR}/data"
                           LIBS "${libs}")
        set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/data" PROPERTIES
                                    MACOSX_PACKAGE_LOCATION "Resources")
    else()
        add_our_executable("${name}" SRCS "${sources}" LIBS "${libs}")
    endif()
    add_dependencies("${name}" copy_example_data)
endfunction(example)

#-----------------------------------------------------------------------------#
# vim: set ts=8 sts=4 sw=4 et: