Fix cmake warnings, FindPASTIX/FindPTSCOTCH.
We were getting a lot of warnings due to nested `find_package` calls within `Find***.cmake` files. The recommended approach is to use [`find_dependency`](https://cmake.org/cmake/help/latest/module/CMakeFindDependencyMacro.html) in package configuration files. I made this change for all instances. Case mismatches between `Find<Package>.cmake` and calling `find_package(<PACKAGE>`) also lead to warnings. Fixed for `FindPASTIX.cmake` and `FindSCOTCH.cmake`. `FindBLASEXT.cmake` was broken due to calling `find_package_handle_standard_args(BLAS ...)`. The package name must match, otherwise the `find_package(BLASEXT)` falsely thinks the package wasn't found. I changed to `BLASEXT`, but then also copied that value to `BLAS_FOUND` for compatibility. `FindPastix.cmake` had a typo that incorrectly added `PTSCOTCH` when looking for the `SCOTCH` component. `FindPTSCOTCH` incorrectly added `***-NOTFOUND` to include/library lists, corrupting them. This led to cmake errors down-the-line. Fixes #2288.
This commit is contained in:
		
							parent
							
								
									8cf6cb27ba
								
							
						
					
					
						commit
						1cdec38653
					
				| @ -147,6 +147,7 @@ mark_as_advanced(BLAS_VERBOSE) | ||||
| 
 | ||||
| include(CheckFunctionExists) | ||||
| include(CheckFortranFunctionExists) | ||||
| include(CMakeFindDependencyMacro) | ||||
| 
 | ||||
| set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) | ||||
| 
 | ||||
| @ -509,9 +510,9 @@ if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") | ||||
| 
 | ||||
|     if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) | ||||
|       if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) | ||||
| 	find_package(Threads) | ||||
| 	find_dependency(Threads) | ||||
|       else() | ||||
| 	find_package(Threads REQUIRED) | ||||
| 	find_dependency(Threads REQUIRED) | ||||
|       endif() | ||||
| 
 | ||||
|       set(BLAS_SEARCH_LIBS "") | ||||
|  | ||||
| @ -41,18 +41,19 @@ | ||||
| #  License text for the above reference.) | ||||
| 
 | ||||
