Reputation: 4757
I have a library libA. Structure is the following:
libA
+ CMakeLists.txt
+ mySRC/headerA.h
+ mySRC/headerB.h
+ mySRC/moduleA/modA.h
+ mySRC/moduleB/modB.h
My lib compiles fine and afterwards I want to install it using this cmake code:
SET(Source_dir mySRC)
SET(LIB_NAME libA)
...
INSTALL(TARGETS ${LIB_NAME} DESTINATION /usr/local/lib)
INSTALL(DIRECTORY ${Source_dir}
DESTINATION /usr/local/include/libA
FILES_MATCHING PATTERN "*.h")
Result:
libA.a ends up in
/usr/local/lib/libA.a (which is fine)
Headers end up in
/usr/local/include/libA/mySRC/*
/usr/local/include/libA/mySRC/moduleA
/usr/local/include/libA/mySRC/moduleB
What is not what I wanted. I want to remove "mySRC":
/usr/local/include/libA/*
/usr/local/include/libA/moduleA
/usr/local/include/libA/moduleB
How can I remove mySRC from the path?
Upvotes: 2
Views: 1597
Reputation: 171097
As CMake documentation says, you can prevent CMake from appending the directory name by following it with a trailing slash:
INSTALL(DIRECTORY ${Source_dir}/
DESTINATION /usr/local/include/libA
FILES_MATCHING PATTERN "*.h")
Upvotes: 2