[CMake] getting paths of header files

Jakob van Bethlehem jsvanbethlehem at gmail.com
Mon Oct 19 02:34:27 EDT 2015


Hej,

A quick glance doesn't show anything out of the ordinary, except that
* I'd prevent any use of `..` in your folder references (by using things
like $<TARGET_PROPERTY:vector3_scalar,INCLUDE_DIRECTORIES> and
$<TARGET_PROPERTY:vector3_scalar,INTERFACE_INCLUDE_DIRECTORIES>
* I think it is more or less standard practice now to _not_ use
'include_directories', but instead use target_include_directories()
* you'

On Sun, Oct 18, 2015 at 11:58 PM, Owen Alanzo Hogarth <gurenchan at gmail.com>
wrote:

> 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.
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151019/eef3733b/attachment-0001.html>


More information about the CMake mailing list