the evil cmake -- gnu makefiles Debug Release adding post-fix

来源:互联网 发布:js modem 电话 编辑:程序博客网 时间:2024/05/21 09:15

summarize: this text discuss how to manage CMake project on building GNU makefile such as Debug and Release build, and how to add postfix on final targets.

whenever you CMakeLists.txt file is done in your project directory, use the cmake command with option -D and set the CMAKE_BUILD_TYPE to Debug, which create a debug version of makefile build, and set to Release will create a release version build, and so on. but you must create your makefile profiles on a standalone directory  respectively for every build target, this means that you can't create a Debug version profiles and a Release profiles under the same build directory, you should always create your Debug build directory for your Debug version profiles, and create your Release build directory for you Relese version profiles. for example, to make your Debug version build profiles, you first create a new folder under your work directory such as makefile_debug

and then use the cd command step into the makefile_debug folder

under the directory, type the command(for windows mingw):


cmake .. -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Debug

then under the makefile_debug folder, cmake will create a debug version of build profiles for you, and you can build your project by using:

make

which will use the gnu makefiles system to build the Debug target for you, that's it.

if you want to add post-fix on your final target files, try used the command:

SET(CMAKE_DEBUG_POSTFIX "_d")

which will add an '_d' post-fix to your target output file.

原创粉丝点击