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 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. IF(NOT MULTI_BUILD)
  9. IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc AND NOT(${SKIP_DOC_OPENVIBE}))
  10. FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/doc/ DESTINATION ${DIST_DOCTMP}/openvibe FILES_MATCHING PATTERN "*.dox")
  11. FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/doc/ DESTINATION ${DIST_DOCTMP}/openvibe PATTERN "*.dox" EXCLUDE)
  12. ENDIF()
  13. IF(IS_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/include) AND NOT(${SKIP_DOCUMENTATION}) AND NOT(${SKIP_DOC_OPENVIBE}))
  14. FILE(APPEND "${DIST_DOCTMP}/openvibe/source-list.txt" "${CMAKE_CURRENT_SOURCE_DIR}/include\n")
  15. ENDIF()
  16. ENDIF()
  17. ENDFUNCTION()
  18. FUNCTION(OV_SET_CUSTOM_DOCUMENTATION doc_project_name doc_product_name)
  19. MESSAGE(STATUS "CUSTOM DOCUMENTATION ENABLED FOR ${doc_project_name}")
  20. SET(HAS_CUSTOM_DOCUMENTATION_${doc_project_name} "1" PARENT_SCOPE)
  21. IF(${BUILD_DOCUMENTATION})
  22. SET(CUSTOM_DOCUMENTATION_PRODUCT_NAME_${doc_project_name} "${doc_product_name}" PARENT_SCOPE)
  23. # if we need also the sources (e.g. the API is documented with doxygen)
  24. SET(ADDITIONAL_FOLDERS_STRING_LIST "")
  25. FOREACH(additional_cpp_source ${ARGN})
  26. SET(ADDITIONAL_FOLDERS_STRING_LIST "${ADDITIONAL_FOLDERS_STRING_LIST} ${CMAKE_CURRENT_SOURCE_DIR}/${doc_project_name}/${additional_cpp_source}")
  27. ENDFOREACH()
  28. SET(CUSTOM_DOCUMENTATION_CPP_SOURCES_${doc_project_name} "${ADDITIONAL_FOLDERS_STRING_LIST}" PARENT_SCOPE)
  29. ENDIF()
  30. ENDFUNCTION()
  31. #
  32. # Adds all directories as subdirectories to the CMake build, using the branch specified (if any) in the root CMakeList.txt or
  33. # trunk otherwise.
  34. #
  35. # The branch variable name that is checked is made up from ${CURRENT_BRANCH_PREFIX}_${DIRNAMEUPPER}.
  36. #
  37. # The script also adds the directory to the global list of projects.
  38. #
  39. FUNCTION(OV_ADD_PROJECTS CURRENT_FOLDER_PREFIX)
  40. FILE(GLOB FILENAMES "*")
  41. FOREACH(FULLPATH ${FILENAMES})
  42. IF(IS_DIRECTORY ${FULLPATH} AND EXISTS "${FULLPATH}/CMakeLists.txt")
  43. GET_FILENAME_COMPONENT(DIRNAME ${FULLPATH} NAME)
  44. STRING(TOUPPER ${DIRNAME} DIRNAMEUPPER)
  45. SET(SKIP_THIS_FOLDER "SKIP_${CURRENT_FOLDER_PREFIX}_${DIRNAMEUPPER}")
  46. SET(SKIP_THIS_CUSTOM_DOCUMENTATION "SKIP_DOC_${CURRENT_FOLDER_PREFIX}_${DIRNAMEUPPER}")
  47. #MESSAGE(STATUS "Checking SKIP_${CURRENT_FOLDER_PREFIX}_${DIRNAMEUPPER} as branch var ${SKIP_THIS_FOLDER}")
  48. IF(${SKIP_THIS_FOLDER})
  49. MESSAGE(STATUS "Note: ${FULLPATH} has been skipped by setting SKIP_${CURRENT_FOLDER_PREFIX}_${DIRNAMEUPPER}")
  50. ELSE()
  51. # MESSAGE(STATUS "Inserting folder ${FULLPATH}")
  52. # 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
  53. GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS)
  54. SET(OV_TMP "${OV_TMP};${FULLPATH}")
  55. SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS ${OV_TMP})
  56. SET(OV_CURRENT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/${DIRNAME}")
  57. GET_PROPERTY(OV_TMP GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS_BUILD_DIR)
  58. SET(OV_TMP "${OV_TMP};${OV_CURRENT_BINARY_DIR}")
  59. SET_PROPERTY(GLOBAL PROPERTY OV_PROP_CURRENT_PROJECTS_BUILD_DIR ${OV_TMP})
  60. SET(HAS_CUSTOM_DOCUMENTATION "HAS_CUSTOM_DOCUMENTATION_${DIRNAME}")
  61. SET(CUSTOM_DOCUMENTATION_PRODUCT_NAME "CUSTOM_DOCUMENTATION_PRODUCT_NAME_${DIRNAME}")
  62. SET(CUSTOM_DOCUMENTATION_CPP_SOURCES "${CUSTOM_DOCUMENTATION_CPP_SOURCES_${DIRNAME}}")
  63. IF(NOT(${SKIP_DOCUMENTATION}) AND NOT(${SKIP_THIS_CUSTOM_DOCUMENTATION}) AND NOT MULTI_BUILD)
  64. IF(NOT(${HAS_CUSTOM_DOCUMENTATION}))
  65. IF(${PUBLISH_DOC_ASSETS})
  66. IF(IS_DIRECTORY ${FULLPATH}/doc)
  67. MESSAGE(STATUS "Documentation files found in ${FULLPATH}/doc")
  68. INSTALL(DIRECTORY ${FULLPATH}/doc/ DESTINATION ${DIST_DOCTMP}/openvibe/box-algorithm-doc/dox-part/ FILES_MATCHING PATTERN "*.dox-part" PATTERN "doc/boxes" EXCLUDE)
  69. INSTALL(DIRECTORY ${FULLPATH}/doc/ DESTINATION ${DIST_DOCTMP}/openvibe FILES_MATCHING PATTERN "*.dox" PATTERN "doc/boxes" EXCLUDE)
  70. INSTALL(DIRECTORY ${FULLPATH}/doc/ DESTINATION ${DIST_DOCTMP}/openvibe
  71. PATTERN "doc/boxes" EXCLUDE PATTERN "*.dox-part" EXCLUDE PATTERN "*.dox" EXCLUDE)
  72. ENDIF()
  73. IF(IS_DIRECTORY ${FULLPATH}/include)
  74. FILE(APPEND "${DIST_DOCTMP}/openvibe/source-list.txt" "${FULLPATH}/include\n")
  75. ENDIF()
  76. ENDIF()
  77. ELSE()
  78. MESSAGE(STATUS "Project ${DIRNAME} has custom documentation")
  79. # we copy the doc files into the temporary folder where everything is built thanks to a cmd script
  80. IF(IS_DIRECTORY ${FULLPATH}/doc/)
  81. FILE(COPY ${FULLPATH}/doc/ DESTINATION "${DIST_DOCTMP}/${DIRNAME}")
  82. ENDIF()
  83. SET(DOC_PROJECT_NAME ${DIRNAME})
  84. SET(DOC_PROJECT_VERSION ${PROJECT_VERSION})
  85. SET(DOC_PROJECT_PRODUCT_NAME "${${CUSTOM_DOCUMENTATION_PRODUCT_NAME}}")
  86. SET(DOC_PROJECT_COMMITHASH ${PROJECT_COMMITHASH})
  87. SET(DOC_PROJECT_BRANCH ${PROJECT_BRANCH})
  88. SET(DOC_PROJECT_CPP_SOURCES "${CUSTOM_DOCUMENTATION_CPP_SOURCES}")
  89. get_directory_property( DirDefs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
  90. SET(DOC_DEFINES "")
  91. foreach( d ${DirDefs} )
  92. #message( STATUS "Found Define: " ${d} )
  93. SET(DOC_DEFINES "${DOC_DEFINES} \\\\ \\n ${d}")
  94. endforeach()
  95. STRING(REPLACE "\"" "\\\"" DOC_DEFINES "${DOC_DEFINES}")
  96. #message( STATUS ${DOC_DEFINES} )
  97. ENDIF()
  98. ENDIF()
  99. add_subdirectory(${FULLPATH})
  100. ENDIF()
  101. ENDIF()
  102. ENDFOREACH(FULLPATH ${FILENAMES})
  103. ENDFUNCTION(OV_ADD_PROJECTS)