From d19125f83867f52f7e6f4f7f7bec1f3b6cce9f50 Mon Sep 17 00:00:00 2001
From: Florent Pruvost <florent.pruvost@inria.fr>
Date: Tue, 13 Jun 2017 16:26:33 +0200
Subject: [PATCH] Add a <PACKAGE>_C_FLAGS variable to give CFLAGS such as
 definitions to users

---
 modules/find/FindCHAMELEON.cmake | 2 ++
 modules/find/FindEZTRACE.cmake   | 3 +++
 modules/find/FindFFTW.cmake      | 8 ++++++--
 modules/find/FindFXT.cmake       | 3 +++
 modules/find/FindGTG.cmake       | 3 +++
 modules/find/FindHWLOC.cmake     | 3 +++
 modules/find/FindMAGMA.cmake     | 2 ++
 modules/find/FindPAPI.cmake      | 3 +++
 modules/find/FindPARSEC.cmake    | 1 +
 modules/find/FindSIMGRID.cmake   | 3 +++
 modules/find/FindSTARPU.cmake    | 3 +++
 11 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/modules/find/FindCHAMELEON.cmake b/modules/find/FindCHAMELEON.cmake
index 837d57c..3be331e 100644
--- a/modules/find/FindCHAMELEON.cmake
+++ b/modules/find/FindCHAMELEON.cmake
@@ -37,6 +37,7 @@
 # This module finds headers and chameleon library.
 # Results are reported in variables:
 #  CHAMELEON_FOUND            - True if headers and requested libraries were found
+#  CHAMELEON_C_FLAGS          - list of required compilation flags (excluding -I)
 #  CHAMELEON_LINKER_FLAGS     - list of required linker flags (excluding -l and -L)
 #  CHAMELEON_INCLUDE_DIRS     - chameleon include directories
 #  CHAMELEON_LIBRARY_DIRS     - Link directories for chameleon libraries
@@ -166,6 +167,7 @@ if(PKG_CONFIG_EXECUTABLE AND NOT CHAMELEON_GIVEN_BY_USER)
     endif()
   endif()
 
+  set(CHAMELEON_C_FLAGS "${CHAMELEON_CFLAGS_OTHER}")
   set(CHAMELEON_INCLUDE_DIRS_DEP "${CHAMELEON_STATIC_INCLUDE_DIRS}")
   set(CHAMELEON_LIBRARY_DIRS_DEP "${CHAMELEON_STATIC_LIBRARY_DIRS}")
   set(CHAMELEON_LIBRARIES_DEP "${CHAMELEON_STATIC_LIBRARIES}")
diff --git a/modules/find/FindEZTRACE.cmake b/modules/find/FindEZTRACE.cmake
index 7584c5e..4c7447a 100644
--- a/modules/find/FindEZTRACE.cmake
+++ b/modules/find/FindEZTRACE.cmake
@@ -20,6 +20,7 @@
 # This module finds headers and eztrace library.
 # Results are reported in variables:
 #  EZTRACE_FOUND           - True if headers and requested libraries were found
+#  EZTRACE_C_FLAGS         - list of required compilation flags (excluding -I)
 #  EZTRACE_INCLUDE_DIRS    - eztrace include directories
 #  EZTRACE_LIBRARY_DIRS    - Link directories for eztrace libraries
 #  EZTRACE_LIBRARIES       - eztrace component libraries to be linked
@@ -86,6 +87,8 @@ if( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER )
     endif()
   endif()
 
+  set(EZTRACE_C_FLAGS "${EZTRACE_CFLAGS_OTHER}")
+
 endif( PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_GIVEN_BY_USER )
 
 if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT EZTRACE_FOUND) OR (EZTRACE_GIVEN_BY_USER) )
diff --git a/modules/find/FindFFTW.cmake b/modules/find/FindFFTW.cmake
index 93e6a00..5b5b36e 100644
--- a/modules/find/FindFFTW.cmake
+++ b/modules/find/FindFFTW.cmake
@@ -230,6 +230,7 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
       pkg_search_module(FFTW3F fftw3f)
       pkg_search_module(FFTW3 fftw3)
       if (FFTW3F_FOUND)
