'CMake: Create DLL including dependencies instead of separate dll's

Im writing a SDK for Windows and Mac OS in C++, and im using CMake. On windows, I'd like the compiled DLL to contain all necessary dependencies, instead of having separate DLLs for all third party libraries im using.

Here are the relevant sections of the MakeFile:

find_package(OpenSSL REQUIRED)
find_package(CURL CONFIG REQUIRED)
find_package(nlohmann_json 3.2.0 REQUIRED)
find_package(spdlog REQUIRED)
find_package(unofficial-sqlite3 CONFIG REQUIRED)
....
add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
...
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::Crypto CURL::libcurl nlohmann_json::nlohmann_json spdlog::spdlog_header_only unofficial::sqlite3::sqlite3)

This generates the following separate DLLs:

fmt.dll
libcrypto-1_1.dll
libcurl.dll
sqlite3.dll
zlib1.dll

Is it possible to create a library containing all dependecies, like it is on Mac OS with the generated dylib?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source