diff --git a/cmake/scripts/GenerateWidget.cmake b/cmake/scripts/GenerateWidget.cmake --- a/cmake/scripts/GenerateWidget.cmake +++ b/cmake/scripts/GenerateWidget.cmake @@ -15,12 +15,12 @@ cmake_minimum_required(VERSION 3.5) # # -if (NOT GENERATE_SOURCE_FILE) +if(NOT GENERATE_SOURCE_FILE) message(FATAL_ERROR "Script needs GENERATE_SOURCE_FILE defined") -endif (NOT GENERATE_SOURCE_FILE) -if (NOT GENERATE_BINARY_FILE) +endif() +if(NOT GENERATE_BINARY_FILE) message(FATAL_ERROR "Script needs GENERATE_BINARY_FILE defined") -endif (NOT GENERATE_BINARY_FILE) +endif() file(STRINGS ${GENERATE_SOURCE_FILE} ENUM_LINES REGEX "@enum") @@ -46,38 +46,38 @@ foreach(ENUM IN LISTS ENUM_LINES) string(REPLACE "${RM_INDENT}" "" LINE "${LINE}") # Remember possible doxygen comment before enum declaration - if ((NOT ACTIVE) AND "${LINE}" MATCHES "/\\*\\*") + if((NOT ACTIVE) AND "${LINE}" MATCHES "/\\*\\*") set(COMMENT "${ADD_INDENT}${LINE}") set(ACTIVE_COMMENT 1) - elseif (ACTIVE_COMMENT EQUAL 1) + elseif(ACTIVE_COMMENT EQUAL 1) string(APPEND COMMENT "\n${ADD_INDENT}${LINE}") endif() # Check for enum match - if ("${LINE}" MATCHES "^ *enum *${ENUM_PATTERN} *\{") + if("${LINE}" MATCHES "^ *enum *${ENUM_PATTERN} *\{") # REGEX REPLACE does a REGEX MATCHALL and fails if an empty string is matched string(REGEX MATCH "[^ ]*" RESULT "${LINE}") string(REPLACE "${RESULT}" "" RM_INDENT "${LINE}") set(ACTIVE 1) - if (ACTIVE_COMMENT GREATER 0) + if(ACTIVE_COMMENT GREATER 0) string(APPEND ${PLACE_HOLDER} "\n${COMMENT}") - endif (ACTIVE_COMMENT GREATER 0) + endif() unset(ACTIVE_COMMENT) unset(COMMENT) - endif ("${LINE}" MATCHES "^ *enum *${ENUM_PATTERN} *\{") + endif() # Forget doxygen comment, if no enum follows - if (ACTIVE_COMMENT EQUAL 2 AND NOT "${LINE}" STREQUAL "") + if(ACTIVE_COMMENT EQUAL 2 AND NOT "${LINE}" STREQUAL "") unset(ACTIVE_COMMENT) unset(COMMENT) - endif (ACTIVE_COMMENT EQUAL 2 AND NOT "${LINE}" STREQUAL "") - if (ACTIVE_COMMENT EQUAL 1 AND "${LINE}" MATCHES "\\*/") + endif() + if(ACTIVE_COMMENT EQUAL 1 AND "${LINE}" MATCHES "\\*/") set(ACTIVE_COMMENT 2) - endif (ACTIVE_COMMENT EQUAL 1 AND "${LINE}" MATCHES "\\*/") + endif() - if (ACTIVE) - if ("${LINE}" MATCHES "^ *[A-Za-z0-9_]* *[,=]") + if(ACTIVE) + if("${LINE}" MATCHES "^ *[A-Za-z0-9_]* *[,=]") # Transform enum values # REGEX REPLACE does a REGEX MATCHALL and replaces too much string(REGEX MATCH " *=[^,]*" RESULT "${LINE}") @@ -92,28 +92,28 @@ foreach(ENUM IN LISTS ENUM_LINES) unset(SPACES) foreach(i RANGE ${LEN}) string(APPEND SPACES " ") - endforeach(i) + endforeach() - if (CMAKE_MATCH_3) + if(CMAKE_MATCH_3) string(APPEND ${PLACE_HOLDER} "\n${ADD_INDENT}${CMAKE_MATCH_1}${CMAKE_MATCH_2}${SPACES} = ::${CMAKE_MATCH_2},${SPACES}${CMAKE_MATCH_3}") - else (CMAKE_MATCH_3) + else() string(APPEND ${PLACE_HOLDER} "\n${ADD_INDENT}${CMAKE_MATCH_1}${CMAKE_MATCH_2}${SPACES} = ::${CMAKE_MATCH_2},") - endif (CMAKE_MATCH_3) - elseif ("${LINE}" STREQUAL "") + endif() + elseif("${LINE}" STREQUAL "") string(APPEND ${PLACE_HOLDER} "\n") - else () + else() string(APPEND ${PLACE_HOLDER} "\n${ADD_INDENT}${LINE}") - endif () - endif (ACTIVE) + endif() + endif() - if ("${LINE}" MATCHES "^ *\};") - if (ACTIVE) + if("${LINE}" MATCHES "^ *\};") + if(ACTIVE) string(APPEND ${PLACE_HOLDER} "\n") - endif (ACTIVE) + endif() unset(ACTIVE) - endif ("${LINE}" MATCHES "^ *\};") - endforeach(LINE) - endforeach(FILE) - endforeach(ENUM) + endif() + endforeach() + endforeach() + endforeach() configure_file(${GENERATE_SOURCE_FILE} ${GENERATE_BINARY_FILE})