[CMake] A little help with cmake and external libraries

Owen Alanzo Hogarth gurenchan at gmail.com
Wed Jun 24 14:38:06 EDT 2015


Hi ladies and gentlemen

I've just started using cmake a week or so ago but I am having some
difficulties getting cmake to find external libraries. I am not new to
programming just new to cmake.

I am making a very simple project with a structure like this
project
...cmakelists.txt
project/source
...cmakelists.txt
...main.c
project/source/core
cmakelists.txt
...source1.h
...source1.c
project/source/core/module1
project/source/core/module2
project/source/core/moduleN

the main.c will include source1.h, source1.h will include headers from the
sub modules as i build them out. The submodule1.h includes external
libraries.

This is what my main cmakelists looks like
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(bluengine)

SET(VERSION_MAJOR "0")
SET(VERSION_MINOR "1")
SET(VERSION_PATCH "0")

SET(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

MESSAGE("Binary tree path ${PROJECT_SOURCE_DIR}")
MESSAGE("Version ${VERSION}")

ADD_SUBDIRECTORY(source)


the source cmake project looks like this:
PROJECT(launcher)

SET(SRC_FILES main.c)

ADD_EXECUTABLE(launcher, "${SRC_FILES}")

ADD_SUBDIRECTORY(source)

This project starts to build but fails because of the import that's
included in main.c

I am on a mac and I know where the files are located, the headers are
located at /Library/Frameworks/SDL2.framework/Headers

but I am unsure how to set this project to go there and find the files.
I've read a few tutorials but they don't quite explain this in a way that I
can follow. Hoping someone on this mailing list can help me figure this out.

Best,
Owen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150625/59fa99e5/attachment.html>


More information about the CMake mailing list