Reputation: 36
First, I am sorry if the question has been answered but I couldn't find any solution.
I am trying to compile a simple program with cmake. But I can't seem to include absolute paths.
My project (located in C:/path/to/my/project
for the understanding) is simple with an include
directory with header files. However, I must include another directory completely somewhere else.
My include_directories
looks like this:
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include" "C:/path/to/my/other/directory/include")
However when I do :
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
message(STATUS "dir='${dir}'")
endforeach()
To check my include directories I have the following answer:
-- dir='/c/path/to/my/project/include'
-- dir='/c/path/to/my/project/C:/path/to/my/other/directory/include'
So cmake
interprets the paths as relative to my project folder.
How can I force cmake
to interpret them as absolute ?
I am using cmake v3.17.3
.
EDIT
I have tried doing so but it doesn't seem to work either since the path is not appended to the INCLUDE_DIRECTORIES property of my target.
add_executable(app src1.c src2.c)
target_include_directories(app BEFORE PRIVATE "C:/path/to/my/other/directory/include")
Thank you by advance.
Upvotes: 1
Views: 2237
Reputation: 975
You can also write the path as:
add_executable(app src1.c src2.c)
target_include_directories(app BEFORE PRIVATE "C:\\path\\to\\my\\other\\directory\\include")
Upvotes: 0
Reputation: 36
So after some research the answer is :
add_executable(app src1.c src2.c)
target_include_directories(app BEFORE PRIVATE "/C/path/to/my/other/directory/include")
The path I was referring to was wrong since I am on msys
. Therefore c:/
should become /c/
.
Upvotes: 1