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

Revision 7727, 6.7 KB checked in by curtis, 9 years ago (diff)

Link executables to jtools.

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_DIST_DIR)
49  set(Jar2Lib_DIST_DIR dist/${projectId})
50endif(NOT DEFINED Jar2Lib_DIST_DIR)
51
52if(NOT DEFINED J2L_BUILD_TYPE)
53  set(J2L_BUILD_TYPE "")
54endif(NOT DEFINED J2L_BUILD_TYPE)
55
56if(NOT DEFINED J2L_LIB_PREFIX)
57  set(J2L_LIB_PREFIX lib)
58endif(NOT DEFINED J2L_LIB_PREFIX)
59
60if(APPLE)
61
62 if(NOT DEFINED J2L_SUFFIX)
63   set(J2L_SUFFIX .dylib)
64 endif(NOT DEFINED J2L_SUFFIX)
65
66 if(NOT DEFINED J2L_JNI_SUFFIX)
67   set(J2L_JNI_SUFFIX .jnilib)
68 endif(NOT DEFINED J2L_JNI_SUFFIX)
69
70 if(NOT DEFINED J2L_EXE_SUFFIX)
71   set(J2L_EXE_SUFFIX "")
72 endif(NOT DEFINED J2L_EXE_SUFFIX)
73
74endif(APPLE)
75
76if(UNIX)
77
78 if(NOT DEFINED J2L_SUFFIX)
79
80   set(J2L_SUFFIX .so)
81
82 endif(NOT DEFINED J2L_SUFFIX)
83
84 if(NOT DEFINED J2L_EXE_SUFFIX)
85   set(J2L_EXE_SUFFIX "")
86 endif(NOT DEFINED J2L_EXE_SUFFIX)
87
88endif(UNIX)
89
90if(WIN32)
91   set(J2L_LIB_PREFIX "")
92   set(J2L_BUILD_TYPE /Release)
93
94# Building in Debug mode is not currently supported in this script
95#  set(J2L_BUILD TYPE /Debug)
96
97  if(NOT DEFINED J2L_SUFFIX)
98
99    set(J2L_SUFFIX .dll)
100
101  endif(NOT DEFINED J2L_SUFFIX)
102
103 if(NOT DEFINED J2L_EXE_SUFFIX)
104   set(J2L_EXE_SUFFIX .exe)
105 endif(NOT DEFINED J2L_EXE_SUFFIX)
106
107endif(WIN32)
108
109if(WIN64)
110  set(J2L_LIB_PREFIX "")
111  set(J2L_BUILD_TYPE /Release)
112
113#  Builing with Debug mode on Windows is not currently supported in this script.
114#  set(J2L_BUILD TYPE /Debug)
115
116  if(NOT DEFINED J2L_SUFFIX)
117
118    set(J2L_SUFFIX .dll)
119
120  endif(NOT DEFINED J2L_SUFFIX)
121
122 if(NOT DEFINED J2L_EXE_SUFFIX)
123   set(J2L_SUFFIX )
124 endif(NOT DEFINED J2L_EXE_SUFFIX)
125
126endif(WIN64)
127
128
129if(APPLE)
130#make a .dylib version of libjace
131  add_custom_command(
132    TARGET ${projectId}
133    DEPENDS "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
134    POST_BUILD
135    COMMAND ${CMAKE_COMMAND} -E copy
136    "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
137    "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_SUFFIX}"
138    VERBATIM
139  )
140
141  add_custom_command(
142    TARGET ${projectId}
143    DEPENDS "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
144    POST_BUILD
145    COMMAND ${CMAKE_COMMAND} -E copy
146    "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
147    "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
148    VERBATIM
149  )
150  install(FILES
151    "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
152    DESTINATION "${Jar2Lib_DIST_DIR}"
153  )
154
155  add_custom_command(
156    TARGET ${projectId}
157    DEPENDS "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
158    POST_BUILD
159    COMMAND ${CMAKE_COMMAND} -E copy
160    "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_JNI_SUFFIX}"
161    "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jace${J2L_SUFFIX}"
162    VERBATIM
163  )
164  install(FILES
165    "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jace${J2L_SUFFIX}"
166    DESTINATION "${Jar2Lib_DIST_DIR}"
167  )
168endif(APPLE)
169
170#copy jace
171add_custom_command(
172  TARGET ${projectId}
173  DEPENDS "${CMAKE_BINARY_DIR}/${Jar2Lib_JACE_DIR}${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jace${J2L_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_SUFFIX}"
177  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jace${J2L_SUFFIX}"
178  VERBATIM
179)
180install(FILES
181  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jace${J2L_SUFFIX}"
182  DESTINATION "${Jar2Lib_DIST_DIR}"
183)
184
185#copy ${projectId}
186add_custom_command(
187  TARGET ${projectId}
188  DEPENDS "${CMAKE_BINARY_DIR}/${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}${projectId}${J2L_SUFFIX}"
189  POST_BUILD
190  COMMAND ${CMAKE_COMMAND} -E copy
191  "${CMAKE_BINARY_DIR}/${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}${projectId}${J2L_SUFFIX}"
192  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}${projectId}${J2L_SUFFIX}"
193  VERBATIM
194)
195install(FILES
196  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}${projectId}${J2L_SUFFIX}"
197  DESTINATION "${Jar2Lib_DIST_DIR}"
198)
199
200#copy jtools
201add_custom_command(
202  TARGET jtools
203  DEPENDS "${CMAKE_BINARY_DIR}/${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jtools${J2L_SUFFIX}"
204  POST_BUILD
205  COMMAND ${CMAKE_COMMAND} -E copy
206  "${CMAKE_BINARY_DIR}/${J2L_BUILD_TYPE}/${J2L_LIB_PREFIX}jtools${J2L_SUFFIX}"
207  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jtools${J2L_SUFFIX}"
208  VERBATIM
209)
210install(FILES
211  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${J2L_LIB_PREFIX}jtools${J2L_SUFFIX}"
212  DESTINATION "${Jar2Lib_DIST_DIR}"
213)
214
215# copy jace_runtime.jar
216add_custom_command(
217  TARGET ${projectId}
218  DEPENDS "${CMAKE_BINARY_DIR}/../jace-runtime.jar"
219  POST_BUILD
220  COMMAND ${CMAKE_COMMAND} -E copy
221  "${CMAKE_BINARY_DIR}/../jace-runtime.jar"
222  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/jace-runtime.jar"
223  VERBATIM
224)
225install(FILES
226  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/jace-runtime.jar"
227  DESTINATION "${Jar2Lib_DIST_DIR}"
228)
229
230#foreach ($jarFile in $sourceJars)
231#set ($jarName = $jarFile.getName())
232# copy ${jarName}
233add_custom_command(
234  TARGET ${projectId}
235  DEPENDS "${jarFile}"
236  POST_BUILD
237  COMMAND ${CMAKE_COMMAND} -E copy
238  "${jarFile}"
239  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${jarName}"
240  VERBATIM
241)
242install(FILES
243  "${CMAKE_BINARY_DIR}/${Jar2Lib_DIST_DIR}/${jarName}"
244  DESTINATION "${Jar2Lib_DIST_DIR}"
245)
246
247#end##foreach $sourceJars
248
249SET(CPACK_PACKAGE_FILE_NAME "${projectId}")
250SET(CPACK_GENERATOR "TGZ;ZIP")
251INCLUDE( CPack )
Note: See TracBrowser for help on using the repository browser.