[CMake] how to find current Windows build configuration?

Petr Kmoch petr.kmoch at gmail.com
Wed Oct 24 10:15:16 EDT 2012


Hi Kent.

As you say, there is no "current build type" in Visual Studio; that depends
on what the user selects in the combo box. If you only need this
information at build time, you can use the generator expression
$<CONFIGURATION> for this purpose. See the documentation of
add_custom_command(); I also believe genexes are undergoing a major
overhaul for the soon-to-be 2.8.10 release.

If you need the information before build time (i.e. at cmake time), you're
pretty much out of luck and you'll have to rework your logic somehow to
push the dependency to build time.

Petr

On Wed, Oct 24, 2012 at 3:57 PM, Kent Williams <nkwmailinglists at gmail.com>wrote:

> On platforms other than Windows, the build type is a single value
> stored in CMAKE_BUILD_TYPE, and can be accessed if you want your build
> to different things in Debug, Release, etc modes.
>
> On Windows with Visual Studio, there's a variable
> CMAKE_CONFIGURATION_TYPE that is a list of the builds that will be
> done.
>
> How do I recover the actual, current build type?
>
> The reason I need to do this: I need to import libraries built in an
> ExternalProject. On OS X or Linux, the libraries generated by the
> ExternalProject are in one predictable place.
> So I can do this:
>
> set(EP_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR}/${EP_NAME}-build/lib)
>
> On windows this will need to be
>
> # fictional variable WINDOWS_CURRENT_BUILD_TYPE giving current build type
> set(EP_LIB_DIR
> ${CMAKE_CURRENT_BINARY_DIR}/${EP_NAME}-build/${WINDOWS_CURRENT_BUILD_TYPE})
>
> Unfortunately, there's no such variable.  And, given how Visual Studio
> works, where you can have a build that actually builds any number of
> build_types at one go, I'm not sure how to handle this.
>
> One thought I had was to always build the External Project as Release
> on Windows; then the libraries are someplace predictable.
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20121024/0e037640/attachment.htm>


More information about the CMake mailing list