Hi,

If the library is a shared object, try to NOT use all those libraries. If they 
are used in the library but are not part of its public API, you most likely 
don't need to link them. If you have no missing symbols when linking, you can 
avoid overlinking you program.

If this is a static library, you have a lot more work. For each library without 
-l, use find_library() and use the library dirs as hints. Do NOT use 
link_directories().

HS




Am 1. April 2016 00:22:09 MESZ, schrieb "Salazar De Troya, Miguel" 
<salazardet...@llnl.gov>:
>Hello
>
>I am trying to compile a program with a library that provides a bash
>script to generate the dependencies, libraries and the link directories
>for the Makefile. I want to generate a CMakeLists.txt that can handle
>these dependencies from that library. I have been able to come up with
>regexp that can extract the information and put it into a variable with
>the dirs or library names separated by comma, for instance:
>
>INCLUDE_DIRS =
>
>/g/g92/miguel/code/libmesh_2D/include;/usr/include/curl;/usr/include/glpk;/usr/local/tools/vtk-6.1.0/include/vtk-6.1;/g/g92/miguel/petsc-3.6.2/include;/g/g92/miguel/petsc-3.6.2/miguel-opt/include;/usr/local/tools/openmpi-intel-1.8.4/include/openmpi/opal/mca/hwloc/hwloc191/hwloc/include;/usr/local/tools/openmpi-intel-1.8.4/include/openmpi/opal/mca/event/libevent2021/libevent;/usr/local/tools/openmpi-intel-1.8.4/include/openmpi/opal/mca/event/libevent2021/libevent/include;/usr/local/tools/openmpi-intel-1.8.4/include;/usr/local/tools/openmpi-intel-1.8.4/include/openmpi;/usr/local/tools/boost-mpi-1.55.0//include
>
>
>LIBS =
>
>-lcurl;-lhdf5;-lglpk;-lvtkIOCore-6.1;-lvtkCommonCore-6.1;-lvtkCommonDataModel-6.1;-lvtkFiltersCore-6.1;-lvtkIOXML-6.1;-lvtkImagingCore-6.1;-lvtkIOImage-6.1;-lvtkImagingMath-6.1;-lz;-lpetsc;-lcmumps;-ldmumps;-lsmumps;-lzmumps;-lmumps_common;-lpord;-lscalapack;-lHYPRE;-lml;-llapack;-lblas;-lparmetis;-lmetis;-lX11;-lhwloc;-lssl;-lcrypto;-lmpi_usempif08;-lmpi_usempi_ignore_tkr;-lmpi_mpifh;-lifport;-lifcore;-lm;-lmpi;-limf;-lsvml;-lirng;-lipgo;-ldecimal;-lcilkrts;-lstdc++;-lgcc_s;-lirc;-lpthread;-lirc_s;-ldl;-lmesh_opt
>
>
>LIB_DIRS =
>
>/usr/lib;/lib;/usr/lib64;/usr/local/tools/vtk-6.1.0/lib;/g/g92/miguel/petsc-3.6.2/miguel-opt/lib;/usr/local/tools/openmpi-intel-1.8.4/lib;/usr/local/tools/ic-14.0.174/composer_xe_2013_sp1.3.174/compiler/lib/intel64;/usr/lib/gcc/x86_64-redhat-linux/4.4.7;/g/g92/miguel/code/libmesh_2D/lib
>
>
>These are variables in my environment that I use in CMake with
>$ENV{VAR}. How can I use this information for the commands:
>
>include_directories($ENV{INCLUDE_DIRS})
>
>link_directories($ENV{LIB_DIRS})
>
>target_link_libraries($ENV{LIBS}) ?
>
>
>It seems that cmake can digest the include directories and the
>target_link_libraries (because they appear correctly in the
>compilation), but not the link_directories. Why? Also, I’ve read that
>it is more correct to use find_library() instead. How would I iterate
>over the LIBS? Can I use a single LIB_DIRS (with all the information
>above) in the PATHS argument of find_library()
>
>
>Thanks
>
>Miguel
>
>
>------------------------------------------------------------------------
>
>-- 
>
>Powered by www.kitware.com
>
>Please keep messages on-topic and check the CMake FAQ at:
>http://www.cmake.org/Wiki/CMake_FAQ
>
>Kitware offers various services to support the CMake community. For
>more information on each offering, please visit:
>
>CMake Support: http://cmake.org/cmake/help/support.html
>CMake Consulting: http://cmake.org/cmake/help/consulting.html
>CMake Training Courses: http://cmake.org/cmake/help/training.html
>
>Visit other Kitware open-source projects at
>http://www.kitware.com/opensource/opensource.html
>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/cmake
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to