From 394daad24282a29d95871460e4765daf4d2174ac Mon Sep 17 00:00:00 2001 From: Modestas Vainius Date: Sun, 19 Jun 2011 15:41:06 +0300 Subject: [PATCH] Imported Upstream version 2.8.5~rc2 --- CMakeLists.txt | 24 +- ChangeLog.manual | 390 +++++++++ Modules/BundleUtilities.cmake | 69 +- Modules/CMakeASM-ATTInformation.cmake | 3 + Modules/CMakeASMCompiler.cmake.in | 1 + Modules/CMakeASMInformation.cmake | 21 +- Modules/CMakeCCompiler.cmake.in | 5 + Modules/CMakeCXXCompiler.cmake.in | 5 + Modules/CMakeCommonLanguageInclude.cmake | 6 +- Modules/CMakeDetermineASMCompiler.cmake | 86 +- Modules/CMakeDetermineCompilerABI.cmake | 11 + Modules/CMakeDetermineCompilerId.cmake | 7 + Modules/CMakeDetermineFortranCompiler.cmake | 3 +- Modules/CMakeDetermineSystem.cmake | 7 +- Modules/CMakeFindEclipseCDT4.cmake | 12 +- Modules/CMakeFortranCompiler.cmake.in | 5 + Modules/CMakeFortranCompilerId.F.in | 2 + Modules/CMakeFortranInformation.cmake | 3 +- Modules/CMakeGenericSystem.cmake | 6 + Modules/CMakeParseImplicitLinkInfo.cmake | 8 +- Modules/CPack.cmake | 503 +---------- Modules/CPackBundle.cmake | 37 + Modules/CPackComponent.cmake | 456 ++++++++++ Modules/CPackDeb.cmake | 25 +- Modules/CPackNSIS.cmake | 83 ++ Modules/CPackRPM.cmake | 64 +- Modules/CTest.cmake | 21 +- Modules/CTestTargets.cmake | 8 + Modules/CheckPrototypeDefinition.c.in | 29 + Modules/CheckPrototypeDefinition.cmake | 96 +++ Modules/Compiler/Absoft-Fortran.cmake | 8 + Modules/Compiler/GNU-ASM.cmake | 6 + Modules/Compiler/GNU.cmake | 2 +- Modules/Compiler/HP-ASM.cmake | 3 + Modules/Compiler/HP-C.cmake | 3 + Modules/Compiler/HP-CXX.cmake | 3 + Modules/Compiler/Intel-ASM.cmake | 13 + Modules/Compiler/SunPro-ASM.cmake | 24 + Modules/Compiler/XL-ASM.cmake | 13 + Modules/Compiler/XL-C.cmake | 13 +- Modules/Compiler/XL-CXX.cmake | 15 +- Modules/Compiler/XL-Fortran.cmake | 16 +- Modules/Compiler/XL.cmake | 48 ++ Modules/ExternalProject.cmake | 26 +- Modules/FindArmadillo.cmake | 100 +++ Modules/FindBLAS.cmake | 96 ++- Modules/FindHDF5.cmake | 140 ++- Modules/FindITK.cmake | 16 +- Modules/FindJNI.cmake | 3 + Modules/FindJava.cmake | 8 +- Modules/FindMPI.cmake | 808 +++++++++++------- Modules/FindOpenSSL.cmake | 209 ++++- Modules/FindPostgreSQL.cmake | 4 +- Modules/FindProtobuf.cmake | 126 ++- Modules/FindQt4.cmake | 324 +++---- Modules/FindSWIG.cmake | 3 +- Modules/FindZLIB.cmake | 2 +- Modules/FortranCInterface/CMakeLists.txt | 13 +- Modules/FortranCInterface/my_module_.c | 7 - Modules/FortranCInterface/mymodule_.c | 7 - Modules/GNUInstallDirs.cmake | 182 ++++ Modules/GetPrerequisites.cmake | 6 +- Modules/InstallRequiredSystemLibraries.cmake | 16 +- Modules/Platform/AIX-GNU.cmake | 2 + Modules/Platform/AIX-XL-ASM.cmake | 2 + Modules/Platform/AIX-XL-C.cmake | 6 +- Modules/Platform/AIX-XL-CXX.cmake | 6 +- Modules/Platform/AIX-XL-Fortran.cmake | 6 +- Modules/Platform/AIX-XL.cmake | 28 + Modules/Platform/AIX.cmake | 2 - Modules/Platform/Darwin-Absoft-Fortran.cmake | 1 + Modules/Platform/Darwin.cmake | 3 +- Modules/Platform/GNU.cmake | 2 + Modules/Platform/HP-UX-HP-ASM.cmake | 6 + Modules/Platform/HP-UX-HP-C.cmake | 11 + Modules/Platform/HP-UX-HP-CXX.cmake | 16 + Modules/Platform/HP-UX-HP-Fortran.cmake | 7 + Modules/Platform/HP-UX-HP.cmake | 34 + Modules/Platform/HP-UX.cmake | 65 -- Modules/Platform/Linux-Absoft-Fortran.cmake | 1 + Modules/Platform/Linux.cmake | 3 + Modules/Platform/Windows-GNU.cmake | 4 + Modules/Platform/Windows-Intel-ASM.cmake | 2 + Modules/Platform/kFreeBSD.cmake | 2 + Modules/ProcessorCount.cmake | 183 ++++ Modules/Qt4Macros.cmake | 6 +- Modules/UseQt4.cmake | 7 + Modules/UseSWIG.cmake | 64 +- Modules/UsewxWidgets.cmake | 2 +- Modules/readme.txt | 22 + Source/CMakeLists.txt | 8 +- Source/CPack/OSXScriptLauncher.cxx | 1 - Source/CPack/cmCPackArchiveGenerator.cxx | 105 ++- Source/CPack/cmCPackArchiveGenerator.h | 2 +- Source/CPack/cmCPackBundleGenerator.cxx | 7 +- Source/CPack/cmCPackBundleGenerator.h | 1 + Source/CPack/cmCPackDebGenerator.cxx | 330 ++++++- Source/CPack/cmCPackDebGenerator.h | 22 + Source/CPack/cmCPackDragNDropGenerator.cxx | 106 ++- Source/CPack/cmCPackDragNDropGenerator.h | 7 +- Source/CPack/cmCPackGenerator.cxx | 264 ++++-- Source/CPack/cmCPackGenerator.h | 59 +- Source/CPack/cmCPackOSXX11Generator.cxx | 27 + Source/CPack/cmCPackRPMGenerator.cxx | 237 ++++- Source/CPack/cmCPackRPMGenerator.h | 17 + Source/CTest/cmCTestBuildHandler.cxx | 4 +- Source/CTest/cmCTestCoverageHandler.cxx | 2 +- Source/CTest/cmCTestGIT.cxx | 45 +- Source/CTest/cmCTestGIT.h | 2 + Source/CTest/cmCTestMemCheckHandler.cxx | 14 +- Source/CTest/cmCTestMultiProcessHandler.cxx | 2 +- Source/CTest/cmCTestRunTest.cxx | 42 +- Source/CTest/cmCTestScriptHandler.cxx | 42 +- Source/CTest/cmCTestSubmitHandler.cxx | 29 +- Source/CTest/cmCTestTestHandler.cxx | 117 +-- Source/CTest/cmCTestTestHandler.h | 6 +- Source/CTest/cmCTestUploadCommand.cxx | 69 ++ Source/CTest/cmCTestUploadCommand.h | 85 ++ Source/CTest/cmCTestUploadHandler.cxx | 77 ++ Source/CTest/cmCTestUploadHandler.h | 45 + Source/CursesDialog/form/frm_driver.c | 2 +- Source/QtDialog/QCMakeCacheView.cxx | 14 +- Source/QtDialog/QCMakeCacheView.h | 4 +- Source/cmAddCustomCommandCommand.cxx | 19 +- Source/cmAddCustomCommandCommand.h | 2 + Source/cmAddCustomTargetCommand.cxx | 14 +- Source/cmAddCustomTargetCommand.h | 2 + Source/cmArchiveWrite.cxx | 3 + Source/cmCPluginAPI.cxx | 2 +- Source/cmCTest.cxx | 136 ++- Source/cmCTest.h | 17 +- Source/cmComputeLinkInformation.cxx | 6 +- Source/cmDocumentVariables.cxx | 48 +- Source/cmExportFileGenerator.cxx | 6 + Source/cmExportInstallFileGenerator.cxx | 14 + Source/cmExtraCodeBlocksGenerator.cxx | 7 + Source/cmExtraEclipseCDT4Generator.cxx | 99 ++- Source/cmExtraEclipseCDT4Generator.h | 3 +- Source/cmFileCommand.cxx | 492 ++++++++--- Source/cmFileCommand.h | 24 +- Source/cmFindBase.cxx | 12 + Source/cmFindLibraryCommand.cxx | 4 + Source/cmFindPackageCommand.cxx | 176 +++- Source/cmFindPackageCommand.h | 11 +- Source/cmFindPathCommand.cxx | 2 + Source/cmFindProgramCommand.cxx | 2 + Source/cmGeneratorExpression.cxx | 2 +- Source/cmGetCMakePropertyCommand.cxx | 21 +- Source/cmGlobalGenerator.cxx | 2 - Source/cmGlobalUnixMakefileGenerator3.cxx | 205 +++-- Source/cmGlobalUnixMakefileGenerator3.h | 8 +- Source/cmGlobalVisualStudio8Generator.cxx | 9 + Source/cmGlobalXCodeGenerator.cxx | 295 +++++-- Source/cmGlobalXCodeGenerator.h | 4 + Source/cmGraphVizWriter.cxx | 190 +++- Source/cmGraphVizWriter.h | 11 +- Source/cmIDEOptions.cxx | 6 + Source/cmIDEOptions.h | 1 + Source/cmIncludeDirectoryCommand.h | 2 +- Source/cmListCommand.h | 8 + Source/cmLocalGenerator.cxx | 31 +- Source/cmLocalGenerator.h | 3 +- Source/cmLocalUnixMakefileGenerator3.cxx | 26 +- Source/cmLocalUnixMakefileGenerator3.h | 2 + Source/cmLocalVisualStudio10Generator.cxx | 4 +- Source/cmLocalVisualStudio10Generator.h | 3 +- Source/cmLocalVisualStudio6Generator.cxx | 2 +- Source/cmLocalVisualStudio7Generator.cxx | 40 +- Source/cmLocalVisualStudioGenerator.cxx | 64 +- Source/cmLocalVisualStudioGenerator.h | 12 +- Source/cmMakefile.cxx | 35 + Source/cmMakefile.h | 12 +- .../cmMakefileExecutableTargetGenerator.cxx | 6 +- Source/cmMakefileLibraryTargetGenerator.cxx | 55 +- Source/cmMakefileLibraryTargetGenerator.h | 1 + Source/cmMakefileTargetGenerator.cxx | 171 +++- Source/cmMakefileTargetGenerator.h | 10 + Source/cmOutputRequiredFilesCommand.h | 13 +- Source/cmPolicies.cxx | 2 +- Source/cmScriptGenerator.cxx | 14 +- Source/cmScriptGenerator.h | 2 + Source/cmSourceFile.cxx | 6 +- Source/cmSourceGroupCommand.cxx | 34 +- Source/cmStringCommand.cxx | 76 +- Source/cmStringCommand.h | 9 +- Source/cmSystemTools.cxx | 120 ++- Source/cmSystemTools.h | 8 + Source/cmTarget.cxx | 65 +- Source/cmTarget.h | 5 +- Source/cmTestGenerator.cxx | 16 + Source/cmTestGenerator.h | 2 + Source/cmTryCompileCommand.h | 16 +- Source/cmUseMangledMesaCommand.h | 14 +- Source/cmVisualStudio10TargetGenerator.cxx | 72 +- Source/cmVisualStudioGeneratorOptions.cxx | 7 +- Source/cmXCodeObject.cxx | 30 +- Source/cmXCodeObject.h | 15 + Source/cmake.cxx | 117 ++- Source/cmake.h | 8 +- Source/cmakemain.cxx | 15 +- Source/kwsys/CMakeLists.txt | 298 ++----- Source/kwsys/CheckCXXSourceRuns.cmake | 62 -- Source/kwsys/EncodeExecutable.c | 1 + Source/kwsys/Terminal.c | 1 + Source/kwsys/kwsysDateStamp.cmake | 2 +- Tests/Assembler/CMakeLists.txt | 40 +- Tests/BundleTest/BundleLib.cxx | 4 +- Tests/BundleTest/BundleTest.cxx | 6 +- Tests/BundleTest/CMakeLists.txt | 12 +- Tests/BundleUtilities/CMakeLists.txt | 84 ++ Tests/BundleUtilities/bundleutils.cmake | 45 + Tests/BundleUtilities/framework.cpp | 8 + Tests/BundleUtilities/framework.h | 17 + Tests/BundleUtilities/module.cpp | 10 + Tests/BundleUtilities/module.h | 7 + Tests/BundleUtilities/shared.cpp | 8 + Tests/BundleUtilities/shared.h | 17 + Tests/BundleUtilities/shared2.cpp | 8 + Tests/BundleUtilities/shared2.h | 17 + Tests/BundleUtilities/testbundleutils1.cpp | 33 + Tests/BundleUtilities/testbundleutils2.cpp | 33 + Tests/CFBundleTest/CMakeLists.txt | 56 ++ Tests/CFBundleTest/ExportList_plugin.txt | 3 + Tests/CFBundleTest/Info.plist.in | 54 ++ Tests/CFBundleTest/InfoPlist.strings.in | 4 + Tests/CFBundleTest/Localized.r | 18 + Tests/CFBundleTest/Localized.rsrc | Bin 0 -> 496 bytes Tests/CFBundleTest/PluginConfig.cmake | 21 + Tests/CFBundleTest/README.txt | 16 + Tests/CFBundleTest/VerifyResult.cmake | 32 + Tests/CFBundleTest/np_macmain.cpp | 49 ++ Tests/CMakeLib/CMakeLists.txt | 5 + Tests/CMakeLib/run_compile_commands.cxx | 141 +++ Tests/CMakeLists.txt | 172 +++- Tests/CMakeTests/CMakeLists.txt | 3 + Tests/CMakeTests/FileDownloadTest.cmake.in | 2 + Tests/CMakeTests/FileTest.cmake.in | 2 +- Tests/CMakeTests/FileTestScript.cmake | 20 + Tests/CMakeTests/FileUploadTest.cmake.in | 49 ++ .../CMakeTests/ImplicitLinkInfoTest.cmake.in | 15 + Tests/CMakeTests/ProcessorCountTest.cmake.in | 72 ++ Tests/CMakeTests/StringTest.cmake.in | 2 +- Tests/CMakeTests/StringTestScript.cmake | 79 ++ Tests/CPackComponentsForAll/CMakeLists.txt | 5 +- .../MyLibCPackConfig-AllGroupsInOne.cmake.in | 18 - .../MyLibCPackConfig-AllInOne.cmake.in | 4 + .../MyLibCPackConfig-IgnoreGroup.cmake.in | 4 + .../MyLibCPackConfig-OnePackPerGroup.cmake.in | 10 +- .../RunCPackVerifyResult.cmake | 83 +- Tests/CTestTest3/test.cmake.in | 120 --- Tests/CTestTestBadExe/test.cmake.in | 3 - Tests/CTestTestChecksum/test.cmake.in | 3 - Tests/CTestTestCostSerial/test.cmake.in | 3 - Tests/CTestTestCrash/test.cmake.in | 3 - Tests/CTestTestCycle/test.cmake.in | 3 - Tests/CTestTestDepends/test.cmake.in | 3 - Tests/CTestTestFailedSubmits/test.cmake.in | 4 - Tests/CTestTestFailure/testNoBuild.cmake.in | 3 - Tests/CTestTestFailure/testNoExe.cmake.in | 3 - Tests/CTestTestParallel/test.cmake.in | 3 - Tests/CTestTestResourceLock/test.cmake.in | 3 - Tests/CTestTestScheduler/test.cmake.in | 3 - Tests/CTestTestStopTime/test.cmake.in | 3 - Tests/CTestTestSubdir/test.cmake.in | 3 - Tests/CTestTestTimeout/test.cmake.in | 3 - Tests/CTestTestUpload/CMakeLists.txt | 4 + Tests/CTestTestUpload/CTestConfig.cmake | 7 + Tests/CTestTestUpload/sleep.c | 21 + Tests/CTestTestUpload/test.cmake.in | 17 + Tests/CTestTestZeroTimeout/test.cmake.in | 3 - Tests/CompileCommandOutput/CMakeLists.txt | 16 + .../compile_command_output.cxx | 9 + .../CompileCommandOutput/file with spaces.cxx | 1 + .../file_with_underscores.cxx | 3 + .../file_with_underscores.h | 1 + Tests/CompileCommandOutput/relative.cxx | 3 + Tests/CompileCommandOutput/relative.h | 11 + Tests/CustomCommand/CMakeLists.txt | 2 +- .../CMakeLists.txt | 21 +- Tests/ExternalOBJ/CMakeLists.txt | 6 + Tests/ExternalProject/CMakeLists.txt | 3 + Tests/FindPackageTest/CMakeLists.txt | 56 +- .../CMakeTestSystemPackageConfig.cmake | 1 + .../lib/RecursiveA/recursivea-config.cmake | 3 + .../lib/arch/Bar/BarConfig.cmake | 1 + .../cmake/zot-4.0/zot-config-version.cmake | 7 + .../lib/arch/cmake/zot-4.0/zot-config.cmake | 1 + .../lib/arch/foo-1.2/CMake/FooConfig.cmake | 1 + .../lib/arch/zot-3.1/zot-config-version.cmake | 7 + .../lib/arch/zot-3.1/zot-config.cmake | 1 + Tests/Fortran/CMakeLists.txt | 18 +- Tests/Fortran/world_gnu.def | 2 + Tests/Fortran/{world.def => world_icl.def} | 0 Tests/IncludeDirectories/CMakeLists.txt | 47 + Tests/IncludeDirectories/main.cpp | 9 + Tests/LinkStatic/CMakeLists.txt | 27 + Tests/LinkStatic/LinkStatic.c | 5 + Tests/SimpleInstall/CMakeLists.txt | 2 +- Tests/SimpleInstallS2/CMakeLists.txt | 2 +- Tests/SourceGroups/CMakeLists.txt | 2 +- Tests/TestsWorkingDirectory/CMakeLists.txt | 4 +- .../subdir/CMakeLists.txt | 4 +- Tests/TryCompile/CMakeLists.txt | 13 + Utilities/Release/create-cmake-release.cmake | 50 +- Utilities/Release/dash2win64_cygwin.cmake | 1 - Utilities/Release/dash2win64_release.cmake | 1 - Utilities/Release/dashmacmini2_release.cmake | 1 - Utilities/Release/ferrari_sgi64_release.cmake | 1 - Utilities/Release/ferrari_sgi_release.cmake | 1 - Utilities/Release/magrathea_release.cmake | 1 - Utilities/Release/release_cmake.cmake | 10 +- Utilities/Release/release_cmake.sh.in | 6 +- Utilities/Release/upload_release.cmake | 11 +- Utilities/Release/v20n250_aix_release.cmake | 1 - Utilities/cmcurl/CMakeLists.txt | 8 +- Utilities/cmcurl/easy.c | 2 +- Utilities/cmcurl/setup.h | 2 +- Utilities/cmlibarchive/CMakeLists.txt | 2 +- bootstrap | 4 +- 319 files changed, 8817 insertions(+), 2998 deletions(-) create mode 100644 Modules/CPackBundle.cmake create mode 100644 Modules/CPackComponent.cmake create mode 100644 Modules/CPackNSIS.cmake create mode 100644 Modules/CheckPrototypeDefinition.c.in create mode 100644 Modules/CheckPrototypeDefinition.cmake create mode 100644 Modules/Compiler/Absoft-Fortran.cmake create mode 100644 Modules/Compiler/GNU-ASM.cmake create mode 100644 Modules/Compiler/HP-ASM.cmake create mode 100644 Modules/Compiler/Intel-ASM.cmake create mode 100644 Modules/Compiler/SunPro-ASM.cmake create mode 100644 Modules/Compiler/XL-ASM.cmake create mode 100644 Modules/Compiler/XL.cmake create mode 100644 Modules/FindArmadillo.cmake create mode 100644 Modules/GNUInstallDirs.cmake create mode 100644 Modules/Platform/AIX-XL-ASM.cmake create mode 100644 Modules/Platform/AIX-XL.cmake create mode 100644 Modules/Platform/Darwin-Absoft-Fortran.cmake create mode 100644 Modules/Platform/HP-UX-HP-ASM.cmake create mode 100644 Modules/Platform/HP-UX-HP-C.cmake create mode 100644 Modules/Platform/HP-UX-HP-CXX.cmake create mode 100644 Modules/Platform/HP-UX-HP-Fortran.cmake create mode 100644 Modules/Platform/HP-UX-HP.cmake create mode 100644 Modules/Platform/Linux-Absoft-Fortran.cmake create mode 100644 Modules/Platform/Windows-Intel-ASM.cmake create mode 100644 Modules/ProcessorCount.cmake create mode 100644 Source/CTest/cmCTestUploadCommand.cxx create mode 100644 Source/CTest/cmCTestUploadCommand.h create mode 100644 Source/CTest/cmCTestUploadHandler.cxx create mode 100644 Source/CTest/cmCTestUploadHandler.h delete mode 100644 Source/kwsys/CheckCXXSourceRuns.cmake create mode 100644 Tests/BundleUtilities/CMakeLists.txt create mode 100644 Tests/BundleUtilities/bundleutils.cmake create mode 100644 Tests/BundleUtilities/framework.cpp create mode 100644 Tests/BundleUtilities/framework.h create mode 100644 Tests/BundleUtilities/module.cpp create mode 100644 Tests/BundleUtilities/module.h create mode 100644 Tests/BundleUtilities/shared.cpp create mode 100644 Tests/BundleUtilities/shared.h create mode 100644 Tests/BundleUtilities/shared2.cpp create mode 100644 Tests/BundleUtilities/shared2.h create mode 100644 Tests/BundleUtilities/testbundleutils1.cpp create mode 100644 Tests/BundleUtilities/testbundleutils2.cpp create mode 100644 Tests/CFBundleTest/CMakeLists.txt create mode 100644 Tests/CFBundleTest/ExportList_plugin.txt create mode 100644 Tests/CFBundleTest/Info.plist.in create mode 100644 Tests/CFBundleTest/InfoPlist.strings.in create mode 100644 Tests/CFBundleTest/Localized.r create mode 100644 Tests/CFBundleTest/Localized.rsrc create mode 100644 Tests/CFBundleTest/PluginConfig.cmake create mode 100644 Tests/CFBundleTest/README.txt create mode 100644 Tests/CFBundleTest/VerifyResult.cmake create mode 100644 Tests/CFBundleTest/np_macmain.cpp create mode 100644 Tests/CMakeLib/run_compile_commands.cxx create mode 100644 Tests/CMakeTests/FileUploadTest.cmake.in create mode 100644 Tests/CMakeTests/ProcessorCountTest.cmake.in delete mode 100644 Tests/CPackComponentsForAll/MyLibCPackConfig-AllGroupsInOne.cmake.in delete mode 100644 Tests/CTestTest3/test.cmake.in create mode 100644 Tests/CTestTestUpload/CMakeLists.txt create mode 100644 Tests/CTestTestUpload/CTestConfig.cmake create mode 100644 Tests/CTestTestUpload/sleep.c create mode 100644 Tests/CTestTestUpload/test.cmake.in create mode 100644 Tests/CompileCommandOutput/CMakeLists.txt create mode 100644 Tests/CompileCommandOutput/compile_command_output.cxx create mode 100644 Tests/CompileCommandOutput/file with spaces.cxx create mode 100644 Tests/CompileCommandOutput/file_with_underscores.cxx create mode 100644 Tests/CompileCommandOutput/file_with_underscores.h create mode 100644 Tests/CompileCommandOutput/relative.cxx create mode 100644 Tests/CompileCommandOutput/relative.h create mode 100644 Tests/FindPackageTest/SystemPackage/CMakeTestSystemPackageConfig.cmake create mode 100644 Tests/FindPackageTest/lib/arch/Bar/BarConfig.cmake create mode 100644 Tests/FindPackageTest/lib/arch/cmake/zot-4.0/zot-config-version.cmake create mode 100644 Tests/FindPackageTest/lib/arch/cmake/zot-4.0/zot-config.cmake create mode 100644 Tests/FindPackageTest/lib/arch/foo-1.2/CMake/FooConfig.cmake create mode 100644 Tests/FindPackageTest/lib/arch/zot-3.1/zot-config-version.cmake create mode 100644 Tests/FindPackageTest/lib/arch/zot-3.1/zot-config.cmake create mode 100644 Tests/Fortran/world_gnu.def rename Tests/Fortran/{world.def => world_icl.def} (100%) create mode 100644 Tests/IncludeDirectories/CMakeLists.txt create mode 100644 Tests/IncludeDirectories/main.cpp create mode 100644 Tests/LinkStatic/CMakeLists.txt create mode 100644 Tests/LinkStatic/LinkStatic.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 91267cb93..d50bcaee4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ #============================================================================= # CMake - Cross Platform Makefile Generator -# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium +# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -9,12 +9,9 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5 FATAL_ERROR) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR) SET(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required PROJECT(CMake) -IF(COMMAND CMAKE_POLICY) - CMAKE_POLICY(SET CMP0003 NEW) -ENDIF(COMMAND CMAKE_POLICY) IF(CMAKE_BOOTSTRAP) # Running from bootstrap script. Set local variable and remove from cache. @@ -22,20 +19,8 @@ IF(CMAKE_BOOTSTRAP) UNSET(CMAKE_BOOTSTRAP CACHE) ENDIF() -MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY) - -# Allow empty endif() and such with CMake 2.4. -SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS 1) - SET(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin) -IF(NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.4) - # Since the built CMake will install itself instead of the - # generating CMake, tell it that the install rules were generated - # by CMake 2.4. - INSTALL(CODE "SET(CMAKE_INSTALL_SELF_2_4 1)") -ENDIF() - IF("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") # Disallow architecture-specific try_run. It may not run on the host. MACRO(TRY_RUN) @@ -340,6 +325,7 @@ MACRO (CMAKE_BUILD_UTILITIES) IF(NOT LibArchive_FOUND) MESSAGE(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!") ENDIF() + SET(CMAKE_TAR_INCLUDES ${LibArchive_INCLUDE_DIRS}) SET(CMAKE_TAR_LIBRARIES ${LibArchive_LIBRARIES}) ELSE(CMAKE_USE_SYSTEM_LIBARCHIVE) SET(HAVE_LIBZ 1) @@ -430,9 +416,9 @@ ENDIF() # The CMake version number. SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 8) -SET(CMake_VERSION_PATCH 4) +SET(CMake_VERSION_PATCH 5) SET(CMake_VERSION_TWEAK 0) -#SET(CMake_VERSION_RC 2) +SET(CMake_VERSION_RC 2) # Releases define a tweak level. IF(DEFINED CMake_VERSION_TWEAK) diff --git a/ChangeLog.manual b/ChangeLog.manual index 20998a3a1..f642734b2 100644 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,3 +1,393 @@ +Changes in CMake 2.8.5-rc2 (since 2.8.5-rc1) +-------------------------------------------- +Bill Hoffman (6): + Fix a memory leak. + Fix for bug#10798. VS10 did not append -I flags with COMPILE_FLAGS prop. + Append and do not clobber CMAKE_CXX_FLAGS in the test. + Use bin tree for inclues to avoid -I with spaces in the path. + One more try. Use full path by default, and relative on broken compilers. + Fix for bug #11927, external project git clone step always runs vs10. + +Brad King (9): + XL: Place Fortran modules with -qmoddir= flag (#12246) + Teach file(DOWNLOAD|UPLOAD) to timeout after inactivity + Xcode: Fix parallel build depends with universal binaries (#11844) + Fix style errors added by parent and grandparent + Use cascading-if for per-config test and install code + CTest: Report tests not run due to unknown configuration + GNU: Fix CMAKE_INCLUDE_SYSTEM_FLAG_ value (#12258) + Teach find_(library|package) about Linux multiarch (#12037) + Test find_package multiarch support (#12037) + +Clinton Stimpson (11): + BundleUtilities: Work w/ non .app exes on Mac (#12034) + BundleUtilities: Fix regex to extract dependents from ldd (#12034) + BundleUtilities: Fix test when using xcode (#12034) + BundleUtilities: Fix issues with custom target DEPENDS in test (#12034) + BundleUtilities: Disable running test on Windows unless using MSVC. + BundleUtilities: Run test on Windows if either MSVC or dumpbin was found. + BundleUtilities: Print reason for not loading module.so + BundleUtilities: Add rpath to loadable modules in test. + Revert "BundleUtilities: Run test on Windows if either MSVC or dumpbin was found." + Qt4: complete module dependencies in UseQt4.cmake + Add imported targets support for frameworks on Mac. + +Daniel R. Gomez (1): + Fix plugin API for gcc 2.9-aix51-020209 (#12233) + +David Cole (3): + BundleUtilities: Avoid a cryptic and unhelpful error message + BundleUtilities: Avoid test on Watcom dashboards (#12034) + CMake: eliminate use of cvs in the Release scripts + +Eric NOULARD (2): + CPackRPM: Enhance documentation + Add some more Specs file tag handling. + +Johan Björk (3): + CMake: Move tokenize to cmSystemTools + Xcode: Support multiple level nesting of XCode folders (#10039) + XCode: Support target folders on XCode. + +Modestas Vainius (1): + multiarch: Set CMAKE_LIBRARY_ARCHITECTURE_REGEX for Linux|Hurd|kFreeBSD + +Philip Lowman (3): + FindProtobuf: Better MSVC support, Searching for protobuf lite + Fix , to - in Copyright message so it passes CMake.ModuleNotices test + 10997: PROTOBUF_GENERATE_CPP now supports proto files outside current dir + +Rolf Eike Beer (1): + CMake: Update documentation of STRING(SUBSTRING) for length -1 (#10740) + +Sean McBride (1): + Fix XCode -> Xcode typos, notably in man page (#12231) + +Tim Gallagher (1): + Modified the FindHDF5.cmake file to locate the Fortran bindings. + +Will Dicharry (7): + HDF5 high level library is a find COMPONENT now. + Add logic for CMake built HDF5 install. + Use CMAKE_CURRENT_LIST_DIR to locate FindPackageHandleStandardArgs. + Use HDF5_FOUND to control autoconf and CMake built FindHDF5. + Fix for bug 11752, mixed debug and release libraries. + FindHDF5 ensures good link lines when libraries are duplicated. + Remove unnecessary mark_as_advanced from FindHDF5. + +Zach Mullen (3): + Dynamic analysis test output should not be compressed. + We will actually compress memcheck output if the server supports it. + Fix type conversion warning + +Changes in CMake 2.8.5-rc1 (since 2.8.4) +---------------------------------------- +Alex Neundorf (33): + Rework the way assembler is handled, use the C/CXX compiler by default + Make it possible to exlude external libs from dot files + GRAPHVIZ_IGNORE_TARGETS is now a list of regular expressions + Also generate dependers-graphviz files. + Fix XML escaping for the project() name in Eclipse projects (#11658) + Fix XML escaping for target names in Eclipse project files (#11658) + Add XML escaping for directory name in Eclipse projects (#11658) + Eclipse projects: created one linked resource for each subproject + Also add the SOURCES from add_custom_target() to CodeBlocks projects (#11736) + Add ASM support for the Intel compiler + Actually use CMAKE_ASM_COMPILER for asm, instead of CMAKE_C_COMPILER + Add support for ASM for the SunPro compiler + Add suport for ASM for the IBM XL compiler + Add support for ASm for the HP compiler. + Set the HP asm file suffix + Change the default rules so they fit better to the new ASM handling + Fix the default CMAKE_ASM_COMPILE_OBJECT, make XL-ASM use it + Add assemble- and preprocess commands for HP + The Assembler test now tests ASM for GNU, Intel, HP, XL and SunPro + Use a regexp instead a lot of ORs for checking the compiler ID + Only try assembler support for Makefile-based generators + Fix bad comparison in the detect assembler-code + It's ELSEIF(), not ELSIF() + Add temporary debug output for compiler ID detection for ASM + Add more regex for gcc, always print the ASM compiler ID + Add support for the Intel compiler used for ASM under Windows + -use CMAKE_C_FLAGS when generating the assembler file + -only enable the asm test for the Intel compiler if we are under UNIX + Remove trailing whitespace + Make use_mangled_mesa() available in cmake script mode (#11926) + Fix parsing include dirs and builtin macros for CXX-only projects + Don't skip the last builtin include dir for the Eclipse project file + -fix VirtualFolders in Eclipse under Windows + +Alexey Ozeritsky (1): + ACML search improvement + +Andreas Schneider (6): + Modules: Added CheckPrototypeDefinition module. + Tests: Added test for check_prototype_definition. + FindOpenSSL: Added support for pkg-config. + FindOpenSSL: We should only use hints to find OpenSSL. + FindOpenSSL: Fixed crypto und ssl variable names. + FindOpenSSL: Use find_package_handle_standard_args for version check. + +Bill Hoffman (2): + With very long file names, VS 2010 was unable to compile files. + Fix for bug where VS2010 did not use .obj files as part of the build. + +Brad King (94): + Reject directory names containing '=' (#11689) + FindQt4: Include builtin FindPackageHandleStandardArgs directly + Handle trailing slashes on add_custom_command DEPENDS + Handle relative WORKING_DIRECTORY in add_custom_(command|target) + Pass -o after -c for Fortran to avoid mpif77 ordering bug + Add link flag table entries for VS 7,8,9 + VS: Create a Fortran DLL's import library directory + Fix linker flag initialization from LDFLAGS (#11840) + ccmake: Remove extra parens around comparison + Avoid direct use of std::stringstream + Honor module .def files with MinGW tools (#9997) + CTest: Update Git submodules with --recursive + libarchive: Remove unused build/windows directory (#11885) + Pass .def files directly to MinGW tools (#9997) + Fix Fortran test .def file symbol mangling + Require at least CMake 2.6.3 to build current CMake + GNUInstallDirs: Simplify and clarify documentation + KWSys: Require at least CMake 2.6.3 + Remove unused CMAKE_BACKWARDS_COMPATIBILITY mark + Factor AIX and XL compiler flags into common module + Move RPATH flags to AIX per-compiler information files + Initialize ASM rpath flags for executables with those for shared libs + Add ASM platform information for XL compiler on AIX + Factor HP compiler flags into per-platform/per-compiler files + Add ASM platform information for HP compiler on HP + Add target property LINK_SEARCH_START_STATIC to aid static linking + Test static linking with LINK_SEARCH_START_STATIC + Fix Assembler test to parse C flags string before using + Teach Assembler test to generate main.s at build time + Do not bother enabling C++ in Assembler test + The link interface of MODULE libraries is empty (#11945) + CTest: Do not fail with submodules and Git < 1.6.5.0 + Remove trailing whitespace + Add parens in cmTarget::ComputeLinkInterface logic + Validate custom command arguments (#11963) + Factor old-style -D flags out from -I flag generation + FindMPI: Fix documentation formatting + Generate target-wide flags before individual build rules + Optionally pass include directories with response files + Pass include directories with response files to GNU on Windows + Enable Java test more carefully on Apple + Disable Java test with Xcode generator + Allow '.' in target names in generator expressions (#12002) + GNUInstallDirs: Propagate DATAROOTDIR changes to dependent defaults + KWSys: Do not trust EXECUTABLE_OUTPUT_PATH for ProcessFwd9x encoding + Refine unused cache variable warning + Fix unused cache warning after multiple configure iterations + FortranCInterface: Fix mangling detection with Cray Fortran >= 7.3.2 + Fix typo in include_directories documentation (#12020) + KWSys: Recognize rxvt-unicode-256color terminal (#12013) + Normalize slashes of add_custom_(command|target) DEPENDS (#11973) + COMP: Fix build against non-standard outside libarchive + Modules: Add comment and copyright notice validation to readme.txt + cmArchiveWrite: Clear xattr and acl from entries (#11958) + find_package: Forward component list for recursive calls in modules + XL: Set C++ and Fortran flags consistently with C + XL: Consolidate compiler flag information + XL: Avoid copying archives into shared libraries that link them + VS10: Fix working directory of consecutive custom commands (#11938) + Fix working drive of make rules on Windows + Change working drive only in MinGW Makefiles + VS: Use setlocal/endlocal only in VS 10 custom commands + VS10: Fix exit code of custom commands with setlocal/endlocal (#11938) + KWSys: Remove unused CheckCXXSourceRuns cmake module + find_package: Rename implementation of user package registry + find_package: Cleanup user package registry less aggressively + find_package: Document user package registry locations + find_package: Search a "system package registry" + find_package: Check both 32-bit and 64-bit registry views + find_package: Test system package registry when possible + find_package: Fix system package registry test path conversion + FindITK: Use passthru find_package config mode for messages + OpenBSD: Use 'arch -s' for host processor (#12143) + Fix case typo in CMAKE_BUILD_TYPE docs (#12148) + KWSys: Fix leaked FILE in EncodeExecutable error case + ENH: Fix Intel 12 plugin project generation for VS < 10 + Revert "Honor RULE_MESSAGES property for build target messages" (#12190) + Fix signed/unsigned comparison in EscapeJSON + Fix run_compile_commands build on Apple GCC 3.3 + Make std::map usage more portable in language=>flags/defines maps + Provide std::map<>::at for use in run_compile_commands + run_compile_commands: Avoid shadow in std::map<>::at workaround + Improve string(RANDOM) default seed + run_compile_commands: Avoid extra stl vector conversion + VS 6: Define _WIN32_WINNT to load wincrypt.h correctly + run_compile_commands: Cast istream::get() result to char + Fix CompileCommandOutput test for Make tools not supporting spaces + Explicitly cast time value in cmSystemTools::RandomSeed + Fix CompileCommandOutput test build on Windows + Add Absoft Fortran compiler id and basic flags + Absoft: Detect implicit link libraries on Linux and Mac + Absoft: Enable FortranCInterface check in Fortran test + Document status of output_required_files command (#12214) + Fix forced-seed argument type in string(RANDOM) + +Clement Creusot (2): + Add new module Armadillo + Corrected copyright format in FindArmadillo.cmake + +Clinton Stimpson (8): + Change to use fphsa to check required variables and version. + Fix grouping bug where "Ungrouped Entries" showed up as a child. + When checking find_package() components, special case qtmain. + Fix issues with find_path() for QtCore include dir on Mac. Fixes 11868. + Fix regression in 43cb9b8. + Speed up creation of parameters file for moc custom command. + Combine component packaging methods into an enum. + Add component support to DragNDrop generator. + +David Cole (34): + ExternalProject Test: Increase test timeout value + CFBundle Test: Add PATHS for finding Rez (#11295) + CTest: Mark DART_TESTING_TIMEOUT as advanced (#10150) + Xcode: Allow override of CMAKE_CONFIGURATION_TYPES (#8914) + Tests: Eliminate unnecessary files and variables. + VS9: Map enable/disable PREfast flags (#10638) + Strip trailing space from xcode-select output (#10723) + CTest: Add alias for make test target (#4564) + Add CMAKE_SCRIPT_MODE_FILE variable (#2828) + Add CMAKE_ARGC and CMAKE_ARGV0..N-1 variables (#2828) + Fix KWStyle line-too-long complaint (#2828) + Documentation: Sync two differing copies of -E docs (#10446) + Clarify list subcommand documentation (#8154) + VS2010: Fixed GenerateManifest flag (#10704) + VS: Only use /MANIFEST if hasManifest is true (#11216) + Make file DOWNLOAD less noisy (#11761) + Begin post-2.8.4 development + Use stable_sort to preserve test order (#11877) + Implement file(UPLOAD (#11286) + Fix KWStyle line too long error (#11286) + ExternalProject: Extract file names from more urls + InstallRequiredSystemLibraries: Read reg values with get_filename_component + Add correct module notice header. + If getconf returns empty output, try cpuinfo. (#11302) + Add ProcessorCount support for QNX via pidin. (#11302) + Compare ProcessorCount to SystemInformation count. (#11302) + ProcessorCount test: more output, do not fail. (#11302) + ProcessorCount: Add support for remaining platforms (#11302) + ProcessorCount: Test fails if count is 0 (#11302) + ProcessorCount: Use ERROR_QUIET with execute_process (#11302) + ExternalProject: Add SVN_TRUST_CERT argument + CMake: Clarify the --debug-trycompile help text + ExternalProject: Always use --non-interactive with svn + VS10: Write header-only files in correct xml element (#11925) + +Eric NOULARD (25): + CPackRPM honors all the different ways of packaging components + CPackRPM fix IRIX compiler warning (variable never used) + CPack remove "-ALL" suffix for ALL-IN-ONE packages + CPack Authorize DISPLAY_NAME usage in component package + CPack fix KWStyle warning + CPack remove previously CPack generated files (if any) before running CPack + CPackRPM Replace space in some CPACK_ vars (Fix bug 9932) + CPackRPM activate CPackRPM test on Linux systems where rpmbuild is found + CPackArchive package all components specified in CPACK_COMPONENTS_ALL + CPack more robust way to collect files belonging to a component + CPackRPM do not run test if build dir contains space + CPack fix compile error on VS70 and avoid KWStyle warnings + CPackRPM add more trace output in order to help failing diagnostics + CPackRPM even more trace in debug mode or in case of failure + CPackRPM non matching ENDIF + CPack try to please SUSE 64 bits and install lib in lib64 and not lib. + Remove debbuging typo + CPack fix CPackDeb crash when CPackDeb.cmake ends with a FATAL_ERROR + CPack fix #11930 and simplifies component packaging options + Fix #11964 Handle lib64 library on Linux + Fix KWStyle warnings + Split CPack.cmake in more manageable parts + Fix KWStyle warnings + CPackRPM Fix #12096: handle absolute install path with component install + CPack make RPM work on AIX. fix #0012183 merge patch from Pasi Valminen + +James Bigler (1): + Add FloatingPointModel to the list of known VS7 generator flags. + +Johan Björk (1): + XCode: Also qoute [] as needed to set build-configurations. + +Kovarththanan Rajaratnam (1): + Documentation: document platform specific -E commands (#10446) + +M. Konrad (1): + CPackDeb add Component Support to DEB generator fix #0011655 + +Manuel Klimek (6): + refactor flags and defines + cache flags and defines + implement cxx command output + make compile command output optional + Adds a test for the compile command line output. + Only offer the compile command output feature on unix systems + +Marco Craveiro (1): + CTest: Use the gcov --preserve-paths flag (#11717) + +Markus Rathgeb (1): + When cross compiling, don't double-root paths when using find_*. + +Martin Konrad (2): + CPackDeb: Fix #12006 broken package names + CPackDeb: Handle dirs for CONTROL_EXTRA correctly when packaging components + +Mathieu Malaterre (8): + This commit fixes bug #0010316 + Add a new function SWIG_GET_WRAPPER_DEPENDENCIES to UseSWIG.cmake + Add support for Java on HP + Add support for java on fedora + UseSWIG.cmake does not expand $(OutDir) + Add support for new swig 2.0 application + UseSWIG.cmake did not support multiple modules and parallel builds + Add support for FindJava on HP-UX and alpha + +Michael Wild (1): + Add module ProcessorCount.cmake (#11302) + +Modestas Vainius (1): + Documentation: Fix a few typos (#11883) + +Nikita Krupen'ko (1): + Add GNUInstallDirs module to define GNU layout (#3976) + +Philip Lowman (1): + VS7/8/9: Map whole program optimization flags (#10263) + +Richard Bateman (1): + Add support for CFBundle targets on the Mac (#11295) + +Rolf Eike Beer (2): + CTest: catch warning output of Apache Maven + FindZLIB: print library instead of include directory + +Sean McBride (1): + Removed most usage of Carbon in favour of CoreFoundation + +Sebastian Herbst (2): + VS8/9: Add flag map entries for /Zc:wchar_t (#10397) + VS7/8/9: Add flag map for string pooling option (#10397) + +Tim Hütz (1): + Add a string(FIND) sub-command (#11795) + +Todd Gamblin (2): + FindMPI: Handle multiple languages + Added backward compatibility for input as well as output vars. + +Wesley Turner (1): + Ensure executable files have executable permissions. + +Zach Mullen (5): + Implement ctest_upload command + Change 'Files' tag to 'Upload' in Upload.xml + Don't tar/gz ctest_upload() files + Add the FILES keyword to ctest_upload command + cmCTestUploadCommand::CheckArgumentKeyword should return false if not FILES + Changes in CMake 2.8.4 (since 2.8.4-rc2) ---------------------------------------- Alex Neundorf (1): diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index 44f2c202e..0143d593d 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -53,9 +53,8 @@ # # GET_DOTAPP_DIR( ) # Returns the nearest parent dir whose name ends with ".app" given the full -# path to an executable. If there is no such parent dir, then return a dir at -# the same level as the executable, named with the executable's base name and -# ending with ".app" +# path to an executable. If there is no such parent dir, then simply return +# the dir containing the executable. # # The returned directory may or may not exist. # @@ -227,35 +226,35 @@ endfunction(get_bundle_main_executable) function(get_dotapp_dir exe dotapp_dir_var) set(s "${exe}") - set(has_dotapp_parent 0) if(s MATCHES "^.*/.*\\.app/.*$") - set(has_dotapp_parent 1) - endif(s MATCHES "^.*/.*\\.app/.*$") - - set(done 0) - while(NOT ${done}) - get_filename_component(snamewe "${s}" NAME_WE) - get_filename_component(sname "${s}" NAME) - get_filename_component(sdir "${s}" PATH) - if(has_dotapp_parent) - # If there is a ".app" parent directory, - # ascend until we hit it: - # (typical of a Mac bundle executable) - # + # If there is a ".app" parent directory, + # ascend until we hit it: + # (typical of a Mac bundle executable) + # + set(done 0) + while(NOT ${done}) + get_filename_component(snamewe "${s}" NAME_WE) + get_filename_component(sname "${s}" NAME) + get_filename_component(sdir "${s}" PATH) set(s "${sdir}") if(sname MATCHES "\\.app$") set(done 1) set(dotapp_dir "${sdir}/${sname}") endif(sname MATCHES "\\.app$") - else(has_dotapp_parent) - # Otherwise use a directory named the same - # as the exe, but with a ".app" extension: - # (typical of a non-bundle executable on Mac, Windows or Linux) - # - set(done 1) - set(dotapp_dir "${sdir}/${snamewe}.app") - endif(has_dotapp_parent) - endwhile(NOT ${done}) + endwhile(NOT ${done}) + else(s MATCHES "^.*/.*\\.app/.*$") + # Otherwise use a directory containing the exe + # (typical of a non-bundle executable on Mac, Windows or Linux) + # + is_file_executable("${s}" is_executable) + if(is_executable) + get_filename_component(sdir "${s}" PATH) + set(dotapp_dir "${sdir}") + else(is_executable) + set(dotapp_dir "${s}") + endif(is_executable) + endif(s MATCHES "^.*/.*\\.app/.*$") + set(${dotapp_dir_var} "${dotapp_dir}" PARENT_SCOPE) endfunction(get_dotapp_dir) @@ -546,13 +545,25 @@ function(fixup_bundle_item resolved_embedded_item exepath dirs) # get_dotapp_dir("${exepath}" exe_dotapp_dir) string(LENGTH "${exe_dotapp_dir}/" exe_dotapp_dir_length) - string(SUBSTRING "${resolved_embedded_item}" 0 ${exe_dotapp_dir_length} item_substring) - if(NOT "${exe_dotapp_dir}/" STREQUAL "${item_substring}") + string(LENGTH "${resolved_embedded_item}" resolved_embedded_item_length) + set(path_too_short 0) + set(is_embedded 0) + if(${resolved_embedded_item_length} LESS ${exe_dotapp_dir_length}) + set(path_too_short 1) + endif() + if(NOT path_too_short) + string(SUBSTRING "${resolved_embedded_item}" 0 ${exe_dotapp_dir_length} item_substring) + if("${exe_dotapp_dir}/" STREQUAL "${item_substring}") + set(is_embedded 1) + endif() + endif() + if(NOT is_embedded) message(" exe_dotapp_dir/='${exe_dotapp_dir}/'") message(" item_substring='${item_substring}'") message(" resolved_embedded_item='${resolved_embedded_item}'") message("") - message("Install or copy the item into the bundle before calling fixup_bundle") + message("Install or copy the item into the bundle before calling fixup_bundle.") + message("Or maybe there's a typo or incorrect path in one of the args to fixup_bundle?") message("") message(FATAL_ERROR "cannot fixup an item that is not in the bundle...") endif() diff --git a/Modules/CMakeASM-ATTInformation.cmake b/Modules/CMakeASM-ATTInformation.cmake index abf560bb0..cb1f5d69c 100644 --- a/Modules/CMakeASM-ATTInformation.cmake +++ b/Modules/CMakeASM-ATTInformation.cmake @@ -18,5 +18,8 @@ SET(ASM_DIALECT "-ATT") # *.S files are supposed to be preprocessed, so they should not be passed to # assembler but should be processed by gcc SET(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS s;asm) + +SET(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT " -o ") + INCLUDE(CMakeASMInformation) SET(ASM_DIALECT) diff --git a/Modules/CMakeASMCompiler.cmake.in b/Modules/CMakeASMCompiler.cmake.in index 230805bf4..2dc24b06d 100644 --- a/Modules/CMakeASMCompiler.cmake.in +++ b/Modules/CMakeASMCompiler.cmake.in @@ -4,6 +4,7 @@ SET(CMAKE_AR "@CMAKE_AR@") SET(CMAKE_RANLIB "@CMAKE_RANLIB@") SET(CMAKE_LINKER "@CMAKE_LINKER@") SET(CMAKE_ASM@ASM_DIALECT@_COMPILER_LOADED 1) +SET(CMAKE_ASM@ASM_DIALECT@_COMPILER_ID "@_CMAKE_ASM_COMPILER_ID@") SET(CMAKE_ASM@ASM_DIALECT@_COMPILER_ENV_VAR "@_CMAKE_ASM_COMPILER_ENV_VAR@") SET(CMAKE_ASM@ASM_DIALECT@_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake index b94303e8e..d50f351e5 100644 --- a/Modules/CMakeASMInformation.cmake +++ b/Modules/CMakeASMInformation.cmake @@ -12,8 +12,6 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -MESSAGE(STATUS "Loaded CMakeASM${ASM_DIALECT}Information - ASM${ASM_DIALECT} support is still experimental, please report issues") - IF(UNIX) SET(CMAKE_ASM${ASM_DIALECT}_OUTPUT_EXTENSION .o) ELSE(UNIX) @@ -34,6 +32,9 @@ IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) INCLUDE(Compiler/${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) IF(NOT _INCLUDED_FILE) + IF("ASM${ASM_DIALECT}" STREQUAL "ASM") + MESSAGE(FATAL_ERROR "Did not find file Compiler/${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT}") + ENDIF("ASM${ASM_DIALECT}" STREQUAL "ASM") INCLUDE(Platform/${CMAKE_BASE_NAME} OPTIONAL) ENDIF(NOT _INCLUDED_FILE) @@ -89,7 +90,7 @@ MARK_AS_ADVANCED(CMAKE_ASM${ASM_DIALECT}_FLAGS IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT) - SET(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT " -o ") + SET(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT " -o -c ") ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT) IF(NOT CMAKE_ASM${ASM_DIALECT}_CREATE_STATIC_LIBRARY) @@ -100,9 +101,21 @@ ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_CREATE_STATIC_LIBRARY) IF(NOT CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE) SET(CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE - " -o ") + " -o ") ENDIF(NOT CMAKE_ASM${ASM_DIALECT}_LINK_EXECUTABLE) +IF(NOT CMAKE_EXECUTABLE_RUNTIME_ASM${ASM_DIALECT}_FLAG) + SET(CMAKE_EXECUTABLE_RUNTIME_ASM${ASM_DIALECT}_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_ASM${ASM_DIALECT}_FLAG}) +ENDIF() + +IF(NOT CMAKE_EXECUTABLE_RUNTIME_ASM${ASM_DIALECT}_FLAG_SEP) + SET(CMAKE_EXECUTABLE_RUNTIME_ASM${ASM_DIALECT}_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_ASM${ASM_DIALECT}_FLAG_SEP}) +ENDIF() + +IF(NOT CMAKE_EXECUTABLE_RPATH_LINK_ASM${ASM_DIALECT}_FLAG) + SET(CMAKE_EXECUTABLE_RPATH_LINK_ASM${ASM_DIALECT}_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_ASM${ASM_DIALECT}_FLAG}) +ENDIF() + # to be done IF(NOT CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_LIBRARY) SET(CMAKE_ASM${ASM_DIALECT}_CREATE_SHARED_LIBRARY) diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 051df4cc7..04a5cec6d 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -28,6 +28,7 @@ SET(CMAKE_C_LINKER_PREFERENCE 10) # Save compiler ABI information. SET(CMAKE_C_SIZEOF_DATA_PTR "@CMAKE_C_SIZEOF_DATA_PTR@") SET(CMAKE_C_COMPILER_ABI "@CMAKE_C_COMPILER_ABI@") +SET(CMAKE_C_LIBRARY_ARCHITECTURE "@CMAKE_C_LIBRARY_ARCHITECTURE@") IF(CMAKE_C_SIZEOF_DATA_PTR) SET(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}") @@ -37,6 +38,10 @@ IF(CMAKE_C_COMPILER_ABI) SET(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}") ENDIF(CMAKE_C_COMPILER_ABI) +IF(CMAKE_C_LIBRARY_ARCHITECTURE) + SET(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_C_LIBRARY_ARCHITECTURE@") +ENDIF() + SET(CMAKE_C_HAS_ISYSROOT "@CMAKE_C_HAS_ISYSROOT@") @CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG_CODE@ diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index d7ae8d994..ea06526cc 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -29,6 +29,7 @@ SET(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1) # Save compiler ABI information. SET(CMAKE_CXX_SIZEOF_DATA_PTR "@CMAKE_CXX_SIZEOF_DATA_PTR@") SET(CMAKE_CXX_COMPILER_ABI "@CMAKE_CXX_COMPILER_ABI@") +SET(CMAKE_CXX_LIBRARY_ARCHITECTURE "@CMAKE_CXX_LIBRARY_ARCHITECTURE@") IF(CMAKE_CXX_SIZEOF_DATA_PTR) SET(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}") @@ -38,6 +39,10 @@ IF(CMAKE_CXX_COMPILER_ABI) SET(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}") ENDIF(CMAKE_CXX_COMPILER_ABI) +IF(CMAKE_CXX_LIBRARY_ARCHITECTURE) + SET(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_CXX_LIBRARY_ARCHITECTURE@") +ENDIF() + SET(CMAKE_CXX_HAS_ISYSROOT "@CMAKE_CXX_HAS_ISYSROOT@") @CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG_CODE@ diff --git a/Modules/CMakeCommonLanguageInclude.cmake b/Modules/CMakeCommonLanguageInclude.cmake index 237f8ddec..a2929f1ea 100644 --- a/Modules/CMakeCommonLanguageInclude.cmake +++ b/Modules/CMakeCommonLanguageInclude.cmake @@ -16,7 +16,7 @@ # cache values that can be initialized in the platform-compiler.cmake file # it may be included by more than one language. -SET (CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS_INIT} $ENV{LDFLAGS} +SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}" CACHE STRING "Flags used by the linker.") @@ -70,11 +70,11 @@ IF(NOT CMAKE_NOT_USING_CONFIG_FLAGS) ENDIF(NOT CMAKE_NOT_USING_CONFIG_FLAGS) # shared linker flags -SET (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS} +SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS}" CACHE STRING "Flags used by the linker during the creation of dll's.") # module linker flags -SET (CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS} +SET (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}" CACHE STRING "Flags used by the linker during the creation of modules.") SET(CMAKE_BUILD_TOOL ${CMAKE_MAKE_PROGRAM} CACHE INTERNAL diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index d6350bfda..171e31f92 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -21,11 +21,37 @@ IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER) ENDIF($ENV{ASM${ASM_DIALECT}} MATCHES ".+") # finally list compilers to try - IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT) - SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT}) - ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT) - SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}as ${_CMAKE_TOOLCHAIN_PREFIX}gas) - ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT) + IF("ASM${ASM_DIALECT}" STREQUAL "ASM") # the generic assembler support + + IF(CMAKE_ASM_COMPILER_INIT) + SET(CMAKE_ASM_COMPILER_LIST ${CMAKE_ASM_COMPILER_INIT}) + ELSE(CMAKE_ASM_COMPILER_INIT) + + IF(CMAKE_C_COMPILER) + SET(CMAKE_ASM_COMPILER "${CMAKE_C_COMPILER}" CACHE FILEPATH "The ASM compiler") + SET(CMAKE_ASM_COMPILER_ID "${CMAKE_C_COMPILER_ID}") + ELSEIF(CMAKE_CXX_COMPILER) + SET(CMAKE_ASM_COMPILER "${CMAKE_CXX_COMPILER}" CACHE FILEPATH "The ASM compiler") + SET(CMAKE_ASM_COMPILER_ID "${CMAKE_CXX_COMPILER_ID}") + ELSE(CMAKE_CXX_COMPILER) + # List all default C and CXX compilers + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}gcc ${_CMAKE_TOOLCHAIN_PREFIX}cc cl bcc xlc + ${_CMAKE_TOOLCHAIN_PREFIX}c++ ${_CMAKE_TOOLCHAIN_PREFIX}g++ CC aCC cl bcc xlC) + ENDIF(CMAKE_C_COMPILER) + + ENDIF(CMAKE_ASM_COMPILER_INIT) + + + ELSE("ASM${ASM_DIALECT}" STREQUAL "ASM") # some specific assembler "dialect" + + IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT) + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_LIST ${CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT}) + ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT) + MESSAGE(FATAL_ERROR "CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT must be preset !") + ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT) + + ENDIF("ASM${ASM_DIALECT}" STREQUAL "ASM") + # Find the compiler. IF (_CMAKE_USER_CXX_COMPILER_PATH OR _CMAKE_USER_C_COMPILER_PATH) @@ -63,7 +89,24 @@ IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) # Table of per-vendor compiler id flags with expected output. LIST(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS GNU ) SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_GNU "--version") - SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_GNU "GNU assembler") + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_GNU "(GNU assembler)|(GCC)|(Free Software Foundation)") + + LIST(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS HP ) + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_HP "-V") + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_HP "HP C") + + LIST(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS Intel ) + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_Intel "--version") + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_Intel "(ICC)") + + LIST(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS SunPro ) + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_SunPro "-V") + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_SunPro "Sun C") + + LIST(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS XL ) + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_XL "-qversion") + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_XL "XL C") + LIST(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS TI_DSP ) SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_TI_DSP "-h") SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_TI_DSP "Texas Instruments") @@ -71,14 +114,15 @@ IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) INCLUDE(CMakeDetermineCompilerId) CMAKE_DETERMINE_COMPILER_ID_VENDOR(ASM${ASM_DIALECT}) - IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) - MESSAGE(STATUS "The ASM${ASM_DIALECT} compiler identification is ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}") - ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) - MESSAGE(STATUS "The ASM${ASM_DIALECT} compiler identification is unknown") - ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) - ENDIF() +IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + MESSAGE(STATUS "The ASM${ASM_DIALECT} compiler identification is ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}") +ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + MESSAGE(STATUS "The ASM${ASM_DIALECT} compiler identification is unknown") +ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + + # If we have a gas/as cross compiler, they have usually some prefix, like # e.g. powerpc-linux-gas, arm-elf-gas or i586-mingw32msvc-gas , optionally @@ -90,10 +134,25 @@ ENDIF() IF (NOT _CMAKE_TOOLCHAIN_PREFIX) GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" NAME) IF (COMPILER_BASENAME MATCHES "^(.+-)g?as(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") - STRING(REGEX REPLACE "^(.+-)g?as(\\.exe)?$" "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}") + SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?as(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX) +# Now try the C compiler regexp: +IF (NOT _CMAKE_TOOLCHAIN_PREFIX) + IF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") + SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") +ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX) + +# Finally try the CXX compiler regexp: +IF (NOT _CMAKE_TOOLCHAIN_PREFIX) + IF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") + SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + ENDIF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") +ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX) + + INCLUDE(CMakeFindBinUtils) SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR "ASM${ASM_DIALECT}") @@ -106,6 +165,7 @@ ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER) SET(_CMAKE_ASM_COMPILER "${CMAKE_ASM${ASM_DIALECT}_COMPILER}") +SET(_CMAKE_ASM_COMPILER_ID "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}") SET(_CMAKE_ASM_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1}") SET(_CMAKE_ASM_COMPILER_ENV_VAR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR}") diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 7f918e6df..39d1f17b7 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -86,6 +86,17 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src) SET(CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES "${implicit_libs}" PARENT_SCOPE) SET(CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES "${implicit_dirs}" PARENT_SCOPE) + # Detect library architecture directory name. + IF(CMAKE_LIBRARY_ARCHITECTURE_REGEX) + FOREACH(dir ${implicit_dirs}) + IF("${dir}" MATCHES "/lib/${CMAKE_LIBRARY_ARCHITECTURE_REGEX}$") + GET_FILENAME_COMPONENT(arch "${dir}" NAME) + SET(CMAKE_${lang}_LIBRARY_ARCHITECTURE "${arch}" PARENT_SCOPE) + BREAK() + ENDIF() + ENDFOREACH() + ENDIF() + ELSE(CMAKE_DETERMINE_${lang}_ABI_COMPILED) MESSAGE(STATUS "Detecting ${lang} compiler ABI info - failed") FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 9a3884af9..b160dee62 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -287,6 +287,13 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang) RESULT_VARIABLE result TIMEOUT 10 ) + + IF("${lang}" STREQUAL "ASM") + MESSAGE(STATUS "Checked for ${vendor}") + MESSAGE(STATUS " Output: -${output}-") + MESSAGE(STATUS " Result: -${result}-") + ENDIF("${lang}" STREQUAL "ASM") + IF("${output}" MATCHES "${regex}") FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" " diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 53558866f..ed4e98335 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -64,7 +64,7 @@ IF(NOT CMAKE_Fortran_COMPILER) # then 77 or older compilers, gnu is always last in the group, # so if you paid for a compiler it is picked by default. SET(CMAKE_Fortran_COMPILER_LIST - ifort ifc efc f95 pathf2003 pathf95 pgf95 lf95 xlf95 fort + ifort ifc af95 af90 efc f95 pathf2003 pathf95 pgf95 lf95 xlf95 fort gfortran gfortran-4 g95 f90 pathf90 pgf90 xlf90 epcf90 fort77 frt pgf77 xlf fl32 af77 g77 f77 ) @@ -72,6 +72,7 @@ IF(NOT CMAKE_Fortran_COMPILER) # Vendor-specific compiler names. SET(_Fortran_COMPILER_NAMES_GNU gfortran gfortran-4 g95 g77) SET(_Fortran_COMPILER_NAMES_Intel ifort ifc efc) + SET(_Fortran_COMPILER_NAMES_Absoft af95 af90 af77) SET(_Fortran_COMPILER_NAMES_PGI pgf95 pgf90 pgf77) SET(_Fortran_COMPILER_NAMES_PathScale pathf2003 pathf95 pathf90) SET(_Fortran_COMPILER_NAMES_XL xlf) diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index 0e65bceae..7ae377517 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -50,14 +50,17 @@ IF(CMAKE_HOST_UNIX) IF(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*") EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) - ELSE(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*") + ELSEIF(CMAKE_HOST_SYSTEM_NAME MATCHES "OpenBSD") + EXEC_PROGRAM(arch ARGS -s OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR + RETURN_VALUE val) + ELSE() EXEC_PROGRAM(uname ARGS -p OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) IF("${val}" GREATER 0) EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) ENDIF("${val}" GREATER 0) - ENDIF(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*") + ENDIF() # check the return of the last uname -m or -p IF("${val}" GREATER 0) SET(CMAKE_HOST_SYSTEM_PROCESSOR "unknown") diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake index fbcdc9841..a756e6454 100644 --- a/Modules/CMakeFindEclipseCDT4.cmake +++ b/Modules/CMakeFindEclipseCDT4.cmake @@ -32,14 +32,20 @@ MACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines SET(${_resultIncludeDirs}) SET(_gccOutput) FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy" "\n" ) - EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -v -E -x ${_lang} -dD dummy + + IF (${_lang} STREQUAL "c++") + SET(_compilerExecutable "${CMAKE_CXX_COMPILER}") + ELSE (${_lang} STREQUAL "c++") + SET(_compilerExecutable "${CMAKE_C_COMPILER}") + ENDIF (${_lang} STREQUAL "c++") + EXECUTE_PROCESS(COMMAND ${_compilerExecutable} -v -E -x ${_lang} -dD dummy WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles ERROR_VARIABLE _gccOutput OUTPUT_VARIABLE _gccStdout ) FILE(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy") # First find the system include dirs: - IF( "${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+) *\n *End of (search) list" ) + IF( "${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+ *\n) *End of (search) list" ) # split the output into lines and then remove leading and trailing spaces from each of them: STRING(REGEX MATCHALL "[^\n]+\n" _includeLines "${CMAKE_MATCH_1}") @@ -48,7 +54,7 @@ MACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines LIST(APPEND ${_resultIncludeDirs} "${_includePath}") ENDFOREACH(nextLine) - ENDIF( "${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+) *\n *End of (search) list" ) + ENDIF( "${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+ *\n) *End of (search) list" ) # now find the builtin macros: diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index 146a6f2c2..53d95525f 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -34,6 +34,7 @@ ENDIF(UNIX) # Save compiler ABI information. SET(CMAKE_Fortran_SIZEOF_DATA_PTR "@CMAKE_Fortran_SIZEOF_DATA_PTR@") SET(CMAKE_Fortran_COMPILER_ABI "@CMAKE_Fortran_COMPILER_ABI@") +SET(CMAKE_Fortran_LIBRARY_ARCHITECTURE "@CMAKE_Fortran_LIBRARY_ARCHITECTURE@") IF(CMAKE_Fortran_SIZEOF_DATA_PTR AND NOT CMAKE_SIZEOF_VOID_P) SET(CMAKE_SIZEOF_VOID_P "${CMAKE_Fortran_SIZEOF_DATA_PTR}") @@ -43,5 +44,9 @@ IF(CMAKE_Fortran_COMPILER_ABI) SET(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_Fortran_COMPILER_ABI}") ENDIF(CMAKE_Fortran_COMPILER_ABI) +IF(CMAKE_Fortran_LIBRARY_ARCHITECTURE) + SET(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_Fortran_LIBRARY_ARCHITECTURE@") +ENDIF() + SET(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "@CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES@") SET(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES "@CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES@") diff --git a/Modules/CMakeFortranCompilerId.F.in b/Modules/CMakeFortranCompilerId.F.in index 858473149..4d25de0ba 100644 --- a/Modules/CMakeFortranCompilerId.F.in +++ b/Modules/CMakeFortranCompilerId.F.in @@ -12,6 +12,8 @@ PRINT *, 'INFO:compiler[G95]' #elif defined(__PATHSCALE__) PRINT *, 'INFO:compiler[PathScale]' +#elif defined(__ABSOFT__) + PRINT *, 'INFO:compiler[Absoft]' #elif defined(__GNUC__) PRINT *, 'INFO:compiler[GNU]' #elif defined(__IBMC__) diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index 4f033e3be..dc15e556e 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -178,9 +178,10 @@ IF(NOT DEFINED CMAKE_Fortran_ARCHIVE_FINISH) ENDIF() # compile a Fortran file into an object file +# (put -o after -c to workaround bug in at least one mpif77 wrapper) IF(NOT CMAKE_Fortran_COMPILE_OBJECT) SET(CMAKE_Fortran_COMPILE_OBJECT - " -o -c ") + " -c -o ") ENDIF(NOT CMAKE_Fortran_COMPILE_OBJECT) # link a fortran program diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index b5d30724a..6615849b2 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -50,6 +50,12 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles") IF(DEFINED CMAKE_RULE_MESSAGES) SET_PROPERTY(GLOBAL PROPERTY RULE_MESSAGES ${CMAKE_RULE_MESSAGES}) ENDIF(DEFINED CMAKE_RULE_MESSAGES) + IF(CMAKE_GENERATOR MATCHES "Unix Makefiles") + SET(CMAKE_EXPORT_COMPILE_COMMANDS OFF CACHE BOOL + "Enable/Disable output of compile commands during generation." + ) + MARK_AS_ADVANCED(CMAKE_EXPORT_COMPILE_COMMANDS) + ENDIF(CMAKE_GENERATOR MATCHES "Unix Makefiles") ENDIF(CMAKE_GENERATOR MATCHES "Makefiles") diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake index 5405bda58..ecb20dc6b 100644 --- a/Modules/CMakeParseImplicitLinkInfo.cmake +++ b/Modules/CMakeParseImplicitLinkInfo.cmake @@ -29,11 +29,13 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var log_var obj_regex) # Construct a regex to match linker lines. It must match both the # whole line and just the command (argv[0]). set(linker_regex "^( *|.*[/\\])(${linker}|ld|collect2)[^/\\]*( |$)") + set(linker_exclude_regex "collect2 version ") set(log "${log} link line regex: [${linker_regex}]\n") string(REGEX REPLACE "\r?\n" ";" output_lines "${text}") foreach(line IN LISTS output_lines) set(cmd) - if("${line}" MATCHES "${linker_regex}") + if("${line}" MATCHES "${linker_regex}" AND + NOT "${line}" MATCHES "${linker_exclude_regex}") if(UNIX) separate_arguments(args UNIX_COMMAND "${line}") else() @@ -64,8 +66,8 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var log_var obj_regex) # Object file full path. list(APPEND implicit_libs_tmp ${arg}) set(log "${log} arg [${arg}] ==> obj [${arg}]\n") - elseif("${arg}" MATCHES "^-Y(P,)?") - # Sun search path. + elseif("${arg}" MATCHES "^-Y(P,)?[^0-9]") + # Sun search path ([^0-9] avoids conflict with Mac -Y). string(REGEX REPLACE "^-Y(P,)?" "" dirs "${arg}") string(REPLACE ":" ";" dirs "${dirs}") list(APPEND implicit_dirs_tmp ${dirs}) diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 797ee5788..bf52b2526 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -11,13 +11,7 @@ # For certain kinds of binary installers (including the graphical # installers on Mac OS X and Windows), CPack generates installers that # allow users to select individual application components to -# install. The contents of each of the components are identified by -# the COMPONENT argument of CMake's INSTALL command. These components -# can be annotated with user-friendly names and descriptions, -# inter-component dependencies, etc., and grouped in various ways to -# customize the resulting installer. See the cpack_add_* commands, -# described below, for more information about component-specific -# installations. +# install. See CPackComponent module for that. # # The CPACK_GENERATOR variable has different meanings in different # contexts. In your CMakeLists.txt file, CPACK_GENERATOR is a @@ -183,93 +177,6 @@ # automatically detected command (or specify its location if the # auto-detection fails to find it.) # -# Installers built on Mac OS X using the Bundle generator use the -# aforementioned DragNDrop variables, plus the following Bundle-specific -# parameters: -# -# CPACK_BUNDLE_NAME - The name of the generated bundle. This -# appears in the OSX finder as the bundle name. Required. -# -# CPACK_BUNDLE_PLIST - Path to an OSX plist file that will be used -# as the Info.plist for the generated bundle. This assumes that -# the caller has generated or specified their own Info.plist file. -# Required. -# -# CPACK_BUNDLE_ICON - Path to an OSX icns file that will be used as -# the icon for the generated bundle. This is the icon that appears -# in the OSX finder for the bundle, and in the OSX dock when the -# bundle is opened. Required. -# -# CPACK_BUNDLE_STARTUP_SCRIPT - Path to an executable or script that -# will be run whenever an end-user double-clicks the generated bundle -# in the OSX Finder. Optional. -# -# The following variables are specific to the graphical installers built -# on Windows using the Nullsoft Installation System. -# -# CPACK_PACKAGE_INSTALL_REGISTRY_KEY - Registry key used when -# installing this project. -# -# CPACK_NSIS_INSTALL_ROOT - The default installation directory presented -# to the end user by the NSIS installer is under this root dir. The full -# directory presented to the end user is: -# ${CPACK_NSIS_INSTALL_ROOT}/${CPACK_PACKAGE_INSTALL_DIRECTORY} -# -# CPACK_NSIS_MUI_ICON - The icon file (.ico) for the generated -# install program. -# -# CPACK_NSIS_MUI_UNIICON - The icon file (.ico) for the generated -# uninstall program. -# -# CPACK_PACKAGE_ICON - A branding image that will be displayed inside -# the installer. -# -# CPACK_NSIS_EXTRA_INSTALL_COMMANDS - Extra NSIS commands that will -# be added to the install Section. -# -# CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS - Extra NSIS commands that will -# be added to the uninstall Section. -# -# CPACK_NSIS_COMPRESSOR - The arguments that will be passed to the -# NSIS SetCompressor command. -# -# CPACK_NSIS_MODIFY_PATH - If this is set to "ON", then an extra page -# will appear in the installer that will allow the user to choose -# whether the program directory should be added to the system PATH -# variable. -# -# CPACK_NSIS_DISPLAY_NAME - The display name string that appears in -# the Windows Add/Remove Program control panel -# -# CPACK_NSIS_PACKAGE_NAME - The title displayed at the top of the -# installer. -# -# CPACK_NSIS_INSTALLED_ICON_NAME - A path to the executable that -# contains the installer icon. -# -# CPACK_NSIS_HELP_LINK - URL to a web site providing assistance in -# installing your application. -# -# CPACK_NSIS_URL_INFO_ABOUT - URL to a web site providing more -# information about your application. -# -# CPACK_NSIS_CONTACT - Contact information for questions and comments -# about the installation process. -# -# CPACK_NSIS_CREATE_ICONS_EXTRA - Additional NSIS commands for -# creating start menu shortcuts. -# -# CPACK_NSIS_DELETE_ICONS_EXTRA -Additional NSIS commands to -# uninstall start menu shortcuts. -# -# CPACK_NSIS_EXECUTABLES_DIRECTORY - Creating NSIS start menu links -# assumes that they are in 'bin' unless this variable is set. -# For example, you would set this to 'exec' if your executables are -# in an exec directory. -# -# CPACK_NSIS_MUI_FINISHPAGE_RUN - Specify an executable to add an option -# to run on the finish page of the NSIS installer. -# # The following variable is specific to installers build on Mac OS X # using PackageMaker: # @@ -310,194 +217,6 @@ # # CPACK_INSTALL_DIRECTORIES - Extra directories to install. # -# Component-specific installation allows users to select specific sets -# of components to install during the install process. Installation -# components are identified by the COMPONENT argument of CMake's -# INSTALL commands, and should be further described by the following -# CPack commands: -# -# cpack_add_component - Describes a CPack installation component -# named by the COMPONENT argument to a CMake INSTALL command. -# -# cpack_add_component(compname -# [DISPLAY_NAME name] -# [DESCRIPTION description] -# [HIDDEN | REQUIRED | DISABLED ] -# [GROUP group] -# [DEPENDS comp1 comp2 ... ] -# [INSTALL_TYPES type1 type2 ... ] -# [DOWNLOADED] -# [ARCHIVE_FILE filename]) -# -# The cmake_add_component command describes an installation -# component, which the user can opt to install or remove as part of -# the graphical installation process. compname is the name of the -# component, as provided to the COMPONENT argument of one or more -# CMake INSTALL commands. -# -# DISPLAY_NAME is the displayed name of the component, used in -# graphical installers to display the component name. This value can -# be any string. -# -# DESCRIPTION is an extended description of the component, used in -# graphical installers to give the user additional information about -# the component. Descriptions can span multiple lines using "\n" as -# the line separator. Typically, these descriptions should be no -# more than a few lines long. -# -# HIDDEN indicates that this component will be hidden in the -# graphical installer, so that the user cannot directly change -# whether it is installed or not. -# -# REQUIRED indicates that this component is required, and therefore -# will always be installed. It will be visible in the graphical -# installer, but it cannot be unselected. (Typically, required -# components are shown greyed out). -# -# DISABLED indicates that this component should be disabled -# (unselected) by default. The user is free to select this component -# for installation, unless it is also HIDDEN. -# -# DEPENDS lists the components on which this component depends. If -# this component is selected, then each of the components listed -# must also be selected. The dependency information is encoded -# within the installer itself, so that users cannot install -# inconsitent sets of components. -# -# GROUP names the component group of which this component is a -# part. If not provided, the component will be a standalone -# component, not part of any component group. Component groups are -# described with the cpack_add_component_group command, detailed -# below. -# -# INSTALL_TYPES lists the installation types of which this component -# is a part. When one of these installations types is selected, this -# component will automatically be selected. Installation types are -# described with the cpack_add_install_type command, detailed below. -# -# DOWNLOADED indicates that this component should be downloaded -# on-the-fly by the installer, rather than packaged in with the -# installer itself. For more information, see the cpack_configure_downloads -# command. -# -# ARCHIVE_FILE provides a name for the archive file created by CPack -# to be used for downloaded components. If not supplied, CPack will -# create a file with some name based on CPACK_PACKAGE_FILE_NAME and -# the name of the component. See cpack_configure_downloads for more -# information. -# -# cpack_add_component_group - Describes a group of related CPack -# installation components. -# -# cpack_add_component_group(groupname -# [DISPLAY_NAME name] -# [DESCRIPTION description] -# [PARENT_GROUP parent] -# [EXPANDED] -# [BOLD_TITLE]) -# -# The cpack_add_component_group describes a group of installation -# components, which will be placed together within the listing of -# options. Typically, component groups allow the user to -# select/deselect all of the components within a single group via a -# single group-level option. Use component groups to reduce the -# complexity of installers with many options. groupname is an -# arbitrary name used to identify the group in the GROUP argument of -# the cpack_add_component command, which is used to place a -# component in a group. The name of the group must not conflict with -# the name of any component. -# -# DISPLAY_NAME is the displayed name of the component group, used in -# graphical installers to display the component group name. This -# value can be any string. -# -# DESCRIPTION is an extended description of the component group, -# used in graphical installers to give the user additional -# information about the components within that group. Descriptions -# can span multiple lines using "\n" as the line -# separator. Typically, these descriptions should be no more than a -# few lines long. -# -# PARENT_GROUP, if supplied, names the parent group of this group. -# Parent groups are used to establish a hierarchy of groups, -# providing an arbitrary hierarchy of groups. -# -# EXPANDED indicates that, by default, the group should show up as -# "expanded", so that the user immediately sees all of the -# components within the group. Otherwise, the group will initially -# show up as a single entry. -# -# BOLD_TITLE indicates that the group title should appear in bold, -# to call the user's attention to the group. -# -# cpack_add_install_type - Add a new installation type containing a -# set of predefined component selections to the graphical installer. -# -# cpack_add_install_type(typename -# [DISPLAY_NAME name]) -# -# The cpack_add_install_type command identifies a set of preselected -# components that represents a common use case for an -# application. For example, a "Developer" install type might include -# an application along with its header and library files, while an -# "End user" install type might just include the application's -# executable. Each component identifies itself with one or more -# install types via the INSTALL_TYPES argument to -# cpack_add_component. -# -# DISPLAY_NAME is the displayed name of the install type, which will -# typically show up in a drop-down box within a graphical -# installer. This value can be any string. -# -# cpack_configure_downloads - Configure CPack to download selected -# components on-the-fly as part of the installation process. -# -# cpack_configure_downloads(site -# [UPLOAD_DIRECTORY dirname] -# [ALL] -# [ADD_REMOVE|NO_ADD_REMOVE]) -# -# The cpack_configure_downloads command configures installation-time -# downloads of selected components. For each downloadable component, -# CPack will create an archive containing the contents of that -# component, which should be uploaded to the given site. When the -# user selects that component for installation, the installer will -# download and extract the component in place. This feature is -# useful for creating small installers that only download the -# requested components, saving bandwidth. Additionally, the -# installers are small enough that they will be installed as part of -# the normal installation process, and the "Change" button in -# Windows Add/Remove Programs control panel will allow one to add or -# remove parts of the application after the original -# installation. On Windows, the downloaded-components functionality -# requires the ZipDLL plug-in for NSIS, available at: -# -# http://nsis.sourceforge.net/ZipDLL_plug-in -# -# On Mac OS X, installers that download components on-the-fly can -# only be built and installed on system using Mac OS X 10.5 or -# later. -# -# The site argument is a URL where the archives for downloadable -# components will reside, e.g., http://www.cmake.org/files/2.6.1/installer/ -# All of the archives produced by CPack should be uploaded to that location. -# -# UPLOAD_DIRECTORY is the local directory where CPack will create the -# various archives for each of the components. The contents of this -# directory should be uploaded to a location accessible by the URL given -# in the site argument. If omitted, CPack will use the directory -# CPackUploads inside the CMake binary directory to store the generated -# archives. -# -# The ALL flag indicates that all components be downloaded. Otherwise, only -# those components explicitly marked as DOWNLOADED or that have a specified -# ARCHIVE_FILE will be downloaded. Additionally, the ALL option implies -# ADD_REMOVE (unless NO_ADD_REMOVE is specified). -# -# ADD_REMOVE indicates that CPack should install a copy of the installer -# that can be called from Windows' Add/Remove Programs dialog (via the -# "Modify" button) to change the set of installed components. NO_ADD_REMOVE -# turns off this behavior. This option is ignored on Mac OS X. #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -512,6 +231,13 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +# Define this var in order to avoid (or warn) concerning multiple inclusion +IF(CPack_CMake_INCLUDED) + MESSAGE(WARNING "CPack.cmake has already been included!!") +ELSE(CPack_CMake_INCLUDED) + SET(CPack_CMake_INCLUDED 1) +ENDIF(CPack_CMake_INCLUDED) + # Pick a configuration file SET(cpack_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in") IF(EXISTS "${CMAKE_SOURCE_DIR}/CPackConfig.cmake.in") @@ -522,214 +248,9 @@ IF(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in") SET(cpack_source_input_file "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in") ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/CPackSourceConfig.cmake.in") -# Argument-parsing macro from http://www.cmake.org/Wiki/CMakeMacroParseArguments -MACRO(cpack_parse_arguments prefix arg_names option_names) - SET(${prefix}_DEFAULT_ARGS) - FOREACH(arg_name ${arg_names}) - SET(${prefix}_${arg_name}) - ENDFOREACH(arg_name) - FOREACH(option ${option_names}) - SET(${prefix}_${option} FALSE) - ENDFOREACH(option) - - SET(current_arg_name DEFAULT_ARGS) - SET(current_arg_list) - FOREACH(arg ${ARGN}) - SET(larg_names ${arg_names}) - LIST(FIND larg_names "${arg}" is_arg_name) - IF (is_arg_name GREATER -1) - SET(${prefix}_${current_arg_name} ${current_arg_list}) - SET(current_arg_name ${arg}) - SET(current_arg_list) - ELSE (is_arg_name GREATER -1) - SET(loption_names ${option_names}) - LIST(FIND loption_names "${arg}" is_option) - IF (is_option GREATER -1) - SET(${prefix}_${arg} TRUE) - ELSE (is_option GREATER -1) - SET(current_arg_list ${current_arg_list} ${arg}) - ENDIF (is_option GREATER -1) - ENDIF (is_arg_name GREATER -1) - ENDFOREACH(arg) - SET(${prefix}_${current_arg_name} ${current_arg_list}) -ENDMACRO(cpack_parse_arguments) - -# Macro that appends a SET command for the given variable name (var) -# to the macro named strvar, but only if the variable named "var" -# has been defined. The string will eventually be appended to a CPack -# configuration file. -MACRO(cpack_append_variable_set_command var strvar) - IF (DEFINED ${var}) - SET(${strvar} "${${strvar}}SET(${var}") - FOREACH(APPENDVAL ${${var}}) - SET(${strvar} "${${strvar}} ${APPENDVAL}") - ENDFOREACH(APPENDVAL) - SET(${strvar} "${${strvar}})\n") - ENDIF (DEFINED ${var}) -ENDMACRO(cpack_append_variable_set_command) - -# Macro that appends a SET command for the given variable name (var) -# to the macro named strvar, but only if the variable named "var" -# has been defined and is a string. The string will eventually be -# appended to a CPack configuration file. -MACRO(cpack_append_string_variable_set_command var strvar) - IF (DEFINED ${var}) - LIST(LENGTH ${var} CPACK_APP_VALUE_LEN) - IF(${CPACK_APP_VALUE_LEN} EQUAL 1) - SET(${strvar} "${${strvar}}SET(${var} \"${${var}}\")\n") - ENDIF(${CPACK_APP_VALUE_LEN} EQUAL 1) - ENDIF (DEFINED ${var}) -ENDMACRO(cpack_append_string_variable_set_command) - -# Macro that appends a SET command for the given variable name (var) -# to the macro named strvar, but only if the variable named "var" -# has been set to true. The string will eventually be -# appended to a CPack configuration file. -MACRO(cpack_append_option_set_command var strvar) - IF (${var}) - LIST(LENGTH ${var} CPACK_APP_VALUE_LEN) - IF(${CPACK_APP_VALUE_LEN} EQUAL 1) - SET(${strvar} "${${strvar}}SET(${var} TRUE)\n") - ENDIF(${CPACK_APP_VALUE_LEN} EQUAL 1) - ENDIF (${var}) -ENDMACRO(cpack_append_option_set_command) - -# Macro that adds a component to the CPack installer -MACRO(cpack_add_component compname) - STRING(TOUPPER ${compname} CPACK_ADDCOMP_UNAME) - cpack_parse_arguments(CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME} - "DISPLAY_NAME;DESCRIPTION;GROUP;DEPENDS;INSTALL_TYPES;ARCHIVE_FILE" - "HIDDEN;REQUIRED;DISABLED;DOWNLOADED" - ${ARGN} - ) - - if (CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DOWNLOADED) - SET(CPACK_ADDCOMP_STR "\n# Configuration for downloaded component \"${compname}\"\n") - else () - SET(CPACK_ADDCOMP_STR "\n# Configuration for component \"${compname}\"\n") - endif () - - IF(NOT CPACK_MONOLITHIC_INSTALL) - # If the user didn't set CPACK_COMPONENTS_ALL explicitly, update the - # value of CPACK_COMPONENTS_ALL in the configuration file. This will - # take care of any components that have been added after the CPack - # moduled was included. - IF(NOT CPACK_COMPONENTS_ALL_SET_BY_USER) - GET_CMAKE_PROPERTY(CPACK_ADDCOMP_COMPONENTS COMPONENTS) - SET(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR}\nSET(CPACK_COMPONENTS_ALL") - FOREACH(COMP ${CPACK_ADDCOMP_COMPONENTS}) - SET(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR} ${COMP}") - ENDFOREACH(COMP) - SET(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR})\n") - ENDIF(NOT CPACK_COMPONENTS_ALL_SET_BY_USER) - ENDIF(NOT CPACK_MONOLITHIC_INSTALL) - - cpack_append_string_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DISPLAY_NAME - CPACK_ADDCOMP_STR) - cpack_append_string_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DESCRIPTION - CPACK_ADDCOMP_STR) - cpack_append_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_GROUP - CPACK_ADDCOMP_STR) - cpack_append_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DEPENDS - CPACK_ADDCOMP_STR) - cpack_append_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_INSTALL_TYPES - CPACK_ADDCOMP_STR) - cpack_append_string_variable_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_ARCHIVE_FILE - CPACK_ADDCOMP_STR) - cpack_append_option_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_HIDDEN - CPACK_ADDCOMP_STR) - cpack_append_option_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_REQUIRED - CPACK_ADDCOMP_STR) - cpack_append_option_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DISABLED - CPACK_ADDCOMP_STR) - cpack_append_option_set_command( - CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DOWNLOADED - CPACK_ADDCOMP_STR) - FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_ADDCOMP_STR}") -ENDMACRO(cpack_add_component) - -# Macro that adds a component group to the CPack installer -MACRO(cpack_add_component_group grpname) - STRING(TOUPPER ${grpname} CPACK_ADDGRP_UNAME) - cpack_parse_arguments(CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME} - "DISPLAY_NAME;DESCRIPTION" - "EXPANDED;BOLD_TITLE" - ${ARGN} - ) - - SET(CPACK_ADDGRP_STR "\n# Configuration for component group \"${grpname}\"\n") - cpack_append_string_variable_set_command( - CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_DISPLAY_NAME - CPACK_ADDGRP_STR) - cpack_append_string_variable_set_command( - CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_DESCRIPTION - CPACK_ADDGRP_STR) - cpack_append_option_set_command( - CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_EXPANDED - CPACK_ADDGRP_STR) - cpack_append_option_set_command( - CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_BOLD_TITLE - CPACK_ADDGRP_STR) - FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_ADDGRP_STR}") -ENDMACRO(cpack_add_component_group) - -# Macro that adds an installation type to the CPack installer -MACRO(cpack_add_install_type insttype) - STRING(TOUPPER ${insttype} CPACK_INSTTYPE_UNAME) - cpack_parse_arguments(CPACK_INSTALL_TYPE_${CPACK_INSTTYPE_UNAME} - "DISPLAY_NAME" - "" - ${ARGN} - ) - - SET(CPACK_INSTTYPE_STR - "\n# Configuration for installation type \"${insttype}\"\n") - SET(CPACK_INSTTYPE_STR - "${CPACK_INSTTYPE_STR}LIST(APPEND CPACK_ALL_INSTALL_TYPES ${insttype})\n") - cpack_append_string_variable_set_command( - CPACK_INSTALL_TYPE_${CPACK_INSTTYPE_UNAME}_DISPLAY_NAME - CPACK_INSTTYPE_STR) - FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_INSTTYPE_STR}") -ENDMACRO(cpack_add_install_type) - -MACRO(cpack_configure_downloads site) - cpack_parse_arguments(CPACK_DOWNLOAD - "UPLOAD_DIRECTORY" - "ALL;ADD_REMOVE;NO_ADD_REMOVE" - ${ARGN} - ) - - SET(CPACK_CONFIG_DL_STR - "\n# Downloaded components configuration\n") - SET(CPACK_UPLOAD_DIRECTORY ${CPACK_DOWNLOAD_UPLOAD_DIRECTORY}) - SET(CPACK_DOWNLOAD_SITE ${site}) - cpack_append_string_variable_set_command( - CPACK_DOWNLOAD_SITE - CPACK_CONFIG_DL_STR) - cpack_append_string_variable_set_command( - CPACK_UPLOAD_DIRECTORY - CPACK_CONFIG_DL_STR) - cpack_append_option_set_command( - CPACK_DOWNLOAD_ALL - CPACK_CONFIG_DL_STR) - IF (${CPACK_DOWNLOAD_ALL} AND NOT ${CPACK_DOWNLOAD_NO_ADD_REMOVE}) - SET(CPACK_DOWNLOAD_ADD_REMOVE ON) - ENDIF (${CPACK_DOWNLOAD_ALL} AND NOT ${CPACK_DOWNLOAD_NO_ADD_REMOVE}) - SET(CPACK_ADD_REMOVE ${CPACK_DOWNLOAD_ADD_REMOVE}) - cpack_append_option_set_command( - CPACK_ADD_REMOVE - CPACK_CONFIG_DL_STR) - FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_CONFIG_DL_STR}") -ENDMACRO(cpack_configure_downloads) +# Backward compatibility +# Include CPackComponent macros if it has not already been included before. +include(CPackComponent) # Macro for setting values if a user did not overwrite them MACRO(cpack_set_if_not_set name value) @@ -739,7 +260,7 @@ MACRO(cpack_set_if_not_set name value) ENDMACRO(cpack_set_if_not_set) # Macro to encode variables for the configuration file -# find any varable that stars with CPACK and create a variable +# find any variable that starts with CPACK and create a variable # _CPACK_OTHER_VARIABLES_ that contains SET commands for # each cpack variable. _CPACK_OTHER_VARIABLES_ is then # used as an @ replacment in configure_file for the CPackConfig. diff --git a/Modules/CPackBundle.cmake b/Modules/CPackBundle.cmake new file mode 100644 index 000000000..3ac4ea8ff --- /dev/null +++ b/Modules/CPackBundle.cmake @@ -0,0 +1,37 @@ +# - CPack Bundle generator (Mac OS X) specific options +# +# Installers built on Mac OS X using the Bundle generator use the +# aforementioned DragNDrop variables, plus the following Bundle-specific +# parameters: +# +# CPACK_BUNDLE_NAME - The name of the generated bundle. This +# appears in the OSX finder as the bundle name. Required. +# +# CPACK_BUNDLE_PLIST - Path to an OSX plist file that will be used +# as the Info.plist for the generated bundle. This assumes that +# the caller has generated or specified their own Info.plist file. +# Required. +# +# CPACK_BUNDLE_ICON - Path to an OSX icns file that will be used as +# the icon for the generated bundle. This is the icon that appears +# in the OSX finder for the bundle, and in the OSX dock when the +# bundle is opened. Required. +# +# CPACK_BUNDLE_STARTUP_SCRIPT - Path to an executable or script that +# will be run whenever an end-user double-clicks the generated bundle +# in the OSX Finder. Optional. + +#============================================================================= +# Copyright 2006-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +#Bundle Generator specific code should be put here diff --git a/Modules/CPackComponent.cmake b/Modules/CPackComponent.cmake new file mode 100644 index 000000000..1c10372ff --- /dev/null +++ b/Modules/CPackComponent.cmake @@ -0,0 +1,456 @@ +# - Build binary and source package installers +# +# The CPackComponent module is the module which handles +# the component part of CPack. See CPack module for +# general information about CPack. +# +# For certain kinds of binary installers (including the graphical +# installers on Mac OS X and Windows), CPack generates installers that +# allow users to select individual application components to +# install. The contents of each of the components are identified by +# the COMPONENT argument of CMake's INSTALL command. These components +# can be annotated with user-friendly names and descriptions, +# inter-component dependencies, etc., and grouped in various ways to +# customize the resulting installer. See the cpack_add_* commands, +# described below, for more information about component-specific +# installations. +# +# Component-specific installation allows users to select specific sets +# of components to install during the install process. Installation +# components are identified by the COMPONENT argument of CMake's +# INSTALL commands, and should be further described by the following +# CPack commands: +# +# cpack_add_component - Describes a CPack installation component +# named by the COMPONENT argument to a CMake INSTALL command. +# +# cpack_add_component(compname +# [DISPLAY_NAME name] +# [DESCRIPTION description] +# [HIDDEN | REQUIRED | DISABLED ] +# [GROUP group] +# [DEPENDS comp1 comp2 ... ] +# [INSTALL_TYPES type1 type2 ... ] +# [DOWNLOADED] +# [ARCHIVE_FILE filename]) +# +# The cmake_add_component command describes an installation +# component, which the user can opt to install or remove as part of +# the graphical installation process. compname is the name of the +# component, as provided to the COMPONENT argument of one or more +# CMake INSTALL commands. +# +# DISPLAY_NAME is the displayed name of the component, used in +# graphical installers to display the component name. This value can +# be any string. +# +# DESCRIPTION is an extended description of the component, used in +# graphical installers to give the user additional information about +# the component. Descriptions can span multiple lines using "\n" as +# the line separator. Typically, these descriptions should be no +# more than a few lines long. +# +# HIDDEN indicates that this component will be hidden in the +# graphical installer, so that the user cannot directly change +# whether it is installed or not. +# +# REQUIRED indicates that this component is required, and therefore +# will always be installed. It will be visible in the graphical +# installer, but it cannot be unselected. (Typically, required +# components are shown greyed out). +# +# DISABLED indicates that this component should be disabled +# (unselected) by default. The user is free to select this component +# for installation, unless it is also HIDDEN. +# +# DEPENDS lists the components on which this component depends. If +# this component is selected, then each of the components listed +# must also be selected. The dependency information is encoded +# within the installer itself, so that users cannot install +# inconsitent sets of components. +# +# GROUP names the component group of which this component is a +# part. If not provided, the component will be a standalone +# component, not part of any component group. Component groups are +# described with the cpack_add_component_group command, detailed +# below. +# +# INSTALL_TYPES lists the installation types of which this component +# is a part. When one of these installations types is selected, this +# component will automatically be selected. Installation types are +# described with the cpack_add_install_type command, detailed below. +# +# DOWNLOADED indicates that this component should be downloaded +# on-the-fly by the installer, rather than packaged in with the +# installer itself. For more information, see the cpack_configure_downloads +# command. +# +# ARCHIVE_FILE provides a name for the archive file created by CPack +# to be used for downloaded components. If not supplied, CPack will +# create a file with some name based on CPACK_PACKAGE_FILE_NAME and +# the name of the component. See cpack_configure_downloads for more +# information. +# +# cpack_add_component_group - Describes a group of related CPack +# installation components. +# +# cpack_add_component_group(groupname +# [DISPLAY_NAME name] +# [DESCRIPTION description] +# [PARENT_GROUP parent] +# [EXPANDED] +# [BOLD_TITLE]) +# +# The cpack_add_component_group describes a group of installation +# components, which will be placed together within the listing of +# options. Typically, component groups allow the user to +# select/deselect all of the components within a single group via a +# single group-level option. Use component groups to reduce the +# complexity of installers with many options. groupname is an +# arbitrary name used to identify the group in the GROUP argument of +# the cpack_add_component command, which is used to place a +# component in a group. The name of the group must not conflict with +# the name of any component. +# +# DISPLAY_NAME is the displayed name of the component group, used in +# graphical installers to display the component group name. This +# value can be any string. +# +# DESCRIPTION is an extended description of the component group, +# used in graphical installers to give the user additional +# information about the components within that group. Descriptions +# can span multiple lines using "\n" as the line +# separator. Typically, these descriptions should be no more than a +# few lines long. +# +# PARENT_GROUP, if supplied, names the parent group of this group. +# Parent groups are used to establish a hierarchy of groups, +# providing an arbitrary hierarchy of groups. +# +# EXPANDED indicates that, by default, the group should show up as +# "expanded", so that the user immediately sees all of the +# components within the group. Otherwise, the group will initially +# show up as a single entry. +# +# BOLD_TITLE indicates that the group title should appear in bold, +# to call the user's attention to the group. +# +# cpack_add_install_type - Add a new installation type containing a +# set of predefined component selections to the graphical installer. +# +# cpack_add_install_type(typename +# [DISPLAY_NAME name]) +# +# The cpack_add_install_type command identifies a set of preselected +# components that represents a common use case for an +# application. For example, a "Developer" install type might include +# an application along with its header and library files, while an +# "End user" install type might just include the application's +# executable. Each component identifies itself with one or more +# install types via the INSTALL_TYPES argument to +# cpack_add_component. +# +# DISPLAY_NAME is the displayed name of the install type, which will +# typically show up in a drop-down box within a graphical +# installer. This value can be any string. +# +# cpack_configure_downloads - Configure CPack to download selected +# components on-the-fly as part of the installation process. +# +# cpack_configure_downloads(site +# [UPLOAD_DIRECTORY dirname] +# [ALL] +# [ADD_REMOVE|NO_ADD_REMOVE]) +# +# The cpack_configure_downloads command configures installation-time +# downloads of selected components. For each downloadable component, +# CPack will create an archive containing the contents of that +# component, which should be uploaded to the given site. When the +# user selects that component for installation, the installer will +# download and extract the component in place. This feature is +# useful for creating small installers that only download the +# requested components, saving bandwidth. Additionally, the +# installers are small enough that they will be installed as part of +# the normal installation process, and the "Change" button in +# Windows Add/Remove Programs control panel will allow one to add or +# remove parts of the application after the original +# installation. On Windows, the downloaded-components functionality +# requires the ZipDLL plug-in for NSIS, available at: +# +# http://nsis.sourceforge.net/ZipDLL_plug-in +# +# On Mac OS X, installers that download components on-the-fly can +# only be built and installed on system using Mac OS X 10.5 or +# later. +# +# The site argument is a URL where the archives for downloadable +# components will reside, e.g., http://www.cmake.org/files/2.6.1/installer/ +# All of the archives produced by CPack should be uploaded to that location. +# +# UPLOAD_DIRECTORY is the local directory where CPack will create the +# various archives for each of the components. The contents of this +# directory should be uploaded to a location accessible by the URL given +# in the site argument. If omitted, CPack will use the directory +# CPackUploads inside the CMake binary directory to store the generated +# archives. +# +# The ALL flag indicates that all components be downloaded. Otherwise, only +# those components explicitly marked as DOWNLOADED or that have a specified +# ARCHIVE_FILE will be downloaded. Additionally, the ALL option implies +# ADD_REMOVE (unless NO_ADD_REMOVE is specified). +# +# ADD_REMOVE indicates that CPack should install a copy of the installer +# that can be called from Windows' Add/Remove Programs dialog (via the +# "Modify" button) to change the set of installed components. NO_ADD_REMOVE +# turns off this behavior. This option is ignored on Mac OS X. + +#============================================================================= +# Copyright 2006-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# Define var in order to avoid multiple inclusion +IF(NOT CPackComponent_CMake_INCLUDED) +SET(CPackComponent_CMake_INCLUDED 1) + +# Argument-parsing macro from http://www.cmake.org/Wiki/CMakeMacroParseArguments +MACRO(cpack_parse_arguments prefix arg_names option_names) + SET(${prefix}_DEFAULT_ARGS) + FOREACH(arg_name ${arg_names}) + SET(${prefix}_${arg_name}) + ENDFOREACH(arg_name) + FOREACH(option ${option_names}) + SET(${prefix}_${option} FALSE) + ENDFOREACH(option) + + SET(current_arg_name DEFAULT_ARGS) + SET(current_arg_list) + FOREACH(arg ${ARGN}) + SET(larg_names ${arg_names}) + LIST(FIND larg_names "${arg}" is_arg_name) + IF (is_arg_name GREATER -1) + SET(${prefix}_${current_arg_name} ${current_arg_list}) + SET(current_arg_name ${arg}) + SET(current_arg_list) + ELSE (is_arg_name GREATER -1) + SET(loption_names ${option_names}) + LIST(FIND loption_names "${arg}" is_option) + IF (is_option GREATER -1) + SET(${prefix}_${arg} TRUE) + ELSE (is_option GREATER -1) + SET(current_arg_list ${current_arg_list} ${arg}) + ENDIF (is_option GREATER -1) + ENDIF (is_arg_name GREATER -1) + ENDFOREACH(arg) + SET(${prefix}_${current_arg_name} ${current_arg_list}) +ENDMACRO(cpack_parse_arguments) + +# Macro that appends a SET command for the given variable name (var) +# to the macro named strvar, but only if the variable named "var" +# has been defined. The string will eventually be appended to a CPack +# configuration file. +MACRO(cpack_append_variable_set_command var strvar) + IF (DEFINED ${var}) + SET(${strvar} "${${strvar}}SET(${var}") + FOREACH(APPENDVAL ${${var}}) + SET(${strvar} "${${strvar}} ${APPENDVAL}") + ENDFOREACH(APPENDVAL) + SET(${strvar} "${${strvar}})\n") + ENDIF (DEFINED ${var}) +ENDMACRO(cpack_append_variable_set_command) + +# Macro that appends a SET command for the given variable name (var) +# to the macro named strvar, but only if the variable named "var" +# has been defined and is a string. The string will eventually be +# appended to a CPack configuration file. +MACRO(cpack_append_string_variable_set_command var strvar) + IF (DEFINED ${var}) + LIST(LENGTH ${var} CPACK_APP_VALUE_LEN) + IF(${CPACK_APP_VALUE_LEN} EQUAL 1) + SET(${strvar} "${${strvar}}SET(${var} \"${${var}}\")\n") + ENDIF(${CPACK_APP_VALUE_LEN} EQUAL 1) + ENDIF (DEFINED ${var}) +ENDMACRO(cpack_append_string_variable_set_command) + +# Macro that appends a SET command for the given variable name (var) +# to the macro named strvar, but only if the variable named "var" +# has been set to true. The string will eventually be +# appended to a CPack configuration file. +MACRO(cpack_append_option_set_command var strvar) + IF (${var}) + LIST(LENGTH ${var} CPACK_APP_VALUE_LEN) + IF(${CPACK_APP_VALUE_LEN} EQUAL 1) + SET(${strvar} "${${strvar}}SET(${var} TRUE)\n") + ENDIF(${CPACK_APP_VALUE_LEN} EQUAL 1) + ENDIF (${var}) +ENDMACRO(cpack_append_option_set_command) + +# Macro that adds a component to the CPack installer +MACRO(cpack_add_component compname) + STRING(TOUPPER ${compname} CPACK_ADDCOMP_UNAME) + cpack_parse_arguments(CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME} + "DISPLAY_NAME;DESCRIPTION;GROUP;DEPENDS;INSTALL_TYPES;ARCHIVE_FILE" + "HIDDEN;REQUIRED;DISABLED;DOWNLOADED" + ${ARGN} + ) + + if (CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DOWNLOADED) + SET(CPACK_ADDCOMP_STR "\n# Configuration for downloaded component \"${compname}\"\n") + else () + SET(CPACK_ADDCOMP_STR "\n# Configuration for component \"${compname}\"\n") + endif () + + IF(NOT CPACK_MONOLITHIC_INSTALL) + # If the user didn't set CPACK_COMPONENTS_ALL explicitly, update the + # value of CPACK_COMPONENTS_ALL in the configuration file. This will + # take care of any components that have been added after the CPack + # moduled was included. + IF(NOT CPACK_COMPONENTS_ALL_SET_BY_USER) + GET_CMAKE_PROPERTY(CPACK_ADDCOMP_COMPONENTS COMPONENTS) + SET(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR}\nSET(CPACK_COMPONENTS_ALL") + FOREACH(COMP ${CPACK_ADDCOMP_COMPONENTS}) + SET(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR} ${COMP}") + ENDFOREACH(COMP) + SET(CPACK_ADDCOMP_STR "${CPACK_ADDCOMP_STR})\n") + ENDIF(NOT CPACK_COMPONENTS_ALL_SET_BY_USER) + ENDIF(NOT CPACK_MONOLITHIC_INSTALL) + + cpack_append_string_variable_set_command( + CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DISPLAY_NAME + CPACK_ADDCOMP_STR) + cpack_append_string_variable_set_command( + CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DESCRIPTION + CPACK_ADDCOMP_STR) + cpack_append_variable_set_command( + CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_GROUP + CPACK_ADDCOMP_STR) + cpack_append_variable_set_command( + CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DEPENDS + CPACK_ADDCOMP_STR) + cpack_append_variable_set_command( + CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_INSTALL_TYPES + CPACK_ADDCOMP_STR) + cpack_append_string_variable_set_command( + CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_ARCHIVE_FILE + CPACK_ADDCOMP_STR) + cpack_append_option_set_command( + CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_HIDDEN + CPACK_ADDCOMP_STR) + cpack_append_option_set_command( + CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_REQUIRED + CPACK_ADDCOMP_STR) + cpack_append_option_set_command( + CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DISABLED + CPACK_ADDCOMP_STR) + cpack_append_option_set_command( + CPACK_COMPONENT_${CPACK_ADDCOMP_UNAME}_DOWNLOADED + CPACK_ADDCOMP_STR) + # Backward compatibility issue. + # Write to config iff the macros is used after CPack.cmake has been + # included, other it's not necessary because the variables + # will be encoded by cpack_encode_variables. + IF(CPack_CMake_INCLUDED) + FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_ADDCOMP_STR}") + ENDIF(CPack_CMake_INCLUDED) +ENDMACRO(cpack_add_component) + +# Macro that adds a component group to the CPack installer +MACRO(cpack_add_component_group grpname) + STRING(TOUPPER ${grpname} CPACK_ADDGRP_UNAME) + cpack_parse_arguments(CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME} + "DISPLAY_NAME;DESCRIPTION" + "EXPANDED;BOLD_TITLE" + ${ARGN} + ) + + SET(CPACK_ADDGRP_STR "\n# Configuration for component group \"${grpname}\"\n") + cpack_append_string_variable_set_command( + CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_DISPLAY_NAME + CPACK_ADDGRP_STR) + cpack_append_string_variable_set_command( + CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_DESCRIPTION + CPACK_ADDGRP_STR) + cpack_append_option_set_command( + CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_EXPANDED + CPACK_ADDGRP_STR) + cpack_append_option_set_command( + CPACK_COMPONENT_GROUP_${CPACK_ADDGRP_UNAME}_BOLD_TITLE + CPACK_ADDGRP_STR) + # Backward compatibility issue. + # Write to config iff the macros is used after CPack.cmake has been + # included, other it's not necessary because the variables + # will be encoded by cpack_encode_variables. + IF(CPack_CMake_INCLUDED) + FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_ADDGRP_STR}") + ENDIF(CPack_CMake_INCLUDED) +ENDMACRO(cpack_add_component_group) + +# Macro that adds an installation type to the CPack installer +MACRO(cpack_add_install_type insttype) + STRING(TOUPPER ${insttype} CPACK_INSTTYPE_UNAME) + cpack_parse_arguments(CPACK_INSTALL_TYPE_${CPACK_INSTTYPE_UNAME} + "DISPLAY_NAME" + "" + ${ARGN} + ) + + SET(CPACK_INSTTYPE_STR + "\n# Configuration for installation type \"${insttype}\"\n") + SET(CPACK_INSTTYPE_STR + "${CPACK_INSTTYPE_STR}LIST(APPEND CPACK_ALL_INSTALL_TYPES ${insttype})\n") + cpack_append_string_variable_set_command( + CPACK_INSTALL_TYPE_${CPACK_INSTTYPE_UNAME}_DISPLAY_NAME + CPACK_INSTTYPE_STR) + # Backward compatibility issue. + # Write to config iff the macros is used after CPack.cmake has been + # included, other it's not necessary because the variables + # will be encoded by cpack_encode_variables. + IF(CPack_CMake_INCLUDED) + FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_INSTTYPE_STR}") + ENDIF(CPack_CMake_INCLUDED) +ENDMACRO(cpack_add_install_type) + +MACRO(cpack_configure_downloads site) + cpack_parse_arguments(CPACK_DOWNLOAD + "UPLOAD_DIRECTORY" + "ALL;ADD_REMOVE;NO_ADD_REMOVE" + ${ARGN} + ) + + SET(CPACK_CONFIG_DL_STR + "\n# Downloaded components configuration\n") + SET(CPACK_UPLOAD_DIRECTORY ${CPACK_DOWNLOAD_UPLOAD_DIRECTORY}) + SET(CPACK_DOWNLOAD_SITE ${site}) + cpack_append_string_variable_set_command( + CPACK_DOWNLOAD_SITE + CPACK_CONFIG_DL_STR) + cpack_append_string_variable_set_command( + CPACK_UPLOAD_DIRECTORY + CPACK_CONFIG_DL_STR) + cpack_append_option_set_command( + CPACK_DOWNLOAD_ALL + CPACK_CONFIG_DL_STR) + IF (${CPACK_DOWNLOAD_ALL} AND NOT ${CPACK_DOWNLOAD_NO_ADD_REMOVE}) + SET(CPACK_DOWNLOAD_ADD_REMOVE ON) + ENDIF (${CPACK_DOWNLOAD_ALL} AND NOT ${CPACK_DOWNLOAD_NO_ADD_REMOVE}) + SET(CPACK_ADD_REMOVE ${CPACK_DOWNLOAD_ADD_REMOVE}) + cpack_append_option_set_command( + CPACK_ADD_REMOVE + CPACK_CONFIG_DL_STR) + # Backward compatibility issue. + # Write to config iff the macros is used after CPack.cmake has been + # included, other it's not necessary because the variables + # will be encoded by cpack_encode_variables. + IF(CPack_CMake_INCLUDED) + FILE(APPEND "${CPACK_OUTPUT_CONFIG_FILE}" "${CPACK_CONFIG_DL_STR}") + ENDIF(CPack_CMake_INCLUDED) +ENDMACRO(cpack_configure_downloads) +ENDIF(NOT CPackComponent_CMake_INCLUDED) diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 98d40d65e..90c80a4dc 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -60,7 +60,7 @@ # CPACK_DEBIAN_PACKAGE_DEBUG # Mandatory : NO # Default : - -# May be set when invoking cpack in order to trace debug informations +# May be set when invoking cpack in order to trace debug information # during CPackDeb run. # CPACK_DEBIAN_PACKAGE_PREDEPENDS # Mandatory : NO @@ -311,6 +311,29 @@ ENDIF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY ) # SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA # "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm") +# Are we packaging components ? +IF(CPACK_DEB_PACKAGE_COMPONENT) + SET(CPACK_DEB_PACKAGE_COMPONENT_PART_NAME "-${CPACK_DEB_PACKAGE_COMPONENT}") + SET(CPACK_DEB_PACKAGE_COMPONENT_PART_PATH "/${CPACK_DEB_PACKAGE_COMPONENT}") + SET(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${CPACK_DEB_PACKAGE_COMPONENT}") + STRING(TOLOWER "${CPACK_PACKAGE_NAME}${CPACK_DEB_PACKAGE_COMPONENT_PART_NAME}" CPACK_DEBIAN_PACKAGE_NAME) +ELSE(CPACK_DEB_PACKAGE_COMPONENT) + SET(CPACK_DEB_PACKAGE_COMPONENT_PART_NAME "") + SET(CPACK_DEB_PACKAGE_COMPONENT_PART_PATH "") + SET(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}") +ENDIF(CPACK_DEB_PACKAGE_COMPONENT) + +# Print out some debug information if we were asked for that +IF(CPACK_DEBIAN_PACKAGE_DEBUG) + MESSAGE("CPackDeb:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}") + MESSAGE("CPackDeb:Debug: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}") + MESSAGE("CPackDeb:Debug: CPACK_TEMPORARY_DIRECTORY = ${CPACK_TEMPORARY_DIRECTORY}") + MESSAGE("CPackDeb:Debug: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}") + MESSAGE("CPackDeb:Debug: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}") + MESSAGE("CPackDeb:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}") + MESSAGE("CPackDeb:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}") + MESSAGE("CPackDeb:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") +ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG) # For debian source packages: # debian/control diff --git a/Modules/CPackNSIS.cmake b/Modules/CPackNSIS.cmake new file mode 100644 index 000000000..d9dab5328 --- /dev/null +++ b/Modules/CPackNSIS.cmake @@ -0,0 +1,83 @@ +# - CPack NSIS generator specific options +# +# The following variables are specific to the graphical installers built +# on Windows using the Nullsoft Installation System. +# +# CPACK_PACKAGE_INSTALL_REGISTRY_KEY - Registry key used when +# installing this project. +# +# CPACK_NSIS_INSTALL_ROOT - The default installation directory presented +# to the end user by the NSIS installer is under this root dir. The full +# directory presented to the end user is: +# ${CPACK_NSIS_INSTALL_ROOT}/${CPACK_PACKAGE_INSTALL_DIRECTORY} +# +# CPACK_NSIS_MUI_ICON - The icon file (.ico) for the generated +# install program. +# +# CPACK_NSIS_MUI_UNIICON - The icon file (.ico) for the generated +# uninstall program. +# +# CPACK_PACKAGE_ICON - A branding image that will be displayed inside +# the installer. +# +# CPACK_NSIS_EXTRA_INSTALL_COMMANDS - Extra NSIS commands that will +# be added to the install Section. +# +# CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS - Extra NSIS commands that will +# be added to the uninstall Section. +# +# CPACK_NSIS_COMPRESSOR - The arguments that will be passed to the +# NSIS SetCompressor command. +# +# CPACK_NSIS_MODIFY_PATH - If this is set to "ON", then an extra page +# will appear in the installer that will allow the user to choose +# whether the program directory should be added to the system PATH +# variable. +# +# CPACK_NSIS_DISPLAY_NAME - The display name string that appears in +# the Windows Add/Remove Program control panel +# +# CPACK_NSIS_PACKAGE_NAME - The title displayed at the top of the +# installer. +# +# CPACK_NSIS_INSTALLED_ICON_NAME - A path to the executable that +# contains the installer icon. +# +# CPACK_NSIS_HELP_LINK - URL to a web site providing assistance in +# installing your application. +# +# CPACK_NSIS_URL_INFO_ABOUT - URL to a web site providing more +# information about your application. +# +# CPACK_NSIS_CONTACT - Contact information for questions and comments +# about the installation process. +# +# CPACK_NSIS_CREATE_ICONS_EXTRA - Additional NSIS commands for +# creating start menu shortcuts. +# +# CPACK_NSIS_DELETE_ICONS_EXTRA -Additional NSIS commands to +# uninstall start menu shortcuts. +# +# CPACK_NSIS_EXECUTABLES_DIRECTORY - Creating NSIS start menu links +# assumes that they are in 'bin' unless this variable is set. +# For example, you would set this to 'exec' if your executables are +# in an exec directory. +# +# CPACK_NSIS_MUI_FINISHPAGE_RUN - Specify an executable to add an option +# to run on the finish page of the NSIS installer. + +#============================================================================= +# Copyright 2006-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +#FIXME we should put NSIS specific code here +#FIXME but I'm not doing it because I'm not able to test it... diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 026c45a6f..729d8dfbc 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -4,8 +4,10 @@ # used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration # # However CPackRPM has specific features which are controlled by -# the specifics CPACK_RPM_XXX variables. You'll find a detailed usage on -# the wiki: +# the specifics CPACK_RPM_XXX variables. +# Usually those vars correspond to RPM spec file entities, one may find +# information about spec files here http://www.rpm.org/wiki/Docs. +# You'll find a detailed usage of CPackRPM on the wiki: # http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29 # However as a handy reminder here comes the list of specific variables: # @@ -68,6 +70,8 @@ # Note that you must enclose the complete requires string between quotes, # for example: # set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.5.0, cmake >= 2.8") +# The required package list of an RPM file could be printed with +# rpm -qp --requires file.rpm # CPACK_RPM_PACKAGE_SUGGESTS # Mandatory : NO # Default : - @@ -77,6 +81,8 @@ # Mandatory : NO # Default : - # May be used to set RPM dependencies (provides). +# The provided package list of an RPM file could be printed with +# rpm -qp --provides file.rpm # CPACK_RPM_PACKAGE_OBSOLETES # Mandatory : NO # Default : - @@ -194,6 +200,25 @@ IF(NOT RPMBUILD_EXECUTABLE) MESSAGE(FATAL_ERROR "RPM package requires rpmbuild executable") ENDIF(NOT RPMBUILD_EXECUTABLE) +# Display lsb_release output if DEBUG mode enable +# This will help to diagnose problem with CPackRPM +# because we will know on which kind of Linux we are +IF(CPACK_RPM_PACKAGE_DEBUG) + find_program(LSB_RELEASE_EXECUTABLE lsb_release) + if(LSB_RELEASE_EXECUTABLE) + execute_process(COMMAND ${LSB_RELEASE_EXECUTABLE} -a + OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(REGEX REPLACE "\n" ", " + LSB_RELEASE_OUTPUT + ${_TMP_LSB_RELEASE_OUTPUT}) + else (LSB_RELEASE_EXECUTABLE) + set(LSB_RELEASE_OUTPUT "lsb_release not installed/found!") + endif(LSB_RELEASE_EXECUTABLE) + MESSAGE("CPackRPM:Debug: LSB_RELEASE = ${LSB_RELEASE_OUTPUT}") +ENDIF(CPACK_RPM_PACKAGE_DEBUG) + # We may use RPM version in the future in order # to shut down warning about space in buildtree # some recent RPM version should support space in different places. @@ -345,7 +370,7 @@ if(CPACK_RPM_PACKAGE_RELOCATABLE) endif(CPACK_RPM_PACKAGE_RELOCATABLE) # check if additional fields for RPM spec header are given -FOREACH(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX) +FOREACH(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV) IF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) STRING(LENGTH ${_RPM_SPEC_HEADER} _PACKAGE_HEADER_STRLENGTH) MATH(EXPR _PACKAGE_HEADER_STRLENGTH "${_PACKAGE_HEADER_STRLENGTH} - 1") @@ -470,12 +495,26 @@ ENDIF(CPACK_RPM_PACKAGE_COMPONENT) # file name by enclosing it between double quotes (thus the sed) # Then we must authorize any man pages extension (adding * at the end) # because rpmbuild may automatically compress those files -EXECUTE_PROCESS(COMMAND find -type f -o -type l - COMMAND sed {s:.*/man.*/.*:&*:} - COMMAND sed {s/\\.\\\(.*\\\)/\"\\1\"/} +EXECUTE_PROCESS(COMMAND find . -type f -o -type l + COMMAND sed s:.*/man.*/.*:&*: + COMMAND sed s/\\.\\\(.*\\\)/\"\\1\"/ WORKING_DIRECTORY "${WDIR}" OUTPUT_VARIABLE CPACK_RPM_INSTALL_FILES) +# In component case, replace CPACK_ABSOLUTE_DESTINATION_FILES +# with the content of CPACK_ABSOLUTE_DESTINATION_FILES_ +# This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES handling +if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_ABSOLUTE_DESTINATION_FILES) + set(COMPONENT_FILES_TAG "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}") + set(CPACK_ABSOLUTE_DESTINATION_FILES "${${COMPONENT_FILES_TAG}}") + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Handling Absolute Destination Files ${CPACK_ABSOLUTE_DESTINATION_FILES}") + message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") + endif(CPACK_RPM_PACKAGE_DEBUG) + endif() +endif() + if (CPACK_ABSOLUTE_DESTINATION_FILES) IF(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: Handling Absolute Destination Files: ${CPACK_ABSOLUTE_DESTINATION_FILES}") @@ -540,6 +579,10 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ \@TMP_RPM_REQUIRES\@ \@TMP_RPM_PROVIDES\@ \@TMP_RPM_OBSOLETES\@ +\@TMP_RPM_CONFLICTS\@ +\@TMP_RPM_AUTOPROV\@ +\@TMP_RPM_AUTOREQ\@ +\@TMP_RPM_AUTOREQPROV\@ \@TMP_RPM_BUILDARCH\@ \@TMP_RPM_PREFIX\@ @@ -621,13 +664,18 @@ IF(RPMBUILD_EXECUTABLE) --buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" "${CPACK_RPM_BINARY_SPECFILE}" WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_PATH}" + RESULT_VARIABLE CPACK_RPMBUILD_EXEC_RESULT ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err" OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out") - IF(CPACK_RPM_PACKAGE_DEBUG) + IF(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT) + FILE(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err RPMBUILDERR) + FILE(READ ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out RPMBUILDOUT) MESSAGE("CPackRPM:Debug: You may consult rpmbuild logs in: ") MESSAGE("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.err") + MESSAGE("CPackRPM:Debug: *** ${RPMBUILDERR} ***") MESSAGE("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.out") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) + MESSAGE("CPackRPM:Debug: *** ${RPMBUILDERR} ***") + ENDIF(CPACK_RPM_PACKAGE_DEBUG OR CPACK_RPMBUILD_EXEC_RESULT) ELSE(RPMBUILD_EXECUTABLE) IF(ALIEN_EXECUTABLE) MESSAGE(FATAL_ERROR "RPM packaging through alien not done (yet)") diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake index bb76ddd25..c261eb385 100644 --- a/Modules/CTest.cmake +++ b/Modules/CTest.cmake @@ -63,7 +63,8 @@ OPTION(BUILD_TESTING "Build the testing tree." ON) # function to turn generator name into a version string # like vs7 vs71 vs8 vs9 FUNCTION(GET_VS_VERSION_STRING generator var) - STRING(REGEX REPLACE "Visual Studio ([0-9][0-9]?)($|.*)" "\\1" NUMBER "${generator}") + STRING(REGEX REPLACE "Visual Studio ([0-9][0-9]?)($|.*)" "\\1" + NUMBER "${generator}") IF("${generator}" MATCHES "Visual Studio 7 .NET 2003") SET(ver_string "vs71") ELSE("${generator}" MATCHES "Visual Studio 7 .NET 2003") @@ -253,15 +254,16 @@ IF(BUILD_TESTING) ENDIF(CTEST_USE_LAUNCHERS) MARK_AS_ADVANCED( + BZRCOMMAND + BZR_UPDATE_OPTIONS COVERAGE_COMMAND + CTEST_SUBMIT_RETRY_DELAY + CTEST_SUBMIT_RETRY_COUNT CVSCOMMAND - SVNCOMMAND - BZRCOMMAND - HGCOMMAND - GITCOMMAND CVS_UPDATE_OPTIONS - SVN_UPDATE_OPTIONS - BZR_UPDATE_OPTIONS + DART_TESTING_TIMEOUT + GITCOMMAND + HGCOMMAND MAKECOMMAND MEMORYCHECK_COMMAND MEMORYCHECK_SUPPRESSIONS_FILE @@ -270,10 +272,9 @@ IF(BUILD_TESTING) SLURM_SBATCH_COMMAND SLURM_SRUN_COMMAND SITE - CTEST_SUBMIT_RETRY_DELAY - CTEST_SUBMIT_RETRY_COUNT + SVNCOMMAND + SVN_UPDATE_OPTIONS ) - # BUILDNAME IF(NOT RUN_FROM_DART) SET(RUN_FROM_CTEST_OR_DART 1) INCLUDE(CTestTargets) diff --git a/Modules/CTestTargets.cmake b/Modules/CTestTargets.cmake index e3ef86cbe..d66874d8f 100644 --- a/Modules/CTestTargets.cmake +++ b/Modules/CTestTargets.cmake @@ -84,4 +84,12 @@ IF(NOT _CTEST_TARGETS_ADDED) ENDFOREACH(testtype) ENDFOREACH(mode) ENDIF("${CMAKE_GENERATOR}" MATCHES Make) + + # If requested, add an alias that is the equivalent of the built-in "test" + # or "RUN_TESTS" target: + IF(CTEST_TEST_TARGET_ALIAS) + ADD_CUSTOM_TARGET(${CTEST_TEST_TARGET_ALIAS} + ${CMAKE_CTEST_COMMAND} ${__conf_types} + ) + ENDIF() ENDIF(NOT _CTEST_TARGETS_ADDED) diff --git a/Modules/CheckPrototypeDefinition.c.in b/Modules/CheckPrototypeDefinition.c.in new file mode 100644 index 000000000..a97344ac3 --- /dev/null +++ b/Modules/CheckPrototypeDefinition.c.in @@ -0,0 +1,29 @@ +@CHECK_PROTOTYPE_DEFINITION_HEADER@ + +static void cmakeRequireSymbol(int dummy, ...) { + (void) dummy; +} + +static void checkSymbol(void) { +#ifndef @CHECK_PROTOTYPE_DEFINITION_SYMBOL@ + cmakeRequireSymbol(0, &@CHECK_PROTOTYPE_DEFINITION_SYMBOL@); +#endif +} + +@CHECK_PROTOTYPE_DEFINITION_PROTO@ { + return @CHECK_PROTOTYPE_DEFINITION_RETURN@; +} + +#ifdef __CLASSIC_C__ +int main() { + int ac; + char*av[]; +#else +int main(int ac, char *av[]) { +#endif + checkSymbol(); + if (ac > 1000) { + return *av[0]; + } + return 0; +} diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake new file mode 100644 index 000000000..244b9b53b --- /dev/null +++ b/Modules/CheckPrototypeDefinition.cmake @@ -0,0 +1,96 @@ +# - Check if the protoype we expect is correct. +# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE) +# FUNCTION - The name of the function (used to check if prototype exists) +# PROTOTYPE- The prototype to check. +# RETURN - The return value of the function. +# HEADER - The header files required. +# VARIABLE - The variable to store the result. +# Example: +# check_prototype_definition(getpwent_r +# "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)" +# "NULL" +# "unistd.h;pwd.h" +# SOLARIS_GETPWENT_R) +# The following variables may be set before calling this macro to +# modify the way the check is run: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link + +#============================================================================= +# Copyright 2005-2009 Kitware, Inc. +# Copyright 2010-2011 Andreas Schneider +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) +# + +get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) + +function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE) + + if ("${_VARIABLE}" MATCHES "^${_VARIABLE}$") + set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n") + + set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS}) + if (CMAKE_REQUIRED_LIBRARIES) + set(CHECK_PROTOTYPE_DEFINITION_LIBS + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + else(CMAKE_REQUIRED_LIBRARIES) + set(CHECK_PROTOTYPE_DEFINITION_LIBS) + endif(CMAKE_REQUIRED_LIBRARIES) + if (CMAKE_REQUIRED_INCLUDES) + set(CMAKE_SYMBOL_EXISTS_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + else(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_SYMBOL_EXISTS_INCLUDES) + endif(CMAKE_REQUIRED_INCLUDES) + + foreach(_FILE ${_HEADER}) + set(CHECK_PROTOTYPE_DEFINITION_HEADER + "${CHECK_PROTOTYPE_DEFINITION_HEADER}#include <${_FILE}>\n") + endforeach(_FILE) + + set(CHECK_PROTOTYPE_DEFINITION_SYMBOL ${_FUNCTION}) + set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE}) + set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN}) + + configure_file("${__check_proto_def_dir}/CheckPrototypeDefinition.c.in" + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY) + + file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE) + + try_compile(${_VARIABLE} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS} + "${CHECK_PROTOTYPE_DEFINITION_LIBS}" + "${CMAKE_SYMBOL_EXISTS_INCLUDES}" + OUTPUT_VARIABLE OUTPUT) + + if (${_VARIABLE}) + set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") + message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n" + "${OUTPUT}\n\n") + else (${_VARIABLE}) + message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False") + set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n" + "${OUTPUT}\n\n${_SOURCE}\n\n") + endif (${_VARIABLE}) + endif("${_VARIABLE}" MATCHES "^${_VARIABLE}$") + +endfunction(CHECK_PROTOTYPE_DEFINITION) diff --git a/Modules/Compiler/Absoft-Fortran.cmake b/Modules/Compiler/Absoft-Fortran.cmake new file mode 100644 index 000000000..bb7d3dc71 --- /dev/null +++ b/Modules/Compiler/Absoft-Fortran.cmake @@ -0,0 +1,8 @@ +SET(CMAKE_Fortran_FLAGS_INIT "") +SET(CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") +SET(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "") +SET(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") +SET(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") +SET(CMAKE_Fortran_MODDIR_FLAG "-YMOD_OUT_DIR=") +SET(CMAKE_Fortran_MODPATH_FLAG "-p") +SET(CMAKE_Fortran_VERBOSE_FLAG "-v") diff --git a/Modules/Compiler/GNU-ASM.cmake b/Modules/Compiler/GNU-ASM.cmake new file mode 100644 index 000000000..e07401d54 --- /dev/null +++ b/Modules/Compiler/GNU-ASM.cmake @@ -0,0 +1,6 @@ +# This file is loaded when gcc/g++ is used for assembler files (the "ASM" cmake language) +include(Compiler/GNU) + +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;S;asm) + +__compiler_gnu(ASM) diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index 0bb31f9e5..8d6f5dfb8 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -33,6 +33,6 @@ macro(__compiler_gnu lang) set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE " -E > ") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE " -S -o ") if(NOT APPLE) - set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ") + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") endif(NOT APPLE) endmacro() diff --git a/Modules/Compiler/HP-ASM.cmake b/Modules/Compiler/HP-ASM.cmake new file mode 100644 index 000000000..8aa7bdb7d --- /dev/null +++ b/Modules/Compiler/HP-ASM.cmake @@ -0,0 +1,3 @@ +SET(CMAKE_ASM_VERBOSE_FLAG "-v") + +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s ) diff --git a/Modules/Compiler/HP-C.cmake b/Modules/Compiler/HP-C.cmake index abf384ab8..dc7fbb21d 100644 --- a/Modules/Compiler/HP-C.cmake +++ b/Modules/Compiler/HP-C.cmake @@ -1 +1,4 @@ SET(CMAKE_C_VERBOSE_FLAG "-v") + +SET(CMAKE_C_CREATE_ASSEMBLY_SOURCE " -S -o ") +SET(CMAKE_C_CREATE_PREPROCESSED_SOURCE " -E > ") diff --git a/Modules/Compiler/HP-CXX.cmake b/Modules/Compiler/HP-CXX.cmake index f3c6b5f82..82c1a861e 100644 --- a/Modules/Compiler/HP-CXX.cmake +++ b/Modules/Compiler/HP-CXX.cmake @@ -1 +1,4 @@ SET(CMAKE_CXX_VERBOSE_FLAG "-v") + +SET(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE " -S -o ") +SET(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE " -E > ") diff --git a/Modules/Compiler/Intel-ASM.cmake b/Modules/Compiler/Intel-ASM.cmake new file mode 100644 index 000000000..59b50a15c --- /dev/null +++ b/Modules/Compiler/Intel-ASM.cmake @@ -0,0 +1,13 @@ +SET(CMAKE_ASM_VERBOSE_FLAG "-v") + +SET(CMAKE_ASM_FLAGS_INIT "") +SET(CMAKE_ASM_FLAGS_DEBUG_INIT "-g") +SET(CMAKE_ASM_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") +SET(CMAKE_ASM_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") +SET(CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") + +IF(UNIX) + SET(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;S) +ELSE(UNIX) + SET(CMAKE_ASM_SOURCE_FILE_EXTENSIONS asm) +ENDIF(UNIX) diff --git a/Modules/Compiler/SunPro-ASM.cmake b/Modules/Compiler/SunPro-ASM.cmake new file mode 100644 index 000000000..dfc5702ee --- /dev/null +++ b/Modules/Compiler/SunPro-ASM.cmake @@ -0,0 +1,24 @@ +set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s ) + +SET(CMAKE_ASM_VERBOSE_FLAG "-#") + +SET(CMAKE_SHARED_LIBRARY_ASM_FLAGS "-KPIC") +SET(CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS "-G") +SET(CMAKE_SHARED_LIBRARY_RUNTIME_ASM_FLAG "-R") +SET(CMAKE_SHARED_LIBRARY_RUNTIME_ASM_FLAG_SEP ":") +SET(CMAKE_SHARED_LIBRARY_SONAME_ASM_FLAG "-h") + +SET(CMAKE_ASM_FLAGS_INIT "") +SET(CMAKE_ASM_FLAGS_DEBUG_INIT "-g") +SET(CMAKE_ASM_FLAGS_MINSIZEREL_INIT "-xO2 -xspace -DNDEBUG") +SET(CMAKE_ASM_FLAGS_RELEASE_INIT "-xO3 -DNDEBUG") +SET(CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT "-g -xO2") + +# Initialize ASM link type selection flags. These flags are used when +# building a shared library, shared module, or executable that links +# to other libraries to select whether to use the static or shared +# versions of the libraries. +FOREACH(type SHARED_LIBRARY SHARED_MODULE EXE) + SET(CMAKE_${type}_LINK_STATIC_ASM_FLAGS "-Bstatic") + SET(CMAKE_${type}_LINK_DYNAMIC_ASM_FLAGS "-Bdynamic") +ENDFOREACH(type) diff --git a/Modules/Compiler/XL-ASM.cmake b/Modules/Compiler/XL-ASM.cmake new file mode 100644 index 000000000..e5d4ffa85 --- /dev/null +++ b/Modules/Compiler/XL-ASM.cmake @@ -0,0 +1,13 @@ +SET(CMAKE_ASM_VERBOSE_FLAG "-V") + +# -qthreaded = Ensures that all optimizations will be thread-safe +# -qalias=noansi = Turns off type-based aliasing completely (safer optimizer) +# -qhalt=e = Halt on error messages (rather than just severe errors) +SET(CMAKE_ASM_FLAGS_INIT "-qthreaded -qalias=noansi -qhalt=e -qsourcetype=assembler") + +SET(CMAKE_ASM_FLAGS_DEBUG_INIT "-g") +SET(CMAKE_ASM_FLAGS_RELEASE_INIT "-O -DNDEBUG") +SET(CMAKE_ASM_FLAGS_MINSIZEREL_INIT "-O -DNDEBUG") +SET(CMAKE_ASM_FLAGS_RELWITHDEBINFO_INIT "-g") + +SET(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s ) diff --git a/Modules/Compiler/XL-C.cmake b/Modules/Compiler/XL-C.cmake index 8f6655762..ae869e37e 100644 --- a/Modules/Compiler/XL-C.cmake +++ b/Modules/Compiler/XL-C.cmake @@ -1,14 +1,9 @@ -SET(CMAKE_C_VERBOSE_FLAG "-V") +include(Compiler/XL) +__compiler_xl(C) +set(CMAKE_C_FLAGS_RELEASE_INIT "${CMAKE_C_FLAGS_RELEASE_INIT} -DNDEBUG") +set(CMAKE_C_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT} -DNDEBUG") # -qthreaded = Ensures that all optimizations will be thread-safe # -qalias=noansi = Turns off type-based aliasing completely (safer optimizer) # -qhalt=e = Halt on error messages (rather than just severe errors) SET(CMAKE_C_FLAGS_INIT "-qthreaded -qalias=noansi -qhalt=e") - -SET(CMAKE_C_FLAGS_DEBUG_INIT "-g") -SET(CMAKE_C_FLAGS_RELEASE_INIT "-O -DNDEBUG") -SET(CMAKE_C_FLAGS_MINSIZEREL_INIT "-O -DNDEBUG") -SET(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g") - -SET(CMAKE_C_CREATE_PREPROCESSED_SOURCE " -E > ") -SET(CMAKE_C_CREATE_ASSEMBLY_SOURCE " -S -o ") diff --git a/Modules/Compiler/XL-CXX.cmake b/Modules/Compiler/XL-CXX.cmake index 961cfee61..29c4b5e37 100644 --- a/Modules/Compiler/XL-CXX.cmake +++ b/Modules/Compiler/XL-CXX.cmake @@ -1,12 +1,11 @@ -SET(CMAKE_CXX_VERBOSE_FLAG "-V") +include(Compiler/XL) +__compiler_xl(CXX) +set(CMAKE_CXX_FLAGS_RELEASE_INIT "${CMAKE_CXX_FLAGS_RELEASE_INIT} -DNDEBUG") +set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT} -DNDEBUG") -SET(CMAKE_CXX_FLAGS_DEBUG_INIT "-g") -SET(CMAKE_CXX_FLAGS_RELEASE_INIT "-O -DNDEBUG") -SET(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-O -DNDEBUG") -SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g") +# -qthreaded = Ensures that all optimizations will be thread-safe +# -qhalt=e = Halt on error messages (rather than just severe errors) +SET(CMAKE_CXX_FLAGS_INIT "-qthreaded -qhalt=e") SET(CMAKE_CXX_COMPILE_OBJECT " -+ -o -c ") - -SET(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE " -E > ") -SET(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE " -S -o ") diff --git a/Modules/Compiler/XL-Fortran.cmake b/Modules/Compiler/XL-Fortran.cmake index cf9b2b657..d88b3f32f 100644 --- a/Modules/Compiler/XL-Fortran.cmake +++ b/Modules/Compiler/XL-Fortran.cmake @@ -1,8 +1,14 @@ -SET(CMAKE_Fortran_VERBOSE_FLAG "-V") +include(Compiler/XL) +__compiler_xl(Fortran) + +SET(CMAKE_Fortran_MODDIR_FLAG "-qmoddir=") SET(CMAKE_Fortran_DEFINE_FLAG "-WF,-D") -SET(CMAKE_Fortran_FLAGS_DEBUG_INIT "-g") -SET(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O") -SET(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-O") -SET(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-g") +# -qthreaded = Ensures that all optimizations will be thread-safe +# -qhalt=e = Halt on error messages (rather than just severe errors) +SET(CMAKE_Fortran_FLAGS_INIT "-qthreaded -qhalt=e") + +# We require updates to CMake C++ code to support preprocessing rules for Fortran. +SET(CMAKE_Fortran_CREATE_PREPROCESSED_SOURCE) +SET(CMAKE_Fortran_CREATE_ASSEMBLY_SOURCE) diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake new file mode 100644 index 000000000..d07890f39 --- /dev/null +++ b/Modules/Compiler/XL.cmake @@ -0,0 +1,48 @@ + +#============================================================================= +# Copyright 2002-2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This module is shared by multiple languages; use include blocker. +if(__COMPILER_XL) + return() +endif() +set(__COMPILER_XL 1) + +# Find the CreateExportList program that comes with this toolchain. +find_program(CMAKE_XL_CreateExportList + NAMES CreateExportList + DOC "IBM XL CreateExportList tool" + ) + +macro(__compiler_xl lang) + # Feature flags. + set(CMAKE_${lang}_VERBOSE_FLAG "-V") + + set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-g") + set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O") + set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-O") + set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-g") + set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE " -E > ") + set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE " -S -o ") + + # The compiler front-end passes all object files, archive files, and shared + # library files named on the command line to CreateExportList to create a + # list of all symbols to be exported from the shared library. This causes + # all archive members to be copied into the shared library whether they are + # needed or not. Instead we run the tool ourselves to pass only the object + # files so that we export only the symbols actually provided by the sources. + set(CMAKE_${lang}_CREATE_SHARED_LIBRARY + "${CMAKE_XL_CreateExportList} /objects.exp " + " -Wl,-bE:/objects.exp -o " + ) +endmacro() diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 3de6b7e68..a37771b92 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -18,6 +18,7 @@ # [SVN_REVISION rev] # Revision to checkout from Subversion repo # [SVN_USERNAME john ] # Username for Subversion checkout and update # [SVN_PASSWORD doe ] # Password for Subversion checkout and update +# [SVN_TRUST_CERT 1 ] # Trust the Subversion server site certificate # [GIT_REPOSITORY url] # URL of git repo # [GIT_TAG tag] # Git branch name, commit id or tag # [URL /.../src.tgz] # Full path or URL of source @@ -403,11 +404,11 @@ endfunction(_ep_write_verifyfile_script) function(_ep_write_extractfile_script script_filename name filename directory) set(args "") - if(filename MATCHES "(\\.bz2|\\.tar\\.gz|\\.tgz|\\.zip)$") + if(filename MATCHES "(\\.|=)(bz2|tar\\.gz|tgz|zip)$") set(args xfz) endif() - if(filename MATCHES "\\.tar$") + if(filename MATCHES "(\\.|=)tar$") set(args xf) endif() @@ -1026,6 +1027,7 @@ function(_ep_add_download_command name) get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION) get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME) get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD) + get_property(svn_trust_cert TARGET ${name} PROPERTY _EP_SVN_TRUST_CERT) set(repository "${svn_repository} user=${svn_username} password=${svn_password}") set(module) @@ -1046,8 +1048,11 @@ function(_ep_add_download_command name) if(svn_password) set(svn_user_pw_args ${svn_user_pw_args} "--password=${svn_password}") endif() + if(svn_trust_cert) + set(svn_trust_cert_args --trust-server-cert) + endif() set(cmd ${Subversion_SVN_EXECUTABLE} co ${svn_repository} ${svn_revision} - ${svn_user_pw_args} ${src_name}) + --non-interactive ${svn_trust_cert_args} ${svn_user_pw_args} ${src_name}) list(APPEND depends ${stamp_dir}/${name}-svninfo.txt) elseif(git_repository) find_package(Git) @@ -1109,10 +1114,15 @@ function(_ep_add_download_command name) else() if("${url}" MATCHES "^[a-z]+://") # TODO: Should download and extraction be different steps? - string(REGEX MATCH "[^/]*$" fname "${url}") - if(NOT "${fname}" MATCHES "\\.(bz2|tar|tgz|tar\\.gz|zip)$") + string(REGEX MATCH "[^/\\?]*$" fname "${url}") + if(NOT "${fname}" MATCHES "(\\.|=)(bz2|tar|tgz|tar\\.gz|zip)$") + string(REGEX MATCH "([^/\\?]+(\\.|=)(bz2|tar|tgz|tar\\.gz|zip))/.*$" match_result "${url}") + set(fname "${CMAKE_MATCH_1}") + endif() + if(NOT "${fname}" MATCHES "(\\.|=)(bz2|tar|tgz|tar\\.gz|zip)$") message(FATAL_ERROR "Could not extract tarball filename from url:\n ${url}") endif() + string(REPLACE ";" "-" fname "${fname}") set(file ${download_dir}/${fname}) get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) _ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" "${url}" "${file}" "${timeout}" "${md5}") @@ -1186,6 +1196,7 @@ function(_ep_add_update_command name) get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION) get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME) get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD) + get_property(svn_trust_cert TARGET ${name} PROPERTY _EP_SVN_TRUST_CERT) set(svn_user_pw_args "") if(svn_username) set(svn_user_pw_args ${svn_user_pw_args} "--username=${svn_username}") @@ -1193,8 +1204,11 @@ function(_ep_add_update_command name) if(svn_password) set(svn_user_pw_args ${svn_user_pw_args} "--password=${svn_password}") endif() + if(svn_trust_cert) + set(svn_trust_cert_args --trust-server-cert) + endif() set(cmd ${Subversion_SVN_EXECUTABLE} up ${svn_revision} - ${svn_user_pw_args}) + --non-interactive ${svn_trust_cert_args} ${svn_user_pw_args}) set(always 1) elseif(git_repository) if(NOT GIT_EXECUTABLE) diff --git a/Modules/FindArmadillo.cmake b/Modules/FindArmadillo.cmake new file mode 100644 index 000000000..6df247328 --- /dev/null +++ b/Modules/FindArmadillo.cmake @@ -0,0 +1,100 @@ +# - Find Armadillo +# Find the Armadillo C++ library +# +# +# == Using Armadillo: == +# find_package(Armadillo RECQUIRED) +# include_directories(${ARMADILLO_INCLUDE_DIRS}) +# add_executable(foo foo.cc) +# target_link_libraries(foo ${ARMADILLO_LIBRARIES}) +# +#============================================================================= +# +# This module sets the following variables: +# ARMADILLO_FOUND - set to true if the library is found +# ARMADILLO_INCLUDE_DIRS - list of required include directories +# ARMADILLO_LIBRARIES - list of libraries to be linked +# ARMADILLO_VERSION_MAJOR - major version number +# ARMADILLO_VERSION_MINOR - minor version number +# ARMADILLO_VERSION_PATCH - patch version number +# ARMADILLO_VERSION_STRING - version number as a string (ex: "1.0.4") +# ARMADILLO_VERSION_NAME - name of the version (ex: "Antipodean Antileech") +# + +#============================================================================= +# Copyright 2011 Clement Creusot +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + + +# UNIX paths are standard, no need to write. +find_library(ARMADILLO_LIBRARY + NAMES armadillo + PATHS "$ENV{ProgramFiles}/Armadillo/lib" "$ENV{ProgramFiles}/Armadillo/lib64" "$ENV{ProgramFiles}/Armadillo" + ) +find_path(ARMADILLO_INCLUDE_DIR + NAMES armadillo + PATHS "$ENV{ProgramFiles}/Armadillo/include" + ) + + +if(ARMADILLO_INCLUDE_DIR) + + # ------------------------------------------------------------------------ + # Extract version information from + # ------------------------------------------------------------------------ + + # WARNING: Early releases of Armadillo didn't have the arma_version.hpp file. + # (e.g. v.0.9.8-1 in ubuntu maverick packages (2001-03-15)) + # If the file is missing, set all values to 0 + set(ARMADILLO_VERSION_MAJOR 0) + set(ARMADILLO_VERSION_MINOR 0) + set(ARMADILLO_VERSION_PATCH 0) + set(ARMADILLO_VERSION_NAME "EARLY RELEASE") + + if(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp") + + # Read and parse armdillo version header file for version number + file(READ "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp" _armadillo_HEADER_CONTENTS) + string(REGEX REPLACE ".*#define ARMA_VERSION_MAJOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MAJOR "${_armadillo_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define ARMA_VERSION_MINOR ([0-9]+).*" "\\1" ARMADILLO_VERSION_MINOR "${_armadillo_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define ARMA_VERSION_PATCH ([0-9]+).*" "\\1" ARMADILLO_VERSION_PATCH "${_armadillo_HEADER_CONTENTS}") + + # WARNING: The number of spaces before the version name is not one. + string(REGEX REPLACE ".*#define ARMA_VERSION_NAME\ +\"([0-9a-zA-Z\ _-]+)\".*" "\\1" ARMADILLO_VERSION_NAME "${_armadillo_HEADER_CONTENTS}") + + endif(EXISTS "${ARMADILLO_INCLUDE_DIR}/armadillo_bits/arma_version.hpp") + + set(ARMADILLO_VERSION_STRING "${ARMADILLO_VERSION_MAJOR}.${ARMADILLO_VERSION_MINOR}.${ARMADILLO_VERSION_PATCH}") +endif (ARMADILLO_INCLUDE_DIR) + +#====================== + + +# Checks 'RECQUIRED', 'QUIET' and versions. +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Armadillo + REQUIRED_VARS ARMADILLO_LIBRARY ARMADILLO_INCLUDE_DIR + VERSION_VAR ARMADILLO_VERSION_STRING) +# version_var fails with cmake < 2.8.4. + +if (ARMADILLO_FOUND) + set(ARMADILLO_INCLUDE_DIRS ${ARMADILLO_INCLUDE_DIR}) + set(ARMADILLO_LIBRARIES ${ARMADILLO_LIBRARY}) +endif (ARMADILLO_FOUND) + + +# Hide internal variables +mark_as_advanced( + ARMADILLO_INCLUDE_DIR + ARMADILLO_LIBRARY) + +#====================== diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index d57513c79..ae4a13f50 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -23,7 +23,7 @@ ########## ### List of vendors (BLA_VENDOR) valid in this module ## ATLAS, PhiPACK,CXML,DXML,SunPerf,SCSL,SGIMATH,IBMESSL,Intel10_32 (intel mkl v10 32 bit),Intel10_64lp (intel mkl v10 64 bit,lp thread model, lp64 model), -## Intel( older versions of mkl 32 and 64 bit), ACML,Apple, NAS, Generic +## Intel( older versions of mkl 32 and 64 bit), ACML,ACML_MP,Apple, NAS, Generic # C/CXX should be enabled to use Intel mkl #============================================================================= @@ -39,12 +39,23 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES) -if (NOT _LANGUAGES_ MATCHES Fortran) include(CheckFunctionExists) -else () include(CheckFortranFunctionExists) -endif() + +# Check the language being used +get_property( _LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES ) +if( _LANGUAGES_ MATCHES Fortran ) + set( _CHECK_FORTRAN TRUE ) +elseif( (_LANGUAGES_ MATCHES C) OR (_LANGUAGES_ MATCHES CXX) ) + set( _CHECK_FORTRAN FALSE ) +else() + if(BLAS_FIND_REQUIRED) + message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.") + else(BLAS_FIND_REQUIRED) + message(STATUS "Looking for BLAS... - NOT found (Unsupported languages)") + return() + endif(BLAS_FIND_REQUIRED) +endif( ) macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _threads) # This macro checks for the existence of the combination of fortran libraries @@ -102,7 +113,7 @@ if(_libraries_work) # Test this combination of libraries. set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_threads}) # message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") - if (_LANGUAGES_ MATCHES Fortran) + if (_CHECK_FORTRAN) check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS) else() check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS) @@ -244,7 +255,76 @@ if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") endif (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") #BLAS in acml library? -if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") +if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR STREQUAL "All") +# the patch from Chuck Atkins: + if( ((_BLAS_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR + ((_BLAS_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) ) + if( WIN32 ) + file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" ) + else() + file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" ) + endif() + if( _ACML_ROOT ) + get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH ) + if( SIZEOF_INTEGER EQUAL 8 ) + set( _ACML_PATH_SUFFIX "_int64" ) + else() + set( _ACML_PATH_SUFFIX "" ) + endif() + if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" ) + set( _ACML_COMPILER32 "ifort32" ) + set( _ACML_COMPILER64 "ifort64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" ) + set( _ACML_COMPILER32 "sun32" ) + set( _ACML_COMPILER64 "sun64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" ) + set( _ACML_COMPILER32 "pgi32" ) + if( WIN32 ) + set( _ACML_COMPILER64 "win64" ) + else() + set( _ACML_COMPILER64 "pgi64" ) + endif() + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" ) + # 32 bit builds not supported on Open64 but for code simplicity + # We'll just use the same directory twice + set( _ACML_COMPILER32 "open64_64" ) + set( _ACML_COMPILER64 "open64_64" ) + elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" ) + set( _ACML_COMPILER32 "nag32" ) + set( _ACML_COMPILER64 "nag64" ) + else() #if( CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" ) + set( _ACML_COMPILER32 "gfortran32" ) + set( _ACML_COMPILER64 "gfortran64" ) + endif() + + if( _BLAS_VENDOR STREQUAL "ACML_MP" ) + set(_ACML_MP_LIB_DIRS + "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib" + "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" ) + else() #if( _BLAS_VENDOR STREQUAL "ACML" ) + set(_ACML_LIB_DIRS + "${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib" + "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" ) + endif() + endif() + endif() + + if( _BLAS_VENDOR STREQUAL "ACML_MP" ) + foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS} ) + _BLAS_LOCATE_AND_TEST( ${_BLAS_VENDOR} "acml_mp;acml_mv" "" ) + if( BLAS_${_BLAS_VENDOR}_FOUND ) + break() + endif() + endforeach() + else() #if( _BLAS_VENDOR STREQUAL "ACML" ) + foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} ) + _BLAS_LOCATE_AND_TEST( ${_BLAS_VENDOR} "acml;acml_mv" "" ) + if( BLAS_${_BLAS_VENDOR}_FOUND ) + break() + endif() + endforeach() + endif() + # Either acml or acml_mp should be in LD_LIBRARY_PATH but not both if(NOT BLAS_LIBRARIES) check_fortran_libraries( @@ -266,7 +346,7 @@ if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") "" ) endif(NOT BLAS_LIBRARIES) -endif (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") +endif () # ACML # Apple BLAS library? if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 90849a1ba..6f01ea0b2 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -9,10 +9,9 @@ # The module will optionally accept the COMPONENTS argument. If no COMPONENTS # are specified, then the find module will default to finding only the HDF5 C # library. If one or more COMPONENTS are specified, the module will attempt to -# find the language bindings for the specified components. Currently, the only -# valid components are C and CXX. The module does not yet support finding the -# Fortran bindings. If the COMPONENTS argument is not given, the module will -# attempt to find only the C bindings. +# find the language bindings for the specified components. The only valid +# components are C, CXX, Fortran, and HL. If the COMPONENTS argument is not +# given, the module will attempt to find only the C bindings. # # On UNIX systems, this module will read the variable HDF5_USE_STATIC_LIBRARIES # to determine whether or not to prefer a static link to a dynamic link for HDF5 @@ -33,12 +32,15 @@ # HDF5_DEFINITIONS - Required compiler definitions for HDF5 # HDF5_C_LIBRARIES - Required libraries for the HDF5 C bindings. # HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings +# HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings +# HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API # HDF5_LIBRARIES - Required libraries for all requested bindings # HDF5_FOUND - true if HDF5 was found on the system # HDF5_LIBRARY_DIRS - the full set of library directories # HDF5_IS_PARALLEL - Whether or not HDF5 was found with parallel IO support # HDF5_C_COMPILER_EXECUTABLE - the path to the HDF5 C wrapper compiler # HDF5_CXX_COMPILER_EXECUTABLE - the path to the HDF5 C++ wrapper compiler +# HDF5_Fortran_COMPILER_EXECUTABLE - the path to the HDF5 Fortran wrapper compiler # HDF5_DIFF_EXECUTABLE - the path to the HDF5 dataset comparison tool #============================================================================= @@ -63,8 +65,26 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) set( HDF5_VALID_COMPONENTS C CXX + Fortran + HL ) +# Validate the list of find components. +if( NOT HDF5_FIND_COMPONENTS ) + set( HDF5_LANGUAGE_BINDINGS "C" ) +else() + # add the extra specified components, ensuring that they are valid. + foreach( component ${HDF5_FIND_COMPONENTS} ) + list( FIND HDF5_VALID_COMPONENTS ${component} component_location ) + if( ${component_location} EQUAL -1 ) + message( FATAL_ERROR + "\"${component}\" is not a valid HDF5 component." ) + else() + list( APPEND HDF5_LANGUAGE_BINDINGS ${component} ) + endif() + endforeach() +endif() + # try to find the HDF5 wrapper compilers find_program( HDF5_C_COMPILER_EXECUTABLE NAMES h5cc h5pcc @@ -80,6 +100,13 @@ find_program( HDF5_CXX_COMPILER_EXECUTABLE DOC "HDF5 C++ Wrapper compiler. Used only to detect HDF5 compile flags." ) mark_as_advanced( HDF5_CXX_COMPILER_EXECUTABLE ) +find_program( HDF5_Fortran_COMPILER_EXECUTABLE + NAMES h5fc h5pfc + HINTS ENV HDF5_ROOT + PATH_SUFFIXES bin Bin + DOC "HDF5 Fortran Wrapper compiler. Used only to detect HDF5 compile flags." ) +mark_as_advanced( HDF5_Fortran_COMPILER_EXECUTABLE ) + find_program( HDF5_DIFF_EXECUTABLE NAMES h5diff HINTS ENV HDF5_ROOT @@ -152,31 +179,39 @@ macro( _HDF5_parse_compile_line endforeach() endmacro() -if( HDF5_INCLUDE_DIRS AND HDF5_LIBRARIES ) - # Do nothing: we already have HDF5_INCLUDE_PATH and HDF5_LIBRARIES in the - # cache, it would be a shame to override them -else() - _HDF5_invoke_compiler( C HDF5_C_COMPILE_LINE HDF5_C_RETURN_VALUE ) - _HDF5_invoke_compiler( CXX HDF5_CXX_COMPILE_LINE HDF5_CXX_RETURN_VALUE ) - - if( NOT HDF5_FIND_COMPONENTS ) - set( HDF5_LANGUAGE_BINDINGS "C" ) - else() - # add the extra specified components, ensuring that they are valid. - foreach( component ${HDF5_FIND_COMPONENTS} ) - list( FIND HDF5_VALID_COMPONENTS ${component} component_location ) - if( ${component_location} EQUAL -1 ) - message( FATAL_ERROR - "\"${component}\" is not a valid HDF5 component." ) - else() - list( APPEND HDF5_LANGUAGE_BINDINGS ${component} ) +# Try to find HDF5 using an installed hdf5-config.cmake +if( NOT HDF5_FOUND ) + find_package( HDF5 QUIET NO_MODULE ) + if( HDF5_FOUND ) + set( HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR} ) + set( HDF5_LIBRARIES ) + set( HDF5_C_TARGET hdf5 ) + set( HDF5_CXX_TARGET hdf5_cpp ) + set( HDF5_HL_TARGET hdf5_hl ) + set( HDF5_Fortran_TARGET hdf5_fortran ) + foreach( _component ${HDF5_LANGUAGE_BINDINGS} ) + list( FIND HDF5_VALID_COMPONENTS ${_component} _component_location ) + get_target_property( _comp_location ${HDF5_${_component}_TARGET} LOCATION ) + if( _comp_location ) + set( HDF5_${_component}_LIBRARY ${_comp_location} CACHE PATH + "HDF5 ${_component} library" ) + mark_as_advanced( HDF5_${_component}_LIBRARY ) + list( APPEND HDF5_LIBRARIES ${HDF5_${_component}_LIBRARY} ) endif() endforeach() endif() - +endif() + +if( NOT HDF5_FOUND ) + _HDF5_invoke_compiler( C HDF5_C_COMPILE_LINE HDF5_C_RETURN_VALUE ) + _HDF5_invoke_compiler( CXX HDF5_CXX_COMPILE_LINE HDF5_CXX_RETURN_VALUE ) + _HDF5_invoke_compiler( Fortran HDF5_Fortran_COMPILE_LINE HDF5_Fortran_RETURN_VALUE ) + # seed the initial lists of libraries to find with items we know we need - set( HDF5_C_LIBRARY_NAMES_INIT hdf5_hl hdf5 ) + set( HDF5_C_LIBRARY_NAMES_INIT hdf5 ) + set( HDF5_HL_LIBRARY_NAMES_INIT hdf5_hl ${HDF5_C_LIBRARY_NAMES_INIT} ) set( HDF5_CXX_LIBRARY_NAMES_INIT hdf5_cpp ${HDF5_C_LIBRARY_NAMES_INIT} ) + set( HDF5_Fortran_LIBRARY_NAMES_INIT hdf5_fortran ${HDF5_C_LIBRARY_NAMES_INIT} ) foreach( LANGUAGE ${HDF5_LANGUAGE_BINDINGS} ) if( HDF5_${LANGUAGE}_COMPILE_LINE ) @@ -198,7 +233,13 @@ else() list( APPEND HDF5_DEFINITIONS ${HDF5_${LANGUAGE}_DEFINITIONS} ) # find the HDF5 include directories - find_path( HDF5_${LANGUAGE}_INCLUDE_DIR hdf5.h + if(${LANGUAGE} STREQUAL "Fortran") + set(HDF5_INCLUDE_FILENAME hdf5.mod) + else() + set(HDF5_INCLUDE_FILENAME hdf5.h) + endif() + + find_path( HDF5_${LANGUAGE}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME} HINTS ${HDF5_${LANGUAGE}_INCLUDE_FLAGS} ENV @@ -266,26 +307,41 @@ else() # We may have picked up some duplicates in various lists during the above # process for the language bindings (both the C and C++ bindings depend on - # libz for example). Remove the duplicates. + # libz for example). Remove the duplicates. It appears that the default + # CMake behavior is to remove duplicates from the end of a list. However, + # for link lines, this is incorrect since unresolved symbols are searched + # for down the link line. Therefore, we reverse the list, remove the + # duplicates, and then reverse it again to get the duplicates removed from + # the beginning. + macro( _remove_duplicates_from_beginning _list_name ) + list( REVERSE ${_list_name} ) + list( REMOVE_DUPLICATES ${_list_name} ) + list( REVERSE ${_list_name} ) + endmacro() + if( HDF5_INCLUDE_DIRS ) - list( REMOVE_DUPLICATES HDF5_INCLUDE_DIRS ) + _remove_duplicates_from_beginning( HDF5_INCLUDE_DIRS ) endif() if( HDF5_LIBRARIES_DEBUG ) - list( REMOVE_DUPLICATES HDF5_LIBRARIES_DEBUG ) + _remove_duplicates_from_beginning( HDF5_LIBRARIES_DEBUG ) endif() if( HDF5_LIBRARIES_RELEASE ) - list( REMOVE_DUPLICATES HDF5_LIBRARIES_RELEASE ) + _remove_duplicates_from_beginning( HDF5_LIBRARIES_RELEASE ) endif() if( HDF5_LIBRARY_DIRS ) - list( REMOVE_DUPLICATES HDF5_LIBRARY_DIRS ) + _remove_duplicates_from_beginning( HDF5_LIBRARY_DIRS ) endif() # Construct the complete list of HDF5 libraries with debug and optimized # variants when the generator supports them. if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) - set( HDF5_LIBRARIES - debug ${HDF5_LIBRARIES_DEBUG} - optimized ${HDF5_LIBRARIES_RELEASE} ) + set( HDF5_LIBRARIES ) + foreach( _lib ${HDF5_LIBRARIES_DEBUG} ) + list( APPEND HDF5_LIBRARIES debug ${_lib} ) + endforeach() + foreach( _lib ${HDF5_LIBRARIES_RELEASE} ) + list( APPEND HDF5_LIBRARIES optimized ${_lib} ) + endforeach() else() set( HDF5_LIBRARIES ${HDF5_LIBRARIES_RELEASE} ) endif() @@ -307,6 +363,12 @@ else() "HDF5 library compiled with parallel IO support" ) mark_as_advanced( HDF5_IS_PARALLEL ) + # For backwards compatibility we set HDF5_INCLUDE_DIR to the value of + # HDF5_INCLUDE_DIRS + if( HDF5_INCLUDE_DIRS ) + set( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" ) + endif() + endif() find_package_handle_standard_args( HDF5 DEFAULT_MSG @@ -314,15 +376,3 @@ find_package_handle_standard_args( HDF5 DEFAULT_MSG HDF5_INCLUDE_DIRS ) -mark_as_advanced( - HDF5_INCLUDE_DIRS - HDF5_LIBRARIES - HDF5_DEFINTIONS - HDF5_LIBRARY_DIRS - HDF5_C_COMPILER_EXECUTABLE - HDF5_CXX_COMPILER_EXECUTABLE ) - -# For backwards compatibility we set HDF5_INCLUDE_DIR to the value of -# HDF5_INCLUDE_DIRS -set( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" ) - diff --git a/Modules/FindITK.cmake b/Modules/FindITK.cmake index 5f43dd951..a3ca99899 100644 --- a/Modules/FindITK.cmake +++ b/Modules/FindITK.cmake @@ -37,19 +37,21 @@ # If this succeeds (possibly because ITK_DIR is already set), the # command will have already loaded ITKConfig.cmake and set ITK_FOUND. IF(NOT ITK_FOUND) - FIND_PACKAGE(ITK QUIET NO_MODULE + SET(_ITK_REQUIRED "") + IF(ITK_FIND_REQUIRED) + SET(_ITK_REQUIRED REQUIRED) + ENDIF() + SET(_ITK_QUIET "") + IF(ITK_FIND_QUIETLY) + SET(_ITK_QUIET QUIET) + ENDIF() + FIND_PACKAGE(ITK ${_ITK_REQUIRED} ${_ITK_QUIET} NO_MODULE NAMES ITK InsightToolkit CONFIGS ITKConfig.cmake ) ENDIF() -SET(ITK_DIR_MESSAGE "Please set ITK_DIR to the directory containing ITKConfig.cmake. This is either the root of the build tree, or PREFIX/lib/InsightToolkit for an installation.") - IF(ITK_FOUND) # Set USE_ITK_FILE for backward-compatability. SET(USE_ITK_FILE ${ITK_USE_FILE}) -ELSEIF(ITK_FIND_REQUIRED) - MESSAGE(FATAL_ERROR ${ITK_DIR_MESSAGE}) -ELSEIF(NOT ITK_FIND_QUIETLY) - MESSAGE(STATUS ${ITK_DIR_MESSAGE}) ENDIF() diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 6ba1826c8..59211019e 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -114,6 +114,7 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES /usr/lib/jvm/java-1.5.0-sun/jre/lib/{libarch} /usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/{libarch} # can this one be removed according to #8821 ? Alex /usr/lib/jvm/java-6-openjdk/jre/lib/{libarch} + /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/{libarch} # fedora # Debian specific paths for default JVM /usr/lib/jvm/default-java/jre/lib/{libarch} /usr/lib/jvm/default-java/jre/lib @@ -226,6 +227,8 @@ FIND_PATH(JAVA_INCLUDE_PATH2 jni_md.h ${JAVA_INCLUDE_PATH}/linux ${JAVA_INCLUDE_PATH}/freebsd ${JAVA_INCLUDE_PATH}/solaris + ${JAVA_INCLUDE_PATH}/hp-ux + ${JAVA_INCLUDE_PATH}/alpha ) FIND_PATH(JAVA_AWT_INCLUDE_PATH jawt.h diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index 8c2128e71..6431836bf 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -42,7 +42,7 @@ #============================================================================= # Copyright 2002-2009 Kitware, Inc. -# Copyright 2009 Mathieu Malaterre +# Copyright 2009-2011 Mathieu Malaterre # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -105,9 +105,9 @@ IF(Java_JAVA_EXECUTABLE) # 2. OpenJDK 1.6 # 3. GCJ 1.5 # 4. Kaffe 1.4.2 - IF(var MATCHES "java version \"[0-9]+\\.[0-9]+\\.[0-9_]+[oem-]*\".*") + IF(var MATCHES "java version \"[0-9]+\\.[0-9]+\\.[0-9_.]+[oem-]*\".*") # This is most likely Sun / OpenJDK, or maybe GCJ-java compat layer - STRING( REGEX REPLACE ".* version \"([0-9]+\\.[0-9]+\\.[0-9_]+)[oem-]*\".*" + STRING( REGEX REPLACE ".* version \"([0-9]+\\.[0-9]+\\.[0-9_.]+)[oem-]*\".*" "\\1" Java_VERSION_STRING "${var}" ) ELSEIF(var MATCHES "java full version \"kaffe-[0-9]+\\.[0-9]+\\.[0-9_]+\".*") # Kaffe style @@ -122,7 +122,7 @@ IF(Java_JAVA_EXECUTABLE) STRING( REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" Java_VERSION_MINOR "${Java_VERSION_STRING}" ) STRING( REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" Java_VERSION_PATCH "${Java_VERSION_STRING}" ) # warning tweak version can be empty: - STRING( REGEX REPLACE "[0-9]+\\.[0-9]+\\.[0-9]+\\_?([0-9]*)$" "\\1" Java_VERSION_TWEAK "${Java_VERSION_STRING}" ) + STRING( REGEX REPLACE "[0-9]+\\.[0-9]+\\.[0-9]+\\_?\\.?([0-9]*)$" "\\1" Java_VERSION_TWEAK "${Java_VERSION_STRING}" ) if( Java_VERSION_TWEAK STREQUAL "" ) # check case where tweak is not defined set(Java_VERSION ${Java_VERSION_MAJOR}.${Java_VERSION_MINOR}.${Java_VERSION_PATCH}) else( ) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index a81a53b0b..1d42a91d2 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -1,59 +1,70 @@ -# - Message Passing Interface (MPI) module. -# +# - Find a Message Passing Interface (MPI) implementation # The Message Passing Interface (MPI) is a library used to write -# high-performance parallel applications that use message passing, and +# high-performance distributed-memory parallel applications, and # is typically deployed on a cluster. MPI is a standard interface # (defined by the MPI forum) for which many implementations are -# available. All of these implementations have somewhat different -# compilation approaches (different include paths, libraries to link -# against, etc.), and this module tries to smooth out those differences. -# -# This module will set the following variables: -# MPI_FOUND TRUE if we have found MPI -# MPI_COMPILE_FLAGS Compilation flags for MPI programs -# MPI_INCLUDE_PATH Include path(s) for MPI header -# MPI_LINK_FLAGS Linking flags for MPI programs -# MPI_LIBRARY First MPI library to link against (cached) -# MPI_EXTRA_LIBRARY Extra MPI libraries to link against (cached) -# MPI_LIBRARIES All libraries to link MPI programs against -# MPIEXEC Executable for running MPI programs -# MPIEXEC_NUMPROC_FLAG Flag to pass to MPIEXEC before giving it the -# number of processors to run on -# MPIEXEC_PREFLAGS Flags to pass to MPIEXEC directly before the -# executable to run. -# MPIEXEC_POSTFLAGS Flags to pass to MPIEXEC after all other flags. +# available. All of them have somewhat different include paths, +# libraries to link against, etc., and this module tries to smooth +# out those differences. # -# This module will attempt to auto-detect these settings, first by -# looking for a MPI compiler, which many MPI implementations provide -# as a pass-through to the native compiler to simplify the compilation -# of MPI programs. The MPI compiler is stored in the cache variable -# MPI_COMPILER, and will attempt to look for commonly-named drivers -# mpic++, mpicxx, mpiCC, or mpicc. If the compiler driver is found and -# recognized, it will be used to set all of the module variables. To -# skip this auto-detection, set MPI_LIBRARY and MPI_INCLUDE_PATH in -# the CMake cache. +# === Variables === # -# If no compiler driver is found or the compiler driver is not -# recognized, this module will then search for common include paths -# and library names to try to detect MPI. +# This module will set the following variables per language in your project, +# where is one of C, CXX, or Fortran: +# MPI__FOUND TRUE if FindMPI found MPI flags for +# MPI__COMPILER MPI Compiler wrapper for +# MPI__COMPILE_FLAGS Compilation flags for MPI programs +# MPI__INCLUDE_PATH Include path(s) for MPI header +# MPI__LINK_FLAGS Linking flags for MPI programs +# MPI__LIBRARIES All libraries to link MPI programs against +# Additionally, FindMPI sets the following variables for running MPI +# programs from the command line: +# MPIEXEC Executable for running MPI programs +# MPIEXEC_NUMPROC_FLAG Flag to pass to MPIEXEC before giving +# it the number of processors to run on +# MPIEXEC_PREFLAGS Flags to pass to MPIEXEC directly +# before the executable to run. +# MPIEXEC_POSTFLAGS Flags to pass to MPIEXEC after other flags +# === Usage === # -# If CMake initially finds a different MPI than was intended, and you -# want to use the MPI compiler auto-detection for a different MPI -# implementation, set MPI_COMPILER to the MPI compiler driver you want -# to use (e.g., mpicxx) and then set MPI_LIBRARY to the string -# MPI_LIBRARY-NOTFOUND. When you re-configure, auto-detection of MPI -# will run again with the newly-specified MPI_COMPILER. +# To use this module, simply call FindMPI from a CMakeLists.txt file, or +# run find_package(MPI), then run CMake. If you are happy with the auto- +# detected configuration for your language, then you're done. If not, you +# have two options: +# 1. Set MPI__COMPILER to the MPI wrapper (mpicc, etc.) of your +# choice and reconfigure. FindMPI will attempt to determine all the +# necessary variables using THAT compiler's compile and link flags. +# 2. If this fails, or if your MPI implementation does not come with +# a compiler wrapper, then set both MPI__LIBRARIES and +# MPI__INCLUDE_PATH. You may also set any other variables +# listed above, but these two are required. This will circumvent +# autodetection entirely. +# When configuration is successful, MPI__COMPILER will be set to the +# compiler wrapper for , if it was found. MPI__FOUND and other +# variables above will be set if any MPI implementation was found for , +# regardless of whether a compiler was found. # -# When using MPIEXEC to execute MPI applications, you should typically -# use all of the MPIEXEC flags as follows: -# ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} PROCS ${MPIEXEC_PREFLAGS} EXECUTABLE -# ${MPIEXEC_POSTFLAGS} ARGS +# When using MPIEXEC to execute MPI applications, you should typically use +# all of the MPIEXEC flags as follows: +# ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} PROCS +# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS # where PROCS is the number of processors on which to execute the program, # EXECUTABLE is the MPI program, and ARGS are the arguments to pass to the # MPI program. +# +# === Backward Compatibility === +# +# For backward compatibility with older versions of FindMPI, these +# variables are set, but deprecated: +# MPI_FOUND MPI_COMPILER MPI_LIBRARY +# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_EXTRA_LIBRARY +# MPI_LINK_FLAGS MPI_LIBRARIES +# In new projects, please use the MPI__XXX equivalents. #============================================================================= -# Copyright 2001-2009 Kitware, Inc. +# Copyright 2001-2011 Kitware, Inc. +# Copyright 2010-2011 Todd Gamblin tgamblin@llnl.gov +# Copyright 2001-2009 Dave Partyka # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -65,295 +76,484 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -# This module is maintained by David Partyka . - -# A set of directories to search through in addition to the standard system paths -# that find_program will search through. -# Microsoft HPC SDK is automatically added to the system path -# Argonne National Labs MPICH2 sets a registry key that we can use. - -set(_MPI_PACKAGE_DIR - mpi - mpich - openmpi - lib/mpi - lib/mpich - lib/openmpi - "MPICH/SDK" - "Microsoft Compute Cluster Pack" - "Microsoft HPC Pack 2008 R2" - ) +# include this to handle the QUIETLY and REQUIRED arguments +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +include(GetPrerequisites) + +# +# This part detects MPI compilers, attempting to wade through the mess of compiler names in +# a sensible way. +# +# The compilers are detected in this order: +# +# 1. Try to find the most generic availble MPI compiler, as this is usually set up by +# cluster admins. e.g., if plain old mpicc is available, we'll use it and assume it's +# the right compiler. +# +# 2. If a generic mpicc is NOT found, then we attempt to find one that matches +# CMAKE__COMPILER_ID. e.g. if you are using XL compilers, we'll try to find mpixlc +# and company, but not mpiicc. This hopefully prevents toolchain mismatches. +# +# If you want to force a particular MPI compiler other than what we autodetect (e.g. if you +# want to compile regular stuff with GNU and parallel stuff with Intel), you can always set +# your favorite MPI__COMPILER explicitly and this stuff will be ignored. +# + +# Start out with the generic MPI compiler names, as these are most commonly used. +set(_MPI_C_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r) +set(_MPI_CXX_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++ + mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r) +set(_MPI_Fortran_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r + mpif90 mpif90_r mpf90 mpf90_r + mpif77 mpif77_r mpf77 mpf77_r) + +# GNU compiler names +set(_MPI_GNU_C_COMPILER_NAMES mpigcc mpgcc mpigcc_r mpgcc_r) +set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r) +set(_MPI_GNU_Fortran_COMPILER_NAMES mpigfortran mpgfortran mpigfortran_r mpgfortran_r + mpig77 mpig77_r mpg77 mpg77_r) + +# Intel MPI compiler names +set(_MPI_Intel_C_COMPILER_NAMES mpiicc) +set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++ mpiiCC) +set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77) + +# PGI compiler names +set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc) +set(_MPI_PGI_CXX_COMPILER_NAMES mpipgCC mppgCC) +set(_MPI_PGI_Fortran_COMPILER_NAMES mpipgf95 mpipgf90 mppgf95 mppgf90 mpipgf77 mppgf77) + +# XLC MPI Compiler names +set(_MPI_XL_C_COMPILER_NAMES mpxlc mpxlc_r mpixlc mpixlc_r) +set(_MPI_XL_CXX_COMPILER_NAMES mpixlcxx mpixlC mpixlc++ mpxlcxx mpxlc++ mpixlc++ mpxlCC + mpixlcxx_r mpixlC_r mpixlc++_r mpxlcxx_r mpxlc++_r mpixlc++_r mpxlCC_r) +set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95_r + mpixlf90 mpixlf90_r mpxlf90 mpxlf90_r + mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r + mpixlf mpixlf_r mpxlf mpxlf_r) + +# append vendor-specific compilers to the list if we either don't know the compiler id, +# or if we know it matches the regular compiler. +foreach (lang C CXX Fortran) + foreach (id GNU Intel PGI XL) + if (NOT CMAKE_${lang}_COMPILER_ID OR "${CMAKE_${lang}_COMPILER_ID}" STREQUAL "${id}") + list(APPEND _MPI_${lang}_COMPILER_NAMES ${_MPI_${id}_${lang}_COMPILER_NAMES}) + endif() + unset(_MPI_${id}_${lang}_COMPILER_NAMES) # clean up the namespace here + endforeach() +endforeach() + +# Names to try for MPI exec +set(_MPI_EXEC_NAMES mpiexec mpirun lamexec srun) + +# Grab the path to MPI from the registry if we're on windows. set(_MPI_PREFIX_PATH) if(WIN32) list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/..") list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]") + list(APPEND _MPI_PREFIX_PATH "$ENV{ProgramW6432}/MPICH2/") endif() +# Build a list of prefixes to search for MPI. foreach(SystemPrefixDir ${CMAKE_SYSTEM_PREFIX_PATH}) foreach(MpiPackageDir ${_MPI_PREFIX_PATH}) if(EXISTS ${SystemPrefixDir}/${MpiPackageDir}) list(APPEND _MPI_PREFIX_PATH "${SystemPrefixDir}/${MpiPackageDir}") endif() - endforeach(MpiPackageDir) -endforeach(SystemPrefixDir) + endforeach() +endforeach() + + +# +# interrogate_mpi_compiler(lang try_libs) +# +# Attempts to extract compiler and linker args from an MPI compiler. The arguments set +# by this function are: +# +# MPI__INCLUDE_PATH MPI__LINK_FLAGS MPI__FOUND +# MPI__COMPILE_FLAGS MPI__LIBRARIES +# +# MPI__COMPILER must be set beforehand to the absolute path to an MPI compiler for +# . Additionally, MPI__INCLUDE_PATH and MPI__LIBRARIES may be set +# to skip autodetection. +# +# If try_libs is TRUE, this will also attempt to find plain MPI libraries in the usual +# way. In general, this is not as effective as interrogating the compilers, as it +# ignores language-specific flags and libraries. However, some MPI implementations +# (Windows implementations) do not have compiler wrappers, so this approach must be used. +# +function (interrogate_mpi_compiler lang try_libs) + # if it's already in the cache, don't bother with any of this stuff + if ((NOT MPI_${lang}_INCLUDE_PATH) OR (NOT MPI_${lang}_LIBRARIES)) + if (MPI_${lang}_COMPILER) + # Check whether the -showme:compile option works. This indicates that we have either OpenMPI + # or a newer version of LAM-MPI, and implies that -showme:link will also work. + execute_process( + COMMAND ${MPI_${lang}_COMPILER} -showme:compile + OUTPUT_VARIABLE MPI_COMPILE_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE MPI_COMPILE_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE MPI_COMPILER_RETURN) + + if (MPI_COMPILER_RETURN EQUAL 0) + # If we appear to have -showme:compile, then we should + # also have -showme:link. Try it. + execute_process( + COMMAND ${MPI_${lang}_COMPILER} -showme:link + OUTPUT_VARIABLE MPI_LINK_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE MPI_LINK_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE MPI_COMPILER_RETURN) + + if (MPI_COMPILER_RETURN EQUAL 0) + # We probably have -showme:incdirs and -showme:libdirs as well, + # so grab that while we're at it. + execute_process( + COMMAND ${MPI_${lang}_COMPILER} -showme:incdirs + OUTPUT_VARIABLE MPI_INCDIRS OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE MPI_INCDIRS ERROR_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND ${MPI_${lang}_COMPILER} -showme:libdirs + OUTPUT_VARIABLE MPI_LIBDIRS OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE MPI_LIBDIRS ERROR_STRIP_TRAILING_WHITESPACE) + + else() + # reset things here if something went wrong. + set(MPI_COMPILE_CMDLINE) + set(MPI_LINK_CMDLINE) + endif() + endif () + + # Older versions of LAM-MPI have "-showme". Try to find that. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + execute_process( + COMMAND ${MPI_${lang}_COMPILER} -showme + OUTPUT_VARIABLE MPI_COMPILE_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE MPI_COMPILE_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE MPI_COMPILER_RETURN) + endif() + + # MVAPICH uses -compile-info and -link-info. Try them. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + execute_process( + COMMAND ${MPI_${lang}_COMPILER} -compile-info + OUTPUT_VARIABLE MPI_COMPILE_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE MPI_COMPILE_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE MPI_COMPILER_RETURN) + + # If we have compile-info, also have link-info. + if (MPI_COMPILER_RETURN EQUAL 0) + execute_process( + COMMAND ${MPI_${lang}_COMPILER} -link-info + OUTPUT_VARIABLE MPI_LINK_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE MPI_LINK_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE MPI_COMPILER_RETURN) + endif() + + # make sure we got compile and link. Reset vars if something's wrong. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + set(MPI_COMPILE_CMDLINE) + set(MPI_LINK_CMDLINE) + endif() + endif() + + # MPICH just uses "-show". Try it. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + execute_process( + COMMAND ${MPI_${lang}_COMPILER} -show + OUTPUT_VARIABLE MPI_COMPILE_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE MPI_COMPILE_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE MPI_COMPILER_RETURN) + endif() + + if (MPI_COMPILER_RETURN EQUAL 0) + # We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE + # into MPI_LINK_CMDLINE, if we didn't find the link line. + if (NOT MPI_LINK_CMDLINE) + set(MPI_LINK_CMDLINE ${MPI_COMPILE_CMDLINE}) + endif() + else() + message(STATUS "Unable to determine MPI from MPI driver ${MPI_${lang}_COMPILER}") + set(MPI_COMPILE_CMDLINE) + set(MPI_LINK_CMDLINE) + endif() + + # Here, we're done with the interrogation part, and we'll try to extract args we care + # about from what we learned from the compiler wrapper scripts. + + # If interrogation came back with something, extract our variable from the MPI command line + if (MPI_COMPILE_CMDLINE OR MPI_LINK_CMDLINE) + # Extract compile flags from the compile command line. + string(REGEX MATCHALL "(^| )-[Df]([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}") + set(MPI_COMPILE_FLAGS_WORK) + + foreach(FLAG ${MPI_ALL_COMPILE_FLAGS}) + if (MPI_COMPILE_FLAGS_WORK) + set(MPI_COMPILE_FLAGS_WORK "${MPI_COMPILE_FLAGS_WORK} ${FLAG}") + else() + set(MPI_COMPILE_FLAGS_WORK ${FLAG}) + endif() + endforeach() + + # Extract include paths from compile command line + string(REGEX MATCHALL "(^| )-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") + foreach(IPATH ${MPI_ALL_INCLUDE_PATHS}) + string(REGEX REPLACE "^ ?-I" "" IPATH ${IPATH}) + string(REGEX REPLACE "//" "/" IPATH ${IPATH}) + list(APPEND MPI_INCLUDE_PATH_WORK ${IPATH}) + endforeach() + + # try using showme:incdirs if extracting didn't work. + if (NOT MPI_INCLUDE_PATH_WORK) + set(MPI_INCLUDE_PATH_WORK ${MPI_INCDIRS}) + separate_arguments(MPI_INCLUDE_PATH_WORK) + endif() + + # If all else fails, just search for mpi.h in the normal include paths. + if (NOT MPI_INCLUDE_PATH_WORK) + set(MPI_HEADER_PATH "MPI_HEADER_PATH-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + find_path(MPI_HEADER_PATH mpi.h + HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} + PATH_SUFFIXES include) + set(MPI_INCLUDE_PATH_WORK ${MPI_HEADER_PATH}) + endif() + + # Extract linker paths from the link command line + string(REGEX MATCHALL "(^| |-Wl,)-L([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") + set(MPI_LINK_PATH) + foreach(LPATH ${MPI_ALL_LINK_PATHS}) + string(REGEX REPLACE "^(| |-Wl,)-L" "" LPATH ${LPATH}) + string(REGEX REPLACE "//" "/" LPATH ${LPATH}) + list(APPEND MPI_LINK_PATH ${LPATH}) + endforeach() + + # try using showme:libdirs if extracting didn't work. + if (NOT MPI_LINK_PATH) + set(MPI_LINK_PATH ${MPI_LIBDIRS}) + separate_arguments(MPI_LINK_PATH) + endif() + + # Extract linker flags from the link command line + string(REGEX MATCHALL "(^| )-Wl,([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") + set(MPI_LINK_FLAGS_WORK) + foreach(FLAG ${MPI_ALL_LINK_FLAGS}) + if (MPI_LINK_FLAGS_WORK) + set(MPI_LINK_FLAGS_WORK "${MPI_LINK_FLAGS_WORK} ${FLAG}") + else() + set(MPI_LINK_FLAGS_WORK ${FLAG}) + endif() + endforeach() + + # Extract the set of libraries to link against from the link command + # line + string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") + + # Determine full path names for all of the libraries that one needs + # to link against in an MPI program + foreach(LIB ${MPI_LIBNAMES}) + string(REGEX REPLACE "^ ?-l" "" LIB ${LIB}) + # MPI_LIB is cached by find_library, but we don't want that. Clear it first. + set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + find_library(MPI_LIB NAMES ${LIB} HINTS ${MPI_LINK_PATH}) + + if (MPI_LIB) + list(APPEND MPI_LIBRARIES_WORK ${MPI_LIB}) + elseif (NOT MPI_FIND_QUIETLY) + message(WARNING "Unable to find MPI library ${LIB}") + endif() + endforeach() + + # Sanity check MPI_LIBRARIES to make sure there are enough libraries + list(LENGTH MPI_LIBRARIES_WORK MPI_NUMLIBS) + list(LENGTH MPI_LIBNAMES MPI_NUMLIBS_EXPECTED) + if (NOT MPI_NUMLIBS EQUAL MPI_NUMLIBS_EXPECTED) + set(MPI_LIBRARIES_WORK "MPI_${lang}_LIBRARIES-NOTFOUND") + endif() + endif() + + elseif(try_libs) + # If we didn't have an MPI compiler script to interrogate, attempt to find everything + # with plain old find functions. This is nasty because MPI implementations have LOTS of + # different library names, so this section isn't going to be very generic. We need to + # make sure it works for MS MPI, though, since there are no compiler wrappers for that. + find_path(MPI_HEADER_PATH mpi.h + HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} + PATH_SUFFIXES include Inc) + set(MPI_INCLUDE_PATH_WORK ${MPI_HEADER_PATH}) + + # Decide between 32-bit and 64-bit libraries for Microsoft's MPI + if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) + set(MS_MPI_ARCH_DIR amd64) + else() + set(MS_MPI_ARCH_DIR i386) + endif() + + set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + find_library(MPI_LIB + NAMES mpi mpich mpich2 msmpi + HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} + PATH_SUFFIXES lib lib/${MS_MPI_ARCH_DIR} Lib Lib/${MS_MPI_ARCH_DIR}) + set(MPI_LIBRARIES_WORK ${MPI_LIB}) + + # Right now, we only know about the extra libs for C++. + # We could add Fortran here (as there is usually libfmpich, etc.), but + # this really only has to work with MS MPI on Windows. + # Assume that other MPI's are covered by the compiler wrappers. + if (${lang} STREQUAL CXX) + set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + find_library(MPI_LIB + NAMES mpi++ mpicxx cxx mpi_cxx + HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} + PATH_SUFFIXES lib) + if (MPI_LIBRARIES_WORK AND MPI_LIB) + set(MPI_LIBRARIES_WORK "${MPI_LIBRARIES_WORK} ${MPI_LIB}") + endif() + endif() + + if (NOT MPI_LIBRARIES_WORK) + set(MPI_LIBRARIES_WORK "MPI_${lang}_LIBRARIES-NOTFOUND") + endif() + endif() + + # If we found MPI, set up all of the appropriate cache entries + set(MPI_${lang}_COMPILE_FLAGS ${MPI_COMPILE_FLAGS_WORK} CACHE STRING "MPI ${lang} compilation flags" FORCE) + set(MPI_${lang}_INCLUDE_PATH ${MPI_INCLUDE_PATH_WORK} CACHE STRING "MPI ${lang} include path" FORCE) + set(MPI_${lang}_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI ${lang} linking flags" FORCE) + set(MPI_${lang}_LIBRARIES ${MPI_LIBRARIES_WORK} CACHE STRING "MPI ${lang} libraries to link against" FORCE) + mark_as_advanced(MPI_${lang}_COMPILE_FLAGS MPI_${lang}_INCLUDE_PATH MPI_${lang}_LINK_FLAGS MPI_${lang}_LIBRARIES) + + # clear out our temporary lib/header detectionv variable here. + set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI lib detection" FORCE) + set(MPI_HEADER_PATH "MPI_HEADER_PATH-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI header detection" FORCE) + endif() + + # finally set a found variable for each MPI language + if (MPI_${lang}_INCLUDE_PATH AND MPI_${lang}_LIBRARIES) + set(MPI_${lang}_FOUND TRUE PARENT_SCOPE) + else() + set(MPI_${lang}_FOUND FALSE PARENT_SCOPE) + endif() +endfunction() + + +# End definitions, commence real work here. # Most mpi distros have some form of mpiexec which gives us something we can reliably look for. find_program(MPIEXEC - NAMES mpiexec mpirun lamexec + NAMES ${_MPI_EXEC_NAMES} PATHS ${_MPI_PREFIX_PATH} PATH_SUFFIXES bin - DOC "Executable for running MPI programs." - ) + DOC "Executable for running MPI programs.") # call get_filename_component twice to remove mpiexec and the directory it exists in (typically bin). # This gives us a fairly reliable base directory to search for /bin /lib and /include from. get_filename_component(_MPI_BASE_DIR "${MPIEXEC}" PATH) get_filename_component(_MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH) -# If there is an mpi compiler find it and interogate (farther below) it for the include -# and lib dirs otherwise we will continue to search from ${_MPI_BASE_DIR}. -find_program(MPI_COMPILER - NAMES mpic++ mpicxx mpiCC mpicc - HINTS "${_MPI_BASE_DIR}" - PATH_SUFFIXES bin - DOC "MPI compiler. Used only to detect MPI compilation flags.") -mark_as_advanced(MPI_COMPILER) - set(MPIEXEC_NUMPROC_FLAG "-np" CACHE STRING "Flag used by MPI to specify the number of processes for MPIEXEC; the next option will be the number of processes.") -set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by MPIEXEC.") -set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will come after all flags given to MPIEXEC.") -set(MPIEXEC_MAX_NUMPROCS "2" CACHE STRING "Maximum number of processors available to run MPI applications.") -mark_as_advanced(MPIEXEC MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS - MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS) - -if (MPI_INCLUDE_PATH AND MPI_LIBRARY) - # Do nothing: we already have MPI_INCLUDE_PATH and MPI_LIBRARY in - # the cache, and we don't want to override those settings. -elseif (MPI_COMPILER) - # Check whether the -showme:compile option works. This indicates - # that we have either Open MPI or a newer version of LAM-MPI, and - # implies that -showme:link will also work. - # Note that Windows distros do not have an mpi compiler to interogate. - exec_program(${MPI_COMPILER} - ARGS -showme:compile - OUTPUT_VARIABLE MPI_COMPILE_CMDLINE - RETURN_VALUE MPI_COMPILER_RETURN) - - if (MPI_COMPILER_RETURN EQUAL 0) - # If we appear to have -showme:compile, then we should also have - # -showme:link. Try it. - exec_program(${MPI_COMPILER} - ARGS -showme:link - OUTPUT_VARIABLE MPI_LINK_CMDLINE - RETURN_VALUE MPI_COMPILER_RETURN) - - # Note that we probably have -showme:incdirs and -showme:libdirs - # as well. - set(MPI_COMPILER_MAY_HAVE_INCLIBDIRS TRUE) - endif (MPI_COMPILER_RETURN EQUAL 0) - - if (MPI_COMPILER_RETURN EQUAL 0) - # Do nothing: we have our command lines now - else (MPI_COMPILER_RETURN EQUAL 0) - # Older versions of LAM-MPI have "-showme". Try it. - exec_program(${MPI_COMPILER} - ARGS -showme - OUTPUT_VARIABLE MPI_COMPILE_CMDLINE - RETURN_VALUE MPI_COMPILER_RETURN) - endif (MPI_COMPILER_RETURN EQUAL 0) - - if (MPI_COMPILER_RETURN EQUAL 0) - # Do nothing: we have our command lines now - else (MPI_COMPILER_RETURN EQUAL 0) - # MPICH uses "-show". Try it. - exec_program(${MPI_COMPILER} - ARGS -show - OUTPUT_VARIABLE MPI_COMPILE_CMDLINE - RETURN_VALUE MPI_COMPILER_RETURN) - endif (MPI_COMPILER_RETURN EQUAL 0) - - if (MPI_COMPILER_RETURN EQUAL 0) - # We have our command lines, but we might need to copy - # MPI_COMPILE_CMDLINE into MPI_LINK_CMDLINE, if the underlying - if (NOT MPI_LINK_CMDLINE) - SET(MPI_LINK_CMDLINE ${MPI_COMPILE_CMDLINE}) - endif (NOT MPI_LINK_CMDLINE) - else (MPI_COMPILER_RETURN EQUAL 0) - message(STATUS "Unable to determine MPI from MPI driver ${MPI_COMPILER}") - endif (MPI_COMPILER_RETURN EQUAL 0) -endif (MPI_INCLUDE_PATH AND MPI_LIBRARY) - -if (MPI_INCLUDE_PATH AND MPI_LIBRARY) - # Do nothing: we already have MPI_INCLUDE_PATH and MPI_LIBRARY in - # the cache, and we don't want to override those settings. -elseif (MPI_COMPILE_CMDLINE) - # Extract compile flags from the compile command line. - string(REGEX MATCHALL "(^| )-[Df]([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}") - set(MPI_COMPILE_FLAGS_WORK) - foreach(FLAG ${MPI_ALL_COMPILE_FLAGS}) - if (MPI_COMPILE_FLAGS_WORK) - set(MPI_COMPILE_FLAGS_WORK "${MPI_COMPILE_FLAGS_WORK} ${FLAG}") - else(MPI_COMPILE_FLAGS_WORK) - set(MPI_COMPILE_FLAGS_WORK ${FLAG}) - endif(MPI_COMPILE_FLAGS_WORK) - endforeach(FLAG) - - # Extract include paths from compile command line - string(REGEX MATCHALL "(^| )-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") - set(MPI_INCLUDE_PATH_WORK) - foreach(IPATH ${MPI_ALL_INCLUDE_PATHS}) - string(REGEX REPLACE "^ ?-I" "" IPATH ${IPATH}) - string(REGEX REPLACE "//" "/" IPATH ${IPATH}) - list(APPEND MPI_INCLUDE_PATH_WORK ${IPATH}) - endforeach(IPATH) - - if (NOT MPI_INCLUDE_PATH_WORK) - if (MPI_COMPILER_MAY_HAVE_INCLIBDIRS) - # The compile command line didn't have any include paths on it, - # but we may have -showme:incdirs. Use it. - exec_program(${MPI_COMPILER} - ARGS -showme:incdirs - OUTPUT_VARIABLE MPI_INCLUDE_PATH_WORK - RETURN_VALUE MPI_COMPILER_RETURN) - separate_arguments(MPI_INCLUDE_PATH_WORK) - endif (MPI_COMPILER_MAY_HAVE_INCLIBDIRS) - endif (NOT MPI_INCLUDE_PATH_WORK) - - if (NOT MPI_INCLUDE_PATH_WORK) - # If all else fails, just search for mpi.h in the normal include - # paths. - find_path(MPI_INCLUDE_PATH mpi.h - HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} - PATH_SUFFIXES include - ) - set(MPI_INCLUDE_PATH_WORK ${MPI_INCLUDE_PATH}) - endif (NOT MPI_INCLUDE_PATH_WORK) - - # Extract linker paths from the link command line - string(REGEX MATCHALL "(^| |-Wl,)-L([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") - set(MPI_LINK_PATH) - foreach(LPATH ${MPI_ALL_LINK_PATHS}) - string(REGEX REPLACE "^(| |-Wl,)-L" "" LPATH ${LPATH}) - string(REGEX REPLACE "//" "/" LPATH ${LPATH}) - list(APPEND MPI_LINK_PATH ${LPATH}) - endforeach(LPATH) - - if (NOT MPI_LINK_PATH) - if (MPI_COMPILER_MAY_HAVE_INCLIBDIRS) - # The compile command line didn't have any linking paths on it, - # but we may have -showme:libdirs. Use it. - exec_program(${MPI_COMPILER} - ARGS -showme:libdirs - OUTPUT_VARIABLE MPI_LINK_PATH - RETURN_VALUE MPI_COMPILER_RETURN) - separate_arguments(MPI_LINK_PATH) - endif (MPI_COMPILER_MAY_HAVE_INCLIBDIRS) - endif (NOT MPI_LINK_PATH) - - # Extract linker flags from the link command line - string(REGEX MATCHALL "(^| )-Wl,([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") - set(MPI_LINK_FLAGS_WORK) - foreach(FLAG ${MPI_ALL_LINK_FLAGS}) - if (MPI_LINK_FLAGS_WORK) - set(MPI_LINK_FLAGS_WORK "${MPI_LINK_FLAGS_WORK} ${FLAG}") - else(MPI_LINK_FLAGS_WORK) - set(MPI_LINK_FLAGS_WORK ${FLAG}) - endif(MPI_LINK_FLAGS_WORK) - endforeach(FLAG) - - # Extract the set of libraries to link against from the link command - # line - string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") - - # Determine full path names for all of the libraries that one needs - # to link against in an MPI program - set(MPI_LIBRARIES) - foreach(LIB ${MPI_LIBNAMES}) - string(REGEX REPLACE "^ ?-l" "" LIB ${LIB}) - set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) - find_library(MPI_LIB ${LIB} HINTS ${MPI_LINK_PATH}) - if (MPI_LIB) - list(APPEND MPI_LIBRARIES ${MPI_LIB}) - elseif (NOT MPI_FIND_QUIETLY) - message(WARNING "Unable to find MPI library ${LIB}") - endif () - endforeach(LIB) - set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI detection" FORCE) - - # Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and - # MPI_EXTRA_LIBRARY. - list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) - list(LENGTH MPI_LIBNAMES MPI_NUMLIBS_EXPECTED) - if (MPI_NUMLIBS EQUAL MPI_NUMLIBS_EXPECTED) - list(GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK) - set(MPI_LIBRARY ${MPI_LIBRARY_WORK} CACHE FILEPATH "MPI library to link against" FORCE) - else (MPI_NUMLIBS EQUAL MPI_NUMLIBS_EXPECTED) - set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND" CACHE FILEPATH "MPI library to link against" FORCE) - endif (MPI_NUMLIBS EQUAL MPI_NUMLIBS_EXPECTED) - if (MPI_NUMLIBS GREATER 1) - set(MPI_EXTRA_LIBRARY_WORK ${MPI_LIBRARIES}) - list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0) - set(MPI_EXTRA_LIBRARY ${MPI_EXTRA_LIBRARY_WORK} CACHE STRING "Extra MPI libraries to link against" FORCE) - else (MPI_NUMLIBS GREATER 1) - set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND" CACHE STRING "Extra MPI libraries to link against" FORCE) - endif (MPI_NUMLIBS GREATER 1) - - # Set up all of the appropriate cache entries - set(MPI_COMPILE_FLAGS ${MPI_COMPILE_FLAGS_WORK} CACHE STRING "MPI compilation flags" FORCE) - set(MPI_INCLUDE_PATH ${MPI_INCLUDE_PATH_WORK} CACHE STRING "MPI include path" FORCE) - set(MPI_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI linking flags" FORCE) -else (MPI_COMPILE_CMDLINE) -# No MPI compiler to interogate so attempt to find everything with find functions. - find_path(MPI_INCLUDE_PATH mpi.h - HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} - PATH_SUFFIXES include Inc - ) - - # Decide between 32-bit and 64-bit libraries for Microsoft's MPI - if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) - set(MS_MPI_ARCH_DIR amd64) - else() - set(MS_MPI_ARCH_DIR i386) +set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by MPIEXEC.") +set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will come after all flags given to MPIEXEC.") +set(MPIEXEC_MAX_NUMPROCS "2" CACHE STRING "Maximum number of processors available to run MPI applications.") +mark_as_advanced(MPIEXEC MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS) + + +#============================================================================= +# Backward compatibility input hacks. Propagate the FindMPI hints to C and +# CXX if the respective new versions are not defined. Translate the old +# MPI_LIBRARY and MPI_EXTRA_LIBRARY to respective MPI_${lang}_LIBRARIES. +# +# Once we find the new variables, we translate them back into their old +# equivalents below. +foreach (lang C CXX) + # Old input variables. + set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS) + + # Set new vars based on their old equivalents, if the new versions are not already set. + foreach (var ${_MPI_OLD_INPUT_VARS}) + if (NOT MPI_${lang}_${var} AND MPI_${var}) + set(MPI_${lang}_${var} "${MPI_${var}}") + endif() + endforeach() + + # Special handling for MPI_LIBRARY and MPI_EXTRA_LIBRARY, which we nixed in the + # new FindMPI. These need to be merged into MPI__LIBRARIES + if (NOT MPI_${lang}_LIBRARIES AND (MPI_LIBRARY OR MPI_EXTRA_LIBRARY)) + set(MPI_${lang}_LIBRARIES ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY}) endif() +endforeach() +#============================================================================= - find_library(MPI_LIBRARY - NAMES mpi mpich msmpi - HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} - PATH_SUFFIXES lib lib/${MS_MPI_ARCH_DIR} Lib Lib/${MS_MPI_ARCH_DIR} - ) - - find_library(MPI_EXTRA_LIBRARY - NAMES mpi++ - HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} - PATH_SUFFIXES lib - DOC "Extra MPI libraries to link against.") - - set(MPI_COMPILE_FLAGS "" CACHE STRING "MPI compilation flags") - set(MPI_LINK_FLAGS "" CACHE STRING "MPI linking flags") -endif (MPI_INCLUDE_PATH AND MPI_LIBRARY) - -# Set up extra variables to conform to -if (MPI_EXTRA_LIBRARY) - set(MPI_LIBRARIES ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY}) -else (MPI_EXTRA_LIBRARY) - set(MPI_LIBRARIES ${MPI_LIBRARY}) -endif (MPI_EXTRA_LIBRARY) - -if (MPI_INCLUDE_PATH AND MPI_LIBRARY) - set(MPI_FOUND TRUE) -else (MPI_INCLUDE_PATH AND MPI_LIBRARY) + +# This loop finds the compilers and sends them off for interrogation. +foreach (lang C CXX Fortran) + if (CMAKE_${lang}_COMPILER_WORKS) + # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler. + if (MPI_${lang}_COMPILER) + is_file_executable(MPI_${lang}_COMPILER MPI_COMPILER_IS_EXECUTABLE) + if (NOT MPI_COMPILER_IS_EXECUTABLE) + # Get rid of our default list of names and just search for the name the user wants. + set(_MPI_${lang}_COMPILER_NAMES ${MPI_${lang}_COMPILER}) + set(MPI_${lang}_COMPILER "MPI_${lang}_COMPILER-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + # If the user specifies a compiler, we don't want to try to search libraries either. + set(try_libs FALSE) + endif() + else() + set(try_libs TRUE) + endif() + + find_program(MPI_${lang}_COMPILER + NAMES ${_MPI_${lang}_COMPILER_NAMES} + PATHS "${MPI_HOME}/bin" "$ENV{MPI_HOME}/bin" ${_MPI_PREFIX_PATH}) + interrogate_mpi_compiler(${lang} ${try_libs}) + mark_as_advanced(MPI_${lang}_COMPILER) + + # Treat each language separately as far as outputting whether we found support for it and setting MPI__FOUND. + find_package_handle_standard_args(MPI_${lang} DEFAULT_MSG MPI_${lang}_LIBRARIES MPI_${lang}_INCLUDE_PATH) + endif() +endforeach() + + +#============================================================================= +# More backward compatibility stuff +# +# Bare MPI sans ${lang} vars are set to CXX then C, depending on what was found. +# This mimics the behavior of the old language-oblivious FindMPI. +set(_MPI_OLD_VARS FOUND COMPILER INCLUDE_PATH COMPILE_FLAGS LINK_FLAGS LIBRARIES) +if (MPI_CXX_FOUND) + foreach (var ${_MPI_OLD_VARS}) + set(MPI_${var} ${MPI_CXX_${var}}) + endforeach() +elseif (MPI_C_FOUND) + foreach (var ${_MPI_OLD_VARS}) + set(MPI_${var} ${MPI_C_${var}}) + endforeach() +else() + # Note that we might still have found Fortran, but you'll need to use MPI_Fortran_FOUND set(MPI_FOUND FALSE) -endif (MPI_INCLUDE_PATH AND MPI_LIBRARY) +endif() -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -# handle the QUIETLY and REQUIRED arguments -find_package_handle_standard_args(MPI DEFAULT_MSG MPI_LIBRARY MPI_INCLUDE_PATH) +# Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and MPI_EXTRA_LIBRARY, and set them in cache. +if (MPI_LIBRARIES) + list(GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK) + set(MPI_LIBRARY ${MPI_LIBRARY_WORK} CACHE FILEPATH "MPI library to link against" FORCE) +else() + set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND" CACHE FILEPATH "MPI library to link against" FORCE) +endif() -mark_as_advanced(MPI_INCLUDE_PATH MPI_COMPILE_FLAGS MPI_LINK_FLAGS MPI_LIBRARY - MPI_EXTRA_LIBRARY) +list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) +if (MPI_NUMLIBS GREATER 1) + set(MPI_EXTRA_LIBRARY_WORK ${MPI_LIBRARIES}) + list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0) + set(MPI_EXTRA_LIBRARY ${MPI_EXTRA_LIBRARY_WORK} CACHE STRING "Extra MPI libraries to link against" FORCE) +else() + set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND" CACHE STRING "Extra MPI libraries to link against" FORCE) +endif() +#============================================================================= -# unset to cleanup namespace -unset(_MPI_PACKAGE_DIR) +# unset these vars to cleanup namespace +unset(_MPI_OLD_VARS) unset(_MPI_PREFIX_PATH) unset(_MPI_BASE_DIR) +foreach (lang C CXX Fortran) + unset(_MPI_${lang}_COMPILER_NAMES) +endforeach() diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index f41a66bc5..af799d6b7 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -7,11 +7,12 @@ # OPENSSL_FOUND - system has the OpenSSL library # OPENSSL_INCLUDE_DIR - the OpenSSL include directory # OPENSSL_LIBRARIES - The libraries needed to use OpenSSL +# OPENSSL_VERSION - This is set to $major.$minor.$revision (eg. 0.9.8) #============================================================================= # Copyright 2006-2009 Kitware, Inc. # Copyright 2006 Alexander Neundorf -# Copyright 2009-2010 Mathieu Malaterre +# Copyright 2009-2011 Mathieu Malaterre # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -23,24 +24,41 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +if (UNIX) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(_OPENSSL openssl) + endif (PKG_CONFIG_FOUND) +endif (UNIX) + # http://www.slproweb.com/products/Win32OpenSSL.html SET(_OPENSSL_ROOT_HINTS + $ENV{OPENSSL_ROOT_DIR} + ${OPENSSL_ROOT_DIR} "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]" ) SET(_OPENSSL_ROOT_PATHS + "$ENV{PROGRAMFILES}/OpenSSL" + "$ENV{PROGRAMFILES}/OpenSSL-Win32" + "$ENV{PROGRAMFILES}/OpenSSL-Win64" "C:/OpenSSL/" + "C:/OpenSSL-Win32/" + "C:/OpenSSL-Win64/" ) -FIND_PATH(OPENSSL_ROOT_DIR - NAMES include/openssl/ssl.h +SET(_OPENSSL_ROOT_HINTS_AND_PATHS HINTS ${_OPENSSL_ROOT_HINTS} PATHS ${_OPENSSL_ROOT_PATHS} -) -MARK_AS_ADVANCED(OPENSSL_ROOT_DIR) + ) -# Re-use the previous path: -FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h - PATHS ${OPENSSL_ROOT_DIR}/include +FIND_PATH(OPENSSL_INCLUDE_DIR + NAMES + openssl/ssl.h + HINTS + ${_OPENSSL_INCLUDEDIR} + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + include ) IF(WIN32 AND NOT CYGWIN) @@ -60,18 +78,52 @@ IF(WIN32 AND NOT CYGWIN) # We are using the libraries located in the VC subdir instead of the parent directory eventhough : # libeay32MD.lib is identical to ../libeay32.lib, and # ssleay32MD.lib is identical to ../ssleay32.lib - FIND_LIBRARY(LIB_EAY_DEBUG NAMES libeay32MDd libeay32 - PATHS ${OPENSSL_ROOT_DIR}/lib/VC - ) - FIND_LIBRARY(LIB_EAY_RELEASE NAMES libeay32MD libeay32 - PATHS ${OPENSSL_ROOT_DIR}/lib/VC - ) - FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssleay32 ssl - PATHS ${OPENSSL_ROOT_DIR}/lib/VC - ) - FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssleay32 ssl - PATHS ${OPENSSL_ROOT_DIR}/lib/VC - ) + FIND_LIBRARY(LIB_EAY_DEBUG + NAMES + libeay32MDd + libeay32 + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "VC" + "lib/VC" + ) + + FIND_LIBRARY(LIB_EAY_RELEASE + NAMES + libeay32MD + libeay32 + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "VC" + "lib/VC" + ) + + FIND_LIBRARY(SSL_EAY_DEBUG + NAMES + ssleay32MDd + ssleay32 + ssl + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "VC" + "lib/VC" + ) + + FIND_LIBRARY(SSL_EAY_RELEASE + NAMES + ssleay32MD + ssleay32 + ssl + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "VC" + "lib/VC" + ) + if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) set( OPENSSL_LIBRARIES optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG} @@ -84,40 +136,115 @@ IF(WIN32 AND NOT CYGWIN) MARK_AS_ADVANCED(LIB_EAY_DEBUG LIB_EAY_RELEASE) ELSEIF(MINGW) # same player, for MingW - FIND_LIBRARY(LIB_EAY NAMES libeay32 - PATHS ${OPENSSL_ROOT_DIR}/lib/MinGW - ) - FIND_LIBRARY(SSL_EAY NAMES ssleay32 - PATHS ${OPENSSL_ROOT_DIR}/lib/MinGW - ) + FIND_LIBRARY(LIB_EAY + NAMES + libeay32 + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "lib/MinGW" + ) + + FIND_LIBRARY(SSL_EAY + NAMES + ssleay32 + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "lib/MinGW" + ) + MARK_AS_ADVANCED(SSL_EAY LIB_EAY) set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) ELSE(MSVC) # Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues: - FIND_LIBRARY(LIB_EAY NAMES libeay32 - PATHS ${OPENSSL_ROOT_DIR}/lib - ) - FIND_LIBRARY(SSL_EAY NAMES ssleay32 - PATHS ${OPENSSL_ROOT_DIR}/lib - ) + FIND_LIBRARY(LIB_EAY + NAMES + libeay32 + HINTS + ${_OPENSSL_LIBDIR} + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + lib + ) + + FIND_LIBRARY(SSL_EAY + NAMES + ssleay32 + HINTS + ${_OPENSSL_LIBDIR} + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + lib + ) + MARK_AS_ADVANCED(SSL_EAY LIB_EAY) set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) ENDIF(MSVC) ELSE(WIN32 AND NOT CYGWIN) - FIND_LIBRARY(OPENSSL_SSL_LIBRARIES NAMES ssl ssleay32 ssleay32MD) - FIND_LIBRARY(OPENSSL_CRYPTO_LIBRARIES NAMES crypto) - MARK_AS_ADVANCED(OPENSSL_CRYPTO_LIBRARIES OPENSSL_SSL_LIBRARIES) + FIND_LIBRARY(OPENSSL_SSL_LIBRARY + NAMES + ssl + ssleay32 + ssleay32MD + HINTS + ${_OPENSSL_LIBDIR} + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + lib + ) - SET(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES}) + FIND_LIBRARY(OPENSSL_CRYPTO_LIBRARY + NAMES + crypto + HINTS + ${_OPENSSL_LIBDIR} + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + lib + ) + + MARK_AS_ADVANCED(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY) + + # compat defines + SET(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY}) + SET(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) + + SET(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) ENDIF(WIN32 AND NOT CYGWIN) +if (OPENSSL_INCLUDE_DIR) + file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str REGEX "^#define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x[0-9][0-9][0-9][0-9][0-9][0-9].*") + + string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9]).*$" "\\1" OPENSSL_VERSION_MAJOR "${openssl_version_str}") + string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x[0-9]([0-9][0-9]).*$" "\\1" OPENSSL_VERSION_MINOR "${openssl_version_str}") + string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x[0-9][0-9][0-9]([0-9][0-9]).*$" "\\1" OPENSSL_VERSION_PATCH "${openssl_version_str}") + + string(REGEX REPLACE "^0" "" OPENSSL_VERSION_MINOR "${OPENSSL_VERSION_MINOR}") + string(REGEX REPLACE "^0" "" OPENSSL_VERSION_PATCH "${OPENSSL_VERSION_PATCH}") + + set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_PATCH}") +endif (OPENSSL_INCLUDE_DIR) + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -find_package_handle_standard_args(OpenSSL DEFAULT_MSG - OPENSSL_LIBRARIES - OPENSSL_INCLUDE_DIR -) -MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES) +if (OPENSSL_VERSION) + find_package_handle_standard_args(OpenSSL + REQUIRED_VARS + OPENSSL_LIBRARIES + OPENSSL_INCLUDE_DIR + VERSION_VAR + OPENSSL_VERSION + FAIL_MESSAGE + "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR" + ) +else (OPENSSL_VERSION) + find_package_handle_standard_args(OpenSSL "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR" + OPENSSL_LIBRARIES + OPENSSL_INCLUDE_DIR + ) +endif (OPENSSL_VERSION) +MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES) diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index 6455c99e1..96b674112 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -1,6 +1,4 @@ -# Find the PostgreSQL installation. -# -# ---------------------------------------------------------------------------- +# - Find the PostgreSQL installation. # Usage: # In your CMakeLists.txt file do something like this: # ... diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index a6e665360..38f5a7572 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -1,15 +1,31 @@ # Locate and configure the Google Protocol Buffers library. +# +# The following variables can be set and are optional: +# +# PROTOBUF_SRC_ROOT_FOLDER - When compiling with MSVC, if this cache variable is set +# the protobuf-default VS project build locations +# (vsprojects/Debug & vsprojects/Release) will be searched +# for libraries and binaries. +# # Defines the following variables: # -# PROTOBUF_FOUND - Found the Google Protocol Buffers library +# PROTOBUF_FOUND - Found the Google Protocol Buffers library (libprotobuf & header files) # PROTOBUF_INCLUDE_DIRS - Include directories for Google Protocol Buffers -# PROTOBUF_LIBRARIES - The protobuf library +# PROTOBUF_LIBRARIES - The protobuf libraries +# [New in CMake 2.8.5] +# PROTOBUF_PROTOC_LIBRARIES - The protoc libraries +# PROTOBUF_LITE_LIBRARIES - The protobuf-lite libraries # -# The following cache variables are also defined: +# The following cache variables are also available to set or use: # PROTOBUF_LIBRARY - The protobuf library # PROTOBUF_PROTOC_LIBRARY - The protoc library # PROTOBUF_INCLUDE_DIR - The include directory for protocol buffers # PROTOBUF_PROTOC_EXECUTABLE - The protoc compiler +# [New in CMake 2.8.5] +# PROTOBUF_LIBRARY_DEBUG - The protobuf library (debug) +# PROTOBUF_PROTOC_LIBRARY_DEBUG - The protoc library (debug) +# PROTOBUF_LITE_LIBRARY - The protobuf lite library +# PROTOBUF_LITE_LIBRARY_DEBUG - The protobuf lite library (debug) # # ==================================================================== # Example: @@ -20,7 +36,7 @@ # include_directories(${CMAKE_CURRENT_BINARY_DIR}) # PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS foo.proto) # add_executable(bar bar.cc ${PROTO_SRCS} ${PROTO_HDRS}) -# target_link_libraries(bar ${PROTOBUF_LIBRARY}) +# target_link_libraries(bar ${PROTOBUF_LIBRARIES}) # # NOTE: You may need to link against pthreads, depending # on the platform. @@ -38,7 +54,7 @@ #============================================================================= # Copyright 2009 Kitware, Inc. -# Copyright 2009 Philip Lowman +# Copyright 2009-2011 Philip Lowman # Copyright 2008 Esben Mose Hansen, Ange Optimization ApS # # Distributed under the OSI-approved BSD License (the "License"); @@ -57,6 +73,20 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS) return() endif(NOT ARGN) + if(PROTOBUF_GENERATE_CPP_APPEND_PATH) + # Create an include path for each file specified + foreach(FIL ${ARGN}) + get_filename_component(ABS_FIL ${FIL} ABSOLUTE) + get_filename_component(ABS_PATH ${ABS_FIL} PATH) + list(FIND _protobuf_include_path ${ABS_PATH} _contains_already) + if(${_contains_already} EQUAL -1) + list(APPEND _protobuf_include_path -I ${ABS_PATH}) + endif() + endforeach() + else() + set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR}) + endif() + set(${SRCS}) set(${HDRS}) foreach(FIL ${ARGN}) @@ -70,7 +100,7 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS) OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc" "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h" COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} - ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} --proto_path ${CMAKE_CURRENT_SOURCE_DIR} ${ABS_FIL} + ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL} DEPENDS ${ABS_FIL} COMMENT "Running C++ protocol buffer compiler on ${FIL}" VERBATIM ) @@ -81,41 +111,91 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS) set(${HDRS} ${${HDRS}} PARENT_SCOPE) endfunction() +# Internal function: search for normal library as well as a debug one +# if the debug one is specified also include debug/optimized keywords +# in *_LIBRARIES variable +function(_protobuf_find_libraries name filename) + find_library(${name}_LIBRARY + NAMES ${filename} + PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Release) + mark_as_advanced(${name}_LIBRARY) + + find_library(${name}_LIBRARY_DEBUG + NAMES ${filename} + PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Debug) + mark_as_advanced(${name}_LIBRARY_DEBUG) + + if(NOT ${name}_LIBRARY_DEBUG) + # There is no debug library + set(${name}_LIBRARY_DEBUG ${${name}_LIBRARY} PARENT_SCOPE) + set(${name}_LIBRARIES ${${name}_LIBRARY} PARENT_SCOPE) + else() + # There IS a debug library + set(${name}_LIBRARIES + optimized ${${name}_LIBRARY} + debug ${${name}_LIBRARY_DEBUG} + PARENT_SCOPE + ) + endif() +endfunction() + +# +# Main. +# + +# By default have PROTOBUF_GENERATE_CPP macro pass -I to protoc +# for each directory where a proto file is referenced. +if(NOT DEFINED PROTOBUF_GENERATE_CPP_APPEND_PATH) + set(PROTOBUF_GENERATE_CPP_APPEND_PATH TRUE) +endif() -find_path(PROTOBUF_INCLUDE_DIR google/protobuf/service.h) # Google's provided vcproj files generate libraries with a "lib" # prefix on Windows -if(WIN32) +if(MSVC) set(PROTOBUF_ORIG_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "") + + find_path(PROTOBUF_SRC_ROOT_FOLDER protobuf.pc.in) endif() -find_library(PROTOBUF_LIBRARY NAMES protobuf - DOC "The Google Protocol Buffers Library" -) -find_library(PROTOBUF_PROTOC_LIBRARY NAMES protoc - DOC "The Google Protocol Buffers Compiler Library" -) -find_program(PROTOBUF_PROTOC_EXECUTABLE NAMES protoc - DOC "The Google Protocol Buffers Compiler" -) +# The Protobuf library +_protobuf_find_libraries(PROTOBUF protobuf) +#DOC "The Google Protocol Buffers RELEASE Library" + +_protobuf_find_libraries(PROTOBUF_LITE protobuf-lite) -mark_as_advanced(PROTOBUF_INCLUDE_DIR - PROTOBUF_LIBRARY - PROTOBUF_PROTOC_LIBRARY - PROTOBUF_PROTOC_EXECUTABLE) +# The Protobuf Protoc Library +_protobuf_find_libraries(PROTOBUF_PROTOC protoc) # Restore original find library prefixes -if(WIN32) +if(MSVC) set(CMAKE_FIND_LIBRARY_PREFIXES "${PROTOBUF_ORIG_FIND_LIBRARY_PREFIXES}") endif() + +# Find the include directory +find_path(PROTOBUF_INCLUDE_DIR + google/protobuf/service.h + PATHS ${PROTOBUF_SRC_ROOT_FOLDER}/src +) +mark_as_advanced(PROTOBUF_INCLUDE_DIR) + +# Find the protoc Executable +find_program(PROTOBUF_PROTOC_EXECUTABLE + NAMES protoc + DOC "The Google Protocol Buffers Compiler" + PATHS + ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Release + ${PROTOBUF_SRC_ROOT_FOLDER}/vsprojects/Debug +) +mark_as_advanced(PROTOBUF_PROTOC_EXECUTABLE) + + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROTOBUF DEFAULT_MSG PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR) if(PROTOBUF_FOUND) set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIR}) - set(PROTOBUF_LIBRARIES ${PROTOBUF_LIBRARY}) endif() diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 79a3d51fb..86fce9df6 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -9,7 +9,7 @@ # QT_LIBRARIES variable. # # Typical usage could be something like: -# find_package(Qt4 4.4.3 COMPONENTS QtCore QtGui QtXml REQUIRED ) +# find_package(Qt4 4.4.3 REQUIRED QtCore QtGui QtXml) # include(${QT_USE_FILE}) # add_executable(myexe main.cpp) # target_link_libraries(myexe ${QT_LIBRARIES}) @@ -354,6 +354,7 @@ ENDIF(QT_QT_LIBRARY) INCLUDE(CheckSymbolExists) INCLUDE(MacroAddFileDependencies) +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake) @@ -374,12 +375,20 @@ MACRO (_QT4_ADJUST_LIB_VARS _camelCaseBasename) IF (QT_${basename}_LIBRARY_RELEASE) SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) - SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}" ) + if(QT_USE_FRAMEWORKS) + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}/${_camelCaseBasename}" ) + else() + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}" ) + endif() ENDIF (QT_${basename}_LIBRARY_RELEASE) IF (QT_${basename}_LIBRARY_DEBUG) SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) - SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}" ) + if(QT_USE_FRAMEWORKS) + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}/${_camelCaseBasename}" ) + else() + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}" ) + endif() ENDIF (QT_${basename}_LIBRARY_DEBUG) ENDIF(NOT TARGET Qt4::${_camelCaseBasename}) @@ -472,6 +481,7 @@ FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 qmake-mac PATHS DOC "The qmake executable for the Qt installation to use" ) +# double check that it was a Qt4 qmake, if not, re-find with different names IF (QT_QMAKE_EXECUTABLE) IF(QT_QMAKE_EXECUTABLE_LAST) @@ -480,8 +490,6 @@ IF (QT_QMAKE_EXECUTABLE) SET(QT_QMAKE_EXECUTABLE_LAST "${QT_QMAKE_EXECUTABLE}" CACHE INTERNAL "" FORCE) - SET(QT4_QMAKE_FOUND FALSE) - _qt4_query_qmake(QT_VERSION QTVERSION) # check for qt3 qmake and then try and find qmake4 or qmake-qt4 in the path @@ -498,74 +506,9 @@ IF (QT_QMAKE_EXECUTABLE) ENDIF(QT_QMAKE_EXECUTABLE) ENDIF(NOT QTVERSION) - # check that we found the Qt4 qmake, Qt3 qmake output won't match here - STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" qt_version_tmp "${QTVERSION}") - IF (qt_version_tmp) - - # we need at least version 4.0.0 - IF (NOT QT_MIN_VERSION) - SET(QT_MIN_VERSION "4.0.0") - ENDIF (NOT QT_MIN_VERSION) - - #now parse the parts of the user given version string into variables - STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" req_qt_major_vers "${QT_MIN_VERSION}") - IF (NOT req_qt_major_vers) - MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"4.0.1\"") - ENDIF (NOT req_qt_major_vers) - - # now parse the parts of the user given version string into variables - STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}") - STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers "${QT_MIN_VERSION}") - STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}") - - # Suppport finding at least a particular version, for instance FIND_PACKAGE( Qt4 4.4.3 ) - # This implementation is a hack to avoid duplicating code and make sure we stay - # source-compatible with CMake 2.6.x - IF( Qt4_FIND_VERSION ) - SET( QT_MIN_VERSION ${Qt4_FIND_VERSION} ) - SET( req_qt_major_vers ${Qt4_FIND_VERSION_MAJOR} ) - SET( req_qt_minor_vers ${Qt4_FIND_VERSION_MINOR} ) - SET( req_qt_patch_vers ${Qt4_FIND_VERSION_PATCH} ) - ENDIF( Qt4_FIND_VERSION ) - - IF (NOT req_qt_major_vers EQUAL 4) - MESSAGE( FATAL_ERROR "Invalid Qt version string given: \"${QT_MIN_VERSION}\", major version 4 is required, e.g. \"4.0.1\"") - ENDIF (NOT req_qt_major_vers EQUAL 4) - - # and now the version string given by qmake - STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" QT_VERSION_MAJOR "${QTVERSION}") - STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" QT_VERSION_MINOR "${QTVERSION}") - STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" QT_VERSION_PATCH "${QTVERSION}") - - # compute an overall version number which can be compared at once - MATH(EXPR req_vers "${req_qt_major_vers}*10000 + ${req_qt_minor_vers}*100 + ${req_qt_patch_vers}") - MATH(EXPR found_vers "${QT_VERSION_MAJOR}*10000 + ${QT_VERSION_MINOR}*100 + ${QT_VERSION_PATCH}") - - # Support finding *exactly* a particular version, for instance FIND_PACKAGE( Qt4 4.4.3 EXACT ) - IF( Qt4_FIND_VERSION_EXACT ) - IF(found_vers EQUAL req_vers) - SET( QT4_QMAKE_FOUND TRUE ) - ELSE(found_vers EQUAL req_vers) - SET( QT4_QMAKE_FOUND FALSE ) - IF (found_vers LESS req_vers) - SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE) - ELSE (found_vers LESS req_vers) - SET(QT4_INSTALLED_VERSION_TOO_NEW TRUE) - ENDIF (found_vers LESS req_vers) - ENDIF(found_vers EQUAL req_vers) - ELSE( Qt4_FIND_VERSION_EXACT ) - IF (found_vers LESS req_vers) - SET(QT4_QMAKE_FOUND FALSE) - SET(QT4_INSTALLED_VERSION_TOO_OLD TRUE) - ELSE (found_vers LESS req_vers) - SET(QT4_QMAKE_FOUND TRUE) - ENDIF (found_vers LESS req_vers) - ENDIF( Qt4_FIND_VERSION_EXACT ) - ENDIF (qt_version_tmp) - ENDIF (QT_QMAKE_EXECUTABLE) -IF (QT4_QMAKE_FOUND) +IF (QT_QMAKE_EXECUTABLE AND QTVERSION) # ask qmake for the mkspecs directory # we do this first because QT_LIBINFIX might be set @@ -600,21 +543,32 @@ IF (QT4_QMAKE_FOUND) # ask qmake for the library dir as a hint, then search for QtCore library and use that as a reference for finding the # others and for setting QT_LIBRARY_DIR - IF (NOT QT_QTCORE_LIBRARY OR QT_QMAKE_CHANGED) + IF (NOT (QT_QTCORE_LIBRARY_RELEASE OR QT_QTCORE_LIBRARY_DEBUG) OR QT_QMAKE_CHANGED) _qt4_query_qmake(QT_INSTALL_LIBS QT_LIBRARY_DIR_TMP) SET(QT_QTCORE_LIBRARY_RELEASE NOTFOUND) SET(QT_QTCORE_LIBRARY_DEBUG NOTFOUND) FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE NAMES QtCore${QT_LIBINFIX} QtCore${QT_LIBINFIX}4 HINTS ${QT_LIBRARY_DIR_TMP} - NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH + NO_DEFAULT_PATH ) FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG NAMES QtCore${QT_LIBINFIX}_debug QtCore${QT_LIBINFIX}d QtCore${QT_LIBINFIX}d4 HINTS ${QT_LIBRARY_DIR_TMP} - NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH + NO_DEFAULT_PATH ) + IF(NOT QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCORE_LIBRARY_DEBUG) + FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE + NAMES QtCore${QT_LIBINFIX} QtCore${QT_LIBINFIX}4 + HINTS ${QT_LIBRARY_DIR_TMP} + ) + FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG + NAMES QtCore${QT_LIBINFIX}_debug QtCore${QT_LIBINFIX}d QtCore${QT_LIBINFIX}d4 + HINTS ${QT_LIBRARY_DIR_TMP} + ) + ENDIF(NOT QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCORE_LIBRARY_DEBUG) + # try dropping a hint if trying to use Visual Studio with Qt built by mingw IF(NOT QT_QTCORE_LIBRARY_RELEASE AND MSVC) IF(EXISTS ${QT_LIBRARY_DIR_TMP}/libqtmain.a) @@ -622,7 +576,18 @@ IF (QT4_QMAKE_FOUND) ENDIF(EXISTS ${QT_LIBRARY_DIR_TMP}/libqtmain.a) ENDIF(NOT QT_QTCORE_LIBRARY_RELEASE AND MSVC) - ENDIF (NOT QT_QTCORE_LIBRARY OR QT_QMAKE_CHANGED) + ENDIF () + + IF (APPLE) + SET(CMAKE_FIND_FRAMEWORK_OLD ${CMAKE_FIND_FRAMEWORK}) + IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) + SET(QT_USE_FRAMEWORKS ON CACHE INTERNAL "" FORCE) + SET(CMAKE_FIND_FRAMEWORK FIRST) + ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) + SET(QT_USE_FRAMEWORKS OFF CACHE INTERNAL "" FORCE) + SET(CMAKE_FIND_FRAMEWORK LAST) + ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) + ENDIF (APPLE) _QT4_ADJUST_LIB_VARS(QtCore) @@ -643,15 +608,6 @@ IF (QT4_QMAKE_FOUND) ENDIF(Qt4_FIND_REQUIRED) ENDIF() - IF (APPLE) - IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - SET(QT_USE_FRAMEWORKS ON CACHE INTERNAL "" FORCE) - ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - SET(QT_USE_FRAMEWORKS OFF CACHE INTERNAL "" FORCE) - ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - MARK_AS_ADVANCED(QT_USE_FRAMEWORKS) - ENDIF (APPLE) - # ask qmake for the binary dir IF (NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) _qt4_query_qmake(QT_INSTALL_BINS qt_bins) @@ -663,8 +619,7 @@ IF (QT4_QMAKE_FOUND) _qt4_query_qmake(QT_INSTALL_HEADERS qt_headers) SET(QT_QTCORE_INCLUDE_DIR NOTFOUND) FIND_PATH(QT_QTCORE_INCLUDE_DIR QtCore - HINTS ${qt_headers} - ${QT_LIBRARY_DIR}/QtCore.framework/Headers + HINTS ${qt_headers} ${QT_LIBRARY_DIR} PATH_SUFFIXES QtCore ) @@ -682,13 +637,17 @@ IF (QT4_QMAKE_FOUND) ENDIF() ENDIF() + IF(APPLE) + SET(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_OLD}) + ENDIF(APPLE) + # Set QT_INCLUDE_DIR based on QT_HEADERS_DIR IF(QT_HEADERS_DIR) IF(QT_USE_FRAMEWORKS) # Qt/Mac frameworks has two include dirs. # One is the framework include for which CMake will add a -F flag # and the other is an include dir for non-framework Qt modules - SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR} ${QT_QTCORE_LIBRARY} ) + SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR} ${QT_QTCORE_LIBRARY_RELEASE} ) ELSE(QT_USE_FRAMEWORKS) SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR}) ENDIF(QT_USE_FRAMEWORKS) @@ -835,7 +794,7 @@ IF (QT4_QMAKE_FOUND) PATHS ${QT_HEADERS_DIR}/${QT_MODULE} ${QT_LIBRARY_DIR}/${QT_MODULE}.framework/Headers - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) # phonon doesn't seem consistent, let's try phonondefs.h for some # installations @@ -844,7 +803,7 @@ IF (QT4_QMAKE_FOUND) PATHS ${QT_HEADERS_DIR}/${QT_MODULE} ${QT_LIBRARY_DIR}/${QT_MODULE}.framework/Headers - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) ENDIF(${QT_MODULE} STREQUAL "phonon") ENDFOREACH(QT_MODULE) @@ -854,11 +813,11 @@ IF (QT4_QMAKE_FOUND) # Set QT_AXCONTAINER_INCLUDE_DIR and QT_AXSERVER_INCLUDE_DIR FIND_PATH(QT_QAXCONTAINER_INCLUDE_DIR ActiveQt PATHS ${QT_HEADERS_DIR}/ActiveQt - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) FIND_PATH(QT_QAXSERVER_INCLUDE_DIR ActiveQt PATHS ${QT_HEADERS_DIR}/ActiveQt - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) ENDIF(Q_WS_WIN) @@ -867,7 +826,7 @@ IF (QT4_QMAKE_FOUND) PATHS ${QT_HEADERS_DIR}/QtDesigner ${QT_LIBRARY_DIR}/QtDesigner.framework/Headers - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) # Set QT_QTASSISTANT_INCLUDE_DIR @@ -875,7 +834,7 @@ IF (QT4_QMAKE_FOUND) PATHS ${QT_HEADERS_DIR}/QtAssistant ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) # Set QT_QTASSISTANTCLIENT_INCLUDE_DIR @@ -883,7 +842,7 @@ IF (QT4_QMAKE_FOUND) PATHS ${QT_HEADERS_DIR}/QtAssistant ${QT_LIBRARY_DIR}/QtAssistant.framework/Headers - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) ######################################## @@ -897,11 +856,11 @@ IF (QT4_QMAKE_FOUND) STRING(TOUPPER ${QT_MODULE} _upper_qt_module) FIND_LIBRARY(QT_${_upper_qt_module}_LIBRARY_RELEASE NAMES ${QT_MODULE}${QT_LIBINFIX} ${QT_MODULE}${QT_LIBINFIX}4 - PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH + PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) FIND_LIBRARY(QT_${_upper_qt_module}_LIBRARY_DEBUG NAMES ${QT_MODULE}${QT_LIBINFIX}_debug ${QT_MODULE}${QT_LIBINFIX}d ${QT_MODULE}${QT_LIBINFIX}d4 - PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH + PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) ENDFOREACH(QT_MODULE) @@ -911,26 +870,26 @@ IF (QT4_QMAKE_FOUND) ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) # Set QT_QTDESIGNERCOMPONENTS_LIBRARY - FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents${QT_LIBINFIX} QtDesignerComponents${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NAMES QtDesignerComponents${QT_LIBINFIX}_debug QtDesignerComponents${QT_LIBINFIX}d QtDesignerComponents${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents${QT_LIBINFIX} QtDesignerComponents${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NAMES QtDesignerComponents${QT_LIBINFIX}_debug QtDesignerComponents${QT_LIBINFIX}d QtDesignerComponents${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) # Set QT_QTMAIN_LIBRARY IF(Q_WS_WIN) - FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmain${QT_LIBINFIX}d PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmain${QT_LIBINFIX}d PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) ENDIF(Q_WS_WIN) # Set QT_QTASSISTANTCLIENT_LIBRARY - FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) # Set QT_QTASSISTANT_LIBRARY - FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 QtAssistant${QT_LIBINFIX} QtAssistant${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 QtAssistant${QT_LIBINFIX}_debug QtAssistant${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 QtAssistant${QT_LIBINFIX} QtAssistant${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 QtAssistant${QT_LIBINFIX}_debug QtAssistant${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) # Set QT_QTHELP_LIBRARY - FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} QtCLucene${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_DEBUG NAMES QtCLucene${QT_LIBINFIX}_debug QtCLucene${QT_LIBINFIX}d QtCLucene${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} QtCLucene${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_DEBUG NAMES QtCLucene${QT_LIBINFIX}_debug QtCLucene${QT_LIBINFIX}d QtCLucene${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE) FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR}) ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE) @@ -942,12 +901,6 @@ IF (QT4_QMAKE_FOUND) # ############################################ - # On OSX when Qt is found as framework, never use the imported targets for now, since - # in this case the handling of the framework directory currently does not work correctly. - IF(QT_USE_FRAMEWORKS) - SET(QT_USE_IMPORTED_TARGETS FALSE) - ENDIF(QT_USE_FRAMEWORKS) - # Set QT_xyz_LIBRARY variable and add # library include path to QT_INCLUDES @@ -993,67 +946,67 @@ IF (QT4_QMAKE_FOUND) FIND_PROGRAM(QT_MOC_EXECUTABLE NAMES moc-qt4 moc PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) FIND_PROGRAM(QT_UIC_EXECUTABLE NAMES uic-qt4 uic PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) FIND_PROGRAM(QT_UIC3_EXECUTABLE NAMES uic3 PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) FIND_PROGRAM(QT_RCC_EXECUTABLE NAMES rcc PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) FIND_PROGRAM(QT_DBUSCPP2XML_EXECUTABLE NAMES qdbuscpp2xml PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) FIND_PROGRAM(QT_DBUSXML2CPP_EXECUTABLE NAMES qdbusxml2cpp PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) FIND_PROGRAM(QT_LUPDATE_EXECUTABLE NAMES lupdate-qt4 lupdate PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) FIND_PROGRAM(QT_LRELEASE_EXECUTABLE NAMES lrelease-qt4 lrelease PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) FIND_PROGRAM(QT_QCOLLECTIONGENERATOR_EXECUTABLE NAMES qcollectiongenerator-qt4 qcollectiongenerator PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) FIND_PROGRAM(QT_DESIGNER_EXECUTABLE NAMES designer-qt4 designer PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) FIND_PROGRAM(QT_LINGUIST_EXECUTABLE NAMES linguist-qt4 linguist PATHS ${QT_BINARY_DIR} - NO_DEFAULT_PATH + NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) IF (QT_MOC_EXECUTABLE) @@ -1075,32 +1028,7 @@ IF (QT4_QMAKE_FOUND) # get the directory of the current file, used later on in the file GET_FILENAME_COMPONENT( _qt4_current_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) - ###################################### - # - # decide if Qt got found - # - ###################################### - - # if the includes,libraries,moc,uic and rcc are found then we have it - IF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND - QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY) - SET( QT4_FOUND "YES" ) - INCLUDE(FindPackageMessage) - FIND_PACKAGE_MESSAGE(Qt4 "Found Qt-Version ${QTVERSION} (using ${QT_QMAKE_EXECUTABLE})" - "[${QT_LIBRARY_DIR}][${QT_INCLUDE_DIR}][${QT_MOC_EXECUTABLE}][${QT_UIC_EXECUTABLE}][${QT_RCC_EXECUTABLE}]") - ELSE( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND - QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY) - SET( QT4_FOUND "NO") - SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE) - IF( Qt4_FIND_REQUIRED) - MESSAGE( FATAL_ERROR "Qt libraries, includes, moc, uic or/and rcc NOT found!") - ENDIF( Qt4_FIND_REQUIRED) - ENDIF( QT_LIBRARY_DIR AND QT_INCLUDE_DIR AND QT_MOC_EXECUTABLE AND - QT_UIC_EXECUTABLE AND QT_RCC_EXECUTABLE AND QT_QTCORE_LIBRARY) - SET(QT_FOUND ${QT4_FOUND}) - - ############################################### # # configuration/system dependent settings @@ -1158,11 +1086,11 @@ IF (QT4_QMAKE_FOUND) IF(QT_IS_STATIC) FIND_LIBRARY(QT_${_upper_qt_plugin}_LIBRARY_RELEASE NAMES ${QT_PLUGIN}${QT_LIBINFIX} ${QT_PLUGIN}${QT_LIBINFIX}4 - PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH + PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) FIND_LIBRARY(QT_${_upper_qt_plugin}_LIBRARY_DEBUG NAMES ${QT_PLUGIN}${QT_LIBINFIX}_debug ${QT_PLUGIN}${QT_LIBINFIX}d ${QT_PLUGIN}${QT_LIBINFIX}d4 - PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH + PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) _QT4_ADJUST_LIB_VARS(${QT_PLUGIN}) ELSE(QT_IS_STATIC) @@ -1171,11 +1099,11 @@ IF (QT4_QMAKE_FOUND) SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_MODULE_SUFFIX} ${CMAKE_SHARED_LIBRARY_SUFFIX}) FIND_LIBRARY(QT_${_upper_qt_plugin}_PLUGIN_RELEASE NAMES ${QT_PLUGIN}${QT_LIBINFIX} ${QT_PLUGIN}${QT_LIBINFIX}4 - PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH + PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) FIND_LIBRARY(QT_${_upper_qt_plugin}_PLUGIN_DEBUG NAMES ${QT_PLUGIN}${QT_LIBINFIX}_debug ${QT_PLUGIN}${QT_LIBINFIX}d ${QT_PLUGIN}${QT_LIBINFIX}d4 - PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH + PATHS ${QT_${_upper_qt_plugin_type}_PLUGINS_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH ) MARK_AS_ADVANCED(QT_${_upper_qt_plugin}_PLUGIN_RELEASE QT_${_upper_qt_plugin}_PLUGIN_DEBUG) SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_DEFAULT}) @@ -1192,44 +1120,58 @@ IF (QT4_QMAKE_FOUND) INCLUDE("${_qt4_current_dir}/Qt4Macros.cmake") + # set version variables + STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" QT_VERSION_MAJOR "${QTVERSION}") + STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" QT_VERSION_MINOR "${QTVERSION}") + STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" QT_VERSION_PATCH "${QTVERSION}") - ####################################### - # - # compatibility settings - # - ####################################### - # Backwards compatibility for CMake1.4 and 1.2 - SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} ) - SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} ) - - SET( QT_QT_LIBRARY "") - -ELSE(QT4_QMAKE_FOUND) - - SET(QT_QMAKE_EXECUTABLE "${QT_QMAKE_EXECUTABLE}-NOTFOUND" CACHE FILEPATH "Invalid qmake found" FORCE) - - # The code below is overly complex to make sure we do not break compatibility with CMake 2.6.x - # For CMake 2.8, it should be simplified by getting rid of QT4_INSTALLED_VERSION_TOO_OLD and - # QT4_INSTALLED_VERSION_TOO_NEW - IF(Qt4_FIND_REQUIRED) - IF(QT4_INSTALLED_VERSION_TOO_OLD) - IF( Qt4_FIND_VERSION_EXACT ) - MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, version ${QT_MIN_VERSION} is required") - ELSE( Qt4_FIND_VERSION_EXACT ) - MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required") - ENDIF( Qt4_FIND_VERSION_EXACT ) - ELSE(QT4_INSTALLED_VERSION_TOO_OLD) - IF( Qt4_FIND_VERSION_EXACT AND QT4_INSTALLED_VERSION_TOO_NEW ) - MESSAGE(FATAL_ERROR "The installed Qt version ${QTVERSION} is too new, version ${QT_MIN_VERSION} is required") - ELSE( Qt4_FIND_VERSION_EXACT AND QT4_INSTALLED_VERSION_TOO_NEW ) - MESSAGE( FATAL_ERROR "Qt qmake not found!") - ENDIF( Qt4_FIND_VERSION_EXACT AND QT4_INSTALLED_VERSION_TOO_NEW ) - ENDIF(QT4_INSTALLED_VERSION_TOO_OLD) - ELSE(Qt4_FIND_REQUIRED) - IF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY) - MESSAGE(STATUS "The installed Qt version ${QTVERSION} is too old, at least version ${QT_MIN_VERSION} is required") - ENDIF(QT4_INSTALLED_VERSION_TOO_OLD AND NOT Qt4_FIND_QUIETLY) - ENDIF(Qt4_FIND_REQUIRED) - -ENDIF (QT4_QMAKE_FOUND) +ENDIF(QT_QMAKE_EXECUTABLE AND QTVERSION) + +#support old QT_MIN_VERSION if set, but not if version is supplied by find_package() +IF(NOT Qt4_FIND_VERSION AND QT_MIN_VERSION) + SET(Qt4_FIND_VERSION ${QT_MIN_VERSION}) +ENDIF(NOT Qt4_FIND_VERSION AND QT_MIN_VERSION) + +IF( Qt4_FIND_COMPONENTS ) + + # if components specified in find_package(), make sure each of those pieces were found + SET(_QT4_FOUND_REQUIRED_VARS QT_QMAKE_EXECUTABLE QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE QT_INCLUDE_DIR QT_LIBRARY_DIR) + FOREACH( component ${Qt4_FIND_COMPONENTS} ) + STRING( TOUPPER ${component} _COMPONENT ) + if(${_COMPONENT} STREQUAL "QTMAIN") + IF(Q_WS_WIN) + SET(_QT4_FOUND_REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS} QT_${_COMPONENT}_LIBRARY) + ENDIF(Q_WS_WIN) + else(${_COMPONENT} STREQUAL "QTMAIN") + SET(_QT4_FOUND_REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS} QT_${_COMPONENT}_INCLUDE_DIR QT_${_COMPONENT}_LIBRARY) + endif(${_COMPONENT} STREQUAL "QTMAIN") + ENDFOREACH( component ) + + if(Qt4_FIND_COMPONENTS MATCHES QtGui) + SET(_QT4_FOUND_REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS} QT_UIC_EXECUTABLE) + endif(Qt4_FIND_COMPONENTS MATCHES QtGui) + +ELSE( Qt4_FIND_COMPONENTS ) + + # if no components specified, we'll make a default set of required variables to say Qt is found + SET(_QT4_FOUND_REQUIRED_VARS QT_QMAKE_EXECUTABLE QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE QT_UIC_EXECUTABLE QT_INCLUDE_DIR + QT_LIBRARY_DIR QT_QTCORE_LIBRARY) + +ENDIF( Qt4_FIND_COMPONENTS ) + +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Qt4 + REQUIRED_VARS ${_QT4_FOUND_REQUIRED_VARS} + VERSION_VAR QTVERSION + ) + +####################################### +# +# compatibility settings +# +####################################### +# Backwards compatibility for CMake1.4 and 1.2 +SET (QT_MOC_EXE ${QT_MOC_EXECUTABLE} ) +SET (QT_UIC_EXE ${QT_UIC_EXECUTABLE} ) +SET( QT_QT_LIBRARY "") +SET(QT_FOUND ${QT4_FOUND}) diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake index 2e719ff61..8c60bcb48 100644 --- a/Modules/FindSWIG.cmake +++ b/Modules/FindSWIG.cmake @@ -15,6 +15,7 @@ #============================================================================= # Copyright 2004-2009 Kitware, Inc. +# Copyright 2011 Mathieu Malaterre # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -26,7 +27,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -FIND_PROGRAM(SWIG_EXECUTABLE swig) +FIND_PROGRAM(SWIG_EXECUTABLE swig2.0 swig) IF(SWIG_EXECUTABLE) EXECUTE_PROCESS(COMMAND ${SWIG_EXECUTABLE} -swiglib diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index 2062a7e77..77f9fda0c 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -67,7 +67,7 @@ ENDIF() # handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_INCLUDE_DIR ZLIB_LIBRARY +FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_LIBRARY ZLIB_INCLUDE_DIR VERSION_VAR ZLIB_VERSION_STRING) IF(ZLIB_FOUND) diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index 4bcaae916..d35a72ce8 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -70,6 +70,17 @@ else() endif() # Generate C symbol sources. +set(symbol_sources) +if(NOT "${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(PathScale|Cray)$") + # Provide mymodule_ and my_module_ init symbols because: + # - PGI Fortran uses module init symbols + # but not for: + # - PathScale Fortran uses module init symbols but module symbols + # use '.in.' so we cannot provide them anyway. + # - Cray Fortran >= 7.3.2 uses module init symbols but module symbols + # use 'mysub$mymodule_' so we cannot provide them anyway. + list(APPEND symbol_sources mymodule_.c my_module_.c) +endif() foreach(symbol IN LISTS global_symbols module_symbols) # Skip symbols with '$' if C cannot handle them. if(C_SUPPORTS_DOLLAR OR NOT "${symbol}" MATCHES "\\$") @@ -89,7 +100,7 @@ endforeach() add_library(myfort STATIC mysub.f my_sub.f ${myfort_modules}) # Provide symbols through C but fall back to Fortran. -add_library(symbols STATIC mymodule_.c my_module_.c ${symbol_sources}) +add_library(symbols STATIC ${symbol_sources}) target_link_libraries(symbols myfort) # Require symbols through Fortran. diff --git a/Modules/FortranCInterface/my_module_.c b/Modules/FortranCInterface/my_module_.c index 364b21460..6510ae977 100644 --- a/Modules/FortranCInterface/my_module_.c +++ b/Modules/FortranCInterface/my_module_.c @@ -1,8 +1 @@ -#if defined(__PATHSCALE__) -/* PathScale Fortran wants my_module_ when calling any my_module symbol, - but module symbols use '.in.' so we cannot provide them anyway. */ -void pathscale_my_module_(void) {} -#else -/* PGI Fortran wants my_module_ when calling any my_module symbol. */ void my_module_(void) {} -#endif diff --git a/Modules/FortranCInterface/mymodule_.c b/Modules/FortranCInterface/mymodule_.c index b5feda6ce..52706058e 100644 --- a/Modules/FortranCInterface/mymodule_.c +++ b/Modules/FortranCInterface/mymodule_.c @@ -1,8 +1 @@ -#if defined(__PATHSCALE__) -/* PathScale Fortran wants mymodule_ when calling any mymodule symbol, - but module symbols use '.in.' so we cannot provide them anyway. */ -void pathscale_mymodule_(void) {} -#else -/* PGI Fortran wants mymodule_ when calling any mymodule symbol. */ void mymodule_(void) {} -#endif diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake new file mode 100644 index 000000000..a114dcb2e --- /dev/null +++ b/Modules/GNUInstallDirs.cmake @@ -0,0 +1,182 @@ +# - Define GNU standard installation directories +# Provides install directory variables as defined for GNU software: +# http://www.gnu.org/prep/standards/html_node/Directory-Variables.html +# Inclusion of this module defines the following variables: +# CMAKE_INSTALL_ - destination for files of a given type +# CMAKE_INSTALL_FULL_ - corresponding absolute path +# where is one of: +# BINDIR - user executables (bin) +# SBINDIR - system admin executables (sbin) +# LIBEXECDIR - program executables (libexec) +# SYSCONFDIR - read-only single-machine data (etc) +# SHAREDSTATEDIR - modifiable architecture-independent data (com) +# LOCALSTATEDIR - modifiable single-machine data (var) +# LIBDIR - object code libraries (lib or lib64) +# INCLUDEDIR - C header files (include) +# OLDINCLUDEDIR - C header files for non-gcc (/usr/include) +# DATAROOTDIR - read-only architecture-independent data root (share) +# DATADIR - read-only architecture-independent data (DATAROOTDIR) +# INFODIR - info documentation (DATAROOTDIR/info) +# LOCALEDIR - locale-dependent data (DATAROOTDIR/locale) +# MANDIR - man documentation (DATAROOTDIR/man) +# DOCDIR - documentation root (DATAROOTDIR/doc/PROJECT_NAME) +# Each CMAKE_INSTALL_ value may be passed to the DESTINATION options of +# install() commands for the corresponding file type. If the includer does +# not define a value the above-shown default will be used and the value will +# appear in the cache for editing by the user. +# Each CMAKE_INSTALL_FULL_ value contains an absolute path constructed +# from the corresponding destination by prepending (if necessary) the value +# of CMAKE_INSTALL_PREFIX. + +#============================================================================= +# Copyright 2011 Nikita Krupen'ko +# Copyright 2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# Installation directories +# +if(NOT DEFINED CMAKE_INSTALL_BINDIR) + set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_SBINDIR) + set(CMAKE_INSTALL_SBINDIR "sbin" CACHE PATH "system admin executables (sbin)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_LIBEXECDIR) + set(CMAKE_INSTALL_LIBEXECDIR "libexec" CACHE PATH "program executables (libexec)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_SYSCONFDIR) + set(CMAKE_INSTALL_SYSCONFDIR "etc" CACHE PATH "read-only single-machine data (etc)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_SHAREDSTATEDIR) + set(CMAKE_INSTALL_SHAREDSTATEDIR "com" CACHE PATH "modifiable architecture-independent data (com)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_LOCALSTATEDIR) + set(CMAKE_INSTALL_LOCALSTATEDIR "var" CACHE PATH "modifiable single-machine data (var)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_LIBDIR) + set(_LIBDIR_DEFAULT "lib") + # Override this default 'lib' with 'lib64' iff: + # - we are on Linux system but NOT cross-compiling + # - we are NOT on debian + # - we are on a 64 bits system + # reason is: amd64 ABI: http://www.x86-64.org/documentation/abi.pdf + # Note that the future of multi-arch handling may be even + # more complicated than that: http://wiki.debian.org/Multiarch + if(CMAKE_SYSTEM_NAME MATCHES "Linux" + AND NOT CMAKE_CROSSCOMPILING + AND NOT EXISTS "/etc/debian_version") + if(NOT DEFINED CMAKE_SIZEOF_VOID_P) + message(AUTHOR_WARNING + "Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. " + "Please enable at least one language before including GNUInstallDirs.") + else() + if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") + set(_LIBDIR_DEFAULT "lib64") + endif() + endif() + endif() + set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "object code libraries (${_LIBDIR_DEFAULT})") +endif() + +if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR) + set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "C header files (include)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_OLDINCLUDEDIR) + set(CMAKE_INSTALL_OLDINCLUDEDIR "/usr/include" CACHE PATH "C header files for non-gcc (/usr/include)") +endif() + +if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR) + set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH "read-only architecture-independent data root (share)") +endif() + +#----------------------------------------------------------------------------- +# Values whose defaults are relative to DATAROOTDIR. Store empty values in +# the cache and store the defaults in local variables if the cache values are +# not set explicitly. This auto-updates the defaults as DATAROOTDIR changes. + +if(NOT CMAKE_INSTALL_DATADIR) + set(CMAKE_INSTALL_DATADIR "" CACHE PATH "read-only architecture-independent data (DATAROOTDIR)") + set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}") +endif() + +if(NOT CMAKE_INSTALL_INFODIR) + set(CMAKE_INSTALL_INFODIR "" CACHE PATH "info documentation (DATAROOTDIR/info)") + set(CMAKE_INSTALL_INFODIR "${CMAKE_INSTALL_DATAROOTDIR}/info") +endif() + +if(NOT CMAKE_INSTALL_LOCALEDIR) + set(CMAKE_INSTALL_LOCALEDIR "" CACHE PATH "locale-dependent data (DATAROOTDIR/locale)") + set(CMAKE_INSTALL_LOCALEDIR "${CMAKE_INSTALL_DATAROOTDIR}/locale") +endif() + +if(NOT CMAKE_INSTALL_MANDIR) + set(CMAKE_INSTALL_MANDIR "" CACHE PATH "man documentation (DATAROOTDIR/man)") + set(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man") +endif() + +if(NOT CMAKE_INSTALL_DOCDIR) + set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (DATAROOTDIR/doc/PROJECT_NAME)") + set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}") +endif() + +#----------------------------------------------------------------------------- + +mark_as_advanced( + CMAKE_INSTALL_BINDIR + CMAKE_INSTALL_SBINDIR + CMAKE_INSTALL_LIBEXECDIR + CMAKE_INSTALL_SYSCONFDIR + CMAKE_INSTALL_SHAREDSTATEDIR + CMAKE_INSTALL_LOCALSTATEDIR + CMAKE_INSTALL_LIBDIR + CMAKE_INSTALL_INCLUDEDIR + CMAKE_INSTALL_OLDINCLUDEDIR + CMAKE_INSTALL_DATAROOTDIR + CMAKE_INSTALL_DATADIR + CMAKE_INSTALL_INFODIR + CMAKE_INSTALL_LOCALEDIR + CMAKE_INSTALL_MANDIR + CMAKE_INSTALL_DOCDIR + ) + +# Result directories +# +foreach(dir + BINDIR + SBINDIR + LIBEXECDIR + SYSCONFDIR + SHAREDSTATEDIR + LOCALSTATEDIR + LIBDIR + INCLUDEDIR + OLDINCLUDEDIR + DATAROOTDIR + DATADIR + INFODIR + LOCALEDIR + MANDIR + DOCDIR + ) + if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_${dir}}) + set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}") + else() + set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}") + endif() +endforeach() diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 853b1a1b6..023b8b560 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -261,9 +261,9 @@ function(gp_resolve_item context item exepath dirs resolved_item_var) # Is it already resolved? # - if(EXISTS "${resolved_item}") + if(IS_ABSOLUTE "${resolved_item}" AND EXISTS "${resolved_item}") set(resolved 1) - endif(EXISTS "${resolved_item}") + endif(IS_ABSOLUTE "${resolved_item}" AND EXISTS "${resolved_item}") if(NOT resolved) if(item MATCHES "@executable_path") @@ -548,7 +548,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa if("${gp_tool}" STREQUAL "ldd") set(gp_cmd_args "") - set(gp_regex "^[\t ]*[^\t ]+ => ([^\t ]+).*${eol_char}$") + set(gp_regex "^[\t ]*[^\t ]+ => ([^\t\(]+) .*${eol_char}$") set(gp_regex_error "not found${eol_char}$") set(gp_regex_fallback "^[\t ]*([^\t ]+) => ([^\t ]+).*${eol_char}$") set(gp_regex_cmp_count 1) diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 2dfe8b1d0..59e5ec168 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -70,9 +70,11 @@ IF(MSVC) IF(MSVC80) # Find the runtime library redistribution directory. + GET_FILENAME_COMPONENT(msvc_install_dir + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0;InstallDir]" ABSOLUTE) FIND_PATH(MSVC80_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC80.CRT/Microsoft.VC80.CRT.manifest PATHS - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0;InstallDir]/../../VC/redist" + "${msvc_install_dir}/../../VC/redist" "${base_dir}/VC/redist" ) MARK_AS_ADVANCED(MSVC80_REDIST_DIR) @@ -103,10 +105,14 @@ IF(MSVC) IF(MSVC90) # Find the runtime library redistribution directory. + GET_FILENAME_COMPONENT(msvc_install_dir + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0;InstallDir]" ABSOLUTE) + GET_FILENAME_COMPONENT(msvc_express_install_dir + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\9.0;InstallDir]" ABSOLUTE) FIND_PATH(MSVC90_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest PATHS - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0;InstallDir]/../../VC/redist" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\9.0;InstallDir]/../../VC/redist" + "${msvc_install_dir}/../../VC/redist" + "${msvc_express_install_dir}/../../VC/redist" "${base_dir}/VC/redist" ) MARK_AS_ADVANCED(MSVC90_REDIST_DIR) @@ -137,9 +143,11 @@ IF(MSVC) IF(MSVC10) # Find the runtime library redistribution directory. + GET_FILENAME_COMPONENT(msvc_install_dir + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]" ABSOLUTE) FIND_PATH(MSVC10_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT PATHS - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]/../../VC/redist" + "${msvc_install_dir}/../../VC/redist" "${base_dir}/VC/redist" "$ENV{ProgramFiles}/Microsoft Visual Studio 10.0/VC/redist" "$ENV{ProgramFiles(x86)}/Microsoft Visual Studio 10.0/VC/redist" diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake index 79c06baa0..543f3e8cf 100644 --- a/Modules/Platform/AIX-GNU.cmake +++ b/Modules/Platform/AIX-GNU.cmake @@ -19,5 +19,7 @@ endif() set(__AIX_COMPILER_GNU 1) macro(__aix_compiler_gnu lang) + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-blibpath:") + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS} -Wl,-G") endmacro() diff --git a/Modules/Platform/AIX-XL-ASM.cmake b/Modules/Platform/AIX-XL-ASM.cmake new file mode 100644 index 000000000..ea0944ba4 --- /dev/null +++ b/Modules/Platform/AIX-XL-ASM.cmake @@ -0,0 +1,2 @@ +include(Platform/AIX-XL) +__aix_compiler_xl(ASM) diff --git a/Modules/Platform/AIX-XL-C.cmake b/Modules/Platform/AIX-XL-C.cmake index 2de30d5b7..5e437fafd 100644 --- a/Modules/Platform/AIX-XL-C.cmake +++ b/Modules/Platform/AIX-XL-C.cmake @@ -1,4 +1,2 @@ -SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-G -Wl,-brtl,-bnoipath") # -shared -SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-brtl,-bnoipath,-bexpall") # +s, flag for exe link to use shared lib -SET(CMAKE_SHARED_LIBRARY_C_FLAGS " ") -SET(CMAKE_SHARED_MODULE_C_FLAGS " ") +include(Platform/AIX-XL) +__aix_compiler_xl(C) diff --git a/Modules/Platform/AIX-XL-CXX.cmake b/Modules/Platform/AIX-XL-CXX.cmake index 648cb311b..ef38a5f23 100644 --- a/Modules/Platform/AIX-XL-CXX.cmake +++ b/Modules/Platform/AIX-XL-CXX.cmake @@ -1,4 +1,2 @@ -SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-G -Wl,-brtl,-bnoipath") # -shared -SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-Wl,-brtl,-bnoipath,-bexpall") # +s, flag for exe link to use shared lib -SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS " ") -SET(CMAKE_SHARED_MODULE_CXX_FLAGS " ") +include(Platform/AIX-XL) +__aix_compiler_xl(CXX) diff --git a/Modules/Platform/AIX-XL-Fortran.cmake b/Modules/Platform/AIX-XL-Fortran.cmake index 8292e785d..6d4f6559f 100644 --- a/Modules/Platform/AIX-XL-Fortran.cmake +++ b/Modules/Platform/AIX-XL-Fortran.cmake @@ -1,4 +1,2 @@ -SET(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-G -Wl,-brtl,-bnoipath") # -shared -SET(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-Wl,-brtl,-bnoipath,-bexpall") # +s, flag for exe link to use shared lib -SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS " ") -SET(CMAKE_SHARED_MODULE_Fortran_FLAGS " ") +include(Platform/AIX-XL) +__aix_compiler_xl(Fortran) diff --git a/Modules/Platform/AIX-XL.cmake b/Modules/Platform/AIX-XL.cmake new file mode 100644 index 000000000..1f9415219 --- /dev/null +++ b/Modules/Platform/AIX-XL.cmake @@ -0,0 +1,28 @@ + +#============================================================================= +# Copyright 2002-2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This module is shared by multiple languages; use include blocker. +if(__AIX_COMPILER_XL) + return() +endif() +set(__AIX_COMPILER_XL 1) + +macro(__aix_compiler_xl lang) + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-blibpath:") + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-G -Wl,-brtl,-bnoipath") # -shared + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,-brtl,-bnoipath,-bexpall") # +s, flag for exe link to use shared lib + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS " ") + set(CMAKE_SHARED_MODULE_${lang}_FLAGS " ") +endmacro() diff --git a/Modules/Platform/AIX.cmake b/Modules/Platform/AIX.cmake index 0ab0cce65..a9f773ed1 100644 --- a/Modules/Platform/AIX.cmake +++ b/Modules/Platform/AIX.cmake @@ -9,8 +9,6 @@ SET(CMAKE_DL_LIBS "-lld") # When our own RPATH is to be added it may be inserted before the # "always" paths. SET(CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH /usr/lib /lib) -SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-blibpath:") -SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # Files named "libfoo.a" may actually be shared libraries. SET_PROPERTY(GLOBAL PROPERTY TARGET_ARCHIVES_MAY_BE_SHARED_LIBS 1) diff --git a/Modules/Platform/Darwin-Absoft-Fortran.cmake b/Modules/Platform/Darwin-Absoft-Fortran.cmake new file mode 100644 index 000000000..beb41a3b8 --- /dev/null +++ b/Modules/Platform/Darwin-Absoft-Fortran.cmake @@ -0,0 +1 @@ +set(CMAKE_Fortran_VERBOSE_FLAG "-X -v") # Runs gcc under the hood. diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index a99ff4a1c..c11c8fbaa 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -68,7 +68,8 @@ IF(NOT _CMAKE_OSX_SDKS) FIND_PROGRAM(CMAKE_XCODE_SELECT xcode-select) IF(CMAKE_XCODE_SELECT) EXECUTE_PROCESS(COMMAND ${CMAKE_XCODE_SELECT} "-print-path" - OUTPUT_VARIABLE OSX_DEVELOPER_ROOT) + OUTPUT_VARIABLE OSX_DEVELOPER_ROOT + OUTPUT_STRIP_TRAILING_WHITESPACE) FILE(GLOB _CMAKE_OSX_SDKS "${OSX_DEVELOPER_ROOT}/SDKs/*") ENDIF(CMAKE_XCODE_SELECT) ENDIF(NOT _CMAKE_OSX_SDKS) diff --git a/Modules/Platform/GNU.cmake b/Modules/Platform/GNU.cmake index e0ed86cb7..4bcfd51ce 100644 --- a/Modules/Platform/GNU.cmake +++ b/Modules/Platform/GNU.cmake @@ -8,4 +8,6 @@ SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") SET(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") +SET(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-gnu[a-z0-9_]*") + INCLUDE(Platform/UnixPaths) diff --git a/Modules/Platform/HP-UX-HP-ASM.cmake b/Modules/Platform/HP-UX-HP-ASM.cmake new file mode 100644 index 000000000..0a85905eb --- /dev/null +++ b/Modules/Platform/HP-UX-HP-ASM.cmake @@ -0,0 +1,6 @@ +include(Platform/HP-UX-HP) +__hpux_compiler_hp(ASM) + +set(CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS "-E -b +nodefaultrpath -L/usr/lib") + +set(CMAKE_ASM_CREATE_SHARED_LIBRARY "ld -o ") diff --git a/Modules/Platform/HP-UX-HP-C.cmake b/Modules/Platform/HP-UX-HP-C.cmake new file mode 100644 index 000000000..d83e01b26 --- /dev/null +++ b/Modules/Platform/HP-UX-HP-C.cmake @@ -0,0 +1,11 @@ +include(Platform/HP-UX-HP) +__hpux_compiler_hp(C) + +set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-E -b +nodefaultrpath -L/usr/lib") + +set(CMAKE_C_CREATE_PREPROCESSED_SOURCE " -E > ") +set(CMAKE_C_CREATE_ASSEMBLY_SOURCE " -S -o ") +set(CMAKE_C_COMPILE_OBJECT " -Aa -Ae -o -c ") + +# use ld directly to create shared libraries for hp cc +set(CMAKE_C_CREATE_SHARED_LIBRARY "ld -o ") diff --git a/Modules/Platform/HP-UX-HP-CXX.cmake b/Modules/Platform/HP-UX-HP-CXX.cmake new file mode 100644 index 000000000..8f3c70c3e --- /dev/null +++ b/Modules/Platform/HP-UX-HP-CXX.cmake @@ -0,0 +1,16 @@ +include(Platform/HP-UX-HP) +__hpux_compiler_hp(CXX) + +set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "+Z -Wl,-E,+nodefaultrpath -b -L/usr/lib") + +set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE " -E > ") +set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE + " -S " + "mv `basename \"\" | sed 's/\\.[^./]*$$//'`.s " + "rm -f `basename \"\" | sed 's/\\.[^./]*$$//'`.o" + ) + +set(CMAKE_CXX_FLAGS_DEBUG_INIT "-g") +set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT "+O3 -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELEASE_INIT "+O2 -DNDEBUG") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g") diff --git a/Modules/Platform/HP-UX-HP-Fortran.cmake b/Modules/Platform/HP-UX-HP-Fortran.cmake new file mode 100644 index 000000000..5a3ab199c --- /dev/null +++ b/Modules/Platform/HP-UX-HP-Fortran.cmake @@ -0,0 +1,7 @@ +include(Platform/HP-UX-HP) +__hpux_compiler_hp(Fortran) + +set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-E -b -L/usr/lib") + +set(CMAKE_Fortran_CREATE_SHARED_LIBRARY + "ld -o ") diff --git a/Modules/Platform/HP-UX-HP.cmake b/Modules/Platform/HP-UX-HP.cmake new file mode 100644 index 000000000..5e70d3175 --- /dev/null +++ b/Modules/Platform/HP-UX-HP.cmake @@ -0,0 +1,34 @@ + +#============================================================================= +# Copyright 2002-2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This module is shared by multiple languages; use include blocker. +if(__HPUX_COMPILER_HP) + return() +endif() +set(__HPUX_COMPILER_HP 1) +set(_Wl_C "") +set(_Wl_CXX "-Wl,") +set(_Wl_Fortran "") +set(_Wl_ASM "") + +macro(__hpux_compiler_hp lang) + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "+Z") + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,+s,-E,+nodefaultrpath") + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "${_Wl_${lang}}+b") + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") + set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "${_Wl_${lang}}+h") + set(CMAKE_EXECUTABLE_RUNTIME_${lang}_FLAG "-Wl,+b") + + set(CMAKE_${lang}_FLAGS_INIT "") +endmacro() diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake index 9d357c942..ab3dc2266 100644 --- a/Modules/Platform/HP-UX.cmake +++ b/Modules/Platform/HP-UX.cmake @@ -15,57 +15,6 @@ SET(CMAKE_LINK_DEPENDENT_LIBRARY_DIRS 1) # specifying the file path. SET(CMAKE_PLATFORM_USES_PATH_WHEN_NO_SONAME 1) -# fortran -IF(CMAKE_COMPILER_IS_GNUG77) -ELSE(CMAKE_COMPILER_IS_GNUG77) - # use ld directly to create shared libraries for hp cc - SET(CMAKE_Fortran_CREATE_SHARED_LIBRARY - "ld -o ") - SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "+Z") # -pic - SET(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-E -b -L/usr/lib") # -shared - SET(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-Wl,+s,-E,+nodefaultrpath") # +s, flag for exe link to use shared lib - SET(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG "+b") # -rpath - SET(CMAKE_SHARED_LIBRARY_RUNTIME_Fortran_FLAG_SEP ":") # : or empty - SET(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG "+h") - SET(CMAKE_EXECUTABLE_RUNTIME_Fortran_FLAG "-Wl,+b") # -rpath -ENDIF(CMAKE_COMPILER_IS_GNUG77) - -# C compiler -IF(CMAKE_COMPILER_IS_GNUCC) -ELSE(CMAKE_COMPILER_IS_GNUCC) - # hp cc - # use ld directly to create shared libraries for hp cc - SET(CMAKE_C_CREATE_SHARED_LIBRARY - "ld -o ") - SET(CMAKE_SHARED_LIBRARY_C_FLAGS "+Z") # -pic - SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-E -b +nodefaultrpath -L/usr/lib") # -shared - SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,+s,-E,+nodefaultrpath") # +s, flag for exe link to use shared lib - SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "+b") # -rpath - SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") # : or empty - SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "+h") - SET(CMAKE_EXECUTABLE_RUNTIME_C_FLAG "-Wl,+b") # -rpath - SET(CMAKE_C_FLAGS_INIT "") - SET(CMAKE_C_COMPILE_OBJECT - " -Aa -Ae -o -c ") -ENDIF(CMAKE_COMPILER_IS_GNUCC) - -# CXX compiler -IF(CMAKE_COMPILER_IS_GNUCXX) -ELSE(CMAKE_COMPILER_IS_GNUCXX) - # for hp aCC - SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "+Z") # -pic - SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "+Z -Wl,-E,+nodefaultrpath -b -L/usr/lib") # -shared - SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "-Wl,+s,-E,+nodefaultrpath") # +s, flag for exe link to use shared lib - SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-Wl,+b") # -rpath - SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP ":") # : or empty - SET(CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG "-Wl,+h") - SET(CMAKE_EXECUTABLE_RUNTIME_CXX_FLAG "-Wl,+b") # -rpath - SET (CMAKE_CXX_FLAGS_INIT "") - SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g") - SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "+O3 -DNDEBUG") - SET (CMAKE_CXX_FLAGS_RELEASE_INIT "+O2 -DNDEBUG") - SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g") -ENDIF(CMAKE_COMPILER_IS_GNUCXX) # set flags for gcc support INCLUDE(Platform/UnixPaths) @@ -81,20 +30,6 @@ LIST(APPEND CMAKE_SYSTEM_LIBRARY_PATH /usr/lib/hpux64) LIST(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES /usr/lib/hpux32 /usr/lib/hpux64) -IF(NOT CMAKE_COMPILER_IS_GNUCC) - SET (CMAKE_C_CREATE_PREPROCESSED_SOURCE " -E > ") - SET (CMAKE_C_CREATE_ASSEMBLY_SOURCE " -S -o ") -ENDIF(NOT CMAKE_COMPILER_IS_GNUCC) - -IF(NOT CMAKE_COMPILER_IS_GNUCXX) - SET (CMAKE_CXX_CREATE_PREPROCESSED_SOURCE " -E > ") - SET (CMAKE_CXX_CREATE_ASSEMBLY_SOURCE - " -S " - "mv `basename \"\" | sed 's/\\.[^./]*$$//'`.s " - "rm -f `basename \"\" | sed 's/\\.[^./]*$$//'`.o" - ) -ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) - # Initialize C and CXX link type selection flags. These flags are # used when building a shared library, shared module, or executable # that links to other libraries to select whether to use the static or diff --git a/Modules/Platform/Linux-Absoft-Fortran.cmake b/Modules/Platform/Linux-Absoft-Fortran.cmake new file mode 100644 index 000000000..beb41a3b8 --- /dev/null +++ b/Modules/Platform/Linux-Absoft-Fortran.cmake @@ -0,0 +1 @@ +set(CMAKE_Fortran_VERBOSE_FLAG "-X -v") # Runs gcc under the hood. diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake index 6490dd1e5..38f469b33 100644 --- a/Modules/Platform/Linux.cmake +++ b/Modules/Platform/Linux.cmake @@ -45,6 +45,9 @@ ELSE(DEFINED CMAKE_INSTALL_SO_NO_EXE) ENDIF(EXISTS "/etc/debian_version") ENDIF(DEFINED CMAKE_INSTALL_SO_NO_EXE) +# Match multiarch library directory names. +SET(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*") + INCLUDE(Platform/UnixPaths) # Debian has lib64 paths only for compatibility so they should not be diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index 7084b83ba..1d3e4b5a9 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -43,6 +43,7 @@ endif() set(CMAKE_DL_LIBS "") set(CMAKE_LIBRARY_PATH_FLAG "-L") set(CMAKE_LINK_LIBRARY_FLAG "-l") +set(CMAKE_LINK_DEF_FILE_FLAG "") # Empty string: passing the file is enough set(CMAKE_LINK_LIBRARY_SUFFIX "") set(CMAKE_CREATE_WIN32_EXE "-mwindows") @@ -78,6 +79,7 @@ macro(__windows_compiler_gnu lang) set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") # No -fPIC on Windows set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS ${__WINDOWS_GNU_LD_RESPONSE}) + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1) # We prefer "@" for response files but it is not supported by gcc 3. execute_process(COMMAND ${CMAKE_${lang}_COMPILER} --version OUTPUT_VARIABLE _ver ERROR_VARIABLE _ver) @@ -91,6 +93,8 @@ macro(__windows_compiler_gnu lang) # Use "-Wl,@" to pass the response file to the linker. set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-Wl,@") endif() + # The GNU 3.x compilers do not support response files (only linkers). + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 0) elseif(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS) # Use "@" to pass the response file to the front-end. set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@") diff --git a/Modules/Platform/Windows-Intel-ASM.cmake b/Modules/Platform/Windows-Intel-ASM.cmake new file mode 100644 index 000000000..31d08c7ad --- /dev/null +++ b/Modules/Platform/Windows-Intel-ASM.cmake @@ -0,0 +1,2 @@ +include(Platform/Windows-Intel) +__windows_compiler_intel(ASM) diff --git a/Modules/Platform/kFreeBSD.cmake b/Modules/Platform/kFreeBSD.cmake index ff050dec1..c1295fb0d 100644 --- a/Modules/Platform/kFreeBSD.cmake +++ b/Modules/Platform/kFreeBSD.cmake @@ -1,2 +1,4 @@ # kFreeBSD looks just like Linux. INCLUDE(Platform/Linux) + +SET(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-kfreebsd-gnu[a-z0-9_]*") diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake new file mode 100644 index 000000000..eff4766b1 --- /dev/null +++ b/Modules/ProcessorCount.cmake @@ -0,0 +1,183 @@ +# - ProcessorCount(var) +# Determine the number of processors/cores and save value in ${var} +# +# Sets the variable named ${var} to the number of physical cores available on +# the machine if the information can be determined. Otherwise it is set to 0. +# Currently this functionality is implemented for AIX, cygwin, FreeBSD, HPUX, +# IRIX, Linux, Mac OS X, QNX, Sun and Windows. +# +# This function is guaranteed to return a positive integer (>=1) if it +# succeeds. It returns 0 if there's a problem determining the processor count. +# +# Example use, in a ctest -S dashboard script: +# +# include(ProcessorCount) +# ProcessorCount(N) +# if(NOT N EQUAL 0) +# set(CTEST_BUILD_FLAGS -j${N}) +# set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N}) +# endif() +# +# This function is intended to offer an approximation of the value of the +# number of compute cores available on the current machine, such that you +# may use that value for parallel building and parallel testing. It is meant +# to help utilize as much of the machine as seems reasonable. Of course, +# knowledge of what else might be running on the machine simultaneously +# should be used when deciding whether to request a machine's full capacity +# all for yourself. + +# A more reliable way might be to compile a small C program that uses the CPUID +# instruction, but that again requires compiler support or compiling assembler +# code. + +#============================================================================= +# Copyright 2010-2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +function(ProcessorCount var) + # Unknown: + set(count 0) + + if(WIN32) + # Windows: + set(count "$ENV{NUMBER_OF_PROCESSORS}") + #message("ProcessorCount: WIN32, trying environment variable") + endif() + + if(NOT count) + # Mac, FreeBSD, OpenBSD (systems with sysctl): + find_program(ProcessorCount_cmd_sysctl sysctl + PATHS /usr/sbin /sbin) + if(ProcessorCount_cmd_sysctl) + execute_process(COMMAND ${ProcessorCount_cmd_sysctl} -n hw.ncpu + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE count) + #message("ProcessorCount: trying sysctl '${ProcessorCount_cmd_sysctl}'") + endif() + endif() + + if(NOT count) + # Linux (systems with getconf): + find_program(ProcessorCount_cmd_getconf getconf) + if(ProcessorCount_cmd_getconf) + execute_process(COMMAND ${ProcessorCount_cmd_getconf} _NPROCESSORS_ONLN + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE count) + #message("ProcessorCount: trying getconf '${ProcessorCount_cmd_getconf}'") + endif() + endif() + + if(NOT count) + # HPUX (systems with machinfo): + find_program(ProcessorCount_cmd_machinfo machinfo + PATHS /usr/contrib/bin) + if(ProcessorCount_cmd_machinfo) + execute_process(COMMAND ${ProcessorCount_cmd_machinfo} + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE machinfo_output) + string(REGEX MATCHALL "Number of CPUs = ([0-9]+)" procs "${machinfo_output}") + set(count "${CMAKE_MATCH_1}") + #message("ProcessorCount: trying machinfo '${ProcessorCount_cmd_machinfo}'") + endif() + endif() + + if(NOT count) + # IRIX (systems with hinv): + find_program(ProcessorCount_cmd_hinv hinv + PATHS /sbin) + if(ProcessorCount_cmd_hinv) + execute_process(COMMAND ${ProcessorCount_cmd_hinv} + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE hinv_output) + string(REGEX MATCHALL "([0-9]+) .* Processors" procs "${hinv_output}") + set(count "${CMAKE_MATCH_1}") + #message("ProcessorCount: trying hinv '${ProcessorCount_cmd_hinv}'") + endif() + endif() + + if(NOT count) + # AIX (systems with lsconf): + find_program(ProcessorCount_cmd_lsconf lsconf + PATHS /usr/sbin) + if(ProcessorCount_cmd_lsconf) + execute_process(COMMAND ${ProcessorCount_cmd_lsconf} + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE lsconf_output) + string(REGEX MATCHALL "Number Of Processors: ([0-9]+)" procs "${lsconf_output}") + set(count "${CMAKE_MATCH_1}") + #message("ProcessorCount: trying lsconf '${ProcessorCount_cmd_lsconf}'") + endif() + endif() + + if(NOT count) + # QNX (systems with pidin): + find_program(ProcessorCount_cmd_pidin pidin) + if(ProcessorCount_cmd_pidin) + execute_process(COMMAND ${ProcessorCount_cmd_pidin} info + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE pidin_output) + string(REGEX MATCHALL "Processor[0-9]+: " procs "${pidin_output}") + list(LENGTH procs count) + #message("ProcessorCount: trying pidin '${ProcessorCount_cmd_pidin}'") + endif() + endif() + + if(NOT count) + # Sun (systems where uname -X emits "NumCPU" in its output): + find_program(ProcessorCount_cmd_uname uname) + if(ProcessorCount_cmd_uname) + execute_process(COMMAND ${ProcessorCount_cmd_uname} -X + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE uname_X_output) + string(REGEX MATCHALL "NumCPU = ([0-9]+)" procs "${uname_X_output}") + set(count "${CMAKE_MATCH_1}") + #message("ProcessorCount: trying uname -X '${ProcessorCount_cmd_uname}'") + endif() + endif() + + # Execute this code when all previously attempted methods return empty + # output: + # + if(NOT count) + # Systems with /proc/cpuinfo: + set(cpuinfo_file /proc/cpuinfo) + if(EXISTS "${cpuinfo_file}") + file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$") + list(LENGTH procs count) + #message("ProcessorCount: trying cpuinfo '${cpuinfo_file}'") + endif() + endif() + + # Since cygwin builds of CMake do not define WIN32 anymore, but they still + # run on Windows, and will still have this env var defined: + # + if(NOT count) + set(count "$ENV{NUMBER_OF_PROCESSORS}") + #message("ProcessorCount: last fallback, trying environment variable") + endif() + + # Ensure an integer return (avoid inadvertently returning an empty string + # or an error string)... If it's not a decimal integer, return 0: + # + if(NOT count MATCHES "^[0-9]+$") + set(count 0) + endif() + + set(${var} ${count} PARENT_SCOPE) +endfunction() diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 86a74044e..6d7a3ec21 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -107,10 +107,8 @@ MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options) ENDIF(_moc_outfile_dir) SET (_moc_parameters_file ${outfile}_parameters) SET (_moc_parameters ${moc_flags} ${moc_options} -o "${outfile}" "${infile}") - FILE (REMOVE ${_moc_parameters_file}) - FOREACH(arg ${_moc_parameters}) - FILE (APPEND ${_moc_parameters_file} "${arg}\n") - ENDFOREACH(arg) + STRING (REPLACE ";" "\n" _moc_parameters "${_moc_parameters}") + FILE (WRITE ${_moc_parameters_file} "${_moc_parameters}") ADD_CUSTOM_COMMAND(OUTPUT ${outfile} COMMAND ${QT_MOC_EXECUTABLE} @${_moc_outfile_name}_parameters DEPENDS ${infile} diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index ab028ed98..9ce475cb7 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -66,6 +66,13 @@ SET(QT_QTSCRIPTTOOLS_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTWEBKIT_MODULE_DEPENDS QTXMLPATTERNS QTGUI QTCORE) SET(QT_QTDECLARATIVE_MODULE_DEPENDS QTWEBKIT QTSCRIPT QTSVG QTSQL QTXMLPATTERNS QTXML QTOPENGL QTGUI QTNETWORK QTCORE) SET(QT_QTMULTIMEDIA_MODULE_DEPENDS QTGUI QTCORE) +SET(QT_QTOPENGL_MODULE_DEPENDS QTGUI QTCORE) +SET(QT_QTSCRIPT_MODULE_DEPENDS QTCORE) +SET(QT_QTGUI_MODULE_DEPENDS QTCORE) +SET(QT_QTTEST_MODULE_DEPENDS QTCORE) +SET(QT_QTXML_MODULE_DEPENDS QTCORE) +SET(QT_QTSQL_MODULE_DEPENDS QTCORE) +SET(QT_QTNETWORK_MODULE_DEPENDS QTCORE) # Qt modules (in order of dependence) FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index b547dc7dd..be15b52f1 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -4,6 +4,9 @@ # - Define swig module with given name and specified language # SWIG_LINK_LIBRARIES(name [ libraries ]) # - Link libraries to swig module +# SWIG_GET_WRAPPER_DEPENDENCIES(swigFile genWrapper language DEST_VARIABLE) +# - Put dependencies of the wrapper genWrapper generated by swig from +# swigFile in DEST_VARIABLE # All other macros are for internal use only. # To get the actual name of the swig module, # use: ${SWIG_MODULE_${name}_REAL_NAME}. @@ -38,6 +41,58 @@ SET(SWIG_EXTRA_LIBRARIES "") SET(SWIG_PYTHON_EXTRA_FILE_EXTENSION "py") +# +# Get dependencies of the generated wrapper. +# +MACRO(SWIG_GET_WRAPPER_DEPENDENCIES swigFile genWrapper language DEST_VARIABLE) + GET_FILENAME_COMPONENT(swig_getdeps_basename ${swigFile} NAME_WE) + GET_FILENAME_COMPONENT(swig_getdeps_outdir ${genWrapper} PATH) + GET_SOURCE_FILE_PROPERTY(swig_getdeps_extra_flags "${swigFile}" SWIG_FLAGS) + IF("${swig_getdeps_extra_flags}" STREQUAL "NOTFOUND") + SET(swig_getdeps_extra_flags "") + ENDIF("${swig_getdeps_extra_flags}" STREQUAL "NOTFOUND") + + IF(NOT swig_getdeps_outdir) + SET(swig_getdeps_outdir ${CMAKE_CURRENT_BINARY_DIR}) + ENDIF(NOT swig_getdeps_outdir) + SET(swig_getdeps_depsfile + ${swig_getdeps_outdir}/swig_${swig_getdeps_basename}_deps.txt) + GET_DIRECTORY_PROPERTY(swig_getdeps_include_directories INCLUDE_DIRECTORIES) + SET(swig_getdeps_include_dirs) + FOREACH(it ${swig_getdeps_include_directories}) + SET(swig_getdeps_include_dirs ${swig_getdeps_include_dirs} "-I${it}") + ENDFOREACH(it) + EXECUTE_PROCESS( + COMMAND ${SWIG_EXECUTABLE} + -MM -MF ${swig_getdeps_depsfile} ${swig_getdeps_extra_flags} + ${CMAKE_SWIG_FLAGS} -${language} + -o ${genWrapper} ${swig_getdeps_include_dirs} ${swigFile} + RESULT_VARIABLE swig_getdeps_result + ERROR_VARIABLE swig_getdeps_error + OUTPUT_STRIP_TRAILING_WHITESPACE) + IF(NOT ${swig_getdeps_error} EQUAL 0) + MESSAGE(SEND_ERROR "Command \"${SWIG_EXECUTABLE} -MM -MF ${swig_getdeps_depsfile} ${swig_getdeps_extra_flags} ${CMAKE_SWIG_FLAGS} -${language} -o ${genWrapper} ${swig_getdeps_include_dirs} ${swigFile}\" failed with output:\n${swig_getdeps_error}") + SET(swig_getdeps_dependencies "") + ELSE(NOT ${swig_getdeps_error} EQUAL 0) + FILE(READ ${swig_getdeps_depsfile} ${DEST_VARIABLE}) + # Remove the first line + STRING(REGEX REPLACE "^.+: +\\\\\n +" "" + ${DEST_VARIABLE} "${${DEST_VARIABLE}}") + # Clean the end of each line + STRING(REGEX REPLACE " +(\\\\)?\n" "\n" ${DEST_VARIABLE} + "${${DEST_VARIABLE}}") + # Clean beginning of each line + STRING(REGEX REPLACE "\n +" "\n" + ${DEST_VARIABLE} "${${DEST_VARIABLE}}") + # clean paths + STRING(REGEX REPLACE "\\\\\\\\" "/" ${DEST_VARIABLE} + "${${DEST_VARIABLE}}") + STRING(REGEX REPLACE "\n" ";" + ${DEST_VARIABLE} "${${DEST_VARIABLE}}") + ENDIF(NOT ${swig_getdeps_error} EQUAL 0) +ENDMACRO(SWIG_GET_WRAPPER_DEPENDENCIES) + + # # For given swig module initialize variables associated with it # @@ -69,6 +124,7 @@ ENDMACRO(SWIG_MODULE_INITIALIZE) # MACRO(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile) + SET(${outfiles} "") GET_SOURCE_FILE_PROPERTY(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename ${infile} SWIG_MODULE_NAME) IF(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND") @@ -125,8 +181,6 @@ MACRO(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) # If CMAKE_SWIG_OUTDIR was specified then pass it to -outdir IF(CMAKE_SWIG_OUTDIR) SET(swig_outdir ${CMAKE_SWIG_OUTDIR}) - # it may not exist, so create it: - file(MAKE_DIRECTORY ${CMAKE_SWIG_OUTDIR}) ELSE(CMAKE_SWIG_OUTDIR) SET(swig_outdir ${CMAKE_CURRENT_BINARY_DIR}) ENDIF(CMAKE_SWIG_OUTDIR) @@ -166,8 +220,14 @@ MACRO(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) IF(SWIG_MODULE_${name}_EXTRA_FLAGS) SET(swig_extra_flags ${swig_extra_flags} ${SWIG_MODULE_${name}_EXTRA_FLAGS}) ENDIF(SWIG_MODULE_${name}_EXTRA_FLAGS) + SWIG_GET_WRAPPER_DEPENDENCIES("${swig_source_file_fullname}" + "${swig_generated_file_fullname}" ${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG} + swig_extra_dependencies) + LIST(APPEND SWIG_MODULE_${name}_EXTRA_DEPS ${swig_extra_dependencies}) ADD_CUSTOM_COMMAND( OUTPUT "${swig_generated_file_fullname}" ${swig_extra_generated_files} + # Let's create the ${swig_outdir} at execution time, in case dir contains $(OutDir) + COMMAND ${CMAKE_COMMAND} -E make_directory ${swig_outdir} COMMAND "${SWIG_EXECUTABLE}" ARGS "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}" ${swig_source_file_flags} diff --git a/Modules/UsewxWidgets.cmake b/Modules/UsewxWidgets.cmake index 9ecfff0cc..a0f2e8632 100644 --- a/Modules/UsewxWidgets.cmake +++ b/Modules/UsewxWidgets.cmake @@ -6,7 +6,7 @@ # # Note that for MinGW users the order of libs is important! # FIND_PACKAGE(wxWidgets REQUIRED net gl core base) # INCLUDE(${wxWidgets_USE_FILE}) -# # and for each of your dependant executable/library targets: +# # and for each of your dependent executable/library targets: # TARGET_LINK_LIBRARIES( ${wxWidgets_LIBRARIES}) # # DEPRECATED diff --git a/Modules/readme.txt b/Modules/readme.txt index dd5200097..e2d7f0674 100644 --- a/Modules/readme.txt +++ b/Modules/readme.txt @@ -64,10 +64,32 @@ For example: # VAR_REALLY_COOL - cool right? # +Test the documentation formatting by running "cmake --help-module FindXXX". +Edit the comments until the output of this command looks satisfactory. + To have a .cmake file in this directory NOT show up in the modules documentation, you should start the file with a blank line. +After the documentation, leave a *BLANK* line, and then add a +copyright and licence notice block like this one: + +#============================================================================= +# Copyright 2009-2011 Your Name +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +The layout of the notice block is strictly enforced by the ModuleNotices test. +Only the year range and name may be changed freely. + A FindXXX.cmake module will typically be loaded by the command FIND_PACKAGE(XXX [major[.minor[.patch[.tweak]]]] [EXACT] diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 7722c1922..ca063d54c 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -266,7 +266,7 @@ IF(UNIX) SET(SRCS ${SRCS} cmGlobalKdevelopGenerator.cxx) ENDIF(UNIX) -# XCode only works on apple +# Xcode only works on Apple IF(APPLE) SET(SRCS ${SRCS} cmXCodeObject.cxx @@ -343,7 +343,7 @@ TARGET_LINK_LIBRARIES(CMakeLib cmsys ${CMAKE_TAR_LIBRARIES} ${CMAKE_COMPRESS_LIBRARIES} ${CMAKE_CURL_LIBRARIES} ) -# On Apple we need Carbon +# On Apple we need CoreFoundation IF(APPLE) TARGET_LINK_LIBRARIES(CMakeLib "-framework CoreFoundation") ENDIF(APPLE) @@ -394,6 +394,8 @@ SET(CTEST_SRCS cmCTest.cxx CTest/cmCTestTestHandler.cxx CTest/cmCTestUpdateCommand.cxx CTest/cmCTestUpdateHandler.cxx + CTest/cmCTestUploadCommand.cxx + CTest/cmCTestUploadHandler.cxx CTest/cmCTestVC.cxx CTest/cmCTestVC.h @@ -465,7 +467,7 @@ IF(APPLE) ADD_EXECUTABLE(OSXScriptLauncher CPack/OSXScriptLauncher.cxx) TARGET_LINK_LIBRARIES(OSXScriptLauncher cmsys) - TARGET_LINK_LIBRARIES(OSXScriptLauncher "-framework Carbon") + TARGET_LINK_LIBRARIES(OSXScriptLauncher "-framework CoreFoundation") ENDIF(APPLE) # Build CMake executable diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx index 99ffeccd8..e0fbe9b75 100644 --- a/Source/CPack/OSXScriptLauncher.cxx +++ b/Source/CPack/OSXScriptLauncher.cxx @@ -14,7 +14,6 @@ #include #include -#include #include // For the PATH_MAX constant diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index 46be99b6f..0ce5b0126 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -121,9 +121,11 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) << std::endl); // Begin the archive for this group std::string packageFileName= std::string(toplevel); - packageFileName += "/" - +std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) - +"-"+compGIt->first + this->GetOutputExtension(); + packageFileName += "/"+ + GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"), + compGIt->first, + true) + + this->GetOutputExtension(); // open a block in order to automatically close archive // at the end of the block { @@ -141,6 +143,39 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) // add the generated package to package file names list packageFileNames.push_back(packageFileName); } + // Handle Orphan components (components not belonging to any groups) + std::map::iterator compIt; + for (compIt=this->Components.begin(); + compIt!=this->Components.end(); ++compIt ) + { + // Does the component belong to a group? + if (compIt->second.Group==NULL) + { + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Component <" + << compIt->second.Name + << "> does not belong to any group, package it separately." + << std::endl); + std::string localToplevel( + this->GetOption("CPACK_TEMPORARY_DIRECTORY") + ); + std::string packageFileName = std::string(toplevel); + + localToplevel += "/"+ compIt->first; + packageFileName += "/"+ + GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"), + compIt->first, + false) + + this->GetOutputExtension(); + { + DECLARE_AND_OPEN_ARCHIVE(packageFileName,archive); + // Add the files of this component to the archive + addOneComponentToArchive(archive,&(compIt->second)); + } + // add the generated package to package file names list + packageFileNames.push_back(packageFileName); + } + } } // CPACK_COMPONENTS_IGNORE_GROUPS is set // We build 1 package per component @@ -154,9 +189,11 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) std::string packageFileName = std::string(toplevel); localToplevel += "/"+ compIt->first; - packageFileName += "/" - +std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) - +"-"+compIt->first + this->GetOutputExtension(); + packageFileName += "/"+ + GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"), + compIt->first, + false) + + this->GetOutputExtension(); { DECLARE_AND_OPEN_ARCHIVE(packageFileName,archive); // Add the files of this component to the archive @@ -170,52 +207,29 @@ int cmCPackArchiveGenerator::PackageComponents(bool ignoreGroup) } //---------------------------------------------------------------------- -int cmCPackArchiveGenerator::PackageComponentsAllInOne(bool allComponent) +int cmCPackArchiveGenerator::PackageComponentsAllInOne() { // reset the package file names packageFileNames.clear(); packageFileNames.push_back(std::string(toplevel)); packageFileNames[0] += "/" +std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) - +"-ALL" + this->GetOutputExtension(); + + this->GetOutputExtension(); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging all groups in one package..." "(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE is set)" << std::endl); DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0],archive); - // The ALL GROUP in ONE package case - if (! allComponent) { - // iterate over the component groups - std::map::iterator compGIt; - for (compGIt=this->ComponentGroups.begin(); - compGIt!=this->ComponentGroups.end(); ++compGIt) - { - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " - << compGIt->first - << std::endl); - // now iterate over the component of this group - std::vector::iterator compIt; - for (compIt=(compGIt->second).Components.begin(); - compIt!=(compGIt->second).Components.end(); - ++compIt) - { - // Add the files of this component to the archive - addOneComponentToArchive(archive,*compIt); - } - } - } - // The ALL COMPONENT in ONE package case - else + // The ALL COMPONENTS in ONE package case + std::map::iterator compIt; + for (compIt=this->Components.begin();compIt!=this->Components.end(); + ++compIt ) { - std::map::iterator compIt; - for (compIt=this->Components.begin();compIt!=this->Components.end(); - ++compIt ) - { - // Add the files of this component to the archive - addOneComponentToArchive(archive,&(compIt->second)); - } + // Add the files of this component to the archive + addOneComponentToArchive(archive,&(compIt->second)); } + // archive goes out of scope so it will finalized and closed. return 1; } @@ -226,25 +240,22 @@ int cmCPackArchiveGenerator::PackageFiles() cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " << toplevel << std::endl); - PrepareGroupingKind(); - if (SupportsComponentInstallation()) { // CASE 1 : COMPONENT ALL-IN-ONE package - // If ALL GROUPS or ALL COMPONENTS in ONE package has been requested + // If ALL COMPONENTS in ONE package has been requested // then the package file is unique and should be open here. - if (allComponentInOne || - (allGroupInOne && (!this->ComponentGroups.empty())) - ) + if (componentPackageMethod == ONE_PACKAGE) { - return PackageComponentsAllInOne(allComponentInOne); + return PackageComponentsAllInOne(); } // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) // There will be 1 package for each component group // however one may require to ignore component group and // in this case you'll get 1 package for each component. - else if ((!this->ComponentGroups.empty()) || (ignoreComponentGroup)) + else { - return PackageComponents(ignoreComponentGroup); + return PackageComponents(componentPackageMethod == + ONE_PACKAGE_PER_COMPONENT); } } diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h index dc172579a..b1bbb8363 100644 --- a/Source/CPack/cmCPackArchiveGenerator.h +++ b/Source/CPack/cmCPackArchiveGenerator.h @@ -65,7 +65,7 @@ protected: * Special case of component install where all * components will be put in a single installer. */ - int PackageComponentsAllInOne(bool allComponent); + int PackageComponentsAllInOne(); virtual const char* GetOutputExtension() = 0; cmArchiveWrite::Compress Compress; cmArchiveWrite::Type Archive; diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index 06a050992..af78e7822 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -165,5 +165,10 @@ int cmCPackBundleGenerator::PackageFiles() cmSystemTools::SetPermissions(command_target.str().c_str(), 0777); } - return this->CreateDMG(); + return this->CreateDMG(toplevel, packageFileNames[0]); +} + +bool cmCPackBundleGenerator::SupportsComponentInstallation() const +{ + return false; } diff --git a/Source/CPack/cmCPackBundleGenerator.h b/Source/CPack/cmCPackBundleGenerator.h index 82814b0a5..ed0187dd4 100644 --- a/Source/CPack/cmCPackBundleGenerator.h +++ b/Source/CPack/cmCPackBundleGenerator.h @@ -32,6 +32,7 @@ protected: virtual int InitializeInternal(); virtual const char* GetPackagingInstallPrefix(); int PackageFiles(); + bool SupportsComponentInstallation() const; std::string InstallPrefix; }; diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 47a1ff64c..8c19bbd96 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -50,15 +50,235 @@ int cmCPackDebGenerator::InitializeInternal() return this->Superclass::InitializeInternal(); } +//---------------------------------------------------------------------- +int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel, + std::string packageName) + { + int retval = 1; + // Begin the archive for this pack + std::string localToplevel(initialTopLevel); + std::string packageFileName( + cmSystemTools::GetParentDirectory(toplevel.c_str()) + ); + std::string outputFileName( + std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + +"-"+packageName + this->GetOutputExtension() + ); + + localToplevel += "/"+ packageName; + /* replace the TEMP DIRECTORY with the component one */ + this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str()); + packageFileName += "/"+ outputFileName; + /* replace proposed CPACK_OUTPUT_FILE_NAME */ + this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str()); + /* replace the TEMPORARY package file name */ + this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", + packageFileName.c_str()); + // Tell CPackDeb.cmake the name of the component GROUP. + this->SetOption("CPACK_DEB_PACKAGE_COMPONENT",packageName.c_str()); + if (!this->ReadListFile("CPackDeb.cmake")) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while execution CPackDeb.cmake" << std::endl); + retval = 0; + return retval; + } + + cmsys::Glob gl; + std::string findExpr(this->GetOption("WDIR")); + findExpr += "/*"; + gl.RecurseOn(); + if ( !gl.FindFiles(findExpr) ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find any files in the installed directory" << std::endl); + return 0; + } + packageFiles = gl.GetFiles(); + + int res = createDeb(); + if (res != 1) + { + retval = 0; + } + // add the generated package to package file names list + packageFileNames.push_back(packageFileName); + return retval; +} + +//---------------------------------------------------------------------- +int cmCPackDebGenerator::PackageComponents(bool ignoreGroup) +{ + int retval = 1; + /* Reset package file name list it will be populated during the + * component packaging run*/ + packageFileNames.clear(); + std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); + + // The default behavior is to have one package by component group + // unless CPACK_COMPONENTS_IGNORE_GROUP is specified. + if (!ignoreGroup) + { + std::map::iterator compGIt; + for (compGIt=this->ComponentGroups.begin(); + compGIt!=this->ComponentGroups.end(); ++compGIt) + { + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " + << compGIt->first + << std::endl); + // Begin the archive for this group + retval &= PackageOnePack(initialTopLevel,compGIt->first); + } + // Handle Orphan components (components not belonging to any groups) + std::map::iterator compIt; + for (compIt=this->Components.begin(); + compIt!=this->Components.end(); ++compIt ) + { + // Does the component belong to a group? + if (compIt->second.Group==NULL) + { + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Component <" + << compIt->second.Name + << "> does not belong to any group, package it separately." + << std::endl); + // Begin the archive for this orphan component + retval &= PackageOnePack(initialTopLevel,compIt->first); + } + } + } + // CPACK_COMPONENTS_IGNORE_GROUPS is set + // We build 1 package per component + else + { + std::map::iterator compIt; + for (compIt=this->Components.begin(); + compIt!=this->Components.end(); ++compIt ) + { + retval &= PackageOnePack(initialTopLevel,compIt->first); + } + } + return retval; +} + +//---------------------------------------------------------------------- +int cmCPackDebGenerator::PackageComponentsAllInOne() +{ + int retval = 1; + std::string compInstDirName; + /* Reset package file name list it will be populated during the + * component packaging run*/ + packageFileNames.clear(); + std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); + + compInstDirName = "ALL_COMPONENTS_IN_ONE"; + + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Packaging all groups in one package..." + "(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)" + << std::endl); + + // The ALL GROUPS in ONE package case + std::string localToplevel(initialTopLevel); + std::string packageFileName( + cmSystemTools::GetParentDirectory(toplevel.c_str()) + ); + std::string outputFileName( + std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + + this->GetOutputExtension() + ); + // all GROUP in one vs all COMPONENT in one + localToplevel += "/"+compInstDirName; + + /* replace the TEMP DIRECTORY with the component one */ + this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str()); + packageFileName += "/"+ outputFileName; + /* replace proposed CPACK_OUTPUT_FILE_NAME */ + this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str()); + /* replace the TEMPORARY package file name */ + this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", + packageFileName.c_str()); + // Tell CPackDeb.cmake the name of the component GROUP. + this->SetOption("CPACK_DEB_PACKAGE_COMPONENT",compInstDirName.c_str()); + if (!this->ReadListFile("CPackDeb.cmake")) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while execution CPackDeb.cmake" << std::endl); + retval = 0; + return retval; + } + + cmsys::Glob gl; + std::string findExpr(this->GetOption("WDIR")); + findExpr += "/*"; + gl.RecurseOn(); + if ( !gl.FindFiles(findExpr) ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find any files in the installed directory" << std::endl); + return 0; + } + packageFiles = gl.GetFiles(); + + int res = createDeb(); + if (res != 1) + { + retval = 0; + } + // add the generated package to package file names list + packageFileNames.push_back(packageFileName); + return retval; +} + //---------------------------------------------------------------------- int cmCPackDebGenerator::PackageFiles() { - this->ReadListFile("CPackDeb.cmake"); + int retval = -1; + + /* Are we in the component packaging case */ + if (SupportsComponentInstallation()) { + // CASE 1 : COMPONENT ALL-IN-ONE package + // If ALL GROUPS or ALL COMPONENTS in ONE package has been requested + // then the package file is unique and should be open here. + if (componentPackageMethod == ONE_PACKAGE) + { + return PackageComponentsAllInOne(); + } + // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) + // There will be 1 package for each component group + // however one may require to ignore component group and + // in this case you'll get 1 package for each component. + else + { + return PackageComponents(componentPackageMethod == + ONE_PACKAGE_PER_COMPONENT); + } + } + // CASE 3 : NON COMPONENT package. + else + { + if (!this->ReadListFile("CPackDeb.cmake")) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while execution CPackDeb.cmake" << std::endl); + retval = 0; + } + else + { + packageFiles = files; + return createDeb(); + } + } + return retval; +} + +int cmCPackDebGenerator::createDeb() +{ const char* cmakeExecutable = this->GetOption("CMAKE_COMMAND"); // debian-binary file std::string dbfilename; - dbfilename = toplevel; + dbfilename += this->GetOption("WDIR"); dbfilename += "/debian-binary"; { // the scope is needed for cmGeneratedFileStream cmGeneratedFileStream out(dbfilename.c_str()); @@ -68,7 +288,7 @@ int cmCPackDebGenerator::PackageFiles() // control file std::string ctlfilename; - ctlfilename = toplevel; + ctlfilename = this->GetOption("WDIR"); ctlfilename += "/control"; // debian policy enforce lower case for package name @@ -158,8 +378,9 @@ int cmCPackDebGenerator::PackageFiles() { std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); dirName += '/'; - for (std::vector::const_iterator fileIt = files.begin(); - fileIt != files.end(); ++ fileIt ) + for (std::vector::const_iterator fileIt = + packageFiles.begin(); + fileIt != packageFiles.end(); ++ fileIt ) { totalSize += cmSystemTools::FileLength(fileIt->c_str()); } @@ -178,14 +399,22 @@ int cmCPackDebGenerator::PackageFiles() // now add all directories which have to be compressed // collect all top level install dirs for that // e.g. /opt/bin/foo, /usr/bin/bar and /usr/bin/baz would give /usr and /opt - size_t topLevelLength = toplevel.length(); + size_t topLevelLength = std::string(this->GetOption("WDIR")).length(); + cmCPackLogger(cmCPackLog::LOG_DEBUG, "WDIR: \"" << this->GetOption("WDIR") + << "\", length = " << topLevelLength + << std::endl); std::set installDirs; - for (std::vector::const_iterator fileIt = files.begin(); - fileIt != files.end(); ++ fileIt ) + for (std::vector::const_iterator fileIt = + packageFiles.begin(); + fileIt != packageFiles.end(); ++ fileIt ) { + cmCPackLogger(cmCPackLog::LOG_DEBUG, "FILEIT: \"" << *fileIt << "\"" + << std::endl); std::string::size_type slashPos = fileIt->find('/', topLevelLength+1); - std::string relativeDir = fileIt->substr(topLevelLength, + std::string relativeDir = fileIt->substr(topLevelLength, slashPos - topLevelLength); + cmCPackLogger(cmCPackLog::LOG_DEBUG, "RELATIVEDIR: \"" << relativeDir + << "\"" << std::endl); if (installDirs.find(relativeDir) == installDirs.end()) { installDirs.insert(relativeDir); @@ -195,11 +424,11 @@ int cmCPackDebGenerator::PackageFiles() } std::string output; - int retVal = -1; + int retval = -1; int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, - &retVal, toplevel.c_str(), this->GeneratorVerbose, 0); + &retval, this->GetOption("WDIR"), this->GeneratorVerbose, 0); - if ( !res || retVal ) + if ( !res || retval ) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/Deb.log"; @@ -215,15 +444,18 @@ int cmCPackDebGenerator::PackageFiles() } std::string md5filename; - md5filename = toplevel; + md5filename = this->GetOption("WDIR"); md5filename += "/md5sums"; { // the scope is needed for cmGeneratedFileStream cmGeneratedFileStream out(md5filename.c_str()); std::vector::const_iterator fileIt; - std::string topLevelWithTrailingSlash = toplevel; +// std::string topLevelWithTrailingSlash = toplevel; + std::string topLevelWithTrailingSlash = + this->GetOption("CPACK_TEMPORARY_DIRECTORY"); topLevelWithTrailingSlash += '/'; - for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt ) + for ( fileIt = packageFiles.begin(); + fileIt != packageFiles.end(); ++ fileIt ) { cmd = "\""; cmd += cmakeExecutable; @@ -233,34 +465,33 @@ int cmCPackDebGenerator::PackageFiles() //std::string output; //int retVal = -1; res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, - &retVal, toplevel.c_str(), this->GeneratorVerbose, 0); + &retval, toplevel.c_str(), this->GeneratorVerbose, 0); // debian md5sums entries are like this: // 014f3604694729f3bf19263bac599765 usr/bin/ccmake // thus strip the full path (with the trailing slash) - cmSystemTools::ReplaceString(output, + cmSystemTools::ReplaceString(output, topLevelWithTrailingSlash.c_str(), ""); out << output; } - // each line contains a eol. + // each line contains a eol. // Do not end the md5sum file with yet another (invalid) } - cmd = "\""; cmd += cmakeExecutable; cmd += "\" -E tar cfz control.tar.gz ./control ./md5sums"; - const char* controlExtra = + const char* controlExtra = this->GetOption("CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA"); if( controlExtra ) - { + { std::vector controlExtraList; cmSystemTools::ExpandListArgument(controlExtra, controlExtraList); - for(std::vector::iterator i = + for(std::vector::iterator i = controlExtraList.begin(); i != controlExtraList.end(); ++i) { - std::string filenamename = + std::string filenamename = cmsys::SystemTools::GetFilenameName(i->c_str()); - std::string localcopy = toplevel; + std::string localcopy = this->GetOption("WDIR"); localcopy += "/"; localcopy += filenamename; // if we can copy the file, it means it does exist, let's add it: @@ -274,9 +505,9 @@ int cmCPackDebGenerator::PackageFiles() } } res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, - &retVal, toplevel.c_str(), this->GeneratorVerbose, 0); + &retval, this->GetOption("WDIR"), this->GeneratorVerbose, 0); - if ( !res || retVal ) + if ( !res || retval ) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/Deb.log"; @@ -295,24 +526,63 @@ int cmCPackDebGenerator::PackageFiles() // since debian packages require BSD ar (most Linux distros and even // FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here. std::vector arFiles; - std::string topLevelString = toplevel; + std::string topLevelString = this->GetOption("WDIR"); topLevelString += "/"; arFiles.push_back(topLevelString + "debian-binary"); arFiles.push_back(topLevelString + "control.tar.gz"); arFiles.push_back(topLevelString + "data.tar.gz"); - res = ar_append(packageFileNames[0].c_str(), arFiles); + std::string outputFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + outputFileName += "/"; + outputFileName += this->GetOption("CPACK_OUTPUT_FILE_NAME"); + res = ar_append(outputFileName.c_str(), arFiles); if ( res!=0 ) { - std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + std::string tmpFile = this->GetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME"); tmpFile += "/Deb.log"; cmGeneratedFileStream ofs(tmpFile.c_str()); ofs << "# Problem creating archive using: " << res << std::endl; return 0; } - return 1; } +bool cmCPackDebGenerator::SupportsComponentInstallation() const + { + if (IsOn("CPACK_DEB_COMPONENT_INSTALL")) + { + return true; + } + else + { + return false; + } + } + +std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix( + const std::string& componentName) + { + if (componentPackageMethod == ONE_PACKAGE_PER_COMPONENT) { + return componentName; + } + + if (componentPackageMethod == ONE_PACKAGE) { + return std::string("ALL_COMPONENTS_IN_ONE"); + } + // We have to find the name of the COMPONENT GROUP + // the current COMPONENT belongs to. + std::string groupVar = "CPACK_COMPONENT_" + + cmSystemTools::UpperCase(componentName) + "_GROUP"; + if (NULL != GetOption(groupVar.c_str())) + { + return std::string(GetOption(groupVar.c_str())); + } + else + { + return componentName; + } + } + + // The following code is taken from OpenBSD ar: // http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ar/ // It has been slightly modified: diff --git a/Source/CPack/cmCPackDebGenerator.h b/Source/CPack/cmCPackDebGenerator.h index 4a357d1d6..f536c474e 100644 --- a/Source/CPack/cmCPackDebGenerator.h +++ b/Source/CPack/cmCPackDebGenerator.h @@ -33,8 +33,30 @@ public: protected: virtual int InitializeInternal(); + /** + * This method factors out the work done in component packaging case. + */ + int PackageOnePack(std::string initialToplevel, std::string packageName); + /** + * The method used to package files when component + * install is used. This will create one + * archive for each component group. + */ + int PackageComponents(bool ignoreGroup); + /** + * Special case of component install where all + * components will be put in a single installer. + */ + int PackageComponentsAllInOne(); virtual int PackageFiles(); virtual const char* GetOutputExtension() { return ".deb"; } + virtual bool SupportsComponentInstallation() const; + virtual std::string GetComponentInstallDirNameSuffix( + const std::string& componentName); + +private: + int createDeb(); + std::vector packageFiles; }; diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index e9ce76c13..83b6b64d4 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -51,6 +51,8 @@ static const char* SLASTREnglish = //---------------------------------------------------------------------- cmCPackDragNDropGenerator::cmCPackDragNDropGenerator() { + // default to one package file for components + this->componentPackageMethod = ONE_PACKAGE; } //---------------------------------------------------------------------- @@ -106,8 +108,57 @@ const char* cmCPackDragNDropGenerator::GetOutputExtension() //---------------------------------------------------------------------- int cmCPackDragNDropGenerator::PackageFiles() { + // gather which directories to make dmg files for + // multiple directories occur if packaging components or groups separately - return this->CreateDMG(); + // monolith + if(this->Components.empty()) + { + return this->CreateDMG(toplevel, packageFileNames[0]); + } + + // component install + std::vector package_files; + + std::map::iterator compIt; + for (compIt=this->Components.begin(); + compIt!=this->Components.end(); ++compIt ) + { + std::string name = GetComponentInstallDirNameSuffix(compIt->first); + package_files.push_back(name); + } + std::sort(package_files.begin(), package_files.end()); + package_files.erase(std::unique(package_files.begin(), + package_files.end()), + package_files.end()); + + + // loop to create dmg files + packageFileNames.clear(); + for(size_t i=0; iGetOption("CPACK_PACKAGE_FILE_NAME"); + } + else + { + full_package_name += package_files[i]; + } + full_package_name += std::string(GetOutputExtension()); + packageFileNames.push_back(full_package_name); + + std::string src_dir = toplevel; + src_dir += "/"; + src_dir += package_files[i]; + + if(0 == this->CreateDMG(src_dir, full_package_name)) + { + return 0; + } + } + return 1; } //---------------------------------------------------------------------- @@ -159,10 +210,11 @@ bool cmCPackDragNDropGenerator::RunCommand(cmOStringStream& command, } //---------------------------------------------------------------------- -int cmCPackDragNDropGenerator::CreateDMG() +int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, + const std::string& output_file) { // Get optional arguments ... - const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON") + const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON") ? this->GetOption("CPACK_PACKAGE_ICON") : ""; const std::string cpack_dmg_volume_name = @@ -197,7 +249,7 @@ int cmCPackDragNDropGenerator::CreateDMG() // The staging directory contains everything that will end-up inside the // final disk image ... cmOStringStream staging; - staging << toplevel; + staging << src_dir; // Add a symlink to /Applications so users can drag-and-drop the bundle // into it @@ -472,7 +524,7 @@ int cmCPackDragNDropGenerator::CreateDMG() final_image_command << cpack_dmg_format; final_image_command << " -imagekey"; final_image_command << " zlib-level=9"; - final_image_command << " -o \"" << packageFileNames[0] << "\""; + final_image_command << " -o \"" << output_file << "\""; if(!this->RunCommand(final_image_command)) { @@ -485,3 +537,47 @@ int cmCPackDragNDropGenerator::CreateDMG() return 1; } + +bool cmCPackDragNDropGenerator::SupportsComponentInstallation() const +{ + return true; +} + +std::string +cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix( + const std::string& componentName) +{ + // we want to group components together that go in the same dmg package + std::string package_file_name = this->GetOption("CPACK_PACKAGE_FILE_NAME"); + + // we have 3 mutually exclusive modes to work in + // 1. all components in one package + // 2. each group goes in its own package with left over + // components in their own package + // 3. ignore groups - if grouping is defined, it is ignored + // and each component goes in its own package + + if(this->componentPackageMethod == ONE_PACKAGE) + { + return "ALL_IN_ONE"; + } + + if(this->componentPackageMethod == ONE_PACKAGE_PER_GROUP) + { + // We have to find the name of the COMPONENT GROUP + // the current COMPONENT belongs to. + std::string groupVar = "CPACK_COMPONENT_" + + cmSystemTools::UpperCase(componentName) + "_GROUP"; + const char* _groupName = GetOption(groupVar.c_str()); + if (_groupName) + { + std::string groupName = _groupName; + + groupName = GetComponentPackageFileName(package_file_name, + groupName, true); + return groupName; + } + } + + return GetComponentPackageFileName(package_file_name, componentName, false); +} diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h index dcef7fb28..808c61886 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.h +++ b/Source/CPack/cmCPackDragNDropGenerator.h @@ -30,11 +30,16 @@ protected: virtual int InitializeInternal(); virtual const char* GetOutputExtension(); int PackageFiles(); + bool SupportsComponentInstallation() const; + bool CopyFile(cmOStringStream& source, cmOStringStream& target); bool RunCommand(cmOStringStream& command, std::string* output = 0); - int CreateDMG(); + std::string + GetComponentInstallDirNameSuffix(const std::string& componentName); + + int CreateDMG(const std::string& src_dir, const std::string& output_file); std::string InstallPrefix; }; diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index feda52c06..7e5b26d62 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -24,6 +24,7 @@ #include #include #include // auto_ptr +#include #if defined(__HAIKU__) #include @@ -35,9 +36,7 @@ cmCPackGenerator::cmCPackGenerator() this->GeneratorVerbose = false; this->MakefileMap = 0; this->Logger = 0; - this->allGroupInOne = false; - this->allComponentInOne = false; - this->ignoreComponentGroup = false; + this->componentPackageMethod = ONE_PACKAGE_PER_GROUP; } //---------------------------------------------------------------------- @@ -684,7 +683,14 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( if (componentInstall) { tempInstallDirectory += "/"; - tempInstallDirectory += installComponent; + // Some CPack generators would rather chose + // the local installation directory suffix. + // Some (e.g. RPM) use + // one install directory for each component **GROUP** + // instead of the default + // one install directory for each component. + tempInstallDirectory += + GetComponentInstallDirNameSuffix(installComponent); } if (!setDestDir) @@ -803,7 +809,55 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( { mf->AddDefinition("CMAKE_INSTALL_DO_STRIP", "1"); } + // Remember the list of files before installation + // of the current component (if we are in component install) + const char* InstallPrefix = tempInstallDirectory.c_str(); + std::vector filesBefore; + std::string findExpr(InstallPrefix); + if (componentInstall) + { + cmsys::Glob glB; + findExpr += "/*"; + glB.RecurseOn(); + glB.FindFiles(findExpr); + filesBefore = glB.GetFiles(); + std::sort(filesBefore.begin(),filesBefore.end()); + } + // do installation int res = mf->ReadListFile(0, installFile.c_str()); + // Now rebuild the list of files after installation + // of the current component (if we are in component install) + if (componentInstall) + { + cmsys::Glob glA; + glA.RecurseOn(); + glA.FindFiles(findExpr); + std::vector filesAfter = glA.GetFiles(); + std::sort(filesAfter.begin(),filesAfter.end()); + std::vector::iterator diff; + std::vector result(filesAfter.size()); + diff = std::set_difference ( + filesAfter.begin(),filesAfter.end(), + filesBefore.begin(),filesBefore.end(), + result.begin()); + + std::vector::iterator fit; + std::string localFileName; + // Populate the File field of each component + for (fit=result.begin();fit!=diff;++fit) + { + localFileName = + cmSystemTools::RelativePath(InstallPrefix, fit->c_str()); + localFileName = + localFileName.substr(localFileName.find('/')+1, + std::string::npos); + Components[installComponent].Files.push_back(localFileName); + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file <" + < to component <" + <"<GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) { if (absoluteDestFiles.length()>0) { absoluteDestFiles +=";"; @@ -813,6 +867,28 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cmCPackLogger(cmCPackLog::LOG_DEBUG, "Got some ABSOLUTE DESTINATION FILES: " << absoluteDestFiles << std::endl); + // define component specific var + if (componentInstall) + { + std::string absoluteDestFileComponent = + std::string("CPACK_ABSOLUTE_DESTINATION_FILES") + + "_" + GetComponentInstallDirNameSuffix(installComponent); + if (NULL != this->GetOption(absoluteDestFileComponent.c_str())) + { + std::string absoluteDestFilesListComponent = + this->GetOption(absoluteDestFileComponent.c_str()); + absoluteDestFilesListComponent +=";"; + absoluteDestFilesListComponent += + mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"); + this->SetOption(absoluteDestFileComponent.c_str(), + absoluteDestFilesListComponent.c_str()); + } + else + { + this->SetOption(absoluteDestFileComponent.c_str(), + mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")); + } + } } if ( cmSystemTools::GetErrorOccuredFlag() || !res ) { @@ -829,8 +905,12 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( //---------------------------------------------------------------------- bool cmCPackGenerator::ReadListFile(const char* moduleName) { + bool retval; std::string fullPath = this->MakefileMap->GetModulesFile(moduleName); - return this->MakefileMap->ReadListFile(0, fullPath.c_str()); + retval = this->MakefileMap->ReadListFile(0, fullPath.c_str()); + // include FATAL_ERROR and ERROR in the return status + retval = retval && (! cmSystemTools::GetErrorOccuredFlag()); + return retval; } //---------------------------------------------------------------------- @@ -873,6 +953,12 @@ int cmCPackGenerator::DoPackage() return 0; } + // Digest Component grouping specification + if ( !this->PrepareGroupingKind() ) + { + return 0; + } + if ( cmSystemTools::IsOn( this->GetOption("CPACK_REMOVE_TOPLEVEL_DIRECTORY")) ) { @@ -939,35 +1025,6 @@ int cmCPackGenerator::DoPackage() // The files to be installed files = gl.GetFiles(); - // For component installations, determine which files go into which - // components. - if (!this->Components.empty()) - { - std::vector::const_iterator it; - for ( it = files.begin(); it != files.end(); ++ it ) - { - // beware we cannot just use tempDirectory as before - // because some generator will "CPACK_INCLUDE_TOPLEVEL_DIRECTORY" - // we really want "CPACK_TEMPORARY_DIRECTORY" - std::string fileN = - cmSystemTools::RelativePath( - this->GetOption("CPACK_TEMPORARY_DIRECTORY"), it->c_str()); - - // Determine which component we are in. - std::string componentName = fileN.substr(0, fileN.find('/')); - - // Strip off the component part of the path. - fileN = fileN.substr(fileN.find('/')+1, std::string::npos); - - // Add this file to the list of files for the component. - this->Components[componentName].Files.push_back(fileN); - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file <" - < to component <" - <"<GetOption( - "CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE"))); - allComponentInOne = (NULL != - (this->GetOption( - "CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE"))); - ignoreComponentGroup = (NULL != - (this->GetOption( - "CPACK_COMPONENTS_IGNORE_GROUPS"))); + // find a component package method specified by the user + ComponentPackageMethod method = UNKNOWN_COMPONENT_PACKAGE_METHOD; + + if(this->GetOption("CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE")) + { + method = ONE_PACKAGE; + } + + if(this->GetOption("CPACK_COMPONENTS_IGNORE_GROUPS")) + { + method = ONE_PACKAGE_PER_COMPONENT; + } + + if(this->GetOption("CPACK_COMPONENTS_ONE_PACKAGE_PER_GROUP")) + { + method = ONE_PACKAGE_PER_GROUP; + } std::string groupingType; @@ -1251,43 +1314,116 @@ int cmCPackGenerator::PrepareGroupingKind() cmCPackLogger(cmCPackLog::LOG_VERBOSE, "[" << this->Name << "]" << " requested component grouping = "<< groupingType <Name << "]" - << " requested component grouping type <"<< groupingType - << "> UNKNOWN not in (ALL_GROUP_IN_ONE," - "ALL_COMPONENT_IN_ONE,IGNORE)" <Name << "]" + << " requested component grouping type <"<< groupingType + << "> UNKNOWN not in (ALL_COMPONENTS_IN_ONE,IGNORE,ONE_PER_GROUP)" + << std::endl); } } // Some components were defined but NO group - // force ignoreGroups - if (this->ComponentGroups.empty() && (!this->Components.empty()) - && (!ignoreComponentGroup)) { + // fallback to default if not group based + if(method == ONE_PACKAGE_PER_GROUP && + this->ComponentGroups.empty() && !this->Components.empty()) + { + if(componentPackageMethod == ONE_PACKAGE) + { + method = ONE_PACKAGE; + } + else + { + method = ONE_PACKAGE_PER_COMPONENT; + } cmCPackLogger(cmCPackLog::LOG_WARNING, "[" - << this->Name << "]" - << " Some Components defined but NO component group:" - << " Ignoring component group." - << std::endl); - ignoreComponentGroup = true; - } + << this->Name << "]" + << " One package per component group requested, " + << "but NO component groups exist: Ignoring component group." + << std::endl); + } + + // if user specified packaging method, override the default packaging method + if(method != UNKNOWN_COMPONENT_PACKAGE_METHOD) + { + componentPackageMethod = method; + } + + const char* method_names[] = + { + "ALL_COMPONENTS_IN_ONE", + "IGNORE_GROUPS", + "ONE_PER_GROUP" + }; + + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "[" + << this->Name << "]" + << " requested component grouping = " + << method_names[componentPackageMethod] + << std::endl); return 1; } +//---------------------------------------------------------------------- +std::string cmCPackGenerator::GetComponentInstallDirNameSuffix( + const std::string& componentName) { + return componentName; +} +//---------------------------------------------------------------------- +std::string cmCPackGenerator::GetComponentPackageFileName( + const std::string& initialPackageFileName, + const std::string& groupOrComponentName, + bool isGroupName) { + + /* + * the default behavior is to use the + * component [group] name as a suffix + */ + std::string suffix="-"+groupOrComponentName; + /* check if we should use DISPLAY name */ + std::string dispNameVar = "CPACK_"+Name+"_USE_DISPLAY_NAME_IN_FILENAME"; + if (IsOn(dispNameVar.c_str())) + { + /* the component Group case */ + if (isGroupName) + { + std::string groupDispVar = "CPACK_COMPONENT_GROUP_" + + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME"; + const char* groupDispName = GetOption(groupDispVar.c_str()); + if (groupDispName) + { + suffix = "-"+std::string(groupDispName); + } + } + /* the [single] component case */ + else + { + std::string dispVar = "CPACK_COMPONENT_" + + cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME"; + const char* dispName = GetOption(dispVar.c_str()); + if(dispName) + { + suffix = "-"+std::string(dispName); + } + } + } + return initialPackageFileName + suffix; +} + //---------------------------------------------------------------------- bool cmCPackGenerator::SupportsComponentInstallation() const { diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index f44a334ad..05d95b874 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -122,15 +122,40 @@ protected: /** * Prepare requested grouping kind from CPACK_xxx vars - * CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE * CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE * CPACK_COMPONENTS_IGNORE_GROUPS * or - * CPACK_COMPONENTS_GROUPING + * CPACK_COMPONENTS_ONE_PACKAGE_PER_GROUP * @return 1 on success 0 on failure. */ virtual int PrepareGroupingKind(); + /** + * Some CPack generators may prefer to have + * CPack install all components belonging to the same + * [component] group to be install in the same directory. + * The default behavior is to install each component in + * a separate directory. + * @param[in] componentName the name of the component to be installed + * @return the name suffix the generator wants for the specified component + * default is "componentName" + */ + virtual std::string GetComponentInstallDirNameSuffix( + const std::string& componentName); + + /** + * CPack specific generator may mangle CPACK_PACKAGE_FILE_NAME + * with CPACK_COMPONENT_xxxx__DISPLAY_NAME if + * CPACK__USE_DISPLAY_NAME_IN_FILENAME is ON. + * @param[in] initialPackageFileName + * @param[in] groupOrComponentName + * @param[in] isGroupName + */ + virtual std::string GetComponentPackageFileName( + const std::string& initialPackageFileName, + const std::string& groupOrComponentName, + bool isGroupName); + /** * Package the list of files and/or components which * has been prepared by the beginning of DoPackage. @@ -212,20 +237,30 @@ protected: */ std::map Components; std::map ComponentGroups; + /** - * If true All component groups will be put in a single package. - */ - bool allGroupInOne; - /** - * If true All component will be put in a single package. + * If components are enabled, this enum represents the different + * ways of mapping components to package files. */ - bool allComponentInOne; + enum ComponentPackageMethod + { + /* one package for all components */ + ONE_PACKAGE, + /* one package for each component */ + ONE_PACKAGE_PER_COMPONENT, + /* one package for each group, + * with left over components in their own package */ + ONE_PACKAGE_PER_GROUP, + UNKNOWN_COMPONENT_PACKAGE_METHOD + }; + /** - * If true component grouping will be ignored. - * You will still get 1 package for each component unless - * allComponentInOne is true. + * The component package method + * The default is ONE_PACKAGE_PER_GROUP, + * and generators may override the default + * before PrepareGroupingKind() is called. */ - bool ignoreComponentGroup; + ComponentPackageMethod componentPackageMethod; cmCPackLog* Logger; private: diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 0e8cbc0a5..75ad640c0 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -21,6 +21,7 @@ #include #include +#include //---------------------------------------------------------------------- cmCPackOSXX11Generator::cmCPackOSXX11Generator() @@ -135,6 +136,32 @@ int cmCPackOSXX11Generator::PackageFiles() return 0; } + // Two of the files need to have execute permission, so ensure they do: + std::string runTimeScript = dir; + runTimeScript += "/"; + runTimeScript += "RuntimeScript"; + + std::string appScriptName = appdir; + appScriptName += "/"; + appScriptName += this->GetOption("CPACK_PACKAGE_FILE_NAME"); + + mode_t mode; + if (cmsys::SystemTools::GetPermissions(runTimeScript.c_str(), mode)) + { + mode |= (S_IXUSR | S_IXGRP | S_IXOTH); + cmsys::SystemTools::SetPermissions(runTimeScript.c_str(), mode); + cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Setting: " << runTimeScript + << " to permission: " << mode << std::endl); + } + + if (cmsys::SystemTools::GetPermissions(appScriptName.c_str(), mode)) + { + mode |= (S_IXUSR | S_IXGRP | S_IXOTH); + cmsys::SystemTools::SetPermissions(appScriptName.c_str(), mode); + cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Setting: " << appScriptName + << " to permission: " << mode << std::endl); + } + std::string output; std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/hdiutilOutput.log"; diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index a5db78f40..1a6c3bef4 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -31,63 +31,195 @@ int cmCPackRPMGenerator::InitializeInternal() { this->SetOption("CPACK_SET_DESTDIR", "I_ON"); } + /* Replace space in CPACK_PACKAGE_NAME in order to avoid + * rpmbuild scream on unwanted space in filename issue + * Moreover RPM file do not usually embed space in filename + */ + if (this->GetOption("CPACK_PACKAGE_NAME")) { + std::string packageName=this->GetOption("CPACK_PACKAGE_NAME"); + cmSystemTools::ReplaceString(packageName," ","-"); + this->SetOption("CPACK_PACKAGE_NAME",packageName.c_str()); + } + /* same for CPACK_PACKAGE_FILE_NAME */ + if (this->GetOption("CPACK_PACKAGE_FILE_NAME")) { + std::string packageName=this->GetOption("CPACK_PACKAGE_FILE_NAME"); + cmSystemTools::ReplaceString(packageName," ","-"); + this->SetOption("CPACK_PACKAGE_FILE_NAME",packageName.c_str()); + } return this->Superclass::InitializeInternal(); } //---------------------------------------------------------------------- -int cmCPackRPMGenerator::PackageFiles() +int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel, + std::string packageName) { int retval = 1; - /* Digest Component grouping specification */ - retval = PrepareGroupingKind(); - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " - << toplevel << std::endl); + // Begin the archive for this pack + std::string localToplevel(initialToplevel); + std::string packageFileName( + cmSystemTools::GetParentDirectory(toplevel.c_str()) + ); + std::string outputFileName( + GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"), + packageName, + true) + + this->GetOutputExtension() + ); - /* Are we in the component packaging case */ - if (SupportsComponentInstallation() & (!this->ComponentGroups.empty())) + localToplevel += "/"+ packageName; + /* replace the TEMP DIRECTORY with the component one */ + this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str()); + packageFileName += "/"+ outputFileName; + /* replace proposed CPACK_OUTPUT_FILE_NAME */ + this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str()); + /* replace the TEMPORARY package file name */ + this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", + packageFileName.c_str()); + // Tell CPackRPM.cmake the name of the component NAME. + this->SetOption("CPACK_RPM_PACKAGE_COMPONENT",packageName.c_str()); + if (!this->ReadListFile("CPackRPM.cmake")) { - /* Reset package file name list it will be populated during the - * component packaging run*/ - packageFileNames.clear(); - std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); - /* One Package per component CASE */ - /* Iterate over components */ + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while execution CPackRPM.cmake" << std::endl); + retval = 0; + } + // add the generated package to package file names list + packageFileNames.push_back(packageFileName); + return retval; +} + +//---------------------------------------------------------------------- +int cmCPackRPMGenerator::PackageComponents(bool ignoreGroup) +{ + int retval = 1; + /* Reset package file name list it will be populated during the + * component packaging run*/ + packageFileNames.clear(); + std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); + + // The default behavior is to have one package by component group + // unless CPACK_COMPONENTS_IGNORE_GROUP is specified. + if (!ignoreGroup) + { + std::map::iterator compGIt; + for (compGIt=this->ComponentGroups.begin(); + compGIt!=this->ComponentGroups.end(); ++compGIt) + { + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " + << compGIt->first + << std::endl); + retval &= PackageOnePack(initialTopLevel,compGIt->first); + } + // Handle Orphan components (components not belonging to any groups) std::map::iterator compIt; for (compIt=this->Components.begin(); compIt!=this->Components.end(); ++compIt ) { - std::string localToplevel(initialTopLevel); - std::string packageFileName( - cmSystemTools::GetParentDirectory(toplevel.c_str()) - ); - std::string outputFileName( - std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME") - ) - +"-"+compIt->first + this->GetOutputExtension()); - - localToplevel += "/"+ compIt->first; - /* replace the TEMP DIRECTORY with the component one */ - this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str()); - packageFileName += "/"+ outputFileName; - /* replace proposed CPACK_OUTPUT_FILE_NAME */ - this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str()); - /* replace the TEMPORARY package file name */ - this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", - packageFileName.c_str()); - - this->SetOption("CPACK_RPM_PACKAGE_COMPONENT",compIt->first.c_str()); - if (!this->ReadListFile("CPackRPM.cmake")) + // Does the component belong to a group? + if (compIt->second.Group==NULL) { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Error while execution CPackRPM.cmake" << std::endl); - retval = 0; + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Component <" + << compIt->second.Name + << "> does not belong to any group, package it separately." + << std::endl); + retval &= PackageOnePack(initialTopLevel,compIt->first); } - - // add the generated package to package file names list - packageFileNames.push_back(packageFileName); } } - /* This is the non component case */ + // CPACK_COMPONENTS_IGNORE_GROUPS is set + // We build 1 package per component + else + { + std::map::iterator compIt; + for (compIt=this->Components.begin(); + compIt!=this->Components.end(); ++compIt ) + { + retval &= PackageOnePack(initialTopLevel,compIt->first); + } + } + return retval; +} + +//---------------------------------------------------------------------- +int cmCPackRPMGenerator::PackageComponentsAllInOne() +{ + int retval = 1; + std::string compInstDirName; + /* Reset package file name list it will be populated during the + * component packaging run*/ + packageFileNames.clear(); + std::string initialTopLevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); + + compInstDirName = "ALL_COMPONENTS_IN_ONE"; + + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Packaging all groups in one package..." + "(CPACK_COMPONENTS_ALL_[GROUPS_]IN_ONE_PACKAGE is set)" + << std::endl); + + // The ALL GROUPS in ONE package case + std::string localToplevel(initialTopLevel); + std::string packageFileName( + cmSystemTools::GetParentDirectory(toplevel.c_str()) + ); + std::string outputFileName( + std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + + this->GetOutputExtension() + ); + // all GROUP in one vs all COMPONENT in one + localToplevel += "/"+compInstDirName; + + /* replace the TEMP DIRECTORY with the component one */ + this->SetOption("CPACK_TEMPORARY_DIRECTORY",localToplevel.c_str()); + packageFileName += "/"+ outputFileName; + /* replace proposed CPACK_OUTPUT_FILE_NAME */ + this->SetOption("CPACK_OUTPUT_FILE_NAME",outputFileName.c_str()); + /* replace the TEMPORARY package file name */ + this->SetOption("CPACK_TEMPORARY_PACKAGE_FILE_NAME", + packageFileName.c_str()); + // Tell CPackRPM.cmake the name of the component GROUP. + this->SetOption("CPACK_RPM_PACKAGE_COMPONENT",compInstDirName.c_str()); + if (!this->ReadListFile("CPackRPM.cmake")) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error while execution CPackRPM.cmake" << std::endl); + retval = 0; + } + // add the generated package to package file names list + packageFileNames.push_back(packageFileName); + + return retval; +} + +//---------------------------------------------------------------------- +int cmCPackRPMGenerator::PackageFiles() +{ + int retval = 1; + + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " + << toplevel << std::endl); + + /* Are we in the component packaging case */ + if (SupportsComponentInstallation()) { + // CASE 1 : COMPONENT ALL-IN-ONE package + // If ALL COMPONENTS in ONE package has been requested + // then the package file is unique and should be open here. + if (componentPackageMethod == ONE_PACKAGE) + { + return PackageComponentsAllInOne(); + } + // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) + // There will be 1 package for each component group + // however one may require to ignore component group and + // in this case you'll get 1 package for each component. + else + { + return PackageComponents(componentPackageMethod == + ONE_PACKAGE_PER_COMPONENT); + } + } + // CASE 3 : NON COMPONENT package. else { if (!this->ReadListFile("CPackRPM.cmake")) @@ -118,3 +250,26 @@ bool cmCPackRPMGenerator::SupportsComponentInstallation() const } } +std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix( + const std::string& componentName) + { + if (componentPackageMethod == ONE_PACKAGE_PER_COMPONENT) { + return componentName; + } + + if (componentPackageMethod == ONE_PACKAGE) { + return std::string("ALL_COMPONENTS_IN_ONE"); + } + // We have to find the name of the COMPONENT GROUP + // the current COMPONENT belongs to. + std::string groupVar = "CPACK_COMPONENT_" + + cmSystemTools::UpperCase(componentName) + "_GROUP"; + if (NULL != GetOption(groupVar.c_str())) + { + return std::string(GetOption(groupVar.c_str())); + } + else + { + return componentName; + } + } diff --git a/Source/CPack/cmCPackRPMGenerator.h b/Source/CPack/cmCPackRPMGenerator.h index 57d5cca70..4883a0d60 100644 --- a/Source/CPack/cmCPackRPMGenerator.h +++ b/Source/CPack/cmCPackRPMGenerator.h @@ -38,8 +38,25 @@ public: protected: virtual int InitializeInternal(); virtual int PackageFiles(); + /** + * This method factors out the work done in component packaging case. + */ + int PackageOnePack(std::string initialToplevel, std::string packageName); + /** + * The method used to package files when component + * install is used. This will create one + * archive for each component group. + */ + int PackageComponents(bool ignoreGroup); + /** + * Special case of component install where all + * components will be put in a single installer. + */ + int PackageComponentsAllInOne(); virtual const char* GetOutputExtension() { return ".rpm"; } virtual bool SupportsComponentInstallation() const; + virtual std::string GetComponentInstallDirNameSuffix( + const std::string& componentName); }; diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 9678ac45c..86bd85d94 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -93,6 +93,7 @@ static const char* cmCTestErrorMatches[] = { ": No such file or directory", ": Invalid argument", "^The project cannot be built\\.", + "^\\[ERROR\\]", 0 }; @@ -119,7 +120,7 @@ static const char* cmCTestWarningMatches[] = { "^\"[^\"]+\", line [0-9]+: [Ww](arning|arnung)", "([^:]+): warning[ \\t]*[0-9]+[ \\t]*:", "^(Warning|Warnung) ([0-9]+):", - "^(Warning|Warnung) ", + "^(Warning|Warnung)[ :]", "WARNING: ", "([^ :]+) : warning", "([^:]+): warning", @@ -131,6 +132,7 @@ static const char* cmCTestWarningMatches[] = { "\".*\", line [0-9]+: remark\\([0-9]*\\):", "cc-[0-9]* CC: REMARK File = .*, Line = [0-9]*", "^CMake Warning.*:", + "^\\[WARNING\\]", 0 }; diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 6863adce4..005651f84 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -825,7 +825,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( // Call gcov to get coverage data for this *.gcda file: // std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str()); - std::string command = "\"" + gcovCommand + "\" -l -o \"" + fileDir + std::string command = "\"" + gcovCommand + "\" -l -p -o \"" + fileDir + "\" \"" + *it + "\""; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str() diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index aa9e55b23..2c1a0afd9 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -23,11 +23,20 @@ #include #include +//---------------------------------------------------------------------------- +static unsigned int cmCTestGITVersion(unsigned int epic, unsigned int major, + unsigned int minor, unsigned int fix) +{ + // 1.6.5.0 maps to 10605000 + return fix + minor*1000 + major*100000 + epic*10000000; +} + //---------------------------------------------------------------------------- cmCTestGIT::cmCTestGIT(cmCTest* ct, std::ostream& log): cmCTestGlobalVC(ct, log) { this->PriorRev = this->Unknown; + this->CurrentGitVersion = 0; } //---------------------------------------------------------------------------- @@ -263,13 +272,47 @@ bool cmCTestGIT::UpdateImpl() std::string top_dir = this->FindTopDir(); const char* git = this->CommandLineTool.c_str(); - char const* git_submodule[] = {git, "submodule", "update", 0}; + const char* recursive = "--recursive"; + + // Git < 1.6.5.0 did not support --recursive + if(this->GetGitVersion() < cmCTestGITVersion(1,6,5,0)) + { + recursive = 0; + // No need to require >= 1.6.5.0 if there are no submodules. + if(cmSystemTools::FileExists((top_dir + "/.gitmodules").c_str())) + { + this->Log << "Git < 1.6.5.0 cannot update submodules recursively\n"; + } + } + + char const* git_submodule[] = {git, "submodule", "update", recursive, 0}; OutputLogger submodule_out(this->Log, "submodule-out> "); OutputLogger submodule_err(this->Log, "submodule-err> "); return this->RunChild(git_submodule, &submodule_out, &submodule_err, top_dir.c_str()); } +//---------------------------------------------------------------------------- +unsigned int cmCTestGIT::GetGitVersion() +{ + if(!this->CurrentGitVersion) + { + const char* git = this->CommandLineTool.c_str(); + char const* git_version[] = {git, "--version", 0}; + std::string version; + OneLineParser version_out(this, "version-out> ", version); + OutputLogger version_err(this->Log, "version-err> "); + unsigned int v[4] = {0,0,0,0}; + if(this->RunChild(git_version, &version_out, &version_err) && + sscanf(version.c_str(), "git version %u.%u.%u.%u", + &v[0], &v[1], &v[2], &v[3]) >= 3) + { + this->CurrentGitVersion = cmCTestGITVersion(v[0], v[1], v[2], v[3]); + } + } + return this->CurrentGitVersion; +} + //---------------------------------------------------------------------------- /* Diff format: diff --git a/Source/CTest/cmCTestGIT.h b/Source/CTest/cmCTestGIT.h index 1765340d5..f4fae8f9d 100644 --- a/Source/CTest/cmCTestGIT.h +++ b/Source/CTest/cmCTestGIT.h @@ -27,6 +27,8 @@ public: virtual ~cmCTestGIT(); private: + unsigned int CurrentGitVersion; + unsigned int GetGitVersion(); std::string GetWorkingRevision(); virtual void NoteOldRevision(); virtual void NoteNewRevision(); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 13a25cb5c..06124491a 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -344,9 +344,21 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) } this->MemoryTesterGlobalResults[kk] += memcheckresults[kk]; } + + std::string logTag; + if(this->CTest->ShouldCompressMemCheckOutput()) + { + this->CTest->CompressString(memcheckstr); + logTag = "\t\n"; + } + else + { + logTag = "\t\n"; + } + os << "\t\t\n" - << "\t\n" << memcheckstr << std::endl + << logTag << memcheckstr << std::endl << "\t\n"; this->WriteTestResultFooter(os, result); if ( current < cc ) diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index f3a445716..2cae80215 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -484,7 +484,7 @@ void cmCTestMultiProcessHandler::CreateTestCostList() } TestComparator comp(this); - std::sort(SortedTests.begin(), SortedTests.end(), comp); + std::stable_sort(SortedTests.begin(), SortedTests.end(), comp); } //--------------------------------------------------------- diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 42a4cff05..60695daa1 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -135,7 +135,10 @@ void cmCTestRunTest::CompressOutput() //--------------------------------------------------------- bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) { - if (this->CTest->ShouldCompressTestOutput()) + if ((!this->TestHandler->MemCheck && + this->CTest->ShouldCompressTestOutput()) || + (this->TestHandler->MemCheck && + this->CTest->ShouldCompressMemCheckOutput())) { this->CompressOutput(); } @@ -279,11 +282,11 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) // Output since that is what is parsed by cmCTestMemCheckHandler if(!this->TestHandler->MemCheck && started) { - this->TestHandler->CleanTestOutput(this->ProcessOutput, - static_cast - (this->TestResult.Status == cmCTestTestHandler::COMPLETED ? - this->TestHandler->CustomMaximumPassedTestOutputSize : - this->TestHandler->CustomMaximumFailedTestOutputSize)); + this->TestHandler->CleanTestOutput(this->ProcessOutput, + static_cast + (this->TestResult.Status == cmCTestTestHandler::COMPLETED ? + this->TestHandler->CustomMaximumPassedTestOutputSize : + this->TestHandler->CustomMaximumFailedTestOutputSize)); } this->TestResult.Reason = reason; if (this->TestHandler->LogFile) @@ -332,7 +335,8 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) // record the results in TestResult if(started) { - bool compress = this->CompressionRatio < 1 && + bool compress = !this->TestHandler->MemCheck && + this->CompressionRatio < 1 && this->CTest->ShouldCompressTestOutput(); this->TestResult.Output = compress ? this->CompressedOutput : this->ProcessOutput; @@ -408,6 +412,30 @@ bool cmCTestRunTest::StartTest(size_t total) this->TestResult.TestCount = this->TestProperties->Index; this->TestResult.Name = this->TestProperties->Name; this->TestResult.Path = this->TestProperties->Directory.c_str(); + + if(args.size() >= 2 && args[1] == "NOT_AVAILABLE") + { + this->TestProcess = new cmProcess; + std::string msg; + if(this->CTest->GetConfigType().empty()) + { + msg = "Test not available without configuration."; + msg += " (Missing \"-C \"?)"; + } + else + { + msg = "Test not available in configuration \""; + msg += this->CTest->GetConfigType(); + msg += "\"."; + } + *this->TestHandler->LogFile << msg << std::endl; + cmCTestLog(this->CTest, ERROR_MESSAGE, msg << std::endl); + this->TestResult.Output = msg; + this->TestResult.FullCommandLine = ""; + this->TestResult.CompletionStatus = "Not Run"; + this->TestResult.Status = cmCTestTestHandler::NOT_RUN; + return false; + } // Check if all required files exist for(std::vector::iterator i = diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index fdf17e0e0..5841b8d42 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -50,6 +50,7 @@ #include "cmCTestSubmitCommand.h" #include "cmCTestTestCommand.h" #include "cmCTestUpdateCommand.h" +#include "cmCTestUploadCommand.h" #define CTEST_INITIAL_CMAKE_OUTPUT_FILE_NAME "CTestInitialCMakeOutput.log" @@ -164,7 +165,7 @@ cmCTestScriptHandler::~cmCTestScriptHandler() //---------------------------------------------------------------------- // just adds an argument to the vector -void cmCTestScriptHandler::AddConfigurationScript(const char *script, +void cmCTestScriptHandler::AddConfigurationScript(const char *script, bool pscope) { this->ConfigurationScripts.push_back(script); @@ -224,12 +225,12 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) argv.push_back("-SR"); argv.push_back(total_script_arg.c_str()); - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Executable for CTest is: " << + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Executable for CTest is: " << this->CTest->GetCTestExecutable() << "\n"); // now pass through all the other arguments - std::vector &initArgs = + std::vector &initArgs = this->CTest->GetInitialCommandLineArguments(); //*** need to make sure this does not have the current script *** for(size_t i=1; i < initArgs.size(); ++i) @@ -252,7 +253,7 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) int pipe = cmSystemTools::WaitForLine(cp, line, 100.0, out, err); while(pipe != cmsysProcess_Pipe_None) { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Output: " + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Output: " << line << "\n"); if(pipe == cmsysProcess_Pipe_STDERR) { @@ -264,7 +265,7 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) } pipe = cmSystemTools::WaitForLine(cp, line, 100, out, err); } - + // Properly handle output of the build command cmsysProcess_WaitForExit(cp, 0); int result = cmsysProcess_GetState(cp); @@ -278,7 +279,7 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg) { retVal = cmsysProcess_GetExitException(cp); cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was an exception: " - << cmsysProcess_GetExceptionString(cp) << " " << + << cmsysProcess_GetExceptionString(cp) << " " << retVal << std::endl); failed = true; } @@ -338,7 +339,7 @@ void cmCTestScriptHandler::CreateCMake() this->Makefile->SetStartDirectory(cwd.c_str()); this->Makefile->SetStartOutputDirectory(cwd.c_str()); - // remove all cmake commands which are not scriptable, since they can't be + // remove all cmake commands which are not scriptable, since they can't be // used in ctest scripts this->CMake->RemoveUnscriptableCommands(); @@ -357,6 +358,7 @@ void cmCTestScriptHandler::CreateCMake() this->AddCTestCommand(new cmCTestSubmitCommand); this->AddCTestCommand(new cmCTestTestCommand); this->AddCTestCommand(new cmCTestUpdateCommand); + this->AddCTestCommand(new cmCTestUploadCommand); } void cmCTestScriptHandler::GetCommandDocumentation( @@ -418,17 +420,17 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) this->Makefile->AddFunctionBlocker(f); - /* Execute CTestScriptMode.cmake, which loads CMakeDetermineSystem and - CMakeSystemSpecificInformation, so + /* Execute CTestScriptMode.cmake, which loads CMakeDetermineSystem and + CMakeSystemSpecificInformation, so that variables like CMAKE_SYSTEM and also the search paths for libraries, header and executables are set correctly and can be used. Makes new-style ctest scripting easier. */ - std::string systemFile = + std::string systemFile = this->Makefile->GetModulesFile("CTestScriptMode.cmake"); if (!this->Makefile->ReadListFile(0, systemFile.c_str()) || cmSystemTools::GetErrorOccuredFlag()) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:" + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:" << systemFile.c_str() << "\n"); return 2; } @@ -440,8 +442,8 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read script: " << script.c_str() << std::endl); - // Reset the error flag so that it can run more than - // one script with an error when you + // Reset the error flag so that it can run more than + // one script with an error when you // use ctest_run_script cmSystemTools::ResetErrorOccuredFlag(); return 2; @@ -880,7 +882,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() // put the initial cache into the bin dir if (!this->InitialCache.empty()) { - if (!this->WriteInitialCache(this->BinaryDir.c_str(), + if (!this->WriteInitialCache(this->BinaryDir.c_str(), this->InitialCache.c_str())) { this->RestoreBackupDirectories(); @@ -986,7 +988,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() } //------------------------------------------------------------------------- -bool cmCTestScriptHandler::WriteInitialCache(const char* directory, +bool cmCTestScriptHandler::WriteInitialCache(const char* directory, const char* text) { std::string cacheFile = directory; @@ -1032,7 +1034,7 @@ void cmCTestScriptHandler::RestoreBackupDirectories() } } -bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char *sname, +bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char *sname, bool InProcess, int* returnValue) { cmCTestScriptHandler* sh = new cmCTestScriptHandler(); @@ -1076,13 +1078,13 @@ double cmCTestScriptHandler::GetRemainingTimeAllowed() const char *timelimitS = this->Makefile->GetDefinition("CTEST_TIME_LIMIT"); - + if (!timelimitS) { return 1.0e7; } double timelimit = atof(timelimitS); - + return timelimit - cmSystemTools::GetTime() + this->ScriptStartTime; } diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 9f9f85a83..142bb4613 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -296,7 +296,7 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix, *this->LogFile << " Error when uploading file: " << local_file.c_str() << std::endl - << " Error message was: " + << " Error message was: " << error_buffer << std::endl << " Curl output was: "; // avoid dereference of empty vector @@ -364,13 +364,13 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, { if(verifyPeerOff) { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Set CURLOPT_SSL_VERIFYPEER to off\n"); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0); } if(verifyHostOff) { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Set CURLOPT_SSL_VERIFYHOST to off\n"); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0); } @@ -601,7 +601,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, *this->LogFile << " Error when uploading file: " << local_file.c_str() << std::endl - << " Error message was: " << error_buffer + << " Error message was: " << error_buffer << std::endl; // avoid deref of begin for zero size array if(chunk.size()) @@ -763,7 +763,7 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP( << error_buffer << std::endl); *this->LogFile << "\tTriggering failed with error: " << error_buffer << std::endl - << " Error message was: " << error_buffer + << " Error message was: " << error_buffer << std::endl; if(chunk.size()) { @@ -913,8 +913,8 @@ bool cmCTestSubmitHandler::SubmitUsingCP( { if ( !localprefix.size() || !files.size() || !remoteprefix.size() || !destination.size() ) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, + { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Missing arguments for submit via cp:\n" << "\tlocalprefix: " << localprefix << "\n" << "\tNumber of files: " << files.size() << "\n" @@ -1204,6 +1204,7 @@ int cmCTestSubmitHandler::ProcessHandler() this->CTest->AddIfExists(cmCTest::PartMemCheck, "DynamicAnalysis.xml"); this->CTest->AddIfExists(cmCTest::PartMemCheck, "Purify.xml"); this->CTest->AddIfExists(cmCTest::PartNotes, "Notes.xml"); + this->CTest->AddIfExists(cmCTest::PartUpload, "Upload.xml"); // Query parts for files to submit. for(cmCTest::Part p = cmCTest::PartStart; @@ -1285,7 +1286,7 @@ int cmCTestSubmitHandler::ProcessHandler() << std::endl); ofs << " Problems when submitting via FTP" << std::endl; return -1; - } + } if(!this->CDash) { cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using HTTP trigger method" @@ -1369,7 +1370,7 @@ int cmCTestSubmitHandler::ProcessHandler() { cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful" << (this->HasWarnings ? ", with warnings." : "") << std::endl); - ofs << " Submission successful" << + ofs << " Submission successful" << (this->HasWarnings ? ", with warnings." : "") << std::endl; } @@ -1439,20 +1440,20 @@ int cmCTestSubmitHandler::ProcessHandler() { std::string location = this->CTest->GetCTestConfiguration("DropLocation"); - + // change to the build directory so that we can uses a relative path // on windows since scp dosn't support "c:" a drive in the path - std::string + std::string oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::ChangeDirectory(buildDirectory.c_str()); cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Change directory: " << buildDirectory.c_str() << std::endl); if ( !this->SubmitUsingCP( - "Testing/"+this->CTest->GetCurrentTag(), - files, - prefix, + "Testing/"+this->CTest->GetCurrentTag(), + files, + prefix, location) ) { cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str()); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 87c75ebf8..e3b81df88 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -108,7 +108,7 @@ bool cmCTestSubdirCommand // does the CTestTestfile.cmake exist ? testFilename = "CTestTestfile.cmake"; } - else if( cmSystemTools::FileExists("DartTestfile.txt") ) + else if( cmSystemTools::FileExists("DartTestfile.txt") ) { // does the DartTestfile.txt exist ? testFilename = "DartTestfile.txt"; @@ -121,7 +121,7 @@ bool cmCTestSubdirCommand } fname += "/"; fname += testFilename; - bool readit = + bool readit = this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(), fname.c_str()); cmSystemTools::ChangeDirectory(cwd.c_str()); @@ -212,7 +212,7 @@ bool cmCTestAddSubdirectoryCommand } fname += "/"; fname += testFilename; - bool readit = + bool readit = this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(), fname.c_str()); cmSystemTools::ChangeDirectory(cwd.c_str()); @@ -538,7 +538,7 @@ int cmCTestTestHandler::ProcessHandler() this->UseExcludeRegExp(); this->SetExcludeRegExp(val); } - + this->TestResults.clear(); cmCTestLog(this->CTest, HANDLER_OUTPUT, @@ -616,7 +616,7 @@ int cmCTestTestHandler::ProcessHandler() cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl << "The following tests FAILED:" << std::endl); this->StartLogFile("TestsFailed", ofs); - + std::vector::iterator ftit; for(ftit = this->TestResults.begin(); ftit != this->TestResults.end(); ++ftit) @@ -625,9 +625,9 @@ int cmCTestTestHandler::ProcessHandler() { ofs << ftit->TestCount << ":" << ftit->Name << std::endl; cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t" << std::setw(3) - << ftit->TestCount << " - " + << ftit->TestCount << " - " << ftit->Name.c_str() << " (" - << this->GetTestStatus(ftit->Status) << ")" + << this->GetTestStatus(ftit->Status) << ")" << std::endl); } } @@ -696,18 +696,18 @@ void cmCTestTestHandler::PrintLabelSummary() // fill maps for(; ri != this->TestResults.end(); ++ri) { - cmCTestTestResult &result = *ri; + cmCTestTestResult &result = *ri; cmCTestTestProperties& p = *result.Properties; if(p.Labels.size() != 0) { for(std::vector::iterator l = p.Labels.begin(); l != p.Labels.end(); ++l) - { + { labelTimes[*l] += result.ExecutionTime; } } } - // now print times + // now print times if(labels.size()) { cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nLabel Time Summary:"); @@ -728,7 +728,7 @@ void cmCTestTestHandler::PrintLabelSummary() } } if(labels.size()) - { + { if(this->LogFile) { *this->LogFile << "\n"; @@ -840,7 +840,7 @@ void cmCTestTestHandler::ComputeTestList() // Now create a final list of tests to run int cnt = 0; inREcnt = 0; - std::string last_directory = ""; + std::string last_directory = ""; ListOfTests finalList; for ( it = this->TestList.begin(); it != this->TestList.end(); it ++ ) { @@ -888,13 +888,13 @@ void cmCTestTestHandler::ComputeTestList() max = p.Name.size(); } } - if(static_cast(this->CTest->GetMaxTestNameWidth()) + if(static_cast(this->CTest->GetMaxTestNameWidth()) != max) { this->CTest->SetMaxTestNameWidth(static_cast(max)); } } - + bool cmCTestTestHandler::GetValue(const char* tag, int& value, std::ifstream& fin) @@ -984,7 +984,7 @@ bool cmCTestTestHandler::GetValue(const char* tag, ret = cmSystemTools::GetLineFromStream(fin, line); // read blank line } else - { + { cmCTestLog(this->CTest, ERROR_MESSAGE, "parse error: missing tag: " << tag << " found [" << line.c_str() << "]" << std::endl); @@ -1036,7 +1036,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, cmCTestMultiProcessHandler::TestMap tests; cmCTestMultiProcessHandler::PropertiesMap properties; - + bool randomSchedule = this->CTest->GetScheduleType() == "Random"; if(randomSchedule) { @@ -1045,7 +1045,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, for (ListOfTests::iterator it = this->TestList.begin(); it != this->TestList.end(); ++it) - { + { cmCTestTestProperties& p = *it; cmCTestMultiProcessHandler::TestSet depends; @@ -1158,7 +1158,7 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os) << result->ExecutionTime << "\n"; if(result->Reason.size()) - { + { const char* reasonType = "Pass Reason"; if(result->Status != cmCTestTestHandler::COMPLETED && result->Status != cmCTestTestHandler::NOT_RUN) @@ -1195,7 +1195,7 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os) os << "\t\t\t\n" << "\t\t\t\tCompressOutput ? + << (result->CompressOutput ? " encoding=\"base64\" compression=\"gzip\">" : ">"); os << cmXMLSafe(result->Output); @@ -1278,11 +1278,11 @@ void cmCTestTestHandler::AttachFiles(std::ostream& os, result->Properties->AttachOnFail.begin(), result->Properties->AttachOnFail.end()); } - for(std::vector::const_iterator file = + for(std::vector::const_iterator file = result->Properties->AttachedFiles.begin(); file != result->Properties->AttachedFiles.end(); ++file) { - std::string base64 = this->EncodeFile(*file); + std::string base64 = this->CTest->Base64GzipEncodeFile(*file); std::string fname = cmSystemTools::GetFilenameName(*file); os << "\t\t" @@ -1292,48 +1292,6 @@ void cmCTestTestHandler::AttachFiles(std::ostream& os, } } -//---------------------------------------------------------------------- -std::string cmCTestTestHandler::EncodeFile(std::string file) -{ - std::string tarFile = file + "_temp.tar.gz"; - std::vector files; - files.push_back(file); - - if(!cmSystemTools::CreateTar(tarFile.c_str(), files, true, false, false)) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, "Error creating tar while " - "attaching file: " << file << std::endl); - return ""; - } - long len = cmSystemTools::FileLength(tarFile.c_str()); - std::ifstream ifs(tarFile.c_str(), std::ios::in -#ifdef _WIN32 - | std::ios::binary -#endif - ); - unsigned char *file_buffer = new unsigned char [ len + 1 ]; - ifs.read(reinterpret_cast(file_buffer), len); - ifs.close(); - cmSystemTools::RemoveFile(tarFile.c_str()); - - unsigned char *encoded_buffer - = new unsigned char [ static_cast( - static_cast(len) * 1.5 + 5.0) ]; - - unsigned long rlen - = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); - - std::string base64 = ""; - for(unsigned long i = 0; i < rlen; i++) - { - base64 += encoded_buffer[i]; - } - delete [] file_buffer; - delete [] encoded_buffer; - - return base64; -} - //---------------------------------------------------------------------- int cmCTestTestHandler::ExecuteCommands(std::vector& vec) { @@ -1362,6 +1320,10 @@ std::string cmCTestTestHandler::FindTheExecutable(const char *exe) std::string resConfig; std::vector extraPaths; std::vector failedPaths; + if(strcmp(exe, "NOT_AVAILABLE") == 0) + { + return exe; + } return cmCTestTestHandler::FindExecutable(this->CTest, exe, resConfig, extraPaths, @@ -1370,7 +1332,7 @@ std::string cmCTestTestHandler::FindTheExecutable(const char *exe) // add additional configurations to the search path void cmCTestTestHandler -::AddConfigurations(cmCTest *ctest, +::AddConfigurations(cmCTest *ctest, std::vector &attempted, std::vector &attemptedConfigs, std::string filepath, @@ -1378,7 +1340,7 @@ void cmCTestTestHandler { std::string tempPath; - if (filepath.size() && + if (filepath.size() && filepath[filepath.size()-1] != '/') { filepath += "/"; @@ -1386,7 +1348,7 @@ void cmCTestTestHandler tempPath = filepath + filename; attempted.push_back(tempPath); attemptedConfigs.push_back(""); - + if(ctest->GetConfigType().size()) { tempPath = filepath; @@ -1425,7 +1387,7 @@ void cmCTestTestHandler tempPath = filepath; tempPath += "RelWithDebInfo/"; tempPath += filename; - attempted.push_back(tempPath); + attempted.push_back(tempPath); attemptedConfigs.push_back("RelWithDebInfo"); tempPath = filepath; tempPath += "Deployment/"; @@ -1472,8 +1434,8 @@ std::string cmCTestTestHandler attemptedConfigs, localfilepath,filename); } - - + + // if extraPaths are provided and we were not passed a full path, try them, // try any extra paths if (filepath.size() == 0) @@ -1489,8 +1451,8 @@ std::string cmCTestTestHandler filepathExtra, filenameExtra); } - } - + } + // store the final location in fullPath std::string fullPath; @@ -1523,7 +1485,7 @@ std::string cmCTestTestHandler } } } - + // if everything else failed, check the users path, but only if a full path // wasn't specified if (fullPath.size() == 0 && filepath.size() == 0) @@ -1547,7 +1509,7 @@ std::string cmCTestTestHandler i->c_str() << "\n"); } } - + return fullPath; } @@ -1589,13 +1551,13 @@ void cmCTestTestHandler::GetListOfTests() cm.AddCommand(newCom1); // Add handler for SUBDIRS - cmCTestSubdirCommand* newCom2 = + cmCTestSubdirCommand* newCom2 = new cmCTestSubdirCommand; newCom2->TestHandler = this; cm.AddCommand(newCom2); // Add handler for ADD_SUBDIRECTORY - cmCTestAddSubdirectoryCommand* newCom3 = + cmCTestAddSubdirectoryCommand* newCom3 = new cmCTestAddSubdirectoryCommand; newCom3->TestHandler = this; cm.AddCommand(newCom3); @@ -1978,6 +1940,7 @@ void cmCTestTestHandler::SetTestsToRunInformation(const char* in) fin.getline(buff, filelen); buff[fin.gcount()] = 0; this->TestsToRunString = buff; + delete [] buff; } } @@ -2156,7 +2119,7 @@ bool cmCTestTestHandler::SetTestsProperties( } } if ( key == "ENVIRONMENT" ) - { + { std::vector lval; cmSystemTools::ExpandListArgument(val.c_str(), lval); std::vector::iterator crit; @@ -2272,7 +2235,7 @@ bool cmCTestTestHandler::AddTest(const std::vector& args) test.Directory = cmSystemTools::GetCurrentWorkingDirectory(); cmCTestLog(this->CTest, DEBUG, "Set test directory: " << test.Directory << std::endl); - + test.IsInBasedOnREOptions = true; test.WillFail = false; test.RunSerial = false; diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 7aa8522e9..3089d35d4 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -126,7 +126,7 @@ public: }; // add configuraitons to a search path for an executable - static void AddConfigurations(cmCTest *ctest, + static void AddConfigurations(cmCTest *ctest, std::vector &attempted, std::vector &attemptedConfigs, std::string filepath, @@ -151,8 +151,6 @@ protected: void WriteTestResultFooter(std::ostream& os, cmCTestTestResult* result); // Write attached test files into the xml void AttachFiles(std::ostream& os, cmCTestTestResult* result); - // Helper function to encode attached test files - std::string EncodeFile(std::string file); //! Clean test output to specified length bool CleanTestOutput(std::string& output, size_t length); @@ -205,7 +203,7 @@ private: // compute the lists of tests that will actually run // based on union regex and -I stuff void ComputeTestList(); - + bool GetValue(const char* tag, std::string& value, std::ifstream& fin); diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx new file mode 100644 index 000000000..731c1c7a3 --- /dev/null +++ b/Source/CTest/cmCTestUploadCommand.cxx @@ -0,0 +1,69 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmCTestUploadCommand.h" + +#include "cmCTest.h" +#include "cmCTestGenericHandler.h" +#include "cmCTestUploadHandler.h" + +cmCTestGenericHandler* cmCTestUploadCommand::InitializeHandler() +{ + cmCTestGenericHandler* handler + = this->CTest->GetInitializedHandler("upload"); + if ( !handler ) + { + this->SetError("internal CTest error. Cannot instantiate upload handler"); + return 0; + } + static_cast(handler)->SetFiles(this->Files); + + return handler; +} + + +//---------------------------------------------------------------------------- +bool cmCTestUploadCommand::CheckArgumentKeyword(std::string const& arg) +{ + if(arg == "FILES") + { + this->ArgumentDoing = ArgumentDoingFiles; + return true; + } + return false; +} + + +//---------------------------------------------------------------------------- +bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg) +{ + if(this->ArgumentDoing == ArgumentDoingFiles) + { + cmStdString filename(arg); + if(cmSystemTools::FileExists(filename.c_str())) + { + this->Files.insert(filename); + return true; + } + else + { + cmOStringStream e; + e << "File \"" << filename << "\" does not exist. Cannot submit " + << "a non-existent file."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + this->ArgumentDoing = ArgumentDoingError; + return false; + } + } + + // Look for other arguments. + return this->Superclass::CheckArgumentValue(arg); +} diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h new file mode 100644 index 000000000..6c2a4c2ef --- /dev/null +++ b/Source/CTest/cmCTestUploadCommand.h @@ -0,0 +1,85 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmCTestUploadCommand_h +#define cmCTestUploadCommand_h + +#include "cmCTestHandlerCommand.h" +#include "cmCTest.h" + +/** \class cmCTestUpload + * \brief Run a ctest script + * + * cmCTestUploadCommand defines the command to upload result files for + * the project. + */ +class cmCTestUploadCommand : public cmCTestHandlerCommand +{ +public: + + cmCTestUploadCommand() + { + } + + /** + * This is a virtual constructor for the command. + */ + virtual cmCommand* Clone() + { + cmCTestUploadCommand* ni = new cmCTestUploadCommand; + ni->CTest = this->CTest; + ni->CTestScriptHandler = this->CTestScriptHandler; + return ni; + } + + /** + * The name of the command as specified in CMakeList.txt. + */ + virtual const char* GetName() { return "ctest_upload";} + + /** + * Succinct documentation. + */ + virtual const char* GetTerseDocumentation() + { + return "Upload files to a dashboard server."; + } + + /** + * More documentation. + */ + virtual const char* GetFullDocumentation() + { + return + " ctest_upload(FILES ...)\n" + "Pass a list of files to be sent along with the build results to " + "the dashboard server.\n"; + } + + cmTypeMacro(cmCTestUploadCommand, cmCTestHandlerCommand); + +protected: + cmCTestGenericHandler* InitializeHandler(); + + virtual bool CheckArgumentKeyword(std::string const& arg); + virtual bool CheckArgumentValue(std::string const& arg); + + enum + { + ArgumentDoingFiles = Superclass::ArgumentDoingLast1, + ArgumentDoingLast2 + }; + + cmCTest::SetOfStrings Files; +}; + + +#endif diff --git a/Source/CTest/cmCTestUploadHandler.cxx b/Source/CTest/cmCTestUploadHandler.cxx new file mode 100644 index 000000000..caf2e5370 --- /dev/null +++ b/Source/CTest/cmCTestUploadHandler.cxx @@ -0,0 +1,77 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmCTestUploadHandler.h" + +#include "cmGeneratedFileStream.h" +#include "cmVersion.h" +#include "cmXMLSafe.h" + +//---------------------------------------------------------------------------- +cmCTestUploadHandler::cmCTestUploadHandler() +{ + this->Initialize(); +} + +//---------------------------------------------------------------------------- +void cmCTestUploadHandler::Initialize() +{ + this->Superclass::Initialize(); + this->Files.clear(); +} + +void cmCTestUploadHandler::SetFiles(const cmCTest::SetOfStrings& files) +{ + this->Files = files; +} + +//---------------------------------------------------------------------------- +int cmCTestUploadHandler::ProcessHandler() +{ + cmGeneratedFileStream ofs; + if ( !this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(), + "Upload.xml", ofs)) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Cannot open Upload.xml file" << std::endl); + return -1; + } + + cmCTest::SetOfStrings::const_iterator it; + ofs << "\n" + << " \"?>\n" + << "CTest->GetCTestConfiguration("BuildName") + << "\" BuildStamp=\"" + << this->CTest->GetCurrentTag() << "-" + << this->CTest->GetTestModelString() << "\" Name=\"" + << this->CTest->GetCTestConfiguration("Site") << "\" Generator=\"ctest" + << cmVersion::GetCMakeVersion() + << "\">\n"; + this->CTest->AddSiteProperties(ofs); + ofs << "\n"; + + for ( it = this->Files.begin(); it != this->Files.end(); it ++ ) + { + cmCTestLog(this->CTest, OUTPUT, + "\tUpload file: " << it->c_str() << std::endl); + ofs << "\n" + << "\n"; + ofs << this->CTest->Base64EncodeFile(*it); + ofs << "\n\n" + << "\n"; + } + ofs << "\n" + << "\n"; + return 0; +} diff --git a/Source/CTest/cmCTestUploadHandler.h b/Source/CTest/cmCTestUploadHandler.h new file mode 100644 index 000000000..23ed35a25 --- /dev/null +++ b/Source/CTest/cmCTestUploadHandler.h @@ -0,0 +1,45 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmCTestUploadHandler_h +#define cmCTestUploadHandler_h + +#include "cmCTestGenericHandler.h" + +/** \class cmCTestUploadHandler + * \brief Helper class for CTest + * + * Submit arbitrary files + * + */ +class cmCTestUploadHandler : public cmCTestGenericHandler +{ +public: + cmTypeMacro(cmCTestUploadHandler, cmCTestGenericHandler); + + cmCTestUploadHandler(); + ~cmCTestUploadHandler() {} + + /* + * The main entry point for this class + */ + int ProcessHandler(); + + void Initialize(); + + /** Specify a set of files to submit. */ + void SetFiles(cmCTest::SetOfStrings const& files); + +private: + cmCTest::SetOfStrings Files; +}; + +#endif diff --git a/Source/CursesDialog/form/frm_driver.c b/Source/CursesDialog/form/frm_driver.c index 03896c29f..f234722f3 100644 --- a/Source/CursesDialog/form/frm_driver.c +++ b/Source/CursesDialog/form/frm_driver.c @@ -1086,7 +1086,7 @@ _nc_Synchronize_Options(FIELD *field, Field_Options newopts) if (form->status & _POSTED) { - if ((form->curpage == field->page)) + if (form->curpage == field->page) { if (changed_opts & O_VISIBLE) { diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 562396ddc..72e9b2464 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -293,6 +293,8 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) parentItems.append(new QStandardItem()); parentItems[0]->setData(QBrush(QColor(255,100,100)), Qt::BackgroundColorRole); parentItems[1]->setData(QBrush(QColor(255,100,100)), Qt::BackgroundColorRole); + parentItems[0]->setData(1, GroupRole); + parentItems[1]->setData(1, GroupRole); root->appendRow(parentItems); int num = props2.size(); @@ -314,6 +316,7 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) QStandardItem* parentItem = new QStandardItem(key.isEmpty() ? tr("Ungrouped Entries") : key); root->appendRow(parentItem); + parentItem->setData(1, GroupRole); int num = props2.size(); for(int i=0; igetPropertyData(idx, prop); - props.append(prop); + if(!data(idx, GroupRole).toInt()) + { + // get data + QCMakeProperty prop; + this->getPropertyData(idx, prop); + props.append(prop); + } // go to the next in the tree while(!idxs.isEmpty() && !idxs.last().sibling(idxs.last().row()+1, 0).isValid()) diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h index 58bbd2d28..0a628b90a 100644 --- a/Source/QtDialog/QCMakeCacheView.h +++ b/Source/QtDialog/QCMakeCacheView.h @@ -67,7 +67,9 @@ public: enum { HelpRole = Qt::ToolTipRole, TypeRole = Qt::UserRole, AdvancedRole, - StringsRole}; + StringsRole, + GroupRole + }; enum ViewType { FlatView, GroupView }; diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 7af6ec8d7..56348494d 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -195,11 +195,13 @@ bool cmAddCustomCommandCommand { // An implicit dependency starting point is also an // explicit dependency. - depends.push_back(copy); + std::string dep = copy; + cmSystemTools::ConvertToUnixSlashes(dep); + depends.push_back(dep); // Add the implicit dependency language and file. cmCustomCommand::ImplicitDependsPair - entry(implicit_depends_lang, copy); + entry(implicit_depends_lang, dep); implicit_depends.push_back(entry); // Switch back to looking for a language. @@ -213,7 +215,11 @@ bool cmAddCustomCommandCommand target = copy; break; case doing_depends: - depends.push_back(copy); + { + std::string dep = copy; + cmSystemTools::ConvertToUnixSlashes(dep); + depends.push_back(dep); + } break; case doing_outputs: outputs.push_back(filename); @@ -286,6 +292,13 @@ bool cmAddCustomCommandCommand return false; } + // Convert working directory to a full path. + if(!working.empty()) + { + const char* build_dir = this->Makefile->GetCurrentOutputDirectory(); + working = cmSystemTools::CollapseFullPath(working.c_str(), build_dir); + } + // Choose which mode of the command to use. bool escapeOldStyle = !verbatim; if(source.empty() && output.empty()) diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h index 490e043ae..47b542c81 100644 --- a/Source/cmAddCustomCommandCommand.h +++ b/Source/cmAddCustomCommandCommand.h @@ -110,6 +110,8 @@ public: "will be treated as PRE_LINK.\n" "If WORKING_DIRECTORY is specified the command will be executed " "in the directory given. " + "If it is a relative path it will be interpreted relative to the " + "build tree directory corresponding to the current source directory. " "If COMMENT is set, the value will be displayed as a " "message before the commands are executed at build time. " "If APPEND is specified the COMMAND and DEPENDS option values " diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index edb787b0f..4eba88636 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -123,7 +123,11 @@ bool cmAddCustomTargetCommand currentLine.push_back(copy); break; case doing_depends: - depends.push_back(copy); + { + std::string dep = copy; + cmSystemTools::ConvertToUnixSlashes(dep); + depends.push_back(dep); + } break; case doing_comment: comment_buffer = copy; @@ -166,6 +170,14 @@ bool cmAddCustomTargetCommand } } + // Convert working directory to a full path. + if(!working_directory.empty()) + { + const char* build_dir = this->Makefile->GetCurrentOutputDirectory(); + working_directory = + cmSystemTools::CollapseFullPath(working_directory.c_str(), build_dir); + } + // Add the utility target to the makefile. bool escapeOldStyle = !verbatim; cmTarget* target = diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h index 7a2b3962b..6d94fb292 100644 --- a/Source/cmAddCustomTargetCommand.h +++ b/Source/cmAddCustomTargetCommand.h @@ -79,6 +79,8 @@ public: "empty target will be created. " "If WORKING_DIRECTORY is set, then the command will be run in that " "directory. " + "If it is a relative path it will be interpreted relative to the " + "build tree directory corresponding to the current source directory. " "If COMMENT is set, the value will be displayed as a " "message before the commands are executed at build time. " "Dependencies listed with the DEPENDS argument may reference files " diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index d9e4742a2..25dc8ba48 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -236,6 +236,9 @@ bool cmArchiveWrite::AddFile(const char* file, this->Error += archive_error_string(this->Disk); return false; } + // Clear acl and xattr fields not useful for distribution. + archive_entry_acl_clear(e); + archive_entry_xattr_clear(e); if(archive_write_header(this->Archive, e) != ARCHIVE_OK) { this->Error = "archive_write_header: "; diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 411a28d08..e23791355 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -518,7 +518,7 @@ public: }; cmCPluginAPISourceFileMap cmCPluginAPISourceFiles; -void * CCONV cmCreateSourceFile() +void * CCONV cmCreateSourceFile(void) { return (void*)new cmCPluginAPISourceFile; } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 2e05883e9..75a564e78 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -16,6 +16,7 @@ #include "cmMakefile.h" #include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" +#include #include #include #include "cmDynamicLoader.h" @@ -31,9 +32,10 @@ #include "cmCTestCoverageHandler.h" #include "cmCTestMemCheckHandler.h" #include "cmCTestScriptHandler.h" +#include "cmCTestSubmitHandler.h" #include "cmCTestTestHandler.h" #include "cmCTestUpdateHandler.h" -#include "cmCTestSubmitHandler.h" +#include "cmCTestUploadHandler.h" #include "cmVersion.h" @@ -48,6 +50,9 @@ #include // auto_ptr +#include +#include + #if defined(__BEOS__) && !defined(__HAIKU__) #include /* disable_debugger() API. */ #endif @@ -306,7 +311,7 @@ cmCTest::cmCTest() this->UseHTTP10 = false; this->PrintLabels = false; this->CompressTestOutput = true; - this->ComputedCompressOutput = false; + this->CompressMemCheckOutput = true; this->TestModel = cmCTest::EXPERIMENTAL; this->MaxTestNameWidth = 30; this->InteractiveDebugMode = true; @@ -323,6 +328,8 @@ cmCTest::cmCTest() this->SuppressUpdatingCTestConfiguration = false; this->DartVersion = 1; this->OutputTestOutputOnTestFailure = false; + this->ComputedCompressTestOutput = false; + this->ComputedCompressMemCheckOutput = false; if(cmSystemTools::GetEnv("CTEST_OUTPUT_ON_FAILURE")) { this->OutputTestOutputOnTestFailure = true; @@ -339,6 +346,7 @@ cmCTest::cmCTest() this->Parts[PartSubmit].SetName("Submit"); this->Parts[PartNotes].SetName("Notes"); this->Parts[PartExtraFiles].SetName("ExtraFiles"); + this->Parts[PartUpload].SetName("Upload"); // Fill the part name-to-id map. for(Part p = PartStart; p != PartCount; p = Part(p+1)) @@ -357,6 +365,7 @@ cmCTest::cmCTest() this->TestingHandlers["configure"] = new cmCTestConfigureHandler; this->TestingHandlers["memcheck"] = new cmCTestMemCheckHandler; this->TestingHandlers["submit"] = new cmCTestSubmitHandler; + this->TestingHandlers["upload"] = new cmCTestUploadHandler; cmCTest::t_TestingHandlers::iterator it; for ( it = this->TestingHandlers.begin(); @@ -390,7 +399,7 @@ void cmCTest::SetParallelLevel(int level) //---------------------------------------------------------------------------- bool cmCTest::ShouldCompressTestOutput() { - if(!this->ComputedCompressOutput) + if(!this->ComputedCompressTestOutput) { std::string cdashVersion = this->GetCDashVersion(); //version >= 1.6? @@ -399,11 +408,26 @@ bool cmCTest::ShouldCompressTestOutput() cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL, cdashVersion.c_str(), "1.6"); this->CompressTestOutput &= cdashSupportsGzip; - this->ComputedCompressOutput = true; + this->ComputedCompressTestOutput = true; } return this->CompressTestOutput; } +//---------------------------------------------------------------------------- +bool cmCTest::ShouldCompressMemCheckOutput() +{ + if(!this->ComputedCompressMemCheckOutput) + { + std::string cdashVersion = this->GetCDashVersion(); + + bool compressionSupported = cmSystemTools::VersionCompare( + cmSystemTools::OP_GREATER, cdashVersion.c_str(), "1.9.0"); + this->CompressMemCheckOutput &= compressionSupported; + this->ComputedCompressMemCheckOutput = true; + } + return this->CompressMemCheckOutput; +} + //---------------------------------------------------------------------------- std::string cmCTest::GetCDashVersion() { @@ -1583,6 +1607,56 @@ int cmCTest::GenerateNotesFile(const char* cfiles) return this->GenerateNotesFile(files); } +//---------------------------------------------------------------------- +std::string cmCTest::Base64GzipEncodeFile(std::string file) +{ + std::string tarFile = file + "_temp.tar.gz"; + std::vector files; + files.push_back(file); + + if(!cmSystemTools::CreateTar(tarFile.c_str(), files, true, false, false)) + { + cmCTestLog(this, ERROR_MESSAGE, "Error creating tar while " + "encoding file: " << file << std::endl); + return ""; + } + std::string base64 = this->Base64EncodeFile(tarFile); + cmSystemTools::RemoveFile(tarFile.c_str()); + return base64; +} + +//---------------------------------------------------------------------- +std::string cmCTest::Base64EncodeFile(std::string file) +{ + long len = cmSystemTools::FileLength(file.c_str()); + std::ifstream ifs(file.c_str(), std::ios::in +#ifdef _WIN32 + | std::ios::binary +#endif + ); + unsigned char *file_buffer = new unsigned char [ len + 1 ]; + ifs.read(reinterpret_cast(file_buffer), len); + ifs.close(); + + unsigned char *encoded_buffer + = new unsigned char [ static_cast( + static_cast(len) * 1.5 + 5.0) ]; + + unsigned long rlen + = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); + + std::string base64 = ""; + for(unsigned long i = 0; i < rlen; i++) + { + base64 += encoded_buffer[i]; + } + delete [] file_buffer; + delete [] encoded_buffer; + + return base64; +} + + //---------------------------------------------------------------------- bool cmCTest::SubmitExtraFiles(const std::vector &files) { @@ -1872,6 +1946,7 @@ void cmCTest::HandleCommandLineArguments(size_t &i, if(this->CheckArgument(arg, "--no-compress-output")) { this->CompressTestOutput = false; + this->CompressMemCheckOutput = false; } if(this->CheckArgument(arg, "--print-labels")) @@ -3001,3 +3076,56 @@ void cmCTest::OutputTestErrors(std::vector const &process_output) } cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl << std::flush); } + +//---------------------------------------------------------------------- +bool cmCTest::CompressString(std::string& str) +{ + int ret; + z_stream strm; + + unsigned char* in = reinterpret_cast( + const_cast(str.c_str())); + //zlib makes the guarantee that this is the maximum output size + int outSize = static_cast( + static_cast(str.size()) * 1.001 + 13.0); + unsigned char* out = new unsigned char[outSize]; + + strm.zalloc = Z_NULL; + strm.zfree = Z_NULL; + strm.opaque = Z_NULL; + ret = deflateInit(&strm, -1); //default compression level + if (ret != Z_OK) + { + return false; + } + + strm.avail_in = static_cast(str.size()); + strm.next_in = in; + strm.avail_out = outSize; + strm.next_out = out; + ret = deflate(&strm, Z_FINISH); + + if(ret == Z_STREAM_ERROR || ret != Z_STREAM_END) + { + cmCTestLog(this, ERROR_MESSAGE, "Error during gzip compression." + << std::endl); + return false; + } + + (void)deflateEnd(&strm); + + // Now base64 encode the resulting binary string + unsigned char* base64EncodedBuffer + = new unsigned char[static_cast(outSize * 1.5)]; + + unsigned long rlen + = cmsysBase64_Encode(out, strm.total_out, base64EncodedBuffer, 1); + + str = ""; + str.append(reinterpret_cast(base64EncodedBuffer), rlen); + + delete [] base64EncodedBuffer; + delete [] out; + + return true; +} diff --git a/Source/cmCTest.h b/Source/cmCTest.h index e54a205c3..44a534907 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -61,6 +61,7 @@ public: PartSubmit, PartNotes, PartExtraFiles, + PartUpload, PartCount // Update names in constructor when adding a part }; @@ -192,8 +193,13 @@ public: ///! Get the current time as string std::string CurrentTime(); + //! tar/gzip and then base 64 encode a file + std::string Base64GzipEncodeFile(std::string file); + //! base64 encode a file + std::string Base64EncodeFile(std::string file); + /** - * Return the time remaianing that the script is allowed to run in + * Return the time remaining that the script is allowed to run in * seconds if the user has set the variable CTEST_TIME_LIMIT. If that has * not been set it returns 1e7 seconds */ @@ -213,6 +219,8 @@ public: bool ShouldPrintLabels() { return this->PrintLabels; } bool ShouldCompressTestOutput(); + bool ShouldCompressMemCheckOutput(); + bool CompressString(std::string& str); std::string GetCDashVersion(); @@ -424,7 +432,8 @@ private: bool RunConfigurationScript; //flag for lazy getter (optimization) - bool ComputedCompressOutput; + bool ComputedCompressTestOutput; + bool ComputedCompressMemCheckOutput; int GenerateNotesFile(const char* files); @@ -481,8 +490,8 @@ private: bool ShortDateFormat; bool CompressXMLFiles; - bool CompressTestOutput; + bool CompressMemCheckOutput; void InitStreams(); std::ostream* StreamOut; @@ -515,7 +524,7 @@ private: //! Reread the configuration file bool UpdateCTestConfiguration(); - //! Create not from files. + //! Create note from files. int GenerateCTestNotesOutput(std::ostream& os, const VectorOfStrings& files); diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index d53200c87..e3c33a2ff 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -817,9 +817,9 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() this->SharedLinkTypeFlag = shared_link_type_flag; } - // TODO: Lookup the starting link type from the target (is it being - // linked statically?). - this->StartLinkType = LinkShared; + // Lookup the starting link type from the target (linked statically?). + const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC"); + this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 0cd5fa2c6..ea25e60fd 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -96,6 +96,30 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "See also CMAKE_CURRENT_LIST_FILE.",false, "Variables that Provide Information"); + cm->DefineProperty + ("CMAKE_SCRIPT_MODE_FILE", cmProperty::VARIABLE, + "Full path to the -P script file currently being processed. ", + "When run in -P script mode, CMake sets this variable to the full " + "path of the script file. When run to configure a CMakeLists.txt " + "file, this variable is not set.", false, + "Variables that Provide Information"); + + cm->DefineProperty + ("CMAKE_ARGC", cmProperty::VARIABLE, + "Number of command line arguments passed to CMake in script mode. ", + "When run in -P script mode, CMake sets this variable to the number " + "of command line arguments. See also CMAKE_ARGV0, 1, 2 ... ", false, + "Variables that Provide Information"); + + cm->DefineProperty + ("CMAKE_ARGV0", cmProperty::VARIABLE, + "Command line argument passed to CMake in script mode. ", + "When run in -P script mode, CMake sets this variable to " + "the first command line argument. It then also sets CMAKE_ARGV1, " + "CMAKE_ARGV2, ... and so on, up to the number of command line arguments " + "given. See also CMAKE_ARGC.", false, + "Variables that Provide Information"); + cm->DefineProperty ("CMAKE_BUILD_TOOL", cmProperty::VARIABLE, "Tool used for the actual build process.", @@ -522,7 +546,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "make based generators. If this variable is supported, " "then CMake will also provide initial values for the " "variables with the name " - " CMAKE_C_FLAGS_[Debug|Release|RelWithDebInfo|MinSizeRel]." + " CMAKE_C_FLAGS_[DEBUG|RELEASE|RELWITHDEBINFO|MINSIZEREL]." " For example, if CMAKE_BUILD_TYPE is Debug, then " "CMAKE_C_FLAGS_DEBUG will be added to the CMAKE_C_FLAGS.",false, "Variables That Change Behavior"); @@ -798,6 +822,18 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "set to the output of uname -r. On other " "systems this is set to major-minor version numbers.",false, "Variables That Describe the System"); + cm->DefineProperty + ("CMAKE_LIBRARY_ARCHITECTURE", cmProperty::VARIABLE, + "Target architecture library directory name, if detected.", + "This is the value of CMAKE__LIBRARY_ARCHITECTURE as " + "detected for one of the enabled languages.",false, + "Variables That Describe the System"); + cm->DefineProperty + ("CMAKE_LIBRARY_ARCHITECTURE_REGEX", cmProperty::VARIABLE, + "Regex matching possible target architecture library directory names.", + "This is used to detect CMAKE__LIBRARY_ARCHITECTURE from the " + "implicit linker search path by matching the name.",false, + "Variables That Describe the System"); cm->DefineProperty ("CMAKE_HOST_SYSTEM", cmProperty::VARIABLE, @@ -1335,6 +1371,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "language and reports the results in this variable.", false, "Variables for Languages"); + cm->DefineProperty + ("CMAKE__LIBRARY_ARCHITECTURE", cmProperty::VARIABLE, + "Target architecture library directory name detected for .", + "If the compiler passes to the linker an architecture-specific " + "system library search directory such as /lib/ this " + "variable contains the name if/as detected by CMake.",false, + "Variables for Languages"); + cm->DefineProperty ("CMAKE__LINKER_PREFERENCE_PROPAGATES", cmProperty::VARIABLE, "True if CMAKE__LINKER_PREFERENCE propagates across targets.", @@ -1451,6 +1495,8 @@ void cmDocumentVariables::DefineVariables(cmake* cm) cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE__STANDARD_LIBRARIES_INIT", cmProperty::VARIABLE,0,0); + cm->DefineProperty("CMAKE__USE_RESPONSE_FILE_FOR_INCLUDES", + cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE__USE_RESPONSE_FILE_FOR_OBJECTS", cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE_EXECUTABLE_SUFFIX_", diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index e2a603544..9e5c91efc 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -325,6 +325,12 @@ cmExportFileGenerator os << "SET_PROPERTY(TARGET " << targetName << " PROPERTY MACOSX_BUNDLE 1)\n"; } + + if (target->IsCFBundleOnApple()) + { + os << "SET_PROPERTY(TARGET " << targetName + << " PROPERTY BUNDLE 1)\n"; + } os << "\n"; } diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 717571ca9..23ff5fb12 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -263,6 +263,20 @@ cmExportInstallFileGenerator value += ".framework/"; value += itgen->GetInstallFilename(target, config); } + else if(target->IsCFBundleOnApple()) + { + const char *ext = target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + ext = "bundle"; + } + + value += itgen->GetInstallFilename(target, config); + value += "."; + value += ext; + value += "/"; + value += itgen->GetInstallFilename(target, config); + } else if(target->IsAppBundleOnApple()) { value += itgen->GetInstallFilename(target, config); diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index a5650d468..4f93067c9 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -416,11 +416,18 @@ void cmExtraCodeBlocksGenerator case cmTarget::STATIC_LIBRARY: case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: + case cmTarget::UTILITY: // can have sources since 2.6.3 { const std::vector&sources=ti->second.GetSourceFiles(); for (std::vector::const_iterator si=sources.begin(); si!=sources.end(); si++) { + // don't add source files which have the GENERATED property set: + if ((*si)->GetPropertyAsBool("GENERATED")) + { + continue; + } + // check whether it is a C/C++ implementation file bool isCFile = false; if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C')) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 0ef771f81..8e26b8ee2 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -102,7 +102,7 @@ void cmExtraEclipseCDT4Generator::CreateSourceProjectFile() const fout << "\n" "\n" - "\t" << name << "\n" + "\t" << this->EscapeForXML(name) << "\n" "\t\n" "\t\n" "\t\n" @@ -376,11 +376,10 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() "\t\n" ; - // TODO: refactor this + fout << "\t\n"; // create linked resources if (this->IsOutOfSourceBuild) { - fout << "\t\n"; // create a linked resource to CMAKE_SOURCE_DIR // (this is not done anymore for each project because of // http://public.kitware.com/Bug/view.php?id=9978 and because I found it @@ -399,18 +398,48 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() this->SrcLinkedResources.push_back(sourceLinkedResourceName); } - // for EXECUTABLE_OUTPUT_PATH when not in binary dir - this->AppendOutLinkedResource(fout, - mf->GetSafeDefinition("CMAKE_RUNTIME_OUTPUT_DIRECTORY"), - mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH")); - // for LIBRARY_OUTPUT_PATH when not in binary dir - this->AppendOutLinkedResource(fout, - mf->GetSafeDefinition("CMAKE_LIBRARY_OUTPUT_DIRECTORY"), - mf->GetSafeDefinition("LIBRARY_OUTPUT_PATH")); + } + + // for each sub project create a linked resource to the source dir + // - only if it is an out-of-source build + this->AppendLinkedResource(fout, "[Subprojects]", + "virtual:/virtual", true); - fout << "\t\n"; + for (std::map >::const_iterator + it = this->GlobalGenerator->GetProjectMap().begin(); + it != this->GlobalGenerator->GetProjectMap().end(); + ++it) + { + std::string linkSourceDirectory = this->GetEclipsePath( + it->second[0]->GetMakefile()->GetStartDirectory()); + // a linked resource must not point to a parent directory of .project or + // .project itself + if ((this->HomeOutputDirectory != linkSourceDirectory) && + !cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(), + linkSourceDirectory.c_str())) + { + std::string linkName = "[Subprojects]/"; + linkName += it->first; + this->AppendLinkedResource(fout, linkName, + this->GetEclipsePath(linkSourceDirectory)); + this->SrcLinkedResources.push_back(it->first); + } } + // I'm not sure this makes too much sense. There can be different + // output directories in different subdirs, so we would need more of them. + + // for EXECUTABLE_OUTPUT_PATH when not in binary dir + this->AppendOutLinkedResource(fout, + mf->GetSafeDefinition("CMAKE_RUNTIME_OUTPUT_DIRECTORY"), + mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH")); + // for LIBRARY_OUTPUT_PATH when not in binary dir + this->AppendOutLinkedResource(fout, + mf->GetSafeDefinition("CMAKE_LIBRARY_OUTPUT_DIRECTORY"), + mf->GetSafeDefinition("LIBRARY_OUTPUT_PATH")); + + fout << "\t\n"; + fout << "\n"; } @@ -431,7 +460,8 @@ void cmExtraEclipseCDT4Generator::AppendIncludeDirectories( { emittedDirs.insert(dir); fout << "\n"; } } @@ -550,14 +580,15 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const it != this->SrcLinkedResources.end(); ++it) { - fout << "\n"; + fout << "EscapeForXML(*it) + << "\"/>\n"; // exlude source directory from output search path // - only if not named the same as an output directory if (!cmSystemTools::FileIsDirectory( std::string(this->HomeOutputDirectory + "/" + *it).c_str())) { - excludeFromOut += *it + "/|"; + excludeFromOut += this->EscapeForXML(*it) + "/|"; } } excludeFromOut += "**/CMakeFiles/"; @@ -572,7 +603,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const it != this->OutLinkedResources.end(); ++it) { - fout << "\n"; + fout << "EscapeForXML(*it) + << "\"/>\n"; } // add pre-processor definitions to allow eclipse to gray out sections @@ -875,8 +907,9 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const fout << "\n" "\n" "\n" - "GetProjectName() << ".null.1\"" - " name=\"" << mf->GetProjectName() << "\"/>\n" + "EscapeForXML(mf->GetProjectName()) + << ".null.1\" name=\"" << this->EscapeForXML(mf->GetProjectName()) + << "\"/>\n" "\n" "\n" ; @@ -927,7 +960,8 @@ cmExtraEclipseCDT4Generator::GenerateProjectName(const std::string& name, const std::string& type, const std::string& path) { - return name + (type.empty() ? "" : "-") + type + "@" + path; + return cmExtraEclipseCDT4Generator::EscapeForXML(name) + +(type.empty() ? "" : "-") + type + "@" + path; } std::string cmExtraEclipseCDT4Generator::EscapeForXML(const std::string& value) @@ -999,15 +1033,17 @@ void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout, const std::string& path, const char* prefix) { + std::string targetXml = cmExtraEclipseCDT4Generator::EscapeForXML(target); + std::string pathXml = cmExtraEclipseCDT4Generator::EscapeForXML(path); fout << - "\n" "" << cmExtraEclipseCDT4Generator::GetEclipsePath(make) << "\n" "" << makeArgs << "\n" - "" << target << "\n" + "" << targetXml << "\n" "true\n" "false\n" "\n" @@ -1046,15 +1082,24 @@ void cmExtraEclipseCDT4Generator void cmExtraEclipseCDT4Generator ::AppendLinkedResource (cmGeneratedFileStream& fout, const std::string& name, - const std::string& path) + const std::string& path, + bool isVirtualFolder) { + const char* locationTag = "location"; + if (isVirtualFolder) // ... and not a linked folder + { + locationTag = "locationURI"; + } + fout << "\t\t\n" - "\t\t\t" << name << "\n" + "\t\t\t" + << cmExtraEclipseCDT4Generator::EscapeForXML(name) + << "\n" "\t\t\t2\n" - "\t\t\t" - << path - << "\n" + "\t\t\t<" << locationTag << ">" + << cmExtraEclipseCDT4Generator::EscapeForXML(path) + << "\n" "\t\t\n" ; } diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index 99e69c42a..a6837313b 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -87,7 +87,8 @@ private: static void AppendLinkedResource (cmGeneratedFileStream& fout, const std::string& name, - const std::string& path); + const std::string& path, + bool isVirtualFolder = false); bool AppendOutLinkedResource(cmGeneratedFileStream& fout, const std::string& defname, diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 8ebd41f92..9a3de9ba9 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -75,6 +75,10 @@ bool cmFileCommand { return this->HandleDownloadCommand(args); } + else if ( subCommand == "UPLOAD" ) + { + return this->HandleUploadCommand(args); + } else if ( subCommand == "READ" ) { return this->HandleReadCommand(args); @@ -1707,7 +1711,7 @@ protected: { DoingType = DoingLast1, DoingRename, - DoingSelf24 + DoingLast2 }; virtual bool CheckKeyword(std::string const& arg); virtual bool CheckValue(std::string const& arg); @@ -1846,22 +1850,12 @@ bool cmFileInstaller::CheckKeyword(std::string const& arg) else if(arg == "COMPONENTS" || arg == "CONFIGURATIONS" || arg == "PROPERTIES") { - if(this->Makefile->IsOn("CMAKE_INSTALL_SELF_2_4")) - { - // When CMake 2.4 builds this CMake version we need to support - // the install scripts it generates since it asks this CMake - // to install itself using the rules it generated. - this->Doing = DoingSelf24; - } - else - { - cmOStringStream e; - e << "INSTALL called with old-style " << arg << " argument. " - << "This script was generated with an older version of CMake. " - << "Re-run this cmake version on your build tree."; - this->FileCommand->SetError(e.str().c_str()); - this->Doing = DoingError; - } + cmOStringStream e; + e << "INSTALL called with old-style " << arg << " argument. " + << "This script was generated with an older version of CMake. " + << "Re-run this cmake version on your build tree."; + this->FileCommand->SetError(e.str().c_str()); + this->Doing = DoingError; } else { @@ -1884,12 +1878,6 @@ bool cmFileInstaller::CheckValue(std::string const& arg) case DoingRename: this->Rename = arg; break; - case DoingSelf24: - // Ignore these arguments for compatibility. This should be - // reached only when CMake 2.4 is installing the current - // CMake. It can be removed when CMake 2.6 or higher is - // required to build CMake. - break; default: return this->cmFileCopier::CheckValue(arg); } @@ -2432,53 +2420,66 @@ bool cmFileCommand::HandleCMakePathCommand(std::vector this->Makefile->AddDefinition(var, value.c_str()); return true; } + + #if defined(CMAKE_BUILD_WITH_CMAKE) -// Stuff for curl download +// Stuff for curl download/upload typedef std::vector cmFileCommandVectorOfChar; -namespace{ + +namespace { + size_t - cmFileCommandWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, - void *data) - { + cmWriteToFileCallback(void *ptr, size_t size, size_t nmemb, + void *data) + { register int realsize = (int)(size * nmemb); std::ofstream* fout = static_cast(data); const char* chPtr = static_cast(ptr); fout->write(chPtr, realsize); return realsize; - } + } + + + size_t + cmWriteToMemoryCallback(void *ptr, size_t size, size_t nmemb, + void *data) + { + register int realsize = (int)(size * nmemb); + cmFileCommandVectorOfChar *vec + = static_cast(data); + const char* chPtr = static_cast(ptr); + vec->insert(vec->end(), chPtr, chPtr + realsize); + return realsize; + } static size_t cmFileCommandCurlDebugCallback(CURL *, curl_infotype, char *chPtr, - size_t size, void *data) - { + size_t size, void *data) + { cmFileCommandVectorOfChar *vec = static_cast(data); vec->insert(vec->end(), chPtr, chPtr + size); - return size; - } + } class cURLProgressHelper { public: - cURLProgressHelper(cmFileCommand *fc) + cURLProgressHelper(cmFileCommand *fc, const char *text) { this->CurrentPercentage = -1; this->FileCommand = fc; + this->Text = text; } bool UpdatePercentage(double value, double total, std::string &status) { int OldPercentage = this->CurrentPercentage; - if (0.0 == total) - { - this->CurrentPercentage = 100; - } - else + if (total > 0.0) { this->CurrentPercentage = static_cast(value/total*100.0 + 0.5); } @@ -2488,7 +2489,8 @@ namespace{ if (updated) { cmOStringStream oss; - oss << "[download " << this->CurrentPercentage << "% complete]"; + oss << "[" << this->Text << " " << this->CurrentPercentage + << "% complete]"; status = oss.str(); } @@ -2503,14 +2505,15 @@ namespace{ private: int CurrentPercentage; cmFileCommand *FileCommand; + std::string Text; }; static int - cmFileCommandCurlProgressCallback(void *clientp, - double dltotal, double dlnow, - double ultotal, double ulnow) - { + cmFileDownloadProgressCallback(void *clientp, + double dltotal, double dlnow, + double ultotal, double ulnow) + { cURLProgressHelper *helper = reinterpret_cast(clientp); @@ -2526,12 +2529,33 @@ namespace{ } return 0; - } + } + + + static int + cmFileUploadProgressCallback(void *clientp, + double dltotal, double dlnow, + double ultotal, double ulnow) + { + cURLProgressHelper *helper = + reinterpret_cast(clientp); + + static_cast(dltotal); + static_cast(dlnow); + + std::string status; + if (helper->UpdatePercentage(ulnow, ultotal, status)) + { + cmFileCommand *fc = helper->GetFileCommand(); + cmMakefile *mf = fc->GetMakefile(); + mf->DisplayStatus(status.c_str(), -1); + } + + return 0; + } } -#endif -#if defined(CMAKE_BUILD_WITH_CMAKE) namespace { class cURLEasyGuard @@ -2563,9 +2587,18 @@ namespace { #endif +#define check_curl_result(result, errstr) \ + if (result != CURLE_OK) \ + { \ + std::string e(errstr); \ + e += ::curl_easy_strerror(result); \ + this->SetError(e.c_str()); \ + return false; \ + } + + bool -cmFileCommand::HandleDownloadCommand(std::vector - const& args) +cmFileCommand::HandleDownloadCommand(std::vector const& args) { #if defined(CMAKE_BUILD_WITH_CMAKE) std::vector::const_iterator i = args.begin(); @@ -2581,6 +2614,7 @@ cmFileCommand::HandleDownloadCommand(std::vector ++i; long timeout = 0; + long inactivity_timeout = 0; std::string verboseLog; std::string statusVar; std::string expectedMD5sum; @@ -2601,6 +2635,19 @@ cmFileCommand::HandleDownloadCommand(std::vector return false; } } + else if(*i == "INACTIVITY_TIMEOUT") + { + ++i; + if(i != args.end()) + { + inactivity_timeout = atol(i->c_str()); + } + else + { + this->SetError("DOWNLOAD missing time for INACTIVITY_TIMEOUT."); + return false; + } + } else if(*i == "LOG") { ++i; @@ -2658,10 +2705,6 @@ cmFileCommand::HandleDownloadCommand(std::vector if (expectedMD5sum == actualMD5sum) { - this->Makefile->DisplayStatus( - "FILE(DOWNLOAD) returning early: file already exists with " - "expected MD5 sum", -1); - if(statusVar.size()) { cmOStringStream result; @@ -2708,88 +2751,44 @@ cmFileCommand::HandleDownloadCommand(std::vector cURLEasyGuard g_curl(curl); ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); - if (res != CURLE_OK) - { - std::string e = "DOWNLOAD cannot set url: "; - e += ::curl_easy_strerror(res); - this->SetError(e.c_str()); - return false; - } + check_curl_result(res, "DOWNLOAD cannot set url: "); res = ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, - cmFileCommandWriteMemoryCallback); - if (res != CURLE_OK) - { - std::string e = "DOWNLOAD cannot set write function: "; - e += ::curl_easy_strerror(res); - this->SetError(e.c_str()); - return false; - } + cmWriteToFileCallback); + check_curl_result(res, "DOWNLOAD cannot set write function: "); res = ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, cmFileCommandCurlDebugCallback); - if (res != CURLE_OK) - { - std::string e = "DOWNLOAD cannot set debug function: "; - e += ::curl_easy_strerror(res); - this->SetError(e.c_str()); - return false; - } + check_curl_result(res, "DOWNLOAD cannot set debug function: "); cmFileCommandVectorOfChar chunkDebug; res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&fout); - - if (res != CURLE_OK) - { - std::string e = "DOWNLOAD cannot set write data: "; - e += ::curl_easy_strerror(res); - this->SetError(e.c_str()); - return false; - } + check_curl_result(res, "DOWNLOAD cannot set write data: "); res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug); - if (res != CURLE_OK) - { - std::string e = "DOWNLOAD cannot set debug data: "; - e += ::curl_easy_strerror(res); - this->SetError(e.c_str()); - return false; - } + check_curl_result(res, "DOWNLOAD cannot set debug data: "); res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); - if (res != CURLE_OK) - { - std::string e = "DOWNLOAD cannot set follow-redirect option: "; - e += ::curl_easy_strerror(res); - this->SetError(e.c_str()); - return false; - } + check_curl_result(res, "DOWNLOAD cannot set follow-redirect option: "); if(verboseLog.size()) { res = ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); - - if (res != CURLE_OK) - { - std::string e = "DOWNLOAD cannot set verbose: "; - e += ::curl_easy_strerror(res); - this->SetError(e.c_str()); - return false; - } + check_curl_result(res, "DOWNLOAD cannot set verbose: "); } if(timeout > 0) { res = ::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout ); + check_curl_result(res, "DOWNLOAD cannot set timeout: "); + } - if (res != CURLE_OK) - { - std::string e = "DOWNLOAD cannot set timeout: "; - e += ::curl_easy_strerror(res); - this->SetError(e.c_str()); - return false; - } + if(inactivity_timeout > 0) + { + // Give up if there is no progress for a long time. + ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1); + ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, inactivity_timeout); } // Need the progress helper's scope to last through the duration of @@ -2797,39 +2796,20 @@ cmFileCommand::HandleDownloadCommand(std::vector // scope intentionally, rather than inside the "if(showProgress)" // block... // - cURLProgressHelper helper(this); + cURLProgressHelper helper(this, "download"); if(showProgress) { - res = ::curl_easy_setopt(curl, - CURLOPT_NOPROGRESS, 0); - if (res != CURLE_OK) - { - std::string e = "DOWNLOAD cannot set noprogress value: "; - e += ::curl_easy_strerror(res); - this->SetError(e.c_str()); - return false; - } + res = ::curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); + check_curl_result(res, "DOWNLOAD cannot set noprogress value: "); res = ::curl_easy_setopt(curl, - CURLOPT_PROGRESSFUNCTION, cmFileCommandCurlProgressCallback); - if (res != CURLE_OK) - { - std::string e = "DOWNLOAD cannot set progress function: "; - e += ::curl_easy_strerror(res); - this->SetError(e.c_str()); - return false; - } + CURLOPT_PROGRESSFUNCTION, cmFileDownloadProgressCallback); + check_curl_result(res, "DOWNLOAD cannot set progress function: "); res = ::curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, reinterpret_cast(&helper)); - if (res != CURLE_OK) - { - std::string e = "DOWNLOAD cannot set progress data: "; - e += ::curl_easy_strerror(res); - this->SetError(e.c_str()); - return false; - } + check_curl_result(res, "DOWNLOAD cannot set progress data: "); } res = ::curl_easy_perform(curl); @@ -2905,3 +2885,241 @@ cmFileCommand::HandleDownloadCommand(std::vector return false; #endif } + + +bool +cmFileCommand::HandleUploadCommand(std::vector const& args) +{ +#if defined(CMAKE_BUILD_WITH_CMAKE) + if(args.size() < 3) + { + this->SetError("UPLOAD must be called with at least three arguments."); + return false; + } + std::vector::const_iterator i = args.begin(); + ++i; + std::string filename = *i; + ++i; + std::string url = *i; + ++i; + + long timeout = 0; + long inactivity_timeout = 0; + std::string logVar; + std::string statusVar; + bool showProgress = false; + + while(i != args.end()) + { + if(*i == "TIMEOUT") + { + ++i; + if(i != args.end()) + { + timeout = atol(i->c_str()); + } + else + { + this->SetError("UPLOAD missing time for TIMEOUT."); + return false; + } + } + else if(*i == "INACTIVITY_TIMEOUT") + { + ++i; + if(i != args.end()) + { + inactivity_timeout = atol(i->c_str()); + } + else + { + this->SetError("UPLOAD missing time for INACTIVITY_TIMEOUT."); + return false; + } + } + else if(*i == "LOG") + { + ++i; + if( i == args.end()) + { + this->SetError("UPLOAD missing VAR for LOG."); + return false; + } + logVar = *i; + } + else if(*i == "STATUS") + { + ++i; + if( i == args.end()) + { + this->SetError("UPLOAD missing VAR for STATUS."); + return false; + } + statusVar = *i; + } + else if(*i == "SHOW_PROGRESS") + { + showProgress = true; + } + + ++i; + } + + // Open file for reading: + // + FILE *fin = fopen(filename.c_str(), "rb"); + if(!fin) + { + std::string errStr = "UPLOAD cannot open file '"; + errStr += filename + "' for reading."; + this->SetError(errStr.c_str()); + return false; + } + + struct stat st; + if(::stat(filename.c_str(), &st)) + { + std::string errStr = "UPLOAD cannot stat file '"; + errStr += filename + "'."; + this->SetError(errStr.c_str()); + return false; + } + + ::CURL *curl; + ::curl_global_init(CURL_GLOBAL_DEFAULT); + curl = ::curl_easy_init(); + if(!curl) + { + this->SetError("UPLOAD error initializing curl."); + return false; + } + + cURLEasyGuard g_curl(curl); + + // enable HTTP ERROR parsing + ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); + + // enable uploading + res = ::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1); + check_curl_result(res, "UPLOAD cannot set upload flag: "); + + res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); + check_curl_result(res, "UPLOAD cannot set url: "); + + res = ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, + cmWriteToMemoryCallback); + check_curl_result(res, "UPLOAD cannot set write function: "); + + res = ::curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, + cmFileCommandCurlDebugCallback); + check_curl_result(res, "UPLOAD cannot set debug function: "); + + cmFileCommandVectorOfChar chunkResponse; + cmFileCommandVectorOfChar chunkDebug; + + res = ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunkResponse); + check_curl_result(res, "UPLOAD cannot set write data: "); + + res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug); + check_curl_result(res, "UPLOAD cannot set debug data: "); + + res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); + check_curl_result(res, "UPLOAD cannot set follow-redirect option: "); + + if(logVar.size()) + { + res = ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); + check_curl_result(res, "UPLOAD cannot set verbose: "); + } + + if(timeout > 0) + { + res = ::curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout ); + check_curl_result(res, "UPLOAD cannot set timeout: "); + } + + if(inactivity_timeout > 0) + { + // Give up if there is no progress for a long time. + ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1); + ::curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, inactivity_timeout); + } + + // Need the progress helper's scope to last through the duration of + // the curl_easy_perform call... so this object is declared at function + // scope intentionally, rather than inside the "if(showProgress)" + // block... + // + cURLProgressHelper helper(this, "upload"); + + if(showProgress) + { + res = ::curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); + check_curl_result(res, "UPLOAD cannot set noprogress value: "); + + res = ::curl_easy_setopt(curl, + CURLOPT_PROGRESSFUNCTION, cmFileUploadProgressCallback); + check_curl_result(res, "UPLOAD cannot set progress function: "); + + res = ::curl_easy_setopt(curl, + CURLOPT_PROGRESSDATA, reinterpret_cast(&helper)); + check_curl_result(res, "UPLOAD cannot set progress data: "); + } + + // now specify which file to upload + res = ::curl_easy_setopt(curl, CURLOPT_INFILE, fin); + check_curl_result(res, "UPLOAD cannot set input file: "); + + // and give the size of the upload (optional) + res = ::curl_easy_setopt(curl, + CURLOPT_INFILESIZE, static_cast(st.st_size)); + check_curl_result(res, "UPLOAD cannot set input file size: "); + + res = ::curl_easy_perform(curl); + + /* always cleanup */ + g_curl.release(); + ::curl_easy_cleanup(curl); + + if(statusVar.size()) + { + cmOStringStream result; + result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\""; + this->Makefile->AddDefinition(statusVar.c_str(), + result.str().c_str()); + } + + ::curl_global_cleanup(); + + fclose(fin); + fin = NULL; + + if(logVar.size()) + { + std::string log; + + if(chunkResponse.size()) + { + chunkResponse.push_back(0); + log += "Response:\n"; + log += &*chunkResponse.begin(); + log += "\n"; + } + + if(chunkDebug.size()) + { + chunkDebug.push_back(0); + log += "Debug:\n"; + log += &*chunkDebug.begin(); + log += "\n"; + } + + this->Makefile->AddDefinition(logVar.c_str(), log.c_str()); + } + + return true; +#else + this->SetError("UPLOAD not supported by bootstrap cmake."); + return false; +#endif +} diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index b11dcde4d..162890abf 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -80,8 +80,11 @@ public: " file(RELATIVE_PATH variable directory file)\n" " file(TO_CMAKE_PATH path result)\n" " file(TO_NATIVE_PATH path result)\n" - " file(DOWNLOAD url file [TIMEOUT timeout] [STATUS status] [LOG log]\n" - " [EXPECTED_MD5 sum] [SHOW_PROGRESS])\n" + " file(DOWNLOAD url file [INACTIVITY_TIMEOUT timeout]\n" + " [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS]\n" + " [EXPECTED_MD5 sum])\n" + " file(UPLOAD filename url [INACTIVITY_TIMEOUT timeout]\n" + " [TIMEOUT timeout] [STATUS status] [LOG log] [SHOW_PROGRESS])\n" "WRITE will write a message into a file called 'filename'. It " "overwrites the file if it already exists, and creates the file " "if it does not exist.\n" @@ -159,12 +162,28 @@ public: "numeric error means no error in the operation. " "If TIMEOUT time is specified, the operation will " "timeout after time seconds, time should be specified as an integer. " + "The INACTIVITY_TIMEOUT specifies an integer number of seconds of " + "inactivity after which the operation should terminate. " "If EXPECTED_MD5 sum is specified, the operation will verify that the " "downloaded file's actual md5 sum matches the expected value. If it " "does not match, the operation fails with an error. " "If SHOW_PROGRESS is specified, progress information will be printed " "as status messages until the operation is complete." "\n" + "UPLOAD will upload the given file to the given URL. " + "If LOG var is specified a log of the upload will be put in var. " + "If STATUS var is specified the status of the operation will" + " be put in var. The status is returned in a list of length 2. " + "The first element is the numeric return value for the operation, " + "and the second element is a string value for the error. A 0 " + "numeric error means no error in the operation. " + "If TIMEOUT time is specified, the operation will " + "timeout after time seconds, time should be specified as an integer. " + "The INACTIVITY_TIMEOUT specifies an integer number of seconds of " + "inactivity after which the operation should terminate. " + "If SHOW_PROGRESS is specified, progress information will be printed " + "as status messages until the operation is complete." + "\n" "The file() command also provides COPY and INSTALL signatures:\n" " file( files... DESTINATION \n" " [FILE_PERMISSIONS permissions...]\n" @@ -223,6 +242,7 @@ protected: bool HandleCopyCommand(std::vector const& args); bool HandleInstallCommand(std::vector const& args); bool HandleDownloadCommand(std::vector const& args); + bool HandleUploadCommand(std::vector const& args); }; diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index d0fe99f24..ce9deb143 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -72,12 +72,14 @@ void cmFindBase::GenerateDocumentation() "1. Search paths specified in cmake-specific cache variables. " "These are intended to be used on the command line with a -DVAR=value. " "This can be skipped if NO_CMAKE_PATH is passed.\n" + "XXX_EXTRA_PREFIX_ENTRY" " /XXX_SUBDIR for each in CMAKE_PREFIX_PATH\n" " CMAKE_XXX_PATH\n" " CMAKE_XXX_MAC_PATH\n" "2. Search paths specified in cmake-specific environment variables. " "These are intended to be set in the user's shell configuration. " "This can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.\n" + "XXX_EXTRA_PREFIX_ENTRY" " /XXX_SUBDIR for each in CMAKE_PREFIX_PATH\n" " CMAKE_XXX_PATH\n" " CMAKE_XXX_MAC_PATH\n" @@ -92,6 +94,7 @@ void cmFindBase::GenerateDocumentation() "5. Search cmake variables defined in the Platform files " "for the current system. This can be skipped if NO_CMAKE_SYSTEM_PATH " "is passed.\n" + "XXX_EXTRA_PREFIX_ENTRY" " /XXX_SUBDIR for each in CMAKE_SYSTEM_PREFIX_PATH\n" " CMAKE_SYSTEM_XXX_PATH\n" " CMAKE_SYSTEM_XXX_MAC_PATH\n" @@ -346,6 +349,15 @@ void cmFindBase::AddPrefixPaths(std::vector const& in_paths, { dir += "/"; } + if(subdir == "lib") + { + const char* arch = + this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"); + if(arch && *arch) + { + this->AddPathInternal(dir+"lib/"+arch, pathType); + } + } std::string add = dir + subdir; if(add != "/") { diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index b3093764a..6355a85a7 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -44,6 +44,10 @@ void cmFindLibraryCommand::GenerateDocumentation() "SEARCH_XXX", "library"); cmSystemTools::ReplaceString(this->GenericDocumentation, "XXX_SUBDIR", "lib"); + cmSystemTools::ReplaceString( + this->GenericDocumentation, + "XXX_EXTRA_PREFIX_ENTRY", + " /lib/ if CMAKE_LIBRARY_ARCHITECTURE is set, and\n"); cmSystemTools::ReplaceString(this->GenericDocumentation, "CMAKE_FIND_ROOT_PATH_MODE_XXX", "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY"); diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index fdc1a0116..5f106bce0 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -54,7 +54,8 @@ cmFindPackageCommand::cmFindPackageCommand() this->CMakePathName = "PACKAGE"; this->Quiet = false; this->Required = false; - this->NoRegistry = false; + this->NoUserRegistry = false; + this->NoSystemRegistry = false; this->NoBuilds = false; this->NoModule = false; this->DebugMode = false; @@ -101,9 +102,10 @@ void cmFindPackageCommand::GenerateDocumentation() "The [version] argument requests a version with which the package found " "should be compatible (format is major[.minor[.patch[.tweak]]]). " "The EXACT option requests that the version be matched exactly. " - "If no [version] is given to a recursive invocation inside a " - "find-module, the [version] and EXACT arguments are forwarded " - "automatically from the outer call. " + "If no [version] and/or component list is given to a recursive " + "invocation inside a find-module, the corresponding arguments " + "are forwarded automatically from the outer call (including the " + "EXACT flag for [version]). " "Version support is currently provided only on a package-by-package " "basis (details below).\n" "User code should generally look for packages using the above simple " @@ -139,6 +141,7 @@ void cmFindPackageCommand::GenerateDocumentation() " [NO_CMAKE_PACKAGE_REGISTRY]\n" " [NO_CMAKE_BUILDS_PATH]\n" " [NO_CMAKE_SYSTEM_PATH]\n" + " [NO_CMAKE_SYSTEM_PACKAGE_REGISTRY]\n" " [CMAKE_FIND_ROOT_PATH_BOTH |\n" " ONLY_CMAKE_FIND_ROOT_PATH |\n" " NO_CMAKE_FIND_ROOT_PATH])\n" @@ -240,9 +243,9 @@ void cmFindPackageCommand::GenerateDocumentation() " /(cmake|CMake)/ (W)\n" " /*/ (W)\n" " /*/(cmake|CMake)/ (W)\n" - " /(share|lib)/cmake/*/ (U)\n" - " /(share|lib)/*/ (U)\n" - " /(share|lib)/*/(cmake|CMake)/ (U)\n" + " /(lib/|lib|share)/cmake/*/ (U)\n" + " /(lib/|lib|share)/*/ (U)\n" + " /(lib/|lib|share)/*/(cmake|CMake)/ (U)\n" "On systems supporting OS X Frameworks and Application Bundles " "the following directories are searched for frameworks or bundles " "containing a configuration file:\n" @@ -254,6 +257,7 @@ void cmFindPackageCommand::GenerateDocumentation() " /.app/Contents/Resources/CMake/ (A)\n" "In all cases the is treated as case-insensitive and corresponds " "to any of the names specified ( or names given by NAMES). " + "Paths with lib/ are enabled if CMAKE_LIBRARY_ARCHITECTURE is set. " "If PATH_SUFFIXES is specified the suffixes are appended to each " "(W) or (U) directory entry one-by-one.\n" "This set of directories is intended to work in cooperation with " @@ -298,9 +302,16 @@ void cmFindPackageCommand::GenerateDocumentation() "dependent projects one after another.\n" "6. Search paths stored in the CMake user package registry. " "This can be skipped if NO_CMAKE_PACKAGE_REGISTRY is passed. " - "Paths are stored in the registry when CMake configures a project " - "that invokes export(PACKAGE ). " - "See the export(PACKAGE) command documentation for more details." + "On Windows a may appear under registry key\n" + " HKEY_CURRENT_USER\\Software\\Kitware\\CMake\\Packages\\\n" + "as a REG_SZ value, with arbitrary name, that specifies the directory " + "containing the package configuration file. " + "On UNIX platforms a may appear under the directory\n" + " ~/.cmake/packages/\n" + "as a file, with arbitrary name, whose content specifies the directory " + "containing the package configuration file. " + "See the export(PACKAGE) command to create user package registry entries " + "for project build trees." "\n" "7. Search cmake variables defined in the Platform files " "for the current system. This can be skipped if NO_CMAKE_SYSTEM_PATH " @@ -308,7 +319,15 @@ void cmFindPackageCommand::GenerateDocumentation() " CMAKE_SYSTEM_PREFIX_PATH\n" " CMAKE_SYSTEM_FRAMEWORK_PATH\n" " CMAKE_SYSTEM_APPBUNDLE_PATH\n" - "8. Search paths specified by the PATHS option. " + "8. Search paths stored in the CMake system package registry. " + "This can be skipped if NO_CMAKE_SYSTEM_PACKAGE_REGISTRY is passed. " + "On Windows a may appear under registry key\n" + " HKEY_LOCAL_MACHINE\\Software\\Kitware\\CMake\\Packages\\\n" + "as a REG_SZ value, with arbitrary name, that specifies the directory " + "containing the package configuration file. " + "There is no system package registry on non-Windows platforms." + "\n" + "9. Search paths specified by the PATHS option. " "These are typically hard-coded guesses.\n" ; this->CommandDocumentation += this->GenericDocumentationMacPolicy; @@ -344,6 +363,13 @@ bool cmFindPackageCommand // Check for debug mode. this->DebugMode = this->Makefile->IsOn("CMAKE_FIND_DEBUG_MODE"); + // Lookup target architecture, if any. + if(const char* arch = + this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) + { + this->LibraryArchitecture = arch; + } + // Lookup whether lib64 paths should be used. if(this->Makefile->PlatformIs64Bit() && this->Makefile->GetCMakeInstance() @@ -443,7 +469,14 @@ bool cmFindPackageCommand } else if(args[i] == "NO_CMAKE_PACKAGE_REGISTRY") { - this->NoRegistry = true; + this->NoUserRegistry = true; + this->NoModule = true; + this->Compatibility_1_6 = false; + doing = DoingNone; + } + else if(args[i] == "NO_CMAKE_SYSTEM_PACKAGE_REGISTRY") + { + this->NoSystemRegistry = true; this->NoModule = true; this->Compatibility_1_6 = false; doing = DoingNone; @@ -524,7 +557,7 @@ bool cmFindPackageCommand cmake::AUTHOR_WARNING, "Ignoring EXACT since no version is requested."); } - if(this->Version.empty()) + if(this->Version.empty() || components.empty()) { // Check whether we are recursing inside "Find.cmake" within // another find_package() call. @@ -532,16 +565,24 @@ bool cmFindPackageCommand mod += "_FIND_MODULE"; if(this->Makefile->IsOn(mod.c_str())) { - // Get version information from the outer call if necessary. - // Requested version string. - std::string ver = this->Name; - ver += "_FIND_VERSION"; - this->Version = this->Makefile->GetSafeDefinition(ver.c_str()); - - // Whether an exact version is required. - std::string exact = this->Name; - exact += "_FIND_VERSION_EXACT"; - this->VersionExact = this->Makefile->IsOn(exact.c_str()); + if(this->Version.empty()) + { + // Get version information from the outer call if necessary. + // Requested version string. + std::string ver = this->Name; + ver += "_FIND_VERSION"; + this->Version = this->Makefile->GetSafeDefinition(ver.c_str()); + + // Whether an exact version is required. + std::string exact = this->Name; + exact += "_FIND_VERSION_EXACT"; + this->VersionExact = this->Makefile->IsOn(exact.c_str()); + } + if(components.empty()) + { + std::string components_var = this->Name + "_FIND_COMPONENTS"; + components = this->Makefile->GetSafeDefinition(components_var.c_str()); + } } } @@ -1172,9 +1213,10 @@ void cmFindPackageCommand::ComputePrefixes() this->AddPrefixesCMakeEnvironment(); this->AddPrefixesUserHints(); this->AddPrefixesSystemEnvironment(); - this->AddPrefixesRegistry(); + this->AddPrefixesUserRegistry(); this->AddPrefixesBuilds(); this->AddPrefixesCMakeSystemVariable(); + this->AddPrefixesSystemRegistry(); this->AddPrefixesUserGuess(); this->ComputeFinalPrefixes(); } @@ -1240,15 +1282,15 @@ void cmFindPackageCommand::AddPrefixesSystemEnvironment() } //---------------------------------------------------------------------------- -void cmFindPackageCommand::AddPrefixesRegistry() +void cmFindPackageCommand::AddPrefixesUserRegistry() { - if(this->NoRegistry || this->NoDefaultPath) + if(this->NoUserRegistry || this->NoDefaultPath) { return; } #if defined(_WIN32) && !defined(__CYGWIN__) - this->LoadPackageRegistryWin(); + this->LoadPackageRegistryWinUser(); #elif defined(__HAIKU__) BPath dir; if (find_directory(B_USER_SETTINGS_DIRECTORY, &dir) == B_OK) @@ -1268,18 +1310,63 @@ void cmFindPackageCommand::AddPrefixesRegistry() #endif } +//---------------------------------------------------------------------------- +void cmFindPackageCommand::AddPrefixesSystemRegistry() +{ + if(this->NoSystemRegistry || this->NoDefaultPath) + { + return; + } + +#if defined(_WIN32) && !defined(__CYGWIN__) + this->LoadPackageRegistryWinSystem(); +#endif +} + #if defined(_WIN32) && !defined(__CYGWIN__) # include # undef GetCurrentDirectory + // http://msdn.microsoft.com/en-us/library/aa384253%28v=vs.85%29.aspx +# if !defined(KEY_WOW64_32KEY) +# define KEY_WOW64_32KEY 0x0200 +# endif +# if !defined(KEY_WOW64_64KEY) +# define KEY_WOW64_64KEY 0x0100 +# endif +//---------------------------------------------------------------------------- +void cmFindPackageCommand::LoadPackageRegistryWinUser() +{ + // HKEY_CURRENT_USER\\Software shares 32-bit and 64-bit views. + this->LoadPackageRegistryWin(true, 0); +} + +//---------------------------------------------------------------------------- +void cmFindPackageCommand::LoadPackageRegistryWinSystem() +{ + // HKEY_LOCAL_MACHINE\\SOFTWARE has separate 32-bit and 64-bit views. + // Prefer the target platform view first. + if(this->Makefile->PlatformIs64Bit()) + { + this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY); + this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY); + } + else + { + this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY); + this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY); + } +} + //---------------------------------------------------------------------------- -void cmFindPackageCommand::LoadPackageRegistryWin() +void cmFindPackageCommand::LoadPackageRegistryWin(bool user, + unsigned int view) { std::string key = "Software\\Kitware\\CMake\\Packages\\"; key += this->Name; std::set bad; HKEY hKey; - if(RegOpenKeyEx(HKEY_CURRENT_USER, key.c_str(), - 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + if(RegOpenKeyEx(user? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, key.c_str(), + 0, KEY_QUERY_VALUE|view, &hKey) == ERROR_SUCCESS) { DWORD valueType = REG_NONE; char name[16384]; @@ -1299,13 +1386,12 @@ void cmFindPackageCommand::LoadPackageRegistryWin() { data[dataSize] = 0; cmsys_ios::stringstream ss(&data[0]); - if(this->CheckPackageRegistryEntry(ss)) + if(!this->CheckPackageRegistryEntry(ss)) { - // The entry is okay. - continue; + // The entry is invalid. + bad.insert(name); } } - bad.insert(name); break; case ERROR_MORE_DATA: data.resize(dataSize+1); @@ -1317,9 +1403,9 @@ void cmFindPackageCommand::LoadPackageRegistryWin() } // Remove bad values if possible. - if(!bad.empty() && + if(user && !bad.empty() && RegOpenKeyEx(HKEY_CURRENT_USER, key.c_str(), - 0, KEY_SET_VALUE, &hKey) == ERROR_SUCCESS) + 0, KEY_SET_VALUE|view, &hKey) == ERROR_SUCCESS) { for(std::set::const_iterator vi = bad.begin(); vi != bad.end(); ++vi) @@ -2111,6 +2197,10 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) // Construct list of common install locations (lib and share). std::vector common; + if(!this->LibraryArchitecture.empty()) + { + common.push_back("lib/"+this->LibraryArchitecture); + } if(this->UseLib64Paths) { common.push_back("lib64"); @@ -2118,7 +2208,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) common.push_back("lib"); common.push_back("share"); - // PREFIX/(share|lib)/cmake/(Foo|foo|FOO).*/ + // PREFIX/(lib/ARCH|lib|share)/cmake/(Foo|foo|FOO).*/ { cmFindPackageFileList lister(this); lister @@ -2132,7 +2222,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) } } - // PREFIX/(share|lib)/(Foo|foo|FOO).*/ + // PREFIX/(lib/ARCH|lib|share)/(Foo|foo|FOO).*/ { cmFindPackageFileList lister(this); lister @@ -2145,7 +2235,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) } } - // PREFIX/(share|lib)/(Foo|foo|FOO).*/(cmake|CMake)/ + // PREFIX/(lib/ARCH|lib|share)/(Foo|foo|FOO).*/(cmake|CMake)/ { cmFindPackageFileList lister(this); lister @@ -2277,11 +2367,3 @@ bool cmFindPackageCommand::SearchAppBundlePrefix(std::string const& prefix_in) } // TODO: Debug cmsys::Glob double slash problem. - -// TODO: Add registry entries after cmake system search path? -// Currently the user must specify them with the PATHS option. -// -// [HKEY_CURRENT_USER\Software\*\Foo*;InstallDir] -// [HKEY_CURRENT_USER\Software\*\*\Foo*;InstallDir] -// [HKEY_LOCAL_MACHINE\Software\*\Foo*;InstallDir] -// [HKEY_LOCAL_MACHINE\Software\*\*\Foo*;InstallDir] diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 19d2b1099..2b2e1dace 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -87,14 +87,17 @@ private: void AddPrefixesCMakeEnvironment(); void AddPrefixesCMakeVariable(); void AddPrefixesSystemEnvironment(); - void AddPrefixesRegistry(); + void AddPrefixesUserRegistry(); + void AddPrefixesSystemRegistry(); void AddPrefixesBuilds(); void AddPrefixesCMakeSystemVariable(); void AddPrefixesUserGuess(); void AddPrefixesUserHints(); void ComputeFinalPrefixes(); void LoadPackageRegistryDir(std::string const& dir); - void LoadPackageRegistryWin(); + void LoadPackageRegistryWinUser(); + void LoadPackageRegistryWinSystem(); + void LoadPackageRegistryWin(bool user, unsigned int view); bool CheckPackageRegistryEntry(std::istream& is); bool SearchDirectory(std::string const& dir); bool CheckDirectory(std::string const& dir); @@ -132,11 +135,13 @@ private: bool Required; bool Compatibility_1_6; bool NoModule; - bool NoRegistry; + bool NoUserRegistry; + bool NoSystemRegistry; bool NoBuilds; bool DebugMode; bool UseLib64Paths; bool PolicyScope; + std::string LibraryArchitecture; std::vector Names; std::vector Configs; std::set IgnoredPaths; diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 83b651b71..846d187cb 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -45,6 +45,8 @@ void cmFindPathCommand::GenerateDocumentation() "SEARCH_XXX", "file in a directory"); cmSystemTools::ReplaceString(this->GenericDocumentation, "XXX_SUBDIR", "include"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "XXX_EXTRA_PREFIX_ENTRY", ""); cmSystemTools::ReplaceString(this->GenericDocumentation, "CMAKE_FIND_ROOT_PATH_MODE_XXX", "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE"); diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index 71cfdcbbe..7c56ad7ce 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -41,6 +41,8 @@ void cmFindProgramCommand::GenerateDocumentation() "SEARCH_XXX", "program"); cmSystemTools::ReplaceString(this->GenericDocumentation, "XXX_SUBDIR", "[s]bin"); + cmSystemTools::ReplaceString(this->GenericDocumentation, + "XXX_EXTRA_PREFIX_ENTRY", ""); cmSystemTools::ReplaceString(this->GenericDocumentation, "CMAKE_FIND_ROOT_PATH_MODE_XXX", "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM"); diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 8710dfc93..f88ab0b71 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -23,7 +23,7 @@ cmGeneratorExpression::cmGeneratorExpression( this->TargetInfo.compile("^\\$$"); } diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx index e3448ded8..8bb54877e 100644 --- a/Source/cmGetCMakePropertyCommand.cxx +++ b/Source/cmGetCMakePropertyCommand.cxx @@ -22,21 +22,22 @@ bool cmGetCMakePropertyCommand this->SetError("called with incorrect number of arguments"); return false; } - + std::vector::size_type cc; std::string variable = args[0]; std::string output = "NOTFOUND"; - if ( args[1] == "VARIABLES") + if ( args[1] == "VARIABLES" ) { int cacheonly = 0; std::vector vars = this->Makefile->GetDefinitions(cacheonly); - for ( cc = 0; cc < vars.size(); cc ++ ) + if (vars.size()>0) { - if ( cc > 0 ) - { - output += ";"; - } + output = vars[0]; + } + for ( cc = 1; cc < vars.size(); ++cc ) + { + output += ";"; output += vars[cc]; } } @@ -62,15 +63,15 @@ bool cmGetCMakePropertyCommand } else { - const char *prop = + const char *prop = this->Makefile->GetCMakeInstance()->GetProperty(args[1].c_str()); if (prop) { output = prop; } } + this->Makefile->AddDefinition(variable.c_str(), output.c_str()); - + return true; } - diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index d47fb6f37..6c8938e5d 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -903,8 +903,6 @@ void cmGlobalGenerator::Generate() } this->CMakeInstance->UpdateProgress("Generating done", -1); - - this->CMakeInstance->RunCheckForUnusedVariables("generation"); } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index d9a341c38..169d77d9d 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -24,13 +24,13 @@ cmGlobalUnixMakefileGenerator3::cmGlobalUnixMakefileGenerator3() this->ForceUnixPaths = true; this->FindMakeProgramFile = "CMakeUnixFindMake.cmake"; this->ToolSupportsColor = true; - this->NoRuleMessages = false; #if defined(_WIN32) || defined(__VMS) this->UseLinkScript = false; #else this->UseLinkScript = true; #endif + this->CommandDatabase = NULL; } void cmGlobalUnixMakefileGenerator3 @@ -139,56 +139,87 @@ void cmGlobalUnixMakefileGenerator3 } //---------------------------------------------------------------------------- +std::string EscapeJSON(const std::string& s) { + std::string result; + for (std::string::size_type i = 0; i < s.size(); ++i) { + if (s[i] == '"' || s[i] == '\\') { + result += '\\'; + } + result += s[i]; + } + return result; +} + void cmGlobalUnixMakefileGenerator3::Generate() { // first do superclass method this->cmGlobalGenerator::Generate(); - cmake* cm = this->GetCMakeInstance(); - if(const char* ruleStatus = cm->GetProperty("RULE_MESSAGES")) + // initialize progress + unsigned long total = 0; + for(ProgressMapType::const_iterator pmi = this->ProgressMap.begin(); + pmi != this->ProgressMap.end(); ++pmi) { - this->NoRuleMessages = cmSystemTools::IsOff(ruleStatus); + total += pmi->second.NumberOfActions; } - if(!this->NoRuleMessages) + // write each target's progress.make this loop is done twice. Bascially the + // Generate pass counts all the actions, the first loop below determines + // how many actions have progress updates for each target and writes to + // corrrect variable values for everything except the all targets. The + // second loop actually writes out correct values for the all targets as + // well. This is because the all targets require more information that is + // computed in the first loop. + unsigned long current = 0; + for(ProgressMapType::iterator pmi = this->ProgressMap.begin(); + pmi != this->ProgressMap.end(); ++pmi) { - // initialize progress - unsigned long total = 0; - for(ProgressMapType::const_iterator pmi = this->ProgressMap.begin(); - pmi != this->ProgressMap.end(); ++pmi) - { - total += pmi->second.NumberOfActions; - } - - // write each target's progress.make this loop is done twice. Bascially the - // Generate pass counts all the actions, the first loop below determines - // how many actions have progress updates for each target and writes to - // corrrect variable values for everything except the all targets. The - // second loop actually writes out correct values for the all targets as - // well. This is because the all targets require more information that is - // computed in the first loop. - unsigned long current = 0; - for(ProgressMapType::iterator pmi = this->ProgressMap.begin(); - pmi != this->ProgressMap.end(); ++pmi) - { - pmi->second.WriteProgressVariables(total, current); - } - for(unsigned int i = 0; i < this->LocalGenerators.size(); ++i) - { - cmLocalUnixMakefileGenerator3 *lg = - static_cast(this->LocalGenerators[i]); - std::string markFileName = lg->GetMakefile()->GetStartOutputDirectory(); - markFileName += "/"; - markFileName += cmake::GetCMakeFilesDirectory(); - markFileName += "/progress.marks"; - cmGeneratedFileStream markFile(markFileName.c_str()); - markFile << this->CountProgressMarksInAll(lg) << "\n"; - } + pmi->second.WriteProgressVariables(total, current); + } + for(unsigned int i = 0; i < this->LocalGenerators.size(); ++i) + { + cmLocalUnixMakefileGenerator3 *lg = + static_cast(this->LocalGenerators[i]); + std::string markFileName = lg->GetMakefile()->GetStartOutputDirectory(); + markFileName += "/"; + markFileName += cmake::GetCMakeFilesDirectory(); + markFileName += "/progress.marks"; + cmGeneratedFileStream markFile(markFileName.c_str()); + markFile << this->CountProgressMarksInAll(lg) << "\n"; } // write the main makefile this->WriteMainMakefile2(); this->WriteMainCMakefile(); + + if (this->CommandDatabase != NULL) { + *this->CommandDatabase << std::endl << "]"; + delete this->CommandDatabase; + this->CommandDatabase = NULL; + } +} + +void cmGlobalUnixMakefileGenerator3::AddCXXCompileCommand( + const std::string &sourceFile, const std::string &workingDirectory, + const std::string &compileCommand) { + if (this->CommandDatabase == NULL) + { + std::string commandDatabaseName = + std::string(this->GetCMakeInstance()->GetHomeOutputDirectory()) + + "/compile_commands.json"; + this->CommandDatabase = + new cmGeneratedFileStream(commandDatabaseName.c_str()); + *this->CommandDatabase << "[" << std::endl; + } else { + *this->CommandDatabase << "," << std::endl; + } + *this->CommandDatabase << "{" << std::endl + << " \"directory\": \"" << EscapeJSON(workingDirectory) << "\"," + << std::endl + << " \"command\": \"" << EscapeJSON(compileCommand) << "\"," + << std::endl + << " \"file\": \"" << EscapeJSON(sourceFile) << "\"" + << std::endl << "}"; } void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2() @@ -747,34 +778,30 @@ cmGlobalUnixMakefileGenerator3 // Write the rule. localName += "/all"; depends.clear(); - std::string progressDir; - if(!this->NoRuleMessages) + std::string progressDir = + lg->GetMakefile()->GetHomeOutputDirectory(); + progressDir += cmake::GetCMakeFilesDirectory(); { - progressDir = - lg->GetMakefile()->GetHomeOutputDirectory(); - progressDir += cmake::GetCMakeFilesDirectory(); + cmOStringStream progCmd; + progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report "; + // all target counts + progCmd << lg->Convert(progressDir.c_str(), + cmLocalGenerator::FULL, + cmLocalGenerator::SHELL); + progCmd << " "; + std::vector& progFiles = + this->ProgressMap[&t->second].Marks; + for (std::vector::iterator i = progFiles.begin(); + i != progFiles.end(); ++i) { - cmOStringStream progCmd; - progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report "; - // all target counts - progCmd << lg->Convert(progressDir.c_str(), - cmLocalGenerator::FULL, - cmLocalGenerator::SHELL); - progCmd << " "; - std::vector& progFiles = - this->ProgressMap[&t->second].Marks; - for (std::vector::iterator i = progFiles.begin(); - i != progFiles.end(); ++i) - { - progCmd << " " << *i; - } - commands.push_back(progCmd.str()); + progCmd << " " << *i; } - progressDir = "Built target "; - progressDir += t->first; - lg->AppendEcho(commands,progressDir.c_str()); + commands.push_back(progCmd.str()); } + progressDir = "Built target "; + progressDir += t->first; + lg->AppendEcho(commands,progressDir.c_str()); this->AppendGlobalTargetDepends(depends,t->second); lg->WriteMakeRule(ruleFileStream, "All Build rule for target.", @@ -790,42 +817,38 @@ cmGlobalUnixMakefileGenerator3 "all", depends, commands, true); } - if(!this->NoRuleMessages) - { - // Write the rule. - commands.clear(); - progressDir = lg->GetMakefile()->GetHomeOutputDirectory(); - progressDir += cmake::GetCMakeFilesDirectory(); + // Write the rule. + commands.clear(); + progressDir = lg->GetMakefile()->GetHomeOutputDirectory(); + progressDir += cmake::GetCMakeFilesDirectory(); - { - // TODO: Convert the total progress count to a make variable. - cmOStringStream progCmd; - progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; - // # in target - progCmd << lg->Convert(progressDir.c_str(), - cmLocalGenerator::FULL, - cmLocalGenerator::SHELL); - // - std::set emitted; - progCmd << " " - << this->CountProgressMarksInTarget(&t->second, emitted); - commands.push_back(progCmd.str()); - } - } + { + // TODO: Convert the total progress count to a make variable. + cmOStringStream progCmd; + progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; + // # in target + progCmd << lg->Convert(progressDir.c_str(), + cmLocalGenerator::FULL, + cmLocalGenerator::SHELL); + // + std::set emitted; + progCmd << " " + << this->CountProgressMarksInTarget(&t->second, emitted); + commands.push_back(progCmd.str()); + } std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash(); tmp += "Makefile2"; commands.push_back(lg->GetRecursiveMakeCall (tmp.c_str(),localName.c_str())); - if(!this->NoRuleMessages) - { - cmOStringStream progCmd; - progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0 - progCmd << lg->Convert(progressDir.c_str(), - cmLocalGenerator::FULL, - cmLocalGenerator::SHELL); - progCmd << " 0"; - commands.push_back(progCmd.str()); - } + { + cmOStringStream progCmd; + progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0 + progCmd << lg->Convert(progressDir.c_str(), + cmLocalGenerator::FULL, + cmLocalGenerator::SHELL); + progCmd << " 0"; + commands.push_back(progCmd.str()); + } depends.clear(); depends.push_back("cmake_check_build_system"); localName = lg->GetRelativeTargetDirectory(t->second); diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index cdc946084..d21d5b957 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -112,6 +112,10 @@ public: /** Record per-target progress information. */ void RecordTargetProgress(cmMakefileTargetGenerator* tg); + void AddCXXCompileCommand(const std::string &sourceFile, + const std::string &workingDirectory, + const std::string &compileCommand); + protected: void WriteMainMakefile2(); void WriteMainCMakefile(); @@ -159,8 +163,6 @@ protected: // in the rule to satisfy the make program. std::string EmptyRuleHackCommand; - bool NoRuleMessages; - // Store per-target progress counters. struct TargetProgress { @@ -178,6 +180,8 @@ protected: size_t CountProgressMarksInTarget(cmTarget* target, std::set& emitted); size_t CountProgressMarksInAll(cmLocalUnixMakefileGenerator3* lg); + + cmGeneratedFileStream *CommandDatabase; }; #endif diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 2d080df2b..ef723b7dc 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -358,6 +358,15 @@ static cmVS7FlagTable cmVS8ExtraFlagTable[] = {"ExceptionHandling", "EHsc", "enable c++ exceptions", "1", 0}, {"ExceptionHandling", "EHa", "enable SEH exceptions", "2", 0}, + {"EnablePREfast", "analyze", "", "true", 0}, + {"EnablePREfast", "analyze-", "", "false", 0}, + + // Language options + {"TreatWChar_tAsBuiltInType", "Zc:wchar_t", + "wchar_t is a built-in type", "true", 0}, + {"TreatWChar_tAsBuiltInType", "Zc:wchar_t-", + "wchar_t is not a built-in type", "false", 0}, + {0,0,0,0,0} }; cmIDEFlagTable const* cmGlobalVisualStudio8Generator::GetExtraFlagTableVS8() diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 358721f83..2cbd3ed62 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -147,7 +147,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::New() } return gg.release(); #else - std::cerr << "CMake should be built with cmake to use XCode, " + std::cerr << "CMake should be built with cmake to use Xcode, " "default to Xcode 1.5\n"; return new cmGlobalXCodeGenerator; #endif @@ -165,13 +165,16 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vectorconst& } else { - mf->AddCacheDefinition( - "CMAKE_CONFIGURATION_TYPES", - "Debug;Release;MinSizeRel;RelWithDebInfo", - "Semicolon separated list of supported configuration types, " - "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, " - "anything else will be ignored.", - cmCacheManager::STRING); + if(!mf->GetDefinition("CMAKE_CONFIGURATION_TYPES")) + { + mf->AddCacheDefinition( + "CMAKE_CONFIGURATION_TYPES", + "Debug;Release;MinSizeRel;RelWithDebInfo", + "Semicolon separated list of supported configuration types, " + "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, " + "anything else will be ignored.", + cmCacheManager::STRING); + } } mf->AddDefinition("CMAKE_GENERATOR_CC", "gcc"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "g++"); @@ -319,6 +322,19 @@ void cmGlobalXCodeGenerator::SetGenerationRoot(cmLocalGenerator* root) this->CurrentXCodeHackMakefile += "/XCODE_DEPEND_HELPER.make"; } +//---------------------------------------------------------------------------- +std::string +cmGlobalXCodeGenerator::PostBuildMakeTarget(std::string const& tName, + std::string const& configName) +{ + std::string out = "PostBuild." + tName; + if(this->XcodeVersion > 20) + { + out += "." + configName; + } + return out; +} + //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, @@ -348,12 +364,8 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, makecommand.push_back(dir.c_str()); makecommand.push_back("-f"); makecommand.push_back(this->CurrentXCodeHackMakefile.c_str()); - if(this->XcodeVersion > 20) - { - makecommand.push_back("all.$(CONFIGURATION)"); - } - cmCustomCommandLines commandLines; - commandLines.push_back(makecommand); + makecommand.push_back(""); // placeholder, see below + // Add Re-Run CMake rules this->CreateReRunCMakeFile(root, gens); @@ -380,6 +392,10 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY)) { + makecommand[makecommand.size()-1] = + this->PostBuildMakeTarget(target.GetName(), "$(CONFIGURATION)"); + cmCustomCommandLines commandLines; + commandLines.push_back(makecommand); lg->GetMakefile()->AddCustomCommandToTarget(target.GetName(), no_depends, commandLines, @@ -578,6 +594,12 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, } } + if(cmtarget.IsCFBundleOnApple()) + { + cmtarget.SetProperty("PREFIX", ""); + cmtarget.SetProperty("SUFFIX", ""); + } + // Add the fileRef to the top level Resources group/folder if it is not // already there. // @@ -812,6 +834,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // some build phases only apply to bundles and/or frameworks bool isFrameworkTarget = cmtarget.IsFrameworkOnApple(); bool isBundleTarget = cmtarget.GetPropertyAsBool("MACOSX_BUNDLE"); + bool isCFBundleTarget = cmtarget.IsCFBundleOnApple(); cmXCodeObject* buildFiles = 0; @@ -857,7 +880,8 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // create resource build phase - only for framework or bundle targets cmXCodeObject* resourceBuildPhase = 0; - if (!resourceFiles.empty() && (isFrameworkTarget || isBundleTarget)) + if (!resourceFiles.empty() && + (isFrameworkTarget || isBundleTarget || isCFBundleTarget)) { resourceBuildPhase = this->CreateObject(cmXCodeObject::PBXResourcesBuildPhase); @@ -878,7 +902,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, // create vector of "non-resource content file" build phases - only for // framework or bundle targets std::vector contentBuildPhases; - if (isFrameworkTarget || isBundleTarget) + if (isFrameworkTarget || isBundleTarget || isCFBundleTarget) { typedef std::map > mapOfVectorOfSourceFiles; @@ -952,7 +976,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, this->CreateString("0")); } - // create list of build phases and create the XCode target + // create list of build phases and create the Xcode target cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST); @@ -1605,7 +1629,33 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("BUNDLE")); - if(this->XcodeVersion >= 22) + if (target.GetPropertyAsBool("BUNDLE")) + { + // It turns out that a BUNDLE is basically the same + // in many ways as an application bundle, as far as + // link flags go + std::string createFlags = + this->LookupFlags("CMAKE_SHARED_MODULE_CREATE_", lang, "_FLAGS", + "-bundle"); + if(!createFlags.empty()) + { + extraLinkOptions += " "; + extraLinkOptions += createFlags; + } + std::string plist = this->ComputeInfoPListLocation(target); + // Xcode will create the final version of Info.plist at build time, + // so let it replace the cfbundle name. This avoids creating + // a per-configuration Info.plist file. The cfbundle plist + // is very similar to the application bundle plist + this->CurrentLocalGenerator + ->GenerateAppleInfoPList(&target, "$(EXECUTABLE_NAME)", + plist.c_str()); + std::string path = + this->ConvertToRelativeForXCode(plist.c_str()); + buildSettings->AddAttribute("INFOPLIST_FILE", + this->CreateString(path.c_str())); + } + else if(this->XcodeVersion >= 22) { buildSettings->AddAttribute("MACH_O_TYPE", this->CreateString("mh_bundle")); @@ -1644,7 +1694,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string plist = this->ComputeInfoPListLocation(target); // Xcode will create the final version of Info.plist at build time, - // so let it replace the framework name. This avoids creating + // so let it replace the framework name. This avoids creating // a per-configuration Info.plist file. this->CurrentLocalGenerator ->GenerateFrameworkInfoPList(&target, "$(EXECUTABLE_NAME)", @@ -2043,7 +2093,10 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(cmTarget& cmtarget) case cmTarget::STATIC_LIBRARY: return "archive.ar"; case cmTarget::MODULE_LIBRARY: - return ((this->XcodeVersion >= 22)? + if (cmtarget.IsCFBundleOnApple()) + return "wrapper.plug-in"; + else + return ((this->XcodeVersion >= 22)? "compiled.mach-o.executable" : "compiled.mach-o.dylib"); case cmTarget::SHARED_LIBRARY: return (cmtarget.GetPropertyAsBool("FRAMEWORK")? @@ -2063,8 +2116,12 @@ const char* cmGlobalXCodeGenerator::GetTargetProductType(cmTarget& cmtarget) case cmTarget::STATIC_LIBRARY: return "com.apple.product-type.library.static"; case cmTarget::MODULE_LIBRARY: - return ((this->XcodeVersion >= 22)? "com.apple.product-type.tool" : - "com.apple.product-type.library.dynamic"); + if (cmtarget.IsCFBundleOnApple()) + return "com.apple.product-type.bundle"; + else + return ((this->XcodeVersion >= 22)? + "com.apple.product-type.tool" : + "com.apple.product-type.library.dynamic"); case cmTarget::SHARED_LIBRARY: return (cmtarget.GetPropertyAsBool("FRAMEWORK")? "com.apple.product-type.framework" : @@ -2393,6 +2450,10 @@ void cmGlobalXCodeGenerator { linkLibs += li->Value; } + if(li->Target && !li->Target->IsImported()) + { + target->AddDependTarget(configName, li->Target->GetName()); + } } this->AppendBuildSettingAttribute(target, "OTHER_LDFLAGS", linkLibs.c_str(), configName); @@ -2456,62 +2517,119 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, } } +cmXCodeObject *cmGlobalXCodeGenerator +::CreatePBXGroup(cmXCodeObject *parent, cmStdString name) +{ + cmXCodeObject* parentChildren = NULL; + if(parent) + parentChildren = parent->GetObject("children"); + cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup); + cmXCodeObject* groupChildren = + this->CreateObject(cmXCodeObject::OBJECT_LIST); + group->AddAttribute("name", this->CreateString(name.c_str())); + group->AddAttribute("children", groupChildren); + if(this->XcodeVersion == 15) + { + group->AddAttribute("refType", this->CreateString("4")); + } + group->AddAttribute("sourceTree", this->CreateString("")); + if(parentChildren) + parentChildren->AddObject(group); + return group; +} + //---------------------------------------------------------------------------- cmXCodeObject* cmGlobalXCodeGenerator ::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg) { - cmStdString s = cmtarget.GetName(); - s += "/"; - s += sg->GetName(); - std::map::iterator i = + cmStdString s; + cmStdString target; + const char *targetFolder= cmtarget.GetProperty("FOLDER"); + if(targetFolder) { + target = targetFolder; + target += "/"; + } + target += cmtarget.GetName(); + s = target + "/"; + s += sg->GetFullName(); + std::map::iterator it = this->GroupNameMap.find(s); - if(i != this->GroupNameMap.end()) + if(it != this->GroupNameMap.end()) { - return i->second; + return it->second; } - i = this->TargetGroup.find(cmtarget.GetName()); + + it = this->TargetGroup.find(target); cmXCodeObject* tgroup = 0; - if(i != this->TargetGroup.end()) + if(it != this->TargetGroup.end()) { - tgroup = i->second; + tgroup = it->second; } else { - tgroup = this->CreateObject(cmXCodeObject::PBXGroup); - this->TargetGroup[cmtarget.GetName()] = tgroup; - cmXCodeObject* tgroupChildren = - this->CreateObject(cmXCodeObject::OBJECT_LIST); - tgroup->AddAttribute("name", this->CreateString(cmtarget.GetName())); - tgroup->AddAttribute("children", tgroupChildren); - if(this->XcodeVersion == 15) + std::vector tgt_folders = + cmSystemTools::tokenize(target, "/"); + cmStdString curr_tgt_folder; + for(std::vector::size_type i = 0; i < tgt_folders.size();i++) { - tgroup->AddAttribute("refType", this->CreateString("4")); + curr_tgt_folder += tgt_folders[i]; + it = this->TargetGroup.find(curr_tgt_folder); + if(it == this->TargetGroup.end()) + { + tgroup = this->CreatePBXGroup(tgroup,tgt_folders[i]); + this->TargetGroup[curr_tgt_folder] = tgroup; + } + else + { + tgroup = it->second; + continue; + } + if(i == 0) + { + this->SourcesGroupChildren->AddObject(tgroup); + } + curr_tgt_folder += "/"; } - tgroup->AddAttribute("sourceTree", this->CreateString("")); - this->SourcesGroupChildren->AddObject(tgroup); } + this->TargetGroup[target] = tgroup; // If it's the default source group (empty name) then put the source file // directly in the tgroup... // - if (cmStdString(sg->GetName()) == "") + if (cmStdString(sg->GetFullName()) == "") { this->GroupNameMap[s] = tgroup; return tgroup; } - cmXCodeObject* tgroupChildren = tgroup->GetObject("children"); - cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup); - cmXCodeObject* groupChildren = - this->CreateObject(cmXCodeObject::OBJECT_LIST); - group->AddAttribute("name", this->CreateString(sg->GetName())); - group->AddAttribute("children", groupChildren); - if(this->XcodeVersion == 15) + //It's a recursive folder structure, let's find the real parent group + if(std::string(sg->GetFullName()) != std::string(sg->GetName())) { - group->AddAttribute("refType", this->CreateString("4")); + std::vector folders = + cmSystemTools::tokenize(sg->GetFullName(), "\\"); + cmStdString curr_folder = cmtarget.GetName(); + curr_folder += "/"; + for(std::vector::size_type i = 0; i < folders.size();i++) + { + curr_folder += folders[i]; + std::map::iterator i_folder = + this->GroupNameMap.find(curr_folder); + //Create new folder + if(i_folder == this->GroupNameMap.end()) + { + cmXCodeObject *group = this->CreatePBXGroup(tgroup,folders[i]); + this->GroupNameMap[curr_folder] = group; + tgroup = group; + } + else + { + tgroup = i_folder->second; + } + curr_folder = curr_folder + "\\"; + } + return tgroup; } - group->AddAttribute("sourceTree", this->CreateString("")); - tgroupChildren->AddObject(group); + cmXCodeObject *group = this->CreatePBXGroup(tgroup,sg->GetName()); this->GroupNameMap[s] = group; return group; } @@ -2838,41 +2956,10 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( // correctly by xcode makefileStream << "# DO NOT EDIT\n"; makefileStream << "# This makefile makes sure all linkable targets are\n"; - makefileStream << "# up-to-date with anything they link to, avoiding a " - "bug in XCode 1.5\n"; - for(std::vector::const_iterator - ct = this->CurrentConfigurationTypes.begin(); - ct != this->CurrentConfigurationTypes.end(); ++ct) - { - if(this->XcodeVersion < 21 || ct->empty()) - { - makefileStream << "all: "; - } - else - { - makefileStream << "all." << *ct << ": "; - } - const char* configName = 0; - if(!ct->empty()) - { - configName = ct->c_str(); - } - for(std::vector::iterator i = targets.begin(); - i != targets.end(); ++i) - { - cmXCodeObject* target = *i; - cmTarget* t =target->GetTarget(); - if(t->GetType() == cmTarget::EXECUTABLE || - t->GetType() == cmTarget::SHARED_LIBRARY || - t->GetType() == cmTarget::MODULE_LIBRARY) - { - std::string tfull = t->GetFullPath(configName); - makefileStream << "\\\n\t" << - this->ConvertToRelativeForMake(tfull.c_str()); - } - } - makefileStream << "\n\n"; - } + makefileStream << "# up-to-date with anything they link to\n" + "default:\n" + "\techo \"Do not invoke directly\"\n" + "\n"; makefileStream << "# For each target create a dummy rule " "so the target does not have to exist\n"; @@ -2918,14 +3005,40 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( { cmXCodeObject* target = *i; cmTarget* t =target->GetTarget(); + + if(t->GetType() == cmTarget::EXECUTABLE || + t->GetType() == cmTarget::STATIC_LIBRARY || + t->GetType() == cmTarget::SHARED_LIBRARY || + t->GetType() == cmTarget::MODULE_LIBRARY) + { + // Declare an entry point for the target post-build phase. + makefileStream << this->PostBuildMakeTarget(t->GetName(), *ct) + << ":\n"; + } + if(t->GetType() == cmTarget::EXECUTABLE || t->GetType() == cmTarget::SHARED_LIBRARY || t->GetType() == cmTarget::MODULE_LIBRARY) { - // Create a rule for this target. std::string tfull = t->GetFullPath(configName); - makefileStream << this->ConvertToRelativeForMake(tfull.c_str()) - << ":"; + std::string trel = this->ConvertToRelativeForMake(tfull.c_str()); + + // Add this target to the post-build phases of its dependencies. + std::map::const_iterator + y = target->GetDependTargets().find(*ct); + if(y != target->GetDependTargets().end()) + { + std::vector const& deptgts = y->second; + for(std::vector::const_iterator d = deptgts.begin(); + d != deptgts.end(); ++d) + { + makefileStream << this->PostBuildMakeTarget(*d, *ct) << ": " + << trel << "\n"; + } + } + + // Create a rule for this target. + makefileStream << trel << ":"; // List dependencies if any exist. std::map::const_iterator @@ -3068,7 +3181,7 @@ void cmGlobalXCodeGenerator::GetDocumentation(cmDocumentationEntry& entry) const { entry.Name = this->GetName(); - entry.Brief = "Generate XCode project files."; + entry.Brief = "Generate Xcode project files."; entry.Full = ""; } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 290532a9b..39a5fd722 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -88,6 +88,8 @@ public: private: cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg); + cmXCodeObject* CreatePBXGroup(cmXCodeObject *parent, + cmStdString name); void CreateGroups(cmLocalGenerator* root, std::vector& generators); @@ -198,6 +200,8 @@ protected: std::vector XCodeObjects; cmXCodeObject* RootObject; private: + std::string PostBuildMakeTarget(std::string const& tName, + std::string const& configName); cmXCodeObject* MainGroupChildren; cmXCodeObject* SourcesGroupChildren; cmXCodeObject* ResourcesGroupChildren; diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index de95aa593..15bad5265 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -54,6 +54,7 @@ cmGraphVizWriter::cmGraphVizWriter(const std::vector& ,GenerateForStaticLibs(true) ,GenerateForSharedLibs(true) ,GenerateForModuleLibs(true) +,GenerateForExternals(true) ,LocalGenerators(localGenerators) ,HaveTargetsAndLibs(false) { @@ -115,36 +116,85 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName, __set_bool_if_set(this->GenerateForExecutables, "GRAPHVIZ_EXECUTABLES"); __set_bool_if_set(this->GenerateForStaticLibs, "GRAPHVIZ_STATIC_LIBS"); __set_bool_if_set(this->GenerateForSharedLibs, "GRAPHVIZ_SHARED_LIBS"); - __set_bool_if_set(this->GenerateForModuleLibs , "GRAPHVIZ_MODULE_LIBS"); + __set_bool_if_set(this->GenerateForModuleLibs, "GRAPHVIZ_MODULE_LIBS"); + __set_bool_if_set(this->GenerateForExternals, "GRAPHVIZ_EXTERNAL_LIBS"); - cmStdString tmpRegexString; - __set_if_set(tmpRegexString, "GRAPHVIZ_TARGET_IGNORE_REGEX"); - if (tmpRegexString.size() > 0) + cmStdString ignoreTargetsRegexes; + __set_if_set(ignoreTargetsRegexes, "GRAPHVIZ_IGNORE_TARGETS"); + + this->TargetsToIgnoreRegex.clear(); + if (ignoreTargetsRegexes.size() > 0) { - if (!this->TargetIgnoreRegex.compile(tmpRegexString.c_str())) + std::vector ignoreTargetsRegExVector; + cmSystemTools::ExpandListArgument(ignoreTargetsRegexes, + ignoreTargetsRegExVector); + for(std::vector::const_iterator itvIt + = ignoreTargetsRegExVector.begin(); + itvIt != ignoreTargetsRegExVector.end(); + ++ itvIt ) { - std::cerr << "Could not compile bad regex \"" << tmpRegexString << "\"" - << std::endl; + cmStdString currentRegexString(*itvIt); + cmsys::RegularExpression currentRegex; + if (!currentRegex.compile(currentRegexString.c_str())) + { + std::cerr << "Could not compile bad regex \"" << currentRegexString + << "\"" << std::endl; + } + this->TargetsToIgnoreRegex.push_back(currentRegex); } } - this->TargetsToIgnore.clear(); - const char* ignoreTargets = mf->GetDefinition("GRAPHVIZ_IGNORE_TARGETS"); - if ( ignoreTargets ) +} + + +// Iterate over all targets and write for each one a graph which shows +// which other targets depend on it. +void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName) +{ + this->CollectTargetsAndLibs(); + + for(std::map::const_iterator ptrIt = + this->TargetPtrs.begin(); + ptrIt != this->TargetPtrs.end(); + ++ptrIt) { - std::vector ignoreTargetsVector; - cmSystemTools::ExpandListArgument(ignoreTargets,ignoreTargetsVector); - for(std::vector::iterator itvIt = ignoreTargetsVector.begin(); - itvIt != ignoreTargetsVector.end(); - ++ itvIt ) + if (ptrIt->second == NULL) { - this->TargetsToIgnore.insert(itvIt->c_str()); + continue; + } + + if (this->GenerateForTargetType(ptrIt->second->GetType()) == false) + { + continue; } - } + std::string currentFilename = fileName; + currentFilename += "."; + currentFilename += ptrIt->first; + currentFilename += ".dependers"; + + cmGeneratedFileStream str(currentFilename.c_str()); + if ( !str ) + { + return; + } + + std::set insertedConnections; + std::set insertedNodes; + + std::cout << "Writing " << currentFilename << "..." << std::endl; + this->WriteHeader(str); + + this->WriteDependerConnections(ptrIt->first.c_str(), + insertedNodes, insertedConnections, str); + + this->WriteFooter(str); + } } +// Iterate over all targets and write for each one a graph which shows +// on which targets it depends. void cmGraphVizWriter::WritePerTargetFiles(const char* fileName) { this->CollectTargetsAndLibs(); @@ -297,6 +347,91 @@ void cmGraphVizWriter::WriteConnections(const char* targetName, } +void cmGraphVizWriter::WriteDependerConnections(const char* targetName, + std::set& insertedNodes, + std::set& insertedConnections, + cmGeneratedFileStream& str) const +{ + std::map::const_iterator targetPtrIt = + this->TargetPtrs.find(targetName); + + if (targetPtrIt == this->TargetPtrs.end()) // not found at all + { + return; + } + + this->WriteNode(targetName, targetPtrIt->second, insertedNodes, str); + + if (targetPtrIt->second == NULL) // it's an external library + { + return; + } + + + std::string myNodeName = this->TargetNamesNodes.find(targetName)->second; + + // now search who links against me + for(std::map::const_iterator dependerIt = + this->TargetPtrs.begin(); + dependerIt != this->TargetPtrs.end(); + ++dependerIt) + { + if (dependerIt->second == NULL) + { + continue; + } + + if (this->GenerateForTargetType(dependerIt->second->GetType()) == false) + { + continue; + } + + // Now we have a target, check whether it links against targetName. + // If so, draw a connection, and then continue with dependers on that one. + const cmTarget::LinkLibraryVectorType* ll = + &(dependerIt->second->GetOriginalLinkLibraries()); + + for (cmTarget::LinkLibraryVectorType::const_iterator llit = ll->begin(); + llit != ll->end(); + ++ llit ) + { + std::string libName = llit->first.c_str(); + if (libName == targetName) + { + // So this target links against targetName. + std::map::const_iterator dependerNodeNameIt = + this->TargetNamesNodes.find(dependerIt->first); + + if(dependerNodeNameIt != this->TargetNamesNodes.end()) + { + std::string connectionName = dependerNodeNameIt->second; + connectionName += "-"; + connectionName += myNodeName; + + if (insertedConnections.find(connectionName) == + insertedConnections.end()) + { + insertedConnections.insert(connectionName); + this->WriteNode(dependerIt->first.c_str(), dependerIt->second, + insertedNodes, str); + + str << " \"" << dependerNodeNameIt->second << "\" -> \"" + << myNodeName << "\""; + str << " // " < " <first<WriteDependerConnections(dependerIt->first.c_str(), + insertedNodes, insertedConnections, str); + } + + + } + break; + } + } + } + +} + + void cmGraphVizWriter::WriteNode(const char* targetName, const cmTarget* target, std::set& insertedNodes, @@ -321,7 +456,10 @@ void cmGraphVizWriter::CollectTargetsAndLibs() { this->HaveTargetsAndLibs = true; int cnt = this->CollectAllTargets(); - this->CollectAllExternalLibs(cnt); + if (this->GenerateForExternals) + { + this->CollectAllExternalLibs(cnt); + } } } @@ -410,14 +548,22 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt) bool cmGraphVizWriter::IgnoreThisTarget(const char* name) { - if (this->TargetIgnoreRegex.is_valid()) + for(std::vector::iterator itvIt + = this->TargetsToIgnoreRegex.begin(); + itvIt != this->TargetsToIgnoreRegex.end(); + ++ itvIt ) { - if (this->TargetIgnoreRegex.find(name)) + cmsys::RegularExpression& regEx = *itvIt; + if (regEx.is_valid()) { - return true; + if (regEx.find(name)) + { + return true; + } } } - return (this->TargetsToIgnore.find(name) != this->TargetsToIgnore.end()); + + return false; } diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index 105eb9635..f784aa0a1 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -30,6 +30,7 @@ public: const char* fallbackSettingsFileName); void WritePerTargetFiles(const char* fileName); + void WriteTargetDependersFiles(const char* fileName); void WriteGlobalFile(const char* fileName); @@ -48,6 +49,11 @@ protected: std::set& insertedConnections, cmGeneratedFileStream& str) const; + void WriteDependerConnections(const char* targetName, + std::set& insertedNodes, + std::set& insertedConnections, + cmGeneratedFileStream& str) const; + void WriteNode(const char* targetName, const cmTarget* target, std::set& insertedNodes, cmGeneratedFileStream& str) const; @@ -67,10 +73,9 @@ protected: bool GenerateForStaticLibs; bool GenerateForSharedLibs; bool GenerateForModuleLibs; + bool GenerateForExternals; - cmsys::RegularExpression TargetIgnoreRegex; - - std::set TargetsToIgnore; + std::vector TargetsToIgnoreRegex; const std::vector& LocalGenerators; diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index 7acb0f0c8..d9c0e87e9 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -171,3 +171,9 @@ void cmIDEOptions::AddFlag(const char* flag, const char* value) { this->FlagMap[flag] = value; } + +//---------------------------------------------------------------------------- +void cmIDEOptions::RemoveFlag(const char* flag) +{ + this->FlagMap.erase(flag); +} diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index a156b23a9..a5be8fbd5 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -28,6 +28,7 @@ public: void AddDefine(const std::string& define); void AddDefines(const char* defines); void AddFlag(const char* flag, const char* value); + void RemoveFlag(const char* flag); protected: // create a map of xml tags to the values they should have in the output diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h index d00f84345..3b35d55de 100644 --- a/Source/cmIncludeDirectoryCommand.h +++ b/Source/cmIncludeDirectoryCommand.h @@ -61,7 +61,7 @@ public: "Add the given directories to those searched by the compiler for " "include files. By default the directories are appended onto " "the current list of directories. This default behavior can be " - "changed by setting CMAKE_include_directories_BEFORE to ON. " + "changed by setting CMAKE_INCLUDE_DIRECTORIES_BEFORE to ON. " "By using BEFORE or AFTER you can select between appending and " "prepending, independent from the default. " "If the SYSTEM option is given the compiler will be told that the " diff --git a/Source/cmListCommand.h b/Source/cmListCommand.h index 7f229faf0..d2152957f 100644 --- a/Source/cmListCommand.h +++ b/Source/cmListCommand.h @@ -83,6 +83,14 @@ public: "REMOVE_DUPLICATES will remove duplicated items in the list.\n" "REVERSE reverses the contents of the list in-place.\n" "SORT sorts the list in-place alphabetically.\n" + "The list subcommands APPEND, INSERT, REMOVE_AT, REMOVE_ITEM, " + "REMOVE_DUPLICATES, REVERSE and SORT may create new values for " + "the list within the current CMake variable scope. Similar to " + "the SET command, the LIST command creates new variable values " + "in the current scope, even if the list itself is actually " + "defined in a parent scope. To propagate the results of these " + "operations upwards, use SET with PARENT_SCOPE, SET with CACHE " + "INTERNAL, or some other means of value propagation.\n" "NOTES: A list in cmake is a ; separated group of strings. " "To create a list the set command can be used. For example, " "set(var a b c d e) creates a list with a;b;c;d;e, and " diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index d3cbc1ff7..7da35eb26 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -575,6 +575,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, flags += this->Makefile->GetSafeDefinition(varString.c_str()); flags += " "; flags += this->GetIncludeFlags(lang); + flags += this->Makefile->GetDefineFlags(); // Construct the command lines. cmCustomCommandLines commandLines; @@ -1184,15 +1185,18 @@ cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote, } //---------------------------------------------------------------------------- -const char* cmLocalGenerator::GetIncludeFlags(const char* lang) +const char* cmLocalGenerator::GetIncludeFlags(const char* lang, + bool forResponseFile) { if(!lang) { return ""; } - if(this->LanguageToIncludeFlags.count(lang)) + std::string key = lang; + key += forResponseFile? "@" : ""; + if(this->LanguageToIncludeFlags.count(key)) { - return this->LanguageToIncludeFlags[lang].c_str(); + return this->LanguageToIncludeFlags[key].c_str(); } cmOStringStream includeFlags; @@ -1250,10 +1254,10 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang) frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str()); if(emitted.insert(frameworkDir).second) { + OutputFormat format = forResponseFile? RESPONSE : SHELL; includeFlags << "-F" << this->Convert(frameworkDir.c_str(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL, true) + START_OUTPUT, format, true) << " "; } continue; @@ -1273,7 +1277,16 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang) } flagUsed = true; } - std::string includePath = this->ConvertToOutputForExisting(i->c_str()); + std::string includePath; + if(forResponseFile) + { + includePath = this->Convert(i->c_str(), START_OUTPUT, + RESPONSE, true); + } + else + { + includePath = this->ConvertToOutputForExisting(i->c_str()); + } if(quotePaths && includePath.size() && includePath[0] != '\"') { includeFlags << "\""; @@ -1291,13 +1304,11 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang) { flags[flags.size()-1] = ' '; } - std::string defineFlags = this->Makefile->GetDefineFlags(); - flags += defineFlags; - this->LanguageToIncludeFlags[lang] = flags; + this->LanguageToIncludeFlags[key] = flags; // Use this temorary variable for the return value to work-around a // bogus GCC 2.95 warning. - const char* ret = this->LanguageToIncludeFlags[lang].c_str(); + const char* ret = this->LanguageToIncludeFlags[key].c_str(); return ret; } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 35aab99ec..aebf9f39a 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -143,7 +143,8 @@ public: const char* config); virtual void AppendFlags(std::string& flags, const char* newFlags); ///! Get the include flags for the current makefile and language - const char* GetIncludeFlags(const char* lang); + const char* GetIncludeFlags(const char* lang, + bool forResponseFile = false); /** * Encode a list of preprocessor definitions for the compiler diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index ff48009ba..5c2cda183 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -880,6 +880,20 @@ cmLocalUnixMakefileGenerator3 } } +//---------------------------------------------------------------------------- +void +cmLocalUnixMakefileGenerator3 +::AppendRuleDepends(std::vector& depends, + std::vector const& ruleFiles) +{ + // Add a dependency on the rule file itself unless an option to skip + // it is specifically enabled by the user or project. + if(!this->Makefile->IsOn("CMAKE_SKIP_RULE_DEPENDENCY")) + { + depends.insert(depends.end(), ruleFiles.begin(), ruleFiles.end()); + } +} + //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 @@ -2214,17 +2228,23 @@ void cmLocalUnixMakefileGenerator3 return; } + // In a Windows shell we must change drive letter too. The shell + // used by NMake and Borland make does not support "cd /d" so this + // feature simply cannot work with them (Borland make does not even + // support changing the drive letter with just "d:"). + const char* cd_cmd = this->MinGWMake? "cd /d " : "cd "; + if(!this->UnixCD) { // On Windows we must perform each step separately and then change // back because the shell keeps the working directory between // commands. - std::string cmd = "cd "; + std::string cmd = cd_cmd; cmd += this->ConvertToOutputForExisting(tgtDir, relRetDir); commands.insert(commands.begin(),cmd); // Change back to the starting directory. - cmd = "cd "; + cmd = cd_cmd; cmd += this->ConvertToOutputForExisting(relRetDir, tgtDir); commands.push_back(cmd); } @@ -2236,7 +2256,7 @@ void cmLocalUnixMakefileGenerator3 std::vector::iterator i = commands.begin(); for (; i != commands.end(); ++i) { - std::string cmd = "cd "; + std::string cmd = cd_cmd; cmd += this->ConvertToOutputForExisting(tgtDir, relRetDir); cmd += " && "; cmd += *i; diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 790eff10c..9ff6e5e51 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -320,6 +320,8 @@ protected: void AppendRuleDepend(std::vector& depends, const char* ruleFileName); + void AppendRuleDepends(std::vector& depends, + std::vector const& ruleFiles); void AppendCustomDepends(std::vector& depends, const std::vector& ccs); void AppendCustomDepend(std::vector& depends, diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index de2a83725..1850c1688 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -119,7 +119,7 @@ void cmLocalVisualStudio10Generator } //---------------------------------------------------------------------------- -std::string cmLocalVisualStudio10Generator::CheckForErrorLine() +const char* cmLocalVisualStudio10Generator::ReportErrorLabel() const { - return "if errorlevel 1 goto :VCEnd"; + return ":VCEnd"; } diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index 06b8b0939..0fccdb071 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -38,7 +38,8 @@ public: const char* path); protected: - virtual std::string CheckForErrorLine(); + virtual const char* ReportErrorLabel() const; + virtual bool CustomCommandUseLocal() const { return true; } private: }; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 7aabf4d99..095e1a796 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -863,7 +863,7 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target, event.Write(target.GetPreBuildCommands()); event.Write(target.GetPreLinkCommands()); cmsys::auto_ptr pcc( - this->MaybeCreateImplibDir(target, configName)); + this->MaybeCreateImplibDir(target, configName, false)); if(pcc.get()) { event.Write(*pcc); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index e839ed350..7a62b9cb1 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -381,6 +381,11 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = "Use sse2 instructions", "2", 0}, {"EnableEnhancedInstructionSet", "arch:SSE", "Use sse instructions", "1", 0}, + {"FloatingPointModel", "fp:precise", + "Use precise floating point model", "0", 0}, + {"FloatingPointModel", "fp:strict", + "Use strict floating point model", "1", 0}, + {"FloatingPointModel", "fp:fast", "Use fast floating point model", "2", 0}, {"FavorSizeOrSpeed", "Ot", "Favor fast code", "1", 0}, {"FavorSizeOrSpeed", "Os", "Favor small code", "2", 0}, {"CompileAs", "TC", "Compile as c code", "1", 0}, @@ -451,8 +456,13 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = "Turn off Run time type information for c++", "FALSE", 0}, {"SmallerTypeCheck", "RTCc", "smaller type check", "TRUE", 0}, {"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "TRUE", 0}, + {"WholeProgramOptimization", "GL", + "Enables whole program optimization", "TRUE", 0}, + {"WholeProgramOptimization", "GL-", + "Disables whole program optimization", "FALSE", 0}, {"WarnAsError", "WX", "Treat warnings as errors", "TRUE", 0}, {"BrowseInformation", "FR", "Generate browse information", "1", 0}, + {"StringPooling", "GF", "Enable StringPooling", "TRUE", 0}, {0,0,0,0,0} }; @@ -466,6 +476,14 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = {"GenerateManifest", "MANIFEST", "enable manifest generation", "TRUE", 0}, {"LinkIncremental", "INCREMENTAL:NO", "link incremental", "1", 0}, {"LinkIncremental", "INCREMENTAL:YES", "link incremental", "2", 0}, + {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0}, + {"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0}, + {"DataExecutionPrevention", "NXCOMPAT:NO", + "Not known to work with Windows Data Execution Prevention", "1", 0}, + {"DataExecutionPrevention", "NXCOMPAT", + "Known to work with Windows Data Execution Prevention", "2", 0}, + {"DelaySign", "DELAYSIGN:NO", "", "false", 0}, + {"DelaySign", "DELAYSIGN", "", "true", 0}, {"EntryPointSymbol", "ENTRY:", "sets the starting address", "", cmVS7FlagTable::UserValue}, {"IgnoreDefaultLibraryNames", "NODEFAULTLIB:", "default libs to ignore", "", @@ -478,8 +496,16 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = {"EnableCOMDATFolding", "OPT:NOICF", "Do not remove redundant COMDATs", "1", 0}, {"EnableCOMDATFolding", "OPT:ICF", "Remove redundant COMDATs", "2", 0}, + {"ResourceOnlyDLL", "NOENTRY", "Create DLL with no entry point", "true", 0}, {"OptimizeReferences", "OPT:NOREF", "Keep unreferenced data", "1", 0}, {"OptimizeReferences", "OPT:REF", "Eliminate unreferenced data", "2", 0}, + {"Profile", "PROFILE", "", "true", 0}, + {"RandomizedBaseAddress", "DYNAMICBASE:NO", + "Image may not be rebased at load-time", "1", 0}, + {"RandomizedBaseAddress", "DYNAMICBASE", + "Image may be rebased at load-time", "2", 0}, + {"SetChecksum", "RELEASE", "Enable setting checksum in header", "true", 0}, + {"SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0}, {"TargetMachine", "MACHINE:I386", "Machine x86", "1", 0}, {"TargetMachine", "MACHINE:X86", "Machine x86", "1", 0}, {"TargetMachine", "MACHINE:AM33", "Machine AM33", "2", 0}, @@ -498,6 +524,8 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = {"TargetMachine", "MACHINE:SH5", "Machine SH5", "15", 0}, {"TargetMachine", "MACHINE:THUMB", "Machine THUMB", "16", 0}, {"TargetMachine", "MACHINE:X64", "Machine x64", "17", 0}, + {"TurnOffAssemblyGeneration", "NOASSEMBLY", + "No assembly even if CLR information is present in objects.", "true", 0}, {"ModuleDefinitionFile", "DEF:", "add an export def file", "", cmVS7FlagTable::UserValue}, {"GenerateMapFile", "MAP", "enable generation of map file", "TRUE", 0}, @@ -1695,7 +1723,7 @@ void cmLocalVisualStudio7Generator event.Start(tool); event.Write(target.GetPreLinkCommands()); cmsys::auto_ptr pcc( - this->MaybeCreateImplibDir(target, configName)); + this->MaybeCreateImplibDir(target, configName, this->FortranProject)); if(pcc.get()) { event.Write(*pcc); @@ -1742,10 +1770,14 @@ cmLocalVisualStudio7Generator vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion"; cmSystemTools::ReadRegistryValue(vskey.c_str(), intelVersion, cmSystemTools::KeyWOW64_32); - - // Version 10.1 actually uses 9.10 in project files! - if(intelVersion == "10.1") + if (intelVersion == "12.0") + { + // Version 12 actually uses 11.0 in project files! + intelVersion = "11.0" ; + } + else if(intelVersion == "10.1") { + // Version 10.1 actually uses 9.10 in project files! intelVersion = "9.10"; } diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 9164beb1c..4390a08a7 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -32,13 +32,17 @@ cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator() //---------------------------------------------------------------------------- cmsys::auto_ptr cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target, - const char* config) + const char* config, + bool isFortran) { cmsys::auto_ptr pcc; // If an executable exports symbols then VS wants to create an // import library but forgets to create the output directory. - if(target.GetType() != cmTarget::EXECUTABLE) { return pcc; } + // The Intel Fortran plugin always forgets to the directory. + if(target.GetType() != cmTarget::EXECUTABLE && + !(isFortran && target.GetType() == cmTarget::SHARED_LIBRARY)) + { return pcc; } std::string outDir = target.GetDirectory(config, false); std::string impDir = target.GetDirectory(config, true); if(impDir == outDir) { return pcc; } @@ -150,15 +154,15 @@ void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements } //---------------------------------------------------------------------------- -std::string cmLocalVisualStudioGenerator::CheckForErrorLine() +const char* cmLocalVisualStudioGenerator::ReportErrorLabel() const { - return "if errorlevel 1 goto :VCReportError"; + return ":VCReportError"; } //---------------------------------------------------------------------------- -std::string cmLocalVisualStudioGenerator::GetCheckForErrorLine() +const char* cmLocalVisualStudioGenerator::GetReportErrorLabel() const { - return this->CheckForErrorLine(); + return this->ReportErrorLabel(); } //---------------------------------------------------------------------------- @@ -168,6 +172,7 @@ cmLocalVisualStudioGenerator const char* configName, const char* newline_text) { + bool useLocal = this->CustomCommandUseLocal(); const cmCustomCommandLines& commandLines = cc.GetCommandLines(); const char* workingDirectory = cc.GetWorkingDirectory(); cmCustomCommandGenerator ccg(cc, configName, this->Makefile); @@ -176,8 +181,29 @@ cmLocalVisualStudioGenerator // Avoid leading or trailing newlines. const char* newline = ""; + // Line to check for error between commands. + std::string check_error = newline_text; + if(useLocal) + { + check_error += "if %errorlevel% neq 0 goto :cmEnd"; + } + else + { + check_error += "if errorlevel 1 goto "; + check_error += this->GetReportErrorLabel(); + } + // Store the script in a string. std::string script; + + // Open a local context. + if(useLocal) + { + script += newline; + newline = newline_text; + script += "setlocal"; + } + if(workingDirectory) { // Change the working directory. @@ -185,6 +211,7 @@ cmLocalVisualStudioGenerator newline = newline_text; script += "cd "; script += this->Convert(workingDirectory, FULL, SHELL); + script += check_error; // Change the working drive. if(workingDirectory[0] && workingDirectory[1] == ':') @@ -193,8 +220,10 @@ cmLocalVisualStudioGenerator newline = newline_text; script += workingDirectory[0]; script += workingDirectory[1]; + script += check_error; } } + // for visual studio IDE add extra stuff to the PATH // if CMAKE_MSVCIDE_RUN_PATH is set. if(this->Makefile->GetDefinition("MSVC_IDE")) @@ -210,6 +239,7 @@ cmLocalVisualStudioGenerator script += ";%PATH%"; } } + // Write each command on a single line. for(unsigned int c = 0; c < ccg.GetNumberOfCommands(); ++c) { @@ -226,9 +256,25 @@ cmLocalVisualStudioGenerator // If there was an error, jump to the VCReportError label, // skipping the run of any subsequent commands in this // sequence. - // - script += newline_text; - script += this->GetCheckForErrorLine(); + script += check_error; + } + + // Close the local context. + if(useLocal) + { + script += newline; + script += ":cmEnd"; + script += newline; + script += "endlocal & call :cmErrorLevel %errorlevel% & goto :cmDone"; + script += newline; + script += ":cmErrorLevel"; + script += newline; + script += "exit /b %1"; + script += newline; + script += ":cmDone"; + script += newline; + script += "if %errorlevel% neq 0 goto "; + script += this->GetReportErrorLabel(); } return script; diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 1954ac5f3..a38bc30bf 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -37,17 +37,17 @@ public: const char* configName, const char* newline = "\n"); - /** Line of batch file text that skips to the end after - * a failed step in a sequence of custom commands. - */ - std::string GetCheckForErrorLine(); + /** Label to which to jump in a batch file after a failed step in a + sequence of custom commands. */ + const char* GetReportErrorLabel() const; protected: - virtual std::string CheckForErrorLine(); + virtual const char* ReportErrorLabel() const; + virtual bool CustomCommandUseLocal() const { return false; } /** Construct a custom command to make exe import lib dir. */ cmsys::auto_ptr - MaybeCreateImplibDir(cmTarget& target, const char* config); + MaybeCreateImplibDir(cmTarget& target, const char* config, bool isFortran); // Safe object file name generation. void ComputeObjectNameRequirements(std::vector const&); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index e14e44d54..63bf03bdd 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -893,6 +893,20 @@ cmMakefile::AddCustomCommandToOutput(const std::vector& outputs, return; } + // Validate custom commands. TODO: More strict? + for(cmCustomCommandLines::const_iterator i=commandLines.begin(); + i != commandLines.end(); ++i) + { + cmCustomCommandLine const& cl = *i; + if(!cl.empty() && !cl[0].empty() && cl[0][0] == '"') + { + cmOStringStream e; + e << "COMMAND may not contain literal quotes:\n " << cl[0] << "\n"; + this->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + } + // Choose a source file on which to store the custom command. cmSourceFile* file = 0; if(main_dependency && main_dependency[0]) @@ -2744,6 +2758,27 @@ void cmMakefile::SetHomeOutputDirectory(const char* lib) } } +void cmMakefile::SetScriptModeFile(const char* scriptfile) +{ + this->AddDefinition("CMAKE_SCRIPT_MODE_FILE", scriptfile); +} + +void cmMakefile::SetArgcArgv(const std::vector& args) +{ + cmOStringStream strStream; + strStream << args.size(); + this->AddDefinition("CMAKE_ARGC", strStream.str().c_str()); + //this->MarkVariableAsUsed("CMAKE_ARGC"); + + for (unsigned int t = 0; t < args.size(); ++t) + { + cmOStringStream tmpStream; + tmpStream << "CMAKE_ARGV" << t; + this->AddDefinition(tmpStream.str().c_str(), args[t].c_str()); + //this->MarkVariableAsUsed(tmpStream.str().c_str()); + } +} + //---------------------------------------------------------------------------- cmSourceFile* cmMakefile::GetSource(const char* sourceName) { diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 837a352a3..1c1aef3c0 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -411,7 +411,17 @@ public: return this->HomeOutputDirectory.c_str(); } //@} - + + /** + * Set CMAKE_SCRIPT_MODE_FILE variable when running a -P script. + */ + void SetScriptModeFile(const char* scriptfile); + + /** + * Set CMAKE_ARGC, CMAKE_ARGV0 ... variables. + */ + void SetArgcArgv(const std::vector& args); + //@{ /** * Set/Get the start directory (or output directory). The start directory diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 4426241c5..cd75d7977 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -47,12 +47,12 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles() // write rules used to help build object files this->WriteCommonCodeRules(); - // write in rules for object files and custom commands - this->WriteTargetBuildRules(); - // write the per-target per-language flags this->WriteTargetLanguageFlags(); + // write in rules for object files and custom commands + this->WriteTargetBuildRules(); + // write the link rules this->WriteExecutableRule(false); if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 049a338c9..31f7be5cf 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -26,6 +26,12 @@ cmMakefileLibraryTargetGenerator ::cmMakefileLibraryTargetGenerator(cmTarget* target): cmMakefileTargetGenerator(target) { + if(this->Target->IsCFBundleOnApple()) + { + target->SetProperty("PREFIX", ""); + target->SetProperty("SUFFIX", ""); + } + this->CustomCommandDriver = OnDepends; this->Target->GetLibraryNames( this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, @@ -41,6 +47,20 @@ cmMakefileLibraryTargetGenerator this->MacContentDirectory += this->FrameworkVersion; this->MacContentDirectory += "/"; } + else if(this->Target->IsCFBundleOnApple()) + { + this->MacContentDirectory = this->Target->GetDirectory(this->ConfigName); + this->MacContentDirectory += "/"; + this->MacContentDirectory += this->TargetNameOut; + this->MacContentDirectory += "."; + const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + ext = "bundle"; + } + this->MacContentDirectory += ext; + this->MacContentDirectory += "/Contents/"; + } } //---------------------------------------------------------------------------- @@ -52,12 +72,12 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() // write rules used to help build object files this->WriteCommonCodeRules(); - // write in rules for object files and custom commands - this->WriteTargetBuildRules(); - // write the per-target per-language flags this->WriteTargetLanguageFlags(); + // write in rules for object files and custom commands + this->WriteTargetBuildRules(); + // write the link rules // Write the rule for this target type. switch(this->Target->GetType()) @@ -300,6 +320,27 @@ cmMakefileLibraryTargetGenerator } } +//---------------------------------------------------------------------------- +void +cmMakefileLibraryTargetGenerator::CreateCFBundle(std::string& targetName, + std::string& outpath) +{ + // Compute bundle directory names. + outpath = this->MacContentDirectory; + outpath += "MacOS"; + cmSystemTools::MakeDirectory(outpath.c_str()); + this->Makefile->AddCMakeOutputFile(outpath.c_str()); + outpath += "/"; + + // Configure the Info.plist file. Note that it needs the executable name + // to be set. + std::string plist = this->MacContentDirectory + "Info.plist"; + this->LocalGenerator->GenerateAppleInfoPList(this->Target, + targetName.c_str(), + plist.c_str()); + this->Makefile->AddCMakeOutputFile(plist.c_str()); +} + //---------------------------------------------------------------------------- void cmMakefileLibraryTargetGenerator::WriteLibraryRules (const char* linkRuleVar, const char* extraFlags, bool relink) @@ -354,6 +395,12 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules outpath = this->MacContentDirectory; this->CreateFramework(targetName); } + else if(this->Target->IsCFBundleOnApple()) + { + outpath = this->Target->GetDirectory(this->ConfigName); + outpath += "/"; + this->CreateCFBundle(targetName, outpath); + } else if(relink) { outpath = this->Makefile->GetStartOutputDirectory(); @@ -417,6 +464,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules buildEcho += " shared library "; break; case cmTarget::MODULE_LIBRARY: + if (this->Target->IsCFBundleOnApple()) + buildEcho += " CFBundle"; buildEcho += " shared module "; break; default: diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h index 2f085adb9..f3c47dbfd 100644 --- a/Source/cmMakefileLibraryTargetGenerator.h +++ b/Source/cmMakefileLibraryTargetGenerator.h @@ -33,6 +33,7 @@ protected: // MacOSX Framework support methods void WriteFrameworkRules(bool relink); void CreateFramework(std::string const& targetName); + void CreateCFBundle(std::string& targetName, std::string& outpath); // Store the computd framework version for OS X Frameworks. std::string FrameworkVersion; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 9dcd8f18e..d0df8f076 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -249,32 +249,56 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules() } //---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::WriteTargetLanguageFlags() +std::string cmMakefileTargetGenerator::GetFlags(const std::string &l) { - // write language flags for target - std::set languages; - this->Target->GetLanguages(languages); - // put the compiler in the rules.make file so that if it changes - // things rebuild - for(std::set::const_iterator l = languages.begin(); - l != languages.end(); ++l) - { - cmStdString compiler = "CMAKE_"; - compiler += *l; - compiler += "_COMPILER"; - *this->FlagFileStream << "# compile " << l->c_str() << " with " << - this->Makefile->GetSafeDefinition(compiler.c_str()) << "\n"; - } - - for(std::set::const_iterator l = languages.begin(); - l != languages.end(); ++l) + ByLanguageMap::iterator i = this->FlagsByLanguage.find(l); + if (i == this->FlagsByLanguage.end()) { - const char *lang = l->c_str(); std::string flags; - std::string defines; + const char *lang = l.c_str(); + bool shared = ((this->Target->GetType() == cmTarget::SHARED_LIBRARY) || (this->Target->GetType() == cmTarget::MODULE_LIBRARY)); + // Add language feature flags. + this->AddFeatureFlags(flags, lang); + + this->LocalGenerator->AddArchitectureFlags(flags, this->Target, + lang, this->ConfigName); + + // Fortran-specific flags computed for this target. + if(l == "Fortran") + { + this->AddFortranFlags(flags); + } + + // Add shared-library flags if needed. + this->LocalGenerator->AddSharedFlags(flags, lang, shared); + + // Add include directory flags. + this->AddIncludeFlags(flags, lang); + + // Append old-style preprocessor definition flags. + this->LocalGenerator-> + AppendFlags(flags, this->Makefile->GetDefineFlags()); + + // Add include directory flags. + this->LocalGenerator-> + AppendFlags(flags,this->GetFrameworkFlags().c_str()); + + ByLanguageMap::value_type entry(l, flags); + i = this->FlagsByLanguage.insert(entry).first; + } + return i->second; +} + +std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) +{ + ByLanguageMap::iterator i = this->DefinesByLanguage.find(l); + if (i == this->DefinesByLanguage.end()) + { + std::string defines; + const char *lang = l.c_str(); // Add the export symbol definition for shared library objects. if(const char* exportMacro = this->Target->GetExportMacro()) { @@ -294,36 +318,41 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() this->LocalGenerator->AppendDefines (defines, this->Target->GetProperty(defPropName.c_str()), lang); - // Add language feature flags. - this->AddFeatureFlags(flags, lang); - - this->LocalGenerator->AddArchitectureFlags(flags, this->Target, - lang, this->ConfigName); - - // Fortran-specific flags computed for this target. - if(*l == "Fortran") - { - this->AddFortranFlags(flags); - } - - // Add shared-library flags if needed. - this->LocalGenerator->AddSharedFlags(flags, lang, shared); + ByLanguageMap::value_type entry(l, defines); + i = this->DefinesByLanguage.insert(entry).first; + } + return i->second; +} - // Add include directory flags. - this->LocalGenerator-> - AppendFlags(flags, this->LocalGenerator->GetIncludeFlags(lang)); - // Add include directory flags. - this->LocalGenerator-> - AppendFlags(flags,this->GetFrameworkFlags().c_str()); +void cmMakefileTargetGenerator::WriteTargetLanguageFlags() +{ + // write language flags for target + std::set languages; + this->Target->GetLanguages(languages); + // put the compiler in the rules.make file so that if it changes + // things rebuild + for(std::set::const_iterator l = languages.begin(); + l != languages.end(); ++l) + { + cmStdString compiler = "CMAKE_"; + compiler += *l; + compiler += "_COMPILER"; + *this->FlagFileStream << "# compile " << l->c_str() << " with " << + this->Makefile->GetSafeDefinition(compiler.c_str()) << "\n"; + } - *this->FlagFileStream << lang << "_FLAGS = " << flags << "\n\n"; - *this->FlagFileStream << lang << "_DEFINES = " << defines << "\n\n"; + for(std::set::const_iterator l = languages.begin(); + l != languages.end(); ++l) + { + *this->FlagFileStream << *l << "_FLAGS = " << this->GetFlags(*l) << "\n\n"; + *this->FlagFileStream << *l << "_DEFINES = " << this->GetDefines(*l) << + "\n\n"; } // Add target-specific flags. if(this->Target->GetProperty("COMPILE_FLAGS")) { - std::string flags; + std::string flags; this->LocalGenerator->AppendFlags (flags, this->Target->GetProperty("COMPILE_FLAGS")); *this->FlagFileStream << "# TARGET_FLAGS = " << flags << "\n\n"; @@ -482,6 +511,8 @@ cmMakefileTargetGenerator { this->LocalGenerator->AppendRuleDepend(depends, this->FlagFileNameFull.c_str()); + this->LocalGenerator->AppendRuleDepends(depends, + this->FlagFileDepends[lang]); // generate the depend scanning rule this->WriteObjectDependRules(source, depends); @@ -635,6 +666,9 @@ cmMakefileTargetGenerator vars.Flags = flags.c_str(); vars.Defines = defines.c_str(); + bool lang_is_c_or_cxx = ((strcmp(lang, "C") == 0) || + (strcmp(lang, "CXX") == 0)); + // Construct the compile rules. { std::string compileRuleVar = "CMAKE_"; @@ -645,6 +679,23 @@ cmMakefileTargetGenerator std::vector compileCommands; cmSystemTools::ExpandListArgument(compileRule, compileCommands); + if (this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS") && + lang_is_c_or_cxx && compileCommands.size() == 1) + { + std::string compileCommand = compileCommands[0]; + this->LocalGenerator->ExpandRuleVariables(compileCommand, vars); + std::string workingDirectory = + this->LocalGenerator->Convert( + this->Makefile->GetStartOutputDirectory(), cmLocalGenerator::FULL); + compileCommand.replace(compileCommand.find(langFlags), + langFlags.size(), this->GetFlags(lang)); + std::string langDefines = std::string("$(") + lang + "_DEFINES)"; + compileCommand.replace(compileCommand.find(langDefines), + langDefines.size(), this->GetDefines(lang)); + this->GlobalGenerator->AddCXXCompileCommand( + source.GetFullPath(), workingDirectory, compileCommand); + } + // Expand placeholders in the commands. for(std::vector::iterator i = compileCommands.begin(); i != compileCommands.end(); ++i) @@ -685,8 +736,6 @@ cmMakefileTargetGenerator } } - bool lang_is_c_or_cxx = ((strcmp(lang, "C") == 0) || - (strcmp(lang, "CXX") == 0)); bool do_preprocess_rules = lang_is_c_or_cxx && this->LocalGenerator->GetCreatePreprocessedSourceRules(); bool do_assembly_rules = lang_is_c_or_cxx && @@ -1719,6 +1768,38 @@ cmMakefileTargetGenerator } } +//---------------------------------------------------------------------------- +void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, + const char* lang) +{ + std::string responseVar = "CMAKE_"; + responseVar += lang; + responseVar += "_USE_RESPONSE_FILE_FOR_INCLUDES"; + bool useResponseFile = this->Makefile->IsOn(responseVar.c_str()); + + std::string includeFlags = + this->LocalGenerator->GetIncludeFlags(lang, useResponseFile); + if(includeFlags.empty()) + { + return; + } + + if(useResponseFile) + { + std::string name = "includes_"; + name += lang; + name += ".rsp"; + std::string arg = "@" + + this->CreateResponseFile(name.c_str(), includeFlags, + this->FlagFileDepends[lang]); + this->LocalGenerator->AppendFlags(flags, arg.c_str()); + } + else + { + this->LocalGenerator->AppendFlags(flags, includeFlags.c_str()); + } +} + //---------------------------------------------------------------------------- const char* cmMakefileTargetGenerator::GetFortranModuleDirectory() { diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index c9aede2f2..b68f8bf3b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -146,6 +146,8 @@ protected: bool useResponseFile, std::string& buildObjs, std::vector& makefile_depends); + void AddIncludeFlags(std::string& flags, const char* lang); + virtual void CloseFileStreams(); void RemoveForbiddenFlags(const char* flagVar, const char* linkLang, std::string& linkFlags); @@ -177,6 +179,8 @@ protected: // the stream for the flag file std::string FlagFileNameFull; cmGeneratedFileStream *FlagFileStream; + class StringList: public std::vector {}; + std::map FlagFileDepends; // the stream for the info file std::string InfoFileNameFull; @@ -212,6 +216,12 @@ protected: std::string MacContentDirectory; std::set MacContentFolders; + typedef std::map ByLanguageMap; + std::string GetFlags(const std::string &l); + ByLanguageMap FlagsByLanguage; + std::string GetDefines(const std::string &l); + ByLanguageMap DefinesByLanguage; + // Target-wide Fortran module output directory. bool FortranModuleDirectoryComputed; std::string FortranModuleDirectory; diff --git a/Source/cmOutputRequiredFilesCommand.h b/Source/cmOutputRequiredFilesCommand.h index 0da7724e1..6038472c5 100644 --- a/Source/cmOutputRequiredFilesCommand.h +++ b/Source/cmOutputRequiredFilesCommand.h @@ -47,8 +47,7 @@ public: */ virtual const char* GetTerseDocumentation() { - return - "Output a list of required source files for a specified source file."; + return "Deprecated. Approximate C preprocessor dependency scanning."; } /** @@ -57,12 +56,22 @@ public: virtual const char* GetFullDocumentation() { return + "This command exists only because ancient CMake versions provided it. " + "CMake handles preprocessor dependency scanning automatically using a " + "more advanced scanner.\n" " output_required_files(srcfile outputfile)\n" "Outputs a list of all the source files that are required by the " "specified srcfile. This list is written into outputfile. This is " "similar to writing out the dependencies for srcfile except that it " "jumps from .h files into .cxx, .c and .cpp files if possible."; } + + /** This command is kept for compatibility with older CMake versions. */ + virtual bool IsDiscouraged() + { + return true; + } + cmTypeMacro(cmOutputRequiredFilesCommand, cmCommand); void ListDependencies(cmDependInformation const *info, diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 2d1f79212..37070b61d 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -453,7 +453,7 @@ cmPolicies::cmPolicies() "Starting with CMake 2.8.4, if a cmake-module shipped with CMake (i.e. " "located in the CMake module directory) calls include() or " "find_package(), the files located in the the CMake module directory are " - "prefered over the files in CMAKE_MODULE_PATH. " + "preferred over the files in CMAKE_MODULE_PATH. " "This makes sure that the modules belonging to " "CMake always get those files included which they expect, and against " "which they were developed and tested. " diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index 86ecebe64..cabe98a51 100644 --- a/Source/cmScriptGenerator.cxx +++ b/Source/cmScriptGenerator.cxx @@ -209,6 +209,7 @@ void cmScriptGenerator::GenerateScriptActionsPerConfig(std::ostream& os, // In a multi-configuration generator we produce a separate rule // in a block for each configuration that is built. We restrict // the list of configurations to those to which this rule applies. + bool first = true; for(std::vector::const_iterator i = this->ConfigurationTypes->begin(); i != this->ConfigurationTypes->end(); ++i) @@ -218,10 +219,19 @@ void cmScriptGenerator::GenerateScriptActionsPerConfig(std::ostream& os, { // Generate a per-configuration block. std::string config_test = this->CreateConfigTest(config); - os << indent << "IF(" << config_test << ")\n"; + os << indent << (first? "IF(" : "ELSEIF(") << config_test << ")\n"; this->GenerateScriptForConfig(os, config, indent.Next()); - os << indent << "ENDIF(" << config_test << ")\n"; + first = false; } } + if(!first) + { + if(this->NeedsScriptNoConfig()) + { + os << indent << "ELSE()\n"; + this->GenerateScriptNoConfig(os, indent.Next()); + } + os << indent << "ENDIF()\n"; + } } } diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h index e2a0da56d..8b2ca335f 100644 --- a/Source/cmScriptGenerator.h +++ b/Source/cmScriptGenerator.h @@ -65,6 +65,8 @@ protected: virtual void GenerateScriptForConfig(std::ostream& os, const char* config, Indent const& indent); + virtual void GenerateScriptNoConfig(std::ostream&, Indent const&) {} + virtual bool NeedsScriptNoConfig() const { return false; } // Test if this generator does something for a given configuration. bool GeneratesForConfig(const char*); diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index ed1da7b0d..42d3f06ff 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -482,17 +482,21 @@ void cmSourceFile::DefineProperties(cmake *cm) cm->DefineProperty ("MACOSX_PACKAGE_LOCATION", cmProperty::SOURCE_FILE, - "Place a source file inside a Mac OS X bundle or framework.", + "Place a source file inside a Mac OS X bundle, CFBundle, or framework.", "Executable targets with the MACOSX_BUNDLE property set are built " "as Mac OS X application bundles on Apple platforms. " "Shared library targets with the FRAMEWORK property set are built " "as Mac OS X frameworks on Apple platforms. " + "Module library targets with the BUNDLE property set are built " + "as Mac OS X CFBundle bundles on Apple platforms. " "Source files listed in the target with this property set will " "be copied to a directory inside the bundle or framework content " "folder specified by the property value. " "For bundles the content folder is \".app/Contents\". " "For frameworks the content folder is " "\".framework/Versions/\". " + "For cfbundles the content folder is " + "\".bundle/Contents\" (unless the extension is changed). " "See the PUBLIC_HEADER, PRIVATE_HEADER, and RESOURCE target " "properties for specifying files meant for Headers, PrivateHeaders, " "or Resources directories."); diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 27d90db58..8e61d0a15 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -11,37 +11,6 @@ ============================================================================*/ #include "cmSourceGroupCommand.h" -inline std::vector tokenize(const std::string& str, - const std::string& sep) -{ - std::vector tokens; - std::string::size_type tokend = 0; - - do - { - std::string::size_type tokstart=str.find_first_not_of(sep, tokend); - if (tokstart==std::string::npos) - { - break; // no more tokens - } - tokend=str.find_first_of(sep,tokstart); - if (tokend==std::string::npos) - { - tokens.push_back(str.substr(tokstart)); - } - else - { - tokens.push_back(str.substr(tokstart,tokend-tokstart)); - } - } while (tokend!=std::string::npos); - - if (tokens.empty()) - { - tokens.push_back(""); - } - return tokens; -} - // cmSourceGroupCommand bool cmSourceGroupCommand ::InitialPass(std::vector const& args, cmExecutionStatus &) @@ -58,7 +27,8 @@ bool cmSourceGroupCommand delimiter = this->Makefile->GetDefinition("SOURCE_GROUP_DELIMITER"); } - std::vector folders = tokenize(args[0], delimiter); + std::vector folders = + cmSystemTools::tokenize(args[0], delimiter); cmSourceGroup* sg = 0; sg = this->Makefile->GetSourceGroup(folders); diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 949fcf5ef..d239c063a 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -72,7 +72,11 @@ bool cmStringCommand { return this->HandleRandomCommand(args); } - + else if(subCommand == "FIND") + { + return this->HandleFindCommand(args); + } + std::string e = "does not recognize sub-command "+subCommand; this->SetError(e.c_str()); return false; @@ -498,6 +502,68 @@ void cmStringCommand::StoreMatches(cmMakefile* mf,cmsys::RegularExpression& re) } } +//---------------------------------------------------------------------------- +bool cmStringCommand::HandleFindCommand(std::vector const& + args) +{ + // check if all required parameters were passed + if(args.size() < 4 || args.size() > 5) + { + this->SetError("sub-command FIND requires 3 or 4 parameters."); + return false; + } + + // check if the reverse flag was set or not + bool reverseMode = false; + if(args.size() == 5 && args[4] == "REVERSE") + { + reverseMode = true; + } + + // if we have 5 arguments the last one must be REVERSE + if(args.size() == 5 && args[4] != "REVERSE") + { + this->SetError("sub-command FIND: unknown last parameter"); + return false; + } + + // local parameter names. + const std::string& sstring = args[1]; + const std::string& schar = args[2]; + const std::string& outvar = args[3]; + + // ensure that the user cannot accidentally specify REVERSE as a variable + if(outvar == "REVERSE") + { + this->SetError("sub-command FIND does not allow to select REVERSE as " + "the output variable. " + "Maybe you missed the actual output variable?"); + return false; + } + + // try to find the character and return its position + size_t pos; + if(!reverseMode) + { + pos = sstring.find(schar); + } + else + { + pos = sstring.rfind(schar); + } + if(std::string::npos != pos) + { + cmOStringStream s; + s << pos; + this->Makefile->AddDefinition(outvar.c_str(), s.str().c_str()); + return true; + } + + // the character was not found, but this is not really an error + this->Makefile->AddDefinition(outvar.c_str(), "-1"); + return true; +} + //---------------------------------------------------------------------------- bool cmStringCommand::HandleCompareCommand(std::vector const& args) @@ -611,7 +677,7 @@ bool cmStringCommand::HandleSubstringCommand(std::vector const& if ( end < -1 || end > leftOverLength ) { cmOStringStream ostr; - ostr << "end index: " << end << " is out of range " << 0 << " - " + ostr << "end index: " << end << " is out of range -1 - " << leftOverLength; this->SetError(ostr.str().c_str()); return false; @@ -704,7 +770,7 @@ bool cmStringCommand static bool seeded = false; bool force_seed = false; - int seed = (int) time(NULL); + unsigned int seed = 0; int length = 5; const char cmStringCommandDefaultAlphabet[] = "qwertyuiopasdfghjklzxcvbnm" "QWERTYUIOPASDFGHJKLZXCVBNM" @@ -731,7 +797,7 @@ bool cmStringCommand else if ( args[i] == "RANDOM_SEED" ) { ++i; - seed = atoi(args[i].c_str()); + seed = static_cast(atoi(args[i].c_str())); force_seed = true; } } @@ -759,7 +825,7 @@ bool cmStringCommand if (!seeded || force_seed) { seeded = true; - srand(seed); + srand(force_seed? seed : cmSystemTools::RandomSeed()); } const char* alphaPtr = alphabet.c_str(); diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index 2a916b407..52b83d9f3 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -90,6 +90,7 @@ public: " string(STRIP )\n" " string(RANDOM [LENGTH ] [ALPHABET ]\n" " [RANDOM_SEED ] )\n" + " string(FIND [REVERSE])\n" "REGEX MATCH will match the regular expression once and store the " "match in the output variable.\n" "REGEX MATCHALL will match the regular expression as many times as " @@ -109,7 +110,8 @@ public: "a file.\n" "TOUPPER/TOLOWER will convert string to upper/lower characters.\n" "LENGTH will return a given string's length.\n" - "SUBSTRING will return a substring of a given string.\n" + "SUBSTRING will return a substring of a given string. If length is " + "-1 the remainder of the string starting at begin will be returned.\n" "STRIP will return a substring of a given string with leading " "and trailing spaces removed.\n" "RANDOM will return a random string of given length consisting of " @@ -117,6 +119,10 @@ public: "characters and default alphabet is all numbers and upper and " "lower case letters. If an integer RANDOM_SEED is given, its " "value will be used to seed the random number generator.\n" + "FIND will return the position where the given substring was found " + "in the supplied string. If the REVERSE flag was used, the command " + "will search for the position of the last occurrence of the " + "specified substring.\n" "The following characters have special meaning in regular expressions:\n" " ^ Matches at beginning of a line\n" " $ Matches at end of a line\n" @@ -152,6 +158,7 @@ protected: bool HandleSubstringCommand(std::vector const& args); bool HandleStripCommand(std::vector const& args); bool HandleRandomCommand(std::vector const& args); + bool HandleFindCommand(std::vector const& args); class RegexReplacement { diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7bc89a4c4..dbb2226be 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -9,6 +9,9 @@ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more information. ============================================================================*/ +#if defined(_MSC_VER) && _MSC_VER < 1300 +# define _WIN32_WINNT 0x0400 /* for wincrypt.h */ +#endif #include "cmSystemTools.h" #include #include @@ -31,7 +34,9 @@ #if defined(_WIN32) # include +# include #else +# include # include # include # include @@ -440,6 +445,13 @@ public: args.push_back(*arg); } } + void Store(std::vector& args) const + { + for(char** arg = this->ArgV; arg && *arg; ++arg) + { + args.push_back(*arg); + } + } }; //---------------------------------------------------------------------------- @@ -451,6 +463,15 @@ void cmSystemTools::ParseUnixCommandLine(const char* command, argv.Store(args); } +//---------------------------------------------------------------------------- +void cmSystemTools::ParseUnixCommandLine(const char* command, + std::vector& args) +{ + // Invoke the underlying parser. + cmSystemToolsArgV argv = cmsysSystem_Parse_CommandForUnix(command, 0); + argv.Store(args); +} + std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg, int shell_flags) { @@ -2232,6 +2253,71 @@ bool cmSystemTools::FileTimeSet(const char* fname, cmSystemToolsFileTime* t) return true; } +//---------------------------------------------------------------------------- +#ifdef _WIN32 +# ifndef CRYPT_SILENT +# define CRYPT_SILENT 0x40 /* Not defined by VS 6 version of header. */ +# endif +static int WinCryptRandom(void* data, size_t size) +{ + int result = 0; + HCRYPTPROV hProvider = 0; + if(CryptAcquireContextW(&hProvider, 0, 0, PROV_RSA_FULL, + CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) + { + result = CryptGenRandom(hProvider, (DWORD)size, (BYTE*)data)? 1:0; + CryptReleaseContext(hProvider, 0); + } + return result; +} +#endif + +//---------------------------------------------------------------------------- +unsigned int cmSystemTools::RandomSeed() +{ +#if defined(_WIN32) && !defined(__CYGWIN__) + unsigned int seed = 0; + + // Try using a real random source. + if(WinCryptRandom(&seed, sizeof(seed))) + { + return seed; + } + + // Fall back to the time and pid. + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + unsigned int t1 = static_cast(ft.dwHighDateTime); + unsigned int t2 = static_cast(ft.dwLowDateTime); + unsigned int pid = static_cast(GetCurrentProcessId()); + return t1 ^ t2 ^ pid; +#else + union + { + unsigned int integer; + char bytes[sizeof(unsigned int)]; + } seed; + + // Try using a real random source. + std::ifstream fin("/dev/urandom"); + if(fin && fin.read(seed.bytes, sizeof(seed)) && + fin.gcount() == sizeof(seed)) + { + return seed.integer; + } + + // Fall back to the time and pid. + struct timeval t; + gettimeofday(&t, 0); + unsigned int pid = static_cast(getpid()); + unsigned int tv_sec = static_cast(t.tv_sec); + unsigned int tv_usec = static_cast(t.tv_usec); + // Since tv_usec never fills more than 11 bits we shift it to fill + // in the slow-changing high-order bits of tv_sec. + return tv_sec ^ (tv_usec << 21) ^ pid; +#endif +} + //---------------------------------------------------------------------------- static std::string cmSystemToolsExecutableDirectory; void cmSystemTools::FindExecutableDirectory(const char* argv0) @@ -2603,7 +2689,7 @@ bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op, else if(lhs[i] > rhs[i]) { // lhs > rhs, so true if operation is GREATER - return op == cmSystemTools::OP_GREATER; + return op == cmSystemTools::OP_GREATER; } } // lhs == rhs, so true if operation is EQUAL @@ -2833,3 +2919,35 @@ bool cmSystemTools::RepeatedRemoveDirectory(const char* dir) } return false; } + +//---------------------------------------------------------------------------- +std::vector cmSystemTools::tokenize(const std::string& str, + const std::string& sep) +{ + std::vector tokens; + std::string::size_type tokend = 0; + + do + { + std::string::size_type tokstart=str.find_first_not_of(sep, tokend); + if (tokstart==std::string::npos) + { + break; // no more tokens + } + tokend=str.find_first_of(sep,tokstart); + if (tokend==std::string::npos) + { + tokens.push_back(str.substr(tokstart)); + } + else + { + tokens.push_back(str.substr(tokstart,tokend-tokstart)); + } + } while (tokend!=std::string::npos); + + if (tokens.empty()) + { + tokens.push_back(""); + } + return tokens; +} diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 6f9147c31..ce499591d 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -237,6 +237,8 @@ public: /** Parse arguments out of a unix command line string. */ static void ParseUnixCommandLine(const char* command, std::vector& args); + static void ParseUnixCommandLine(const char* command, + std::vector& args); /** Compute an escaped version of the given argument for use in a windows shell. See kwsys/System.h.in for details. */ @@ -402,6 +404,9 @@ public: static bool FileTimeGet(const char* fname, cmSystemToolsFileTime* t); static bool FileTimeSet(const char* fname, cmSystemToolsFileTime* t); + /** Random seed generation. */ + static unsigned int RandomSeed(); + /** Find the directory containing the running executable. Save it in a global location to be queried by GetExecutableDirectory later. */ @@ -439,6 +444,9 @@ public: /** Remove a directory; repeat a few times in case of locked files. */ static bool RepeatedRemoveDirectory(const char* dir); + /** Tokenize a string */ + static std::vector tokenize(const std::string& str, + const std::string& sep); private: static bool s_ForceUnixPaths; static bool s_RunCommandHideConsole; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 72efce308..7bd537236 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -187,6 +187,22 @@ void cmTarget::DefineProperties(cmake *cm) "A message to display on some generators (such as makefiles) when " "the target is built."); + cm->DefineProperty + ("BUNDLE", cmProperty::TARGET, + "This target is a CFBundle on the Mac.", + "If a module library target has this property set to true it will " + "be built as a CFBundle when built on the mac. It will have the " + "directory structure required for a CFBundle and will be suitable " + "to be used for creating Browser Plugins or other application " + "resources."); + + cm->DefineProperty + ("BUNDLE_EXTENSION", cmProperty::TARGET, + "The file extension used to name a BUNDLE target on the Mac.", + "The default value is \"bundle\" - you can also use \"plugin\" or " + "whatever file extension is required by the host app for your " + "bundle."); + cm->DefineProperty ("FRAMEWORK", cmProperty::TARGET, "This target is a framework on the Mac.", @@ -471,17 +487,32 @@ void cmTarget::DefineProperties(cmake *cm) "Per-configuration linker flags for a target.", "This is the configuration-specific version of LINK_FLAGS."); +#define CM_LINK_SEARCH_SUMMARY \ + "Some linkers support switches such as -Bstatic and -Bdynamic " \ + "to determine whether to use static or shared libraries for -lXXX " \ + "options. CMake uses these options to set the link type for " \ + "libraries whose full paths are not known or (in some cases) are in " \ + "implicit link directories for the platform. " + + cm->DefineProperty + ("LINK_SEARCH_START_STATIC", cmProperty::TARGET, + "Assume the linker looks for static libraries by default.", + CM_LINK_SEARCH_SUMMARY + "By default the linker search type is assumed to be -Bdynamic at " + "the beginning of the library list. This property switches the " + "assumption to -Bstatic. It is intended for use when linking an " + "executable statically (e.g. with the GNU -static option). " + "See also LINK_SEARCH_END_STATIC."); + cm->DefineProperty ("LINK_SEARCH_END_STATIC", cmProperty::TARGET, "End a link line such that static system libraries are used.", - "Some linkers support switches such as -Bstatic and -Bdynamic " - "to determine whether to use static or shared libraries for -lXXX " - "options. CMake uses these options to set the link type for " - "libraries whose full paths are not known or (in some cases) are in " - "implicit link directories for the platform. By default the " - "linker search type is left at -Bdynamic by the end of the library " - "list. This property switches the final linker search type to " - "-Bstatic."); + CM_LINK_SEARCH_SUMMARY + "By default CMake adds an option at the end of the library list (if " + "necessary) to set the linker search type back to its starting type. " + "This property switches the final linker search type to -Bstatic " + "regardless of how it started. " + "See also LINK_SEARCH_START_STATIC."); cm->DefineProperty ("LINKER_LANGUAGE", cmProperty::TARGET, @@ -1210,6 +1241,14 @@ bool cmTarget::IsAppBundleOnApple() this->GetPropertyAsBool("MACOSX_BUNDLE")); } +//---------------------------------------------------------------------------- +bool cmTarget::IsCFBundleOnApple() +{ + return (this->GetType() == cmTarget::MODULE_LIBRARY && + this->Makefile->IsOn("APPLE") && + this->GetPropertyAsBool("BUNDLE")); +} + //---------------------------------------------------------------------------- class cmTargetTraceDependencies { @@ -4278,9 +4317,13 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface) } } - // There is no implicit link interface for executables, so if none - // was explicitly set, there is no link interface. - if(!explicitLibraries && this->GetType() == cmTarget::EXECUTABLE) + // There is no implicit link interface for executables or modules + // so if none was explicitly set then there is no link interface. + // Note that CMake versions 2.2 and below allowed linking to modules. + bool canLinkModules = this->Makefile->NeedBackwardsCompatibility(2,2); + if(!explicitLibraries && + (this->GetType() == cmTarget::EXECUTABLE || + (this->GetType() == cmTarget::MODULE_LIBRARY && !canLinkModules))) { return false; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f2b7d61e8..3b1f016a6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -326,7 +326,7 @@ public: */ bool FindSourceFiles(); - ///! Return the prefered linker language for this target + ///! Return the preferred linker language for this target const char* GetLinkerLanguage(const char* config = 0); ///! Return the rule variable used to create this type of target, @@ -430,6 +430,9 @@ public: Apple. */ bool IsFrameworkOnApple(); + /** Return whether this target is a CFBundle (plugin) on Apple. */ + bool IsCFBundleOnApple(); + /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple(); diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 39f86388b..e0892b282 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -129,6 +129,22 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, os << ")\n"; } +//---------------------------------------------------------------------------- +void cmTestGenerator::GenerateScriptNoConfig(std::ostream& os, + Indent const& indent) +{ + os << indent << "ADD_TEST(" << this->Test->GetName() << " NOT_AVAILABLE)\n"; +} + +//---------------------------------------------------------------------------- +bool cmTestGenerator::NeedsScriptNoConfig() const +{ + return (this->TestGenerated && // test generated for at least one config + this->ActionsPerConfig && // test is config-aware + this->Configurations.empty() && // test runs in all configs + !this->ConfigurationTypes->empty()); // config-dependent command +} + //---------------------------------------------------------------------------- void cmTestGenerator::GenerateOldStyle(std::ostream& fout, Indent const& indent) diff --git a/Source/cmTestGenerator.h b/Source/cmTestGenerator.h index 85d9091d6..2c69fc3c5 100644 --- a/Source/cmTestGenerator.h +++ b/Source/cmTestGenerator.h @@ -34,6 +34,8 @@ protected: virtual void GenerateScriptForConfig(std::ostream& os, const char* config, Indent const& indent); + virtual void GenerateScriptNoConfig(std::ostream& os, Indent const& indent); + virtual bool NeedsScriptNoConfig() const; void GenerateOldStyle(std::ostream& os, Indent const& indent); cmTest* Test; diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index 0c67a8ba4..9923d03b7 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -77,14 +77,20 @@ public: "Specify COPY_FILE to get a copy of the linked executable at the " "given fileName." "\n" - "In this version all files in bindir/CMakeFiles/CMakeTmp, " - "will be cleaned automatically, for debugging a --debug-trycompile can " - "be passed to cmake to avoid the clean. Some extra flags that " - " can be included are, " + "In this version all files in bindir/CMakeFiles/CMakeTmp " + "will be cleaned automatically. For debugging, --debug-trycompile can " + "be passed to cmake to avoid this clean. However, multiple sequential " + "try_compile operations reuse this single output directory. If you " + "use --debug-trycompile, you can only debug one try_compile call at a " + "time. The recommended procedure is to configure with cmake all the " + "way through once, then delete the cache entry associated with " + "the try_compile call of interest, and then re-run cmake again with " + "--debug-trycompile." + "\n" + "Some extra flags that can be included are, " "INCLUDE_DIRECTORIES, LINK_DIRECTORIES, and LINK_LIBRARIES. " "COMPILE_DEFINITIONS are -Ddefinition that will be passed to the " "compile line. " - "try_compile creates a CMakeList.txt " "file on the fly that looks like this:\n" " add_definitions( const& args, cmExecutionStatus &status); - + /** * The name of the command as specified in CMakeList.txt. */ @@ -50,11 +50,11 @@ public: /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Copy mesa headers for use in combination with system GL."; } - + /** * More documentation. */ @@ -68,6 +68,11 @@ public: "being added to the include directory path earlier."; } + /** + * This determines if the command is invoked when in script mode. + */ + virtual bool IsScriptable() { return true; } + /** This command is kept for compatibility with older CMake versions. */ virtual bool IsDiscouraged() { @@ -80,5 +85,4 @@ protected: }; - #endif diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 4cb745e7e..2a4ff9210 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -167,6 +167,7 @@ void cmVisualStudio10TargetGenerator::Generate() // Write the encoding header into the file char magic[] = {0xEF,0xBB, 0xBF}; this->BuildFileStream->write(magic, 3); + this->WriteString("\n",0); this->WriteString("LocalGenerator; @@ -366,10 +378,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, static_cast (this->GlobalGenerator)->GetConfigurations(); this->WriteString("Makefile->GetCurrentOutputDirectory(), - sourcePath.c_str()); + std::string path = sourcePath; this->ConvertToWindowsSlash(path); (*this->BuildFileStream ) << path << "\">\n"; for(std::vector::iterator i = configs->begin(); @@ -451,11 +460,17 @@ void cmVisualStudio10TargetGenerator::WriteGroups() bool header = (*s)->GetPropertyAsBool("HEADER_FILE_ONLY") || this->GlobalGenerator->IgnoreFile ((*s)->GetExtension().c_str()); + std::string ext = + cmSystemTools::LowerCase((*s)->GetExtension()); if(!lang) { lang = "None"; } - if(lang[0] == 'C') + if(header) + { + headers.push_back(sf); + } + else if(lang[0] == 'C') { clCompile.push_back(sf); } @@ -467,11 +482,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups() { customBuild.push_back(sf); } - else if(header) - { - headers.push_back(sf); - } - else if(sf->GetExtension() == "idl") + else if(ext == "idl") { idls.push_back(sf); } @@ -608,9 +619,6 @@ WriteGroupSources(const char* name, const char* filter = sourceGroup.GetFullName(); this->WriteString("<", 2); std::string path = source; - path = cmSystemTools::RelativePath( - this->Makefile->GetCurrentOutputDirectory(), - source.c_str()); this->ConvertToWindowsSlash(path); (*this->BuildFileStream) << name << " Include=\"" << path; @@ -641,14 +649,28 @@ void cmVisualStudio10TargetGenerator::WriteObjSources() for(std::vector::const_iterator source = sources.begin(); source != sources.end(); ++source) { - if((*source)->GetExtension() == "obj") + std::string ext = + cmSystemTools::LowerCase((*source)->GetExtension()); + if(ext == "obj" || ext == "o") { if(first) { this->WriteString("\n", 1); first = false; } - this->WriteString("GetPropertyAsBool("GENERATED")) + { + this->WriteString("WriteString("BuildFileStream ) << (*source)->GetFullPath() << "\" />\n"; } } @@ -670,8 +692,8 @@ void cmVisualStudio10TargetGenerator::WriteCLSources() for(std::vector::const_iterator source = sources.begin(); source != sources.end(); ++source) { - std::string ext = (*source)->GetExtension(); - if((*source)->GetCustomCommand() || ext == "obj") + std::string ext = cmSystemTools::LowerCase((*source)->GetExtension()); + if((*source)->GetCustomCommand() || ext == "o" || ext == "obj") { continue; } @@ -684,9 +706,6 @@ void cmVisualStudio10TargetGenerator::WriteCLSources() bool rc = lang && (strcmp(lang, "RC") == 0); bool idl = ext == "idl"; std::string sourceFile = (*source)->GetFullPath(); - sourceFile = cmSystemTools::RelativePath( - this->Makefile->GetCurrentOutputDirectory(), - sourceFile.c_str()); this->ConvertToWindowsSlash(sourceFile); // output the source file if(header) @@ -998,6 +1017,15 @@ OutputLinkIncremental(std::string const& configName) this->WritePlatformConfigTag("LinkIncremental", configName.c_str(), 3); *this->BuildFileStream << incremental << "\n"; + + const char* manifest = "true"; + if(flags.find("MANIFEST:NO") != flags.npos) + { + manifest = "false"; + } + this->WritePlatformConfigTag("GenerateManifest", configName.c_str(), 3); + *this->BuildFileStream << manifest + << "\n"; } //---------------------------------------------------------------------------- @@ -1326,7 +1354,7 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& linkDirs += "%(AdditionalLibraryDirectories)"; linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs.c_str()); linkOptions.AddFlag("AdditionalDependencies", libs.c_str()); - linkOptions.AddFlag("Version", "0.0"); + linkOptions.AddFlag("Version", ""); if(linkOptions.IsDebug() || flags.find("/debug") != flags.npos) { linkOptions.AddFlag("GenerateDebugInformation", "true"); @@ -1369,6 +1397,8 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& linkOptions.AddFlag("ModuleDefinitionFile", this->ModuleDefinitionFile.c_str()); } + + linkOptions.RemoveFlag("GenerateManifest"); linkOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); linkOptions.OutputFlagMap(*this->BuildFileStream, " "); diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index ed0d60ced..ae496ad12 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -299,7 +299,12 @@ cmVisualStudioGeneratorOptions { fout << "<" << m->first << ">"; } - fout << m->second << "first << ">\n"; + fout << m->second; + if (m->first == "AdditionalIncludeDirectories") + { + fout << ";%(AdditionalIncludeDirectories)"; + } + fout << "first << ">\n"; } } else diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 592047031..71c7c2557 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -146,13 +146,15 @@ void cmXCodeObject::Print(std::ostream& out) if(j->second->TypeValue == STRING) { - out << j->first << " = "; + cmXCodeObject::PrintString(out,j->first); + out << " = "; j->second->PrintString(out); out << ";"; } else if(j->second->TypeValue == OBJECT_LIST) { - out << j->first << " = ("; + cmXCodeObject::PrintString(out,j->first); + out << " = ("; for(unsigned int k = 0; k < j->second->List.size(); k++) { if(j->second->List[k]->TypeValue == STRING) @@ -169,7 +171,8 @@ void cmXCodeObject::Print(std::ostream& out) } else { - out << j->first << " = error_unexpected_TypeValue_" << + cmXCodeObject::PrintString(out,j->first); + out << " = error_unexpected_TypeValue_" << j->second->TypeValue << ";"; } @@ -180,7 +183,8 @@ void cmXCodeObject::Print(std::ostream& out) } else if(object->TypeValue == OBJECT_REF) { - out << i->first << " = " << object->Object->Id; + cmXCodeObject::PrintString(out,i->first); + out << " = " << object->Object->Id; if(object->Object->HasComment() && i->first != "remoteGlobalIDString") { out << " "; @@ -190,7 +194,8 @@ void cmXCodeObject::Print(std::ostream& out) } else if(object->TypeValue == STRING) { - out << i->first << " = "; + cmXCodeObject::PrintString(out,i->first); + out << " = "; object->PrintString(out); out << ";" << separator; } @@ -230,19 +235,19 @@ void cmXCodeObject::CopyAttributes(cmXCodeObject* copy) } //---------------------------------------------------------------------------- -void cmXCodeObject::PrintString(std::ostream& os) const +void cmXCodeObject::PrintString(std::ostream& os,cmStdString String) { // The string needs to be quoted if it contains any characters // considered special by the Xcode project file parser. bool needQuote = - (this->String.empty() || - this->String.find_first_of(" <>.+-=@$") != this->String.npos); + (String.empty() || + String.find_first_of(" <>.+-=@$[]") != String.npos); const char* quote = needQuote? "\"" : ""; // Print the string, quoted and escaped as necessary. os << quote; - for(std::string::const_iterator i = this->String.begin(); - i != this->String.end(); ++i) + for(std::string::const_iterator i = String.begin(); + i != String.end(); ++i) { if(*i == '"') { @@ -254,6 +259,11 @@ void cmXCodeObject::PrintString(std::ostream& os) const os << quote; } +void cmXCodeObject::PrintString(std::ostream& os) const +{ + cmXCodeObject::PrintString(os,this->String); +} + //---------------------------------------------------------------------------- void cmXCodeObject::SetString(const char* s) { diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index 2bea63b18..369fe669d 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -139,8 +139,22 @@ public: { return this->DependLibraries; } + void AddDependTarget(const char* configName, + const char* tName) + { + if(!configName) + { + configName = ""; + } + this->DependTargets[configName].push_back(tName); + } + std::map const& GetDependTargets() + { + return this->DependTargets; + } std::vector const& GetObjectList() { return this->List;} void SetComment(const char* c) { this->Comment = c;} + static void PrintString(std::ostream& os,cmStdString String); protected: void PrintString(std::ostream& os) const; @@ -155,6 +169,7 @@ protected: cmXCodeObject* PBXTargetDependencyValue; std::vector List; std::map DependLibraries; + std::map DependTargets; std::map ObjectAttributes; }; #endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index bab0aaf83..45927cb04 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -462,7 +462,7 @@ bool cmake::SetCacheArgs(const std::vector& args) } } std::cerr << "loading initial cache file " << path.c_str() << "\n"; - this->ReadListFile(path.c_str()); + this->ReadListFile(args, path.c_str()); } else if(arg.find("-P",0) == 0) { @@ -478,13 +478,14 @@ bool cmake::SetCacheArgs(const std::vector& args) cmSystemTools::Error("No cmake script provided."); return false; } - this->ReadListFile(path.c_str()); + this->ReadListFile(args, path.c_str()); } } return true; } -void cmake::ReadListFile(const char *path) +void cmake::ReadListFile(const std::vector& args, + const char *path) { // if a generator was not yet created, temporarily create one cmGlobalGenerator *gg = this->GetGlobalGenerator(); @@ -510,6 +511,14 @@ void cmake::ReadListFile(const char *path) (cmSystemTools::GetCurrentWorkingDirectory().c_str()); lg->GetMakefile()->SetStartDirectory (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + if (this->GetScriptMode()) + { + std::string file(cmSystemTools::CollapseFullPath(path)); + cmSystemTools::ConvertToUnixSlashes(file); + lg->GetMakefile()->SetScriptModeFile(file.c_str()); + + lg->GetMakefile()->SetArgcArgv(args); + } if (!lg->GetMakefile()->ReadListFile(0, path)) { cmSystemTools::Error("Error processing file:", path); @@ -979,37 +988,39 @@ void CMakeCommandUsage(const char* program) errorStream << "Usage: " << program << " -E [command] [arguments ...]\n" << "Available commands: \n" + << " build build_dir - build the project in build_dir.\n" << " chdir dir cmd [args]... - run command in a given directory\n" - << " rename oldname newname - rename a file or directory " - "(on one volume)\n" + << " compare_files file1 file2 - check if file1 is same as file2\n" << " copy file destination - copy file to destination (either file " "or directory)\n" - << " copy_if_different in-file out-file - copy file if input has " - "changed\n" << " copy_directory source destination - copy directory 'source' " "content to directory 'destination'\n" - << " compare_files file1 file2 - check if file1 is same as file2\n" + << " copy_if_different in-file out-file - copy file if input has " + "changed\n" << " echo [string]... - displays arguments as text\n" << " echo_append [string]... - displays arguments as text but no new " "line\n" << " environment - display the current environment\n" << " make_directory dir - create a directory\n" << " md5sum file1 [...] - compute md5sum of files\n" - << " remove_directory dir - remove a directory and its contents\n" << " remove [-f] file1 file2 ... - remove the file(s), use -f to force " "it\n" + << " remove_directory dir - remove a directory and its contents\n" + << " rename oldname newname - rename a file or directory " + "(on one volume)\n" << " tar [cxt][vfz][cvfj] file.tar " "file/dir1 file/dir2 ... - create a tar " "archive\n" << " time command [args] ... - run command and return elapsed time\n" << " touch file - touch a file.\n" << " touch_nocreate file - touch a file but do not create it.\n" - << " build build_dir - build the project in build_dir.\n" #if defined(_WIN32) && !defined(__CYGWIN__) - << " write_regv key value - write registry value\n" - << " delete_regv key - delete registry value\n" + << "Available on Windows only:\n" << " comspec - on windows 9x use this for RunCommand\n" + << " delete_regv key - delete registry value\n" + << " write_regv key value - write registry value\n" #else + << "Available on UNIX only:\n" << " create_symlink old new - create a symbolic link new -> old\n" #endif ; @@ -1984,8 +1995,32 @@ int cmake::Configure() } +bool cmake::RejectUnsupportedPaths(const char* desc, std::string const& path) +{ + // Some characters are not well-supported by native build systems. + std::string::size_type pos = path.find_first_of("="); + if(pos == std::string::npos) + { + return false; + } + cmOStringStream e; + e << "The path to the " << desc << " directory:\n" + << " " << path << "\n" + << "contains unsupported character '" << path[pos] << "'.\n" + << "Please use a different " << desc << " directory name."; + cmListFileBacktrace bt; + this->IssueMessage(cmake::FATAL_ERROR, e.str(), bt); + return true; +} + int cmake::ActualConfigure() { + if(this->RejectUnsupportedPaths("source", this->cmHomeDirectory) || + this->RejectUnsupportedPaths("binary", this->HomeOutputDirectory)) + { + return 1; + } + // Construct right now our path conversion table before it's too late: this->UpdateConversionPathTable(); this->CleanupCommandsAndMacros(); @@ -2197,13 +2232,14 @@ int cmake::ActualConfigure() void cmake::PreLoadCMakeFiles() { + std::vector args; std::string pre_load = this->GetHomeDirectory(); if ( pre_load.size() > 0 ) { pre_load += "/PreLoad.cmake"; if ( cmSystemTools::FileExists(pre_load.c_str()) ) { - this->ReadListFile(pre_load.c_str()); + this->ReadListFile(args, pre_load.c_str()); } } pre_load = this->GetHomeOutputDirectory(); @@ -2212,7 +2248,7 @@ void cmake::PreLoadCMakeFiles() pre_load += "/PreLoad.cmake"; if ( cmSystemTools::FileExists(pre_load.c_str()) ) { - this->ReadListFile(pre_load.c_str()); + this->ReadListFile(args, pre_load.c_str()); } } } @@ -2310,11 +2346,6 @@ int cmake::Run(const std::vector& args, bool noconfigure) std::string oldstartoutputdir = this->GetStartOutputDirectory(); this->SetStartDirectory(this->GetHomeDirectory()); this->SetStartOutputDirectory(this->GetHomeOutputDirectory()); - const bool warncli = this->WarnUnusedCli; - if (!this->ScriptMode) - { - this->WarnUnusedCli = false; - } int ret = this->Configure(); if (ret || this->ScriptMode) { @@ -2336,7 +2367,6 @@ int cmake::Run(const std::vector& args, bool noconfigure) #endif return ret; } - this->WarnUnusedCli = warncli; ret = this->Generate(); std::string message = "Build files have been written to: "; message += this->GetHomeOutputDirectory(); @@ -2358,6 +2388,10 @@ int cmake::Generate() return -1; } this->GlobalGenerator->Generate(); + if(this->WarnUnusedCli) + { + this->RunCheckForUnusedVariables(); + } if(cmSystemTools::GetErrorOccuredFlag()) { return -1; @@ -2898,6 +2932,7 @@ void cmake::GenerateGraphViz(const char* fileName) const gvWriter->ReadSettings(settingsFile.c_str(), fallbackSettingsFile.c_str()); gvWriter->WritePerTargetFiles(fileName); + gvWriter->WriteTargetDependersFiles(fileName); gvWriter->WriteGlobalFile(fileName); #endif @@ -4108,7 +4143,10 @@ int cmake::VisualStudioLinkNonIncremental(std::vector& args, return -1; } // Run the link command as given - linkCommand.push_back("/MANIFEST"); + if (hasManifest) + { + linkCommand.push_back("/MANIFEST"); + } if(!cmake::RunCommand("LINK", linkCommand, verbose)) { return -1; @@ -4308,7 +4346,10 @@ void cmake::WatchUnusedCli(const char* var) { #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this); - this->UsedCliVariables[var] = false; + if(this->UsedCliVariables.find(var) == this->UsedCliVariables.end()) + { + this->UsedCliVariables[var] = false; + } #endif } @@ -4316,27 +4357,29 @@ void cmake::UnwatchUnusedCli(const char* var) { #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch->RemoveWatch(var, cmWarnUnusedCliWarning); - this->UsedCliVariables[var] = true; + this->UsedCliVariables.erase(var); #endif } -void cmake::RunCheckForUnusedVariables(const std::string& reason) const +void cmake::RunCheckForUnusedVariables() { #ifdef CMAKE_BUILD_WITH_CMAKE - if(this->WarnUnusedCli) + bool haveUnused = false; + cmOStringStream msg; + msg << "Manually-specified variables were not used by the project:"; + for(std::map::const_iterator + it = this->UsedCliVariables.begin(); + it != this->UsedCliVariables.end(); ++it) + { + if(!it->second) { - std::map::const_iterator it; - for(it = this->UsedCliVariables.begin(); - it != this->UsedCliVariables.end(); ++it) - { - if(!it->second) - { - std::string message = "CMake Warning: The variable, '" + it->first + - "', specified manually, was not used during the " + reason + - "."; - cmSystemTools::Message(message.c_str()); - } - } + haveUnused = true; + msg << "\n " << it->first; } + } + if(haveUnused) + { + this->IssueMessage(cmake::WARNING, msg.str(), cmListFileBacktrace()); + } #endif } diff --git a/Source/cmake.h b/Source/cmake.h index 1bb42d32c..fac86c18e 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -368,8 +368,8 @@ class cmake void UnwatchUnusedCli(const char* var); void WatchUnusedCli(const char* var); - void RunCheckForUnusedVariables(const std::string& reason) const; protected: + void RunCheckForUnusedVariables(); void InitializeProperties(); int HandleDeleteCacheVariables(const char* var); cmPropertyMap Properties; @@ -406,7 +406,7 @@ protected: bool DoSuppressDevWarnings; ///! read in a cmake list file to initialize the cache - void ReadListFile(const char *path); + void ReadListFile(const std::vector& args, const char *path); ///! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file. /// If it is set, truncate it to 50kb @@ -451,6 +451,8 @@ protected: ///! Find the full path to one of the cmake programs like ctest, cpack, etc. std::string FindCMakeProgram(const char* name) const; + + bool RejectUnsupportedPaths(const char* desc, std::string const& path); private: cmake(const cmake&); // Not implemented. void operator=(const cmake&); // Not implemented. @@ -465,7 +467,7 @@ private: bool WarnUnused; bool WarnUnusedCli; bool CheckSystemVars; - std::map UsedCliVariables; + std::map UsedCliVariables; std::string CMakeEditCommand; std::string CMakeCommand; std::string CXXEnvironment; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index a51673cb9..663ce8f07 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -71,11 +71,13 @@ static const char * cmDocumentationOptions[][3] = {"-E", "CMake command mode.", "For true platform independence, CMake provides a list of commands " "that can be used on all systems. Run with -E help for the usage " - "information. Commands available are: chdir, copy, copy_if_different " - "copy_directory, compare_files, echo, echo_append, environment, " - "make_directory, md5sum, remove_directory, remove, tar, time, " - "touch, touch_nocreate, write_regv, delete_regv, comspec, " - "create_symlink."}, + "information. Commands available are: build, chdir, compare_files, copy, " + "copy_directory, copy_if_different, echo, echo_append, environment, " + "make_directory, md5sum, remove, remove_directory, rename, tar, time, " + "touch, touch_nocreate. In addition, some platform specific commands " + "are available. " + "On Windows: comspec, delete_regv, write_regv. " + "On UNIX: create_symlink."}, {"-i", "Run in wizard mode.", "Wizard mode runs cmake interactively without a GUI. The user is " "prompted to answer questions about the project configuration. " @@ -107,7 +109,8 @@ static const char * cmDocumentationOptions[][3] = "Dump a wide range of information about the current system. If run " "from the top of a binary tree for a CMake project it will dump " "additional information such as the cache, log files etc."}, - {"--debug-trycompile", "Do not delete the try compile directories..", + {"--debug-trycompile", "Do not delete the try_compile build tree. Only " + "useful on one try_compile at a time.", "Do not delete the files and directories created for try_compile calls. " "This is useful in debugging failed try_compiles. It may however " "change the results of the try-compiles as old junk from a previous " diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index a35a01f7f..0ef4e28c8 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -1,6 +1,6 @@ #============================================================================= # KWSys - Kitware System Library -# Copyright 2000-2009 Kitware, Inc., Insight Software Consortium +# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -44,9 +44,7 @@ # SET(KWSYS_IOS_FORCE_OLD 1) # # -# Optional settings to setup install rules work in one of two ways. -# The modern way utilizes the CMake 2.4 INSTALL command. Settings -# for this mode are as follows: +# Optional settings to setup install rules are as follows: # # KWSYS_INSTALL_BIN_DIR = The installation target directories into # KWSYS_INSTALL_LIB_DIR which the libraries and headers from @@ -70,25 +68,6 @@ # SET(KWSYS_INSTALL_INCLUDE_DIR include) # SET(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME Runtime) # SET(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT Development) -# -# The old way uses the original CMake INSTALL_* commands. Settings -# for this mode are as follows: -# -# KWSYS_LIBRARY_INSTALL_DIR = The installation target directories into -# KWSYS_HEADER_INSTALL_DIR which the libraries and headers from -# kwsys should be installed by a "make install". -# The values should be specified relative to -# the installation prefix and start with a '/'. -# Example: -# -# SET(KWSYS_LIBRARY_INSTALL_DIR /lib) -# SET(KWSYS_HEADER_INSTALL_DIR /include) -# -# The modern way will be used whenever the INSTALL command is -# available. If the settings are not available the old names will be -# used to construct them. The old way will be used whenever the -# INSTALL command is not available. If the settings are not available -# the new names will be used to construct them. # Once configured, kwsys should be used as follows from C or C++ code: # @@ -105,13 +84,7 @@ # any outside mailing list and no documentation of the change will be # written. -CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5 FATAL_ERROR) -IF(COMMAND CMAKE_POLICY) - CMAKE_POLICY(SET CMP0003 NEW) -ENDIF(COMMAND CMAKE_POLICY) - -# Allow empty endif() and such with CMake 2.4. -SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS 1) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR) #----------------------------------------------------------------------------- # If a namespace is not specified, use "kwsys" and enable testing. @@ -126,23 +99,11 @@ ENDIF(NOT KWSYS_NAMESPACE) # The project name is that of the specified namespace. PROJECT(${KWSYS_NAMESPACE}) -# Some properties we set only with CMake 2.6 and above. -IF(COMMAND SET_PROPERTY) - MACRO(KWSYS_SET_PROPERTY) - SET_PROPERTY(${ARGV}) - ENDMACRO(KWSYS_SET_PROPERTY) -ELSE(COMMAND SET_PROPERTY) - MACRO(KWSYS_SET_PROPERTY) - ENDMACRO(KWSYS_SET_PROPERTY) -ENDIF(COMMAND SET_PROPERTY) - # Tell CMake how to follow dependencies of sources in this directory. -IF(COMMAND SET_PROPERTY) - SET_PROPERTY(DIRECTORY - PROPERTY IMPLICIT_DEPENDS_INCLUDE_TRANSFORM - "KWSYS_HEADER(%)=<${KWSYS_NAMESPACE}/%>" - ) -ENDIF(COMMAND SET_PROPERTY) +SET_PROPERTY(DIRECTORY + PROPERTY IMPLICIT_DEPENDS_INCLUDE_TRANSFORM + "KWSYS_HEADER(%)=<${KWSYS_NAMESPACE}/%>" + ) # Select library components. IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) @@ -208,97 +169,75 @@ INCLUDE(CheckTypeSize) # Do full dependency headers. INCLUDE_REGULAR_EXPRESSION("^.*$") -# Choose which kind of install commands to use. -IF(COMMAND INSTALL) - # Use new KWSYS_INSTALL_*_DIR variable names to control installation. - # Take defaults from the old names. Note that there was no old name - # for the bin dir, so we take the old lib dir name so DLLs will be - # installed in a compatible way for old code. - IF(NOT KWSYS_INSTALL_INCLUDE_DIR) - STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_INCLUDE_DIR - "${KWSYS_HEADER_INSTALL_DIR}") - ENDIF(NOT KWSYS_INSTALL_INCLUDE_DIR) - IF(NOT KWSYS_INSTALL_LIB_DIR) - STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_LIB_DIR - "${KWSYS_LIBRARY_INSTALL_DIR}") - ENDIF(NOT KWSYS_INSTALL_LIB_DIR) - IF(NOT KWSYS_INSTALL_BIN_DIR) - STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_BIN_DIR - "${KWSYS_LIBRARY_INSTALL_DIR}") - ENDIF(NOT KWSYS_INSTALL_BIN_DIR) - - # Setup header install rules. - SET(KWSYS_INSTALL_INCLUDE_OPTIONS) - IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) - SET(KWSYS_INSTALL_INCLUDE_OPTIONS ${KWSYS_INSTALL_INCLUDE_OPTIONS} - COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT} - ) - ENDIF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) +# Use new KWSYS_INSTALL_*_DIR variable names to control installation. +# Take defaults from the old names. Note that there was no old name +# for the bin dir, so we take the old lib dir name so DLLs will be +# installed in a compatible way for old code. +IF(NOT KWSYS_INSTALL_INCLUDE_DIR) + STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_INCLUDE_DIR + "${KWSYS_HEADER_INSTALL_DIR}") +ENDIF(NOT KWSYS_INSTALL_INCLUDE_DIR) +IF(NOT KWSYS_INSTALL_LIB_DIR) + STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_LIB_DIR + "${KWSYS_LIBRARY_INSTALL_DIR}") +ENDIF(NOT KWSYS_INSTALL_LIB_DIR) +IF(NOT KWSYS_INSTALL_BIN_DIR) + STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_BIN_DIR + "${KWSYS_LIBRARY_INSTALL_DIR}") +ENDIF(NOT KWSYS_INSTALL_BIN_DIR) + +# Setup header install rules. +SET(KWSYS_INSTALL_INCLUDE_OPTIONS) +IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) + SET(KWSYS_INSTALL_INCLUDE_OPTIONS ${KWSYS_INSTALL_INCLUDE_OPTIONS} + COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT} + ) +ENDIF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) - # Setup library install rules. - SET(KWSYS_INSTALL_LIBRARY_RULE) - IF(KWSYS_INSTALL_LIB_DIR) - IF(KWSYS_INSTALL_EXPORT_NAME) - LIST(APPEND KWSYS_INSTALL_LIBRARY_RULE EXPORT ${KWSYS_INSTALL_EXPORT_NAME}) - ENDIF() - # Install the shared library to the lib directory. +# Setup library install rules. +SET(KWSYS_INSTALL_LIBRARY_RULE) +IF(KWSYS_INSTALL_LIB_DIR) + IF(KWSYS_INSTALL_EXPORT_NAME) + LIST(APPEND KWSYS_INSTALL_LIBRARY_RULE EXPORT ${KWSYS_INSTALL_EXPORT_NAME}) + ENDIF() + # Install the shared library to the lib directory. + SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} + LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR} + ) + # Assign the shared library to the runtime component. + IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} - LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR} + COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} ) - # Assign the shared library to the runtime component. - IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) - SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} - COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} - ) - ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) + ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) - # Install the archive to the lib directory. + # Install the archive to the lib directory. + SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} + ARCHIVE DESTINATION ${KWSYS_INSTALL_LIB_DIR} + ) + # Assign the archive to the development component. + IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} - ARCHIVE DESTINATION ${KWSYS_INSTALL_LIB_DIR} + COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT} ) - # Assign the archive to the development component. - IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) - SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} - COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT} - ) - ENDIF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) - ENDIF(KWSYS_INSTALL_LIB_DIR) - IF(KWSYS_INSTALL_BIN_DIR) - # Install the runtime library to the bin directory. + ENDIF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT) +ENDIF(KWSYS_INSTALL_LIB_DIR) +IF(KWSYS_INSTALL_BIN_DIR) + # Install the runtime library to the bin directory. + SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} + RUNTIME DESTINATION ${KWSYS_INSTALL_BIN_DIR} + ) + # Assign the runtime library to the runtime component. + IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} - RUNTIME DESTINATION ${KWSYS_INSTALL_BIN_DIR} + COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} ) - # Assign the runtime library to the runtime component. - IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) - SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE} - COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME} - ) - ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) - ENDIF(KWSYS_INSTALL_BIN_DIR) - - # Do not support old KWSYS_*_INSTALL_DIR variable names. - SET(KWSYS_HEADER_INSTALL_DIR) - SET(KWSYS_LIBRARY_INSTALL_DIR) - -ELSE(COMMAND INSTALL) - # Use old KWSYS_*_INSTALL_DIR variable names. - # Take defaults from the new names. - IF(KWSYS_INSTALL_LIB_DIR) - IF(NOT KWSYS_LIBRARY_INSTALL_DIR) - SET(KWSYS_LIBRARY_INSTALL_DIR "/${KWSYS_INSTALL_LIB_DIR}") - ENDIF(NOT KWSYS_LIBRARY_INSTALL_DIR) - ENDIF(KWSYS_INSTALL_LIB_DIR) - IF(KWSYS_INSTALL_INCLUDE_DIR) - IF(NOT KWSYS_HEADER_INSTALL_DIR) - SET(KWSYS_HEADER_INSTALL_DIR "/${KWSYS_INSTALL_INCLUDE_DIR}") - ENDIF(NOT KWSYS_HEADER_INSTALL_DIR) - ENDIF(KWSYS_INSTALL_INCLUDE_DIR) + ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME) +ENDIF(KWSYS_INSTALL_BIN_DIR) - # Do not support new KWSYS_INSTALL_*_DIR variable names. - SET(KWSYS_INSTALL_BIN_DIR) - SET(KWSYS_INSTALL_INCLUDE_DIR) - SET(KWSYS_INSTALL_LIB_DIR) -ENDIF(COMMAND INSTALL) +# Do not support old KWSYS_*a_INSTALL_DIR variable names. +SET(KWSYS_HEADER_INSTALL_DIR) +SET(KWSYS_LIBRARY_INSTALL_DIR) # Generated source files will need this header. STRING(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}" @@ -680,10 +619,6 @@ FOREACH(header DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl ${KWSYS_INSTALL_INCLUDE_OPTIONS}) ENDIF(KWSYS_INSTALL_INCLUDE_DIR) - IF(KWSYS_HEADER_INSTALL_DIR) - INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/stl - FILES ${KWSYS_HEADER_DIR}/stl/${header}.hxx) - ENDIF(KWSYS_HEADER_INSTALL_DIR) ELSE(KWSYS_STL_HEADER_EXTRA_${header}) SET(KWSYS_STL_HEADER_EXTRA "") ENDIF(KWSYS_STL_HEADER_EXTRA_${header}) @@ -697,10 +632,6 @@ FOREACH(header DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl ${KWSYS_INSTALL_INCLUDE_OPTIONS}) ENDIF(KWSYS_INSTALL_INCLUDE_DIR) - IF(KWSYS_HEADER_INSTALL_DIR) - INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/stl - FILES ${KWSYS_HEADER_DIR}/stl/${header}) - ENDIF(KWSYS_HEADER_INSTALL_DIR) ENDFOREACH(header) # Provide cstddef header. @@ -711,10 +642,6 @@ IF(KWSYS_INSTALL_INCLUDE_DIR) INSTALL(FILES ${KWSYS_HEADER_DIR}/cstddef DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_INCLUDE_OPTIONS}) - IF(KWSYS_HEADER_INSTALL_DIR) - INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE} - FILES ${KWSYS_HEADER_DIR}/cstddef) - ENDIF(KWSYS_HEADER_INSTALL_DIR) ENDIF(KWSYS_INSTALL_INCLUDE_DIR) #----------------------------------------------------------------------------- @@ -732,10 +659,6 @@ FOREACH(header iostream fstream sstream iosfwd) DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/ios ${KWSYS_INSTALL_INCLUDE_OPTIONS}) ENDIF(KWSYS_INSTALL_INCLUDE_DIR) - IF(KWSYS_HEADER_INSTALL_DIR) - INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/ios - FILES ${KWSYS_HEADER_DIR}/ios/${header}) - ENDIF(KWSYS_HEADER_INSTALL_DIR) ENDFOREACH(header) #----------------------------------------------------------------------------- @@ -824,10 +747,6 @@ FOREACH(c ${KWSYS_CLASSES}) DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_INCLUDE_OPTIONS}) ENDIF(KWSYS_INSTALL_INCLUDE_DIR) - IF(KWSYS_HEADER_INSTALL_DIR) - INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE} - FILES ${KWSYS_HEADER_DIR}/${c}.hxx) - ENDIF(KWSYS_HEADER_INSTALL_DIR) ENDFOREACH(c) # Configure C headers. @@ -843,10 +762,6 @@ FOREACH(h ${KWSYS_H_FILES}) DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_INCLUDE_OPTIONS}) ENDIF(KWSYS_INSTALL_INCLUDE_DIR) - IF(KWSYS_HEADER_INSTALL_DIR) - INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE} - FILES ${KWSYS_HEADER_DIR}/${h}.h) - ENDIF(KWSYS_HEADER_INSTALL_DIR) ENDFOREACH(h) # Configure other C++ headers. @@ -862,10 +777,6 @@ FOREACH(h ${KWSYS_HXX_FILES}) DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE} ${KWSYS_INSTALL_INCLUDE_OPTIONS}) ENDIF(KWSYS_INSTALL_INCLUDE_DIR) - IF(KWSYS_HEADER_INSTALL_DIR) - INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE} - FILES ${KWSYS_HEADER_DIR}/${h}.hxx) - ENDIF(KWSYS_HEADER_INSTALL_DIR) ENDFOREACH(h) #----------------------------------------------------------------------------- @@ -873,7 +784,7 @@ ENDFOREACH(h) IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) ADD_LIBRARY(${KWSYS_NAMESPACE} ${KWSYS_LIBRARY_TYPE} ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS}) - KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY LABELS ${KWSYS_LABELS_LIB}) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY LABELS ${KWSYS_LABELS_LIB}) IF(KWSYS_USE_DynamicLoader) IF(UNIX) TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS}) @@ -895,15 +806,12 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) IF(KWSYS_INSTALL_LIBRARY_RULE) INSTALL(TARGETS ${KWSYS_NAMESPACE} ${KWSYS_INSTALL_LIBRARY_RULE}) ENDIF(KWSYS_INSTALL_LIBRARY_RULE) - IF(KWSYS_LIBRARY_INSTALL_DIR) - INSTALL_TARGETS(${KWSYS_LIBRARY_INSTALL_DIR} ${KWSYS_NAMESPACE}) - ENDIF(KWSYS_LIBRARY_INSTALL_DIR) ENDIF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS) # Add a C-only library if requested. IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS) ADD_LIBRARY(${KWSYS_NAMESPACE}_c ${KWSYS_LIBRARY_TYPE} ${KWSYS_C_SRCS}) - KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}_c PROPERTY LABELS ${KWSYS_LABELS_LIB}) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}_c PROPERTY LABELS ${KWSYS_LABELS_LIB}) # Apply user-defined target properties to the library. IF(KWSYS_PROPERTIES_C) @@ -916,9 +824,6 @@ IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS) IF(KWSYS_INSTALL_LIBRARY_RULE) INSTALL(TARGETS ${KWSYS_NAMESPACE}_c ${KWSYS_INSTALL_LIBRARY_RULE}) ENDIF(KWSYS_INSTALL_LIBRARY_RULE) - IF(KWSYS_LIBRARY_INSTALL_DIR) - INSTALL_TARGETS(${KWSYS_LIBRARY_INSTALL_DIR} ${KWSYS_NAMESPACE}_c) - ENDIF(KWSYS_LIBRARY_INSTALL_DIR) ENDIF(KWSYS_ENABLE_C AND KWSYS_C_SRCS) # For building kwsys itself, we use a macro defined on the command @@ -942,14 +847,10 @@ IF(KWSYS_USE_Process) # encode it into a C file. ADD_EXECUTABLE(${KWSYS_NAMESPACE}ProcessFwd9x ProcessFwd9x.c) ADD_EXECUTABLE(${KWSYS_NAMESPACE}EncodeExecutable EncodeExecutable.c) - KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}ProcessFwd9x PROPERTY LABELS ${KWSYS_LABELS_EXE}) - KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}EncodeExecutable PROPERTY LABELS ${KWSYS_LABELS_EXE}) - - # Construct the location of the executable to be encoded. - SET(BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}) - IF(EXECUTABLE_OUTPUT_PATH) - SET(BIN_DIR ${EXECUTABLE_OUTPUT_PATH}) - ENDIF(EXECUTABLE_OUTPUT_PATH) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}ProcessFwd9x PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}EncodeExecutable PROPERTY RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}ProcessFwd9x PROPERTY LABELS ${KWSYS_LABELS_EXE}) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}EncodeExecutable PROPERTY LABELS ${KWSYS_LABELS_EXE}) SET(CFG_INTDIR "/${CMAKE_CFG_INTDIR}") IF(CMAKE_BUILD_TOOL MATCHES "make") @@ -957,25 +858,14 @@ IF(KWSYS_USE_Process) ENDIF(CMAKE_BUILD_TOOL MATCHES "make") # Take advantage of a better custom command syntax if possible. - SET(CMD ${BIN_DIR}${CFG_INTDIR}/${KWSYS_NAMESPACE}EncodeExecutable.exe) - SET(FWD ${BIN_DIR}${CFG_INTDIR}/${KWSYS_NAMESPACE}ProcessFwd9x.exe) - IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.6) - ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c - COMMAND ${CMD} - ARGS ${FWD} ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c - ${KWSYS_NAMESPACE} ProcessFwd9x - DEPENDS ${CMD} ${FWD}) - ELSE("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.6) - ADD_CUSTOM_COMMAND( - TARGET ${KWSYS_NAMESPACE} - SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/ProcessFwd9x.c - COMMAND ${CMD} - ARGS ${FWD} ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c - ${KWSYS_NAMESPACE} ProcessFwd9x - OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c - DEPENDS ${CMD} ${FWD}) - ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.6) + SET(CMD ${CMAKE_CURRENT_BINARY_DIR}${CFG_INTDIR}/${KWSYS_NAMESPACE}EncodeExecutable.exe) + SET(FWD ${CMAKE_CURRENT_BINARY_DIR}${CFG_INTDIR}/${KWSYS_NAMESPACE}ProcessFwd9x.exe) + ADD_CUSTOM_COMMAND( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c + COMMAND ${CMD} + ARGS ${FWD} ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c + ${KWSYS_NAMESPACE} ProcessFwd9x + DEPENDS ${CMD} ${FWD}) # Make sure build occurs in proper order. ADD_DEPENDENCIES(${KWSYS_NAMESPACE} ${KWSYS_NAMESPACE}ProcessFwd9x @@ -998,19 +888,19 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) testEncode testTerminal ) - IF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE) + IF(KWSYS_STANDALONE) SET(KWSYS_C_TESTS ${KWSYS_C_TESTS} testFail) - ENDIF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE) + ENDIF() CREATE_TEST_SOURCELIST( KWSYS_C_TEST_SRCS ${KWSYS_NAMESPACE}TestsC.c ${KWSYS_C_TESTS} ) ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsC ${KWSYS_C_TEST_SRCS}) - KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsC PROPERTY LABELS ${KWSYS_LABELS_EXE}) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsC PROPERTY LABELS ${KWSYS_LABELS_EXE}) TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsC ${KWSYS_NAMESPACE}_c) FOREACH(test ${KWSYS_C_TESTS}) ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}}) - KWSYS_SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST}) + SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST}) ENDFOREACH(test) # C++ tests @@ -1034,7 +924,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader) # If kwsys contains the DynamicLoader, need extra library ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c) - KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB}) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB}) ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestDynload ${KWSYS_NAMESPACE}) ENDIF(KWSYS_USE_DynamicLoader) CREATE_TEST_SOURCELIST( @@ -1042,7 +932,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) ${KWSYS_CXX_TESTS} ) ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_CXX_TEST_SRCS}) - KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY LABELS ${KWSYS_LABELS_EXE}) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY LABELS ${KWSYS_LABELS_EXE}) TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_NAMESPACE}) SET(TEST_SYSTEMTOOLS_BIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/testSystemTools.bin") @@ -1089,19 +979,19 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) ) FOREACH(test ${KWSYS_CXX_TESTS}) ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}}) - KWSYS_SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST}) + SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST}) ENDFOREACH(test) # Process tests. ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestProcess testProcess.c) - KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestProcess PROPERTY LABELS ${KWSYS_LABELS_EXE}) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestProcess PROPERTY LABELS ${KWSYS_LABELS_EXE}) TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestProcess ${KWSYS_NAMESPACE}_c) IF(NOT CYGWIN) SET(KWSYS_TEST_PROCESS_7 7) ENDIF(NOT CYGWIN) FOREACH(n 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7}) ADD_TEST(kwsys.testProcess-${n} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n}) - KWSYS_SET_PROPERTY(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST}) + SET_PROPERTY(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST}) SET_TESTS_PROPERTIES(kwsys.testProcess-${n} PROPERTIES TIMEOUT 120) ENDFOREACH(n) @@ -1115,13 +1005,13 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) ${PROJECT_BINARY_DIR}/testSharedForward.c @ONLY IMMEDIATE) ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestSharedForward ${PROJECT_BINARY_DIR}/testSharedForward.c) - KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestSharedForward PROPERTY LABELS ${KWSYS_LABELS_EXE}) + SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestSharedForward PROPERTY LABELS ${KWSYS_LABELS_EXE}) ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestSharedForward ${KWSYS_NAMESPACE}_c) ADD_TEST(kwsys.testSharedForward ${EXEC_DIR}/${KWSYS_NAMESPACE}TestSharedForward 1) - KWSYS_SET_PROPERTY(TEST kwsys.testSharedForward PROPERTY LABELS ${KWSYS_LABELS_TEST}) + SET_PROPERTY(TEST kwsys.testSharedForward PROPERTY LABELS ${KWSYS_LABELS_TEST}) # Configure some test properties. - IF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE) + IF(KWSYS_STANDALONE) # We expect test to fail SET_TESTS_PROPERTIES(kwsys.testFail PROPERTIES WILL_FAIL ON) GET_TEST_PROPERTY(kwsys.testFail WILL_FAIL wfv) @@ -1129,7 +1019,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET_TESTS_PROPERTIES(kwsys.testRegistry PROPERTIES PASS_REGULAR_EXPRESSION "Test passed") SET_TESTS_PROPERTIES(kwsys.testFail PROPERTIES MEASUREMENT "Some Key=Some Value") MESSAGE(STATUS "GET_TEST_PROPERTY returned: ${wfv}") - ENDIF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE) + ENDIF() # Suppress known consistent failures on buggy systems. IF(KWSYS_TEST_BOGUS_FAILURES) diff --git a/Source/kwsys/CheckCXXSourceRuns.cmake b/Source/kwsys/CheckCXXSourceRuns.cmake deleted file mode 100644 index 7bcc87387..000000000 --- a/Source/kwsys/CheckCXXSourceRuns.cmake +++ /dev/null @@ -1,62 +0,0 @@ -# - Check if the source code provided in the SOURCE argument compiles. -# CHECK_CXX_SOURCE_COMPILES(SOURCE VAR) -# - macro which checks if the source code compiles\ -# SOURCE - source code to try to compile -# VAR - variable to store size if the type exists. -# -# The following variables may be set before calling this macro to -# modify the way the check is run: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -MACRO(CHECK_CXX_SOURCE_RUNS SOURCE VAR COMMENT) - IF("HAVE_${VAR}" MATCHES "^HAVE_${VAR}$") - SET(MACRO_CHECK_FUNCTION_DEFINITIONS - "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") - IF(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") - ELSE(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES) - ENDIF(CMAKE_REQUIRED_LIBRARIES) - IF(CMAKE_REQUIRED_INCLUDES) - SET(CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES - "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") - ELSE(CMAKE_REQUIRED_INCLUDES) - SET(CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES) - ENDIF(CMAKE_REQUIRED_INCLUDES) - SET(CMAKE_EMPTY_INPUT_FILE_CONTENT "${SOURCE}") - CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/CMakeEmptyInputFile.in" - "${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/src.cxx" IMMEDIATE) - - MESSAGE(STATUS "Performing Test ${COMMENT}") - TRY_RUN(${VAR} HAVE_${VAR} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeTmp/src.cxx - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} - "${CHECK_CXX_SOURCE_COMPILES_ADD_LIBRARIES}" - "${CHECK_CXX_SOURCE_COMPILES_ADD_INCLUDES}" - OUTPUT_VARIABLE OUTPUT) - IF(HAVE_${VAR}) - SET(${VAR} 1 CACHE INTERNAL "Test ${COMMENT}") - MESSAGE(STATUS "Performing Test ${COMMENT} - Success") - FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log - "Performing C++ SOURCE FILE Test ${COMMENT} succeded with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${SOURCE}\n") - ELSE(HAVE_${VAR}) - MESSAGE(STATUS "Performing Test ${COMMENT} - Failed") - SET(${VAR} "" CACHE INTERNAL "Test ${COMMENT}") - FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log - "Performing C++ SOURCE FILE Test ${COMMENT} failed with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${SOURCE}\n") - ENDIF(HAVE_${VAR}) - ENDIF("HAVE_${VAR}" MATCHES "^HAVE_${VAR}$") -ENDMACRO(CHECK_CXX_SOURCE_RUNS) - - diff --git a/Source/kwsys/EncodeExecutable.c b/Source/kwsys/EncodeExecutable.c index ba474b89c..bc30568ff 100644 --- a/Source/kwsys/EncodeExecutable.c +++ b/Source/kwsys/EncodeExecutable.c @@ -41,6 +41,7 @@ int main(int argc, char* argv[]) if(!ofp) { fprintf(stderr, "Cannot open output file: \"%s\"\n", argv[2]); + fclose(ifp); return 2; } diff --git a/Source/kwsys/Terminal.c b/Source/kwsys/Terminal.c index 3bf257996..7a3266f5e 100644 --- a/Source/kwsys/Terminal.c +++ b/Source/kwsys/Terminal.c @@ -160,6 +160,7 @@ static const char* kwsysTerminalVT100Names[] = "rxvt-cygwin", "rxvt-cygwin-native", "rxvt-unicode", + "rxvt-unicode-256color", "screen", "screen-256color", "screen-bce", diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 2fc508632..ece79a4e5 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -15,7 +15,7 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 02) +SET(KWSYS_DATE_STAMP_MONTH 06) # KWSys version date day component. Format is DD. SET(KWSYS_DATE_STAMP_DAY 15) diff --git a/Tests/Assembler/CMakeLists.txt b/Tests/Assembler/CMakeLists.txt index b2937bbb1..ad27e57e9 100644 --- a/Tests/Assembler/CMakeLists.txt +++ b/Tests/Assembler/CMakeLists.txt @@ -1,26 +1,32 @@ cmake_minimum_required (VERSION 2.6) -project(Assembler) +project(Assembler C) +message("CTEST_FULL_OUTPUT ") +set(CMAKE_VERBOSE_MAKEFILE 1) set(SRCS) -# if no file has been set as source and we are on linux with an x86 processor try to use the gas/as assembler -# main-linux-x86-gas.s seems to work for Linux and FreeBSD -if(NOT SRCS AND CMAKE_SYSTEM_PROCESSOR MATCHES "[ix].?86$") - if(CMAKE_SYSTEM MATCHES Linux OR CMAKE_SYSTEM MATCHES FreeBSD) - message(STATUS "Trying to enable ASM-ATT for Linux or FreeBSD on x86") - enable_language(ASM-ATT OPTIONAL) - if(CMAKE_ASM-ATT_COMPILER_WORKS) - message(STATUS "Trying to enable ASM-ATT for Linux/x86 - succeeded") - # this assembler file was created using gcc -S main.c - set(SRCS main-linux-x86-gas.s) - endif(CMAKE_ASM-ATT_COMPILER_WORKS) - endif(CMAKE_SYSTEM MATCHES Linux OR CMAKE_SYSTEM MATCHES FreeBSD) -endif(NOT SRCS AND CMAKE_SYSTEM_PROCESSOR MATCHES "[ix].?86$") +# (at least) the following toolchains can process assembler files directly +# and also generate assembler files from C: +if("${CMAKE_GENERATOR}" MATCHES "Makefile") + if(("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|HP|SunPro|XL)$") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" AND UNIX)) + set(C_FLAGS "${CMAKE_C_FLAGS}") + separate_arguments(C_FLAGS) + set(SRCS main.s) + add_custom_command( + OUTPUT main.s + COMMAND ${CMAKE_C_COMPILER} ${C_FLAGS} -S ${CMAKE_CURRENT_SOURCE_DIR}/main.c -o main.s + DEPENDS main.c + VERBATIM + ) + endif(("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|HP|SunPro|XL)$") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" AND UNIX)) +endif("${CMAKE_GENERATOR}" MATCHES "Makefile") -if(NOT SRCS) + +if(SRCS) + enable_language(ASM OPTIONAL) +else(SRCS) message(STATUS "No assembler enabled, using C") set(SRCS main.c) -endif(NOT SRCS) +endif(SRCS) add_executable(HelloAsm ${SRCS}) -set_target_properties(HelloAsm PROPERTIES LINKER_LANGUAGE C) diff --git a/Tests/BundleTest/BundleLib.cxx b/Tests/BundleTest/BundleLib.cxx index bab745e46..b68ee25dd 100644 --- a/Tests/BundleTest/BundleLib.cxx +++ b/Tests/BundleTest/BundleLib.cxx @@ -3,7 +3,7 @@ #include #include -#include +#include int fileExists(char* filename) { @@ -51,7 +51,7 @@ int findBundleFile(char* exec, const char* file) int foo(char *exec) { - // Call a "Carbon" function... + // Call a CoreFoundation function... // CFBundleRef br = CFBundleGetMainBundle(); (void) br; diff --git a/Tests/BundleTest/BundleTest.cxx b/Tests/BundleTest/BundleTest.cxx index 29d17dbbe..a66d601d3 100644 --- a/Tests/BundleTest/BundleTest.cxx +++ b/Tests/BundleTest/BundleTest.cxx @@ -1,6 +1,6 @@ #include -#include +#include extern int foo(char* exec); @@ -8,8 +8,8 @@ int main(int argc, char* argv[]) { printf("Started with: %d arguments\n", argc); - // Call a "Carbon" function... but pull in the link dependency on "-framework - // Carbon" via CMake's dependency chaining mechanism. This code exists to + // Call a CoreFoundation function... but pull in the link dependency on "-framework + // CoreFoundation" via CMake's dependency chaining mechanism. This code exists to // verify that the chaining mechanism works with "-framework blah" style // link dependencies. // diff --git a/Tests/BundleTest/CMakeLists.txt b/Tests/BundleTest/CMakeLists.txt index 5ccf2bf85..5342f49bd 100644 --- a/Tests/BundleTest/CMakeLists.txt +++ b/Tests/BundleTest/CMakeLists.txt @@ -25,14 +25,14 @@ SET_SOURCE_FILES_PROPERTIES( SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/foobar") # Test building a bundle linking to a shared library where the -# shared library links to Carbon, but the executable does not -# explicitly link to Carbon, but the executable does *depend* -# on Carbon. There should be a link failure for the executable +# shared library links to CoreFoundation, but the executable does not +# explicitly link to CoreFoundation, but the executable does *depend* +# on CoreFoundation. There should be a link failure for the executable # if CMake's dependency chaining for libraries with "-framework # blah" style dependencies gets broken... # ADD_LIBRARY(BundleTestLib SHARED BundleLib.cxx) -TARGET_LINK_LIBRARIES(BundleTestLib "-framework Carbon") +TARGET_LINK_LIBRARIES(BundleTestLib "-framework CoreFoundation") ADD_EXECUTABLE(BundleTest MACOSX_BUNDLE @@ -43,8 +43,8 @@ ADD_EXECUTABLE(BundleTest ) TARGET_LINK_LIBRARIES(BundleTest BundleTestLib) # -# DO NOT: TARGET_LINK_LIBRARIES(BundleTest "-framework Carbon") -# (see above comments about Carbon) +# DO NOT: TARGET_LINK_LIBRARIES(BundleTest "-framework CoreFoundation") +# (see above comments about CoreFoundation) # # Test bundle installation. diff --git a/Tests/BundleUtilities/CMakeLists.txt b/Tests/BundleUtilities/CMakeLists.txt new file mode 100644 index 000000000..6209c8fcd --- /dev/null +++ b/Tests/BundleUtilities/CMakeLists.txt @@ -0,0 +1,84 @@ +cmake_minimum_required(VERSION 2.8) +project(BundleUtilities) + +###### the various types of dependencies we can have + +# a shared library +add_library(shared SHARED shared.cpp shared.h) + +# another shared library +add_library(shared2 SHARED shared2.cpp shared2.h) + + +# a framework library +add_library(framework SHARED framework.cpp framework.h) +# TODO: fix problems with local frameworks without rpaths +#set_target_properties(framework PROPERTIES FRAMEWORK 1) + +# make sure rpaths are not helping BundleUtilities or the executables +set_target_properties(shared shared2 framework PROPERTIES + SKIP_BUILD_RPATH 1) + + +###### test a Bundle application using dependencies + +# a loadable module (depends on shared2) +# testbundleutils1 will load this at runtime +add_library(module1 MODULE module.cpp module.h) +set_target_properties(module1 PROPERTIES PREFIX "") +get_target_property(module_loc module1 LOCATION) +target_link_libraries(module1 shared2) + +# a bundle application +add_executable(testbundleutils1 MACOSX_BUNDLE testbundleutils1.cpp) +target_link_libraries(testbundleutils1 shared framework ${CMAKE_DL_LIBS}) +get_target_property(loc testbundleutils1 LOCATION) + +set_target_properties(testbundleutils1 module1 PROPERTIES + INSTALL_RPATH "${CMAKE_CURRENT_BINARY_DIR}/testdir1" + BUILD_WITH_INSTALL_RPATH 1) + +# add custom target to install and test the app +add_custom_target(testbundleutils1_test ALL + COMMAND ${CMAKE_COMMAND} + "-DINPUT=${loc}" + "-DMODULE=${module_loc}" + "-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" + "-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir1" + -P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake" + DEPENDS testbundleutils1 module1 + ) + +add_dependencies(testbundleutils1_test testbundleutils1) + + + +###### test a non-Bundle application using dependencies + +# a loadable module (depends on shared2) +# testbundleutils2 will load this at runtime +add_library(module2 MODULE module.cpp module.h) +set_target_properties(module2 PROPERTIES PREFIX "") +get_target_property(module_loc module2 LOCATION) +target_link_libraries(module2 shared2) + +# a non-bundle application +add_executable(testbundleutils2 testbundleutils2.cpp) +target_link_libraries(testbundleutils2 shared framework ${CMAKE_DL_LIBS}) +get_target_property(loc testbundleutils2 LOCATION) + +set_target_properties(testbundleutils2 module2 PROPERTIES + INSTALL_RPATH "${CMAKE_CURRENT_BINARY_DIR}/testdir2" + BUILD_WITH_INSTALL_RPATH 1) + +# add custom target to install and test the app +add_custom_target(testbundleutils2_test ALL + COMMAND ${CMAKE_COMMAND} + "-DINPUT=${loc}" + "-DMODULE=${module_loc}" + "-DINPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}" + "-DOUTPUTDIR=${CMAKE_CURRENT_BINARY_DIR}/testdir2" + -P "${CMAKE_CURRENT_SOURCE_DIR}/bundleutils.cmake" + DEPENDS testbundleutils1 module2 + ) +add_dependencies(testbundleutils2_test testbundleutils2) diff --git a/Tests/BundleUtilities/bundleutils.cmake b/Tests/BundleUtilities/bundleutils.cmake new file mode 100644 index 000000000..46765e733 --- /dev/null +++ b/Tests/BundleUtilities/bundleutils.cmake @@ -0,0 +1,45 @@ + +# clean passed in arguments +get_filename_component(INPUT ${INPUT} ABSOLUTE) +get_filename_component(INPUTDIR ${INPUTDIR} ABSOLUTE) + +message("INPUT = ${INPUT}") +message("MODULE = ${MODULE}") +message("INPUTDIR = ${INPUTDIR}") +message("OUTPUTDIR = ${OUTPUTDIR}") + +# compute location to install/test things +file(RELATIVE_PATH relative_exe "${INPUTDIR}" "${INPUT}") +set(OUTPUT "${OUTPUTDIR}/${relative_exe}") +message("OUTPUT = ${OUTPUT}") +get_filename_component(EXE_DIR "${OUTPUT}" PATH) +get_filename_component(MODULE_NAME "${MODULE}" NAME) +set(OUTPUT_MODULE "${EXE_DIR}/${MODULE_NAME}") +message("OUTPUTMODULE = ${OUTPUT_MODULE}") + +# clean output dir +file(REMOVE_RECURSE "${OUTPUTDIR}") +# copy the app and plugin to installation/testing directory +configure_file("${INPUT}" "${OUTPUT}" COPYONLY) +configure_file("${MODULE}" "${OUTPUT_MODULE}" COPYONLY) + +# have BundleUtilities grab all dependencies and +# check that the app runs + +# for this test we'll override location to put all dependencies +# (in the same dir as the app) +# this shouldn't be necessary except for the non-bundle case on Mac +function(gp_item_default_embedded_path_override item path) + set(path "@executable_path" PARENT_SCOPE) +endfunction(gp_item_default_embedded_path_override) + +include(BundleUtilities) +fixup_bundle("${OUTPUT}" "${OUTPUT_MODULE}" "${INPUTDIR}") + +# make sure we can run the app +message("Executing ${OUTPUT} in ${EXE_DIR}") +execute_process(COMMAND "${OUTPUT}" RESULT_VARIABLE result OUTPUT_VARIABLE out ERROR_VARIABLE out WORKING_DIRECTORY "${EXE_DIR}") + +if(NOT result STREQUAL "0") + message(FATAL_ERROR " failed to execute test program\n${out}") +endif(NOT result STREQUAL "0") diff --git a/Tests/BundleUtilities/framework.cpp b/Tests/BundleUtilities/framework.cpp new file mode 100644 index 000000000..abda195ed --- /dev/null +++ b/Tests/BundleUtilities/framework.cpp @@ -0,0 +1,8 @@ + +#include "framework.h" +#include "stdio.h" + +void framework() +{ + printf("framework\n"); +} diff --git a/Tests/BundleUtilities/framework.h b/Tests/BundleUtilities/framework.h new file mode 100644 index 000000000..bdd10f05d --- /dev/null +++ b/Tests/BundleUtilities/framework.h @@ -0,0 +1,17 @@ + +#ifndef framework_h +#define framework_h + +#ifdef WIN32 +# ifdef framework_EXPORTS +# define FRAMEWORK_EXPORT __declspec(dllexport) +# else +# define FRAMEWORK_EXPORT __declspec(dllimport) +# endif +#else +# define FRAMEWORK_EXPORT +#endif + +void FRAMEWORK_EXPORT framework(); + +#endif diff --git a/Tests/BundleUtilities/module.cpp b/Tests/BundleUtilities/module.cpp new file mode 100644 index 000000000..ee1b542fb --- /dev/null +++ b/Tests/BundleUtilities/module.cpp @@ -0,0 +1,10 @@ + +#include "module.h" +#include "stdio.h" +#include "shared2.h" + +void module() +{ + printf("module\n"); + shared2(); +} diff --git a/Tests/BundleUtilities/module.h b/Tests/BundleUtilities/module.h new file mode 100644 index 000000000..0659bc742 --- /dev/null +++ b/Tests/BundleUtilities/module.h @@ -0,0 +1,7 @@ + +#ifndef module_h +#define module_h + +void module(); + +#endif diff --git a/Tests/BundleUtilities/shared.cpp b/Tests/BundleUtilities/shared.cpp new file mode 100644 index 000000000..e5e7dc5ae --- /dev/null +++ b/Tests/BundleUtilities/shared.cpp @@ -0,0 +1,8 @@ + +#include "shared.h" +#include "stdio.h" + +void shared() +{ + printf("shared\n"); +} diff --git a/Tests/BundleUtilities/shared.h b/Tests/BundleUtilities/shared.h new file mode 100644 index 000000000..3588fb88e --- /dev/null +++ b/Tests/BundleUtilities/shared.h @@ -0,0 +1,17 @@ + +#ifndef shared_h +#define shared_h + +#ifdef WIN32 +# ifdef shared_EXPORTS +# define SHARED_EXPORT __declspec(dllexport) +# else +# define SHARED_EXPORT __declspec(dllimport) +# endif +#else +# define SHARED_EXPORT +#endif + +void SHARED_EXPORT shared(); + +#endif diff --git a/Tests/BundleUtilities/shared2.cpp b/Tests/BundleUtilities/shared2.cpp new file mode 100644 index 000000000..84af5d061 --- /dev/null +++ b/Tests/BundleUtilities/shared2.cpp @@ -0,0 +1,8 @@ + +#include "shared2.h" +#include "stdio.h" + +void shared2() +{ + printf("shared2\n"); +} diff --git a/Tests/BundleUtilities/shared2.h b/Tests/BundleUtilities/shared2.h new file mode 100644 index 000000000..d53546cb0 --- /dev/null +++ b/Tests/BundleUtilities/shared2.h @@ -0,0 +1,17 @@ + +#ifndef shared2_h +#define shared2_h + +#ifdef WIN32 +# ifdef shared2_EXPORTS +# define SHARED2_EXPORT __declspec(dllexport) +# else +# define SHARED2_EXPORT __declspec(dllimport) +# endif +#else +# define SHARED2_EXPORT +#endif + +void SHARED2_EXPORT shared2(); + +#endif diff --git a/Tests/BundleUtilities/testbundleutils1.cpp b/Tests/BundleUtilities/testbundleutils1.cpp new file mode 100644 index 000000000..23d3cbd2e --- /dev/null +++ b/Tests/BundleUtilities/testbundleutils1.cpp @@ -0,0 +1,33 @@ + +#include "framework.h" +#include "shared.h" +#include "stdio.h" + +#if defined(WIN32) +#include +#else +#include "dlfcn.h" +#endif + +int main(int, char**) +{ + framework(); + shared(); + +#if defined(WIN32) + HANDLE lib = LoadLibraryA("module1.dll"); + if(!lib) + { + printf("Failed to open module1\n"); + } +#else + void* lib = dlopen("module1.so", RTLD_LAZY); + if(!lib) + { + printf("Failed to open module1\n%s\n", dlerror()); + } +#endif + + + return lib == 0 ? 1 : 0; +} diff --git a/Tests/BundleUtilities/testbundleutils2.cpp b/Tests/BundleUtilities/testbundleutils2.cpp new file mode 100644 index 000000000..319be8984 --- /dev/null +++ b/Tests/BundleUtilities/testbundleutils2.cpp @@ -0,0 +1,33 @@ + +#include "framework.h" +#include "shared.h" +#include "stdio.h" + +#if defined(WIN32) +#include +#else +#include "dlfcn.h" +#endif + +int main(int, char**) +{ + framework(); + shared(); + +#if defined(WIN32) + HANDLE lib = LoadLibraryA("module2.dll"); + if(!lib) + { + printf("Failed to open module2\n"); + } +#else + void* lib = dlopen("module2.so", RTLD_LAZY); + if(!lib) + { + printf("Failed to open module2\n%s\n", dlerror()); + } +#endif + + + return lib == 0 ? 1 : 0; +} diff --git a/Tests/CFBundleTest/CMakeLists.txt b/Tests/CFBundleTest/CMakeLists.txt new file mode 100644 index 000000000..8fd9efdc6 --- /dev/null +++ b/Tests/CFBundleTest/CMakeLists.txt @@ -0,0 +1,56 @@ +#this is adapted from FireBreath (http://www.firebreath.org) + +cmake_minimum_required(VERSION 2.8) + +project(CFBundleTest) + +include(PluginConfig.cmake) + +message ("Creating Mac Browser Plugin project ${PROJECT_NAME}") +set(SOURCES + np_macmain.cpp + Localized.r + ${CMAKE_CURRENT_BINARY_DIR}/Info.plist + ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings + ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc +) + +add_library( ${PROJECT_NAME} MODULE + ${SOURCES} + ) + +set (RCFILES ${CMAKE_CURRENT_SOURCE_DIR}/Localized.r) + +configure_file(Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) +configure_file(InfoPlist.strings.in ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings) + +# Compile the resource file +find_program(RC_COMPILER Rez NO_DEFAULT_PATHS PATHS /Developer/Tools) +if(NOT RC_COMPILER) + message(FATAL_ERROR "could not find Rez to build resources from .r file...") +endif() + +execute_process(COMMAND + ${RC_COMPILER} ${RCFILES} -useDF -o ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc + ) + +set_source_files_properties( + ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc + PROPERTIES GENERATED 1 + ) +# note that for some reason, the makefile and xcode generators use a different +# property to indicate where the Info.plist file is :-/ For that reason, we +# specify it twice so it will work both places +set_target_properties(CFBundleTest PROPERTIES + BUNDLE 1 + BUNDLE_EXTENSION plugin + XCODE_ATTRIBUTE_WRAPPER_EXTENSION plugin #sets the extension to .plugin + XCODE_ATTRIBUTE_MACH_O_TYPE mh_bundle + XCODE_ATTRIBUTE_INFOPLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/Info.plist + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_BINARY_DIR}/Info.plist + LINK_FLAGS "-Wl,-exported_symbols_list,\"${CMAKE_CURRENT_SOURCE_DIR}/ExportList_plugin.txt\"") + +set_source_files_properties( + ${CMAKE_CURRENT_BINARY_DIR}/InfoPlist.strings + ${CMAKE_CURRENT_BINARY_DIR}/Localized.rsrc + PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/English.lproj") diff --git a/Tests/CFBundleTest/ExportList_plugin.txt b/Tests/CFBundleTest/ExportList_plugin.txt new file mode 100644 index 000000000..31d6f640d --- /dev/null +++ b/Tests/CFBundleTest/ExportList_plugin.txt @@ -0,0 +1,3 @@ +_NP_GetEntryPoints +_NP_Initialize +_NP_Shutdown diff --git a/Tests/CFBundleTest/Info.plist.in b/Tests/CFBundleTest/Info.plist.in new file mode 100644 index 000000000..638002f34 --- /dev/null +++ b/Tests/CFBundleTest/Info.plist.in @@ -0,0 +1,54 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${PLUGIN_NAME} + CFBundleGetInfoString + ${PLUGIN_NAME} ${FBSTRING_PLUGIN_VERSION}, ${FBSTRING_LegalCopyright} + CFBundleIdentifier + com.${ACTIVEX_PROGID} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BRPL + CFBundleShortVersionString + ${PLUGIN_NAME} ${FBSTRING_PLUGIN_VERSION} + CFBundleSignature + ???? + CFBundleVersion + ${FBSTRING_PLUGIN_VERSION} + CFPlugInDynamicRegisterFunction + + CFPlugInDynamicRegistration + NO + CFPlugInFactories + + 00000000-0000-0000-0000-000000000000 + MyFactoryFunction + + CFPlugInTypes + + 00000000-0000-0000-0000-000000000000 + + 00000000-0000-0000-0000-000000000000 + + + CFPlugInUnloadFunction + + WebPluginName + ${FBSTRING_ProductName} + WebPluginDescription + ${FBSTRING_FileDescription} + WebPluginMIMETypes + + ${FBSTRING_MIMEType} + + WebPluginTypeDescription + ${FBSTRING_FileDescription} + + + + diff --git a/Tests/CFBundleTest/InfoPlist.strings.in b/Tests/CFBundleTest/InfoPlist.strings.in new file mode 100644 index 000000000..790ead05d --- /dev/null +++ b/Tests/CFBundleTest/InfoPlist.strings.in @@ -0,0 +1,4 @@ +/* Localized versions of Info.plist keys */ + +CFBundleName = "${PLUGIN_NAME}.plugin"; +NSHumanReadableCopyright = "${FBSTRING_LegalCopyright}"; diff --git a/Tests/CFBundleTest/Localized.r b/Tests/CFBundleTest/Localized.r new file mode 100644 index 000000000..e988e262c --- /dev/null +++ b/Tests/CFBundleTest/Localized.r @@ -0,0 +1,18 @@ +#include + +resource 'STR#' (126) +{ { + "${FBSTRING_LegalCopyright}", + "${FBSTRING_ProductName}" +} }; + +resource 'STR#' (127) +{ { + "${FBSTRING_FileDescription}" +} }; + +resource 'STR#' (128) +{ { + "${FBSTRING_MIMEType}", + "${FBSTRING_FileExtents}" +} }; diff --git a/Tests/CFBundleTest/Localized.rsrc b/Tests/CFBundleTest/Localized.rsrc new file mode 100644 index 0000000000000000000000000000000000000000..cbf35235b3f73416f2f0eb6003e75b58409b9c00 GIT binary patch literal 496 zcmZQzU}RumU|a?yK-de2M;b6 + +typedef void (*NPP_ShutdownProcPtr)(void); +typedef short NPError; + +#pragma GCC visibility push(default) + +struct NPNetscapeFuncs; +struct NPPluginFuncs; + +extern "C" { + NPError NP_Initialize(NPNetscapeFuncs *browserFuncs); + NPError NP_GetEntryPoints(NPPluginFuncs *pluginFuncs); + NPError NP_Shutdown(void); +} + +#pragma GCC visibility pop + +void initPluginModule() +{ +} + +NPError NP_GetEntryPoints(NPPluginFuncs* pFuncs) +{ + printf("NP_GetEntryPoints()\n"); + return 0; +} + +NPError NP_Initialize(NPNetscapeFuncs* pFuncs) +{ + printf("NP_Initialize()\n"); + return 0; +} + +NPError NP_Shutdown() +{ + return 0; +} diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index bda2fa5f8..41bf03437 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -30,3 +30,8 @@ endif() foreach(test ${CMakeLib_TESTS}) add_test(CMakeLib.${test} CMakeLibTests ${test}) endforeach() + +if(TEST_CompileCommandOutput) + add_executable(runcompilecommands run_compile_commands.cxx) + target_link_libraries(runcompilecommands CMakeLib) +endif() diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx new file mode 100644 index 000000000..3f141c537 --- /dev/null +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -0,0 +1,141 @@ +#include "cmSystemTools.h" + +class CompileCommandParser { +public: + class CommandType: public std::map + { + public: + cmStdString const& at(cmStdString const& k) const + { + const_iterator i = this->find(k); + if(i != this->end()) { return i->second; } + static cmStdString emptyString; + return emptyString; + } + }; + typedef std::vector TranslationUnitsType; + + CompileCommandParser(std::ifstream *input) + { + this->Input = input; + } + + void Parse() + { + NextNonWhitespace(); + ParseTranslationUnits(); + } + + const TranslationUnitsType& GetTranslationUnits() + { + return this->TranslationUnits; + } + +private: + void ParseTranslationUnits() + { + this->TranslationUnits = TranslationUnitsType(); + ExpectOrDie('[', "at start of compile command file"); + do + { + ParseTranslationUnit(); + this->TranslationUnits.push_back(this->Command); + } while(Expect(',')); + ExpectOrDie(']', "at end of array"); + } + + void ParseTranslationUnit() + { + this->Command = CommandType(); + if(!Expect('{')) return; + if(Expect('}')) return; + do + { + ParseString(); + std::string name = this->String; + ExpectOrDie(':', "between name and value"); + ParseString(); + std::string value = this->String; + this->Command[name] = value; + } while(Expect(',')); + ExpectOrDie('}', "at end of object"); + } + + void ParseString() + { + this->String.clear(); + if(!Expect('"')) return; + while (!Expect('"')) + { + Expect('\\'); + this->String.push_back(C); + Next(); + } + } + + bool Expect(char c) + { + if(this->C == c) + { + NextNonWhitespace(); + return true; + } + return false; + } + + void ExpectOrDie(char c, const std::string & message) + { + if (!Expect(c)) + ErrorExit(std::string("'") + c + "' expected " + message + "."); + } + + void NextNonWhitespace() + { + do { Next(); } while (IsWhitespace()); + } + + void Next() + { + this->C = char(Input->get()); + if (this->Input->bad()) ErrorExit("Unexpected end of file."); + } + + void ErrorExit(const std::string &message) { + std::cout << "ERROR: " << message; + exit(1); + } + + bool IsWhitespace() + { + return (this->C == ' ' || this->C == '\t' || + this->C == '\n' || this->C == '\r'); + } + + char C; + TranslationUnitsType TranslationUnits; + CommandType Command; + std::string String; + std::ifstream *Input; +}; + +int main () +{ + std::ifstream file("compile_commands.json"); + CompileCommandParser parser(&file); + parser.Parse(); + for(CompileCommandParser::TranslationUnitsType::const_iterator + it = parser.GetTranslationUnits().begin(), + end = parser.GetTranslationUnits().end(); it != end; ++it) + { + std::vector command; + cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command); + if (!cmSystemTools::RunSingleCommand( + command, 0, 0, it->at("directory").c_str())) + { + std::cout << "ERROR: Failed to run command \"" + << command[0] << "\"" << std::endl; + exit(1); + } + } + return 0; +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2c1191946..2ad9a7759 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -11,6 +11,7 @@ MACRO(ADD_TEST_MACRO NAME COMMAND) --build-generator ${CMAKE_TEST_GENERATOR} --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-project ${proj} + ${${NAME}_EXTRA_OPTIONS} --test-command ${COMMAND} ${ARGN}) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}") ENDMACRO(ADD_TEST_MACRO) @@ -39,6 +40,10 @@ CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in # Testing IF(BUILD_TESTING) + IF("${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") + SET(TEST_CompileCommandOutput 1) + ENDIF() + ADD_SUBDIRECTORY(CMakeLib) # Collect a list of all test build directories. @@ -188,6 +193,24 @@ IF(BUILD_TESTING) LIST(APPEND TEST_BUILD_DIRS ${CMake_TEST_INSTALL_PREFIX}) + + # run test for BundleUtilities on supported platforms/compilers + if(MSVC OR + CMAKE_SYSTEM_NAME MATCHES "Linux" OR + CMAKE_SYSTEM_NAME MATCHES "Darwin") + if(NOT "${CMAKE_TEST_GENERATOR}" STREQUAL "Watcom WMake") + ADD_TEST(BundleUtilities ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/BundleUtilities" + "${CMake_BINARY_DIR}/Tests/BundleUtilities" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project BundleUtilities + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleUtilities") + endif() + endif() + SET(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/COnly") SET(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/CMakeBuildCOnly") CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CMakeBuildTest.cmake.in" @@ -566,12 +589,26 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ set(CPackRun_CPackCommand "-DCPackCommand=${CMAKE_CPACK_COMMAND}") # set up list of CPack generators list(APPEND GENLST "ZIP") + if(APPLE) + list(APPEND GENLST "DragNDrop") + endif(APPLE) + if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*") + find_program(RPMBUILD NAMES rpmbuild) + endif(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*") + if (RPMBUILD) + list(APPEND GENLST "RPM") + endif(RPMBUILD) + if (CMAKE_SYSTEM_NAME MATCHES "Linux") + find_program(DPKG NAMES dpkg) + if (DPKG) + list(APPEND GENLST "DEB") + endif(DPKG) + endif(CMAKE_SYSTEM_NAME MATCHES "Linux") # set up list of component packaging ways list(APPEND CWAYLST "default") list(APPEND CWAYLST "OnePackPerGroup") list(APPEND CWAYLST "IgnoreGroup") list(APPEND CWAYLST "AllInOne") - list(APPEND CWAYLST "AllGroupsInOne") foreach(CPackGen ${GENLST}) set(CPackRun_CPackGen "-DCPackGen=${CPackGen}") foreach(CPackComponentWay ${CWAYLST}) @@ -815,11 +852,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --test-command ${CMAKE_CTEST_COMMAND} -V ) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProject") - # The ExternalProject test takes 900 seconds on some machines! - GET_TEST_PROPERTY(ExternalProject TIMEOUT PREVIOUS_TIMEOUT) - IF("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) - SET_TESTS_PROPERTIES(ExternalProject PROPERTIES TIMEOUT 1000) - ENDIF("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) + SET_TESTS_PROPERTIES(ExternalProject PROPERTIES + TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) # do each of the tutorial steps FOREACH(STP RANGE 1 7) @@ -1002,6 +1036,22 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ SET_TESTS_PROPERTIES ( linkorder2 PROPERTIES DEPENDS linkorder1) SET_TESTS_PROPERTIES ( SimpleInstall-Stage2 PROPERTIES DEPENDS SimpleInstall) + # Test static linking on toolchains known to support it. + IF("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU)$" + AND NOT APPLE AND NOT WIN32 AND NOT CYGWIN + AND EXISTS "/usr/lib/libm.a") + ADD_TEST(LinkStatic ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/LinkStatic" + "${CMake_BINARY_DIR}/Tests/LinkStatic" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project LinkStatic + --build-options -DMATH_LIBRARY:FILEPATH=/usr/lib/libm.a + --test-command LinkStatic + ) + ENDIF() + IF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) ADD_TEST(kwsys ${CMAKE_CTEST_COMMAND} --build-and-test @@ -1082,8 +1132,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ IF(CMAKE_TEST_MSVC) ADD_TEST_MACRO(ForceInclude foo) ADD_TEST_MACRO(PrecompiledHeader foo) + ENDIF() + IF(CMAKE_TEST_MSVC OR + "${CMAKE_TEST_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles") ADD_TEST_MACRO(ModuleDefinition example_exe) - ENDIF(CMAKE_TEST_MSVC) + ENDIF() ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables) @@ -1144,6 +1197,21 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ${BundleTestInstallDir}/Applications/SecondBundleExe.app/Contents/MacOS/SecondBundleExe) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleTest") + ADD_TEST(CFBundleTest ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CFBundleTest" + "${CMake_BINARY_DIR}/Tests/CFBundleTest" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project CFBundleTest + --test-command + ${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=\${CTEST_CONFIGURATION_TYPE} + -Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest + -Dgen=${CMAKE_TEST_GENERATOR} + -P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest") + ADD_TEST_MACRO(ObjC++ ObjC++) ENDIF (APPLE AND CMAKE_COMPILER_IS_GNUCXX) @@ -1202,7 +1270,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-project WarnUnusedCliUnused --build-options "-DUNUSED_CLI_VARIABLE=Unused") SET_TESTS_PROPERTIES(WarnUnusedCliUnused PROPERTIES - PASS_REGULAR_EXPRESSION "CMake Warning: The variable, 'UNUSED_CLI_VARIABLE'") + PASS_REGULAR_EXPRESSION "CMake Warning:.*Manually-specified variables were not used by the project:.* UNUSED_CLI_VARIABLE") LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedCliUnused") ADD_TEST(WarnUnusedCliUsed ${CMAKE_CTEST_COMMAND} @@ -1242,7 +1310,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory" --force-new-ctest-process - --test-command ${CMAKE_CTEST_COMMAND} -V + --test-command ${CMAKE_CTEST_COMMAND} -V -C \${CTEST_CONFIGURATION_TYPE} ) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory") @@ -1400,6 +1468,16 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ PASS_REGULAR_EXPRESSION "Could not find executable" FAIL_REGULAR_EXPRESSION "SegFault") + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestUpload/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestUpload ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestUpload/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestUpload/testOut.log" + ) + SET_TESTS_PROPERTIES(CTestTestUpload PROPERTIES + PASS_REGULAR_EXPRESSION "Upload\\.xml") # Use macro, not function so that build can still be driven by CMake 2.4. # After 2.6 is required, this could be a function without the extra 'set' @@ -1825,39 +1903,30 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ENDIF() ENDIF() - if(NOT DEFINED CTEST_RUN_Java) - if(APPLE) - set(CTEST_RUN_Java OFF) - else() - set(CTEST_RUN_Java ON) - endif() - endif() - - IF(CTEST_RUN_Java) - find_package(Java QUIET) - IF(JAVA_COMPILE AND JAVA_RUNTIME AND JAVA_ARCHIVE AND NOT MINGW) - GET_FILENAME_COMPONENT(JNIPATH ${JAVA_COMPILE} PATH) - FIND_FILE(JNI_H jni.h - "${JNIPATH}/../include" - "${JNIPATH}/../java/include") - IF(JNI_H) - FILE(READ "${JNI_H}" JNI_FILE) - IF("${JNI_FILE}" MATCHES "JDK1_2") - ADD_TEST(Java ${CMAKE_CTEST_COMMAND} - --build-and-test - "${CMake_SOURCE_DIR}/Tests/Java" - "${CMake_BINARY_DIR}/Tests/Java" - --build-generator ${CMAKE_TEST_GENERATOR} - --build-project hello - --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} - --build-two-config - --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/" - --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld) - LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Java") - ENDIF("${JNI_FILE}" MATCHES "JDK1_2") - ENDIF(JNI_H) - ENDIF(JAVA_COMPILE AND JAVA_RUNTIME AND JAVA_ARCHIVE AND NOT MINGW) - ENDIF(CTEST_RUN_Java) + find_package(Java QUIET) + IF(JAVA_COMPILE AND JAVA_RUNTIME AND JAVA_ARCHIVE AND NOT MINGW + AND NOT "${CMAKE_TEST_GENERATOR}" MATCHES "Xcode") + GET_FILENAME_COMPONENT(JNIPATH ${JAVA_COMPILE} PATH) + FIND_FILE(JNI_H jni.h + "${JNIPATH}/../include" + "${JNIPATH}/../java/include") + IF(JNI_H AND EXISTS "${JNI_H}") # in case jni.h is a broken symlink + FILE(READ "${JNI_H}" JNI_FILE) + IF("${JNI_FILE}" MATCHES "JDK1_2") + ADD_TEST(Java ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Java" + "${CMake_BINARY_DIR}/Tests/Java" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project hello + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/Java/" + --test-command ${JAVA_RUNTIME} -classpath hello.jar HelloWorld) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Java") + ENDIF("${JNI_FILE}" MATCHES "JDK1_2") + ENDIF() + ENDIF() # add some cross compiler tests, for now only with makefile based generators IF(CMAKE_TEST_GENERATOR MATCHES "Makefiles" OR CMAKE_TEST_GENERATOR MATCHES "KDevelop") @@ -1985,6 +2054,25 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ENDIF() SET_TESTS_PROPERTIES(Contracts.${project} PROPERTIES TIMEOUT ${timeout}) ENDFOREACH() + + IF(TEST_CompileCommandOutput) + SET(CompileCommandOutput_EXTRA_OPTIONS + --build-options -DMAKE_SUPPORTS_SPACES=${MAKE_IS_GNU}) + ADD_TEST_MACRO(CompileCommandOutput + "${CMake_BINARY_DIR}/Tests/CMakeLib/runcompilecommands") + ENDIF() + + ADD_TEST(IncludeDirectories ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/IncludeDirectories" + "${CMake_BINARY_DIR}/Tests/IncludeDirectories" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project IncludeDirectories + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command IncludeDirectories) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories") + ENDIF(BUILD_TESTING) SUBDIRS(CMakeTests) diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 8fd52dfd3..5cb50c93a 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -27,12 +27,15 @@ AddCMakeTest(String "") AddCMakeTest(Math "") AddCMakeTest(CMakeMinimumRequired "") AddCMakeTest(CompilerIdVendor "") +AddCMakeTest(ProcessorCount "") AddCMakeTest(FileDownload "") set_property(TEST CMake.FileDownload PROPERTY PASS_REGULAR_EXPRESSION "file already exists with expected MD5 sum" ) +AddCMakeTest(FileUpload "") + if(HAVE_ELF_H) AddCMakeTest(ELF "") endif() diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in index 578f51016..9dc2ebb27 100644 --- a/Tests/CMakeTests/FileDownloadTest.cmake.in +++ b/Tests/CMakeTests/FileDownloadTest.cmake.in @@ -37,5 +37,7 @@ file(DOWNLOAD ${url} ${dir}/file3.png TIMEOUT 2 + STATUS status EXPECTED_MD5 d16778650db435bda3a8c3435c3ff5d1 ) +message(STATUS "${status}") diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index 721f311f9..b6dcaa6d1 100644 --- a/Tests/CMakeTests/FileTest.cmake.in +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -27,7 +27,7 @@ check_cmake_test(File # Also execute each test listed in FileTestScript.cmake: # set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/FileTestScript.cmake") -set(number_of_tests_expected 56) +set(number_of_tests_expected 62) include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake") execute_all_script_tests(${scriptname} number_of_tests_executed) diff --git a/Tests/CMakeTests/FileTestScript.cmake b/Tests/CMakeTests/FileTestScript.cmake index c4e27bd27..9a4356973 100644 --- a/Tests/CMakeTests/FileTestScript.cmake +++ b/Tests/CMakeTests/FileTestScript.cmake @@ -201,6 +201,26 @@ elseif(testname STREQUAL download_with_bogus_protocol) # pass message("l='${l}'") message("s='${s}'") +elseif(testname STREQUAL upload_wrong_number_of_args) # fail + file(UPLOAD ./ffff) + +elseif(testname STREQUAL upload_missing_time) # fail + file(UPLOAD ./ffff zzzz://bogus/ffff TIMEOUT) + +elseif(testname STREQUAL upload_missing_log_var) # fail + file(UPLOAD ./ffff zzzz://bogus/ffff TIMEOUT 2 LOG) + +elseif(testname STREQUAL upload_missing_status_var) # fail + file(UPLOAD ./ffff zzzz://bogus/ffff TIMEOUT 2 LOG l STATUS) + +elseif(testname STREQUAL upload_file_that_doesnt_exist) # fail + file(UPLOAD ./ffff zzzz://bogus/ffff) + +elseif(testname STREQUAL upload_with_bogus_protocol) # pass + file(UPLOAD ${CMAKE_CURRENT_LIST_FILE} zzzz://bogus/ffff TIMEOUT 2 LOG l STATUS s) + message("l='${l}'") + message("s='${s}'") + else() # fail message(FATAL_ERROR "testname='${testname}' - error: no such test in '${CMAKE_CURRENT_LIST_FILE}'") diff --git a/Tests/CMakeTests/FileUploadTest.cmake.in b/Tests/CMakeTests/FileUploadTest.cmake.in new file mode 100644 index 000000000..8577aefd2 --- /dev/null +++ b/Tests/CMakeTests/FileUploadTest.cmake.in @@ -0,0 +1,49 @@ +file(REMOVE_RECURSE "@CMAKE_CURRENT_BINARY_DIR@/uploads") + +if(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/uploads/file1.png") + message(FATAL_ERROR "error: file1.png exists - should have been deleted") +endif() +if(EXISTS "@CMAKE_CURRENT_BINARY_DIR@/uploads/file2.png") + message(FATAL_ERROR "error: file2.png exists - should have been deleted") +endif() + +file(MAKE_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/uploads") + +set(filename "@CMAKE_CURRENT_SOURCE_DIR@/FileDownloadInput.png") +set(urlbase "file://@CMAKE_CURRENT_BINARY_DIR@/uploads") + +message(STATUS "FileUpload:1") +file(UPLOAD + ${filename} + ${urlbase}/file1.png + TIMEOUT 2 + ) + +message(STATUS "FileUpload:2") +file(UPLOAD + ${filename} + ${urlbase}/file2.png + STATUS status + LOG log + SHOW_PROGRESS + ) + +execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum + "@CMAKE_CURRENT_BINARY_DIR@/uploads/file1.png" + OUTPUT_VARIABLE sum1 + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT sum1 MATCHES "^d16778650db435bda3a8c3435c3ff5d1 .*/uploads/file1.png$") + message(FATAL_ERROR "file1.png did not upload correctly (sum1='${sum1}')") +endif() + +execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum + "@CMAKE_CURRENT_BINARY_DIR@/uploads/file2.png" + OUTPUT_VARIABLE sum2 + OUTPUT_STRIP_TRAILING_WHITESPACE) +if(NOT sum2 MATCHES "^d16778650db435bda3a8c3435c3ff5d1 .*/uploads/file2.png$") + message(FATAL_ERROR "file2.png did not upload correctly (sum2='${sum2}')") +endif() + +message(STATUS "log='${log}'") +message(STATUS "status='${status}'") +message(STATUS "DONE") diff --git a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in index 3fb4652f0..dbe95005e 100644 --- a/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in +++ b/Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in @@ -84,6 +84,13 @@ set(linux64_nagfor_dirs "/usr/lib/gcc/x86_64-redhat-linux/4.4.5;/usr/lib64;/lib6 set(linux64_nagfor_obj_regex "^/usr/local/NAG/lib") list(APPEND platforms linux64_nagfor) +# absoft dummy.f -X -v +set(linux64_absoft_text "collect2 version 4.4.5 (x86-64 Linux/ELF) +/usr/bin/ld --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.4.5/crtbegin.o -L/opt/absoft11.1/lib64 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.5 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.5 -L/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../.. /tmp/E3Bii1/dummy.o -v -laf90math -lafio -lamisc -labsoftmain -laf77math -lm -lmv -lpthread -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.4.5/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crtn.o") +set(linux64_absoft_libs "af90math;afio;amisc;absoftmain;af77math;m;mv;pthread;c") +set(linux64_absoft_dirs "/opt/absoft11.1/lib64;/usr/lib/gcc/x86_64-linux-gnu/4.4.5;/usr/lib;/lib") +list(APPEND platforms linux64_absoft) + # gcc dummy.c -v # in strange path set(linux64_test1_text " /this/might/match/as/a/linker/ld/but/it/is/not because the ld is not the last path component @@ -125,6 +132,14 @@ set(mac_ppc_g++_libs "stdc++") set(mac_ppc_g++_dirs "/usr/lib/powerpc-apple-darwin10/4.2.1;/usr/lib/gcc/powerpc-apple-darwin10/4.2.1;/usr/lib") list(APPEND platforms mac_ppc_g++) +# absoft dummy.f -X -v +set(mac_absoft_text "collect2 version 4.2.1 (Apple Inc. build 5664) (i686 Darwin) +/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld -dynamic -arch i386 -macosx_version_min 10.6.6 -weak_reference_mismatches non-weak -o a.out -lcrt1.10.6.o -L/Applications/Absoft11.1/lib -L/usr/lib/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../i686-apple-darwin10/4.2.1 -L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../.. /var/folders/04/04+Djjm8GZWBmuEdp2Gsw++++TM/-Tmp-//bTAoJc/dummy.o -v -Y 10 -laf90math -lafio -lamisc -labsoftmain -laf77math -lm -lmv -lSystem -lgcc -lSystem +") +set(mac_absoft_libs "af90math;afio;amisc;absoftmain;af77math;m;mv") +set(mac_absoft_dirs "/Applications/Absoft11.1/lib;/usr/lib/i686-apple-darwin10/4.2.1;/usr/lib/gcc/i686-apple-darwin10/4.2.1;/usr/lib") +list(APPEND platforms mac_absoft) + #----------------------------------------------------------------------------- # Sun diff --git a/Tests/CMakeTests/ProcessorCountTest.cmake.in b/Tests/CMakeTests/ProcessorCountTest.cmake.in new file mode 100644 index 000000000..98f6ab16d --- /dev/null +++ b/Tests/CMakeTests/ProcessorCountTest.cmake.in @@ -0,0 +1,72 @@ +include(ProcessorCount) + +ProcessorCount(processor_count) + +message("### 1. This line should be the first line of text in the test output.") +message("### 2. If there was output from this test before line #1, then the") +message("### 3. ProcessorCount(...) function call is emitting output that it shouldn't...") + +message("processor_count='${processor_count}'") + +execute_process( + COMMAND "@CMAKE_BINARY_DIR@/Source/kwsys/$ENV{CMAKE_CONFIG_TYPE}/cmsysTestsCxx" + testSystemInformation + OUTPUT_VARIABLE tsi_out + ERROR_VARIABLE tsi_err) +string(REGEX REPLACE "(.*)GetNumberOfPhysicalCPU:.([0-9]*)(.*)" "\\2" + system_info_processor_count "${tsi_out}") + +message("system_info_processor_count='${system_info_processor_count}'") + +if(system_info_processor_count EQUAL processor_count) + message("processor count matches system information") +endif() + +message("") +message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +message("") +message("tsi_out='${tsi_out}'") +message("tsi_err='${tsi_err}'") +message("") + +# Evaluate possible error conditions: +# +set(err 0) +set(fatal 0) + +if(processor_count EQUAL 0) + set(err 1) + set(fatal 1) + message("err 1") + message("could not determine number of processors +- Additional code for this platform needed in ProcessorCount.cmake?") + message("") +endif() + +if(NOT system_info_processor_count EQUAL processor_count) + set(err 2) + message("err 2") + message("SystemInformation and ProcessorCount.cmake disagree:\n" + "processor_count='${processor_count}'\n" + "SystemInformation processor_count='${system_info_processor_count}'") + message("") +endif() + +if(NOT processor_count MATCHES "^[0-9]+$") + set(err 3) + set(fatal 1) + message("err 3") + message("ProcessorCount function returned a non-integer") + message("") +endif() + +if(NOT system_info_processor_count MATCHES "^[0-9]+$") + set(err 4) + message("err 4") + message("SystemInformation ProcessorCount function returned a non-integer") + message("") +endif() + +if(fatal) + message(FATAL_ERROR "processor_count='${processor_count}' - see previous test output for more details - it is likely more/different code is needed in ProcessorCount.cmake to fix this test failure - processor_count should be a non-zero positive integer (>=1) for all supported CMake platforms") +endif() diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in index 54fee7f4c..6bb60f4fe 100644 --- a/Tests/CMakeTests/StringTest.cmake.in +++ b/Tests/CMakeTests/StringTest.cmake.in @@ -1,7 +1,7 @@ # Execute each test listed in StringTestScript.cmake: # set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/StringTestScript.cmake") -set(number_of_tests_expected 52) +set(number_of_tests_expected 69) include("@CMAKE_CURRENT_SOURCE_DIR@/ExecuteScriptTests.cmake") execute_all_script_tests(${scriptname} number_of_tests_executed) diff --git a/Tests/CMakeTests/StringTestScript.cmake b/Tests/CMakeTests/StringTestScript.cmake index 37038561d..7a264a0e2 100644 --- a/Tests/CMakeTests/StringTestScript.cmake +++ b/Tests/CMakeTests/StringTestScript.cmake @@ -194,6 +194,85 @@ elseif(testname STREQUAL random_with_various_alphabets) # pass string(RANDOM LENGTH 78 ALPHABET "~`!@#$%^&*()_-+={}[]\\|:\\;'\",.<>/?" v) message(STATUS "v='${v}'") + message(STATUS "CMAKE_SCRIPT_MODE_FILE='${CMAKE_SCRIPT_MODE_FILE}'") + +elseif(testname STREQUAL string_find_with_no_parameter) # fail + string(FIND) + +elseif(testname STREQUAL string_find_with_one_parameter) # fail + string(FIND "CMake is great.") + +elseif(testname STREQUAL string_find_with_two_parameters) # fail + string(FIND "CMake is great." "a") + +elseif(testname STREQUAL string_find_with_three_parameters) # pass + string(FIND "CMake is great." "a" v) + message(STATUS "v='${v}'") + +elseif(testname STREQUAL string_find_with_four_parameters) # fail + string(FIND "CMake is great." "a" v v2) + +elseif(testname STREQUAL string_find_reverse_with_no_parameter) # fail + string(FIND REVERSE) + +elseif(testname STREQUAL string_find_reverse_with_one_parameter) # fail + string(FIND "CMake is great." REVERSE) + +elseif(testname STREQUAL string_find_reverse_with_two_parameters) # fail + string(FIND "CMake is great." "a" REVERSE) + +elseif(testname STREQUAL string_find_reverse_with_three_parameters) # pass + string(FIND "CMake is great." "a" v REVERSE) + message(STATUS "v='${v}'") + +elseif(testname STREQUAL string_find_reverse_with_four_parameters_part1) # fail + string(FIND "CMake is great." "a" v v2 REVERSE) + +elseif(testname STREQUAL string_find_reverse_with_four_parameters_part2) # fail + string(FIND "CMake is great." "a" v REVERSE v2) + +elseif(testname STREQUAL string_find_with_no_possible_result) # pass + string(FIND "CMake is a great application." "z" v) + message(STATUS "v='${v}'") + if(NOT(-1 EQUAL ${v})) + message(SEND_ERROR "FIND sub-command should return -1 but returned ${v}.") + endif(NOT(-1 EQUAL ${v})) + +elseif(testname STREQUAL string_find_reverse_with_no_possible_result) # pass + string(FIND "CMake is a great application." "z" v REVERSE) + message(STATUS "v='${v}'") + if(NOT(-1 EQUAL ${v})) + message(SEND_ERROR "FIND REVERSE sub-command should return -1 but returned ${v}.") + endif(NOT(-1 EQUAL ${v})) + +elseif(testname STREQUAL string_find_with_required_result) # pass + string(FIND "CMake is a great application." "g" v) + message(STATUS "v='${v}'") + if(NOT(11 EQUAL ${v})) + message(SEND_ERROR "FIND sub-command should return 11 but returned ${v}.") + endif(NOT(11 EQUAL ${v})) + +elseif(testname STREQUAL string_find_reverse_with_required_result) # pass + string(FIND "CMake is a great application." "e" v REVERSE) + message(STATUS "v='${v}'") + if(NOT(13 EQUAL ${v})) + message(SEND_ERROR "FIND REVERSE sub-command should return 13 but returned ${v}.") + endif(NOT(13 EQUAL ${v})) + +elseif(testname STREQUAL string_find_word_reverse_with_required_result) # pass + string(FIND "The command should find REVERSE in this string. Or maybe this REVERSE?!" "REVERSE" v) + message(STATUS "v='${v}'") + if(NOT(24 EQUAL ${v})) + message(SEND_ERROR "FIND sub-command should return 24 but returned ${v}.") + endif(NOT(24 EQUAL ${v})) + +elseif(testname STREQUAL string_find_reverse_word_reverse_with_required_result) # pass + string(FIND "The command should find REVERSE in this string. Or maybe this REVERSE?!" "REVERSE" v REVERSE) + message(STATUS "v='${v}'") + if(NOT(62 EQUAL ${v})) + message(SEND_ERROR "FIND sub-command should return 62 but returned ${v}.") + endif(NOT(62 EQUAL ${v})) + else() # fail message(FATAL_ERROR "testname='${testname}' - error: no such test in '${CMAKE_CURRENT_LIST_FILE}'") diff --git a/Tests/CPackComponentsForAll/CMakeLists.txt b/Tests/CPackComponentsForAll/CMakeLists.txt index bcec50988..5449d09dc 100644 --- a/Tests/CPackComponentsForAll/CMakeLists.txt +++ b/Tests/CPackComponentsForAll/CMakeLists.txt @@ -10,6 +10,9 @@ cmake_minimum_required(VERSION 2.8.3.20101130 FATAL_ERROR) project(CPackComponentsForAll) +# Use GNUInstallDirs in order to enforce lib64 if needed +include(GNUInstallDirs) + # Create the mylib library add_library(mylib mylib.cpp) @@ -27,7 +30,7 @@ target_link_libraries(mylibapp2 mylib) # be used to create the installation components. install(TARGETS mylib ARCHIVE - DESTINATION lib + DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) install(TARGETS mylibapp RUNTIME diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-AllGroupsInOne.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-AllGroupsInOne.cmake.in deleted file mode 100644 index 3a7119ee7..000000000 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-AllGroupsInOne.cmake.in +++ /dev/null @@ -1,18 +0,0 @@ -# -# Activate component packaging -# -if(CPACK_GENERATOR MATCHES "ZIP") - set(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") -endif(CPACK_GENERATOR MATCHES "ZIP") - -if(CPACK_GENERATOR MATCHES "RPM") - set(CPACK_RPM_COMPONENT_INSTALL "ON") -endif(CPACK_GENERATOR MATCHES "RPM") - -# -# Choose grouping way -# -set(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE 1) -#set(CPACK_COMPONENTS_GROUPING) -#set(CPACK_COMPONENTS_IGNORE_GROUPS 1) -#set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE 1) diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in index 9a40293cd..1d203c8d8 100644 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-AllInOne.cmake.in @@ -9,6 +9,10 @@ if(CPACK_GENERATOR MATCHES "RPM") set(CPACK_RPM_COMPONENT_INSTALL "ON") endif(CPACK_GENERATOR MATCHES "RPM") +if(CPACK_GENERATOR MATCHES "DEB") + set(CPACK_DEB_COMPONENT_INSTALL "ON") +endif(CPACK_GENERATOR MATCHES "DEB") + # # Choose grouping way # diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in index 92a97a5b9..d82943f83 100644 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in @@ -9,6 +9,10 @@ if(CPACK_GENERATOR MATCHES "RPM") set(CPACK_RPM_COMPONENT_INSTALL "ON") endif(CPACK_GENERATOR MATCHES "RPM") +if(CPACK_GENERATOR MATCHES "DEB") + set(CPACK_DEB_COMPONENT_INSTALL "ON") +endif(CPACK_GENERATOR MATCHES "DEB") + # # Choose grouping way # diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in index 4180891a2..1e1a410ab 100644 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in @@ -9,10 +9,18 @@ if(CPACK_GENERATOR MATCHES "RPM") set(CPACK_RPM_COMPONENT_INSTALL "ON") endif(CPACK_GENERATOR MATCHES "RPM") +if(CPACK_GENERATOR MATCHES "DEB") + set(CPACK_DEB_COMPONENT_INSTALL "ON") +endif(CPACK_GENERATOR MATCHES "DEB") + +if(CPACK_GENERATOR MATCHES "DragNDrop") + set(CPACK_COMPONENTS_GROUPING "ONE_PER_GROUP") +endif(CPACK_GENERATOR MATCHES "DragNDrop") + # # Choose grouping way # #set(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE) #set(CPACK_COMPONENTS_GROUPING) #set(CPACK_COMPONENTS_IGNORE_GROUPS) -#set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE) \ No newline at end of file +#set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE) diff --git a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake index d5137bd70..e2d343d9f 100644 --- a/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake +++ b/Tests/CPackComponentsForAll/RunCPackVerifyResult.cmake @@ -30,9 +30,69 @@ set(config_type $ENV{CMAKE_CONFIG_TYPE}) set(config_args ) if(config_type) set(config_args -C ${config_type}) +endif(config_type) +set(config_verbose ) + +if(CPackGen MATCHES "ZIP") + set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip") + if (${CPackComponentWay} STREQUAL "default") + set(expected_count 1) + elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + set(expected_count 3) + elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + set(expected_count 4) + elseif (${CPackComponentWay} STREQUAL "AllInOne") + set(expected_count 1) + endif () +elseif (CPackGen MATCHES "RPM") + set(config_verbose -D "CPACK_RPM_PACKAGE_DEBUG=1") + set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.rpm") + if (${CPackComponentWay} STREQUAL "default") + set(expected_count 1) + elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + set(expected_count 3) + elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + set(expected_count 4) + elseif (${CPackComponentWay} STREQUAL "AllInOne") + set(expected_count 1) + endif () +elseif (CPackGen MATCHES "DEB") + set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.deb") + if (${CPackComponentWay} STREQUAL "default") + set(expected_count 1) + elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + set(expected_count 3) + elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + set(expected_count 4) + elseif (${CPackComponentWay} STREQUAL "AllInOne") + set(expected_count 1) + endif () endif() -message(" ${config_args}") -execute_process(COMMAND ${CPackCommand} -G ${CPackGen} ${config_args} + +if(CPackGen MATCHES "DragNDrop") + set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.dmg") + if (${CPackComponentWay} STREQUAL "default") + set(expected_count 1) + elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup") + set(expected_count 3) + elseif (${CPackComponentWay} STREQUAL "IgnoreGroup") + set(expected_count 4) + elseif (${CPackComponentWay} STREQUAL "AllInOne") + set(expected_count 1) + endif () +endif(CPackGen MATCHES "DragNDrop") + +# clean-up previously CPack generated files +if(expected_file_mask) + file(GLOB expected_file "${expected_file_mask}") + if (expected_file) + file(REMOVE ${expected_file}) + endif(expected_file) +endif(expected_file_mask) + +message("config_args = ${config_args}") +message("config_verbose = ${config_verbose}") +execute_process(COMMAND ${CPackCommand} ${config_verbose} -G ${CPackGen} ${config_args} RESULT_VARIABLE CPack_result OUTPUT_VARIABLE CPack_output ERROR_VARIABLE CPack_error @@ -44,25 +104,6 @@ else (CPack_result) message(STATUS "CPack_output=${CPack_output}") endif(CPack_result) -if(CPackGen MATCHES "ZIP") - set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.zip") - if (${CPackComponentWay} STREQUAL "default") - set(expected_count 1) - endif(${CPackComponentWay} STREQUAL "default") - if (${CPackComponentWay} STREQUAL "OnePackPerGroup") - set(expected_count 2) - endif (${CPackComponentWay} STREQUAL "OnePackPerGroup") - if (${CPackComponentWay} STREQUAL "IgnoreGroup") - set(expected_count 4) - endif (${CPackComponentWay} STREQUAL "IgnoreGroup") - if (${CPackComponentWay} STREQUAL "AllInOne") - set(expected_count 1) - endif (${CPackComponentWay} STREQUAL "AllInOne") - if (${CPackComponentWay} STREQUAL "AllGroupsInOne") - set(expected_count 1) - endif (${CPackComponentWay} STREQUAL "AllGroupsInOne") -endif(CPackGen MATCHES "ZIP") - # Now verify if the number of expected file is OK # - using expected_file_mask and # - expected_count diff --git a/Tests/CTestTest3/test.cmake.in b/Tests/CTestTest3/test.cmake.in deleted file mode 100644 index 1e8ea5023..000000000 --- a/Tests/CTestTest3/test.cmake.in +++ /dev/null @@ -1,120 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.1) - -MACRO(PROJECT_START NAME) - MESSAGE("###################################################") - MESSAGE("") - MESSAGE("Start project: ${NAME}") - MESSAGE("") - MESSAGE("###################################################") -ENDMACRO(PROJECT_START) - -# Project 1 -PROJECT_START("KWSys from CVS") - -# Settings: -SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest3") -SET(CTEST_SITE "@SITE@") -SET(CTEST_BUILD_NAME "KWSys-@BUILDNAME@-CTest3-CVS") - -# --- -SET(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/CVS/KWSys") -SET(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/CVS/KWSysBin") -SET(CTEST_UPDATE_COMMAND "@CVSCOMMAND@") -SET(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") -SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") -# for unix purify has to be used as a linker, and -# will not work with ctest. So disable it so -# that it is not attempted. -IF(UNIX) - IF("${CTEST_MEMORYCHECK_COMMAND}" MATCHES purify) - SET(CTEST_MEMORYCHECK_COMMAND) - ENDIF() -ENDIF() -SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") -SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") -SET(CTEST_CHECKOUT_COMMAND "\"${CTEST_UPDATE_COMMAND}\" -q -z3 \"-d:pserver:anoncvs@www.cmake.org:/cvsroot/KWSys\" co -r CTest-Testing-Tag KWSys") - -CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) - -FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " -CMAKE_CXX_FLAGS:STRING=@CMAKE_CXX_FLAGS@ -CMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@ -CMAKE_C_COMPILER:STRING=@CMAKE_C_COMPILER@ -CMAKE_CXX_COMPILER:STRING=@CMAKE_CXX_COMPILER@ -CMAKE_C_COMPILER_ARG1:STRING=@CMAKE_C_COMPILER_ARG1@ -CMAKE_CXX_COMPILER_ARG1:STRING=@CMAKE_CXX_COMPILER_ARG1@ - -# This one is needed for testing advanced ctest features -CTEST_TEST_KWSYS:BOOL=ON -") - -SET(CTEST_CUSTOM_WARNING_MATCH CommandLineArguments) - -CTEST_START(Nightly) -CTEST_UPDATE(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) -CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -CTEST_READ_CUSTOM_FILES("${CTEST_BINARY_DIRECTORY}") -CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 5 SCHEDULE_RANDOM ON) -CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -CTEST_COVERAGE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) - -set(CTEST_DROP_METHOD "@protocol@") -set(CTEST_DROP_SITE "@server@") -set(CTEST_DROP_LOCATION "@path@/submit.php?project=PublicDashboard") - -CTEST_SUBMIT(RETURN_VALUE res) - -#SET(svncommand "@SVNCOMMAND@") -set(svncommand FALSE) # turn this off until namic svn cmake is back -IF(svncommand) - # Project 2 - PROJECT_START("KWSys from SVN") - - # Settings: - SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest3") - SET(CTEST_SITE "@SITE@") - SET(CTEST_BUILD_NAME "KWSys-@BUILDNAME@-CTest3-SVN") - - # --- - SET(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/SVN/kwsys") - SET(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/SVN/kwsysBin") - SET(CTEST_UPDATE_COMMAND "@SVNCOMMAND@") - SET(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") - SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") - SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") - SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") - SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") - SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") - SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") - SET(CTEST_CHECKOUT_COMMAND "\"${CTEST_UPDATE_COMMAND}\" co \"http://svn.na-mic.org:8000/svn/CMake/Source/kwsys/\" -r 500") - - CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) - - FILE(WRITE "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt" " - CMAKE_CXX_FLAGS:STRING=@CMAKE_CXX_FLAGS@ - CMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@ - CMAKE_C_COMPILER:STRING=@CMAKE_C_COMPILER@ - CMAKE_CXX_COMPILER:STRING=@CMAKE_CXX_COMPILER@ - CMAKE_C_COMPILER_ARG1:STRING=@CMAKE_C_COMPILER_ARG1@ - CMAKE_CXX_COMPILER_ARG1:STRING=@CMAKE_CXX_COMPILER_ARG1@ - - # This one is needed for testing advanced ctest features - CTEST_TEST_KWSYS:BOOL=ON - ") - - CTEST_START(Experimental) - CTEST_UPDATE(SOURCE "${CTEST_SOURCE_DIRECTORY}" RETURN_VALUE res) - CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) - CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) - CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 5 SCHEDULE_RANDOM ON) - CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 5) - CTEST_COVERAGE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) - CTEST_SUBMIT(RETURN_VALUE res) - -ELSE(svncommand) - MESSAGE("Cannot find SVN command: ${svncommand}") -ENDIF(svncommand) diff --git a/Tests/CTestTestBadExe/test.cmake.in b/Tests/CTestTestBadExe/test.cmake.in index 743e83524..5d22d3587 100644 --- a/Tests/CTestTestBadExe/test.cmake.in +++ b/Tests/CTestTestBadExe/test.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestBadEx SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestChecksum/test.cmake.in b/Tests/CTestTestChecksum/test.cmake.in index c3c41a5fe..84135446f 100644 --- a/Tests/CTestTestChecksum/test.cmake.in +++ b/Tests/CTestTestChecksum/test.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestParal SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestCostSerial/test.cmake.in b/Tests/CTestTestCostSerial/test.cmake.in index ce4d60a58..ca216e3fc 100644 --- a/Tests/CTestTestCostSerial/test.cmake.in +++ b/Tests/CTestTestCostSerial/test.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCostS SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestCrash/test.cmake.in b/Tests/CTestTestCrash/test.cmake.in index 259c86590..5cec594cd 100644 --- a/Tests/CTestTestCrash/test.cmake.in +++ b/Tests/CTestTestCrash/test.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCrash SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestCycle/test.cmake.in b/Tests/CTestTestCycle/test.cmake.in index a17adca01..201f6044e 100644 --- a/Tests/CTestTestCycle/test.cmake.in +++ b/Tests/CTestTestCycle/test.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCycle SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestDepends/test.cmake.in b/Tests/CTestTestDepends/test.cmake.in index ed4e18226..36a1ebf87 100644 --- a/Tests/CTestTestDepends/test.cmake.in +++ b/Tests/CTestTestDepends/test.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestDepen SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestFailedSubmits/test.cmake.in b/Tests/CTestTestFailedSubmits/test.cmake.in index 9b581ebea..b0e16322d 100644 --- a/Tests/CTestTestFailedSubmits/test.cmake.in +++ b/Tests/CTestTestFailedSubmits/test.cmake.in @@ -22,9 +22,6 @@ SET(CTEST_BINARY_DIRECTORY "@build@") SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") @@ -39,7 +36,6 @@ CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -CTEST_MEMCHECK(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) CTEST_COVERAGE(BUILD "${CTEST_BINARY_DIRECTORY}" @ctest_coverage_labels_args@ RETURN_VALUE res) # ok to call ctest_submit - still avoids network activity because there is diff --git a/Tests/CTestTestFailure/testNoBuild.cmake.in b/Tests/CTestTestFailure/testNoBuild.cmake.in index b0bb039c5..7bc921a31 100644 --- a/Tests/CTestTestFailure/testNoBuild.cmake.in +++ b/Tests/CTestTestFailure/testNoBuild.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailu SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestFailure/testNoExe.cmake.in b/Tests/CTestTestFailure/testNoExe.cmake.in index 69d4f8452..59c18d752 100644 --- a/Tests/CTestTestFailure/testNoExe.cmake.in +++ b/Tests/CTestTestFailure/testNoExe.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailu SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestParallel/test.cmake.in b/Tests/CTestTestParallel/test.cmake.in index 6ca15f691..83845dee4 100644 --- a/Tests/CTestTestParallel/test.cmake.in +++ b/Tests/CTestTestParallel/test.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestParal SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestResourceLock/test.cmake.in b/Tests/CTestTestResourceLock/test.cmake.in index 0f353b8e1..98c5901c4 100644 --- a/Tests/CTestTestResourceLock/test.cmake.in +++ b/Tests/CTestTestResourceLock/test.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestResou SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestScheduler/test.cmake.in b/Tests/CTestTestScheduler/test.cmake.in index 2a91829f4..505bd7c5b 100644 --- a/Tests/CTestTestScheduler/test.cmake.in +++ b/Tests/CTestTestScheduler/test.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestSched SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestStopTime/test.cmake.in b/Tests/CTestTestStopTime/test.cmake.in index 6a5534ebf..2d03686e6 100644 --- a/Tests/CTestTestStopTime/test.cmake.in +++ b/Tests/CTestTestStopTime/test.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestStopT SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestSubdir/test.cmake.in b/Tests/CTestTestSubdir/test.cmake.in index c8d4fdabf..f240473ee 100644 --- a/Tests/CTestTestSubdir/test.cmake.in +++ b/Tests/CTestTestSubdir/test.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestSubdi SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestTimeout/test.cmake.in b/Tests/CTestTestTimeout/test.cmake.in index 6ed11a45c..8a8dc24e5 100644 --- a/Tests/CTestTestTimeout/test.cmake.in +++ b/Tests/CTestTestTimeout/test.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestTimeo SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") diff --git a/Tests/CTestTestUpload/CMakeLists.txt b/Tests/CTestTestUpload/CMakeLists.txt new file mode 100644 index 000000000..bc164b10c --- /dev/null +++ b/Tests/CTestTestUpload/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(CTestTestUpload) + +add_executable (Sleep sleep.c) diff --git a/Tests/CTestTestUpload/CTestConfig.cmake b/Tests/CTestTestUpload/CTestConfig.cmake new file mode 100644 index 000000000..89c5b9474 --- /dev/null +++ b/Tests/CTestTestUpload/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestUpload") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set (CTEST_DROP_METHOD "http") +set (CTEST_DROP_SITE "www.cdash.org") +set (CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set (CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestUpload/sleep.c b/Tests/CTestTestUpload/sleep.c new file mode 100644 index 000000000..b5896474b --- /dev/null +++ b/Tests/CTestTestUpload/sleep.c @@ -0,0 +1,21 @@ +#if defined(_WIN32) +# include +#else +# include +#endif + +/* sleeps for n seconds, where n is the argument to the program */ +int main(int argc, char** argv) +{ + int time; + if(argc > 1) + { + time = atoi(argv[1]); + } +#if defined(_WIN32) + Sleep(time * 1000); +#else + sleep(time); +#endif + return 0; +} diff --git a/Tests/CTestTestUpload/test.cmake.in b/Tests/CTestTestUpload/test.cmake.in new file mode 100644 index 000000000..acfa233bc --- /dev/null +++ b/Tests/CTestTestUpload/test.cmake.in @@ -0,0 +1,17 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Upload") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestUpload") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestUpload") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_UPLOAD(FILES "${CTEST_SOURCE_DIRECTORY}/sleep.c" "${CTEST_BINARY_DIRECTORY}/CMakeCache.txt") +CTEST_SUBMIT() diff --git a/Tests/CTestTestZeroTimeout/test.cmake.in b/Tests/CTestTestZeroTimeout/test.cmake.in index 0ff32a449..56bae9d17 100644 --- a/Tests/CTestTestZeroTimeout/test.cmake.in +++ b/Tests/CTestTestZeroTimeout/test.cmake.in @@ -10,9 +10,6 @@ SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestZeroT SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") -SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") -SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") SET(CTEST_TEST_TIMEOUT 2) diff --git a/Tests/CompileCommandOutput/CMakeLists.txt b/Tests/CompileCommandOutput/CMakeLists.txt new file mode 100644 index 000000000..bd8e305c2 --- /dev/null +++ b/Tests/CompileCommandOutput/CMakeLists.txt @@ -0,0 +1,16 @@ +# a simple C only test case +cmake_minimum_required (VERSION 2.6) +project (CompileCommandOutput CXX) + +SET(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") +IF(MAKE_SUPPORTS_SPACES) + SET(test1_srcs "file with spaces.cxx") +ELSE() + SET(test1_srcs "file_with_underscores.cxx") +ENDIF() +ADD_LIBRARY(test1 STATIC ${test1_srcs}) +ADD_LIBRARY(test2 SHARED "../CompileCommandOutput/relative.cxx") +INCLUDE_DIRECTORIES(${CompileCommandOutput_SOURCE_DIR}/../../Source) +ADD_EXECUTABLE(CompileCommandOutput compile_command_output.cxx) +TARGET_LINK_LIBRARIES(CompileCommandOutput test1 test2) diff --git a/Tests/CompileCommandOutput/compile_command_output.cxx b/Tests/CompileCommandOutput/compile_command_output.cxx new file mode 100644 index 000000000..145a06426 --- /dev/null +++ b/Tests/CompileCommandOutput/compile_command_output.cxx @@ -0,0 +1,9 @@ +#include "file_with_underscores.h" +#include "relative.h" + +int main (int argc, char** argv) +{ + file_with_underscores(); + relative(); + return 0; +} diff --git a/Tests/CompileCommandOutput/file with spaces.cxx b/Tests/CompileCommandOutput/file with spaces.cxx new file mode 100644 index 000000000..554e176e4 --- /dev/null +++ b/Tests/CompileCommandOutput/file with spaces.cxx @@ -0,0 +1 @@ +#include "file_with_underscores.cxx" diff --git a/Tests/CompileCommandOutput/file_with_underscores.cxx b/Tests/CompileCommandOutput/file_with_underscores.cxx new file mode 100644 index 000000000..4f42ccf56 --- /dev/null +++ b/Tests/CompileCommandOutput/file_with_underscores.cxx @@ -0,0 +1,3 @@ +#include "file_with_underscores.h" + +void file_with_underscores() {} diff --git a/Tests/CompileCommandOutput/file_with_underscores.h b/Tests/CompileCommandOutput/file_with_underscores.h new file mode 100644 index 000000000..0d73e3159 --- /dev/null +++ b/Tests/CompileCommandOutput/file_with_underscores.h @@ -0,0 +1 @@ +void file_with_underscores(); diff --git a/Tests/CompileCommandOutput/relative.cxx b/Tests/CompileCommandOutput/relative.cxx new file mode 100644 index 000000000..eae11e226 --- /dev/null +++ b/Tests/CompileCommandOutput/relative.cxx @@ -0,0 +1,3 @@ +#include "relative.h" + +void relative() {} diff --git a/Tests/CompileCommandOutput/relative.h b/Tests/CompileCommandOutput/relative.h new file mode 100644 index 000000000..ddfe5519b --- /dev/null +++ b/Tests/CompileCommandOutput/relative.h @@ -0,0 +1,11 @@ +#if defined(_WIN32) +# ifdef test2_EXPORTS +# define TEST2_EXPORT __declspec(dllexport) +# else +# define TEST2_EXPORT __declspec(dllimport) +# endif +#else +# define TEST2_EXPORT +#endif + +TEST2_EXPORT void relative(); diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 19e3c2c19..b7c9ea268 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -102,7 +102,7 @@ ADD_CUSTOM_TARGET(TDocument ALL COMMAND ${CMAKE_COMMAND} -E echo " Copying doc1.h to doc2.h." COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/doc1.h ${PROJECT_BINARY_DIR}/doc2.h - DEPENDS ${PROJECT_BINARY_DIR}/doc1.h doc1.txt + DEPENDS doc1.txt ${PROJECT_BINARY_DIR}//doc1.h # test 2 slashes COMMENT "Running top-level TDocument commands" SOURCES doc1.tex ) diff --git a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt index 57cb712ab..36d32e4a0 100644 --- a/Tests/CustomCommandWorkingDirectory/CMakeLists.txt +++ b/Tests/CustomCommandWorkingDirectory/CMakeLists.txt @@ -9,8 +9,8 @@ ADD_CUSTOM_COMMAND( ) SET_SOURCE_FILES_PROPERTIES( - "${TestWorkingDir_BINARY_DIR}/working.c" - "${TestWorkingDir_BINARY_DIR}/customTarget.c" + "${TestWorkingDir_BINARY_DIR}/customTarget.c" + "${TestWorkingDir_BINARY_DIR}/customTarget2.c" PROPERTIES GENERATED 1) ADD_EXECUTABLE(working "${TestWorkingDir_BINARY_DIR}/working.c" @@ -23,3 +23,20 @@ ADD_CUSTOM_TARGET( ) ADD_DEPENDENCIES(working Custom) + +file(MAKE_DIRECTORY ${TestWorkingDir_BINARY_DIR}/work) +add_custom_command( + OUTPUT working2.c # Relative to build tree + COMMAND "${CMAKE_COMMAND}" -E copy ${TestWorkingDir_SOURCE_DIR}/working.c.in ../working2.c + DEPENDS ${TestWorkingDir_SOURCE_DIR}/working.c.in/ # trailing slash should be removed + WORKING_DIRECTORY work/ # Relative to build tree, trailing slash + ) +add_executable(working2 working2.c ${TestWorkingDir_BINARY_DIR}/customTarget2.c) + +add_custom_target( + Custom2 ALL + COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${TestWorkingDir_SOURCE_DIR}/customTarget.c ../customTarget2.c + WORKING_DIRECTORY work/ # Relative to build tree, trailing slash +) + +add_dependencies(working2 Custom2) diff --git a/Tests/ExternalOBJ/CMakeLists.txt b/Tests/ExternalOBJ/CMakeLists.txt index 3fef1356d..f12de11d7 100644 --- a/Tests/ExternalOBJ/CMakeLists.txt +++ b/Tests/ExternalOBJ/CMakeLists.txt @@ -51,5 +51,11 @@ ADD_CUSTOM_COMMAND( DEPENDS ${EXTERNAL_OBJECT} ) +message("${EXTERNAL_OBJECT}") # Build an executable using the external object file. ADD_EXECUTABLE(ExternalOBJ executable.cxx ${CUSTOM_OBJECT}) +# A bug showed up in VS2010 where an object file that was +# part of a custom commad output worked, but ones that were +# not didn't work. So, repeat the executable using the object +# directly and not from the output of the copy. +ADD_EXECUTABLE(ExternalOBJ2 executable.cxx ${EXTERNAL_OBJECT}) diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index 5158f3105..4a542d722 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -100,6 +100,9 @@ ExternalProject_Add(${proj} STEP_TARGETS install update SVN_REPOSITORY "" SVN_REVISION "" + SVN_USERNAME "" + SVN_PASSWORD "" + SVN_TRUST_CERT 1 TEST_COMMAND "" TIMEOUT "" URL "" diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index f420f4bd5..87fe84eb1 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -37,6 +37,38 @@ FIND_PACKAGE(VersionTestB 1.2) FIND_PACKAGE(VersionTestC 1.2.3) FIND_PACKAGE(VersionTestD 1.2.3.4) +#----------------------------------------------------------------------------- +# Test system package registry if possible. +SET(CMakeTestSystemPackage "") +IF(WIN32 AND NOT CYGWIN) + # Try writing a value to the system package registry. + SET(_data "${FindPackageTest_SOURCE_DIR}/SystemPackage") + SET(_key "HKLM\\Software\\Kitware\\CMake\\Packages\\CMakeTestSystemPackage") + SET(_file "${FindPackageTest_BINARY_DIR}/CMakeTestSystemPackage.data") + FILE(WRITE ${_file} "${_data}\n") + EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -E md5sum ${_file} + OUTPUT_VARIABLE _output ERROR_VARIABLE _error RESULT_VARIABLE _failed + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + STRING(REGEX REPLACE " .*" "" _value "${_output}") + IF(NOT _failed AND _value) + EXECUTE_PROCESS( + COMMAND reg add "${_key}" /v "${_value}" /t REG_SZ /d "${_data}" /f + OUTPUT_VARIABLE _output ERROR_VARIABLE _output RESULT_VARIABLE _failed + ) + ENDIF() + # If the above worked, add the rest of the test and a rule to + # cleanup the value. + IF(NOT _failed) + MESSAGE(STATUS "HKLM is writable: enabling CMakeTestSystemPackage") + SET(CMakeTestSystemPackage_CLEANUP reg delete "${_key}" /v "${_value}" /f) + SET(CMakeTestSystemPackage CMakeTestSystemPackage) + ELSE() + MESSAGE(STATUS "HKLM is readonly: disabling CMakeTestSystemPackage") + ENDIF() +ENDIF() + #----------------------------------------------------------------------------- #SET(CMAKE_FIND_DEBUG_MODE 1) @@ -48,7 +80,9 @@ SET(PACKAGES WrongA WrongB WrongC WrongD wibbleA wibbleB RecursiveA RecursiveB RecursiveC + ArchA ArchB ArchC ArchD EnvA EnvB + ${CMakeTestSystemPackage} ) FOREACH(p ${PACKAGES}) SET(${p}_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) @@ -105,10 +139,18 @@ FIND_PACKAGE(wibbleA NAMES wibble PATHS B) FIND_PACKAGE(wibbleB NAMES wibble HINTS B) # Look for package with recursive find-modules. -FIND_PACKAGE(RecursiveA) +FIND_PACKAGE(RecursiveA COMPONENTS A) FIND_PACKAGE(RecursiveB 2) FIND_PACKAGE(RecursiveC 3.1 EXACT) +# Test architecture-specific search directories. +SET(CMAKE_LIBRARY_ARCHITECTURE arch) +FIND_PACKAGE(ArchA NAMES Bar) +FIND_PACKAGE(ArchB NAMES Foo CONFIGS FooConfig.cmake) +FIND_PACKAGE(ArchC 3.1 EXACT NAMES zot) +FIND_PACKAGE(ArchD 4.0 EXACT NAMES zot) +UNSET(CMAKE_LIBRARY_ARCHITECTURE) + # Test _DIR environment variable. # We erase the main prefix path to ensure the env var is used. SET(CMAKE_PREFIX_PATH) @@ -116,6 +158,13 @@ SET(ENV{EnvA_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/lib/zot-3.1") FIND_PACKAGE(EnvA 3.1 EXACT QUIET NAMES zot) # Should Work FIND_PACKAGE(EnvB 3.1 EXACT QUIET NAMES zot) # Should Fail +# Test system package registry if available. +IF(CMakeTestSystemPackage) + FIND_PACKAGE(CMakeTestSystemPackage) + EXECUTE_PROCESS(COMMAND ${CMakeTestSystemPackage_CLEANUP} + OUTPUT_VARIABLE _output ERROR_VARIABLE _error) +ENDIF() + # Expected locations at which packages should be found. SET(foo_EXPECTED "lib/foo-1.2/foo-config.cmake") SET(Foo_EXPECTED "lib/foo-1.2/CMake/FooConfig.cmake") @@ -143,8 +192,13 @@ SET(wibbleB_EXPECTED "B/wibble-config.cmake") SET(RecursiveA_EXPECTED "lib/RecursiveA/recursivea-config.cmake") SET(RecursiveB_EXPECTED "lib/zot-2.0/zot-config.cmake") SET(RecursiveC_EXPECTED "lib/zot-3.1/zot-config.cmake") +SET(ArchA_EXPECTED "lib/arch/Bar/BarConfig.cmake") +SET(ArchB_EXPECTED "lib/arch/foo-1.2/CMake/FooConfig.cmake") +SET(ArchC_EXPECTED "lib/arch/zot-3.1/zot-config.cmake") +SET(ArchD_EXPECTED "lib/arch/cmake/zot-4.0/zot-config.cmake") SET(EnvA_EXPECTED "lib/zot-3.1/zot-config.cmake") SET(EnvB_MISSING "EnvB_DIR-NOTFOUND") +SET(CMakeTestSystemPackage_EXPECTED "SystemPackage/CMakeTestSystemPackageConfig.cmake") # Check the results. FOREACH(p ${PACKAGES}) diff --git a/Tests/FindPackageTest/SystemPackage/CMakeTestSystemPackageConfig.cmake b/Tests/FindPackageTest/SystemPackage/CMakeTestSystemPackageConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/SystemPackage/CMakeTestSystemPackageConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/RecursiveA/recursivea-config.cmake b/Tests/FindPackageTest/lib/RecursiveA/recursivea-config.cmake index deffa5729..eff4d4fd0 100644 --- a/Tests/FindPackageTest/lib/RecursiveA/recursivea-config.cmake +++ b/Tests/FindPackageTest/lib/RecursiveA/recursivea-config.cmake @@ -1 +1,4 @@ # Test config file. +if(NOT "${RecursiveA_FIND_COMPONENTS}" STREQUAL "A") + message(FATAL_ERROR "find_package(RecursiveA NO_MODULE) did not forward components") +endif() diff --git a/Tests/FindPackageTest/lib/arch/Bar/BarConfig.cmake b/Tests/FindPackageTest/lib/arch/Bar/BarConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/arch/Bar/BarConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/arch/cmake/zot-4.0/zot-config-version.cmake b/Tests/FindPackageTest/lib/arch/cmake/zot-4.0/zot-config-version.cmake new file mode 100644 index 000000000..2f768e8f5 --- /dev/null +++ b/Tests/FindPackageTest/lib/arch/cmake/zot-4.0/zot-config-version.cmake @@ -0,0 +1,7 @@ +SET(PACKAGE_VERSION 4.0) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 4) + SET(PACKAGE_VERSION_COMPATIBLE 1) + IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 0) + SET(PACKAGE_VERSION_EXACT 1) + ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 0) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 4) diff --git a/Tests/FindPackageTest/lib/arch/cmake/zot-4.0/zot-config.cmake b/Tests/FindPackageTest/lib/arch/cmake/zot-4.0/zot-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/arch/cmake/zot-4.0/zot-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/arch/foo-1.2/CMake/FooConfig.cmake b/Tests/FindPackageTest/lib/arch/foo-1.2/CMake/FooConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/arch/foo-1.2/CMake/FooConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/arch/zot-3.1/zot-config-version.cmake b/Tests/FindPackageTest/lib/arch/zot-3.1/zot-config-version.cmake new file mode 100644 index 000000000..13763adf1 --- /dev/null +++ b/Tests/FindPackageTest/lib/arch/zot-3.1/zot-config-version.cmake @@ -0,0 +1,7 @@ +SET(PACKAGE_VERSION 3.1) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3) + SET(PACKAGE_VERSION_COMPATIBLE 1) + IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1) + SET(PACKAGE_VERSION_EXACT 1) + ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3) diff --git a/Tests/FindPackageTest/lib/arch/zot-3.1/zot-config.cmake b/Tests/FindPackageTest/lib/arch/zot-3.1/zot-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/arch/zot-3.1/zot-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 04563efeb..c216529f4 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -22,8 +22,19 @@ elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU") endif() endif() +# Pick a module .def file with the properly mangled symbol name. +set(world_def "") +if(WIN32 AND NOT CYGWIN) + if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") + set(world_def world_gnu.def) + elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel" OR + "${CMAKE_GENERATOR}" MATCHES "Visual Studio") # Intel plugin + set(world_def world_icl.def) + endif() +endif() + add_library(hello STATIC hello.f) -add_library(world ${_SHARED} world.f world.def) +add_library(world ${_SHARED} world.f ${world_def}) add_executable(testf testf.f) target_link_libraries(testf hello world) @@ -34,7 +45,7 @@ function(test_fortran_c_interface_module) FortranCInterface_VERIFY() FortranCInterface_VERIFY(CXX) if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|MIPSpro|PathScale") + if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "SunPro|MIPSpro|PathScale|Absoft") set(module_expected 1) endif() if(FortranCInterface_MODULE_FOUND OR module_expected) @@ -108,6 +119,9 @@ if(("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel") ) set(COMPATABLE_COMPILERS TRUE) endif() +if("${CMAKE_Fortran_COMPILER_ID}:${CMAKE_C_COMPILER_ID}" MATCHES "Absoft:GNU") + set(COMPATABLE_COMPILERS TRUE) +endif() if(COMPATABLE_COMPILERS OR ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "${CMAKE_C_COMPILER_ID}" )) test_fortran_c_interface_module() diff --git a/Tests/Fortran/world_gnu.def b/Tests/Fortran/world_gnu.def new file mode 100644 index 000000000..161779877 --- /dev/null +++ b/Tests/Fortran/world_gnu.def @@ -0,0 +1,2 @@ +EXPORTS + world_ diff --git a/Tests/Fortran/world.def b/Tests/Fortran/world_icl.def similarity index 100% rename from Tests/Fortran/world.def rename to Tests/Fortran/world_icl.def diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt new file mode 100644 index 000000000..60b8c22b2 --- /dev/null +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -0,0 +1,47 @@ +cmake_minimum_required (VERSION 2.6) +project(IncludeDirectories) + +file(WRITE ${CMAKE_BINARY_DIR}/Flags/Flags.h +"//Flags.h +") +file(WRITE ${CMAKE_BINARY_DIR}/IncDir/IncDir.h +"//IncDir.h +") +file(WRITE ${CMAKE_BINARY_DIR}/SrcProp/SrcProp.h +"//SrcProp.h +") +file(WRITE ${CMAKE_BINARY_DIR}/TarProp/TarProp.h +"//TarProp.h +") + +# default to testing with full path +# some compilers can not handle the escape for directories +# with spaces in them. +set(USE_FULLPATH TRUE) +if(WATCOM OR MSVC60) + set(USE_FULLPATH FALSE) +endif() +if(USE_FULLPATH) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \"-I${CMAKE_BINARY_DIR}/Flags\"") +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -IFlags") +endif() + +include_directories(${CMAKE_BINARY_DIR}/IncDir) +if(USE_FULLPATH) + set_source_files_properties(main.cpp PROPERTIES COMPILE_FLAGS + "\"-I${CMAKE_BINARY_DIR}/SrcProp\"") +else() + set_source_files_properties(main.cpp PROPERTIES COMPILE_FLAGS + "-ISrcProp") +endif() + +add_executable(IncludeDirectories main.cpp) + +if(USE_FULLPATH) + set_target_properties(IncludeDirectories + PROPERTIES COMPILE_FLAGS "\"-I${CMAKE_BINARY_DIR}/TarProp\"") +else() + set_target_properties(IncludeDirectories + PROPERTIES COMPILE_FLAGS "-ITarProp") +endif() diff --git a/Tests/IncludeDirectories/main.cpp b/Tests/IncludeDirectories/main.cpp new file mode 100644 index 000000000..a59d27c39 --- /dev/null +++ b/Tests/IncludeDirectories/main.cpp @@ -0,0 +1,9 @@ +#include "Flags.h" +#include "IncDir.h" +#include "SrcProp.h" +#include "TarProp.h" + +int main(int argc, char** argv) +{ + return 0; +} diff --git a/Tests/LinkStatic/CMakeLists.txt b/Tests/LinkStatic/CMakeLists.txt new file mode 100644 index 000000000..2062c4345 --- /dev/null +++ b/Tests/LinkStatic/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 2.8.4.20110303 FATAL_ERROR) +project(LinkStatic C) + +if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU)$") + message(FATAL_ERROR "This test works only with the GNU compiler!") +endif() + +find_library(MATH_LIBRARY NAMES libm.a) +if(MATH_LIBRARY) + get_filename_component(MATH_LIB_DIR ${MATH_LIBRARY} PATH) + link_directories(${MATH_LIB_DIR}) + # Name the library both with a full path and as "-lm" to + # activate the link type switching code for both cases. + # If the second one links shared then the link will fail. + set(MATH_LIBRARIES ${MATH_LIBRARY} -lm) +else() + message(FATAL_ERROR "Cannot find libm.a needed for this test") +endif() + +add_executable(LinkStatic LinkStatic.c) +target_link_libraries(LinkStatic ${MATH_LIBRARIES}) + +# Enable static linking. +set(LinkStatic_FLAG "-static" CACHE STRING "Flag to link statically") +set_property(TARGET LinkStatic PROPERTY LINK_FLAGS "${LinkStatic_FLAG}") +set_property(TARGET LinkStatic PROPERTY LINK_SEARCH_START_STATIC 1) +#set_property(TARGET LinkStatic PROPERTY LINK_SEARCH_END_STATIC 1) # insufficient diff --git a/Tests/LinkStatic/LinkStatic.c b/Tests/LinkStatic/LinkStatic.c new file mode 100644 index 000000000..360097744 --- /dev/null +++ b/Tests/LinkStatic/LinkStatic.c @@ -0,0 +1,5 @@ +#include +int main(void) +{ + return (int)sin(0); +} diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index 5fc655064..564db9ff1 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -294,7 +294,7 @@ ELSE(STAGE2) "${CMAKE_INSTALL_PREFIX}/InstallScriptOut.cmake;${CMAKE_INSTALL_PREFIX}/InstallScript4Out.cmake") SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) - # Disable VERSION test until it is implemented in the XCode generator. + # Disable VERSION test until it is implemented in the Xcode generator. IF(NOT XCODE) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) ENDIF(NOT XCODE) diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index 5fc655064..564db9ff1 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -294,7 +294,7 @@ ELSE(STAGE2) "${CMAKE_INSTALL_PREFIX}/InstallScriptOut.cmake;${CMAKE_INSTALL_PREFIX}/InstallScript4Out.cmake") SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) - # Disable VERSION test until it is implemented in the XCode generator. + # Disable VERSION test until it is implemented in the Xcode generator. IF(NOT XCODE) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) ENDIF(NOT XCODE) diff --git a/Tests/SourceGroups/CMakeLists.txt b/Tests/SourceGroups/CMakeLists.txt index e57e0192e..c3cf38c7a 100644 --- a/Tests/SourceGroups/CMakeLists.txt +++ b/Tests/SourceGroups/CMakeLists.txt @@ -5,7 +5,7 @@ project(SourceGroups) # it is more an example with several source_group() # commands. # The created projects have to be loaded manually -# in Visual Studio/XCode/Eclipse/... +# in Visual Studio/Xcode/Eclipse/... # to see whether the correct groups have been created. source_group(Base FILES main.c) diff --git a/Tests/TestsWorkingDirectory/CMakeLists.txt b/Tests/TestsWorkingDirectory/CMakeLists.txt index a0fd18a69..6a6e9b6c7 100644 --- a/Tests/TestsWorkingDirectory/CMakeLists.txt +++ b/Tests/TestsWorkingDirectory/CMakeLists.txt @@ -23,7 +23,7 @@ set_tests_properties(WorkingDirectory2 PROPERTIES set(_default_cwd "${CMAKE_BINARY_DIR}") -# FIXME: How to deal with /debug, /release, etc. with VS or XCode? +# FIXME: How to deal with /debug, /release, etc. with VS or Xcode? if(${CMAKE_GENERATOR} MATCHES "Makefiles") add_test(WorkingDirectory3 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd}) endif() @@ -34,7 +34,7 @@ string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_BINARY_DIR}") add_test(NAME WorkingDirectory5 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/.. COMMAND WorkingDirectory ${_parent_dir}) -# FIXME: How to deal with /debug, /release, etc. with VS or XCode? +# FIXME: How to deal with /debug, /release, etc. with VS or Xcode? if(${CMAKE_GENERATOR} MATCHES "Makefiles") add_test(WorkingDirectory6 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..) endif() diff --git a/Tests/TestsWorkingDirectory/subdir/CMakeLists.txt b/Tests/TestsWorkingDirectory/subdir/CMakeLists.txt index 523f02e44..c16b1db43 100644 --- a/Tests/TestsWorkingDirectory/subdir/CMakeLists.txt +++ b/Tests/TestsWorkingDirectory/subdir/CMakeLists.txt @@ -14,7 +14,7 @@ set_tests_properties(WorkingDirectory-Subdir2 PROPERTIES set(_default_cwd "${CMAKE_CURRENT_BINARY_DIR}") -# FIXME: How to deal with /debug, /release, etc. with VS or XCode? +# FIXME: How to deal with /debug, /release, etc. with VS or Xcode? if(${CMAKE_GENERATOR} MATCHES "Makefiles") add_test(WorkingDirectory-Subdir3 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd}) endif() @@ -25,7 +25,7 @@ string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_CURRENT_BINARY_DIR}") add_test(NAME WorkingDirectory-Subdir5 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.. COMMAND WorkingDirectory ${_parent_dir}) -# FIXME: How to deal with /debug, /release, etc. with VS or XCode? +# FIXME: How to deal with /debug, /release, etc. with VS or Xcode? if(${CMAKE_GENERATOR} MATCHES "Makefiles") add_test(WorkingDirectory-Subdir6 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..) endif() diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 90c2cfce2..938c092c0 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -232,3 +232,16 @@ IF("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") CHECK_C_COMPILER_FLAG("-Werror;-Wstrict-prototypes" C_STRICT_PROTOTYPES) TEST_ASSERT(C_STRICT_PROTOTYPES "CHECK_C_COMPILER_FLAG failed -Werror -Wstrict-prototypes") ENDIF() + +####################################################################### +# +# also test that the check_prototype_definition macro works + +include(CheckPrototypeDefinition) + +check_prototype_definition(remove + "int remove(const char *pathname)" + "0" + "stdio.h" + TEST_REMOVE_PROTO) +test_assert(TEST_REMOVE_PROTO "check_prototype_definition for remove() failed") diff --git a/Utilities/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake index fd916659b..75b00616a 100644 --- a/Utilities/Release/create-cmake-release.cmake +++ b/Utilities/Release/create-cmake-release.cmake @@ -1,28 +1,42 @@ if(NOT DEFINED CMAKE_CREATE_VERSION) - message(FATAL_ERROR "CMAKE_CREATE_VERSION not defined") -endif(NOT DEFINED CMAKE_CREATE_VERSION) + set(CMAKE_CREATE_VERSION "release") + message("Using default value of 'release' for CMAKE_CREATE_VERSION") +endif() -set(RELEASE_SCRIPTS +file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/logs) + +set(RELEASE_SCRIPTS_BATCH_1 + dash2win64_release.cmake # Windows dashmacmini2_release.cmake # Mac Darwin universal - dashsun1_release.cmake # SunOS -# destiny_release.cmake # HPUX -- destiny is dead; long live destiny magrathea_release.cmake # Linux - dash2win64_release.cmake # Windows -# dash2win64_cygwin.cmake # Cygwin -# blight_cygwin.cmake # Cygwin - v20n250_aix_release.cmake # AIX 5.3 + dashsun1_release.cmake # SunOS + v20n250_aix_release.cmake # AIX 5.3 ferrari_sgi64_release.cmake # IRIX 64 - ferrari_sgi_release.cmake # IRIX 64 + ferrari_sgi_release.cmake # IRIX ) -file(WRITE create-${CMAKE_CREATE_VERSION}.sh "#!/bin/bash") -make_directory(${CMAKE_CURRENT_SOURCE_DIR}/logs) +set(RELEASE_SCRIPTS_BATCH_2 + dash2win64_cygwin.cmake # Cygwin +) -foreach(f ${RELEASE_SCRIPTS}) - file(APPEND create-${CMAKE_CREATE_VERSION}.sh +function(write_batch_shell_script filename) + set(scripts ${ARGN}) + set(i 0) + file(WRITE ${filename} "#!/bin/bash") + foreach(f ${scripts}) + math(EXPR x "420*(${i}/4)") + math(EXPR y "160*(${i}%4)") + file(APPEND ${filename} " ${CMAKE_COMMAND} -DCMAKE_CREATE_VERSION=${CMAKE_CREATE_VERSION} -P ${CMAKE_ROOT}/Utilities/Release/${f} < /dev/null >& ${CMAKE_CURRENT_SOURCE_DIR}/logs/${f}-${CMAKE_CREATE_VERSION}.log & - xterm -geometry 80x10 -sb -sl 2000 -T ${f}-${CMAKE_CREATE_VERSION}.log -e tail -f ${CMAKE_CURRENT_SOURCE_DIR}/logs/${f}-${CMAKE_CREATE_VERSION}.log&") -endforeach(f) -execute_process(COMMAND chmod a+x create-${CMAKE_CREATE_VERSION}.sh) -message("Run ./create-${CMAKE_CREATE_VERSION}.sh") +xterm -geometry 64x6+${x}+${y} -sb -sl 2000 -T ${f}-${CMAKE_CREATE_VERSION}.log -e tail -f ${CMAKE_CURRENT_SOURCE_DIR}/logs/${f}-${CMAKE_CREATE_VERSION}.log& +") + math(EXPR i "${i}+1") + endforeach(f) + execute_process(COMMAND chmod a+x ${filename}) +endfunction() + +write_batch_shell_script("create-${CMAKE_CREATE_VERSION}-batch1.sh" ${RELEASE_SCRIPTS_BATCH_1}) +write_batch_shell_script("create-${CMAKE_CREATE_VERSION}-batch2.sh" ${RELEASE_SCRIPTS_BATCH_2}) + +message("Run ./create-${CMAKE_CREATE_VERSION}-batch1.sh, then after all those builds complete, run ./create-${CMAKE_CREATE_VERSION}-batch2.sh") diff --git a/Utilities/Release/dash2win64_cygwin.cmake b/Utilities/Release/dash2win64_cygwin.cmake index 64099a969..da6600292 100644 --- a/Utilities/Release/dash2win64_cygwin.cmake +++ b/Utilities/Release/dash2win64_cygwin.cmake @@ -12,7 +12,6 @@ CMAKE_Fortran_COMPILER_FULLPATH:FILEPATH=FALSE set(CXX g++) set(CC gcc) set(SCRIPT_NAME dash2win64cygwin) -set(GIT_COMMAND git) set(GIT_EXTRA "git config core.autocrlf true") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) include(${path}/release_cmake.cmake) diff --git a/Utilities/Release/dash2win64_release.cmake b/Utilities/Release/dash2win64_release.cmake index 94decdd10..fb82de0d0 100644 --- a/Utilities/Release/dash2win64_release.cmake +++ b/Utilities/Release/dash2win64_release.cmake @@ -15,6 +15,5 @@ BUILD_QtDialog:BOOL:=TRUE QT_QMAKE_EXECUTABLE:FILEPATH=c:/Dashboards/Support/qt-build/Qt/bin/qmake.exe ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) -set(GIT_COMMAND git) set(GIT_EXTRA "git config core.autocrlf true") include(${path}/release_cmake.cmake) diff --git a/Utilities/Release/dashmacmini2_release.cmake b/Utilities/Release/dashmacmini2_release.cmake index 6deeb413b..d117014f9 100644 --- a/Utilities/Release/dashmacmini2_release.cmake +++ b/Utilities/Release/dashmacmini2_release.cmake @@ -15,6 +15,5 @@ CPACK_SYSTEM_NAME:STRING=Darwin-universal BUILD_QtDialog:BOOL:=TRUE QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Software/QtBinUniversal/bin/qmake ") -set(GIT_COMMAND /opt/local/bin/git) get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) include(${path}/release_cmake.cmake) diff --git a/Utilities/Release/ferrari_sgi64_release.cmake b/Utilities/Release/ferrari_sgi64_release.cmake index 770c7e82a..4425f0557 100644 --- a/Utilities/Release/ferrari_sgi64_release.cmake +++ b/Utilities/Release/ferrari_sgi64_release.cmake @@ -1,4 +1,3 @@ -set(CVS_COMMAND "/home/whoffman/bin/cvs") set(CMAKE_RELEASE_DIRECTORY "/home/whoffman/CMakeReleaseDirectory64") set(PROCESSORS 2) set(CFLAGS "-64") diff --git a/Utilities/Release/ferrari_sgi_release.cmake b/Utilities/Release/ferrari_sgi_release.cmake index dd3c62486..ee5121a9b 100644 --- a/Utilities/Release/ferrari_sgi_release.cmake +++ b/Utilities/Release/ferrari_sgi_release.cmake @@ -1,4 +1,3 @@ -set(CVS_COMMAND "/home/whoffman/bin/cvs") set(CMAKE_RELEASE_DIRECTORY "/home/whoffman/CMakeReleaseDirectory") set(PROCESSORS 2) set(HOST sgi) diff --git a/Utilities/Release/magrathea_release.cmake b/Utilities/Release/magrathea_release.cmake index a34823594..549460ecd 100644 --- a/Utilities/Release/magrathea_release.cmake +++ b/Utilities/Release/magrathea_release.cmake @@ -3,7 +3,6 @@ set(HOST magrathea) set(MAKE_PROGRAM "make") set(CC gcc332s) set(CXX c++332s) -set(GIT_COMMAND /home/kitware/.userroot/git/bin/git) set(INITIAL_CACHE " CMAKE_BUILD_TYPE:STRING=Release CURSES_LIBRARY:FILEPATH=/usr/i686-gcc-332s/lib/libncurses.a diff --git a/Utilities/Release/release_cmake.cmake b/Utilities/Release/release_cmake.cmake index 939d9dcb8..0c9b3f9c5 100644 --- a/Utilities/Release/release_cmake.cmake +++ b/Utilities/Release/release_cmake.cmake @@ -1,5 +1,3 @@ -set(CVSROOT ":pserver:anonymous@cmake.org:/cmake.git") - get_filename_component(SCRIPT_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH) # default to self extracting tgz, tgz, and tar.Z @@ -30,17 +28,15 @@ endif(NOT DEFINED PROCESSORS) if(NOT DEFINED CMAKE_CREATE_VERSION) message(FATAL_ERROR "CMAKE_CREATE_VERSION not defined") endif(NOT DEFINED CMAKE_CREATE_VERSION) -if(NOT DEFINED CVS_COMMAND) - set(CVS_COMMAND cvs) -endif(NOT DEFINED CVS_COMMAND) +if(NOT DEFINED GIT_COMMAND) + set(GIT_COMMAND git) +endif() if(${CMAKE_CREATE_VERSION} MATCHES "^(release|maint|next|nightly)$") set(GIT_BRANCH origin/${CMAKE_CREATE_VERSION}) else() set(GIT_BRANCH ${CMAKE_CREATE_VERSION}) endif() -set( CMAKE_CHECKOUT "${CVS_COMMAND} -q -d ${CVSROOT} co -d ${CMAKE_CREATE_VERSION} ${CMAKE_CREATE_VERSION}") - if(NOT DEFINED FINAL_PATH ) set(FINAL_PATH ${CMAKE_RELEASE_DIRECTORY}/${CMAKE_CREATE_VERSION}-build) diff --git a/Utilities/Release/release_cmake.sh.in b/Utilities/Release/release_cmake.sh.in index 8455e92c8..50882c5de 100755 --- a/Utilities/Release/release_cmake.sh.in +++ b/Utilities/Release/release_cmake.sh.in @@ -93,10 +93,8 @@ if [ ! -z "@GIT_COMMAND@" ]; then check_exit_value $? "git checkout" || exit 1 cd .. else - # for CVS just run the CMAKE_CHECKOUT command as set - # in release_cmake.cmake - @CMAKE_CHECKOUT@ - check_exit_value $? "CVS Checkout cmake source" || exit 1 + echo GIT_COMMAND does not exist + exit 1 fi cd @CMAKE_RELEASE_DIRECTORY@/@CMAKE_CREATE_VERSION@-build diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake index b57853cd0..dc6c78f38 100644 --- a/Utilities/Release/upload_release.cmake +++ b/Utilities/Release/upload_release.cmake @@ -2,13 +2,16 @@ set(PROJECT_PREFIX cmake-) if(NOT VERSION) set(VERSION 2.8) endif() +set(dir "v${VERSION}") if("${VERSION}" MATCHES "master") - set(VERSION CVS) + set(dir "dev") endif() file(GLOB FILES ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_PREFIX}*") +list(SORT FILES) +list(REVERSE FILES) message("${FILES}") set(UPLOAD_LOC - "kitware@www.cmake.org:/projects/FTP/pub/cmake/v${VERSION}") + "kitware@www.cmake.org:/projects/FTP/pub/cmake/${dir}") set(count 0) foreach(file ${FILES}) if(NOT IS_DIRECTORY ${file}) @@ -19,8 +22,8 @@ foreach(file ${FILES}) math(EXPR count "${count} + 1") if("${result}" GREATER 0) message(FATAL_ERROR "failed to upload file to ${UPLOAD_LOC}") - endif("${result}" GREATER 0) - endif(NOT IS_DIRECTORY ${file}) + endif() + endif() endforeach(file) if(${count} EQUAL 0) message(FATAL_ERROR "Error no files uploaded.") diff --git a/Utilities/Release/v20n250_aix_release.cmake b/Utilities/Release/v20n250_aix_release.cmake index 7a5c8b937..53c34d7ce 100644 --- a/Utilities/Release/v20n250_aix_release.cmake +++ b/Utilities/Release/v20n250_aix_release.cmake @@ -1,7 +1,6 @@ set(CMAKE_RELEASE_DIRECTORY "/bench1/noibm34/CMakeReleaseDirectory") set(FINAL_PATH /u/noibm34/cmake-release) set(PROCESSORS 2) -set(CVS_COMMAND /vol/local/bin/cvs) set(HOST "sshserv.centers.ihost.com") set(EXTRA_HOP "rsh p90n03") set(MAKE_PROGRAM "make") diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index 454d2d13d..7030b2eb2 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -1,10 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.4) -IF(COMMAND CMAKE_POLICY) - CMAKE_POLICY(SET CMP0003 NEW) -ENDIF(COMMAND CMAKE_POLICY) -IF(CMAKE_OSX_ARCHITECTURES) - CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR) -ENDIF(CMAKE_OSX_ARCHITECTURES) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR) PROJECT(LIBCURL C) # Setup package meta-data diff --git a/Utilities/cmcurl/easy.c b/Utilities/cmcurl/easy.c index f3c227317..209d1c3e0 100644 --- a/Utilities/cmcurl/easy.c +++ b/Utilities/cmcurl/easy.c @@ -708,7 +708,7 @@ void curl_easy_reset(CURL *curl) data->set.ssl.verifypeer = TRUE; data->set.ssl.verifyhost = 2; #ifdef CURL_CA_BUNDLE - /* This is our prefered CA cert bundle since install time */ + /* This is our preferred CA cert bundle since install time */ data->set.ssl.CAfile = (char *)CURL_CA_BUNDLE; #endif diff --git a/Utilities/cmcurl/setup.h b/Utilities/cmcurl/setup.h index e302f35be..5ae881fba 100644 --- a/Utilities/cmcurl/setup.h +++ b/Utilities/cmcurl/setup.h @@ -155,7 +155,7 @@ typedef unsigned char bool; #define SIZEOF_CURL_OFF_T 4 #endif -/* We set up our internal prefered (CURL_)FORMAT_OFF_T here */ +/* We set up our internal preferred (CURL_)FORMAT_OFF_T here */ #if SIZEOF_CURL_OFF_T > 4 #define FORMAT_OFF_T "lld" #else diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt index 08cda1e9c..0b9380fdb 100644 --- a/Utilities/cmlibarchive/CMakeLists.txt +++ b/Utilities/cmlibarchive/CMakeLists.txt @@ -1,8 +1,8 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR) # # PROJECT(libarchive C) # -CMAKE_MINIMUM_REQUIRED(VERSION 2.6.1) SET(CMAKE_MODULE_PATH "${libarchive_SOURCE_DIR}/build/cmake") # We use CHECK_TYPE_SIZE for existence tests, so use only one arch. diff --git a/bootstrap b/bootstrap index b95e36a35..c9998882e 100755 --- a/bootstrap +++ b/bootstrap @@ -666,9 +666,9 @@ if ${cmake_system_cygwin}; then cmake_ld_flags="${LDFLAGS} -Wl,--enable-auto-import" fi -# Add Carbon framework on Darwin +# Add CoreFoundation framework on Darwin if ${cmake_system_darwin}; then - cmake_ld_flags="${LDFLAGS} -framework Carbon" + cmake_ld_flags="${LDFLAGS} -framework CoreFoundation" fi # Add BeOS toolkits...