Error in CMake path - cmake

I'm trying to build the Visual Studio project for a kinect demo thing, rgbddemo. According to the instructions on the page, I need to set the PATH variable to include QMAKE from QT. I did that, but I keep getting this error:
CMake Error at CMakeLists.txt:1 (QT4_WRAP_CPP):
Unknown CMake command "QT4_WRAP_CPP".
From what I could gather from google, it's a problem with CMake knowing where something from QT is. The page I linked above also mentions that you can set the path for QMAKE within CMake, but I don't know how to do that. Does anyone have any suggestions? Thanks.

You could try inserting the line
FIND_PACKAGE(Qt4)
into the top-level CMakeLists.txt file after the line
INCLUDE("${nestk_BINARY_DIR}/UseNestk.cmake")
That should cause it to try to find qmake for you. I'm not sure why they don't have that though, but then I'm not that familiar with cmake.

I think this lines in your CMakeLists.txt file can help you.
find_package(Qt4 Required)
include(${QT_USE_FILE}) #contains path to Qt header
#...
qt4_wrap_cpp(MOC_SOURCES ${MY_HEADERS}) #invoking moc
add_library(MY_LIB ${SOURCES} ${MOC_SOURCES}) #building lib
target_link_libraries(MY_LIB ${QT_LIBRARIES})
qt4_add_resources(MY_QT_RSC ${RESOURCES}) #if you want to compile from resource files
add_library(MY_LIB_2 ${MY_QT_RSC} {SOURCES})

Related

Build gtest as shared library (dll) in CMake

I have never worked with CMake before, so please forgive any rookie mistakes. Most of the following working frame has been given to me by my project group.
The goal is to build GoogleTest into a .dll, to be used in different, indepentent parts of our project. I'm having troubles setting up CMake the right way.
The work-flow so far has been:
Clone gtest from git --> also downloads a CMake List file
Alter variables in CMakeCache.txt to have it produce a Code::Blocks project file
Compile the project file in Code::Blocks
So far, it produces a static library (.a files) that can be used in our project. I'm having troubles genereating .dll files.
Variables I have tried changing:
BUILD_SHARED_LIBS:BOOL=ON --> the files generated by Code::Blocks now have a .dll.a double extension
CMAKE_C_FLAGS and all the corresponding C++ flags where set to -DGTEST_CREATE_SHARED_LIBRARY=1 as given here
CMAKE_EXE_LINKER_FLAGS has been set to -shared to make the linker produce .dll files
I have worked my way through the GoogleTest documentation here and here but in both, building it into a .dll is merely a 2-sentence-topic.
As #Tsyvarev pointed out, the .dll files were created in a (very) different folder.

CMake include precompiled library

I'm trying to get compiled project under QTCreator with CMake under Windows, I'm wonder how to add external library and its headers to my project. I have my CMakeList.txt as follows
cmake_minimum_required(VERSION 2.8)
project(opencl_info)
add_executable(${PROJECT_NAME} "main.cpp")
include_directories(c:\\AMD APP SDK\\3.0\\include\\)
target_link_libraries(opencl_info c:\\AMD APP SDK\\3.0\\lib\\x86_64\\OpenCL.lib)
I'm getting "CL\cl.h - No such file or directory" how to include it? for now with "hardlink"?
Thank you.
Under VS15 I'm running this project and it requires to have:
"Additional Include Directories" c:\AMD APP SDK\3.0\include\
"Additional Library Directories" c:\AMD APP SDK\3.0\lib\x86_64\
"Additional Depandancies" OpenCL.lib and th eproject runs.
I need to have OpenCL.dll within my path.
So I'm looking for the same/similar behaviour for QTCreator/CMake to include headers and libraries (.lib,.dll) for my project.
Thank you.
I have more opencl platfroms (nVidia, AMD) present on my machine, per using FIND_PACKAGE(OpenCL REQUIRED) its nVidia identified instead Found OpenCL: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64/OpenCL.lib (found version "1.2")
How to tell CMake explicitly to find and use AMD?
In CMake spaces are separators. If you want to use string with spaces, enclose it in double quotes:
"c:\\AMD APP SDK\\3.0\\include\\"
Partial success, I moved AMD APP SDK to another directory named as c:\opencl\
which is shorten with no space in path directory
I included direcotries include_directories(c:\\opencl\\include\\) and now an issue of missing "CL\cl.h - No such file or directory" is gone.
I found solution :)
cmake_minimum_required(VERSION 2.8)
project(opencl_info)
include_directories("c:\\AMD APP SDK\\3.0\\include\\")
link_directories("c:\\AMD APP SDK\\3.0\\lib\\x86_64\\")
add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(opencl_info OpenCL.lib)
Thanks for help, guys!!!

Nested CmakeLists.txt seems to forget qt4 package

I've got a new project to work on and it's being built by cmake. I'm sort of familiar with the system but not really a user that knows what's really going on. The project works with qt4 and in a subdirectory of the root it uses the command "qt4_wrap_cpp(...)". The problem is that cmake throws an error : Unknown Cmake command "qt4_wrap_cpp". The CMakeLists.txt in the top-level folder has the line "find_package(qt4)" in it and all i've seen this far suggested adding that line.
Does anyone have an idea what i could do next to tell cmake i've already added qt4 ?
EDIT: Structure example
root //here lies the top-level cmakelists
->find_package(qt4 required)
->add_subdirectory(sub)
sub:
->add_subdirectory(another_sub)
another_sub:
->qt4_wrap_cpp()

Error with Ogre and CMake

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()

llvm's cmake integration

I'm currently building a compiler/interpreter in C/C++.
When I noticed LLVM I thought it would fit greatly to what I needed and so I'm trying to integrate LLVM in my existing build system (I use CMake).
I read this bout integration of LLVM in CMake. I copy and pasted the example CMakeLists.txt, changed the LLVM_ROOT to ~/.llvm/ (that's where I downloaded and build LLVM and clang) and it says it isn't a valid LLVM-install. Best result I could achieve was the error message "Can't find LLVMConfig" by changing LLVM_ROOT to ~/.llvm/llvm.
My ~/.llvm/ folder looks like this:
~/.llvm/llvm # this folder contains source files
~/.llvm/build # this folder contains object, executable and library files
I downloaded LLVM and clang via SVN. I did not build it with CMake.
Is it just me or is something wrong with the CMakeLists.txt?
This CMake documentation page got rotted, but setting up CMake for LLVM developing isn't different from any other project. If your headers/libs are installed into non-standard prefix, there is no way for CMake to guess it.
You need to set CMAKE_PREFIX_PATH to the LLVM installation prefix or CMAKE_MODULE_PATH to prefix/share/llvm/cmake to make it work.
And yes, use the second code snippet from documentation (under Alternativaly, you can utilize CMake’s find_package functionality. line).