据我了解,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
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found Java: /usr/bin/java (found version "1.7.0.25")
CMake Error at CMakeLists.txt:8 (add_jar):
Unknown CMake command "add_jar".
-- Configuring incomplete, errors occurred!
Run Code Online (Sandbox Code Playgroud)
我在这里缺少什么?
UseJava您还必须包含该模块。
find_package(Java)
include(UseJava)
add_jar(hello ${source})
Run Code Online (Sandbox Code Playgroud)
该find_package调用仅确定 Java 在磁盘上的安装位置,而该UseJava模块提供了使用 Java 的功能(如add_jar)。正如文档所述,前者是加载后者的先决条件。
| 归档时间: |
|
| 查看次数: |
3500 次 |
| 最近记录: |