Skip to content

Commit

Permalink
CHANGE: modules are searched for a branch names as the omegalib branch.
Browse files Browse the repository at this point in the history
during configuration branches are switched so all modules se the same branch
as the omegalib core if available (i.e. release branches of modules are used for
release builds)
  • Loading branch information
febret committed May 31, 2015
1 parent 91986c7 commit afddd6e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 33 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ endif(COMMAND cmake_policy)

message("CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")

# Fin the current branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

#-------------------------------------------------------------------------------
# Create a build name depending on the OS, Toolset and architecture.
if(CMAKE_GENERATOR STREQUAL "Visual Studio 9 2008")
Expand Down Expand Up @@ -166,7 +174,7 @@ else()
set(OMEGALIB_VERSION ${OMEGALIB_VERSION_MAJOR}.${OMEGALIB_VERSION_MINOR})
endif()

message("Omegalib version identified: ${OMEGALIB_VERSION}")
message("Omegalib version identified: ${OMEGALIB_VERSION} - ${GIT_BRANCH}")
# Add subdirectiories
add_subdirectory(src)

Expand Down
40 changes: 8 additions & 32 deletions CMakeModules/ModuleUtils.cmake
Original file line number Diff line number Diff line change
@@ -1,39 +1,15 @@
#-------------------------------------------------------------------------------
function(select_module_version MODULE_VERSION DIR MODULE_NAME)
string(REPLACE "X" ${MODULE_VERSION} MODULE_VERSION "vX")
#message("Fetching and setting version for ${MODULE_NAME}")
# fetch to make sure tags are up to date.
execute_process(COMMAND ${GIT_EXECUTABLE} fetch WORKING_DIRECTORY ${DIR})

# Can we find a tag with the full omegalib version name (i.e. v6.1)
execute_process(COMMAND ${GIT_EXECUTABLE} tag -l ${MODULE_VERSION}
function(select_module_branch BRANCH_NAME DIR MODULE_NAME)

# Can we find a tag with the branch name?
execute_process(COMMAND ${GIT_EXECUTABLE} branch --list ${BRANCH_NAME}
WORKING_DIRECTORY ${DIR} OUTPUT_VARIABLE RESULT)

if(NOT ${RESULT} STREQUAL "")
# Tag found: check it out
message(" >>> checking out tag ${MODULE_VERSION}")
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${MODULE_VERSION} -q
WORKING_DIRECTORY ${DIR} OUTPUT_VARIABLE RESULT)

else()
# Can we find a tag CONTAINING the major version name?
# i.e. tag v3v4v5v6 will match version v4.
string(REGEX MATCH "v[0-9]+" MODULE_VERSION_MAJOR ${MODULE_VERSION})
execute_process(COMMAND ${GIT_EXECUTABLE} tag -l *${MODULE_VERSION_MAJOR}*
# Branch found: check it out
#message("${MODULE_NAME}: switching to branch ${BRANCH_NAME}")
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${BRANCH_NAME} -q
WORKING_DIRECTORY ${DIR} OUTPUT_VARIABLE RESULT)

if(NOT ${RESULT} STREQUAL "")
# remove trailing newline
string(REPLACE "\n" "" RESULT ${RESULT})

# Tag found: check it out
message(" >>> checking out tag ${RESULT}")
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${RESULT} -q
WORKING_DIRECTORY ${DIR} OUTPUT_VARIABLE RESULT)

# no versioned tag/branch found for this module.
# just keep using whatever branch/tag we're on.
endif()
endif()
endfunction()

Expand All @@ -53,7 +29,7 @@ function(module_def MODULE_NAME URL DESCRIPTION)
message(STATUS "Module ${MODULE_NAME} installed")
endif()

select_module_version(${OMEGALIB_VERSION} ${CMAKE_SOURCE_DIR}/modules/${MODULE_NAME} ${MODULE_NAME})
select_module_branch(${GIT_BRANCH} ${CMAKE_SOURCE_DIR}/modules/${MODULE_NAME} ${MODULE_NAME})

# Add this module to the list of enabled modules.
set(ENABLED_MODULES "${ENABLED_MODULES};${MODULE_NAME}" CACHE INTERNAL "")
Expand Down

0 comments on commit afddd6e

Please sign in to comment.