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
812d2db1
Commit
812d2db1
authored
3 years ago
by
Lars Bilke
Browse files
Options
Downloads
Patches
Plain Diff
[cmake] Added module BuildExternalProject.
https://github.com/Sbte/BuildExternalProject/commit/ce1a70996aa538aac17a6faf07db487c3a238838
parent
2ae4ff74
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/cmake/BuildExternalProject.cmake
+87
-0
87 additions, 0 deletions
scripts/cmake/BuildExternalProject.cmake
with
87 additions
and
0 deletions
scripts/cmake/BuildExternalProject.cmake
0 → 100644
+
87
−
0
View file @
812d2db1
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
}
)
message
(
STATUS
"Building
${
target
}
"
)
file
(
MAKE_DIRECTORY
${
build_dir
}
)
set
(
CMAKE_LIST_CONTENT
"
cmake_minimum_required(VERSION 2.8.2)
include(ExternalProject)
ExternalProject_add(
${
target
}
PREFIX
${
build_dir
}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
LOG_DOWNLOAD ON
LOG_UPDATE ON
LOG_CONFIGURE ON
LOG_BUILD ON
LOG_TEST ON
LOG_INSTALL ON
${
ARGN
}
)
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
}
)
endif
()
else
()
file
(
WRITE
${
build_dir
}
/CMakeLists.txt
"
${
CMAKE_LIST_CONTENT
}
"
)
BuildExternalProject_configure
(
${
build_dir
}
)
endif
()
BuildExternalProject_build
(
${
build_dir
}
)
message
(
STATUS
"Finished building
${
target
}
"
)
endfunction
()
function
(
BuildExternalProject_configure build_dir
)
execute_process
(
COMMAND
${
CMAKE_COMMAND
}
-G
"
${
CMAKE_GENERATOR
}
"
.
RESULT_VARIABLE result
WORKING_DIRECTORY
${
build_dir
}
OUTPUT_QUIET
)
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
)
if
(
result
)
message
(
FATAL_ERROR
"Build step for external project failed:
${
result
}
"
)
endif
()
endfunction
()
\ No newline at end of file
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