[CMake] getting paths of header files

Owen Alanzo Hogarth gurenchan at gmail.com
Sun Oct 18 17:58:45 EDT 2015


I am having some trouble with my cmake build. I recently redesigned the
physical layout of my files so that it'll be a bit easier to maintain in
the long run.

I have my project structure setup like this.

MAIN_PROJECT/
project/main.c # this is the executable
resources/...    # a folder filled with resources
source/
source/moduleA/moduleA.h #includes all headers for this module
                                             #a user would just import
moduleA.h

source/moduleA/headers/header1.h header2.h
source/moduleA/src/source1.c  source2.c
source/moduleA/common/common_structs.h #holds common structs for

#all src files in this module


with my project re-organized like this and try to build my shared libraries
I get no output.

For example main cmakelists.txt file

PROJECT(project)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY $(CMAKE_BINARY_DIR)/lib)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY $(CMAKE_BINARY_DIR)/lib)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY $(CMAKE_BINARY_DIR)/bin)

SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)

ADD_SUBDIRECTORY(source)

FILE(COPY ${CMAKE_CURRENT_SOURCE_DIR}/resources/ DESTINATION
${CMAKE_CURRENT_BINARY_DIR}/bin/resources/)

this is one module within the source folder, a matrix4

PROJECT(matrix4_scalar)

INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../common")
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_SOURCE_DIR}/../vector3_scalar/headers/vector3_scalar.h")

SET(HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/../common/common_structs.h"
"${CMAKE_CURRENT_SOURCE_DIR}/../vector3_scalar/headers/vector3_scalar.h")


SET(SRC_FILES src/matrix4_scalar.c ${HEADER_FILES})

ADD_LIBRARY(matrix4_scalar SHARED ${SRC_FILES})

TARGET_LINK_LIBRARIES(matrix4_scalar vector3_scalar)



The vector3 class is built in a similar way but has no outside dependencies
except for the common_struct.h header file.

This matrix class depends on the vector3 class so I have it as a target
link library.

When I build like this I get no output to my lib directories and I am not
sure what's going on.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151019/05059aab/attachment.html>


More information about the CMake mailing list