出于某些奇怪的原因,我必须显式添加库路径(请参阅#1),并且无法执行我认为会更简单且更可靠的操作(#2)。 (它抱怨第一个nng.lib我找不到该文件)
我在Windows 10上使用CMAKE 3.12和VS2017。
set(NNG_LIB ${CMAKE_CURRENT_SOURCE_DIR}/nng/lib/nng.lib)
set(FB_LIB ${CMAKE_CURRENT_SOURCE_DIR}/flatbuffers/lib/flatbuffers.lib)
set(WinsockLib "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.17134.0/um/x64/mswsock.lib")
set(ws "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.17134.0/um/x64/ws2_32.lib")
set(adv "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.17134.0/um/x64/advapi32.lib")
target_link_libraries(${PROJECT_NAME} ${NNG_LIB} ${FB_LIB} ${WinsockLib} ${ws} ${adv})
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/WinSDK
${CMAKE_CURRENT_SOURCE_DIR}/nng/lib
${CMAKE_CURRENT_SOURCE_DIR}/flatbuffers/lib)
target_link_libraries(${PROJECT_NAME} nng.lib flatbuffers.lib mswsock.lib ws2_32.lib advapi32.lib )