RSS
 

CMake … Java … Pain …

22 Jan

I’ve been working quite fervently to get CMake working for a Java project I’ve taken on and have found that it has a couple of issues still. The first issue is an undefined CMAKE_Java_LINK_EXECUTABLE variable, which because Java doesn’t really do linking (JIT takes care of doing something that I haven’t looked into yet) we don’t really need, but CMake expects it to be there. By simply making it a mv string and setting up the classpath option (via INCLUDE_DIRECTORIES directives) correctly, we can compile our java project using CMake almost the same way we would expect to make a CXX project.

If anyone knows of the platform agnostic way to move files in CMake I’d love to know.

Unfortunately the following changes are required to some CMake 2.8 system files for this to work:

In /usr/share/cmake/Modules/CMakeJavaInformation.cmake:

IF(NOT ${CMAKE_Java_LINK_EXECUTABLE})
SET(CMAKE_Java_LINK_EXECUTABLE 
    "mv <OBJECTS> <TARGET>")
ENDIF(NOT ${CMAKE_Java_LINK_EXECUTABLE})

In /usr/share/cmake/Modules/CMakeJavaCompiler.cmake.in:

SET(CMAKE_Java_LINK_EXECUTABLE "@CMAKE_Java_LINK_EXECUTABLE@")
 

Tags: , ,

  1. Stephen Williams

    2010/05/27 at 5:40 PM

    cmake -E rename or cmake -E copy or cmake -E copy_if_different.

    Any pointers on converting from Ant-based to Cmake?

     
    • Alex Brandt

      2010/05/27 at 6:23 PM

      Unfortunately, I don’t have any pointers on that style of migration. I was looking at using cmake because it was system I understood coming from the C side of things. Being forced to work with Java was a part of one of the projects I was working on and just made me realize that I didn’t understand Java’s build types at all even after trying to forget about linking and objects.