[CMake] How Do I Make A Static Library from FORTRAN and CPP sources?

Petr Kmoch petr.kmoch at gmail.com
Mon Mar 4 04:57:10 EST 2013


Hi Peter.

How is it "not working?"

Also, I believe you shouldn't call enable_language() before calling
project(). And since you apparently need Fortran unconditionally, you
might simply start your CMakeList like this:

cmake_minimum_required(VERSION 2.8)

project(MYFORTRANLIB C CXX Fortran)

# ... the rest as before

Petr

On Sat, Mar 2, 2013 at 12:48 AM, Peter Willis <pwillis at aslenv.com> wrote:
>
> Hello,
>
> I would like to make a static library from FORTRAN sources (as opposed to
> C/C++).
>
> I have  in my CMakeLists.txt :
>
> cmake_minimum_required(VERSION 2.8)
> enable_language (Fortran)
>
> PROJECT(MYFORTRANLIB)
>
> get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER}
> NAME)
>
> SET(SOMEFORTRAN " libfuncs.F  statsfuncs.F ")
> SET(SOMECPP " one_lonely_function.cpp " )
>
> SET(MYSOURCES ${SOMEFORTRAN} ${SOMECPP} )
>
> ADD_LIBRARY(libmyfortran  STATIC  ${MYSOURCES} )
>
>
> ----------------------------------------------------------------------------
> ----
>
> Is it possible to generate object files for both the CPP file and the
> FORTRAN files
> in the same build. or do I need to set up 2 directories with a library build
> for each?
>
> The CMakeLists.txt file above is not working yet.
>
> Thanks
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list