请举一个小例子来说明我的问题:
project(Test)
set(TestLibName mytest)
subdirs(src) # will generate mytest.dll dynamic library
set_property(TARGET ${TestLibName} PROPERTY FOLDER "test")
在这个小脚本中,我想使用src
foler中的CMakeLists.txt文件生成动态库,然后在顶层CMakeLists.txt中设置该库的属性。但是,它似乎不起作用,因为我遇到以下错误:
set_property cannot find Target "mytest". Perhaps it has been created yet.
解决此问题的一种方法是将set_property放入创建动态库(src/CMakeLists.txt
)的CMakeLists.txt中。如果我坚持将其放在顶级CMakeLists.txt文件中,该怎么办?谢谢。
不要使用不推荐使用的命令子目录。用add_subdirectory替换后,一切正常
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句