From 010fbce845a7cd89b8afd7f05e8827ae25146c49 Mon Sep 17 00:00:00 2001 From: Tamas Kenez Date: Tue, 16 Jan 2024 23:34:55 +0100 Subject: [PATCH] improve finding armadillo --- cmake/carmaDependencyTargets.cmake | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/cmake/carmaDependencyTargets.cmake b/cmake/carmaDependencyTargets.cmake index 080f929..527910c 100644 --- a/cmake/carmaDependencyTargets.cmake +++ b/cmake/carmaDependencyTargets.cmake @@ -25,18 +25,29 @@ IF (NOT DEFINED PYTHON_EXECUTABLE) ENDIF () # Armadillo dependency -IF (NOT TARGET armadillo) +IF (NOT TARGET armadillo AND NOT TARGET armadillo::armadillo) IF (carma_FIND_REQUIRED) FIND_PACKAGE(Armadillo REQUIRED) ELSE () FIND_PACKAGE(Armadillo) ENDIF () - ADD_LIBRARY(armadillo INTERFACE) - TARGET_INCLUDE_DIRECTORIES(armadillo INTERFACE ${ARMADILLO_INCLUDE_DIRS}) - TARGET_LINK_LIBRARIES(armadillo INTERFACE ${ARMADILLO_LIBRARIES}) ENDIF () -IF (armadillo_FOUND OR ARMADILLO_FOUND OR TARGET armadillo) - ADD_LIBRARY(armadillo::armadillo ALIAS armadillo) +IF (NOT TARGET armadillo::armadillo) + IF (TARGET armadillo) + ADD_LIBRARY(armadillo::armadillo ALIAS armadillo) + ELSEIF (Armadillo_FOUND) + if(NOT ARMADILLO_INCLUDE_DIRS OR NOT ARMADILLO_LIBRARIES) + message(FATAL_ERROR "Armadillo_FOUND is true but ARMADILLO_INCLUDE_DIRS or ARMADILLO_LIBRARIES are not set.") + ENDIF () + ADD_LIBRARY(armadillo::armadillo INTERFACE) + TARGET_INCLUDE_DIRECTORIES(armadillo::armadillo INTERFACE ${ARMADILLO_INCLUDE_DIRS}) + TARGET_LINK_LIBRARIES(armadillo::armadillo INTERFACE ${ARMADILLO_LIBRARIES}) + ENDIF () +ENDIF () +IF (TARGET armadillo::armadillo) + if(NOT ARMADILLO_INCLUDE_DIRS OR NOT ARMADILLO_LIBRARIES) + message(FATAL_ERROR "armadillo::armadillo is a target but ARMADILLO_INCLUDE_DIRS is not set.") + ENDIF () LIST(APPEND carma_INCLUDE_DIRS ${ARMADILLO_INCLUDE_DIRS}) ENDIF ()