https://kotlinlang.org logo
Title
d

david.bilik

02/26/2018, 8:43 AM
hello, should task
generateCmake
generate CMakeList with all interop setup and used libraries? Because for me it does not
i

ilya.matveev

02/26/2018, 9:29 AM
What do you mean by "all interop setup and used libraries"? Could you please share your
build.gradle
and the CMake file generated from it?
d

david.bilik

02/26/2018, 9:32 AM
my
build.gradle
apply plugin: 'konan'

buildscript {
	repositories {
		maven {
        	url "<https://dl.bintray.com/jetbrains/kotlin-native-dependencies>"
        }
	}
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:+"
    }
}

konan.targets = ['iphone_sim']

konanArtifacts {

    def productsDir = new File("../ios/Frameworks")
    println(productsDir)

    interop("libs") {
        defFile "src/main/c_interop/libs.def"

        compilerOpts "-F${productsDir}"
        linkerOpts "-F${productsDir}"

        includeDirs new File(".").getAbsolutePath()
    }


    framework('ComapLike', targets: ['iphone_sim']) {
        srcDir 'src/main/kotlin'

        enableMultiplatform true
        enableDebug false

        linkerOpts "-F${productsDir}"


        libraries {
            artifact "libs"
        }

    }


}

dependencies {
    expectedBy project(':common')
}
and generated CMakeList
cmake_minimum_required(VERSION 3.8)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/KotlinCMakeModule)

project(common-ios Kotlin)
If I import this to CLion, I cant see the classes from my libs.def definition (which contains some ios frameworks)
o

olonho

02/26/2018, 9:48 AM
Generally, we suggest to use Gradle as the build system, and
generateCmake
is a workaround for lacking Gradle support in CLion. It is being fixed, and so for now we'd suggest to not use this workaround and just call Gradle from XCode.
d

david.bilik

02/26/2018, 9:50 AM
I dont want to use cmake for build but just use clion as IDE, proper autocomplete etc. Its not possible?
o

olonho

02/26/2018, 11:21 AM
Guess you could do that without fully functional CMake export, don't you?
d

david.bilik

02/26/2018, 12:04 PM
I dont know how to use the built binary of my iOS framework inside clion. My guess is that I should use that
.klib
file and import it there
v

Vyacheslav Karpukhin [JB]

02/28/2018, 8:24 PM
Hi David, apologies for the delay with reply. Unfortunately, at the moment it's not possible to use CLion with Kotlin/Native, unless you fully describe all dependencies in CMake. We're working on improving that, but right now that's the only way. All available CMake functions are declared in the CMakeKotlinInformation.cmake. It's not documented, but there are project templates that you can use as a reference. For instance, CurlHTTP is a good example of how you can use an external dependency. To add an existing native binary as a dependency you need to declare it with a
konanc_library
command, and then link it to the executable. If you have a .klib, then you can add it to your CMake project using a
klib
command. I hope that helps. Please let me know, if you have any other questions.