You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2020/10/08 01:40:32 UTC

[qpid-proton] branch master updated (341d30f -> d67c180)

This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git.


    from 341d30f  PROTON-2278: Events are received after PN_RAW_CONNECTION_DISCONNECTED if connection refused - Change raw_connect to carry on after connections refused - Add a unit test that replicates the bug - Small refactor changing an internal API to allow us to fix bug
     new 924cc98  PROTON-2233: Rearrange C/C++ example CMake files so that they use the recommended method - Changed to use modern CMake imported targets - Rearranged the in build tree CMake config files so the examples can transparently use them
     new d67c180  PROTON-2233: Remove example CMake bits that won't work in installed example directories - Move running the example tests into tests/examples

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CMakeLists.txt                                     |  6 ++
 c/CMakeLists.txt                                   |  5 +-
 c/examples/CMakeLists.txt                          | 30 +--------
 cpp/CMakeLists.txt                                 | 19 +++---
 cpp/examples/CMakeLists.txt                        | 43 ++-----------
 tests/examples/CMakeLists.txt                      | 71 ++++++++++++++++++++++
 .../cmake/config}/ProtonConfig.cmake               |  6 ++
 .../cmake/config}/ProtonCppConfig.cmake            |  3 +
 8 files changed, 106 insertions(+), 77 deletions(-)
 create mode 100644 tests/examples/CMakeLists.txt
 rename {c/examples => tools/cmake/config}/ProtonConfig.cmake (95%)
 rename {cpp/examples => tools/cmake/config}/ProtonCppConfig.cmake (97%)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[qpid-proton] 01/02: PROTON-2233: Rearrange C/C++ example CMake files so that they use the recommended method - Changed to use modern CMake imported targets - Rearranged the in build tree CMake config files so the examples can transparently use them

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit 924cc980299f2b4c9d1dfce3df93b504942aa40e
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Tue Oct 6 22:46:54 2020 -0400

    PROTON-2233: Rearrange C/C++ example CMake files so that they use the recommended method
    - Changed to use modern CMake imported targets
    - Rearranged the in build tree CMake config files so the examples can transparently use them
---
 CMakeLists.txt                                           |  4 ++++
 c/CMakeLists.txt                                         |  2 +-
 c/examples/CMakeLists.txt                                |  8 +++-----
 cpp/CMakeLists.txt                                       | 16 ++++++++--------
 cpp/examples/CMakeLists.txt                              | 12 ++++--------
 {c/examples => tools/cmake/config}/ProtonConfig.cmake    |  6 ++++++
 .../cmake/config}/ProtonCppConfig.cmake                  |  3 +++
 7 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d75dfdb..f2dcdca 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,6 +42,10 @@ include(tests/PNAddTest.cmake)
 # Set up runtime checks (valgrind, sanitizers etc.)
 include(tests/RuntimeCheck.cmake)
 
+## Set up so that find_package(Proton) & find_package(ProtonCpp) work in the build tree
+set (Proton_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/config)
+set (ProtonCpp_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake/config)
+
 ## Variables used across components
 
 set (PN_ENV_SCRIPT "${PYTHON_EXECUTABLE}" "${CMAKE_SOURCE_DIR}/scripts/env.py")
diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt
index d86eab4..66de789 100644
--- a/c/CMakeLists.txt
+++ b/c/CMakeLists.txt
@@ -180,7 +180,7 @@ set(C_EXAMPLE_FLAGS_GNU "-pedantic")
 set(C_EXAMPLE_FLAGS_Clang "-pedantic")
 
 # Flags for example self-test build
-set(C_EXAMPLE_FLAGS "${C_STANDARD_FLAGS} ${COMPILE_WARNING_FLAGS} ${C_EXAMPLE_FLAGS_${CMAKE_C_COMPILER_ID}}")
+set(C_EXAMPLE_FLAGS "${COMPILE_WARNING_FLAGS} ${C_EXAMPLE_FLAGS_${CMAKE_C_COMPILER_ID}}")
 set(C_EXAMPLE_LINK_FLAGS "${SANITIZE_FLAGS}")
 
 set(qpid-proton-platform_GNU src/compiler/gcc/start.c)
