English 中文(简体)
为CMake中的一个子公司设定一个清洁目标
原标题:Generating a clean target for a subdirectory in CMake
  • 时间:2011-11-15 07:02:45
  •  标签:
  • cmake

我想提出一个子标题的clean目标。

我的项目结构就是这样:

app/
  A
  B

lib/
   A
   B
   C

有时,我只想提一下,不希望清理图书馆。

是否有可能告诉CMake为每个名录设定一个clean的目标?

Or a custom target like app-clean which will call clean on each application sub-directory?

最佳回答

您仅可打到{CMAKE_BINaire_DIR}/app/A,并在那里操作make Clean

Of course, you can add_custom_target(app-A-clean ...) which would do this for you.

macro(add_clean_target dir)
add_custom_target(clean-${dir} COMMAND ${CMAKE_MAKE_PROGRAM} clean WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${dir})
endmacro(add_clean_target)

现在你可以这样使用:

add_clean_target(app-A)
问题回答




相关问题
Why can t CLion see header files, WSL2 toolchain?

My setup: Windows 10 Pro 22H2 (19045.2965) CLion 2020.1.3 (JetBrains) WSL2 with Ubuntu 22.04.2 LTS gcc 11.3.0 cmake 3.22.1 gdb 12.1 gmake 4.3 CMakeLists.txt cmake_minimum_required(VERSION 3.22)...

CMake linking problem

I am trying to use CMake to compile a C++ application that uses the C library GStreamer. My main.cpp file looks like this: extern "C" { #include <gst/gst.h> #include <glib.h> } int main(...

How to add an extra plist property using CMake?

I m trying to add the item <key>UIStatusBarHidden</key><true/> to my plist that s auto-generated by CMake. For certain keys, it appears there are pre-defined ways to add an item; ...

(c)make - resursive compile

Let s assume I have directories like: dir1 main.cpp dir2 abc.cpp dir3 def.cpp dir4 ghi.cpp jkl.cpp And let s assume that main.cpp ...

Reading registry values with cmake

On a Windows 7 machine I cannot read any registry values that contain a semicolon. For example if you have 7-zip, running the following SET(MYPATH [HKEY_LOCAL_MACHINE\SOFTWARE\7-Zip;Path]) ...

Finding the correct Python framework with cmake

I am using the macports version of python on a Snow Leopard computer, and using cmake to build a cross-platform extension to it. I search for the python interpreter and libraries on the system using ...

热门标签