我目前正在try 从GitHubLink安装gr-matchstiq
,但遇到了问题.该代码不再符合CMake的标准.
具体地说,cmake 2.6引入了逻辑目标名称必须唯一的策略(见:CMP0002).但是,目标‘All’被重复使用.我相信是这样的,因为我得到了一个错误:
$ cmake -Wno-dev ../
-- Build type not specified: defaulting to release.
Traceback (most recent call last):
File "<string>", line 2, in <module>
TypeError: Strings must be encoded before hashing
Traceback (most recent call last):
File "<string>", line 2, in <module>
TypeError: Strings must be encoded before hashing
CMake Error at cmake/Modules/GrPython.cmake:115 (add_custom_target):
add_custom_target cannot create target "ALL" because another target with
the same name already exists. The existing target is a custom target
created in source directory "/home/me/Projects/gr-matchstiq/swig".
See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
cmake/Modules/GrPython.cmake:214 (GR_UNIQUE_TARGET)
python/CMakeLists.txt:31 (GR_PYTHON_INSTALL)
Traceback (most recent call last):
File "<string>", line 2, in <module>
TypeError: Strings must be encoded before hashing
CMake Error at cmake/Modules/GrPython.cmake:115 (add_custom_target):
add_custom_target cannot create target "ALL" because another target with
the same name already exists. The existing target is a custom target
created in source directory "/home/me/Projects/gr-matchstiq/swig".
See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
cmake/Modules/GrPython.cmake:214 (GR_UNIQUE_TARGET)
apps/CMakeLists.txt:22 (GR_PYTHON_INSTALL)
-- Configuring incomplete, errors occurred!
See also "/home/me/Projects/gr-matchstiq/build/CMakeFiles/CMakeOutput.log".
See also "/home/me/Projects/gr-matchstiq/build/CMakeFiles/CMakeError.log".
Cmake/Modules/GrPython.cmake:115中的代码为:
add_custom_target(${_target} ALL DEPENDS ${ARGN})
Cmake/Modules/GrPython.cmake:214中的代码为:
GR_UNIQUE_TARGET("pygen" ${python_install_gen_targets})
我几乎没有使用cmake的经验,所以我也不确定哪个修复是最安全的
-
在根CMakelists.txt文件中,添加一行(注意:这不起作用,但可能我做错了什么):
set_property(GLOBAL ALLOW_DUPLICATE_TARGETS TRUE)
个 -
将‘All’cmake/Modules/GrPython.cmake:115更改为类似‘ALL_PY’的内容-即
add_custom_target(${_target} ALL_PY DEPENDS ${ARGN})
个 -
以某种方式修改GR_UNIQUE_TARGET函数(GrPython.cmake的第107-116行):
######################################################################## # Create an always-built target with a unique name # Usage: GR_UNIQUE_TARGET(<description> <dependencies list>) ######################################################################## function(GR_UNIQUE_TARGET desc) file(RELATIVE_PATH reldir ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import re, hashlib unique = hashlib.md5('${reldir}${ARGN}').hexdigest()[:5] print(re.sub('\\W', '_', '${desc} ${reldir} ' + unique))" OUTPUT_VARIABLE _target OUTPUT_STRIP_TRAILING_WHITESPACE) add_custom_target(${_target} ALL DEPENDS ${ARGN}) endfunction(GR_UNIQUE_TARGET)
或者,还有什么我应该做的吗?
PS-我需要进行的另一个修复是在第95-102行:
########################################################################
# Sets the python installation directory GR_PYTHON_DIR
########################################################################
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "
from distutils import sysconfig
print (sysconfig.get_python_lib(plat_specific=True, prefix=''))
" OUTPUT_VARIABLE GR_PYTHON_DIR OUTPUT_STRIP_TRAILING_WHITESPACE
)
最初,Python print语句没有由Python3请求的"("&;")")
PPS-我不知道如何处理或找到类型错误,所以将在稍后处理它们.