source: trunk/projects/jar2lib/src/main/resources/CMakeLists.vm @ 7731

Revision 7731, 8.6 KB checked in by hinerm, 8 years ago (diff)

Fixes for ticket #298 and #654

Ticket #298 fixes:

  • search for a /jar subdirectory in working directory or provided classpath
  • all files in /jar are added to the classpath of the instantiated JVM

Ticket #654 fixes:

  • copying of project headers
  • copying of proxy headers
  • copying of jar dependencies to /jar
  • removal of loci_tool dependency
  • packaging improvements to remove full path references
Line 
1#
2# CMakeLists.txt
3#
4$headerBlock
5# CMake build file for $projectName.
6
7cmake_minimum_required(VERSION 2.8)
8
9project($projectId)
10
11include(jace/Prerequisites.cmake)
12
13add_subdirectory(jace)
14
15include_directories(include "proxies/include" "jace/include" "jtools/include"
16  "${JAVA_INCLUDE_PATH}" "${JAVA_INCLUDE_PATH2}" "${Boost_INCLUDE_DIR}")
17
18file(GLOB_RECURSE PROJECT_SRC "proxies/source/*.cpp")
19
20add_library(jtools SHARED "jtools/source/javaTools.cxx")
21
22add_library($projectId SHARED ${PROJECT_SRC})
23
24target_link_libraries($projectId jace)
25
26target_link_libraries(jtools jace)
27
28if(CMAKE_COMPILER_IS_GNUCXX)
29  set_target_properties($projectId PROPERTIES
30    COMPILE_FLAGS "-fpermissive")
31else(CMAKE_COMPILER_IS_GNUCXX)
32  set_target_properties($projectId PROPERTIES
33    DEFINE_SYMBOL JACE_PROXY_EXPORTS)
34endif(CMAKE_COMPILER_IS_GNUCXX)
35
36#foreach ($sourceFile in $sourceFiles)
37#set ($execName = $q.simpleName($sourceFile))
38#set ($sourceName = $sourceFile.getName())
39add_executable($execName source/$sourceName)
40target_link_libraries($execName $projectId jtools jace "${JAVA_JVM_LIBRARY}")
41#end##foreach $sourceFile
42
43### post-build copies to dist dir ###
44if(NOT DEFINED Jar2Lib_JACE_DIR)
45  set(Jar2Lib_JACE_DIR jace)
46endif(NOT DEFINED Jar2Lib_JACE_DIR)
47
48if(NOT DEFINED Jar2Lib_PROXY_DIR)
49  set(Jar2Lib_PROXY_DIR ../proxies)
50endif(NOT DEFINED Jar2Lib_PROXY_DIR)
51
52if(NOT DEFINED Jar2Lib_INCLDE_DIR)
53  set(Jar2Lib_INCLDE_DIR ../include)
54endif(NOT DEFINED Jar2Lib_INCLDE_DIR)
55
56if(NOT DEFINED Jar2Lib_DEPS_DIR)
57  set(Jar2Lib_DEPS_DIR jar)
58endif(NOT DEFINED Jar2Lib_DEPS_DIR)
59
60if(NOT DEFINED Jar2Lib_DIST_DIR)
61  set(Jar2Lib_DIST_DIR dist/${projectId})
62endif(NOT DEFINED Jar2Lib_DIST_DIR)
63
64if(NOT DEFINED Jar2Lib_DEPS_SRC)
65  set(Jar2Lib_DEPS_SRC ../../dependency)
66endif(NOT DEFINED Jar2Lib_DEPS_SRC)
67
68if(NOT DEFINED J2L_BUILD_TYPE)
69  set(J2L_BUILD_TYPE "")
70endif(NOT DEFINED J2L_BUILD_TYPE)
71
72if(NOT DEFINED J2L_LIB_PREFIX)
73  set(J2L_LIB_PREFIX lib)
74endif(NOT DEFINED J2L_LIB_PREFIX)
75
76if(APPLE)
77
78 if(NOT DEFINED J2L_SUFFIX)
79   set(J2L_SUFFIX .dylib)
80 endif(NOT DEFINED J2L_SUFFIX)
81
82 if(NOT DEFINED J2L_JNI_SUFFIX)
83   set(J2L_JNI_SUFFIX .jnilib)
84 endif(NOT DEFINED J2L_JNI_SUFFIX)
85
86 if(NOT DEFINED J2L_EXE_SUFFIX)
87   set(J2L_EXE_SUFFIX "")
88 endif(NOT DEFINED J2L_EXE_SUFFIX)
89
90endif(APPLE)
91
92if(UNIX)
93
94 if(NOT DEFINED J2L_SUFFIX)
95
96   set(J2L_SUFFIX .so)
97
98 endif(NOT DEFINED J2L_SUFFIX)
99
100 if(NOT DEFINED J2L_EXE_SUFFIX)
101   set(J2L_EXE_SUFFIX "")
102 endif(NOT DEFINED J2L_EXE_SUFFIX)
103
104endif(UNIX)
105
106if(WIN32)
107   set(J2L_LIB_PREFIX "")
108   set(J2L_BUILD_TYPE /Release)
109
110# Building in Debug mode is not currently supported in this script
111#  set(J2L_BUILD TYPE /Debug)
112
113  if(NOT DEFINED J2L_SUFFIX)
114
115    set(J2L_SUFFIX .dll)
116
117  endif(NOT DEFINED J2L_SUFFIX)
118
119 if(NOT DEFINED J2L_EXE_SUFFIX)
120   set(J2L_EXE_SUFFIX .exe)
121 endif(NOT DEFINED J2L_EXE_SUFFIX)
122
123endif(WIN32)
124
125if(WIN64)
126  set(J2L_LIB_PREFIX "")
127  set(J2L_BUILD_TYPE /Release)
128
129#  Builing with Debug mode on Windows is not currently supported in this script.
130#  set(J2L_BUILD TYPE /Debug)
131
132  if(NOT DEFINED J2L_SUFFIX)
133
134    set(J2L_SUFFIX .dll)
135
136  endif(NOT DEFINED J2L_SUFFIX)
137
138 if(NOT DEFINED J2L_EXE_SUFFIX)
139   set(J2L_SUFFIX )
140 endif(NOT DEFINED J2L_EXE_SUFFIX)
141
142endif(WIN64)
143
144
145if(APPLE)
146#make a .dylib version of libjace
147  add_custom_command(
148    TARGET ${projectId}
149    DEPENDS "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
150    POST_BUILD
151    COMMAND ${CMAKE_COMMAND} -E copy
152    "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
153    "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_SUFFIX}"
154    VERBATIM
155  )
156
157  add_custom_command(
158    TARGET ${projectId}
159    DEPENDS "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
160    POST_BUILD
161    COMMAND ${CMAKE_COMMAND} -E copy
162    "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
163    "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
164    VERBATIM
165  )
166  install(FILES
167    "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
168    DESTINATION "."
169  )
170
171  add_custom_command(
172    TARGET ${projectId}
173    DEPENDS "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
174    POST_BUILD
175    COMMAND ${CMAKE_COMMAND} -E copy
176    "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
177    "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jace${J2L_SUFFIX}"
178    VERBATIM
179  )
180  install(FILES
181    "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jace${J2L_SUFFIX}"
182    DESTINATION "."
183  )
184endif(APPLE)
185
186#copy jace
187add_custom_command(
188  TARGET ${projectId}
189  DEPENDS "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_SUFFIX}"
190  POST_BUILD
191  COMMAND ${CMAKE_COMMAND} -E copy
192  "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_SUFFIX}"
193  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jace${J2L_SUFFIX}"
194  VERBATIM
195)
196install(FILES
197  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jace${J2L_SUFFIX}"
198  DESTINATION "."
199)
200
201#copy ${projectId}
202add_custom_command(
203  TARGET ${projectId}
204  DEPENDS "${CMAKE_BINARY_DIR}/${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}${projectId}${J2L_SUFFIX}"
205  POST_BUILD
206  COMMAND ${CMAKE_COMMAND} -E copy
207  "${CMAKE_BINARY_DIR}/${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}${projectId}${J2L_SUFFIX}"
208  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}${projectId}${J2L_SUFFIX}"
209  VERBATIM
210)
211
212#copy jtools
213add_custom_command(
214  TARGET jtools
215  DEPENDS "${CMAKE_BINARY_DIR}/${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jtools${J2L_SUFFIX}"
216  POST_BUILD
217  COMMAND ${CMAKE_COMMAND} -E copy
218  "${CMAKE_BINARY_DIR}/${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jtools${J2L_SUFFIX}"
219  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jtools${J2L_SUFFIX}"
220  VERBATIM
221)
222
223# copy jace_runtime.jar
224add_custom_command(
225  TARGET ${projectId}
226  DEPENDS "${CMAKE_BINARY_DIR}/../jace-runtime.jar"
227  POST_BUILD
228  COMMAND ${CMAKE_COMMAND} -E copy
229  "${CMAKE_BINARY_DIR}/../jace-runtime.jar"
230  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${Jar2Lib_DEPS_DIR}/jace-runtime.jar"
231  VERBATIM
232)
233install(FILES
234  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${Jar2Lib_DEPS_DIR}/jace-runtime.jar"
235  DESTINATION "./${Jar2Lib_DEPS_DIR}"
236)
237
238#foreach ($jarFile in $sourceJars)
239#set ($jarName = $jarFile.getName())
240# copy ${jarName}
241add_custom_command(
242  TARGET ${projectId}
243  DEPENDS "${jarFile}"
244  POST_BUILD
245  COMMAND ${CMAKE_COMMAND} -E copy
246  "${jarFile}"
247  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${Jar2Lib_DEPS_DIR}/${jarName}"
248  VERBATIM
249)
250install(FILES
251  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${Jar2Lib_DEPS_DIR}/${jarName}"
252  DESTINATION "./${Jar2Lib_DEPS_DIR}/"
253)
254
255#end##foreach $sourceJars
256
257# copy and install executables
258#foreach ($sourceFile in $sourceFiles)
259#set ($execName = $q.simpleName($sourceFile))
260#set ($sourceName = $sourceFile.getName())
261add_custom_command(
262  TARGET ${execName}
263  DEPENDS "${CMAKE_BINARY_DIR}/${execName}"
264  POST_BUILD
265  COMMAND ${CMAKE_COMMAND} -E copy
266  "${CMAKE_BINARY_DIR}/${execName}"
267  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${execName}"
268  VERBATIM
269)
270#end##foreach $sourceFile
271
272# copy and install dependencies
273add_custom_command(
274  TARGET ${projectId}
275  DEPENDS "${CMAKE_BINARY_DIR}/${Jar2Lib_DEPS_SRC}"
276  POST_BUILD
277  COMMAND ${CMAKE_COMMAND} -E copy_directory
278  "${CMAKE_BINARY_DIR}/${Jar2Lib_DEPS_SRC}"
279  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${Jar2Lib_DEPS_DIR}/"
280  VERBATIM
281)
282
283install(DIRECTORY
284  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${Jar2Lib_DEPS_DIR}/"
285  DESTINATION "./${Jar2Lib_DEPS_DIR}/"
286)
287
288# copy dependency headers
289add_custom_command(
290  TARGET ${projectId}
291  DEPENDS "${Jar2Lib_INCLDE_DIR}"
292  COMMAND ${CMAKE_COMMAND} -E copy_directory
293  "${Jar2Lib_INCLDE_DIR}"
294  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/include"
295  VERBATIM
296)
297
298# copy and install proxies
299add_custom_command(
300  TARGET ${projectId}
301  DEPENDS "${CMAKE_BINARY_DIR}/${Jar2Lib_PROXY_DIR}"
302  POST_BUILD
303  COMMAND ${CMAKE_COMMAND} -E copy_directory
304  "${CMAKE_BINARY_DIR}/${Jar2Lib_PROXY_DIR}/include"
305  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/include"
306  VERBATIM
307)
308
309install(DIRECTORY
310  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/include/"
311  DESTINATION "./include"
312)
313
314# install targets
315install(TARGETS
316  jtools
317  ${projectId}
318#foreach ($sourceFile in $sourceFiles)
319#set ($execName = $q.simpleName($sourceFile))
320  ${execName}
321#end##foreach $sourceFile
322  RUNTIME DESTINATION .
323  LIBRARY DESTINATION .
324  ARCHIVE DESTINATION .
325)
326
327SET(CPACK_PACKAGE_FILE_NAME "${projectId}")
328SET(CPACK_GENERATOR "TGZ;ZIP")
329INCLUDE( CPack )
330
Note: See TracBrowser for help on using the repository browser.