[CMake] explain usage of CMAKE_CONFIGURATION_TYPES

hex hex7c3 at gmail.com
Tue Jan 22 15:53:52 EST 2019


> good afternoon,
>
> I am following the CMake book to learn about CMake. I have trouble to 
> follow chapter 3: build configurations 
> (https://riptutorial.com/cmake/example/26702/setting-a-release-debug-configuration)
>
> In this part it is not very clear why these configurations are used, 
> and how they work.
>
> here is the script in cmake:
>
> *CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)**
> **SET(PROJ_NAME "myproject")**
> **PROJECT(${PROJ_NAME})**
> **
> *# Configuration types*
> **SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" 
> FORCE)**
> **IF(DEFINED CMAKE_BUILD_TYPE AND CMAKE_VERSION VERSION_GREATER "2.8")**
> **  SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 
> ${CMAKE_CONFIGURATION_TYPES})**
> **ENDIF()**
> **
> **SET(${PROJ_NAME}_PATH_INSTALL "/opt/project"                     
> CACHE PATH "This directory contains installation Path")**
> **SET(CMAKE_DEBUG_POSTFIX "d")**
> *
> # Install
> #---------------------------------------------------#*
> **INSTALL(TARGETS ${PROJ_NAME}**
> **    DESTINATION 
> "${${PROJ_NAME}_PATH_INSTALL}/lib/${CMAKE_BUILD_TYPE}/"**
> **    )**
> *
>
> So, instead of building the project relative to my project folder, it 
> installs into "/opt/" directory in linux. Why would I want/prefere to 
> do that? And what if I am working with Windows, instead?
>
> Since the application is build in "/opt/" it suggests that cmake in 
> above example functions similar to an software installer.
>
>
> The documentation on cmake.org states that CMAKE_CONFIGURATION_TYPES 
> specifies multiple build types (Debug, Release, Test, etc), which is 
> ultimately what I am interested in.
>
> I suppose I am also able to use this concept if I want relative path 
> for debug/release directories like in Eclipse?
>
>
> thank you!
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190122/c4796c7a/attachment.html>


More information about the CMake mailing list