CodeQL needs to know how to process each compilation unit you want to analyze, in order to get things like include paths, macros from the compiler command-line, C/C++ dialect and language version, and data model right. Because of this, there's no direct way of importing a project you can't build; interpreting arbitrary partial C/C++ source code accurately is just not possible.
Depending on your exact situation, you may be able to work around in various ways. For example, you could write a bash script that invokes gcc
or clang
on all the source files you care about, with your best-guess of options that should be passed, and suppressing the error exit code with || true
or similar after each command. If you then give this script as the "build command" for CodeQL, it will follow your lead and interpret the code as your compiler invocations would. Even if you get compilation errors, you'll still get a (partial) CodeQL database which you can use.