Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Özgür Ozan Sen
ogs
Commits
988b1156
Commit
988b1156
authored
3 years ago
by
Lars Bilke
Browse files
Options
Downloads
Patches
Plain Diff
[cmake] Modified BuildExternalProject.
parent
812d2db1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.pre-commit-config.yaml
+1
-1
1 addition, 1 deletion
.pre-commit-config.yaml
scripts/cmake/BuildExternalProject.cmake
+62
-54
62 additions, 54 deletions
scripts/cmake/BuildExternalProject.cmake
with
63 additions
and
55 deletions
.pre-commit-config.yaml
+
1
−
1
View file @
988b1156
...
...
@@ -45,4 +45,4 @@ repos:
exclude
:
'
scripts/cmake/jedbrown/.*|PackagingMacros.cmake|conan.cmake|CPM.cmake|FindFilesystem.cmake|ConanSetup.cmake|Tests.cmake'
-
id
:
cmake-lint
additional_dependencies
:
[
"
cmakelang[YAML]"
]
exclude
:
'
scripts/cmake/jedbrown/.*|PackagingMacros.cmake|conan.cmake|CPM.cmake|FindFilesystem.cmake|ConanSetup.cmake'
exclude
:
'
scripts/cmake/jedbrown/.*|PackagingMacros.cmake|conan.cmake|CPM.cmake|FindFilesystem.cmake|ConanSetup.cmake
|BuildExternalProject.cmake
'
This diff is collapsed.
Click to expand it.
scripts/cmake/BuildExternalProject.cmake
+
62
−
54
View file @
988b1156
macro
(
BuildExternalProject_find_package target
)
set
(
build_dir
${
CMAKE_BINARY_DIR
}
/external/build_
${
target
}
)
# Set CMake prefix path so we can look there for the module
set
(
_CMAKE_PREFIX_PATH
${
CMAKE_PREFIX_PATH
}
)
mark_as_advanced
(
_CMAKE_PREFIX_PATH
)
list
(
APPEND CMAKE_PREFIX_PATH
${
build_dir
}
)
find_package
(
${
target
}
MODULE QUIET
)
if
(
NOT
${
target
}
_FOUND
)
# Look for config version if there was no module
find_package
(
${
target
}
CONFIG REQUIRED HINTS
${
build_dir
}
NO_DEFAULT_PATH
)
endif
()
# Set CMake prefix path back to what it was
set
(
CMAKE_PREFIX_PATH
${
_CMAKE_PREFIX_PATH
}
)
unset
(
_CMAKE_PREFIX_PATH
)
# Modified from
# https://github.com/Sbte/BuildExternalProject/commit/ce1a70996aa538aac17a6faf07db487c3a238838
macro
(
BuildExternalProject_find_package target
)
set
(
build_dir
${
CMAKE_BINARY_DIR
}
/external/build_
${
target
}
)
# Set CMake prefix path so we can look there for the module
set
(
_CMAKE_PREFIX_PATH
${
CMAKE_PREFIX_PATH
}
)
mark_as_advanced
(
_CMAKE_PREFIX_PATH
)
list
(
APPEND CMAKE_PREFIX_PATH
${
build_dir
}
)
find_package
(
${
target
}
MODULE QUIET
)
if
(
NOT
${
target
}
_FOUND
)
# Look for config version if there was no module
find_package
(
${
target
}
CONFIG REQUIRED HINTS
${
build_dir
}
NO_DEFAULT_PATH
)
endif
()
# Set CMake prefix path back to what it was
set
(
CMAKE_PREFIX_PATH
${
_CMAKE_PREFIX_PATH
}
)
unset
(
_CMAKE_PREFIX_PATH
)
endmacro
()
function
(
BuildExternalProject target
)
set
(
build_dir
${
CMAKE_BINARY_DIR
}
/external/build_
${
target
}
)
function
(
BuildExternalProject target
)
set
(
build_dir
${
CMAKE_BINARY_DIR
}
/external/build_
${
target
}
)
message
(
STATUS
"Building
${
target
}
"
)
message
(
STATUS
"Building
${
target
}
"
)
file
(
MAKE_DIRECTORY
${
build_dir
}
)
file
(
MAKE_DIRECTORY
${
build_dir
}
)
set
(
CMAKE_LIST_CONTENT
"
cmake_minimum_required(VERSION 2.8.2)
set
(
CMAKE_LIST_CONTENT
"
cmake_minimum_required(VERSION
${
CMAKE_MINIMUM_REQUIRED_VERSION
}
)
project(externalproject_
${
target
}
)
include(ExternalProject)
ExternalProject_add(
${
target
}
...
...
@@ -42,46 +48,48 @@ function (BuildExternalProject target)
add_custom_target(build_
${
target
}
)
add_dependencies(build_
${
target
}
${
target
}
)
"
)
if
(
EXISTS
${
build_dir
}
/CMakeLists.txt
)
file
(
SHA256
${
build_dir
}
/CMakeLists.txt file_sha
)
string
(
SHA256 new_sha
"
${
CMAKE_LIST_CONTENT
}
"
)
"
)
if
(
NOT file_sha STREQUAL new_sha
)
file
(
WRITE
${
build_dir
}
/CMakeLists.txt
"
${
CMAKE_LIST_CONTENT
}
"
)
BuildExternalProject_configure
(
${
build_dir
}
)
if
(
EXISTS
${
build_dir
}
/CMakeLists.txt
)
file
(
SHA256
${
build_dir
}
/CMakeLists.txt file_sha
)
string
(
SHA256 new_sha
"
${
CMAKE_LIST_CONTENT
}
"
)
if
(
NOT file_sha STREQUAL new_sha
)
file
(
WRITE
${
build_dir
}
/CMakeLists.txt
"
${
CMAKE_LIST_CONTENT
}
"
)
BuildExternalProject_configure
(
${
build_dir
}
)
endif
()
else
()
file
(
WRITE
${
build_dir
}
/CMakeLists.txt
"
${
CMAKE_LIST_CONTENT
}
"
)
BuildExternalProject_configure
(
${
build_dir
}
)
endif
()
else
()
file
(
WRITE
${
build_dir
}
/CMakeLists.txt
"
${
CMAKE_LIST_CONTENT
}
"
)
BuildExternalProject_configure
(
${
build_dir
}
)
endif
()
BuildExternalProject_build
(
${
build_dir
}
)
BuildExternalProject_build
(
${
build_dir
}
)
message
(
STATUS
"Finished building
${
target
}
"
)
message
(
STATUS
"Finished building
${
target
}
. Logs in
${
build_dir
}
/src/
${
target
}
-stamp"
)
endfunction
()
function
(
BuildExternalProject_configure build_dir
)
execute_process
(
COMMAND
${
CMAKE_COMMAND
}
-G
"
${
CMAKE_GENERATOR
}
"
.
RESULT_VARIABLE result
WORKING_DIRECTORY
${
build_dir
}
OUTPUT_QUIET
function
(
BuildExternalProject_configure build_dir
)
execute_process
(
COMMAND
${
CMAKE_COMMAND
}
-G
"
${
CMAKE_GENERATOR
}
"
.
RESULT_VARIABLE result WORKING_DIRECTORY
${
build_dir
}
)
if
(
result
)
message
(
FATAL_ERROR
"CMake step for external project failed:
${
result
}
"
)
endif
()
if
(
result
)
message
(
FATAL_ERROR
"CMake step for external project failed:
${
result
}
"
)
endif
()
endfunction
()
function
(
BuildExternalProject_build build_dir
)
execute_process
(
COMMAND
${
CMAKE_COMMAND
}
--build .
RESULT_VARIABLE result
WORKING_DIRECTORY
${
build_dir
}
OUTPUT_QUIET
function
(
BuildExternalProject_build build_dir
)
execute_process
(
COMMAND
${
CMAKE_COMMAND
}
--build . RESULT_VARIABLE result
WORKING_DIRECTORY
${
build_dir
}
)
if
(
result
)
message
(
FATAL_ERROR
"Build step for external project failed:
${
result
}
"
)
endif
()
endfunction
()
\ No newline at end of file
if
(
result
)
message
(
FATAL_ERROR
"Build step for external project failed:
${
result
}
"
)
endif
()
endfunction
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment