How to print / show included directories in CMakeList

I'm trying to create a trivial proof of concept design using CMake, and I quickly get tired of it - to the point where I think it would be better to handle my own damn Makefile.

I have a directory structure that looks something like this:

project:
    /extproj
    /src/file.cpp
    /include/file1.h

      

My CMakeLists.txt file contains the following section, which I, after reading the CMake documentation, would rather naively believe, would specify the include directories for the project:

INCLUDE_DIRECTORIES (include/ 
                     extproj/sdk/math/linearalg/ 
                     extproj/sdk/math/nonlinearsolvers/ 
                    )  

      

I am trying to build it using the following command

COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_FLAGS} ${ALL_SOURCES}

Where ${ALL_SOURCES}

is a list variable containing all the C ++ files that I need to compile. I have verified that this variable contains the correct files.

I cannot, however, for the life of me figure out what is actually passed to the compiler as include directories.

I have searched the internet and so the post is the recommended one to use get_directory_properties

. I tried this, and of course CMake was immediately unable to create the Makefile and complained:

Unknown CMake command "get_directory_properties".

When I create a Makefile and run make on it, the compiler immediately outputs with an error message:

/path/to/project/src/file1.cpp:1:10: fatal error: file1.h missing found

Is there any way I can find out what on earth is being used as include paths passed to my compiler?

0


source to share


1 answer


I believe the correct way is to compile the source files add_executable(executableName ${SRCS}

. The directories added with are include_directories(...)

then automatically passed to the compiler.

If you are using a custom command to compile, you need to modify the CMakeLists.txt file.



set(MY_INCLUDE_DIRS_FLAGS "-Iinclude/ -Iextproj/sdk/math/linearalg/ -Iextproj/sdk/mat/nonlinearsolvers/")

set(MY_COMPILE_COMMAND ${CMAKE_CXX_COMPILER} ${MY_INCLUDE_DIRS_FLAGS} ${CMAKE_CXX_FLAGS} ${ALL_SOURCES}

      

+1


source







All Articles