diff options
Diffstat (limited to 'cmake/modules/OpenLMIMacros.cmake')
-rw-r--r-- | cmake/modules/OpenLMIMacros.cmake | 84 |
1 files changed, 61 insertions, 23 deletions
diff --git a/cmake/modules/OpenLMIMacros.cmake b/cmake/modules/OpenLMIMacros.cmake index ca63d0d..30bdb69 100644 --- a/cmake/modules/OpenLMIMacros.cmake +++ b/cmake/modules/OpenLMIMacros.cmake @@ -1,31 +1,70 @@ -# This macro takes name of the MOF for one provider and header files using -# konkretcmpi. It also generates provider skeleton if it doesn't exist. +# This macro takes names of the MOFs for one provider and creates the +# headerfiles using konkretcmpi. It also generates provider skeleton +# if it doesn't exist. # -# @param[in] MOF name of the MOF file (should be in mof/ directory of the project root) -# @param[out] CIM_PROVIDERS list of sources of the provider generated from the MOF -# @param[out] CIM_HEADERS list of header file generated from the MOF +# @param[in] MOFS filenames of the MOF files which will be used to generate +# or a list with multiple MOF files, where relative paths mean mof/ directory +# of the project root (Note: list is semi-colon separated, enclosed in quotes) +# @param[out] CIM_PROVIDERS list of sources of the provider generated from the MOFS +# @param[out] CIM_HEADERS list of header files generated from the MOFS +# @param[in] the rest of the argument are mof files that should be included +# in konkret header generation but are not scanned for classes # -macro(konkretcmpi_generate MOF CIM_PROVIDERS CIM_HEADERS) - # Check if MOF exists - set(MOF_FILE ${CMAKE_SOURCE_DIR}/mof/${MOF}) - message(STATUS "Using mof ${MOF} ${MOF_FILE}") - if (NOT EXISTS ${MOF_FILE}) - message(FATAL_ERROR "MOF file ${MOF} not found") - endif (NOT EXISTS ${MOF_FILE}) - - # Read CIM classes out of MOF file - file(READ ${MOF_FILE} MOF_CONTENT) - string(REGEX MATCHALL "class [A-Za-z0-9_]+" CIM_CLASSESX ${MOF_CONTENT}) +macro(konkretcmpi_generate MOFS CIM_PROVIDERS CIM_HEADERS) + # Create list of MOF files for konkret generator and + # list of classes defined in the MOF files + set(KONKRET_MOF_FILES "") set(CIM_CLASSES "") - foreach(CLASSX ${CIM_CLASSESX}) - string(REPLACE "class " "" CLASS ${CLASSX}) - set(CIM_CLASSES ${CIM_CLASSES} ${CLASS}) - endforeach(CLASSX ${CIM_CLASSESX}) + + # Add includes first (needs to be parsed before others) + foreach(MOF ${ARGN}) + # Check if path is absolute, make it absolute if not + if (IS_ABSOLUTE ${MOF}) + set(MOF_FILE ${MOF}) + else (IS_ABSOLUTE ${MOF}) + set(MOF_FILE ${CMAKE_SOURCE_DIR}/mof/${MOF}) + endif (IS_ABSOLUTE ${MOF}) + + # Check if MOF file exists + if (NOT EXISTS ${MOF_FILE}) + message(FATAL_ERROR "MOF file ${MOF} not found") + endif (NOT EXISTS ${MOF_FILE}) + + message(STATUS "Using mof ${MOF} ${MOF_FILE}") + set(KONKRET_MOF_FILES ${KONKRET_MOF_FILES} -m ${MOF_FILE}) + endforeach(MOF ${ARGN}) + + # Read the MOFs with class definition + foreach(MOF ${MOFS}) + # Check if path is absolute, make it absolute if not + if (IS_ABSOLUTE ${MOF}) + set(MOF_FILE ${MOF}) + else (IS_ABSOLUTE ${MOF}) + set(MOF_FILE ${CMAKE_SOURCE_DIR}/mof/${MOF}) + endif (IS_ABSOLUTE ${MOF}) + + # Check if MOF file exists + if (NOT EXISTS ${MOF_FILE}) + message(FATAL_ERROR "MOF file ${MOF} not found") + endif (NOT EXISTS ${MOF_FILE}) + + message(STATUS "Using mof ${MOF} ${MOF_FILE}") + set(KONKRET_MOF_FILES ${KONKRET_MOF_FILES} -m ${MOF_FILE}) + + # Read CIM classes out of MOF files + file(READ ${MOF_FILE} MOF_CONTENT) + string(REGEX MATCHALL "class [A-Za-z0-9_]+" CIM_CLASSESX ${MOF_CONTENT}) + foreach(CLASSX ${CIM_CLASSESX}) + string(REPLACE "class " "" CLASS ${CLASSX}) + set(CIM_CLASSES ${CIM_CLASSES} ${CLASS}) + endforeach(CLASSX ${CIM_CLASSESX}) + endforeach(MOF in LISTS MOFS) + list(LENGTH CIM_CLASSES LEN) if (${LEN} EQUAL 0) - message(FATAL_ERROR "No class found in the MOF file ${MOF_FILE}") + message(FATAL_ERROR "No class found in the MOF files ${MOFS}") else (${LEN} EQUAL 0) # Get headers and sources names from the list of CIM classes set(HEADERS "") @@ -51,8 +90,7 @@ macro(konkretcmpi_generate MOF CIM_PROVIDERS CIM_HEADERS) # Generate headers for CIM classes set(ENV{KONKRET_SCHEMA_DIR} "/usr/share/mof/cim-current") execute_process(COMMAND ${KONKRETCMPI_KONKRET} - #-m /usr/share/sblim-cmpi-base/Linux_Base.mof - -m ${MOF_FILE} + ${KONKRET_MOF_FILES} ${GENERATE_PROVIDERS} ${CIM_CLASSES} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |