Skip to content

Commit

Permalink
rename, enhance classified repo cmake
Browse files Browse the repository at this point in the history
* sdClassifiedRepo renamed to xpClassifiedRepo and uses cmake_parse_arguments
* xpClassifiedRepo sets XP_CLAS_REPO with PARENT_SCOPE
  * makes this cmake variable visible to calling cmake and subdirectories below calling cmake
  * which makes cmake variable CLASSIFIED_BUILD kind of redundant and unnecessary, so removed
  * CLASS_BUILD definition removed (unnecessary and avoids a global definition)
  * if code needs a definition (CLASS_BUILD) it can do so itself where it needs it
    if(DEFINED XP_CLAS_REPO)
      add_definition(-DCLASS_BUILD)
    endif()
  * used by xpClassifiedSrc and xpClassifiedSrcExc functions
* classified_src cmake macro renamed to xpClassifiedSrc and made a cmake function
* classified_exclusive_src cmake macro renamed to xpClassifiedSrcExc and made a cmake function

see issue #180
  • Loading branch information
Scott M Anderson committed Apr 5, 2018
1 parent ce57650 commit e542f1a
Showing 1 changed file with 45 additions and 28 deletions.
73 changes: 45 additions & 28 deletions modules/xpfunmac.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1297,53 +1297,70 @@ function(xpGitCheckout url hash dir)
endif()
endfunction()

function(sdClassifiedRepo repo hash dir)
# details from VantageShared removed...
if(${repo} STREQUAL "isr.git")
if(EXISTS ${repo_path}/${repo} AND IS_DIRECTORY ${repo_path}/${repo})
set(CLASSIFIED_BUILD ON PARENT_SCOPE)
function(xpClassifiedRepo)
set(options VERBOSE)
set(oneValueArgs REPO HASH WORKING_TREE PATH_UNIX PATH_MSW)
cmake_parse_arguments(P "${options}" "${oneValueArgs}" "" ${ARGN})
if(NOT DEFINED P_REPO OR NOT DEFINED P_HASH OR NOT DEFINED P_WORKING_TREE)
message(FATAL_ERROR "xpClassifiedRepo: REPO, HASH, and WORKING_TREE must be specified")
endif()
if(WIN32 OR CYGWIN)
if(NOT DEFINED P_PATH_MSW)
message(FATAL_ERROR "xpClassifiedRepo: PATH_MSW must be specified")
endif()
set(repoPath ${P_PATH_MSW})
else()
if(NOT DEFINED P_PATH_UNIX)
message(FATAL_ERROR "xpClassifiedRepo: PATH_UNIX must be specified")
endif()
set(repoPath ${P_PATH_UNIX})
endif()
if(EXISTS ${repoPath}/${P_REPO} AND IS_DIRECTORY ${repoPath}/${P_REPO})
if(P_VERBOSE)
message(STATUS "=====================================================================")
message(STATUS " Classified repo found. Classified build configuration proceeding... ")
message(STATUS "=====================================================================")
xpGitCheckout(${repo_path}/${repo} ${hash} ${dir})
add_definitions(-DCLASS_BUILD)
else()
message(STATUS "Unclassified build, repo not accessible: ${repo_path}/${repo}")
endif()
elseif(EXISTS ${repo_path}/${repo} AND IS_DIRECTORY ${repo_path}/${repo})
xpGitCheckout(${repo_path}/${repo} ${hash} ${dir})
xpGitCheckout(${repoPath}/${P_REPO} ${P_HASH} ${P_WORKING_TREE})
# make XP_CLAS_REPO available to xpClassifiedSrc and xpClassifiedSrcExc via PARENT_SCOPE
set(XP_CLAS_REPO ${P_WORKING_TREE} PARENT_SCOPE)
elseif(P_VERBOSE)
message(STATUS "Unclassified build, repo not accessible: ${repoPath}/${P_REPO}")
endif()
endfunction()

macro(classified_src srcGroup srcList)
file(RELATIVE_PATH rel_path ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
function(xpClassifiedSrc srcGroup srcList)
file(RELATIVE_PATH relPath ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
foreach(f ${srcList})
if(EXISTS ${clas_repo}/${rel_path}/${f})
list(APPEND ${srcGroup} ${clas_repo}/${rel_path}/${f})
message(STATUS " CLAS: ${clas_repo}/${rel_path}/${f}")
if(DEFINED XP_CLAS_REPO AND EXISTS ${XP_CLAS_REPO}/${relPath}/${f})
list(APPEND ${srcGroup} ${XP_CLAS_REPO}/${relPath}/${f})
message(STATUS " CLAS: ${XP_CLAS_REPO}/${relPath}/${f}")
else()
list(APPEND ${srcGroup} ${f})
if(EXISTS ${clas_repo})
if(DEFINED XP_CLAS_REPO AND EXISTS ${XP_CLAS_REPO})
message(STATUS " UNCLAS: ${CMAKE_CURRENT_SOURCE_DIR}/${f}")
endif()
endif()
endforeach()
endmacro()
set(${srcGroup} ${${srcGroup}} PARENT_SCOPE)
endfunction()

macro(classified_exclusive_src srcGroup srcList)
file(RELATIVE_PATH rel_path ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
if(EXISTS ${clas_repo}/${rel_path} AND IS_DIRECTORY ${clas_repo}/${rel_path})
include_directories(${clas_repo}/${rel_path})
# exclusive: source only in classified repo, no unclassified version
function(xpClassifiedSrcExc srcGroup srcList)
file(RELATIVE_PATH relPath ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
if(DEFINED XP_CLAS_REPO AND EXISTS ${XP_CLAS_REPO}/${relPath} AND IS_DIRECTORY ${XP_CLAS_REPO}/${relPath})
include_directories(${XP_CLAS_REPO}/${relPath})
endif()
foreach(f ${srcList})
if(EXISTS ${clas_repo}/${rel_path}/${f})
list(APPEND ${srcGroup} ${clas_repo}/${rel_path}/${f})
message(STATUS " CLAS_EXCL: ${clas_repo}/${rel_path}/${f}")
elseif(EXISTS ${clas_repo})
message(STATUS " MISSING: ${clas_repo}/${rel_path}/${f}")
if(EXISTS ${XP_CLAS_REPO}/${relPath}/${f})
list(APPEND ${srcGroup} ${XP_CLAS_REPO}/${relPath}/${f})
message(STATUS " CLAS_EXCL: ${XP_CLAS_REPO}/${relPath}/${f}")
elseif(EXISTS ${XP_CLAS_REPO})
message(STATUS " MISSING: ${XP_CLAS_REPO}/${relPath}/${f}")
endif()
endforeach()
endmacro()
set(${srcGroup} ${${srcGroup}} PARENT_SCOPE)
endfunction()

function(xpPostBuildCopy theTarget copyList toPath)
if(IS_ABSOLUTE ${toPath}) # absolute toPath
Expand Down

0 comments on commit e542f1a

Please sign in to comment.