Mercurial > malikania
comparison cmake/function/MalikaniaDefineExample.cmake @ 80:a162f380f02e
CMake: create examples, closes #615
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 22 Jan 2017 09:59:14 +0100 |
parents | |
children | 119bcc5a727e |
comparison
equal
deleted
inserted
replaced
79:8b41e9a2e095 | 80:a162f380f02e |
---|---|
1 # | |
2 # MalikaniaDefineExample.cmake -- CMake build system for malikania | |
3 # | |
4 # Copyright (c) 2013-2017 Malikania Authors | |
5 # | |
6 # Permission to use, copy, modify, and/or distribute this software for any | |
7 # purpose with or without fee is hereby granted, provided that the above | |
8 # copyright notice and this permission notice appear in all copies. | |
9 # | |
10 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 # | |
18 | |
19 include(CMakeParseArguments) | |
20 | |
21 include(${CMAKE_CURRENT_LIST_DIR}/MalikaniaVeraCheck.cmake) | |
22 | |
23 function(malikania_define_example) | |
24 set(singleArgs TARGET) | |
25 set(multiArgs FLAGS LIBRARIES SOURCES) | |
26 | |
27 cmake_parse_arguments(EXP "" "${singleArgs}" "${multiArgs}" ${ARGN}) | |
28 | |
29 if (NOT EXP_TARGET) | |
30 message(FATAL_ERROR "Missing TARGET parameter") | |
31 elseif (NOT EXP_SOURCES) | |
32 message(FATAL_ERROR "Missing SOURCES parameter") | |
33 endif () | |
34 | |
35 list(APPEND EXP_FLAGS SOURCE_DIRECTORY=\"${CMAKE_CURRENT_SOURCE_DIR}/resources\") | |
36 add_executable(example-${EXP_TARGET} ${EXP_SOURCES}) | |
37 target_link_libraries(example-${EXP_TARGET} ${EXP_LIBRARIES}) | |
38 target_compile_definitions(example-${EXP_TARGET} PRIVATE ${EXP_FLAGS}) | |
39 endfunction() |