Skip to content
Browse files

Revamp cmake install directory handling

Clean up some things to allow greater flexibility in specifying the install
directory structure.  The following new user-visible cmake path variables are
defined:

BIN_INSTALL_DIR     - replaces BINDIR, renamed for clarity
LIB_INSTALL_DIR     - replaces LIBDIR
PYLIB_INSTALL_DIR   - replaces PYLIBDIR
INCLUDE_INSTALL_DIR - new
DOC_INSTALL_DIR     - new
MAN_INSTALL_DIR     - new

In addition, there is an INSTALL_DOCS option for the benefit of linux packagers
relying on the packaging system to do the docs install.

Finally, there is a variable SELF_CONTAINED_INSTALL_TREE to specify whether the
user will be installing into standard unix system directories, or into a
special self-contained oiio directory.  It is false by default, but is
explicitly set in the Makefile, so anybody doing makefile builds should see
very few changes.  Windows builds are always set up as "self-contained".

Also clean up the docs install to avoid installing a few developer-centric
things which will normally be obtained directly from git.
  • Loading branch information...
1 parent 2d830b5 commit 5de68071e5885be5cfac6377b416aea11ec1cc64 @c42f c42f committed Jul 10, 2011
Showing with 73 additions and 33 deletions.
  1. +1 −1 Makefile
  2. +50 −8 src/CMakeLists.txt
  3. +3 −3 src/cmake/oiio_macros.cmake
  4. +15 −13 src/doc/CMakeLists.txt
  5. +2 −6 src/include/CMakeLists.txt
  6. +2 −2 src/python/CMakeLists.txt
