summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorAlan Antonuk <alan.antonuk@gmail.com>2021-04-02 06:28:05 +0000
committerAlan Antonuk <alan.antonuk@gmail.com>2021-04-01 23:40:05 -0700
commit188d1be3e3498c5843b8f9fc439b828c64af57fd (patch)
tree7b9699e5a71248c9a06453220331b704ef5d2bdb /cmake
parentd5bbafae56ddcc3fcbef49b35271b7abab8c2621 (diff)
downloadrabbitmq-c-188d1be3e3498c5843b8f9fc439b828c64af57fd.tar.gz
cmake: use modern version of project() command
This also gets rid of a non-top-level project command that probably shouldn't be used. Signed-off-by: GitHub <noreply@github.com>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/VersionFunctions.cmake21
1 files changed, 21 insertions, 0 deletions
diff --git a/cmake/VersionFunctions.cmake b/cmake/VersionFunctions.cmake
new file mode 100644
index 0000000..27ec3a7
--- /dev/null
+++ b/cmake/VersionFunctions.cmake
@@ -0,0 +1,21 @@
+function(get_library_version VERSION_ARG)
+ file(STRINGS librabbitmq/amqp.h _API_VERSION_MAJOR REGEX "^#define AMQP_VERSION_MAJOR [0-9]+$")
+ file(STRINGS librabbitmq/amqp.h _API_VERSION_MINOR REGEX "^#define AMQP_VERSION_MINOR [0-9]+$")
+ file(STRINGS librabbitmq/amqp.h _API_VERSION_PATCH REGEX "^#define AMQP_VERSION_PATCH [0-9]+$")
+
+ string(REGEX MATCH "[0-9]+" _API_VERSION_MAJOR ${_API_VERSION_MAJOR})
+ string(REGEX MATCH "[0-9]+" _API_VERSION_MINOR ${_API_VERSION_MINOR})
+ string(REGEX MATCH "[0-9]+" _API_VERSION_PATCH ${_API_VERSION_PATCH})
+
+ # VERSION to match what is in autotools
+ set(${VERSION_ARG} ${_API_VERSION_MAJOR}.${_API_VERSION_MINOR}.${_API_VERSION_PATCH} PARENT_SCOPE)
+endfunction()
+
+function(compute_soversion CURRENT REVISION AGE VERSION SOVERSION)
+ math(EXPR MAJOR "${CURRENT} - ${AGE}")
+ math(EXPR MINOR "${AGE}")
+ math(EXPR PATCH "${REVISION}")
+
+ set(${VERSION} ${MAJOR}.${MINOR}.${PATCH} PARENT_SCOPE)
+ set(${SOVERSION} ${MAJOR} PARENT_SCOPE)
+endfunction() \ No newline at end of file