Hi Michael,<br><br>I am using cmake 2.6. It worked by following your previous pattern. I can't remember where is wrong exactly. Maybe I shouldn't write "target_link_libraries(core <font class="Apple-style-span" color="#FF0000">libutil.a</font>)" but "target_link_libraries(core <font class="Apple-style-span" color="#FF0000">util</font>)".<div>
<br></div><div>Thanks again!</div><div><br></div><div>DONG Li<br><br><div class="gmail_quote">2009/11/18 Michael Wild <span dir="ltr"><<a href="mailto:themiwi@gmail.com" target="_blank">themiwi@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><div><div></div><div><br>
On 18. Nov, 2009, at 6:18 , ¶Àí wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
Michael Wild дµÀ:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<br>
On 17. Nov, 2009, at 4:31 , DONG Li wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
Hi all,<br>
<br>
I am trying to use CMake as my Fortran project build tool, it is a wonderful project guard!. But a annoying problem comes up. I searched all around the internet, but no easy document for me : (. Since I want to use static-linking, the Intel Fortran compiler complains "undefined reference to" when it links objects for an executable.<br>
<br>
The structure of the project is:<br>
<br>
CMakeLists.txt core init_data main test util<br>
<br>
and there will be static libraries under util and core as libutil.a and libcore.a. Further more, libcore.a depends on libutil.a.<br>
<br>
Finally, an executable will be generated under main which uses libcore.a and libutil.a.<br>
<br>
So how can I accomplish this? Thanks very much. I really want to learn CMake~<br>
<br>
Best regards,<br>
<br>
DONG Li_______________________________________________<br>
<br>
</blockquote>
<br>
CMakeLists.txt<br>
---------------<br>
cmake_minimum_required(VERSION 2.6)<br>
project(SuperDuper Fortran)<br>
add_subdirectory(util)<br>
add_subdirectory(core)<br>
add_subdirectory(main)<br>
<br>
util/CMakeLists.txt<br>
-------------------<br>
add_library(util util1.f util2.f)<br>
<br>
core/CMakeLists.txt<br>
-------------------<br>
add_library(core core1.f core2.f)<br>
target_link_libraries(core util)<br>
<br>
main/CMakeLists.txt<br>
-------------------<br>
add_executable(${PROJECT_NAME} main1.f main2.f)<br>
target_link_libraries(${PROJECT_NAME} util core)<br>
<br>
<br>
HTH<br>
<br>
Michael<br>
</blockquote>
Hi Michael,<br>
<br>
I have tried this pattern, but it doesn't work. Forgot to say that my programs are in Fortran 90 with several modules. Does this matter?<br>
<br>
<br>
Best regards,<br>
<br>
DONG Li<br>
</blockquote>
<br>
<br></div></div>
Well, "doesn't work" certainly isn't enough information. Which version of CMake are you using? What are the errors you get? Still the linking errors? Then you must be missing either some sources, some external libraries or have typos in your code.<br>
<br>
And, please, keep the messages on the list by using the "reply-all" button.<br><font color="#888888">
<br>
Michael</font></blockquote></div><br><br clear="all"><br>-- <br>×£ºÃ<br>¶Àí<br>
</div>