[CMake] Does cmake support fortran lang with F extension?

Maik Beckmann beckmann.maik at googlemail.com
Sat Jan 3 11:24:01 EST 2009


谢歆 schrieb am Samstag 03 Januar 2009 um 16:22:
> hi,
>
> I decide to use cmake for an old FORTAN program what consists a lot of
> F extension source code and wrote a simple CMakelists.txt.
> Hoever, the default setting did not seem to support F extension.

CMake support the F extension.

>
> And when I cmake, I got this error information:
[snip]
> You have called ADD_LIBRARY for library ukmoradlib without any
> source files. This typically indicates a problem with your CMakeLists.txt
> file
> -- Configuring done
> CMake Error: Cannot determine link language for target "ukmoradlib".
[snip]

The point is: 
"You have called ADD_LIBRARY for library ukmoradlib without any source files. 
This typically indicates a problem with your CMakeLists.txt file"

Your script above does
{{{
add_library(ukmoradlib STATIC ${ukmorad_SRCS})
..
set(ukmorad_SRCS
  ${ukmorad_main_SRCS}
  ${ukmorad_ses_setup_SRCS}
  ${ukmorad_common_SRCS} 
  ${ukmorad_ses_flux_calc_SRCS
)
set(ukmorad_main_SRCS ..
}}}

This results in ${ukmorad_SRCS} being nothing when evaluated in:
add_library(ukmoradlib STATIC ${ukmorad_SRCS})

You have to set the variables _before_ you use them:
{{{
set(ukmorad_main_SRCS ..
..
set(ukmorad_SRCS
  ${ukmorad_main_SRCS}
  ${ukmorad_ses_setup_SRCS}
  ${ukmorad_common_SRCS} 
  ${ukmorad_ses_flux_calc_SRCS}
)
add_library(ukmoradlib STATIC ${ukmorad_SRCS})
}}}


> I have both Intel and PGI compilers in my computer. Cmake did find
> intel compiler. But my question is how I can change the
> cmake setting so that I can use PGI compiler?

set the FC environment variable.

HTH,
 -- Maik



More information about the CMake mailing list