Skip to content

Build fixes #5

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

Closed
wants to merge 2 commits into from
Closed

Build fixes #5

wants to merge 2 commits into from

Conversation

nschloe
Copy link

@nschloe nschloe commented Apr 12, 2015

This pull request adds project(Albany CXX C Fortran), a command that sets important CMake-internal variables crucial for find_package(). It also enforces proper compiler selection which now has to happen on terminal level when cmake is invoked, e.g.,

CXX=mpicxx \
CC=mpicc \
FC=mpif90 \
cmake \
  ../../source

If the selected compilers don't match the Trilinos compilers, an error is thrown.
With the changes of this PR, find_package(Trilinos REQUIRED) works are expected.

The PR also fixes underlinking in libAlbany and libAlbanySTK (see bug #3).

nschloe added 2 commits April 10, 2015 22:31
This set some very important global variables and makes sure that finding
modules works as expected.
As a side effect, compilers cannot be explicitly set according to Trilinos'
configuration. This shouldn't happen in the main CMakeLists.txt anyways,
though.
@ambrad
Copy link
Contributor

ambrad commented Apr 12, 2015

Hi Nico,

Could you explain a bit more about the requirement that the compilers be specified in the Albany cmake config line? My understanding is that currently that information is provided by the Trilinos install's TrilinosConfig.cmake. Albany reads that information and sets the compilers accordingly. Hence I think the Albany build's compilers are automatically consistent with the Trilinos ones.

Thanks,
Andrew

@nschloe
Copy link
Author

nschloe commented Apr 12, 2015

The project() line is needed for getting find_package to work, and one cannot set compilers after project(Albany C CXX Fortran). See Brad King's (one of the core CMake devs) comment from here:

CMAKE__COMPILER should not be set after a language is enabled by the project() or enable_language() command. Normally it should not be set in your CMakeLists.txt code at all.

(One can certainly find a reference in the CMake docs for that, too.) The error-on-compiler-mismatch is the best way I've found dealing with this. See the sample do-configures for Nosh.

@nschloe
Copy link
Author

nschloe commented Apr 12, 2015

Btw, do we really need C and Fortran compilers here?

@ambrad
Copy link
Contributor

ambrad commented Apr 12, 2015

Let's back up a bit. Currently, Albany's CMakeLists.txt does this:

SET(CMAKE_CXX_COMPILER ${Trilinos_CXX_COMPILER} )
SET(CMAKE_C_COMPILER ${Trilinos_C_COMPILER} )
SET(CMAKE_Fortran_COMPILER ${Trilinos_Fortran_COMPILER} )

Then, a few lines later, it issues the project command:

PROJECT(Albany)

Perhaps we could modify this line to

PROJECT(Albany C CXX Fortran)

as you suggest. But I don't see why we can't continue to use the Trilinos_*_COMPILER data. I might be missing something, but the current procedure seems to prevent mismatch errors entirely, and it saves users and tests build scripts from having to manually map Trilinos compilers -> Albany compilers.

@nschloe
Copy link
Author

nschloe commented Apr 12, 2015

But I don't see why we can't continue use the Trilinos_*_COMPILER data.

project() needs to be set before find_package(), and for some reason you cannot set the compilers in CMake after project().

@ambrad
Copy link
Contributor

ambrad commented Apr 12, 2015

Is the requirement that PROJECT be set before FIND_PACKAGE new?

@nschloe
Copy link
Author

nschloe commented Apr 12, 2015

Not that I knew, and I don't know the details. I vaguely remember having had similar problems once. I'll hit the CMake mailing list to gather some details on this.

@nschloe
Copy link
Author

nschloe commented Apr 13, 2015

http://public.kitware.com/pipermail/cmake/2015-April/060322.html:
Trilinos installs its export files into lib/<multiarch-tuple> (see http://www.cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html, and option supported by TriBits), so Albany's CMake has to be aware of the architecture before package can be found. The architecture is determined in project().
@ambrad, you might not have experienced this error if you have installed all of Albany's dependencies into architecture-independent directories.

@ambrad
Copy link
Contributor

ambrad commented Apr 14, 2015

All,

I'm not going to accept this pull request at this time. Another Albany dev should feel free to do so if desired.

My reasoning is as follows. Nico brings up a good point about Albany's configuration: evidently, Albany won't configure correctly with the PROJECT and FIND_PACKAGE order currently used if Trilinos is configured with -DTrilinos_USE_GNUINSTALLDIRS:BOOL=ON. However, the order that is used allows Albany to determine the compilers used to build the Trilinos installation, thus saving having to specify them again. I prefer to keep this feature.

Additionally, at least at this time, Albany's configuration seems not to be preventing Nico's progress on his modifications to I think Tribits, so I don't feel that there's any immediate need to make a decision on this configuration issue. Again, others should feel free to chime in.

Thanks,
Andrew

@ambrad
Copy link
Contributor

ambrad commented Apr 14, 2015

We might introduce an option to distinguish between Nico's preferred build behavior (representing users who want to use the Trilinos_USE_GNUINSTALLDIRS=ON installation configuration) and the current build.

@ambrad
Copy link
Contributor

ambrad commented Apr 20, 2015

Changes committed. Nico tested these. Closing this PR. Thanks Nico!

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