|
| 1 | +# |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 3 | +# or more contributor license agreements. See the NOTICE file |
| 4 | +# distributed with this work for additional information |
| 5 | +# regarding copyright ownership. The ASF licenses this file |
| 6 | +# to you under the Apache License, Version 2.0 (the |
| 7 | +# "License"); you may not use this file except in compliance |
| 8 | +# with the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, |
| 13 | +# software distributed under the License is distributed on an |
| 14 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | +# KIND, either express or implied. See the License for the |
| 16 | +# specific language governing permissions and limitations |
| 17 | +# under the License. |
| 18 | +# |
| 19 | +project(qmf2_examples) |
| 20 | +cmake_minimum_required(VERSION 2.4.0 FATAL_ERROR) |
| 21 | +if(COMMAND cmake_policy) |
| 22 | + cmake_policy(SET CMP0003 NEW) |
| 23 | +endif(COMMAND cmake_policy) |
| 24 | + |
| 25 | +include_directories(${CMAKE_BINARY_DIR}/include) |
| 26 | +include_directories(${CMAKE_SOURCE_DIR}/include) |
| 27 | + |
| 28 | +# Shouldn't need this... but there are still client header inclusions |
| 29 | +# of Boost. When building examples at an install site, the Boost files |
| 30 | +# should be locatable aside from these settings. |
| 31 | +# So set up to find the headers, find the libs at link time, but dynamically |
| 32 | +# link them all and clear the CMake Boost library names to avoid adding them to |
| 33 | +# the project files. |
| 34 | +include_directories( ${Boost_INCLUDE_DIR} ) |
| 35 | +link_directories( ${Boost_LIBRARY_DIRS} ) |
| 36 | + |
| 37 | +# Visual Studio needs some Windows-specific simplifications. |
| 38 | +# Linux needs to reference the boost libs, even though they should be |
| 39 | +# resolved via the Qpid libs. |
| 40 | +if (MSVC) |
| 41 | + add_definitions( /D "NOMINMAX" /D "WIN32_LEAN_AND_MEAN" /D "BOOST_ALL_DYN_LINK" ) |
| 42 | + # On Windows, prevent the accidental inclusion of Boost headers from |
| 43 | + # autolinking in the Boost libs. There should be no direct references to |
| 44 | + # Boost in the examples, and references via qpidclient/qpidcommon are |
| 45 | + # resolved in the Qpid libs. |
| 46 | + add_definitions( /D "BOOST_ALL_NO_LIB" ) |
| 47 | +else (MSVC) |
| 48 | + set(_boost_libs_needed ${Boost_PROGRAM_OPTIONS_LIBRARY} |
| 49 | + ${Boost_FILESYSTEM_LIBRARY}) |
| 50 | +endif (MSVC) |
| 51 | + |
| 52 | +# There are numerous duplicate names within the examples. Since all target |
| 53 | +# names must be unique, define a macro to prepend a prefix and manage the |
| 54 | +# actual names. |
| 55 | +# There can be an optional arguments at the end: libs to include |
| 56 | +macro(add_example subdir example) |
| 57 | + add_executable(${subdir}_${example} ${example}.cpp) |
| 58 | + set_target_properties(${subdir}_${example} PROPERTIES OUTPUT_NAME ${example}) |
| 59 | + if (${ARGC} GREATER 2) |
| 60 | + target_link_libraries(${subdir}_${example} ${ARGN} qpidclient |
| 61 | + ${_boost_libs_needed}) |
| 62 | + else (${ARGC} GREATER 2) |
| 63 | + target_link_libraries(${subdir}_${example} qpidclient |
| 64 | + ${_boost_libs_needed}) |
| 65 | + endif (${ARGC} GREATER 2) |
| 66 | +endmacro(add_example) |
| 67 | + |
| 68 | +macro(add_installed_example subdir example) |
| 69 | + add_example(${subdir} ${example} ${ARGN}) |
| 70 | + |
| 71 | + # For installs, don't install the built example; that would be pointless. |
| 72 | + # Install the things a user needs to build the example on-site. |
| 73 | + install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${example}.cpp |
| 74 | + DESTINATION ${QPID_INSTALL_EXAMPLESDIR}/${subdir} |
| 75 | + COMPONENT ${QPID_COMPONENT_EXAMPLES}) |
| 76 | + if (MSVC) |
| 77 | + install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${subdir}_${example}.vcproj |
| 78 | + DESTINATION ${QPID_INSTALL_EXAMPLESDIR}/${subdir} |
| 79 | + COMPONENT ${QPID_COMPONENT_EXAMPLES}) |
| 80 | + endif (MSVC) |
| 81 | + |
| 82 | +endmacro(add_installed_example) |
| 83 | + |
| 84 | +install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/README.txt |
| 85 | + DESTINATION ${QPID_INSTALL_EXAMPLESDIR} |
| 86 | + COMPONENT ${QPID_COMPONENT_EXAMPLES}) |
| 87 | +if (MSVC) |
| 88 | + install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples.sln |
| 89 | + DESTINATION ${QPID_INSTALL_EXAMPLESDIR} |
| 90 | + COMPONENT ${QPID_COMPONENT_EXAMPLES}) |
| 91 | +endif (MSVC) |
| 92 | + |
| 93 | +add_installed_example(qmf2 agent qmf2) |
| 94 | +add_installed_example(qmf2 event_driven_list_agents qmf2) |
| 95 | +add_installed_example(qmf2 list_agents qmf2) |
| 96 | +add_installed_example(qmf2 print_events qmf2) |
| 97 | + |
0 commit comments