aboutsummaryrefslogtreecommitdiff
path: root/cmake/SetupOSGTargets.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/SetupOSGTargets.cmake')
-rw-r--r--cmake/SetupOSGTargets.cmake60
1 files changed, 60 insertions, 0 deletions
diff --git a/cmake/SetupOSGTargets.cmake b/cmake/SetupOSGTargets.cmake
new file mode 100644
index 0000000..58354b7
--- /dev/null
+++ b/cmake/SetupOSGTargets.cmake
@@ -0,0 +1,60 @@
+function(_GetDebugOptimizedLib libraries)
+ set(debug_found 0)
+ set(optimized_found 0)
+ set(default ${libraries})
+ unset(_out_libraries)
+
+ foreach(path ${libraries})
+ if (${path} STREQUAL "debug")
+ set(debug_found 1)
+ elseif (${path} STREQUAL "optimized")
+ set(optimized_found 1)
+ elseif(debug_found)
+ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(_out_libraries ${_out_libraries} ${path})
+ endif()
+
+ set(debug_found 0)
+ elseif(optimized_found)
+ if(CMAKE_BUILD_TYPE STREQUAL "Release")
+ set(_out_libraries ${_out_libraries} ${path})
+ endif()
+
+ set(optimized_found 0)
+ endif()
+ endforeach()
+
+ if(_out_libraries STREQUAL "")
+ set(_out_libraries "${default}" PARENT_SCOPE)
+ else()
+ set(_out_libraries ${_out_libraries} PARENT_SCOPE)
+ message(STATUS "Choosing ${_out_libraries}")
+ endif()
+endfunction()
+
+if(NOT TARGET OpenThreads::OpenThreads)
+ add_library(OpenThreads::OpenThreads INTERFACE IMPORTED)
+ _GetDebugOptimizedLib("${OPENTHREADS_LIBRARY}")
+ set_target_properties(OpenThreads::OpenThreads PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${OPENTHREADS_INCLUDE_DIR}"
+ INTERFACE_LINK_LIBRARIES "${_out_libraries}")
+endif()
+
+if(NOT TARGET OpenSceneGraph::Core)
+ add_library(OpenSceneGraph::Core INTERFACE IMPORTED)
+ _GetDebugOptimizedLib("${OPENSCENEGRAPH_LIBRARIES}")
+ set_target_properties(OpenSceneGraph::Core PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${OPENSCENEGRAPH_INCLUDE_DIRS}"
+ INTERFACE_LINK_LIBRARIES "${_out_libraries}")
+endif()
+
+if(NOT TARGET OpenSceneGraph::Viewer)
+ add_library(OpenSceneGraph::Viewer INTERFACE IMPORTED)
+ _GetDebugOptimizedLib("${OSGVIEWER_LIBRARY}")
+ set_target_properties(OpenSceneGraph::Viewer PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${OSGVIEWER_INCLUDE_DIR}"
+ INTERFACE_LINK_LIBRARIES "${_out_libraries}")
+endif()
+
+unset(_out_libraries)
+target_link_libraries(OpenSceneGraph::Core INTERFACE OpenThreads::OpenThreads)