Uninstall targets in CMake would be useful. I'm developing on Linux. During debugging of a development branch, it's useful to install to system directories, then test whether things work when installed, so that I'm not relying on any build directory specific path weirdness. Doing this multiple times, it's useful to get rid of any stale install components that accumulate. This may become more of an issue now that David Rogers (MasterFalcon) has generously added a shared library versioning scheme to allow multiple simultaneous Ogre installations.
Example: when testing the GL3PLUS renderer, I almost tripped myself over a stale SampleBrowser_d in my /usr/local/bin. I recently erased my hg repository, did a clean clone of it, then fumbled with default vs. v1-9 branch for a bit. Got it built, probably forgot to configure the Debug option, so I installed SampleBrowser etc. instead of *_d files. I was in the habit of typing SampleBrowser_d for the past few weeks. ldd showed it was linked against libOgreMain_d.so.2.1.0, whereas my newly built SampleBrowser was linked against libOgreMain.so.1.9.0.
I suppose that means an uninstall should be smart about not clobbering Ogre versions it doesn't own. Er, maybe this implies that installed apps would benefit from versioning as well. It is unfortunate that they all use the same /usr/local/bin installation target by default. I suppose on Linux a ldd and a regex could be used to extract the version info, don't know about Windows or Mac. Trying to figure out how to head off DLL Hell at the pass.
CMake uninstall targets and versioning
-
bvanevery
- Goblin
- Posts: 218
- Joined: Wed Feb 28, 2007 4:54 am
- Location: Asheville, NC
- x 7
-
Syniurge
- Halfling
- Posts: 40
- Joined: Thu Aug 30, 2012 1:43 pm
- Location: France
- x 3
Re: CMake uninstall targets and versioning
With Cmake "make install" records every file it installs into install_manifest.txt, so to uninstall before rebuilding Ogre you just need to enter:
Code: Select all
cat install_manifest.txt|while read f; do rm "$f"; done-
bvanevery
- Goblin
- Posts: 218
- Joined: Wed Feb 28, 2007 4:54 am
- Location: Asheville, NC
- x 7
Re: CMake uninstall targets and versioning
Thanks for the tip if I have a specific directory cleaning problem that I want to perform manually. I still think it would be beneficial to users to have a canonical, automatic "make uninstall" target.
-
jacmoe
- OGRE Retired Moderator

- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
Re: CMake uninstall targets and versioning
We have 'uninstall' for Ogitor.
In the main CMakeLists.txt:
cmake_uninstall.cmake.in:
It seems to work great. 
In the main CMakeLists.txt:
Code: Select all
# 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)
Code: Select all
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}")
list(REVERSE files)
foreach (file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
if (EXISTS "$ENV{DESTDIR}${file}")
execute_process(
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
if(NOT ${rm_retval} EQUAL 0)
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
endif (NOT ${rm_retval} EQUAL 0)
else (EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
endif (EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.