|
| 1 | +# Copyright (c) 2010-2020 United States Government as represented by |
| 2 | +# the U.S. Army Research Laboratory. |
| 3 | +# |
| 4 | +# Redistribution and use in source and binary forms, with or without |
| 5 | +# modification, are permitted provided that the following conditions |
| 6 | +# are met: |
| 7 | +# |
| 8 | +# 1. Redistributions of source code must retain the above copyright |
| 9 | +# notice, this list of conditions and the following disclaimer. |
| 10 | +# |
| 11 | +# 2. Redistributions in binary form must reproduce the above |
| 12 | +# copyright notice, this list of conditions and the following |
| 13 | +# disclaimer in the documentation and/or other materials provided |
| 14 | +# with the distribution. |
| 15 | +# |
| 16 | +# 3. The name of the author may not be used to endorse or promote |
| 17 | +# products derived from this software without specific prior written |
| 18 | +# permission. |
| 19 | +# |
| 20 | +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS |
| 21 | +# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 22 | +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 23 | +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
| 24 | +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 25 | +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE |
| 26 | +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 27 | +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 28 | +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 29 | +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 30 | +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | + |
| 32 | + |
| 33 | +#--------------------------------------------------------------------- |
| 34 | +# Define relative install locations. Don't set these if they have already |
| 35 | +# been set by some other means (like a higher level CMakeLists.txt file |
| 36 | +# including this one). |
| 37 | + |
| 38 | +# The location in which to install BRL-CAD executables. |
| 39 | +if(NOT BIN_DIR) |
| 40 | + set(BIN_DIR bin) |
| 41 | +endif(NOT BIN_DIR) |
| 42 | + |
| 43 | +# Define a relative path that will "reset" a path back to |
| 44 | +# the point before BIN_DIR was appended. This is primarily |
| 45 | +# useful when working with generator expressions |
| 46 | +unset(RBIN_DIR CACHE) |
| 47 | +set(LBIN_DIR "${BIN_DIR}") |
| 48 | +while (NOT "${LBIN_DIR}" STREQUAL "") |
| 49 | + get_filename_component(LBDIR "${LBIN_DIR}" DIRECTORY) |
| 50 | + set(LBIN_DIR "${LBDIR}") |
| 51 | + if ("${RBIN_DIR}" STREQUAL "") |
| 52 | + set(RBIN_DIR "..") |
| 53 | + else ("${RBIN_DIR}" STREQUAL "") |
| 54 | + set(RBIN_DIR "../${RBIN_DIR}") |
| 55 | + endif ("${RBIN_DIR}" STREQUAL "") |
| 56 | +endwhile (NOT "${LBIN_DIR}" STREQUAL "") |
| 57 | + |
| 58 | +# The location in which to install BRL-CAD libraries. |
| 59 | +if(NOT LIB_DIR) |
| 60 | + set(LIB_DIR lib) |
| 61 | +endif(NOT LIB_DIR) |
| 62 | +if(NOT LIBEXEC_DIR) |
| 63 | + set(LIBEXEC_DIR libexec) |
| 64 | +endif(NOT LIBEXEC_DIR) |
| 65 | + |
| 66 | +# The location in which to install BRL-CAD header files. |
| 67 | +if(NOT INCLUDE_DIR) |
| 68 | + set(INCLUDE_DIR include) |
| 69 | +endif(NOT INCLUDE_DIR) |
| 70 | + |
| 71 | +# The location in which to install BRL-CAD data files |
| 72 | +if(NOT DATA_DIR) |
| 73 | + set(DATA_DIR share) |
| 74 | +endif(NOT DATA_DIR) |
| 75 | + |
| 76 | +# The location in which to install BRL-CAD documentation files |
| 77 | +if(NOT DOC_DIR) |
| 78 | + set(DOC_DIR ${DATA_DIR}/doc) |
| 79 | +endif(NOT DOC_DIR) |
| 80 | + |
| 81 | +# The location in which to install BRL-CAD Manual pages |
| 82 | +if(NOT MAN_DIR) |
| 83 | + set(MAN_DIR ${DATA_DIR}/man) |
| 84 | +endif(NOT MAN_DIR) |
| 85 | + |
| 86 | +# Make sure no absolute paths have been supplied to these variables |
| 87 | +set(INSTALL_DIRS BIN INCLUDE LIB LIBEXEC DATA MAN DOC) |
| 88 | +foreach(instdir ${INSTALL_DIRS}) |
| 89 | + get_filename_component(instdir_full ${${instdir}_DIR} ABSOLUTE) |
| 90 | + if("${${instdir}_DIR}" STREQUAL "${instdir_full}") |
| 91 | + message(FATAL_ERROR "Error - absolute path supplied for ${instdir}_DIR. This path must be relative - e.g. \"bin\" instead of \"/usr/bin\"") |
| 92 | + set(HAVE_INSTALL_DIR_FULL_PATH 1) |
| 93 | + endif("${${instdir}_DIR}" STREQUAL "${instdir_full}") |
| 94 | +endforeach(instdir ${INSTALL_DIRS}) |
| 95 | + |
| 96 | +#--------------------------------------------------------------------- |
| 97 | +# Output directories - this is where built library and executable |
| 98 | +# files will be placed after building but prior to install. The |
| 99 | +# necessary variables change between single and multi configuration |
| 100 | +# build systems, so it is necessary to handle both cases on a |
| 101 | +# conditional basis. |
| 102 | + |
| 103 | +if(NOT CMAKE_CONFIGURATION_TYPES) |
| 104 | + # If we're not doing multi-configuration, just set the three main |
| 105 | + # variables to the correct values. |
| 106 | + if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) |
| 107 | + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${${PROJECT_NAME}_BINARY_DIR}/${LIB_DIR} CACHE INTERNAL "Single output directory for building all libraries.") |
| 108 | + endif(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY) |
| 109 | + if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY) |
| 110 | + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${${PROJECT_NAME}_BINARY_DIR}/${LIB_DIR} CACHE INTERNAL "Single output directory for building all archives.") |
| 111 | + endif(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY) |
| 112 | + if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) |
| 113 | + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${${PROJECT_NAME}_BINARY_DIR}/${BIN_DIR} CACHE INTERNAL "Single output directory for building all executables.") |
| 114 | + endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY) |
| 115 | +else(NOT CMAKE_CONFIGURATION_TYPES) |
| 116 | + # Multi-configuration is more difficult. Not only do we need to |
| 117 | + # properly set the output directories, but we also need to |
| 118 | + # identify the "toplevel" directory for each configuration so |
| 119 | + # we can place files, documentation, etc. in the correct |
| 120 | + # relative positions. Because files may be placed by CMake |
| 121 | + # without a build target to put them in their proper relative build |
| 122 | + # directory position using these paths, we must fully qualify them |
| 123 | + # without using CMAKE_CFG_INTDIR. |
| 124 | + # |
| 125 | + # We define directories that may not be quite "standard" |
| 126 | + # for a particular build tool - for example, native VS2010 projects use |
| 127 | + # another directory to denote CPU type being compiled for - but CMake only |
| 128 | + # supports multi-configuration setups having multiple configurations, |
| 129 | + # not multiple compilers. |
| 130 | + # |
| 131 | + # One additional wrinkle we must watch for here is the case where |
| 132 | + # a multi-configuration setup uses "." for its internal directory - |
| 133 | + # if that's the case, we need to just set the various config output |
| 134 | + # directories to the same value. |
| 135 | + set(CFG_ROOT ${${PROJECT_NAME}_BINARY_DIR}) |
| 136 | + foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES}) |
| 137 | + if(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") |
| 138 | + set(CFG_ROOT ${${PROJECT_NAME}_BINARY_DIR}/${CFG_TYPE}) |
| 139 | + endif(NOT "${CMAKE_CFG_INTDIR}" STREQUAL ".") |
| 140 | + string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER) |
| 141 | + if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) |
| 142 | + set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} libraries.") |
| 143 | + endif(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) |
| 144 | + if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) |
| 145 | + set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} archives.") |
| 146 | + endif(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) |
| 147 | + if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) |
| 148 | + set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${BIN_DIR} CACHE INTERNAL "Single output directory for building ${CFG_TYPE} executables.") |
| 149 | + endif(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}) |
| 150 | + if(NOT DEFINED CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}) |
| 151 | + set("CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.") |
| 152 | + endif(NOT DEFINED CMAKE_BINARY_DIR_${CFG_TYPE_UPPER}) |
| 153 | + if(NOT DEFINED ${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}) |
| 154 | + set("${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}" ${CFG_ROOT} CACHE INTERNAL "Toplevel binary dir for ${CFG_TYPE} building.") |
| 155 | + endif(NOT DEFINED ${PROJECT_NAME}_BINARY_DIR_${CFG_TYPE_UPPER}) |
| 156 | + endforeach() |
| 157 | +endif(NOT CMAKE_CONFIGURATION_TYPES) |
| 158 | + |
| 159 | +# Local Variables: |
| 160 | +# tab-width: 8 |
| 161 | +# mode: cmake |
| 162 | +# indent-tabs-mode: t |
| 163 | +# End: |
| 164 | +# ex: shiftwidth=2 tabstop=8 |
0 commit comments