-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build target to check if cmake-init template is up-to-date
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
# | ||
# Get cmake-init latest commit SHA on master | ||
# | ||
|
||
file(DOWNLOAD | ||
"https://api.github.com/repos/cginternals/cmake-init/commits/master" | ||
"${PROJECT_BINARY_DIR}/cmake-init.github.data" | ||
) | ||
file(READ | ||
"${PROJECT_BINARY_DIR}/cmake-init.github.data" | ||
CMAKE_INIT_INFO | ||
) | ||
|
||
string(REGEX MATCH | ||
"\"sha\": \"([0-9a-f]+)\"," | ||
CMAKE_INIT_SHA | ||
${CMAKE_INIT_INFO}) | ||
|
||
string(SUBSTRING | ||
${CMAKE_INIT_SHA} | ||
8 | ||
40 | ||
CMAKE_INIT_SHA | ||
) | ||
|
||
# | ||
# Get latest cmake-init commit on this repository | ||
# | ||
|
||
# APPLIED_CMAKE_INIT_SHA can be set by parent script | ||
if(NOT APPLIED_CMAKE_INIT_SHA) | ||
# [TODO]: Get from git commit list (see cmake_init/source/scripts/check_template.sh) | ||
set(APPLIED_CMAKE_INIT_SHA "") | ||
endif () | ||
|
||
if("${APPLIED_CMAKE_INIT_SHA}" STREQUAL "") | ||
message(WARNING | ||
"No cmake-init version detected, could not verify up-to-dateness. " | ||
"Set the cmake-init version by defining a META_CMAKE_INIT_SHA for your project." | ||
) | ||
return() | ||
endif() | ||
|
||
if(${APPLIED_CMAKE_INIT_SHA} STREQUAL ${CMAKE_INIT_SHA}) | ||
message(STATUS "cmake-init template is up-to-date (${CMAKE_INIT_SHA})") | ||
else() | ||
message(STATUS "cmake-init template needs an update https://github.com/cginternals/cmake-init/compare/${APPLIED_CMAKE_INIT_SHA}...master") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
# | ||
# Add project health scripts as cmake targets | ||
# | ||
|
||
add_custom_target( | ||
check-template | ||
COMMAND ${CMAKE_COMMAND} | ||
-DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} | ||
-DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR} | ||
-DAPPLIED_CMAKE_INIT_SHA=${META_CMAKE_INIT_SHA} | ||
-P ${PROJECT_SOURCE_DIR}/cmake/CheckTemplate.cmake | ||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
) |