Can I get cmake to generate debugging characters?

I want cmake to generate characters in their releases.

I know that I can generate RelWithDebInfo assemblies and get characters in them, but I need characters in Release assemblies. I never need an assembly that has no characters.

Can I do it?

+4
source share
2 answers

To increase @doqtor's correct answer, you have several options. Or install on a global scale that applies these flags to all assembly types: CMAKE_CXX_FLAGS

if(MSVC)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi")
else()
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
endif()

or for finer-grained control, use along with the generator expression to apply flags for each target: target_compile_options

target_compile_options(example_target PRIVATE
    $<$<CXX_COMPILER_ID:MSVC>:/Zi>
    $<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-g>
    )

CMake 3.2.2, CMake, " ". , - , , CMake.

, , ; MSVC Z7, Zi Zi - ?

+10

, , , 2 , , ... ( , , gcc):

SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")

, , , , .

+3

All Articles