"Fossies" - the Fresh Open Source Software Archive

Member "apt-1.9.4/CMake/Misc.cmake" (19 Sep 2019, 3907 Bytes) of package /linux/misc/apt-1.9.4.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 include(CheckCXXCompilerFlag)
    2 
    3 # Flatten our header structure
    4 function(flatify target headers)
    5     foreach(header ${headers})
    6         get_filename_component(tgt ${header} NAME)
    7         configure_file(${header} ${target}/${tgt} COPYONLY)
    8     endforeach(header ${headers})
    9 endfunction()
   10 
   11 
   12 function(add_optional_compile_options flags)
   13     foreach(flag ${flags})
   14         check_cxx_compiler_flag(-${flag} have-compiler-flag:-${flag})
   15         if (have-compiler-flag:-${flag})
   16             add_compile_options("-${flag}")
   17         endif()
   18     endforeach()
   19 endfunction()
   20 
   21 # Substitute vendor references in a file
   22 function(add_vendor_file)
   23     set(options)
   24     set(oneValueArgs OUTPUT INPUT MODE)
   25     set(multiValueArgs VARIABLES)
   26     cmake_parse_arguments(AVF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
   27 
   28     set(in ${CMAKE_CURRENT_SOURCE_DIR}/${AVF_INPUT})
   29     set(out ${CMAKE_CURRENT_BINARY_DIR}/${AVF_OUTPUT})
   30 
   31     add_custom_command(
   32         OUTPUT ${out}
   33         COMMAND ${CMAKE_COMMAND} -DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
   34                                  "-DVARS=${AVF_VARIABLES}"
   35                                  -DCURRENT_VENDOR=${CURRENT_VENDOR}
   36                                  -DIN=${in}
   37                                  -DOUT=${out}
   38                                  -P ${PROJECT_SOURCE_DIR}/CMake/vendor_substitute.cmake
   39         COMMAND chmod ${AVF_MODE} ${out}
   40         DEPENDS ${in}
   41                 ${PROJECT_SOURCE_DIR}/doc/apt-verbatim.ent
   42                 ${PROJECT_SOURCE_DIR}/vendor/${CURRENT_VENDOR}/apt-vendor.ent
   43                 ${PROJECT_SOURCE_DIR}/vendor/getinfo
   44                 ${PROJECT_SOURCE_DIR}/CMake/vendor_substitute.cmake
   45         VERBATIM
   46     )
   47 
   48     # Would like to use ${AVF_OUTPUT} as target name, but then ninja gets
   49     # cycles.
   50     add_custom_target(vendor-${AVF_OUTPUT} ALL DEPENDS ${out})
   51 endfunction()
   52 
   53 # Add symbolic links to a file
   54 function(add_slaves destination master)
   55     set(slaves "")
   56     foreach(slave ${ARGN})
   57         add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${slave}
   58                            COMMAND ${CMAKE_COMMAND} -E create_symlink ${master} ${CMAKE_CURRENT_BINARY_DIR}/${slave})
   59         list(APPEND slaves ${CMAKE_CURRENT_BINARY_DIR}/${slave})
   60     endforeach()
   61 
   62     STRING(REPLACE "/" "-" master "${master}")
   63     add_custom_target(${master}-slaves ALL DEPENDS ${slaves})
   64     install(FILES ${slaves} DESTINATION ${destination})
   65 endfunction()
   66 
   67 # Generates a simple version script versioning everything with current SOVERSION
   68 function(add_version_script target)
   69     get_target_property(soversion ${target} SOVERSION)
   70     set(script "${CMAKE_CURRENT_BINARY_DIR}/${target}.versionscript")
   71     string(REPLACE "-" "" name "${target}_${soversion}")
   72     string(TOUPPER "${name}" name)
   73     add_custom_command(OUTPUT "${script}"
   74                        COMMAND echo "${name} {global: *; };" > "${script}"
   75                        VERBATIM )
   76     add_custom_target(${target}-versionscript DEPENDS "${script}")
   77     target_link_libraries(${target} PRIVATE -Wl,-version-script="${script}")
   78     add_dependencies(${target} ${target}-versionscript)
   79 endfunction()
   80 
   81 function(path_join out path1 path2)
   82     string(SUBSTRING ${path2} 0 1 init_char)
   83     if ("${init_char}" STREQUAL "/")
   84         set(${out} "${path2}" PARENT_SCOPE)
   85     else()
   86         set(${out} "${path1}/${path2}" PARENT_SCOPE)
   87     endif()
   88 endfunction()
   89 
   90 # install_empty_directories(path ...)
   91 #
   92 # Creates empty directories in the install destination dir. Paths may be
   93 # absolute or relative; in the latter case, the value of CMAKE_INSTALL_PREFIX
   94 # is prepended.
   95 function(install_empty_directories)
   96     foreach(path ${ARGN})
   97         path_join(full_path "${CMAKE_INSTALL_PREFIX}" "${path}")
   98         INSTALL(CODE "MESSAGE(STATUS \"Creating directory: \$ENV{DESTDIR}${full_path}\")"
   99                 CODE "FILE(MAKE_DIRECTORY \$ENV{DESTDIR}${full_path})")
  100     endforeach()
  101 endfunction()