12 SET(BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON)
14 MESSAGE(STATUS "ARGS: ${ARGC} | ${ARGV} ")
15 MESSAGE(STATUS "OPT : ${OSG_OPTIONAL_COMPONENTS}")
17 SET(_OSG_COMPONENTS ${ARGV})
19 SET(OSG_PLATFORM_64 0)
20 SET(OSG_PLATFORM_32 0)
21 SET(OSG_LIBDIR_SUFFIX "")
23 IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
24 SET(OSG_PLATFORM_64 1)
25 SET(OSG_LIBDIR_SUFFIX "64")
27 SET(OSG_LIBDIR_BASE_SUFFIX "64")
30 SET(OSG_PLATFORM_32 1)
33 IF(OSG_DISABLE_MICROSOFT_SECURE_CXXX)
34 OPTION(OSG_DISABLE_MS_ITERATOR_DEBUGGING "" ON)
35 ELSE(OSG_DISABLE_MICROSOFT_SECURE_CXXX)
36 OPTION(OSG_DISABLE_MS_ITERATOR_DEBUGGING "" OFF)
37 ENDIF(OSG_DISABLE_MICROSOFT_SECURE_CXXX)
39 OPTION(OSG_ENABLE_CUDA "Build OpenSG with CUDA support" OFF)
41 IF(NOT WIN32 AND NOT CMAKE_BUILD_TYPE)
42 SET(CMAKE_BUILD_TYPE Debug CACHE STRING
43 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
45 ENDIF(NOT WIN32 AND NOT CMAKE_BUILD_TYPE)
52 LIST(FIND _OSG_COMPONENTS OSGFileIO _OSG_USE_FILEIO)
53 LIST(FIND _OSG_COMPONENTS OSGImageFileIO _OSG_USE_IMAGEFILEIO)
54 LIST(FIND _OSG_COMPONENTS OSGContribComputeBase _OSG_USE_CONTRIBCOMPUTE)
55 LIST(FIND _OSG_COMPONENTS OSGContribCSM _OSG_USE_CONTRIBCSM)
56 LIST(FIND _OSG_COMPONENTS OSGCluster _OSG_USE_CLUSTER)
57 LIST(FIND _OSG_COMPONENTS OSGWindowQT4 _OSG_USE_QT)
58 LIST(FIND _OSG_COMPONENTS OSGSystem _OSG_USE_SYSTEM)
60 IF(_OSG_USE_CONTRIBCOMPUTE EQUAL -1 AND NOT _OSG_USE_SYSTEM EQUAL -1)
61 LIST(FIND OSGSystem_DEP_LIB CUDA_CUDART_LIBRARY _OSG_USE_CONTRIBCOMPUTE)
64 IF(NOT _OSG_USE_CONTRIBCSM EQUAL -1)
65 IF(_OSG_USE_FILEIO EQUAL -1)
66 LIST(APPEND _OSG_COMPONENTS OSGFileIO)
67 SET(_OSG_USE_FILEIO 1)
68 ENDIF(_OSG_USE_FILEIO EQUAL -1)
70 IF(_OSG_USE_CLUSTER EQUAL -1)
71 LIST(APPEND _OSG_COMPONENTS OSGCluster)
72 SET(_OSG_USE_CLUSTER 1)
73 ENDIF(_OSG_USE_CLUSTER EQUAL -1)
74 ENDIF(NOT _OSG_USE_CONTRIBCSM EQUAL -1)
76 FIND_PACKAGE(OpenSG REQUIRED COMPONENTS ${_OSG_COMPONENTS})
79 IF(NOT OSG_COMPILER_DEFAULTS)
80 INCLUDE(SetupCompiler)
81 SET(OSG_COMPILER_DEFAULTS 1 CACHE INTERNAL "Defaults written" FORCE ) #INTERNAL
82 ENDIF(NOT OSG_COMPILER_DEFAULTS)
84 INCLUDE(UpdateCompiler)
86 INCLUDE(BuildFunctions)
87 INCLUDE(ConfigurePackages)
89 INCLUDE_DIRECTORIES(${OpenSG_INCLUDE_DIRS})
98 FIND_LIBRARY(OSG_THREAD_LIB NAMES pthread)
99 FIND_LIBRARY(OSG_DL_LIB NAMES dl)
101 OSG_ADD_OPT(OSG_THREAD_LIB)
102 OSG_ADD_OPT(OSG_DL_LIB)
106 FIND_LIBRARY(OSG_APPLICATIONSERVICES_FRAMEWORK NAMES ApplicationServices)
107 FIND_LIBRARY(OSG_CARBON_FRAMEWORK NAMES Carbon)
108 FIND_LIBRARY(OSG_COCOA_FRAMEWORK NAMES Cocoa)
115 FIND_PACKAGE(OpenGL REQUIRED)
117 OSG_ADD_OPT(OPENGL_gl_LIBRARY)
118 OSG_ADD_OPT(OPENGL_glu_LIBRARY)
127 OSG_SET(OSG_WITH_GLUT 1)
128 OSG_SET(OSG_GLUT_INC_DIR ${GLUT_INCLUDE_DIR})
129 OSG_SET(OSG_GLUT_LIBS ${GLUT_LIBRARIES})
131 OSG_SET(OSG_WITH_GLUT 0)
132 OSG_SET(OSG_GLUT_INC_DIR "")
133 OSG_SET(OSG_GLUT_LIBS "")
140 FIND_PACKAGE(PythonInterp)
146 OSG_CONFIGURE_BOOST()
149 MESSAGE(STATUS "Need fileio deps : ${_OSG_USE_FILEIO}")
150 MESSAGE(STATUS "Need imgfileio deps : ${_OSG_USE_IMAGEFILEIO}")
151 MESSAGE(STATUS "Need cuda deps : ${_OSG_USE_CONTRIBCOMPUTE}")
152 MESSAGE(STATUS "Need cluster : ${_OSG_USE_CLUSTER}")
153 MESSAGE(STATUS "Need csm : ${_OSG_USE_CONTRIBCSM}")
154 MESSAGE(STATUS "Need qt : ${_OSG_USE_QT}")
156 IF(NOT _OSG_USE_IMAGEFILEIO EQUAL -1)
158 MESSAGE(STATUS "Configure image file io")
163 OSG_CONFIGURE_OPENEXR()
164 ENDIF(NOT _OSG_USE_IMAGEFILEIO EQUAL -1)
166 IF(NOT _OSG_USE_FILEIO EQUAL -1)
168 MESSAGE(STATUS "Configure file io")
170 OSG_CONFIGURE_COLLADA()
174 IF(CMAKE_BUILD_TYPE STREQUAL "Debug" OR
175 CMAKE_BUILD_TYPE STREQUAL "DebugOpt")
177 OSG_SET(OSG_COLLADA_LIBS ${COLLADA_LIBRARY_DEBUG})
181 OSG_SET(OSG_COLLADA_LIBS ${COLLADA_LIBRARY_RELEASE})
186 SET(OSG_COLLADA_LIBS ${OSG_COLLADA_TARGETS})
191 SET(OSG_COLLADA_LIBS "")
194 ENDIF(NOT _OSG_USE_FILEIO EQUAL -1)
196 IF(NOT _OSG_USE_CONTRIBCOMPUTE EQUAL -1) # AND OSG_ENABLE_CUDA)
198 MESSAGE(STATUS "Configure cuda deps")
200 FIND_PACKAGE(CUDA QUIET REQUIRED)
202 INCLUDE(ConfigurePackages.OSGContribComputeBase)
204 IF(NOT OSG_BUILD_DEPENDEND)
205 OSG_CONFIGURE_NVSDKCOMMON()
206 OSG_CONFIGURE_NVOCLUTILS()
207 OSG_CONFIGURE_CUDACOMMON()
208 OSG_CONFIGURE_CUDAUTIL()
209 OSG_CONFIGURE_CUDPP()
210 OSG_CONFIGURE_CUDAPARTSDK()
211 ENDIF(NOT OSG_BUILD_DEPENDEND)
213 MESSAGE(STATUS "NV Status: NV:${OSG_NVSDKCOMMON_FOUND}")
214 MESSAGE(STATUS "Cuda Status: CC:${OSG_CUDACOMMON_FOUND} CU:${OSG_CUDAUTIL_FOUND} CP:${OSG_CUDPP_FOUND}")
215 MESSAGE(STATUS "OCL Status : NV:${OSG_NVOCLUTILS_FOUND}")
221 SET(OSG_WITH_OPENCL 1)
224 ENDIF(NOT _OSG_USE_CONTRIBCOMPUTE EQUAL -1) # AND OSG_ENABLE_CUDA)
226 IF(NOT _OSG_USE_QT EQUAL -1)
239 FIND_PACKAGE(PythonLibs)
241 OSG_ADD_OPT(PYTHON_INCLUDE_PATH)
242 OSG_ADD_OPT(PYTHON_LIBRARY)
244 IF(Boost_FOUND AND PYTHONLIBS_FOUND)
246 FIND_PACKAGE(Boost COMPONENTS python)
248 IF(Boost_FOUND AND WIN32)
250 SET(OSG_BOOST_PYTHON_TARGETS )
251 OSG_ADD_IMPORT_LIB(OSG_BOOST_PYTHON_TARGETS Boost_PYTHON_LIBRARY)
252 SET(OSG_BOOST_PYTHON_LIBS ${OSG_BOOST_PYTHON_TARGETS})
254 ELSE(Boost_FOUND AND WIN32)
256 IF(CMAKE_BUILD_TYPE STREQUAL "Debug" OR
257 CMAKE_BUILD_TYPE STREQUAL "DebugOpt")
259 SET(OSG_BOOST_PYTHON_LIBS ${Boost_PYTHON_LIBRARY_DEBUG})
262 SET(OSG_BOOST_PYTHON_LIBS ${Boost_PYTHON_LIBRARY_RELEASE})
265 ENDIF(Boost_FOUND AND WIN32)
267 # We ignore if boost python fails, we catch that somewhere else
268 # so if we get here Boost_FOUND was true in the first place
269 SET(Boost_FOUND TRUE)
271 ENDIF(Boost_FOUND AND PYTHONLIBS_FOUND)
276 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
277 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
278 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
280 ADD_CUSTOM_TARGET(OSGAll)
282 # optional pass for test programs
284 ADD_CUSTOM_TARGET(OSGAllTests)
285 ADD_DEPENDENCIES(OSGAll OSGAllTests)
286 # ENDIF(OSGBUILD_TESTS)
288 ADD_CUSTOM_TARGET(OSGAllApps)
289 ADD_DEPENDENCIES(OSGAll OSGAllApps)
293 OSG_OPTION(OSG_USE_SEPARATE_LIBDIRS "" ON)
296 IF(OSGEXCLUDE_TESTS_FROM_ALL)
297 SET(OSGEXCLUDE_TESTS EXCLUDE_FROM_ALL)
299 SET(OSGEXCLUDE_TESTS "")
302 IF(OSGEXCLUDE_UNITTESTS_FROM_ALL)
303 SET(OSGEXCLUDE_UNITTESTS EXCLUDE_FROM_ALL)
305 SET(OSGEXCLUDE_UNITTESTS "")
308 IF(OSGEXCLUDE_EXAMPLES_SIMPLE_FROM_ALL)
309 SET(OSGEXCLUDE_EXAMPLES_SIMPLE EXCLUDE_FROM_ALL)
311 SET(OSGEXCLUDE_EXAMPLES_SIMPLE "")
314 IF(OSGEXCLUDE_EXAMPLES_ADVANCED_FROM_ALL)
315 SET(OSGEXCLUDE_EXAMPLES_ADVANCED EXCLUDE_FROM_ALL)
317 SET(OSGEXCLUDE_EXAMPLES_ADVANCED "")
323 MACRO(_OSG_SETUP_BUILD)
325 # when adding passes, make sure to add a corresponding pass directory variable
326 # OSG_PASSDIR_${PASSNAME} - this variable may not be empty!
327 SET(OSG_CMAKE_PASSES "OSGCOLLECT" "OSGSETUP")
329 SET(OSG_PASSDIR_OSGCOLLECT "Collect")
330 SET(OSG_PASSDIR_OSGSETUP "Build")
336 FILE(GLOB OSG_OLD_BUILD_FILES "${CMAKE_BINARY_DIR}/*.cmake")
338 IF(OSG_OLD_BUILD_FILES)
339 FILE(REMOVE ${OSG_OLD_BUILD_FILES})
340 ENDIF(OSG_OLD_BUILD_FILES)
342 # FOREACH(_OSG_COMPONENT ${STORED_PROJECTS})
343 FOREACH(_OSG_COMPONENT ${_OSG_COMPONENTS})
344 MESSAGE(STATUS "FAKE : ${CMAKE_BINARY_DIR}/${_OSG_COMPONENT}.cmake")
345 FILE(WRITE ${CMAKE_BINARY_DIR}/${_OSG_COMPONENT}.cmake "#dummy")
347 SET(_OSG_COMPONENT_LI )
349 FOREACH(_OSG_COMPONENT_DEP ${${_OSG_COMPONENT}_DEP_OSG_LIB})
350 LIST(APPEND _OSG_COMPONENT_LI ${_OSG_COMPONENT_DEP})
351 ENDFOREACH(_OSG_COMPONENT_DEP ${${_OSG_COMPONENT}_DEP_OSG_LIB})
353 FOREACH(_OSG_COMPONENT_DEP ${${_OSG_COMPONENT}_DEP_LIB})
354 IF(TARGET ${_OSG_COMPONENT_DEP})
355 LIST(APPEND _OSG_COMPONENT_LI ${_OSG_COMPONENT_DEP})
356 ELSE(TARGET ${_OSG_COMPONENT_DEP})
357 LIST(APPEND _OSG_COMPONENT_LI ${${_OSG_COMPONENT_DEP}})
358 ENDIF(TARGET ${_OSG_COMPONENT_DEP})
359 ENDFOREACH(_OSG_COMPONENT_DEP ${${_OSG_COMPONENT}_DEP_LIB})
361 IF(_OSG_COMPONENT_LI AND TARGET ${_OSG_COMPONENT})
362 SET_TARGET_PROPERTIES(${_OSG_COMPONENT} PROPERTIES
363 IMPORTED_LINK_INTERFACE_LIBRARIES "${_OSG_COMPONENT_LI}")
364 ENDIF(_OSG_COMPONENT_LI AND TARGET ${_OSG_COMPONENT})
366 ENDFOREACH(_OSG_COMPONENT ${STORE_PROJECTS})
372 # optional pass for test programs
373 LIST(APPEND OSG_CMAKE_PASSES "OSGSETUPTEST")
374 SET(OSG_PASSDIR_OSGSETUPTEST "Test")
376 OSG_OPTION(OSG_ENABLE_FCD2CODE "" ON)
377 OSG_OPTION(OSG_FCD2CODE_WRITE_CLASS "" OFF)
379 ADD_CUSTOM_TARGET(OSGAllLibs)
380 ADD_CUSTOM_TARGET(OSGAllContribLibs)
382 SET(OSG_MAIN_LIB_TARGET OSGAllContribLibs)
384 ADD_DEPENDENCIES(OSGAllLibs OSGAllContribLibs)
385 ADD_DEPENDENCIES(OSGAll OSGAllLibs)
387 ENDMACRO(_OSG_SETUP_BUILD)
389 MACRO(_OSG_RUN_PASSES)
391 FOREACH(LIBCONFIGFILE ${OSG_LIBRARY_CONFIG_FILES})
392 GET_FILENAME_COMPONENT(LIBCONFIGDIR "${LIBCONFIGFILE}" PATH)
393 GET_FILENAME_COMPONENT(LIBFILENAME "${LIBCONFIGFILE}" NAME)
394 STRING(REPLACE "CMakeLists.Lib." "" LIBFILENAME "${LIBFILENAME}")
395 STRING(REPLACE ".txt" "" LIBFILENAME "${LIBFILENAME}")
397 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBCONFIGDIR}/${LIBFILENAME}.Prepare.cmake)
398 INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/${LIBCONFIGDIR}/${LIBFILENAME}.Prepare.cmake)
400 ENDFOREACH(LIBCONFIGFILE)
403 FOREACH(PASS ${OSG_CMAKE_PASSES})
404 SET(OSG_CMAKE_PASS ${PASS})
406 MESSAGE(STATUS "\nPASS : ${OSG_CMAKE_PASS} in ${OSG_PASSDIR_${PASS}}\n")
408 FOREACH(LIBCONFIGFILE ${OSG_LIBRARY_CONFIG_FILES})
409 GET_FILENAME_COMPONENT(LIBCONFIGDIR "${LIBCONFIGFILE}" PATH)
410 GET_FILENAME_COMPONENT(LIBFILENAME "${LIBCONFIGFILE}" NAME)
411 STRING(REPLACE "CMakeLists.Lib." "" LIBFILENAME "${LIBFILENAME}")
412 STRING(REPLACE ".txt" "" LIBFILENAME "${LIBFILENAME}")
414 ADD_SUBDIRECTORY("${LIBCONFIGDIR}" "${OSG_PASSDIR_${PASS}}/${LIBFILENAME}")
416 ENDFOREACH(LIBCONFIGFILE)
420 ENDMACRO(_OSG_RUN_PASSES)
422 MACRO(OSG_COLLECT_LIBS CURRENT_DIR_ONLY)
430 SET(_OSG_CURRDIR_ONLY ${CURRENT_DIR_ONLY})
432 # Find files describing libraries to build, but make sure base
433 # and system are processed first
435 IF(_OSG_CURRDIR_ONLY)
436 FILE(GLOB OSG_LIBRARY_CONFIG_FILES RELATIVE "${CMAKE_SOURCE_DIR}"
437 "./*CMakeLists.Lib.*.txt")
439 FILE(GLOB_RECURSE OSG_LIBRARY_CONFIG_FILES RELATIVE "${CMAKE_SOURCE_DIR}"
440 "./*CMakeLists.Lib.*.txt")
443 IF(OSG_EXCLUDE_FROM_BUILD)
444 LIST(REMOVE_ITEM OSG_LIBRARY_CONFIG_FILES ${OSG_EXCLUDE_FROM_BUILD})
449 ENDMACRO(OSG_COLLECT_LIBS CURRENT_DIR_ONLY)
451 MACRO(OSG_DOCOLLECT_LIBS)
459 SET(_OSG_CURRDIR_ONLY ${CURRENT_DIR_ONLY})
461 SET(_OSG_TMPLIST ${ARGV})
462 MATH(EXPR _OSG_LISTCOUNT ${ARGC}-1)
464 # Find files describing libraries to build, but make sure base
465 # and system are processed first
467 SET(_OSG_TMPLIST ${ARGV})
468 MATH(EXPR _OSG_LISTCOUNT ${ARGC}-1)
470 FOREACH(_LOOPC RANGE 0 ${_OSG_LISTCOUNT} 2)
472 MATH(EXPR _LOOPN ${_LOOPC}+1)
474 LIST(GET _OSG_TMPLIST ${_LOOPC} OSGLIB_SOURCE_DIR)
475 LIST(GET _OSG_TMPLIST ${_LOOPN} _OSG_CURRDIR_ONLY)
477 IF(_OSG_CURRDIR_ONLY)
478 FILE(GLOB _OSG_LIBRARY_CONFIG_FILES RELATIVE "${CMAKE_SOURCE_DIR}"
479 "${${OSGLIB_SOURCE_DIR}}/*CMakeLists.Lib.*.txt")
481 FILE(GLOB_RECURSE _OSG_LIBRARY_CONFIG_FILES RELATIVE "${CMAKE_SOURCE_DIR}"
482 "${${OSGLIB_SOURCE_DIR}}/*CMakeLists.Lib.*.txt")
485 LIST(APPEND OSG_LIBRARY_CONFIG_FILES ${_OSG_LIBRARY_CONFIG_FILES})
488 IF(OSG_EXCLUDE_FROM_BUILD)
489 LIST(REMOVE_ITEM OSG_LIBRARY_CONFIG_FILES ${OSG_EXCLUDE_FROM_BUILD})
494 ENDMACRO(OSG_DOCOLLECT_LIBS)