cmake_minimum_required(VERSION 3.10) project(jlilv VERSION 1.0.0 DESCRIPTION "Java Bindings for Lilv" LANGUAGES C) #set(CMAKE_CXX_STANDARD 17) #set(CMAKE_CXX_STANDARD_REQUIRED ON) #set(CMAKE_CXX_EXTENSIONS OFF) include(GNUInstallDirs) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) # jvm find_package(Java REQUIRED) # https://stackoverflow.com/questions/51047978/cmake-could-not-find-jni set(JAVA_AWT_LIBRARY NotNeeded) set(JAVA_JVM_LIBRARY NotNeeded) find_package(JNI REQUIRED) include(FindPkgConfig) if(NOT PKG_CONFIG_FOUND) message(FATAL_ERROR "pkg-config not found!" ) endif() include_directories(${JNI_INCLUDE_DIRS}) # force off-tree build if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) message(FATAL_ERROR "CMake generation is not allowed within the source directory! Remove the CMakeCache.txt file and try again from another folder, e.g.: mkdir build && cd build cmake .. ") endif() # default to Release build if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) endif() include_directories(build/generated/sources/headers/java/main/) add_library(jlilv SHARED src/main/c/Lilv.c) #target_link_libraries(jlilv ${LILV_LIBRARIES}) #target_include_directories(jlilv PUBLIC ${LILV_INCLUDE_DIRS}) #target_compile_options(jlilv PUBLIC ${LILV_CFLAGS_OTHER}) pkg_check_modules(lilv-0 REQUIRED IMPORTED_TARGET lilv-0) target_link_libraries(jlilv PkgConfig::lilv-0)