1include(helpers) 2 3tristate(IGRAPH_ENABLE_LTO "Enable link-time optimization" OFF) 4 5include(CheckIPOSupported) 6 7if(IGRAPH_ENABLE_LTO) 8 # this matches both ON and AUTO 9 check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_NOT_SUPPORTED_REASON) 10 if(IGRAPH_ENABLE_LTO STREQUAL "AUTO") 11 # autodetection 12 set(IGRAPH_ENABLE_LTO ${IPO_SUPPORTED}) 13 if(IPO_SUPPORTED) 14 set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) 15 endif() 16 elseif(IPO_SUPPORTED) 17 # user wanted LTO and the compiler supports it 18 set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE) 19 else() 20 # user wanted LTO and the compiler does not support it 21 message(FATAL_ERROR "Link-time optimization not supported on this compiler") 22 endif() 23endif() 24