Cordova: Renamed cmake Find module for bindings

Renamed find module from FindCordova to FindUpmCordovaGenerator to be
more descriptive with the intent of the find module.  Updated the find
module to use find_package_handle_standard_args so a version can be
specified and handle REQUIRED keyword.

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck 2018-03-15 13:33:38 -07:00
parent b09944f4b8
commit 757683b2ca
3 changed files with 21 additions and 9 deletions

View File

@ -178,7 +178,7 @@ if (BUILDCORDOVA)
find_package (Node REQUIRED) find_package (Node REQUIRED)
find_package (Npm REQUIRED) find_package (Npm REQUIRED)
find_package (Cordova REQUIRED) find_package (UpmCordovaGenerator 0.2.1 REQUIRED)
endif (BUILDCORDOVA) endif (BUILDCORDOVA)
# Find swig if any wrapper is enabled # Find swig if any wrapper is enabled

View File

@ -1,8 +0,0 @@
find_program(UPM_CORDOVA_BINDING NAMES upm-cordova-binding
)
if(UPM_CORDOVA_BINDING)
message(STATUS "The npm package to build cordova bindings found at ${UPM_CORDOVA_BINDING}")
else()
message(FATAL_ERROR "Unable to find the npm package for building cordova bindings, please install by 'npm install -g upm-cordova-binding'")
endif()

View File

@ -0,0 +1,20 @@
find_program (UPM_CORDOVA_BINDING NAMES upm-cordova-binding
DOC "UPM Cordova binding generator")
include (FindPackageHandleStandardArgs)
# Get version
if (UPM_CORDOVA_BINDING)
execute_process(COMMAND ${NPM_EXECUTABLE} info upm-cordova-binding version
OUTPUT_VARIABLE UPM_CORDOVA_BINDING_VERSION
ERROR_VARIABLE UPM_CORDOVA_BINDING_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE)
endif()
find_package_handle_standard_args(UpmCordovaGenerator
REQUIRED_VARS UPM_CORDOVA_BINDING
VERSION_VAR UPM_CORDOVA_BINDING_VERSION
FAIL_MESSAGE "Unable to find the npm package for generating UPM Cordova bindings. The generator can be installed via: 'npm install -g upm-cordova-binding'")
mark_as_advanced (UPM_CORDOVA_BINDING UPM_CORDOVA_BINDING_VERSION)