From ceec68bc7af40360b8f60fa4f677fdf462f3bab5 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 19 Sep 2017 12:31:17 +0200 Subject: [PATCH] Fixed XSD compil & link issues --- cmake/FindLibXsd.cmake | 57 ++++++++++++++++++++++++++ console/CMakeLists.txt | 4 +- coreapi/help/examples/C/CMakeLists.txt | 2 +- daemon/CMakeLists.txt | 2 +- include/linphone/api/c-chat-message.h | 28 ++++++------- src/CMakeLists.txt | 27 ++++++++++-- tester/CMakeLists.txt | 2 +- tools/CMakeLists.txt | 10 ++--- 8 files changed, 105 insertions(+), 27 deletions(-) create mode 100644 cmake/FindLibXsd.cmake diff --git a/cmake/FindLibXsd.cmake b/cmake/FindLibXsd.cmake new file mode 100644 index 000000000..7775dbc4a --- /dev/null +++ b/cmake/FindLibXsd.cmake @@ -0,0 +1,57 @@ +############################################################################ +# FindLibXsd.cmake +# Copyright (C) 2017 Belledonne Communications, Grenoble France +# +############################################################################ +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +############################################################################ +# +# - Find the libxsd library +# +# XSD_FOUND - system has libxsd +# XSD_LIBRARIES - The libraries needed to use libxsd + +if(APPLE) +set(XSDCXX_DEFAULT_ROOT_PATH "/usr/local") +else () +set(XSDCXX_DEFAULT_ROOT_PATH "/usr") +endif() + +set(XSDCXX_ROOT_PATH ${XSDCXX_DEFAULT_ROOT_PATH} CACHE STRING "Path of where the bin/xsdcxx executable will be found. Comes from http://www.codesynthesis.com/products/xsd/download.xhtml. On mac use 'brew install xsd'") + +find_program(XSDCXX_PROG NAMES "xsdcxx" "xsd" + HINTS ${XSDCXX_ROOT_PATH}/bin +) +if(XSDCXX_PROG) + set(XSD_FOUND 1) + message(STATUS "XSD found at ${XSDCXX_PROG}, enabling XSD") + # TODO: check XSD is the correct executable + find_library(XERCES_LIBS NAMES xerces-c) + if(NOT XERCES_LIBS) + message(FATAL_ERROR "Failed to find the Xerces library.") + endif() + find_path(XERCES_INCLUDE_DIRS NAMES xercesc/util/XercesDefs.hpp) + if(NOT XERCES_INCLUDE_DIRS) + message(FATAL_ERROR "Failed to find the Xerces includes.") + endif() + set(XSD_LIBRARIES ${XERCES_LIBS}) +else() + set(XSD_FOUND 0) + message(STATUS "Program 'xsdcxx' could not be found in ${XSDCXX_ROOT_PATH}/bin, disabling XSD features") +endif() + +mark_as_advanced(XSD_FOUND) diff --git a/console/CMakeLists.txt b/console/CMakeLists.txt index a23ad6cba..1e4de5e1d 100644 --- a/console/CMakeLists.txt +++ b/console/CMakeLists.txt @@ -37,7 +37,7 @@ if(MSVC) endif() add_executable(linphonec ${LINPHONEC_SOURCE_FILES}) -target_link_libraries(linphonec ${LINPHONE_LIBS_FOR_TOOLS} ${BCTOOLBOX_CORE_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES}) +target_link_libraries(linphonec ${LINPHONE_LIBS_FOR_TOOLS} ${BCTOOLBOX_CORE_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES} ${XSD_LIBRARIES}) set_target_properties(linphonec PROPERTIES LINK_FLAGS "${LINPHONE_LDFLAGS}") if(INTL_FOUND) @@ -46,7 +46,7 @@ endif() if(WIN32) add_executable(linphoned WIN32 ${LINPHONEC_SOURCE_FILES}) - target_link_libraries(linphoned ${LINPHONE_LIBS_FOR_TOOLS} ${BCTOOLBOX_CORE_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES}) + target_link_libraries(linphoned ${LINPHONE_LIBS_FOR_TOOLS} ${BCTOOLBOX_CORE_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES} ${XSD_LIBRARIES}) if(INTL_FOUND) target_link_libraries(linphoned ${INTL_LIBRARIES}) endif() diff --git a/coreapi/help/examples/C/CMakeLists.txt b/coreapi/help/examples/C/CMakeLists.txt index 84a5b38d5..e89cde8db 100644 --- a/coreapi/help/examples/C/CMakeLists.txt +++ b/coreapi/help/examples/C/CMakeLists.txt @@ -29,7 +29,7 @@ if (ENABLE_TOOLS) string(REPLACE ".c" "" EXECUTABLE_NAME ${EXECUTABLE}) bc_apply_compile_flags(${EXECUTABLE} STRICT_OPTIONS_CPP STRICT_OPTIONS_C) add_executable(${EXECUTABLE_NAME} ${USE_BUNDLE} ${EXECUTABLE}) - target_link_libraries(${EXECUTABLE_NAME} ${LINPHONE_LIBS_FOR_TOOLS} ${MEDIASTREAMER2_LIBRARIES} ${ORTP_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES}) + target_link_libraries(${EXECUTABLE_NAME} ${LINPHONE_LIBS_FOR_TOOLS} ${MEDIASTREAMER2_LIBRARIES} ${ORTP_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES} ${XSD_LIBRARIES}) set_target_properties(${EXECUTABLE_NAME} PROPERTIES LINK_FLAGS "${LINPHONE_LDFLAGS}") if (NOT IOS) install(TARGETS ${EXECUTABLE_NAME} diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index 61178d119..c50915234 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -115,7 +115,7 @@ bc_apply_compile_flags(DAEMON_PIPETEST_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OP add_executable(linphone-daemon ${DAEMON_SOURCE_FILES}) target_include_directories(linphone-daemon PRIVATE ${CMAKE_CURRENT_LIST_DIR}) -target_link_libraries(linphone-daemon ${LINPHONE_LIBS_FOR_TOOLS} ${MEDIASTREAMER2_LIBRARIES} ${ORTP_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES}) +target_link_libraries(linphone-daemon ${LINPHONE_LIBS_FOR_TOOLS} ${MEDIASTREAMER2_LIBRARIES} ${ORTP_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES} ${XSD_LIBRARIES}) set_target_properties(linphone-daemon PROPERTIES LINK_FLAGS "${LINPHONE_LDFLAGS}") add_executable(linphone-daemon-pipetest ${DAEMON_PIPETEST_SOURCE_FILES}) diff --git a/include/linphone/api/c-chat-message.h b/include/linphone/api/c-chat-message.h index bced0fb36..f6979295e 100644 --- a/include/linphone/api/c-chat-message.h +++ b/include/linphone/api/c-chat-message.h @@ -16,21 +16,21 @@ * along with this program. If not, see . */ - #ifndef _C_CHAT_MESSAGE_H_ - #define _C_CHAT_MESSAGE_H_ +#ifndef _C_CHAT_MESSAGE_H_ +#define _C_CHAT_MESSAGE_H_ - #include "linphone/api/c-types.h" +#include "linphone/api/c-types.h" - // ============================================================================= +// ============================================================================= - #ifdef __cplusplus - extern "C" { - #endif // ifdef __cplusplus +#ifdef __cplusplus + extern "C" { +#endif // ifdef __cplusplus - /** - * @addtogroup chatmessage - * @{ - */ +/** + * @addtogroup chatmessage + * @{ + */ /** * Acquire a reference to the chat message. @@ -59,9 +59,9 @@ LINPHONE_PUBLIC void *linphone_chat_message_get_user_data(const LinphoneChatMess **/ LINPHONE_PUBLIC void linphone_chat_message_set_user_data(LinphoneChatMessage *msg, void *ud); - /** - * @} - */ +/** + * @} + */ #ifdef __cplusplus } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4cbec9c3b..0703ce488 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -160,9 +160,30 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES xml/xml.cpp ) -ADD_XSD_WRAPPERS(xml/xml "XML XSD - xml.xsd") -ADD_XSD_WRAPPERS(xml/conference-info "Conference info XSD - conference-info.xsd") -ADD_XSD_WRAPPERS(xml/resource-lists "Resourece lists XSD - resource-lists.xsd") +function(ADD_XSD_WRAPPERS file _comment) + set(destinations ${CMAKE_CURRENT_BINARY_DIR}/xml/${file}.hxx ${CMAKE_CURRENT_BINARY_DIR}/xml/${file}.cxx) + set(source ${CMAKE_CURRENT_LIST_DIR}/xml/${file}.xsd) + file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/xml") + + set(regex "%http://.+/(.+)%\\\$$1%") + + add_custom_command(OUTPUT ${destinations} + COMMAND "${XSDCXX_PROG}" "cxx-tree" "--generate-wildcard" + "--generate-serialization" "--generate-ostream" + "--generate-detach" "--std" "c++11" "--type-naming" "java" + "--function-naming" "java" "--location-regex-trace" "--show-sloc" + "--location-regex" "\"${regex}\"" + "--output-dir" "${CMAKE_CURRENT_BINARY_DIR}/xml" "${source}" + COMMENT "${_comment}") + + add_custom_target(${file} DEPENDS ${destinations} SOURCES ${source}) + + set_source_files_properties(${destinations} PROPERTIES GENERATED ON) + set(FLEXISIP_SOURCES ${FLEXISIP_SOURCES} ${destinations} PARENT_SCOPE) +endfunction() +ADD_XSD_WRAPPERS(xml "XML XSD - xml.xsd") +ADD_XSD_WRAPPERS(conference-info "Conference info XSD - conference-info.xsd") +ADD_XSD_WRAPPERS(resource-lists "Resourece lists XSD - resource-lists.xsd") set(LINPHONE_CXX_OBJECTS_INCLUDE_DIRS ${BELR_INCLUDE_DIRS} ${LIBXSD_INCLUDE_DIRS}) set(LINPHONE_CXX_OBJECTS_DEFINITIONS "-DLIBLINPHONE_EXPORTS") diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index d9730363d..1b71c03db 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -20,7 +20,7 @@ # ############################################################################ -set(OTHER_LIBS_FOR_TESTER ${BCTOOLBOX_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES} ${BELLESIP_LIBRARIES} ${XML2_LIBRARIES}) +set(OTHER_LIBS_FOR_TESTER ${BCTOOLBOX_LIBRARIES} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES} ${BELLESIP_LIBRARIES} ${XML2_LIBRARIES} ${XSD_LIBRARIES}) if(INTL_FOUND) list(APPEND OTHER_LIBS_FOR_TESTER ${INTL_LIBRARIES}) endif() diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index fdc797c02..3c66c9cf2 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -33,31 +33,31 @@ endif() set(LP_AUTO_ANSWER_SOURCE_FILES auto_answer.c) bc_apply_compile_flags(LP_AUTO_ANSWER_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_C) add_executable(lp-auto-answer ${USE_BUNDLE} ${LP_AUTO_ANSWER_SOURCE_FILES}) -target_link_libraries(lp-auto-answer ${LINPHONE_LIBS_FOR_TOOLS} ${MEDIASTREAMER2_LIBRARIES} ${ORTP_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES}) +target_link_libraries(lp-auto-answer ${LINPHONE_LIBS_FOR_TOOLS} ${MEDIASTREAMER2_LIBRARIES} ${ORTP_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES} ${XSD_LIBRARIES}) set_target_properties(lp-auto-answer PROPERTIES LINK_FLAGS "${LINPHONE_LDFLAGS}") set(LP_SENDMSG_SOURCE_FILES lpsendmsg.c) bc_apply_compile_flags(LP_SENDMSG_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_C) add_executable(lp-sendmsg ${USE_BUNDLE} ${LP_SENDMSG_SOURCE_FILES}) -target_link_libraries(lp-sendmsg ${LINPHONE_LIBS_FOR_TOOLS} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES}) +target_link_libraries(lp-sendmsg ${LINPHONE_LIBS_FOR_TOOLS} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES} ${XSD_LIBRARIES}) set_target_properties(lp-sendmsg PROPERTIES LINK_FLAGS "${LINPHONE_LDFLAGS}") set(LP_LPC2XML_TEST_SOURCE_FILES lpc2xml_test.c) bc_apply_compile_flags(LP_LPC2XML_TEST_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_C) add_executable(lpc2xml_test ${USE_BUNDLE} ${LP_LPC2XML_TEST_SOURCE_FILES}) -target_link_libraries(lpc2xml_test ${LINPHONE_LIBS_FOR_TOOLS} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES}) +target_link_libraries(lpc2xml_test ${LINPHONE_LIBS_FOR_TOOLS} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES} ${XSD_LIBRARIES}) set_target_properties(lpc2xml_test PROPERTIES LINK_FLAGS "${LINPHONE_LDFLAGS}") set(LP_XML2LPC_TEST_SOURCE_FILES xml2lpc_test.c) bc_apply_compile_flags(LP_XML2LPC_TEST_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_C) add_executable(xml2lpc_test ${USE_BUNDLE} ${LP_XML2LPC_TEST_SOURCE_FILES}) -target_link_libraries(xml2lpc_test ${LINPHONE_LIBS_FOR_TOOLS} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES}) +target_link_libraries(xml2lpc_test ${LINPHONE_LIBS_FOR_TOOLS} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES} ${XSD_LIBRARIES}) set_target_properties(xml2lpc_test PROPERTIES LINK_FLAGS "${LINPHONE_LDFLAGS}") set(LP_TEST_ECC_SOURCE_FILES test_ecc.c) bc_apply_compile_flags(LP_TEST_ECC_SOURCE_FILES STRICT_OPTIONS_CPP STRICT_OPTIONS_C) add_executable(lp-test-ecc ${USE_BUNDLE} ${LP_TEST_ECC_SOURCE_FILES}) -target_link_libraries(lp-test-ecc ${LINPHONE_LIBS_FOR_TOOLS} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES}) +target_link_libraries(lp-test-ecc ${LINPHONE_LIBS_FOR_TOOLS} ${ORTP_LIBRARIES} ${MEDIASTREAMER2_LIBRARIES} ${BCTOOLBOX_CORE_LIBRARIES} ${XSD_LIBRARIES}) set_target_properties(lp-test-ecc PROPERTIES LINK_FLAGS "${LINPHONE_LDFLAGS}") if (NOT IOS)