Closed zhanghua7099 closed 2 months ago
I think the last paragraph of the error message has already given you the hint :-)
After you build Easy3D, you will find the file Easy3DConfig.cmake
in the build (or installation) directory, e.g.,
/Users/lnan/Documents/Projects/Easy3D/cmake-build-release
or (if you have installed Easy3d)
/usr/local/Cellar/easy3d/2.5.2/lib/CMake/Easy3D/Easy3DConfig.cmake
After CMake (of course it shows the error message), open the CMake cache file CMakeCache.txt
and you will see the following line:
Easy3D_DIR:PATH=Easy3D_DIR-NOTFOUND
You can simply replace Easy3D_DIR-NOTFOUND
with any of the above paths.
Rerun CMake and it should work now.
In case you use the UI version of CMake, you first run CMake and you will encounter the error. Then you can simply search Easy3D_DIR
, pass one of the above paths to it, and rerun CMake.
BTW, this process is standard for almost all software based on the CMake build system (meaning your question is not specific to Easy3D, but the usage of CMake).
Hi! Thanks for the tips about cmake!
I solved this problem using the following steps. I run the sudo make install
thus the Easy3D installed at /usr/local/easy3d-2.5.3/
.
The external project is organized as:
Easy3DTest
├── cmake
│ ├── Easy3DTargets.cmake
│ ├── Easy3DTargets-noconfig.cmake
│ └── FindEasy3D.cmake
├── CMakeLists.txt
└── main.cpp
The file in the folder cmake
is copied from
/usr/local/easy3d-2.5.3/lib/CMake/Easy3D/Easy3DTargets.cmake
/usr/local/easy3d-2.5.3/lib/CMake/Easy3D/Easy3DTargets-noconfig.cmake
/usr/local/easy3d-2.5.3/lib/CMake/Easy3D/Easy3DConfig.cmake
Important!: The Easy3DConfig.cmake
is renamed as FindEasy3D.cmake
so that cmake can find Easy3D.
The CMakeLists.txt
is modified to
cmake_minimum_required(VERSION 3.12)
project(MyProject)
set(CMAKE_CXX_STANDARD 11) # specify C++ standard
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package(Easy3D COMPONENTS viewer REQUIRED) # request Easy3D (recommended to request only needed components)
add_executable(Test main.cpp) # create an executable target
target_link_libraries(Test easy3d::viewer) # link to necessary Easy3D modules (add more if needed, e.g., algo)
The demo can be built in my computer.
mkdir build && cd build && cmake .. && make
./Test
Thanks again for your great works!
Glad it work. But I still want to point out that your way of renaming the file is not standard and thus not recommended.
Hi! I have build Easy3D follow the method:
I follow the method from https://github.com/LiangliangNan/Easy3D?tab=readme-ov-file#use-easy3d-in-your-project
and the cmake will output the following errors:
How to get the file "FindEasy3D.cmake"? My system is Ubuntu 20.04.