functions.include 1.77 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

################################################################################
# functions collecting all headers in the directory
################################################################################

# getFilesFromDir( directory, pattern )
# returns a list of all files matching pattern in directory
defineReplace(getFilesFromDir) {
	dirs       = $$1
  	pattern = $$2

	files =

	for(dir, dirs) {
		found = $$files( $${dir}/$${pattern} ) 
        	 files += $$found
         }

     return( $$files )
}

# addSubdirs(subdirs,deps): Adds directories to the project that depend on
# other directories
defineTest( addSubdirs ) {
    for(subdirs, 1) {
        entries = $$files($$subdirs)
        for(entry, entries) {
            name = $$replace(entry, [/\\\\], _)
            name = $$replace(name, - , _)
            SUBDIRS += $$name
            eval ($${name}.subdir = $$entry)
            for(dep, 2): {
			tempval = $$replace(dep, [/\\\\], _)
			eval ($${name}.depends += $$replace(tempval, - , _) )
		}
            export ($${name}.subdir)
            export ($${name}.depends)
        }
    }
    export (SUBDIRS)
}

# given a list of paths and a libname this function checks if the lib is there
# adds the path and returns true if found otherwise false
defineTest( addLib ) {
    dirs = $$1
    name = $$2

    # check for the library
    for(dir , dirs) {
        check = $${dir}/lib$${name}.so

        # Found, so use it
	      exists( $$check ) {
           LIBS *= -L$${dir} -l$$name
      	   export(LIBS)
           return(true)
        }
    }

    return(false)
}


defineReplace( getCurrentDir ) {
	DIR = ''
	unix {
		DIR = $$system( pwd )
	}

	win32 {
		DIR = $$system( cd )
	}

	return( $$DIR )    
}