Browse Source

Remove optional arguments from else() and end*() commands

This adds a brief explanation of the optional condition in the `else()`
and removes all legacy usages of `else()` and `end*()` commands.
Peter Kokot 11 months ago
parent
commit
9f2efc3270

+ 3 - 0
Help/command/else.rst

@@ -8,3 +8,6 @@ Starts the else portion of an if block.
   else([<condition>])
 
 See the :command:`if` command.
+
+The optional ``<condition>`` argument is supported for backward compatibility
+only and is not evaluated.

+ 1 - 1
Modules/CMakeDetermineCompilerId.cmake

@@ -32,7 +32,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
     set(CMAKE_${lang}_COMPILER_ID_FLAGS ${CMAKE_${lang}_FLAGS})
   elseif(DEFINED ENV{${flagvar}})
     set(CMAKE_${lang}_COMPILER_ID_FLAGS $ENV{${flagvar}})
-  else(CMAKE_${lang}_FLAGS_INIT)
+  else()
     set(CMAKE_${lang}_COMPILER_ID_FLAGS ${CMAKE_${lang}_FLAGS_INIT})
   endif()
   separate_arguments(CMAKE_${lang}_COMPILER_ID_FLAGS_LIST NATIVE_COMMAND "${CMAKE_${lang}_COMPILER_ID_FLAGS}")

+ 2 - 2
Modules/CPackIFW.cmake

@@ -651,7 +651,7 @@ macro(_cpack_ifw_resolve_lisenses _variable)
         set(_ifw_license_file TRUE)
       endif()
       list(APPEND _ifw_licenses_fix "${_ifw_licenses_arg}")
-    endforeach(_ifw_licenses_arg)
+    endforeach()
     set(${_variable} "${_ifw_licenses_fix}")
   endif()
 endmacro()
@@ -667,7 +667,7 @@ macro(_cpack_ifw_resolve_file_list _variable)
       else()
         message(WARNING "CPack IFW: page file \"${_ifw_file_arg}\" does not exist. Skipping")
       endif()
-    endforeach(_ifw_file_arg)
+    endforeach()
     set(${_variable} "${_ifw_list_fix}")
   endif()
 endmacro()

+ 1 - 1
Modules/FeatureSummary.cmake

@@ -136,7 +136,7 @@ function(_FS_GET_FEATURE_SUMMARY _property _var _includeQuiet)
   get_property(_EnabledFeatures  GLOBAL PROPERTY ${_property})
   if(_EnabledFeatures)
     list(REMOVE_DUPLICATES _EnabledFeatures)
-  endif(_EnabledFeatures)
+  endif()
 
   foreach(_currentFeature ${_EnabledFeatures})
 

+ 2 - 2
Modules/FindBacktrace.cmake

@@ -58,9 +58,9 @@ set(_Backtrace_STD_ARGS Backtrace_INCLUDE_DIR)
 
 if(Backtrace_HEADER)
   set(_Backtrace_HEADER_TRY "${Backtrace_HEADER}")
-else(Backtrace_HEADER)
+else()
   set(_Backtrace_HEADER_TRY "execinfo.h")
-endif(Backtrace_HEADER)
+endif()
 
 find_path(Backtrace_INCLUDE_DIR "${_Backtrace_HEADER_TRY}")
 set(Backtrace_INCLUDE_DIRS ${Backtrace_INCLUDE_DIR})

+ 1 - 1
Modules/FindCUDA.cmake

@@ -903,7 +903,7 @@ if(CMAKE_CROSSCOMPILING)
       set(CUDA_TOOLKIT_TARGET_NAMES "aarch64-qnx")
     else()
       set(CUDA_TOOLKIT_TARGET_NAMES "aarch64-linux" "sbsa-linux")
-    endif (ANDROID_ARCH_NAME STREQUAL "arm64")
+    endif()
   endif()
 
   foreach(CUDA_TOOLKIT_TARGET_NAME IN LISTS CUDA_TOOLKIT_TARGET_NAMES)

