osgQt icon indicating copy to clipboard operation
osgQt copied to clipboard

How to import osgQt into project via vcpkg + cmake?

Open Dizww opened this issue 2 years ago • 1 comments

I try to use vcpkg + cmake to import osgQt to my project. To Reproduce First use vcpkg to install osgQt vcpkg install osgQt:x64-windows then wirte the following information into CMakeLists.txt

find_package(OpenSceneGraph REQUIRED 
        COMPONENTS osg osgDB osgUtil osgViewer  osgQt
)
include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS})
add_executable(myproject ${source})
target_link_libraries(myproject PRIVATE ${OPENSCENEGRAPH_LIBRARIES})

Failure logs

set VCPKG_ROOT:
set VCPKG_TARGET_TRIPLET: x64-windows
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
-- Build directory: D:/myproject/build
-- Build type : Release
-- Could NOT find osgQt (missing: OSGQT_LIBRARY)
CMake Error at D:/Program/CMake/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find OpenSceneGraph (missing: OSGQT_FOUND) (found version
  "3.6.5")
Call Stack (most recent call first):
  D:/Program/CMake/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  D:/Program/CMake/share/cmake-3.22/Modules/FindOpenSceneGraph.cmake:226 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  D:/package/vcpkg/scripts/buildsystems/vcpkg.cmake:824 (_find_package)
  src/CMakeLists.txt:3 (find_package)


-- Configuring incomplete, errors occurred!

so, is there any way to import osgQt into the project via vcpkg + cmake?

Dizww avatar Aug 11 '22 02:08 Dizww

edit this file C:\Program Files\CMake\share\cmake-3.23\Modules\FindosgQt.cmake like

include(${CMAKE_CURRENT_LIST_DIR}/Findosg_functions.cmake)
OSG_FIND_PATH   (OSGQT osgQOpenGL/osgQOpenGLWidget)
OSG_FIND_LIBRARY(OSGQT osgQOpenGL)

include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgQt DEFAULT_MSG
    OSGQT_LIBRARY OSGQT_INCLUDE_DIR)

then

find_package(OpenSceneGraph 3.6.5
    REQUIRED COMPONENTS
        osg
        osgUtil
        osgGA
        osgViewer
        osgQt # https://blog.csdn.net/yao_yu_126/article/details/119410640
)
target_link_libraries(${target_name}
    PRIVATE
        ${OPENSCENEGRAPH_LIBRARIES} # 必须大写 我惊呆了
)

ref: https://blog.csdn.net/yao_yu_126/article/details/119410640

toszyrt avatar Sep 06 '22 07:09 toszyrt