У меня очень простой Java-проект cmake
(1) CMakeLists.txt:
cmake_minimum_required (VERSION 2.8)
find_package(Java)
include(UseJava)
enable_testing()
project (HelloWorld)
set(CMAKE_JAVA_COMPILE_FLAGS "-source" "1.8" "-target" "1.8")
set(CMAKE_JAVA_MANIFEST MANIFEST.MF)
add_jar(HelloWorld HelloWorld.java)
get_target_property(_jarFile HelloWorld JAR_FILE)
get_target_property(_classDir HelloWorld CLASSDIR)
message(STATUS "Jar file ${_jarFile}")
message(STATUS "Class compiled to ${_classDir}")
(2) HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
(3) MANIFEST.MF
Manifest-Version: 1.0
Extension-Name: My
Implementation-Version: 1.1
Main-Class: HelloWorld
(4) cmake.&& make
-- Jar file /root/mynet/mytest/build/useCmake/forJava/HelloWorld.jar
-- Class compiled to /root/mynet/mytest/build/useCmake/forJava/CMakeFiles/HelloWorld.dir
-- Configuring done
-- Generating done
-- Build files have been written to: /root/mynet/mytest/build/useCmake/forJava
/usr/bin/cmake -H/root/mynet/mytest/build/useCmake/forJava -B/root/mynet/mytest/build/useCmake/forJava --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /root/mynet/mytest/build/useCmake/forJava/CMakeFiles /root/mynet/mytest/build/useCmake/forJava/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/root/mynet/mytest/build/useCmake/forJava'
make -f CMakeFiles/HelloWorld.dir/build.make CMakeFiles/HelloWorld.dir/depend
make[2]: Entering directory '/root/mynet/mytest/build/useCmake/forJava'
cd /root/mynet/mytest/build/useCmake/forJava && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /root/mynet/mytest/build/useCmake/forJava /root/mynet/mytest/build/useCmake/forJava /root/mynet/mytest/build/useCmake/forJava /root/mynet/mytest/build/useCmake/forJava /root/mynet/mytest/build/useCmake/forJava/CMakeFiles/HelloWorld.dir/DependInfo.cmake --color=
make[2]: Leaving directory '/root/mynet/mytest/build/useCmake/forJava'
make -f CMakeFiles/HelloWorld.dir/build.make CMakeFiles/HelloWorld.dir/build
make[2]: Entering directory '/root/mynet/mytest/build/useCmake/forJava'
make[2]: Nothing to be done for 'CMakeFiles/HelloWorld.dir/build'.
make[2]: Leaving directory '/root/mynet/mytest/build/useCmake/forJava'
[100%] Built target HelloWorld
make[1]: Leaving directory '/root/mynet/mytest/build/useCmake/forJava'
/usr/bin/cmake -E cmake_progress_start /root/mynet/mytest/build/useCmake/forJava/CMakeFiles 0
ОК, все выглядит хорошо, но
java -jar HelloWorld.jar
no main manifest attribute, in HelloWorld.jar
Я проверил META-INF / MANIFEST.MF в моей банке, это не мой МАНИФЕСТ:
jar tvf HelloWorld.jar
0 Tue Feb 19 03:56:08 GMT 2019 META-INF/
69 Tue Feb 19 03:56:08 GMT 2019 META-INF/MANIFEST.MF
427 Tue Feb 19 03:49:20 GMT 2019 HelloWorld.class
Он содержит только 2 строки:
Manifest-Version: 1.0
Created-By: 1.8.0_191 (Oracle Corporation)
Так что, похоже, мой файл манифеста не вступил в силу.Как это исправить?Большое спасибо