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?
CodePudding user response:
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.