From a90e1d94208cd61c21651e0180aee10b8e38774b Mon Sep 17 00:00:00 2001 From: Martin Beseda <martin.beseda@vsb.cz> Date: Tue, 19 Feb 2019 03:56:17 +0100 Subject: [PATCH] FIX: Trying to fix Armadillo finding module --- FindArmadillo.cmake | 75 ++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/FindArmadillo.cmake b/FindArmadillo.cmake index ff8c0dc9..df72ed3a 100644 --- a/FindArmadillo.cmake +++ b/FindArmadillo.cmake @@ -24,48 +24,45 @@ FIND_PATH( include/armadillo ) -# Find library -set(LIBNAME ${LIB_PREFIX}armadillo.so) -message(${LIBNAME}) -FIND_LIBRARY( - ARMADILLO_LIBRARY_DIR +# Is Armadillo downloaded locally? +option(LOCAL OFF) +IF(${ARMADILLO_INCLUDE_DIR} MATCHES "^.*external_dependencies.*$") + set(LOCAL ON) + set(TMP "") + string(REGEX REPLACE "/include" "" TMP ${ARMADILLO_INCLUDE_DIR}) + add_subdirectory(${TMP} ${TMP}) +endif() - NAMES - ${LIBNAME} - - HINTS - external_dependencies/armadillo - - PATHS - /usr/lib - /usr/local/lib -) - -# Set ARMADILLO_FOUND honoring the QUIET and REQUIRED arguments -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS( - armadillo - "Armadillo was NOT found!" - ARMADILLO_INCLUDE_DIR - ARMADILLO_LIBRARY_DIR) +if(LOCAL) + # If Armadillo is downloaded locally, the library will be compiled during build-time + INCLUDE(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS( + armadillo + "Armadillo was NOT found!" + ARMADILLO_INCLUDE_DIR) -# Output variables -IF(ARMADILLO_FOUND) - # Include dirs - SET(ARMADILLO_INCLUDE_DIRS ${ARMADILLO_INCLUDE_DIR}) +else() + # Find library + set(LIBNAME ${LIB_PREFIX}armadillo.so) + FIND_LIBRARY( + ARMADILLO_LIBRARY_DIR - # If Armadillo is downloaded as a source code, add it to the project, so the library will be compiled - # automatically - IF(${ARMADILLO_INCLUDE_DIR} MATCHES "^.*external_dependencies.*$") - set(TMP "") - string(REGEX REPLACE "/include" "" TMP ${ARMADILLO_INCLUDE_DIR}) - add_subdirectory(${TMP} ${TMP}) - ENDIF() + NAMES + ${LIBNAME} - message("Armadillo was successfully found.") -ENDIF() + HINTS + external_dependencies/armadillo -# Advanced options for not cluttering the cmake UIs: -MARK_AS_ADVANCED(ARMADILLO_INCLUDE_DIR) -MARK_AS_ADVANCED(ARMADILLO_LIBRARY_DIR) + PATHS + /usr/lib + /usr/local/lib + ) + # Set ARMADILLO_FOUND honoring the QUIET and REQUIRED arguments + INCLUDE(FindPackageHandleStandardArgs) + FIND_PACKAGE_HANDLE_STANDARD_ARGS( + armadillo + "Armadillo was NOT found!" + ARMADILLO_INCLUDE_DIR + ARMADILLO_LIBRARY_DIR) +endif() \ No newline at end of file -- GitLab