📥Installation

There are a few ways you can import CMakeKt into your project.

Prerequisites

Kotlin/Native command line tools must be available on your PATH. The link specified can show you how to set it up. Specifically, the cinteropand run_konancommands must be available.

If you're building on GitHub Actions, you can use actions like fwile2/setup-kotlin to install them for you:

- uses: fwilhe2/setup-kotlin@main
  with:
    version: 2.1.20
    install-native: true

Once you use one of the installation methods below, you can include the file into your CMakeLists.txt:

include(CMakeKt)
add_klib_binary(my_target)

Copy CMakeKt.cmake to your project

The CMakeKt.cmake file is available on GitHub. You can copy the contents into your own CMakeKt.cmakefile.

Use as a Git Submodule

You can also clone the repository and use it in a Git Submodule.

# Clone Repository
git submodule add https://github.com/gmitch215/cmakekt cmake/CMakeKt

You can use the FetchContent module to use CMakeKt.

include(FetchContent)
FetchContent_Declare(
    cmakekt
    GIT_REPOSITORY https://github.com/gmitch215/cmakekt.git
    GIT_TAG        master
)
FetchContent_MakeAvailable(cmakekt)
include(CMakeKt)
add_klib_binary(my_target)

If you need to use sudo for the installation process, you need to create a symlink to the tools in the sudo lookup path.

# Assuming KOTLIN_NATIVE_HOME goes to a valid Kotlin/Native installation directory
sudo ln -s $KOTLIN_NATIVE_HOME/bin/cinterop /usr/local/bin/cinterop
sudo ln -s $KOTLIN_NATIVE_HOME/bin/run_konan /usr/local/bin/run_konan

Last updated