[CMake] getting paths of header files

Jakob van Bethlehem jsvanbethlehem at gmail.com
Mon Oct 19 02:37:42 EDT 2015


Damn..... send the unfinished message, I'll repeat what I had, and type the
rest:

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 do add_subdirectory(source), but don't show the lists-file in that
folder, which may cause the problem you're seeing

The first thing I see that seems really wrong though, is that you type the
'project()' command twice. AFAIK you're supposed to use this command
exactly once, to set the properties of the entire project. Using it
multiple times causes undefined behaviour, and may very well be the cause
for what you're seeing

Sincerely,
Jakob


On Mon, Oct 19, 2015 at 8:34 AM, Jakob van Bethlehem <
jsvanbethlehem at gmail.com> wrote:

> 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/b657371b/attachment.html>


More information about the CMake mailing list