<div dir="ltr">Hi,<div><br></div><div>I have 4 configurations (2 for Debug and 2 for Release) and I would like to install the libraries such that they are installed in the correct directories.</div><div><br></div><div>Installing without worrying about configurations looks like this:</div><div><br></div><div><div>    install(TARGETS ${LIB_NAME}</div><div>        EXPORT ${LIB_NAME}Config<br></div><div>        PUBLIC_HEADER DESTINATION "include/${LIB_NAME}"</div><div>        LIBRARY DESTINATION "bin/${LIB_NAME}/"</div><div>        ARCHIVE DESTINATION "lib/${LIB_NAME}/"</div><div>        )</div></div><div><br></div><div>However, different configurations overwrite the binaries. So instead, I did something like this (I'm going over all my configurations in a foreach):</div><div><br></div><div><div>    install(TARGETS ${LIB_NAME}</div><div>        CONFIGURATIONS DEBUG</div><div>        EXPORT ${LIB_NAME}Config<br></div><div>        PUBLIC_HEADER DESTINATION "include/${LIB_NAME}"</div><div>        LIBRARY DESTINATION "bin/${LIB_NAME}/debug/"</div><div>        ARCHIVE DESTINATION "lib/${LIB_NAME}/debug"</div><div>        )</div></div><div><br></div><div><div>    install(TARGETS ${LIB_NAME}</div><div>        CONFIGURATIONS RELEASE</div><div>        EXPORT ${LIB_NAME}Config<br></div><div>        PUBLIC_HEADER DESTINATION "include/${LIB_NAME}"</div><div>        LIBRARY DESTINATION "bin/${LIB_NAME}/release/"</div><div>        ARCHIVE DESTINATION "lib/${LIB_NAME}/release/"</div><div>        )</div></div><div><br></div><div>however, that results in the error:</div><div>CMake Error: INSTALL(EXPORT ...) includes target "MyLibrary" more than once in the export set.</div><div><br></div><div>The error makes sense, in that I cannot have multiple exports in the same export set, in this case ${LIB_NAME}Config. However, I would like CMake to choose a different directory based on the configuration.</div><div><br></div><div>Now there is a workaround... sort of. I could name the binaries based on the configuration but that doesn't work with our existing build systems. We want the following:</div><div><br></div><div>lib/${LIB_NAME}/${CONFIG}/libname</div><div><br></div><div>Any way to get CMake to install the libraries this way?</div><div><br></div><div>Thank you,</div><div>Saad</div></div>