add_executable cannot create target "openssl_test_qnx_aaa" because another target with the same name already exists. The existing target is an executable created in source directory "/home/docker/projects/TN_8540/code/dev/qnx_xdc/oss/openssl/test". See documentation for policy CMP0002 for more details.
时间: 2023-11-22 14:53:22 浏览: 58
这个错误的原因是因为你尝试创建一个名为 "openssl_test_qnx_aaa" 的可执行文件,但是 CMake 检测到已经有一个同名的可执行文件存在于源代码目录中 "/home/docker/projects/TN_8540/code/dev/qnx_xdc/oss/openssl/test"。这可能是因为你在 CMakeLists.txt 文件中多次定义了同一个目标,或者在不同的 CMakeLists.txt 文件中定义了同一个目标。
要解决这个问题,你需要确保在同一个 CMakeLists.txt 文件中只定义一次目标,并且确保每个目标都有唯一的名称。你还可以考虑使用不同的名称来避免与现有目标重复。你可以在 CMakeLists.txt 文件中使用以下命令来创建一个名为 "new_target_name" 的可执行文件:
```
add_executable(new_target_name source_file.cpp)
```
如果你仍然遇到问题,请查看文档 CMP0002,该文档提供了有关如何处理同名目标的更多信息。
相关问题
D:\zxing-cpp\CMakeLists.txt:102: error: add_executable cannot create target "ZXing" because another target with the same name already exists. The existing target is a shared library created in source directory "D:/zxing-cpp/core". See documentation for policy CMP0002 for more details.
这个错误是因为你尝试在同一个项目中创建两个名字相同的目标(target)。因为你已经在"core"目录中创建了一个名为"ZXing"的共享库,所以你不能再在其他地方创建一个同名的可执行文件。
要解决这个问题,可以考虑重命名其中一个目标,或者将它们放在不同的项目中。你也可以通过设置 CMake 策略 CMP0002 来禁用这个错误检查,但这不是一个推荐的做法,因为它可能会导致其他问题。
还是会报错D:\Qt\6.2.4\mingw_64\lib\cmake\Qt6Core\Qt6CoreMacros.cmake:559: error: add_executable cannot create target "new1" because another target with the same name already exists. The existing target is an executable created in source directory "D:/Qt/Qt.learn/new1". See documentation for policy CMP0002 for more details. D:/Qt/6.2.4/mingw_64/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:523 (_qt_internal_create_executable) D:/Qt/6.2.4/mingw_64/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:933 (qt6_add_executable) CMakeLists.txt:27 (qt_add_executable)
这个错误提示是因为在你的代码中已经存在一个名为"new1"的可执行文件,而你又在 CMakeLists.txt 中尝试创建一个同名的可执行文件。这会导致冲突。
为了解决这个问题,你需要更改 CMakeLists.txt 中的 `qt_add_executable` 函数的第一个参数,以确保它所创建的可执行文件的名称与你现有的可执行文件不同。例如,你可以将其更改为 "new2":
```
qt_add_executable(new2
main.cpp
)
```
这样就不会再出现同名冲突的问题了。