You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

OvAddProjects.cmake 3.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Adds the current project to the global properties
  2. FUNCTION(OV_ADD_THIS_TO_PROJECT_LIST)
  3. #MESSAGE(STATUS "ADDING: ${CMAKE_CURRENT_SOURCE_DIR}")
  4. # Add the dir to be parsed for documentation later. We need to do this before adding subdir, in case the subdir is the actual docs dir
  5. GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS)
  6. SET(OV_TMP "${OV_TMP};${CMAKE_CURRENT_SOURCE_DIR}")
  7. SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS ${OV_TMP})
  8. ENDFUNCTION(OV_ADD_THIS_TO_PROJECT_LIST)
  9. FUNCTION(SOURCE_DIRECTORIES CURRENT_DIR RETURN_LIST)
  10. FILE(GLOB_RECURSE NEW_LIST ${CURRENT_DIR}/*.cpp ${CURRENT_DIR}/*.h ${CURRENT_DIR}/*.hpp ${CURRENT_DIR}/*.inl)
  11. SET(DIR_LIST "")
  12. FOREACH(FILE_PATH ${NEW_LIST})
  13. GET_FILENAME_COMPONENT(DIR_PATH ${FILE_PATH} PATH)
  14. SET(DIR_LIST ${DIR_LIST} "${DIR_PATH}/..")
  15. ENDFOREACH()
  16. LIST(REMOVE_DUPLICATES DIR_LIST)
  17. SET(${RETURN_LIST} ${DIR_LIST} PARENT_SCOPE)
  18. ENDFUNCTION(SOURCE_DIRECTORIES)
  19. # Adds the given directory to the CMake build
  20. FUNCTION(OV_ADD_SOURCE_DIR CURRENT_SOURCE_DIR)
  21. # Add the given current directory
  22. GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS)
  23. SET(OV_TMP "${OV_TMP};${CURRENT_SOURCE_DIR}")
  24. SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS ${OV_TMP})
  25. # Add source code directories
  26. SOURCE_DIRECTORIES(${CURRENT_SOURCE_DIR} LIST_DIR)
  27. FOREACH(SUBDIR ${LIST_DIR})
  28. GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS)
  29. SET(OV_TMP "${OV_TMP};${SUBDIR}")
  30. SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS ${OV_TMP})
  31. ENDFOREACH()
  32. ENDFUNCTION(OV_ADD_SOURCE_DIR)
  33. #
  34. # Adds all directories as subdirectories to the CMake build, using the branch specified (if any) in the root CMakeList.txt or
  35. # trunk otherwise.
  36. #
  37. # The branch variable name that is checked is made up from ${CURRENT_BRANCH_PREFIX}_${DIRNAMEUPPER}.
  38. #
  39. # The script also adds the directory to the global list of projects.
  40. #
  41. FUNCTION(OV_ADD_PROJECTS CURRENT_FOLDER_PREFIX)
  42. FILE(GLOB FILENAMES "*")
  43. FOREACH(FULLPATH ${FILENAMES})
  44. IF(IS_DIRECTORY ${FULLPATH} AND EXISTS "${FULLPATH}/CMakeLists.txt" AND NOT ${FULLPATH} MATCHES ".*\\.svn")
  45. GET_FILENAME_COMPONENT(DIRNAME ${FULLPATH} NAME)
  46. STRING(TOUPPER ${DIRNAME} DIRNAMEUPPER)
  47. SET(SKIP_THIS_FOLDER "SKIP_${CURRENT_FOLDER_PREFIX}_${DIRNAMEUPPER}")
  48. #MESSAGE(STATUS "Checking SKIP_${CURRENT_FOLDER_PREFIX}_${DIRNAMEUPPER} as branch var ${SKIP_THIS_FOLDER}")
  49. IF(${SKIP_THIS_FOLDER})
  50. MESSAGE(STATUS "Note: ${FULLPATH} has been skipped by setting SKIP_${CURRENT_FOLDER_PREFIX}_${DIRNAMEUPPER}")
  51. ELSE(${SKIP_THIS_FOLDER})
  52. # MESSAGE(STATUS "Inserting folder ${FULLPATH}")
  53. # Add the dir to be parsed for documentation later. We need to do this before adding subdir, in case the subdir is the actual docs dir
  54. GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS)
  55. SET(OV_TMP "${OV_TMP};${FULLPATH}")
  56. SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS ${OV_TMP})
  57. SET(OV_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${DIRNAME}")
  58. GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS_BUILD_DIR)
  59. SET(OV_TMP "${OV_TMP};${OV_CURRENT_BINARY_DIR}")
  60. SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS_BUILD_DIR ${OV_TMP})
  61. add_subdirectory(${FULLPATH})
  62. ENDIF(${SKIP_THIS_FOLDER})
  63. ENDIF(IS_DIRECTORY ${FULLPATH} AND EXISTS "${FULLPATH}/CMakeLists.txt" AND NOT ${FULLPATH} MATCHES ".*\\.svn")
  64. ENDFOREACH(FULLPATH ${FILENAMES})
  65. ENDFUNCTION(OV_ADD_PROJECTS)