[CMake] Creating DLL from FORTRAN code

Petr Kmoch petr.kmoch at gmail.com
Wed Feb 25 08:47:36 EST 2015


You're not giving the DLL micro_linMatl_l any source files, so there's
nothing to build. You need to list at least one source file in the
add_library() call. You mentioned a main subroutine in your first e-mail;
the file containing the main subroutine should be listed in the
add_library(SHARED) call.

Your use of ${EXTRA_LIBS} in that command is strange - from what I can
tell, it only contains a directory name, which should definitely not be
listed.

include_directories() controls the compiler switch which specifies paths to
look for include files. If you have a CMakeLists.txt file in Modules and
want to process that, you need add_subdirectory().

You should probably look at some CMake tutorials or example simple CMake
files to get better hang of how individual CMake commands work and
interoperate.

Petr

On Wed, Feb 25, 2015 at 2:21 PM, Doron Klepach <klepachd at gmail.com> wrote:

> 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/0f633966/attachment.html>


More information about the CMake mailing list