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

谢歆 xiexinyls at gmail.com
Sat Jan 3 10:22:49 EST 2009


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.

My cmakelists.txt is as follows:

cmake_minimum_required(VERSION 2.6)
project(testukmo)

include_directories(ukmorad/headers)
link_directories(ukmorad)

enable_language(Fortran)
add_executable(testukmo
  main.F
)

add_library(ukmoradlib STATIC ${ukmorad_SRCS})
target_link_libraries(testukmo ukmoradlib)

set(ukmorad_SRCS
  ${ukmorad_main_SRCS}
  ${ukmorad_ses_setup_SRCS}
  ${ukmorad_common_SRCS}
  ${ukmorad_ses_flux_calc_SRCS}
)

set(ukmorad_main_SRCS
  radctl_ukmo.F
  ses_lwdrv.F
  ses_setup.F
  ses_swdrv.F
)

set(ukmorad_ses_setup_SRCS
  ses_setup/ses_t_level.F
  ses_setup/ses_inter_pt.F
  ses_setup/ses_qsat_gill.F
  ses_setup/ses_calc_density.F
  ses_setup/ses_cld_point.F
  ses_setup/ses_volc_interp.F
  ses_setup/ses_ovlap_mix_max.F
  ses_setup/ses_aer_interp.F
  ses_setup/ses_ovlap_mix_ran.F
  ses_setup/ses_gen_aer_fields.F
  ses_setup/ses_moist_aerosol.F
)

set(ukmorad_common_SRCS
  common/ses_cld_geometry.F
  common/ses_whenflt.F
  common/ses_whenfle.F
  common/compj.F
  common/ses_locate.F
  common/ses_whenfgt.F
)

set(ukmorad_ses_flux_calc_SRCS
  ses_flux_calc/ses_assign_flux.F
  ses_flux_calc/ses_agu_flux_sw.F
  ses_flux_calc/ses_sur_prop.F
  ses_flux_calc/ses_total_flux.F
...
... more fortran source code
...
)
...
...
...
---------------------------------------------------------------------------------------------

And when I cmake, I got this error information:

-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- The Fortran compiler identification is Intel
-- Check for working Fortran compiler: /opt/intel/fc/10.1.018/bin/ifort
-- Check for working Fortran compiler: /opt/intel/fc/10.1.018/bin/ifort -- works
-- Checking whether /opt/intel/fc/10.1.018/bin/ifort supports Fortran 90
-- Checking whether /opt/intel/fc/10.1.018/bin/ifort supports Fortran 90 -- yes
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".
-- Generating done
-- Build files have been written to: /home/xiexin/modeltest/testukmo

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?

Can anyone give a solution? Thank you very much!

Xie Xin


More information about the CMake mailing list