annotate cmake/IrccdDefinePlugin.cmake @ 1149:d0e522ff5143 release-4.0

plugins: substitute version, closes #2533
author David Demelier <markand@malikania.fr>
date Fri, 04 Feb 2022 10:04:04 +0100
parents f06e9761cc90
children 1845a0509a93
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 #
1136
f06e9761cc90 misc: update copyright years
David Demelier <markand@malikania.fr>
parents: 1129
diff changeset
4 # Copyright (c) 2013-2022 David Demelier <markand@malikania.fr>
1098
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
1129
cd8ad6ed02ca cmake: include GNUInstallDirs in macro
David Demelier <markand@malikania.fr>
parents: 1125
diff changeset
19 include(GNUInstallDirs)
cd8ad6ed02ca cmake: include GNUInstallDirs in macro
David Demelier <markand@malikania.fr>
parents: 1125
diff changeset
20
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
21 function(irccd_define_native_plugin)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
22 set(options "")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
23 set(oneValueArgs "MAN;NAME")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
24 set(multiValueArgs "FLAGS;INCLUDES;LIBRARIES;SOURCES")
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 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
27
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
28 if (NOT PLG_NAME)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
29 message(FATAL_ERROR "Missing NAME")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
30 elseif (NOT PLG_SOURCES)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
31 message(FATAL_ERROR "Missing SOURCES")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
32 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
33
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
34 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
35 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
36
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
37 if (PLG_FLAGS)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
38 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
39 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
40 if (PLG_INCLUDES)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
41 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
42 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
43 if (PLG_LIBRARIES)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
44 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
45 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
46
1125
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1098
diff changeset
47 if (APPLE)
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1098
diff changeset
48 target_link_libraries(irccd-plugin-${PLG_NAME} "-undefined dynamic_lookup")
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1098
diff changeset
49 endif ()
75e228008e07 cmake: add export
David Demelier <markand@malikania.fr>
parents: 1098
diff changeset
50
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
51 set_target_properties(
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
52 irccd-plugin-${PLG_NAME}
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
53 PROPERTIES
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
54 OUTPUT_NAME ${PLG_NAME}
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
55 PREFIX ""
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
56 FOLDER plugins
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
57 )
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
58
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
59 install(
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
60 TARGETS irccd-plugin-${PLG_NAME}
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
61 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/irccd
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
62 )
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
63
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
64 if (PLG_MAN)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
65 install(
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
66 FILES ${PLG_MAN}
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
67 DESTINATION ${CMAKE_INSTALL_MANDIR}/man7
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
68 RENAME irccd-plugin-${PLG_NAME}.7
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
69 )
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
70 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
71 endfunction()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
72
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
73 function(irccd_define_javascript_plugin)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
74 set(options "")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
75 set(oneValueArgs "MAN;NAME")
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
76 set(multiValueArgs "SCRIPT")
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 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
79
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
80 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
81 set_target_properties(irccd-plugin-${PLG_NAME} PROPERTIES FOLDER plugins)
1149
d0e522ff5143 plugins: substitute version, closes #2533
David Demelier <markand@malikania.fr>
parents: 1136
diff changeset
82
d0e522ff5143 plugins: substitute version, closes #2533
David Demelier <markand@malikania.fr>
parents: 1136
diff changeset
83 cmake_path(GET PLG_SCRIPT FILENAME filename)
d0e522ff5143 plugins: substitute version, closes #2533
David Demelier <markand@malikania.fr>
parents: 1136
diff changeset
84 configure_file(
d0e522ff5143 plugins: substitute version, closes #2533
David Demelier <markand@malikania.fr>
parents: 1136
diff changeset
85 ${PLG_SCRIPT}
d0e522ff5143 plugins: substitute version, closes #2533
David Demelier <markand@malikania.fr>
parents: 1136
diff changeset
86 ${CMAKE_CURRENT_BINARY_DIR}/${filename}
d0e522ff5143 plugins: substitute version, closes #2533
David Demelier <markand@malikania.fr>
parents: 1136
diff changeset
87 @ONLY
d0e522ff5143 plugins: substitute version, closes #2533
David Demelier <markand@malikania.fr>
parents: 1136
diff changeset
88 )
d0e522ff5143 plugins: substitute version, closes #2533
David Demelier <markand@malikania.fr>
parents: 1136
diff changeset
89 install(
d0e522ff5143 plugins: substitute version, closes #2533
David Demelier <markand@malikania.fr>
parents: 1136
diff changeset
90 FILES ${CMAKE_CURRENT_BINARY_DIR}/${filename}
d0e522ff5143 plugins: substitute version, closes #2533
David Demelier <markand@malikania.fr>
parents: 1136
diff changeset
91 DESTINATION ${CMAKE_INSTALL_LIBDIR}/irccd
d0e522ff5143 plugins: substitute version, closes #2533
David Demelier <markand@malikania.fr>
parents: 1136
diff changeset
92 )
1098
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
93
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
94 if (PLG_MAN)
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
95 install(
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
96 FILES ${PLG_MAN}
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
97 DESTINATION ${CMAKE_INSTALL_MANDIR}/man7
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
98 RENAME irccd-plugin-${PLG_NAME}.7
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
99 )
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
100 endif ()
6c15d37b7518 cmake: switch back to CMake because of portability issues
David Demelier <markand@malikania.fr>
parents:
diff changeset
101 endfunction()