"Fossies" - the Fresh Open Source Software Archive

Member "protobuf-3.12.3/cmake/examples.cmake" (2 Jun 2020, 2112 Bytes) of package /linux/misc/protobuf-all-3.12.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) CMake source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 if(protobuf_VERBOSE)
    2   message(STATUS "Protocol Buffers Examples Configuring...")
    3 endif()
    4 
    5 get_filename_component(examples_dir "../examples" ABSOLUTE)
    6 
    7 if(protobuf_VERBOSE)
    8   message(STATUS "Protocol Buffers Examples Configuring done")
    9 endif()
   10 include(ExternalProject)
   11 
   12 # Internal utility function: Create a custom target representing a build of examples with custom options.
   13 function(add_examples_build NAME)
   14 
   15   ExternalProject_Add(${NAME}
   16     PREFIX ${NAME}
   17     SOURCE_DIR "${examples_dir}"
   18     BINARY_DIR ${NAME}
   19     STAMP_DIR ${NAME}/logs
   20     INSTALL_COMMAND "" #Skip
   21     LOG_CONFIGURE 1
   22     CMAKE_CACHE_ARGS "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
   23                      "-Dprotobuf_VERBOSE:BOOL=${protobuf_VERBOSE}"
   24                      ${ARGN}
   25   )
   26   set_property(TARGET ${NAME} PROPERTY FOLDER "Examples")
   27   set_property(TARGET ${NAME} PROPERTY EXCLUDE_FROM_ALL TRUE)
   28 endfunction()
   29 
   30 # Add examples as an external project.
   31 # sub_directory cannot be used because the find_package(protobuf) call would cause failures with redefined targets.
   32 add_examples_build(examples "-Dprotobuf_DIR:PATH=${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}")
   33 add_dependencies(examples libprotobuf protoc)
   34 
   35 option(protobuf_BUILD_EXAMPLES_MULTITEST "Build Examples in multiple configurations. Useful for testing." OFF)
   36 mark_as_advanced(protobuf_BUILD_EXAMPLES_MULTITEST)
   37 if(protobuf_BUILD_EXAMPLES_MULTITEST)
   38   set_property(GLOBAL PROPERTY USE_FOLDERS ON)
   39 
   40   #Build using the legacy compatibility module.
   41   add_examples_build(examples-legacy
   42     "-Dprotobuf_DIR:PATH=${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}"
   43     "-Dprotobuf_MODULE_COMPATIBLE:BOOL=TRUE"
   44   )
   45   add_dependencies(examples-legacy libprotobuf protoc)
   46 
   47   #Build using the installed library.
   48   add_examples_build(examples-installed
   49     "-Dprotobuf_DIR:PATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}"
   50   )
   51 
   52   #Build using the installed library in legacy compatibility mode.
   53   add_examples_build(examples-installed-legacy
   54     "-Dprotobuf_DIR:PATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}"
   55     "-Dprotobuf_MODULE_COMPATIBLE:BOOL=TRUE"
   56   )
   57 endif()