据我了解,cmake从2.8.6版本开始支持java。我找到了命令 add_jar 但我似乎无法让它工作。我的 CMakeLists.txt 如下所示:
cmake_minimum_required(VERSION 2.8.10)
find_package(Java)
FILE(GLOB source
"${CMAKE_CURRENT_SOURCE_DIR}/*.java"
)
add_jar(hello ${source})
Run Code Online (Sandbox Code Playgroud)
当我运行 cmake 时,我得到这个:
-- The C compiler identification is GNU 4.7.3
-- The CXX compiler identification is GNU 4.7.3
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- …Run Code Online (Sandbox Code Playgroud)