Questions tagged [cmake]

CMake is a cross-platform, open-source build system generator. It generates files for build systems like native makefiles, ninja-build and project files for several integrated development environments.

CMake is a cross-platform, open-source build system generator. It generates files for build systems like native makefiles, ninja-build and project files for several integrated development environments.

It is often used along with , and .

Official

Quick Start / Howtos

Wisdom of the Stack

Books

27471 questions
10
votes
1 answer

How to set a number of parallel jobs for make in Cmake QtCreator project?

My project is managed by CMake and I use QtCreator as a main IDE. I want to make QtCreator run make -j number_here command when it launches a build task to speed it up, but I am unable to find a corresponding configuration in QtCreator's project…
CorellianAle
  • 645
  • 8
  • 16
10
votes
1 answer

How do I make CMake run a python script before building, in order to generate files for my project to be used in the build?

I have a python script that parses all of the C++ source files in the project's directory, looks for some stuff in the files, and then generates a file. This python script works fine, but I want it to automatically run before building my C++…
irfna
  • 525
  • 1
  • 4
  • 13
10
votes
4 answers

nvcc fatal : Unsupported gpu architecture 'compute_20' while cuda 9.1+caffe+openCV 3.4.0 is installed

I have installed CUDA 9.1+cudnn-9.1+opencv 3.4.0+caffe. When I tried to run make all -j8 in caffe directory, this error occurred: nvcc fatal : Unsupported gpu architecture 'compute_20' I have tried to run: "cmake -D CMAKE_BUILD_TYPE=RELEASE -D…
Lawrence_Liu
  • 127
  • 1
  • 1
  • 6
10
votes
3 answers

How do I set CUDA architecture to compute_50 and sm_50 from cmake (3.10 version)?

My project uses CMake-GUI with visual studio. There is no gpu card installed on my system. The visual studio solution generated sets the nvcc flags to compute_30 and sm_30 but I need to set it to compute_50 and sm_50. I use CMake 3.10.1 and Visual…
C0D3R
  • 339
  • 1
  • 3
  • 12
10
votes
1 answer

undefined reference to `pthread_getspecific' when using cmake for googletest

I am following this book. I have a GoogleTest installation and I built the libraries: kuyu@ub16:~/Downloads/googletest-master$ find . -name…
hermit.crab
  • 852
  • 1
  • 8
  • 20
10
votes
2 answers

CMake: multiple targets use the same source file

add_library(target1 funtion.c target1.c ) add_library(target2 funtion.c target2.c ) add_executable(main.out main.c) target_link_libraries(main.out target1 target2 ${LDFLAGS}) Here is my CMakeLists.txt above. Both targets need to use the source…
Samuel
  • 803
  • 8
  • 17
10
votes
3 answers

CMake shared project subdirectories avoid rebuilding

For a project, I am using Android gradle scripts with CMake, gradle plugin is version 3:0:0, CMake version 3.6. Both gradle and CMake files are pretty simple and uninteresting (just defining the files used - I can still copy-paste them as…
Gerasimos R
  • 2,056
  • 1
  • 12
  • 22
10
votes
1 answer

fail to use Q_OBJECT Macro in CMake Project

I am having trouble with the meta Object Compiler of Qt in my CMake Project. A shared lib I am building contains the following code and employs the pimpl idiom. After invoking CMake and upon compilation I get AUTOGEN: error:…
CD86
  • 979
  • 10
  • 27
10
votes
1 answer

Very long linking time with -g and without -DNDEBUG options

I'm building a third-party CMake-based C++ project. Building the project in release mode only takes a couple of seconds. The linking stage takes less than a second (when make prints Linking CXX executable myproject.exe). Building in debug mode takes…
Jawap
  • 2,463
  • 3
  • 28
  • 46
10
votes
3 answers

Can I use a Release config of OpenCV with Debug config of my app?

I am writing a Universal Windows application that uses OpenCV to do camera calibration and tag detection, among other things. I'd like to be able to use release mode, fully-optimized OpenCV DLLs while my own is in debug mode. Is this possible? If…
Evan Lang
  • 101
  • 1
  • 4
10
votes
1 answer

How to static linking to glibc in cmake

I'm trying to build a package from Fedora that can run on a RedHat 6 machine. So I need to build and static linking with some library that does not exist in RedHat machine. I found that I can you -static-libgcc or -static-libstdc++ to link with…
Phạm Văn Thông
  • 743
  • 2
  • 7
  • 21
10
votes
1 answer

Using cmake options in generator expressions

I would like to use a cmake option inside a generator expression in order to turn on a certain compile flag. From the documentation it is not clear to me how to achieve this. I would like to write something like option(MYOPTION " ... "…
Wentzell
  • 183
  • 1
  • 8
10
votes
2 answers

Creating a cmake project with visual studio

Visual Studio 2017 provides built-in support for handling CMake projects. The documentation mostly covers scenarios based on pre-existing cmake projects. But is there any support for creating a cmake project without having to fiddle with the…
Oblomov
  • 8,953
  • 22
  • 60
  • 106
10
votes
2 answers

Where are include and libs when using a Python virtual environment?

I use a Python virtual environment. Basically, it works fine, but I run into problems when compiling some Python bindings, namely with libIGL and pybind11. CMake has the following Python-related variables: PYTHON_EXECUTABLE …
Michael
  • 7,407
  • 8
  • 41
  • 84
10
votes
2 answers

Can parameter DESTINATION for INSTALL be empty?

In general, relative parameters of type PATH, like "lib" or "source/include" are resolved in CMake to an absolute path using current value of variables, like for instance: ${CMAKE_INSTALL_PREFIX} in case of command INSTALL. This, however, does not…
Piotr G
  • 959
  • 1
  • 7
  • 25