我使用cmake編譯我的工作projets之一,這裏的多個子項目是交易CMake的:使用相同的靜態庫
-
client/
CMakeLists.txt
server/
CMakeLists.txt
libs/
libstuff/
CMakeLists.txt
CMakeLists.txt
所以我想能夠單獨編譯每個子項目,並建立來自根文件夾的客戶端和服務器。
假設客戶端和服務器需要libstuff。
我試圖在客戶端和服務器CMakeLists.txt中使用lib的路徑使用「add_subdirectory」,它在編譯服務器或客戶端時起作用,但如果您嘗試從根目錄運行這兩個文件:
CMake Error at common/libplugin/CMakeLists.txt:33 (ADD_LIBRARY):
add_library cannot create target "plugin" because another target with the
same name already exists. The existing target is a static library created
in source directory "/home/adrien/git/r-type/common/libplugin". See
documentation for policy CMP0002 for more details.
所以我一種新的W/cmake的,我不知道我應該做的,我應該使用add_dependencies?
感謝您的幫助,
你是什麼意思與「分開編譯」?如果你建立一個VS項目或生成文件,你可以選擇要編譯的項目... – Philipp