[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    [CMake] Mixted C++/Fortran library on Windows [resolved]
From:       Francis Giraldeau <francis.giraldeau () gmail ! com>
Date:       2019-02-20 21:22:28
Message-ID: CAC6yHM4T49c0CXWznqc2oRv50QWqXRGfD-rD39KkWCDPdRn7MQ () mail ! gmail ! com
[Download RAW message or body]

I just wanted to share a solution for mixing C++ and Fortran programs
on Windows using Visual Studio and Intel Fortran. The build was
failing at link time with undefined symbols comming from fortran code.
Actually, none of the fortran sources were compiled, even though it
was working fine on Linux using Makefiles.

When generating a shared library with both fortran and c++ sources like this:

    add_library(mix foo.f bar.cpp)

It produces the following .vcxproj (snippet):

  <ItemGroup>
    <ClCompile Include="C:\path\to\foo.f" />
    <None Include="C:\path\to\bar.cpp" />
  </ItemGroup>

The None compiler, well, does nothing.

The trick is to create two libraries, one for C++ code and the other
for the fortran code:

    add_library(foo foo.f)
    add_library(bar bar.cpp)

Then, both .vcxproj and .vfproj gets created and the fortran code is compiled.

It might be useful to document it somewhere. Perhaps it is already
documented and I haven't found it?

Cheers,

Francis
-- 

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:
https://cmake.org/mailman/listinfo/cmake


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic