view cmake/function/MalikaniaDefineExample.cmake @ 182:3107ce017c3a

Misc: switch back to SDL Qt Quick and QML was an exciting experiment but it's definitely not enough flexible and easy to use for game development. Using SDL2 will let us focusing on our own drawing functions without any kind of overhead. While here, start massive cleanup.
author David Demelier <markand@malikania.fr>
date Fri, 19 Oct 2018 20:18:19 +0200
parents
children 387f6b0a5420
line wrap: on
line source

#
# MalikaniaDefineExample.cmake -- CMake build system for malikania
#
# Copyright (c) 2013-2018 David Demelier <markand@malikania.fr>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

include(CMakeParseArguments)

include(${CMAKE_CURRENT_LIST_DIR}/MalikaniaVeraCheck.cmake)

function(malikania_define_example)
    set(singleArgs TARGET)
    set(multiArgs FLAGS LIBRARIES SOURCES)

    cmake_parse_arguments(EXP "" "${singleArgs}" "${multiArgs}" ${ARGN})

    if (NOT EXP_TARGET)
        message(FATAL_ERROR "Missing TARGET parameter")
    elseif (NOT EXP_SOURCES)
        message(FATAL_ERROR "Missing SOURCES parameter")
    endif ()

    add_executable(example-${EXP_TARGET} ${EXP_SOURCES})
    target_link_libraries(example-${EXP_TARGET} ${EXP_LIBRARIES})
    target_compile_definitions(
        example-${EXP_TARGET}
        PRIVATE
            CMAKE_CURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
            CMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}"
            ${EXP_FLAGS}
    )
    set_target_properties(
        example-${EXP_TARGET}
        PROPERTIES
            RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
    )
    foreach (c ${CMAKE_CONFIGURATION_TYPES})
        string(TOUPPER ${c} cu)
        set_target_properties(
            example-${EXP_TARGET}
            PROPERTIES
                RUNTIME_OUTPUT_DIRECTORY_${cu} ${CMAKE_BINARY_DIR}/bin/${c}
        )
    endforeach ()
endfunction()