+        set(FFTW_C_FLAGS "${FFTW3F_CFLAGS_OTHER}")
 	if (NOT FFTW_FIND_QUIETLY)
 	  message(STATUS "Looking for FFTW3F - found using PkgConfig")
 	endif()
@@ -259,6 +260,7 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
       pkg_search_module(FFTW3L fftw3l)
       pkg_search_module(FFTW3 fftw3)
       if (FFTW3L_FOUND)
+       set(FFTW_C_FLAGS "${FFTW3L_CFLAGS_OTHER}")
 	if (NOT FFTW_FIND_QUIETLY)
 	  message(STATUS "Looking for FFTW3L - found using PkgConfig")
 	endif()
@@ -288,6 +290,7 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
       pkg_search_module(FFTW3Q fftw3q)
       pkg_search_module(FFTW3 fftw3)
       if (FFTW3Q_FOUND)
+        set(FFTW_C_FLAGS "${FFTW3Q_CFLAGS_OTHER}")
 	if (NOT FFTW_FIND_QUIETLY)
 	  message(STATUS "Looking for FFTW3Q - found using PkgConfig")
 	endif()
@@ -317,6 +320,7 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
       pkg_search_module(FFTW3 fftw3)
     endif()
     if (FFTW3_FOUND)
+      set(FFTW_C_FLAGS "${FFTW3_CFLAGS_OTHER}")
       if (NOT FFTW_FIND_QUIETLY)
 	message(STATUS "Looking for FFTW3 - found using PkgConfig")
       endif()
@@ -324,7 +328,7 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
 	list(APPEND FFTW_LIBRARIES "${FFTW3_LIBRARIES}")
       endif()
       if(FFTW3_INCLUDE_DIRS)
-	list(APPEND FFTW_INCLUDE_DIRS "${FFTW3_INCLUDE_DIRS}")
+	    list(APPEND FFTW_INCLUDE_DIRS "${FFTW3_INCLUDE_DIRS}")
       else()
 	if (NOT FFTW_FIND_QUIETLY)
 	  message(WARNING "FFTW3_INCLUDE_DIRS is empty using PkgConfig."
@@ -333,7 +337,7 @@ if (NOT FFTW_LOOK_FOR_MKL AND NOT FFTW_LOOK_FOR_ESSL)
 	endif()
       endif()
       if(FFTW3_LIBRARY_DIRS)
-	list(APPEND FFTW_LIBRARY_DIRS "${FFTW3_LIBRARY_DIRS}")
+	    list(APPEND FFTW_LIBRARY_DIRS "${FFTW3_LIBRARY_DIRS}")
       endif()
     else(FFTW3_FOUND)
       if (NOT FFTW_FIND_QUIETLY)
diff --git a/modules/find/FindFXT.cmake b/modules/find/FindFXT.cmake
index 3fd9a6e..754ee7d 100644
--- a/modules/find/FindFXT.cmake
+++ b/modules/find/FindFXT.cmake
@@ -16,6 +16,7 @@
 # This module finds headers and fxt library.
 # Results are reported in variables:
 #  FXT_FOUND           - True if headers and requested libraries were found
+#  FXT_C_FLAGS         - list of required compilation flags (excluding -I)
 #  FXT_INCLUDE_DIRS    - fxt include directories
 #  FXT_LIBRARY_DIRS    - Link directories for fxt libraries
 #  FXT_LIBRARIES       - fxt component libraries to be linked
@@ -82,6 +83,8 @@ if(PKG_CONFIG_EXECUTABLE AND NOT FXT_GIVEN_BY_USER)
     endif()
   endif()
 
+  set(FXT_C_FLAGS "${FXT_CFLAGS_OTHER}")
+
 endif(PKG_CONFIG_EXECUTABLE AND NOT FXT_GIVEN_BY_USER)
 
 if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT FXT_FOUND) OR (FXT_GIVEN_BY_USER) )
diff --git a/modules/find/FindGTG.cmake b/modules/find/FindGTG.cmake
index 855388f..dbdaf01 100644
--- a/modules/find/FindGTG.cmake
+++ b/modules/find/FindGTG.cmake
@@ -16,6 +16,7 @@
 # This module finds headers and gtg library.
 # Results are reported in variables:
 #  GTG_FOUND           - True if headers and requested libraries were found
