I'm getting into CMAKE usage with C and actually I'm creating two very small static libraries.
My goal is:
- The libraries are compiled and linked into *.a files. [THIS
WORKS]
- Then I wish to copy that *.a files into /usr/local/lib [THIS ALSO WORKS]
- As far as I know about libraries (very little), they are linked using
-lnameoflib
, which is a compiler flag. OK. I have prepared my CMakeLists.txt and it actually copies *.a files into /usr/local/lib
. However, to be able to use them in a program, I also need to copy their header files into /usr/local/include
, then I can include them the easy way #include <mylibheader.h>
. That's how I understand it now.
And my question is - how is the proper way of copying header files into /usr/include folder with CMAKE? I would like it to copy them automatically when make install
is executed, like *.a files are.
For both of the libraries I have a smiliar CMakeLists.txt:
project(programming-network)
add_library(programming-network STATIC
send_string.c
recv_line.c
)
INSTALL(TARGETS programming-network
DESTINATION "lib"
)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…