PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, May 15, 2022

[FIXED] How to build CMake Debug version using different target name for executables?

 May 15, 2022     c++, cmake, ubuntu     No comments   

Issue

I am building using cmake -DCMAKE_BUILD_TYPE=Debug ..

And I am using set(CMAKE_DEBUG_POSTFIX d) to add a d to the end of the filename.

This is working for static libraries and I expected it to work for executables as well. But, at least in my case, it is compiling all the static libraries using *d.a and the executable without d suffix.

Am I missing something?


Solution

You are not missing anything. As the documentation says (emphasis mine):

When a non-executable target is created its <CONFIG>_POSTFIX target property is initialized with the value of this variable if it is set.

See: https://cmake.org/cmake/help/latest/variable/CMAKE_CONFIG_POSTFIX.html

By the sounds of it, though, you could manually set the property on your executable target with set_target_properties:

set_target_properties(
  target1 ... targetN
  PROPERTIES
  DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}"
)

Note, however, that it doesn't apply to executables by default because that's rarely what you want. For libraries, it's fairly common to package and deploy debug and release configurations simultaneously. On Windows, for development, it is a requirement. On the other hand, one very rarely needs to deploy debug applications and hence one very rarely wants a postfix applied.



Answered By - Alex Reinking
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing