CMakLists.txt文件内容
set(LIB_SRC hello.cpp)
add_library(hello_static STATIC ${LIB_SRC})
set_target_properties(hello_static PROPERTIES OUTPUT_NAME hello)
set_target_properties(hello_static PROPERTIES CLEAN_DIECT_OUTPUT 1)
add_library(hello SHARED ${LIB_SRC})
set_target_properties(hello PROPERTIES OUTPUT_NAME hello)
set_target_properties(hello PROPERTIES CLEAN_DIECT_OUTPUT 1)
报错
CMake Error:
Running
'D:/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe' '-C' 'D:/cmaketest/CMaketest/out/build/x64-debug' '-t' 'recompact'
failed with:
ninja: error: build.ninja:142: multiple rules generate /c/bin/hello.lib [-w dupbuild=err]
貌似set_target_properties命令根本不起作用,只要改成相同的名字就会报错,求拯救一下,已经卡了很久了
题主试试在BUILD.gn中指定编译配置项,具体可参考之前写的这篇文章
centos7.9使用gn+ninja编译程序_来灵的博客-CSDN博客_centos ninja
把hello_static库的OUTPUT_NAME改成别的名字,比如hello_static,不然和共享库的OUTPUT_NAME冲突了。
set_target_properties(hello_static PROPERTIES OUTPUT_NAME hello_static)