+#  GTG_C_FLAGS         - list of required compilation flags (excluding -I)
 #  GTG_INCLUDE_DIRS    - gtg include directories
 #  GTG_LIBRARY_DIRS    - Link directories for gtg libraries
 #  GTG_LIBRARIES       - gtg component libraries to be linked
@@ -82,6 +83,8 @@ if(PKG_CONFIG_EXECUTABLE AND NOT GTG_GIVEN_BY_USER)
     endif()
   endif()
 
+  set(GTG_C_FLAGS "${GTG_CFLAGS_OTHER}")
+
 endif(PKG_CONFIG_EXECUTABLE AND NOT GTG_GIVEN_BY_USER)
 
 if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT GTG_FOUND) OR (GTG_GIVEN_BY_USER) )
diff --git a/modules/find/FindHWLOC.cmake b/modules/find/FindHWLOC.cmake
index a831b5c..8a0eb7d 100644
--- a/modules/find/FindHWLOC.cmake
+++ b/modules/find/FindHWLOC.cmake
@@ -16,6 +16,7 @@
 # This module finds headers and hwloc library.
 # Results are reported in variables:
 #  HWLOC_FOUND           - True if headers and requested libraries were found
+#  HWLOC_C_FLAGS         - list of required compilation flags (excluding -I)
 #  HWLOC_INCLUDE_DIRS    - hwloc include directories
 #  HWLOC_LIBRARY_DIRS    - Link directories for hwloc libraries
 #  HWLOC_LIBRARIES       - hwloc component libraries to be linked
@@ -85,6 +86,8 @@ if( PKG_CONFIG_EXECUTABLE AND NOT HWLOC_GIVEN_BY_USER )
     endif()
   endif()
 
+  set(HWLOC_C_FLAGS "${HWLOC_CFLAGS_OTHER}")
+
 endif( PKG_CONFIG_EXECUTABLE AND NOT HWLOC_GIVEN_BY_USER )
 
 if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT HWLOC_FOUND) OR (HWLOC_GIVEN_BY_USER) )
diff --git a/modules/find/FindMAGMA.cmake b/modules/find/FindMAGMA.cmake
index 548a0b8..c4f740a 100644
--- a/modules/find/FindMAGMA.cmake
+++ b/modules/find/FindMAGMA.cmake
@@ -27,6 +27,7 @@
 #
 # Results are reported in variables:
 #  MAGMA_FOUND            - True if headers and requested libraries were found
+#  MAGMA_C_FLAGS          - list of required compilation flags (excluding -I)
 #  MAGMA_LINKER_FLAGS     - list of required linker flags (excluding -l and -L)
 #  MAGMA_INCLUDE_DIRS     - magma include directories
 #  MAGMA_LIBRARY_DIRS     - Link directories for magma libraries
@@ -162,6 +163,7 @@ if(PKG_CONFIG_EXECUTABLE AND NOT MAGMA_GIVEN_BY_USER)
   set(MAGMA_INCLUDE_DIRS_DEP "${MAGMA_STATIC_INCLUDE_DIRS}")
   set(MAGMA_LIBRARY_DIRS_DEP "${MAGMA_STATIC_LIBRARY_DIRS}")
   set(MAGMA_LIBRARIES_DEP "${MAGMA_STATIC_LIBRARIES}")
+  set(MAGMA_C_FLAGS "${MAGMA_CFLAGS_OTHER}")
 
 endif(PKG_CONFIG_EXECUTABLE AND NOT MAGMA_GIVEN_BY_USER)
 
diff --git a/modules/find/FindPAPI.cmake b/modules/find/FindPAPI.cmake
index 918edb4..c8395ae 100644
--- a/modules/find/FindPAPI.cmake
+++ b/modules/find/FindPAPI.cmake
@@ -16,6 +16,7 @@
 # This module finds headers and papi library.
 # Results are reported in variables:
 #  PAPI_FOUND           - True if headers and requested libraries were found
+#  PAPI_C_FLAGS         - list of required compilation flags (excluding -I)
 #  PAPI_INCLUDE_DIRS    - papi include directories
 #  PAPI_LIBRARY_DIRS    - Link directories for papi libraries
 #  PAPI_LIBRARIES       - papi component libraries to be linked
@@ -82,6 +83,8 @@ if(PKG_CONFIG_EXECUTABLE AND NOT PAPI_GIVEN_BY_USER)
     endif()
   endif()
 
