<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: times new roman,new york,times,serif; font-size: 12pt; color: #000000'>You're not using the results of the find_package.<br><br>It should look like:<br><br><font face="Courier New, Courier, monospace">cmake_minimum_required(VERSION
2.8)<br>
project(collision)<br>
enable_language(Fortran)<br>
FIND_PACKAGE(BLAS REQUIRED)<br>
add_definitions(-O3)<br>
add_executable(collision test.f90)</font><br><font face="Courier New, Courier, monospace">target_link_libraries(collision ${BLAS_LIBRARIES})</font><br><br>Also, the add_definitions shouldn't really be used for things like -O3, it should be used for things like -DMY_FLAG or something. Flags like -O3 should be added to the CMAKE_Fortran_FLAGS.<br><br>Tim<br><br><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Matthew Clay" <mpclay@gmail.com><br><b>To: </b>cmake@cmake.org<br><b>Sent: </b>Thursday, May 3, 2012 11:25:23 PM<br><b>Subject: </b>[CMake] FORTRAN and BLAS Issue<br><br>
Fellow cmake users:<br>
<br>
I am experiencing a minor issue with cmake, and can't seem to find
an answer browsing the web. I have a minimal working example that
highlights the issue with my main code. The problem is this:
compiling by myself with gfortran and the appropriate flags produces
no errors, while attempting to build the code with cmake throws an
error. <br>
<br>
The FORTRAN code--note that DDOT is the call to BLAS that I want to
make:<br>
<br>
<font face="Courier New, Courier, monospace">PROGRAM TEST<br>
IMPLICIT NONE<br>
DOUBLE PRECISION,DIMENSION(2) :: x,y ! The two vectors.<br>
REAL(KIND=8),EXTERNAL :: DDOT ! Their dot product.<br>
x(:) = (/ 1.,100. /)<br>
y(:) = (/ 1.,1. /)<br>
WRITE (*,*) DDOT(2,x,1,y,1)<br>
END PROGRAM TEST</font><br>
<br>
What works:<br>
<br>
<font face="Courier New, Courier, monospace">gfortran test.f90 -O3
-lblas</font><br>
<font face="Courier New, Courier, monospace">./a.out</font><br>
<br>
What doesn't work:<br>
<br>
<font face="Courier New, Courier, monospace">cmake_minimum_required(VERSION
2.8)<br>
project(collision)<br>
enable_language(Fortran)<br>
FIND_PACKAGE(BLAS REQUIRED)<br>
add_definitions(-O3 -lblas)<br>
add_executable(collision test.f90)</font><br>
<br>
Upon attempting [ <font face="Courier New, Courier, monospace">mkdir
build && cd build && cmake .. && make ]</font>
as with any other code I get the following result:<br>
<br>
<font face="Courier New, Courier, monospace">Scanning dependencies
of target collision<br>
[100%] Building Fortran object CMakeFiles/collision.dir/test.f90.o<br>
Linking Fortran executable collision<br>
CMakeFiles/collision.dir/test.f90.o: In function `MAIN__':<br>
test.f90:(.text+0x7d): undefined reference to `ddot_'<br>
collect2: error: ld returned 1 exit status<br>
make[2]: *** [collision] Error 1<br>
make[1]: *** [CMakeFiles/collision.dir/all] Error 2</font><br>
<br>
It appears that BLAS is not being linked with the code...maybe? I am
not a cmake expert, and would greatly appreciate any words of wisdom
for troubleshooting this problem!<br>
<br>
Thanks,<br>
Matt<br>
<br>--<br><br>Powered by www.kitware.com<br><br>Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html<br><br>Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.cmake.org/mailman/listinfo/cmake</div><br></div></body></html>