+ 1 - 1
Modules/FindEnvModules.cmake

@@ -241,7 +241,7 @@ function(env_module)
   if(MOD_ARGS_RESULT_VARIABLE)
     set(${MOD_ARGS_RESULT_VARIABLE} ${ret_var} PARENT_SCOPE)
   endif()
-endfunction(env_module)
+endfunction()
 
 #------------------------------------------------------------------------------
 function(env_module_swap out_mod in_mod)

+ 1 - 1
Modules/FindHg.cmake

@@ -89,7 +89,7 @@ if(HG_EXECUTABLE)
 
     string(REGEX REPLACE "([0-9a-f]+)\\+? [0-9]+\\+?" "\\1" ${prefix}_WC_CHANGESET ${${prefix}_WC_DATA})
     string(REGEX REPLACE "[0-9a-f]+\\+? ([0-9]+)\\+?" "\\1" ${prefix}_WC_REVISION ${${prefix}_WC_DATA})
-  endmacro(HG_WC_INFO)
+  endmacro()
 endif()
 
 include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)

+ 5 - 5
Modules/FindJNI.cmake

@@ -111,7 +111,7 @@ if(NOT JNI_FIND_COMPONENTS)
       set(JNI_FIND_COMPONENTS NativeHelper)
       set(JNI_FIND_REQUIRED_NativeHelper TRUE)
     endif()
-  else(ANDROID)
+  else()
     set(JNI_FIND_COMPONENTS AWT JVM)
     # For compatibility purposes, if no components are specified both are
     # considered required.
@@ -434,7 +434,7 @@ foreach(search IN LISTS _JNI_SEARCHES)
     find_library(JAVA_JVM_LIBRARY ${_JNI_${search}_JVM}
       DOC "Java Virtual Machine library"
     )
-  endif(JVM IN_LIST JNI_FIND_COMPONENTS)
+  endif()
 
   if(AWT IN_LIST JNI_FIND_COMPONENTS)
     find_library(JAVA_AWT_LIBRARY ${_JNI_${search}_JAWT}
@@ -538,7 +538,7 @@ endif()
 # JVM is available even on Android referencing the nativehelper library
 if(JAVA_JVM_LIBRARY)
   set(JNI_JVM_FOUND TRUE)
-else(JAVA_JVM_LIBRARY)
+else()
   set(JNI_JVM_FOUND FALSE)
 endif()
 
@@ -646,7 +646,7 @@ if(JNI_FOUND)
   if(JNI_AWT_FOUND)
     if(NOT TARGET JNI::AWT)
       add_library(JNI::AWT IMPORTED UNKNOWN)
-    endif(NOT TARGET JNI::AWT)
+    endif()
 
     set_property(TARGET JNI::AWT PROPERTY INTERFACE_INCLUDE_DIRECTORIES
       ${JAVA_AWT_INCLUDE_PATH})
@@ -669,7 +669,7 @@ if(JNI_FOUND)
       else()
         add_library(JNI::JVM IMPORTED INTERFACE)
       endif()
-    endif(NOT TARGET JNI::JVM)
+    endif()
 
     set_property(TARGET JNI::JVM PROPERTY INTERFACE_LINK_LIBRARIES JNI::JNI)
     get_property(_JNI_JVM_TYPE TARGET JNI::JVM PROPERTY TYPE)

+ 2 - 2
Modules/FindLua.cmake

@@ -106,7 +106,7 @@ function(_lua_set_version_vars)
   endforeach ()
 
   set(_lua_include_subdirs "${_lua_include_subdirs}" PARENT_SCOPE)
-endfunction(_lua_set_version_vars)
+endfunction()
 
 function(_lua_get_header_version)
   unset(LUA_VERSION_STRING PARENT_SCOPE)
@@ -145,7 +145,7 @@ function(_lua_get_header_version)
       return()
     endif ()
   endforeach ()
-endfunction(_lua_get_header_version)
+endfunction()
 
 function(_lua_find_header)
   _lua_set_version_vars()

+ 2 - 2
Modules/FindSDL_sound.cmake

@@ -217,8 +217,8 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
       )
       if(MIKMOD_LIBRARY)
         set(SDL_SOUND_LIBRARIES_TMP ${SDL_SOUND_LIBRARIES_TMP} ${MIKMOD_LIBRARY})
