[CMake] Is there any way to set a build-type specific install path for multiconfig tools?

David Cole DLRdave at aol.com
Mon Jul 13 12:05:40 EDT 2015


I think this should be achievable somehow with CMAKE_INSTALL_PREFIX
set to "/parent_dirs" and then using appropriate DESTINATION and
CONFIGURATIONS arguments to the CMake install commands.

Have you tried using the CONFIGURATIONS args to the install command?



On Mon, Jul 13, 2015 at 10:26 AM, Clifford Yapp <cliffyapp at gmail.com> wrote:
> One challenge we've experienced with CMake is properly controlling the
> installation path when using multi-config tools like Visual Studio or
> Xcode.  Since I'm in the middle of re-examining our more gnarly CMake
> logic anyway, I thought I'd raise this one and see if anybody knows of
> a good solution.
>
> The problem is as follows - for multi-config build tools, the build
> profile (Release, Debug, etc.) is selected at build time, not CMake
> configure time.  Consequently, if one wishes to change the
> CMAKE_INSTALL_PREFIX based on the current build configuration (our
> convention for default install paths is to use
> /parent_dirs/rel-<version> for release builds and
> /parent_dirs/dev-<version> for development builds) that change has to
> happen at build time.
>
> To the best of my knowledge there is no good way to do this in CMake
> currently.  The closest I could come when I tried originally was to
> insert a variable into the CMAKE_INSTALL_PREFIX path that evaluated to
> the current build configuration (IIRC) but that wasn't quite correct
> per our convention.  I finally settled on a rather scary trick where I
> created a custom build target that would manually rewrite all of the
> generated CMake build files (via running a CMake script) to use the
> desired path, and that build target becomes flagged for a re-run every
> time the build configuration in the build tool is changed.  In
> essence, I'm post processing the CMake generated build files.
>
> The "preferred" solution to this (I think) would be to have
> CMAKE_${CFG_TYPE}_INSTALL_PREFIX variables that could be set the same
> way the C/CXX flag variables have per-configuration versions.  That
> way the CMakeLists.txt file could simply specify the target install
> paths for each configuration and have then written directly to the
> appropriate output build files.  However, to the best of my knowledge
> there is no existing CMake feature that currently supports this.
>
> Has anyone else encountered the problem?  If not, would the devs
> consider adding a per-config CMAKE_INSTALL_PREFIX feature for the
> multi-config tools?
>
> Thanks,
> CY
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list