-
Notifications
You must be signed in to change notification settings - Fork 31
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
Rewrite CMake for robustness as both standalone library and part of Trelis plugin #68
Conversation
… the Trelis plugin and also as a standalone program has become more robust.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested this, but it looks like there are some missing pieces in the new version?
add_subdirectory(${CMAKE_SOURCE_DIR}/cli) | ||
endif() | ||
|
||
find_package(Eigen3 3.3 REQUIRED NO_MODULE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we still need to find Eigen3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not as far as I can tell. It finds it automatically for me. I could put it back in just in case though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked into this some more. As far as I can tell, this line wasn't doing anything in the first place. You would need to add the line include_directories(${EIGEN3_INCLUDE_DIRS})
for it to do anything.
The reason it worked despite this is that Eigen3 is located in /usr/include
, and you don't need to specify /usr/include
as a included directory because it's already included by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we always assume that Eigen is installed in the include path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this -- I'm going to re-introduce this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this line back in gives an error saying that it can't be used until CMake 3.0, so this can't be added without removing support for CMake 2.8. I'm going to add the line anyway and change the required version since 3.0 is still relatively ancient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gonuke if you find_package
eigen3 on a system with system eigen3, it sets EIGEN3_INCLUDE_DIR
to /usr/include/eigen3
. However, this directory is not useful because when we include eigen in the c++ files, we use the line #include <eigen3/Eigen/Eigen>
. Should these lines be changed to #include <Eigen/Eigen>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That change is probably the right thing to do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just pushed a commit that made this change. It added these lines:
find_package(Eigen3 3.3 REQUIRED)
message(STATUS "EIGEN3_INCLUDE_DIR: ${EIGEN3_INCLUDE_DIR}")
include_directories(${EIGEN3_INCLUDE_DIR})
edit: and it changed the #include
lines in the cpp files
CMakeLists.txt
Outdated
# IGEOM_DIR must be specified if mcnp2cad is being built as a standalone | ||
# library. If it is not specified, then CMake will assume that mcnp2cad is being | ||
# built as a part of a larger project which already knows the location of iGeom. | ||
if (IGEOM_DIR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should building the CLI be a trigger for standalone? Don't we need to find iGeom
headers somewhere even when building in the plugin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea. We could have a -DSTANDALONE
flag or something, and if it's standalone then it requires you to tell it where iGeom is and it builds the CLI automatically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an option for -DSTANDALONE_MCNP2CAD
. It defaults to on, but it is turned off in the Trelis-plugin config. If it is on, then it expects -DIGEOM_DIR
to be present and it builds the CLI.
volumes.hpp) | ||
|
||
# mcnp2cad library | ||
add_library(mcnp2cad SHARED ${MCNP2CAD_SRC_FILES}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this build find the iGeom
libraries when part of the plugin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this CMakeFile will be included via the add_subdirectory
command, CMake should already know what is meant when the iGeom
library is specified. It's no different than in DAGMC, when we build the dagmc
library, and everywhere else in the project we only need to specify dagmc
to link to that library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this was one of the complications of the circular system... perhaps it's only the iGeom
headers that need to be found when building as part of the plugin. This is were there is a gap between
- the
add_subdirectory
implementation in which it is difficult to pass in the location of headerse - the build directly from the parent directory in which you can take full control but may diverge from this package's build configuration
It would be great if there was a clean CMake-approved way to pass information into this build using the add_subdirectory
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I'm following what the problem is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have to try it to articulate more clearly, but using the add_subdirectory
method from the plugin will drop into this directory and run it's CMake. Building this library requires access to iGeom
headers, but those headers are not installed anywhere and I am not sure if there is a way to alter the list of include directories for this project from the CMake instance that calls it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we build mcnp2cad
as a part of the plugin, it knows where the iGeom headers are because we're also building iGeom
as a part of the plugin. The top-level Trelis-plugin CMakeFile includes the line
include_directories(iGeom)
which means that all CMakeFiles in subdirectories already have the iGeom headers available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK - I'll just have to try it. I know there was something not working correctly at some point...
I just realized that I made this branch in in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comments from Software review
I just confirmed that it is possible to build mcnp2cad as a standalone library (along with the CLI executable) on top of CGM which is built on top of OpenCascade. No guarantees that it works though. |
…arget_link_directories to specify locations of iGeom directories
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with these updates now. Thanks for your diligence, @ljacobson64!
I just realized that the mcnp2cad readme now contains wrong information. I could take some time to update it, or we could just leave it and update it later. |
I'm fine w/ making that a separate PR right after this one. |
@gonuke when you have time can you take another look? I think we're close to getting these Trelis-Plugin/mcnp2cad issues resolved. |
I left a couple of final comments. The most pressing one is about ensuring we can find Eigen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to submit review
add_library(mcnp2cad SHARED ${MCNP2CAD_SRC_FILES}) | ||
target_link_libraries(mcnp2cad iGeom) | ||
if (STANDALONE_MCNP2CAD) | ||
# Only install public headers if building standalone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the use case for installing headers if building standalone?. Or is this just in case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There used to be some reason why I thought this was needed, but I don't think it's needed anymore. I can remove it if you want, although I don't think it's hurting anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe they are necessary? In a world where a dev writes their own cli they'll need these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ljacobson64
This is a companion PR to svalinn/Cubit-plugin#56.