annotate cmake/IrccdDefinePlugin.cmake @ 1125:75e228008e07

cmake: add export
author David Demelier <markand@malikania.fr>
date Sat, 04 Dec 2021 20:14:49 +0100
parents 6c15d37b7518
children cd8ad6ed02ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
1 #
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
2 # CMakeLists.txt -- CMake build system for irccd
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
3 #
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
4 # Copyright (c) 2013-2021 David Demelier <markand@malikania.fr>
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
5 #
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
6 # Permission to use, copy, modify, and/or distribute this software for any
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
7 # purpose with or without fee is hereby granted, provided that the above
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
8 # copyright notice and this permission notice appear in all copies.
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
9 #
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
10 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
11 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
12 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
13 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
14 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
15 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
16 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
17 #
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
18
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
19 function(irccd_define_native_plugin)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
20 set(options "")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
21 set(oneValueArgs "MAN;NAME")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
22 set(multiValueArgs "FLAGS;INCLUDES;LIBRARIES;SOURCES")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
23
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
24 cmake_parse_arguments(PLG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
25
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
26 if (NOT PLG_NAME)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
27 message(FATAL_ERROR "Missing NAME")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
28 elseif (NOT PLG_SOURCES)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
29 message(FATAL_ERROR "Missing SOURCES")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
30 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
31
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
32 add_library(irccd-plugin-${PLG_NAME} MODULE ${PLG_SOURCES} ${PLG_MAN})
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
33 target_link_libraries(irccd-plugin-${PLG_NAME} irccd)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
34
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
35 if (PLG_FLAGS)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
36 target_compile_definitions(irccd-plugin-${PLG_NAME} ${PLG_FLAGS})
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
37 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
38 if (PLG_INCLUDES)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
39 target_include_directories(irccd-plugin-${PLG_NAME} ${PLG_INCLUDES})
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
40 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
41 if (PLG_LIBRARIES)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
42 target_link_libraries(irccd-plugin-${PLG_NAME} ${PLG_LIBRARIES})
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
43 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
44
1125
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1098
diff changeset
45 if (APPLE)
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1098
diff changeset
46 target_link_libraries(irccd-plugin-${PLG_NAME} "-undefined dynamic_lookup")
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1098
diff changeset
47 endif ()
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1098
diff changeset
48
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
49 set_target_properties(
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
50 irccd-plugin-${PLG_NAME}
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
51 PROPERTIES
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
52 OUTPUT_NAME ${PLG_NAME}
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
53 PREFIX ""
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
54 FOLDER plugins
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
55 )
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
56
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
57 install(
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
58 TARGETS irccd-plugin-${PLG_NAME}
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
59 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/irccd
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
60 )
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
61
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
62 if (PLG_MAN)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
63 install(
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
64 FILES ${PLG_MAN}
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
65 DESTINATION ${CMAKE_INSTALL_MANDIR}/man7
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
66 RENAME irccd-plugin-${PLG_NAME}.7
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
67 )
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
68 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
69 endfunction()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
70
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
71 function(irccd_define_javascript_plugin)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
72 set(options "")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
73 set(oneValueArgs "MAN;NAME")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
74 set(multiValueArgs "SCRIPT")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
75
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
76 cmake_parse_arguments(PLG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
77
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
78 add_custom_target(irccd-plugin-${PLG_NAME} SOURCES ${PLG_SCRIPT})
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
79 set_target_properties(irccd-plugin-${PLG_NAME} PROPERTIES FOLDER plugins)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
80 install(FILES ${PLG_SCRIPT} DESTINATION ${CMAKE_INSTALL_LIBDIR}/irccd)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
81
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
82 if (PLG_MAN)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
83 install(
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
84 FILES ${PLG_MAN}
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
85 DESTINATION ${CMAKE_INSTALL_MANDIR}/man7
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
86 RENAME irccd-plugin-${PLG_NAME}.7
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
87 )
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
88 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
89 endfunction()