-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
188 lines (169 loc) · 5.61 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
cmake_minimum_required(VERSION 2.13)
project(jgrapht)
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/etc/cmake")
find_package(Java 11)
find_package(JNI)
find_program(NativeImage NAMES native-image native-image.cmd REQUIRED)
find_package(Maven REQUIRED)
message(STATUS "native-image found at ${NativeImage}")
include(GNUInstallDirs)
SET(JGRAPHT_LIBRARY "${CMAKE_SHARED_LIBRARY_PREFIX}jgrapht_capi${CMAKE_SHARED_LIBRARY_SUFFIX}")
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/target/jgrapht-capi-0.1.jar
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/jgrapht-capi/pom.xml ${CMAKE_BINARY_DIR}/
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/jgrapht-capi/src ${CMAKE_BINARY_DIR}/src
COMMAND mvn -B -f ${CMAKE_BINARY_DIR} package
COMMENT "Building jar file with C native scopes"
)
add_custom_target(
build-jar
DEPENDS ${CMAKE_BINARY_DIR}/target/jgrapht-capi-0.1.jar
)
add_custom_command(
OUTPUT ${JGRAPHT_LIBRARY} jgrapht_capi.h jgrapht_capi_dynamic.h graal_isolate.h graal_isolate_dynamic.h
COMMAND native-image -cp ${CMAKE_BINARY_DIR}/target/jgrapht-capi-0.1.jar --no-fallback --initialize-at-build-time --no-server --shared
COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_BINARY_DIR}/jgrapht_capi${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/${JGRAPHT_LIBRARY}
DEPENDS build-jar
COMMENT "Producing shared library from jar file"
)
if(APPLE)
add_custom_command(
OUTPUT ${JGRAPHT_LIBRARY} APPEND
COMMAND install_name_tool -id "@rpath/${JGRAPHT_LIBRARY}" ${CMAKE_BINARY_DIR}/${JGRAPHT_LIBRARY}
)
endif(APPLE)
add_custom_target(
build-jgrapht-sharedlib
DEPENDS ${JGRAPHT_LIBRARY}
)
set_property(SOURCE ${CMAKE_BINARY_DIR}/jgrapht-capi/jgrapht_capi.h PROPERTY GENERATED 1)
set_property(SOURCE ${CMAKE_BINARY_DIR}/jgrapht-capi/jgrapht_capi_dynamic.h PROPERTY GENERATED 1)
set_property(SOURCE ${CMAKE_BINARY_DIR}/jgrapht-capi/graal_isolate.h PROPERTY GENERATED 1)
set_property(SOURCE ${CMAKE_BINARY_DIR}/jgrapht-capi/graal_isolate_dynamic.h PROPERTY GENERATED 1)
set_property(SOURCE ${CMAKE_BINARY_DIR}/jgrapht-capi/${JGRAPHT_LIBRARY} PROPERTY GENERATED 1)
add_library(jgrapht_capi SHARED IMPORTED)
set_property(TARGET jgrapht_capi PROPERTY IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/${JGRAPHT_LIBRARY})
IF(WIN32)
set_property(TARGET jgrapht_capi PROPERTY IMPORTED_IMPLIB ${CMAKE_BINARY_DIR}/jgrapht_capi.lib)
ENDIF(WIN32)
add_dependencies(jgrapht_capi build-jgrapht-sharedlib)
install(
FILES
${CMAKE_BINARY_DIR}/jgrapht_capi.h
${CMAKE_BINARY_DIR}/jgrapht_capi_dynamic.h
${CMAKE_BINARY_DIR}/graal_isolate.h
${CMAKE_BINARY_DIR}/graal_isolate_dynamic.h
${CMAKE_SOURCE_DIR}/jgrapht-capi/src/main/native/jgrapht_capi_types.h
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/jgrapht_capi
)
install(
FILES
${CMAKE_BINARY_DIR}/${JGRAPHT_LIBRARY}
DESTINATION
${CMAKE_INSTALL_LIBDIR}
)
enable_testing()
include(CTest)
set(
TEST_SOURCES
"test_vertices.c"
"test_addvertex.c"
"test_edges.c"
"test_directed_graph.c"
"test_ll_directed_graph.c"
"test_undirected_graph.c"
"test_error.c"
"test_map.c"
"test_set.c"
"test_list.c"
"test_mst.c"
"test_vertexcover.c"
"test_clustering.c"
"test_coloring.c"
"test_views.c"
"test_graphtests.c"
"test_graphmetrics.c"
"test_partition.c"
"test_matching.c"
"test_generate.c"
"test_scoring.c"
"test_traverse.c"
"test_spanner.c"
"test_tour.c"
"test_shortestpaths.c"
"test_contraction_hierarchy.c"
"test_k_shortestpaths.c"
"test_clique.c"
"test_dimacs.c"
"test_gml.c"
"test_json.c"
"test_json2.c"
"test_lemon.c"
"test_flow.c"
"test_planar.c"
"test_gexf.c"
"test_graph6.c"
"test_sparse6.c"
"test_csv.c"
"test_graphml.c"
"test_graphml_simple.c"
"test_dot.c"
"test_mincut.c"
"test_iso.c"
"test_iso_subgraph.c"
"test_edgesupplier.c"
"test_mincostflow.c"
"test_eulerian.c"
"test_chinese_postman.c"
"test_fundamental_basis_paton.c"
"test_fundamental_basis_bfs.c"
"test_fundamental_basis_stack.c"
"test_simple_cycles_hawick_james.c"
"test_simple_cycles_tarjan.c"
"test_simple_cycles_tiernan.c"
"test_simple_cycles_szwarcfiter_lauer.c"
"test_simple_cycles_johnson.c"
"test_connectivity.c"
"test_sparse_graph.c"
"test_sparse_graph2.c"
"test_sparse_graph3.c"
"test_sparse_graph4.c"
"test_listenable.c"
"test_dag.c"
"test_graph_union.c"
"test_independent.c"
"test_multi_shortestpaths.c"
"test_json_edgelist.c"
"test_gexf_edgelist.c"
"test_csv_edgelist.c"
"test_gml_edgelist.c"
"test_graphml_simple_edgelist.c"
"test_graphml_edgelist.c"
"test_dot_edgelist.c"
"test_graph6_edgelist.c"
"test_dimacs_edgelist.c"
"test_draw_random.c"
"test_draw_circular.c"
"test_draw_fr.c"
"test_gomoryhu.c"
"test_equivalentflow.c"
"test_oddmincutset.c"
"test_link_prediction.c"
"test_draw_bipartite.c"
"test_mean_cycle.c"
"test_succinct_graph.c"
)
foreach(testsourcefile ${TEST_SOURCES})
string(REPLACE ".c" "" testname ${testsourcefile})
add_executable(${testname} test/${testsourcefile})
target_include_directories(${testname} PUBLIC ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/jgrapht-capi/src/main/native)
target_link_libraries(${testname} jgrapht_capi)
if(UNIX)
target_link_libraries(${testname} m)
endif(UNIX)
if(APPLE)
target_link_options(${testname} PUBLIC "LINKER:-rpath,@loader_path")
endif(APPLE)
add_test(NAME ${testname} COMMAND ${testname})
endforeach(testsourcefile ${TEST_SOURCES})