Closed wingdi closed 2 years ago
You probably haven't included the directory correctly. You should be using target_include_directories
in place of include_directories
now-a-days. You've put in the path NumCpp/Coordinates
as a relative path to your build directory and probably have it incorrect. For example if your project was setup like this:
MyProject/
├── CMakeLists.txt
├── NumCpp
│ └── Coordinates
├── build
└── mySource.cpp
then your CMakeLists.txt
would look like:
project(MyProject CXX)
add_executable(${PROJECT_NAME} mySource.cpp)
target_include_directories(${PROJECT_NAME}, ${CMAKE_CURRENT_BUILD_DIR}/../NumCpp/Coordinates)
To build you would:
>> cd build
>> cmake ..
>> cmake --build . --target MyProject
Very thanks for your reply .
Here is a test Project:
This is CMakeLists.txt :
This is mySource.cpp:
This is NumCpp folder copied from NumCpp-master/include :
Developing tool is CLion.
It still get this error . even use file(glob .. ) , still didn't solve it.
I guess I don't understand why you are including the NumCpp/Coordinates
directory if you aren't specifically including any of the files from that directory? In your example above you are including the top level NumCpp.hpp
header so you will need to include the directory that that file is in. eg.
target_include_directories({$PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
Actually i want to include all the NumCpp, because the report error is about NumCpp/Coordinates , so i start solve from it..
Now problem solved, thanks very much !
I have add this in CMakelists.txt:
include_directories(NumCpp NumCpp/Coordinates)
Why can't find it ?