Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 即使check\u ipo\u supported()在CMake中起作用,也未设置过程间优化_Visual Studio_Cmake_Lto_Link Time Optimization - Fatal编程技术网

Visual studio 即使check\u ipo\u supported()在CMake中起作用,也未设置过程间优化

Visual studio 即使check\u ipo\u supported()在CMake中起作用,也未设置过程间优化,visual-studio,cmake,lto,link-time-optimization,Visual Studio,Cmake,Lto,Link Time Optimization,我在CMake 3.14.0中有一个项目,它为Visual Studio 2017 64位生成器构建了一个项目(最低版本为3.10.0,因为其他开发人员可以拥有CMake的早期版本,但高于3.9.0): 我添加了一些命令,用于在VisualStudio中添加对LTO的支持。我已经看到我必须检查对IPO的支持,如果可以的话,我必须设置过程间优化属性,这就是我所做的 当我运行项目时,我得到以下消息(我也在使用vcpkg,这就是第一行的原因): 就我所见,链接时间优化并没有为项目启用。我还在Visua

我在CMake 3.14.0中有一个项目,它为Visual Studio 2017 64位生成器构建了一个项目(最低版本为3.10.0,因为其他开发人员可以拥有CMake的早期版本,但高于3.9.0):

我添加了一些命令,用于在VisualStudio中添加对LTO的支持。我已经看到我必须检查对IPO的支持,如果可以的话,我必须设置
过程间优化
属性,这就是我所做的

当我运行项目时,我得到以下消息(我也在使用vcpkg,这就是第一行的原因):

就我所见,链接时间优化并没有为项目启用。我还在Visual Studio中打开了该项目,并检查了该项目的命令行,这是该建筑的结果:

/GS /TP /W3 /Zc:wchar_t /I"M:\project\src\Data\.." /Zi /Gm- /Od /Ob0 /Fd"data.dir\Debug\vc141.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_WINDOWS" /D "DATA_EXPORTS" /D "CMAKE_INTDIR=\"Debug\"" /D "data_EXPORTS" /D "_WINDLL" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /RTC1 /GR /Gd /MDd /std:c++17 /Fa"Debug/" /EHsc /nologo /Fo"data.dir\Debug\" /Fp"data.dir\Debug\data.pch" /diagnostics:classic
和链接

/OUT:"M:\project\build\vscode\build\bin\Debug\data.dll" /MANIFEST /NXCOMPAT /PDB:"M:/project/build/vscode/build/bin/Debug/data.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib" /IMPLIB:"M:/project/build/vscode/build/lib/Debug/data.lib" /DEBUG /DLL /MACHINE:X64 /INCREMENTAL /PGD:"M:\project\build\vscode\build\bin\Debug\data.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"data.dir\Debug\data.dll.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1 
我没有看到LTO的任何标志

我已经为策略运行了命令,结果如下:

cmake --help-policy CMP0069
CMP0069
-------

``INTERPROCEDURAL_OPTIMIZATION`` is enforced when enabled.

CMake 3.9 and newer prefer to add IPO flags whenever the
``INTERPROCEDURAL_OPTIMIZATION`` target property is enabled and
produce an error if flags are not known to CMake for the current compiler.
Since a given compiler may not support IPO flags in all environments in which
it is used, it is now the project's responsibility to use the
``CheckIPOSupported`` module to check for support before enabling the
``INTERPROCEDURAL_OPTIMIZATION`` target property.  This approach
allows a project to conditionally activate IPO when supported.  It also
allows an end user to set the ``CMAKE_INTERPROCEDURAL_OPTIMIZATION``
variable in an environment known to support IPO even if the project does
not enable the property.

Since CMake 3.8 and lower only honored ``INTERPROCEDURAL_OPTIMIZATION``
for the Intel compiler on Linux, some projects may unconditionally enable the
target property.  Policy ``CMP0069`` provides compatibility with such projects.

This policy takes effect whenever the IPO property is enabled.  The ``OLD``
behavior for this policy is to add IPO flags only for Intel compiler on Linux.
The ``NEW`` behavior for this policy is to add IPO flags for the current
compiler or produce an error if CMake does not know the flags.

This policy was introduced in CMake version 3.9.  CMake version
3.14.0 warns when the policy is not set and uses ``OLD`` behavior.
Use the ``cmake_policy()`` command to set it to ``OLD`` or ``NEW``
explicitly.

.. note::
  The ``OLD`` behavior of a policy is
  ``deprecated by definition``
  and may be removed in a future version of CMake.

Examples
^^^^^^^^

Behave like CMake 3.8 and do not apply any IPO flags except for Intel compiler
on Linux:

 cmake_minimum_required(VERSION 3.8)
 project(foo)

 # ...

 set_property(TARGET ... PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)

Use the ``CheckIPOSupported`` module to detect whether IPO is
supported by the current compiler, environment, and CMake version.
Produce a fatal error if support is not available:

 cmake_minimum_required(VERSION 3.9) # CMP0069 NEW
 project(foo)

 include(CheckIPOSupported)
 check_ipo_supported()

 # ...

 set_property(TARGET ... PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)

