From 0ff3bdba204fec0671e601be5ff8b7af3ba821c8 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Thu, 21 Jun 2001 12:01:18 -0400 Subject: [PATCH] better install support --- CMakeLists.txt | 3 +- Makefile.in | 49 --------------- Modules/CMakeLists.txt | 2 + Source/cmInstallFilesCommand.cxx | 57 ++++++++++++------ Source/cmInstallFilesCommand.h | 3 +- Source/cmSystemTools.cxx | 23 +++++++ Source/cmSystemTools.h | 4 +- Source/cmake.cxx | 12 ++-- Templates/CMakeLists.txt | 3 + install-sh => Templates/install-sh | 0 configure | 96 +----------------------------- configure.in | 1 - 12 files changed, 82 insertions(+), 171 deletions(-) create mode 100644 Modules/CMakeLists.txt create mode 100644 Templates/CMakeLists.txt rename install-sh => Templates/install-sh (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index ebc7243fa..559d7c31f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,10 @@ PROJECT(CMake) -SUBDIRS(Source) +SUBDIRS(Source Modules Templates) # Include the standard Dart testing module INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake) + diff --git a/Makefile.in b/Makefile.in index 5217e5e30..89a250cf5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -7,52 +7,3 @@ all: cd Source; ${MAKE} -# Default top-level directories in which to install architecture- -# specific files (exec_prefix) and machine-independent files such -# as scripts (prefix). The values specified here may be overridden -# at configure-time with the --exec-prefix and --prefix options -# to the "configure" script. - -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -# Directory in which to install the program cmake -BIN_INSTALL_DIR = $(exec_prefix)/bin - -# Directory in which to install the templates and modules -LIB_INSTALL_DIR = $(exec_prefix)/share/CMake - -INSTALL = @srcdir@/install-sh -c -INSTALL_PROGRAM = ${INSTALL} -m 755 -INSTALL_DATA = ${INSTALL} -m 644 - -install: - @for i in $(LIB_INSTALL_DIR)/Modules $(LIB_INSTALL_DIR)/Templates $(BIN_INSTALL_DIR) ; \ - do \ - if [ ! -d $$i ] ; then \ - echo "Making directory $$i"; \ - mkdir -p $$i; \ - chmod 755 $$i; \ - else true; \ - fi; \ - done; - @echo "Installing CMake" - chmod +x @srcdir@/install-sh - @echo "Installing cmake executable" - @$(INSTALL_PROGRAM) Source/cmake $(BIN_INSTALL_DIR)/cmake - @for i in @srcdir@/Modules/*.cmake*; \ - do \ - echo "Installing $$i"; \ - $(INSTALL_DATA) $$i $(LIB_INSTALL_DIR)/Modules; \ - done; - @for i in @srcdir@/Templates/*.cmake*; \ - do \ - echo "Installing $$i"; \ - $(INSTALL_DATA) $$i $(LIB_INSTALL_DIR)/Templates; \ - done; - @echo "Installing configure" - @$(INSTALL_PROGRAM) @srcdir@/Templates/configure $(LIB_INSTALL_DIR)/Templates - @echo "Installing install-sh" - @$(INSTALL_PROGRAM) @srcdir@/install-sh $(LIB_INSTALL_DIR)/Templates - - diff --git a/Modules/CMakeLists.txt b/Modules/CMakeLists.txt new file mode 100644 index 000000000..3fb52defb --- /dev/null +++ b/Modules/CMakeLists.txt @@ -0,0 +1,2 @@ +# just install the modules +INSTALL_FILES(/share/CMake/Modules .*\.cmake$) diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 97f9cfe69..4de311026 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // cmExecutableCommand bool cmInstallFilesCommand::InitialPass(std::vector& args) { - if(args.size() < 3) + if(args.size() < 2) { this->SetError("called with incorrect number of arguments"); return false; @@ -71,7 +71,13 @@ void cmInstallFilesCommand::FinalPass() std::string testf; std::string ext = m_FinalArgs[0]; - if (tgts.find("INSTALL") != tgts.end()) + if (tgts.find("INSTALL") == tgts.end()) + { + return; + } + + // two different options + if (m_FinalArgs.size() > 1) { // now put the files into the list std::vector::iterator s = m_FinalArgs.begin(); @@ -84,24 +90,39 @@ void cmInstallFilesCommand::FinalPass() m_Makefile->ExpandVariablesInString(temps); // look for a srclist if (m_Makefile->GetSources().find(temps) != m_Makefile->GetSources().end()) - { - const std::vector &clsList = - m_Makefile->GetSources().find(temps)->second; - std::vector::const_iterator c = clsList.begin(); - for (; c != clsList.end(); ++c) - { - testf = c->GetSourceName() + ext; - // add to the result - tgts["INSTALL"].GetSourceLists().push_back(testf); - } - } + { + const std::vector &clsList = + m_Makefile->GetSources().find(temps)->second; + std::vector::const_iterator c = clsList.begin(); + for (; c != clsList.end(); ++c) + { + testf = c->GetSourceName() + ext; + // add to the result + tgts["INSTALL"].GetSourceLists().push_back(testf); + } + } // if one wasn't found then assume it is a single class else - { - testf = temps + ext; - // add to the result - tgts["INSTALL"].GetSourceLists().push_back(testf); - } + { + testf = temps + ext; + // add to the result + tgts["INSTALL"].GetSourceLists().push_back(testf); + } + } + } + else // reg exp list + { + std::vector files; + cmSystemTools::Glob(m_Makefile->GetCurrentDirectory(), + m_FinalArgs[0].c_str(), files); + + std::vector::iterator s = files.begin(); + // for each argument, get the files + for (;s != files.end(); ++s) + { + tgts["INSTALL"].GetSourceLists().push_back(*s); } } } + + diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h index f5a764d0b..0f86d88d2 100644 --- a/Source/cmInstallFilesCommand.h +++ b/Source/cmInstallFilesCommand.h @@ -95,7 +95,8 @@ public: { return "INSTALL_FILES(path extension srclist file file srclist ...)\n" - "Create rules to install the listed files into the path. Path is relative to the variable PREFIX. The files can be specified explicitly or by referenceing source lists. All files must either have the extension specified or exist with the extension appended. A typical extension is .h etc..."; + "INSTALL_FILES(path regexp)\n" + "Create rules to install the listed files into the path. Path is relative to the variable CMAKE_INSTALL_PREFIX. There are two forms for this command. In the first the files can be specified explicitly or by referenceing source lists. All files must either have the extension specified or exist with the extension appended. A typical extension is .h etc... In the second form any files in the current directory that match the regular expression will be installed."; } cmTypeMacro(cmInstallFilesCommand, cmCommand); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index bbbd3a3c6..5d3864cd1 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "cmRegularExpression.h" #include +#include "cmDirectory.h" #if defined(_MSC_VER) || defined(__BORLANDC__) #include @@ -1064,3 +1065,25 @@ std::string cmSystemTools::GetFilenameNameWithoutExtension(const std::string& fi } } + +void cmSystemTools::Glob(const char *directory, const char *regexp, + std::vector& files) +{ + cmDirectory d; + cmRegularExpression reg(regexp); + + if (d.Load(directory)) + { + int i, numf; + numf = d.GetNumberOfFiles(); + for (i = 0; i < numf; i++) + { + std::string fname = d.GetFile(i); + if (reg.find(fname)) + { + files.push_back(fname); + } + } + } +} + diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index e40416850..8ea7724c3 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -204,7 +204,9 @@ public: ///! return true if the file is a directory. static bool FileIsDirectory(const char* name); - + static void Glob(const char *directory, const char *regexp, + std::vector& files); + static std::string GetCurrentWorkingDirectory(); static std::string GetProgramPath(const char*); static void SplitProgramPath(const char* in_name, diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 7e2a14b3a..f015024bc 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -157,19 +157,19 @@ void cmake::AddCMakePaths(const std::vector& args) cMakeRoot = cMakeRoot.substr(0, slashPos); } // is there no Modules direcory there? - std::string modules = cMakeRoot + "/Modules"; - if (!cmSystemTools::FileIsDirectory(modules.c_str())) + std::string modules = cMakeRoot + "/Modules/FindVTK.cmake"; + if (!cmSystemTools::FileExists(modules.c_str())) { // try exe/../share/cmake - modules = cMakeRoot + "/share/CMake/Modules"; - if (!cmSystemTools::FileIsDirectory(modules.c_str())) + modules = cMakeRoot + "/share/CMake/Modules/FindVTK.cmake"; + if (!cmSystemTools::FileExists(modules.c_str())) { #ifdef CMAKE_ROOT_DIR // try compiled in value on UNIX cMakeRoot = CMAKE_ROOT_DIR; - modules = cMakeRoot + "/Modules"; + modules = cMakeRoot + "/Modules/FindVTK.cmake"; #endif - if (!cmSystemTools::FileIsDirectory(modules.c_str())) + if (!cmSystemTools::FileExists(modules.c_str())) { // couldn't find modules cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n", diff --git a/Templates/CMakeLists.txt b/Templates/CMakeLists.txt new file mode 100644 index 000000000..2162908f6 --- /dev/null +++ b/Templates/CMakeLists.txt @@ -0,0 +1,3 @@ +# just install the modules +INSTALL_FILES(/share/CMake/Templates .*\.cmake$) +INSTALL_FILES(/share/CMake/Templates "" configure install-sh) diff --git a/install-sh b/Templates/install-sh similarity index 100% rename from install-sh rename to Templates/install-sh diff --git a/configure b/configure index 6aa55371d..ae61b41d0 100755 --- a/configure +++ b/configure @@ -895,89 +895,6 @@ else fi fi -ac_aux_dir= -for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do - if test -f $ac_dir/install-sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f $ac_dir/install.sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } -fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:930: checking for a BSD compatible install" >&5 -if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" - for ac_dir in $PATH; do - # Account for people who put trailing slashes in PATH elements. - case "$ac_dir/" in - /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - if test -f $ac_dir/$ac_prog; then - if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - else - ac_cv_path_install="$ac_dir/$ac_prog -c" - break 2 - fi - fi - done - ;; - esac - done - IFS="$ac_save_IFS" - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL="$ac_cv_path_install" - else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the path is relative. - INSTALL="$ac_install_sh" - fi -fi -echo "$ac_t""$INSTALL" 1>&6 - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - fullSrcDir=`cd $srcdir; pwd` CMAKE_ROOT_DIR=$fullSrcDir @@ -1030,7 +947,7 @@ fi # ansi stream files (without the .h) if test $ac_cv_prog_gxx = no; then echo $ac_n "checking ansi standard C++ stream headers ""... $ac_c" 1>&6 -echo "configure:1034: checking ansi standard C++ stream headers " >&5 +echo "configure:951: checking ansi standard C++ stream headers " >&5 rm -rf conftest.* cat > conftest.cc < @@ -1049,7 +966,7 @@ fi # check to see if stl is in the std namespace if test $ac_cv_prog_gxx = no; then echo $ac_n "checking ansi standard namespace support ""... $ac_c" 1>&6 -echo "configure:1053: checking ansi standard namespace support " >&5 +echo "configure:970: checking ansi standard namespace support " >&5 rm -rf conftest.* cat > conftest.cc < @@ -1166,7 +1083,6 @@ do done ac_given_srcdir=$srcdir -ac_given_INSTALL="$INSTALL" trap 'rm -fr `echo "Makefile Source/Makefile Source/cmConfigure.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF @@ -1203,9 +1119,6 @@ s%@mandir@%$mandir%g s%@CMAKE_CONFIG_DIR@%$CMAKE_CONFIG_DIR%g s%@CC@%$CC%g s%@CXX@%$CXX%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g -s%@INSTALL_DATA@%$INSTALL_DATA%g s%@CMAKE_ROOT_DIR@%$CMAKE_ROOT_DIR%g s%@CMAKE_ANSI_CFLAGS@%$CMAKE_ANSI_CFLAGS%g s%@CMAKE_TEMPLATE_FLAGS@%$CMAKE_TEMPLATE_FLAGS%g @@ -1285,10 +1198,6 @@ for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then top_srcdir="$ac_dots$ac_given_srcdir" ;; esac - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; - esac echo creating "$ac_file" rm -f "$ac_file" @@ -1304,7 +1213,6 @@ for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then s%@configure_input@%$configure_input%g s%@srcdir@%$srcdir%g s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file fi; done rm -f conftest.s* diff --git a/configure.in b/configure.in index 9312a5fa8..1af27fbd9 100644 --- a/configure.in +++ b/configure.in @@ -11,7 +11,6 @@ AC_SUBST(CMAKE_CONFIG_DIR) # AC_PROG_CC AC_PROG_CXX -AC_PROG_INSTALL fullSrcDir=`cd $srcdir; pwd` CMAKE_ROOT_DIR=$fullSrcDir