[CMake] escape the dollar sign
Vikas Kumar
vikasnkumar at users.sourceforge.net
Tue Jun 6 16:22:50 EDT 2006
Hi, Below is the cmake file I use. main.java is the main java file.
Foo.java is a class Foo that has a nested static object inside it
called Bar. So when Java compiles Foo, it will generate a
Foo$Bar.class.
What i really want to do is a "make clean". Now when i do that, all
the *.class except for the Foo$Bar.class get cleaned up. This is
because the Cmakelists.txt does not know about the existence of
Foo$Bar.class. I tried to add it explicitly to the variable
CLEAN_CLASSES, but that did not work.
I must say that the ADD_CUSTOM_TARGET is great. I have compiled C# and
JAva apps using that on both Linux and Windows.
I hope the formatting looks ok, in the file below.
I have also written a small Foo.java for you.
################START of CMakeLists.txt #######################
PROJECT(JavaBuffon)
INCLUDE(${FPVM_SOURCE_DIR}/CModules/Java.cmake)
SET (JAVAC javac)
SET (JAVAR jar)
SET (PROJ JavaTest)
SET (PROJ_SRC_DIR ${JavaTest_SOURCE_DIR})
SET (USER_OUTPUT_DIR "/home/johnsmith/")
SET (JAVA_NAMES
Foo
main
)
SET (JAVA_FILES "")
SET (CLEAN_CLASSES "")
FOREACH (JAVA_NAME ${JAVA_NAMES})
SET (JAVA_FILES ${JAVA_FILES} ${PROJ_SRC_DIR}/${JAVA_NAME}.java)
SET (CLEAN_CLASSES ${CLEAN_CLASSES}
${USER_OUTPUT_DIR}/java/${PROJ}/${JAVA_NAME}.class )
ENDFOREACH(JAVA_NAME)
MAKE_DIRECTORY(${USER_OUTPUT_DIR}/java/${PROJ})
ADD_CUSTOM_TARGET(
${PROJ}.jar ALL
${JAVAC} -d ${USER_OUTPUT_DIR}/java/${PROJ} -classpath
"${PROJ_SRC_DIR}${JPATH_SEP}${JNI_SOURCE_DIR}"
${PROJ_SRC_DIR}/main.java
COMMAND ${JAVAC} -d ${USER_OUTPUT_DIR}/java/${PROJ}
-classpath "${PROJ_SRC_DIR}${JPATH_SEP}${JNI_SOURCE_DIR}"
${PROJ_SRC_DIR}/Buffon.java
COMMAND ${JAVAR} cvf ${USER_OUTPUT_DIR}/${PROJ}.jar -C
${USER_OUTPUT_DIR}/java/${PROJ} .
DEPENDS ${JAVA_FILES}
)
SET (CLEAN_CLASSES ${CLEAN_CLASSES} ${USER_OUTPUT_DIR}/${PROJ}.jar )
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
"${CLEAN_CLASSES}" )
################END of CMakeLists.txt ############################
// Foo.java begins here
public class Foo {
int a;
static class Bar {
double b;
}
Foo() {}
}
// Foo.java ends here
On 6/6/06, William A. Hoffman <billlist at nycap.rr.com> wrote:
> At 01:08 PM 6/6/2006, Vikas Kumar wrote:
> >I tried that. It did not work
> >I even tried "Foo\$Bar.class" that also did not work.
> >It took it as "Fooar.class" since $B has no value.
> Can you post your cmakelist file?
>
> -Bill
>
>
More information about the CMake
mailing list