diff --git a/c/examples/CMakeLists.txt b/c/examples/CMakeLists.txt
index ec29888..d19c868 100644
--- a/c/examples/CMakeLists.txt
+++ b/c/examples/CMakeLists.txt
@@ -18,17 +18,15 @@
 #
 cmake_minimum_required (VERSION 2.8.12)
 
-set (Proton_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+project(ProtonCExamples C)
+
 find_package(Proton REQUIRED Core Proactor)
 set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
 find_package(Threads REQUIRED)
 
-include_directories(${Proton_INCLUDE_DIRS})
-add_definitions(${Proton_DEFINITIONS})
-
 foreach (name broker send receive direct send-abort send-ssl raw_echo raw_connect)
   add_executable(c-${name} ${name}.c)
-  target_link_libraries(c-${name} ${Proton_Proactor_LIBRARIES} ${Proton_Core_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+  target_link_libraries(c-${name} Proton::core Proton::proactor Threads::Threads)
   set_target_properties(c-${name} PROPERTIES
     OUTPUT_NAME ${name})
 endforeach()
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index bd926df..9c92139 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -198,6 +198,14 @@ install (DIRECTORY "examples/"
   USE_SOURCE_PERMISSIONS
   PATTERN "ProtonCppConfig.cmake" EXCLUDE)
 
+if (DEFINED CMAKE_IMPORT_LIBRARY_PREFIX)
+set(PROTONCPPLIB ${CMAKE_IMPORT_LIBRARY_PREFIX}qpid-proton-cpp${CMAKE_IMPORT_LIBRARY_SUFFIX})
+set(PROTONCPPLIBDEBUG ${CMAKE_IMPORT_LIBRARY_PREFIX}qpid-proton-cpp${CMAKE_DEBUG_POSTFIX}${CMAKE_IMPORT_LIBRARY_SUFFIX})
+else ()
+set(PROTONCPPLIB ${CMAKE_SHARED_LIBRARY_PREFIX}qpid-proton-cpp${CMAKE_SHARED_LIBRARY_SUFFIX})
+set(PROTONCPPLIBDEBUG ${CMAKE_SHARED_LIBRARY_PREFIX}qpid-proton-cpp${CMAKE_DEBUG_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX})
+endif ()
+
 add_subdirectory(examples)
 add_subdirectory(docs)
 
@@ -209,14 +217,6 @@ install (FILES
   ${CMAKE_CURRENT_BINARY_DIR}/libqpid-proton-cpp.pc
   DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 
-if (DEFINED CMAKE_IMPORT_LIBRARY_PREFIX)
-set(PROTONCPPLIB ${CMAKE_IMPORT_LIBRARY_PREFIX}qpid-proton-cpp${CMAKE_IMPORT_LIBRARY_SUFFIX})
-set(PROTONCPPLIBDEBUG ${CMAKE_IMPORT_LIBRARY_PREFIX}qpid-proton-cpp${CMAKE_DEBUG_POSTFIX}${CMAKE_IMPORT_LIBRARY_SUFFIX})
-else ()
-set(PROTONCPPLIB ${CMAKE_SHARED_LIBRARY_PREFIX}qpid-proton-cpp${CMAKE_SHARED_LIBRARY_SUFFIX})
-set(PROTONCPPLIBDEBUG ${CMAKE_SHARED_LIBRARY_PREFIX}qpid-proton-cpp${CMAKE_DEBUG_POSTFIX}${CMAKE_SHARED_LIBRARY_SUFFIX})
-endif ()
-
 include(WriteBasicConfigVersionFile)
 
 configure_file(
diff --git a/cpp/examples/CMakeLists.txt b/cpp/examples/CMakeLists.txt
index 8c50612..f6f739b 100644
--- a/cpp/examples/CMakeLists.txt
+++ b/cpp/examples/CMakeLists.txt
@@ -18,18 +18,12 @@
 #
 cmake_minimum_required (VERSION 2.8.12)
 
-enable_language(CXX)
+project(ProtonCppExamples C CXX)
 
-set (ProtonCpp_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 find_package(ProtonCpp REQUIRED)
 set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
 find_package(Threads REQUIRED)
 
-include_directories(${ProtonCpp_INCLUDE_DIRS})
-link_libraries(${ProtonCpp_LIBRARIES})
-add_definitions(${ProtonCpp_DEFINITIONS})
-
-
 macro (has_cxx_features result)
 set(${result} OFF)
 if (DEFINED CMAKE_CXX_COMPILE_FEATURES)
@@ -82,6 +76,7 @@ foreach(example
     ssl_client_cert
     encode_decode)
   add_executable(${example} ${example}.cpp)
+  target_link_libraries(${example} Proton::cpp)
 endforeach()
 
 if(HAS_ENOUGH_CPP11)
@@ -90,6 +85,7 @@ if(HAS_ENOUGH_CPP11)
       scheduled_send
       service_bus)
     add_executable(${example} ${example}.cpp)
+    target_link_libraries(${example} Proton::cpp)
   endforeach()
 
   # Examples that use threads directly
@@ -98,7 +94,7 @@ if(HAS_ENOUGH_CPP11)
         multithreaded_client
         multithreaded_client_flow_control)
       add_executable(${example} ${example}.cpp)
-      target_link_libraries(${example} Threads::Threads)
+      target_link_libraries(${example} Proton::cpp Threads::Threads)
     endforeach()
   endif()
 endif()
diff --git a/c/examples/ProtonConfig.cmake b/tools/cmake/config/ProtonConfig.cmake
similarity index 95%
rename from c/examples/ProtonConfig.cmake
rename to tools/cmake/config/ProtonConfig.cmake
index 2343e24..6291d6f 100644
--- a/c/examples/ProtonConfig.cmake
+++ b/tools/cmake/config/ProtonConfig.cmake
@@ -37,12 +37,18 @@ set (Proton_FOUND True)
 set (Proton_Core_INCLUDE_DIRS  ${CMAKE_SOURCE_DIR}/c/include)
 set (Proton_Core_LIBRARIES     ${C_EXAMPLE_LINK_FLAGS} qpid-proton-core)
 set (Proton_Core_DEFINITIONS   ${C_EXAMPLE_FLAGS})
+
+add_library(Proton::core ALIAS qpid-proton-core)
+
 set (Proton_Core_FOUND True)
 
 if (${HAS_PROACTOR})
   set (Proton_Proactor_INCLUDE_DIRS  ${CMAKE_SOURCE_DIR}/c/include)
   set (Proton_Proactor_LIBRARIES     ${C_EXAMPLE_LINK_FLAGS} qpid-proton-proactor)
   set (Proton_Proactor_DEFINITIONS   ${C_EXAMPLE_FLAGS})
+
+  add_library(Proton::proactor ALIAS qpid-proton-proactor)
+
   set (Proton_Proactor_FOUND True)
 endif()
 
diff --git a/cpp/examples/ProtonCppConfig.cmake b/tools/cmake/config/ProtonCppConfig.cmake
similarity index 97%
rename from cpp/examples/ProtonCppConfig.cmake
rename to tools/cmake/config/ProtonCppConfig.cmake
index 2694d0f..d7a942a 100644
--- a/cpp/examples/ProtonCppConfig.cmake
+++ b/tools/cmake/config/ProtonCppConfig.cmake
@@ -32,4 +32,7 @@ set (ProtonCpp_INCLUDE_DIRS  ${CMAKE_SOURCE_DIR}/c/include ${CMAKE_SOURCE_DIR}/c
                              ${CMAKE_BINARY_DIR}/cpp)
 set (ProtonCpp_LIBRARIES     ${CXX_EXAMPLE_LINK_FLAGS} qpid-proton-cpp)
 set (ProtonCpp_DEFINITIONS   ${CXX_EXAMPLE_FLAGS})
+
+add_library(Proton::cpp ALIAS qpid-proton-cpp)
+
 set (ProtonCpp_FOUND True)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[qpid-proton] 02/02: PROTON-2233: Remove example CMake bits that won't work in installed example directories - Move running the example tests into tests/examples

Posted by as...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

astitcher pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-proton.git

commit d67c180777e5ddb7305e39aa32ec90669bfe0572
Author: Andrew Stitcher <as...@apache.org>
AuthorDate: Tue Oct 6 23:09:55 2020 -0400

    PROTON-2233: Remove example CMake bits that won't work in installed example directories
    - Move running the example tests into tests/examples
---
 CMakeLists.txt                |  2 ++
 c/CMakeLists.txt              |  3 +-
 c/examples/CMakeLists.txt     | 22 --------------
 cpp/CMakeLists.txt            |  3 +-
 cpp/examples/CMakeLists.txt   | 31 -------------------
 tests/examples/CMakeLists.txt | 71 +++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 77 insertions(+), 55 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f2dcdca..5fe49f3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -428,3 +428,5 @@ configure_file(${CMAKE_SOURCE_DIR}/misc/config.sh.in
                ${CMAKE_BINARY_DIR}/config.sh @ONLY)
 configure_file(${CMAKE_SOURCE_DIR}/misc/config.bat.in
                ${CMAKE_BINARY_DIR}/config.bat @ONLY)
+
+add_subdirectory(tests/examples)
diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt
index 66de789..89028fb 100644
--- a/c/CMakeLists.txt
+++ b/c/CMakeLists.txt
@@ -589,4 +589,5 @@ add_subdirectory(tools)
 install (DIRECTORY examples/
          DESTINATION "${PROTON_SHARE}/examples/c"
          USE_SOURCE_PERMISSIONS
-         PATTERN ProtonConfig.cmake EXCLUDE)
+         PATTERN "ProtonConfig.cmake" EXCLUDE
+         PATTERN "testme" EXCLUDE)
diff --git a/c/examples/CMakeLists.txt b/c/examples/CMakeLists.txt
index d19c868..87f85c4 100644
--- a/c/examples/CMakeLists.txt
+++ b/c/examples/CMakeLists.txt
@@ -30,25 +30,3 @@ foreach (name broker send receive direct send-abort send-ssl raw_echo raw_connec
   set_target_properties(c-${name} PROPERTIES
     OUTPUT_NAME ${name})
 endforeach()
-
-
-find_package (PythonInterp)     # For test-driver script
-if (PYTHON_EXECUTABLE)
-  if(WIN32)
-    # NOTE: need to escape semicolons as cmake uses them as list separators.
-    set(test_path "$<TARGET_FILE_DIR:c-broker>\;$<TARGET_FILE_DIR:qpid-proton-core>\;$<TARGET_FILE_DIR:qpid-proton-proactor>")
-  else()
-    set(test_path "$<TARGET_FILE_DIR:c-broker>:$ENV{PATH}")
-  endif()
-
-  set(test_env
-    "PATH=${test_path}"
-    "PYTHONPATH=../../tests/py")
-
-  pn_add_test(
-    UNWRAPPED
-    NAME c-example-tests
-    PREPEND_ENVIRONMENT "${test_env}"
-    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-    COMMAND ${PYTHON_EXECUTABLE} testme -v)
-endif()
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index 9c92139..7d4ed98 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -196,7 +196,8 @@ install (FILES "${CMAKE_CURRENT_BINARY_DIR}/config_presets.hpp" DESTINATION "${I
 install (DIRECTORY "examples/"
   DESTINATION "${PROTON_SHARE}/examples/cpp"
   USE_SOURCE_PERMISSIONS
-  PATTERN "ProtonCppConfig.cmake" EXCLUDE)
+  PATTERN "ProtonCppConfig.cmake" EXCLUDE
+  PATTERN "testme" EXCLUDE)
 
 if (DEFINED CMAKE_IMPORT_LIBRARY_PREFIX)
 set(PROTONCPPLIB ${CMAKE_IMPORT_LIBRARY_PREFIX}qpid-proton-cpp${CMAKE_IMPORT_LIBRARY_SUFFIX})
diff --git a/cpp/examples/CMakeLists.txt b/cpp/examples/CMakeLists.txt
index f6f739b..a5b9c91 100644
--- a/cpp/examples/CMakeLists.txt
+++ b/cpp/examples/CMakeLists.txt
@@ -98,34 +98,3 @@ if(HAS_ENOUGH_CPP11)
     endforeach()
   endif()
 endif()
-
-find_package (PythonInterp)     # For test-driver script
-if (PYTHON_EXECUTABLE)
-  if(WIN32)
-    # NOTE: need to escape semicolons as cmake uses them as list separators.
-    set(test_path "$<TARGET_FILE_DIR:broker>\;$<TARGET_FILE_DIR:qpid-proton-core>\;$<TARGET_FILE_DIR:qpid-proton-cpp>")
-  else()
-    set(test_path "$<TARGET_FILE_DIR:broker>:$ENV{PATH}")
-  endif()
-
-  set(test_env
-    "PATH=${test_path}"
-    "PYTHONPATH=../../tests/py"
-    "HAS_CPP11=$<$<BOOL:${HAS_ENOUGH_CPP11}>:1>")
-
-  pn_add_test(
-    UNWRAPPED
-    NAME cpp-example-container
-    PREPEND_ENVIRONMENT "${test_env}"
-    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-    COMMAND ${PYTHON_EXECUTABLE} testme -v ContainerExampleTest)
-
-  if (NOT SSL_IMPL STREQUAL none)
-    pn_add_test(
-      UNWRAPPED
-      NAME cpp-example-container-ssl
-      PREPEND_ENVIRONMENT "${test_env}"
-      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-      COMMAND ${PYTHON_EXECUTABLE} testme -v ContainerExampleSSLTest)
-  endif()
-endif()
diff --git a/tests/examples/CMakeLists.txt b/tests/examples/CMakeLists.txt
new file mode 100644
index 0000000..4c78dd2
--- /dev/null
+++ b/tests/examples/CMakeLists.txt
@@ -0,0 +1,71 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+
+if (NOT PYTHON_EXECUTABLE)
+  return()
+endif()
+
+if(WIN32)
+  # NOTE: need to escape semicolons as cmake uses them as list separators.
+  set(c_test_path "$<TARGET_FILE_DIR:c-broker>\;$<TARGET_FILE_DIR:qpid-proton-core>\;$<TARGET_FILE_DIR:qpid-proton-proactor>")
+else()
+  set(c_test_path "$<TARGET_FILE_DIR:c-broker>:$ENV{PATH}")
+endif()
+
+set(c_test_env
+  "PATH=${c_test_path}"
+  "PYTHONPATH=${Proton_SOURCE_DIR}/tests/py")
+
+pn_add_test(
+  UNWRAPPED
+  NAME c-example-tests
+  PREPEND_ENVIRONMENT "${c_test_env}"
+  WORKING_DIRECTORY ${ProtonCExamples_SOURCE_DIR}
+  COMMAND ${PYTHON_EXECUTABLE} testme -v)
+
+if (BUILD_CPP)
+  if(WIN32)
+    # NOTE: need to escape semicolons as cmake uses them as list separators.
+    set(cpp_test_path "$<TARGET_FILE_DIR:broker>\;$<TARGET_FILE_DIR:qpid-proton-core>\;$<TARGET_FILE_DIR:qpid-proton-cpp>")
+  else()
+    set(cpp_test_path "$<TARGET_FILE_DIR:broker>:$ENV{PATH}")
+  endif()
+
+  set(cpp_test_env
+    "PATH=${cpp_test_path}"
+    "PYTHONPATH=${Proton_SOURCE_DIR}/tests/py"
+    "HAS_CPP11=$<$<BOOL:${HAS_ENOUGH_CPP11}>:1>")
+
+  pn_add_test(
+    UNWRAPPED
+    NAME cpp-example-container
+    PREPEND_ENVIRONMENT "${cpp_test_env}"
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+    COMMAND ${PYTHON_EXECUTABLE} ${ProtonCppExamples_SOURCE_DIR}/testme -v ContainerExampleTest)
+
+  if (NOT SSL_IMPL STREQUAL none)
+    pn_add_test(
+      UNWRAPPED
+      NAME cpp-example-container-ssl
+      PREPEND_ENVIRONMENT "${cpp_test_env}"
+      WORKING_DIRECTORY ${ProtonCppExamples_SOURCE_DIR}
+      COMMAND ${PYTHON_EXECUTABLE} testme -v ContainerExampleSSLTest)
+  endif()
+endif()


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org