From 5299ed5172004fc582d28464b2d52a85971f4c5b Mon Sep 17 00:00:00 2001 From: David_Korzeniewski Date: Thu, 4 Dec 2014 19:21:23 +0100 Subject: [PATCH] Adapted FindCusp to fail silently if cusp is not found. Now configuring fails with a meaningful error message instead of syntax errors. Former-commit-id: e77388a186b4c071d2c1aeedd707b2ee25fb9294 --- resources/cmake/FindCusp.cmake | 51 +++++++++++++++++----------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/resources/cmake/FindCusp.cmake b/resources/cmake/FindCusp.cmake index 9520d1426..bda100911 100644 --- a/resources/cmake/FindCusp.cmake +++ b/resources/cmake/FindCusp.cmake @@ -23,33 +23,34 @@ find_path(CUSP_INCLUDE_DIR ) if(CUSP_INCLUDE_DIR) list(REMOVE_DUPLICATES CUSP_INCLUDE_DIR) -endif(CUSP_INCLUDE_DIR) + + # Find cusp version + file(STRINGS ${CUSP_INCLUDE_DIR}/cusp/version.h + version + REGEX "#define CUSP_VERSION[ \t]+([0-9x]+)" + ) + string(REGEX REPLACE + "#define CUSP_VERSION[ \t]+" + "" + version + "${version}" + ) -# Find cusp version -file(STRINGS ${CUSP_INCLUDE_DIR}/cusp/version.h - version - REGEX "#define CUSP_VERSION[ \t]+([0-9x]+)" -) -string(REGEX REPLACE - "#define CUSP_VERSION[ \t]+" - "" - version - "${version}" -) - -#define CUSP_MAJOR_VERSION (CUSP_VERSION / 100000) -#define CUSP_MINOR_VERSION (CUSP_VERSION / 100 % 1000) -#define CUSP_SUBMINOR_VERSION (CUSP_VERSION % 100) + #define CUSP_MAJOR_VERSION (CUSP_VERSION / 100000) + #define CUSP_MINOR_VERSION (CUSP_VERSION / 100 % 1000) + #define CUSP_SUBMINOR_VERSION (CUSP_VERSION % 100) -math(EXPR CUSP_MAJOR_VERSION "${version} / 100000") -math(EXPR CUSP_MINOR_VERSION "${version} / 100 % 1000") -math(EXPR CUSP_PATCH_VERSION "${version} % 100") + math(EXPR CUSP_MAJOR_VERSION "${version} / 100000") + math(EXPR CUSP_MINOR_VERSION "${version} / 100 % 1000") + math(EXPR CUSP_PATCH_VERSION "${version} % 100") -set(CUSP_VERSION "${CUSP_MAJOR_VERSION}.${CUSP_MINOR_VERSION}.${CUSP_PATCH_VERSION}") + set(CUSP_VERSION "${CUSP_MAJOR_VERSION}.${CUSP_MINOR_VERSION}.${CUSP_PATCH_VERSION}") -# Check for required components -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Cusp REQUIRED_VARS CUSP_INCLUDE_DIR VERSION_VAR CUSP_VERSION) + # Check for required components + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Cusp REQUIRED_VARS CUSP_INCLUDE_DIR VERSION_VAR CUSP_VERSION) -set(CUSP_INCLUDE_DIRS ${CUSP_INCLUDE_DIR}) -mark_as_advanced(CUSP_INCLUDE_DIR) \ No newline at end of file + set(CUSP_INCLUDE_DIRS ${CUSP_INCLUDE_DIR}) + mark_as_advanced(CUSP_INCLUDE_DIR) + +endif(CUSP_INCLUDE_DIR) \ No newline at end of file