[CMake] Using cmake to compile mixed C++ and Fortran code
Shipeng Shu
spshu.uiuc at gmail.com
Sat Jun 2 08:26:30 EDT 2012
Hi, I'm writing a C++ code but I want to also use some of the Fortran code that has been previously tested.
And I'm new to cmake.
My CmakeList.txt looks like this:
PROJECT (IRR CXX Fortran)
ENABLE_LANGUAGE(Fortran)
SET(SRC_LIST demo.cpp global.cpp global_variables.cpp init_config.cpp input.cpp irr.cpp output.cpp ./src_tools/rng.cpp global.h global_variables.h init_config.h input.h irr.h ./src_tools/nr3.h output.h ./src_tools/rng.h ./src_tools/vector3.h ./src_tools/tool_output.h ./src_tools/tools.cpp ./src_tools/tools.h ./src_tools/timer.h ./src_tools/timer.cpp ./src_tools/difconnector.h)
SET(SRC_FORTRAN_LIST ./src_tools/difquat.f ./src_tools/fourn.f)
SET(CMAKE_CXX_FLAGS "-O3 -ip")
ADD_EXECUTABLE(irr.x ${SRC_LIST} ${SRC_FORTRAN_LIST})
But the compiler gives me error information like these:
CMakeFiles/irr.x.dir/src_tools/difquat.o: In function `difquat_':
/home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0xc4): undefined reference to `for_write_seq_lis'
/home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0xef): undefined reference to `for_write_seq_lis_xmit'
/home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0x159): undefined reference to `for_open'
/home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0x1cc): undefined reference to `for_open'
/home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0x214): undefined reference to `for_read_seq_lis'
/home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0x24e): undefined reference to `for_close'
/home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0xb94): undefined reference to `for_write_seq_fmt'
/home/spshu/9_new_KMC_code/12.irr/src_tools/difquat.f:(.text+0xbb9): undefined reference to `for_write_seq_fmt_xmit'
It seems to me that I need some Fortran library, but I think Cmake should have include them since I enabled Fortran. I'm confused about it.
Could you please tell me why I get all these things?
How should I modify the CmakeList.txt to get things work?
Thanks a lot!
--
Shipeng Shu
Research Assistant
Department of MatSE
University of Illinois at Urbana-Champaign
1304 W. Green St.
Urbana 61801, IL
USA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120602/7be100be/attachment.htm>
More information about the CMake
mailing list