CMake: Update Java support
* Add define SWIGWORDSIZE64 on Linux * Add -doxygen option
This commit is contained in:
@@ -9,6 +9,14 @@ endif()
|
||||
find_package(SWIG REQUIRED)
|
||||
include(UseSWIG)
|
||||
|
||||
if(${SWIG_VERSION} VERSION_GREATER_EQUAL 4)
|
||||
list(APPEND CMAKE_SWIG_FLAGS "-doxygen")
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
list(APPEND CMAKE_SWIG_FLAGS "-DSWIGWORDSIZE64")
|
||||
endif()
|
||||
|
||||
# Generate Protobuf java sources
|
||||
set(PROTO_JAVAS)
|
||||
file(GLOB_RECURSE proto_java_files RELATIVE ${PROJECT_SOURCE_DIR}
|
||||
@@ -28,7 +36,7 @@ foreach(PROTO_FILE ${proto_java_files})
|
||||
OUTPUT ${PROTO_JAVA}
|
||||
COMMAND protobuf::protoc
|
||||
"--proto_path=${PROJECT_SOURCE_DIR}"
|
||||
"--java_out=${PROJECT_BINARY_DIR}/java"
|
||||
"--java_out=${PROJECT_BINARY_DIR}/java/com/google/"
|
||||
${PROTO_FILE}
|
||||
DEPENDS ${PROTO_FILE} protobuf::protoc
|
||||
COMMENT "Running C++ protocol buffer compiler on ${PROTO_FILE}"
|
||||
@@ -46,9 +54,9 @@ find_package(JNI REQUIRED)
|
||||
set(FLAGS -DUSE_BOP -DUSE_GLOP -DABSL_MUST_USE_RESULT)
|
||||
if(USE_COINOR)
|
||||
list(APPEND FLAGS
|
||||
"-DUSE_CBC"
|
||||
"-DUSE_CLP"
|
||||
)
|
||||
"-DUSE_CBC"
|
||||
"-DUSE_CLP"
|
||||
)
|
||||
endif()
|
||||
list(APPEND CMAKE_SWIG_FLAGS ${FLAGS} "-I${PROJECT_SOURCE_DIR}")
|
||||
|
||||
@@ -56,11 +64,22 @@ foreach(SUBPROJECT constraint_solver linear_solver sat graph algorithms data)
|
||||
#add_subdirectory(ortools/${SUBPROJECT}/java)
|
||||
endforeach()
|
||||
|
||||
file(GENERATE
|
||||
OUTPUT java/pom.xml
|
||||
INPUT ortools/java/pom.xml.in)
|
||||
|
||||
|
||||
# Main Target
|
||||
add_custom_target(java_package ALL
|
||||
DEPENDS pom.xml
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory dist
|
||||
DEPENDS
|
||||
ortools::ortools
|
||||
Java${PROJECT_NAME}_proto
|
||||
java/pom.xml
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory com
|
||||
COMMAND ${Java_JAVAC_EXECUTABLE} pom.xml
|
||||
BYPRODUCTS
|
||||
java
|
||||
WORKING_DIRECTORY java
|
||||
)
|
||||
|
||||
# Test
|
||||
|
||||
22
ortools/java/pom.xml.in
Normal file
22
ortools/java/pom.xml.in
Normal file
@@ -0,0 +1,22 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.google.ortools</groupId>
|
||||
<artifactId>ortools-java</artifactId>
|
||||
<version>${PROJECT_VERSION}</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.google.protobuf</groupId>
|
||||
<artifactId>protobuf-java</artifactId>
|
||||
<version>3.11.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<directory>${project.basedir}</directory>
|
||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||
<sourceDirectory>${project.basedir}/ortools</sourceDirectory>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user