[CMake] Executable using a library (.a or .so)

houssen houssen at ipgp.fr
Fri Nov 13 12:28:51 EST 2015


Hello,

How to write a library (myLib as .a or .so) that can be used from an 
executable (myExe) ?

I read the CMake doc but, obviously, I still miss some major points 
!... My understanding is that, I need :
- to write a FindMyLib.cmake for myExe to find myLib (= finding 
include/library directories, and, libraries to link with)
- to use find_package from myExe to find myLib

I tried to write a mini-project (attached to this mail) to do that but 
it doesn't work: find_package doesn't find FindMyLib.cmake although 
CMAKE_MODULE_PATH has been updated.

Can somebody help me on making this project to work ? (not able to find 
FindMyLib.cmake, not sure to know the "good" way to write 
FindMyLib.cmake, others... - I would appreciate any remarks to explain 
me the "good" way to do thing)

Thanks,

Franck

Note: I set CMAKE_MODULE_PATH in the CMakeLists.txt of myLib (doing 
that from myExe sounds not relevant: if you know where the package is, 
no need to call find_package).
Note: my understanding is that when this will work, I would be possible 
to build myLib as a .a or a .so, am I correct ?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: myProject.tar.gz
Type: application/x-gzip
Size: 1087 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151113/cf10dfb0/attachment.bin>


More information about the CMake mailing list