From 57e020a826bfc50cf861addbf11c17dd4f5f63f0 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Sat, 6 May 2017 06:38:59 +0800 Subject: [PATCH] plugin-standalone: refactor cmake part to ease multiple sources --- plugin-standalone/CMakeLists.txt | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/plugin-standalone/CMakeLists.txt b/plugin-standalone/CMakeLists.txt index c5e92a0..2d213e9 100644 --- a/plugin-standalone/CMakeLists.txt +++ b/plugin-standalone/CMakeLists.txt @@ -17,6 +17,9 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE} ${PACKAGE_VERSION}") set(SOVERSION "1") set(VERSION "0.1") +set(PLUGIN_NAME "protocol_example_standalone") +# space-separated list of sources +set(PLUGIN_SRCS protocol_example_standalone.c) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/") @@ -50,29 +53,21 @@ endif() set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}") -macro(create_plugin PLUGIN_NAME MAIN_SRC) - set(PLUGIN_SRCS ${MAIN_SRC}) - - source_group("Headers Private" FILES ${PLUGIN_HDR}) - source_group("Sources" FILES ${PLUGIN_SRCS}) - add_library(${PLUGIN_NAME} SHARED ${PLUGIN_SRCS} ${PLUGIN_HDR}) - - target_link_libraries(${PLUGIN_NAME} -lwebsockets) - - # Set test app specific defines. - set_property(TARGET ${PLUGIN_NAME} - PROPERTY COMPILE_DEFINITIONS - INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/plugins" - ) - - list(APPEND PLUGINS_LIST ${PLUGIN_NAME}) -endmacro() +source_group("Headers Private" FILES ${PLUGIN_HDR}) +source_group("Sources" FILES ${PLUGIN_SRCS}) +add_library(${PLUGIN_NAME} SHARED ${PLUGIN_SRCS} ${PLUGIN_HDR}) +target_link_libraries(${PLUGIN_NAME} -lwebsockets) -create_plugin(protocol_example_standalone - "protocol_example_standalone.c") +# Set test app specific defines. +set_property(TARGET ${PLUGIN_NAME} + PROPERTY COMPILE_DEFINITIONS + INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/plugins" +) + +list(APPEND PLUGINS_LIST ${PLUGIN_NAME}) install(TARGETS ${PLUGINS_LIST} PERMISSIONS OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE OWNER_READ GROUP_READ WORLD_READ DESTINATION share/libwebsockets-test-server/plugins - COMPONENT plugins) \ No newline at end of file + COMPONENT plugins) -- 2.7.4