issue when building module using cmake - cmake

i am trying to build box2D using cmake. When i click configure (and selecting my version of visual studio) cmake starts working but it finnishes with the error message:
You have called ADD_LIBRARY for library glfw without any source files.
This typically indicates a problem with your CMakeLists.txt file
Configuring done
What is the issue and how can i solve it? Where is the CMakeLists.txt located and how can i edit it to build without errors?

It is probably an error in this library. Try another version or post a bug.
It means that according to this file, a library should be created without source files (an empty library), which is probably bug.
CMakeLists.txt is located in every cmake source directory, make sure you're choosing the right directory.

Related

cmake not finding package configuration file

I am using Qt Creator as IDE and MSVC 2019.
I built and installed the pagmo library from the source. Now I am trying to use it for my project.
Even though the installation seems fine, when I try to load it I get strange errors, telling me that "pagmo" is not found. In particular:
error:
By not providing "FindPagmo.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Pagmo",
but CMake did not find one.
Could not find a package configuration file provided by "Pagmo" with any
of the following names:
PagmoConfig.cmake
pagmo-config.cmake
Add the installation prefix of "Pagmo" to CMAKE_PREFIX_PATH or set
"Pagmo_DIR" to a directory containing one of the above files. If
"Pagmo" provides a separate development package or SDK, be sure it has
been installed.
In my CMakeLists.txt I have set the following command:
find_package(Pagmo REQUIRED)
Now, as far as I know FindPagmo.cmake does not exist, BUT I am giving as input parameter Pagmo_DIR, which contains the file pagmo-config.cmake. I can't understand why CMake is not finding it. I also tried to set CMAKE_MODULE_PATH to the same folder but nothing changed.
Does anybody have suggestions on how to solve this problem?
I am setting pagmo directory as follows:
-DPagmo_DIR = C:\Lib\pagmo\install\debug\lib\cmake\pagmo
in that folder I have the following files:
Findpagmo_IPOPT.cmake;
pagmo_export.cmake;
pagmo_export-debug.cmake;
pagmo-config.cmake;
pagmo-config-version.cmake;
PagmoFindBoost.cmake

CMake linking error at runtime from other lib in subdirectory

I am trying to get a project running that is using dynamic openCASCADE libraries.
So first i set up a minimal test project using the following CMake file:
...
include_directories(/home/user/occt/build_r/include/opencascade/)
add_executable(testOCCT
main.cpp
step2stl.cpp
)
find_package(OpenCASCADE REQUIRED NO_DEFAULT_PATH)
set(OCCT_LIBS TKMesh; TKSTEP; TKSTL; TKXSBase; TKernel)
target_link_libraries(testOCCT ${OCCT_LIBS})
This is working as it should.
Now i want to link the same libraries to another library that is used in a larger project.
For the project there are 3 CMake files, one for the project and two subdirectory, one for the executable one for the myLib, which are added by add_subdirectory().
In the CMake file for myLib which is inside one of the subdirectories I've added:
...
include_directories(/home/user/occt/build_r/include/opencascade/)
...
add_library(${MY_LIB_NAME} SHARED ${my_sources})
find_package(OpenCASCADE REQUIRED NO_DEFAULT_PATH)
set(OCCT_LIBS TKMesh; TKSTEP; TKSTL; TKXSBase; TKernel)
target_link_libraries(${MY_LIB_NAME} ${OCCT_LIBS})
so basically the same as in the test project.
However now I get an error (at runtime):
symbol lookup error: myLib.so: undefined symbol: _ZN24BRepMesh_IncrementalMeshC1ERK12TopoDS_Shapedbdb
Ok, so i found the problem myself. The reason it did not work was not because of CMake, but that there was some other version of the libraries installed over the packet manager, which then got loaded instead of the right one.
purging those libs solved the problem.
However what I still don't get is why it loaded the correct library version on the test project and the wrong on the other (both tested on the same machine)

Gnuradio OOT not seeing sources?

When trying to write an OOT block for Gnuradio, I ran cmake ../, and then make. The make process successfully builds some objects, but when it gets to the step:
Linking CXX executable test-XXXXXXXX
there is the problem:
libgnuradio-XXXXXXXX.so: undefined reference to 'YYYYYYYY'
YYYYYYYY is a function defined in a .cc file, which I add to the _impl.cc for the block using a header. This source is apparently not being found, despite being in the same source directory as the _impl.cc file.
Cmake explicitly warns not to make any modifications to the generated Makefile, and it is a fairly complex makefile anyway, so I would be hesitant to try messing with it. Is there another way to direct make to include that additional source when linking?
Your best bet is to look at the CMakeLists.txt at the top of your OOT folder. It is most likely that you are seeing a link problem and that a package dependency is not satisfied. The cmake find_package utility can be used to determine if a dependency is available on the system. If you look at the cmake/Modules directory under the main OOT folder, there should be a couple of examples. Cmake ships with many modules so it's likely what you need will exist.
By adding some find_package logic to the main CMakeLists.txt file, and then blowing away the build directory and making it again and executing "cmake ../", the dependency issue should be apparent. Put another way, whatever libgnuradio-*.so thinks is missing must belong to a package that is not installed on your system. Using find_package will confirm it, and then the answer is to install it.
Look at some other CMakeLists.txt files, say, in gr-digital, for find_package examples.

Openscenegraph not generating viewer examples

I downloaded the latest release of OpenSceneGraph (3.4.0) (zipped file and latest github repository).
I am trying to generate at least the osgviewerQT and osgViewerWX examples. They are contained in the examples folder, but after using CMake to generate everything, the only osgviewer-Example is osgviewerGLUT. Also osgqt.lib and osgwx.lib are missing in the lib-folder after building the generated projects via ALL_BUILD and INSTALL.
In CMake I made sure that all wx and Qt5 (using Qt5.6) folders are found. But still no examples after generating. Any ideas?
The CMake rules for OpenSceneGraph include a BUILD_OSG_EXAMPLES toggle. Did you select that option in CMake?
You need to select the BUILD_OSG_APPLICATIONS toggle and you will see the applications (osgarchive, osgconv, osgfilecache, osgversion, osgviewer, present3D) in the bin directory.
In order to compile osgViewerQt you need to set QT_QMAKE_EXECUTABLE to the location where you have qmake (typically in the directory bin of Qt). This varialbe, when not just found, is available under "Ungrouped Entries".
After setting such url, CMake will be able to find Qt; then, enabling BUILD_OSG_APPLICATIONS and BUILD_OSG_EXAMPLES, it will also build other applications related to Qt.

Building third party library as part of CMake project

I have a top level CMakeLists.txt file which builds a library called Camellia and several executables in subdirectories which link with Camellia. I would like to add a third party library called XDMF as a dependency for Camellia under Camellia/TPL/Xdmf. Luckily, XDMF is already on a CMake build system, but when I use
add_subdirectory(TPL/Xdmf)
and then
add_library(Camellia ${LIB_SOURCES} ${HEADERS})
it builds Camellia in the build/TPL/Xdmf/bin directory rather than build as it does without the add_subdirectory(TPL/Xdmf). Why does adding a subdirectory change the build directory for Camellia, and how do I fix it? Also how do I make sure Camellia is linking with Xdmf once I get that figured out?
I think that ExternalProject_Add(...) is what you want.
Please see CMake: How to build external projects and include their targets which describes a similar issue.