Finding libraries

os.findlib has several missing capabilities:
* It doesn't allow to specify additional paths where to search for library
* It doesn't allow to specify alternative paths (instead of system ones) where to search for library
* It doesn't search for static libraries
* It doesn't search for Mac OS X frameworks

Let's see what CMake provides:

find_library(
                           <VAR>
                           name | NAMES name1 [name2 ...]
                           [HINTS path1 [path2 ... ENV var]]
                           [PATHS path1 [path2 ... ENV var]]
                           [PATH_SUFFIXES suffix1 [suffix2 ...]]
                           [DOC "cache documentation string"]
                           [NO_DEFAULT_PATH]
                           [NO_CMAKE_ENVIRONMENT_PATH]
                           [NO_CMAKE_PATH]
                           [NO_SYSTEM_ENVIRONMENT_PATH]
                           [NO_CMAKE_SYSTEM_PATH]
                           [CMAKE_FIND_ROOT_PATH_BOTH |
                            ONLY_CMAKE_FIND_ROOT_PATH |
                            NO_CMAKE_FIND_ROOT_PATH]
                          )

where is return value, name is the name of library, paths in HINTS are checked before system paths and those in PATH are checked after.
There are additional variables CMAKE_LIBRARY_PATH, CMAKE_SYSTEM_LIBRARY_PATH, CMAKE_FRAMEWORK_PATH, CMAKE_SYSTEM_FRAMEWORK_PATH, which could be set up in CMake project file.

CMake's approach has overcomplicated syntax, however it allows to do these things (we only support "name" parameter). Any ideas how to improve os.findlib (additional arguments, other os.* functions, ...)?

BTW, CMake has its Achilles' heel: it does not allow to search only for static or only for shared libs, it search for both, shared before static, if specific file suffixes are not set for search.

Also, it desirable to be able to filter so version. For example, I'd like to link with OpenSSL 0.9.8 and skip OpenSSL 1.0.0 if it's found before 0.9.8.

Well, we could make it a little more readable with a table of named arguments:

findlib("mylibrary", {
   extraPaths = { ... },
   ignoreDefaultPath = true,
   ...
})

Though I'm not sure if that's really any cleaner.

Can we take settings table as last of varargs:

findlib("mylibrary", ..., {
   ignoreDefaultPath = true,
   ...
})

?
If last vararg is string append it to paths, otherwise read settings.