From 73da47480493d626fd66ee457ed5958043ddc17b Mon Sep 17 00:00:00 2001 From: KangLin Date: Sun, 28 Mar 2021 20:19:15 -0700 Subject: [PATCH 1/7] CMake: add runtime install --- CMakeLists.txt | 13 +++++++++++++ src/apps/common/CMakeLists.txt | 2 ++ src/apps/natdiscovery/CMakeLists.txt | 1 + src/apps/oauth/CMakeLists.txt | 1 + src/apps/peer/CMakeLists.txt | 1 + src/apps/relay/CMakeLists.txt | 1 + src/apps/rfc5769/CMakeLists.txt | 1 + src/apps/stunclient/CMakeLists.txt | 1 + src/apps/uclient/CMakeLists.txt | 1 + src/client/CMakeLists.txt | 2 ++ src/server/CMakeLists.txt | 2 ++ 11 files changed, 26 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index b32b69f4..a5810d4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ cmake_minimum_required(VERSION 3.5) project(coturn) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) +# TODO: Modify this when the version is released SET(BUILD_VERSION "4.5.2") # Find Git Version Patch @@ -60,6 +61,18 @@ include(CheckIncludeFile) include(CheckIncludeFileCXX) include(CheckFunctionExists) +# Create install runtime target +add_custom_target(install-runtime + COMMAND + "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=Runtime + -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_install.cmake" +) +# Create uninstall runtime target +add_custom_target(uninstall-runtime + COMMAND + "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=Runtime + -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" +) # Create will be delete files CONFIGURE_FILE( "${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" diff --git a/src/apps/common/CMakeLists.txt b/src/apps/common/CMakeLists.txt index d66953cc..520d09da 100644 --- a/src/apps/common/CMakeLists.txt +++ b/src/apps/common/CMakeLists.txt @@ -62,7 +62,9 @@ set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Config RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT Runtime ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} diff --git a/src/apps/natdiscovery/CMakeLists.txt b/src/apps/natdiscovery/CMakeLists.txt index 0935b634..c7df4d1e 100644 --- a/src/apps/natdiscovery/CMakeLists.txt +++ b/src/apps/natdiscovery/CMakeLists.txt @@ -10,4 +10,5 @@ add_executable(${PROJECT_NAME} ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} PRIVATE turnclient) INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime ) diff --git a/src/apps/oauth/CMakeLists.txt b/src/apps/oauth/CMakeLists.txt index 3f14067c..18ce9380 100644 --- a/src/apps/oauth/CMakeLists.txt +++ b/src/apps/oauth/CMakeLists.txt @@ -10,4 +10,5 @@ add_executable(${PROJECT_NAME} ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} PRIVATE turnclient) INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime ) diff --git a/src/apps/peer/CMakeLists.txt b/src/apps/peer/CMakeLists.txt index f920e7be..3ff80574 100644 --- a/src/apps/peer/CMakeLists.txt +++ b/src/apps/peer/CMakeLists.txt @@ -10,4 +10,5 @@ add_executable(${PROJECT_NAME} ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} PRIVATE turnclient) INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime ) diff --git a/src/apps/relay/CMakeLists.txt b/src/apps/relay/CMakeLists.txt index 2f1a57db..6b801e73 100644 --- a/src/apps/relay/CMakeLists.txt +++ b/src/apps/relay/CMakeLists.txt @@ -96,4 +96,5 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE ${turnserver_DEFINED}) INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime ) diff --git a/src/apps/rfc5769/CMakeLists.txt b/src/apps/rfc5769/CMakeLists.txt index 9c428280..492e1947 100644 --- a/src/apps/rfc5769/CMakeLists.txt +++ b/src/apps/rfc5769/CMakeLists.txt @@ -10,4 +10,5 @@ add_executable(${PROJECT_NAME} ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} PRIVATE turnclient) INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime ) diff --git a/src/apps/stunclient/CMakeLists.txt b/src/apps/stunclient/CMakeLists.txt index ddb41e68..3e64b3b9 100644 --- a/src/apps/stunclient/CMakeLists.txt +++ b/src/apps/stunclient/CMakeLists.txt @@ -10,4 +10,5 @@ add_executable(${PROJECT_NAME} ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} PRIVATE turnclient) INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime ) diff --git a/src/apps/uclient/CMakeLists.txt b/src/apps/uclient/CMakeLists.txt index 47422c02..86e6eefd 100644 --- a/src/apps/uclient/CMakeLists.txt +++ b/src/apps/uclient/CMakeLists.txt @@ -12,4 +12,5 @@ add_executable(${PROJECT_NAME} ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} PRIVATE turnclient) INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime ) diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 818f8db8..3bcc6446 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -33,7 +33,9 @@ set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Config RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT Runtime ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/turn/client INCLUDES DESTINATION diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt index fcc21ee7..8c2261f1 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -36,7 +36,9 @@ set_target_properties(${PROJECT_NAME} PROPERTIES INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Config RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + COMPONENT Runtime ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} From 2110991cd6edc6616a5bc681ba728767af292f06 Mon Sep 17 00:00:00 2001 From: KangLin Date: Sun, 28 Mar 2021 21:32:47 -0700 Subject: [PATCH 2/7] CMake: add turnadmin --- src/apps/relay/CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/apps/relay/CMakeLists.txt b/src/apps/relay/CMakeLists.txt index 6b801e73..73fbe9b2 100644 --- a/src/apps/relay/CMakeLists.txt +++ b/src/apps/relay/CMakeLists.txt @@ -94,7 +94,16 @@ target_link_libraries(${PROJECT_NAME} PRIVATE turn_server ${turnserver_LIBS}) target_include_directories(${PROJECT_NAME} PRIVATE ${turnserver_include_dirs}) target_compile_definitions(${PROJECT_NAME} PRIVATE ${turnserver_DEFINED}) +add_custom_target(turnadmin ALL + COMMAND + ${CMAKE_COMMAND} -E create_symlink $ turnadmin + DEPENDS ${PROJECT_NAME}) + INSTALL(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT Runtime ) + +INSTALL(FILES $/turnadmin + DESTINATION "${CMAKE_INSTALL_BINDIR}" + COMPONENT Runtime) From 86f1da7baba383d838d77e731d34cd25afcaf0ef Mon Sep 17 00:00:00 2001 From: KangLin Date: Mon, 29 Mar 2021 01:30:28 -0700 Subject: [PATCH 3/7] CMake: install documents, configure, script files --- CMakeLists.txt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5810d4a..11d40c57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,3 +85,31 @@ ADD_CUSTOM_TARGET(uninstall add_subdirectory(src) +install(DIRECTORY man DESTINATION . + COMPONENT Runtime) +install(DIRECTORY turndb/ + DESTINATION share/turnserver + COMPONENT Runtime) +install(DIRECTORY turndb/ + DESTINATION doc/turnserver + COMPONENT Runtime) +install(FILES + LICENSE + README.turnserver + README.turnadmin + README.turnutils + INSTALL + postinstall.txt + DESTINATION doc/turnserver + COMPONENT Runtime) +install(FILES examples/etc/turnserver.conf + DESTINATION ${CMAKE_INSTALL_SYSCONFDIR} + COMPONENT Runtime + RENAME turnserver.conf.default + ) +install(DIRECTORY + examples/etc + examples/scripts + DESTINATION share/examples/turnserver + PATTERN "rfc5769.sh" EXCLUDE + ) From 33dd25e36c2c483eb1c5670a55bc659bbfeade51 Mon Sep 17 00:00:00 2001 From: KangLin Date: Mon, 29 Mar 2021 06:05:56 -0700 Subject: [PATCH 4/7] CMake: add cmake to ci --- .travis.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.travis.yml b/.travis.yml index 33f0cda6..bb44e3f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,15 @@ before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew unlink protobuf; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install mysql sqlite hiredis; fi +script: + - mkdir build + - cd build + - cmake .. -DCMAKE_INSTALL_PREFIX=`pwd`/install -DCMAKE_VERBOSE_MAKEFILE=TURE + - cmake --build . + - cmake --build . --target install + - cd .. + - ./configure && make && make test + jobs: include: - name: ubuntu focal AMD64 C @@ -147,6 +156,7 @@ jobs: - libmysqlclient-dev - libhiredis-dev + notifications: slack: secure: N12+BCGiTDzfKkYnjF+666ZhREuBncfPpWge9AdG6DwusyGza+hNrjfRRHjF8WfGQj+X8ogFoF1lVFDC27lwH1ElOv4GJHShnGbtsWv10Va1GdDafDeC5JorUNWHlsDHC1AZkNUj9n2KAZTSbN076gUaNhwsXob/B1MEnNKXibitDdyE2FC6wCRu6ckXM4UiEXoG/a7lHS4m9dKt2xDUNK8vwhtRdCkip9YW8rUFdiwqMScdr9OdF8YWiKJIUYV7LC7eXF0YqslWTJkeIMEEnvotLs4JNytFz1wNPzTiY8hM4nPM0YwC1oPhFWlBodQ1x+dBX3vxitnque0gVhj/p6Eij0amM3tirgONw/r2V9JToE6vfh6ERAWIVzI/+tmqcEbZZvwcgafZphlT9W/8Gzy/av/zTpdfaTUEYnsuQRCA87FPIFAAVjzSmT3llY6WQXFB+UU0T0ZE42PkPqhR3zpjqt7nDXf2g1ZY5ZRkWRvznyqBdrVx0Ld8AKnv/Ynk/KqiJqV94DUMhGzAadqbYrDL/87eiDtW4lBpCl7cQnfEI7besdduNzWlgmJ93CU1kyruK37/w+D1jyBnc1ppQTj1+B2GanB0weY7ViNqyQmN+tam7EmM+9R8VKMi8EO0xlvb1YFL18NtrCMMMEsZRHj823g68lFntUWs5oGsFMI= From 9f6defdac472a6e9a0307a991f4f1c6d5ad08ab2 Mon Sep 17 00:00:00 2001 From: KangLin Date: Mon, 29 Mar 2021 06:31:50 -0700 Subject: [PATCH 5/7] CMake: add -Wno-deprecated-declarations --- .travis.yml | 2 +- src/apps/common/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bb44e3f8..ab22cfa6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ before_install: script: - mkdir build - cd build - - cmake .. -DCMAKE_INSTALL_PREFIX=`pwd`/install -DCMAKE_VERBOSE_MAKEFILE=TURE + - cmake .. -DCMAKE_INSTALL_PREFIX=`pwd`/install - cmake --build . - cmake --build . --target install - cd .. diff --git a/src/apps/common/CMakeLists.txt b/src/apps/common/CMakeLists.txt index 520d09da..359dfd7d 100644 --- a/src/apps/common/CMakeLists.txt +++ b/src/apps/common/CMakeLists.txt @@ -43,6 +43,7 @@ add_library(${PROJECT_NAME} ${SOURCE_FILES} ${HEADER_FILES}) target_link_libraries(${PROJECT_NAME} PUBLIC ${COMMON_LIBS}) target_compile_definitions(${PROJECT_NAME} PUBLIC ${COMMON_DEFINED}) +target_compile_options(${PROJECT_NAME} PUBLIC -Wno-deprecated-declarations) # See: http://www.it1352.com/478094.html target_include_directories(${PROJECT_NAME} PUBLIC From bd46483efa5cd1d6ba1c1b5bfdf622350f4ec217 Mon Sep 17 00:00:00 2001 From: KangLin Date: Mon, 5 Apr 2021 11:23:21 +0800 Subject: [PATCH 6/7] Modify INSTALL --- INSTALL | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/INSTALL b/INSTALL index 40ce9607..2245e27f 100644 --- a/INSTALL +++ b/INSTALL @@ -55,6 +55,8 @@ examples and documentation. III. BUILD +1) Use autoconfigure build + If you are sure that you system is ready for the build (see the section "Extra libraries and Utilities" below) then you can build the system. First, you have to run the configure script: @@ -152,6 +154,60 @@ NOTE: On most modern systems, the build will produce dynamically linked executables. If you want statically linked executables, you have to modify, accordingly, the Makefile.in template file. +2) Use cmake build + +If you are sure that you system is ready for the build (see the section +"Extra libraries and Utilities" below) and cmake tools then you can build +the system. +First, create build directory. you have to run the follow script: + + $ cd coturn + $ mkdir build + +Then you have to run the configure script: + + $ cmake .. + +It will create a Makefile customized for your system. + +By default, the generated Makefile will install everything to: + + - /usr on Solaris. + - /usr/pkg on NetBSD. + - /usr/local everywhere else. + +The binaries will be copied to the bin subdirectory of the installation +destination, config files copied to etc subdirectory. The default SQLite database +will be created in var/db/turndb. There will be +also documents, examples and some other files, in separate directories. + +You can change the root configured destination directory by +setting CMAKE_INSTALL_PREFIX variable in the +configure command line. For example: + + $ cmake .. -DCMAKE_INSTALL_PREFIX=/opt + +Build the project: + + $ cmake --build . + +Install all files(runtime programmes and develop library): + + $ cmake --build . --target install + +Remove all installed: + + $ cmake --build . --target uninstall + +If you want to only install runtime programmes(programmes, configure files, +script files and database): + + $ cmake --build . --target install-runtime + +Remove all installed: + + $ cmake --build . --target uninstall-runtime + IV. OPENSSL If you are using the OpenSSL that is coming with your system, and you are From da60faca1d97a887f23288aee08888059c6741f3 Mon Sep 17 00:00:00 2001 From: KangLin Date: Tue, 6 Apr 2021 14:27:01 +0800 Subject: [PATCH 7/7] Modify debug flag --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11d40c57..76ff6ebb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,9 +36,10 @@ message("BUILD_VERSION:${BUILD_VERSION}") set(VERSION ${BUILD_VERSION}) if(NOT DEFINED CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release") + set(CMAKE_BUILD_TYPE "Release") endif(NOT DEFINED CMAKE_BUILD_TYPE) -if("Debug" STREQUAL CMAKE_BUILD_TYPE) +string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type) +if("debug" STREQUAL build_type) add_definitions(-D_DEBUG) endif()