+  set(PAPI_C_FLAGS "${PAPI_CFLAGS_OTHER}")
+
 endif(PKG_CONFIG_EXECUTABLE AND NOT PAPI_GIVEN_BY_USER)
 
 if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT PAPI_FOUND) OR (PAPI_GIVEN_BY_USER) )
diff --git a/modules/find/FindPARSEC.cmake b/modules/find/FindPARSEC.cmake
index 0cdb474..dd79f3e 100644
--- a/modules/find/FindPARSEC.cmake
+++ b/modules/find/FindPARSEC.cmake
@@ -239,6 +239,7 @@ if(PKG_CONFIG_EXECUTABLE AND NOT PARSEC_GIVEN_BY_USER)
   set(PARSEC_INCLUDE_DIRS_DEP "${PARSEC_INCLUDE_DIRS}")
   set(PARSEC_LIBRARY_DIRS_DEP "${PARSEC_LIBRARY_DIRS}")
   set(PARSEC_LIBRARIES_DEP "${PARSEC_LIBRARIES}")
+  set(PARSEC_C_FLAGS "${PARSEC_CFLAGS_OTHER}")
 
   # create list of binaries to find
   set(PARSEC_bins_to_find "parsec_ptgpp")
diff --git a/modules/find/FindSIMGRID.cmake b/modules/find/FindSIMGRID.cmake
index fb1ab1f..db03529 100644
--- a/modules/find/FindSIMGRID.cmake
+++ b/modules/find/FindSIMGRID.cmake
@@ -16,6 +16,7 @@
 # This module finds headers and simgrid library.
 # Results are reported in variables:
 #  SIMGRID_FOUND           - True if headers and requested libraries were found
+#  SIMGRID_C_FLAGS         - list of required compilation flags (excluding -I)
 #  SIMGRID_INCLUDE_DIRS    - simgrid include directories
 #  SIMGRID_LIBRARY_DIRS    - Link directories for simgrid libraries
 #  SIMGRID_LIBRARIES       - simgrid component libraries to be linked
@@ -82,6 +83,8 @@ if(PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_GIVEN_BY_USER)
     endif()
   endif()
 
+  set(SIMGRID_C_FLAGS "${SIMGRID_CFLAGS_OTHER}")
+
 endif(PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_GIVEN_BY_USER)
 
 if( (NOT PKG_CONFIG_EXECUTABLE) OR (PKG_CONFIG_EXECUTABLE AND NOT SIMGRID_FOUND) OR (SIMGRID_GIVEN_BY_USER) )
diff --git a/modules/find/FindSTARPU.cmake b/modules/find/FindSTARPU.cmake
index fb01497..adf884a 100644
--- a/modules/find/FindSTARPU.cmake
+++ b/modules/find/FindSTARPU.cmake
@@ -275,9 +275,11 @@ if(PKG_CONFIG_EXECUTABLE AND NOT STARPU_GIVEN_BY_USER)
     endif()
     set(STARPU_LIBRARIES "${STARPU_MPI_STATIC_LIBRARIES}")
     set(STARPU_LINKER_FLAGS "${STARPU_MPI_STATIC_LDFLAGS_OTHER}")
+    set(STARPU_C_FLAGS "${STARPU_MPI_CFLAGS_OTHER}")
   elseif(STARPU_SHM_LIBRARIES)
     set(STARPU_LIBRARIES "${STARPU_SHM_STATIC_LIBRARIES}")
     set(STARPU_LINKER_FLAGS "${STARPU_SHM_STATIC_LDFLAGS_OTHER}")
+    set(STARPU_C_FLAGS "${STARPU_CFLAGS_OTHER}")
   else()
     set(STARPU_LIBRARIES "STARPU_LIBRARIES-NOTFOUND")
   endif()
@@ -292,6 +294,7 @@ if(PKG_CONFIG_EXECUTABLE AND NOT STARPU_GIVEN_BY_USER)
   if (STARPU_LOOK_FOR_MPI AND NOT STARPU_MPI_FOUND)
     set(STARPU_FOUND "FALSE")
   endif()
+
 endif(PKG_CONFIG_EXECUTABLE AND NOT STARPU_GIVEN_BY_USER)
 
 
-- 
GitLab