[CMake] Download and Build external dependencies
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 ___ 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
[CMake] Add external static libraries / ar-archives to a build.
Hi, I'm working on a library to solve sparse linear systems. All basic vector operations are realized by using the BLAS. The FindBLAS works fine but most of the blas implementations are provided as an ar-archive somewhere in the filesystem ( we use a standard blas, ATLAS, GotoBlas or malefactor specific variants). Is it possible to pass the wanted libblas.a as a parameter to cmake and add it to a target? For example when I want to use the GotoBLAS I want to call cmake this way: cmake -DBLAS=/path/to/lib/libgoto.a PATH_TO_SOURCE If I link the lib manually I enter gcc -o output myfile.c /path/to/lib/libgoto.a Is there an easy way to do so in cmake? The static linking is necessary because programs based on this library are executed on an MPI-Cluster and working with dynamic libraries is more than buggy. regards, Martin Pt! Schon vom neuen WEB.DE MultiMessenger gehört? Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123 ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Add external static libraries / ar-archiv es to a build.
The libary could be the wrong because there are better ones on the system or in order to evalute so performece details I ( and other members of the project ) want to switch the version easily. So its the best way, I think , to do this by changing the command line options and not to search in the cmake cache and change the values there. An other problem is that the FindBlas tooks an implementation that cause segfaults with my lib ( for example if the matlab blas is chosen) regards, martin -Ursprüngliche Nachricht- Von: Mathieu Malaterre [EMAIL PROTECTED] Gesendet: 21.10.08 10:34:16 An: Martin Köhler [EMAIL PROTECTED] CC: CMake cmake@cmake.org Betreff: Re: [CMake] Add external static libraries / ar-archives to a build. [keep the mail on cmake ml, pls] On Tue, Oct 21, 2008 at 10:26 AM, Martin Köhler [EMAIL PROTECTED] wrote: Von: Mathieu Malaterre [EMAIL PROTECTED] Gesendet: 21.10.08 10:10:44 An: Martin Köhler [EMAIL PROTECTED] CC: cmake@cmake.org Betreff: Re: [CMake] Add external static libraries / ar-archives to a build. On Tue, Oct 21, 2008 at 10:06 AM, Martin Köhler [EMAIL PROTECTED] wrote: Hi, I'm working on a library to solve sparse linear systems. All basic vector operations are realized by using the BLAS. The FindBLAS works fine but most of the blas implementations are provided as an ar-archive somewhere in the filesystem ( we use a standard blas, ATLAS, GotoBlas or malefactor specific variants). Is it possible to pass the wanted libblas.a as a parameter to cmake and add it to a target? For example when I want to use the GotoBLAS I want to call cmake this way: cmake -DBLAS=/path/to/lib/libgoto.a PATH_TO_SOURCE If I link the lib manually I enter gcc -o output myfile.c /path/to/lib/libgoto.a FIND_PACKAGE(BLAS REQUIRED) ADD_EXECUTABLE(output myfile.c) TARGET_LINK_LIBRARIES(output ${BLAS_LIBRARIES}) This way already works fine(I already noticed) but it is not that flexible I need for the project. I need to specify the ar-archive that contain the blas routines myself. The Find_package macro mostly finds the wrong blas that I don't want to use. I do not understand what you mean. there is no 'wrong' library, cmake just pick the first one based on your environment. If you have multiple installation of blas, I do not see how cmake could guess which one you want. In my opinion the best way is to pass the right file as parameter. The cause is that the choose of the blas implementation is very important to solve the problems as fast as possible and so I want an easy way to switch which blas is used. Either run it via ccmake and changed whatever option is wrong. reading the code of FindBLAS.cmake there is apparently a subtle mechanism which rely on the setting of BLA_VENDOR, change this value until you are happy with cmake system inspection (neither did I wrote this module, nor did I ever used it...) 2cts -- Mathieu Schon gehört? Bei WEB.DE gibt' s viele kostenlose Spiele: http://games.entertainment.web.de/de/entertainment/games/free/index.html ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Add external static libraries / ar-archiv es to a build.
When I pass the absolute path of the ar-archive it seems to work. It's not the perfect solution because it doesn't check if the lib could be linked to the other files. -Ursprüngliche Nachricht- Von: Paul Harris [EMAIL PROTECTED] Gesendet: 21.10.08 10:54:12 An: Mathieu Malaterre [EMAIL PROTECTED] CC: cmake@cmake.org Betreff: Re: [CMake] Add external static libraries / ar-archives to a build. snip cmake -DBLAS=/path/to/lib/libgoto.a PATH_TO_SOURCE If I link the lib manually I enter gcc -o output myfile.c /path/to/lib/libgoto.a FIND_PACKAGE(BLAS REQUIRED) ADD_EXECUTABLE(output myfile.c) TARGET_LINK_LIBRARIES(output ${BLAS_LIBRARIES}) snip In my opinion the best way is to pass the right file as parameter. The cause is that the choose of the blas implementation is very important to solve the problems as fast as possible and so I want an easy way to switch which blas is used. Either run it via ccmake and changed whatever option is wrong. reading the code of FindBLAS.cmake there is apparently a subtle mechanism which rely on the setting of BLA_VENDOR, change this value until you are happy with cmake system inspection (neither did I wrote this module, nor did I ever used it...) I am in a vaguely similar position, and I can understand the desire to specify the library on the command line (so that you can configure via a selection of scripts that call cmake), rather than having to manually edit the properties in ccmake. Maybe instead, is it possible to set the value of BLAS_LIBRARIES via the command line? You would probably also want to set BLAS_INCLUDES too in case you have different headers as well. At the end of the day, FIND_PACKAGE()'s goal is to set the values of numerous standard variables (eg BLAS_LIBRARIES)... so if you can do a better job than cmake's automatic package finding tool, then it might be easier to just specify the required variables yourself and remove the FIND_PACKAGE call entirely. Pt! Schon vom neuen WEB.DE MultiMessenger gehört? Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123 ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake