From 78cf9c508cbe60e8dec6a27bf17dad983e2b920c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20Pep=C3=A8=20Sciarria?= Date: Thu, 6 Mar 2025 10:50:24 +0100 Subject: [PATCH] adapt CMakeLists.txt to handle installed psblas --- test/hello/CMakeLists.txt | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/test/hello/CMakeLists.txt b/test/hello/CMakeLists.txt index a35c7582..70b0b04d 100644 --- a/test/hello/CMakeLists.txt +++ b/test/hello/CMakeLists.txt @@ -2,16 +2,18 @@ cmake_minimum_required(VERSION 3.10) project(HelloWorld Fortran) # Accept a user-defined library path -#set(LIBRARY_DIR "" CACHE PATH "Path to the library directory") +set(LIBRARY_DIR "" CACHE PATH "Path to the library directory") # Check if the user provided a library directory -#if(NOT LIBRARY_DIR) -# message(FATAL_ERROR "Library directory not specified! Use -DLIBRARY_DIR=path/to/library") -#endif() +if(NOT LIBRARY_DIR) + message(FATAL_ERROR "Library directory not specified! Use -DLIBRARY_DIR=path/to/library") +endif() +# Include CMakePackageConfigHelpers to work with configuration files include(CMakePackageConfigHelpers) + # Find the package -find_package(psblas REQUIRED) +find_package(psblas REQUIRED PATHS ${LIBRARY_DIR}/lib/cmake/psblas NO_DEFAULT_PATH) # Check if the package was found if(NOT psblas_FOUND) @@ -19,15 +21,15 @@ if(NOT psblas_FOUND) endif() # Include directories for the library -#include_directories(${LIBRARY_DIR}/include) # Path to header files -include_directories(${psblas_DIR}/modules) # Path to module files - message(STATUS "Library directory ${psblas_DIR}") - +include_directories(${LIBRARY_DIR}/include) # Path to header files +include_directories(${psblas_DIR}/modules) # Path to module files + +message(STATUS "Library directory: ${psblas_DIR}") + # Add the executables add_executable(hello hello.f90) add_executable(pingpong pingpong.f90) - # Link the specific library targets target_link_libraries(hello PRIVATE psblas::base) target_link_libraries(pingpong PRIVATE psblas::base)