View
2 Makefile
@@ -27,7 +27,7 @@ ifdef PROFILE
endif
MY_MAKE_FLAGS ?=
-MY_CMAKE_FLAGS ?=
+MY_CMAKE_FLAGS ?= -DSELF_CONTAINED_INSTALL_TREE:BOOL=TRUE
# Site-specific build instructions
ifndef OPENIMAGEIO_SITE
View
58 src/CMakeLists.txt
@@ -87,19 +87,61 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions ("-DDEBUG=1")
endif ()
-# Exec Install Locations
-set (BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
-set (LIBDIR "${CMAKE_INSTALL_PREFIX}/lib")
-set (PYLIBDIR "${CMAKE_INSTALL_PREFIX}/python")
+###########################################################################
+# Paths for install tree customization. Note that relative paths are relative
+# to CMAKE_INSTALL_PREFIX.
+set (DEFAULT_BIN_INSTALL_DIR "bin")
+set (DEFAULT_LIB_INSTALL_DIR "lib")
+set (DEFAULT_INCLUDE_INSTALL_DIR "include/OpenImageIO")
+if (UNIX AND NOT SELF_CONTAINED_INSTALL_TREE)
+ # Try to be well-behaved and install into reasonable places according to
+ # the "standard" unix directory heirarchy
+ # TODO: Figure out how to get the correct python directory
+ set (DEFAULT_PYLIB_INSTALL_DIR "lib/python/site-packages")
+ set (DEFAULT_DOC_INSTALL_DIR "share/doc/openimageio")
+ set (DEFAULT_MAN_INSTALL_DIR "share/man/man1")
+else ()
+ # Here is the "self-contained install tree" case: the expectation here is
+ # that everything OIIO related will go into its own directory, not into
+ # some standard system heirarchy.
+ set (DEFAULT_PYLIB_INSTALL_DIR "python")
+ set (DEFAULT_DOC_INSTALL_DIR "doc")
+ set (DEFAULT_MAN_INSTALL_DIR "doc/man")
+endif ()
if (EXEC_INSTALL_PREFIX)
- set (BINDIR "${EXEC_INSTALL_PREFIX}/bin")
- set (LIBDIR "${EXEC_INSTALL_PREFIX}/lib")
- set (PYLIBDIR "${EXEC_INSTALL_PREFIX}/python")
+ # Tack on an extra prefix to support multi-arch builds.
+ set (DEFAULT_BIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/${DEFAULT_BIN_INSTALL_DIR}")
+ set (DEFAULT_LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/${DEFAULT_LIB_INSTALL_DIR}")
+ set (DEFAULT_PYLIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/${DEFAULT_PYLIB_INSTALL_DIR}")
endif ()
+# Set up cmake cache variables corresponding to the defaults deduced above, so
+# that the user can override them as desired:
+set (BIN_INSTALL_DIR ${DEFAULT_BIN_INSTALL_DIR} CACHE STRING
+ "Install location for binaries (relative to CMAKE_INSTALL_PREFIX or absolute)")
+set (LIB_INSTALL_DIR ${DEFAULT_LIB_INSTALL_DIR} CACHE STRING
+ "Install location for libraries (relative to CMAKE_INSTALL_PREFIX or absolute)")
+set (PYLIB_INSTALL_DIR ${DEFAULT_PYLIB_INSTALL_DIR} CACHE STRING
+ "Install location for python libraries (relative to CMAKE_INSTALL_PREFIX or absolute)")
+set (INCLUDE_INSTALL_DIR ${DEFAULT_INCLUDE_INSTALL_DIR} CACHE STRING
+ "Install location of header files (relative to CMAKE_INSTALL_PREFIX or absolute)")
+set (DOC_INSTALL_DIR ${DEFAULT_DOC_INSTALL_DIR} CACHE STRING
+ "Install location for documentation (relative to CMAKE_INSTALL_PREFIX or absolute)")
+if (UNIX)
+ set (MAN_INSTALL_DIR ${DEFAULT_MAN_INSTALL_DIR} CACHE STRING
+ "Install location for manual pages (relative to CMAKE_INSTALL_PREFIX or absolute)")
+endif()
-set (CMAKE_INSTALL_RPATH "${LIBDIR}")
+set (INSTALL_DOCS ON CACHE BOOL "Install documentation")
+
+
+#####
+set (CMAKE_INSTALL_RPATH "${LIB_INSTALL_DIR}")
+if (NOT IS_ABSOLUTE ${CMAKE_INSTALL_RPATH})
+ set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}")
+endif ()
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+
###########################################################################
if (MSVC)
add_definitions (-D_CRT_SECURE_NO_DEPRECATE)
View
6 src/cmake/oiio_macros.cmake
@@ -7,9 +7,9 @@
#
macro (oiio_install_targets)
install (TARGETS ${ARGN}
- RUNTIME DESTINATION "${BINDIR}" COMPONENT user
- LIBRARY DESTINATION "${LIBDIR}" COMPONENT user
- ARCHIVE DESTINATION "${LIBDIR}" COMPONENT developer)
+ RUNTIME DESTINATION "${BIN_INSTALL_DIR}" COMPONENT user
+ LIBRARY DESTINATION "${LIB_INSTALL_DIR}" COMPONENT user
+ ARCHIVE DESTINATION "${LIB_INSTALL_DIR}" COMPONENT developer)
endmacro ()
# Macro to add a build target for an IO plugin.
View
28 src/doc/CMakeLists.txt
@@ -1,22 +1,22 @@
project(documentation)
-set (public_docs openimageio.pdf CLA-INDIVIDUAL CLA-CORPORATE)
-install (FILES ${public_docs} DESTINATION doc COMPONENT documentation)
+set (public_docs
+ openimageio.pdf
+ ${OpenImageIO_SOURCE_DIR}/../LICENSE
+ ${OpenImageIO_SOURCE_DIR}/../CHANGES
+)
-install (FILES ${OpenImageIO_SOURCE_DIR}/../LICENSE
- ${OpenImageIO_SOURCE_DIR}/../INSTALL
- ${OpenImageIO_SOURCE_DIR}/../CHANGES
- DESTINATION .)
-
-#install (DIRECTORY doxygen/html DESTINATION doc
-# PATTERN .svn EXCLUDE)
+if (INSTALL_DOCS)
+ install (FILES ${public_docs} DESTINATION ${DOC_INSTALL_DIR}
+ COMPONENT documentation)
+endif ()
# generate man pages using txt2man and a tiny python script to munge the
-# result of "tool --help"
+# result of "$tool --help"
find_program(TXT2MAN txt2man)
find_package(PythonInterp)
if (UNIX AND TXT2MAN AND PYTHONINTERP_FOUND)
- message (STATUS "Generating manual page docs")
+ message (STATUS "Unix man page documentation will be generated")
set (cli_tools iinfo maketx idiff iv igrep iprocess iconvert)
foreach (tool ${cli_tools})
@@ -32,6 +32,8 @@ if (UNIX AND TXT2MAN AND PYTHONINTERP_FOUND)
# force man page build before install
add_custom_target (man_pages ALL DEPENDS ${manpage_files})
- install (FILES ${manpage_files}
- DESTINATION doc/man COMPONENT documentation)
+ if (INSTALL_DOCS)
+ install (FILES ${manpage_files}
+ DESTINATION ${MAN_INSTALL_DIR} COMPONENT documentation)
+ endif ()
endif()
View
8 src/include/CMakeLists.txt
@@ -15,15 +15,11 @@ set (OIIO_VERSION_NS "v${MANGLED_SOVERSION}")
configure_file(version.h.in ${CMAKE_BINARY_DIR}/include/version.h @ONLY)
list(APPEND public_headers ${CMAKE_BINARY_DIR}/include/version.h)
-install (FILES ${public_headers} DESTINATION include/OpenImageIO
+install (FILES ${public_headers} DESTINATION ${INCLUDE_INSTALL_DIR}
COMPONENT developer)
if (USE_TBB)
- file (GLOB tbb_headers tbb/*.h)
- file (GLOB tbb_headers2 tbb/machine/*.h)
- install (FILES ${tbb_headers} DESTINATION include/OpenImageIO/tbb
- COMPONENT developer)
- install (FILES ${tbb_headers2} DESTINATION include/OpenImageIO/tbb/machine
+ install (DIRECTORY tbb DESTINATION ${INCLUDE_INSTALL_DIR}
COMPONENT developer)
endif ()
View
4 src/python/CMakeLists.txt
@@ -42,7 +42,7 @@ if ( BOOST_CUSTOM OR Boost_FOUND AND PYTHONLIBS_FOUND)
endif()
install (TARGETS PyOpenImageIO
- RUNTIME DESTINATION ${PYLIBDIR} COMPONENT user
- LIBRARY DESTINATION ${PYLIBDIR} COMPONENT user)
+ RUNTIME DESTINATION ${PYLIB_INSTALL_DIR} COMPONENT user
+ LIBRARY DESTINATION ${PYLIB_INSTALL_DIR} COMPONENT user)
endif ()

0 comments on commit 5de6807

Please sign in to comment.
Something went wrong with that request. Please try again.