-
Notifications
You must be signed in to change notification settings - Fork 19
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
omp module logic troubled by newer cmake #247
Comments
Thanks Lori! I will try to reproduce this. |
I believe there is a problem but at this moment cannot reproduce it with CMake 3.9.6 and GNU 8.1.0. I probably use a different compiler. Using which compilers do you observe this? |
I'm on cmake 3.9.4 and gcc 7.2.0 (from conda). conda gfortran isn't providing |
OK thanks. It would be nice if we could query |
We could for each language check whether either |
Yes, I was just going to ask if there'd be forseeable trouble with |
I expect no trouble. Not sure what to do with the if(DEFINED CMAKE_C_COMPILER_ID)
if(OPENMP_FOUND OR OPENMP_C_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
endif()
endif()
# etc. for the other languages On the other hand the "proper" way for 3.9 and above is actually this: |
The |
You mean shipping the latest |
I'll experiment with those lines, thanks. I'm a huge fan of the imported target in general. But I don't dare do it here b/c of the problem I was discussing with @robertodr about needing to suppress |
You can still get the flags out from the new module (though that might be on its way to deprecation) |
By as-is on the definitions, you mean set when C found, @robertodr? Or potentially added three times if all langs enabled? |
Gee, what a mess! No we definitely don't want that, so I guess either they spill over to the client:
or it spills over to the compiler flags:
quite ugly in both cases, but I'd rather prefer the former: explicit is better than implicit (of sorts) and you get to choose the name of the preprocessor definition! @bast, yes that's what I meant. I recall it didn't work out for |
I'm going with
|
Definitely more compact. |
Well, 7 lines where there used to be 1. But I don't see another dumb way around it (classifying your sol'ns as "smart" cmake uses). |
Don't know it mine was "smart". Yours is compact wrt spilling variables over to other CMake files. |
For more compactness we can add a foreach looping over the languages. I think we should rename this module to omp-flags since it's really only about flags. I will test backwards compatibility of recent find module and sleep on this issue and then tomorrow comment more and/or send a PR based on our findings. |
Using latest FindOpenMP.cmake with older versions of CMake does not work. Already 3.5 chokes on it. |
Don't consider Psi4 as a an impediment to bumping min supported cmake version. For one, all the repos have their own copies of the autocmake file. For second, someday when need is pressing and the blas/omp detection landscape is cleaner, I'll probably bump the p4 ecosystem to 3.9 or whereever all the Intel/OMP/MPI goodies are. conda is distributing 3.11 now, so access not a problem. |
We (the editorial we :-) are not super sure yet which minimum we want to support (#243) but until we settle that, probably as far back as 2.8 and mostly because of more conservative codes than Psi4. I will send a PR and let you both review it and we go from there. |
changes: - append flags if either OPENMP_FOUND OR OpenMP_${_lang}_FOUND - do not set OPENMP_FOUND - make version dependence of workaround for CMake < 3.5 more explicit - do not add_definitions(-DHAVE_OPENMP) - rename to omp-flags.cmake to be more explicit and to not silently drop -DHAVE_OPENMP
FYI, cmake 3.11 (but not 3.9) gets around my initial problem by letting you specify a subset of the enabled langs to search for |
3.10 is the exact introduction date of the components mentioned above. fyi, libraries returned in the
and all that can be copied into a new target via
|
Thank you for the information! I will revise #248. |
I pinged you on psi4/psi4#1031 and would be glad of any comments on that new OpenMP-finding scheme. Most everything is centered in https://github.com/loriab/psi4/tree/openblas/external/common/lapack . The FindTargetOpenMP.cmake file within is most relevant to this autocmake issue. It finds an OpenMP target with modern cmake or constructs one to compensate in old cmake. I know autocmake doesn't deal much with targets, but the usual variables can just read off the target. Also the psi one is CXX only, so extensions would need be be made for other langs. |
Thanks! I will look at it. Also I will finally restart work on this issue hopefully today. |
I don't think the autocmake OpenMP module is playing nicely with modern Kitware OpenMP module.
In particular, when C/CXX/Fortran are active languages, if FindOpenMP finds flags & libs for C & CXX but not for Fortran, then
OPENMP_FOUND
is False, so no flags get added to CMAKE__FLAGS in this section. But then Fortran does pick up flags in this section b/c empty from previous. So net result (cmake 3.9) is that only C/CXX openmp detected by kitware module, but only CMAKE_Fortran_FLAGS end up with any openmp flags after passing through autocmake_omp.The text was updated successfully, but these errors were encountered: