Multiple Cmake_Prefix_Paths

To provide multiple paths in the CMAKE_PREFIX_PATH variable you need to delimit each entry by ;(semicolon). So your command will look like: cmake -DCMAKE_PREFIX_PATH=”C:\Qt\5.5\msvc2013\lib\cmake;C:\protobuf\src;C:\protobuf\c‌​make\build\Release” To check if everything alright with the provided paths you can use the following code in the cmake file: foreach(path ${CMAKE_PREFIX_PATH}) message(“Path: ” ${path}) endforeach(path) It will print every path provided.

CMake command line for C++ #define

I managed to do it this way now: I was able to convince everybody to add the following lines to the common CMakeLists.txt: IF (NOT DEFINED _MYDEFINE) SET(_MYDEFINE <default value>) ENDIF() ADD_DEFINITIONS(-D_MYDEFINE=${_MYDEFINE}) (No it is not really called “MYDEFINE”, and <default value> is just a placeholder, I just replaced all that for this example) This … Read more

Mixing C and assembly sources and build with cmake

CMake supports assembler out of the box. Just be sure to enable the “ASM” language in your project. If an assembler source file needs preprocessing, also set the source file’s compilation options: project(assembler C ASM) set_property(SOURCE foo.s APPEND PROPERTY COMPILE_OPTIONS “-x” “assembler-with-cpp”) add_executable(hello foo.s bar.c)

What does “Performing Test CMAKE_HAVE_LIBC_PTHREAD” failed actually mean?

The lines — Looking for pthread.h — Looking for pthread.h – found — Performing Test CMAKE_HAVE_LIBC_PTHREAD — Performing Test CMAKE_HAVE_LIBC_PTHREAD – Failed — Looking for pthread_create in pthreads — Looking for pthread_create in pthreads – not found — Looking for pthread_create in pthread — Looking for pthread_create in pthread – found are output of a … Read more

CMake one build directory for multiple projects

First of all, it doesn’t look like the CMake code you posted belongs to the top CMakeList.txt file, since it directly references .cpp files, and “projectA”. There are also a few things that are not idiomatic: cmake_minimum_required(VERSION 3.2.2.) why the trailing dot here ? Not sure whether cmake will complain, but it is useless either … Read more

How to test if CMake found a library with find_library

You can simply test the variable as such, e.g.: find_library(LUA_LIB lua) if(NOT LUA_LIB) message(FATAL_ERROR “lua library not found”) endif() Example output: CMake Error at CMakeLists.txt:99 (message): lua library not found — Configuring incomplete, errors occurred! Note that we use if(NOT LUA_LIB) and not if(NOT ${LUA_LIB}) because of the different semantics. With ${}, the variable LUA_LIB … Read more

In CMake, how do I work around the Debug and Release directories Visual Studio 2010 tries to add?

It depends a bit on what you want precisely, but I would recommend to take a look at the available target properties, similar to this question. It depends a bit on what you want exactly. For each target, you could manually set the library_output_directory or runtime_output_directory properties. if ( MSVC ) set_target_properties( ${targetname} PROPERTIES LIBRARY_OUTPUT_DIRECTORY … Read more