Configuring Assimp - cmake

I want to build ASSIMP without SMD importer.
I use cmake.
I added in CMakeLists:add_definitions(ASSIMP_BUILD_NO_SMD_IMPORTER)
I entered this in command prompt:
cmake -G "MinGW Makefiles" CMakelists.txt -S ./ -B ./BUILD_ASSIMP
Normaly after disabling SMD it should be written "disabled importer formats:SMD " but it's only written "disabled importer formats:"
Here is a part of the entire log:
--Enabled importer formats: AMF 3DS AC ASE ASSBIN B3D BVH COLLADA DXF CSM HMP IRRMESH IRR LWO LWS MD2 MD3 MD5 MDC MDL NFF NDO OFF OBJ OGRE OPENGEX PLY MS3D COB BLEND IFC XGL FBX Q3D Q3BSP RAW SIB SMD STL TERRAGEN 3D X X3D GLTF 3MF MMD STEP
-- Disabled importer formats:
-- Enabled exporter formats: 3DS ASSBIN ASSXML COLLADA OBJ OPENGEX PLY FBX STL X X3D GLTF 3MF ASSJSON STEP
-- Disabled exporter formats:
-- Configuring done
How to disable the SMD loader?

If you want to disable the SMD_LOADER you need to specify which loaders shall be included:
cmake CMakeLists.txt -DASSIMP_BUILD_SMD_IMPORTER=ON
Now only the SMD loader will be included and all others will be disabled. Do this with the loaders you want to have and do not enable the SMD-Importer.
Or you can just add the following option in your CMakeLists-file which runs the assimp-build:
add_definition(ASSIMP_BUILD_NO_SMD_IMPORTER

Related

Use generated images in a Sphinx document with CMake

How do I include an image in a Sphinx .rst file that has been automatically generated outside the Sphinx source directory?
I build a Sphinx project using CMake. One of the Sphinx source files includes a PDF image that is generated by a separate target in the CMake project. As far as I understand, one should not generate outputs from a CMake build process inside the CMake source tree. (I think this can be justified by the fact that different CMake build configurations generate different outputs). Thus, the input to the Sphinx build cannot be in the Sphinx source tree and the relative path to the the image to include in the Sphinx document is unknown when writing the Sphinx code.
How can I solve this?
Here's a sketch of a solution (too big for a comment):
You could call Sphinx from CMake with an environment variable set that points to the build (sub)directory where your generated images are stored. Pass this with add_custom_command and ${CMAKE_COMMAND} -E env ...
Your Sphinx config could read that environment variable (``) and add the result to html_static_path:
import os
# ...
html_static_path = [
# ...
os.getenv('BUILD_DIR'),
]
Then ensure that you have a custom target (call it generate_doc_images) to drive the custom command(s) that generate your images. Use add_dependencies to make sure that the image generators run before Sphinx.
If you provide an MRE that gets you almost all the way there, I can help you wire things up correctly.

Include OpenCV directory in YOLOv3 darknet (AlexeyAB) installation in cmake

I am trying to link OpenCV to the darknet directory.
I am working with a Nvidia Jetson AGX Xavier (Ubuntu 18.04). Until recently OpenCV was installed by JetPack in the directory /usr. With this configuration the real time detection of darknet (https://github.com/AlexeyAB/darknet) with a webcam was working.
I had to renew the installation of OpenCV and now its directory is home/user/OpenCV. I could not include it in the previous directory because of missing permissions.
Now, every time I start the real time detection of darknet with the command
./darknet detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights -c 0
I recieve this error log:
./darknet: error while loading shared libraries: libopencv_highgui.so.3.3: cannot open shared object file: No such file or directory
When I recompile darknet (cmake, make, install) I receive another error message:
Demo needs OpenCV for webcam images.
So I assume, that OpenCV is not included in the compilation and darknet does not find the libraries.
I tested this options:
In the Makefile of darknet OPENCV=1 is included (double checked, totally sure, that this is not the fault)
I tried to export the path of OpenCV to its previous path e.g. with export OpenCV_DIR=/usr/share/OpenCV
I tried to link the path e.g. with LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
or LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/share
I think there could be a possibility to include the OpenCV path in some file related to cmake. In the CmakeLists.txt file is the line
set(PThreads_windows_DIR ${CMAKE_CURRENT_LIST_DIR}/3rdparty/pthreads CACHE PATH "Path where pthreads for windows can be located")
endif()
set(Stb_DIR ${CMAKE_CURRENT_LIST_DIR}/3rdparty/stb CACHE PATH "Path where Stb image library can be located")
set(CMAKE_DEBUG_POSTFIX d)
set(CMAKE_THREAD_PREFER_PTHREAD ON)
find_package(Threads REQUIRED)
if(MSVC)
find_package(PThreads_windows REQUIRED)
endif()
if(ENABLE_OPENCV)
if(OpenCV_FOUND)
if(SELECT_OPENCV_MODULES)
I think here or maybe somewhere else I should include the new directory path to OpenCV. I tried with find_package or set_path, but I am not sure if this was the right point to enter this option. Also I have no file called finOpencv.cmake.
Does someone have an idea, how i could 'tell' darknet, where OpenCV is located?
If you need further information, I will be happy to share.
Any help is appreciated. Thanks!
Edit: If I include Find_Package(OpenCV) in CMakeLists.txt and recompile, I recieve this output:
CMake Warning at CMakeLists.txt:96 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
Edit: If I include Find_Package(OpenCV) in CMakeLists.txt and recompile, I recieve this output
It's good. And as a next step in darknet build directory:
cmake . -DOpenCV_DIR=/usr/share/OpenCV

Using HDF5 on Windows 10: Could NOT find HDF5 (missing: HDF5_DIR)

I was successfully able to use HDF5 in my C++ project on MacOS and Linux.
Currently I am trying to get it to work on Windows 10, but I get the following CMake output:
-- Could NOT find HDF5 (missing: HDF5_DIR)
-- Configuring done
-- Generating done
-- Build files have been written to: /cygdrive/z/hdf5parser/cmake-build-debug
I installed the Pre-built Binary Distribution of HDF5 on Windows and set the environment variable HDF5_DIR to C:/Program Files/HDF_Group/HDF5/1.10.5/cmake.
According to the official documentation I use the following CMake configuration for my project:
cmake_minimum_required (VERSION 3.10)
project (HDF5MyApp C CXX)
set (LIB_TYPE STATIC) # or SHARED
string(TOLOWER ${LIB_TYPE} SEARCH_TYPE)
find_package (HDF5 NAMES hdf5 COMPONENTS C ${SEARCH_TYPE})
set_directory_properties(PROPERTIES INCLUDE_DIRECTORIES "${HDF5_INCLUDE_DIR}")
set (LINK_LIBS ${LINK_LIBS} ${HDF5_C_${LIB_TYPE}_LIBRARY})
set (example HdfHandler)
add_executable(...) # I skipped this part
target_link_libraries(hdf5parser PRIVATE ${LINK_LIBS})
Had somebody similar problems or can give me a hint to use HDF5 on Windows?

CMake wrapper for new command-line tools

I'm trying to provide a simple CMake function to render PlantUML diagrams to PNG as part of my build process. The idea is that I have a bunch of .uml files containing PlantUML diagrams that I want to render to PNG as part of my build process. I would like to have a function similar to add_library() et. al. that renders any diagram for which the image file is older than the source file.
Using add_custom_command(), I came up with the following snippet:
#
# Create top-level target that renders a PlantUML diagram to a PNG image.
#
function(add_diagram target source)
# Program used to render the diagram.
set(plantuml java -jar ${PLANTUML_JARFILE})
# Diagram source file basename used to create output file name.
get_filename_component(output ${source} NAME_WE)
# Render the diagram and write an "${output}.png"
# file in the current binary folder.
add_custom_command(
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/${output}.png
COMMAND
${plantuml} -o ${CMAKE_CURRENT_BINARY_DIR} -tpng ${source}
MAIN_DEPENDENCY
${source}
COMMENT
"Rendering diagram '${output}'."
)
# Top-level target to build the output file.
add_custom_target(${target}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${output}.png)
endfunction()
And I invoke this function as:
add_diagram(foo ${CMAKE_CURRENT_SOURCE_DIR}/foo.uml)
where foo.uml is a file containing a PlantUML diagram. At a very basic level, this "works" in that it creates a named top-level target that I can build manually (e.g. using make foo, nmake foo, jom foo, etc.).
How can I add this target to the default target (all?) such that this is automatically built with the rest of the libraries and executables?
From the CMake documentation:
add_custom_target: Add a target with no output so it will always be built.
If the ALL option is specified it indicates that this target should be added to the default build target so that it will be run every time.
Dependencies listed with the DEPENDS argument may reference files and outputs of custom commands created with add_custom_command() in the same directory (CMakeLists.txt file).
If you are using Visual Studio, the only drawback is that it will create a new project for each target.

Imagemagick not working with png files

For some reason my imagemagick cant process any png files. They all complain with something like the following (can be replicated easily using identify -format %wx%h afile.png ):
identify: memory allocation failed `afile.png' # error/png.c/ReadOnePNGImage/2123.
identify: corrupt image `afile.png' # error/png.c/ReadPNGImage/3668.
Jpegs work fine. But no matter what png file I create on photoshop or download of the net it wont work.
I am using mac os x 10.5 and imagemagick 6.7.1-0 2011-08-01 Q8
CONFIGURE ./configure '--prefix=/usr/local' '--disable-static' '--with-modules' '--without-perl' '--without-magick-plus-plus' '--with-quantum-depth=8' '--disable-openmp' '--with-gs-font-dir=/usr/local/share/ghostscript/fonts' 'LDFLAGS=-L/usr/local/lib' 'CPPFLAGS=-I/usr/local/include'
CONFIGURE_PATH /usr/local/etc/ImageMagick/
COPYRIGHT Copyright (C) 1999-2011 ImageMagick Studio LLC
CPPFLAGS -I/usr/local/include/ImageMagick
CXX g++
CXXFLAGS -g -O2 -D_THREAD_SAFE -pthread
DEFS -DHAVE_CONFIG_H
DELEGATES bzlib freetype jpeg jng lcms2 png tiff x11 xml zlib
DISTCHECK_CONFIG_FLAGS 'CPPFLAGS=-I/usr/local/include' 'LDFLAGS=-L/usr/local/lib' --disable-deprecated --with-umem=no --with-autotrace=no --with-gslib=no --with-fontpath= --with-gs-font-dir=/usr/local/share/ghostscript/fonts --with-perl=no
DOCUMENTATION_PATH /usr/local/share/doc/ImageMagick-6.7.1/
EXEC-PREFIX /usr/local
EXECUTABLE_PATH /usr/local/bin
FEATURES
FILTER_PATH /usr/local/lib/ImageMagick-6.7.1/modules-Q8/filters
HOST i386-apple-darwin9.8.0
LDFLAGS -L/usr/local/lib -L/usr/local/lib -L/usr/X11/lib -R/usr/X11/lib
LIB_VERSION 0x671
LIB_VERSION_NUMBER 6,7,1,0
LIBRARY_PATH /usr/local/lib/ImageMagick-6.7.1
LIBS -lMagickCore -llcms2 -ltiff -lfreetype -ljpeg -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -lpthread
NAME ImageMagick
I have googled everything but cant seem to get a handle on it. I am able to change settings in Imagemagick but I cant really pass in params to the function calls as I am calling this lib through a ruby on rails third party gem. Has anyone else had this issue?
You need to make sure you have installed the requisite PNG libraries and build ImageMagick with those libraries included.
The best instructions for building ImageMagick for use with rmagick (the Ruby on Rails gem) are at the source - http://rmagick.rubyforge.org/install-linux.html
Some additional notes, run your ./configure command again, or check your configure log, and look for the summary section (it is noted in the document linked above or just search for "ImageMagick is configured as follows". There you will see a list of libraries it is attempting to use and what are found. You should see a line like:
PNG --with-png=yes yes
If it says --with-png=no, or if it has the value "no", then that is your problem. You need to install the png libs. And make sure you install the png-devel libs too, since they are needed for building from source. Now, when you run ./configure, it should discover the png libs and included them in the build.
One last final note, not covered in the document linked above, is that you might need to include --disable-openmp in your ./configure parameters, depending on your hardware. And it looks like you have included it, so you should be good.