You're not using the results of the find_package. It should look like:
cmake_minimum_required(VERSION 2.8) project(collision) enable_language(Fortran) FIND_PACKAGE(BLAS REQUIRED) add_definitions(-O3) add_executable(collision test.f90) target_link_libraries(collision ${BLAS_LIBRARIES}) 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. Tim ----- Original Message ----- From: "Matthew Clay" <mpc...@gmail.com> To: cmake@cmake.org Sent: Thursday, May 3, 2012 11:25:23 PM Subject: [CMake] FORTRAN and BLAS Issue Fellow cmake users: 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. The FORTRAN code--note that DDOT is the call to BLAS that I want to make: PROGRAM TEST IMPLICIT NONE DOUBLE PRECISION,DIMENSION(2) :: x,y ! The two vectors. REAL(KIND=8),EXTERNAL :: DDOT ! Their dot product. x(:) = (/ 1.,100. /) y(:) = (/ 1.,1. /) WRITE (*,*) DDOT(2,x,1,y,1) END PROGRAM TEST What works: gfortran test.f90 -O3 -lblas ./a.out What doesn't work: cmake_minimum_required(VERSION 2.8) project(collision) enable_language(Fortran) FIND_PACKAGE(BLAS REQUIRED) add_definitions(-O3 -lblas) add_executable(collision test.f90) Upon attempting [ mkdir build && cd build && cmake .. && make ] as with any other code I get the following result: Scanning dependencies of target collision [100%] Building Fortran object CMakeFiles/collision.dir/test.f90.o Linking Fortran executable collision CMakeFiles/collision.dir/test.f90.o: In function `MAIN__': test.f90:(.text+0x7d): undefined reference to `ddot_' collect2: error: ld returned 1 exit status make[2]: *** [collision] Error 1 make[1]: *** [CMakeFiles/collision.dir/all] Error 2 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! Thanks, Matt -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
-- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake