Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
743ec448
Commit
743ec448
authored
Jul 31, 2015
by
Konstantin Podsvirov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parsing version from configure.ac for CMake project
parent
82983433
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
15 deletions
+24
-15
CMakeLists.txt
cmake/CMakeLists.txt
+22
-15
protobuf-config.cmake.in
cmake/protobuf-config.cmake.in
+2
-0
No files found.
cmake/CMakeLists.txt
View file @
743ec448
...
...
@@ -11,24 +11,31 @@ if (MSVC)
option
(
ZLIB
"Build with zlib support"
OFF
)
endif
(
MSVC
)
# Path to
common header
set
(
protobuf_CO
MMON_HEADER
"../src/google/protobuf/stubs/common.h
"
)
# Path to
main configure script
set
(
protobuf_CO
NFIGURE_SCRIPT
"../configure.ac
"
)
# Parse version from co
mmon header
file
(
STRINGS
"
${
protobuf_CO
MMON_HEADER
}
"
protobuf_VERSION_LINE
# Parse version from co
nfigure script
file
(
STRINGS
"
${
protobuf_CO
NFIGURE_SCRIPT
}
"
protobuf_VERSION_LINE
LIMIT_COUNT 1
REGEX
"^#define GOOGLE_PROTOBUF_VERSION [0-9]+$"
)
string
(
REGEX REPLACE
"^.*PROTOBUF_VERSION ([0-9]+).*$"
"
\\
1"
protobuf_VERSION_NUMBER
"
${
protobuf_VERSION_LINE
}
"
)
math
(
EXPR protobuf_VERSION_MICRO
"
${
protobuf_VERSION_NUMBER
}
% 1000"
)
math
(
EXPR protobuf_VERSION_MINOR
"(
${
protobuf_VERSION_NUMBER
}
-
${
protobuf_VERSION_MICRO
}
) % 1000000 / 1000"
)
math
(
EXPR protobuf_VERSION_MAJOR
"(
${
protobuf_VERSION_NUMBER
}
-
${
protobuf_VERSION_MINOR
}
* 1000 -
${
protobuf_VERSION_MICRO
}
) % 1000000000 / 1000000"
)
set
(
protobuf_VERSION_PATCH
${
protobuf_VERSION_MICRO
}
)
REGEX
"^AC_INIT"
)
# Replace special characters
string
(
REPLACE
"("
"_"
protobuf_VERSION_LINE
${
protobuf_VERSION_LINE
}
)
string
(
REPLACE
")"
"_"
protobuf_VERSION_LINE
${
protobuf_VERSION_LINE
}
)
string
(
REPLACE
"["
"_"
protobuf_VERSION_LINE
${
protobuf_VERSION_LINE
}
)
string
(
REPLACE
"]"
"_"
protobuf_VERSION_LINE
${
protobuf_VERSION_LINE
}
)
# Parse version string
string
(
REGEX REPLACE
"^AC_INIT__Protocol Buffers_,_([^_]+).*$"
"
\\
1"
protobuf_VERSION_STRING
"
${
protobuf_VERSION_LINE
}
"
)
# Parse version tweaks
string
(
REGEX REPLACE
"^([0-9]+)
\\
.([0-9]+)
\\
.([0-9]+).*$"
"
\\
1"
protobuf_VERSION_MAJOR
"
${
protobuf_VERSION_STRING
}
"
)
string
(
REGEX REPLACE
"^([0-9]+)
\\
.([0-9]+)
\\
.([0-9]+).*$"
"
\\
2"
protobuf_VERSION_MINOR
"
${
protobuf_VERSION_STRING
}
"
)
string
(
REGEX REPLACE
"^([0-9]+)
\\
.([0-9]+)
\\
.([0-9]+).*$"
"
\\
3"
protobuf_VERSION_PATCH
"
${
protobuf_VERSION_STRING
}
"
)
# Package version
set
(
protobuf_VERSION
"
${
protobuf_VERSION_MAJOR
}
.
${
protobuf_VERSION_MINOR
}
.
${
protobuf_VERSION_
MICRO
}
"
)
"
${
protobuf_VERSION_MAJOR
}
.
${
protobuf_VERSION_MINOR
}
.
${
protobuf_VERSION_
PATCH
}
"
)
add_definitions
(
-DGOOGLE_PROTOBUF_CMAKE_BUILD
)
...
...
cmake/protobuf-config.cmake.in
View file @
743ec448
set(protobuf_VERSION_STRING "@protobuf_VERSION_STRING@")
include("${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake")
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment