changed: export values to ext project for linux as well
[opensg.git] / CMake / BuildFunctions.cmake
blob8f2b11b9bf78e1795e1c7593b5eef0af2d1ccde8
2 #############################################################################
3 # print message depending on the setting of OSG_VERBOSE_BUILD_MESSAGES
5 FUNCTION(OSG_MSG MSG)
6     IF(OSG_VERBOSE_BUILD_MESSAGES)
7         MESSAGE(STATUS "${MSG}")
8     ENDIF(OSG_VERBOSE_BUILD_MESSAGES)
9 ENDFUNCTION(OSG_MSG)
11 #############################################################################
12 # includes _OSG_FILENAME if it exists, otherwise bails with an error.
14 MACRO(OSG_CHECKED_INCLUDE _OSG_FILENAME)
15     IF(NOT EXISTS "${_OSG_FILENAME}")
16         MESSAGE(FATAL_ERROR "File \"${_OSG_FILENAME}\" not found, "
17                 "required by ${PROJECT_NAME}\n")
18     ENDIF(NOT EXISTS "${_OSG_FILENAME}")
20     INCLUDE("${_OSG_FILENAME}")
21 ENDMACRO(OSG_CHECKED_INCLUDE)
23 #############################################################################
24 # includes _OSG_FILENAME if it exists, otherwise just ignores it.
26 MACRO(OSG_OPTIONAL_INCLUDE _OSG_FILENAME)
27     IF(EXISTS "${_OSG_FILENAME}")
28         INCLUDE("${_OSG_FILENAME}")
29     ENDIF(EXISTS "${_OSG_FILENAME}")
30 ENDMACRO(OSG_OPTIONAL_INCLUDE)
32 ################################
33 # check and symlink
35 MACRO(OSG_SYMLINK_CHECKED _OSG_SRC_FILENAME _OSG_DST_FILENAME)
36   IF(NOT EXISTS "${_OSG_DST_FILENAME}")
37     EXECUTE_PROCESS(
38       COMMAND "${CMAKE_COMMAND}" -E create_symlink
39                "${_OSG_SRC_FILENAME}"
40                "${_OSG_DST_FILENAME}")
41   ENDIF(NOT EXISTS "${_OSG_DST_FILENAME}")
42 ENDMACRO(OSG_SYMLINK_CHECKED)
44 #############################################################################
45 # given a list of OpenSG libraries (BASELIST) it determines the full list of
46 # OpenSG libs they depend upon (OUTDEPLIST) and any dependencies that could
47 # not be found (OUTDEPMISSINGLIST).
48 # Useful to get all the include dirs needed by a lib during the build.
50 FUNCTION(OSG_GET_ALL_DEP_OSG_LIB BASELIST OUTDEPLIST OUTDEPMISSINGLIST)
52     SET(_DEPLIST        ${BASELIST})
53     SET(_DEPLISTNEW                )
54     SET(_DEPMISSINGLIST            )
56     # CMake has no do{ }while, duplicate the while loop body once
57     # outside the while loop:
59     FOREACH(DEP ${_DEPLIST})
60         SET(DEPFILE "${CMAKE_BINARY_DIR}/${DEP}.cmake")
62         IF(NOT EXISTS "${DEPFILE}")
63             LIST(APPEND _DEPMISSINGLIST ${DEP})
64         ENDIF(NOT EXISTS "${DEPFILE}")
66         OSG_OPTIONAL_INCLUDE("${DEPFILE}")
68         LIST(APPEND _DEPLISTNEW ${DEP})
69         LIST(APPEND _DEPLISTNEW ${${DEP}_DEP_OSG_LIB})
71         LIST(SORT              _DEPLISTNEW)
72         LIST(REMOVE_DUPLICATES _DEPLISTNEW)
73     ENDFOREACH(DEP)
75     LIST(LENGTH _DEPLIST    _DEPLISTLEN   )
76     LIST(LENGTH _DEPLISTNEW _DEPLISTNEWLEN)
78     #MESSAGE("_DEPLIST   : ${_DEPLIST}"   )
79     #MESSAGE("_DEPLISTNEW: ${_DEPLISTNEW}")
81     # keep iterating as long as new elements are added
82     WHILE(${_DEPLISTNEWLEN} GREATER ${_DEPLISTLEN})
84         SET(_DEPLIST    ${_DEPLISTNEW})
85         SET(_DEPLISTNEW               )
87         FOREACH(DEP ${_DEPLIST})
88             SET(DEPFILE "${CMAKE_BINARY_DIR}/${DEP}.cmake")
90             IF(NOT EXISTS "${DEPFILE}")
91                 LIST(APPEND _DEPMISSINGLIST ${DEP})
92             ENDIF(NOT EXISTS "${DEPFILE}")
94             OSG_OPTIONAL_INCLUDE("${DEPFILE}")
96             LIST(APPEND _DEPLISTNEW ${DEP}               )
97             LIST(APPEND _DEPLISTNEW ${${DEP}_DEP_OSG_LIB})
99             LIST(SORT              _DEPLISTNEW)
100             LIST(REMOVE_DUPLICATES _DEPLISTNEW)
101         ENDFOREACH(DEP)
103         #MESSAGE("_DEPLIST   : ${_DEPLIST}"   )
104         #MESSAGE("_DEPLISTNEW: ${_DEPLISTNEW}")
106         LIST(LENGTH _DEPLIST    _DEPLISTLEN   )
107         LIST(LENGTH _DEPLISTNEW _DEPLISTNEWLEN)
108     ENDWHILE(${_DEPLISTNEWLEN} GREATER ${_DEPLISTLEN})
110     IF(_DEPMISSINGLIST)
111         LIST(REMOVE_DUPLICATES _DEPMISSINGLIST)
112     ENDIF(_DEPMISSINGLIST)
114     SET(${OUTDEPLIST}        "${_DEPLISTNEW}"     PARENT_SCOPE)
115     SET(${OUTDEPMISSINGLIST} "${_DEPMISSINGLIST}" PARENT_SCOPE)
117 ENDFUNCTION(OSG_GET_ALL_DEP_OSG_LIB)
119 #############################################################################
120 # register project with build
122 MACRO(OSG_ADD_PROJECT PNAME)
123     PROJECT(${PNAME})
124     IF(${OSG_CMAKE_PASS} STREQUAL "OSGCOLLECT")
125       OPTION(OSGBUILD_${PROJECT_NAME} "Build the ${PROJECT_NAME} library" ON)
126       IF(NOT OSG_DISABLE_SOURCE_GROUPS)
127         SET(${PROJECT_NAME}_SOURCE_GROUPS "" CACHE INTERNAL "" FORCE)
128       ENDIF()
129     ENDIF(${OSG_CMAKE_PASS} STREQUAL "OSGCOLLECT")
130 ENDMACRO(OSG_ADD_PROJECT)
132 #############################################################################
133 # select the current project as the one settings are added to
135 MACRO(OSG_SELECT_PROJECT)
137     IF(OSGBUILD_${PROJECT_NAME})
138         MESSAGE(STATUS "Processing ${PROJECT_NAME}")
139     ELSE(OSGBUILD_${PROJECT_NAME})
140         OSG_MSG("Skipping ${PROJECT_NAME}")
141         RETURN()
142     ENDIF(OSGBUILD_${PROJECT_NAME})
144     SET_DIRECTORY_PROPERTIES(PROPERTIES CLEAN_NO_CUSTOM TRUE)
146     SET(${PROJECT_NAME}_BUILD_FILE
147         "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.cmake")
148     SET(${PROJECT_NAME}_CONFIG_FILE
149         "${CMAKE_BINARY_DIR}/bin/osg2-config.part2.tmp")
151     # write header
152     IF(${OSG_CMAKE_PASS} STREQUAL "OSGCOLLECT")
153         FILE(WRITE ${${PROJECT_NAME}_BUILD_FILE}
154             "# ${PROJECT_NAME}.cmake -- auto generated\n\n")
156         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
157             "SET(${PROJECT_NAME}_SRC ${OSG_ADD_GLOBAL_SRC} ${${PROJECT_NAME}_ADD_SRC})\n")
158         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
159             "SET(${PROJECT_NAME}_HDR)\n")
160         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
161             "SET(${PROJECT_NAME}_INL)\n")
162         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
163             "SET(${PROJECT_NAME}_INS)\n")
164         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
165             "SET(${PROJECT_NAME}_FCD)\n")
166         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
167             "SET(${PROJECT_NAME}_LL)\n")
168         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
169             "SET(${PROJECT_NAME}_YY)\n")
170         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
171              "SET(${PROJECT_NAME}_MOC)\n")
172         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
173             "SET(${PROJECT_NAME}_UNITTEST_SRC)\n")
174         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
175             "SET(${PROJECT_NAME}_TEST_SRC)\n")
176         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
177             "SET(${PROJECT_NAME}_APP_SRC)\n")
178         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
179             "SET(${PROJECT_NAME}_INC)\n\n")
180     ENDIF(${OSG_CMAKE_PASS} STREQUAL "OSGCOLLECT")
182     # clear dependency variables
183     SET(${PROJECT_NAME}_DEP_OSG_LIB)
184     SET(${PROJECT_NAME}_DEP_TEST_OSG_LIB)
185     SET(${PROJECT_NAME}_DEP_TEST_OSG_EEX_LIB)
186     SET(${PROJECT_NAME}_DEP_UNITTEST_OSG_LIB)
188     SET(${PROJECT_NAME}_DEP_LIB)
189     SET(${PROJECT_NAME}_DEP_LIBDIR)
190     SET(${PROJECT_NAME}_DEP_INCDIR)
191     SET(${PROJECT_NAME}_DEP_DEFS)
193     SET(${PROJECT_NAME}_DEP_TEST_LIB)
194     SET(${PROJECT_NAME}_DEP_TEST_LIBDIR)
195     SET(${PROJECT_NAME}_DEP_TEST_INCDIR)
196     SET(${PROJECT_NAME}_DEP_TEST_DEFS)
198     SET(${PROJECT_NAME}_DEP_UNITTEST_LIB)
199     SET(${PROJECT_NAME}_DEP_UNITTEST_LIBDIR)
200     SET(${PROJECT_NAME}_DEP_UNITTEST_INCDIR)
202     SET(${PROJECT_NAME}_DEP_ADD_INCDIR)
204     SET(${PROJECT_NAME}_EXCL_FILES)
206     SET(${PROJECT_NAME}_BASE_DIR)
208     SET(${PROJECT_NAME}_SRC_PATTERNS)
209     SET(${PROJECT_NAME}_HDR_PATTERNS)
210     SET(${PROJECT_NAME}_INL_PATTERNS)
212     SET(${PROJECT_NAME}_SUFFIX)
214     SET(${PROJECT_NAME}_NO_DOC)
216     SET(${PROJECT_NAME}_NO_PYTHON)
217     SET(${PROJECT_NAME}_NO_DBG_INSTALL FALSE)
218     SET(${PROJECT_NAME}_ENABLE_WRITE_PYTHON_TO_SOURCE)
220 ENDMACRO(OSG_SELECT_PROJECT)
222 #############################################################################
223 # Extract separate libs and paths from a list of files.
225 # cmake stores libraries as full paths to the library file, this splits
226 # this form into a library (suitable for use on the linker command line) and
227 # the path where that library can be found.
228 FUNCTION(OSG_EXTRACT_LIB_AND_LIBDIR INLIBS OUTLIBS OUTLIBDIRS)
230     FOREACH(INLIB ${INLIBS})
231         GET_FILENAME_COMPONENT(INLIB_LIB    ${INLIB} NAME)
232         GET_FILENAME_COMPONENT(INLIB_LIBDIR ${INLIB} PATH)
234         STRING(REPLACE "${CMAKE_SHARED_LIBRARY_PREFIX}" "" INLIB_LIB ${INLIB_LIB})
235         STRING(REPLACE "${CMAKE_SHARED_LIBRARY_SUFFIX}" "" INLIB_LIB ${INLIB_LIB})
237         LIST(APPEND OLIBS ${INLIB_LIB})
238         LIST(APPEND OLIBDIRS ${INLIB_LIBDIR})
239     ENDFOREACH(INLIB)
241     SET(${OUTLIBS} ${OLIBS} PARENT_SCOPE)
242     SET(${OUTLIBDIRS} ${OLIBDIRS} PARENT_SCOPE)
244 ENDFUNCTION(OSG_EXTRACT_LIB_AND_LIBDIR)
246 FUNCTION(OSG_EXTRACT_LIBDIR INLIBDIRS OUTLIBDIRS)
248     FOREACH(INLIBDIR ${INLIBDIRS})
249         LIST(APPEND OLIBDIRS ${INLIBDIR})
250     ENDFOREACH(INLIBDIR)
252     SET(${OUTLIBDIRS} ${OLIBDIRS} PARENT_SCOPE)
253 ENDFUNCTION(OSG_EXTRACT_LIBDIR)
255 FUNCTION(OSG_EXTRACT_INCDIR ININCDIRS OUTINCDIRS)
257     FOREACH(ININCDIR ${ININCDIRS})
258         LIST(APPEND OINCDIRS ${ININCDIR})
259     ENDFOREACH(ININCDIR)
261     SET(${OUTINCDIRS} ${OINCDIRS} PARENT_SCOPE)
262 ENDFUNCTION(OSG_EXTRACT_INCDIR)
264 #############################################################################
265 # write the dependecy variables to the ${${PROJECT_NAME}_BUILD_FILE} file
266 # for use during the build and to
267 # ${${PROJECT_NAME}_CONFIG_FILE} for constructing osg2-config
269 FUNCTION(OSG_STORE_PROJECT_DEPENDENCIES)
270     IF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGCOLLECT")
271         RETURN()
272     ENDIF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGCOLLECT")
274     IF(OSG_ENABLE_WRITE_PYTHON_TO_SOURCE OR ${PROJECT_NAME}_ENABLE_WRITE_PYTHON_TO_SOURCE)
275       SET(OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/module" CACHE INTERNAL "" FORCE)
276     ELSE()
277       IF(OSG_PYTHON_MODULE_BASE_DIR)
278         SET(OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR "${OSG_PYTHON_MODULE_BASE_DIR}/${PROJECT_NAME}/module" CACHE INTERNAL "" FORCE)
279       ELSE()
280         SET(OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR "${CMAKE_BINARY_DIR}/Python/${PROJECT_NAME}/module" CACHE INTERNAL "" FORCE)
281       ENDIF()
282     ENDIF()
284     #########################################
285     # store dependencies for the build
287     # dependencies - OpenSG
288     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
289         "SET(${PROJECT_NAME}_DEP_OSG_LIB ${${PROJECT_NAME}_DEP_OSG_LIB})\n")
290     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
291         "SET(${PROJECT_NAME}_DEP_TEST_OSG_LIB ${${PROJECT_NAME}_DEP_TEST_OSG_LIB})\n\n")
292     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
293         "SET(${PROJECT_NAME}_DEP_TEST_OSG_EEX_LIB ${${PROJECT_NAME}_DEP_TEST_OSG_EEX_LIB})\n\n")
294     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
295         "SET(${PROJECT_NAME}_DEP_UNITTEST_OSG_LIB ${${PROJECT_NAME}_DEP_UNITTEST_OSG_LIB})\n\n")
297     # dependencies - external
298     IF(OSG_GLOBAL_LIB)
299       LIST(APPEND ${PROJECT_NAME}_DEP_LIB ${OSG_GLOBAL_LIB})
300     ENDIF(OSG_GLOBAL_LIB)
301     IF(${PROJECT_NAME}_ADD_LIB)
302       LIST(APPEND ${PROJECT_NAME}_DEP_LIB ${${PROJECT_NAME}_ADD_LIB})
303     ENDIF(${PROJECT_NAME}_ADD_LIB)
305     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
306         "SET(${PROJECT_NAME}_DEP_LIB ${${PROJECT_NAME}_DEP_LIB})\n")
307     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
308         "SET(${PROJECT_NAME}_DEP_LIBDIR ${${PROJECT_NAME}_DEP_LIBDIR})\n")
309     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
310         "SET(${PROJECT_NAME}_DEP_INCDIR ${${PROJECT_NAME}_DEP_INCDIR})\n\n")
312     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
313         "SET(${PROJECT_NAME}_DEP_TEST_LIB ${${PROJECT_NAME}_DEP_TEST_LIB})\n")
314     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
315         "SET(${PROJECT_NAME}_DEP_TEST_LIBDIR ${${PROJECT_NAME}_DEP_TEST_LIBDIR})\n")
316     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
317         "SET(${PROJECT_NAME}_DEP_TEST_INCDIR ${${PROJECT_NAME}_DEP_TEST_INCDIR})\n\n")
319     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
320         "SET(${PROJECT_NAME}_DEP_UNITTEST_LIB ${${PROJECT_NAME}_DEP_UNITTEST_LIB})\n")
321     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
322         "SET(${PROJECT_NAME}_DEP_UNITTEST_LIBDIR ${${PROJECT_NAME}_DEP_UNITTEST_LIBDIR})\n")
323     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
324         "SET(${PROJECT_NAME}_DEP_UNITTEST_INCDIR ${${PROJECT_NAME}_DEP_UNITTEST_INCDIR})\n\n")
326     # dependencies - additional
327     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
328         "SET(${PROJECT_NAME}_DEP_ADD_INCDIR ${${PROJECT_NAME}_DEP_ADD_INCDIR})\n\n")
329     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
330         "SET(${PROJECT_NAME}_DEP_DEFS ${${PROJECT_NAME}_DEP_DEFS})\n\n")
332     # for external projects
334     FILE(APPEND "${CMAKE_BINARY_DIR}/OpenSGExtDep.cmake"
335         "SET(${PROJECT_NAME}_DEP_OSG_LIB ${${PROJECT_NAME}_DEP_OSG_LIB})\n\n")
337     FILE(APPEND "${CMAKE_BINARY_DIR}/OpenSGExtDep.cmake"
338         "SET(${PROJECT_NAME}_DEP_LIB ${${PROJECT_NAME}_DEP_LIB})\n\n")
340     FILE(APPEND "${CMAKE_BINARY_DIR}/OpenSGExtDep.cmake"
341         "LIST(APPEND STORED_PROJECTS ${PROJECT_NAME})\n\n")
345     #########################################################################
346     # Store dependencies for osg2-config.
347     # This is a bit lengthy as it writes a python dictionary
349     FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
350         "############################################################\n")
351     FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
352         "## Dependecies for ${PROJECT_NAME}\n\n")
354     # OpenSG libraries this lib depends on
355     FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
356         "\"${PROJECT_NAME}\" : {\n")
357     FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
358         "    \"dep_osg_lib\"  :  [")
360     FOREACH(DEPOSGLIB ${${PROJECT_NAME}_DEP_OSG_LIB})
361         FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
362             " \"${DEPOSGLIB}\", ")
363     ENDFOREACH(DEPOSGLIB)
365     FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
366         " ],\n")
368     # global dependencies
369     FOREACH(DEPLIB ${OSG_GLOBAL_DEP_LIBS})
370         OSG_EXTRACT_LIB_AND_LIBDIR("${${DEPLIB}}" LIBS LIBDIRS)
372         FOREACH(LIB ${LIBS})
373             # if the lib is an import target, get the location and
374             # split that into library name and path
376             IF(TARGET ${LIB})
377                 GET_TARGET_PROPERTY(_LIB_LOCATION ${LIB} IMPORTED_LOCATION)
379                 OSG_EXTRACT_LIB_AND_LIBDIR("${_LIB_LOCATION}" _LIBS _LIBDIRS)
381                 LIST(APPEND DEPLIBS    ${_LIBS})
382                 LIST(APPEND DEPLIBDIRS ${_LIBDIRS})
383             ELSE(TARGET ${LIB})
384                 LIST(APPEND DEPLIBS ${LIB})
385             ENDIF(TARGET ${LIB})
386         ENDFOREACH(LIB)
388         LIST(APPEND DEPLIBDIRS ${LIBDIRS})
389     ENDFOREACH(DEPLIB)
391     FOREACH(DEPLIBDIR ${OSG_GLOBAL_DEP_LIBDIR})
392         OSG_EXTRACT_LIBDIR("${${DEPLIBDIR}}" LIBDIRS)
394         LIST(APPEND DEPLIBDIRS ${LIBDIRS})
395     ENDFOREACH(DEPLIBDIR)
397     FOREACH(DEPINCDIR ${OSG_GLOBAL_DEP_INCDIR})
398         OSG_EXTRACT_INCDIR("${${DEPINCDIR}}" INCDIRS)
400         LIST(APPEND DEPINCDIRS ${INCDIRS})
401     ENDFOREACH(DEPINCDIR)
403     # External libraries this lib depends on
404     # we build lists of libs, libdirs and incdirs then write them
405     FOREACH(DEPLIB ${${PROJECT_NAME}_DEP_LIB})
406         OSG_EXTRACT_LIB_AND_LIBDIR("${${DEPLIB}}" LIBS LIBDIRS)
408         FOREACH(LIB ${LIBS})
409             # if the lib is an import target, get the location and
410             # split that into library name and path
412             IF(TARGET ${LIB})
413                 GET_TARGET_PROPERTY(_LIB_LOCATION ${LIB} IMPORTED_LOCATION)
415                 OSG_EXTRACT_LIB_AND_LIBDIR("${_LIB_LOCATION}" _LIBS _LIBDIRS)
417                 LIST(APPEND DEPLIBS    ${_LIBS})
418                 LIST(APPEND DEPLIBDIRS ${_LIBDIRS})
419             ELSE(TARGET ${LIB})
420                 LIST(APPEND DEPLIBS ${LIB})
421             ENDIF(TARGET ${LIB})
422         ENDFOREACH(LIB)
424         LIST(APPEND DEPLIBDIRS ${LIBDIRS})
425     ENDFOREACH(DEPLIB)
427     FOREACH(DEPLIBDIR ${${PROJECT_NAME}_DEP_LIBDIR})
428         OSG_EXTRACT_LIBDIR("${${DEPLIBDIR}}" LIBDIRS)
430         LIST(APPEND DEPLIBDIRS ${LIBDIRS})
431     ENDFOREACH(DEPLIBDIR)
433     FOREACH(DEPINCDIR ${${PROJECT_NAME}_DEP_INCDIR})
434         OSG_EXTRACT_INCDIR("${${DEPINCDIR}}" INCDIRS)
436         LIST(APPEND DEPINCDIRS ${INCDIRS})
437     ENDFOREACH(DEPINCDIR)
439     IF(DEPLIBS)
440         LIST(REMOVE_DUPLICATES DEPLIBS)
441     ENDIF(DEPLIBS)
443     IF(DEPLIBDIRS)
444         LIST(REMOVE_DUPLICATES DEPLIBDIRS)
445     ENDIF(DEPLIBDIRS)
447     IF(DEPINCDIRS)
448         LIST(REMOVE_DUPLICATES DEPINCDIRS)
449     ENDIF(DEPINCDIRS)
451     IF(DEPLIBS OR DEPLIBDIRS OR DEPINCDIRS)
452         OSG_MSG("   DEPLIBS: ${DEPLIBS}")
453         OSG_MSG("   DEPLIBDIRS: ${DEPLIBDIRS}")
454         OSG_MSG("   DEPINCDIRS: ${DEPINCDIRS}")
455     ENDIF(DEPLIBS OR DEPLIBDIRS OR DEPINCDIRS)
457     FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
458         "    \"dep_lib\"  :  [")
460     FOREACH(LIB ${DEPLIBS})
461         FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
462             " \"${LIB}\", ")
463     ENDFOREACH(LIB)
465     FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
466         " ],\n")
467     FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
468         "    \"dep_lib_dir\"  :  [")
470     FOREACH(LIBDIR ${DEPLIBDIRS})
471         FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
472             " \"${LIBDIR}\", ")
473     ENDFOREACH(LIBDIR)
475     FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
476         " ],\n")
478     FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
479         "    \"dep_inc_dir\"  :  [")
481     FOREACH(INCDIR ${DEPINCDIRS})
482         FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
483             " \"${INCDIR}\", ")
484     ENDFOREACH(INCDIR)
486     FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
487         " ],\n")
489     FILE(APPEND ${${PROJECT_NAME}_CONFIG_FILE}
490         "},\n")
492 ENDFUNCTION(OSG_STORE_PROJECT_DEPENDENCIES)
495 #############################################################################
496 # add directory DIRNAME to current project
498 FUNCTION(OSG_ADD_DIRECTORY DIRNAME)
500     IF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGCOLLECT")
501         RETURN()
502     ENDIF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGCOLLECT")
504     OSG_MSG("Adding directory: ${DIRNAME}")
506     SET(_OSG_ADD_SRC_LOOKUP)
507     SET(_OSG_ADD_HDR_LOOKUP)
508     SET(_OSG_ADD_INL_LOOKUP)
510     IF(EXISTS "${CMAKE_SOURCE_DIR}/${DIRNAME}")
511         SET(_OSG_CURR_DIRNAME "${CMAKE_SOURCE_DIR}/${DIRNAME}")
513         FOREACH(_OSG_FILE_PATTERN ${${PROJECT_NAME}_SRC_PATTERNS})
514           LIST(APPEND _OSG_ADD_SRC_LOOKUP "${CMAKE_SOURCE_DIR}/${DIRNAME}/${_OSG_FILE_PATTERN}")
515         ENDFOREACH()
517         FOREACH(_OSG_FILE_PATTERN ${${PROJECT_NAME}_HDR_PATTERNS})
518           LIST(APPEND _OSG_ADD_HDR_LOOKUP "${CMAKE_SOURCE_DIR}/${DIRNAME}/${_OSG_FILE_PATTERN}")
519         ENDFOREACH()
521         FOREACH(_OSG_FILE_PATTERN ${${PROJECT_NAME}_INL_PATTERNS})
522           LIST(APPEND _OSG_ADD_INL_LOOKUP "${CMAKE_SOURCE_DIR}/${DIRNAME}/${_OSG_FILE_PATTERN}")
523         ENDFOREACH()
525         FILE(GLOB LOCAL_SRC          "${CMAKE_SOURCE_DIR}/${DIRNAME}/OSG*.cpp"
526                                      "${CMAKE_SOURCE_DIR}/${DIRNAME}/OSG*.mm"
527                                       ${_OSG_ADD_SRC_LOOKUP}                )
528         FILE(GLOB LOCAL_HDR          "${CMAKE_SOURCE_DIR}/${DIRNAME}/OSG*.h"
529                                       ${_OSG_ADD_HDR_LOOKUP}               )
530         FILE(GLOB LOCAL_INL          "${CMAKE_SOURCE_DIR}/${DIRNAME}/OSG*.inl"
531                                       ${_OSG_ADD_INL_LOOKUP}                 )
532         FILE(GLOB LOCAL_INS          "${CMAKE_SOURCE_DIR}/${DIRNAME}/OSG*.ins")
533         FILE(GLOB LOCAL_FCD          "${CMAKE_SOURCE_DIR}/${DIRNAME}/OSG*.fcd")
534         FILE(GLOB LOCAL_LL           "${CMAKE_SOURCE_DIR}/${DIRNAME}/OSG*.ll")
535         FILE(GLOB LOCAL_YY           "${CMAKE_SOURCE_DIR}/${DIRNAME}/OSG*.yy")
536         FILE(GLOB LOCAL_MOC          "${CMAKE_SOURCE_DIR}/${DIRNAME}/OSG*_qt.h")
537         FILE(GLOB LOCAL_UNITTEST_SRC "${CMAKE_SOURCE_DIR}/${DIRNAME}/OSG*Test.cpp")
538         FILE(GLOB LOCAL_TEST_SRC     "${CMAKE_SOURCE_DIR}/${DIRNAME}/test*.cpp"
539                                      "${CMAKE_SOURCE_DIR}/${DIRNAME}/test*.mm")
540         FILE(GLOB LOCAL_APP_SRC      "${CMAKE_SOURCE_DIR}/${DIRNAME}/app*.cpp")
541         FILE(GLOB BASE_MM            "${CMAKE_SOURCE_DIR}/${DIRNAME}/OSG*Base.mm")
542     ELSEIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}")
543         SET(_OSG_CURR_DIRNAME "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}")
545         FOREACH(_OSG_FILE_PATTERN ${${PROJECT_NAME}_SRC_PATTERNS})
546           LIST(APPEND _OSG_ADD_SRC_LOOKUP "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/${_OSG_FILE_PATTERN}")
547         ENDFOREACH()
549         FOREACH(_OSG_FILE_PATTERN ${${PROJECT_NAME}_HDR_PATTERNS})
550           LIST(APPEND _OSG_ADD_HDR_LOOKUP "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/${_OSG_FILE_PATTERN}")
551         ENDFOREACH()
553         FOREACH(_OSG_FILE_PATTERN ${${PROJECT_NAME}_INL_PATTERNS})
554           LIST(APPEND _OSG_ADD_INL_LOOKUP "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/${_OSG_FILE_PATTERN}")
555         ENDFOREACH()
557         FILE(GLOB LOCAL_SRC          "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/OSG*.cpp"
558                                      "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/OSG*.mm"
559                                       ${_OSG_ADD_SRC_LOOKUP}                        )
560         FILE(GLOB LOCAL_HDR          "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/OSG*.h"
561                                      ${_OSG_ADD_HDR_LOOKUP}                        )
562         FILE(GLOB LOCAL_INL          "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/OSG*.inl"
563                                      ${_OSG_ADD_INL_LOOKUP}                          )
564         FILE(GLOB LOCAL_INS          "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/OSG*.ins")
565         FILE(GLOB LOCAL_FCD          "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/OSG*.fcd")
566         FILE(GLOB LOCAL_LL           "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/OSG*.ll")
567         FILE(GLOB LOCAL_YY           "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/OSG*.yy")
568         FILE(GLOB LOCAL_MOC          "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/OSG*_qt.h")
569         FILE(GLOB LOCAL_UNITTEST_SRC "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/OSG*Test.cpp")
570         FILE(GLOB LOCAL_TEST_SRC     "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/test*.cpp"
571                                      "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/test*.mm")
572         FILE(GLOB LOCAL_APP_SRC      "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/app*.cpp")
573         FILE(GLOB BASE_MM            "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}/OSG*Base.mm")
574     ELSE()
575         SET(_OSG_CURR_DIRNAME "${DIRNAME}")
577         FOREACH(_OSG_FILE_PATTERN ${${PROJECT_NAME}_SRC_PATTERNS})
578           LIST(APPEND _OSG_ADD_SRC_LOOKUP "${DIRNAME}/${_OSG_FILE_PATTERN}")
579         ENDFOREACH()
581         FOREACH(_OSG_FILE_PATTERN ${${PROJECT_NAME}_HDR_PATTERNS})
582           LIST(APPEND _OSG_ADD_HDR_LOOKUP "${DIRNAME}/${_OSG_FILE_PATTERN}")
583         ENDFOREACH()
585         FOREACH(_OSG_FILE_PATTERN ${${PROJECT_NAME}_INL_PATTERNS})
586           LIST(APPEND _OSG_ADD_INL_LOOKUP "${DIRNAME}/${_OSG_FILE_PATTERN}")
587         ENDFOREACH()
589         # Guess it's an absolute dir we got as the rel one is not there
590         FILE(GLOB LOCAL_SRC          "${DIRNAME}/OSG*.cpp" 
591                                      "${DIRNAME}/OSG*.mm"
592                                       ${_OSG_ADD_SRC_LOOKUP})
593         FILE(GLOB LOCAL_HDR          "${DIRNAME}/OSG*.h"
594                                       ${_OSG_ADD_HDR_LOOKUP})
595         FILE(GLOB LOCAL_INL          "${DIRNAME}/OSG*.inl"
596                                       ${_OSG_ADD_INL_LOOKUP})
597         FILE(GLOB LOCAL_INS          "${DIRNAME}/OSG*.ins")
598         FILE(GLOB LOCAL_FCD          "${DIRNAME}/OSG*.fcd")
599         FILE(GLOB LOCAL_LL           "${DIRNAME}/OSG*.ll")
600         FILE(GLOB LOCAL_YY           "${DIRNAME}/OSG*.yy")
601         FILE(GLOB LOCAL_MOC          "${DIRNAME}/OSG*_qt.h")
602         FILE(GLOB LOCAL_UNITTEST_SRC "${DIRNAME}/OSG*Test.cpp")
603         FILE(GLOB LOCAL_TEST_SRC     "${DIRNAME}/test*.cpp"
604                                      "${DIRNAME}/test*.mm")
605         FILE(GLOB LOCAL_APP_SRC      "${DIRNAME}/app*.cpp")
606         FILE(GLOB BASE_MM            "${DIRNAME}/OSG*Base.mm")
607     ENDIF()
609     IF(BASE_MM)
610         FOREACH(BaseMMFile ${BASE_MM})
611         STRING(REGEX REPLACE mm$ cpp BaseMMFileCPP ${BaseMMFile})
612         LIST(APPEND BASE_MM_CPP ${BaseMMFileCPP})
613     ENDFOREACH()
614     ENDIF(BASE_MM)
616     IF(BASE_MM_CPP)
617         LIST(REMOVE_ITEM LOCAL_SRC ${BASE_MM_CPP})
618     ENDIF(BASE_MM_CPP)
620     IF(${PROJECT_NAME}_EXCL_FILES)
621         LIST(REMOVE_ITEM LOCAL_SRC          ${${PROJECT_NAME}_EXCL_FILES})
622         LIST(REMOVE_ITEM LOCAL_HDR          ${${PROJECT_NAME}_EXCL_FILES})
623         LIST(REMOVE_ITEM LOCAL_INL          ${${PROJECT_NAME}_EXCL_FILES})
624         LIST(REMOVE_ITEM LOCAL_INS          ${${PROJECT_NAME}_EXCL_FILES})
625         LIST(REMOVE_ITEM LOCAL_FCD          ${${PROJECT_NAME}_EXCL_FILES})
626         LIST(REMOVE_ITEM LOCAL_LL           ${${PROJECT_NAME}_EXCL_FILES})
627         LIST(REMOVE_ITEM LOCAL_YY           ${${PROJECT_NAME}_EXCL_FILES})
628         LIST(REMOVE_ITEM LOCAL_UNITTEST_SRC ${${PROJECT_NAME}_EXCL_FILES})
629         LIST(REMOVE_ITEM LOCAL_TEST_SRC     ${${PROJECT_NAME}_EXCL_FILES})
630         LIST(REMOVE_ITEM LOCAL_APP_SRC      ${${PROJECT_NAME}_EXCL_FILES})
631     ENDIF(${PROJECT_NAME}_EXCL_FILES)
633     # filter unittest sources out of library sources
634     IF(LOCAL_UNITTEST_SRC)
635         LIST(REMOVE_ITEM LOCAL_SRC ${LOCAL_UNITTEST_SRC})
636     ENDIF(LOCAL_UNITTEST_SRC)
638     # store file lists
639     FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE} "# File lists for ${DIRNAME}\n\n")
641     # library sources
642     IF(LOCAL_SRC)
643         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
644              "LIST(APPEND ${PROJECT_NAME}_SRC \"${LOCAL_SRC}\")\n\n")
645     ENDIF(LOCAL_SRC)
647     IF(LOCAL_HDR)
648         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
649              "LIST(APPEND ${PROJECT_NAME}_HDR \"${LOCAL_HDR}\")\n\n")
650     ENDIF(LOCAL_HDR)
652     IF(LOCAL_INL)
653         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
654              "LIST(APPEND ${PROJECT_NAME}_INL \"${LOCAL_INL}\")\n\n")
655     ENDIF(LOCAL_INL)
657     IF(LOCAL_INS)
658         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
659              "LIST(APPEND ${PROJECT_NAME}_INS \"${LOCAL_INS}\")\n\n")
660     ENDIF(LOCAL_INS)
662     IF(LOCAL_FCD)
663         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
664              "LIST(APPEND ${PROJECT_NAME}_FCD \"${LOCAL_FCD}\")\n\n")
665     ENDIF(LOCAL_FCD)
667     IF(LOCAL_LL)
668         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
669              "LIST(APPEND ${PROJECT_NAME}_LL \"${LOCAL_LL}\")\n\n")
670     ENDIF(LOCAL_LL)
672     IF(LOCAL_YY)
673         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
674              "LIST(APPEND ${PROJECT_NAME}_YY \"${LOCAL_YY}\")\n\n")
675     ENDIF(LOCAL_YY)
677     IF(LOCAL_MOC)
678         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
679              "LIST(APPEND ${PROJECT_NAME}_MOC \"${LOCAL_MOC}\")\n\n")
680     ENDIF(LOCAL_MOC)
682     IF(NOT OSG_DISABLE_SOURCE_GROUPS)
683       IF(NOT ${PROJECT_NAME}_BASE_DIR)
684         # Add the source files to the source group
685         #Strip the path down to a relative one
686         IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}")
687           FILE(RELATIVE_PATH THE_SOURCE_GROUP
688                              ${CMAKE_CURRENT_SOURCE_DIR}/Source
689                              ${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME})
690         ELSEIF(EXISTS "${CMAKE_SOURCE_DIR}/${DIRNAME}")
691           FILE(RELATIVE_PATH THE_SOURCE_GROUP
692                              ${CMAKE_SOURCE_DIR}/Source
693                              ${CMAKE_SOURCE_DIR}/${DIRNAME})
694         ELSE()
695           FILE(RELATIVE_PATH THE_SOURCE_GROUP
696                              ${CMAKE_SOURCE_DIR}/Source
697                              ${CMAKE_SOURCE_DIR}/${DIRNAME})
698         ENDIF()
699       ELSE()
700           FILE(RELATIVE_PATH THE_SOURCE_GROUP
701                              ${${PROJECT_NAME}_BASE_DIR}/
702                              ${_OSG_CURR_DIRNAME})
703       ENDIF()
705       IF(THE_SOURCE_GROUP)
706            STRING(REPLACE "/" "\\" THE_SOURCE_GROUP ${THE_SOURCE_GROUP})
707       ELSE(THE_SOURCE_GROUP)
708            SET(THE_SOURCE_GROUP "Source")
709       ENDIF(THE_SOURCE_GROUP)
711       IF(${THE_SOURCE_GROUP} STREQUAL "\\")
712            SET(THE_SOURCE_GROUP "Source")
713       ENDIF()
715       LIST(APPEND ${PROJECT_NAME}_SOURCE_GROUPS ${THE_SOURCE_GROUP})
716       SET(${PROJECT_NAME}_SOURCE_GROUPS ${${PROJECT_NAME}_SOURCE_GROUPS}
717                                         CACHE INTERNAL "" FORCE)
719       STRING(REPLACE "\\" "_" THE_SOURCE_GROUP ${THE_SOURCE_GROUP})
720       LIST(APPEND ${PROJECT_NAME}_SOURCE_GROUP_${THE_SOURCE_GROUP}
721                   ${LOCAL_SRC}
722                   ${LOCAL_HDR}
723                   ${LOCAL_INL}
724                   ${LOCAL_INS}
725                   ${LOCAL_FCD}
726                   ${LOCAL_LL}
727                   ${LOCAL_YY}
728                   ${LOCAL_MOC})
730       SET(${PROJECT_NAME}_SOURCE_GROUP_${THE_SOURCE_GROUP}
731             ${${PROJECT_NAME}_SOURCE_GROUP_${THE_SOURCE_GROUP}}
732             CACHE INTERNAL "" FORCE)
734     ENDIF(NOT OSG_DISABLE_SOURCE_GROUPS)
736     # unittests
737     IF(LOCAL_UNITTEST_SRC)
738         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
739             "LIST(APPEND ${PROJECT_NAME}_UNITTEST_SRC \"${LOCAL_UNITTEST_SRC}\")\n\n")
740     ENDIF(LOCAL_UNITTEST_SRC)
742     # tests
743     IF(LOCAL_TEST_SRC)
744         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
745              "LIST(APPEND ${PROJECT_NAME}_TEST_SRC \"${LOCAL_TEST_SRC}\")\n\n")
746     ENDIF(LOCAL_TEST_SRC)
748     # apps
749     IF(LOCAL_APP_SRC)
750         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
751              "LIST(APPEND ${PROJECT_NAME}_APP_SRC \"${LOCAL_APP_SRC}\")\n\n")
752     ENDIF(LOCAL_APP_SRC)
754     IF(EXISTS "${CMAKE_SOURCE_DIR}/${DIRNAME}")
755         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
756              "LIST(APPEND ${PROJECT_NAME}_INC \"${CMAKE_SOURCE_DIR}/${DIRNAME}\")\n\n")
757     ELSEIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}")
758         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
759              "LIST(APPEND ${PROJECT_NAME}_INC \"${CMAKE_CURRENT_SOURCE_DIR}/${DIRNAME}\")\n\n")
760     ELSE()
761         FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
762              "LIST(APPEND ${PROJECT_NAME}_INC \"${DIRNAME}\")\n\n")
763     ENDIF()
764 ENDFUNCTION(OSG_ADD_DIRECTORY)
767 #############################################################################
768 # perform default actions for pass OSGSETUP
770 FUNCTION(OSG_SETUP_LIBRARY_BUILD PROJ_DEFINE)
772     IF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGSETUP")
773         RETURN()
774     ENDIF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGSETUP")
776     IF(${PROJECT_NAME}_NO_LIB)
777         RETURN()
778     ENDIF()
780     # read file lists
781     OSG_CHECKED_INCLUDE(${${PROJECT_NAME}_BUILD_FILE})
783     #####
784     # FCD
785     #####
787     IF(OSG_ENABLE_FCD2CODE AND PYTHONINTERP_FOUND)
789         FOREACH(FCDFile ${${PROJECT_NAME}_FCD})
790             GET_FILENAME_COMPONENT(FCDBase ${FCDFile} NAME_WE)
791             GET_FILENAME_COMPONENT(FCDDir  ${FCDFile} PATH)
793             SET(FCDBaseHdr "${FCDBase}Base.h")
794             SET(FCDBaseCpp "${FCDBase}Base.cpp")
795             SET(FCDBaseInl "${FCDBase}Base.inl")
796             SET(FCDBaseFld "${FCDBase}Fields.h")
798             SET(FCDClassHdr "${FCDBase}.h")
799             SET(FCDClassCpp "${FCDBase}.cpp")
800             SET(FCDClassInl "${FCDBase}.inl")
802             IF(NOT EXISTS ${FCDDir}/${FCDBaseCpp})
803                 SET(${PROJECT_NAME}_SRC ${${PROJECT_NAME}_SRC} ${FCDDir}/${FCDBaseCpp})
804                 SET(${PROJECT_NAME}_HDR ${${PROJECT_NAME}_HDR} ${FCDDir}/${FCDBaseHdr})
805                 SET(${PROJECT_NAME}_INL ${${PROJECT_NAME}_INL} ${FCDDir}/${FCDBaseInl})
806                 SET(${PROJECT_NAME}_HDR ${${PROJECT_NAME}_HDR} ${FCDDir}/${FCDBaseFld})
808                 IF(NOT EXISTS ${FCDDir}/${FCDClassHdr})
809                     SET(${PROJECT_NAME}_SRC ${${PROJECT_NAME}_SRC} ${FCDDir}/${FCDClassCpp})
810                     SET(${PROJECT_NAME}_HDR ${${PROJECT_NAME}_HDR} ${FCDDir}/${FCDClassHdr})
811                     SET(${PROJECT_NAME}_INL ${${PROJECT_NAME}_INL} ${FCDDir}/${FCDClassInl})
813                     SET(FCD_TMP_OUT ${FCDDir}/${FCDClassCpp}
814                                     ${FCDDir}/${FCDClassHdr}
815                                     ${FCDDir}/${FCDClassInl})
816                 ENDIF(NOT EXISTS ${FCDDir}/${FCDClassHdr})
817             ENDIF(NOT EXISTS ${FCDDir}/${FCDBaseCpp})
819             SET(FCDBaseDir ${CMAKE_SOURCE_DIR}/Tools/fcd2code)
820             SET(FCDCommand ${CMAKE_SOURCE_DIR}/Tools/fcd2code/fcd2code)
821             SET(FCDRoot -r ${CMAKE_SOURCE_DIR})
822             SET(FCDTemp "")
824             SET(FCDPath ${CMAKE_SOURCE_DIR}/Tools/fcd2code)
826             IF(NOT EXISTS FCDPath AND OpenSG_DIR) #external setup
827               SET(FCDBaseDir ${OpenSG_DIR}/bin/fcd2code)
829               SET(FCDCommand ${OpenSG_DIR}/bin/fcd2code/fcd2code)
831               SET(FCDRoot "")
832               SET(FCDTemp -t ${FCDBaseDir})
833             ENDIF(NOT EXISTS FCDPath AND OpenSG_DIR)
835             IF(NOT EXISTS ${FCDDir}/${FCDClassHdr} AND
836                NOT EXISTS ${FCDDir}/${FCDClassCpp} AND
837                NOT EXISTS ${FCDDir}/${FCDClassInl} AND
838                OSG_FCD2CODE_WRITE_CLASS              )
840                SET(_OSG_IGNORE_CLASSWRITE -1)
842                IF(OSG_IGNORE_CLASSBUILD)
843                  LIST(FIND OSG_IGNORE_CLASSBUILD ${FCDBase} _OSG_IGNORE_CLASSWRITE)
844                ENDIF(OSG_IGNORE_CLASSBUILD)
846                IF(_OSG_IGNORE_CLASSWRITE EQUAL -1)
847                  MESSAGE(STATUS "writing ${FCDDir}/${FCDClassHdr} ${FCDDir}/${FCDClassCpp} ${FCDDir}/${FCDClassInl}")
849                  EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} ${FCDCommand} -c -f -d ${FCDFile} -p ${FCDDir} ${FCDRoot} ${FCDTemp})
850                ENDIF(_OSG_IGNORE_CLASSWRITE EQUAL -1)
852             ENDIF()
854             ADD_CUSTOM_COMMAND(
855                 OUTPUT ${FCDDir}/${FCDBaseHdr}
856                        ${FCDDir}/${FCDBaseCpp}
857                        ${FCDDir}/${FCDBaseInl}
858                        ${FCDDir}/${FCDBaseFld}
859                        ${FCD_TMP_OUT}
860                 COMMAND ${PYTHON_EXECUTABLE} ${FCDCommand} -c -b -d ${FCDFile} -p ${FCDDir} ${FCDRoot} ${FCDTemp}
861                 MAIN_DEPENDENCY ${FCDFile}
862                 DEPENDS ${FCDBaseDir}/TemplateFieldContainerBase_h.txt
863                         ${FCDBaseDir}/TemplateFieldContainerBase_inl.txt
864                         ${FCDBaseDir}/TemplateFieldContainerBase_cpp.txt
865                         ${FCDBaseDir}/TemplateFieldContainerFields_h.txt)
867             SET(FCD_TMP_OUT )
868         ENDFOREACH(FCDFile)
870     ENDIF(OSG_ENABLE_FCD2CODE AND PYTHONINTERP_FOUND)
872     ############
873     # Qt4
874     ############
876     IF(${PROJECT_NAME} STREQUAL "OSGWindowQT4")
877         # Here only the OSG_WITH_QT define is passes to qt moc.
878         SET(moc_flags -DOSG_WITH_QT)
880         SET(${PROJECT_NAME}_INC ${${PROJECT_NAME}_INC} ${CMAKE_CURRENT_BINARY_DIR})
882         FOREACH(MOCFile ${${PROJECT_NAME}_MOC})
883             GET_FILENAME_COMPONENT(MOCFile ${MOCFile} ABSOLUTE)
884             QT4_MAKE_OUTPUT_FILE(${MOCFile} moc_ cpp MOCOutFile)
886             ADD_CUSTOM_COMMAND(
887                 OUTPUT ${MOCOutFile}
888                 COMMAND ${QT_MOC_EXECUTABLE}
889                 ARGS ${moc_flags} ${moc_options} -o ${MOCOutFile} ${MOCFile}
890                 DEPENDS ${MOCFile})
891             LIST(APPEND ${PROJECT_NAME}_SRC ${MOCOutFile})
892         ENDFOREACH(MOCFile)
893     ENDIF(${PROJECT_NAME} STREQUAL "OSGWindowQT4")
895     ############
896     # Flex/Bison
897     ############
899     IF(OSG_ENABLE_SCANPARSE_REGEN AND FLEX_EXE AND BISON_EXE)
901         FOREACH(YYFile ${${PROJECT_NAME}_YY})
903             GET_FILENAME_COMPONENT(YYBase ${YYFile} NAME_WE)
905             STRING(REPLACE "Parser" "_" YYOpt ${YYBase})
907             SET(YYSrc ${CMAKE_CURRENT_BINARY_DIR}/${YYBase}.cpp)
908             SET(YYHdr ${CMAKE_CURRENT_BINARY_DIR}/${YYBase}.hpp)
910             ADD_CUSTOM_COMMAND(
911                 OUTPUT ${YYSrc} ${YYHdr}
912                 COMMAND ${BISON_EXE} -d -v -p${YYOpt} -b${YYOpt} -o ${YYSrc} ${YYFile}
913                 MAIN_DEPENDENCY ${YYFile})
915             LIST(APPEND ${PROJECT_NAME}_SRC ${YYSrc})
916             LIST(APPEND ${PROJECT_NAME}_HDR ${YYHdr})
918         ENDFOREACH()
920         FOREACH(LLFile ${${PROJECT_NAME}_LL})
922             GET_FILENAME_COMPONENT(LLBase ${LLFile} NAME_WE)
924             STRING(REPLACE "Scanner" "_" LLOpt ${LLBase})
926             IF(OSG_USE_OSG2_NAMESPACE)
927               STRING(REPLACE "OSG" "OSG2"
928                      LLOpt_VERSIONED
929                      ${LLOpt})
930             ELSE()
931               SET(LLOpt_VERSIONED ${LLOpt})
932             ENDIF()
934             SET(LLSrc ${CMAKE_CURRENT_BINARY_DIR}/${LLBase}.cpp)
936             ADD_CUSTOM_COMMAND(
937                 OUTPUT ${LLSrc}
938                 COMMAND ${FLEX_EXE} -+ -P${LLOpt_VERSIONED} -t ${LLFile} >  ${LLSrc}
939                 MAIN_DEPENDENCY ${LLFile})
941             SET(${PROJECT_NAME}_SRC ${${PROJECT_NAME}_SRC} ${LLSrc})
943         ENDFOREACH()
945         IF(${PROJECT_NAME}_YY OR ${PROJECT_NAME}_LL)
946             SET(${PROJECT_NAME}_INC ${${PROJECT_NAME}_INC} ${CMAKE_CURRENT_BINARY_DIR})
948             FILE(APPEND ${${PROJECT_NAME}_BUILD_FILE}
949                 "LIST(APPEND ${PROJECT_NAME}_INC \"${CMAKE_CURRENT_BINARY_DIR}\")\n\n")
951         ENDIF(${PROJECT_NAME}_YY OR ${PROJECT_NAME}_LL)
953     ENDIF(OSG_ENABLE_SCANPARSE_REGEN AND FLEX_EXE AND BISON_EXE)
955     ###############
956     # build the lib
957     ###############
959     ## LINK_DIRS have to go first, before the ADD_LIB statement
961     FOREACH(LIBDIR ${OSG_GLOBAL_DEP_LIBDIR})
962         OSG_MSG("  (global) - library dir ${LIBDIR} = ${${LIBDIR}}")
963         LINK_DIRECTORIES(${${LIBDIR}})
964     ENDFOREACH(LIBDIR)
966     FOREACH(LIBDIR ${${PROJECT_NAME}_DEP_LIBDIR})
967         OSG_MSG("  (global) - library dir ${LIBDIR} = ${${LIBDIR}}")
968         LINK_DIRECTORIES(${${LIBDIR}})
969     ENDFOREACH(LIBDIR)
972     IF(NOT OSG_DISABLE_SOURCE_GROUPS)
973       #Add Source Files to Source Groups
974       #Loop through all of the groups for this Project
975       FOREACH(PROJECT_SOURCE_GROUP_NAME ${${PROJECT_NAME}_SOURCE_GROUPS})
976         STRING(REPLACE "\\" "_" THE_SOURCE_GROUP ${PROJECT_SOURCE_GROUP_NAME})
977         SOURCE_GROUP(${PROJECT_SOURCE_GROUP_NAME} FILES
978                      ${${PROJECT_NAME}_SOURCE_GROUP_${THE_SOURCE_GROUP}})
979       ENDFOREACH(PROJECT_SOURCE_GROUP_NAME)
980     ENDIF(NOT OSG_DISABLE_SOURCE_GROUPS)
982     IF(APPLE AND IOS)
983       ADD_LIBRARY(${PROJECT_NAME} STATIC
984                   ${${PROJECT_NAME}_SRC}
985                   ${${PROJECT_NAME}_HDR}
986                   ${${PROJECT_NAME}_INL}
987                   ${${PROJECT_NAME}_INS})
988     ELSE()
989       ADD_LIBRARY(${PROJECT_NAME} 
990                   ${${PROJECT_NAME}_SRC}
991                   ${${PROJECT_NAME}_HDR}
992                   ${${PROJECT_NAME}_INL}
993                   ${${PROJECT_NAME}_INS})
994     ENDIF()
996     ADD_DEPENDENCIES(OSGAllLibs ${PROJECT_NAME})
997     ADD_DEPENDENCIES(${OSG_MAIN_LIB_TARGET} ${PROJECT_NAME})
999     INCLUDE_DIRECTORIES(${${PROJECT_NAME}_INC})
1001     SET(_OSG_DEBUG_POSTFIX "")
1003     IF(WIN32)
1004         SET(_OSG_DEBUG_POSTFIX DEBUG_POSTFIX "D")
1005     ENDIF(WIN32)
1007     IF(OSG_USE_OSG2_NAMESPACE)
1008       STRING(REGEX REPLACE "^OSG" "OSG2"
1009              PROJECT_NAME_VERSIONED
1010              ${PROJECT_NAME})
1011     ELSE()
1012       SET(PROJECT_NAME_VERSIONED ${PROJECT_NAME})
1013     ENDIF()
1015     SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
1016         DEFINE_SYMBOL ${PROJ_DEFINE}
1017         VERSION ${OSG_VERSION}
1018         SOVERSION ${OSG_VERSION}
1019         ${_OSG_DEBUG_POSTFIX}
1020         DEBUGOPT_POSTFIX "DO"
1021         RELEASENOOPT_POSTFIX "RN"
1022         OUTPUT_NAME ${PROJECT_NAME_VERSIONED})
1024     IF(${PROJECT_NAME}_SUFFIX)
1025       SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
1026                             SUFFIX ${${PROJECT_NAME}_SUFFIX})
1028     ENDIF(${PROJECT_NAME}_SUFFIX)
1030     # dependencies - OpenSG
1031     OSG_GET_ALL_DEP_OSG_LIB(
1032         "${${PROJECT_NAME}_DEP_OSG_LIB}" DEP_OSG_LIST DEP_MISSING_LIST)
1034     # a lib with missing dependencies is fatal - it should not have made it here
1035     IF(DEP_MISSING_LIST)
1036         MESSAGE(FATAL_ERROR "Project ${PROJECT_NAME} has missing dependencies: ${DEP_MISSING_LIST}")
1037     ENDIF(DEP_MISSING_LIST)
1039     FOREACH(OSGDEP ${DEP_OSG_LIST})
1040         OSG_CHECKED_INCLUDE("${CMAKE_BINARY_DIR}/${OSGDEP}.cmake")
1041         INCLUDE_DIRECTORIES(${${OSGDEP}_INC})
1042     ENDFOREACH(OSGDEP)
1044     FOREACH(OSGDEP ${${PROJECT_NAME}_DEP_OSG_LIB})
1045         OSG_CHECKED_INCLUDE  ("${CMAKE_BINARY_DIR}/${OSGDEP}.cmake")
1047         SET(${_OSGDEP_IMPORTED} FALSE)
1049         IF(TARGET ${OSGDEP})
1050           GET_PROPERTY(_OSGDEP_IMPORTED TARGET ${OSGDEP} PROPERTY IMPORTED)
1051         ENDIF(TARGET ${OSGDEP})
1053         IF(NOT _OSGDEP_IMPORTED)
1054           ADD_DEPENDENCIES     (${PROJECT_NAME} ${OSGDEP})
1055         ENDIF(NOT _OSGDEP_IMPORTED)
1057         IF(NOT APPLE OR NOT IOS)
1058           TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${OSGDEP})
1059         ENDIF()
1060     ENDFOREACH(OSGDEP)
1062     # dependencies - global
1063     FOREACH(INCDIR ${OSG_GLOBAL_DEP_INCDIR})
1064         OSG_MSG("  (global) - include dir ${INCDIR} = ${${INCDIR}}")
1065         INCLUDE_DIRECTORIES(${${INCDIR}})
1066     ENDFOREACH(INCDIR)
1068     FOREACH(LIB ${OSG_GLOBAL_DEP_LIBS})
1069         OSG_MSG("  (global) - library ${LIB} = ${${LIB}}")
1070         TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${${LIB}})
1071     ENDFOREACH(LIB)
1073     IF(OSG_GLOBAL_DEP_DEFS)
1074         OSG_MSG("  (global) - definitions = ${OSG_GLOBAL_DEP_DEFS}")
1075         SET_PROPERTY(TARGET ${PROJECT_NAME}
1076             APPEND PROPERTY COMPILE_DEFINITIONS ${OSG_GLOBAL_DEP_DEFS})
1077     ENDIF(OSG_GLOBAL_DEP_DEFS)
1079     # dependencies - External
1080     FOREACH(INCDIR ${${PROJECT_NAME}_DEP_INCDIR})
1081         OSG_MSG("  (external) - include dir ${INCDIR} = ${${INCDIR}}")
1082         INCLUDE_DIRECTORIES(${${INCDIR}})
1083     ENDFOREACH(INCDIR)
1085     FOREACH(LIB ${${PROJECT_NAME}_DEP_LIB})
1086         OSG_MSG("  (external) - library ${LIB} = ${${LIB}}")
1087         IF(NOT APPLE OR NOT IOS)
1088           TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${${LIB}})
1089         ENDIF()
1090     ENDFOREACH(LIB)
1092     IF(${PROJECT_NAME}_DEP_DEFS)
1093         OSG_MSG("  (external) - definitions = ${${PROJECT_NAME}_DEP_DEFS}")
1094         SET_PROPERTY(TARGET ${PROJECT_NAME}
1095             APPEND PROPERTY COMPILE_DEFINITIONS ${${PROJECT_NAME}_DEP_DEFS})
1096     ENDIF(${PROJECT_NAME}_DEP_DEFS)
1098     IF(${PROJECT_NAME}_CXXFLAGS)
1099       SET_PROPERTY(TARGET ${PROJECT_NAME}
1100                     APPEND PROPERTY COMPILE_FLAGS ${${PROJECT_NAME}_CXXFLAGS})
1101     ENDIF(${PROJECT_NAME}_CXXFLAGS)
1103     IF(OSG_IGNORE_INSTALL_${PROJECT_NAME})
1104       RETURN()
1105     ENDIF()
1107     # install rules
1108     IF(WIN32)
1110         IF(OSG_INSTALL_SUBDIR)
1111             SET(_OSG_ISC "${OSG_INSTALL_SUBDIR}/")
1112         ELSE(OSG_INSTALL_SUBDIR)
1113             SET(_OSG_ISC "")
1114         ENDIF(OSG_INSTALL_SUBDIR)
1116         IF(OSG_USE_SEPARATE_LIBDIRS)
1117           SET(_OSG_TARGET_BINDIR_REL bin/${_OSG_ISC}rel)
1118           SET(_OSG_TARGET_BINDIR_DBG bin/${_OSG_ISC}debug)
1119           SET(_OSG_TARGET_BINDIR_RELNO bin/${_OSG_ISC}relnoopt)
1120           SET(_OSG_TARGET_BINDIR_DBGO bin/${_OSG_ISC}debugopt)
1122           SET(_OSG_TARGET_LIBDIR_REL lib/${_OSG_ISC}rel)
1123           SET(_OSG_TARGET_LIBDIR_DBG lib/${_OSG_ISC}debug)
1124           SET(_OSG_TARGET_LIBDIR_RELNO lib/${_OSG_ISC}relnoopt)
1125           SET(_OSG_TARGET_LIBDIR_DBGO lib/${_OSG_ISC}debugopt)
1126         ELSE(OSG_USE_SEPARATE_LIBDIRS)
1127           SET(_OSG_TARGET_BINDIR_REL bin/${_OSG_ISC})
1128           SET(_OSG_TARGET_BINDIR_DBG bin/${_OSG_ISC})
1129           SET(_OSG_TARGET_BINDIR_RELNO bin/${_OSG_ISC})
1130           SET(_OSG_TARGET_BINDIR_DBGO bin/${_OSG_ISC})
1132           SET(_OSG_TARGET_LIBDIR_REL lib/${_OSG_ISC})
1133           SET(_OSG_TARGET_LIBDIR_DBG lib/${_OSG_ISC})
1134           SET(_OSG_TARGET_LIBDIR_RELNO lib/${_OSG_ISC})
1135           SET(_OSG_TARGET_LIBDIR_DBGO lib/${_OSG_ISC})
1136         ENDIF(OSG_USE_SEPARATE_LIBDIRS)
1138         INSTALL(TARGETS ${PROJECT_NAME}
1139                 CONFIGURATIONS Release
1140                 RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_REL}
1141                 COMPONENT release_runtimes)
1143         INSTALL(TARGETS ${PROJECT_NAME}
1144                 CONFIGURATIONS Release
1145                 LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_REL}
1146                 ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_REL}
1147                 COMPONENT release_libraries)
1149         IF(NOT ${PROJECT_NAME}_NO_DBG_INSTALL)
1150           INSTALL(TARGETS ${PROJECT_NAME}
1151                   CONFIGURATIONS Debug
1152                   RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_DBG}
1153                   COMPONENT debug_runtimes)
1155           INSTALL(TARGETS ${PROJECT_NAME}
1156                   CONFIGURATIONS Debug
1157                   LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_DBG}
1158                   ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_DBG}
1159                   COMPONENT debug_libraries)
1160         ENDIF()
1162         INSTALL(TARGETS ${PROJECT_NAME}
1163                 CONFIGURATIONS ReleaseNoOpt
1164                 RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_RELNO}
1165                 COMPONENT release_no_opt_runtimes)
1167         INSTALL(TARGETS ${PROJECT_NAME}
1168                 CONFIGURATIONS ReleaseNoOpt
1169                 LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_RELNO}
1170                 ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_RELNO}
1171                 COMPONENT release_no_opt_libraries)
1173         IF(NOT ${PROJECT_NAME}_NO_DBG_INSTALL)
1174           INSTALL(TARGETS ${PROJECT_NAME}
1175                   CONFIGURATIONS DebugOpt
1176                   RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_DBGO}
1177                   COMPONENT debug_opt_runtimes)
1179           INSTALL(TARGETS ${PROJECT_NAME}
1180                   CONFIGURATIONS DebugOpt
1181                   LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_DBGO}
1182                   ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_DBGO}
1183                   COMPONENT debug_opt_libraries)
1184         ENDIF()
1187         IF(OSG_INSTALL_PDB_FILES)
1189           GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME} Release_LOCATION)
1191           STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
1193           INSTALL(FILES ${_TMPVAL1}
1194                   CONFIGURATIONS Release
1195                   DESTINATION ${_OSG_TARGET_BINDIR_REL}
1196                   COMPONENT release_program_db)
1199           GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME} Debug_LOCATION)
1201           STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
1203           INSTALL(FILES ${_TMPVAL1}
1204                   CONFIGURATIONS Debug
1205                   DESTINATION ${_OSG_TARGET_BINDIR_DBG}
1206                   COMPONENT debug_program_db)
1209           GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME} ReleaseNoOpt_LOCATION)
1211           STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
1213           INSTALL(FILES ${_TMPVAL1}
1214                   CONFIGURATIONS ReleaseNoOpt
1215                   DESTINATION ${_OSG_TARGET_BINDIR_RELNO}
1216                   COMPONENT release_no_opt_program_db)
1219           GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME} DebugOpt_LOCATION)
1221           STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
1223           INSTALL(FILES ${_TMPVAL1}
1224                   CONFIGURATIONS DebugOpt
1225                   DESTINATION ${_OSG_TARGET_BINDIR_DBGO}
1226                   COMPONENT debug_opt_program_db)
1228         ENDIF(OSG_INSTALL_PDB_FILES)
1231         INSTALL(TARGETS ${PROJECT_NAME}
1232                 CONFIGURATIONS MinSizeRel
1233                 RUNTIME DESTINATION lib/minsizerel
1234                 COMPONENT release_minsize_runtimes)
1236         INSTALL(TARGETS ${PROJECT_NAME}
1237                 CONFIGURATIONS MinSizeRel
1238                 LIBRARY DESTINATION lib/minsizerel
1239                 ARCHIVE DESTINATION lib/minsizerel
1240                 COMPONENT release_minsize_libraries)
1242         INSTALL(TARGETS ${PROJECT_NAME}
1243                 CONFIGURATIONS RelWithDebInfo
1244                 RUNTIME DESTINATION lib/relwithdbg
1245                 COMPONENT release_with_debinfo_runtimes)
1247         INSTALL(TARGETS ${PROJECT_NAME}
1248                 CONFIGURATIONS RelWithDebInfo
1249                 RUNTIME DESTINATION lib/relwithdbg
1250                 COMPONENT release_with_debinfo_libraries)
1251     ELSEIF(APPLE AND IOS)
1252         INSTALL(TARGETS ${PROJECT_NAME}
1253                 CONFIGURATIONS Release-iphoneos
1254                 DESTINATION lib/Release-iphoneos)
1255         INSTALL(TARGETS ${PROJECT_NAME}
1256                 CONFIGURATIONS Debug-iphoneos
1257                 DESTINATION lib/Debug-iphoneos)
1258         INSTALL(TARGETS ${PROJECT_NAME}
1259                 CONFIGURATIONS Release-iphonesimulator
1260                 DESTINATION lib/Release-iphonesimulator)
1261         INSTALL(TARGETS ${PROJECT_NAME}
1262                 CONFIGURATIONS Debug-iphonesimulator
1263                 DESTINATION lib/Debug-iphonesimulator)
1264     ELSEIF(XCODE_VERSION)
1265 #        INSTALL(TARGETS ${PROJECT_NAME}
1266 #                CONFIGURATIONS Release
1267 #                RUNTIME DESTINATION lib${OSG_LIBDIR_BASE_SUFFIX}
1268 #                COMPONENT release_runtimes)
1270         INSTALL(TARGETS ${PROJECT_NAME}
1271                 CONFIGURATIONS Release
1272                 LIBRARY DESTINATION lib${OSG_LIBDIR_BASE_SUFFIX}
1273                 ARCHIVE DESTINATION lib${OSG_LIBDIR_BASE_SUFFIX}
1274                 COMPONENT release_libraries)
1276 #        INSTALL(TARGETS ${PROJECT_NAME}
1277 #                CONFIGURATIONS Debug
1278 #                RUNTIME DESTINATION lib${OSG_LIBDIR_BASE_SUFFIX}/debug
1279 #                COMPONENT debug_runtimes)
1281         INSTALL(TARGETS ${PROJECT_NAME}
1282                 CONFIGURATIONS Debug
1283                 LIBRARY DESTINATION lib${OSG_LIBDIR_BASE_SUFFIX}/debug
1284                 ARCHIVE DESTINATION lib${OSG_LIBDIR_BASE_SUFFIX}/debug
1285                 COMPONENT debug_libraries)
1286     ELSE(WIN32)
1287         INSTALL(TARGETS ${PROJECT_NAME}
1288                 RUNTIME DESTINATION lib${OSG_LIBDIR_SUFFIX}
1289                 LIBRARY DESTINATION lib${OSG_LIBDIR_SUFFIX}
1290                 ARCHIVE DESTINATION lib${OSG_LIBDIR_SUFFIX}
1291                 COMPONENT libraries)
1292     ENDIF(WIN32)
1294     INSTALL(FILES ${${PROJECT_NAME}_HDR}
1295             DESTINATION include/OpenSG
1296             PERMISSIONS OWNER_WRITE OWNER_READ
1297                         GROUP_READ
1298                         WORLD_READ
1299                 COMPONENT code_headers)
1301     INSTALL(FILES ${${PROJECT_NAME}_INL}
1302             DESTINATION include/OpenSG
1303             PERMISSIONS OWNER_WRITE OWNER_READ
1304                         GROUP_READ
1305                         WORLD_READ
1306                 COMPONENT code_headers)
1308     INSTALL(FILES ${${PROJECT_NAME}_INS}
1309             DESTINATION include/OpenSG
1310             PERMISSIONS OWNER_WRITE OWNER_READ
1311                         GROUP_READ
1312                         WORLD_READ
1313                 COMPONENT code_headers)
1315     IF(NOT ${PROJECT_NAME}_NO_PYTHON)
1316       FILE(APPEND "${CMAKE_BINARY_DIR}/Python/Helper/libOrder.py" "libInfo[\"${PROJECT_NAME}\"] = [\n")
1317       FOREACH(OSG_DEP ${DEP_OSG_LIST})
1318         FILE(APPEND "${CMAKE_BINARY_DIR}/Python/Helper/libOrder.py" "\"${OSG_DEP}\",")
1319       ENDFOREACH()
1320       FILE(APPEND "${CMAKE_BINARY_DIR}/Python/Helper/libOrder.py" "]\n\n\n")
1321     ENDIF()
1323     FILE(APPEND "${CMAKE_BINARY_DIR}/Python/Helper/libOrder.py" "fullLibInfo[\"${PROJECT_NAME}\"] = [\n")
1324     FOREACH(OSG_DEP ${DEP_OSG_LIST})
1325       FILE(APPEND "${CMAKE_BINARY_DIR}/Python/Helper/libOrder.py" "\"${OSG_DEP}\",")
1326     ENDFOREACH()
1327     FILE(APPEND "${CMAKE_BINARY_DIR}/Python/Helper/libOrder.py" "]\n\n\n")
1329 ENDFUNCTION(OSG_SETUP_LIBRARY_BUILD)
1332 #############################################################################
1333 # perform default actions for pass OSGSETUPTEST
1335 FUNCTION(OSG_SETUP_TEST_BUILD)
1337     IF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGSETUPTEST")
1338         RETURN()
1339     ENDIF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGSETUPTEST")
1341     OSG_CHECKED_INCLUDE(${${PROJECT_NAME}_BUILD_FILE})
1342     INCLUDE_DIRECTORIES(${${PROJECT_NAME}_INC})
1344     # dependencies - OpenSG
1345     OSG_GET_ALL_DEP_OSG_LIB(
1346         "${${PROJECT_NAME}_DEP_OSG_LIB}" DEP_OSG_LIB DEP_MISSING_LIST)
1348     # if depencies are missing we skip the tests
1349     IF(DEP_MISSING_LIST)
1350         MESSAGE(STATUS "Tests for project ${PROJECT_NAME} have missing dependencies: ${DEP_MISSING_LIST} - skipping")
1351         RETURN()
1352     ENDIF(DEP_MISSING_LIST)
1354     FOREACH(OSGDEP ${DEP_OSG_LIB})
1355         OSG_CHECKED_INCLUDE("${CMAKE_BINARY_DIR}/${OSGDEP}.cmake")
1356         INCLUDE_DIRECTORIES(${${OSGDEP}_INC})
1357     ENDFOREACH(OSGDEP)
1359     # dependencies - test OpenSG
1360     OSG_GET_ALL_DEP_OSG_LIB(
1361         "${${PROJECT_NAME}_DEP_TEST_OSG_LIB}" DEP_TEST_OSG_LIB DEP_MISSING_LIST)
1363     # if depencies are missing we skip the tests
1364     IF(DEP_MISSING_LIST)
1365         MESSAGE(STATUS "Tests for project ${PROJECT_NAME} have missing dependencies: ${DEP_MISSING_LIST} - skipping")
1366         RETURN()
1367     ENDIF(DEP_MISSING_LIST)
1369     FOREACH(OSGTESTDEP ${DEP_TEST_OSG_LIB})
1370         OSG_CHECKED_INCLUDE("${CMAKE_BINARY_DIR}/${OSGTESTDEP}.cmake")
1371         INCLUDE_DIRECTORIES(${${OSGTESTDEP}_INC})
1372     ENDFOREACH(OSGTESTDEP)
1374     # dependencies - global
1375     FOREACH(INCDIR ${OSG_GLOBAL_DEP_INCDIR})
1376         OSG_MSG("  (global) - include dir ${INCDIR} = ${${INCDIR}}")
1377         INCLUDE_DIRECTORIES(${${INCDIR}})
1378     ENDFOREACH(INCDIR)
1380     FOREACH(LIBDIR ${OSG_GLOBAL_DEP_LIBDIR})
1381         OSG_MSG("  (global) - library dir ${LIBDIR} = ${${LIBDIR}}")
1382         LINK_DIRECTORIES(${${LIBDIR}})
1383     ENDFOREACH(LIBDIR)
1385     # dependencies - External
1386     FOREACH(INCDIR ${${PROJECT_NAME}_DEP_INCDIR})
1387         OSG_MSG("  (external) - include dir ${INCDIR} = ${${INCDIR}}")
1388         INCLUDE_DIRECTORIES(${${INCDIR}})
1389     ENDFOREACH(INCDIR)
1391     FOREACH(LIBDIR ${${PROJECT_NAME}_DEP_LIBDIR})
1392         OSG_MSG("  (external) - library dir ${LIBDIR} = ${${LIBDIR}}")
1393         LINK_DIRECTORIES(${${LIBDIR}})
1394     ENDFOREACH(LIBDIR)
1396     # dependencies - test External
1397     FOREACH(INCDIR ${${PROJECT_NAME}_DEP_TEST_INCDIR})
1398         OSG_MSG("  (test) - include dir ${INCDIR} = ${${INCDIR}}")
1399         INCLUDE_DIRECTORIES(${${INCDIR}})
1400     ENDFOREACH(INCDIR)
1402     FOREACH(LIBDIR ${${PROJECT_NAME}_DEP_TEST_LIBDIR})
1403         OSG_MSG("  (test) - library dir ${LIBDIR} = ${${LIBDIR}}")
1404         LINK_DIRECTORIES(${${LIBDIR}})
1405     ENDFOREACH(LIBDIR)
1407     # build test programs
1408     FOREACH(EXE_SRC ${${PROJECT_NAME}_TEST_SRC} ${${PROJECT_NAME}_APP_SRC})
1409         GET_FILENAME_COMPONENT(EXE ${EXE_SRC} NAME_WE)
1411         ADD_EXECUTABLE(${EXE} ${OSGEXCLUDE_TESTS} ${EXE_SRC} )
1413         ADD_DEPENDENCIES(OSGAllTests ${EXE})
1415         FOREACH(OSGTESTDEP ${${PROJECT_NAME}_DEP_TEST_OSG_LIB})
1416             GET_PROPERTY(_OSGTESTDEP_IMPORTED TARGET ${OSGTESTDEP} PROPERTY IMPORTED)
1418             IF(NOT _OSGTESTDEP_IMPORTED)
1419               ADD_DEPENDENCIES(${EXE} ${OSGTESTDEP})
1420             ENDIF(NOT _OSGTESTDEP_IMPORTED)
1422             TARGET_LINK_LIBRARIES(${EXE} ${OSGTESTDEP})
1423         ENDFOREACH(OSGTESTDEP)
1425         FOREACH(OSGTESTDEP ${${PROJECT_NAME}_DEP_TEST_OSG_EEX_LIB})
1426             IF(TARGET ${OSGTESTDEP})
1427               GET_PROPERTY(_OSGTESTDEP_IMPORTED TARGET ${OSGTESTDEP} PROPERTY IMPORTED)
1429               IF(NOT _OSGTESTDEP_IMPORTED)
1430                 ADD_DEPENDENCIES(${EXE} ${OSGTESTDEP})
1431               ENDIF(NOT _OSGTESTDEP_IMPORTED)
1433               TARGET_LINK_LIBRARIES(${EXE} ${OSGTESTDEP})
1434             ENDIF(TARGET ${OSGTESTDEP})
1435         ENDFOREACH(OSGTESTDEP)
1437         FOREACH(LIB ${${PROJECT_NAME}_DEP_TEST_LIB})
1438             OSG_MSG("  (test) - library ${LIB} = ${${LIB}}")
1439             TARGET_LINK_LIBRARIES(${EXE} ${${LIB}})
1440         ENDFOREACH(LIB)
1442         IF(NOT ${PROJECT_NAME}_NO_LIB)
1443           TARGET_LINK_LIBRARIES(${EXE} ${PROJECT_NAME})
1444         ENDIF(NOT ${PROJECT_NAME}_NO_LIB)
1446         IF(${PROJECT_NAME}_DEP_DEFS)
1447             OSG_MSG("  (external) - definitions ${PROJECT_NAME}_DEP_DEFS = ${${PROJECT_NAME}_DEP_DEFS}")
1448             SET_PROPERTY(TARGET ${EXE} APPEND
1449                 PROPERTY COMPILE_DEFINITIONS ${${PROJECT_NAME}_DEP_DEFS})
1450         ENDIF(${PROJECT_NAME}_DEP_DEFS)
1452         IF(${PROJECT_NAME}_CXXFLAGS)
1453           SET_PROPERTY(TARGET ${EXE}
1454                        APPEND PROPERTY COMPILE_FLAGS ${${PROJECT_NAME}_CXXFLAGS})
1455         ENDIF(${PROJECT_NAME}_CXXFLAGS)
1457         IF(${PROJECT_NAME}_DEP_TEST_DEFS)
1458             OSG_MSG("  (test) - definitions ${PROJECT_NAME}_DEP_TEST_DEFS = ${${PROJECT_NAME}_DEP_TEST_DEFS}")
1459             SET_PROPERTY(TARGET ${EXE} APPEND
1460                 PROPERTY COMPILE_DEFINITIONS ${${PROJECT_NAME}_DEP_TEST_DEFS})
1461         ENDIF(${PROJECT_NAME}_DEP_TEST_DEFS)
1462     ENDFOREACH(EXE_SRC)
1464     FOREACH(EXE_SRC ${${PROJECT_NAME}_APP_SRC})
1465       GET_FILENAME_COMPONENT(EXE ${EXE_SRC} NAME_WE)
1466         ADD_DEPENDENCIES(OSGAllApps ${EXE})
1467     ENDFOREACH()
1469     FOREACH(EXE_SRC ${${PROJECT_NAME}_APP_SRC})
1470       GET_FILENAME_COMPONENT(EXE ${EXE_SRC} NAME_WE)
1472       SET_TARGET_PROPERTIES(${EXE} PROPERTIES EXCLUDE_FROM_ALL FALSE)
1473     ENDFOREACH()
1475     IF(OSG_INSTALL_APPS)
1476       IF(WIN32)
1477         IF(OSG_INSTALL_SUBDIR)
1478             SET(_OSG_ISC "${OSG_INSTALL_SUBDIR}/")
1479         ELSE(OSG_INSTALL_SUBDIR)
1480             SET(_OSG_ISC "")
1481         ENDIF(OSG_INSTALL_SUBDIR)
1483         IF(OSG_USE_SEPARATE_LIBDIRS)
1484           SET(_OSG_TARGET_BINDIR_REL bin/${_OSG_ISC}rel)
1485           SET(_OSG_TARGET_BINDIR_DBG bin/${_OSG_ISC}debug)
1486           SET(_OSG_TARGET_BINDIR_RELNO bin/${_OSG_ISC}relnoopt)
1487           SET(_OSG_TARGET_BINDIR_DBGO bin/${_OSG_ISC}debugopt)
1489           SET(_OSG_TARGET_LIBDIR_REL lib/${_OSG_ISC}rel)
1490           SET(_OSG_TARGET_LIBDIR_DBG lib/${_OSG_ISC}debug)
1491           SET(_OSG_TARGET_LIBDIR_RELNO lib/${_OSG_ISC}relnoopt)
1492           SET(_OSG_TARGET_LIBDIR_DBGO lib/${_OSG_ISC}debugopt)
1493         ELSE(OSG_USE_SEPARATE_LIBDIRS)
1494           SET(_OSG_TARGET_BINDIR_REL bin/${_OSG_ISC})
1495           SET(_OSG_TARGET_BINDIR_DBG bin/${_OSG_ISC})
1496           SET(_OSG_TARGET_BINDIR_RELNO bin/${_OSG_ISC})
1497           SET(_OSG_TARGET_BINDIR_DBGO bin/${_OSG_ISC})
1499           SET(_OSG_TARGET_LIBDIR_REL lib/${_OSG_ISC})
1500           SET(_OSG_TARGET_LIBDIR_DBG lib/${_OSG_ISC})
1501           SET(_OSG_TARGET_LIBDIR_RELNO lib/${_OSG_ISC})
1502           SET(_OSG_TARGET_LIBDIR_DBGO lib/${_OSG_ISC})
1503         ENDIF(OSG_USE_SEPARATE_LIBDIRS)
1504       ENDIF(WIN32)
1506       FOREACH(EXE_SRC ${${PROJECT_NAME}_APP_SRC})
1507         GET_FILENAME_COMPONENT(EXE ${EXE_SRC} NAME_WE)
1509         SET_TARGET_PROPERTIES(${EXE} PROPERTIES EXCLUDE_FROM_ALL FALSE)
1511         IF(WIN32)
1513           INSTALL(TARGETS ${EXE}
1514                   CONFIGURATIONS Release
1515                   RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_REL}
1516                   COMPONENT release_binaries)
1517           INSTALL(TARGETS ${EXE}
1518                   CONFIGURATIONS Debug
1519                   RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_DBG}
1520                   COMPONENT debug_binaries)
1521           INSTALL(TARGETS ${EXE}
1522                   CONFIGURATIONS ReleaseNoOpt
1523                   RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_RELNO}
1524                   COMPONENT release_no_opt_binaries)
1525           INSTALL(TARGETS ${EXE}
1526                   CONFIGURATIONS DebugOpt
1527                   RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_DBGO}
1528                   COMPONENT debug_opt_binaries)
1530         ELSE(WIN32)
1532           INSTALL(TARGETS ${EXE}
1533                   CONFIGURATIONS Release
1534                   RUNTIME DESTINATION bin
1535                   COMPONENT release_binaries)
1537           INSTALL(TARGETS ${EXE}
1538                   CONFIGURATIONS Debug
1539                   RUNTIME DESTINATION bin/debug
1540                   COMPONENT debug_binaries)
1542           INSTALL(TARGETS ${EXE}
1543                   CONFIGURATIONS DebugGV
1544                   RUNTIME DESTINATION bin/debug
1545                   COMPONENT debug_binaries)
1547         ENDIF(WIN32)
1548       ENDFOREACH()
1549     ENDIF(OSG_INSTALL_APPS)
1551 ENDFUNCTION(OSG_SETUP_TEST_BUILD)
1554 #############################################################################
1555 # perform default actions for pass OSGSETUPUNITTEST
1557 FUNCTION(OSG_SETUP_UNITTEST_BUILD)
1558     IF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGSETUPUNITTEST")
1559         RETURN()
1560     ENDIF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGSETUPUNITTEST")
1562     INCLUDE(${${PROJECT_NAME}_BUILD_FILE})
1564     # are there unittests to build?
1565     IF(NOT ${PROJECT_NAME}_UNITTEST_SRC)
1566         RETURN()
1567     ENDIF(NOT ${PROJECT_NAME}_UNITTEST_SRC)
1569     INCLUDE_DIRECTORIES(${${PROJECT_NAME}_INC})
1570     INCLUDE_DIRECTORIES(${OSG_UNITTEST_INCLUDE_DIRS})
1572     # dependencies - OpenSG
1573     OSG_GET_ALL_DEP_OSG_LIB(
1574         "${${PROJECT_NAME}_DEP_OSG_LIB}" DEP_OSG_LIB DEP_MISSING_LIST)
1576     # if depencies are missing we skip the unittests
1577     IF(DEP_MISSING_LIST)
1578         MESSAGE(STATUS "Unittests for project ${PROJECT_NAME} have missing dependencies: ${DEP_MISSING_LIST} - skipping")
1579         RETURN()
1580     ENDIF(DEP_MISSING_LIST)
1582     FOREACH(OSGDEP ${DEP_OSG_LIB})
1583         OSG_CHECKED_INCLUDE("${CMAKE_BINARY_DIR}/${OSGDEP}.cmake")
1584         INCLUDE_DIRECTORIES(${${OSGDEP}_INC})
1585     ENDFOREACH(OSGDEP)
1587     # dependencies - unittest OpenSG
1588     OSG_GET_ALL_DEP_OSG_LIB(
1589         "${${PROJECT_NAME}_DEP_UNITTEST_OSG_LIB}" DEP_UNITTEST_OSG_LIB DEP_MISSING_LIST)
1591     # if depencies are missing we skip the unittests
1592     IF(DEP_MISSING_LIST)
1593         MESSAGE(STATUS "Unittests for project ${PROJECT_NAME} have missing dependencies: ${DEP_MISSING_LIST} - skipping")
1594         RETURN()
1595     ENDIF(DEP_MISSING_LIST)
1597     FOREACH(OSGDEP ${DEP_UNITTEST_OSG_LIB})
1598         OSG_CHECKED_INCLUDE("${CMAKE_BINARY_DIR}/${OSGDEP}.cmake")
1599         INCLUDE_DIRECTORIES(${${OSGDEP}_INC})
1600     ENDFOREACH(OSGDEP)
1602     # dependencies global
1603     FOREACH(INCDIR ${OSG_GLOBAL_DEP_INCDIR})
1604         OSG_MSG("  (global) - include dir ${INCDIR} = ${${INCDIR}}")
1605         INCLUDE_DIRECTORIES(${${INCDIR}})
1606     ENDFOREACH(INCDIR)
1608     FOREACH(LIBDIR ${OSG_GLOBAL_DEP_LIBDIR})
1609         OSG_MSG("  (global) - library dir ${LIBDIR} = ${${LIBDIR}}")
1610         LINK_DIRECTORIES(${${LIBDIR}})
1611     ENDFOREACH(LIBDIR)
1613     # dependencies - unittest External
1614     FOREACH(INCDIR ${${PROJECT_NAME}_DEP_UNITTEST_INCDIR})
1615         OSG_MSG("  (unittest) - include dir ${INCDIR} = ${${INCDIR}}")
1616         INCLUDE_DIRECTORIES(${${INCDIR}})
1617     ENDFOREACH(INCDIR)
1619     FOREACH(LIBDIR ${${PROJECT_NAME}_DEP_UNITTEST_LIBDIR})
1620         OSG_MSG("  (unittest) - library dir ${LIBDIR} = ${${LIBDIR}}")
1621         LINK_DIRECTORIES(${${LIBDIR}})
1622     ENDFOREACH(LIBDIR)
1624     LINK_DIRECTORIES(${OSG_UNITTEST_LIBRARY_DIRS})
1626     # add the unittest runner source
1627     LIST(APPEND ${PROJECT_NAME}_UNITTEST_SRC
1628         "${CMAKE_SOURCE_DIR}/Tools/unittest-cpp/UnitTestRunner.cpp")
1630     # build unittest executable
1631     ADD_EXECUTABLE("UnitTest${PROJECT_NAME}"
1632                    ${OSGEXCLUDE_UNITTESTS}
1633                    ${${PROJECT_NAME}_UNITTEST_SRC})
1635     ADD_DEPENDENCIES(OSGAllUnitTests UnitTest${PROJECT_NAME})
1637     TARGET_LINK_LIBRARIES("UnitTest${PROJECT_NAME}" "${OSG_UNITTEST_LIBRARY}")
1638     TARGET_LINK_LIBRARIES("UnitTest${PROJECT_NAME}" ${PROJECT_NAME})
1640     FOREACH(OSGDEP ${${PROJECT_NAME}_DEP_UNITTEST_OSG_LIB})
1641         ADD_DEPENDENCIES("UnitTest${PROJECT_NAME}" ${OSGDEP})
1642         TARGET_LINK_LIBRARIES("UnitTest${PROJECT_NAME}" ${OSGDEP})
1643     ENDFOREACH(OSGDEP)
1645     FOREACH(LIB ${${PROJECT_NAME}_DEP_UNITTEST_LIB})
1646         OSG_MSG("  (unittest) - library ${LIB} = ${${LIB}}")
1647         TARGET_LINK_LIBRARIES("UnitTest${PROJECT_NAME}" ${${LIB}})
1648     ENDFOREACH(LIB)
1650     #MESSAGE("--------- ADDING TEST --------- ${PROJECT_NAME}") # Trips up ccmake
1651     ADD_TEST("UnitTest${PROJECT_NAME}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/UnitTest${PROJECT_NAME}")
1653 ENDFUNCTION(OSG_SETUP_UNITTEST_BUILD)
1655 #############################################################################
1656 # perform default actions for pass OSGPYTHON
1658 FUNCTION(OSG_SETUP_PYTHON_BUILD)
1660   IF(${PROJECT_NAME}_NO_PYTHON OR NOT PYTHONLIBS_FOUND)
1661       RETURN()
1662   ENDIF(${PROJECT_NAME}_NO_PYTHON OR NOT PYTHONLIBS_FOUND)
1664   MESSAGE("  setup python for ${PROJECT_NAME} | ${OSG_CAN_REGEN_PYTHON_BINDINGS}")
1666   ##################################
1667   # Dependency includes
1668   ##################################
1670   OSG_GET_ALL_DEP_OSG_LIB("${${PROJECT_NAME}_DEP_OSG_LIB}" DEP_OSG_LIST DEP_MISSING_LIST)
1672   # read file lists
1673   FOREACH(OSGDEP ${DEP_OSG_LIST})
1674     OSG_CHECKED_INCLUDE(${CMAKE_BINARY_DIR}/${OSGDEP}.cmake)
1675   ENDFOREACH()
1677   OSG_CHECKED_INCLUDE(${${PROJECT_NAME}_BUILD_FILE})
1680   ##################################
1681   # Configure files
1682   ##################################
1684   FILE(MAKE_DIRECTORY ${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR})
1686   SET(_OSG_GEN_INIT_FILE_OUT "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/__init__.py")
1688   IF(OSG_CAN_REGEN_PYTHON_BINDINGS)
1690     SET(_OSG_GEN_CONFIG_FILE_IN  "${CMAKE_SOURCE_DIR}/Bindings/Python/osgGenBindings.py.in")
1691     SET(_OSG_GEN_CONFIG_FILE_OUT "${CMAKE_CURRENT_BINARY_DIR}/osgGenBindings_${PROJECT_NAME}.py")
1692     SET(_OSG_GEN_SETUP_FILE_IN   "${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/osgSetupBindings_${PROJECT_NAME}.py.in")
1693     SET(_OSG_GEN_SETUP_FILE      "${CMAKE_CURRENT_BINARY_DIR}/osgSetupBindings_${PROJECT_NAME}.py")
1695     IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/__init__.py.in")
1696       SET(_OSG_GEN_INIT_FILE_IN  "${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/__init__.py.in")
1697     ELSE()
1698       SET(_OSG_GEN_INIT_FILE_IN  "${CMAKE_SOURCE_DIR}/Bindings/Python/__init__.py.in")
1699     ENDIF()
1701     IF(OSGBUILD_PYTHON_DUMP_DECLS)
1702       SET(OSG_DO_DUMP_PYTHON_DECLS True)
1703     ELSE()
1704       SET(OSG_DO_DUMP_PYTHON_DECLS False)
1705     ENDIF()
1707     CONFIGURE_FILE("${_OSG_GEN_CONFIG_FILE_IN}"
1708                    "${_OSG_GEN_CONFIG_FILE_OUT}")
1710     CONFIGURE_FILE("${_OSG_GEN_INIT_FILE_IN}"
1711                    "${_OSG_GEN_INIT_FILE_OUT}")
1713     ##################################
1714     # Setup File Base
1715     ##################################
1717     IF(EXISTS ${_OSG_GEN_SETUP_FILE_IN})
1718       CONFIGURE_FILE("${_OSG_GEN_SETUP_FILE_IN}"
1719                      "${_OSG_GEN_SETUP_FILE}")
1720       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "\n\n###############################\n")
1721       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "#auto setup for python bindings\n\n")
1722     ELSE()
1723       EXECUTE_PROCESS(
1724         COMMAND "${CMAKE_COMMAND}" -E copy_if_different
1725                 "${CMAKE_SOURCE_DIR}/Bindings/Python/osgDefaultGen.py"
1726                 "${_OSG_GEN_SETUP_FILE}")
1727     ENDIF()
1730     ##################################
1731     # Setup File ModuleHeader
1732     ##################################
1734     FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleHeaders = \\\n[\n")
1736     LIST(INSERT ${PROJECT_NAME}_PYTHON_BIND_HEADERS 0 "pypp_aliases.h")
1737     LIST(INSERT ${PROJECT_NAME}_PYTHON_BIND_HEADERS 0 "PreBoostPython.h")
1739     FOREACH(_OSG_HEADER ${${PROJECT_NAME}_PYTHON_BIND_HEADERS})
1740       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${_OSG_HEADER}\",\n")
1741     ENDFOREACH()
1743     FILE(APPEND ${_OSG_GEN_SETUP_FILE} "]\n\n\n")
1745     ##################################
1746     # Setup File ModuleFCs
1747     ##################################
1749     IF(${PROJECT_NAME}_PYTHON_BIND_FCS)
1750       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleFCs = \\\n[\n")
1752       FOREACH(_OSG_FC ${${PROJECT_NAME}_PYTHON_BIND_FCS})
1753         FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${_OSG_FC}\",\n")
1754       ENDFOREACH()
1756       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "]\n\n\n")
1758       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleFCDFiles = None\n\n\n")
1759     ELSE()
1760       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleFCs = None\n\n\n")
1762       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleFCDFiles = \\\n[\n")
1764       FOREACH(_OSG_FC ${${PROJECT_NAME}_FCD})
1765         FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${_OSG_FC}\",\n")
1766       ENDFOREACH()
1768       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "]\n\n\n")
1769     ENDIF()
1771     ##################################
1772     # Setup File ModuleIncludes
1773     ##################################
1775     FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleIncludes = \\\n[\n")
1777     FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${PYTHON_INCLUDE_PATH}\",\n")
1779     IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/Wrapper")
1780       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/Wrapper\",\n")
1781     ENDIF()
1782     IF(EXISTS "${CMAKE_SOURCE_DIR}/Bindings/Python/Common")
1783       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${CMAKE_SOURCE_DIR}/Bindings/Python/Common\",\n")
1784     ENDIF()
1786     FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${CMAKE_BINARY_DIR}/Source/Base/Base\",\n")
1788     FOREACH(_OSG_INC ${${PROJECT_NAME}_INC})
1789       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${_OSG_INC}\",\n")
1790     ENDFOREACH()
1792     FILE(APPEND ${_OSG_GEN_SETUP_FILE} "]\n\n\n")
1794     ##################################
1795     # Setup File ModuleDepIncludes
1796     ##################################
1798     IF(DEP_OSG_LIST)
1799       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleDepIncludes = \\\n[\n")
1801       FOREACH(OSGDEP ${DEP_OSG_LIST})
1802         FOREACH(_OSG_INC ${${OSGDEP}_INC})
1803           FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${_OSG_INC}\",\n")
1804         ENDFOREACH()
1805       ENDFOREACH()
1807       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "]\n\n\n")
1808     ELSE()
1809       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleDepIncludes = None\n\n\n")
1810     ENDIF()
1812     ##################################
1813     # Setup File PythonModuleDeps
1814     ##################################
1816     IF(DEP_OSG_LIST)
1817       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleDepencies = \\\n[\n")
1819       FOREACH(OSGDEP ${DEP_OSG_LIST})
1820         FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${OSG_PYTHON_${OSGDEP}_MODULE_DIR}/generated\",\n")
1821       ENDFOREACH()
1823       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "]\n\n\n")
1824     ELSE()
1825       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleDepencies = None\n\n\n")
1826     ENDIF()
1828     ##################################
1829     # Setup File NativeWinDependents
1830     ##################################
1832     IF(${PROJECT_NAME}_PYTHON_NATIVEWINDOW_DEPENDENT)
1833       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "nativeWinDependends = \\\n[\n")
1835       FOREACH(_OSG_NATIVEWIN_DEP ${${PROJECT_NAME}_PYTHON_NATIVEWINDOW_DEPENDENT})
1836         FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${_OSG_NATIVEWIN_DEP}\",\n")
1837       ENDFOREACH()
1839       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "]\n\n\n")
1840       IF(UNIX AND NOT APPLE)
1841         FILE(APPEND ${_OSG_GEN_SETUP_FILE} "nativeWin = \"XWindow\"\n\n\n")
1842       ELSEIF(WIN32)
1843         FILE(APPEND ${_OSG_GEN_SETUP_FILE} "nativeWin = \"WIN32Window\"\n\n\n")
1844       ELSEIF(UNIX AND APPLE)
1845         FILE(APPEND ${_OSG_GEN_SETUP_FILE} "nativeWin = \"CocoaWindow\"\n\n\n")
1846       ENDIF()
1847     ELSE()
1848       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "nativeWinDependends = None\n\n\n")
1849     ENDIF()
1852     ##################################
1853     # Bindings Gen Target
1854     ##################################
1856     ADD_CUSTOM_TARGET(${PROJECT_NAME}PyGenOnly COMMAND ${PYTHON_EXECUTABLE} osgGenBindings_${PROJECT_NAME}.py)
1857     ADD_CUSTOM_TARGET(${PROJECT_NAME}PyGen     COMMAND ${PYTHON_EXECUTABLE} osgGenBindings_${PROJECT_NAME}.py)
1860     FOREACH(OSG_DEP ${${PROJECT_NAME}_DEP_OSG_LIB})
1861       ADD_DEPENDENCIES(${PROJECT_NAME}PyGen ${OSG_DEP}PyGen)
1862     ENDFOREACH()
1864     ADD_DEPENDENCIES(OSGPyGen   ${PROJECT_NAME}PyGen)
1866   ENDIF(OSG_CAN_REGEN_PYTHON_BINDINGS)
1868   ##################################
1869   # Bindings Lib Target
1870   ##################################
1872   IF(EXISTS "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/generated" AND NOT ${PROJECT_NAME}_PYTHON_GET_ONLY)
1873     FILE(GLOB   _OSG_BIND_SRC "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/generated/*.pypp.cpp")
1874     LIST(APPEND _OSG_BIND_SRC "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/generated/${PROJECT_NAME}Py.main.cpp")
1876     FILE(GLOB   _OSG_BIND_SRC_TMP "${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/Wrapper/*.cpp")
1878     LIST(APPEND _OSG_BIND_SRC ${_OSG_BIND_SRC_TMP})
1880     IF(${PROJECT_NAME}_PYTHON_NATIVEWINDOW_DEPENDENT)
1882       FOREACH(_OSG_NATIVEWIN_DEP ${${PROJECT_NAME}_PYTHON_NATIVEWINDOW_DEPENDENT})
1883         SET(_OSG_NATIVEWIN_DEP_IN      ${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/generated/${_OSG_NATIVEWIN_DEP}Base.pypp.cpp)
1884         SET(_OSG_NATIVEWIN_DEP_PATCHED ${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/generated/${_OSG_NATIVEWIN_DEP}Base.pypp.cpp.patched)
1885         SET(_OSG_NATIVEWIN_DEP_OUT     ${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/generated/${_OSG_NATIVEWIN_DEP}Base.pypp.patched.cpp)
1887         LIST(REMOVE_ITEM _OSG_BIND_SRC ${_OSG_NATIVEWIN_DEP_IN})
1888         LIST(REMOVE_ITEM _OSG_BIND_SRC ${_OSG_NATIVEWIN_DEP_OUT})
1890         IF(EXISTS ${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/generated/${_OSG_NATIVEWIN_DEP}Base.pypp.patched.cpp)
1891           LIST(APPEND      _OSG_BIND_SRC ${_OSG_NATIVEWIN_DEP_OUT})
1892         ENDIF()
1894       ENDFOREACH()
1895       
1896     ENDIF(${PROJECT_NAME}_PYTHON_NATIVEWINDOW_DEPENDENT)
1899     ADD_LIBRARY(${PROJECT_NAME}Py EXCLUDE_FROM_ALL ${_OSG_BIND_SRC})
1901     SET_TARGET_PROPERTIES(${PROJECT_NAME}Py PROPERTIES PREFIX "")
1903     IF(WIN32)
1905         SET_TARGET_PROPERTIES(${PROJECT_NAME}Py PROPERTIES
1906             VERSION              ${OSG_VERSION}
1907             SOVERSION            ${OSG_VERSION}
1908             SUFFIX               ".pyd")
1910     ENDIF(WIN32)
1913     INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
1914     INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/Bindings/Python/Common)
1915     INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/Wrapper)
1916     INCLUDE_DIRECTORIES(${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR})
1918     ADD_DEFINITIONS(-DBOOST_PYTHON_MAX_ARITY=21)
1920     FOREACH(OSGDEP ${DEP_OSG_LIST})
1921       INCLUDE_DIRECTORIES(${${OSGDEP}_INC})
1922     ENDFOREACH()
1924     INCLUDE_DIRECTORIES(${${PROJECT_NAME}_INC})
1925     INCLUDE_DIRECTORIES(${OSG_BOOST_INCDIRS})
1927     TARGET_LINK_LIBRARIES(${PROJECT_NAME}Py ${PROJECT_NAME})
1928     TARGET_LINK_LIBRARIES(${PROJECT_NAME}Py ${OSG_BOOST_PYTHON_LIBS})
1929     TARGET_LINK_LIBRARIES(${PROJECT_NAME}Py ${PYTHON_LIBRARY})
1931     IF(WIN32) 
1933       IF(OSG_INSTALL_SUBDIR)
1934           SET(_OSG_ISC "${OSG_INSTALL_SUBDIR}/")
1935       ELSE(OSG_INSTALL_SUBDIR)
1936           SET(_OSG_ISC "")
1937       ENDIF(OSG_INSTALL_SUBDIR)
1939       SET(_OSG_TARGET_BINDIR_REL   bin/${_OSG_ISC}rel)
1940       SET(_OSG_TARGET_BINDIR_DBG   bin/${_OSG_ISC}debug)
1941       SET(_OSG_TARGET_BINDIR_RELNO bin/${_OSG_ISC}relnoopt)
1942       SET(_OSG_TARGET_BINDIR_DBGO  bin/${_OSG_ISC}debugopt)
1944       SET(_OSG_TARGET_LIBDIR_REL   lib/${_OSG_ISC}rel)
1945       SET(_OSG_TARGET_LIBDIR_DBG   lib/${_OSG_ISC}debug)
1946       SET(_OSG_TARGET_LIBDIR_RELNO lib/${_OSG_ISC}relnoopt)
1947       SET(_OSG_TARGET_LIBDIR_DBGO  lib/${_OSG_ISC}debugopt)
1949       SET(_OSG_TARGET_PYLIBDIR_REL   lib/python/${_OSG_ISC}rel/osg2/${PROJECT_NAME})
1950       SET(_OSG_TARGET_PYLIBDIR_DBG   lib/python/${_OSG_ISC}debug/osg2/${PROJECT_NAME})
1951       SET(_OSG_TARGET_PYLIBDIR_RELNO lib/python/${_OSG_ISC}relnoopt/osg2/${PROJECT_NAME})
1952       SET(_OSG_TARGET_PYLIBDIR_DBGO  lib/python/${_OSG_ISC}debugopt/osg2/${PROJECT_NAME})
1954       INSTALL(TARGETS ${PROJECT_NAME}Py
1955               CONFIGURATIONS Release
1956               RUNTIME DESTINATION ${_OSG_TARGET_PYLIBDIR_REL}
1957               COMPONENT release_runtimes
1958               OPTIONAL)
1960       INSTALL(TARGETS ${PROJECT_NAME}Py
1961               CONFIGURATIONS Release
1962               LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_REL}
1963               ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_REL}
1964               COMPONENT release_libraries
1965               OPTIONAL)
1967       INSTALL(TARGETS ${PROJECT_NAME}Py
1968               CONFIGURATIONS Debug
1969               RUNTIME DESTINATION ${_OSG_TARGET_PYLIBDIR_DBG}
1970               COMPONENT debug_runtimes
1971               OPTIONAL)
1973       INSTALL(TARGETS ${PROJECT_NAME}Py
1974               CONFIGURATIONS Debug
1975               LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_DBG}
1976               ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_DBG}
1977               COMPONENT debug_libraries
1978               OPTIONAL)
1980       INSTALL(TARGETS ${PROJECT_NAME}Py
1981               CONFIGURATIONS ReleaseNoOpt
1982               RUNTIME DESTINATION ${_OSG_TARGET_PYLIBDIR_RELNO}
1983               COMPONENT release_no_opt_runtimes
1984               OPTIONAL)
1986       INSTALL(TARGETS ${PROJECT_NAME}Py
1987               CONFIGURATIONS ReleaseNoOpt
1988               LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_RELNO}
1989               ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_RELNO}
1990               COMPONENT release_no_opt_libraries
1991               OPTIONAL)
1993       INSTALL(TARGETS ${PROJECT_NAME}Py
1994               CONFIGURATIONS DebugOpt
1995               RUNTIME DESTINATION ${_OSG_TARGET_PYLIBDIR_DBGO}
1996               COMPONENT debug_opt_runtimes
1997               OPTIONAL)
1999       INSTALL(TARGETS ${PROJECT_NAME}Py
2000               CONFIGURATIONS DebugOpt
2001               LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_DBGO}
2002               ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_DBGO}
2003               COMPONENT debug_opt_libraries
2004               OPTIONAL)
2007       IF(OSG_INSTALL_PDB_FILES)
2009         GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME}Py Release_LOCATION)
2011         STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
2013         INSTALL(FILES ${_TMPVAL1}
2014                 CONFIGURATIONS Release
2015                 DESTINATION ${_OSG_TARGET_PYLIBDIR_REL}
2016                 COMPONENT release_program_db
2017                 OPTIONAL)
2020         GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME}Py Debug_LOCATION)
2022         STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
2024         INSTALL(FILES ${_TMPVAL1}
2025                 CONFIGURATIONS Debug
2026                 DESTINATION ${_OSG_TARGET_PYLIBDIR_DBG}
2027                 COMPONENT debug_program_db
2028                 OPTIONAL)
2031         GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME}Py ReleaseNoOpt_LOCATION)
2033         STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
2035         INSTALL(FILES ${_TMPVAL1}
2036                 CONFIGURATIONS ReleaseNoOpt
2037                 DESTINATION ${_OSG_TARGET_PYLIBDIR_RELNO}
2038                 COMPONENT release_no_opt_program_db
2039                 OPTIONAL)
2042         GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME}Py DebugOpt_LOCATION)
2044         STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
2046         INSTALL(FILES ${_TMPVAL1}
2047                 CONFIGURATIONS DebugOpt
2048                 DESTINATION ${_OSG_TARGET_PYLIBDIR_DBGO}
2049                 COMPONENT debug_opt_program_db
2050                 OPTIONAL)
2052       ENDIF(OSG_INSTALL_PDB_FILES)
2054       SET(_OSG_GEN_INIT_FILE_OUT "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/__init__.py")
2056       INSTALL(FILES          ${_OSG_GEN_INIT_FILE_OUT} 
2057               DESTINATION    ${_OSG_TARGET_PYLIBDIR_REL}
2058               CONFIGURATIONS Release
2059               OPTIONAL)
2061       SET(_OSG_GEN_INIT_FILE_OUT "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/__init__.py")
2062   
2063       INSTALL(FILES       ${_OSG_GEN_INIT_FILE_OUT} 
2064               DESTINATION ${_OSG_TARGET_PYLIBDIR_DBG}
2065               CONFIGURATIONS Debug
2066               OPTIONAL)
2068       SET(_OSG_GEN_INIT_FILE_OUT "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/__init__.py")
2069   
2070       INSTALL(FILES       ${_OSG_GEN_INIT_FILE_OUT} 
2071               DESTINATION ${_OSG_TARGET_PYLIBDIR_DBGO}
2072               CONFIGURATIONS DebugOpt
2073               OPTIONAL)
2075       SET(_OSG_GEN_INIT_FILE_OUT "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/__init__.py")
2076   
2077       INSTALL(FILES       ${_OSG_GEN_INIT_FILE_OUT} 
2078               DESTINATION ${_OSG_TARGET_PYLIBDIR_RELNO}
2079               CONFIGURATIONS ReleaseNoOpt
2080               OPTIONAL)
2083     ELSE(WIN32)   
2084       GET_FILENAME_COMPONENT(_PY_VERSION_DIR ${PYTHON_INCLUDE_PATH} NAME)
2086       SET(_OSG_PY_INST_BASE 
2087           "lib${OSG_LIBDIR_BASE_SUFFIX}/${_PY_VERSION_DIR}/site-packages/${OSG_LIBDIR_BUILD_TYPE_SUFFIX}/osg2/${PROJECT_NAME}")
2089       INSTALL(TARGETS ${PROJECT_NAME}Py
2090               RUNTIME DESTINATION ${_OSG_PY_INST_BASE}
2091               LIBRARY DESTINATION ${_OSG_PY_INST_BASE}
2092               ARCHIVE DESTINATION ${_OSG_PY_INST_BASE}
2093               COMPONENT libraries
2094               OPTIONAL)
2096       INSTALL(FILES       ${_OSG_GEN_INIT_FILE_OUT} 
2097               DESTINATION ${_OSG_PY_INST_BASE}
2098               OPTIONAL)
2101       GET_PROPERTY(_OSG_CURR_SO_PATH TARGET ${PROJECT_NAME}Py PROPERTY LOCATION)
2103       GET_FILENAME_COMPONENT(_OSG_CURR_SO_NAME ${_OSG_CURR_SO_PATH} NAME)
2105       FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Python/lib/osg2/${PROJECT_NAME})
2107       OSG_SYMLINK_CHECKED(${_OSG_GEN_INIT_FILE_OUT}
2108                           ${CMAKE_BINARY_DIR}/Python/lib/osg2/${PROJECT_NAME}/__init__.py)
2109       OSG_SYMLINK_CHECKED(${_OSG_CURR_SO_PATH}
2110                           ${CMAKE_BINARY_DIR}/Python/lib/osg2/${PROJECT_NAME}/${_OSG_CURR_SO_NAME})
2112     ENDIF(WIN32)
2114     ADD_DEPENDENCIES(OSGPy      ${PROJECT_NAME}Py)
2115   ENDIF()
2117 ENDFUNCTION(OSG_SETUP_PYTHON_BUILD)
2119 #############################################################################
2120 # perform default actions for pass OSGDOXYDOC
2122 FUNCTION(OSG_SETUP_SEPARATE_LIBS_DOXYDOC)
2123     IF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGDOXYDOC")
2124         RETURN()
2125     ENDIF()
2127     IF(${PROJECT_NAME}_NO_DOC)
2128         RETURN()
2129     ENDIF(${PROJECT_NAME}_NO_DOC)
2131     # set up variables for the config file
2132     SET(OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE_IN "${CMAKE_SOURCE_DIR}/Doc/opensg-doxy.in")
2133     SET(OSG_${PROJECT_NAME}_DOC_DIRECTORY              "${OSG_DOXY_HTML_DIR}/${PROJECT_NAME}")
2134     SET(OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE    "${CMAKE_BINARY_DIR}/Doc/${PROJECT_NAME}-doxy")
2136     SET(OSG_${PROJECT_NAME}_DEP_DOXY_TAGFILES"")
2137     SET(OSG_${PROJECT_NAME}_DOXY_TAGFILE     "${CMAKE_BINARY_DIR}/Doc/${PROJECT_NAME}_DOXYGEN_TAGS")
2138     SET(OSG_${PROJECT_NAME}_DEP_DOCS         "")
2140     # dependencies - OpenSG
2141     OSG_GET_ALL_DEP_OSG_LIB("${${PROJECT_NAME}_DEP_OSG_LIB}" DEP_OSG_LIST DEP_MISSING_LIST)
2143     FOREACH(OSGDEP ${DEP_OSG_LIST})
2144         SET(OSG_${PROJECT_NAME}_DEP_DOXY_TAGFILES "${OSG_${PROJECT_NAME}_DEP_DOXY_TAGFILES} ./${OSGDEP}_DOXYGEN_TAGS=../../${OSGDEP}/html")
2145         LIST(APPEND OSG_${PROJECT_NAME}_DEP_DOCS "${OSGDEP}Doc")
2146     ENDFOREACH()
2148     IF(EXISTS "${CMAKE_BINARY_DIR}/Doc/Include/${PROJECT_NAME}.include")
2149       SET(OSG_DOC_BASIC_INPUT "${CMAKE_BINARY_DIR}/Doc/Include/${PROJECT_NAME}.include")
2150     ENDIF()
2152     # write doxygen config file
2153     CONFIGURE_FILE("${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE_IN}"
2154                    "${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE}")
2156     SET(OSG_DOC_BASIC_INPUT "${CMAKE_BINARY_DIR}/Doc/Include/OSGDummy.include")
2158     IF(DOXYGEN_EXECUTABLE)
2159         #ADD_CUSTOM_TARGET(DocUpload COMMAND unison -batch -ui text opensg_doc)
2160         #ADD_DEPENDENCIES(DocUpload Doc)
2162         SET(OSG_DOC_PIPES "")
2164         IF(OSG_DOXY_STDOUT_LOG)
2165           SET(OSG_DOC_PIPES > ${OSG_DOXY_STDOUT_LOG}.${PROJECT_NAME})
2166         ENDIF(OSG_DOXY_STDOUT_LOG)
2168         ADD_CUSTOM_TARGET(${PROJECT_NAME}DocOnly
2169             VERBATIM
2170             COMMAND ${DOXYGEN_EXECUTABLE} ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE} ${OSG_DOC_PIPES}
2171             WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Doc")
2173         ADD_CUSTOM_TARGET(${PROJECT_NAME}Doc
2174             VERBATIM
2175             COMMAND ${DOXYGEN_EXECUTABLE} ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE} ${OSG_DOC_PIPES}
2176             WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Doc")
2178         FOREACH(OSGDEPDOC ${OSG_${PROJECT_NAME}_DEP_DOCS})
2179             ADD_DEPENDENCIES(${PROJECT_NAME}Doc ${OSGDEPDOC})
2180         ENDFOREACH()
2182         ADD_DEPENDENCIES(Doc ${PROJECT_NAME}Doc)
2183     ENDIF()
2185     INCLUDE(${${PROJECT_NAME}_BUILD_FILE})
2189 #    FILE(APPEND ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE}
2190 #        "#############################################################################\n")
2192 #    IF(${PROJECT_NAME}_DOXY_EXTRA_INC)
2193 #        FILE(APPEND ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE}
2194 #            "# doc input files for ${PROJECT_NAME}\n\n")
2196 #        FOREACH(DOXYFILE ${${PROJECT_NAME}_DOXY_EXTRA_INC})
2197 #            FILE(APPEND ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE}
2198 #                "INPUT += ${DOXYFILE}\n")
2199 #        ENDFOREACH()
2201 #        FILE(APPEND ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE} "\n")
2202 #    ENDIF()
2204     FILE(APPEND ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE}
2205         "# source code input files for ${PROJECT_NAME}\n\n")
2207     FOREACH(INCDIR ${${PROJECT_NAME}_INC})
2208         FILE(APPEND ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE}
2209             "INPUT += ${INCDIR}\n")
2210     ENDFOREACH()
2212     FILE(APPEND ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE} "\n")
2214 ENDFUNCTION(OSG_SETUP_SEPARATE_LIBS_DOXYDOC)
2216 #############################################################################
2217 # perform default actions for pass OSGDOXYDOC
2219 FUNCTION(OSG_SETUP_DOXYDOC)
2220     IF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGDOXYDOC")
2221         RETURN()
2222     ENDIF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGDOXYDOC")
2224     IF(${PROJECT_NAME}_NO_DOC)
2225         RETURN()
2226     ENDIF(${PROJECT_NAME}_NO_DOC)
2229     INCLUDE(${${PROJECT_NAME}_BUILD_FILE})
2231     FILE(APPEND ${OSG_DOXY_CONFIGURATION_FILE}
2232         "#############################################################################\n"
2233         )
2234     FILE(APPEND ${OSG_DOXY_CONFIGURATION_FILE}
2235         "# doc input files for ${PROJECT_NAME}\n\n"
2236         )
2238     FOREACH(INCDIR ${${PROJECT_NAME}_INC})
2239         FILE(APPEND ${OSG_DOXY_CONFIGURATION_FILE}
2240             "INPUT += ${INCDIR}\n")
2241     ENDFOREACH(INCDIR)
2243     FILE(APPEND ${OSG_DOXY_CONFIGURATION_FILE} "\n")
2245 ENDFUNCTION(OSG_SETUP_DOXYDOC)
2247 #############################################################################
2248 # perform default actions for build passes
2250 FUNCTION(OSG_SETUP_PROJECT PROJ_DEFINE)
2252     FOREACH(_OSG_${PROJECT_NAME}_EXT_DIR ${${PROJECT_NAME}_EXT_DIRS})
2253       OSG_ADD_DIRECTORY(${_OSG_${PROJECT_NAME}_EXT_DIR})
2254     ENDFOREACH(_OSG_${PROJECT_NAME}_EXT_DIR ${${PROJECT_NAME}_EXT_DIRS})
2256     IF(OSG_CMAKE_PASS STREQUAL "OSGSETUP")
2257         OSG_SETUP_LIBRARY_BUILD(${PROJ_DEFINE})
2259     ELSEIF(OSG_CMAKE_PASS STREQUAL "OSGSETUPTEST")
2260         OSG_SETUP_TEST_BUILD()
2262     ELSEIF(OSG_CMAKE_PASS STREQUAL "OSGSETUPUNITTEST")
2263         OSG_SETUP_UNITTEST_BUILD()
2265     ELSEIF(OSG_CMAKE_PASS STREQUAL "OSGDOXYDOC")
2266         IF(OSG_GENERATE_SEPARATE_LIB_DOC)
2267             OSG_SETUP_SEPARATE_LIBS_DOXYDOC()
2268         ELSE()
2269             OSG_SETUP_DOXYDOC()
2270         ENDIF()
2272     ELSEIF(OSG_CMAKE_PASS STREQUAL "OSGPYTHON")
2273       OSG_SETUP_PYTHON_BUILD()
2275     ENDIF(OSG_CMAKE_PASS STREQUAL "OSGSETUP")
2277 ENDFUNCTION(OSG_SETUP_PROJECT)
2279 #############################################################################
2280 # setup import targets so the debug/debugopt build type works correctly
2282 FUNCTION(OSG_SETUP_IMPORT_LIB_WINDOWS NEW_LIB)
2284   IF(${NEW_LIB}_RELEASE)
2285       GET_FILENAME_COMPONENT(OSG_TMP_LIB_DIR ${${NEW_LIB}_RELEASE} PATH)
2286   ENDIF(${NEW_LIB}_RELEASE)
2288   IF(NOT OSG_TMP_LIB_DIR AND ${NEW_LIB}_DEBUG)
2289       GET_FILENAME_COMPONENT(OSG_TMP_LIB_DIR ${${NEW_LIB}_DEBUG} PATH)
2290   ENDIF(NOT OSG_TMP_LIB_DIR AND ${NEW_LIB}_DEBUG)
2293   SET_TARGET_PROPERTIES(OSG_${NEW_LIB}_TARGET PROPERTIES
2294                         IMPORTED_IMPLIB_RELEASE ${${NEW_LIB}_RELEASE}
2295                         IMPORTED_LOCATION_RELEASE ${OSG_TMP_LIB_DIR}
2296                         IMPORTED_IMPLIB_RELEASENOOPT ${${NEW_LIB}_RELEASE}
2297                         IMPORTED_LOCATION_RELEASENOOPT ${OSG_TMP_LIB_DIR}
2298                         IMPORTED_IMPLIB_DEBUG ${${NEW_LIB}_DEBUG}
2299                         IMPORTED_LOCATION_DEBUG ${OSG_TMP_LIB_DIR}
2300                         IMPORTED_IMPLIB_DEBUGOPT ${${NEW_LIB}_DEBUG}
2301                         IMPORTED_LOCATION_DEBUGOPT ${OSG_TMP_LIB_DIR})
2303 ENDFUNCTION(OSG_SETUP_IMPORT_LIB_WINDOWS)
2305 FUNCTION(OSG_SETUP_IMPORT_LIB_UNIX NEW_LIB)
2307   IF(${NEW_LIB}_RELEASE)
2308       GET_FILENAME_COMPONENT(OSG_TMP_LIB_DIR ${${NEW_LIB}_RELEASE} PATH)
2309   ENDIF(${NEW_LIB}_RELEASE)
2311   IF(NOT OSG_TMP_LIB_DIR AND ${NEW_LIB}_DEBUG)
2312       GET_FILENAME_COMPONENT(OSG_TMP_LIB_DIR ${${NEW_LIB}_DEBUG} PATH)
2313   ENDIF(NOT OSG_TMP_LIB_DIR AND ${NEW_LIB}_DEBUG)
2315   IF(${NEW_LIB}_RELEASE AND NOT ${NEW_LIB}_DEBUG)
2316     SET(${NEW_LIB}_DEBUG ${${NEW_LIB}_RELEASE} CACHE FILEPATH "" FORCE)
2317   ENDIF(${NEW_LIB}_RELEASE AND NOT ${NEW_LIB}_DEBUG)
2319   IF(NOT ${NEW_LIB}_RELEASE AND ${NEW_LIB}_DEBUG)
2320     SET(${NEW_LIB}_RELEASE ${${NEW_LIB}_DEBUG} CACHE FILEPATH "" FORCE)
2321   ENDIF(NOT ${NEW_LIB}_RELEASE AND ${NEW_LIB}_DEBUG)
2323   SET_TARGET_PROPERTIES(OSG_${NEW_LIB}_TARGET PROPERTIES
2324                         IMPORTED_LOCATION ${${NEW_LIB}_RELEASE}
2325                         IMPORTED_LOCATION_DEBUG ${${NEW_LIB}_DEBUG}
2326                         IMPORTED_LOCATION_DEBUGGV ${${NEW_LIB}_DEBUG})
2328 ENDFUNCTION(OSG_SETUP_IMPORT_LIB_UNIX)
2330 MACRO(OSG_ADD_IMPORT_LIB LIB_LIST NEW_LIB)
2332     IF(NOT TARGET OSG_${NEW_LIB}_TARGET)
2333       ADD_LIBRARY(OSG_${NEW_LIB}_TARGET SHARED IMPORTED)
2334     ENDIF()
2336     IF(WIN32)
2337       OSG_SETUP_IMPORT_LIB_WINDOWS(${NEW_LIB})
2338     ELSE(WIN32)
2339       OSG_SETUP_IMPORT_LIB_UNIX(${NEW_LIB})
2341       OSG_ADD_OPT(${NEW_LIB}_RELEASE)
2342       OSG_ADD_OPT(${NEW_LIB}_DEBUG)
2343       OSG_ADD_OPT(OSG_${NEW_LIB}_TARGET)
2344     ENDIF(WIN32)
2346     LIST(APPEND ${LIB_LIST} OSG_${NEW_LIB}_TARGET)
2348 ENDMACRO(OSG_ADD_IMPORT_LIB)
2350 ##########################################################################
2351 # write settings so different variants can be build with the same settings
2353 MACRO(OSG_OPTION NAME DESC VALUE)
2354     LIST(APPEND OSG_OPTION_LIST ${NAME})
2355     OSG_MSG("adding option ${NAME} = ${VALUE}")
2357     OPTION(${NAME} "${DESC}" ${VALUE})
2358 ENDMACRO(OSG_OPTION)
2360 MACRO(OSG_SET_CACHE NAME VALUE TYPE DESC)
2361     LIST(APPEND OSG_OPTION_LIST ${NAME})
2363     SET(${NAME} ${VALUE} CACHE ${TYPE} "${DESC}")
2364 ENDMACRO(OSG_SET_CACHE)
2366 MACRO(OSG_SET NAME VALUE)
2367     LIST(APPEND OSG_OPTION_LIST ${NAME})
2369     SET(${NAME} ${VALUE})
2370 ENDMACRO(OSG_SET)
2372 MACRO(OSG_ADD_OPT NAME)
2373     LIST(APPEND OSG_OPTION_LIST ${NAME})
2374 ENDMACRO(OSG_ADD_OPT)
2376 MACRO(OSG_FIND_PACKAGE NAME)
2377     FIND_PACKAGE(${NAME})
2379     IF(${NAME}_FOUND)
2380         OSG_ADD_OPT(${NAME}_LIBRARIES)
2381         OSG_ADD_OPT(${NAME}_INCLUDE_DIR)
2382     ENDIF(${NAME}_FOUND)
2384     OSG_ADD_OPT(${NAME}_FOUND)
2385 ENDMACRO(OSG_FIND_PACKAGE)
2387 MACRO(OSG_BOOST_DEP_SETUP)
2388     SET(Boost_USE_MULTITHREAD ON )
2389     SET(Boost_USE_STATIC_LIBS OFF)
2391     FIND_PACKAGE(Boost COMPONENTS filesystem)
2393     IF(Boost_FOUND)
2395         IF(${Boost_MINOR_VERSION} GREATER 34)
2396           FIND_PACKAGE(Boost COMPONENTS system)
2397         ENDIF(${Boost_MINOR_VERSION} GREATER 34)
2399         IF(PYTHON_INCLUDE_PATH AND PYTHON_LIBRARY)
2400           FIND_PACKAGE(Boost COMPONENTS python)
2401         ENDIF(PYTHON_INCLUDE_PATH AND PYTHON_LIBRARY)
2403         # We ignore if boost python fails, we catch that somewhere else
2404         # so if we get here Boost_FOUND was true in the first place
2405         SET(Boost_FOUND TRUE)
2407         # Hide settings
2408         SET(Boost_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY}
2409                                      CACHE INTERNAL "")
2410         SET(Boost_FILESYSTEM_LIBRARY_DEBUG ${Boost_FILESYSTEM_LIBRARY_DEBUG}
2411                                            CACHE INTERNAL "")
2412         SET(Boost_FILESYSTEM_LIBRARY_RELEASE
2413            ${Boost_FILESYSTEM_LIBRARY_RELEASE}
2414            CACHE INTERNAL "")
2416         SET(Boost_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY}
2417                                CACHE INTERNAL "")
2418         SET(Boost_SYSTEM_LIBRARY_DEBUG ${Boost_SYSTEM_LIBRARY_DEBUG}
2419                                        CACHE INTERNAL "")
2420         SET(Boost_SYSTEM_LIBRARY_RELEASE
2421            ${Boost_SYSTEM_LIBRARY_RELEASE}
2422            CACHE INTERNAL "")
2424         SET(Boost_PYTHON_LIBRARY ${Boost_PYTHON_LIBRARY}
2425                                      CACHE INTERNAL "")
2426         SET(Boost_PYTHON_LIBRARY_DEBUG ${Boost_PYTHON_LIBRARY_DEBUG}
2427                                            CACHE INTERNAL "")
2428         SET(Boost_PYTHON_LIBRARY_RELEASE
2429            ${Boost_PYTHON_LIBRARY_RELEASE}
2430            CACHE INTERNAL "")
2433         SET(Boost_INCLUDE_DIR ${Boost_INCLUDE_DIR}
2434                               CACHE INTERNAL "")
2436         SET(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS}
2437                                CACHE INTERNAL "")
2439         SET(Boost_USE_MULTITHREADED ${Boost_USE_MULTI_THREADED}
2440                                     CACHE INTERNAL "")
2443         INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR} )
2445         IF(UNIX)
2446             LINK_DIRECTORIES   (${Boost_LIBRARY_DIRS})
2447         ENDIF(UNIX)
2449         IF(NOT Boost_USE_STATIC_LIBS)
2450           ADD_DEFINITIONS(-DBOOST_ALL_DYN_LINK)
2451         ENDIF(NOT Boost_USE_STATIC_LIBS)
2453         IF(CMAKE_BUILD_TYPE STREQUAL "Debug" OR
2454            CMAKE_BUILD_TYPE STREQUAL "DebugOpt")
2456           IF(${Boost_MINOR_VERSION} GREATER 34)
2457             SET(OSG_BOOST_LIBS ${Boost_FILESYSTEM_LIBRARY_DEBUG} 
2458                                ${Boost_SYSTEM_LIBRARY_DEBUG})
2459           ELSE()
2460             SET(OSG_BOOST_LIBS ${Boost_FILESYSTEM_LIBRARY_DEBUG})
2461           ENDIF(${Boost_MINOR_VERSION} GREATER 34)
2463           SET(OSG_BOOST_PYTHON_LIBS ${Boost_PYTHON_LIBRARY_DEBUG})
2465         ELSE()
2467           IF(${Boost_MINOR_VERSION} GREATER 34)
2468             SET(OSG_BOOST_LIBS ${Boost_FILESYSTEM_LIBRARY_RELEASE} 
2469                                ${Boost_SYSTEM_LIBRARY_RELEASE})
2470           ELSE()
2471             SET(OSG_BOOST_LIBS ${Boost_FILESYSTEM_LIBRARY_RELEASE})
2472           ENDIF(${Boost_MINOR_VERSION} GREATER 34)
2474           SET(OSG_BOOST_PYTHON_LIBS ${Boost_PYTHON_LIBRARY_RELEASE})
2476         ENDIF()
2478         SET(OSG_BOOST_INCDIRS ${Boost_INCLUDE_DIR})
2480     ENDIF(Boost_FOUND)
2481 ENDMACRO(OSG_BOOST_DEP_SETUP)
2483 FUNCTION(OSG_WRITE_SETTINGS FILENAME)
2484     FILE(WRITE ${FILENAME}
2485             "# CMake.settings -- auto generated\n\n")
2487     FOREACH(OSG_OPT ${OSG_OPTION_LIST})
2488       IF(TARGET ${OSG_OPT})
2489         STRING(REPLACE _TARGET "" _OSG_OPT_BASE ${OSG_OPT})
2490         STRING(REPLACE OSG_ "" _OSG_OPT_OSGBASE ${_OSG_OPT_BASE})
2492         IF(NOT ${_OSG_OPT_OSGBASE}_DEBUG)
2493           SET(${_OSG_OPT_OSGBASE}_DEBUG ${OSG_${_OSG_OPT_OSGBASE}_DEBUG})
2494         ENDIF()
2495         IF(NOT ${_OSG_OPT_OSGBASE}_RELEASE)
2496           SET(${_OSG_OPT_OSGBASE}_RELEASE ${OSG_${_OSG_OPT_OSGBASE}_RELEASE})
2497         ENDIF()
2499         FILE(APPEND ${FILENAME}
2500           "ADD_LIBRARY(${_OSG_OPT_BASE}_TARGET SHARED IMPORTED)\n"
2501           "SET_TARGET_PROPERTIES(${_OSG_OPT_BASE}_TARGET PROPERTIES\n"
2502           "                      IMPORTED_LOCATION ${${_OSG_OPT_OSGBASE}_RELEASE}\n"
2503           "                      IMPORTED_LOCATION_DEBUG ${${_OSG_OPT_OSGBASE}_DEBUG}\n"
2504           "                      IMPORTED_LOCATION_DEBUGGV ${${_OSG_OPT_OSGBASE}_DEBUG})\n")
2505       ELSE()
2506         FILE(APPEND ${FILENAME}
2507              "SET(${OSG_OPT} ${${OSG_OPT}} CACHE INTERNAL \"\")\n")
2508       ENDIF()
2509     ENDFOREACH(OSG_OPT ${OSG_OPTION_LIST})
2511 ENDFUNCTION(OSG_WRITE_SETTINGS FILENAME)
2513 FUNCTION(CHECK_BUILD_DIR)
2514   IF("${${CMAKE_PROJECT_NAME}_SOURCE_DIR}"  STREQUAL "${${CMAKE_PROJECT_NAME}_BINARY_DIR}")
2515     MESSAGE(FATAL_ERROR "${CMAKE_PROJECT_NAME} requires an out of source Build. \n"
2516                         "Please create a separate binary directory and run "
2517                         "CMake there.")
2518   ENDIF("${${CMAKE_PROJECT_NAME}_SOURCE_DIR}"  STREQUAL "${${CMAKE_PROJECT_NAME}_BINARY_DIR}")
2519 ENDFUNCTION(CHECK_BUILD_DIR)
2521 MACRO(OSG_CHECK_INSTALL)
2523 MESSAGE(STATUS  "process ignore install ${OSG_IGNORE_INSTALL}")
2525   IF(OSG_IGNORE_INSTALL)
2526     FOREACH(OSG_IGNORE_PRJ ${OSG_IGNORE_INSTALL})
2527       SET(OSG_IGNORE_INSTALL_${OSG_IGNORE_PRJ} TRUE)
2528     ENDFOREACH()
2529   ENDIF(OSG_IGNORE_INSTALL)
2530 ENDMACRO(OSG_CHECK_INSTALL)
2532 ##########################################################################
2533 # Add Tutorial builds as tests
2535 FUNCTION(OSG_ADD_TUTORIAL_TESTS TUTORIALS_NAME TUTORIAL_SOURCE_DIR)
2536     IF(NOT OSGBUILD_UNITTESTS)
2537         RETURN()
2538     ENDIF()
2540     FILE(GLOB TUTORIAL_SOURCES "${TUTORIAL_SOURCE_DIR}/[0-9][0-9]*.cpp")
2542     FOREACH(TUTORIAL ${TUTORIAL_SOURCES})
2543         #Get the path to the tutorial executable
2544         STRING(LENGTH ${TUTORIAL} SOURCE_PATH_LENGTH)
2545         MATH(EXPR SOURCE_PATH_LENGTH '${SOURCE_PATH_LENGTH}-4')
2546         STRING(SUBSTRING ${TUTORIAL} 0 ${SOURCE_PATH_LENGTH} TUTORIAL_EXE_PATH )
2547         SET(TUTORIAL_EXE_PATH "${TUTORIAL_EXE_PATH}${CMAKE_EXECUTABLE_SUFFIX}")
2549         #Extract a short name for the tutorial test
2550         STRING(REGEX MATCH "([0-9][0-9].*)[.]cpp" TUTORIAL_NAME ${TUTORIAL})
2551         SET(TUTORIAL_NAME ${CMAKE_MATCH_1})
2553         #Add a test to see if the tutorial exists
2554         ADD_TEST(NAME "${TUTORIALS_NAME}-${TUTORIAL_NAME}"
2555                  COMMAND test -e ${TUTORIAL_EXE_PATH})
2556     ENDFOREACH()
2557 ENDFUNCTION()