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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. # Adds the current project to the global properties
  2. FUNCTION(OV_ADD_THIS_TO_PROJECT_LIST)
  3. debug_message( "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. # skip_documentation is project-wide
  20. IF(NOT(${SKIP_DOCUMENTATION}))
  21. debug_message( "CUSTOM DOCUMENTATION ENABLED FOR ${doc_project_name}")
  22. SET(HAS_CUSTOM_DOCUMENTATION_${doc_project_name} "1" PARENT_SCOPE)
  23. SET(CUSTOM_DOCUMENTATION_PRODUCT_NAME_${doc_project_name} "${doc_product_name}" PARENT_SCOPE)
  24. # if we need also the sources (e.g. the API is documented with doxygen)
  25. SET(ADDITIONAL_FOLDERS_STRING_LIST "")
  26. FOREACH(additional_cpp_source ${ARGN})
  27. SET(ADDITIONAL_FOLDERS_STRING_LIST "${ADDITIONAL_FOLDERS_STRING_LIST} ${CMAKE_CURRENT_SOURCE_DIR}/${doc_project_name}/${additional_cpp_source}")
  28. ENDFOREACH()
  29. SET(CUSTOM_DOCUMENTATION_CPP_SOURCES_${doc_project_name} "${ADDITIONAL_FOLDERS_STRING_LIST}" PARENT_SCOPE)
  30. ENDIF()
  31. ENDFUNCTION()
  32. #
  33. # Adds all directories as subdirectories to the CMake build, using the branch specified (if any) in the root CMakeList.txt or
  34. # trunk otherwise.
  35. #
  36. # The branch variable name that is checked is made up from ${CURRENT_BRANCH_PREFIX}_${DIRNAMEUPPER}.
  37. #
  38. # The script also adds the directory to the global list of projects.
  39. #
  40. FUNCTION(OV_ADD_PROJECTS CURRENT_FOLDER_PREFIX)
  41. FILE(GLOB FILENAMES "*")
  42. FOREACH(FULLPATH ${FILENAMES})
  43. IF(IS_DIRECTORY ${FULLPATH} AND EXISTS "${FULLPATH}/CMakeLists.txt")
  44. GET_FILENAME_COMPONENT(DIRNAME ${FULLPATH} NAME)
  45. STRING(TOUPPER ${DIRNAME} DIRNAMEUPPER)
  46. SET(SKIP_THIS_FOLDER "SKIP_${CURRENT_FOLDER_PREFIX}_${DIRNAMEUPPER}")
  47. SET(SKIP_THIS_CUSTOM_DOCUMENTATION "SKIP_DOC_${CURRENT_FOLDER_PREFIX}_${DIRNAMEUPPER}")
  48. debug_message( "Checking SKIP_${CURRENT_FOLDER_PREFIX}_${DIRNAMEUPPER} as branch var ${SKIP_THIS_FOLDER}")
  49. IF(${SKIP_THIS_FOLDER})
  50. debug_message( "Note: ${FULLPATH} has been skipped by setting SKIP_${CURRENT_FOLDER_PREFIX}_${DIRNAMEUPPER}")
  51. ELSE()
  52. debug_message( "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. SET(HAS_CUSTOM_DOCUMENTATION "HAS_CUSTOM_DOCUMENTATION_${DIRNAME}")
  62. SET(CUSTOM_DOCUMENTATION_PRODUCT_NAME "CUSTOM_DOCUMENTATION_PRODUCT_NAME_${DIRNAME}")
  63. SET(CUSTOM_DOCUMENTATION_CPP_SOURCES "${CUSTOM_DOCUMENTATION_CPP_SOURCES_${DIRNAME}}")
  64. IF(NOT(${SKIP_DOCUMENTATION}) AND NOT(${SKIP_THIS_CUSTOM_DOCUMENTATION}) AND NOT MULTI_BUILD)
  65. IF(NOT(${HAS_CUSTOM_DOCUMENTATION}))
  66. IF(NOT(${SKIP_DOC_OPENVIBE}))
  67. IF(IS_DIRECTORY ${FULLPATH}/doc)
  68. debug_message( "Documentation files found in ${FULLPATH}/doc")
  69. INSTALL(DIRECTORY ${FULLPATH}/doc/ DESTINATION ${DIST_DOCTMP}/openvibe/box-algorithm-doc/dox-part/ FILES_MATCHING PATTERN "*.dox-part")
  70. INSTALL(DIRECTORY ${FULLPATH}/doc/ DESTINATION ${DIST_DOCTMP}/openvibe FILES_MATCHING PATTERN "*.dox")
  71. INSTALL(DIRECTORY ${FULLPATH}/doc/ DESTINATION ${DIST_DOCTMP}/openvibe 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. debug_message( "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. CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/documentation/src/build-documentation.cmake-skeleton" "${DIST_DOCTMP}/build-documentation-${DIRNAME}.cmake" @ONLY)
  98. FILE(APPEND "${DIST_DOCTMP}/build-documentation.cmd"
  99. "cmake -P build-documentation-${DIRNAME}.cmake\n")
  100. ENDIF()
  101. ENDIF()
  102. add_subdirectory(${FULLPATH})
  103. ENDIF()
  104. ENDIF()
  105. ENDFOREACH(FULLPATH ${FILENAMES})
  106. ENDFUNCTION(OV_ADD_PROJECTS)