本地环境 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出现此问题,后续版本不知是否还存在此问题。
|