Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need an easy to find example of CMakeLists.txt file #2847

Closed
pauljurczak opened this issue Jan 1, 2021 · 5 comments
Closed

Need an easy to find example of CMakeLists.txt file #2847

pauljurczak opened this issue Jan 1, 2021 · 5 comments
Labels
build/install Build or installation issue feature request

Comments

@pauljurczak
Copy link
Contributor

I had a bit of difficulty trying to set up a simple C++ project on Linux. I followed the default installation procedure.

The documentation at http://www.open3d.org/docs/release/cpp_project.html mentions a CMakeLists.txt, but that link doesn't work on my browser. The files Open3D/CMakeLists.txt, Open3D/cpp/CMakeLists.txt and Open3D/examples/cpp/CMakeLists.txt didn't help.

I used:

cmake_minimum_required(VERSION 3.18)
project(o3d VERSION 0.1.0)

add_executable(o3d main.cpp)

find_package(Open3D REQUIRED)

include_directories(
  /usr/local/include/open3d/3rdparty
)

target_link_libraries(o3d Open3D::Open3D)

but I expected that including /usr/local/include/open3d/3rdparty will not be necessary. Am I missing something?

@pauljurczak pauljurczak changed the title Need easy to find example of CMakeLists.txt file Need an easy to find example of CMakeLists.txt file Jan 1, 2021
@cbenitez81
Copy link

I think that you're looking for something more like this below, which it works at least for version 0.9.0

cmake_minimum_required(VERSION 3.18)
project(o3d VERSION 0.1.0)

add_executable(o3d main.cpp)

find_package(Open3D REQUIRED)

target_include_directories(o3d
    PUBLIC
    ${Open3D_INCLUDE_DIRS}
    )

target_link_libraries(o3d
    PRIVATE
    ${Open3D_LIBRARIES})

@pauljurczak
Copy link
Contributor Author

Thank you for responding. There are still some issues.

target_include_directories(o3d PUBLIC ${Open3D_INCLUDE_DIRS})

is equivalent to:

include_directories(/usr/local/include/open3d/3rdparty)

but none of them covers tinyfiledialogs, which is not installed into system space, so I have to use:

include_directories(
  /usr/local/include/open3d/3rdparty
  /home/paul/Open3D/3rdparty/tinyfiledialogs/include
)

@pauljurczak
Copy link
Contributor Author

I'm also curious about Open3D::Open3D vs Open3D_LIBRARIES. I see set(Open3D_LIBRARIES Open3D::Open3D) line in Open3DConfig.cmake file. Is this a question of style or is there something deeper here?

@cbenitez81
Copy link

I might say that is something of style, i personally use the one provided on the recipe that I sent. Also using target_include_libraries automatically infers the folder whereas include_directories is set in a stone, but if you provide the "correct" folder, it would work for your system, but not necessarily across platforms or different versions of OS.

Also, 3rdparty folders are mainly created to compile the library, in this case Open3D, and not to have additional libraries installed in your system. Even though once you install open3d some libraries might get installed such as fmt and glew. If you see tinyfiledialogs is used in VisualizationWithEditing.cpp so there is no reference of it in any h file so there is no need to install that in the system. The best that you can do on the top of my head is using it as you're using it right now, in your own module, or install that manually. Another alternative is to modify the CMakeLists inside 3rdparty to add that to the system.

That being say, it would be nice if in the documentation there is a small example of CMakeLists of your own project.

Hope that helps!

@theNded theNded added the build/install Build or installation issue label Nov 21, 2021
@ssheorey
Copy link
Member

ssheorey commented Feb 4, 2022

Two example CMake projects for building your code with Open3D are available here:
http://www.open3d.org/docs/latest/cpp_project.html

@ssheorey ssheorey closed this as completed Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build/install Build or installation issue feature request
Projects
None yet
Development

No branches or pull requests

4 participants