From c96422a5683ae8548987ac0d0c1fe46af356e2b8 Mon Sep 17 00:00:00 2001 From: Florent Pruvost <florent.pruvost@inria.fr> Date: Fri, 23 Dec 2022 15:55:19 +0100 Subject: [PATCH] CMake modifications to avoid cmake projects dependents to rediscover all our dependencies at configure time --- CMakeLists.txt | 13 +++++--- cmake_modules/CHAMELEONConfig.cmake.in | 41 +++++++------------------- cmake_modules/morse_cmake | 2 +- runtime/openmp/CMakeLists.txt | 1 + runtime/parsec/CMakeLists.txt | 1 + runtime/quark/CMakeLists.txt | 1 + runtime/starpu/CMakeLists.txt | 1 + 7 files changed, 24 insertions(+), 36 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21b0dc0c0..85b7d3a70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,6 +330,7 @@ endif() # Add math library (libm), searched with MORSE module FindM.cmake # it normally exists on all common systems provided with a C compiler find_package(M REQUIRED) +morse_export_imported_target(MORSE M m chameleon) # If simulation we don't enter in kernel functions so that we don't need to link # with concerned libraries @@ -346,10 +347,12 @@ if(NOT CHAMELEON_SIMULATION) # CHAMELEON depends on CBLAS #--------------------------- find_package(CBLAS REQUIRED) + morse_export_imported_target(MORSE CBLAS cblas chameleon) # CHAMELEON depends on LAPACKE #----------------------------- find_package(LAPACKE REQUIRED) + morse_export_imported_target(MORSE LAPACKE lapacke chameleon) # CHAMELEON depends on CUDA/CUBLAS #---------------------------------- @@ -396,6 +399,8 @@ if(NOT CHAMELEON_SIMULATION) "\n CUDA_LIBRARIES to be found. Be sure you have" "\n libcuda with your distribution of CUDA.") endif() + morse_export_imported_target(CUDA CUDA cuda chameleon) + morse_export_imported_target(CUDA CUBLAS cublas chameleon) endif (CUDA_FOUND) endif(CHAMELEON_USE_CUDA) @@ -417,6 +422,8 @@ if(NOT CHAMELEON_SIMULATION) " - Activate MPI in Chameleon${ColourReset}") endif (MPI_C_FOUND) + morse_export_imported_target(MPI MPI_C mpi chameleon) + endif (CHAMELEON_USE_MPI) else (NOT CHAMELEON_SIMULATION) @@ -504,6 +511,8 @@ else (NOT CHAMELEON_SIMULATION) " - Activate MPI in Chameleon${ColourReset}") endif (MPI_C_FOUND) + morse_export_imported_target(MPI MPI_C mpi chameleon) + endif (CHAMELEON_USE_MPI) endif(NOT CHAMELEON_SIMULATION) @@ -651,10 +660,6 @@ write_basic_package_version_file(CHAMELEONConfigVersion.cmake install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CHAMELEONConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/CHAMELEONConfigVersion.cmake DESTINATION ${LIB_INSTALL_DIR}/cmake/chameleon) -# need MORSE Find modules: necessary files must be distributed in the install path -set(morse_dependencies "M;BLASEXT;LAPACKEXT;CBLAS;LAPACKE;HWLOC;PARSEC;QUARK;STARPU") -morse_install_finds(morse_dependencies ${LIB_INSTALL_DIR}/cmake/chameleon/find) - ############################################################################### # Config files (pkg_config) # ############################# diff --git a/cmake_modules/CHAMELEONConfig.cmake.in b/cmake_modules/CHAMELEONConfig.cmake.in index c4b93d79f..eda084878 100644 --- a/cmake_modules/CHAMELEONConfig.cmake.in +++ b/cmake_modules/CHAMELEONConfig.cmake.in @@ -9,51 +9,30 @@ set_and_check(CHAMELEON_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") check_required_components(CHAMELEON) -# need MORSE Find modules: necessary files must be distributed in the install path -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/find") - # dependencies of CHAMELEON -include(CMakeFindDependencyMacro) -find_dependency(M) +include("${CMAKE_CURRENT_LIST_DIR}/mTargets.cmake") if (NOT @CHAMELEON_SIMULATION@) - find_dependency(CBLAS REQUIRED) - find_dependency(LAPACKE REQUIRED) + include("${CMAKE_CURRENT_LIST_DIR}/cblasTargets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/lapackeTargets.cmake") endif() if (@CHAMELEON_SCHED_OPENMP@) - find_dependency(OpenMP REQUIRED) + include("${CMAKE_CURRENT_LIST_DIR}/openmpTargets.cmake") endif() if (@CHAMELEON_SCHED_PARSEC@) - find_dependency(PARSEC REQUIRED) + include("${CMAKE_CURRENT_LIST_DIR}/parsecTargets.cmake") endif() if (@CHAMELEON_SCHED_QUARK@) - find_dependency(QUARK REQUIRED COMPONENTS HWLOC) + include("${CMAKE_CURRENT_LIST_DIR}/quarkTargets.cmake") endif() if (@CHAMELEON_SCHED_STARPU@) - find_package(STARPU @CHAMELEON_STARPU_VERSION@ REQUIRED) + include("${CMAKE_CURRENT_LIST_DIR}/starpuTargets.cmake") endif() if (@CHAMELEON_USE_MPI@) - find_dependency(MPI REQUIRED) + include("${CMAKE_CURRENT_LIST_DIR}/mpiTargets.cmake") endif() if (@CHAMELEON_USE_CUDA@ AND NOT @CHAMELEON_SIMULATION@) - find_dependency(CUDA REQUIRED) - if ( CUDA_FOUND ) - if (NOT TARGET CUDA::CUDA) - add_library(CUDA::CUDA INTERFACE IMPORTED) - if (CUDA_INCLUDE_DIRS) - set_target_properties(CUDA::CUDA PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CUDA_INCLUDE_DIRS}") - endif() - if (CUDA_LIBRARIES) - set_target_properties(CUDA::CUDA PROPERTIES INTERFACE_LINK_LIBRARIES "${CUDA_LIBRARIES}") - endif() - if (NOT TARGET CUDA::CUBLAS) - add_library(CUDA::CUBLAS INTERFACE IMPORTED) - if (CUDA_CUBLAS_LIBRARIES) - set_target_properties(CUDA::CUBLAS PROPERTIES INTERFACE_LINK_LIBRARIES "${CUDA_CUBLAS_LIBRARIES}") - endif() - target_link_libraries(CUDA::CUBLAS INTERFACE CUDA::CUDA) - endif() - endif() - endif() + include("${CMAKE_CURRENT_LIST_DIR}/cudaTargets.cmake") + include("${CMAKE_CURRENT_LIST_DIR}/cublasTargets.cmake") endif() # add the targets file diff --git a/cmake_modules/morse_cmake b/cmake_modules/morse_cmake index 0540e7368..fdd64e56f 160000 --- a/cmake_modules/morse_cmake +++ b/cmake_modules/morse_cmake @@ -1 +1 @@ -Subproject commit 0540e73689762bfb5a3c9e8231de3cc1d14cf4dd +Subproject commit fdd64e56f4d1b3b1a31cb568dec374f9fde84796 diff --git a/runtime/openmp/CMakeLists.txt b/runtime/openmp/CMakeLists.txt index 2bc8716da..6c2968a30 100644 --- a/runtime/openmp/CMakeLists.txt +++ b/runtime/openmp/CMakeLists.txt @@ -29,6 +29,7 @@ cmake_minimum_required(VERSION 3.1) find_package(OpenMP REQUIRED) +morse_export_imported_target(OpenMP OpenMP_C openmp chameleon) if ( OPENMP_FOUND ) message("-- ${Blue}Add definition CHAMELEON_SCHED_OPENMP" diff --git a/runtime/parsec/CMakeLists.txt b/runtime/parsec/CMakeLists.txt index bf9fda273..cf7095974 100644 --- a/runtime/parsec/CMakeLists.txt +++ b/runtime/parsec/CMakeLists.txt @@ -29,6 +29,7 @@ cmake_minimum_required(VERSION 3.1) find_package( PARSEC REQUIRED ) +morse_export_imported_target(MORSE PARSEC parsec chameleon) if(PARSEC_FOUND) message("-- ${Blue}Add definition CHAMELEON_SCHED_PARSEC" diff --git a/runtime/quark/CMakeLists.txt b/runtime/quark/CMakeLists.txt index ceccd00b9..3e0caf4fe 100644 --- a/runtime/quark/CMakeLists.txt +++ b/runtime/quark/CMakeLists.txt @@ -29,6 +29,7 @@ cmake_minimum_required(VERSION 3.1) find_package( QUARK REQUIRED COMPONENTS HWLOC ) +morse_export_imported_target(MORSE QUARK quark chameleon) # Add definition and include_dir if found if(QUARK_FOUND) diff --git a/runtime/starpu/CMakeLists.txt b/runtime/starpu/CMakeLists.txt index 68ea73c47..8664a455d 100644 --- a/runtime/starpu/CMakeLists.txt +++ b/runtime/starpu/CMakeLists.txt @@ -35,6 +35,7 @@ include(CheckStructHasMember) set(CHAMELEON_STARPU_VERSION "1.3" CACHE STRING "necessary STARPU API version") find_package(STARPU ${CHAMELEON_STARPU_VERSION} REQUIRED) +morse_export_imported_target(MORSE STARPU starpu chameleon) # check available functions # note: recall STARPU_VERSION provides the version -- GitLab