dev-cafe / autocmake

CMake plugin composer.
http://autocmake.org
BSD 3-Clause "New" or "Revised" License
42 stars 18 forks source link

How to assign user-selected math library ? Test for EXPLICIT_LIBS ? #52

Closed miroi closed 9 years ago

miroi commented 9 years ago

On my system I have GNU blas as well as MKL-blas. By default is chooses MKL, but I want to force it to use other library.

The -blas="/usr/lib64/libblas.a" is not working. I haven't found in the manual how to do it. Any help ?

milias@login.grid.umb.sk:~/Work/qch/software/software_projects/autocmake_devel/autocmake/test/fc_blas/.python setup.py --fc=gfortran --blas="/u
sr/lib64/libblas.a"   build_gfortran2
FC=gfortran cmake -DEXTRA_FCFLAGS="''" -DENABLE_64BIT_INTEGERS=False -DENABLE_BLAS=/usr/lib64/libblas.a -DENABLE_LAPACK=auto -DMKL_FLAG=off -DMATH_LIB_SEARCH_ORDER="MKL;ESSL;ATLAS;ACML;SYSTEM_NATIVE" -DBLAS_LANG=Fortran -DLAPACK_LANG=Fortran -DCMAKE_BUILD_TYPE=release -G "Unix Makefiles" None /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake/test/fc_blas

CMake Error at src/CMakeLists.txt:5 (message):
  BLAS library not found for the test fc_blas!

-- The C compiler identification is GNU 4.4.7
-- The CXX compiler identification is GNU 4.4.7
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- The Fortran compiler identification is GNU
-- Check for working Fortran compiler: /usr/bin/gfortran
-- Check for working Fortran compiler: /usr/bin/gfortran  -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/bin/gfortran supports Fortran 90
-- Checking whether /usr/bin/gfortran supports Fortran 90 -- yes
-- LAPACK will be searched for based on MKLROOT=/mnt/apps/intel/composer_xe_2013_sp1.1.106/mkl
-- Searching for LAPACK using search order MKL;ESSL;ATLAS;ACML;SYSTEM_NATIVE
-- Found LAPACK: MKL (-Wl,--start-group;/mnt/apps/intel/composer_xe_2013_sp1.1.106/mkl/lib/intel64/libmkl_lapack95_lp64.a;/mnt/apps/intel/composer_xe_2013_sp1.1.106/mkl/lib/intel64/libmkl_gf_lp64.so;-fopenmp;-Wl,--end-group)
-- Configuring incomplete, errors occurred!
See also "/home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake/test/fc_blas/build_gfortran2/CMakeFiles/CMakeOutput.log".

milias@login.grid.umb.sk:~/Work/qch/software/software_projects/autocmake_devel/autocmake/test/fc_blas/.~~~
bast commented 9 years ago

You can change the order using MATH_LIB_SEARCH_ORDER: https://github.com/scisoft/autocmake/blob/master/modules/math_libs.cmake#L7

miroi commented 9 years ago

The order is fine (MKL first !), but I would like explicitly assign library (as in DIRAC)....

bast commented 9 years ago

In DIRAC we solve it like this:

[explicit]
docopt: --explicit-libs=<LIBS> Explicit linker specification for extra libraries passed directly to the linker [default: off].
define: '-DEXPLICIT_LIBS=%s' % arguments['--explicit-libs'].strip()

And then you use ${EXPLICIT_LIBS} in target_link_libraries.

miroi commented 9 years ago

Good. In such a case I have to switch off autocmake selection of math libs:

python setup.py --static --fc=gfortran  --explicit-libs="/usr/lib64/libblas.a" --blas=off --lapack=off  build_gfortran_libblas_static1
.
.
.milias@login.grid.umb.sk:~/Work/qch/software/software_projects/autocmake_devel/autocmake/.py.test -v test/test.py 
=============================================================== test session starts ================================================================
platform linux2 -- Python 2.6.6 -- py-1.4.28 -- pytest-2.7.1 -- /usr/bin/python
rootdir: /home/milias/Work/qch/software/software_projects/autocmake_devel/autocmake/test, inifile: 
collected 8 items 

test/test.py::test_cxx_custom PASSED
test/test.py::test_extra_cmake_options PASSED
test/test.py::test_cxx PASSED
test/test.py::test_cxx_static PASSED
test/test.py::test_fc PASSED
test/test.py::test_fc_static PASSED
test/test.py::test_fc_blas PASSED
test/test.py::test_fc_blas_static PASSED

============================================================ 8 passed in 30.68 seconds =============================================================
miroi commented 9 years ago

Well, your comment https://github.com/scisoft/autocmake/issues/52#issuecomment-127051854 can be put in into the documentation and than we can close this issue, IMHO.

bast commented 9 years ago

I agree that the documentation should have a section on linking.

miroi commented 9 years ago

Hi Rado,

due to the importance of passing the EXPLICIT_LIBS to linked (if the automatic math-libs detection does not work), I advocate for two new tests, fc_blas_explicit, fc_lapack_explicit.

These could be based upon existing tests, fc_blas+fc_lapack, where we would change local CMakeFiles.txt files for EXPLICIT_LIBS detection.

Maybe it would be sufficient to have only one extra test for EXPLICIT_LIBS detection, fc_blas_explicit.

I have one working example for Windows, https://github.com/miroi/mathlibs-tester/blob/master/src/CMakeLists.txt . At the moment we don't have OpenBLAS automatic detection on Windows, so explicit_libs is the workaround.

Comments, please ?

bast commented 9 years ago

A problem with such tests is that they might work on Travis/Appveyor but fail outside. I want the test suite to work also on my laptop without jumping through hoops. Also testing explicit libs is in principle independent of math so I would avoid couple those.

miroi commented 9 years ago

Ok, fine. Let us rely on math_libs.cmake detection only. Closing this issue.