fixed: win32 nsis package naming
[opensg.git] / CMake / BuildFunctions.cmake
blob8f57b256bd7b616b624f739012e8bb4b88f82b44
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}_MOC)
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}_MOC)
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     IF(WIN32)
1000       IF(${OSG_MAIN_LIB_TARGET} MATCHES OSGAllCoreLibs)
1001         SET_PROPERTY(TARGET ${PROJECT_NAME} PROPERTY FOLDER "OSGCoreLibraries")
1002       ELSEIF(${OSG_MAIN_LIB_TARGET} MATCHES OSGAllContribLibs)
1003         SET_PROPERTY(TARGET ${PROJECT_NAME} PROPERTY FOLDER "OSGContribLibraries")
1004       ENDIF()
1005     ENDIF()
1007     INCLUDE_DIRECTORIES(${${PROJECT_NAME}_INC})
1009     SET(_OSG_DEBUG_POSTFIX "")
1011     IF(WIN32)
1012         SET(_OSG_DEBUG_POSTFIX DEBUG_POSTFIX "D")
1013     ENDIF(WIN32)
1015     IF(OSG_USE_OSG2_NAMESPACE)
1016       STRING(REGEX REPLACE "^OSG" "OSG2"
1017              PROJECT_NAME_VERSIONED
1018              ${PROJECT_NAME})
1019     ELSE()
1020       SET(PROJECT_NAME_VERSIONED ${PROJECT_NAME})
1021     ENDIF()
1023     SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
1024         DEFINE_SYMBOL ${PROJ_DEFINE}
1025         VERSION ${OSG_VERSION}
1026         SOVERSION ${OSG_VERSION}
1027         ${_OSG_DEBUG_POSTFIX}
1028         DEBUGOPT_POSTFIX "DO"
1029         RELEASENOOPT_POSTFIX "RN"
1030         OUTPUT_NAME ${PROJECT_NAME_VERSIONED})
1032     IF(${PROJECT_NAME}_SUFFIX)
1033       SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
1034                             SUFFIX ${${PROJECT_NAME}_SUFFIX})
1036     ENDIF(${PROJECT_NAME}_SUFFIX)
1038     # dependencies - OpenSG
1039     OSG_GET_ALL_DEP_OSG_LIB(
1040         "${${PROJECT_NAME}_DEP_OSG_LIB}" DEP_OSG_LIST DEP_MISSING_LIST)
1042     # a lib with missing dependencies is fatal - it should not have made it here
1043     IF(DEP_MISSING_LIST)
1044         MESSAGE(FATAL_ERROR "Project ${PROJECT_NAME} has missing dependencies: ${DEP_MISSING_LIST}")
1045     ENDIF(DEP_MISSING_LIST)
1047     FOREACH(OSGDEP ${DEP_OSG_LIST})
1048         OSG_CHECKED_INCLUDE("${CMAKE_BINARY_DIR}/${OSGDEP}.cmake")
1049         INCLUDE_DIRECTORIES(${${OSGDEP}_INC})
1050     ENDFOREACH(OSGDEP)
1052     FOREACH(OSGDEP ${${PROJECT_NAME}_DEP_OSG_LIB})
1053         OSG_CHECKED_INCLUDE  ("${CMAKE_BINARY_DIR}/${OSGDEP}.cmake")
1055         SET(${_OSGDEP_IMPORTED} FALSE)
1057         IF(TARGET ${OSGDEP})
1058           GET_PROPERTY(_OSGDEP_IMPORTED TARGET ${OSGDEP} PROPERTY IMPORTED)
1059         ENDIF(TARGET ${OSGDEP})
1061         IF(NOT _OSGDEP_IMPORTED)
1062           ADD_DEPENDENCIES     (${PROJECT_NAME} ${OSGDEP})
1063         ENDIF(NOT _OSGDEP_IMPORTED)
1065         IF(NOT APPLE OR NOT IOS)
1066           TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${OSGDEP})
1067         ENDIF()
1068     ENDFOREACH(OSGDEP)
1070     # dependencies - global
1071     FOREACH(INCDIR ${OSG_GLOBAL_DEP_INCDIR})
1072         OSG_MSG("  (global) - include dir ${INCDIR} = ${${INCDIR}}")
1073         INCLUDE_DIRECTORIES(${${INCDIR}})
1074     ENDFOREACH(INCDIR)
1076     FOREACH(LIB ${OSG_GLOBAL_DEP_LIBS})
1077         OSG_MSG("  (global) - library ${LIB} = ${${LIB}}")
1078         TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${${LIB}})
1079     ENDFOREACH(LIB)
1081     IF(OSG_GLOBAL_DEP_DEFS)
1082         OSG_MSG("  (global) - definitions = ${OSG_GLOBAL_DEP_DEFS}")
1083         SET_PROPERTY(TARGET ${PROJECT_NAME}
1084             APPEND PROPERTY COMPILE_DEFINITIONS ${OSG_GLOBAL_DEP_DEFS})
1085     ENDIF(OSG_GLOBAL_DEP_DEFS)
1087     # dependencies - External
1088     FOREACH(INCDIR ${${PROJECT_NAME}_DEP_INCDIR})
1089         OSG_MSG("  (external) - include dir ${INCDIR} = ${${INCDIR}}")
1090         INCLUDE_DIRECTORIES(${${INCDIR}})
1091     ENDFOREACH(INCDIR)
1093     FOREACH(LIB ${${PROJECT_NAME}_DEP_LIB})
1094         OSG_MSG("  (external) - library ${LIB} = ${${LIB}}")
1095         IF(NOT APPLE OR NOT IOS)
1096           TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${${LIB}})
1097         ENDIF()
1098     ENDFOREACH(LIB)
1100     IF(${PROJECT_NAME}_DEP_DEFS)
1101         OSG_MSG("  (external) - definitions = ${${PROJECT_NAME}_DEP_DEFS}")
1102         SET_PROPERTY(TARGET ${PROJECT_NAME}
1103             APPEND PROPERTY COMPILE_DEFINITIONS ${${PROJECT_NAME}_DEP_DEFS})
1104     ENDIF(${PROJECT_NAME}_DEP_DEFS)
1106     IF(${PROJECT_NAME}_CXXFLAGS)
1107       SET_PROPERTY(TARGET ${PROJECT_NAME}
1108                     APPEND PROPERTY COMPILE_FLAGS ${${PROJECT_NAME}_CXXFLAGS})
1109     ENDIF(${PROJECT_NAME}_CXXFLAGS)
1111     IF(OSG_IGNORE_INSTALL_${PROJECT_NAME})
1112       RETURN()
1113     ENDIF()
1115     # install rules
1116     IF(WIN32)
1118         IF(OSG_INSTALL_SUBDIR)
1119             SET(_OSG_ISC "${OSG_INSTALL_SUBDIR}/")
1120         ELSE(OSG_INSTALL_SUBDIR)
1121             SET(_OSG_ISC "")
1122         ENDIF(OSG_INSTALL_SUBDIR)
1124         IF(OSG_USE_SEPARATE_LIBDIRS)
1125           SET(_OSG_TARGET_BINDIR_REL bin/${_OSG_ISC}rel)
1126           SET(_OSG_TARGET_BINDIR_DBG bin/${_OSG_ISC}debug)
1127           SET(_OSG_TARGET_BINDIR_RELNO bin/${_OSG_ISC}relnoopt)
1128           SET(_OSG_TARGET_BINDIR_DBGO bin/${_OSG_ISC}debugopt)
1130           SET(_OSG_TARGET_LIBDIR_REL lib/${_OSG_ISC}rel)
1131           SET(_OSG_TARGET_LIBDIR_DBG lib/${_OSG_ISC}debug)
1132           SET(_OSG_TARGET_LIBDIR_RELNO lib/${_OSG_ISC}relnoopt)
1133           SET(_OSG_TARGET_LIBDIR_DBGO lib/${_OSG_ISC}debugopt)
1134         ELSE(OSG_USE_SEPARATE_LIBDIRS)
1135           SET(_OSG_TARGET_BINDIR_REL bin/${_OSG_ISC})
1136           SET(_OSG_TARGET_BINDIR_DBG bin/${_OSG_ISC})
1137           SET(_OSG_TARGET_BINDIR_RELNO bin/${_OSG_ISC})
1138           SET(_OSG_TARGET_BINDIR_DBGO bin/${_OSG_ISC})
1140           SET(_OSG_TARGET_LIBDIR_REL lib/${_OSG_ISC})
1141           SET(_OSG_TARGET_LIBDIR_DBG lib/${_OSG_ISC})
1142           SET(_OSG_TARGET_LIBDIR_RELNO lib/${_OSG_ISC})
1143           SET(_OSG_TARGET_LIBDIR_DBGO lib/${_OSG_ISC})
1144         ENDIF(OSG_USE_SEPARATE_LIBDIRS)
1146         INSTALL(TARGETS ${PROJECT_NAME}
1147                 CONFIGURATIONS Release
1148                 RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_REL}
1149                 COMPONENT release_runtimes)
1151         INSTALL(TARGETS ${PROJECT_NAME}
1152                 CONFIGURATIONS Release
1154                 LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_REL}
1155                 COMPONENT release_libraries
1157                 ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_REL}
1158                 COMPONENT release_libraries)
1160         IF(NOT ${PROJECT_NAME}_NO_DBG_INSTALL)
1161           INSTALL(TARGETS ${PROJECT_NAME}
1162                   CONFIGURATIONS Debug
1163                   RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_DBG}
1164                   COMPONENT debug_runtimes)
1166           INSTALL(TARGETS ${PROJECT_NAME}
1167                   CONFIGURATIONS Debug
1169                   LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_DBG}
1170                   COMPONENT debug_libraries 
1172                   ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_DBG}
1173                   COMPONENT debug_libraries)
1174         ENDIF()
1176         INSTALL(TARGETS ${PROJECT_NAME}
1177                 CONFIGURATIONS ReleaseNoOpt
1178                 RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_RELNO}
1179                 COMPONENT release_no_opt_runtimes)
1181         INSTALL(TARGETS ${PROJECT_NAME}
1182                 CONFIGURATIONS ReleaseNoOpt
1184                 LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_RELNO}
1185                 COMPONENT release_no_opt_libraries
1187                 ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_RELNO}
1188                 COMPONENT release_no_opt_libraries)
1190         IF(NOT ${PROJECT_NAME}_NO_DBG_INSTALL)
1191           INSTALL(TARGETS ${PROJECT_NAME}
1192                   CONFIGURATIONS DebugOpt
1193                   RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_DBGO}
1194                   COMPONENT debug_opt_runtimes)
1196           INSTALL(TARGETS ${PROJECT_NAME}
1197                   CONFIGURATIONS DebugOpt
1199                   LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_DBGO}
1200                   COMPONENT debug_opt_libraries
1202                   ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_DBGO}
1203                   COMPONENT debug_opt_libraries)
1204         ENDIF()
1207         IF(OSG_INSTALL_PDB_FILES)
1209           GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME} Release_LOCATION)
1211           STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
1213           INSTALL(FILES ${_TMPVAL1}
1214                   CONFIGURATIONS Release
1215                   DESTINATION ${_OSG_TARGET_BINDIR_REL}
1216                   COMPONENT release_program_db)
1219           GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME} Debug_LOCATION)
1221           STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
1223           INSTALL(FILES ${_TMPVAL1}
1224                   CONFIGURATIONS Debug
1225                   DESTINATION ${_OSG_TARGET_BINDIR_DBG}
1226                   COMPONENT debug_program_db)
1229           GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME} ReleaseNoOpt_LOCATION)
1231           STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
1233           INSTALL(FILES ${_TMPVAL1}
1234                   CONFIGURATIONS ReleaseNoOpt
1235                   DESTINATION ${_OSG_TARGET_BINDIR_RELNO}
1236                   COMPONENT release_no_opt_program_db)
1239           GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME} DebugOpt_LOCATION)
1241           STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
1243           INSTALL(FILES ${_TMPVAL1}
1244                   CONFIGURATIONS DebugOpt
1245                   DESTINATION ${_OSG_TARGET_BINDIR_DBGO}
1246                   COMPONENT debug_opt_program_db)
1248         ENDIF(OSG_INSTALL_PDB_FILES)
1250         IF(FALSE)
1251           INSTALL(TARGETS ${PROJECT_NAME}
1252                   CONFIGURATIONS MinSizeRel
1253                   RUNTIME DESTINATION lib/minsizerel
1254                   COMPONENT release_minsize_runtimes)
1256           INSTALL(TARGETS ${PROJECT_NAME}
1257                   CONFIGURATIONS MinSizeRel
1258                   LIBRARY DESTINATION lib/minsizerel
1259                   COMPONENT release_minsize_libraries
1260                   ARCHIVE DESTINATION lib/minsizerel
1261                   COMPONENT release_minsize_libraries)
1263           INSTALL(TARGETS ${PROJECT_NAME}
1264                   CONFIGURATIONS RelWithDebInfo
1265                   RUNTIME DESTINATION lib/relwithdbg
1266                   COMPONENT release_with_debinfo_runtimes)
1268           INSTALL(TARGETS ${PROJECT_NAME}
1269                   CONFIGURATIONS RelWithDebInfo
1270                   LIBRARY DESTINATION lib/relwithdbg
1271                   COMPONENT release_with_debinfo_libraries
1272                   ARCHIVE DESTINATION lib/relwithdbg
1273                   COMPONENT release_with_debinfo_libraries)
1274         ENDIF()
1275     ELSEIF(APPLE AND IOS)
1276         INSTALL(TARGETS ${PROJECT_NAME}
1277                 CONFIGURATIONS Release-iphoneos
1278                 DESTINATION lib/Release-iphoneos)
1279         INSTALL(TARGETS ${PROJECT_NAME}
1280                 CONFIGURATIONS Debug-iphoneos
1281                 DESTINATION lib/Debug-iphoneos)
1282         INSTALL(TARGETS ${PROJECT_NAME}
1283                 CONFIGURATIONS Release-iphonesimulator
1284                 DESTINATION lib/Release-iphonesimulator)
1285         INSTALL(TARGETS ${PROJECT_NAME}
1286                 CONFIGURATIONS Debug-iphonesimulator
1287                 DESTINATION lib/Debug-iphonesimulator)
1288     ELSEIF(XCODE_VERSION)
1289 #        INSTALL(TARGETS ${PROJECT_NAME}
1290 #                CONFIGURATIONS Release
1291 #                RUNTIME DESTINATION lib${OSG_LIBDIR_BASE_SUFFIX}
1292 #                COMPONENT release_runtimes)
1294         INSTALL(TARGETS ${PROJECT_NAME}
1295                 CONFIGURATIONS Release
1297                 LIBRARY DESTINATION lib${OSG_LIBDIR_BASE_SUFFIX}
1298                 COMPONENT release_libraries
1300                 ARCHIVE DESTINATION lib${OSG_LIBDIR_BASE_SUFFIX}
1301                 COMPONENT release_libraries)
1303 #        INSTALL(TARGETS ${PROJECT_NAME}
1304 #                CONFIGURATIONS Debug
1305 #                RUNTIME DESTINATION lib${OSG_LIBDIR_BASE_SUFFIX}/debug
1306 #                COMPONENT debug_runtimes)
1308         INSTALL(TARGETS ${PROJECT_NAME}
1309                 CONFIGURATIONS Debug
1311                 LIBRARY DESTINATION lib${OSG_LIBDIR_BASE_SUFFIX}/debug
1312                 COMPONENT debug_libraries
1314                 ARCHIVE DESTINATION lib${OSG_LIBDIR_BASE_SUFFIX}/debug
1315                 COMPONENT debug_libraries)
1316     ELSE(WIN32)
1317         INSTALL(TARGETS ${PROJECT_NAME}
1319                 RUNTIME DESTINATION lib${OSG_LIBDIR_SUFFIX}
1320                 COMPONENT libraries
1322                 LIBRARY DESTINATION lib${OSG_LIBDIR_SUFFIX}
1323                 COMPONENT libraries
1325                 ARCHIVE DESTINATION lib${OSG_LIBDIR_SUFFIX}
1326                 COMPONENT libraries)
1327     ENDIF(WIN32)
1329     INSTALL(FILES ${${PROJECT_NAME}_HDR}
1330             DESTINATION include/OpenSG
1331             PERMISSIONS OWNER_WRITE OWNER_READ
1332                         GROUP_READ
1333                         WORLD_READ
1334             COMPONENT code_headers)
1336     INSTALL(FILES ${${PROJECT_NAME}_INL}
1337             DESTINATION include/OpenSG
1338             PERMISSIONS OWNER_WRITE OWNER_READ
1339                         GROUP_READ
1340                         WORLD_READ
1341             COMPONENT code_headers)
1343     INSTALL(FILES ${${PROJECT_NAME}_INS}
1344             DESTINATION include/OpenSG
1345             PERMISSIONS OWNER_WRITE OWNER_READ
1346                         GROUP_READ
1347                         WORLD_READ
1348             COMPONENT code_headers)
1350     IF(NOT ${PROJECT_NAME}_NO_PYTHON)
1351       FILE(APPEND "${CMAKE_BINARY_DIR}/Python/Helper/libOrder.py" "libInfo[\"${PROJECT_NAME}\"] = [\n")
1352       FOREACH(OSG_DEP ${DEP_OSG_LIST})
1353         FILE(APPEND "${CMAKE_BINARY_DIR}/Python/Helper/libOrder.py" "\"${OSG_DEP}\",")
1354       ENDFOREACH()
1355       FILE(APPEND "${CMAKE_BINARY_DIR}/Python/Helper/libOrder.py" "]\n\n\n")
1356     ENDIF()
1358     FILE(APPEND "${CMAKE_BINARY_DIR}/Python/Helper/libOrder.py" "fullLibInfo[\"${PROJECT_NAME}\"] = [\n")
1359     FOREACH(OSG_DEP ${DEP_OSG_LIST})
1360       FILE(APPEND "${CMAKE_BINARY_DIR}/Python/Helper/libOrder.py" "\"${OSG_DEP}\",")
1361     ENDFOREACH()
1362     FILE(APPEND "${CMAKE_BINARY_DIR}/Python/Helper/libOrder.py" "]\n\n\n")
1364 ENDFUNCTION(OSG_SETUP_LIBRARY_BUILD)
1367 #############################################################################
1368 # perform default actions for pass OSGSETUPTEST
1370 FUNCTION(OSG_SETUP_TEST_BUILD)
1372     IF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGSETUPTEST")
1373         RETURN()
1374     ENDIF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGSETUPTEST")
1376     OSG_CHECKED_INCLUDE(${${PROJECT_NAME}_BUILD_FILE})
1377     INCLUDE_DIRECTORIES(${${PROJECT_NAME}_INC})
1379     # dependencies - OpenSG
1380     OSG_GET_ALL_DEP_OSG_LIB(
1381         "${${PROJECT_NAME}_DEP_OSG_LIB}" DEP_OSG_LIB DEP_MISSING_LIST)
1383     # if depencies are missing we skip the tests
1384     IF(DEP_MISSING_LIST)
1385         MESSAGE(STATUS "Tests for project ${PROJECT_NAME} have missing dependencies: ${DEP_MISSING_LIST} - skipping")
1386         RETURN()
1387     ENDIF(DEP_MISSING_LIST)
1389     FOREACH(OSGDEP ${DEP_OSG_LIB})
1390         OSG_CHECKED_INCLUDE("${CMAKE_BINARY_DIR}/${OSGDEP}.cmake")
1391         INCLUDE_DIRECTORIES(${${OSGDEP}_INC})
1392     ENDFOREACH(OSGDEP)
1394     # dependencies - test OpenSG
1395     OSG_GET_ALL_DEP_OSG_LIB(
1396         "${${PROJECT_NAME}_DEP_TEST_OSG_LIB}" DEP_TEST_OSG_LIB DEP_MISSING_LIST)
1398     # if depencies are missing we skip the tests
1399     IF(DEP_MISSING_LIST)
1400         MESSAGE(STATUS "Tests for project ${PROJECT_NAME} have missing dependencies: ${DEP_MISSING_LIST} - skipping")
1401         RETURN()
1402     ENDIF(DEP_MISSING_LIST)
1404     FOREACH(OSGTESTDEP ${DEP_TEST_OSG_LIB})
1405         OSG_CHECKED_INCLUDE("${CMAKE_BINARY_DIR}/${OSGTESTDEP}.cmake")
1406         INCLUDE_DIRECTORIES(${${OSGTESTDEP}_INC})
1407     ENDFOREACH(OSGTESTDEP)
1409     # dependencies - global
1410     FOREACH(INCDIR ${OSG_GLOBAL_DEP_INCDIR})
1411         OSG_MSG("  (global) - include dir ${INCDIR} = ${${INCDIR}}")
1412         INCLUDE_DIRECTORIES(${${INCDIR}})
1413     ENDFOREACH(INCDIR)
1415     FOREACH(LIBDIR ${OSG_GLOBAL_DEP_LIBDIR})
1416         OSG_MSG("  (global) - library dir ${LIBDIR} = ${${LIBDIR}}")
1417         LINK_DIRECTORIES(${${LIBDIR}})
1418     ENDFOREACH(LIBDIR)
1420     # dependencies - External
1421     FOREACH(INCDIR ${${PROJECT_NAME}_DEP_INCDIR})
1422         OSG_MSG("  (external) - include dir ${INCDIR} = ${${INCDIR}}")
1423         INCLUDE_DIRECTORIES(${${INCDIR}})
1424     ENDFOREACH(INCDIR)
1426     FOREACH(LIBDIR ${${PROJECT_NAME}_DEP_LIBDIR})
1427         OSG_MSG("  (external) - library dir ${LIBDIR} = ${${LIBDIR}}")
1428         LINK_DIRECTORIES(${${LIBDIR}})
1429     ENDFOREACH(LIBDIR)
1431     # dependencies - test External
1432     FOREACH(INCDIR ${${PROJECT_NAME}_DEP_TEST_INCDIR})
1433         OSG_MSG("  (test) - include dir ${INCDIR} = ${${INCDIR}}")
1434         INCLUDE_DIRECTORIES(${${INCDIR}})
1435     ENDFOREACH(INCDIR)
1437     FOREACH(LIBDIR ${${PROJECT_NAME}_DEP_TEST_LIBDIR})
1438         OSG_MSG("  (test) - library dir ${LIBDIR} = ${${LIBDIR}}")
1439         LINK_DIRECTORIES(${${LIBDIR}})
1440     ENDFOREACH(LIBDIR)
1442     # build test programs
1443     FOREACH(EXE_SRC ${${PROJECT_NAME}_TEST_SRC} ${${PROJECT_NAME}_APP_SRC})
1444         GET_FILENAME_COMPONENT(EXE ${EXE_SRC} NAME_WE)
1446         ADD_EXECUTABLE(${EXE} ${OSGEXCLUDE_TESTS} ${EXE_SRC} )
1448         ADD_DEPENDENCIES(OSGAllTests ${EXE})
1450         FOREACH(OSGTESTDEP ${${PROJECT_NAME}_DEP_TEST_OSG_LIB})
1451             GET_PROPERTY(_OSGTESTDEP_IMPORTED TARGET ${OSGTESTDEP} PROPERTY IMPORTED)
1453             IF(NOT _OSGTESTDEP_IMPORTED)
1454               ADD_DEPENDENCIES(${EXE} ${OSGTESTDEP})
1455             ENDIF(NOT _OSGTESTDEP_IMPORTED)
1457             TARGET_LINK_LIBRARIES(${EXE} ${OSGTESTDEP})
1458         ENDFOREACH(OSGTESTDEP)
1460         FOREACH(OSGTESTDEP ${${PROJECT_NAME}_DEP_TEST_OSG_EEX_LIB})
1461             IF(TARGET ${OSGTESTDEP})
1462               GET_PROPERTY(_OSGTESTDEP_IMPORTED TARGET ${OSGTESTDEP} PROPERTY IMPORTED)
1464               IF(NOT _OSGTESTDEP_IMPORTED)
1465                 ADD_DEPENDENCIES(${EXE} ${OSGTESTDEP})
1466               ENDIF(NOT _OSGTESTDEP_IMPORTED)
1468               TARGET_LINK_LIBRARIES(${EXE} ${OSGTESTDEP})
1469             ENDIF(TARGET ${OSGTESTDEP})
1470         ENDFOREACH(OSGTESTDEP)
1472         FOREACH(LIB ${${PROJECT_NAME}_DEP_TEST_LIB})
1473             OSG_MSG("  (test) - library ${LIB} = ${${LIB}}")
1474             TARGET_LINK_LIBRARIES(${EXE} ${${LIB}})
1475         ENDFOREACH(LIB)
1477         IF(NOT ${PROJECT_NAME}_NO_LIB)
1478           TARGET_LINK_LIBRARIES(${EXE} ${PROJECT_NAME})
1479         ENDIF(NOT ${PROJECT_NAME}_NO_LIB)
1481         IF(${PROJECT_NAME}_DEP_DEFS)
1482             OSG_MSG("  (external) - definitions ${PROJECT_NAME}_DEP_DEFS = ${${PROJECT_NAME}_DEP_DEFS}")
1483             SET_PROPERTY(TARGET ${EXE} APPEND
1484                 PROPERTY COMPILE_DEFINITIONS ${${PROJECT_NAME}_DEP_DEFS})
1485         ENDIF(${PROJECT_NAME}_DEP_DEFS)
1487         IF(${PROJECT_NAME}_CXXFLAGS)
1488           SET_PROPERTY(TARGET ${EXE}
1489                        APPEND PROPERTY COMPILE_FLAGS ${${PROJECT_NAME}_CXXFLAGS})
1490         ENDIF(${PROJECT_NAME}_CXXFLAGS)
1492         IF(${PROJECT_NAME}_DEP_TEST_DEFS)
1493             OSG_MSG("  (test) - definitions ${PROJECT_NAME}_DEP_TEST_DEFS = ${${PROJECT_NAME}_DEP_TEST_DEFS}")
1494             SET_PROPERTY(TARGET ${EXE} APPEND
1495                 PROPERTY COMPILE_DEFINITIONS ${${PROJECT_NAME}_DEP_TEST_DEFS})
1496         ENDIF(${PROJECT_NAME}_DEP_TEST_DEFS)
1498         IF(WIN32)
1499           IF(EXE_SRC MATCHES ^.*/app.*.cpp$)
1500             SET_PROPERTY(TARGET ${EXE} PROPERTY FOLDER "Apps")
1501           ELSE()
1502             SET_PROPERTY(TARGET ${EXE} PROPERTY FOLDER "Tests")
1503           ENDIF()
1504         ENDIF()
1505     ENDFOREACH(EXE_SRC)
1507     FOREACH(EXE_SRC ${${PROJECT_NAME}_APP_SRC})
1508       GET_FILENAME_COMPONENT(EXE ${EXE_SRC} NAME_WE)
1509         ADD_DEPENDENCIES(OSGAllApps ${EXE})
1510     ENDFOREACH()
1512     FOREACH(EXE_SRC ${${PROJECT_NAME}_APP_SRC})
1513       GET_FILENAME_COMPONENT(EXE ${EXE_SRC} NAME_WE)
1515       SET_TARGET_PROPERTIES(${EXE} PROPERTIES EXCLUDE_FROM_ALL FALSE)
1516     ENDFOREACH()
1518     IF(OSG_INSTALL_APPS)
1519       IF(WIN32)
1520         IF(OSG_INSTALL_SUBDIR)
1521             SET(_OSG_ISC "${OSG_INSTALL_SUBDIR}/")
1522         ELSE(OSG_INSTALL_SUBDIR)
1523             SET(_OSG_ISC "")
1524         ENDIF(OSG_INSTALL_SUBDIR)
1526         IF(OSG_USE_SEPARATE_LIBDIRS)
1527           SET(_OSG_TARGET_BINDIR_REL bin/${_OSG_ISC}rel)
1528           SET(_OSG_TARGET_BINDIR_DBG bin/${_OSG_ISC}debug)
1529           SET(_OSG_TARGET_BINDIR_RELNO bin/${_OSG_ISC}relnoopt)
1530           SET(_OSG_TARGET_BINDIR_DBGO bin/${_OSG_ISC}debugopt)
1532           SET(_OSG_TARGET_LIBDIR_REL lib/${_OSG_ISC}rel)
1533           SET(_OSG_TARGET_LIBDIR_DBG lib/${_OSG_ISC}debug)
1534           SET(_OSG_TARGET_LIBDIR_RELNO lib/${_OSG_ISC}relnoopt)
1535           SET(_OSG_TARGET_LIBDIR_DBGO lib/${_OSG_ISC}debugopt)
1536         ELSE(OSG_USE_SEPARATE_LIBDIRS)
1537           SET(_OSG_TARGET_BINDIR_REL bin/${_OSG_ISC})
1538           SET(_OSG_TARGET_BINDIR_DBG bin/${_OSG_ISC})
1539           SET(_OSG_TARGET_BINDIR_RELNO bin/${_OSG_ISC})
1540           SET(_OSG_TARGET_BINDIR_DBGO bin/${_OSG_ISC})
1542           SET(_OSG_TARGET_LIBDIR_REL lib/${_OSG_ISC})
1543           SET(_OSG_TARGET_LIBDIR_DBG lib/${_OSG_ISC})
1544           SET(_OSG_TARGET_LIBDIR_RELNO lib/${_OSG_ISC})
1545           SET(_OSG_TARGET_LIBDIR_DBGO lib/${_OSG_ISC})
1546         ENDIF(OSG_USE_SEPARATE_LIBDIRS)
1547       ENDIF(WIN32)
1549       FOREACH(EXE_SRC ${${PROJECT_NAME}_APP_SRC})
1550         GET_FILENAME_COMPONENT(EXE ${EXE_SRC} NAME_WE)
1552         SET_TARGET_PROPERTIES(${EXE} PROPERTIES EXCLUDE_FROM_ALL FALSE)
1554         IF(WIN32)
1556           INSTALL(TARGETS ${EXE}
1557                   CONFIGURATIONS Release
1558                   RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_REL}
1559                   COMPONENT release_binaries)
1560           INSTALL(TARGETS ${EXE}
1561                   CONFIGURATIONS Debug
1562                   RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_DBG}
1563                   COMPONENT debug_binaries)
1564           INSTALL(TARGETS ${EXE}
1565                   CONFIGURATIONS ReleaseNoOpt
1566                   RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_RELNO}
1567                   COMPONENT release_no_opt_binaries)
1568           INSTALL(TARGETS ${EXE}
1569                   CONFIGURATIONS DebugOpt
1570                   RUNTIME DESTINATION ${_OSG_TARGET_BINDIR_DBGO}
1571                   COMPONENT debug_opt_binaries)
1573         ELSE(WIN32)
1575           INSTALL(TARGETS ${EXE}
1576                   CONFIGURATIONS Release Debug DebugGV
1577                   RUNTIME DESTINATION bin/${OSG_LIBDIR_BUILD_TYPE_SUFFIX}
1578                   COMPONENT binaries)
1580         ENDIF(WIN32)
1581       ENDFOREACH()
1582     ENDIF(OSG_INSTALL_APPS)
1584 ENDFUNCTION(OSG_SETUP_TEST_BUILD)
1587 #############################################################################
1588 # perform default actions for pass OSGSETUPUNITTEST
1590 FUNCTION(OSG_SETUP_UNITTEST_BUILD)
1591     IF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGSETUPUNITTEST")
1592         RETURN()
1593     ENDIF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGSETUPUNITTEST")
1595     INCLUDE(${${PROJECT_NAME}_BUILD_FILE})
1597     # are there unittests to build?
1598     IF(NOT ${PROJECT_NAME}_UNITTEST_SRC)
1599         RETURN()
1600     ENDIF(NOT ${PROJECT_NAME}_UNITTEST_SRC)
1602     INCLUDE_DIRECTORIES(${${PROJECT_NAME}_INC})
1603     INCLUDE_DIRECTORIES(${OSG_UNITTEST_INCLUDE_DIRS})
1605     # dependencies - OpenSG
1606     OSG_GET_ALL_DEP_OSG_LIB(
1607         "${${PROJECT_NAME}_DEP_OSG_LIB}" DEP_OSG_LIB DEP_MISSING_LIST)
1609     # if depencies are missing we skip the unittests
1610     IF(DEP_MISSING_LIST)
1611         MESSAGE(STATUS "Unittests for project ${PROJECT_NAME} have missing dependencies: ${DEP_MISSING_LIST} - skipping")
1612         RETURN()
1613     ENDIF(DEP_MISSING_LIST)
1615     FOREACH(OSGDEP ${DEP_OSG_LIB})
1616         OSG_CHECKED_INCLUDE("${CMAKE_BINARY_DIR}/${OSGDEP}.cmake")
1617         INCLUDE_DIRECTORIES(${${OSGDEP}_INC})
1618     ENDFOREACH(OSGDEP)
1620     # dependencies - unittest OpenSG
1621     OSG_GET_ALL_DEP_OSG_LIB(
1622         "${${PROJECT_NAME}_DEP_UNITTEST_OSG_LIB}" DEP_UNITTEST_OSG_LIB DEP_MISSING_LIST)
1624     # if depencies are missing we skip the unittests
1625     IF(DEP_MISSING_LIST)
1626         MESSAGE(STATUS "Unittests for project ${PROJECT_NAME} have missing dependencies: ${DEP_MISSING_LIST} - skipping")
1627         RETURN()
1628     ENDIF(DEP_MISSING_LIST)
1630     FOREACH(OSGDEP ${DEP_UNITTEST_OSG_LIB})
1631         OSG_CHECKED_INCLUDE("${CMAKE_BINARY_DIR}/${OSGDEP}.cmake")
1632         INCLUDE_DIRECTORIES(${${OSGDEP}_INC})
1633     ENDFOREACH(OSGDEP)
1635     # dependencies global
1636     FOREACH(INCDIR ${OSG_GLOBAL_DEP_INCDIR})
1637         OSG_MSG("  (global) - include dir ${INCDIR} = ${${INCDIR}}")
1638         INCLUDE_DIRECTORIES(${${INCDIR}})
1639     ENDFOREACH(INCDIR)
1641     FOREACH(LIBDIR ${OSG_GLOBAL_DEP_LIBDIR})
1642         OSG_MSG("  (global) - library dir ${LIBDIR} = ${${LIBDIR}}")
1643         LINK_DIRECTORIES(${${LIBDIR}})
1644     ENDFOREACH(LIBDIR)
1646     # dependencies - unittest External
1647     FOREACH(INCDIR ${${PROJECT_NAME}_DEP_UNITTEST_INCDIR})
1648         OSG_MSG("  (unittest) - include dir ${INCDIR} = ${${INCDIR}}")
1649         INCLUDE_DIRECTORIES(${${INCDIR}})
1650     ENDFOREACH(INCDIR)
1652     FOREACH(LIBDIR ${${PROJECT_NAME}_DEP_UNITTEST_LIBDIR})
1653         OSG_MSG("  (unittest) - library dir ${LIBDIR} = ${${LIBDIR}}")
1654         LINK_DIRECTORIES(${${LIBDIR}})
1655     ENDFOREACH(LIBDIR)
1657     LINK_DIRECTORIES(${OSG_UNITTEST_LIBRARY_DIRS})
1659     # add the unittest runner source
1660     LIST(APPEND ${PROJECT_NAME}_UNITTEST_SRC
1661         "${CMAKE_SOURCE_DIR}/Tools/unittest-cpp/UnitTestRunner.cpp")
1663     # build unittest executable
1664     ADD_EXECUTABLE("UnitTest${PROJECT_NAME}"
1665                    ${OSGEXCLUDE_UNITTESTS}
1666                    ${${PROJECT_NAME}_UNITTEST_SRC})
1668     ADD_DEPENDENCIES(OSGAllUnitTests UnitTest${PROJECT_NAME})
1670     TARGET_LINK_LIBRARIES("UnitTest${PROJECT_NAME}" "${OSG_UNITTEST_LIBRARY}")
1671     TARGET_LINK_LIBRARIES("UnitTest${PROJECT_NAME}" ${PROJECT_NAME})
1673     FOREACH(OSGDEP ${${PROJECT_NAME}_DEP_UNITTEST_OSG_LIB})
1674         ADD_DEPENDENCIES("UnitTest${PROJECT_NAME}" ${OSGDEP})
1675         TARGET_LINK_LIBRARIES("UnitTest${PROJECT_NAME}" ${OSGDEP})
1676     ENDFOREACH(OSGDEP)
1678     FOREACH(LIB ${${PROJECT_NAME}_DEP_UNITTEST_LIB})
1679         OSG_MSG("  (unittest) - library ${LIB} = ${${LIB}}")
1680         TARGET_LINK_LIBRARIES("UnitTest${PROJECT_NAME}" ${${LIB}})
1681     ENDFOREACH(LIB)
1683     #MESSAGE("--------- ADDING TEST --------- ${PROJECT_NAME}") # Trips up ccmake
1684     ADD_TEST("UnitTest${PROJECT_NAME}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/UnitTest${PROJECT_NAME}")
1686 ENDFUNCTION(OSG_SETUP_UNITTEST_BUILD)
1688 #############################################################################
1689 # perform default actions for pass OSGPYTHON
1691 FUNCTION(OSG_SETUP_PYTHON_BUILD)
1693   IF(${PROJECT_NAME}_NO_PYTHON OR NOT PYTHONLIBS_FOUND)
1694       RETURN()
1695   ENDIF(${PROJECT_NAME}_NO_PYTHON OR NOT PYTHONLIBS_FOUND)
1697   MESSAGE("  setup python for ${PROJECT_NAME} | ${OSG_CAN_REGEN_PYTHON_BINDINGS}")
1699   ##################################
1700   # Dependency includes
1701   ##################################
1703   OSG_GET_ALL_DEP_OSG_LIB("${${PROJECT_NAME}_DEP_OSG_LIB}" DEP_OSG_LIST DEP_MISSING_LIST)
1705   # read file lists
1706   FOREACH(OSGDEP ${DEP_OSG_LIST})
1707     OSG_CHECKED_INCLUDE(${CMAKE_BINARY_DIR}/${OSGDEP}.cmake)
1708   ENDFOREACH()
1710   OSG_CHECKED_INCLUDE(${${PROJECT_NAME}_BUILD_FILE})
1713   ##################################
1714   # Configure files
1715   ##################################
1717   FILE(MAKE_DIRECTORY ${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR})
1719   SET(_OSG_GEN_INIT_FILE_OUT "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/__init__.py")
1721   IF(OSG_CAN_REGEN_PYTHON_BINDINGS)
1723     SET(_OSG_GEN_CONFIG_FILE_IN  "${CMAKE_SOURCE_DIR}/Bindings/Python/osgGenBindings.py.in")
1724     SET(_OSG_GEN_CONFIG_FILE_OUT "${CMAKE_CURRENT_BINARY_DIR}/osgGenBindings_${PROJECT_NAME}.py")
1725     SET(_OSG_GEN_SETUP_FILE_IN   "${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/osgSetupBindings_${PROJECT_NAME}.py.in")
1726     SET(_OSG_GEN_SETUP_FILE      "${CMAKE_CURRENT_BINARY_DIR}/osgSetupBindings_${PROJECT_NAME}.py")
1728     IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/__init__.py.in")
1729       SET(_OSG_GEN_INIT_FILE_IN  "${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/__init__.py.in")
1730     ELSE()
1731       SET(_OSG_GEN_INIT_FILE_IN  "${CMAKE_SOURCE_DIR}/Bindings/Python/__init__.py.in")
1732     ENDIF()
1734     IF(OSGBUILD_PYTHON_DUMP_DECLS)
1735       SET(OSG_DO_DUMP_PYTHON_DECLS True)
1736     ELSE()
1737       SET(OSG_DO_DUMP_PYTHON_DECLS False)
1738     ENDIF()
1740     CONFIGURE_FILE("${_OSG_GEN_CONFIG_FILE_IN}"
1741                    "${_OSG_GEN_CONFIG_FILE_OUT}")
1743     CONFIGURE_FILE("${_OSG_GEN_INIT_FILE_IN}"
1744                    "${_OSG_GEN_INIT_FILE_OUT}")
1746     ##################################
1747     # Setup File Base
1748     ##################################
1750     IF(EXISTS ${_OSG_GEN_SETUP_FILE_IN})
1751       CONFIGURE_FILE("${_OSG_GEN_SETUP_FILE_IN}"
1752                      "${_OSG_GEN_SETUP_FILE}")
1753       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "\n\n###############################\n")
1754       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "#auto setup for python bindings\n\n")
1755     ELSE()
1756       EXECUTE_PROCESS(
1757         COMMAND "${CMAKE_COMMAND}" -E copy_if_different
1758                 "${CMAKE_SOURCE_DIR}/Bindings/Python/osgDefaultGen.py"
1759                 "${_OSG_GEN_SETUP_FILE}")
1760     ENDIF()
1763     ##################################
1764     # Setup File ModuleHeader
1765     ##################################
1767     FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleHeaders = \\\n[\n")
1769     LIST(INSERT ${PROJECT_NAME}_PYTHON_BIND_HEADERS 0 "pypp_aliases.h")
1770     LIST(INSERT ${PROJECT_NAME}_PYTHON_BIND_HEADERS 0 "PreBoostPython.h")
1772     FOREACH(_OSG_HEADER ${${PROJECT_NAME}_PYTHON_BIND_HEADERS})
1773       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${_OSG_HEADER}\",\n")
1774     ENDFOREACH()
1776     FILE(APPEND ${_OSG_GEN_SETUP_FILE} "]\n\n\n")
1778     ##################################
1779     # Setup File ModuleFCs
1780     ##################################
1782     IF(${PROJECT_NAME}_PYTHON_BIND_FCS)
1783       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleFCs = \\\n[\n")
1785       FOREACH(_OSG_FC ${${PROJECT_NAME}_PYTHON_BIND_FCS})
1786         FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${_OSG_FC}\",\n")
1787       ENDFOREACH()
1789       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "]\n\n\n")
1791       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleFCDFiles = None\n\n\n")
1792     ELSE()
1793       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleFCs = None\n\n\n")
1795       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleFCDFiles = \\\n[\n")
1797       FOREACH(_OSG_FC ${${PROJECT_NAME}_FCD})
1798         FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${_OSG_FC}\",\n")
1799       ENDFOREACH()
1801       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "]\n\n\n")
1802     ENDIF()
1804     ##################################
1805     # Setup File ModuleIncludes
1806     ##################################
1808     FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleIncludes = \\\n[\n")
1810     FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${PYTHON_INCLUDE_PATH}\",\n")
1812     IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/Wrapper")
1813       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/Wrapper\",\n")
1814     ENDIF()
1815     IF(EXISTS "${CMAKE_SOURCE_DIR}/Bindings/Python/Common")
1816       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${CMAKE_SOURCE_DIR}/Bindings/Python/Common\",\n")
1817     ENDIF()
1819     FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${CMAKE_BINARY_DIR}/Source/Base/Base\",\n")
1821     FOREACH(_OSG_INC ${${PROJECT_NAME}_INC})
1822       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${_OSG_INC}\",\n")
1823     ENDFOREACH()
1825     FILE(APPEND ${_OSG_GEN_SETUP_FILE} "]\n\n\n")
1827     ##################################
1828     # Setup File ModuleDepIncludes
1829     ##################################
1831     IF(DEP_OSG_LIST)
1832       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleDepIncludes = \\\n[\n")
1834       FOREACH(OSGDEP ${DEP_OSG_LIST})
1835         FOREACH(_OSG_INC ${${OSGDEP}_INC})
1836           FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${_OSG_INC}\",\n")
1837         ENDFOREACH()
1838       ENDFOREACH()
1840       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "]\n\n\n")
1841     ELSE()
1842       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleDepIncludes = None\n\n\n")
1843     ENDIF()
1845     ##################################
1846     # Setup File PythonModuleDeps
1847     ##################################
1849     IF(DEP_OSG_LIST)
1850       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleDepencies = \\\n[\n")
1852       FOREACH(OSGDEP ${DEP_OSG_LIST})
1853         FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${OSG_PYTHON_${OSGDEP}_MODULE_DIR}/generated\",\n")
1854       ENDFOREACH()
1856       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "]\n\n\n")
1857     ELSE()
1858       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "moduleDepencies = None\n\n\n")
1859     ENDIF()
1861     ##################################
1862     # Setup File NativeWinDependents
1863     ##################################
1865     IF(${PROJECT_NAME}_PYTHON_NATIVEWINDOW_DEPENDENT)
1866       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "nativeWinDependends = \\\n[\n")
1868       FOREACH(_OSG_NATIVEWIN_DEP ${${PROJECT_NAME}_PYTHON_NATIVEWINDOW_DEPENDENT})
1869         FILE(APPEND ${_OSG_GEN_SETUP_FILE} "  \"${_OSG_NATIVEWIN_DEP}\",\n")
1870       ENDFOREACH()
1872       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "]\n\n\n")
1873       IF(UNIX AND NOT APPLE)
1874         FILE(APPEND ${_OSG_GEN_SETUP_FILE} "nativeWin = \"XWindow\"\n\n\n")
1875       ELSEIF(WIN32)
1876         FILE(APPEND ${_OSG_GEN_SETUP_FILE} "nativeWin = \"WIN32Window\"\n\n\n")
1877       ELSEIF(UNIX AND APPLE)
1878         FILE(APPEND ${_OSG_GEN_SETUP_FILE} "nativeWin = \"CocoaWindow\"\n\n\n")
1879       ENDIF()
1880     ELSE()
1881       FILE(APPEND ${_OSG_GEN_SETUP_FILE} "nativeWinDependends = None\n\n\n")
1882     ENDIF()
1885     ##################################
1886     # Bindings Gen Target
1887     ##################################
1889     ADD_CUSTOM_TARGET(${PROJECT_NAME}PyGenOnly COMMAND ${PYTHON_EXECUTABLE} osgGenBindings_${PROJECT_NAME}.py)
1890     ADD_CUSTOM_TARGET(${PROJECT_NAME}PyGen     COMMAND ${PYTHON_EXECUTABLE} osgGenBindings_${PROJECT_NAME}.py)
1893     FOREACH(OSG_DEP ${${PROJECT_NAME}_DEP_OSG_LIB})
1894       ADD_DEPENDENCIES(${PROJECT_NAME}PyGen ${OSG_DEP}PyGen)
1895     ENDFOREACH()
1897     ADD_DEPENDENCIES(OSGPyGen   ${PROJECT_NAME}PyGen)
1899   ENDIF(OSG_CAN_REGEN_PYTHON_BINDINGS)
1901   ##################################
1902   # Bindings Lib Target
1903   ##################################
1905   IF(EXISTS "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/generated" AND NOT ${PROJECT_NAME}_PYTHON_GET_ONLY)
1906     FILE(GLOB   _OSG_BIND_SRC "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/generated/*.pypp.cpp")
1907     LIST(APPEND _OSG_BIND_SRC "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/generated/${PROJECT_NAME}Py.main.cpp")
1909     FILE(GLOB   _OSG_BIND_SRC_TMP "${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/Wrapper/*.cpp")
1911     LIST(APPEND _OSG_BIND_SRC ${_OSG_BIND_SRC_TMP})
1913     IF(${PROJECT_NAME}_PYTHON_NATIVEWINDOW_DEPENDENT)
1915       FOREACH(_OSG_NATIVEWIN_DEP ${${PROJECT_NAME}_PYTHON_NATIVEWINDOW_DEPENDENT})
1916         SET(_OSG_NATIVEWIN_DEP_IN      ${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/generated/${_OSG_NATIVEWIN_DEP}Base.pypp.cpp)
1917         SET(_OSG_NATIVEWIN_DEP_PATCHED ${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/generated/${_OSG_NATIVEWIN_DEP}Base.pypp.cpp.patched)
1918         SET(_OSG_NATIVEWIN_DEP_OUT     ${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/generated/${_OSG_NATIVEWIN_DEP}Base.pypp.patched.cpp)
1920         LIST(REMOVE_ITEM _OSG_BIND_SRC ${_OSG_NATIVEWIN_DEP_IN})
1921         LIST(REMOVE_ITEM _OSG_BIND_SRC ${_OSG_NATIVEWIN_DEP_OUT})
1923         IF(EXISTS ${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/generated/${_OSG_NATIVEWIN_DEP}Base.pypp.patched.cpp)
1924           LIST(APPEND      _OSG_BIND_SRC ${_OSG_NATIVEWIN_DEP_OUT})
1925         ENDIF()
1927       ENDFOREACH()
1928       
1929     ENDIF(${PROJECT_NAME}_PYTHON_NATIVEWINDOW_DEPENDENT)
1932     ADD_LIBRARY(${PROJECT_NAME}Py EXCLUDE_FROM_ALL ${_OSG_BIND_SRC})
1934     SET_TARGET_PROPERTIES(${PROJECT_NAME}Py PROPERTIES PREFIX "")
1936     IF(WIN32)
1938         SET_TARGET_PROPERTIES(${PROJECT_NAME}Py PROPERTIES
1939             VERSION              ${OSG_VERSION}
1940             SOVERSION            ${OSG_VERSION}
1941             SUFFIX               ".pyd")
1943         SET_PROPERTY(TARGET "${PROJECT_NAME}Py" PROPERTY FOLDER "PythonBindings")
1945     ENDIF(WIN32)
1948     INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
1949     INCLUDE_DIRECTORIES(${OSG_PYTHON_COMMON_INCDIR})
1950     INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Python/Wrapper)
1951     INCLUDE_DIRECTORIES(${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR})
1953     ADD_DEFINITIONS(-DBOOST_PYTHON_MAX_ARITY=21)
1955     FOREACH(OSGDEP ${DEP_OSG_LIST})
1956       INCLUDE_DIRECTORIES(${${OSGDEP}_INC})
1957     ENDFOREACH()
1959     INCLUDE_DIRECTORIES(${${PROJECT_NAME}_INC})
1960     INCLUDE_DIRECTORIES(${OSG_BOOST_INCDIRS})
1962     TARGET_LINK_LIBRARIES(${PROJECT_NAME}Py ${PROJECT_NAME})
1963     TARGET_LINK_LIBRARIES(${PROJECT_NAME}Py ${OSG_BOOST_PYTHON_LIBS})
1964     TARGET_LINK_LIBRARIES(${PROJECT_NAME}Py ${PYTHON_LIBRARY})
1966     IF(WIN32) 
1968       IF(OSG_INSTALL_SUBDIR)
1969           SET(_OSG_ISC "${OSG_INSTALL_SUBDIR}/")
1970       ELSE(OSG_INSTALL_SUBDIR)
1971           SET(_OSG_ISC "")
1972       ENDIF(OSG_INSTALL_SUBDIR)
1974       SET(_OSG_TARGET_BINDIR_REL   bin/${_OSG_ISC}rel)
1975       SET(_OSG_TARGET_BINDIR_DBG   bin/${_OSG_ISC}debug)
1976       SET(_OSG_TARGET_BINDIR_RELNO bin/${_OSG_ISC}relnoopt)
1977       SET(_OSG_TARGET_BINDIR_DBGO  bin/${_OSG_ISC}debugopt)
1979       SET(_OSG_TARGET_LIBDIR_REL   lib/${_OSG_ISC}rel)
1980       SET(_OSG_TARGET_LIBDIR_DBG   lib/${_OSG_ISC}debug)
1981       SET(_OSG_TARGET_LIBDIR_RELNO lib/${_OSG_ISC}relnoopt)
1982       SET(_OSG_TARGET_LIBDIR_DBGO  lib/${_OSG_ISC}debugopt)
1984       SET(_OSG_TARGET_PYLIBDIR_REL   lib/python/${_OSG_ISC}rel/osg2/${PROJECT_NAME})
1985       SET(_OSG_TARGET_PYLIBDIR_DBG   lib/python/${_OSG_ISC}debug/osg2/${PROJECT_NAME})
1986       SET(_OSG_TARGET_PYLIBDIR_RELNO lib/python/${_OSG_ISC}relnoopt/osg2/${PROJECT_NAME})
1987       SET(_OSG_TARGET_PYLIBDIR_DBGO  lib/python/${_OSG_ISC}debugopt/osg2/${PROJECT_NAME})
1989       INSTALL(TARGETS ${PROJECT_NAME}Py
1990               CONFIGURATIONS Release
1991               RUNTIME DESTINATION ${_OSG_TARGET_PYLIBDIR_REL}
1992               COMPONENT release_runtimes
1993               OPTIONAL)
1995       INSTALL(TARGETS ${PROJECT_NAME}Py
1996               CONFIGURATIONS Release
1998               LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_REL}
1999               COMPONENT release_libraries
2000               OPTIONAL
2002               ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_REL}
2003               COMPONENT release_libraries
2004               OPTIONAL)
2006       INSTALL(TARGETS ${PROJECT_NAME}Py
2007               CONFIGURATIONS Debug
2008               RUNTIME DESTINATION ${_OSG_TARGET_PYLIBDIR_DBG}
2009               COMPONENT debug_runtimes
2010               OPTIONAL)
2012       INSTALL(TARGETS ${PROJECT_NAME}Py
2013               CONFIGURATIONS Debug
2015               LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_DBG}
2016               COMPONENT debug_libraries
2017               OPTIONAL
2019               ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_DBG}
2020               COMPONENT debug_libraries
2021               OPTIONAL)
2023       INSTALL(TARGETS ${PROJECT_NAME}Py
2024               CONFIGURATIONS ReleaseNoOpt
2025               RUNTIME DESTINATION ${_OSG_TARGET_PYLIBDIR_RELNO}
2026               COMPONENT release_no_opt_runtimes
2027               OPTIONAL)
2029       INSTALL(TARGETS ${PROJECT_NAME}Py
2030               CONFIGURATIONS ReleaseNoOpt
2032               LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_RELNO}
2033               COMPONENT release_no_opt_libraries
2034               OPTIONAL
2036               ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_RELNO}
2037               COMPONENT release_no_opt_libraries
2038               OPTIONAL)
2040       INSTALL(TARGETS ${PROJECT_NAME}Py
2041               CONFIGURATIONS DebugOpt
2042               RUNTIME DESTINATION ${_OSG_TARGET_PYLIBDIR_DBGO}
2043               COMPONENT debug_opt_runtimes
2044               OPTIONAL)
2046       INSTALL(TARGETS ${PROJECT_NAME}Py
2047               CONFIGURATIONS DebugOpt
2049               LIBRARY DESTINATION ${_OSG_TARGET_LIBDIR_DBGO}
2050               COMPONENT debug_opt_libraries
2051               OPTIONAL
2053               ARCHIVE DESTINATION ${_OSG_TARGET_LIBDIR_DBGO}
2054               COMPONENT debug_opt_libraries
2055               OPTIONAL)
2058       IF(OSG_INSTALL_PDB_FILES)
2060         GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME}Py Release_LOCATION)
2062         STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
2064         INSTALL(FILES ${_TMPVAL1}
2065                 CONFIGURATIONS Release
2066                 DESTINATION ${_OSG_TARGET_PYLIBDIR_REL}
2067                 COMPONENT release_program_db
2068                 OPTIONAL)
2071         GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME}Py Debug_LOCATION)
2073         STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
2075         INSTALL(FILES ${_TMPVAL1}
2076                 CONFIGURATIONS Debug
2077                 DESTINATION ${_OSG_TARGET_PYLIBDIR_DBG}
2078                 COMPONENT debug_program_db
2079                 OPTIONAL)
2082         GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME}Py ReleaseNoOpt_LOCATION)
2084         STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
2086         INSTALL(FILES ${_TMPVAL1}
2087                 CONFIGURATIONS ReleaseNoOpt
2088                 DESTINATION ${_OSG_TARGET_PYLIBDIR_RELNO}
2089                 COMPONENT release_no_opt_program_db
2090                 OPTIONAL)
2093         GET_TARGET_PROPERTY(_TMPVAL ${PROJECT_NAME}Py DebugOpt_LOCATION)
2095         STRING(REPLACE "dll" "pdb" _TMPVAL1 ${_TMPVAL})
2097         INSTALL(FILES ${_TMPVAL1}
2098                 CONFIGURATIONS DebugOpt
2099                 DESTINATION ${_OSG_TARGET_PYLIBDIR_DBGO}
2100                 COMPONENT debug_opt_program_db
2101                 OPTIONAL)
2103       ENDIF(OSG_INSTALL_PDB_FILES)
2105       SET(_OSG_GEN_INIT_FILE_OUT "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/__init__.py")
2107       INSTALL(FILES          ${_OSG_GEN_INIT_FILE_OUT} 
2108               DESTINATION    ${_OSG_TARGET_PYLIBDIR_REL}
2109               CONFIGURATIONS Release
2110               COMPONENT      release_runtimes
2111               OPTIONAL)
2113       SET(_OSG_GEN_INIT_FILE_OUT "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/__init__.py")
2114   
2115       INSTALL(FILES       ${_OSG_GEN_INIT_FILE_OUT} 
2116               DESTINATION ${_OSG_TARGET_PYLIBDIR_DBG}
2117               CONFIGURATIONS Debug
2118               COMPONENT      debug_runtimes
2119               OPTIONAL)
2121       SET(_OSG_GEN_INIT_FILE_OUT "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/__init__.py")
2122   
2123       INSTALL(FILES       ${_OSG_GEN_INIT_FILE_OUT} 
2124               DESTINATION ${_OSG_TARGET_PYLIBDIR_DBGO}
2125               CONFIGURATIONS DebugOpt
2126               COMPONENT      debug_opt_runtimes
2127               OPTIONAL)
2129       SET(_OSG_GEN_INIT_FILE_OUT "${OSG_PYTHON_${PROJECT_NAME}_MODULE_DIR}/__init__.py")
2130   
2131       INSTALL(FILES       ${_OSG_GEN_INIT_FILE_OUT} 
2132               DESTINATION ${_OSG_TARGET_PYLIBDIR_RELNO}
2133               CONFIGURATIONS ReleaseNoOpt
2134               COMPONENT      release_no_opt_runtimes
2135               OPTIONAL)
2138     ELSE(WIN32)   
2139       GET_FILENAME_COMPONENT(_PY_VERSION_DIR ${PYTHON_INCLUDE_PATH} NAME)
2141       SET(_OSG_PY_INST_BASE 
2142           "lib${OSG_LIBDIR_BASE_SUFFIX}/${_PY_VERSION_DIR}/site-packages/${OSG_LIBDIR_BUILD_TYPE_SUFFIX}/osg2/${PROJECT_NAME}")
2144       INSTALL(TARGETS ${PROJECT_NAME}Py
2146               RUNTIME DESTINATION ${_OSG_PY_INST_BASE}
2147               COMPONENT libraries
2148               OPTIONAL
2150               LIBRARY DESTINATION ${_OSG_PY_INST_BASE}
2151               COMPONENT libraries
2152               OPTIONAL
2154               ARCHIVE DESTINATION ${_OSG_PY_INST_BASE}
2155               COMPONENT libraries
2157               OPTIONAL)
2159       INSTALL(FILES       ${_OSG_GEN_INIT_FILE_OUT} 
2160               DESTINATION ${_OSG_PY_INST_BASE}
2161               COMPONENT   libraries
2162               OPTIONAL)
2165       GET_PROPERTY(_OSG_CURR_SO_PATH TARGET ${PROJECT_NAME}Py PROPERTY LOCATION)
2167       GET_FILENAME_COMPONENT(_OSG_CURR_SO_NAME ${_OSG_CURR_SO_PATH} NAME)
2169       FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Python/lib/osg2/${PROJECT_NAME})
2171       OSG_SYMLINK_CHECKED(${_OSG_GEN_INIT_FILE_OUT}
2172                           ${CMAKE_BINARY_DIR}/Python/lib/osg2/${PROJECT_NAME}/__init__.py)
2173       OSG_SYMLINK_CHECKED(${_OSG_CURR_SO_PATH}
2174                           ${CMAKE_BINARY_DIR}/Python/lib/osg2/${PROJECT_NAME}/${_OSG_CURR_SO_NAME})
2176     ENDIF(WIN32)
2178     ADD_DEPENDENCIES(OSGPy      ${PROJECT_NAME}Py)
2179   ENDIF()
2181 ENDFUNCTION(OSG_SETUP_PYTHON_BUILD)
2183 #############################################################################
2184 # perform default actions for pass OSGDOXYDOC
2186 FUNCTION(OSG_SETUP_SEPARATE_LIBS_DOXYDOC)
2187     IF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGDOXYDOC")
2188         RETURN()
2189     ENDIF()
2191     IF(${PROJECT_NAME}_NO_DOC)
2192         RETURN()
2193     ENDIF(${PROJECT_NAME}_NO_DOC)
2195     # set up variables for the config file
2196     SET(OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE_IN "${CMAKE_SOURCE_DIR}/Doc/opensg-doxy.in")
2197     SET(OSG_${PROJECT_NAME}_DOC_DIRECTORY              "${OSG_DOXY_HTML_DIR}/${PROJECT_NAME}")
2198     SET(OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE    "${CMAKE_BINARY_DIR}/Doc/${PROJECT_NAME}-doxy")
2200     SET(OSG_${PROJECT_NAME}_DEP_DOXY_TAGFILES"")
2201     SET(OSG_${PROJECT_NAME}_DOXY_TAGFILE     "${CMAKE_BINARY_DIR}/Doc/${PROJECT_NAME}_DOXYGEN_TAGS")
2202     SET(OSG_${PROJECT_NAME}_DEP_DOCS         "")
2204     # dependencies - OpenSG
2205     OSG_GET_ALL_DEP_OSG_LIB("${${PROJECT_NAME}_DEP_OSG_LIB}" DEP_OSG_LIST DEP_MISSING_LIST)
2207     FOREACH(OSGDEP ${DEP_OSG_LIST})
2208         SET(OSG_${PROJECT_NAME}_DEP_DOXY_TAGFILES "${OSG_${PROJECT_NAME}_DEP_DOXY_TAGFILES} ./${OSGDEP}_DOXYGEN_TAGS=../../${OSGDEP}/html")
2209         LIST(APPEND OSG_${PROJECT_NAME}_DEP_DOCS "${OSGDEP}Doc")
2210     ENDFOREACH()
2212     IF(EXISTS "${CMAKE_BINARY_DIR}/Doc/Include/${PROJECT_NAME}.include")
2213       SET(OSG_DOC_BASIC_INPUT "${CMAKE_BINARY_DIR}/Doc/Include/${PROJECT_NAME}.include")
2214     ENDIF()
2216     # write doxygen config file
2217     CONFIGURE_FILE("${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE_IN}"
2218                    "${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE}")
2220     SET(OSG_DOC_BASIC_INPUT "${CMAKE_BINARY_DIR}/Doc/Include/OSGDummy.include")
2222     IF(DOXYGEN_EXECUTABLE)
2223         #ADD_CUSTOM_TARGET(DocUpload COMMAND unison -batch -ui text opensg_doc)
2224         #ADD_DEPENDENCIES(DocUpload Doc)
2226         SET(OSG_DOC_PIPES "")
2228         IF(OSG_DOXY_STDOUT_LOG)
2229           SET(OSG_DOC_PIPES > ${OSG_DOXY_STDOUT_LOG}.${PROJECT_NAME})
2230         ENDIF(OSG_DOXY_STDOUT_LOG)
2232         ADD_CUSTOM_TARGET(${PROJECT_NAME}DocOnly
2233             VERBATIM
2234             COMMAND ${DOXYGEN_EXECUTABLE} ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE} ${OSG_DOC_PIPES}
2235             WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Doc")
2237         ADD_CUSTOM_TARGET(${PROJECT_NAME}Doc
2238             VERBATIM
2239             COMMAND ${DOXYGEN_EXECUTABLE} ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE} ${OSG_DOC_PIPES}
2240             WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Doc")
2242         FOREACH(OSGDEPDOC ${OSG_${PROJECT_NAME}_DEP_DOCS})
2243             ADD_DEPENDENCIES(${PROJECT_NAME}Doc ${OSGDEPDOC})
2244         ENDFOREACH()
2246         ADD_DEPENDENCIES(Doc ${PROJECT_NAME}Doc)
2247     ENDIF()
2249     INCLUDE(${${PROJECT_NAME}_BUILD_FILE})
2253 #    FILE(APPEND ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE}
2254 #        "#############################################################################\n")
2256 #    IF(${PROJECT_NAME}_DOXY_EXTRA_INC)
2257 #        FILE(APPEND ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE}
2258 #            "# doc input files for ${PROJECT_NAME}\n\n")
2260 #        FOREACH(DOXYFILE ${${PROJECT_NAME}_DOXY_EXTRA_INC})
2261 #            FILE(APPEND ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE}
2262 #                "INPUT += ${DOXYFILE}\n")
2263 #        ENDFOREACH()
2265 #        FILE(APPEND ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE} "\n")
2266 #    ENDIF()
2268     FILE(APPEND ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE}
2269         "# source code input files for ${PROJECT_NAME}\n\n")
2271     FOREACH(INCDIR ${${PROJECT_NAME}_INC})
2272         FILE(APPEND ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE}
2273             "INPUT += ${INCDIR}\n")
2274     ENDFOREACH()
2276     FILE(APPEND ${OSG_${PROJECT_NAME}_DOXY_CONFIGURATION_FILE} "\n")
2278 ENDFUNCTION(OSG_SETUP_SEPARATE_LIBS_DOXYDOC)
2280 #############################################################################
2281 # perform default actions for pass OSGDOXYDOC
2283 FUNCTION(OSG_SETUP_DOXYDOC)
2284     IF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGDOXYDOC")
2285         RETURN()
2286     ENDIF(NOT ${OSG_CMAKE_PASS} STREQUAL "OSGDOXYDOC")
2288     IF(${PROJECT_NAME}_NO_DOC)
2289         RETURN()
2290     ENDIF(${PROJECT_NAME}_NO_DOC)
2293     INCLUDE(${${PROJECT_NAME}_BUILD_FILE})
2295     FILE(APPEND ${OSG_DOXY_CONFIGURATION_FILE}
2296         "#############################################################################\n"
2297         )
2298     FILE(APPEND ${OSG_DOXY_CONFIGURATION_FILE}
2299         "# doc input files for ${PROJECT_NAME}\n\n"
2300         )
2302     FOREACH(INCDIR ${${PROJECT_NAME}_INC})
2303         FILE(APPEND ${OSG_DOXY_CONFIGURATION_FILE}
2304             "INPUT += ${INCDIR}\n")
2305     ENDFOREACH(INCDIR)
2307     FILE(APPEND ${OSG_DOXY_CONFIGURATION_FILE} "\n")
2309 ENDFUNCTION(OSG_SETUP_DOXYDOC)
2311 #############################################################################
2312 # perform default actions for build passes
2314 FUNCTION(OSG_SETUP_PROJECT PROJ_DEFINE)
2316     FOREACH(_OSG_${PROJECT_NAME}_EXT_DIR ${${PROJECT_NAME}_EXT_DIRS})
2317       OSG_ADD_DIRECTORY(${_OSG_${PROJECT_NAME}_EXT_DIR})
2318     ENDFOREACH(_OSG_${PROJECT_NAME}_EXT_DIR ${${PROJECT_NAME}_EXT_DIRS})
2320     IF(OSG_CMAKE_PASS STREQUAL "OSGSETUP")
2321         OSG_SETUP_LIBRARY_BUILD(${PROJ_DEFINE})
2323     ELSEIF(OSG_CMAKE_PASS STREQUAL "OSGSETUPTEST")
2324         OSG_SETUP_TEST_BUILD()
2326     ELSEIF(OSG_CMAKE_PASS STREQUAL "OSGSETUPUNITTEST")
2327         OSG_SETUP_UNITTEST_BUILD()
2329     ELSEIF(OSG_CMAKE_PASS STREQUAL "OSGDOXYDOC")
2330         IF(OSG_GENERATE_SEPARATE_LIB_DOC)
2331             OSG_SETUP_SEPARATE_LIBS_DOXYDOC()
2332         ELSE()
2333             OSG_SETUP_DOXYDOC()
2334         ENDIF()
2336     ELSEIF(OSG_CMAKE_PASS STREQUAL "OSGPYTHON")
2337       OSG_SETUP_PYTHON_BUILD()
2339     ENDIF(OSG_CMAKE_PASS STREQUAL "OSGSETUP")
2341 ENDFUNCTION(OSG_SETUP_PROJECT)
2343 #############################################################################
2344 # setup import targets so the debug/debugopt build type works correctly
2346 FUNCTION(OSG_SETUP_IMPORT_LIB_WINDOWS NEW_LIB)
2348   IF(${NEW_LIB}_RELEASE)
2349       GET_FILENAME_COMPONENT(OSG_TMP_LIB_DIR ${${NEW_LIB}_RELEASE} PATH)
2350   ENDIF(${NEW_LIB}_RELEASE)
2352   IF(NOT OSG_TMP_LIB_DIR AND ${NEW_LIB}_DEBUG)
2353       GET_FILENAME_COMPONENT(OSG_TMP_LIB_DIR ${${NEW_LIB}_DEBUG} PATH)
2354   ENDIF(NOT OSG_TMP_LIB_DIR AND ${NEW_LIB}_DEBUG)
2357   SET_TARGET_PROPERTIES(OSG_${NEW_LIB}_TARGET PROPERTIES
2358                         IMPORTED_IMPLIB_RELEASE ${${NEW_LIB}_RELEASE}
2359                         IMPORTED_LOCATION_RELEASE ${OSG_TMP_LIB_DIR}
2360                         IMPORTED_IMPLIB_RELEASENOOPT ${${NEW_LIB}_RELEASE}
2361                         IMPORTED_LOCATION_RELEASENOOPT ${OSG_TMP_LIB_DIR}
2362                         IMPORTED_IMPLIB_DEBUG ${${NEW_LIB}_DEBUG}
2363                         IMPORTED_LOCATION_DEBUG ${OSG_TMP_LIB_DIR}
2364                         IMPORTED_IMPLIB_DEBUGOPT ${${NEW_LIB}_DEBUG}
2365                         IMPORTED_LOCATION_DEBUGOPT ${OSG_TMP_LIB_DIR})
2367 ENDFUNCTION(OSG_SETUP_IMPORT_LIB_WINDOWS)
2369 FUNCTION(OSG_SETUP_IMPORT_LIB_UNIX NEW_LIB)
2371   IF(${NEW_LIB}_RELEASE)
2372       GET_FILENAME_COMPONENT(OSG_TMP_LIB_DIR ${${NEW_LIB}_RELEASE} PATH)
2373   ENDIF(${NEW_LIB}_RELEASE)
2375   IF(NOT OSG_TMP_LIB_DIR AND ${NEW_LIB}_DEBUG)
2376       GET_FILENAME_COMPONENT(OSG_TMP_LIB_DIR ${${NEW_LIB}_DEBUG} PATH)
2377   ENDIF(NOT OSG_TMP_LIB_DIR AND ${NEW_LIB}_DEBUG)
2379   IF(${NEW_LIB}_RELEASE AND NOT ${NEW_LIB}_DEBUG)
2380     SET(${NEW_LIB}_DEBUG ${${NEW_LIB}_RELEASE} CACHE FILEPATH "" FORCE)
2381   ENDIF(${NEW_LIB}_RELEASE AND NOT ${NEW_LIB}_DEBUG)
2383   IF(NOT ${NEW_LIB}_RELEASE AND ${NEW_LIB}_DEBUG)
2384     SET(${NEW_LIB}_RELEASE ${${NEW_LIB}_DEBUG} CACHE FILEPATH "" FORCE)
2385   ENDIF(NOT ${NEW_LIB}_RELEASE AND ${NEW_LIB}_DEBUG)
2387   SET_TARGET_PROPERTIES(OSG_${NEW_LIB}_TARGET PROPERTIES
2388                         IMPORTED_LOCATION ${${NEW_LIB}_RELEASE}
2389                         IMPORTED_LOCATION_DEBUG ${${NEW_LIB}_DEBUG}
2390                         IMPORTED_LOCATION_DEBUGGV ${${NEW_LIB}_DEBUG})
2392 ENDFUNCTION(OSG_SETUP_IMPORT_LIB_UNIX)
2394 MACRO(OSG_ADD_IMPORT_LIB LIB_LIST NEW_LIB)
2396   IF(NOT TARGET OSG_${NEW_LIB}_TARGET)
2397     ADD_LIBRARY(OSG_${NEW_LIB}_TARGET SHARED IMPORTED)
2399     IF(WIN32)
2400       OSG_SETUP_IMPORT_LIB_WINDOWS(${NEW_LIB})
2401     ELSE(WIN32)
2402       OSG_SETUP_IMPORT_LIB_UNIX(${NEW_LIB})
2404       OSG_ADD_OPT(${NEW_LIB}_RELEASE)
2405       OSG_ADD_OPT(${NEW_LIB}_DEBUG)
2406       OSG_ADD_OPT(OSG_${NEW_LIB}_TARGET)
2407     ENDIF(WIN32)
2409     LIST(APPEND ${LIB_LIST} OSG_${NEW_LIB}_TARGET)
2410   ENDIF()
2412 ENDMACRO(OSG_ADD_IMPORT_LIB)
2414 ##########################################################################
2415 # write settings so different variants can be build with the same settings
2417 MACRO(OSG_OPTION NAME DESC VALUE)
2418     LIST(APPEND OSG_OPTION_LIST ${NAME})
2419     OSG_MSG("adding option ${NAME} = ${VALUE}")
2421     OPTION(${NAME} "${DESC}" ${VALUE})
2422 ENDMACRO(OSG_OPTION)
2424 MACRO(OSG_SET_CACHE NAME VALUE TYPE DESC)
2425     LIST(APPEND OSG_OPTION_LIST ${NAME})
2427     SET(${NAME} ${VALUE} CACHE ${TYPE} "${DESC}")
2428 ENDMACRO(OSG_SET_CACHE)
2430 MACRO(OSG_SET NAME VALUE)
2431     LIST(APPEND OSG_OPTION_LIST ${NAME})
2433     SET(${NAME} ${VALUE})
2434 ENDMACRO(OSG_SET)
2436 MACRO(OSG_ADD_OPT NAME)
2437     LIST(APPEND OSG_OPTION_LIST ${NAME})
2438 ENDMACRO(OSG_ADD_OPT)
2440 MACRO(OSG_ADD_OPT_SUBDIR NAME)
2441     LIST(APPEND OSG_OPTION_LIST ${NAME})
2443     SET(OSG_OPTION_LIST "${OSG_OPTION_LIST}" PARENT_SCOPE)
2444 ENDMACRO(OSG_ADD_OPT_SUBDIR)
2446 MACRO(OSG_FIND_PACKAGE NAME)
2447     FIND_PACKAGE(${NAME})
2449     IF(${NAME}_FOUND)
2450         OSG_ADD_OPT(${NAME}_LIBRARIES)
2451         OSG_ADD_OPT(${NAME}_INCLUDE_DIR)
2452     ENDIF(${NAME}_FOUND)
2454     OSG_ADD_OPT(${NAME}_FOUND)
2455 ENDMACRO(OSG_FIND_PACKAGE)
2457 MACRO(OSG_BOOST_DEP_SETUP)
2458     SET(Boost_USE_MULTITHREAD ON )
2459     SET(Boost_USE_STATIC_LIBS OFF)
2461     FIND_PACKAGE(Boost COMPONENTS filesystem system)
2463     IF(Boost_FOUND)
2465         IF(PYTHON_INCLUDE_PATH AND PYTHON_LIBRARY)
2466           FIND_PACKAGE(Boost COMPONENTS python)
2467         ENDIF(PYTHON_INCLUDE_PATH AND PYTHON_LIBRARY)
2469         # We ignore if boost python fails, we catch that somewhere else
2470         # so if we get here Boost_FOUND was true in the first place
2471         SET(Boost_FOUND TRUE)
2473         # Hide settings
2474         SET(Boost_FILESYSTEM_LIBRARY ${Boost_FILESYSTEM_LIBRARY}
2475                                      CACHE INTERNAL "")
2476         SET(Boost_FILESYSTEM_LIBRARY_DEBUG ${Boost_FILESYSTEM_LIBRARY_DEBUG}
2477                                            CACHE INTERNAL "")
2478         SET(Boost_FILESYSTEM_LIBRARY_RELEASE
2479            ${Boost_FILESYSTEM_LIBRARY_RELEASE}
2480            CACHE INTERNAL "")
2482         SET(Boost_SYSTEM_LIBRARY ${Boost_SYSTEM_LIBRARY}
2483                                CACHE INTERNAL "")
2484         SET(Boost_SYSTEM_LIBRARY_DEBUG ${Boost_SYSTEM_LIBRARY_DEBUG}
2485                                        CACHE INTERNAL "")
2486         SET(Boost_SYSTEM_LIBRARY_RELEASE
2487            ${Boost_SYSTEM_LIBRARY_RELEASE}
2488            CACHE INTERNAL "")
2490         SET(Boost_PYTHON_LIBRARY ${Boost_PYTHON_LIBRARY}
2491                                      CACHE INTERNAL "")
2492         SET(Boost_PYTHON_LIBRARY_DEBUG ${Boost_PYTHON_LIBRARY_DEBUG}
2493                                            CACHE INTERNAL "")
2494         SET(Boost_PYTHON_LIBRARY_RELEASE
2495            ${Boost_PYTHON_LIBRARY_RELEASE}
2496            CACHE INTERNAL "")
2499         SET(Boost_INCLUDE_DIR ${Boost_INCLUDE_DIR}
2500                               CACHE INTERNAL "")
2502         SET(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS}
2503                                CACHE INTERNAL "")
2505         SET(Boost_USE_MULTITHREADED ${Boost_USE_MULTI_THREADED}
2506                                     CACHE INTERNAL "")
2509         INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR} )
2511         IF(UNIX)
2512             LINK_DIRECTORIES   (${Boost_LIBRARY_DIRS})
2513         ENDIF(UNIX)
2515         IF(NOT Boost_USE_STATIC_LIBS)
2516           ADD_DEFINITIONS(-DBOOST_ALL_DYN_LINK)
2517         ENDIF(NOT Boost_USE_STATIC_LIBS)
2519         IF(CMAKE_BUILD_TYPE STREQUAL "Debug" OR
2520            CMAKE_BUILD_TYPE STREQUAL "DebugOpt")
2522           SET(OSG_BOOST_LIBS ${Boost_FILESYSTEM_LIBRARY_DEBUG} 
2523                              ${Boost_SYSTEM_LIBRARY_DEBUG})
2525           SET(OSG_BOOST_PYTHON_LIBS ${Boost_PYTHON_LIBRARY_DEBUG})
2527         ELSE()
2529           SET(OSG_BOOST_LIBS ${Boost_FILESYSTEM_LIBRARY_RELEASE} 
2530                              ${Boost_SYSTEM_LIBRARY_RELEASE})
2532           SET(OSG_BOOST_PYTHON_LIBS ${Boost_PYTHON_LIBRARY_RELEASE})
2534         ENDIF()
2536         SET(OSG_BOOST_INCDIRS ${Boost_INCLUDE_DIR})
2538     ENDIF(Boost_FOUND)
2539 ENDMACRO(OSG_BOOST_DEP_SETUP)
2541 FUNCTION(OSG_WRITE_SETTINGS FILENAME)
2542     FILE(WRITE ${FILENAME}
2543             "# CMake.settings -- auto generated\n\n")
2545     FOREACH(OSG_OPT ${OSG_OPTION_LIST})
2546       IF(TARGET ${OSG_OPT})
2547         STRING(REPLACE _TARGET "" _OSG_OPT_BASE ${OSG_OPT})
2548         STRING(REPLACE OSG_ "" _OSG_OPT_OSGBASE ${_OSG_OPT_BASE})
2550         IF(NOT ${_OSG_OPT_OSGBASE}_DEBUG)
2551           SET(${_OSG_OPT_OSGBASE}_DEBUG ${OSG_${_OSG_OPT_OSGBASE}_DEBUG})
2552         ENDIF()
2553         IF(NOT ${_OSG_OPT_OSGBASE}_RELEASE)
2554           SET(${_OSG_OPT_OSGBASE}_RELEASE ${OSG_${_OSG_OPT_OSGBASE}_RELEASE})
2555         ENDIF()
2557         FILE(APPEND ${FILENAME}
2558           "ADD_LIBRARY(${_OSG_OPT_BASE}_TARGET SHARED IMPORTED)\n"
2559           "SET_TARGET_PROPERTIES(${_OSG_OPT_BASE}_TARGET PROPERTIES\n"
2560           "                      IMPORTED_LOCATION ${${_OSG_OPT_OSGBASE}_RELEASE}\n"
2561           "                      IMPORTED_LOCATION_DEBUG ${${_OSG_OPT_OSGBASE}_DEBUG}\n"
2562           "                      IMPORTED_LOCATION_DEBUGGV ${${_OSG_OPT_OSGBASE}_DEBUG})\n")
2563       ELSE()
2564         FILE(APPEND ${FILENAME}
2565              "SET(${OSG_OPT} \"${${OSG_OPT}}\" CACHE INTERNAL \"\")\n")
2566       ENDIF()
2567     ENDFOREACH(OSG_OPT ${OSG_OPTION_LIST})
2569 ENDFUNCTION(OSG_WRITE_SETTINGS FILENAME)
2571 FUNCTION(OSG_WRITE_OSGBUILD FILENAME)
2573   FILE(WRITE ${FILENAME}
2574             "# CMake.build.settings -- auto generated\n\n")
2576   GET_CMAKE_PROPERTY(_variableNames VARIABLES)
2578   FOREACH(_variableName ${_variableNames})
2579     IF(_variableName MATCHES "^OSGBUILD_")
2580       FILE(APPEND ${FILENAME}
2581            "SET(${_variableName} ${${_variableName}} CACHE BOOL \"\" FORCE)\n")
2582     ENDIF()
2583   ENDFOREACH()
2584 ENDFUNCTION(OSG_WRITE_OSGBUILD FILENAME)
2586 FUNCTION(CHECK_BUILD_DIR)
2587   IF("${${CMAKE_PROJECT_NAME}_SOURCE_DIR}"  STREQUAL "${${CMAKE_PROJECT_NAME}_BINARY_DIR}")
2588     MESSAGE(FATAL_ERROR "${CMAKE_PROJECT_NAME} requires an out of source Build. \n"
2589                         "Please create a separate binary directory and run "
2590                         "CMake there.")
2591   ENDIF("${${CMAKE_PROJECT_NAME}_SOURCE_DIR}"  STREQUAL "${${CMAKE_PROJECT_NAME}_BINARY_DIR}")
2592 ENDFUNCTION(CHECK_BUILD_DIR)
2594 MACRO(OSG_CHECK_INSTALL)
2596 MESSAGE(STATUS  "process ignore install ${OSG_IGNORE_INSTALL}")
2598   IF(OSG_IGNORE_INSTALL)
2599     FOREACH(OSG_IGNORE_PRJ ${OSG_IGNORE_INSTALL})
2600       SET(OSG_IGNORE_INSTALL_${OSG_IGNORE_PRJ} TRUE)
2601     ENDFOREACH()
2602   ENDIF(OSG_IGNORE_INSTALL)
2603 ENDMACRO(OSG_CHECK_INSTALL)
2605 ##########################################################################
2606 # Add Tutorial builds as tests
2608 FUNCTION(OSG_ADD_TUTORIAL_TESTS TUTORIALS_NAME TUTORIAL_SOURCE_DIR)
2609     IF(NOT OSGBUILD_UNITTESTS)
2610         RETURN()
2611     ENDIF()
2613     FILE(GLOB TUTORIAL_SOURCES "${TUTORIAL_SOURCE_DIR}/[0-9][0-9]*.cpp")
2615     FOREACH(TUTORIAL ${TUTORIAL_SOURCES})
2616         #Get the path to the tutorial executable
2617         STRING(LENGTH ${TUTORIAL} SOURCE_PATH_LENGTH)
2618         MATH(EXPR SOURCE_PATH_LENGTH '${SOURCE_PATH_LENGTH}-4')
2619         STRING(SUBSTRING ${TUTORIAL} 0 ${SOURCE_PATH_LENGTH} TUTORIAL_EXE_PATH )
2620         SET(TUTORIAL_EXE_PATH "${TUTORIAL_EXE_PATH}${CMAKE_EXECUTABLE_SUFFIX}")
2622         #Extract a short name for the tutorial test
2623         STRING(REGEX MATCH "([0-9][0-9].*)[.]cpp" TUTORIAL_NAME ${TUTORIAL})
2624         SET(TUTORIAL_NAME ${CMAKE_MATCH_1})
2626         #Add a test to see if the tutorial exists
2627         ADD_TEST(NAME "${TUTORIALS_NAME}-${TUTORIAL_NAME}"
2628                  COMMAND test -e ${TUTORIAL_EXE_PATH})
2629     ENDFOREACH()
2630 ENDFUNCTION()