I followed this thread to be able to set different library files for each configuration I have. My current use case is that I use 4 configurations (Debug, Release, MinSizeRel, RelWithDebInfo). I want to have a structure where I have output_folder/Debug, output_folder/Release, etc, and copy all libraries I need into each folder. This way, I have all libraries related to each configuration in the respective output folders.
The problem is that I am having issues with linking my project. What seems to happend is that I have specific libraries to specific configurations. For instance, I might need a library for Debug that I don't need for Release. The problem is that the Release configuration is linked to this Debug library and cannot find the file. Here's an example:
Let's say I need liblokid.lib
for Debug, but I don't need it for Release, and that I need libtinyxml2.lib
for Release but not for Debug.
add_library(libloki STATIC IMPORTED)
set_target_properties(libloki PROPERTIES IMPORTED_LOCATION_DEBUG ${CMAKE_BINARY_DIR}/bin/Debug/liblokid.lib)
target_link_libraries(${iProjectName} libloki)
add_library(libtinyxml2 STATIC IMPORTED)
set_target_properties(libtinyxml2 PROPERTIES IMPORTED_LOCATION_RELEASE ${CMAKE_BINARY_DIR}/bin/Release/libtinyxml2.lib)
target_link_libraries(${iProjectName} libtinyxml2)
When I open my Visual Studio solution, this is what I see when I select my Debug config when I go to [subproject]->properties->Linker->Input->Additional Dependencies:
..\bin\Debug\liblokid.lib
libtinyxml2.lib-NOTFOUND
And this is when I select the Release configuration:
..\bin\Release\tinyxml2.lib
liblokid.lib-NOTFOUND
Is there a way to have a library linked only during certain configurations? It seems like it is not possible from my results.