MantisBT - CMake
View Issue Details
0006960CMakeCMakepublic2008-05-05 17:392016-06-10 14:30
Mike Mattie 
Bill Hoffman 
normalmajoralways
closedmoved 
CMake-2-6 
 
0006960: Cmake 2.4.8 No way to specify Main-Class in manifest when creating jar files (ADD_EXECUTABLE with java support?)
While using CMake (2.4.8) on darwin (10.4 ppc)

There is no way I could discover in the man page to specify the entry point
for a jar file.

ADD_EXECUTABLE: does not work with java,

ADD_LIBRARY: creates a jar file, no way to specify the value of Main-Class or
a manifest file to be supplied to the jar command.
No tags attached.
Issue History
2008-05-05 17:39Mike MattieNew Issue
2008-09-25 17:03Bill HoffmanStatusnew => assigned
2008-09-25 17:03Bill HoffmanAssigned To => Bill Hoffman
2010-07-28 10:00Denis ScherbakovNote Added: 0021510
2010-07-28 11:04Denis ScherbakovNote Added: 0021512
2016-06-10 14:27Kitware RobotNote Added: 0041424
2016-06-10 14:27Kitware RobotStatusassigned => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0021510)
Denis Scherbakov   
2010-07-28 10:00   
I am using 2.6.4 and the problem is still there. (not sure about 2.8) What we need is just to be able to specify an entry point.

- CMAKE_Java_CREATE_STATIC_LIBRARY: <CMAKE_Java_ARCHIVE> -cf <TARGET> -C <OBJECT_DIR> ${class_files_mask}
+ CMAKE_Java_CREATE_STATIC_LIBRARY: <CMAKE_Java_ARCHIVE> -cfe <TARGET> org.my.special.java.class.MyEntryPoint -C <OBJECT_DIR> ${class_files_mask}

Example:
/usr/bin/jar -cfe myprog.jar org.my.special.java.class.MyEntryPoint -C CMakeFiles/myprog.dir .
(0021512)
Denis Scherbakov   
2010-07-28 11:04   
Or alternatively, we could use ADD_LIBRARY and then ADD_CUSTOM_COMMAND to update JAR:

MACRO(MACRO_MAKE_JAR_EXECUTABLE VAR_TARGET VAR_ENTRY)
  GET_TARGET_PROPERTY(VAR_LOCATION "${VAR_TARGET}" LOCATION)
  ADD_CUSTOM_COMMAND(TARGET ${VAR_TARGET} POST_BUILD COMMAND ${CMAKE_Java_ARCHIVE} ufe ${VAR_LOCATION} ${VAR_ENTRY} COMMENT "Creating JAR entry point.")
  UNSET(VAR_LOCATION)
ENDMACRO()

SET (MY_ENTRY "path.to.my.Main")

ADD_LIBRARY(MyJavaLibrary ${MY_SRCS})
MACRO_MAKE_JAR_EXECUTABLE(MyJavaLibrary "${MY_ENTRY}")
(0041424)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.