dev-cafe / autocmake

CMake plugin composer.
http://autocmake.org
BSD 3-Clause "New" or "Revised" License
41 stars 18 forks source link

Parse language field in YAML #194

Closed robertodr closed 7 years ago

robertodr commented 7 years ago

Parse language field in YAML to generate project(<PROJECT_NAME <PROJECT_LANGUAGE>) in CMakeLists.txt

Why? Delayed enabling of languages within the cc.cmake, cxx.cmake and fc.cmake causes CMake to load C and C++ as default languages for a project. This is in principle unnecessary for a project that only needs one language. The "only one language" behavior can be enforced by setting the language when declaring the project.

Questions

bast commented 7 years ago

Interesting. I did not know there was a difference between declaring a language with project or enable_language. I liked that the language was defined in one place and this is now lost but I think your suggestion is better although one could now declare Fortran in the YAML and then include C via the module.

The ternary is a bit terse but I can then expand it and add a comment.

Indeed the enable_language is now redundant.

Do the broken tests have anything to do with this PR? You mentioned over coffee that this might need more testing or was this something else?

robertodr commented 7 years ago

I did not know either. It came as a big surprise that for a Fortran-only project both the C and C++ compiler were searched for before the Fortran compiler. I think this need documenting inside Autocmake, i.e. that the language is set in the YAML file and in a module. If you don't have time writing docs, hold off merging until I can.

By the way, the language field in the YAML is now compulsory.

robertodr commented 7 years ago

The fc_omp test is broken, as it seems CMake checks for the C OpenMP flag even though the language is not defined. I am puzzled by the fact that the if(DEFINED CMAKE_<LANG>_COMPILER_ID) checks are in place and should avoid these scenarios...

bast commented 7 years ago

I cannot reproduce the problem locally. I will check whether this is linked to the CMake version.

bast commented 7 years ago

Can you please update your branch with latest changes on upstream master? Now testing CMake 3.8.0 instead of an arcane 2.8. Hopefully this will resolve the problem.

robertodr commented 7 years ago

Apologies for slow response. Fortran tests cases are failing Mac OS X.

bast commented 7 years ago

No problem - if somebody is slow then it's me. Just for my reference saving your good suggestion: "Try using a layer xcode image 7.3".

robertodr commented 7 years ago

And it worked! I think you can ignore the older XCode version on Travis. I will rebase and squash some of the commits so you get a cleaner history.

bast commented 7 years ago

Awesome! Thank you so much for this important change and also for your patience with this.