Questions tagged [cmake-format]

A program to format CMake's CMakeLists.txt files, similar in spirit to clang-format

cmake-format is a program to format CMake files (CMakeLists.txt as well as *.cmake files.)

It is similar to [[clang-format]], which does the same on C++ files (other languages also supported).

https://github.com/cheshirekow/cmake_format

19 questions
21
votes
4 answers

Is there any utility that can reformat a cmake file

I have relatively complex cmake files and I am wondering if there is any utility that can reformat a cmakeList.txt and beautify it for easier reading? Some simple tricks would do the jobs, such as indenting if else endif sections and so on. Is there…
mans
  • 17,104
  • 45
  • 172
  • 321
11
votes
2 answers

Formatting CMakeLists.txt with Clang-Format

Is there a way to get clang-format to correctly format a CMake file? I have a .clang-format file with Language: Cpp and BasedOnStyle: Google. No other language is specified. Ideally, I would like to customize the style, however the biggest problem…
Unapiedra
  • 15,037
  • 12
  • 64
  • 93
2
votes
0 answers

CMake: remove a compile flag from CMAKE_C_FLAGS_RELEASE only for a specific target

I have set(CMAKE_CXX_FLAGS_RELEASE "-O3 -m64 -march=native -flto") but I'd like to remove -flto for a specific target compilation: file(GLOB TST_SOURCES "${CMAKE_SOURCE_DIR}/x64_test/*.cpp") add_executable(_x64_test…
GinoC
  • 442
  • 4
  • 16
2
votes
1 answer

Cannot generate 32 bit configuration for Visual Studio 2019 with host=x86 or -A Win32

I am trying to configure cmake to build for 32bit and 64bit separately... So far 64bit is easy as I just need to add -A x64 cmake -G "Visual Studio 16 2019" -A x64 But I am not able to set 32bit arch. Official documentation suggest -A Win32 or…
AtiqGauri
  • 1,483
  • 13
  • 26
1
vote
1 answer

Setting environment variables to ExternalProject_Add context

I have a CMakeLists.txt file in which there are multiple external projects I need to build. I am using the ExternalProject_Add feature of CMake. I need to set an environment variable in one of the ExternalProject_Add project modules. The project…
Subbu
  • 839
  • 2
  • 12
  • 34
1
vote
1 answer

CMake error "include could not find load file: FetchContent"

I am getting the following error while executing the cmake command on Ubuntu. CMake version - 3.10.2. mapp@ubuntu:~/Desktop/LocatePro$ cmake . -- Enable testing: ON CMake Error at CMakeLists.txt:40 (include): include could not find load file: …
mapppppp
  • 25
  • 1
  • 6
0
votes
1 answer

Keep multiple space-aligned `set(VARIABLE value)` the way they were during cmake-format

We have a lot of CMake files that contain set()-sequences like set(VERSION_MAJOR 1) set(VERSION_MINOR 2) set(VERSION_ABI 3) set(VERSION_PATCH 0-rc2) I can't find a for cmake-format to keep things aligned like that; it will always condense the…
Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
0
votes
3 answers

Cmake string to get key value pairs from a string list containing key values separated by colon

I have a stringlist (input): set(MY_LIST "A:1;B:2;C:3") I want to fetch the key values using foreach and set them as cmake constants. Something like: foreach(ITEM ${MY_LIST}) SET( ) endforeach() So basically i want the end…
deb
  • 15
  • 7
0
votes
0 answers

Printing Interface library in cmake

How to print the interface library in cmake. Actually i want to do this for a debugging purpose. so want to know how to print what are all the include directories in that interface library I have a interface library A which is linked to 2 interface…
0
votes
2 answers

How to create cmake library that expects an external header file

I feel like I'm missing some key idea with this one. I have a library that I'd like to create a CMakeLists.txt file for. I want to link against it with different applications. This library expects a conf.h file to be defined. The application has to…
triplebig
  • 422
  • 1
  • 7
  • 20
0
votes
1 answer

How to add_dependencies between projects in cmake

include_directories(${CMAKE_CURRENT_SOURCE_DIR}) AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} source) project(abc) #a_certain_source_file.cpp is a generated file built by another project. add_library(${PROJECT_NAME} STATIC ${source}…
badri
  • 575
  • 2
  • 8
  • 22
0
votes
1 answer

how cmake Error in compiling for riscv64-unknown-elf-g++

The error looks like the below when I cmake .. from the terminal: (base) k:~ cd /Users/yuli/Documents/version3/cpp/ (base) k:~ ls CMakeLists.txt src riscv-gnu-toolchain test (base) k:~ mkdir build (base) k:~ cd build (base) k:~ cmake .. -- The…
Yulia
  • 31
  • 8
0
votes
0 answers

How can I avoid rebuilding 15GB-8hr long PCL library every time I move to a new identical HW?

I am using Jetson TX2 boards for my work with PCL and GPU. Since, GPU sub-systems are not available on any apt-repos, I am told to build them from source every time I move to a new system. Since all HW is identical,how can I just copy the same PCL…
0
votes
0 answers

Compiling a 32-bit C++ program in CLion on MacOS

I having trouble with my CMake file in CLion running on Mac OSX 10.14. Currently, I have the following for a 32-bit program I copied from a Linux server using a built "supplied.o" file from an instructor. I wanted to work in CLion and wondering if…
devonf
  • 1
0
votes
1 answer

linking librarys as a part of flags in toolchain file in cmake

i've tried to add PROFILE to the CMAKE_BUILD_TYPES. For this I need to add -finstrument-functionsto the CMAKE_CXX_FLAGS in the toolchain file and link the belonging library with the absolut path in the CMakeLists.txt via target_link_libraries. So…
1
2