2.0 KiB
2.0 KiB
| Linux | macOS | Windows |
|---|---|---|
Introduction
Build the Binary Package
To build the java package, simply run:
cmake -S. -Bbuild -DBUILD_JAVA=ON
cmake --build build
cmake --build build --target java_package
Build directory layout
Since Java use the directory layout and we want to use the CMAKE_BINARY_DIR to generate the Java binary package.
We want this layout (tree build --prune -U -P "*.java|*.so*" -I "build"):
build/java/com/google/ortools
Managing SWIG generated files
You can use CMAKE_SWIG_DIR to change the output directory for the .java file e.g.:
set(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_BINARY_DIR}/..)
And you can use CMAKE_LIBRARY_OUTPUT_DIRECTORY to change the output directory for the .so file e.g.:
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..)
[optional]You can use SWIG_OUTFILE_DIR to change the output directory for the .cxx file e.g.:
set(SWIG_OUTFILE_DIR ${CMAKE_CURRENT_BINARY_DIR}/..)
Then you only need to create a pom.xml file in build/java to be able to use
the build directory to generate the Java package.
Testing Java
TODO