CMake生成lib和dll

set(LIBNAME test)
add_library(${LIBNAME} SHARED "test.cpp" "test.h" )
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
target_link_libraries(${LIBNAME} PRIVATE Qt5::Core Qt5::Widgets Qt5::Quick)

加参数SHARED,生成动态库dll,否则生成静态库lib。

你可能感兴趣的:(C/C++,c++)