<div dir="ltr">my main CMakeLists.txt file already has a few directives that move the libs to an output folder so the binaries go to /bin while static and shared libraries go to /lib<div><br></div><div><div>set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)</div><div>set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)</div><div>set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)</div></div><div><br></div><div><br></div><div>it seems like this line in your reply above</div><div><span style="font-size:12.8px">install( TARGETS lib1 lib2 DESTINATION lib )</span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">moves the shared libraries to the lib folder and this line below moves the header files to the newly created include directory.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">install( FILES lib1/headers/lib1.h lib2/headers/lib2.h DESTINATION include )</span><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">is that right?</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 10, 2015 at 1:46 PM, Attila Krasznahorkay <span dir="ltr"><<a href="mailto:attila.krasznahorkay@gmail.com" target="_blank">attila.krasznahorkay@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Owen,<br>
<br>
This seems like a textbook example of using target_include_directories(…) with generator expressions. Let’s take the example where:<br>
<br>
lib1/headers/lib1.h<br>
lib1/lib1.c<br>
lib2/headers/lib2.h<br>
lib2/lib2.c<br>
<br>
If you want to be able to include lib1.h and lib2.h with simply<br>
<br>
#include “lib1.h”<br>
<br>
and<br>
<br>
#include “lib2.h”<br>
<br>
in your user code, and in the library code itself, you’d do something like:<br>
<br>
add_library( lib1 SHARED lib1/lib1.c )<br>
target_include_directories( lib1 PUBLIC<br>
   $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/lib1/headers><br>
   $<INSTALL_INTERFACE:include> )<br>
<br>
add_library( lib2 SHARED lib2/lib2.c )<br>
target_include_directories( lib2 PUBLIC<br>
   $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/lib2/headers><br>
   $<INSTALL_INTERFACE:include> )<br>
target_link_libraries( lib2 lib1 )<br>
<br>
install( FILES lib1/headers/lib1.h lib2/headers/lib2.h DESTINATION include )<br>
install( TARGETS lib1 lib2 DESTINATION lib )<br>
<br>
In this setup “lib1” should get a -I${CMAKE_SOURCE_DIR}/lib1/headers flag, and “lib2” should get both -I${CMAKE_SOURCE_DIR}/lib1/headers and -I${CMAKE_SOURCE_DIR}/lib2/headers. Finally the headers both get installed into the same include directory, so an outside user will just have to be able to find that one directory. (Or if you export CMake’s targets, the lib1/2 imported targets will know that their header files are in that directory.)<br>
<br>
Cheers,<br>
        Attila<br>
<div><div class="h5"><br>
> On Dec 10, 2015, at 12:07 AM, Owen Alanzo Hogarth <<a href="mailto:gurenchan@gmail.com">gurenchan@gmail.com</a>> wrote:<br>
><br>
> hi<br>
><br>
> I am building a shared library project that's composed of many smaller shared library files.<br>
><br>
> Here's the main shared library project and a list of all the sub projects.<br>
><br>
> SET(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/headers/main_lib.h)<br>
> SET(SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/main_lib.c)<br>
> SET(TARGET_LIBS core_math point2d line2d quad2d timer_utils)<br>
><br>
> ADD_LIBRARY(main_lib SHARED ${SRC_FILES} ${HEADER_FILES})<br>
> TARGET_LINK_LIBRARIES(core_engine ${TARGET_LIBS})<br>
><br>
> i have each module setup like this.<br>
> module<br>
> module/headers/module.h<br>
> module/module.c<br>
><br>
> then the module.c will look like this<br>
> #include "headers/module.h"<br>
><br>
> the file main_lib.h depends on all those target libs, which makes my main_lib.h file's include statement look like this<br>
><br>
> #include "../../module/headers/module.h"<br>
> #include "../../module1/headers/module1.h"<br>
> #include "../../module2/headers/module2.h"<br>
><br>
><br>
> is there any way that I can clean up these includes?<br>
><br>
> For example if I want to use io functions I can just do #include <stdio.h> or #include <math.h><br>
><br>
> for math functions.<br>
><br>
> I would like to make my include statements not relative to the files actual location, the way it's currently hard coded.<br>
</div></div>> --<br>
><br>
> Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
><br>
> Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
><br>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
><br>
> CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
> CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
> CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
><br>
> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/cmake</a><br>
<br>
</blockquote></div><br></div>