CMake : how to link a library WITHOUT automatic search function FIND_PACKAGE?

Viewed 31608

I wonder how to find/link a library without any FIND_PACKAGE.

Assume that we have a "personal" library called testlib :

/perso/testlib/include/testlib1.h
/perso/testlib/include/testlib2.h
/perso/testlib/lib/testlib1.a
/perso/testlib/lib/testlib2.a

How to link it with CMake ?

1) What are the functions to link it directly in the code of the CMakeLists.txt ?

2) How to allow the user to select where are the files ?

3) I have difficulties to understand what is interpreted and what it's not by CMake. For example if you define a variable ${MYVARIABLE_INCLUDE_DIR} or ${MYVARIABLE_LIBRARIES} is "INCLUDE_DIR" or "LIBRARIES" an extension interpreted by CMake or there is no difference if I call this variable ${MYVARIABLE_INCDIR} ?

4) How to do the same procedures (including a "personal" library) if you have a library that contains ten library files or more in the lib directory ?

5) And finally, when you type TARGET_LINK_LIBRARIES(myexecutable gmp), how do you know that the name of the library is "gmp". Why not "Gmp" or "GMP" ? Is the name of the library to put in this function just equal to the .a file minus "lib" and ".a" ? For example libgmp.a -> gmp ? If I want to link a library called libtestlolexample.a, do I have to type TARGET_LINK_LIBRARIES(myexecutable testlolexample) ?

Thank you very much.

3 Answers
Related