Currently I am trying to build PlusRemote from SlicerIGT, but I keep getting errors that don't make much sense to me. I downloaded SlicerIGT from GitHub here, and I made sure to update CMake to version 3.2.3. The directory I am getting the source from should be fine. This is the error log I am getting:
CMake Error at CMakeLists.txt:19 (slicerMacroBuildScriptedModule):
Unknown CMake command "slicerMacroBuildScriptedModule".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.2)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
Is there any way to solve this, or is there a better way to go about building PlusRemote?
EDIT:
I managed to specify the minimum required version so now the only error I am getting is:
CMake Error at CMakeLists.txt:19 (slicerMacroBuildScriptedModule):
Unknown CMake command "slicerMacroBuildScriptedModule".
If anything, this is what CMake is reading:
#-----------------------------------------------------------------------------
set(MODULE_NAME PlusRemote)
cmake_minimum_required(VERSION 3.2)
#-----------------------------------------------------------------------------
set(MODULE_PYTHON_SCRIPTS
${MODULE_NAME}.py
)
set(MODULE_PYTHON_RESOURCES
Resources/Icons/${MODULE_NAME}.png
Resources/Icons/icon_Record.png
Resources/Icons/icon_Stop.png
Resources/Icons/icon_Wait.png
Resources/Icons/VisibleOff.png
Resources/Icons/VisibleOn.png
)
#-----------------------------------------------------------------------------
slicerMacroBuildScriptedModule(
NAME ${MODULE_NAME}
SCRIPTS ${MODULE_PYTHON_SCRIPTS}
RESOURCES ${MODULE_PYTHON_RESOURCES}
WITH_GENERIC_TESTS
)
#-----------------------------------------------------------------------------
if(BUILD_TESTING)
# Register the unittest subclass in the main script as a ctest.
# Note that the test will also be available at runtime.
slicer_add_python_unittest(SCRIPT ${MODULE_NAME}.py)
# Additional build-time testing
add_subdirectory(Testing)
endif()
Did I miss downloading or updating anything?
EDIT: Is this what I'm missing?
PlusRemote does not need to be built using CMake in order to have Plus run. Plus will start on it's own. Wish I had known this 3 hours ago.
Related
I am trying to include tensorflow-lite in a project per the minimal example here: Build TensorFlow Lite with CMake. Specifically, I'm trying to add_subdirectory the CMakeLists.txt for tflite, as recommended.
This works when the project is first built, but if I change my top-level CMakeLists.txt for any reason (adding a test or linking something to a different target, say), then the build fails with the following:
-- Setting build type to Release, for debug builds use'-DCMAKE_BUILD_TYPE=Debug'.
CMake Warning at build/abseil-cpp/CMakeLists.txt:70 (message):
A future Abseil release will default ABSL_PROPAGATE_CXX_STD to ON for CMake
3.8 and up. We recommend enabling this option to ensure your project still
builds correctly.
-- Standard libraries to link to explicitly: none
-- The Fortran compiler identification is GNU 9.4.0
-- Could NOT find CLANG_FORMAT: Found unsuitable version "0.0", but required is exact version "9" (found CLANG_FORMAT_EXECUTABLE-NOTFOUND)
--
-- Configured Eigen 3.4.90
--
-- Proceeding with version: 2.0.6.v2.0.6
-- CMAKE_CXX_FLAGS: -std=c++0x -Wall -pedantic -Werror -Wextra -Werror=shadow -faligned-new -Werror=implicit-fallthrough=2 -Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter -fsigned-char
CMake Error at build/cpuinfo/CMakeLists.txt:262 (ADD_SUBDIRECTORY):
ADD_SUBDIRECTORY not given a binary directory but the given source
directory "/opt/------/workspace/------/build/clog-source"
is not a subdirectory of
"/opt/------/workspace/------/build/cpuinfo". When
specifying an out-of-tree source a binary directory must be explicitly
specified.
CMake Error at build/cpuinfo/CMakeLists.txt:265 (SET_PROPERTY):
SET_PROPERTY could not find TARGET clog. Perhaps it has not yet been
created.
-- Configuring incomplete, errors occurred!
See also "/opt/------/workspace/------/build/CMakeFiles/CMakeOutput.log".
See also "/opt/------/workspace/------/build/CMakeFiles/CMakeError.log".
(Those dashes aren't real paths, they're just to mask sensitive info.)
Just to reiterate, it DOES configure and build correctly the first time, but reruns of cmake .. will fail.
I've tried this on a couple of platforms and got the same result. You should be able to reproduce with a minimal CMakeLists.txt containing add_subdirectory and some helloworld target to link tensorflow-lite.
I tried giving the add_subdirectory for clog a binary location but just got a cascade of new errors, and at that point my CMake know-how definitely runs out.
The issue is due to the same cmake variable CLOG_SOURCE_DIR used in both xnnpack and cpuinfo.
In xnnpack, it uses a cmake script to download, configure and build the clog.
In cpuinfo, it add as a subdirectory.
So they use different ways to add dependency. We need to fix this issue in either xnnpack or cpuinfo but as a walkaround, we can change the CLOG_SOURCE_DIR in either project to a different name (e.g. CLOG_SOURCE_DIR1) then this problem will go away.
I'm having trouble understanding how to use pybind11 conan package. I can use some others, but pybind11 is giving me hard time.
My starting point is as follows:
conanfile.txt:
[requires]
pybind11/2.7.1
[generators]
cmake
main.cpp:
#include <pybind11/pybind11.h>
int add(int i, int j) {return i + j;}
PYBIND11_MODULE(cobind, m) {m.def("add", &add);}
CMakeLists.txt
cmake_minimum_required(VERSION 3.21)
project(cobind11 VERSION 1.0 LANGUAGES CXX)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
pybind11_add_module(cobind main.cpp)
The log of my suffering trying to make this work:
💀 Starting point
If I try to build as above the project I get the following error:
CMake Error at CMakeLists.txt:10 (pybind11_add_module):
Unknown CMake command "pybind11_add_module".
-- Configuring incomplete, errors occurred!
💀💀 Adding find_package(pybind11 REQUIRED)
If I add a line find_package(pybind11 REQUIRED) I get the following error:
CMake Error at CMakeLists.txt:16 (find_package):
By not providing "Findpybind11.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "pybind11",
but CMake did not find one.
💀💀💀 Adding include([...]/pybind11Tools.cmake)
If I add a line #include(${CONAN_PYBIND11_ROOT}/lib/cmake/pybind11/pybind11Tools.cmake) I get the following error:
CMake Error at /home/[...]/pybind11Tools.cmake:100 (set_property):
set_property could not find TARGET pybind11::pybind11. Perhaps it has not yet been created.
like in this issue https://github.com/pybind/pybind11/issues/3388. Maybe it is fixed in the new release?
💀💀💀💀 Upgrading to 2.8.1
The fresh pybind11 is 2.8.1, let's upgrade
pybind11/2.8.1: Not found in local cache, looking in remotes...
pybind11/2.8.1: Trying with 'conancenter'...
ERROR: Unable to find 'pybind11/2.8.1' in remotes
OK. One can read between the lines, that it used to work, so maybe let's downgrade?
💀💀💀💀💀 Downgrading to 2.4.3
If I require pybind/2.4.3 instead of pybind/2.7.1 in conanfile.txt I get
fatal error: Python.h: No such file or directory
112 | #include <Python.h>
| ^~~~~~~~~
like in this issue https://github.com/pybind/pybind11/issues/1781. Differently from that issue, installing python*-dev does not help. But whatever, I don't want to use old pybind anyway.
💀💀💀💀💀💀 Trying a conanfile from test package
The conancentral recipes contain a test package (https://github.com/conan-io/conan-center-index/tree/master/recipes/pybind11/all/test_package), which is tested automatically when the package is created. Let's try that instead!
CMake Error at CMakeLists.txt:13 (find_package):
By not providing "Findpybind11.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "pybind11",
but CMake did not find one.
Am I just hopeless???
Maybe, but! I can:
💪 Build the https://github.com/pybind/cmake_example
💪 Build the https://github.com/pybind/python_example
💪 Build the conancentral pybind11 recipe! The same that fails when I extract the test package to a separate folder. Whaaat?? 😱
I have used pybind in the past (two or three years ago) and it worked without problems with conan. However, I tried to install it now and faced similar problems. This might be related to the evolution of conan towards conan 2.0 (an alpha version was released today) and that the recipe was not updated to account changes.
An alternative that you might consider, is to install pybind with conan using a different generator. More specifically, the CMakeDeps generator. With the CMakeDeps generator conan will create a pybind11-config.cmake file for you and you just need to use find_package(pybind11 REQUIRED) in CMakeLists.txt. That is, there is no "conan specific stuff" in your CMakeLists.txt file.
conanfile.txt
[requires]
pybind11/2.7.1
[generators]
CMakeDeps
CMakeLists.txt
cmake_minimum_required(VERSION 3.21)
project(cobind11 VERSION 1.0 LANGUAGES CXX)
# Tell cmake to also search in the buld folder for the "<library>-config.cmake"
# files
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}")
find_package(pybind11 REQUIRED)
pybind11_add_module(cobind main.cpp)
main.cpp
#include <pybind11/pybind11.h>
int add(int i, int j) { return i + j; }
PYBIND11_MODULE(cobind, m) { m.def("add", &add); }
With this I was able to build the library and use it in Python.
Conan deeper integration with CMake
You can also use the CMakeToolchain generator in addition to the CMakeDeps generator. It generates a conan_toolchain.cmake file that you pass to the cmake command with --toolchain conan_toolchain.cmake. If you use it, there is no need to add the list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}") line to your CMakeLists.txt file. Furthermore, the settings you specify in conan, such as build type and compiler, will impact cmake. That is, you don't need to specify these things in both conan and cmake. This seems to be where conan is going, regarding cmake integration, in the comming 2.0 release.
Very new to make files here, so please forgive me if this is a noob question. I can't seem to find the answer on the internet.
I've forked a public repository from github, and it repository itself is supposed to be download, make and run, but I've already fixed a half dozen errors in their make files trying to get it running. Now I'm down to this one, which seems to be something to do with CMake not finding the right QT4 command.
When I'm in a build folder, the instructions (according to the owner of the repository) says to type "cmake .." - which is an obvious reference to CMakeList.txt in the parent folder. The file is hosted on Github, the line that throws the error is line 94, it says:
QT4_ADD_RESOURCES(OFFNAO_RES_SRCS ${OFFNAO_RES})
I am trying to build this program on Ubuntu 14.04.5 (because that's the OS it was originally built on, I can work on upgrading that after it is working).
The error text it spits out is:
CMake Error at CMakeLists.txt:94(QT$_ADD_RESOURCES):
Unknown CMake command "QT4_ADD_RESOURCES".
-- Configuring incomplete, errors occurred!
I have installed qt4-dev-tools (which also installs all qt4 libraries).
I can't seem to find how to get CMake to recognise QT4 and its commands.
I'm new to CMake and this is the first time I've come across QT4 so I don't know what I'm looking for. Happy to provide any more info if needed. All help is appreciated.
EDIT:
Here's the contents of the offnao CMakeList.txt:
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
PROJECT(OFFNAO)
INCLUDE_DIRECTORIES("${CMAKE_CURRENT_BINARY_DIR}")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${CTC_DIR}/libnaoqi/include)
INCLUDE_DIRECTORIES(${CTC_DIR}/zlib/include)
INCLUDE_DIRECTORIES(${CTC_DIR}/../sysroot_legacy/usr/include)
SET(OFFNAO_CXX_SRCS
utils/OverlayPainter.cpp
// contents skipped for brevity
tabs/teamBallTab.cpp
)
SET(OFFNAO_MOC
readers/reader.hpp
// contents skipped for brevity
tabs/teamBallTab.hpp
)
if(CMAKE_TOOLCHAIN_FILE)
list(APPEND OFFNAO_CXX_SRCS tabs/cameraTab.cpp)
list(APPEND OFFNAO_MOC tabs/cameraTab.hpp)
endif(CMAKE_TOOLCHAIN_FILE)
SET(OFFNAO_UI
visualiser.ui
ConnectionBar.ui
tabs/LogTab.ui
tabs/LogsTab.ui
)
SET(OFFNAO_RES
resources/visualiser_resources.qrc
)
# build cxx files for resources
QT4_ADD_RESOURCES(OFFNAO_RES_SRCS ${OFFNAO_RES})
# build ui_XXX files from the XML-style .ui files
QT4_WRAP_UI(OFFNAO_UI_SRCS ${OFFNAO_UI})
# this moc's the above variable and appends to the cxx sources
QT4_WRAP_CPP(OFFNAO_MOC_SRCS ${OFFNAO_MOC})
ADD_EXECUTABLE(offnao.bin ${OFFNAO_CXX_SRCS} ${OFFNAO_RES_SRCS} ${OFFNAO_MOC_SRCS} ${OFFNAO_UI_SRCS})
cotire(offnao.bin)
set_source_files_properties(
tabs/graphTab.cpp
tabs/plots.cpp
tabs/walkTab.cpp
tabs/zmpTab.cpp
main.cpp
visualiser.cpp
${OFFNAO_MOC_SRCS} #too lazy to split and list them
PROPERTIES COMPILE_FLAGS "-I${QWT_INCLUDE_DIR}")
find_library ( QGLVIEWER_LIBRARY NAMES QGLViewer qglviewer-qt4 )
find_package ( OpenGL REQUIRED )
find_package ( PNG REQUIRED )
TARGET_LINK_LIBRARIES(
offnao.bin
${QT_LIBRARIES}
${QWT_LIBRARY}
${QGLVIEWER_LIBRARY}
Furthermore, the README that states to build this is rather vague, it doesn't actually say what folder to run these commands from. It states:
Welcome to Off-Nao, the rUNSWift debugging toolsuite.
To build this project, either:
You get lucky and bin/build_setup.sh just works :D
(verified under Ubuntu 14.04.1 LTS both natively and in VMs;
but builds successfully then segfaults at runtime in libGL.so.1
under fresh download of 14.04.3 LTS # 15/9/2015
according to gdb - so much for Ubuntu being stable).
---OR---
You need Qt4 and probably a bunch of other things like QGLViewer to build it natively:
$ mkdir build
$ cd build
$ cmake ..
$ make
$ ./offnao
Once you have performed the steps above once, in future you only need to:
$ make
$ ./offnao
In the 'build' directory
I do get the segfault as mentioned in the README at LibGL.so.1 so I've attempted to follow the instruction below it. I can only get the the "cmake .." stage and that's where I get the error.
Reformulating my previous comment as answer:
To use macros QT4_ADD_RESOURCES, QT4_WRAP_UI, QT4_WRAP_CPP and others you need to call find_package(Qt4 REQUIRED) first in your CMakeLists.txt. See the documentation for the FindQt4.cmake module (https://cmake.org/cmake/help/v3.0/module/FindQt4.html).
How can you link GLEW to a project with CMake?
We've been trying to link GLEW to our project using CMake for at least 3 hours without any success so any help is accepted.
I'm using the FindGLEW.cmake which comes with CMake 3.1.0
CMakeLists.txt
find_package(GLEW REQUIRED)
if (GLEW_FOUND)
include_directories($(GLEW_INCLUDE_DIRS))
endif()
Environment Variables
I'm using MinGW w64 to compile the sources and we successfully linked GLFW and GLM just by copying the includes and libs to their respective folders, but after doing the same with GLEW, CMake still couldn't find it.
Sorry if I wasn't clear enough while formulating the question. I will provide any additional information required.
Edit: I've managed to link the header files by specifying their location in the CMake Cache file, though I'm getting undefined reference to glew functions like glewInit().
Typical CMake scripts like FindGLEW will define variables that specify the paths and files that your project needs. If the script can't automatically identify the correct paths (usually because of nonstandard install location, which is fine), then it leaves these variables up to you to fill in.
With command line CMake, you use the -D flag to define and set the value of a given variable. Other CMake interfaces, like CMake-gui or an IDE integration, give you this ability some other way.
However you do it, you can also modify the cache directly (CMakeCache.txt) and see what CMake is using in there or just clear the cache altogether. You'll have to rerun CMake for it to pick up your changes.
When it comes to linking, that's when you need to tell CMake which libs to link. Use the link_libraries command with what the automated script gives you.
find_package(GLEW REQUIRED)
include_directories(${GLEW_INCLUDE_DIRS})
link_libraries(${GLEW_LIBRARIES})
Other answers do obviously work, but the target based style of cmake makes it even easier since the GLEW find module defines the imported target GLEW::GLEW. All you need is:
find_package(GLEW REQUIRED)
target_link_libraries(YourTarget GLEW::GLEW)
YourTarget is the target that you created with add_executable or add_library. No need to explicitly add include directories, they are added automatically by linking the targets.
The secret of find_package(GLEW) is in FindGLEW.cmake file with cmake install.
find_path(GLEW_INCLUDE_DIR GL/glew.h)
find_library(GLEW_LIBRARY NAMES GLEW glew32 glew glew32s PATH_SUFFIXES lib64)
The find_path and find_library commands find paths in standard system paths. If you want them to find paths in user defined directories, you should tell them.
For example:
set(CMAKE_PREFIX_PATH "d:/libs/glew-1.10.0")
set(CMAKE_LIBRARY_PATH "d:/libs/glew-1.10.0/lib/Release/Win32/")
find_package(GLEW REQUIRED)
Reference:
http://www.cmake.org/cmake/help/v3.0/command/find_path.html
http://www.cmake.org/cmake/help/v3.0/command/find_library.html
I was struggling hard to link glew to cmake through command line on mac. This might be helpful but I am not sure :) I will walk you through step by step of what I have done.
I installed Cmake source from the web.
Then I went inside the cmake folder in terminal and typed
./bootstrap && make && make install
(this will install cmake command line tools on our OS platform)
I have some exercise files. I want cmake to generate xcode files for me for all those exercise files (ex. triangles.cpp, shader.cpp etc) So i made a directory inside exercise files folder.
$ mkdir xcode
$ cd xcode
$ cmake -G "Xcode" ..
At this point, Cmake suppose to install all xcode files that included correct libraries. But there was an error :
$ cmake -G "Xcode" ..
CMake Warning (dev) at CMakeLists.txt:3 (cmake_minimum_required):
Compatibility with CMake < 2.4 is not supported by CMake >= 3.0.
This warning is for project developers. Use -Wno-dev to suppress it.
system name is: Darwin-14.1.0
system processor is: x86_64
-- Could NOT find GLEW (missing: GLEW_INCLUDE_DIR GLEW_LIBRARY)
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- Using Cocoa for window creation
-- Using NSGL for context creation
-- Building GLFW only for the native architecture
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:
GLEW_LIBRARY
linked by target "TextureLoader" in directory /Users/Mydir/Desktop/Exercise/Exercise Files
-- Configuring incomplete, errors occurred!
Then to make sure I have installed GLEW and all its libraries correctly, I ran
$brew install glew
Yes, I have installed glew already but it was NOT linked. See the Warning below:
Warning: glew-1.12.0 already installed, it's just not linked
Then I ran the following commands:
$ brew unlink glew
$ brew link glew
And I have solved the error. So just make sure that you have linked glew. Hope this helps.
Happy Coding :)
Finally I found a simple and short CMakeLists which works if you have installed everything in default paths.(openGL, glfw and glew)
cmake_minimum_required(VERSION 3.3)
project(openGL_tutorial)
find_package(OpenGL REQUIRED)
if(NOT OPENGL_FOUND)
message("ERROR: OpenGL not found")
endif(NOT OPENGL_FOUND)
set(GL_LIBRARY GL GLU X11)
add_executable(openGL_tutorial main.cpp)
target_link_libraries(openGL_tutorial glfw GLEW libGLEW.so libGLU.so libGL.so)
For what it is worth, in 2023, this works for me, on macOS, with GLEW, GLFW, and CMake installed using Homebrew:
cmake_minimum_required(VERSION 3.10)
project(Project)
add_executable(Project main.cpp)
find_package(glfw3 REQUIRED)
find_package(GLEW REQUIRED)
target_link_libraries(Project glfw GLEW::glew)
I installed Ogre3D 1.8.1 (the source package) on Ubuntu 12.04 and everything went fine (I managed to run some samples on the Ogre interface). However, I hit a problem while I was compiling an external project (that one) that needed the OpenCV, ArUco and Ogre librarys. When I run the CMake of the project, I receive the following:
CMake Error at CMakeLists.txt:46 (find_package):
By not providing "FindOGRE.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OGRE", but
CMake did not find one.
Could not find a package configuration file provided by "OGRE" with any of
the following names:
OGREConfig.cmake
ogre-config.cmake
Add the installation prefix of "OGRE" to CMAKE_PREFIX_PATH or set
"OGRE_DIR" to a directory containing one of the above files. If "OGRE"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
I know where the FindOGRE.cmake is, it's in the /usr/local/lib/OGRE/cmake, but I don't know how to say to CMake to look for that folder and fix this problem.
You just need to use the -D command line option along with the CMAKE_MODULE_PATH variable:
cmake . -DCMAKE_MODULE_PATH=/usr/local/lib/OGRE/cmake
Just for the record, an alternative solution would be to add the module path directly in the CMakeLists.txt. For example (tested on Debian 9):
set(CMAKE_MODULE_PATH "/usr/share/OGRE/cmake/modules/;${CMAKE_MODULE_PATH}")
Just make sure to add the line before find_package is called.
For me, it only works to set the following in CMakeLists.txt before find_package:
set(OGRE_DIR /usr/share/OGRE/build/sdk/CMake)
Note that the CMake directory is the one containing OGREConfig.cmake. For some reason, my CMake ignores CMAKE_MODULE_PATH.
Maybe, of some help for someone
For me, this solution work on manjaro:
set(CMAKE_MODULE_PATH "/usr/lib/OGRE/cmake;${CMAKE_MODULE_PATH}")
find_package(OGRE QUIET)
if (OGRE_FOUND)
include_directories( ${ogre_INCLUDE_DIR})
link_directories(${OGRE_LIBRARIES})
message(STATUS "OGRE: FOUND")
else()
message(STATUS "OGRE: NOT FOUND")
endif()