使用CMake 2.8.11.2编译osgQt(Windows7 MSVS11 Qt 5.1 OSG 3.2.0)

时间:2013-09-06 19:57:59

标签: windows cmake qt5 openscenegraph

我正在尝试编译Qt-Library osgQt,因为它未在预编译的软件包中提供(至少不适用于Windows 7(x64)和MSVS 11 - x64)。因此,我遵循这些指示:

  

注意:此库是OSG源代码的一部分,但它不是预构建二进制文件的一部分。有必要下载整个OSG项目来构建osgQt库。

     

予。下载osg 3.0.1源代码。

     

II。使用CMake生成Visual Studio解决方案。

     

要执行此操作,您可以运行准备好的批处理文件。       - 它创建没有任何osg依赖关系的VS解决方案。 (希望足够)       - 有必要在文件头中设置变量。       - 运行之后,应该有一个包含OpenSceneGraph.sln文件和src / osgQt目录的build文件夹。

我无法使用此批处理文件,因为它不可用和其他软件条件(MSVS 2008,Qt 4.7.4),因此必须自己使用CMake构建它。

  

III。在Visual Studio中打开OpenSceneGraph.sln

     

IV。选择调试win32(或您想要的其他配置)

     

诉选择osgQt项目

     

VI。从菜单中选择Build,Build osgQt

     

结果:osgQt lib和dll文件......将它们复制到预构建的osg库旁边。

但是我在第二步遇到了麻烦:

使用CMake 2.8.11.2时,我收到以下错误:

CMake Error at D:/Programme/QT/5.1.0/msvc2012_64_opengl/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:14 (message):
Failed to find "glu32" in "".
Call Stack (most recent call first):
D:/Programme/QT/5.1.0/msvc2012_64_opengl/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:48 (_qt5gui_find_extra_libs)
D:/Programme/QT/5.1.0/msvc2012_64_opengl/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:127 (include)
D:/Programme/QT/5.1.0/msvc2012_64_opengl/lib/cmake/Qt5Widgets/Qt5WidgetsConfig.cmake:83 (find_package)
CMakeLists.txt:570 (FIND_PACKAGE)

