这是我下面的最小示例:https://www.dropbox.com/s/7fwsr3sigb60rtw/leveling-test.zip?dl=0
我当前的项目文件夹结构和相关的CMakeLists内容:
leveling
├── CMakeLists.txt: add_subdirectory(deps)
└── deps
├── CMakeLists.txt: add_subdirectory(xml-reading)
└── xml-reading
├── CMakeLists.txt: add_subdirectory(deps)
│ add_library(xml-reading ...)
│ target_include_directories(xml-reading PUBLIC ${CMAKE_CURRENT_LIST_DIR}/deps/tinyxml2)
│ target_link_libraries(xml-reading PUBLIC tinyxml2)
└── deps
├── CMakeLists.txt: add_subdirectory(tinyxml2)
└── tinyxml2
这将生成一个xml-reading.dll文件。
但是随后,级配项目链接器选项将具有/DYNAMICBASE "bin\windows-32\debug\xml-reading.lib" "bin\windows-32\debug\BOBPrimitives.lib" "bin\windows-32\debug\tinyxml2d.lib"
哪个产量:
2>LINK : fatal error LNK1104: cannot open file 'bin\windows-32\debug\xml-reading.lib'
怎么了?
add_library(xml-reading SHARED ...)
,但没有帮助add_library(xml-reading STATIC ...)
处设置了STATIC以强制其生成.lib文件-但我想了解发生了什么