|
1 | 1 | include_guard() |
2 | 2 |
|
3 | 3 | macro(enable_interprocedural_optimization project_name) |
4 | | - if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18.0") |
5 | | - if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") |
6 | | - include(CheckIPOSupported) |
7 | | - check_ipo_supported(RESULT result OUTPUT output) |
8 | | - is_mingw(_is_mingw) |
9 | | - if(result AND NOT ${_is_mingw}) |
10 | | - # If a static library of this project is used in another project that does not have `CMAKE_INTERPROCEDURAL_OPTIMIZATION` enabled, a linker error might happen. |
11 | | - # TODO set this option in `package_project` function. |
12 | | - message( |
13 | | - STATUS |
14 | | - "Interprocedural optimization is enabled. In other projects, linking with the compiled libraries of this project might require `set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)`" |
15 | | - ) |
16 | | - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) |
17 | | - set_target_properties(${project_name} PROPERTIES INTERPROCEDURAL_OPTIMIZATION ON) |
18 | | - else() |
19 | | - message(WARNING "Interprocedural Optimization is not supported. Not using it. Here is the error log: ${output}") |
20 | | - endif() |
| 4 | + if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") |
| 5 | + include(CheckIPOSupported) |
| 6 | + check_ipo_supported(RESULT result OUTPUT output) |
| 7 | + is_mingw(_is_mingw) |
| 8 | + if(result AND NOT ${_is_mingw}) |
| 9 | + # If a static library of this project is used in another project that does not have `CMAKE_INTERPROCEDURAL_OPTIMIZATION` enabled, a linker error might happen. |
| 10 | + # TODO set this option in `package_project` function. |
| 11 | + message( |
| 12 | + STATUS |
| 13 | + "Interprocedural optimization is enabled. In other projects, linking with the compiled libraries of this project might require `set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)`" |
| 14 | + ) |
| 15 | + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) |
| 16 | + set_target_properties(${project_name} PROPERTIES INTERPROCEDURAL_OPTIMIZATION ON) |
| 17 | + else() |
| 18 | + message(WARNING "Interprocedural Optimization is not supported. Not using it. Here is the error log: ${output}") |
21 | 19 | endif() |
22 | | - else() |
23 | | - message( |
24 | | - WARNING |
25 | | - "Consider upgrading CMake to the latest version. CMake ${CMAKE_VERSION} does not support ENABLE_INTERPROCEDURAL_OPTIMIZATION." |
26 | | - ) |
27 | 20 | endif() |
28 | 21 | endmacro() |
29 | 22 |
|
|
0 commit comments