-
Notifications
You must be signed in to change notification settings - Fork 35
/
CMakeLists.txt
133 lines (119 loc) · 4.43 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#@file CMakeLists.txt
#@brief CMake file for Java interface for the SCIP Optimization Suite
#@author Robert Gottwald, Benjamin Mueller
cmake_minimum_required (VERSION 3.3)
project (JSCIPOpt)
# per default compile a release version
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release")
endif()
#
# find JNI and java
#
find_package (JNI REQUIRED JVM)
find_package (Java REQUIRED)
include (UseJava)
#
# list of all java sources
#
set(SWIG_JAVA_SOURCES
${PROJECT_SOURCE_DIR}/java/jscip/ObjMessagehdlr.java
${PROJECT_SOURCE_DIR}/java/jscip/SCIPJNI.java
${PROJECT_SOURCE_DIR}/java/jscip/SCIPJNIJNI.java
${PROJECT_SOURCE_DIR}/java/jscip/SCIP_Retcode.java
${PROJECT_SOURCE_DIR}/java/jscip/SCIP_Vartype.java
${PROJECT_SOURCE_DIR}/java/jscip/SCIP_ParamEmphasis.java
${PROJECT_SOURCE_DIR}/java/jscip/SCIP_Objsense.java
${PROJECT_SOURCE_DIR}/java/jscip/SCIP_VerbLevel.java
${PROJECT_SOURCE_DIR}/java/jscip/SCIP_Status.java
${PROJECT_SOURCE_DIR}/java/jscip/SCIP_Stage.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_char.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_double.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_int.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_long_long.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_unsigned_int.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_FILE.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_p_char.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_p_SCIP.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_p_SCIP_SOL.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_p_SCIP_VAR.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_SCIP_CONS.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_SCIP.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_SCIP_SOL.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_SCIP_VAR.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_SCIP_HEUR.java
${PROJECT_SOURCE_DIR}/java/jscip/SWIGTYPE_p_SCIP_Messagehdlr.java
)
set(JAVA_SOURCES
${SWIG_JAVA_SOURCES}
${PROJECT_SOURCE_DIR}/java/jscip/Constraint.java
${PROJECT_SOURCE_DIR}/java/jscip/Scip.java
${PROJECT_SOURCE_DIR}/java/jscip/Variable.java
${PROJECT_SOURCE_DIR}/java/jscip/Constraint.java
${PROJECT_SOURCE_DIR}/java/jscip/Solution.java
${PROJECT_SOURCE_DIR}/java/jscip/MessageHandler.java
)
#
# find SWIG
#
find_package (SWIG)
if (SWIG_FOUND)
add_custom_command(OUTPUT ${PROJECT_SOURCE_DIR}/src/scipjni_wrap.cxx ${SWIG_JAVA_SOURCES}
COMMAND ${SWIG_EXECUTABLE} -package jscip -c++ -java -outdir ${PROJECT_SOURCE_DIR}/java/jscip/ ${PROJECT_SOURCE_DIR}/src/scipjni.i
DEPENDS ${PROJECT_SOURCE_DIR}/src/scipjni.i)
endif()
#
# find SCIP library and add include directories
#
if (SCIP_DIR)
# The user explicitly passed a SCIP_DIR, so only look there and not in some
# random other path that may contain a binary-incompatible version.
find_package(SCIP REQUIRED CONFIG NO_DEFAULT_PATH PATHS ${SCIP_DIR})
else()
find_package(SCIP REQUIRED CONFIG)
endif()
# Check the minimum SCIP version here. We cannot just pass it to find_package
# because that will accept only the same major version. See #52 and scip#116.
set (SCIP_MINIMUM_VERSION "8.0.0")
if (SCIP_VERSION VERSION_LESS SCIP_MINIMUM_VERSION)
message(FATAL_ERROR "SCIP too old. Found SCIP version ${SCIP_VERSION}, but at least SCIP ${SCIP_MINIMUM_VERSION} is required.")
endif()
include_directories (${JNI_INCLUDE_DIRS} ${SCIP_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/src)
#
# check whether SCIP is a static library (in which case it is safe to use macros)
#
get_target_property(LIBSCIP_TARGET_TYPE libscip TYPE)
message("libscip is a ${LIBSCIP_TARGET_TYPE}.")
if (LIBSCIP_TARGET_TYPE STREQUAL STATIC_LIBRARY)
add_definitions(-DHAVE_STATIC_LIBSCIP=1)
endif()
#
# link directories
#
link_directories (${PROJECT_SOURCE_DIR}/lib)
#
# build JSCIPOpt library
#
add_library (jscip SHARED ${PROJECT_SOURCE_DIR}/src/scipjni_wrap.cxx)
set_target_properties(jscip PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${CMAKE_BUILD_TYPE})
#
# add dependencies of other libraries
#
target_link_libraries (jscip ${SCIP_LIBRARIES})
#
# generate jar
#
add_jar (scipjar
SOURCES ${JAVA_SOURCES}
OUTPUT_NAME scip
OUTPUT_DIR ${PROJECT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
)
#
# generate jar containing all examples
#
FILE (GLOB example_sources ${PROJECT_SOURCE_DIR}/examples/*.java)
add_jar (examples
SOURCES ${example_sources}
INCLUDE_JARS scipjar
OUTPUT_DIR ${PROJECT_BINARY_DIR}/${CMAKE_BUILD_TYPE}
)