-      endif(MIKMOD_LIBRARY)
-    endif("${MY_OUTPUT}" MATCHES "MikMod_")
+      endif()
+    endif()
 
     # Find ModPlug
     if("${MY_OUTPUT}" MATCHES "MODPLUG_")

+ 7 - 7
Modules/FindXCTest.cmake

@@ -108,13 +108,13 @@ find_package_handle_standard_args(XCTest
 if(XCTest_FOUND)
   set(XCTest_INCLUDE_DIRS "${XCTest_INCLUDE_DIR}")
   set(XCTest_LIBRARIES "${XCTest_LIBRARY}")
-endif(XCTest_FOUND)
+endif()
 
 
 function(xctest_add_bundle target testee)
   if(NOT XCTest_FOUND)
     message(FATAL_ERROR "XCTest is required to create a XCTest Bundle.")
-  endif(NOT XCTest_FOUND)
+  endif()
 
   if(NOT CMAKE_OSX_SYSROOT)
     message(FATAL_ERROR "Adding XCTest bundles requires CMAKE_OSX_SYSROOT to be set.")
@@ -166,15 +166,15 @@ function(xctest_add_bundle target testee)
         set_target_properties(${target} PROPERTIES
           LIBRARY_OUTPUT_DIRECTORY "${_output_directory}")
       endif()
-    else(XCODE)
+    else()
       target_link_libraries(${target}
         PRIVATE -bundle_loader $<TARGET_FILE:${testee}>)
-    endif(XCODE)
+    endif()
 
   else()
     message(FATAL_ERROR "Testee ${testee} is of unsupported type.")
   endif()
-endfunction(xctest_add_bundle)
+endfunction()
 
 
 function(xctest_add_test name bundle)
@@ -186,7 +186,7 @@ function(xctest_add_test name bundle)
 
   if(NOT TARGET ${bundle})
     message(FATAL_ERROR "${bundle} is not a target.")
-  endif(NOT TARGET ${bundle})
+  endif()
 
   get_property(_test_type TARGET ${bundle} PROPERTY TYPE)
   get_property(_test_bundle TARGET ${bundle} PROPERTY BUNDLE)
@@ -221,4 +221,4 @@ function(xctest_add_test name bundle)
     set_property(TEST ${name} APPEND PROPERTY
       ENVIRONMENT DYLD_FRAMEWORK_PATH=$<TARGET_LINKER_FILE_DIR:${_testee}>/..)
   endif()
-endfunction(xctest_add_test)
+endfunction()

+ 2 - 2
Modules/Platform/Haiku.cmake

@@ -91,11 +91,11 @@ LIST(APPEND CMAKE_HAIKU_COMMON_INCLUDE_DIRECTORIES
   /boot/system/develop/headers/posix
   /boot/system/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
   )
-IF (CMAKE_HAIKU_SECONDARY_ARCH)
+if(CMAKE_HAIKU_SECONDARY_ARCH)
   LIST(APPEND CMAKE_HAIKU_COMMON_INCLUDE_DIRECTORIES
     /boot/system/develop/headers
     )
-ENDIF (CMAKE_HAIKU_SECONDARY_ARCH)
+endif()
 
 LIST(APPEND CMAKE_HAIKU_C_INCLUDE_DIRECTORIES
   ${CMAKE_HAIKU_COMMON_INCLUDE_DIRECTORIES}

+ 1 - 1
Modules/Platform/Windows-GNU.cmake

@@ -184,7 +184,7 @@ macro(__windows_compiler_gnu_abi lang)
       if(_vs_dir)
         list(APPEND _vs_installer_paths "${_vs_dir}/VC/Auxiliary/Build")
       endif()
-    endforeach(vs)
+    endforeach()
 
     if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
       find_program(CMAKE_GNUtoMS_VCVARS NAMES vcvars32.bat

+ 4 - 4
Modules/UseQt4.cmake

@@ -17,9 +17,9 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<NOT:$<CONFIG:Debu
 
 if(QT_INCLUDE_DIRS_NO_SYSTEM)
   include_directories(${QT_INCLUDE_DIR})
-else(QT_INCLUDE_DIRS_NO_SYSTEM)
+else()
   include_directories(SYSTEM ${QT_INCLUDE_DIR})
-endif(QT_INCLUDE_DIRS_NO_SYSTEM)
+endif()
 
 set(QT_LIBRARIES "")
 set(QT_LIBRARIES_PLUGINS "")
@@ -85,9 +85,9 @@ foreach(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN
         add_definitions(-DQT_${qt_module_def}_LIB)
         if(QT_INCLUDE_DIRS_NO_SYSTEM)
           include_directories(${QT_${module}_INCLUDE_DIR})
-        else(QT_INCLUDE_DIRS_NO_SYSTEM)
+        else()
           include_directories(SYSTEM ${QT_${module}_INCLUDE_DIR})
-        endif(QT_INCLUDE_DIRS_NO_SYSTEM)
+        endif()
       endif()
       if(QT_USE_${module} OR QT_IS_STATIC)
         set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY})

+ 1 - 1
Tests/RunCMake/Autogen_common/utils.cmake

@@ -24,7 +24,7 @@ ${make_program_stderr}
             "top ${RunCMake_MAKE_PROGRAM} build failed exited with status ${make_program_result}")
     endif()
   set(make_program_stdout "${make_program_stdout}" PARENT_SCOPE)
-endfunction(run_make_program)
+endfunction()
 
 function(count_substring STRING SUBSTRING COUNT_VAR)
   string(LENGTH "${STRING}" STRING_LENGTH)

+ 1 - 1
Tests/RunCMake/CommandLine/RunCMakeTest.cmake

@@ -434,7 +434,7 @@ function(run_EnvironmentExportCompileCommands)
   run_cmake(env-export-compile-commands-override)
 
   unset(ENV{CMAKE_EXPORT_COMPILE_COMMANDS})
-endfunction(run_EnvironmentExportCompileCommands)
+endfunction()
 
 if(RunCMake_GENERATOR MATCHES "Unix Makefiles" OR RunCMake_GENERATOR MATCHES "Ninja")
   run_EnvironmentExportCompileCommands()

+ 4 - 4
Tests/RunCMake/Ninja/RunCMakeTest.cmake

@@ -175,7 +175,7 @@ ${ninja_stderr}
       "top ninja build failed exited with status ${ninja_result}")
   endif()
   set(ninja_stdout "${ninja_stdout}" PARENT_SCOPE)
-endfunction(run_ninja)
+endfunction()
 
 function (run_LooseObjectDepends)
   set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/LooseObjectDepends-build)
@@ -256,11 +256,11 @@ macro(ninja_escape_path path out)
   string(REPLACE "\$ " "\$\$" "${out}" "${path}")
   string(REPLACE " " "\$ " "${out}" "${${out}}")
   string(REPLACE ":" "\$:" "${out}" "${${out}}")
-endmacro(ninja_escape_path)
+endmacro()
 
 macro(shell_escape string out)
   string(REPLACE "\"" "\\\"" "${out}" "${string}")
-endmacro(shell_escape)
+endmacro()
 
 function(run_sub_cmake test ninja_output_path_prefix)
   set(top_build_dir "${RunCMake_BINARY_DIR}/${test}-build/")
@@ -343,7 +343,7 @@ build build.ninja: RERUN ${escaped_build_ninja_dep} || ${escaped_ninja_output_pa
   build.ninja     = ${mtime_top_build_ninja}")
   endif()
 
-endfunction(run_sub_cmake)
+endfunction()
 
 if("${ninja_version}" VERSION_LESS 1.6)
   message(WARNING "Ninja is too old; skipping rest of test.")