Project Scaffolding
The kreate-jni-initialize task creates the native C++ project structure on first run. It is registered automatically when JNI is enabled and runs as a dependency of kreate-jni-build.
What Gets Generated
Given a project named example, Kreate creates the following structure under the configured projectDirectory:
All files are only written if they do not already exist. Running the task on an existing project is safe and idempotent.
Generated CMakeLists.txt
Key properties of the generated configuration:
C++17 standard enforced (
CMAKE_CXX_STANDARD 17)Position-independent code enabled (
-fPIC) for shared library compatibilityJNI headers located and linked automatically via
find_package(JNI REQUIRED)All
.cppand.ccfiles undersrc/are included viafile(GLOB ...)An optional
include/directory is pre-wired for custom headers
Generated Placeholder Source
This file ensures CMake has at least one translation unit to compile on the first build invocation. Replace its content with your actual JNI function implementations.
Running the Task Manually
Customizing the CMake Configuration
After the initial scaffold, CMakeLists.txt is yours to modify freely. Kreate never overwrites an existing CMakeLists.txt, so any changes you make are preserved across builds.
Common customizations include:
Adding subdirectories with
add_subdirectory()Linking additional system or third-party libraries with
target_link_libraries()Adding compile definitions with
target_compile_definitions()Including additional header search paths with
target_include_directories()