diff cmake/function/IrccdDefinePlugin.cmake @ 773:8c44bbcbbab9

Misc: style, cleanup and update
author David Demelier <markand@malikania.fr>
date Fri, 26 Oct 2018 13:01:00 +0200
parents d8bf53170fb6
children 80bccab4a093
line wrap: on
line diff
--- a/cmake/function/IrccdDefinePlugin.cmake	Wed Oct 24 13:24:03 2018 +0200
+++ b/cmake/function/IrccdDefinePlugin.cmake	Fri Oct 26 13:01:00 2018 +0200
@@ -20,21 +20,26 @@
 # irccd_define_plugin
 # -------------------
 #
+# Synopsis for Javascript plugins.
+#
 # irccd_define_plugin(
-#   NAME canonical plugin name
-#   TYPE JS or NATIVE
-#   DOCS documentation files in markdown
-#
-#   Options for TYPE JS:
+#   NAME        canonical plugin name
+#   TYPE        JS
+#   DOCS        documentation files in markdown
+#   SCRIPT      absolute path to the Javascript file (ending with .js)
+# )
 #
-#   SCRIPT absolute path to the Javascript file (ending with .js)
-#
-#   Options for TYPE NATIVE:
+# Synopsis for native plugins.
 #
-#   SOURCES c++ source files
-#   LIBRARIES additional libraries
+# irccd_define_plugin(
+#   NAME        canonical plugin name
+#   TYPE        NATIVE
+#   DOCS        documentation files in markdown
+#   SOURCES     c++ source files
+#   LIBRARIES   additional libraries
+# )
 #
-# Create a Javascript or Native plugin.
+# Create a Javascript or native plugin.
 #
 # The NAME parameter identifies the plugin. The same name will be used for the
 # plugin filename.
@@ -52,102 +57,102 @@
 #
 
 function(_irccd_define_javascript_plugin)
-    if (NOT PLG_SCRIPT)
-        message(FATAL_ERROR "Missing SCRIPT parameter")
-    endif ()
+	if (NOT PLG_SCRIPT)
+		message(FATAL_ERROR "Missing SCRIPT parameter")
+	endif ()
 
-    get_filename_component(name ${PLG_SCRIPT} NAME)
+	get_filename_component(name ${PLG_SCRIPT} NAME)
 
-    configure_file(
-        ${PLG_SCRIPT}
-        ${CMAKE_CURRENT_BINARY_DIR}/${name}
-    )
+	configure_file(
+		${PLG_SCRIPT}
+		${CMAKE_CURRENT_BINARY_DIR}/${name}
+	)
 
-    install(
-        FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}
-        COMPONENT ${PLG_NAME}
-        DESTINATION ${CMAKE_INSTALL_LIBDIR}/irccd
-    )
+	install(
+		FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}
+		COMPONENT ${PLG_NAME}
+		DESTINATION ${CMAKE_INSTALL_LIBDIR}/irccd
+	)
 
-    add_custom_target(
-        plugin-${PLG_NAME}
-        ALL
-        DEPENDS ${PLG_OUTPUT_DOC}
-        SOURCES ${PLG_SCRIPT} ${PLG_DOCS}
-    )
+	add_custom_target(
+		plugin-${PLG_NAME}
+		ALL
+		DEPENDS ${PLG_OUTPUT_DOC}
+		SOURCES ${PLG_SCRIPT} ${PLG_DOCS}
+	)
 endfunction()
 
 function(_irccd_define_native_plugin)
-    if (NOT PLG_SOURCES)
-        message(FATAL_ERROR "Missing SOURCES parameter")
-    endif ()
+	if (NOT PLG_SOURCES)
+		message(FATAL_ERROR "Missing SOURCES parameter")
+	endif ()
 
-    add_library(plugin-${PLG_NAME} MODULE ${PLG_SOURCES} ${PLG_OUTPUT_DOC} ${PLG_DOCS})
-    target_link_libraries(plugin-${PLG_NAME} libirccd ${PLG_LIBRARIES})
+	add_library(plugin-${PLG_NAME} MODULE ${PLG_SOURCES} ${PLG_OUTPUT_DOC} ${PLG_DOCS})
+	target_link_libraries(plugin-${PLG_NAME} libirccd ${PLG_LIBRARIES})
 
