[CMake] Creating DLL from FORTRAN code

Doron Klepach klepachd at gmail.com
Wed Feb 25 08:21:37 EST 2015


Hello Petr,

Thank you for the quick reply. At this point I am not getting any errors,
but nothing happens when I build the sln in Visual Studio -> no dll is
created.
Here is the main CMake code:

cmake_minimum_required (VERSION 3.1)
project (micro_linMatl_I)
enable_language (Fortran)

# The version number.
set (micro_linMatl_I_VERSION_MAJOR 4)
set (micro_linMatl_I_VERSION_MINOR 0)

#include all the required modules from the folder "Modules"
include_directories ("${PROJECT_SOURCE_DIR}/Modules")
set (EXTRA_LIBS ${EXTRA_LIBS} Modules)

ADD_Library(micro_linMatl_I SHARED ${EXTRA_LIBS})
SET_TARGET_PROPERTIES(micro_linMatl_I PROPERTIES LINKER_LANGUAGE Fortran)
target_link_libraries (micro_linMatl_I  ${EXTRA_LIBS})

and here is the one in the folder "Modules"

add_library(Modules mod1.F90 mod2.F90 ...)

Thank you for your help,
Doron

On Wed, Feb 25, 2015 at 3:07 PM, Petr Kmoch <petr.kmoch at gmail.com> wrote:

> Hi Doron,
>
> it would be helpful if you provided the error you're getting from
> add_library(), and also showed the exact CMake code you used.
>
> Petr
>
> On Wed, Feb 25, 2015 at 1:57 PM, Doron Klepach <klepachd at gmail.com> wrote:
>
>> Hello there,
>>
>> I am new to CMake and I am trying to convert a project to work with CMake.
>>
>> As a part of the process I need to create a DLL from a FORTRAN code.
>>
>> Here are some details:
>> *The code works on Visual Studio and creates the DLL as required.
>>
>> *The main subroutine looks like this:
>>
>> subroutine sub1(var1,var2 ...)
>>
>> !DEC$ ATTRIBUTES DLLEXPORT      :: sub1
>>
>> ...
>>
>> ens subroutine sub1
>>
>> * I looked at the CMake command
>>
>> add_library(<name> [STATIC | SHARED | MODULE]
>>             [EXCLUDE_FROM_ALL]
>>             source1 [source2 ...])
>>
>> and tried the SHARED option, but that did not work, giving an error.
>>
>> * I looked at several sources for help, including
>> http://www.kitware.com/blog/home/post/231
>>
>> but I was not able to figure out how to create the DLL (the link to the example is not working)
>>
>> I would appreciate a simple example that shows how to do this.
>>
>> Thank you for your help,
>>
>> Doron
>>
>>
>>
>> --
>>
>> 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/20150225/c708668e/attachment.html>


More information about the CMake mailing list