summaryrefslogtreecommitdiffstats
path: root/cmake/modules
diff options
context:
space:
mode:
authorRadek Novacek <rnovacek@redhat.com>2012-08-28 12:56:54 +0200
committerRadek Novacek <rnovacek@redhat.com>2012-08-28 15:02:54 +0200
commit6f28bde1b99b9a8553125926885bb1dcdd740f82 (patch)
treec58c409dffd1b35886324a00cc3ccd7be4fec25a /cmake/modules
parenteb7b04edecfa19ed88e5a9d8553d24e31aaf1e7f (diff)
downloadopenlmi-providers-6f28bde1b99b9a8553125926885bb1dcdd740f82.tar.gz
openlmi-providers-6f28bde1b99b9a8553125926885bb1dcdd740f82.tar.xz
openlmi-providers-6f28bde1b99b9a8553125926885bb1dcdd740f82.zip
Don't call sed from CuraMacros, use cmake regex instead
Diffstat (limited to 'cmake/modules')
-rw-r--r--cmake/modules/CuraMacros.cmake107
1 files changed, 54 insertions, 53 deletions
diff --git a/cmake/modules/CuraMacros.cmake b/cmake/modules/CuraMacros.cmake
index f4b40c3..7d83d42 100644
--- a/cmake/modules/CuraMacros.cmake
+++ b/cmake/modules/CuraMacros.cmake
@@ -15,65 +15,66 @@ macro(konkretcmpi_generate MOF CIM_PROVIDERS CIM_HEADERS)
endif (NOT EXISTS ${MOF_FILE})
# Read CIM classes out of MOF file
- execute_process(COMMAND sed -e "/class/ !D" -e "s/class \\(.*\\):.*/\\1/g"
- INPUT_FILE ${MOF_FILE}
- OUTPUT_VARIABLE CIM_CLASSES
- )
+ file(READ ${MOF_FILE} MOF_CONTENT)
+ string(REGEX MATCHALL "class [A-Za-z_]+" CIM_CLASSESX ${MOF_CONTENT})
+ set(CIM_CLASSES "")
+ foreach(CLASSX ${CIM_CLASSESX})
+ string(REPLACE "class " "" CLASS ${CLASSX})
+ set(CIM_CLASSES ${CIM_CLASSES} ${CLASS})
+ endforeach(CLASSX ${CIM_CLASSESX})
- if (${CIM_CLASSES} STREQUAL "")
+ list(LENGTH CIM_CLASSES LEN)
+ if (${LEN} EQUAL 0)
message(FATAL_ERROR "No class found in the MOF file ${MOF_FILE}")
- endif (${CIM_CLASSES} STREQUAL "")
-
- # And fill list with them
- string(REGEX MATCHALL "[a-zA-Z_-]+" CIM_CLASSES ${CIM_CLASSES})
-
- # Get headers and sources names from the list of CIM classes
- set(HEADERS "")
- set(PROVIDERS "")
- set(GENERATE_PROVIDERS "")
- set(NEW_PROVIDERS "")
- foreach(CLASS ${CIM_CLASSES})
- # Add generated header to the list
- set(HEADERS ${HEADERS} ${CLASS}.h)
- # Get name of the source file
- set(PROVIDER ${CLASS}Provider.c)
- # If the provider doesn't exist, generate it
- if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${PROVIDER})
- # Part of generating command - passed to konkret
- set(GENERATE_PROVIDERS ${GENERATE_PROVIDERS} -s ${CLASS})
- # List of freshly generated providers
- set(NEW_PROVIDERS ${NEW_PROVIDERS} ${PROVIDER})
- endif (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${PROVIDER})
- # Add provider source to the list
- set(PROVIDERS ${PROVIDERS} ${PROVIDER})
- endforeach(CLASS ${CIM_CLASSES})
+ else (${LEN} EQUAL 0)
+ # Get headers and sources names from the list of CIM classes
+ set(HEADERS "")
+ set(PROVIDERS "")
+ set(GENERATE_PROVIDERS "")
+ set(NEW_PROVIDERS "")
+ foreach(CLASS ${CIM_CLASSES})
+ # Add generated header to the list
+ set(HEADERS ${HEADERS} ${CLASS}.h)
+ # Get name of the source file
+ set(PROVIDER ${CLASS}Provider.c)
+ # If the provider doesn't exist, generate it
+ if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${PROVIDER})
+ # Part of generating command - passed to konkret
+ set(GENERATE_PROVIDERS ${GENERATE_PROVIDERS} -s ${CLASS})
+ # List of freshly generated providers
+ set(NEW_PROVIDERS ${NEW_PROVIDERS} ${PROVIDER})
+ endif (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${PROVIDER})
+ # Add provider source to the list
+ set(PROVIDERS ${PROVIDERS} ${PROVIDER})
+ endforeach(CLASS ${CIM_CLASSES})
- # 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}
- ${GENERATE_PROVIDERS}
- ${CIM_CLASSES}
- WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- RESULT_VARIABLE RES
- OUTPUT_VARIABLE OUT
- ERROR_VARIABLE ERR
- )
+ # 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}
+ ${GENERATE_PROVIDERS}
+ ${CIM_CLASSES}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ RESULT_VARIABLE RES
+ OUTPUT_VARIABLE OUT
+ ERROR_VARIABLE ERR
+ )
- # Show error message when konkret fails
- if (NOT ${RES} EQUAL 0)
- message(FATAL_ERROR "KonkretCMPI failed: ${RES} ${ERR}")
- endif (NOT ${RES} EQUAL 0)
+ # Show error message when konkret fails
+ if (NOT ${RES} EQUAL 0)
+ message(FATAL_ERROR "KonkretCMPI failed: ${RES} ${ERR}")
+ endif (NOT ${RES} EQUAL 0)
- # Move pregenerated sources for providers to source directory
- foreach(PROVIDER ${NEW_PROVIDERS})
- file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/${PROVIDER} ${CMAKE_CURRENT_SOURCE_DIR}/${PROVIDER})
- endforeach(PROVIDER ${NEW_PROVIDERS})
+ # Move pregenerated sources for providers to source directory
+ foreach(PROVIDER ${NEW_PROVIDERS})
+ file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/${PROVIDER} ${CMAKE_CURRENT_SOURCE_DIR}/${PROVIDER})
+ endforeach(PROVIDER ${NEW_PROVIDERS})
- # Return to caller
- set(${CIM_HEADERS} ${HEADERS})
- set(${CIM_PROVIDERS} ${PROVIDERS})
+ # Return to caller
+ set(${CIM_HEADERS} ${HEADERS})
+ set(${CIM_PROVIDERS} ${PROVIDERS})
+ endif (${LEN} EQUAL 0)
endmacro(konkretcmpi_generate MOF PROVIDERS HEADERS)
# This macro creates registration file from shared library