-    # Change output name.
-    set_target_properties(
-        plugin-${PLG_NAME}
-        PROPERTIES
-            PREFIX ""
-            OUTPUT_NAME ${PLG_NAME}
-    )
-    foreach (cfg ${CMAKE_CONFIGURATION_TYPES})
-        string(TOUPPER ${cfg} CFG)
-        set_target_properties(
-            plugin-${PLG_NAME}
-            PROPERTIES
-                PREFIX ""
-                OUTPUT_NAME_${CFG} ${PLG_NAME}
-        )
-    endforeach ()
+	# Change output name.
+	set_target_properties(
+		plugin-${PLG_NAME}
+		PROPERTIES
+			PREFIX ""
+			OUTPUT_NAME ${PLG_NAME}
+	)
+	foreach (cfg ${CMAKE_CONFIGURATION_TYPES})
+		string(TOUPPER ${cfg} CFG)
+		set_target_properties(
+			plugin-${PLG_NAME}
+			PROPERTIES
+				PREFIX ""
+				OUTPUT_NAME_${CFG} ${PLG_NAME}
+		)
+	endforeach ()
 
-    install(
-        TARGETS plugin-${PLG_NAME}
-        COMPONENT ${PLG_NAME}
-        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/irccd
-    )
+	install(
+		TARGETS plugin-${PLG_NAME}
+		COMPONENT ${PLG_NAME}
+		LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/irccd
+	)
 endfunction()
 
 function(irccd_define_plugin)
-    set(options "")
-    set(oneValueArgs NAME DOCS TYPE SCRIPT)
-    set(multiValueArgs SOURCES LIBRARIES)
+	set(options "")
+	set(oneValueArgs NAME DOCS TYPE SCRIPT)
+	set(multiValueArgs SOURCES LIBRARIES)
 
-    cmake_parse_arguments(PLG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+	cmake_parse_arguments(PLG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
 
-    if (NOT PLG_NAME)
-        message(FATAL_ERROR "Missing NAME parameter")
-    endif ()
+	if (NOT PLG_NAME)
+		message(FATAL_ERROR "Missing NAME parameter")
+	endif ()
 
-    string(TOUPPER ${PLG_NAME} PLG_UPPER_NAME)
-    option(IRCCD_WITH_PLUGIN_${PLG_UPPER_NAME} "Enable ${PLG_NAME} plugin" On)
+	string(TOUPPER ${PLG_NAME} PLG_UPPER_NAME)
+	option(IRCCD_WITH_PLUGIN_${PLG_UPPER_NAME} "Enable ${PLG_NAME} plugin" On)
 
-    if (NOT IRCCD_WITH_PLUGIN_${PLG_UPPER_NAME})
-        setg(IRCCD_WITH_PLUGIN_${PLG_UPPER_NAME}_MSG "No (disabled by user)")
-    else ()
-        setg(IRCCD_WITH_PLUGIN_${PLG_UPPER_NAME}_MSG "Yes")
+	if (NOT IRCCD_WITH_PLUGIN_${PLG_UPPER_NAME})
+		setg(IRCCD_WITH_PLUGIN_${PLG_UPPER_NAME}_MSG "No (disabled by user)")
+	else ()
+		setg(IRCCD_WITH_PLUGIN_${PLG_UPPER_NAME}_MSG "Yes")
 
-        # Optional documentation.
-        if (PLG_DOCS AND HAVE_HTML)
-            irccd_build_html(
-                SOURCE ${PLG_DOCS}
-                OUTPUT plugin/${PLG_NAME}
-                COMPONENT ${PLG_NAME}
-                OUTPUT_VAR PLG_OUTPUT_DOC
-            )
-        endif ()
+		# Optional documentation.
+		if (PLG_DOCS AND HAVE_HTML)
+			irccd_build_html(
+				SOURCE ${PLG_DOCS}
+				OUTPUT plugin/${PLG_NAME}
+				COMPONENT ${PLG_NAME}
+				OUTPUT_VAR PLG_OUTPUT_DOC
+			)
+		endif ()
 
-        if (PLG_TYPE MATCHES "JS")
-            _irccd_define_javascript_plugin()
-        elseif (PLG_TYPE MATCHES "NATIVE")
-            _irccd_define_native_plugin()
-        else ()
-            message(FATAL_ERROR "Invalid TYPE given, must be JS or NATIVE")
-        endif ()
+		if (PLG_TYPE MATCHES "JS")
+			_irccd_define_javascript_plugin()
+		elseif (PLG_TYPE MATCHES "NATIVE")
+			_irccd_define_native_plugin()
+		else ()
+			message(FATAL_ERROR "Invalid TYPE given, must be JS or NATIVE")
+		endif ()
 
-        # Component grouping in installer.
-        setg(CPACK_COMPONENT_${PLG_UPPER_NAME}_GROUP "Plugins")
-        setg(CPACK_COMPONENT_${PLG_UPPER_NAME}_DESCRIPTION "Install ${PLG_NAME} plugin.")
-    endif ()
+		# Component grouping in installer.
+		setg(CPACK_COMPONENT_${PLG_UPPER_NAME}_GROUP "Plugins")
+		setg(CPACK_COMPONENT_${PLG_UPPER_NAME}_DESCRIPTION "Install ${PLG_NAME} plugin.")
+	endif ()
 endfunction()