How to pass multiple classpaths (multiple jars) to kotlinc compile

We are using CMake build system for our builds.

I want to pass multiple jars for -classpath (-cp) parameter for kotlinc compiler. Something like bellow

kotlinc A.kt B.kt C.kt -cp “PathToJar1;PathToJar2;PathToJar3” -d sample.jar

When I am doing like above for PathToJar2 and next it says,

error: source entry is not a Kotlin file: PathToJar2
error: source entry is not a Kotlin file: PathToJar3

Any help wpould be greatly appreciated.

It’s not clear from the Compiler options page of the language docs, but the output from kotlinc -h on my machine starts with:

Usage: kotlinc-jvm <options> <source files>

In other words, the options come before the source files. (This ordering restriction is fairly common for command-line programs.)

So the first thing I’d try is rearranging your command to put the -cp […] before the source files.