What use is find_package() when you need to specify CMAKE_MODULE_PATH?

I’m trying to get a cross-plattform build system working using CMake. Now the software has a few dependencies. I compiled them myself and installed them on my system. Some example files which got installed: — Installing: /usr/local/share/SomeLib/SomeDir/somefile — Installing: /usr/local/share/SomeLib/SomeDir/someotherfile — Installing: /usr/local/lib/SomeLib/somesharedlibrary — Installing: /usr/local/lib/SomeLib/cmake/FindSomeLib.cmake — Installing: /usr/local/lib/SomeLib/cmake/HelperFile.cmake Now CMake has a find_package() which … Read more

How exactly does CMake work?

I’m not asking this for just myself. I hope this question will be a reference for the many newbies who like me, found it utterly perplexing about what exactly what was going on behind the scenes when for such a small CMakeLists.txt file cmake_minimum_required (VERSION 2.6) project(Tutorial) add_executable(Tutorial tutorial.cpp) and such a small tutorial.cpp int … Read more

CMake: Print out all accessible variables in a script

I’m wondering if there is a way to print out all accessible variables in CMake. I’m not interested in the CMake variables – as in the –help-variables option. I’m talking about my variables that I defined, or the variables defined by included scripts. I’m currently including: INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake) And I was hoping that I could … Read more

Switching between GCC and Clang/LLVM using CMake

I have a number of projects built using CMake and I’d like to be able to easily switch between using GCC or Clang/LLVM to compile them. I believe (please correct me if I’m mistaken!) that to use Clang I need to set the following: SET (CMAKE_C_COMPILER “/usr/bin/clang”) SET (CMAKE_C_FLAGS “-Wall -std=c99”) SET (CMAKE_C_FLAGS_DEBUG “-g”) SET … Read more

Looking for a ‘cmake clean’ command to clear up CMake output

Just as make clean deletes all the files that a makefile has produced, I would like to do the same with CMake. All too often I find myself manually going through directories removing files like cmake_install.cmake and CMakeCache.txt, and the CMakeFiles folders. Is there a command like cmake clean to remove all these files automatically? … Read more