// Top-level build file where you can add configuration options common to all sub-projects/modules.

import static java.nio.file.Files.*
import static java.nio.file.Paths.get
import static java.util.stream.Collectors.toSet

plugins {
    id "org.jetbrains.kotlin.platform.native" version "1.3.11"
}

allprojects {
    repositories {
        mavenCentral()
    }
}

components.main {

    // Set up targets
    targets = ['linux_x64']

    // Set up output kinds
    outputKinds = [EXECUTABLE]

    // Specify custom entry point for executables
    entryPoint = "hello.MainKt.main"

    // Target-specific options
    target('linux_x64') {
//        linkerOpts '-L/usr/lib/x86_64-linux-gnu -lglfw -lGL'
    }

    // Targets independent options
//    allTargets {
//        linkerOpts '-L/common/lib/path'
//    }

    dependencies {
        cinterop('glfw') {
            // Def-file describing the native API.
            // The default path is src/main/c_interop/<interop-name>.def
//            defFile project.file("glfw.def")

            // Package to place the Kotlin API generated.
            packageName 'org.glfw'

            // Options to be passed to compiler and linker by cinterop tool.
            compilerOpts '-I/usr/include'
//            linkerOpts '-L/usr/lib/x86_64-linux-gnu -lglfw -lGL'

            // Additional headers to parse.
//            headers project.files('GLFW/glfw3.h', 'GLFW/glfw3native.h')

            // Directories to look for headers.
            includeDirs {
                // All objects accepted by the Project.file method may be used with both options.

                // Directories for header search (an analogue of the -I<path> compiler option).
                allHeaders 'GLFW/glfw3.h', 'GLFW/glfw3native.h'
//
//                // Additional directories to search headers listed in the 'headerFilter' def-file option.
//                // -headerFilterAdditionalSearchPrefix command line option analogue.
//                headerFilterOnly 'path1', 'path2'
            }
            // A shortcut for includeDirs.allHeaders.
//            includeDirs "include/directory" "another/directory"

            // Pass additional command line options to the cinterop tool.
//            extraOpts '-shims', 'true'

            // Additional configuration for Linux.
//            target('linux') {
//                compilerOpts 'Linux-specific options'
//            }
        }
    }
}