[CMake] Download and Build external dependencies

Martin Köhler martin.pleissa at web.de
Fri Jul 1 07:48:32 EDT 2011


Hi,
I'm currently trying to  write a cmake script, which downloads some
source code and compile it during the configuration step. In my case
this I want to try it with BLAS from netlib.org because it represents
the problem in a good way ( and I need it for BLAS and similar
structured source code). That background is: If a necessary library
isn't found on the system, I will download the reference version and
compile it.

Therefore I wrote the following code:

# Download and Build reference BLAS
MESSAGE(STATUS " --> BUILD BLAS")
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/build)
SET (BLAS_DIR ${CMAKE_BINARY_DIR}/build/BLAS)
MESSAGE(STATUS " --> DOWNLOAD BLAS")
file(DOWNLOAD http://www.netlib.org/blas/blas.tgz
${CMAKE_BINARY_DIR}/build/blas.tgz SHOW_PROGRESS)
MESSAGE(STATUS " --> EXTRACT BLAS")
execute_process(COMMAND tar xzf blas.tgz WORKING_DIRECTORY
${CMAKE_BINARY_DIR}/build/ )
MESSAGE(STATUS " --> COMPILE BLAS: "  "${CMAKE_Fortran_COMPILER}
${CMAKE_FORTRAN_FLAGS} -c -O2 *.f  in  ${CMAKE_BINARY_DIR}/build/BLAS" )
execute_process(COMMAND "${CMAKE_Fortran_COMPILER}
${CMAKE_FORTRAN_FLAGS} -c -O2 *.f" WORKING_DIRECTORY
${CMAKE_BINARY_DIR}/build/BLAS/ )
execute_process(COMMAND ar cr libblas.a *.f WORKING_DIRECTORY
${CMAKE_BINARY_DIR}/build/BLAS/)


This works until the archive is extracted. The compile step seems to be
not executed. The ar step claims that there is not such file *.f


How can I get this running?


best regards, Martin



More information about the CMake mailing list