Warning, /sdk/kde-dev-scripts/cmake-utils/scripts/generate_findpackage_file is written in an unsupported language. File is not indexed.
0001 #!/usr/bin/env ruby 0002 0003 # simple script to generate simple cmake modules for finding libraries (packages) 0004 # Alexander Neundorf <neundorf@kde.org>, 2006 0005 # Laurent Montel <montel@kde.org>, 2008 0006 # usage: generate_findpackage_file 0007 # then you will be prompted to enter the required parameters 0008 0009 print("Name of package: ") 0010 package=gets.chomp 0011 0012 print("pkgconfig package name [e.g. \"libxml-2.0\", we can add check as \"glib-2.0>=2.10 gtk+-2.0\" leave empty to skip pkgconfig]: ") 0013 pkgconfig=gets.chomp 0014 0015 print("Look for header (e.g. \"jpeglib.h\" or \"libxml/xpath.h\"): ") 0016 header=gets.chomp 0017 0018 print("Include subdir (e.g. \"libxml2\", empty to skip ): ") 0019 incSubDir=gets.chomp 0020 0021 print("Look for library (e.g. \"jpeg\" or \"xml2\"): ") 0022 lib=gets.chomp 0023 0024 cmakeIncDirName=package.upcase+"_INCLUDE_DIR" 0025 cmakeLibName=package.upcase+"_LIBRARIES" 0026 cmakeDefsName=package.upcase+"_DEFINITIONS" 0027 cmakeFoundName=package.upcase+"_FOUND" 0028 cmakeQuietName=package+"_FIND_QUIETLY" 0029 cmakeRequiredName=package+"_FIND_REQUIRED" 0030 cmakeFlagsName=package.upcase+"_CFLAGS" 0031 cmakeLibDirName=package.upcase+"_LIBRARY_DIRS" 0032 cmakeIncludeDirName=package.upcase+"_INCLUDE_DIRS" 0033 0034 file=File.new("Find#{package}.cmake", "w+") 0035 0036 0037 file.printf("# - Try to find #{package}\n") 0038 file.printf("# Once done this will define\n") 0039 file.printf("#\n") 0040 file.printf("# #{cmakeFoundName} - system has #{package}\n") 0041 file.printf("# #{cmakeIncDirName} - the #{package} include directory\n") 0042 file.printf("# #{cmakeLibName} - Link these to use #{package}\n") 0043 file.printf("# #{cmakeDefsName} - Compiler switches required for using #{package}\n") 0044 file.printf("# Redistribution and use is allowed according to the terms of the BSD license.\n") 0045 file.printf("# For details see the accompanying COPYING-CMAKE-SCRIPTS file.\n") 0046 file.printf("#\n\n\n") 0047 0048 file.printf("if ( #{cmakeIncDirName} AND #{cmakeLibName} )\n") 0049 file.printf(" # in cache already\n") 0050 file.printf(" SET(#{package}_FIND_QUIETLY TRUE)\n") 0051 file.printf("endif ( #{cmakeIncDirName} AND #{cmakeLibName} )\n\n") 0052 0053 if not pkgconfig.empty? 0054 file.printf("# use pkg-config to get the directories and then use these values\n") 0055 file.printf("# in the FIND_PATH() and FIND_LIBRARY() calls\n") 0056 file.printf("if( NOT WIN32 )\n") 0057 file.printf(" find_package(PkgConfig)\n\n") 0058 file.printf(" pkg_check_modules(#{package.upcase} #{pkgconfig})\n\n") 0059 file.printf(" set(#{cmakeDefsName} ${#{cmakeFlagsName}})\n") 0060 file.printf("endif( NOT WIN32 )\n\n") 0061 end 0062 0063 if not header.empty? 0064 file.printf("FIND_PATH(#{cmakeIncDirName} NAMES #{header}\n") 0065 if not pkgconfig.empty? 0066 file.printf(" PATHS\n") 0067 file.printf(" ${#{cmakeIncludeDirName}}\n") 0068 end 0069 0070 if not incSubDir.empty? 0071 file.printf(" PATH_SUFFIXES #{incSubDir}\n") 0072 end 0073 file.printf(")\n\n") 0074 end 0075 0076 if not lib.empty? 0077 file.printf("FIND_LIBRARY(#{cmakeLibName} NAMES #{lib}\n") 0078 if not pkgconfig.empty? 0079 file.printf(" PATHS\n") 0080 file.printf(" ${#{cmakeLibDirName}}\n") 0081 end 0082 file.printf(")\n\n") 0083 end 0084 0085 file.printf("include(FindPackageHandleStandardArgs)\n") 0086 file.printf("FIND_PACKAGE_HANDLE_STANDARD_ARGS(#{package} DEFAULT_MSG #{cmakeIncDirName} #{cmakeLibName} )\n\n") 0087 0088 file.printf("# show the #{cmakeIncDirName} and #{cmakeLibName} variables only in the advanced view\n") 0089 file.printf("MARK_AS_ADVANCED(#{cmakeIncDirName} #{cmakeLibName} )\n\n") 0090 0091 0092 printf("Done, generated Find#{package}.cmake\n")