Here is recommended to pass CMAKE_BUILD_TYPE
as an argument to cmake when I want to obtain debug or release project builds. I'm trying to compile libharu with cmake and I would like to compile it with debug symbols. I've searched CMakeLists.txt included in libharu for following strings:
CMAKE_BUILD_TYPE
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_DEBUG
but I've found nothing. My question is that if it does make any sense to specify CMAKE_BUILD_TYPE
when libharu's CMakeLists.txt doesn't mention it? If not, how can I compile libharu with debug symbols?
PS: I've noticed that project that was generated for Visual Studio 2013 with cmake had set Debug/Win32, is this sufficient? Where in CMakeLists.txt is specified this info?
PPS: I guess this question is highly depending on particular project but is there some way to do this in general? I mean, does CMAKE_BUILD_TYPE=Debug
always create Debug build or is there something else that I should be aware of?
Thanks
Setting configuration type via
CMAKE_BUILD_TYPE
switches set of additional options for compiler to one, which normally reflects meaning of the configuration. That is, passingto
cmake
tells compiler to generate debugging information unless CMakeLists.txt modifies that behavior.Config-dependent compiler options are contained in variables
CMAKE_<LANG>_FLAGS_<CONFIG>
. For example, variableCMAKE_C_FLAGS_DEBUG
contains additional options for C compiler in "Debug" configuration. These variables are filled by CMake automatically, andCMakeLists.txt
itself rare modifies them.So, if you found that
CMakeLists.txt
doesn't play with variablesCMAKE_BUILD_TYPE
andCMAKE_<LANG>_FLAGS_<CONFIG>
, then it follows common conventions about configuration type.This doesn't mean that
CMakeLists.txt
shouldn't play with that variables.Often
CMakeLists.txt
setsCMAKE_BUILD_TYPE
to some default value, provided the variable is not set by the user and single-config generator is used.CMakeLists.txt
also may set some of variablesCMAKE_<LANG>_FLAGS_<CONFIG>
, if default setting for compiler is not suited for the project.But even if
CMakeLists.txt
does not touch these variables, they work.