因为在我遵循这条指令之前,其他许多人都有这个问题 (http://qt-project.org/forums/viewthread/30006/):

  

所以它对我有用(至少是CMake配置,并没有尝试在编译中实际使用它)。   重现的步骤:

     
      
  1. 我使用了Qt 5.1的预编译版本(用于VS2012的OpenGL x64版本)。使用它应该没问题,因为Qt 5.1应该支持开箱即用的OpenGL3.2 +配置文件,我认为你不再需要使用Glew了,只需看看http://qt-project.org/doc/qt-> 5.1 / qtgui / qabstractopenglfunctions。 html层次结构
  2.   
  3. 已安装Win SDK 8.0。但我认为7.0可能没问题。
  4.   
  5. 加入   set(CMAKE_PREFIX_PATH“C:\ Program Files(x86)\ Windows Kits \ 8.0 \ Lib \ win8 \ um \ x64”)   line到我的cmake文件。   这就是glu32.lib和类似文件的位置。
  6.   
  7. 使用VS 11 win64作为生成器运行cmake-gui configure& generate。
  8.   

它尝试了两种方法(不是在同一个构建过程中):

set(CMAKE_PREFIX_PATH “D:\Programme\Microsoft SDKs\Windows\v7.0\Lib\x64”)
set(CMAKE_PREFIX_PATH “C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x64”)

我收到上面发布的错误以及以下警告:

CMake Warning (dev) at CMakeLists.txt:4 (set):
Syntax error in cmake code at

D:/OpenSceneGraph-3.2.0/OpenSceneGraph/CMakeLists.txt:4

when parsing string

"C:\Program
Invalid escape sequence \P

Policy CMP0010 is not set: Bad variable reference syntax is an error.  Run
"cmake --help-policy CMP0010" for policy details.  Use the cmake_policy
command to set the policy and suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at CMakeLists.txt:4 (set):
Syntax error in cmake code at

D:/OpenSceneGraph-3.2.0/OpenSceneGraph/CMakeLists.txt:4

when parsing string

\Windows

Invalid escape sequence \W

Policy CMP0010 is not set: Bad variable reference syntax is an error.  Run
"cmake --help-policy CMP0010" for policy details.  Use the cmake_policy
command to set the policy and suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at CMakeLists.txt:4 (set):
Syntax error in cmake code at

D:/OpenSceneGraph-3.2.0/OpenSceneGraph/CMakeLists.txt:4

when parsing string

Kits\8.0\Lib\win8\um\x64”

Invalid escape sequence \8

Policy CMP0010 is not set: Bad variable reference syntax is an error.  Run
"cmake --help-policy CMP0010" for policy details.  Use the cmake_policy
command to set the policy and suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it.

我不认为这些警告与大多数其他警告一样无害,并且表明CMake根本无法找到正确的目录。

有没有人知道如何解决这个问题,或者不知道如何在Windows7(x64)上使用osg 3.2.0和MSVS2012预编译版本的osgQt for Qt 5.1?

修改1:

Qt5GuiConfigExtras.cmake的代码

macro(_qt5gui_find_extra_libs Name Libs LibDir IncDirs)
    set(Qt5Gui_${Name}_LIBRARIES)
    set(Qt5Gui_${Name}_INCLUDE_DIRS ${IncDirs})
    foreach(_lib ${Libs})
        string(REGEX REPLACE [^_A-Za-z0-9] _ _cmake_lib_name ${_lib})
        if (NOT TARGET Qt5::Gui_${_cmake_lib_name})
            find_library(Qt5Gui_${_cmake_lib_name}_LIBRARY ${_lib}
            )
            if (NOT Qt5Gui_${_cmake_lib_name}_LIBRARY)
                if ("${ARGN}" STREQUAL "OPTIONAL")
                    break()
                else()
                    message(FATAL_ERROR "Failed to find \"${_lib}\" in \"${LibDir}\".")
                endif()
            endif()
            add_library(Qt5::Gui_${_cmake_lib_name} SHARED IMPORTED)
            set_property(TARGET Qt5::Gui_${_cmake_lib_name} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${IncDirs})

            set_property(TARGET Qt5::Gui_${_cmake_lib_name} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
            _qt5_Gui_check_file_exists("${Qt5Gui_${_cmake_lib_name}_LIBRARY}")
            set_property(TARGET Qt5::Gui_${_cmake_lib_name} PROPERTY IMPORTED_LOCATION_RELEASE "${Qt5Gui_${_cmake_lib_name}_LIBRARY}")

            set_property(TARGET Qt5::Gui_${_cmake_lib_name} PROPERTY IMPORTED_IMPLIB_RELEASE "${Qt5Gui_${_cmake_lib_name}_LIBRARY}")
            unset(Qt5Gui_${_cmake_lib_name}_LIBRARY CACHE)

            find_library(Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG ${_lib}d
                PATHS "${LibDir}" NO_DEFAULT_PATH)
            if (Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG)
                set_property(TARGET Qt5::Gui_${_cmake_lib_name} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
                _qt5_Gui_check_file_exists("${Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG}")
                set_property(TARGET Qt5::Gui_${_cmake_lib_name} PROPERTY IMPORTED_LOCATION_DEBUG "${Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG}")
                set_property(TARGET Qt5::Gui_${_cmake_lib_name} PROPERTY IMPORTED_IMPLIB_DEBUG "${Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG}")
            endif()
            unset(Qt5Gui_${_cmake_lib_name}_LIBRARY_DEBUG CACHE)
        endif()
        list(APPEND Qt5Gui_${Name}_LIBRARIES Qt5::Gui_${_cmake_lib_name})
    endforeach()
    if (NOT CMAKE_CROSSCOMPILING)
        foreach(_dir ${IncDirs})
            _qt5_Gui_check_file_exists(${_dir})
        endforeach()
    endif()
endmacro()



_qt5gui_find_extra_libs(OPENGL "GlU32;opengl32;gdi32;user32" "" "")



set(Qt5Gui_OPENGL_IMPLEMENTATION GL)

get_target_property(_configs Qt5::Gui IMPORTED_CONFIGURATIONS)
foreach(_config ${_configs})
    set_property(TARGET Qt5::Gui APPEND PROPERTY
        IMPORTED_LINK_DEPENDENT_LIBRARIES_${_config}
        ${Qt5Gui_EGL_LIBRARIES} ${Qt5Gui_OPENGL_LIBRARIES}
    )
endforeach()
unset(_configs)

提前致谢。

2 个答案:

答案 0 :(得分:2)

在CMake中,\是转义字符。要将实际\添加到字符串,您需要将其转义,即将其设为\\

所以你需要这样做:

set(CMAKE_PREFIX_PATH "D:\\Programme\\Microsoft SDKs\\Windows\\v7.0\\Lib\\x64")

或者,您可以将路径分隔符更改为/,即使对于Windows:

set(CMAKE_PREFIX_PATH "D:/Programme/Microsoft SDKs/Windows/v7.0/Lib/x64")

答案 1 :(得分:0)

同样的问题,CMAKE_PREFIX_PATH没有纠正错误,但以下工作:

set(CMAKE_MODULE_PATH "C:/Program Files/Microsoft SDKs/Windows/v7.1/Lib")