I have a Love-Hate relationship with CMake. That is, I love to hate CMake... because it may literally be the worst language ever invented and certainly the worst I've ever used. It is opaque, does tons of magic things that are incomprehensible, and does them in a super inefficient way! I think I literally despise the tool. After using it fairly regularly for over a year I have neither acclimated to the tool or have warmed up to it in any way. Every time I want to do the simplest thing with CMake it can take me and my fellow developers hours to solve it effectively (and by effectively that is to say hack something in and hope that it works). I think it has also cost my company literally years of man-hours to migrate over to it as our primary build system. Worse still, due to the complexity and pain of migrating to it, I think those who made the decision to do so would never admit that it is terrible and will never want to move to something else that would be sane like... I don't know a bash script would be better. I feel like they, and everyone else, are just following the trendy herd.
The thing with CMake is that I NEVER feel like I am doing something other than hackery that isn't going to blow up in my face at any minute. To put this in perspective, C++ Template Meta Programming is more comprehensible.
As evidence to how terrible it is I just visited the FAQ Page to find a nugget on how to accomplish an uninstall target in a make file. I've pasted that entire bit below (all credit and copyrights goes back to Kitware for the below). So what takes an incomprehensible bit of CMake (yeah good luck writing that from scratch...) they casually mention could also be done in one super simple and easy to understand xargs statement in shell. It's no wonder I prefer nothing but Make and Bash.
Can I do "make uninstall" with CMake?
By default, CMake does not provide the "make uninstall" target, so you cannot do this. We do not want "make uninstall" to remove useful files from the system.
If you want an "uninstall" target in your project, then nobody prevents you from providing one. You need to delete the files listed in install_manifest.txt file. Here is how to do it. First create file cmake_uninstall.cmake.in in the top-level directory of the project:
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)
Then in the top-level CMakeLists.txt add the following logic:
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
Now you will have an "uninstall" target at the top-level directory of your build tree.
Instead of creating an "uninstall" target, Unix users could enter this command in the shell:
xargs rm < install_manifest.txt
No comments:
Post a Comment