Apply IPO flags only if compiler supports it:

 cmake_minimum_required(VERSION 3.9) # CMP0069 NEW
 project(foo)

 include(CheckIPOSupported)

 # ...

 check_ipo_supported(RESULT result)
 if(result)
   set_property(TARGET ... PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
 endif()

Apply IPO flags without any checks.  This may lead to build errors if IPO
is not supported by the compiler in the current environment.  Produce an
error if CMake does not know IPO flags for the current compiler:

 cmake_minimum_required(VERSION 3.9) # CMP0069 NEW
 project(foo)

 # ...

 set_property(TARGET ... PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
看来我用得对

我不明白的是,如果命令
check\u ipo\u supported
告诉我另一个故事,为什么不应用该属性


我做错了什么?

奇怪的是,我在Linux(NixOS 19.03,GCC)上尝试了question中的代码,它对我很好。我相信您希望打印您当前正在吞咽的诊断信息。这可能有助于解决问题。(它帮助了我,我错过了C++编译器,而 CuthTypIoPux/<代码>默认检查C和C++的IPO都是工作的) 它来自

您需要设置策略: cmake_策略(设置CMP0069新) 设置(CMAKE\U策略\U默认\U CMP0069新)

/OUT:"M:\project\build\vscode\build\bin\Debug\data.dll" /MANIFEST /NXCOMPAT /PDB:"M:/project/build/vscode/build/bin/Debug/data.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib" /IMPLIB:"M:/project/build/vscode/build/lib/Debug/data.lib" /DEBUG /DLL /MACHINE:X64 /INCREMENTAL /PGD:"M:\project\build\vscode\build\bin\Debug\data.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"data.dir\Debug\data.dll.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1 
cmake --help-policy CMP0069
CMP0069
-------

``INTERPROCEDURAL_OPTIMIZATION`` is enforced when enabled.

CMake 3.9 and newer prefer to add IPO flags whenever the
``INTERPROCEDURAL_OPTIMIZATION`` target property is enabled and
produce an error if flags are not known to CMake for the current compiler.
Since a given compiler may not support IPO flags in all environments in which
it is used, it is now the project's responsibility to use the
``CheckIPOSupported`` module to check for support before enabling the
``INTERPROCEDURAL_OPTIMIZATION`` target property.  This approach
allows a project to conditionally activate IPO when supported.  It also
allows an end user to set the ``CMAKE_INTERPROCEDURAL_OPTIMIZATION``
variable in an environment known to support IPO even if the project does
not enable the property.

Since CMake 3.8 and lower only honored ``INTERPROCEDURAL_OPTIMIZATION``
for the Intel compiler on Linux, some projects may unconditionally enable the
target property.  Policy ``CMP0069`` provides compatibility with such projects.

This policy takes effect whenever the IPO property is enabled.  The ``OLD``
behavior for this policy is to add IPO flags only for Intel compiler on Linux.
The ``NEW`` behavior for this policy is to add IPO flags for the current
compiler or produce an error if CMake does not know the flags.

This policy was introduced in CMake version 3.9.  CMake version
3.14.0 warns when the policy is not set and uses ``OLD`` behavior.
Use the ``cmake_policy()`` command to set it to ``OLD`` or ``NEW``
explicitly.

.. note::
  The ``OLD`` behavior of a policy is
  ``deprecated by definition``
  and may be removed in a future version of CMake.

Examples
^^^^^^^^

Behave like CMake 3.8 and do not apply any IPO flags except for Intel compiler
on Linux:

 cmake_minimum_required(VERSION 3.8)
 project(foo)

 # ...

 set_property(TARGET ... PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)

Use the ``CheckIPOSupported`` module to detect whether IPO is
supported by the current compiler, environment, and CMake version.
Produce a fatal error if support is not available:

 cmake_minimum_required(VERSION 3.9) # CMP0069 NEW
 project(foo)

 include(CheckIPOSupported)
 check_ipo_supported()

 # ...

 set_property(TARGET ... PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)

Apply IPO flags only if compiler supports it:

 cmake_minimum_required(VERSION 3.9) # CMP0069 NEW
 project(foo)

 include(CheckIPOSupported)

 # ...

 check_ipo_supported(RESULT result)
 if(result)
   set_property(TARGET ... PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
 endif()

Apply IPO flags without any checks.  This may lead to build errors if IPO
is not supported by the compiler in the current environment.  Produce an
error if CMake does not know IPO flags for the current compiler:

 cmake_minimum_required(VERSION 3.9) # CMP0069 NEW
 project(foo)

 # ...

 set_property(TARGET ... PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
check_ipo_supported(RESULT result OUTPUT output)
if(result)
  set_property(TARGET foo PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
else()
  message(WARNING "IPO is not supported: ${output}")
endif()