Link ceres to CGAL to use the smooth_mesh() function - cmake

I want to add a smoothing function to my C++ project so I'm trying to use the smooth_mesh() function in the CGAL library. This function requires ceres-solver to work (and glog and Eigen) so I included it in an include folder in my project.
My problem is that when I try to launch a CGAL::Polygon_mesh_processing::smooth_mesh(), it returns an error (even though everything compiles properly):
Area-based smoothing requires the Ceres Library, which is not available.
The full way I use the function is the following:
CGAL::Polygon_mesh_processing::smooth_mesh(mesh,
CGAL::Polygon_mesh_processing::parameters::number_of_iterations(nb_iterations)
.use_area_smoothing(true)
.use_safety_constraints(false)
.edge_is_constrained_map(eif));
There is a very similar question on stack but the given solution did not help me to solve my problem. The answer directed me to use #define CGAL_PMP_USE_CERES_SOLVER but even with that the error is still happening.
It also mentions Cmake but I haven't built my project nor the libraries with CMake because CGAL instructions use vcpkg so I'm guessing that it may be where the problem comes from considering most ceres doc I found use Cmake. But instructions to link ceres and cgal using Cmake are pretty hard to find and/or not very clear (and I'm also very new to Cmake so that's not helping...).
I have tried to add the library manually to my project settings (I'm using Visual Studio on Windows), add some #include linking to ceres in some cgal files but nothing seems to be working.
I'm hoping someone here has run into this problem and managed to solve it.
If you can help me, thank you in advance!

Related

Compiling project that depend on LLVM using CMake on Windows

I'm a *nix user, installing LLVM is easy for me, just download the precompiled file, set LLVM_DIR, and you're done. But I'm having a lot of problems with Windows ...
I downloaded LLVM-<version>-win64.exe from the GitHub release, but I can't find LLVMConfig.cmake file. Then I tried to compile LLVM from the source following this documentation.
When I started compiling my own project, I got this error:
'C:/<...>/Debug/libLLVMSupport.lib', needed by '<...>.exe', missing and no known rule to make it
I guess maybe I'm missing some compile options. but I can't find the documentation for LLVM_ENABLE_PROJECTS or BUILD_SHARED_LIBS, not even a list of component names.
I tried to add -DBUILD_SHARED_LIBS=ON but CMake told me BUILD_SHARED_LIBS option is not supported on Windows.

Using CGAL 5.1 with third party Libraries

I am trying to compile the example read_las_example.cpp in CGAL examples directory Point_set_processing_3.
However cmake command runs into the error:
include could not find load file:
CGAL_LASLIB_support
There are some directions on using CGAL with third party libraries here : https://doc.cgal.org/latest/Manual/thirdparty.html#thirdpartyLASlib
but I am not able to follow it. In particular I don't understand how to do this - "the executables should be linked with the CMake imported target CGAL::LASLIB_support provided in CGAL_LASLIB_support.cmake". If it helps, the CGAL_LASLIB_support.cmake file is located in the directory cgal/5.1/lib/cmake/CGAL
Can anyone help with how to use CGAL with third party libraries, in particular LASlib.
It means you need to include CGAL_LASLIB_support and call target_link_libraries(your_exe_name CGAL::LASLIB_support)
It is already used in the example's CmakeLists.txt, you should check that the CGAL you are using is really 5.1, not another version cached somewhere in your system. The target CGAL::LASLIB_support only exists since 5.1, so the error seems to indicate that the CGAL version you are using is not the right one.

What is the purpose of additional CGAL targets that are generated by cmake

I have installed CGAL and added it to myProject via cmake:
find_package(CGAL REQUIRED)
target_link_libraries(myProject PRIVATE CGAL::CGAL)
I can use CGAL in myProject without problems, however it adds the following targets in cmake (or in Visual Studio the respective projects to my solution):
Continuous, Experimental, Nightly, NightlyMemoryCheck
I wasn't able to find any documentation on what their purpose is. The "How to use CGAL with CMake" wiki page doesn't mention them either.
The names could suggest that they might be used if one wants to contribute to CGAL. Is that correct or do they have another purpose? Can these targets be disabled if I don't need them?
Those targets are created by the CTest module of CMake, that CGAL includes. Actually, it should not include it because CGAL does not really uses it. My mistake. The pull-request CGAL/cgal#3657 will fix that in the development branch of CGAL, and soon in CGAL-4.14.

Why is VULKAN_LIBRARY set to VULKAN_LIBRARY-NOTFOUND yet VULKAN_FOUND is TRUE?

I'm interested in trying out Vulkan for myself, but I'm having difficulty getting CMake to link to it reliably. I decided to use CMake's FindVulkan module... or at least how I think it should work. Here's how I did it:
# Hey CMake. Look for Vulkan.
find_package(Vulkan REQUIRED)
# Alright, no errors? Tell me what you found!
message("Vulkan found? " ${VULKAN_FOUND})
message("Alright, where is it? " ${VULKAN_LIBRARY})
message("And I can include it? " ${VULKAN_INCLUDE_DIR})
And a little later in the file:
# Let's make a library and link vulkan
include_directories(${VULKAN_INCLUDE_DIR})
add_library(myLib myLib.cpp myLib.h)
target_link_libraries(myLib ${VULKAN_LIBRARY})
So, I get my results! First off, my CMake output:
Vulkan found? TRUE
Alright, where is it? VULKAN_LIBRARY-NOTFOUND
And I can include it? C:/VulkanSDK/1.0.65.1/Include
-- Could NOT find Vulkan (missing: VULKAN_LIBRARY)
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Using Win32 for window creation
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
VULKAN_LIBRARY (ADVANCED)
linked by target "TOVE" in directory C:/Users/User/Desktop/TOVE
Odd, looks like you found my include directory, but you can't find my library. The messages in the middle are actually GLFW. I kept them in just incase they meant something more. Finally, CMake stops with an error.
Some additional testing reveals that both ${VULKAN_LIBRARIES} and ${VULKAN_INCLUDE_DIRS} are blank. As expected, swapping them out with their singular counterparts makes Visual Studio 2017 mountains of confused about my vulkan/vulkan.h include.
I can't find any case on the internet where someone gets a VULKAN_LIBRARY-NOTFOUND, but there might be another library that has similar issues. Why am I finding only half of the information here? Is it an issue with Vulkan or CMake, or am I just really bad at writing with CMake. I'm relatively new to CMake, and I'm just experimenting with it so I apologize if it was just me misusing some important function or something among those lines.
I had the same error while trying to compile GLFW 3.2.1 on Windows. The problem is that GLFW CMakeLists uses its own FindVulkan.cmake in "${GLFW_SOURCE_DIR}/CMake/modules" which seems a bit outdated.
Taking some code from the FindVulkan.cmake inside CMake distribution (3.10) to modify the GLFW file works as expected and VULKAN_LIBRARY cache var is filled with the path of the .lib file.

error related to static linking of glibcxx and glibc

I am am trying to cross-compile an x86 program for alpha using g++. For that, I tried both "-static-libgcc" and "--static" options when linking the object file with libraries to generate the binaries. The cross compilation was successful, however I got the following errors when I ran the binaries on alpha machine:
./word_count: /lib/libc.so.6.1: version GLIBC_2.4' not found (required by ./word_count)
./word_count: /usr/lib/libstdc++.so.6: versionGLIBCXX_3.4.10' not found (required by ./word_
These errors shouldn't happen, since I am using static linking! So, I cannot figure out why I am getting these errors! Any help is appreciated.
You need to link against both, standard C and C++ libraries. (source)