set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELWITHDEBINFO " /LTCG /USEPROFILE:PGD=${ProfilePath}")
else(WIN32)
if(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
- if(HAVE_LTO)
- target_compile_options(${TargetName} PRIVATE -flto -fprofile-instr-use=${ProfilePath} -Wno-profile-instr-out-of-date)
- set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS " -flto -fuse-ld=gold -fprofile-instr-use=${ProfilePath}")
- endif(HAVE_LTO)
+ if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)
+ if(HAVE_LTO)
+ target_compile_options(${TargetName} PRIVATE -flto -fprofile-instr-use=${ProfilePath} -Wno-profile-instr-out-of-date)
+ set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS " -flto -fuse-ld=gold -fprofile-instr-use=${ProfilePath}")
+ else(HAVE_LTO)
+ message(WARNING "LTO is not supported, skipping profile guided optimizations")
+ endif(HAVE_LTO)
+ else(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)
+ message(WARNING "PGO is not supported; Clang 3.6 or later is required for profile guided optimizations")
+ endif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)
endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
endif(WIN32)
endif(EXISTS ${ProfilePath})