#StackBounty: #c++ #cmake Generate DLL configuration type with CMake

Bounty: 50

I’m using CMake to generate my Visual Studio solutions. Right now, CMake generates two configuration Release and Debug, under a single project. Both configs builds a win32 (.exe) application.

This works great, but I would also like to generate a third configuration, that builds a DLL instead. I’m aware that in CMake we can use add_library(LibraryName SHARED [files]) to generate a separate a project that creates builds a DLL target, but that is not what I want. Instead, I would like to generate a DLL configuration in visual studio, along side Debug and Release.

I can get the configuration by adding set(CMAKE_CONFIGURATION_TYPES Release Debug DLL) in CMakeList, but I’m not sure how to go about actually configuring it. How do I make this custom configuration actually build a DLL? If possible, I would also like to customize the output name and directory of this configuration, just like how I’m able to with CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE etc.

Is this possible?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.