<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1273439866;
        mso-list-template-ids:1463462430;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt'>Hi, I attempted to use create_test_sourcelist with a Fortran routines using the recipe from the cmake book. The CMakeLists.txt and fortran file are given below. The test *.cpp file is generated correctly, but the linker gives me this:<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>cd /home/eli/work/selfe_trunk/build/unittest/Hydro && /usr/local/dms/pkg/cmake/2.8.8/bin/cmake -E cmake_link_script CMakeFiles/Driver.dir/link.txt --verbose=1<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>/usr/bin/c++ -O3 -DNDEBUG CMakeFiles/Driver.dir/driver.cpp.o CMakeFiles/Driver.dir/test_attempt.F90.o -o ../../bin/Driver -rdynamic -L/usr/local/dms/pkg/hdf5/1.8.7-intel12.0-parallel/lib -lifport -lifcore -limf -lsvml -lipgo -lintlc -lpthread -lirc_s -ldl <o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>CMakeFiles/Driver.dir/driver.cpp.o:(.data+0x8): undefined reference to `test_attempt(int, char**)'<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt'><o:p> </o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt'>I can’t tell whether this is a Fortran-C interoperability issue or some sort of linking problem. In order to reduce the interoperability issue as a confounder, I manually altered the generated driver.cpp file my Fortran file to sequentially eliminate the double pointer, then all arguments and finally the return value. In each case I got the same result: the symbol test_attempt is in test_attempt.F90.o but it is considered an undefined reference. Anyone know how to make it work? The solution should be of general interest since this is always the signature expected by create_test_sourcelist. I am on ifort with cmake 2.8.8.<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt'><o:p> </o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt'>Thanks -- Eli<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;line-height:24.0pt'><span style='font-size:10.0pt'>**********<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>create_test_sourcelist(Tests<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'> driver.cpp<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'> test_attempt.F90)<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>add_executable(Driver ${Tests})<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>set(TestsToRun ${tests})<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>remove(TestsToRun driver.cpp)<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>foreach (test ${TestsToRun})<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'> get_filename_component(TName ${test} NAME_WE)<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'> add_test( ${TName} Driver ${TName})<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>endforeach()<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><o:p> </o:p></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'>*********** <o:p></o:p></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-family:"Courier New"'> function test_attempt(argc,argv) bind( c)<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-family:"Courier New"'> use iso_c_binding<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-family:"Courier New"'> integer(c_int) :: test_attempt<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-family:"Courier New"'> integer(c_int) :: argc<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-family:"Courier New"'> type(c_ptr), dimension(1) :: argv<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-family:"Courier New"'> print*, "Hello"<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-family:"Courier New"'> test_attempt=0<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><span style='font-family:"Courier New"'> end function<o:p></o:p></span></p><p class=MsoNormal style='text-align:justify;mso-line-height-alt:0pt'><o:p> </o:p></p></div></body></html>