| # macro to factorize this call | ||||
| include(CMakeFindDependencyMacro) | ||||
| macro(find_package_blas) | ||||
|   if(BLASEXT_FIND_REQUIRED) | ||||
|     if(BLASEXT_FIND_QUIETLY) | ||||
|       find_package(BLAS REQUIRED QUIET) | ||||
|       find_dependency(BLAS REQUIRED QUIET) | ||||
|     else() | ||||
|       find_package(BLAS REQUIRED) | ||||
|       find_dependency(BLAS REQUIRED) | ||||
|     endif() | ||||
|   else() | ||||
|     if(BLASEXT_FIND_QUIETLY) | ||||
|       find_package(BLAS QUIET) | ||||
|       find_dependency(BLAS QUIET) | ||||
|     else() | ||||
|       find_package(BLAS) | ||||
|       find_dependency(BLAS) | ||||
|     endif() | ||||
|   endif() | ||||
| endmacro() | ||||
| @ -316,7 +317,7 @@ if(BLA_VENDOR MATCHES "Intel*") | ||||
| 	"\n   (see BLAS_SEQ_LIBRARIES and BLAS_PAR_LIBRARIES)") | ||||
|       message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") | ||||
|     endif() | ||||
|     find_package_handle_standard_args(BLAS DEFAULT_MSG | ||||
|     find_package_handle_standard_args(BLASEXT DEFAULT_MSG | ||||
|       BLAS_SEQ_LIBRARIES | ||||
|       BLAS_LIBRARY_DIRS | ||||
|       BLAS_INCLUDE_DIRS) | ||||
| @ -324,14 +325,14 @@ if(BLA_VENDOR MATCHES "Intel*") | ||||
|       if(NOT BLASEXT_FIND_QUIETLY) | ||||
| 	message(STATUS "BLAS parallel libraries stored in BLAS_PAR_LIBRARIES") | ||||
|       endif() | ||||
|       find_package_handle_standard_args(BLAS DEFAULT_MSG | ||||
|       find_package_handle_standard_args(BLASEXT DEFAULT_MSG | ||||
| 	BLAS_PAR_LIBRARIES) | ||||
|     endif() | ||||
|   else() | ||||
|     if(NOT BLASEXT_FIND_QUIETLY) | ||||
|       message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") | ||||
|     endif() | ||||
|     find_package_handle_standard_args(BLAS DEFAULT_MSG | ||||
|     find_package_handle_standard_args(BLASEXT DEFAULT_MSG | ||||
|       BLAS_SEQ_LIBRARIES | ||||
|       BLAS_LIBRARY_DIRS | ||||
|       BLAS_INCLUDE_DIRS) | ||||
| @ -343,14 +344,14 @@ elseif(BLA_VENDOR MATCHES "ACML*") | ||||
|       "\n   (see BLAS_SEQ_LIBRARIES and BLAS_PAR_LIBRARIES)") | ||||
|     message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") | ||||
|   endif() | ||||
|   find_package_handle_standard_args(BLAS DEFAULT_MSG | ||||
|   find_package_handle_standard_args(BLASEXT DEFAULT_MSG | ||||
|     BLAS_SEQ_LIBRARIES | ||||
|     BLAS_LIBRARY_DIRS) | ||||
|   if(BLAS_PAR_LIBRARIES) | ||||
|     if(NOT BLASEXT_FIND_QUIETLY) | ||||
|       message(STATUS "BLAS parallel libraries stored in BLAS_PAR_LIBRARIES") | ||||
|     endif() | ||||
|     find_package_handle_standard_args(BLAS DEFAULT_MSG | ||||
|     find_package_handle_standard_args(BLASEXT DEFAULT_MSG | ||||
|       BLAS_PAR_LIBRARIES) | ||||
|   endif() | ||||
| elseif(BLA_VENDOR MATCHES "IBMESSL*") | ||||
| @ -360,21 +361,24 @@ elseif(BLA_VENDOR MATCHES "IBMESSL*") | ||||
|       "\n   (see BLAS_SEQ_LIBRARIES and BLAS_PAR_LIBRARIES)") | ||||
|     message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") | ||||
|   endif() | ||||
|   find_package_handle_standard_args(BLAS DEFAULT_MSG | ||||
|   find_package_handle_standard_args(BLASEXT DEFAULT_MSG | ||||
|     BLAS_SEQ_LIBRARIES | ||||
|     BLAS_LIBRARY_DIRS) | ||||
|   if(BLAS_PAR_LIBRARIES) | ||||
|     if(NOT BLASEXT_FIND_QUIETLY) | ||||
|       message(STATUS "BLAS parallel libraries stored in BLAS_PAR_LIBRARIES") | ||||
|     endif() | ||||
|     find_package_handle_standard_args(BLAS DEFAULT_MSG | ||||
|     find_package_handle_standard_args(BLASEXT DEFAULT_MSG | ||||
|       BLAS_PAR_LIBRARIES) | ||||
|   endif() | ||||
| else() | ||||
|   if(NOT BLASEXT_FIND_QUIETLY) | ||||
|     message(STATUS "BLAS sequential libraries stored in BLAS_SEQ_LIBRARIES") | ||||
|   endif() | ||||
|   find_package_handle_standard_args(BLAS DEFAULT_MSG | ||||
|   find_package_handle_standard_args(BLASEXT DEFAULT_MSG | ||||
|     BLAS_SEQ_LIBRARIES | ||||
|     BLAS_LIBRARY_DIRS) | ||||
| endif() | ||||
| 
 | ||||
| # Callers expect BLAS_FOUND to be set as well. | ||||
| set(BLAS_FOUND BLASEXT_FOUND) | ||||
|  | ||||
| @ -41,7 +41,8 @@ set(COMPUTECPP_BITCODE "spir64" CACHE STRING | ||||
|   "Bitcode type to use as SYCL target in compute++") | ||||
| mark_as_advanced(COMPUTECPP_BITCODE) | ||||
| 
 | ||||
| find_package(OpenCL REQUIRED) | ||||
| include(CMakeFindDependencyMacro) | ||||
| find_dependency(OpenCL REQUIRED) | ||||
| 
 | ||||
| # Find ComputeCpp package | ||||
| 
 | ||||
|  | ||||
| @ -22,7 +22,8 @@ if( NOT FFTW_ROOT AND ENV{FFTWDIR} ) | ||||
| endif() | ||||
| 
 | ||||
| # Check if we can use PkgConfig | ||||
| find_package(PkgConfig) | ||||
| include(CMakeFindDependencyMacro) | ||||
| find_dependency(PkgConfig) | ||||
| 
 | ||||
| #Determine from PKG | ||||
| if( PKG_CONFIG_FOUND AND NOT FFTW_ROOT ) | ||||
|  | ||||
| @ -65,8 +65,9 @@ endif() | ||||
| 
 | ||||
| # Optionally use pkg-config to detect include/library dirs (if pkg-config is available) | ||||
| # ------------------------------------------------------------------------------------- | ||||
| include(FindPkgConfig) | ||||
| find_package(PkgConfig QUIET) | ||||
| include(CMakeFindDependencyMacro) | ||||
| # include(FindPkgConfig) | ||||
| find_dependency(PkgConfig QUIET) | ||||
| if( PKG_CONFIG_EXECUTABLE AND NOT HWLOC_GIVEN_BY_USER ) | ||||
| 
 | ||||
|   pkg_search_module(HWLOC hwloc) | ||||
|  | ||||
| @ -26,6 +26,7 @@ | ||||
| 
 | ||||
| 
 | ||||
| include(CheckFunctionExists) | ||||
| include(CMakeFindDependencyMacro) | ||||
| 
 | ||||
| # This macro checks for the existence of the combination of fortran libraries | ||||
| # given by _list.  If the combination is found, this macro checks (using the | ||||
| @ -88,7 +89,7 @@ macro(check_lapack_libraries DEFINITIONS LIBRARIES _prefix _name _flags _list _b | ||||
|     set(${LIBRARIES}    ${_libraries_found}) | ||||
|     # Some C++ linkers require the f2c library to link with Fortran libraries. | ||||
|     # I do not know which ones, thus I just add the f2c library if it is available. | ||||
|     find_package( F2C QUIET ) | ||||
|     find_dependency( F2C QUIET ) | ||||
|     if ( F2C_FOUND ) | ||||
|       set(${DEFINITIONS}  ${${DEFINITIONS}} ${F2C_DEFINITIONS}) | ||||
|       set(${LIBRARIES}    ${${LIBRARIES}} ${F2C_LIBRARIES}) | ||||
| @ -135,9 +136,9 @@ endmacro() | ||||
| 
 | ||||
| # LAPACK requires BLAS | ||||
| if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) | ||||
|   find_package(BLAS) | ||||
|   find_dependency(BLAS) | ||||
| else() | ||||
|   find_package(BLAS REQUIRED) | ||||
|   find_dependency(BLAS REQUIRED) | ||||
| endif() | ||||
| 
 | ||||
| if (NOT BLAS_FOUND) | ||||
|  | ||||
| @ -118,7 +118,7 @@ if( PASTIX_FIND_COMPONENTS ) | ||||
|     if (${component} STREQUAL "SCOTCH") | ||||
|       set(PASTIX_LOOK_FOR_SCOTCH ON) | ||||
|     endif() | ||||
|     if (${component} STREQUAL "SCOTCH") | ||||
|     if (${component} STREQUAL "PTSCOTCH") | ||||
|       set(PASTIX_LOOK_FOR_PTSCOTCH ON) | ||||
|     endif() | ||||
|     if (${component} STREQUAL "METIS") | ||||
| @ -133,14 +133,14 @@ endif() | ||||
| 
 | ||||
| # Required dependencies | ||||
| # --------------------- | ||||
| 
 | ||||
| include(CMakeFindDependencyMacro) | ||||
| if (NOT PASTIX_FIND_QUIETLY) | ||||
|   message(STATUS "Looking for PASTIX - Try to detect pthread") | ||||
| endif() | ||||
| if (PASTIX_FIND_REQUIRED) | ||||
|   find_package(Threads REQUIRED QUIET) | ||||
|   find_dependency(Threads REQUIRED QUIET) | ||||
| else() | ||||
|   find_package(Threads QUIET) | ||||
|   find_dependency(Threads QUIET) | ||||
| endif() | ||||
| set(PASTIX_EXTRA_LIBRARIES "") | ||||
| if( THREADS_FOUND ) | ||||
| @ -198,9 +198,9 @@ if (NOT PASTIX_FIND_QUIETLY) | ||||
|   message(STATUS "Looking for PASTIX - Try to detect HWLOC") | ||||
| endif() | ||||
| if (PASTIX_FIND_REQUIRED) | ||||
|   find_package(HWLOC REQUIRED QUIET) | ||||
|   find_dependency(HWLOC REQUIRED QUIET) | ||||
| else() | ||||
|   find_package(HWLOC QUIET) | ||||
|   find_dependency(HWLOC QUIET) | ||||
| endif() | ||||
| 
 | ||||
| # PASTIX depends on BLAS | ||||
| @ -209,9 +209,9 @@ if (NOT PASTIX_FIND_QUIETLY) | ||||
|   message(STATUS "Looking for PASTIX - Try to detect BLAS") | ||||
| endif() | ||||
| if (PASTIX_FIND_REQUIRED) | ||||
|   find_package(BLASEXT REQUIRED QUIET) | ||||
|   find_dependency(BLASEXT REQUIRED QUIET) | ||||
| else() | ||||
|   find_package(BLASEXT QUIET) | ||||
|   find_dependency(BLASEXT QUIET) | ||||
| endif() | ||||
| 
 | ||||
| # Optional dependencies | ||||
| @ -230,9 +230,9 @@ if (NOT MPI_FOUND AND PASTIX_LOOK_FOR_MPI) | ||||
|     set(MPI_C_COMPILER mpicc) | ||||
|   endif() | ||||
|   if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_MPI) | ||||
|     find_package(MPI REQUIRED QUIET) | ||||
|     find_dependency(MPI REQUIRED QUIET) | ||||
|   else() | ||||
|     find_package(MPI QUIET) | ||||
|     find_dependency(MPI QUIET) | ||||
|   endif() | ||||
|   if (MPI_FOUND) | ||||
|     mark_as_advanced(MPI_LIBRARY) | ||||
| @ -272,10 +272,10 @@ if( NOT STARPU_FOUND AND PASTIX_LOOK_FOR_STARPU) | ||||
|   endif() | ||||
|   # set the list of optional dependencies we may discover | ||||
|   if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_STARPU) | ||||
|     find_package(STARPU ${PASTIX_STARPU_VERSION} REQUIRED | ||||
|     find_dependency(STARPU ${PASTIX_STARPU_VERSION} REQUIRED | ||||
|       COMPONENTS ${STARPU_COMPONENT_LIST}) | ||||
|   else() | ||||
|     find_package(STARPU ${PASTIX_STARPU_VERSION} | ||||
|     find_dependency(STARPU ${PASTIX_STARPU_VERSION} | ||||
|       COMPONENTS ${STARPU_COMPONENT_LIST}) | ||||
|   endif() | ||||
| 
 | ||||
| @ -288,9 +288,9 @@ if (NOT SCOTCH_FOUND AND PASTIX_LOOK_FOR_SCOTCH) | ||||
|     message(STATUS "Looking for PASTIX - Try to detect SCOTCH") | ||||
|   endif() | ||||
|   if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_SCOTCH) | ||||
|     find_package(SCOTCH REQUIRED QUIET) | ||||
|     find_dependency(SCOTCH REQUIRED QUIET) | ||||
|   else() | ||||
|     find_package(SCOTCH QUIET) | ||||
|     find_dependency(SCOTCH QUIET) | ||||
|   endif() | ||||
| endif() | ||||
| 
 | ||||
| @ -301,9 +301,9 @@ if (NOT PTSCOTCH_FOUND AND PASTIX_LOOK_FOR_PTSCOTCH) | ||||
|     message(STATUS "Looking for PASTIX - Try to detect PTSCOTCH") | ||||
|   endif() | ||||
|   if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_PTSCOTCH) | ||||
|     find_package(PTSCOTCH REQUIRED QUIET) | ||||
|     find_dependency(PTSCOTCH REQUIRED QUIET) | ||||
|   else() | ||||
|     find_package(PTSCOTCH QUIET) | ||||
|     find_dependency(PTSCOTCH QUIET) | ||||
|   endif() | ||||
| endif() | ||||
| 
 | ||||
| @ -314,9 +314,9 @@ if (NOT METIS_FOUND AND PASTIX_LOOK_FOR_METIS) | ||||
|     message(STATUS "Looking for PASTIX - Try to detect METIS") | ||||
|   endif() | ||||
|   if (PASTIX_FIND_REQUIRED AND PASTIX_FIND_REQUIRED_METIS) | ||||
|     find_package(METIS REQUIRED QUIET) | ||||
|     find_dependency(METIS REQUIRED QUIET) | ||||
|   else() | ||||
|     find_package(METIS QUIET) | ||||
|     find_dependency(METIS QUIET) | ||||
|   endif() | ||||
| endif() | ||||
| 
 | ||||
| @ -79,20 +79,21 @@ if( PTSCOTCH_FIND_COMPONENTS ) | ||||
| endif() | ||||
| 
 | ||||
| # PTSCOTCH depends on Threads, try to find it | ||||
| include(CMakeFindDependencyMacro) | ||||
| if (NOT THREADS_FOUND) | ||||
|   if (PTSCOTCH_FIND_REQUIRED) | ||||
|     find_package(Threads REQUIRED) | ||||
|     find_dependency(Threads REQUIRED) | ||||
|   else() | ||||
|     find_package(Threads) | ||||
|     find_dependency(Threads) | ||||
|   endif() | ||||
| endif() | ||||
| 
 | ||||
| # PTSCOTCH depends on MPI, try to find it | ||||
| if (NOT MPI_FOUND) | ||||
|   if (PTSCOTCH_FIND_REQUIRED) | ||||
|     find_package(MPI REQUIRED) | ||||
|     find_dependency(MPI REQUIRED) | ||||
|   else() | ||||
|     find_package(MPI) | ||||
|     find_dependency(MPI) | ||||
|   endif() | ||||
| endif() | ||||
| 
 | ||||
| @ -171,7 +172,6 @@ foreach(ptscotch_hdr ${PTSCOTCH_hdrs_to_find}) | ||||
|   if (PTSCOTCH_${ptscotch_hdr}_DIRS) | ||||
|     list(APPEND PTSCOTCH_INCLUDE_DIRS "${PTSCOTCH_${ptscotch_hdr}_DIRS}") | ||||
|   else () | ||||
|     set(PTSCOTCH_INCLUDE_DIRS "PTSCOTCH_INCLUDE_DIRS-NOTFOUND") | ||||
|     if (NOT PTSCOTCH_FIND_QUIETLY) | ||||
|       message(STATUS "Looking for ptscotch -- ${ptscotch_hdr} not found") | ||||
|     endif() | ||||
| @ -255,7 +255,6 @@ foreach(ptscotch_lib ${PTSCOTCH_libs_to_find}) | ||||
|     list(APPEND PTSCOTCH_LIBRARIES "${PTSCOTCH_${ptscotch_lib}_LIBRARY}") | ||||
|     list(APPEND PTSCOTCH_LIBRARY_DIRS "${${ptscotch_lib}_lib_path}") | ||||
|   else () | ||||
|     list(APPEND PTSCOTCH_LIBRARIES "${PTSCOTCH_${ptscotch_lib}_LIBRARY}") | ||||
|     if (NOT PTSCOTCH_FIND_QUIETLY) | ||||
|       message(STATUS "Looking for ptscotch -- lib ${ptscotch_lib} not found") | ||||
|     endif() | ||||
|  | ||||
| @ -71,11 +71,12 @@ if( SCOTCH_FIND_COMPONENTS ) | ||||
| endif() | ||||
| 
 | ||||
| # SCOTCH may depend on Threads, try to find it | ||||
| include(CMakeFindDependencyMacro) | ||||
| if (NOT THREADS_FOUND) | ||||
|   if (SCOTCH_FIND_REQUIRED) | ||||
|     find_package(Threads REQUIRED) | ||||
|     find_dependency(Threads REQUIRED) | ||||
|   else() | ||||
|     find_package(Threads) | ||||
|     find_dependency(Threads) | ||||
|   endif() | ||||
| endif() | ||||
| 
 | ||||
| @ -67,8 +67,9 @@ set(CXX_STANDARD_REQUIRED ON) | ||||
| 
 | ||||
| 
 | ||||
| # Find OpenCL package | ||||
| include(CMakeFindDependencyMacro) | ||||
| if(TRISYCL_OPENCL) | ||||
|   find_package(OpenCL REQUIRED) | ||||
|   find_dependency(OpenCL REQUIRED) | ||||
|   if(UNIX) | ||||
|     set(BOOST_COMPUTE_INCPATH /usr/include/compute CACHE PATH | ||||
|       "Path to Boost.Compute headers (default is: /usr/include/compute)") | ||||
| @ -77,11 +78,11 @@ endif() | ||||
| 
 | ||||
| # Find OpenMP package | ||||
| if(TRISYCL_OPENMP) | ||||
|   find_package(OpenMP REQUIRED) | ||||
|   find_dependency(OpenMP REQUIRED) | ||||
| endif() | ||||
| 
 | ||||
| # Find Boost | ||||
| find_package(Boost 1.58 REQUIRED COMPONENTS chrono log) | ||||
| find_dependency(Boost 1.58 REQUIRED COMPONENTS chrono log) | ||||
| 
 | ||||
| # If debug or trace we need boost log | ||||
| if(TRISYCL_DEBUG OR TRISYCL_DEBUG_STRUCTORS OR TRISYCL_TRACE_KERNEL) | ||||
| @ -90,7 +91,7 @@ else() | ||||
|   set(LOG_NEEDED OFF) | ||||
| endif() | ||||
| 
 | ||||
| find_package(Threads REQUIRED) | ||||
| find_dependency(Threads REQUIRED) | ||||
| 
 | ||||
| # Find triSYCL directory | ||||
| if (TRISYCL_INCLUDES AND TRISYCL_LIBRARIES) | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Antonio Sanchez
						Antonio Sanchez