changed: prep package builds
[opensg.git] / Support / opennurbs / CMakeLists.txt
blobfd56b7cadcec2dd56158bd3884aad5210467324a
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
3 FUNCTION(PROCESS_FILES SUBDIR OUTLIST FILES)
4   FOREACH(_ON_FILE ${${FILES}})
5     EXECUTE_PROCESS(
6       COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${OSGOpenNurbsSrcDir}/${SUBDIR}/${_ON_FILE}"
7               "${CMAKE_BINARY_DIR}/External/opennurbs/${SUBDIR}/")
9       LIST(APPEND TMP_OUTLIST "${CMAKE_BINARY_DIR}/External/opennurbs/${SUBDIR}/${_ON_FILE}")
10   ENDFOREACH()
13   SET(${OUTLIST} ${TMP_OUTLIST} PARENT_SCOPE)
14 ENDFUNCTION()
16 IF(OSGOpenNurbsSrcDir)
18   PROJECT(OSGOpenNurbs)
20   SET(${PROJECT_NAME}SharedTarget osgopennurbs)
21   IF(WIN32)
22     SET(${PROJECT_NAME}StaticTarget libosgopennurbs)
23   ELSE(WIN32)
24     SET(${PROJECT_NAME}StaticTarget osgopennurbslib)
25   ENDIF(WIN32)
28   SET(OSG_OPENNURBS_LSRCS opennurbs_3dm_attributes.cpp  
29                           opennurbs_3dm_properties.cpp  
30                           opennurbs_3dm_settings.cpp  
31                           opennurbs_annotation.cpp  
32                           opennurbs_annotation2.cpp  
33                           opennurbs_arc.cpp  
34                           opennurbs_arccurve.cpp  
35                           opennurbs_archive.cpp  
36                           opennurbs_array.cpp  
37                           opennurbs_base32.cpp  
38                           opennurbs_base64.cpp  
39                           opennurbs_basic.cpp  
40                           opennurbs_beam.cpp  
41                           opennurbs_bezier.cpp  
42                           opennurbs_beziervolume.cpp  
43                           opennurbs_bitmap.cpp  
44                           opennurbs_bounding_box.cpp  
45                           opennurbs_box.cpp  
46                           opennurbs_brep.cpp  
47                           opennurbs_brep_extrude.cpp  
48                           opennurbs_brep_io.cpp  
49                           opennurbs_brep_isvalid.cpp  
50                           opennurbs_brep_region.cpp  
51                           opennurbs_brep_tools.cpp  
52                           opennurbs_brep_v2valid.cpp  
53                           opennurbs_circle.cpp  
54                           opennurbs_color.cpp  
55                           opennurbs_compress.cpp
56                           opennurbs_cone.cpp  
57                           opennurbs_crc.cpp  
58                           opennurbs_curve.cpp  
59                           opennurbs_curveonsurface.cpp  
60                           opennurbs_curveproxy.cpp  
61                           opennurbs_cylinder.cpp  
62                           opennurbs_defines.cpp  
63                           opennurbs_detail.cpp  
64                           opennurbs_dimstyle.cpp  
65                           opennurbs_ellipse.cpp  
66                           opennurbs_embedded_file.cpp   
67                           opennurbs_error.cpp  
68                           opennurbs_error_message.cpp  
69                           opennurbs_evaluate_nurbs.cpp  
70                           opennurbs_extensions.cpp  
71                           opennurbs_font.cpp  
72                           opennurbs_fsp.cpp 
73                           opennurbs_geometry.cpp  
74                           opennurbs_gl.cpp  
75                           opennurbs_group.cpp  
76                           opennurbs_hatch.cpp  
77                           opennurbs_instance.cpp  
78                           opennurbs_intersect.cpp  
79                           opennurbs_knot.cpp  
80                           opennurbs_layer.cpp  
81                           opennurbs_light.cpp  
82                           opennurbs_line.cpp  
83                           opennurbs_linecurve.cpp  
84                           opennurbs_linetype.cpp  
85                           opennurbs_lookup.cpp  
86                           opennurbs_massprop.cpp  
87                           opennurbs_material.cpp  
88                           opennurbs_math.cpp  
89                           opennurbs_matrix.cpp  
90                           opennurbs_memory.c  
91                           opennurbs_memory_util.c  
92                           opennurbs_mesh.cpp  
93                           opennurbs_mesh_ngon.cpp  
94                           opennurbs_mesh_tools.cpp  
95                           opennurbs_morph.cpp  
96                           opennurbs_nurbscurve.cpp  
97                           opennurbs_nurbssurface.cpp  
98                           opennurbs_nurbsvolume.cpp  
99                           opennurbs_object.cpp  
100                           opennurbs_object_history.cpp  
101                           opennurbs_objref.cpp  
102                           opennurbs_offsetsurface.cpp  
103                           opennurbs_optimize.cpp  
104                           opennurbs_plane.cpp  
105                           opennurbs_planesurface.cpp  
106                           opennurbs_pluginlist.cpp  
107                           opennurbs_point.cpp  
108                           opennurbs_pointcloud.cpp  
109                           opennurbs_pointgeometry.cpp  
110                           opennurbs_pointgrid.cpp  
111                           opennurbs_polycurve.cpp  
112                           opennurbs_polyedgecurve.cpp  
113                           opennurbs_polyline.cpp  
114                           opennurbs_polylinecurve.cpp  
115                           opennurbs_quaternion.cpp  
116                           opennurbs_rand.cpp  
117                           opennurbs_revsurface.cpp  
118                           opennurbs_rtree.cpp  
119                           opennurbs_sort.cpp
120                           opennurbs_sphere.cpp  
121                           opennurbs_string.cpp  
122                           opennurbs_sum.cpp  
123                           opennurbs_sumsurface.cpp  
124                           opennurbs_surface.cpp  
125                           opennurbs_surfaceproxy.cpp  
126                           opennurbs_textlog.cpp  
127                           opennurbs_torus.cpp  
128                           opennurbs_unicode.cpp
129                           opennurbs_userdata.cpp  
130                           opennurbs_uuid.cpp  
131                           opennurbs_viewport.cpp  
132                           opennurbs_workspace.cpp  
133                           opennurbs_wstring.cpp  
134                           opennurbs_xform.cpp 
135                           opennurbs_zlib.cpp 
136                           opennurbs_zlib_memory.cpp)
138   SET(OSG_OPENNURBS_LHDR opennurbs.h  
139                          opennurbs_3dm.h  
140                          opennurbs_3dm_attributes.h  
141                          opennurbs_3dm_properties.h  
142                          opennurbs_3dm_settings.h  
143                          opennurbs_annotation.h  
144                          opennurbs_annotation2.h  
145                          opennurbs_arc.h  
146                          opennurbs_arccurve.h  
147                          opennurbs_archive.h  
148                          opennurbs_base32.h  
149                          opennurbs_base64.h  
150                          opennurbs_beam.h  
151                          opennurbs_bezier.h  
152                          opennurbs_bitmap.h  
153                          opennurbs_bounding_box.h  
154                          opennurbs_box.h  
155                          opennurbs_brep.h  
156                          opennurbs_circle.h  
157                          opennurbs_color.h 
158                          opennurbs_compress.h
159                          opennurbs_cone.h  
160                          opennurbs_crc.h  
161                          opennurbs_curve.h  
162                          opennurbs_curveonsurface.h  
163                          opennurbs_curveproxy.h  
164                          opennurbs_cylinder.h  
165                          opennurbs_defines.h  
166                          opennurbs_detail.h  
167                          opennurbs_dimstyle.h  
168                          opennurbs_ellipse.h  
169                          opennurbs_error.h  
170                          opennurbs_evaluate_nurbs.h  
171                          opennurbs_extensions.h  
172                          opennurbs_font.h  
173                          opennurbs_fpoint.h
174                          opennurbs_fsp_defs.h
175                          opennurbs_fsp.h
176                          opennurbs_geometry.h  
177                          opennurbs_gl.h  
178                          opennurbs_group.h  
179                          opennurbs_hatch.h  
180                          opennurbs_hsort_template.h
181                          opennurbs_instance.h  
182                          opennurbs_intersect.h  
183                          opennurbs_knot.h  
184                          opennurbs_layer.h  
185                          opennurbs_light.h  
186                          opennurbs_line.h  
187                          opennurbs_linecurve.h  
188                          opennurbs_linestyle.h  
189                          opennurbs_linetype.h  
190                          opennurbs_lookup.h  
191                          opennurbs_mapchan.h  
192                          opennurbs_massprop.h  
193                          opennurbs_material.h  
194                          opennurbs_math.h  
195                          opennurbs_matrix.h  
196                          opennurbs_memory.h  
197                          opennurbs_mesh.h  
198                          opennurbs_nurbscurve.h  
199                          opennurbs_nurbssurface.h  
200                          opennurbs_object.h  
201                          opennurbs_object_history.h  
202                          opennurbs_objref.h  
203                          opennurbs_offsetsurface.h  
204                          opennurbs_optimize.h  
205                          opennurbs_plane.h  
206                          opennurbs_planesurface.h  
207                          opennurbs_pluginlist.h  
208                          opennurbs_point.h  
209                          opennurbs_pointcloud.h  
210                          opennurbs_pointgeometry.h  
211                          opennurbs_pointgrid.h  
212                          opennurbs_polycurve.h  
213                          opennurbs_polyedgecurve.h  
214                          opennurbs_polyline.h  
215                          opennurbs_polylinecurve.h  
216                          opennurbs_qsort_template.h
217                          opennurbs_quaternion.h  
218                          opennurbs_rand.h  
219                          opennurbs_rendering.h  
220                          opennurbs_revsurface.h  
221                          opennurbs_rtree.h  
222                          opennurbs_sphere.h  
223                          opennurbs_string.h  
224                          opennurbs_sumsurface.h  
225                          opennurbs_surface.h  
226                          opennurbs_surfaceproxy.h  
227                          opennurbs_textlog.h  
228                          opennurbs_texture.h  
229                          opennurbs_texture_mapping.h  
230                          opennurbs_torus.h  
231                          opennurbs_unicode.h
232                          opennurbs_userdata.h  
233                          opennurbs_uuid.h  
234                          opennurbs_viewport.h  
235                          opennurbs_workspace.h  
236                          opennurbs_xform.h  
237                          opennurbs_zlib.h)
239   SET(OSG_OPENNURBS_HDR_PATCH opennurbs_array_defs.h
240                               opennurbs_array.h  
241                               opennurbs_system.h  
242                               opennurbs_version.h   )
244   SET(OSG_OPENNURBS_ZLIB_LSRCS adler32.c 
245                                        compress.c 
246                                        crc32.c 
247                                        deflate.c 
248                                        infback.c 
249                                        inffast.c 
250                                        inflate.c 
251                                        inftrees.c 
252                                        trees.c 
253                                        uncompr.c 
254                                        zutil.c)
256   SET(OSG_OPENNURBS_ZLIB_LHDR crc32.h
257                                       deflate.h
258                                       inffast.h
259                                       inffixed.h
260                                       inflate.h 
261                                       inftrees.h
262                                       trees.h 
263                                       zconf.h 
264                                       zlib.h 
265                                       zutil.h)
267   SET(OSG_OPENNURBS_PATCHES 01_array_defs.patch
268                             02_version.patch 
269                             03_system.patch
270                             04_array.patch    )
272   SET(OSGOPENNURBS_DEF  MY_ZCALLOC;Z_PREFIX)
274   IF(WIN32)
275     SET(OSGOPENNURBS_DEF  ${OSGOPENNURBS_DEF};UNICODE;_UNICODE)
276   ELSE(WIN32)
277     SET(OSGOPENNURBS_DEF  ${OSGOPENNURBS_DEF};_GNU_SOURCE)
278   ENDIF(WIN32)
281   EXECUTE_PROCESS(
282         COMMAND "${CMAKE_COMMAND}" -E make_directory "${OSGOpenNurbsSrcDir}/patched")
283   EXECUTE_PROCESS(
284         COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_BINARY_DIR}/External/opennurbs/")
285   EXECUTE_PROCESS(
286         COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_BINARY_DIR}/External/opennurbs/zlib/")
288   FOREACH(_ON_PATCHED_HDR ${OSG_OPENNURBS_HDR_PATCH})
289     EXECUTE_PROCESS(
290         COMMAND "${CMAKE_COMMAND}" -E copy "${OSGOpenNurbsSrcDir}/${_ON_PATCHED_HDR}" "${OSGOpenNurbsSrcDir}/patched/")
291   ENDFOREACH()
293   FOREACH(_ON_PATCH ${OSG_OPENNURBS_PATCHES})
294     EXECUTE_PROCESS(COMMAND "patch" "-p1" 
295                     INPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${_ON_PATCH}"
296                     WORKING_DIRECTORY "${OSGOpenNurbsSrcDir}/patched")
297   ENDFOREACH()
299   PROCESS_FILES(. "OSG_OPENNURBS_SRCS" OSG_OPENNURBS_LSRCS)
300   PROCESS_FILES(. "OSG_OPENNURBS_HDR"  OSG_OPENNURBS_LHDR)
302   PROCESS_FILES(zlib "OSG_OPENNURBS_ZLIB_SRCS" OSG_OPENNURBS_ZLIB_LSRCS)
303   PROCESS_FILES(zlib "OSG_OPENNURBS_ZLIB_HDR"  OSG_OPENNURBS_ZLIB_LHDR)
305   FOREACH(_ON_PATCHED_HDR ${OSG_OPENNURBS_HDR_PATCH})
306     EXECUTE_PROCESS(
307         COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${OSGOpenNurbsSrcDir}/patched/${_ON_PATCHED_HDR}"
308                                    "${CMAKE_BINARY_DIR}/External/opennurbs/")
309     LIST(APPEND OSG_OPENNURBS_HDR "${CMAKE_BINARY_DIR}/External/opennurbs/${_ON_PATCHED_HDR}")
310   ENDFOREACH()
312   IF(WIN32)
313     INCLUDE_DIRECTORIES(${OSG_ZLIB_INCLUDE_DIR})
314   ENDIF(WIN32)
316   IF(BUILD_SHARED_LIBS)
317     ADD_LIBRARY(${${PROJECT_NAME}SharedTarget} SHARED 
318                   ${OSG_OPENNURBS_SRCS}
319                   ${OSG_OPENNURBS_ZLIB_SRCS})
321     ADD_DEPENDENCIES(ALL_STANDARD_BUILD ${${PROJECT_NAME}SharedTarget})
323     IF(WIN32)
324       SET_TARGET_PROPERTIES(${${PROJECT_NAME}SharedTarget} PROPERTIES
325                             DEBUG_POSTFIX "D")
327       TARGET_LINK_LIBRARIES(${${PROJECT_NAME}SharedTarget} ${OPENGL_gl_LIBRARY}
328                                                            ${OPENGL_glu_LIBRARY}
329                                                            Rpcrt4)
330     ENDIF(WIN32)
332     IF(APPLE)
333       TARGET_LINK_LIBRARIES(${${PROJECT_NAME}SharedTarget} ${OPENGL_gl_LIBRARY})
334     ENDIF(APPLE)
336     IF(WIN32)
337       SET(OSGOPENNURBS_DEF_SHARED ${OSGOPENNURBS_DEF};ON_DLL_EXPORTS;ON_COMPILING_OPENNURBS)
338     ELSE(WIN32)
339       SET(OSGOPENNURBS_DEF_SHARED ${OSGOPENNURBS_DEF})
340     ENDIF(WIN32)
342     SET_TARGET_PROPERTIES(${${PROJECT_NAME}SharedTarget} PROPERTIES
343                           COMPILE_DEFINITIONS "${OSGOPENNURBS_DEF_SHARED}")
345     IF(WIN32)    
346       INSTALL(TARGETS ${${PROJECT_NAME}SharedTarget}
347                   CONFIGURATIONS Release
348                   RUNTIME DESTINATION bin COMPONENT release_runtimes
349                   LIBRARY DESTINATION lib COMPONENT release_libraries
350                   ARCHIVE DESTINATION lib COMPONENT release_libraries)
352       INSTALL(TARGETS ${${PROJECT_NAME}SharedTarget}
353                   CONFIGURATIONS Debug
354                   RUNTIME DESTINATION bin COMPONENT debug_runtimes
355                   LIBRARY DESTINATION lib COMPONENT debug_libraries
356                   ARCHIVE DESTINATION lib COMPONENT debug_libraries)
357     ELSE(WIN32)
358       INSTALL(TARGETS ${${PROJECT_NAME}SharedTarget}
359                   RUNTIME DESTINATION lib${OSG_LIBDIR_SUFFIX} COMPONENT libraries
360                   LIBRARY DESTINATION lib${OSG_LIBDIR_SUFFIX} COMPONENT libraries
361                   ARCHIVE DESTINATION lib${OSG_LIBDIR_SUFFIX} COMPONENT libraries)
362     ENDIF(WIN32)
364   ENDIF(BUILD_SHARED_LIBS)
366   IF(BUILD_STATIC_LIBS)
367     ADD_LIBRARY(${${PROJECT_NAME}StaticTarget} STATIC ${OSG_OPENNURBS_SRCS})
369     ADD_DEPENDENCIES(ALL_STANDARD_BUILD ${${PROJECT_NAME}StaticTarget})
371     IF(WIN32)
372       SET_TARGET_PROPERTIES(${${PROJECT_NAME}StaticTarget} PROPERTIES
373                             DEBUG_POSTFIX "D")
374     ENDIF(WIN32)
376     SET_TARGET_PROPERTIES(${${PROJECT_NAME}StaticTarget} PROPERTIES
377                           COMPILE_DEFINITIONS "${OSGOPENNURBS_DEF}")
380     IF(WIN32)    
381       INSTALL(TARGETS ${${PROJECT_NAME}StaticTarget}
382                   CONFIGURATIONS Release
383                   RUNTIME DESTINATION lib COMPONENT release_libraries
384                   LIBRARY DESTINATION lib COMPONENT release_libraries
385                   ARCHIVE DESTINATION lib COMPONENT release_libraries)
387       INSTALL(TARGETS ${${PROJECT_NAME}StaticTarget}
388                   CONFIGURATIONS Debug
389                   RUNTIME DESTINATION lib COMPONENT debug_libraries
390                   LIBRARY DESTINATION lib COMPONENT debug_libraries
391                   ARCHIVE DESTINATION lib COMPONENT debug_libraries)
392     ELSE(WIN32)
393       INSTALL(TARGETS ${${PROJECT_NAME}StaticTarget}
394                   RUNTIME DESTINATION lib${OSG_LIBDIR_SUFFIX} COMPONENT static_libraries
395                   LIBRARY DESTINATION lib${OSG_LIBDIR_SUFFIX} COMPONENT static_libraries
396                   ARCHIVE DESTINATION lib${OSG_LIBDIR_SUFFIX} COMPONENT static_libraries)
397     ENDIF(WIN32)
399   ENDIF(BUILD_STATIC_LIBS)
401   INSTALL(FILES ${OSG_OPENNURBS_HDR}
402           DESTINATION include${OSG_SUPPORT_INC_SUBDIR}/opennurbs
403           COMPONENT code_headers
404           PERMISSIONS OWNER_WRITE OWNER_READ
405                       GROUP_READ
406                       WORLD_READ)
408   INSTALL(FILES ${OSG_OPENNURBS_ZLIB_HDR}
409           DESTINATION include${OSG_SUPPORT_INC_SUBDIR}/opennurbs/zlib
410           COMPONENT code_headers
411           PERMISSIONS OWNER_WRITE OWNER_READ
412                       GROUP_READ
413                       WORLD_READ)
415 ELSE(OSGOpenNurbsSrcDir)
416   SET(OSGOpenNurbsSrcDir "" CACHE PATH "")
417 ENDIF(OSGOpenNurbsSrcDir)