find_package(REQUIRED) won't fail if package name capitalization isn't identical to the module's
The examples assume that either GLEW or wxWidgets aren't already installed or can't be found by CMake.
The following:
cmake_minimum_required(VERSION 3.8.1)
find_package(glew REQUIRED)
find_package(wxwidgets REQUIRED)
Will fail with:
Could NOT find GLEW (missing: GLEW_INCLUDE_DIR GLEW_LIBRARY)
Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS)
Configuring done
Generating done
But the following:
cmake_minimum_required(VERSION 3.8.1)
find_package(GLEW REQUIRED)
find_package(wxWidgets REQUIRED)
Will fail with:
CMake Error at C:/Program Files/CMake/share/cmake-3.8/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find GLEW (missing: GLEW_INCLUDE_DIR GLEW_LIBRARY)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.8/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.8/Modules/FindGLEW.cmake:38 (find_package_handle_standard_args)
CMakeLists.txt:2 (find_package)
Configuring incomplete, errors occurred!
See also "[redacted]/build/CMakeFiles/CMakeOutput.log".
The 1st example still executed FindGLEW and FindwxWidgets, but neither fail if the libraries aren't found. The failure was the expected result due to the REQUIRED
. If the capitalization is exactly same as the module's, as it is in the 2nd example, then it will fail as expected. It might be worth noting the extra space after the "missing: " in the 1st example.