-
Notifications
You must be signed in to change notification settings - Fork 262
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
Suggestion for root CMakeLists.txt #175
Comments
Thanks -- I'll take a look. |
@Fabian188 Very useful! It works fine for me. |
Making a confusion in my various tests, I also needed to propagate the CMAKE_INSTALL_PREFIX:
|
@fabiencastan thanks for the input. I just created a fork SuiteSparse-root-cmake and included your suggestion. Feel free to suggest more :) |
What I do not like with this approach is, that a "make" implies a "make install". This is probably due to the external projects. |
@Fabian188 Do you have a link to your proposal? Or could you create a draft PR? |
@DrTimothyAldenDavis I'm currently trying to fix this automatic make install issue. |
Honestly, I beliefe a real central cmake configuration is a much better solution.
One could e.g. configure once and then select modules via ccmake or by make AMD, make CHOLMOD, ... This would be much more work than my approach but in the end the solution is IMHO the better one with much less total cmake code. Central cmake configuration have been realized by https://github.com/jlblancoc/suitesparse-metis-for-windows and https://github.com/sergiud/SuiteSparse. We actually have a own very old solution of my former colleague Simon Triebenbacher which consists of 20 CMakeLists.txt with a total of 700 lines, where the current SuiteSparse 6.0.0 has 35 CMakeLists.txt with a total of 20K lines. I'm happy to share Simon's outdated solution (he'll be happy, too). |
I solved the instant make install. Now the procedure is as common:
|
Not sure, if the use of |
I also would prefer a central root CMakeLists.txt with add_subdirectory(). However the subprojects are currently independent projects with a total of 20K cmake lines and would require a lot cmake changes. There are forks doing exactly this, is e.g. Sergui's at https://github.com/sergiud/SuiteSparse |
Thanks for the link, I wasn't aware of that fork. Should have read all comments before posting. |
I'm very reluctant to add a top-level CMakeLists.txt file. It would essentially merge all of the suitesparse packages into a single package with a single build folder. That would require lots of changes to each package cmake build system, and it would make suitesparse monolithic. Currently, the suitesparse packages are a la carte. End users and pick and choose which they want, and build each independently. This is essential for licensing issues. Each package has a different license -- some GPL, some LGPL, some Apache, some BSD, and one mixed (CHOLMOD: GPL and LGPL). End users who can only use LGPL, Apache, and BSD, for example, can simply remove the GPL packages. Right now, the top-level Makefile is optional, and each package can just be built as its own package. |
I don't think it would make suitesparse monolithic. You could add options to select each package individually and use the My view is from the perspective of a package maintainer for the source-based Gentoo Linux distribution. While the package is being released as a single tarball, we have to maintain several packages with different versioning, instead of a single package with options to build and install each of the suitesparse packages. It could make the life of maintainers easier if we would have the possibility of a top-level CMakeLists.txt. |
Thanks for the feedback. I'll consider it in a future release (after I post v6.0.2, which should appear soon). |
v7.0.0.beta1 is now posted. I'll be considering this for v7.1.0 in the near future. I do agree it would make life easier for Windows users, as something to use in place of my simple (but linux/mac only) top-level Makefile. |
I have created a CMake file to build all modules independently. I don't think using ExternalProject violated any license since the codes are not even copied during the building stages. |
We have something like this in progress. There are lots of pending changes to the SuiteSparse build system, in the various development branches. |
Thank you for the reply. What about the suggestions i made here #309 ? As I know, these install ( TARGETS amd_static
EXPORT ${PROJECT_NAME} #Export a target that can be install as SuiteSparse::amd_static
ARCHIVE DESTINATION ${SUITESPARSE_LIBDIR} )
target_include_directories(amd_static INTERFACE
$<INSTALL_INTERFACE:${SUITESPARSE_INCLUDEDIR}>) #set the interface header dir
install (EXPORT ${PROJECT_NAME}
FILE ${PROJECT_NAME}Config.cmake
NAMESPACE SuiteSparse::
DESTINATION ${CMAKE_INSTALL_PREFIX}/cmake) #install the cmake config modules |
The CMake build rules are modified to export targets instead of modules now. (There can still be improvements to them. But the basic transition should be complete.) If we'd like to replace the root Makefile by a root CMakeLists.txt, we'd probably need to add support for all existing Makefile targets. |
From my experience with ctest, there needs to be a tool doing the decision and returning either 0 (ok) or another value (at least return values >= 1 indicate errors). I quickly checked cs_demo1/2/3.c and it seems that these always return 0 within main. If one does still want to run all tests and not exit on the first failing function, the tests could return an error value, main could sum the return values and return it for the demo. So only if all functions return 0, the result will be 0. |
Yes, those are all passing tests. I would need to work through all my packages to revise the demos to return 0 from the main program, to make them suitable for ctest, however. I am not sure if I do that now. I've used ctest a bit, but not in my own package. LAGraph is a package I contribute to quite a bit as a co-author, and it has a ctest (I didn't write the ctest framework, but I do write tests in LAGraph for ctest). See https://github.com/GraphBLAS/LAGraph . At some point (soon) when LAGraph becomes reasonably stable, I will mirror it inside SuiteSparse. It's a package that relies on GraphBLAS to solve graph problems (or any library that implements the GraphBLAS C API, in particular, not just SuiteSparse/GraphBLAS). A ctest framework would be a very good idea to add in the future. It will take me a while to get to this though. It wouldn't be necessary for a top-level cmake build system to enable all existing Makefile targets, at least at first. ctest would be nice. I also have a top-level "make cov" which does test coverage in all packages. Those tests are substantial but only work on Linux. Most work on the Mac I think. I doubt any would work (as is) on Windows. The GraphBLAS test coverage is a very strange one: it has to be run inside MATLAB, and it requires my own test coverage mechanism because you can't do statement coverage of a C code called by MATLAB using existing tools. It takes about 2 hours to run. I've run it on Mac and Linux; I don't think it works on Windows but it might. |
In the light of #383 and #408: Are SuiteSparse libraries meant to be compilable as stand-alone projects? |
I didn't write the original LAGraph CMakeLists.txt. I can't recall why it got added. I think it's an attempt to pick up a non-SuiteSparse GraphBLAS, but that should be handled by FindGraphBLAS.cmake anyway (if there is another version). So let's delete that line. |
The original reason for that line is here, in the comments: |
I opened #552 that deletes that line. |
I'll have a few more changes as I sync the SuiteSparse/LAGraph v1.1 with the original LAGraph repo. So far it's looking good; just one tiny change to the LAGraph/CMakelists.txt. I'll push that to SuiteSparse shortly. |
These changess allow LAGraph to use GraphBLAS 7.1.0 (using its old build system, and older style FindGraphBLAS.cmake), and it allows LAGraph to be built outside of SuiteSparse: The LAGraph/CMakeLists.txt file doesn't change much. Just the place where it doesn't find itself inside SuiteSparse. I had to copy the SuiteSparsePolicy.cmake into the LAGraph/cmake_modules, which is a bit unfortunate, but it works. |
I freshly cloned
And compilation fails
Interesting that it does fail for Apple clang version 15.0.0 but not vanialla clang 17, often I have similar issues on both - for IntelLLVM (also clang based) the issues are more often different. I suggest to handle this for "AppleClang". |
Does the following change fix the error for you? diff --git a/CHOLMOD/Supernodal/t_cholmod_super_numeric_worker.c b/CHOLMOD/Supernodal/t_cholmod_super_numeric_worker.c
index 8cec363cb..fdfee8f29 100644
--- a/CHOLMOD/Supernodal/t_cholmod_super_numeric_worker.c
+++ b/CHOLMOD/Supernodal/t_cholmod_super_numeric_worker.c
@@ -9,6 +9,7 @@
//------------------------------------------------------------------------------
#include "cholmod_template.h"
+#include "SuiteSparse_config.h"
// Template routine for cholmod_super_numeric. All xtypes supported, except
// that a zomplex A and F result in a complex L (there is no supernodal zomplex |
No, same error. |
This is the same problem: you are getting a stale SuiteSparse_config.h. The old SuiteSparse_config.h does not have macros that wrap the single precision BLAS. THe new one does. So you're getting an old SuiteSparse_config.h from somewhere. |
Could you please run |
This might help with the search order of include and library directories. Use OpenMP CMake target instead of library and include folder names. Maybe helps with the issue described in DrTimothyAldenDavis#175.
I should revise all of my public headers to make them check version numbers of my other packages they rely on. They would #error in the C/C++ preprocessor if the version is outside a valid range. The error message would be more clear than something like "Suitesparse BLAS ssyrk not defined" from the compiler. All my packages have #defined package_VERSION_* macros just for this purpose. For example, cholmod 5.1.0 requires suitesparse_config 7.4.0 and will die badly (what you see here) if it finds an older Suitesparse_config.h. |
Here you are - I'm quite busy today and almost not at my computer |
You are right, there is a SuiteSparse_config.h in my /usr/local/include from nov 2022.
I still have it after removing the file in /usr/local/include and cmake --fresh. It compiles with the suppression of the warning. |
This might help with the search order of include and library directories. Use OpenMP CMake target instead of library and include folder names. Maybe helps with the issue described in DrTimothyAldenDavis#175.
It looks like OpenMP is adding that path to the include directories:
I'll try and propose some changes. Fwiw, it's the following for me (using Clang/MinGW):
|
AAIK installing an external OpenMP is still the necessary variant for macOS. So all developers shall have this configuration. But note, that the issues were on /usr/local/include. brew is a common packager for macOS. With x86_64 it used /usr/local to install code. With arm64 the arm64 compiled tools are by default installed to /opt/homebrew. However one can run the x86_64 binaries from /usr/local transparently via emulation.
Sure, I'll respond whenever it is possible. The question is no how to compile SuiteSparse out of the box on macOS, right? |
in /opt/homebrew/include I again have the headers, now more recent
|
It compiles with Homebrew on macOS in the CI on GitHub. However, the CI doesn't install an older version of the SuiteSparse libraries before building. So, issues like the one you are seeing can go unnoticed... |
IIUC, you'd need the headers from version 7.4.0 (or newer). That (together with the OpenMP include directory) could explain the C99 error... |
@DrTimothyAldenDavis: We can't do anything about older versions. But could the headers of the SuiteSparse libraries be installed in a sub-directory (e.g., Probably not something that should be changed for the current release (or ever). But maybe for a later release? Edit: Looking at the commit log, this is probably not a new issue. But it might have gone unnoticed so far because there weren't any breaking changes in SuiteSparse_config.h in a long time... |
with this change to the dev2 branch: |
Yes, if the SUITESPARSE_BLAS_ssyrk is being seen as an undeclared function, then you're getting a stale SuiteSparse_config.h. Their would be many other errors as well. I have a stale SuiteSparse_config.h in /usr/local/include on my Mac, because that's where "make install" in SuiteSparse installs itself, and I had my own (old) copy there. But doing a fresh build doesn't bring that in. The old one is version 7.2.0, and the new one is 7.4.0, and none of my #error's trigger, at least with this update on the dev2 branch. |
The root CMakeLists.txt file is working well in the prerelease (SuiteSparse 7.4.0.beta1). Shall I close this issue? |
Thanks both of you very much for your effort! I close the issue. Possibly I suggest in the future variants of handling the root CMakeLists.txt. |
Thanks again for the suggestion and for the help in testing it. |
I propose a simple CMakeLists.txt
It makes use of the SuiteSparse CMake files via cmake external projects and just adds the root CMakeLists.txt.
This is just a template with a small selection of options to demonstrate how it could be re realized.
I'm far from a CMake guru but it appears as an appropriate way for a simple wrapper for the original SuiteSparse CMake structure.
Please feel free to use and modify the file as you like. I wrote it myself and as it is so small and easy I put it into public domain without any restrictions - no need to mention me.
Example usage for an empty SuiteSparse folder: mkdir mybuild; cd mybuild; ccmake ..
When changing the CMakeLists.txt for some major changes it is necessary to clean the build directory (here mybuild) and call make clean of SuiteSparse. I testet it with dev2 from Nov 10
CMakeLists.txt
The text was updated successfully, but these errors were encountered: