changes to cmake list to install rol as package#28
Conversation
dridzal
left a comment
There was a problem hiding this comment.
This looks good. Can you add to this PR the change to README.md that goes all the way to make install? Making this change would update the build instructions for our github website. Later, we can copy the instructions to rol.sandia.gov. Also, I am wondering if it would be possible to provide a (very) compact cmake project example that uses ROL, including the cmake file and a ROL::StdVector based example. It could go into Getting Started.
|
Can do - would you want to change make to cmake or ninja? I haven't tested with make install but I would assume it works. Re: cmake project example - I was thinking we put the MFEM example hook-up as well somewhere once that's up and running. But for the simple one, perhaps I can raise an issue and put it in a subsequent PR? |
You can just use make and make install. In your script, you can test it by deleting the line with ninja and just running plain make. Regarding the example, I was hoping that it would be compact enough to include in README.md, but it's ok to raise an issue. |
|
I'm not sure it would be compact enough to include in the "getting started". Would you want a whole example? To me it feels like a whole website section/page. |
Yes, it may be better to have this on rol.sandia.gov. |
GrahamBenHarper
left a comment
There was a problem hiding this comment.
I can confirm this works on Ubuntu with CMake 3.28.3 and gcc 13.3.0 by linking it against a minimal external example.
$ cmake .
-- CMAKE_PREFIX_PATH=
-- ROL_LIB=/home/gbharpe/Programming/cpp/rol/rol-install/lib/librol.so
-- ROL_INCLUDE_DIR=/home/gbharpe/Programming/cpp/rol/rol-install/include
-- Configuring done (0.0s)
-- Generating done (0.1s)
-- Build files have been written to: /home/gbharpe/Programming/cpp/rol/rol-examples
$ make
[ 50%] Linking CXX executable main
[100%] Built target main
$ ./main
Hello from ROL
$ cat main.cpp
#include <iostream>
#include "ROL_Ptr.hpp"
int main() {
ROL::Ptr<int> p;
std::cout << "Hello from ROL" << std::endl;
}
|
We should also include the cmake example. |
initial build changes for parameterlist cpp circular reference
GrahamBenHarper
left a comment
There was a problem hiding this comment.
ROL_config.h is only created in the build directory but not the install directory, so we need to make sure that also gets copied into the install directory
GrahamBenHarper
left a comment
There was a problem hiding this comment.
These should fix one problem, but I still see those Teuchos linker errors, which might be a little more tricky
|
|
||
| message(STATUS "ROL directory is: ${ROL_DIR}/include") | ||
| include_directories("${ROL_DIR}/include") #one down for all files | ||
| include_directories("${ROL_DIR}/lib/librol.so") |
There was a problem hiding this comment.
You can remove the bottom line include_directories("${ROL_DIR}/lib/librol.so") and just include the include directory
| enable_language(C) | ||
| enable_language(CXX) | ||
|
|
||
| message(STATUS "ROL directory is: ${ROL_DIR}/include") |
There was a problem hiding this comment.
You're missing the actual link against the ROL library. Here's the minimum amount of boilerplate to link against the library that I use for my code. Note the add_executable and target_link_libraries in your case will be slightly differently named
| message(STATUS "ROL directory is: ${ROL_DIR}/include") | |
| message(STATUS "ROL directory is: ${ROL_DIR}/include") | |
| include_directories("${ROL_DIR}/include") #one down for all files | |
| find_library(ROL_LIB NAMES rol librol PATHS ${ROL_DIR}/lib NO_DEFAULT_PATH) | |
| if(ROL_LIB) | |
| message(STATUS "We found ROL!") | |
| else() | |
| message(FATAL_ERROR "ROL library not found!") | |
| endif() | |
| add_library(rol::rol UNKNOWN IMPORTED) | |
| set_target_properties(rol::rol PROPERTIES IMPORTED_LOCATION "${ROL_LIB}") | |
| add_executable(main main.cpp) | |
| target_link_libraries(main PRIVATE rol::rol) | |
Co-authored-by: Graham Harper <GrahamBenHarper@users.noreply.github.com>
Modified the cmake file to allow for rol to be built as a package.