[CMake] Support overriding CLANG_VERSION_*
authorChris Bieneman <beanz@apple.com>
Tue, 20 Sep 2016 19:09:21 +0000 (19:09 +0000)
committerChris Bieneman <beanz@apple.com>
Tue, 20 Sep 2016 19:09:21 +0000 (19:09 +0000)
As with how we handle LLVM_VERSION_* variables we should support
overriding clang version variables.

llvm-svn: 282003

clang/CMakeLists.txt

index afdcdde..7efef3c 100644 (file)
@@ -261,10 +261,16 @@ if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
   endif()
 endif()
 
-# Compute the Clang version from the LLVM version.
-set(CLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
-set(CLANG_VERSION_MINOR ${LLVM_VERSION_MINOR})
-set(CLANG_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH})
+# If CLANG_VERSION_* is specified, use it, if not use LLVM_VERSION_*.
+if(NOT DEFINED CLANG_VERSION_MAJOR)
+  set(CLANG_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
+endif()
+if(NOT DEFINED CLANG_VERSION_MINOR)
+  set(CLANG_VERSION_MINOR ${LLVM_VERSION_MINOR})
+endif()
+if(NOT DEFINED CLANG_VERSION_PATCHLEVEL)
+  set(CLANG_VERSION_PATCHLEVEL ${LLVM_VERSION_PATCH})
+endif()
 # Unlike PACKAGE_VERSION, CLANG_VERSION does not include LLVM_VERSION_SUFFIX.
 set(CLANG_VERSION "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}.${CLANG_VERSION_PATCHLEVEL}")
 message(STATUS "Clang version: ${CLANG_VERSION}")