0
在我只有頭庫我有以下CMakeLists.txt
文件:如何爲僅標題庫創建缺少`乾淨`目標?
cmake_minimum_required(VERSION 2.8.11)
project(Math)
set(PROJECT_VERSION 0.1)
# Install prefix
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX /usr/local)
endif()
message("++ Installation prefix set to \"${CMAKE_INSTALL_PREFIX}\"")
configure_file("${CMAKE_SOURCE_DIR}/pkg-config.pc.cmake"
"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc")
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_PREFIX}/include/Math")
install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/pkgconfig/")
它正常工作,但現在看來,當我說make clean
(我希望是一個空操作,但對於這make
應返回0),我得到
make[1]: *** No rule to make target `clean'. Stop.
make: *** [clean] Error 2
我看到有確實在build目錄存在clean
目標Makefile
,但它要求一個clean
目標CMakeFiles/Makefile2
,它不存在。
我發現,如果我添加以下CMakeLists.txt
目標是創建:
add_custom_target(clean)
但後來我得到任何make
調用一些討厭的警告:
Makefile:150: warning: overriding commands for target `clean'
Makefile:123: warning: ignoring old commands for target `clean'
即由於某種原因,Makefile
獲得了兩個clean
目標實例。
我該如何創建一個無操作的目標clean
乾淨,沒有得到任何警告?