Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
glslang
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
glslang
Commits
05798c17
Commit
05798c17
authored
Feb 07, 2021
by
Evgeny Proydakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issues 2496. Used option 4: parse_version.cmake to avoid python3 usage.
https://github.com/KhronosGroup/glslang/issues/2496
parent
386b4fcb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
45 deletions
+66
-45
CMakeLists.txt
CMakeLists.txt
+14
-34
build_info.h.tmpl
build_info.h.tmpl
+4
-4
build_info.py
build_info.py
+7
-7
parse_version.cmake
parse_version.cmake
+41
-0
No files found.
CMakeLists.txt
View file @
05798c17
...
@@ -234,55 +234,33 @@ if(NOT COMMAND find_host_package)
...
@@ -234,55 +234,33 @@ if(NOT COMMAND find_host_package)
endmacro
()
endmacro
()
endif
()
endif
()
# CMake needs to find the right version of python, right from the beginning,
# otherwise, it will find the wrong version and fail later
find_host_package
(
PythonInterp 3 REQUIRED
)
# Root directory for build-time generated include files
# Root directory for build-time generated include files
set
(
GLSLANG_GENERATED_INCLUDEDIR
"
${
CMAKE_BINARY_DIR
}
/include"
)
set
(
GLSLANG_GENERATED_INCLUDEDIR
"
${
CMAKE_BINARY_DIR
}
/include"
)
################################################################################
################################################################################
# Build version information generation
# Build version information generation
################################################################################
################################################################################
include
(
parse_version.cmake
)
set
(
GLSLANG_CHANGES_FILE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/CHANGES.md"
)
set
(
GLSLANG_CHANGES_FILE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/CHANGES.md"
)
set
(
GLSLANG_BUILD_INFO_PY
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/build_info.py"
)
set
(
GLSLANG_BUILD_INFO_H_TMPL
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/build_info.h.tmpl"
)
set
(
GLSLANG_BUILD_INFO_H_TMPL
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/build_info.h.tmpl"
)
set
(
GLSLANG_BUILD_INFO_H
"
${
GLSLANG_GENERATED_INCLUDEDIR
}
/glslang/build_info.h"
)
set
(
GLSLANG_BUILD_INFO_H
"
${
GLSLANG_GENERATED_INCLUDEDIR
}
/glslang/build_info.h"
)
# Command to build the build_info.h file
parse_version
(
${
GLSLANG_CHANGES_FILE
}
GLSLANG
)
add_custom_command
(
OUTPUT
${
GLSLANG_BUILD_INFO_H
}
function
(
configurate_version
)
COMMAND
${
PYTHON_EXECUTABLE
}
"
${
GLSLANG_BUILD_INFO_PY
}
"
set
(
major
${
GLSLANG_VERSION_MAJOR
}
)
${
CMAKE_CURRENT_SOURCE_DIR
}
set
(
minor
${
GLSLANG_VERSION_MINOR
}
)
"-i"
${
GLSLANG_BUILD_INFO_H_TMPL
}
set
(
patch
${
GLSLANG_VERSION_PATCH
}
)
"-o"
${
GLSLANG_BUILD_INFO_H
}
set
(
flavor
${
GLSLANG_VERSION_FLAVOR
}
)
DEPENDS
${
GLSLANG_BUILD_INFO_PY
}
configure_file
(
${
GLSLANG_BUILD_INFO_H_TMPL
}
${
GLSLANG_BUILD_INFO_H
}
@ONLY
)
${
GLSLANG_CHANGES_FILE
}
endfunction
()
${
GLSLANG_BUILD_INFO_H_TMPL
}
COMMENT
"Generating
${
GLSLANG_BUILD_INFO_H
}
"
)
configurate_version
()
# Target to build the build_info.h file
add_custom_target
(
glslang-build-info DEPENDS
${
GLSLANG_BUILD_INFO_H
}
)
# Populate the CMake GLSLANG_VERSION* variables with the build version
# information.
execute_process
(
COMMAND
${
PYTHON_EXECUTABLE
}
"
${
GLSLANG_BUILD_INFO_PY
}
"
${
CMAKE_CURRENT_SOURCE_DIR
}
"<major>.<minor>.<patch><-flavor>;<major>;<minor>;<patch>;<flavor>"
OUTPUT_VARIABLE
"GLSLANG_VERSIONS"
OUTPUT_STRIP_TRAILING_WHITESPACE
)
list
(
GET
"GLSLANG_VERSIONS"
0
"GLSLANG_VERSION"
)
list
(
GET
"GLSLANG_VERSIONS"
1
"GLSLANG_VERSION_MAJOR"
)
list
(
GET
"GLSLANG_VERSIONS"
2
"GLSLANG_VERSION_MINOR"
)
list
(
GET
"GLSLANG_VERSIONS"
3
"GLSLANG_VERSION_PATCH"
)
list
(
GET
"GLSLANG_VERSIONS"
4
"GLSLANG_VERSION_FLAVOR"
)
configure_file
(
${
GLSLANG_CHANGES_FILE
}
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CHANGES.md"
)
# Required to re-run cmake on version change
# glslang_add_build_info_dependency() adds the glslang-build-info dependency and
# glslang_add_build_info_dependency() adds the glslang-build-info dependency and
# generated include directories to target.
# generated include directories to target.
function
(
glslang_add_build_info_dependency target
)
function
(
glslang_add_build_info_dependency target
)
target_include_directories
(
${
target
}
PUBLIC $<BUILD_INTERFACE:
${
GLSLANG_GENERATED_INCLUDEDIR
}
>
)
target_include_directories
(
${
target
}
PUBLIC $<BUILD_INTERFACE:
${
GLSLANG_GENERATED_INCLUDEDIR
}
>
)
add_dependencies
(
${
target
}
glslang-build-info
)
endfunction
()
endfunction
()
# glslang_only_export_explicit_symbols() makes the symbol visibility hidden by
# glslang_only_export_explicit_symbols() makes the symbol visibility hidden by
...
@@ -316,6 +294,8 @@ else()
...
@@ -316,6 +294,8 @@ else()
endif
()
endif
()
if
(
BUILD_EXTERNAL AND IS_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
/External
)
if
(
BUILD_EXTERNAL AND IS_DIRECTORY
${
CMAKE_CURRENT_SOURCE_DIR
}
/External
)
find_package
(
PythonInterp 3 REQUIRED
)
# We depend on these for later projects, so they should come first.
# We depend on these for later projects, so they should come first.
add_subdirectory
(
External
)
add_subdirectory
(
External
)
endif
()
endif
()
...
...
build_info.h.tmpl
View file @
05798c17
...
@@ -34,10 +34,10 @@
...
@@ -34,10 +34,10 @@
#ifndef GLSLANG_BUILD_INFO
#ifndef GLSLANG_BUILD_INFO
#define GLSLANG_BUILD_INFO
#define GLSLANG_BUILD_INFO
#define GLSLANG_VERSION_MAJOR
<major>
#define GLSLANG_VERSION_MAJOR
@major@
#define GLSLANG_VERSION_MINOR
<minor>
#define GLSLANG_VERSION_MINOR
@minor@
#define GLSLANG_VERSION_PATCH
<patch>
#define GLSLANG_VERSION_PATCH
@patch@
#define GLSLANG_VERSION_FLAVOR "
<flavor>
"
#define GLSLANG_VERSION_FLAVOR "
@flavor@
"
#define GLSLANG_VERSION_GREATER_THAN(major, minor, patch) \
#define GLSLANG_VERSION_GREATER_THAN(major, minor, patch) \
(((major) > GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \
(((major) > GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \
...
...
build_info.py
View file @
05798c17
...
@@ -201,13 +201,13 @@ def main():
...
@@ -201,13 +201,13 @@ def main():
software_version
=
deduce_software_version
(
directory
)
software_version
=
deduce_software_version
(
directory
)
commit
=
describe
(
directory
)
commit
=
describe
(
directory
)
output
=
template
\
output
=
template
\
.
replace
(
"
<major>
"
,
software_version
[
"major"
])
\
.
replace
(
"
@major@
"
,
software_version
[
"major"
])
\
.
replace
(
"
<minor>
"
,
software_version
[
"minor"
])
\
.
replace
(
"
@minor@
"
,
software_version
[
"minor"
])
\
.
replace
(
"
<patch>
"
,
software_version
[
"patch"
])
\
.
replace
(
"
@patch@
"
,
software_version
[
"patch"
])
\
.
replace
(
"
<flavor>
"
,
software_version
[
"flavor"
])
\
.
replace
(
"
@flavor@
"
,
software_version
[
"flavor"
])
\
.
replace
(
"
<-flavor>
"
,
software_version
[
"-flavor"
])
\
.
replace
(
"
@-flavor@
"
,
software_version
[
"-flavor"
])
\
.
replace
(
"
<date>
"
,
software_version
[
"date"
])
\
.
replace
(
"
@date@
"
,
software_version
[
"date"
])
\
.
replace
(
"
<commit>
"
,
commit
)
.
replace
(
"
@commit@
"
,
commit
)
if
output_file
is
None
:
if
output_file
is
None
:
print
(
output
)
print
(
output
)
...
...
parse_version.cmake
0 → 100644
View file @
05798c17
# Copyright 2020 The Marl Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# parse_version() reads and parses the version string from FILE, assigning the
# version string to ${PROJECT}_VERSION and the parsed version to
# ${PROJECT}_VERSION_MAJOR, ${PROJECT}_VERSION_MINOR, ${PROJECT}_VERSION_PATCH,
# and the optional ${PROJECT}_VERSION_FLAVOR.
#
# The version string take one of the forms:
# <major>.<minor>.<patch>
# <major>.<minor>.<patch>-<flavor>
function
(
parse_version FILE PROJECT
)
configure_file
(
${
FILE
}
"
${
CMAKE_CURRENT_BINARY_DIR
}
/CHANGES.md"
)
# Required to re-run cmake on version change
file
(
READ
${
FILE
}
CHANGES
)
if
(
${
CHANGES
}
MATCHES
"#+ *([0-9]+)
\\
.([0-9]+)
\\
.([0-9]+)(-[a-zA-Z0-9]+)?"
)
set
(
FLAVOR
""
)
if
(
NOT
"
${
CMAKE_MATCH_4
}
"
STREQUAL
""
)
string
(
SUBSTRING
${
CMAKE_MATCH_4
}
1 -1 FLAVOR
)
endif
()
set
(
"
${
PROJECT
}
_VERSION_MAJOR"
${
CMAKE_MATCH_1
}
PARENT_SCOPE
)
set
(
"
${
PROJECT
}
_VERSION_MINOR"
${
CMAKE_MATCH_2
}
PARENT_SCOPE
)
set
(
"
${
PROJECT
}
_VERSION_PATCH"
${
CMAKE_MATCH_3
}
PARENT_SCOPE
)
set
(
"
${
PROJECT
}
_VERSION_FLAVOR"
${
FLAVOR
}
PARENT_SCOPE
)
set
(
"
${
PROJECT
}
_VERSION"
"
${
CMAKE_MATCH_1
}
.
${
CMAKE_MATCH_2
}
.
${
CMAKE_MATCH_3
}${
CMAKE_MATCH_4
}
"
PARENT_SCOPE
)
else
()
message
(
FATAL_ERROR
"Unable to parse version from '
${
FILE
}
'"
)
endif
()
endfunction
()
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