diff options
| author | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-12-17 23:33:15 +0100 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi92@disroot.org> | 2025-12-17 23:35:11 +0100 |
| commit | e2f9ee3f8cd319e952e4f5d5ec466f0ea9e6e77f (patch) | |
| tree | 5380dcacfe1690139a338de6ee16a3c6d049a467 /cmake/SetupOSGTargets.cmake | |
| parent | 600ff28dd73f2cf17725382b68a4b1b2573f2e34 (diff) | |
OSGosg
Diffstat (limited to 'cmake/SetupOSGTargets.cmake')
| -rw-r--r-- | cmake/SetupOSGTargets.cmake | 60 |
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) |
