[CMake] Allow version overrides with -DLLDB_VERSION_MAJOR/MINOR/PATCH/SUFFIX

Summary:
This follows the approach in Clang. If no overrides are given, LLDB_VERSION_* is inferred from LLVM_VERSION_*. This mimics the current behaviour (PACKAGE_VERSION itself is generated from LLVM_VERSION_*).
For in-tree builds LLVM_VERSION_* will be defined at this point already. For standalone builds, LLDBConfig.cmake is included after LLDBStandalone.cmake which includes LLVMConfig.cmake.

Reviewers: labath, xiaobai

Subscribers: mgorny, friss, aprantl, lldb-commits

Differential Revision: https://reviews.llvm.org/D54333

llvm-svn: 346668
This commit is contained in:
Stefan Granitz 2018-11-12 16:22:28 +00:00
parent 73ee35eefc
commit de62b76c51
2 changed files with 15 additions and 4 deletions

View File

@ -56,7 +56,7 @@ if(LLDB_BUILD_FRAMEWORK)
# the framework, and must be defined before building liblldb.
set(PRODUCT_NAME "LLDB")
set(EXECUTABLE_NAME "LLDB")
set(CURRENT_PROJECT_VERSION "360.99.0")
set(CURRENT_PROJECT_VERSION "${LLDB_VERSION}")
set(LLDB_SUITE_TARGET lldb-framework)
set(LLDB_FRAMEWORK_DIR

View File

@ -265,9 +265,20 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
"`CMakeFiles'. Please delete them.")
endif()
# Compute the LLDB version from the LLVM version.
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" LLDB_VERSION
${PACKAGE_VERSION})
# If LLDB_VERSION_* is specified, use it, if not use LLVM_VERSION_*.
if(NOT DEFINED LLDB_VERSION_MAJOR)
set(LLDB_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
endif()
if(NOT DEFINED LLDB_VERSION_MINOR)
set(LLDB_VERSION_MINOR ${LLVM_VERSION_MINOR})
endif()
if(NOT DEFINED LLDB_VERSION_PATCH)
set(LLDB_VERSION_PATCH ${LLVM_VERSION_PATCH})
endif()
if(NOT DEFINED LLDB_VERSION_SUFFIX)
set(LLDB_VERSION_SUFFIX ${LLVM_VERSION_SUFFIX})
endif()
set(LLDB_VERSION "${LLDB_VERSION_MAJOR}.${LLDB_VERSION_MINOR}.${LLDB_VERSION_PATCH}${LLDB_VERSION_SUFFIX}")
message(STATUS "LLDB version: ${LLDB_VERSION}")
include_directories(BEFORE