本地利用CMake重新编译VTK8.0,并为其添加Qt5.12.7支持时报错。

本地环境
Windows 10 Pro 64 Bit
CMake 3.22.4
Qt 5.12.7 msvc2017 64 Bit
VTK 8.0

本地使用cmake编译时出现如下错误:
CMake Error at C:/Libs/Qt/5.12.7/msvc2017_64/lib/cmake/Qt5Core/Qt5CoreMacros.cmake:131 (file):
file failed to open for writing (Invalid argument):
D:/Temp/vtk/build-nmake/GUISupport/Qt/moc_D:/Temp/vtk/build-nmake/GUISupport/Qt/QVTKInteractorAdapter.cpp_parameters
Call Stack (most recent call first):
C:/Libs/Qt/5.12.7/msvc2017_64/lib/cmake/Qt5Core/Qt5CoreMacros.cmake:181 (qt5_create_moc_command)
GUISupport/Qt/CMakeLists.txt:80 (qt5_wrap_cpp)

出现以上错误,找到如下文件Qt5CoreMacros.cmake,在自己QT安装目录上(示例D:\SoftWare\Qt\5.12.7\msvc2017_64\lib\cmake\Qt5Core),修改前`

      endif()
    else()
        file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
    endif()
    if(WIN32 AND rel MATCHES "^([a-zA-Z]):(.*)$") # absolute path
        set(rel "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}")
    endif()
    set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
    string(REPLACE ".." "__" _outfile ${_outfile})
    get_filename_component(outpath ${_outfile} PATH)
    **string(REGEX REPLACE "\\.[^.]*$" "" _outfile ${_outfile})**
    file(MAKE_DIRECTORY ${outpath})
    set(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
endmacro()


macro(QT5_GET_MOC_FLAGS _moc_flags)
    set(${_moc_flags})
    get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)

    if(CMAKE_INCLUDE_CURRENT_DIR)

修改后

     endif()
    else()
        file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
    endif()
    if(WIN32 AND rel MATCHES "^([a-zA-Z]):(.*)$") # absolute path
        set(rel "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}")
    endif()
    set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
    string(REPLACE ".." "__" _outfile ${_outfile})
    get_filename_component(outpath ${_outfile} PATH)
    **if(CMAKE_VERSION VERSION_LESS "3.14")
        get_filename_component(_outfile_ext ${_outfile} EXT)
        get_filename_component(_outfile_ext ${_outfile_ext} NAME_WE)
        get_filename_component(_outfile ${_outfile} NAME_WE)
        string(APPEND _outfile ${_outfile_ext})
    else()
        get_filename_component(_outfile ${_outfile} NAME_WLE)
    endif()**
    file(MAKE_DIRECTORY ${outpath})
    set(${outfile} ${outpath}/${prefix}${_outfile}.${ext})
endmacro()


macro(QT5_GET_MOC_FLAGS _moc_flags)
    set(${_moc_flags})
    get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)

    if(CMAKE_INCLUDE_CURRENT_DIR)

目前只针对QT5.12.7出现此问题,后续版本不知是否还存在此问题。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值