Back to the Vavoom Forum Archives


Forum

[Implemented] Pass custom DATADIR and BINDIR to CMake

Thu, 31 Jan 2008 23:31:00

scen

After the switch to Cmake, i've played around a little with it, and i've updated accordingly the SVN live ebuild for Gentoo Linux (see relevant discussion). I suggest to improve the CMake configuration files (CMakeLists.txt) to allow the installation of datafiles and binary executables into custom path, passing a DATADIR and/or a BINDIR variable to Cmake, like this:
cmake -DDATADIR=/path/to/data -DBINDIR=/path/to/bin .
Here a little patch to introduce this feature:
--- CMakeLists.txt	2008-01-31 22:32:53.000000000 +0100
+++ CMakeLists.txt	2008-01-31 22:45:47.000000000 +0100
@@ -16,7 +16,13 @@
 	add_definitions(-DHAVE_INTTYPES_H=1)
 endif(INTTYPES_INCLUDE_DIR)

-set(DATADIR share/vavoom)
+IF(NOT DEFINED DATADIR)
+	set(DATADIR share/vavoom)
+ENDIF(NOT DEFINED DATADIR)
+
+IF(NOT DEFINED BINDIR)
+	set(BINDIR bin)
+ENDIF(NOT DEFINED BINDIR)

 add_subdirectory(utils)
 add_subdirectory(source)
--- source/CMakeLists.txt	2008-01-31 22:34:28.000000000 +0100
+++ source/CMakeLists.txt	2008-02-01 00:20:31.000000000 +0100
@@ -855,7 +855,7 @@
 target_link_libraries(vavoom ${MAIN_LIBS})
 add_dependencies(vavoom timidity glbsp libglvis)

-install(TARGETS vavoom DESTINATION bin)
+install(TARGETS vavoom DESTINATION ${BINDIR})

 install(FILES vavoom.png DESTINATION ${DATADIR})

@@ -865,10 +865,11 @@
 # Needed to make symlinks/shortcuts work.
 # the binaries must run with correct working directory
 cd \"${CMAKE_INSTALL_PREFIX}/${DATADIR}\"
-\"${CMAKE_INSTALL_PREFIX}/bin/vavoom.i686\" $* ${IWADDIR}
+\"${CMAKE_INSTALL_PREFIX}/${BINDIR}/vavoom.i686\" $* ${IWADDIR}
 exit $?
 ")
-	install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/vavoom DESTINATION bin)
+	install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/vavoom DESTINATION
+	${BINDIR})
 endif(UNIX)

 endif(ENABLE_CLIENT)
@@ -897,7 +898,7 @@
 target_link_libraries(vavoom-dedicated glbsp ${ZLIB_LIBRARY} ${NET_LIBRARIES})
 add_dependencies(vavoom-dedicated glbsp)

-install(TARGETS vavoom-dedicated DESTINATION bin)
+install(TARGETS vavoom-dedicated DESTINATION ${BINDIR})

 if(UNIX)
 	file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/vavoom-dedicated
@@ -905,10 +906,11 @@
 # Needed to make symlinks/shortcuts work.
 # the binaries must run with correct working directory
 cd \"${CMAKE_INSTALL_PREFIX}/${DATADIR}\"
-\"${CMAKE_INSTALL_PREFIX}/bin/vavoom-dedicated.i686\" $* ${IWADDIR}
+\"${CMAKE_INSTALL_PREFIX}/${BINDIR}/vavoom-dedicated.i686\" $* ${IWADDIR}
 exit $?
 ")
-	install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/vavoom-dedicated DESTINATION bin)
+	install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/vavoom-dedicated
+	DESTINATION ${BINDIR})
 endif(UNIX)

 endif(ENABLE_SERVER)
--- utils/vlaunch/CMakeLists.txt	2008-01-31 22:53:37.000000000 +0100
+++ utils/vlaunch/CMakeLists.txt	2008-01-31 22:53:56.000000000 +0100
@@ -9,7 +9,7 @@
 	)
 	target_link_libraries(vlaunch ${wxWidgets_LIBRARIES})

-	install(TARGETS vlaunch DESTINATION bin)
+	install(TARGETS vlaunch DESTINATION ${BINDIR})

 #EXTRA_DIST = \
 #	vavoom.xpm \
Tell me what do you think about <!-- s8) --><img src="{SMILIES_PATH}/icon_cool.gif" alt="8)" title="Cool" /><!-- s8) --> (FYI, i've already implemented it in my Gentoo Linux ebuild, but i think it would be also useful applying it upstream).
Sat, 02 Feb 2008 13:17:07

Janis Legzdinsh

Good idea. Added.

Back to the Vavoom Forum Archives