[CMake] CheckFortranSourceCompiles alternative for cmake 2.8.12

victor sv victorsv at gmail.com
Tue Feb 23 11:34:49 EST 2016


HI again,

I'm using TRY_COMPILE in a MPI Fortran project with CMake 2.8.11 to check
if the mpi.mod file is compatible with the current Fortran compiler.

The CMake code snippet is as follows:

...
    FIND_PATH(MPI_MOD_FOUND mpi.mod  PATHS ${MPI_Fortran_INCLUDE_PATH})
    IF(MPI_MOD_FOUND)
        TRY_COMPILE(FORTRAN_COMPILER_MATCH_MPI_MOD
                    ${PROJECT_BINARY_DIR}
                    ${SERIAL_TESTS_PATH}/try_compile_mpi_mod.f90
                    CMAKE_FLAGS

"-DINCLUDE_DIRECTORIES:STRING=${MPI_Fortran_INCLUDE_PATH}"
                        "-DLINK_LIBRARIES:STRING=${MPI_Fortran_LIBRARIES}")
...

And the Fortan code of try_compile_mpi_mod.f90 is:

program test
use mpi
end program

this is the best choice to ensure the compatibility of current Fortran
compiler and the Fortran compiler used to compile the linked MPI library?

Thanks in advance.

Best regards,
Víctor



2016-02-23 12:46 GMT+01:00 victor sv <victorsv at gmail.com>:

> Thanks Pter!
>
> Is the solution I was looking for. Great, it works as expected! :)
>
>
> 2016-02-23 12:31 GMT+01:00 Petr Kmoch <petr.kmoch at gmail.com>:
>
>> Hi Victor,
>>
>> have a look at the try_compile() command (
>> https://cmake.org/cmake/help/v2.8.12/cmake.html#command:try_compile ),
>> especially the second signature (the one which takes SOURCES).
>>
>> Petr
>>
>> On Tue, Feb 23, 2016 at 11:56 AM, victor sv <victorsv at gmail.com> wrote:
>>
>>> Hi all,
>>>
>>> I've seen that in CMake 3.0 appeared the nice CheckFortranSourceCompiles
>>> feature.
>>>
>>> Currently, common SO's like Ubuntu 14 includes CMake 2.8.12.2, but not
>>> CMake 3.0 or higher. I would like to check if a very small Fortran test
>>> program compiles using CMake 2.8.12.2, is this possible? how can i do that?
>>>
>>> Best regards,
>>> Víctor.
>>>
>>> --
>>>
>>> Powered by www.kitware.com
>>>
>>> Please keep messages on-topic and check the CMake FAQ at:
>>> http://www.cmake.org/Wiki/CMake_FAQ
>>>
>>> Kitware offers various services to support the CMake community. For more
>>> information on each offering, please visit:
>>>
>>> CMake Support: http://cmake.org/cmake/help/support.html
>>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://public.kitware.com/mailman/listinfo/cmake
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160223/19d6f762/attachment-0001.html>


More information about the CMake mailing list