Our project has a CMakeList.txt, but its not our primary build system. On Mac OS X, using Cmake generates a warning (nothing new here):
MACOSX_RPATH is not specified for the following targets...
The cited question/answer states to use either set(CMAKE_MACOSX_RPATH 0) or set(CMAKE_MACOSX_RPATH 1). Our problem is, the feature is too new and it breaks existing Cmake installations, like those found on Ubuntu LTS's or CentOS. We need to guard its use for Cmake >= 2.8.12, but the blog post does not discuss how to do it.
Searching is not producing useful results: how to guard cmake directive. My inability to find relevant results is probably due to my inexperience with Cmake (others were supposed to maintain it).
How do we guard set(CMAKE_MACOSX_RPATH 0) or set(CMAKE_MACOSX_RPATH 1)?
Please note, I'm not looking for cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR). The best I can tell it does not do a damn thing. From testing we know it does not reject target_include_directories even though target_include_directories does not meet minimum requirements and causes failures in down level clients like Ubuntu LTS's.
I think what I'm looking for is closer to a C preprocessor macro:
#define 2_8_12 ...
#if CMAKE_VERSION >= 2_8_12
set(CMAKE_MACOSX_RPATH 0)
#endif