Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPEX: Try to put MPFR and GMP include directories last. #566

Merged
merged 1 commit into from
Dec 3, 2023

Conversation

mmuetzel
Copy link
Contributor

@mmuetzel mmuetzel commented Dec 3, 2023

IIUC, CMake adds system include directories always after "normal" include directories. Try to add the include directories last in the order by making them system include directories and adding the keyword AFTER.

Tbh, it's not entirely clean why CMake decides to add some of the include directories as system include directories. But this change might help to work around #565.

@DrTimothyAldenDavis DrTimothyAldenDavis merged commit e442d82 into DrTimothyAldenDavis:dev2 Dec 3, 2023
24 checks passed
@DrTimothyAldenDavis
Copy link
Owner

SPEX still fails, if SPEX is built with "cd SPEX/build ; cmake .." etc. It gets the stale headers for all 3 packages: SuiteSparse_config, AMD, and COLAMD.

In the root CMakeLists (cd SuiteSparse/build ; cmake .. ; " etc, SPEX finds the correct SuiteSparse_config, but not AMD or COLAMD. That was a parallel build and if I slow it down with "VERBOSE=1 ; make -j1" it fails on CHOLMOD first (getting the wrong headers for AMD, COLAMD, CAMD, and CCOLAMD).

@mmuetzel
Copy link
Contributor Author

mmuetzel commented Dec 3, 2023

Could you please show the failing compiler command?

I guess the fact that SuiteSparse_config depends on OpenMP and most of the SuiteSparse libraries depend on SuiteSparse_config makes that the folder where OpenMP installed its headers is added quite early...

@mmuetzel
Copy link
Contributor Author

mmuetzel commented Dec 3, 2023

Does the following change make a difference?

diff --git "a/SuiteSparse_config/CMakeLists.txt" "b/SuiteSparse_config/CMakeLists.txt"
index 1ff9b66f6..b2c31f91f 100644
--- "a/SuiteSparse_config/CMakeLists.txt"
+++ "b/SuiteSparse_config/CMakeLists.txt"
@@ -146,11 +146,13 @@ if ( OpenMP_C_FOUND )
     message ( STATUS "OpenMP C flags:          ${OpenMP_C_FLAGS} ")
     if ( BUILD_SHARED_LIBS )
         target_link_libraries ( SuiteSparseConfig PRIVATE OpenMP::OpenMP_C )
-        target_include_directories ( SuiteSparseConfig PUBLIC
+        target_include_directories ( SuiteSparseConfig SYSTEM AFTER PUBLIC
             "$<TARGET_PROPERTY:OpenMP::OpenMP_C,INTERFACE_INCLUDE_DIRECTORIES>" )
     endif ( )
     if ( BUILD_STATIC_LIBS )
-        target_link_libraries ( SuiteSparseConfig_static PUBLIC OpenMP::OpenMP_C )
+        target_link_libraries ( SuiteSparseConfig_static PRIVATE OpenMP::OpenMP_C )
+        target_include_directories ( SuiteSparseConfig_static SYSTEM AFTER PUBLIC
+            "$<TARGET_PROPERTY:OpenMP::OpenMP_C,INTERFACE_INCLUDE_DIRECTORIES>" )
     endif ( )
 endif ( )
 

@DrTimothyAldenDavis
Copy link
Owner

Here's the failed command when I remove my hack and revert to a clean copy of dev2, with added linebreaks for readability:

Consolidate compiler generated dependencies of target SPEX
/Library/Developer/CommandLineTools/usr/bin/make  -f CMakeFiles/SPEX.dir/build.make CMakeFiles/SPEX.dir/build
[  1%] Building C object CMakeFiles/SPEX.dir/SPEX_Left_LU/Source/SPEX_Left_LU_backslash.c.o

/Library/Developer/CommandLineTools/usr/bin/cc -DSPEX_EXPORTS
-I/Users/davis/dev2/SuiteSparse/SPEX/build 
-I/Users/davis/dev2/SuiteSparse/SPEX
-I/Users/davis/dev2/SuiteSparse/SPEX/SPEX_Left_LU/Source
-I/Users/davis/dev2/SuiteSparse/SPEX/SPEX_Util/Source
-I/Users/davis/dev2/SuiteSparse/SPEX/Include
-I/Users/davis/dev2/SuiteSparse/SPEX/SPEX_Left_LU/Demo 
-isystem /Users/davis/dev2/SuiteSparse/SuiteSparse_config 
-isystem /usr/local/include
-isystem /opt/homebrew/include 
-isystem /Users/davis/dev2/SuiteSparse/AMD/Include 
-isystem /Users/davis/dev2/SuiteSparse/COLAMD/Include
-O3 -DNDEBUG -std=gnu11 -arch arm64 
-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk
-mmacosx-version-min=13.6 -fPIC -MD -MT
CMakeFiles/SPEX.dir/SPEX_Left_LU/Source/SPEX_Left_LU_backslash.c.o -MF
CMakeFiles/SPEX.dir/SPEX_Left_LU/Source/SPEX_Left_LU_backslash.c.o.d -o
CMakeFiles/SPEX.dir/SPEX_Left_LU/Source/SPEX_Left_LU_backslash.c.o -c
/Users/davis/dev2/SuiteSparse/SPEX/SPEX_Left_LU/Source/SPEX_Left_LU_backslash.c

In file included from /Users/davis/dev2/SuiteSparse/SPEX/SPEX_Left_LU/Source/SPEX_Left_LU_backslash.c:45:
In file included from /Users/davis/dev2/SuiteSparse/SPEX/SPEX_Left_LU/Source/spex_left_lu_internal.h:18:
/Users/davis/dev2/SuiteSparse/SPEX/SPEX_Util/Source/spex_util_internal.h:114:2: error: "SPEX requires AMD 3.3.0 or later"
#error "SPEX requires AMD 3.3.0 or later"
 ^
/Users/davis/dev2/SuiteSparse/SPEX/SPEX_Util/Source/spex_util_internal.h:118:2: error: "SPEX requires COLAMD 3.3.0 or later"
#error "SPEX requires COLAMD 3.3.0 or later"
 ^
2 errors generated.

@DrTimothyAldenDavis
Copy link
Owner

Does the following change make a difference?

trying it now.

@mmuetzel
Copy link
Contributor Author

mmuetzel commented Dec 3, 2023

Which version of CMake do you use?
IIUC, starting with CMake 3.25, imported targets are treated as system includes by default:
https://cmake.org/cmake/help/latest/prop_tgt/SYSTEM.html

Maybe, we could change that?

@DrTimothyAldenDavis
Copy link
Owner

On my mac I'm using cmake 3.27.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants