use cmake to generate pdb

我正在使用cmake编译leptonica1.78,在生成sln方案后,我使用了vs2017来生成.dll动态链接库,
当用实用工具cppan-d-b-d来生成pvt.cppan.demo.jpeg-9.2.0.dll等依赖时,并没有生成pdb文件,由于配置属性是utility,在vs2017中无法更改设置。
我想请教一下cmake中有没有指令可以配置utility生成pdb文件。
目前尝试过的指令是 “set(CMAKE_CXX_FLAGS_RELEASE “${CMAKE_CXX_FLAGS_RELEASE} /Zi”)
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE “${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF”)”
但是我不知道将这个指令放在什么位置。
谢谢你。

Thanks. Note that this is largely an English-speaking forum and other languages are a best-effort and depends on who is available.

In the interest of at least getting something, here is Google Translate’s take:

I think putting those set commands in the top-level scope should be sufficient. Is there a reason that using the RelWithDebInfo build type is not suitable?

I always make sure to build a PDB because than otherwise visual studio’s profiling capabilities are limited. Now that stripped PDBs exist I don’t really see a reason to not create a PDB by default even for release builds.

So I have the following code before I define any targets.

    # Debug Information Format
    #
    # This is only really necessary for the Release configuration
    #
    # Explanation: Without this flag you won't get good profiling information in Release builds
    #
    # Use of /Zi doesn't affect optimizations
    #
    # Because we have a stripped PDB that we release to the public we should always specify this option
    # for our internal PDBs
    add_compile_option("/Zi")

That sounds like a feature request to CMake to change its default flags to me.

I don’t think the intent of this post is asking for cmake to change anything. Just how to always generate the PDB. I just gave an explanation of my workflow, to try and guess a similar intent.

Usually after the sln file is generated, we use vs to generate the dll and lib files. What I mean is that the configuration type of the project I compiled is a utility, and it is impossible to set and generate a pdb file in VS. Therefore, I would like to ask whether my goal can be achieved through cmake commands.
So far, I have searched the Internet and tried the following commands:
set(CMAKE_CXX_FLAGS_RELEASE “${CMAKE_CXX_FLAGS_RELEASE} /Zi”)
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE “${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF”)
But I don’t know where this command should be placed in which cmakelists, and whether it will really work.Thank you for your help.

Sorry for not using English, I will correct it

Placing it in the top-level CMakeLists.txt should be sufficient.