[petsc-users] Using PETSc with CMake on Windows
John Fettig
john.fettig at gmail.com
Sun Mar 10 13:21:06 CDT 2013
Jed,
There was some conversion necessary on the paths, since the windows
compilers expect msdos style paths. Since PETSc already requires cygwin, I
figured it was a safe assumption that "cygpath" was available. Also,
Windows compilers need the whole library name (e.g. "libfoo" instead of
"foo" on linux). Finally, there is some nonsense required if PETSc was
built with the static runtime library.
The commit is here:
https://github.com/johnfettig/cmake-modules/commit/53ed281a37bfc1bfebdf5d6c0133de3e7901cba7
Let me know if you have any trouble with it. It works well with the NMake
generator. I was unable to test the Visual Studio generator because I
built PETSc with icl and CMake's Visual Studio generator doesn't like that.
For anybody else interested in using this, here is my CMakeLists.txt for
building one of the PETSc examples:
######
cmake_minimum_required (VERSION 2.6)
project (example)
set(PETSC_DIR $ENV{PETSC_DIR})
set(PETSC_ARCH $ENV{PETSC_ARCH})
set(CMAKE_MODULE_PATH C:/path/to/cmake-modules)
include(FindPETSc)
include_directories(${PETSC_INCLUDES})
add_executable(ex2 ex2.c)
target_link_libraries(ex2 ${PETSC_LIBRARIES})
######
Regards,
John
On Fri, Mar 8, 2013 at 4:53 PM, John Fettig <john.fettig at gmail.com> wrote:
> Ah, ok. I'll have a crack at it.
>
> Thanks,
> John
>
> On Fri, Mar 8, 2013 at 4:40 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> > I have not tested it on Windows so I would not be surprised if it does
> not
> > work. It should not be difficult to make work and I would happily accept
> > patches.
> >
> > On Mar 8, 2013 2:55 PM, "John Fettig" <john.fettig at gmail.com> wrote:
> >>
> >> Looking through the mailing list archives, I found a pointer to Jed's
> >> CMake module FindPETSc.cmake. Has this been tested on windows?
> >> Should this work when PETSc has been installed via make install? The
> >> directions given at the end of that say
> >>
> >> ====================================
> >> Install complete. It is useable with
> >> PETSC_DIR=/path/to/my/petsc/install [and no more PETSC_ARCH].
> >> Now to check if the libraries are working do (in current directory):
> >> make PETSC_DIR=/path/to/my/petsc/install test
> >> ====================================
> >>
> >> However, when I only set PETSC_DIR, CMake bails with
> >>
> >> CMake Error at FindPETSc.cmake:118 (message):
> >> The pair
> >> PETSC_DIR=/path/to/my/petsc/install
> >> PETSC_ARCH= do not specify a valid PETSc installation
> >> Call Stack (most recent call first):
> >> CMakeLists.txt:9 (include)
> >>
> >>
> >> -- PETSc could not be found. Be sure to set PETSC_DIR and PETSC_ARCH.
> >> (missing: PETSC_INCLUDES PETSC_LIBRARIES PETSC_EXECUTABLE_RUNS)
> >>
> >>
> >> Thanks for any help,
> >> John
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130310/3680c112/attachment.html>
More information about the petsc-users
mailing list