Mercurial > irccd
comparison cmake/function/IrccdDefineLibrary.cmake @ 0:1158cffe5a5e
Initial import
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 08 Feb 2016 16:43:14 +0100 |
parents | |
children | 98ac3c79009f |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:1158cffe5a5e |
---|---|
1 # | |
2 # IrccdDefineLibrary.cmake -- CMake build system for irccd | |
3 # | |
4 # Copyright (c) 2013-2016 David Demelier <markand@malikania.fr> | |
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 # | |
20 # irccd_define_library | |
21 # ------------------------------------------------------------------- | |
22 # | |
23 # irccd_define_library( | |
24 # TARGET target name | |
25 # SOURCES src1, src2, srcn | |
26 # FLAGS (Optional) C/C++ flags (without -D) | |
27 # LIBRARIES (Optional) libraries to link | |
28 # LOCAL_INCLUDES (Optional) local includes for the target only | |
29 # PUBLIC_INCLUDES (Optional) includes to share with target dependencies | |
30 # ) | |
31 # | |
32 # Create a static library for internal use. | |
33 # | |
34 | |
35 function(irccd_define_library) | |
36 set(oneValueArgs TARGET) | |
37 set(multiValueArgs SOURCES FLAGS LIBRARIES LOCAL_INCLUDES PUBLIC_INCLUDES) | |
38 set(mandatory TARGET SOURCES) | |
39 | |
40 cmake_parse_arguments(LIB "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | |
41 | |
42 if (NOT LIB_TARGET) | |
43 message(FATAL_ERROR "Please set TARGET") | |
44 endif () | |
45 if (NOT LIB_SOURCES) | |
46 message(FATAL_ERROR "Please set SOURCES") | |
47 endif () | |
48 | |
49 add_library(${LIB_TARGET} STATIC ${LIB_SOURCES}) | |
50 target_include_directories(${LIB_TARGET} PRIVATE ${LIB_LOCAL_INCLUDES} PUBLIC ${LIB_PUBLIC_INCLUDES}) | |
51 target_compile_definitions(${LIB_TARGET} PUBLIC ${LIB_FLAGS}) | |
52 target_link_libraries(${LIB_TARGET} ${LIB_LIBRARIES}) | |
53 endfunction() |