[CMake] organizing includes statements

Owen Alanzo Hogarth gurenchan at gmail.com
Wed Dec 9 18:07:48 EST 2015


hi

I am building a shared library project that's composed of many smaller
shared library files.

Here's the main shared library project and a list of all the sub projects.

SET(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/headers/main_lib.h)
SET(SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/main_lib.c)
SET(TARGET_LIBS core_math point2d line2d quad2d timer_utils)

ADD_LIBRARY(main_lib SHARED ${SRC_FILES} ${HEADER_FILES})
TARGET_LINK_LIBRARIES(core_engine ${TARGET_LIBS})

i have each module setup like this.
module
module/headers/module.h
module/module.c

then the module.c will look like this
#include "headers/module.h"

the file main_lib.h depends on all those target libs, which makes my
main_lib.h file's include statement look like this

#include "../../module/headers/module.h"
#include "../../module1/headers/module1.h"
#include "../../module2/headers/module2.h"


is there any way that I can clean up these includes?

For example if I want to use io functions I can just do #include <stdio.h>
or #include <math.h>

for math functions.

I would like to make my include statements not relative to the files actual
location, the way it's currently hard coded.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151210/99e54acf/attachment-0001.html>


More information about the CMake mailing list