From d90445442454ff5da507afe6b0f8bdffa048c395 Mon Sep 17 00:00:00 2001 From: Modestas Vainius Date: Sun, 12 Oct 2008 21:55:53 +0300 Subject: [PATCH] Import cmake 2.6.2 Signed-off-by: Modestas Vainius --- CMakeCPack.cmake | 19 +- CMakeCPackOptions.cmake.in | 2 +- CMakeLists.txt | 4 +- CTestConfig.cmake | 28 +- ChangeLog.manual | 255 +++++++ DartConfig.cmake | 66 +- Docs/cmake-syntax.vim | 12 +- Modules/BundleUtilities.cmake | 645 ++++++++++++++++ Modules/CMakeCCompilerABI.c | 20 +- Modules/CMakeCCompilerId.c.in | 21 +- Modules/CMakeCInformation.cmake | 12 +- Modules/CMakeCXXCompilerABI.cpp | 16 +- Modules/CMakeCXXCompilerId.cpp.in | 14 +- Modules/CMakeCXXInformation.cmake | 12 +- Modules/CMakeDetermineASMCompiler.cmake | 17 +- Modules/CMakeDetermineCCompiler.cmake | 38 +- Modules/CMakeDetermineCXXCompiler.cmake | 34 +- Modules/CMakeFindBinUtils.cmake | 31 +- Modules/CMakeFortranCompilerId.F90.in | 2 + Modules/CMakeFortranInformation.cmake | 12 +- Modules/CMakeImportBuildSettings.cmake | 4 +- Modules/CMakeTestFortranCompiler.cmake | 5 +- Modules/CPack.Info.plist.in | 2 +- Modules/CPack.RuntimeScript.in | 6 +- Modules/CPack.cmake | 636 +++++++++++++++- Modules/CPack.distribution.dist.in | 9 + Modules/CPackRPM.cmake | 64 +- Modules/CheckCCompilerFlag.cmake | 4 + Modules/CheckFortranFunctionExists.cmake | 5 +- Modules/CheckTypeSizeC.c.in | 13 +- Modules/FindBLAS.cmake | 445 +++++++---- Modules/FindBoost.cmake | 421 ++++++----- Modules/FindCurses.cmake | 81 +- Modules/FindFLTK.cmake | 23 +- Modules/FindFreetype.cmake | 22 +- Modules/FindGDAL.cmake | 17 +- Modules/FindGIF.cmake | 18 +- Modules/FindGettext.cmake | 2 +- Modules/FindImageMagick.cmake | 233 ++++-- Modules/FindJNI.cmake | 34 +- Modules/FindJPEG.cmake | 4 +- Modules/FindKDE3.cmake | 149 ++-- Modules/FindKDE4.cmake | 28 +- Modules/FindLAPACK.cmake | 208 +++-- Modules/FindLibXml2.cmake | 13 +- Modules/FindLua50.cmake | 27 +- Modules/FindLua51.cmake | 21 +- Modules/FindMPI.cmake | 13 +- Modules/FindMatlab.cmake | 4 +- Modules/FindOpenAL.cmake | 17 +- Modules/FindOpenGL.cmake | 8 +- Modules/FindOpenSSL.cmake | 141 ++-- Modules/FindOpenThreads.cmake | 27 +- Modules/FindPHP4.cmake | 2 + Modules/FindPNG.cmake | 2 +- Modules/FindPackageHandleStandardArgs.cmake | 9 +- Modules/FindPhysFS.cmake | 19 +- Modules/FindProducer.cmake | 16 +- Modules/FindQt3.cmake | 79 +- Modules/FindQt4.cmake | 210 +++-- Modules/FindQuickTime.cmake | 9 +- Modules/FindSDL.cmake | 24 +- Modules/FindSDL_image.cmake | 16 +- Modules/FindSDL_mixer.cmake | 16 +- Modules/FindSDL_net.cmake | 16 +- Modules/FindSDL_sound.cmake | 11 +- Modules/FindSDL_ttf.cmake | 15 +- Modules/FindSWIG.cmake | 8 +- Modules/FindSubversion.cmake | 31 +- Modules/FindTCL.cmake | 14 +- Modules/FindTIFF.cmake | 6 +- Modules/FindTclsh.cmake | 6 +- Modules/FindThreads.cmake | 12 + Modules/FindWish.cmake | 6 +- Modules/FindX11.cmake | 6 +- Modules/FindXMLRPC.cmake | 4 +- Modules/Findosg.cmake | 17 +- Modules/FindosgDB.cmake | 17 +- Modules/FindosgFX.cmake | 17 +- Modules/FindosgGA.cmake | 17 +- Modules/FindosgIntrospection.cmake | 17 +- Modules/FindosgManipulator.cmake | 17 +- Modules/FindosgParticle.cmake | 17 +- Modules/FindosgProducer.cmake | 17 +- Modules/FindosgShadow.cmake | 17 +- Modules/FindosgSim.cmake | 17 +- Modules/FindosgTerrain.cmake | 17 +- Modules/FindosgText.cmake | 17 +- Modules/FindosgUtil.cmake | 17 +- Modules/FindosgViewer.cmake | 17 +- Modules/FindwxWidgets.cmake | 67 +- Modules/GetPrerequisites.cmake | 235 +++++- Modules/InstallRequiredSystemLibraries.cmake | 31 +- Modules/MacOSXBundleInfo.plist.in | 36 + Modules/MacOSXFrameworkInfo.plist.in | 26 + Modules/NSIS.template.in | 365 +++++++-- Modules/Platform/Darwin.cmake | 7 +- Modules/Platform/Linux-Intel-C.cmake | 3 + Modules/Platform/Linux-Intel-CXX.cmake | 3 + Modules/Platform/Linux-PGI-Fortran.cmake | 9 + Modules/Platform/Windows-icl.cmake | 2 +- Modules/TestEndianess.c.in | 13 +- Modules/UsePkgConfig.cmake | 16 +- Modules/UseQt4.cmake | 8 +- Modules/readme.txt | 19 +- Source/CMakeLists.txt | 15 + Source/CPack/cmCPackBundleGenerator.cxx | 359 +++++++++ Source/CPack/cmCPackBundleGenerator.h | 49 ++ Source/CPack/cmCPackComponentGroup.cxx | 49 ++ Source/CPack/cmCPackComponentGroup.h | 143 ++++ Source/CPack/cmCPackDebGenerator.cxx | 15 +- Source/CPack/cmCPackGenerator.cxx | 627 +++++++++------ Source/CPack/cmCPackGenerator.h | 23 +- Source/CPack/cmCPackGeneratorFactory.cxx | 7 +- Source/CPack/cmCPackNSISGenerator.cxx | 539 ++++++++++++- Source/CPack/cmCPackNSISGenerator.h | 37 +- Source/CPack/cmCPackPackageMakerGenerator.cxx | 715 ++++++++++++++++-- Source/CPack/cmCPackPackageMakerGenerator.h | 76 +- Source/CPack/cpack.cxx | 6 +- Source/CTest/cmCTestBuildAndTestHandler.cxx | 22 +- Source/CTest/cmCTestBuildCommand.h | 8 +- Source/CTest/cmCTestConfigureCommand.h | 8 +- Source/CTest/cmCTestCoverageCommand.h | 8 +- Source/CTest/cmCTestCoverageHandler.cxx | 46 +- .../cmCTestEmptyBinaryDirectoryCommand.h | 8 +- Source/CTest/cmCTestMemCheckCommand.h | 8 +- Source/CTest/cmCTestReadCustomFilesCommand.h | 4 +- Source/CTest/cmCTestRunScriptCommand.h | 8 +- Source/CTest/cmCTestSleepCommand.h | 10 +- Source/CTest/cmCTestStartCommand.h | 8 +- Source/CTest/cmCTestSubmitCommand.h | 8 +- Source/CTest/cmCTestTestHandler.cxx | 47 +- Source/CTest/cmCTestUpdateCommand.h | 8 +- Source/CursesDialog/cmCursesStringWidget.cxx | 15 +- Source/QtDialog/AddCacheEntry.cxx | 18 +- Source/QtDialog/AddCacheEntry.h | 6 +- Source/QtDialog/AddCacheEntry.ui | 8 +- Source/QtDialog/CMakeFirstConfigure.cxx | 244 ++++++ Source/QtDialog/CMakeFirstConfigure.h | 48 ++ Source/QtDialog/CMakeFirstConfigure.ui | 606 +++++++++++++++ Source/QtDialog/CMakeLists.txt | 9 +- Source/QtDialog/CMakeSetupDialog.cxx | 204 +++-- Source/QtDialog/CMakeSetupDialog.h | 9 +- Source/QtDialog/CMakeSetupDialog.ui | 18 +- Source/QtDialog/QCMake.cxx | 46 +- Source/QtDialog/QCMake.h | 31 +- Source/QtDialog/QCMakeCacheView.cxx | 673 +++++++++-------- Source/QtDialog/QCMakeCacheView.h | 143 ++-- Source/QtDialog/QCMakeWidgets.cxx | 122 +++ Source/QtDialog/QCMakeWidgets.h | 71 ++ Source/cmAddCustomCommandCommand.cxx | 4 +- Source/cmAddCustomCommandCommand.h | 4 +- Source/cmAddLibraryCommand.cxx | 20 +- Source/cmAddLibraryCommand.h | 6 +- Source/cmAddSubDirectoryCommand.h | 26 +- Source/cmBootstrapCommands.cxx | 6 +- Source/cmCMakePolicyCommand.cxx | 65 +- Source/cmCMakePolicyCommand.h | 10 +- Source/cmCacheManager.cxx | 8 +- Source/cmCallVisualStudioMacro.cxx | 46 +- Source/cmCallVisualStudioMacro.h | 7 +- Source/cmCommands.cxx | 6 +- Source/cmComputeLinkDepends.cxx | 410 ++++++---- Source/cmComputeLinkDepends.h | 44 +- Source/cmComputeLinkInformation.cxx | 117 ++- Source/cmComputeLinkInformation.h | 7 +- Source/cmComputeTargetDepends.cxx | 25 +- Source/cmComputeTargetDepends.h | 7 +- Source/cmCustomCommand.cxx | 4 +- Source/cmCustomCommand.h | 4 +- Source/cmDepends.cxx | 22 +- Source/cmDepends.h | 11 +- Source/cmDependsC.cxx | 186 ++++- Source/cmDependsC.h | 26 +- Source/cmDependsFortran.cxx | 29 +- Source/cmDependsFortran.h | 9 +- Source/cmDocumentVariables.cxx | 124 ++- Source/cmDocumentation.cxx | 15 +- Source/cmDocumentation.h | 11 +- Source/cmDocumentationFormatter.cxx | 8 +- Source/cmDocumentationFormatterDocbook.cxx | 6 +- Source/cmDocumentationFormatterHTML.cxx | 49 +- Source/cmELF.cxx | 15 +- Source/cmExtraCodeBlocksGenerator.cxx | 19 +- Source/cmExtraEclipseCDT4Generator.cxx | 10 +- Source/cmFLTKWrapUICommand.cxx | 18 +- Source/cmFileCommand.cxx | 108 ++- Source/cmFileCommand.h | 12 +- Source/cmFindBase.cxx | 381 +++++----- Source/cmFindBase.h | 33 +- Source/cmFindCommon.cxx | 158 ++-- Source/cmFindCommon.h | 33 +- Source/cmFindLibraryCommand.cxx | 131 ++-- Source/cmFindLibraryCommand.h | 9 +- Source/cmFindPackageCommand.cxx | 441 ++++++----- Source/cmFindPackageCommand.h | 19 +- Source/cmFindPathCommand.cxx | 149 ++-- Source/cmFindPathCommand.h | 12 +- Source/cmFindProgramCommand.cxx | 11 +- Source/cmGetCMakePropertyCommand.cxx | 20 +- Source/cmGetCMakePropertyCommand.h | 7 +- Source/cmGetPropertyCommand.h | 6 +- Source/cmGlobalGenerator.cxx | 286 ++++++- Source/cmGlobalGenerator.h | 20 +- Source/cmGlobalKdevelopGenerator.cxx | 23 +- Source/cmGlobalUnixMakefileGenerator3.cxx | 39 +- Source/cmGlobalUnixMakefileGenerator3.h | 6 +- Source/cmGlobalVisualStudio7Generator.cxx | 5 +- Source/cmGlobalVisualStudioGenerator.cxx | 12 +- Source/cmGlobalXCodeGenerator.cxx | 183 +++-- Source/cmGlobalXCodeGenerator.h | 6 +- Source/cmIfCommand.cxx | 80 +- Source/cmIfCommand.h | 11 +- Source/cmInstallCommand.cxx | 81 +- Source/cmInstallFilesCommand.cxx | 9 +- Source/cmInstallProgramsCommand.cxx | 9 +- Source/cmInstallTargetGenerator.cxx | 10 +- Source/cmInstallTargetGenerator.h | 6 +- Source/cmInstallTargetsCommand.cxx | 7 +- Source/cmListCommand.cxx | 74 +- Source/cmLocalGenerator.cxx | 236 +++--- Source/cmLocalGenerator.h | 12 +- Source/cmLocalUnixMakefileGenerator3.cxx | 134 ++-- Source/cmLocalVisualStudio6Generator.cxx | 15 +- Source/cmLocalVisualStudio7Generator.cxx | 20 +- Source/cmMakefile.cxx | 329 +++++--- Source/cmMakefile.h | 10 +- .../cmMakefileExecutableTargetGenerator.cxx | 6 +- Source/cmMakefileLibraryTargetGenerator.cxx | 63 +- Source/cmMakefileLibraryTargetGenerator.h | 9 +- Source/cmMakefileTargetGenerator.cxx | 71 +- Source/cmOrderDirectories.cxx | 95 ++- Source/cmOrderDirectories.h | 11 +- Source/cmPolicies.cxx | 196 ++--- Source/cmPolicies.h | 22 +- Source/cmReturnCommand.h | 18 +- Source/cmSetPropertyCommand.cxx | 7 +- Source/cmSetSourceFilesPropertiesCommand.cxx | 7 +- Source/cmSetTargetPropertiesCommand.cxx | 5 +- Source/cmSourceFile.cxx | 22 +- Source/cmSourceFileLocation.cxx | 122 ++- Source/cmSourceFileLocation.h | 6 +- Source/cmSourceGroup.cxx | 63 +- Source/cmSourceGroup.h | 14 +- Source/cmStringCommand.cxx | 6 +- Source/cmSystemTools.cxx | 378 +++++---- Source/cmSystemTools.h | 13 +- Source/cmTarget.cxx | 224 +++++- Source/cmTarget.h | 26 +- Source/cmTargetLinkLibrariesCommand.cxx | 174 ++++- Source/cmTargetLinkLibrariesCommand.h | 54 +- Source/cmVersion.cxx | 12 +- Source/cmWin32ProcessExecution.cxx | 26 +- Source/cmXCodeObject.cxx | 66 +- Source/cmXCodeObject.h | 6 +- Source/cmake.cxx | 137 +++- Source/cmake.h | 13 +- Source/cmakemain.cxx | 37 +- Source/kwsys/CMakeLists.txt | 8 + Source/kwsys/CPU.h.in | 8 + Source/kwsys/DynamicLoader.cxx | 7 +- Source/kwsys/Glob.cxx | 15 +- Source/kwsys/Glob.hxx.in | 12 + Source/kwsys/ProcessUNIX.c | 19 +- Source/kwsys/ProcessWin32.c | 2 +- Source/kwsys/RegularExpression.cxx | 37 + Source/kwsys/RegularExpression.hxx.in | 5 + Source/kwsys/SystemInformation.cxx | 71 +- Source/kwsys/SystemTools.cxx | 59 +- Source/kwsys/SystemTools.hxx.in | 16 +- Source/kwsys/Terminal.c | 20 +- Templates/DLLHeader.dsptemplate | 16 +- Templates/EXEHeader.dsptemplate | 8 +- Templates/EXEWinHeader.dsptemplate | 8 +- Tests/BuildDepends/CMakeLists.txt | 52 +- Tests/BuildDepends/Project/CMakeLists.txt | 15 +- Tests/BuildDepends/Project/zot.cxx | 6 +- Tests/BuildDepends/Project/zot_macro_dir.cxx | 7 + Tests/BuildDepends/Project/zot_macro_tgt.cxx | 7 + Tests/BundleGeneratorTest/BundleIcon.icns | Bin 0 -> 33478 bytes Tests/BundleGeneratorTest/CMakeLists.txt | 24 + Tests/BundleGeneratorTest/Executable.cxx | 8 + Tests/BundleGeneratorTest/Info.plist | 14 + Tests/BundleGeneratorTest/Library.cxx | 7 + Tests/BundleGeneratorTest/StartupCommand | 12 + Tests/BundleTest/BundleLib.cxx | 7 + Tests/BundleTest/BundleSubDir/CMakeLists.txt | 6 +- Tests/BundleTest/BundleTest.cxx | 11 + Tests/BundleTest/CMakeLists.txt | 19 +- Tests/CMakeLists.txt | 80 +- .../cmake_i_do_not_exist_in_the_system.h | 1 + Tests/CMakeTests/FindBaseTest.cmake.in | 18 + Tests/CMakeTests/ToolchainTest.cmake.in | 4 +- Tests/CPackComponents/CMakeLists.txt | 72 ++ Tests/CPackComponents/VerifyResult.cmake | 48 ++ Tests/CPackComponents/mylib.cpp | 7 + Tests/CPackComponents/mylib.h | 1 + Tests/CPackComponents/mylibapp.cpp | 6 + Tests/Complex/CMakeLists.txt | 5 + Tests/Complex/Executable/CMakeLists.txt | 17 + Tests/Complex/Library/CMakeLists.txt | 4 + Tests/ComplexOneConfig/CMakeLists.txt | 5 + .../Executable/CMakeLists.txt | 17 + Tests/ComplexOneConfig/Library/CMakeLists.txt | 4 + Tests/ComplexRelativePaths/CMakeLists.txt | 5 + .../Executable/CMakeLists.txt | 17 + .../Library/CMakeLists.txt | 4 + Tests/CustomCommand/CMakeLists.txt | 14 +- Tests/CustomCommand/wrapper.cxx | 18 + Tests/Dependency/CMakeLists.txt | 1 + Tests/Dependency/Case4/CMakeLists.txt | 23 + Tests/Dependency/Case4/bar.c | 2 + Tests/Dependency/Case4/foo.c | 1 + Tests/ExportImport/Export/CMakeLists.txt | 26 +- Tests/ExportImport/Export/testLib4lib.c | 4 + Tests/ExportImport/Export/testLib4libdbg.c | 14 + Tests/ExportImport/Export/testLib4libdbg1.c | 1 + Tests/ExportImport/Export/testLib4libopt.c | 14 + Tests/ExportImport/Export/testLib4libopt1.c | 1 + Tests/ExportImport/Import/CMakeLists.txt | 2 + Tests/ExportImport/Import/imp_testExe1.c | 12 +- Tests/FindModulesExecuteAll/CMakeLists.txt | 30 + Tests/FindModulesExecuteAll/main.c | 4 + Tests/FindPackageTest/A/wibble-config.cmake | 1 + Tests/FindPackageTest/B/wibble-config.cmake | 1 + Tests/FindPackageTest/CMakeLists.txt | 26 + Tests/FindPackageTest/FindVersionTestA.cmake | 18 +- Tests/FindPackageTest/FindVersionTestB.cmake | 12 +- Tests/FindPackageTest/FindVersionTestC.cmake | 6 + Tests/FindPackageTest/FindVersionTestD.cmake | 18 + Tests/Framework/CMakeLists.txt | 13 +- Tests/Framework/fooExtensionlessResource | 1 + Tests/Framework/fooPrivateExtensionlessHeader | 1 + Tests/Framework/fooPublicExtensionlessHeader | 1 + .../OutOfSourceSubdir/CMakeLists.txt | 7 +- Tests/ReturnTest/CMakeLists.txt | 8 + Tests/ReturnTest/include_return.cmake | 3 + Tests/SimpleInstall/CMakeLists.txt | 32 +- Tests/SimpleInstallS2/CMakeLists.txt | 32 +- Tests/TryCompile/CMakeLists.txt | 1 + Utilities/CMakeLists.txt | 12 +- .../CMake/CurlCheckCSourceCompiles.cmake | 75 ++ .../cmcurl/CMake/CurlCheckCSourceRuns.cmake | 83 ++ Utilities/cmcurl/CMake/OtherTests.cmake | 20 +- Utilities/cmcurl/CMakeLists.txt | 22 +- Utilities/cmtar/CMakeLists.txt | 7 +- 346 files changed, 13646 insertions(+), 4899 deletions(-) create mode 100644 Modules/BundleUtilities.cmake create mode 100644 Modules/CPack.distribution.dist.in create mode 100644 Modules/MacOSXBundleInfo.plist.in create mode 100644 Modules/MacOSXFrameworkInfo.plist.in create mode 100644 Modules/Platform/Linux-PGI-Fortran.cmake create mode 100644 Source/CPack/cmCPackBundleGenerator.cxx create mode 100644 Source/CPack/cmCPackBundleGenerator.h create mode 100644 Source/CPack/cmCPackComponentGroup.cxx create mode 100644 Source/CPack/cmCPackComponentGroup.h create mode 100644 Source/QtDialog/CMakeFirstConfigure.cxx create mode 100644 Source/QtDialog/CMakeFirstConfigure.h create mode 100644 Source/QtDialog/CMakeFirstConfigure.ui create mode 100644 Source/QtDialog/QCMakeWidgets.cxx create mode 100644 Source/QtDialog/QCMakeWidgets.h create mode 100644 Tests/BuildDepends/Project/zot_macro_dir.cxx create mode 100644 Tests/BuildDepends/Project/zot_macro_tgt.cxx create mode 100644 Tests/BundleGeneratorTest/BundleIcon.icns create mode 100644 Tests/BundleGeneratorTest/CMakeLists.txt create mode 100644 Tests/BundleGeneratorTest/Executable.cxx create mode 100644 Tests/BundleGeneratorTest/Info.plist create mode 100644 Tests/BundleGeneratorTest/Library.cxx create mode 100644 Tests/BundleGeneratorTest/StartupCommand create mode 100644 Tests/CMakeTests/A/include/cmake_i_do_not_exist_in_the_system.h create mode 100644 Tests/CPackComponents/CMakeLists.txt create mode 100644 Tests/CPackComponents/VerifyResult.cmake create mode 100644 Tests/CPackComponents/mylib.cpp create mode 100644 Tests/CPackComponents/mylib.h create mode 100644 Tests/CPackComponents/mylibapp.cpp create mode 100644 Tests/Dependency/Case4/CMakeLists.txt create mode 100644 Tests/Dependency/Case4/bar.c create mode 100644 Tests/Dependency/Case4/foo.c create mode 100644 Tests/ExportImport/Export/testLib4lib.c create mode 100644 Tests/ExportImport/Export/testLib4libdbg.c create mode 100644 Tests/ExportImport/Export/testLib4libdbg1.c create mode 100644 Tests/ExportImport/Export/testLib4libopt.c create mode 100644 Tests/ExportImport/Export/testLib4libopt1.c create mode 100644 Tests/FindModulesExecuteAll/CMakeLists.txt create mode 100644 Tests/FindModulesExecuteAll/main.c create mode 100644 Tests/FindPackageTest/A/wibble-config.cmake create mode 100644 Tests/FindPackageTest/B/wibble-config.cmake create mode 100644 Tests/FindPackageTest/FindVersionTestD.cmake create mode 100644 Tests/Framework/fooExtensionlessResource create mode 100644 Tests/Framework/fooPrivateExtensionlessHeader create mode 100644 Tests/Framework/fooPublicExtensionlessHeader create mode 100644 Tests/ReturnTest/include_return.cmake create mode 100644 Utilities/cmcurl/CMake/CurlCheckCSourceCompiles.cmake create mode 100644 Utilities/cmcurl/CMake/CurlCheckCSourceRuns.cmake diff --git a/CMakeCPack.cmake b/CMakeCPack.cmake index 6532d9e1c..ec4cb9964 100755 --- a/CMakeCPack.cmake +++ b/CMakeCPack.cmake @@ -32,7 +32,13 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") "${CPACK_SOURCE_PACKAGE_FILE_NAME}-RC-${CMake_VERSION_RC}") ENDIF(CMake_VERSION_RC) IF(NOT DEFINED CPACK_SYSTEM_NAME) - SET(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}) + # make sure package is not Cygwin-unknown, for Cygwin just + # cygwin is good for the system name + IF("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN") + SET(CPACK_SYSTEM_NAME Cygwin) + ELSE("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN") + SET(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}) + ENDIF("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN") ENDIF(NOT DEFINED CPACK_SYSTEM_NAME) IF(${CPACK_SYSTEM_NAME} MATCHES Windows) IF(CMAKE_CL_64) @@ -42,7 +48,15 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") ENDIF(CMAKE_CL_64) ENDIF(${CPACK_SYSTEM_NAME} MATCHES Windows) IF(NOT DEFINED CPACK_PACKAGE_FILE_NAME) - SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}") + # if the CPACK_PACKAGE_FILE_NAME is not defined by the cache + # default to source package - system, on cygwin system is not + # needed + IF(CYGWIN) + SET(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}") + ELSE(CYGWIN) + SET(CPACK_PACKAGE_FILE_NAME + "${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_SYSTEM_NAME}") + ENDIF(CYGWIN) ENDIF(NOT DEFINED CPACK_PACKAGE_FILE_NAME) SET(CPACK_PACKAGE_CONTACT "cmake@cmake.org") IF(UNIX) @@ -52,6 +66,7 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") ENDIF(UNIX) # cygwin specific packaging stuff IF(CYGWIN) + # if we are on cygwin and have cpack, then force the # doc, data and man dirs to conform to cygwin style directories SET(CMAKE_DOC_DIR "/share/doc/${CPACK_PACKAGE_FILE_NAME}") diff --git a/CMakeCPackOptions.cmake.in b/CMakeCPackOptions.cmake.in index 0c571d069..16941c89c 100755 --- a/CMakeCPackOptions.cmake.in +++ b/CMakeCPackOptions.cmake.in @@ -26,7 +26,7 @@ if(CPACK_GENERATOR MATCHES "NSIS") # tell cpack to create a desktop link to CMakeSetup SET(CPACK_CREATE_DESKTOP_LINKS "CMakeSetup") SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\CMakeSetup.exe") - SET(CPACK_NSIS_DISPLAY_NAME "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR} a cross-platform, open-source build system") + SET(CPACK_NSIS_DISPLAY_NAME "CMake @CMake_VERSION_MAJOR@.@CMake_VERSION_MINOR@ a cross-platform, open-source build system") SET(CPACK_NSIS_HELP_LINK "http:\\\\www.cmake.org") SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\www.kitware.com") SET(CPACK_NSIS_CONTACT @CPACK_PACKAGE_CONTACT@) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cbc639eb..8f228abbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -353,8 +353,8 @@ ENDMACRO (CMAKE_BUILD_UTILITIES) # The CMake version number. SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 6) -SET(CMake_VERSION_PATCH 0) -#SET(CMake_VERSION_RC 1) +SET(CMake_VERSION_PATCH 2) +#SET(CMake_VERSION_RC 6) # CVS versions are odd, if this is an odd minor version # then set the CMake_VERSION_DATE variable IF("${CMake_VERSION_MINOR}" MATCHES "[13579]$") diff --git a/CTestConfig.cmake b/CTestConfig.cmake index 2e43722c4..49b04bbbc 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -1,23 +1,7 @@ -SET (CTEST_PROJECT_NAME "CMake") -SET (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") - -MACRO(SET_IF_NOT_SET var val) - IF(NOT DEFINED "${var}") - SET("${var}" "${val}") - ENDIF(NOT DEFINED "${var}") -ENDMACRO(SET_IF_NOT_SET) - -SET_IF_NOT_SET(CTEST_DROP_METHOD "http") -IF(CTEST_DROP_METHOD STREQUAL "http") - SET (CTEST_DROP_SITE "public.kitware.com") - SET (CTEST_DROP_LOCATION "/cgi-bin/HTTPUploadDartFile.cgi") - SET (CTEST_TRIGGER_SITE "http://${CTEST_DROP_SITE}/cgi-bin/Submit-CMake-TestingResults.cgi") -ENDIF(CTEST_DROP_METHOD STREQUAL "http") - -IF(CTEST_DROP_METHOD STREQUAL "xmlrpc") - SET (CTEST_DROP_SITE "http://www.na-mic.org:8081") - SET (CTEST_DROP_LOCATION "CMake") - SET (CTEST_TRIGGER_SITE "not used") - SET (COMPRESS_SUBMISSION ON) -ENDIF(CTEST_DROP_METHOD STREQUAL "xmlrpc") +set(CTEST_PROJECT_NAME "CMake") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=CMake") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/ChangeLog.manual b/ChangeLog.manual index c49a154c8..bd31d9b15 100755 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,3 +1,258 @@ +Changes in CMake 2.6.2 RC 6 +- Fix bug#7669 cpack did not work when sym-linked after install + +Changes in CMake 2.6.2 RC 5 +- Add beta BundleUtilities.cmake file +- CPackRPM 7435 fixes to add optional post-install +- Fix Bug #7456, FindBoost versioned find not working +- Fix FindCurses to be able to work without ncurses.h +- FindQt4 fix bug #7433, add a bit more documentation and add ability + to specify extra flags to lupdate. + +Changes in CMake 2.6.2 RC 4 +- Fix bug #7359 make llvm-gcc work, by explicitely excluding + "llvm-" from _CMAKE_TOOLCHAIN_PREFIX +- Fix bug 7046: OS X Framework support: extensionless headers were + being ignored when specified as public headers +- Fix documentation in CheckCCompilerFlag.cmake +- Add better version support to find_package command +- Fix Xcode debug not working +- Add VERSION compare to if command +- Make FindThreads sete THREADS_FOUND +- Deb cpack generator sets Installed-Size for the package +- Do not add an empty /D"" at the end of VS 6 .dsp compile lines +- Recognize /MAP in VS 7 and greater +- Add new policy CMP0009 - GLOB_RECURSE should not follow symlinks by default + +Changes in CMake 2.6.2 RC 3 +- Fix bug, and remove extra closing > in visual fortran projects. +- Fix bug in ctest -C where it was sometimes ignored. +- Fix crash with exec_process when cmake is being debugged on windows +- Fix unsetting of global properties + +Changes in CMake 2.6.2 RC 2 +- allow tool chains to limit object path length +- add info.plist to frameworks +- better preservation of user link lines +- add a get command for cmake policies +- support for imported libraries of unknown type +- support link interface in target_link_libraries +- Do not hang when select lies +- .m compiled with gcc and g++ on mac +- Fix issue when application bundle dir is removed cmake + needs to re-run automatically +- Report an error when configure has one error +- Fix bug where -E commands stole command line options +- Fix infinite recursion bug with try-compile and change of compilers +- Fix delete and backspace in ccmake +- Fix coverage not to follow symlinks +- Add more possible languages for NSIS in cpack +- FindQt4.cmake fix bug #7433, add documentation that + directories also can be specified to update the translation files. +- Add standard arg handling to FindPHP4.cmake +- Add X11R6 to search path for FindOpenGL +- update cmake-syntax.vim to have more keywords +- BUG: fix #7477, set VERBOSE=1 in the kdevelop setting for + the environment, not together with the make executable +- UsePkgConfig.cmake - clean up, add a status message in case + pkgconfig didn't find the package, sync with kde +- FindX11 look in more places +- FindTIFF look for more names +- FindQt3, make sure qt4 is not found and some style stuff +- FindPNG add more names of linpng (sync with the KDE version) +- FindKDE3/KDE4 sanity checks on qt versions found +- FindLibXMl2 also search for xmllint, which comes with libxml2 + (sync with FindLibXml2.cmake from KDE) +- Fix sizeof, and other compiler INFO string checks with + GNU linker's --gc-sections +- Fix bogus dependency on executable targets when a linked library + happended to match the name of an executable target +- Improve readability of circular depends error +- Fix crash on circular target dependencies +- find_package now knows about lib64 paths +- Fix gentoo elf security issue with RPATH and RUNPATH + +Changes in CMake 2.6.2 RC 1 +- Fix abort in eclipse generator with empty EXECUTABLE_OUTPUT_PATH +- Fix FindKDE3.cmake syntax error +- Fix custom command output by relative path not always working +- Fix bug, Do not convert RPATH entries to full path. +- Allow for "$ORIGIN" into the RPATH> +- Allow for static libraries with lots of objects using archive append +- Fix documentation for FindImageMagick.cmake +- Fix link error with MS compiler and comdef +- Fix crash when attempting to load the RPATH out of a non-ELF file +- Add --trace option to cmake allowing for the tracing of a cmake run +- Fix for issue #4971 where the case of the drive letter component of + the filenames might be different when analyzing gcov output. +- Add warning level W0 to visual studio +- Add support for OSX library version flags + +Changes in CMake 2.6.1 RC 16 +- Fix for bug 7427, preinstall target name hard coded +- Fix issue #7088 - do not emit error messages when attempts to run + Visual Studio macros fail. You can still get the error output + as messages if you want using --debug-output from the cmake command line. +- Fix InstallRequiredSystemLibraries.cmake to work with win64 + +Changes in CMake 2.6.1 RC 15 +- Fix bug 7426 FindJPEG module causes error when setting JPEG_LIBRARY to blank +- Fix bug 7414 PackageMaker generator crashes when given components + with circular dependencies +- Fix source files to not add extra /, and look for extensions for + all enabled languages. +- Change link line to preserve input given to target_link_libraries even + if a shared library is repeated. +- Fix for bug 7421, fortran did not get arch flags on the mac +- For CMP0008 do not depend on the files that are not there, which + makes the Xcode generator delete executables after they are built. +- Work around Boost 1.36.0 bug fix on Darwin by setting the mangled + compiler name to -xgccVERSION +- Updated FindImageMagick to: + - Find newer additions such as animate, compare, etc. + - Find development api: Magick++, MagickCore, MagickWand + - Use FindPackageHandleStandardArgs to output standard messages. + +Changes in CMake 2.6.1 RC 14 +- Change dashboard submission to go directly to CDash. +- Add policy CMP0008- Full-path libraries must be a valid library file name + +Changes in CMake 2.6.1 RC 12 +- More find locations for FindJNI. +- Fix bug with source files ending in .l and .l.cpp, causing cmake + to think they were the same file in some cases. +- Fix issue with .lib being seen as .obj with VS due to a full path + to a library given without the file extension. This only worked + with the VS generator, but some projects had worked around it with + if statements. It now issues a warning, but should link. +- Update cpack stuff for beta OSX bundle generator for CPack +- CheckFortranFunctionExists.cmake now calls the function. +- FindBLAS.cmake, FindLAPACK.cmake modules were redesigned so + now you have three new variables BLA_VENDOR (you can specify the VENDOR), + BLA_STATIC (gets the static version of libs), BLA_F95 + (gets the fortran 95 interface). BLA_VENDOR can be specified as + an environment variable. Intel mkls libs need FindThreads to + be found correctly so you will need to enable the C/CXX +- FindMPI: Use the HINTS feature of find_library to find the right + libraries for MPI, and act a bit more intelligently when MPI cannot be found. +- Improved support for finding wxWidgets in MinGW environment. +- CMAKE[_SYSTEM]_(LIBRARY|PROGRAM|INCLUDE|PREFIX)_PATH variables + moved CMAKE_CROSSCOMPILING from "Variables that modify behaviour" to + "variables that Provide Information" +- handle HTML documentation for single items better: no warning about + ComputeSectionLinkPrefix, don't create an index for only one item. +- Better error messages in CPackBundleGenerator + +Changes in CMake 2.6.1 RC 11 +- Fix curl build issue with Xcode 3.1 +Changes in CMake 2.6.1 RC 10 +- Add a fix for bug # 7340, CMAKE_USER_MAKE_RULES_OVERRIDE was + not able to support a try-compile in cmake 2.6 +- Remove bad test for bug # 7316 +Changes in CMake 2.6.1 RC 9 +- Fix bug # 7316 Xcode double escaped define strings +- FindBoost can now find the upcoming Boost 1.36 +Changes in CMake 2.6.1 RC 8 +- Fix build problem with missing cpack file + +Changes in CMake 2.6.1 RC 7 +- More fixes for CPack components functionality +- Fixes for Xcode generater #7277 #7044, do not compile foo.txt. + Rebuild application bundles when a library changes. Set the project + location for Xcode 3.1 +- Do not automatically add EXECUTABLE_OUTPUT_PATH to cache. +- New tree view in cmake-gui +- FindBoost.cmake, find boost as installed by the BoostPro/Boost Consulting + installers on Windows. And cleanup FindBoost module, fixing several small + bugs and providing better diagnostic information when things go wrong. +- Fix FindwxWidgets.cmake to find richtext library +- Fix FindQt4.cmake with empty qconfig.pri files. Fixes #7287. +- Fix add/remove program version string again... +- Fix column width in cmake-gui + +Changes in CMake 2.6.1 RC 6 +- Fix DEFINITIONS property to be compatible with 2.4 +- Fix escaping of $ for visual studio +- FindGettext.cmake fix bug #7230: don't ignore first parameter if it's not ALL +Changes in CMake 2.6.1 RC 5 +- Add support for component based packages in cpack. +- Fix FindBLAS.cmake if no fortran compiler is found +- Fix FindFLTK.cmake to pass new module test +- Fix FindKDE3.cmake to not add flags if kde3 is not found +- Fix FindMatlab.cmake, FindOpenSSL.cmake, FindQt3.cmake, + FindSWIG.cmake, to only error if it is required +- Fix FindwxWidgets.cmake to work on msys +- Add a beta OSX bundle generator for CPack +- Fix bug in cmake --build-and-test where cmake output was lost +- Fix ctest handling of CDash dart measurement support +- Add a group view to cmake-gui +- Fix nmake/make with visual studio compiler to handle long link lines +- Fix FLTK_WRAP_UI to better notice when mistakes are made with the target name +- Fix spelling error EnableFiberSafeOptimizations + +Changes in CMake 2.6.1 RC 4 +- Change to find_*, a new HINTS keyword was added to avoid the + need for NO_DEFAULT_PATH, and a repeated call to find_* +- Update all NO_DEFAULT_PATH usage in Modules/Find* +- Fix for cpack self extracting .sh files to work with more shells +- FindQt4 now finds dependencies for some qt modules +- ctest cpu information fixes for cygwin and linux +- Recognize more color terminals for color output +- Remove SKIP_RULE_DEPENDS from custom command because CMake + now can detect when a cutom command actually changes and only + re-run the rule then. This fixes the problem of custom commands + re-running every time a file is added to a target. +- Fix for very slow find_path on OSX because of framework searchs +- Fix for bug 6364, extra help targets when there are subdirectories + of the top level. +- Fix for Xcode generator to not eat some flags by mistake. +- Add end of file checking for close if, foreach, macro, functions + etc enabled. + +Changes in CMake 2.6.1 RC 3 +- FindQt4 - Find qt debug libraries on windows with d postfix. +- Find 64 bit windows registry stuff with 32 bit cmake +- Give a message if rpath is changed during install +- rpath changer during install understands symlinks now +- If a source file is not found and is a full path cmake complains. + +Changes in CMake 2.6.1 RC 2 + +- FindQt4 - report an error when trying to use MSVC with Qt built by mingw. +- FindQt4 - make Qt not found if the QtCore library can't be found. +- UseQt4 - only add flags for modles that are used +- Log file and LC_ALL fix for FindSubversion +- Make MacOSXBundleInfo.plist.in a configured file again +- Fix makefile generator targets to depend on full path link libraries +- Allow CMakeImportBuildSettings to not match tools if + CMAKE_OVERRIDE_COMPILER_MISMATCH is set +- Fix incorrect extension extraction in gcc cross compiler check +- Add support for Portand Fortran +- Fix list command with empty list values +- Add support for setting compiler and toolchain in qt cmake-gui +- Fix Bug 7011, FindQt4 was slow on a mac, find_path should not glob in / +- Fix install directories for cygwin package of CMake + +Changes in CMake 2.6.1 RC 1 +- Add a way to modify depend scanning with the property: + IMPLICIT_DEPENDS_INCLUDE_TRANSFORM +- Add a way for custom commands to skip depending on the rule.make file +- Fix ENABLE_LANGUAGE(ASM-ATT OPTIONAL) to work +- Fix gcov in ctest in French or other non-English runs +- Fix help for ctest commands to be lower case +- Find QtCLucene on Qt/Mac binary +- Fix for build on ARM +- Fix for docbook to add newlines +- Fix -Wno-dev to not eat path to source tree +- Fix bug in NSIS CPack where CPACK_NSIS_MODIFY_PATH did modify the path +- Fix FindBoost version variable names to correct bug in Boost version +- Fix Add/Remove program name for CMake install on windows +- Fix bug 0006988 coverage not reported on dashboards +- Fix bug 0006990 CMake crashes with bad input to set_source_files_properties +- Fix bug in FindCurses where you could not run cmake twice +- Fix 64 bit cmake creation of Xcode projects +- Add --help-policy to --help + Changes in CMake 2.6.0 - Fix links in generated documentation - Fix for FindQt and some mac frameworks diff --git a/DartConfig.cmake b/DartConfig.cmake index 367d98a91..49b04bbbc 100644 --- a/DartConfig.cmake +++ b/DartConfig.cmake @@ -1,61 +1,7 @@ -# Dashboard is opened for submissions for a 24 hour period starting at -# the specified NIGHLY_START_TIME. Time is specified in 24 hour format. -SET (NIGHTLY_START_TIME "21:00:00 EDT") - -# Dart server to submit results (used by client) -IF(NOT DROP_METHOD) - SET(DROP_METHOD http) -ENDIF(NOT DROP_METHOD) -IF(DROP_METHOD MATCHES http) - SET (DROP_SITE "public.kitware.com") - SET (DROP_LOCATION "/cgi-bin/HTTPUploadDartFile.cgi") -ELSE(DROP_METHOD MATCHES http) - IF(DROP_METHOD MATCHES xmlrpc) - SET (DROP_SITE "http://www.na-mic.org:8081") - SET (DROP_LOCATION "CMake") - SET (COMPRESS_SUBMISSION ON) - ELSE(DROP_METHOD MATCHES xmlrpc) - SET (DROP_SITE "public.kitware.com") - SET (DROP_LOCATION "/incoming") - SET (DROP_SITE_USER "ftpuser") - SET (DROP_SITE_PASSWORD "public") - ENDIF(DROP_METHOD MATCHES xmlrpc) -ENDIF(DROP_METHOD MATCHES http) - -SET (TRIGGER_SITE - "http://${DROP_SITE}/cgi-bin/Submit-CMake-TestingResults.cgi") - -# Project Home Page -SET (PROJECT_URL "http://www.cmake.org") - -# Dart server configuration -SET (ROLLUP_URL "http://${DROP_SITE}/cgi-bin/cmake-rollup-dashboard.sh") -SET (CVS_WEB_URL "http://${DROP_SITE}/cgi-bin/viewcvs.cgi/") -SET (CVS_WEB_CVSROOT "CMake") - -OPTION(BUILD_DOXYGEN "Build source documentation using doxygen" "Off") -SET (DOXYGEN_CONFIG "${PROJECT_BINARY_DIR}/doxygen.config" ) -MARK_AS_ADVANCED(BUILD_DOXYGEN) -SET (USE_DOXYGEN "On") -SET (DOXYGEN_URL "${PROJECT_URL}/doc/nightly/html/" ) - -SET (USE_GNATS "On") -SET (GNATS_WEB_URL "${PROJECT_URL}/Bug/query.php?projects=2&status%5B%5D=1&status%5B%5D=2&status%5B%5D=3&status%5B%5D=4&status%5B%5D=6&op=doquery") - -# Continuous email delivery variables -SET (CONTINUOUS_FROM "cmake-dashboard@public.kitware.com") -SET (SMTP_MAILHOST "public.kitware.com") -SET (CONTINUOUS_MONITOR_LIST "cmake-dashboard@public.kitware.com") -SET (CONTINUOUS_BASE_URL "${PROJECT_URL}/Testing") - -SET (DELIVER_BROKEN_BUILD_EMAIL_WITH_TEST_FAILURES ON) -SET (DELIVER_BROKEN_BUILD_EMAIL "Continuous Nightly") -SET (EMAIL_FROM "cmake-dashboard@public.kitware.com") -SET (DARTBOARD_BASE_URL "${PROJECT_URL}/Testing") - -SET (DELIVER_BROKEN_BUILD_EMAIL_WITH_CONFIGURE_FAILURES 1) -SET (DELIVER_BROKEN_BUILD_EMAIL_WITH_BUILD_ERRORS 1) -SET (DELIVER_BROKEN_BUILD_EMAIL_WITH_BUILD_WARNINGS 1) -SET (DELIVER_BROKEN_BUILD_EMAIL_WITH_TEST_NOT_RUNS 1) -SET (DELIVER_BROKEN_BUILD_EMAIL_WITH_TEST_FAILURES 1) +set(CTEST_PROJECT_NAME "CMake") +set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=CMake") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Docs/cmake-syntax.vim b/Docs/cmake-syntax.vim index f01e7ad0e..bdbe98e8e 100644 --- a/Docs/cmake-syntax.vim +++ b/Docs/cmake-syntax.vim @@ -3,8 +3,8 @@ " Program: CMake - Cross-Platform Makefile Generator " Module: $RCSfile: cmake-syntax.vim,v $ " Language: VIM -" Date: $Date: 2008-01-16 16:53:53 $ -" Version: $Revision: 1.9 $ +" Date: $Date: 2008-09-03 13:43:16 $ +" Version: $Revision: 1.9.2.1 $ " " ============================================================================= @@ -12,8 +12,8 @@ " Language: CMake " Author: Andy Cedilnik " Maintainer: Karthik Krishnan -" Last Change: $Date: 2008-01-16 16:53:53 $ -" Version: $Revision: 1.9 $ +" Last Change: $Date: 2008-09-03 13:43:16 $ +" Version: $Revision: 1.9.2.1 $ " " Licence: The CMake license applies to this file. See " http://www.cmake.org/HTML/Copyright.html @@ -41,7 +41,7 @@ syn region cmakeString start=/"/ end=/"/ syn region cmakeArguments start=/(/ end=/)/ \ contains=ALLBUT,cmakeArguments,cmakeTodo syn keyword cmakeSystemVariables - \ WIN32 UNIX APPLE CYGWIN BORLAND MINGW MSVC MSVC_IDE MSVC60 MSVC70 MSVC71 MSVC80 + \ WIN32 UNIX APPLE CYGWIN BORLAND MINGW MSVC MSVC_IDE MSVC60 MSVC70 MSVC71 MSVC80 MSVC90 syn keyword cmakeOperators \ ABSOLUTE AND BOOL CACHE COMMAND DEFINED DOC EQUAL EXISTS EXT FALSE GREATER INTERNAL LESS MATCHES NAME NAMES NAME_WE NOT OFF ON OR PATH PATHS PROGRAM STREQUAL STRGREATER STRING STRLESS TRUE \ contained @@ -50,7 +50,7 @@ syn keyword cmakeDeprecated ABSTRACT_FILES BUILD_NAME SOURCE_FILES SOURCE_FILES_ " The keywords are generated as: cmake --help-command-list | tr "\n" " " syn keyword cmakeStatement - \ ADD_CUSTOM_COMMAND ADD_CUSTOM_TARGET ADD_DEFINITIONS ADD_DEPENDENCIES ADD_EXECUTABLE ADD_LIBRARY ADD_SUBDIRECTORY ADD_TEST AUX_SOURCE_DIRECTORY BUILD_COMMAND BUILD_NAME CMAKE_MINIMUM_REQUIRED CONFIGURE_FILE CREATE_TEST_SOURCELIST ELSE ELSEIF ENABLE_LANGUAGE ENABLE_TESTING ENDFOREACH ENDFUNCTION ENDIF ENDMACRO ENDWHILE EXEC_PROGRAM EXECUTE_PROCESS EXPORT_LIBRARY_DEPENDENCIES FILE FIND_FILE FIND_LIBRARY FIND_PACKAGE FIND_PATH FIND_PROGRAM FLTK_WRAP_UI FOREACH FUNCTION GET_CMAKE_PROPERTY GET_DIRECTORY_PROPERTY GET_FILENAME_COMPONENT GET_SOURCE_FILE_PROPERTY GET_TARGET_PROPERTY GET_TEST_PROPERTY IF INCLUDE INCLUDE_DIRECTORIES INCLUDE_EXTERNAL_MSPROJECT INCLUDE_REGULAR_EXPRESSION INSTALL INSTALL_FILES INSTALL_PROGRAMS INSTALL_TARGETS LINK_DIRECTORIES LINK_LIBRARIES LIST LOAD_CACHE LOAD_COMMAND MACRO MAKE_DIRECTORY MARK_AS_ADVANCED MATH MESSAGE OPTION OUTPUT_REQUIRED_FILES PROJECT QT_WRAP_CPP QT_WRAP_UI REMOVE REMOVE_DEFINITIONS SEPARATE_ARGUMENTS SET SET_DIRECTORY_PROPERTIES SET_SOURCE_FILES_PROPERTIES SET_TARGET_PROPERTIES SET_TESTS_PROPERTIES SITE_NAME SOURCE_GROUP STRING SUBDIR_DEPENDS SUBDIRS TARGET_LINK_LIBRARIES TRY_COMPILE TRY_RUN USE_MANGLED_MESA UTILITY_SOURCE VARIABLE_REQUIRES VTK_MAKE_INSTANTIATOR VTK_WRAP_JAVA VTK_WRAP_PYTHON VTK_WRAP_TCL WHILE WRITE_FILE + \ ADD_CUSTOM_COMMAND ADD_CUSTOM_TARGET ADD_DEFINITIONS ADD_DEPENDENCIES ADD_EXECUTABLE ADD_LIBRARY ADD_SUBDIRECTORY ADD_TEST AUX_SOURCE_DIRECTORY BUILD_COMMAND BUILD_NAME CMAKE_MINIMUM_REQUIRED CONFIGURE_FILE CREATE_TEST_SOURCELIST ELSE ELSEIF ENABLE_LANGUAGE ENABLE_TESTING ENDFOREACH ENDFUNCTION ENDIF ENDMACRO ENDWHILE EXEC_PROGRAM EXECUTE_PROCESS EXPORT_LIBRARY_DEPENDENCIES FILE FIND_FILE FIND_LIBRARY FIND_PACKAGE FIND_PATH FIND_PROGRAM FLTK_WRAP_UI FOREACH FUNCTION GET_CMAKE_PROPERTY GET_DIRECTORY_PROPERTY GET_FILENAME_COMPONENT GET_SOURCE_FILE_PROPERTY GET_TARGET_PROPERTY GET_TEST_PROPERTY IF INCLUDE INCLUDE_DIRECTORIES INCLUDE_EXTERNAL_MSPROJECT INCLUDE_REGULAR_EXPRESSION INSTALL INSTALL_FILES INSTALL_PROGRAMS INSTALL_TARGETS LINK_DIRECTORIES LINK_LIBRARIES LIST LOAD_CACHE LOAD_COMMAND MACRO MAKE_DIRECTORY MARK_AS_ADVANCED MATH MESSAGE OPTION OUTPUT_REQUIRED_FILES PROJECT QT_WRAP_CPP QT_WRAP_UI REMOVE REMOVE_DEFINITIONS SEPARATE_ARGUMENTS SET SET_DIRECTORY_PROPERTIES SET_SOURCE_FILES_PROPERTIES SET_TARGET_PROPERTIES SET_TESTS_PROPERTIES SITE_NAME SOURCE_GROUP STRING SUBDIR_DEPENDS SUBDIRS TARGET_LINK_LIBRARIES TRY_COMPILE TRY_RUN UNSET USE_MANGLED_MESA UTILITY_SOURCE VARIABLE_REQUIRES VTK_MAKE_INSTANTIATOR VTK_WRAP_JAVA VTK_WRAP_PYTHON VTK_WRAP_TCL WHILE WRITE_FILE \ nextgroup=cmakeArguments syn keyword cmakeTodo \ TODO FIXME XXX diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake new file mode 100644 index 000000000..d11979a48 --- /dev/null +++ b/Modules/BundleUtilities.cmake @@ -0,0 +1,645 @@ +# BundleUtilities.cmake +# +# A collection of CMake utility functions useful for dealing with .app bundles +# on the Mac and bundle-like directories on any OS. +# +# The following functions are provided by this script: +# get_bundle_main_executable +# get_dotapp_dir +# get_bundle_and_executable +# get_bundle_all_executables +# get_item_key +# clear_bundle_keys +# set_bundle_key_values +# get_bundle_keys +# copy_resolved_item_into_bundle +# fixup_bundle_item +# fixup_bundle +# copy_and_fixup_bundle +# verify_bundle_prerequisites +# verify_bundle_symlinks +# verify_app +# +# Requires CMake 2.6 or greater because it uses function, break and +# PARENT_SCOPE. Also depends on GetPrerequisites.cmake. + + +# The functions defined in this file depend on the get_prerequisites function +# (and possibly others) found in: +# +get_filename_component(BundleUtilities_cmake_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) +include("${BundleUtilities_cmake_dir}/GetPrerequisites.cmake") + + +# get_bundle_main_executable +# +# The result will be the full path name of the bundle's main executable file +# or an "error:" prefixed string if it could not be determined. +# +function(get_bundle_main_executable bundle result_var) + set(result "error: '${bundle}/Contents/Info.plist' file does not exist") + + if(EXISTS "${bundle}/Contents/Info.plist") + set(result "error: no CFBundleExecutable in '${bundle}/Contents/Info.plist' file") + set(line_is_main_executable 0) + set(bundle_executable "") + + # Read Info.plist as a list of lines: + # + set(eol_char "E") + file(READ "${bundle}/Contents/Info.plist" info_plist) + string(REGEX REPLACE ";" "\\\\;" info_plist "${info_plist}") + string(REGEX REPLACE "\n" "${eol_char};" info_plist "${info_plist}") + + # Scan the lines for "CFBundleExecutable" - the line after that + # is the name of the main executable. + # + foreach(line ${info_plist}) + if(line_is_main_executable) + string(REGEX REPLACE "^.*(.*).*$" "\\1" bundle_executable "${line}") + break() + endif(line_is_main_executable) + + if(line MATCHES "^.*CFBundleExecutable.*$") + set(line_is_main_executable 1) + endif(line MATCHES "^.*CFBundleExecutable.*$") + endforeach(line) + + if(NOT "${bundle_executable}" STREQUAL "") + if(EXISTS "${bundle}/Contents/MacOS/${bundle_executable}") + set(result "${bundle}/Contents/MacOS/${bundle_executable}") + else(EXISTS "${bundle}/Contents/MacOS/${bundle_executable}") + + # Ultimate goal: + # If not in "Contents/MacOS" then scan the bundle for matching files. If + # there is only one executable file that matches, then use it, otherwise + # it's an error... + # + #file(GLOB_RECURSE file_list "${bundle}/${bundle_executable}") + + # But for now, pragmatically, it's an error. Expect the main executable + # for the bundle to be in Contents/MacOS, it's an error if it's not: + # + set(result "error: '${bundle}/Contents/MacOS/${bundle_executable}' does not exist") + endif(EXISTS "${bundle}/Contents/MacOS/${bundle_executable}") + endif(NOT "${bundle_executable}" STREQUAL "") + else(EXISTS "${bundle}/Contents/Info.plist") + # + # More inclusive technique... (This one would work on Windows and Linux + # too, if a developer followed the typical Mac bundle naming convention...) + # + # If there is no Info.plist file, try to find an executable with the same + # base name as the .app directory: + # + endif(EXISTS "${bundle}/Contents/Info.plist") + + set(${result_var} "${result}" PARENT_SCOPE) +endfunction(get_bundle_main_executable) + + +# 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" +# +# The returned directory may or may not exist. +# +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) + # + 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}) + + set(${dotapp_dir_var} "${dotapp_dir}" PARENT_SCOPE) +endfunction(get_dotapp_dir) + + +# get_bundle_and_executable +# +# Takes either a ".app" directory name or the name of an executable +# nested inside a ".app" directory and returns the path to the ".app" +# directory in ${bundle_var} and the path to its main executable in +# ${executable_var} +# +function(get_bundle_and_executable app bundle_var executable_var valid_var) + set(valid 0) + + if(EXISTS "${app}") + # Is it a directory ending in .app? + if(IS_DIRECTORY "${app}") + if(app MATCHES "\\.app$") + get_bundle_main_executable("${app}" executable) + if(EXISTS "${app}" AND EXISTS "${executable}") + set(${bundle_var} "${app}" PARENT_SCOPE) + set(${executable_var} "${executable}" PARENT_SCOPE) + set(valid 1) + #message(STATUS "info: handled .app directory case...") + else(EXISTS "${app}" AND EXISTS "${executable}") + message(STATUS "warning: *NOT* handled - .app directory case...") + endif(EXISTS "${app}" AND EXISTS "${executable}") + else(app MATCHES "\\.app$") + message(STATUS "warning: *NOT* handled - directory but not .app case...") + endif(app MATCHES "\\.app$") + else(IS_DIRECTORY "${app}") + # Is it an executable file? + is_file_executable("${app}" is_executable) + if(is_executable) + get_dotapp_dir("${app}" dotapp_dir) + if(EXISTS "${dotapp_dir}" AND EXISTS "${app}") + set(${bundle_var} "${dotapp_dir}" PARENT_SCOPE) + set(${executable_var} "${app}" PARENT_SCOPE) + set(valid 1) + #message(STATUS "info: handled executable file case...") + else(EXISTS "${dotapp_dir}" AND EXISTS "${app}") + message(STATUS "warning: *NOT* handled - executable file case...") + endif(EXISTS "${dotapp_dir}" AND EXISTS "${app}") + else(is_executable) + message(STATUS "warning: *NOT* handled - not .app dir, not executable file...") + endif(is_executable) + endif(IS_DIRECTORY "${app}") + else(EXISTS "${app}") + message(STATUS "warning: *NOT* handled - directory/file does not exist...") + endif(EXISTS "${app}") + + if(NOT valid) + set(${bundle_var} "error: not a bundle" PARENT_SCOPE) + set(${executable_var} "error: not a bundle" PARENT_SCOPE) + endif(NOT valid) + + set(${valid_var} ${valid} PARENT_SCOPE) +endfunction(get_bundle_and_executable) + + +# get_bundle_all_executables +# +# Scans the given bundle recursively for all executable files and accumulates +# them into a variable. +# +function(get_bundle_all_executables bundle exes_var) + set(exes "") + + file(GLOB_RECURSE file_list "${bundle}/*") + foreach(f ${file_list}) + is_file_executable("${f}" is_executable) + if(is_executable) + set(exes ${exes} "${f}") + endif(is_executable) + endforeach(f) + + set(${exes_var} "${exes}" PARENT_SCOPE) +endfunction(get_bundle_all_executables) + + +# get_item_key +# +# Given a file (item) name, generate a key that should be unique considering the set of +# libraries that need copying or fixing up to make a bundle standalone. This is +# essentially the file name including extension with "." replaced by "_" +# +# This key is used as a prefix for CMake variables so that we can associate a set +# of variables with a given item based on its key. +# +function(get_item_key item key_var) + get_filename_component(item_name "${item}" NAME) + string(REGEX REPLACE "\\." "_" ${key_var} "${item_name}") + set(${key_var} ${${key_var}} PARENT_SCOPE) +endfunction(get_item_key) + + +# clear_bundle_keys +# +# Loop over the list of keys, clearing all the variables associated with each +# key. After the loop, clear the list of keys itself. +# +# Caller of get_bundle_keys should call clear_bundle_keys when done with list +# of keys. +# +function(clear_bundle_keys keys_var) + foreach(key ${${keys_var}}) + set(${key}_ITEM PARENT_SCOPE) + set(${key}_RESOLVED_ITEM PARENT_SCOPE) + set(${key}_DEFAULT_EMBEDDED_PATH PARENT_SCOPE) + set(${key}_EMBEDDED_ITEM PARENT_SCOPE) + set(${key}_RESOLVED_EMBEDDED_ITEM PARENT_SCOPE) + set(${key}_COPYFLAG PARENT_SCOPE) + endforeach(key) + set(${keys_var} PARENT_SCOPE) +endfunction(clear_bundle_keys) + + +# set_bundle_key_values +# +# Add a key to the list (if necessary) for the given item. If added, +# also set all the variables associated with that key. +# +function(set_bundle_key_values keys_var context item exepath dirs copyflag) + get_filename_component(item_name "${item}" NAME) + + get_item_key("${item}" key) + + list(LENGTH ${keys_var} length_before) + gp_append_unique(${keys_var} "${key}") + list(LENGTH ${keys_var} length_after) + + if(NOT length_before EQUAL length_after) + gp_resolve_item("${context}" "${item}" "${exepath}" "${dirs}" resolved_item) + + gp_item_default_embedded_path("${item}" default_embedded_path) + + if(item MATCHES "[^/]+\\.framework/") + # For frameworks, construct the name under the embedded path from the + # opening "${item_name}.framework/" to the closing "/${item_name}": + # + string(REGEX REPLACE "^.*(${item_name}.framework/.*/${item_name}).*$" "${default_embedded_path}/\\1" embedded_item "${item}") + else(item MATCHES "[^/]+\\.framework/") + # For other items, just use the same name as the original, but in the + # embedded path: + # + set(embedded_item "${default_embedded_path}/${item_name}") + endif(item MATCHES "[^/]+\\.framework/") + + # Replace @executable_path and resolve ".." references: + # + string(REPLACE "@executable_path" "${exepath}" resolved_embedded_item "${embedded_item}") + get_filename_component(resolved_embedded_item "${resolved_embedded_item}" ABSOLUTE) + + # *But* -- if we are not copying, then force resolved_embedded_item to be + # the same as resolved_item. In the case of multiple executables in the + # original bundle, using the default_embedded_path results in looking for + # the resolved executable next to the main bundle executable. This is here + # so that exes in the other sibling directories (like "bin") get fixed up + # properly... + # + if(NOT copyflag) + set(resolved_embedded_item "${resolved_item}") + endif(NOT copyflag) + + set(${keys_var} ${${keys_var}} PARENT_SCOPE) + set(${key}_ITEM "${item}" PARENT_SCOPE) + set(${key}_RESOLVED_ITEM "${resolved_item}" PARENT_SCOPE) + set(${key}_DEFAULT_EMBEDDED_PATH "${default_embedded_path}" PARENT_SCOPE) + set(${key}_EMBEDDED_ITEM "${embedded_item}" PARENT_SCOPE) + set(${key}_RESOLVED_EMBEDDED_ITEM "${resolved_embedded_item}" PARENT_SCOPE) + set(${key}_COPYFLAG "${copyflag}" PARENT_SCOPE) + else(NOT length_before EQUAL length_after) + #message("warning: item key '${key}' already in the list, subsequent references assumed identical to first") + endif(NOT length_before EQUAL length_after) +endfunction(set_bundle_key_values) + + +# get_bundle_keys +# +# Loop over all the executable and library files within the bundle (and given as +# extra "${libs}") and accumulate a list of keys representing them. Set values +# associated with each key such that we can loop over all of them and copy +# prerequisite libs into the bundle and then do appropriate install_name_tool +# fixups. +# +function(get_bundle_keys app libs dirs keys_var) + set(${keys_var} PARENT_SCOPE) + + get_bundle_and_executable("${app}" bundle executable valid) + if(valid) + # Always use the exepath of the main bundle executable for @executable_path + # replacements: + # + get_filename_component(exepath "${executable}" PATH) + + # But do fixups on all executables in the bundle: + # + get_bundle_all_executables("${bundle}" exes) + + # For each extra lib, accumulate a key as well and then also accumulate + # any of its prerequisites. (Extra libs are typically dynamically loaded + # plugins: libraries that are prerequisites for full runtime functionality + # but that do not show up in otool -L output...) + # + foreach(lib ${libs}) + set_bundle_key_values(${keys_var} "${lib}" "${lib}" "${exepath}" "${dirs}" 1) + + set(prereqs "") + get_prerequisites("${lib}" prereqs 1 1 "${exepath}" "${dirs}") + foreach(pr ${prereqs}) + set_bundle_key_values(${keys_var} "${lib}" "${pr}" "${exepath}" "${dirs}" 1) + endforeach(pr) + endforeach(lib) + + # For each executable found in the bundle, accumulate keys as we go. + # The list of keys should be complete when all prerequisites of all + # binaries in the bundle have been analyzed. + # + foreach(exe ${exes}) + # Add the exe itself to the keys: + # + set_bundle_key_values(${keys_var} "${exe}" "${exe}" "${exepath}" "${dirs}" 0) + + # Add each prerequisite to the keys: + # + set(prereqs "") + get_prerequisites("${exe}" prereqs 1 1 "${exepath}" "${dirs}") + foreach(pr ${prereqs}) + set_bundle_key_values(${keys_var} "${exe}" "${pr}" "${exepath}" "${dirs}" 1) + endforeach(pr) + endforeach(exe) + + # Propagate values to caller's scope: + # + set(${keys_var} ${${keys_var}} PARENT_SCOPE) + foreach(key ${${keys_var}}) + set(${key}_ITEM "${${key}_ITEM}" PARENT_SCOPE) + set(${key}_RESOLVED_ITEM "${${key}_RESOLVED_ITEM}" PARENT_SCOPE) + set(${key}_DEFAULT_EMBEDDED_PATH "${${key}_DEFAULT_EMBEDDED_PATH}" PARENT_SCOPE) + set(${key}_EMBEDDED_ITEM "${${key}_EMBEDDED_ITEM}" PARENT_SCOPE) + set(${key}_RESOLVED_EMBEDDED_ITEM "${${key}_RESOLVED_EMBEDDED_ITEM}" PARENT_SCOPE) + set(${key}_COPYFLAG "${${key}_COPYFLAG}" PARENT_SCOPE) + endforeach(key) + endif(valid) +endfunction(get_bundle_keys) + + +# copy_resolved_item_into_bundle +# +# Copy a resolved item into the bundle if necessary. Copy is not necessary if the resolved_item +# is the same as the resolved_embedded_item. +# +function(copy_resolved_item_into_bundle resolved_item resolved_embedded_item) + if("${resolved_item}" STREQUAL "${resolved_embedded_item}") + message(STATUS "warning: resolved_item == resolved_embedded_item - not copying...") + else("${resolved_item}" STREQUAL "${resolved_embedded_item}") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_item}" "${resolved_embedded_item}") + endif("${resolved_item}" STREQUAL "${resolved_embedded_item}") +endfunction(copy_resolved_item_into_bundle) + + +# fixup_bundle_item +# +# Get the direct/non-system prerequisites of the resolved embedded item. For each +# prerequisite, change the way it is referenced to the value of the _EMBEDDED_ITEM +# keyed variable for that prerequisite. (Most likely changing to an "@executable_path" +# style reference.) +# +# Also, change the id of the item being fixed up to its own _EMBEDDED_ITEM value. +# +# Accumulate changes in a local variable and make *one* call to install_name_tool +# at the end of the function with all the changes at once. +# +function(fixup_bundle_item resolved_embedded_item exepath dirs) + # This item's key is "ikey": + # + get_item_key("${resolved_embedded_item}" ikey) + + set(prereqs "") + get_prerequisites("${resolved_embedded_item}" prereqs 1 0 "${exepath}" "${dirs}") + + set(changes "") + + foreach(pr ${prereqs}) + # Each referenced item's key is "rkey" in the loop: + # + get_item_key("${pr}" rkey) + + if(NOT "${${rkey}_EMBEDDED_ITEM}" STREQUAL "") + set(changes ${changes} "-change" "${pr}" "${${rkey}_EMBEDDED_ITEM}") + else(NOT "${${rkey}_EMBEDDED_ITEM}" STREQUAL "") + message("warning: unexpected reference to '${pr}'") + endif(NOT "${${rkey}_EMBEDDED_ITEM}" STREQUAL "") + endforeach(pr) + + # Change this item's id and all of its references in one call + # to install_name_tool: + # + execute_process(COMMAND install_name_tool + ${changes} -id "${${ikey}_EMBEDDED_ITEM}" "${resolved_embedded_item}" + ) +endfunction(fixup_bundle_item) + + +# fixup_bundle +# +# Fix up a bundle in-place and make it standalone, such that it can be drag-n-drop +# copied to another machine and run on that machine as long as all of the system +# libraries are compatible. +# +# Gather all the keys for all the executables and libraries in a bundle, and then, +# for each key, copy each prerequisite into the bundle. Then fix each one up according +# to its own list of prerequisites. +# +# Then clear all the keys and call verify_app on the final bundle to ensure that +# it is truly standalone. +# +function(fixup_bundle app libs dirs) + message(STATUS "fixup_bundle") + message(STATUS " app='${app}'") + message(STATUS " libs='${libs}'") + message(STATUS " dirs='${dirs}'") + + get_bundle_and_executable("${app}" bundle executable valid) + if(valid) + get_filename_component(exepath "${executable}" PATH) + + message(STATUS "fixup_bundle: preparing...") + get_bundle_keys("${app}" "${libs}" "${dirs}" keys) + + message(STATUS "fixup_bundle: copying...") + list(LENGTH keys n) + math(EXPR n ${n}*2) + + set(i 0) + foreach(key ${keys}) + math(EXPR i ${i}+1) + if(${${key}_COPYFLAG}) + message(STATUS "${i}/${n}: copying '${${key}_RESOLVED_ITEM}'") + else(${${key}_COPYFLAG}) + message(STATUS "${i}/${n}: *NOT* copying '${${key}_RESOLVED_ITEM}'") + endif(${${key}_COPYFLAG}) + + set(show_status 0) + if(show_status) + message(STATUS "key='${key}'") + message(STATUS "item='${${key}_ITEM}'") + message(STATUS "resolved_item='${${key}_RESOLVED_ITEM}'") + message(STATUS "default_embedded_path='${${key}_DEFAULT_EMBEDDED_PATH}'") + message(STATUS "embedded_item='${${key}_EMBEDDED_ITEM}'") + message(STATUS "resolved_embedded_item='${${key}_RESOLVED_EMBEDDED_ITEM}'") + message(STATUS "copyflag='${${key}_COPYFLAG}'") + message(STATUS "") + endif(show_status) + + if(${${key}_COPYFLAG}) + copy_resolved_item_into_bundle("${${key}_RESOLVED_ITEM}" + "${${key}_RESOLVED_EMBEDDED_ITEM}") + endif(${${key}_COPYFLAG}) + endforeach(key) + + message(STATUS "fixup_bundle: fixing...") + foreach(key ${keys}) + math(EXPR i ${i}+1) + message(STATUS "${i}/${n}: fixing up '${${key}_RESOLVED_EMBEDDED_ITEM}'") + #message(STATUS " exepath='${exepath}'") + fixup_bundle_item("${${key}_RESOLVED_EMBEDDED_ITEM}" "${exepath}" "${dirs}") + endforeach(key) + + message(STATUS "fixup_bundle: cleaning up...") + clear_bundle_keys(keys) + + message(STATUS "fixup_bundle: verifying...") + verify_app("${app}") + else(valid) + message(STATUS "error: fixup_bundle: not a valid bundle") + endif(valid) + + message(STATUS "fixup_bundle: done") +endfunction(fixup_bundle) + + +# copy_and_fixup_bundle +# +# Makes a copy of the bundle "src" at location "dst" and then fixes up the +# new copied bundle in-place at "dst"... +# +function(copy_and_fixup_bundle src dst libs dirs) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${src}" "${dst}") + fixup_bundle("${dst}" "${libs}" "${dirs}") +endfunction(copy_and_fixup_bundle) + + +# verify_bundle_prerequisites +# +# Verifies that the sum of all prerequisites of all files inside the bundle +# are contained within the bundle or are "system" libraries, presumed to exist +# everywhere. +# +function(verify_bundle_prerequisites bundle result_var info_var) + set(result 1) + set(info "") + set(count 0) + + get_bundle_main_executable("${bundle}" main_bundle_exe) + + file(GLOB_RECURSE file_list "${bundle}/*") + foreach(f ${file_list}) + is_file_executable("${f}" is_executable) + if(is_executable) + get_filename_component(exepath "${f}" PATH) + message(STATUS "executable file: ${f}") + + math(EXPR count "${count} + 1") + + set(prereqs "") + get_prerequisites("${f}" prereqs 1 1 "${exepath}" "") + + # "embedded" and "system" prerequisites are fine... anything else means + # the bundle's prerequisites are not verified (i.e., the bundle is not + # really "standalone") + # + set(external_prereqs "") + foreach(p ${prereqs}) + set(p_type "") + gp_file_type("${f}" "${p}" p_type) + if (NOT "${p_type}" STREQUAL "embedded" AND NOT "${p_type}" STREQUAL "system") + set(external_prereqs ${external_prereqs} "${p}") + endif (NOT "${p_type}" STREQUAL "embedded" AND NOT "${p_type}" STREQUAL "system") + endforeach(p) + + if(external_prereqs) + # Found non-system/non-embedded prerequisites: + set(result 0) + set(info ${info} "non-system/non-embedded prerequisites found:\nf='${f}'\nexternal_prereqs='${external_prereqs}'\n") + endif(external_prereqs) + endif(is_executable) + endforeach(f) + + if(result) + set(info "Verified ${count} executable files in '${bundle}'") + endif(result) + + set(${result_var} "${result}" PARENT_SCOPE) + set(${info_var} "${info}" PARENT_SCOPE) +endfunction(verify_bundle_prerequisites) + + +# verify_bundle_symlinks +# +# Verifies that any symlinks found in the bundle point to other files that are +# already also in the bundle... Anything that points to an external file causes +# this function to fail the verification. +# +function(verify_bundle_symlinks bundle result_var info_var) + set(result 1) + set(info "") + set(count 0) + + # TODO: implement this function for real... + # Right now, it is just a stub that verifies unconditionally... + + set(${result_var} "${result}" PARENT_SCOPE) + set(${info_var} "${info}" PARENT_SCOPE) +endfunction(verify_bundle_symlinks) + + +# verify_app +# +# Verifies that an application appears valid based on running analysis tools on it. +# Calls message/FATAL_ERROR if the application is not verified. +# +function(verify_app app) + set(verified 0) + set(info "") + + get_bundle_and_executable("${app}" bundle executable valid) + + message(STATUS "===========================================================================") + message(STATUS "Analyzing app='${app}'") + message(STATUS "bundle='${bundle}'") + message(STATUS "executable='${executable}'") + message(STATUS "valid='${valid}'") + + # Verify that the bundle does not have any "external" prerequisites: + # + verify_bundle_prerequisites("${bundle}" verified info) + message(STATUS "verified='${verified}'") + message(STATUS "info='${info}'") + message(STATUS "") + + if(verified) + # Verify that the bundle does not have any symlinks to external files: + # + verify_bundle_symlinks("${bundle}" verified info) + message(STATUS "verified='${verified}'") + message(STATUS "info='${info}'") + message(STATUS "") + endif(verified) + + if(NOT verified) + message(FATAL_ERROR "error: verify_app failed") + endif(NOT verified) +endfunction(verify_app) diff --git a/Modules/CMakeCCompilerABI.c b/Modules/CMakeCCompilerABI.c index f73e7fcc3..e6a07f4c4 100644 --- a/Modules/CMakeCCompilerABI.c +++ b/Modules/CMakeCCompilerABI.c @@ -12,17 +12,17 @@ /*--------------------------------------------------------------------------*/ -/* Make sure the information strings are referenced. */ -#define REQUIRE(x) (&x[0] != &require) - -int main() +#ifdef __CLASSIC_C__ +int main(argc, argv) int argc; char *argv[]; +#else +int main(int argc, char *argv[]) +#endif { - const char require = 0; - return - ( - REQUIRE(info_sizeof_dptr) + int require = 0; + require += info_sizeof_dptr[argc]; #if defined(ABI_ID) - && REQUIRE(info_abi) + require += info_abi[argc]; #endif - ); + (void)argv; + return require; } diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index ecbe431b7..35d7df77a 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -2,15 +2,9 @@ # error "A C++ compiler has been selected for C." #endif -/* Provide main() so the program can link. */ #if defined(__18CXX) # define ID_VOID_MAIN #endif -#ifdef ID_VOID_MAIN -void main() {} -#else -int main() { return 0; } -#endif #if defined(__INTEL_COMPILER) || defined(__ICC) # define COMPILER_ID "Intel" @@ -82,3 +76,18 @@ int main() { return 0; } char* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; @CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@ + +/*--------------------------------------------------------------------------*/ + +#ifdef ID_VOID_MAIN +void main() {} +#else +int main(int argc, char* argv[]) +{ + int require = 0; + require += info_compiler[argc]; + require += info_platform[argc]; + (void)argv; + return require; +} +#endif diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index e3a8d9343..a2ad460f9 100755 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -98,7 +98,6 @@ INCLUDE(CMakeCommonLanguageInclude) # CMAKE_C_CREATE_SHARED_LIBRARY # CMAKE_C_CREATE_SHARED_MODULE -# CMAKE_C_CREATE_STATIC_LIBRARY # CMAKE_C_COMPILE_OBJECT # CMAKE_C_LINK_EXECUTABLE @@ -133,12 +132,11 @@ IF(NOT CMAKE_C_CREATE_SHARED_MODULE) SET(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_C_CREATE_SHARED_LIBRARY}) ENDIF(NOT CMAKE_C_CREATE_SHARED_MODULE) -# create a C static library -IF(NOT CMAKE_C_CREATE_STATIC_LIBRARY) - SET(CMAKE_C_CREATE_STATIC_LIBRARY - " cr " - " ") -ENDIF(NOT CMAKE_C_CREATE_STATIC_LIBRARY) +# Create a static archive incrementally for large object file counts. +# If CMAKE_C_CREATE_STATIC_LIBRARY is set it will override these. +SET(CMAKE_C_ARCHIVE_CREATE " cr ") +SET(CMAKE_C_ARCHIVE_APPEND " r ") +SET(CMAKE_C_ARCHIVE_FINISH " ") # compile a C file into an object file IF(NOT CMAKE_C_COMPILE_OBJECT) diff --git a/Modules/CMakeCXXCompilerABI.cpp b/Modules/CMakeCXXCompilerABI.cpp index 7fb361887..c9b0440b8 100644 --- a/Modules/CMakeCXXCompilerABI.cpp +++ b/Modules/CMakeCXXCompilerABI.cpp @@ -8,17 +8,13 @@ /*--------------------------------------------------------------------------*/ -/* Make sure the information strings are referenced. */ -#define REQUIRE(x) (&x[0] != &require) - -int main() +int main(int argc, char* argv[]) { - const char require = 0; - return - ( - REQUIRE(info_sizeof_dptr) + int require = 0; + require += info_sizeof_dptr[argc]; #if defined(ABI_ID) - && REQUIRE(info_abi) + require += info_abi[argc]; #endif - ); + (void)argv; + return require; } diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 060c7e9c1..fa2178c0b 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -5,9 +5,6 @@ # error "A C compiler has been selected for C++." #endif -/* Provide main() so the program can link. */ -int main() { return 0; } - #if defined(__COMO__) # define COMPILER_ID "Comeau" @@ -70,3 +67,14 @@ int main() { return 0; } char* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; @CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@ + +/*--------------------------------------------------------------------------*/ + +int main(int argc, char* argv[]) +{ + int require = 0; + require += info_compiler[argc]; + require += info_platform[argc]; + (void)argv; + return require; +} diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 65c590248..c5608e0ad 100755 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -176,7 +176,6 @@ INCLUDE(CMakeCommonLanguageInclude) # now define the following rules: # CMAKE_CXX_CREATE_SHARED_LIBRARY # CMAKE_CXX_CREATE_SHARED_MODULE -# CMAKE_CXX_CREATE_STATIC_LIBRARY # CMAKE_CXX_COMPILE_OBJECT # CMAKE_CXX_LINK_EXECUTABLE @@ -212,12 +211,11 @@ IF(NOT CMAKE_CXX_CREATE_SHARED_MODULE) ENDIF(NOT CMAKE_CXX_CREATE_SHARED_MODULE) -# create a C++ static library -IF(NOT CMAKE_CXX_CREATE_STATIC_LIBRARY) - SET(CMAKE_CXX_CREATE_STATIC_LIBRARY - " cr " - " ") -ENDIF(NOT CMAKE_CXX_CREATE_STATIC_LIBRARY) +# Create a static archive incrementally for large object file counts. +# If CMAKE_CXX_CREATE_STATIC_LIBRARY is set it will override these. +SET(CMAKE_CXX_ARCHIVE_CREATE " cr ") +SET(CMAKE_CXX_ARCHIVE_APPEND " r ") +SET(CMAKE_CXX_ARCHIVE_FINISH " ") # compile a C++ file into an object file IF(NOT CMAKE_CXX_COMPILE_OBJECT) diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 44bd234d8..eac8c55cd 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -43,14 +43,17 @@ IF (NOT _CMAKE_TOOLCHAIN_LOCATION) GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" PATH) ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION) -# if we have a gcc cross compiler, they have usually some prefix, like -# e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc -# the other tools of the toolchain usually have the same prefix +# If we have a gcc cross compiler, they have usually some prefix, like +# e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc . +# The other tools of the toolchain usually have the same prefix +# NAME_WE cannot be used since then this test will fail for names lile +# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be +# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" IF (NOT _CMAKE_TOOLCHAIN_PREFIX) - GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" NAME_WE) - IF (COMPILER_BASENAME MATCHES "^(.+-)g?as") - STRING(REGEX REPLACE "^(.+-)g?as" "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}") - ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?as") + GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" NAME) + IF (COMPILER_BASENAME MATCHES "^(.+-)g?as(\\.exe)?$") + STRING(REGEX REPLACE "^(.+-)g?as(\\.exe)?$" "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}") + ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?as(\\.exe)?$") ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX) INCLUDE(CMakeFindBinUtils) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index ffe0703f0..82e944894 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -88,17 +88,6 @@ IF (NOT _CMAKE_TOOLCHAIN_LOCATION) GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH) ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION) -# if we have a gcc cross compiler, they have usually some prefix, like -# e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc -# the other tools of the toolchain usually have the same prefix -IF (NOT _CMAKE_TOOLCHAIN_PREFIX) - GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME_WE) - IF (COMPILER_BASENAME MATCHES "^(.+-)g?cc") - STRING(REGEX REPLACE "^(.+-)g?cc" "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}") - ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?cc") -ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX) - - # Build a small source file to identify the compiler. IF(${CMAKE_GENERATOR} MATCHES "Visual Studio") SET(CMAKE_C_COMPILER_ID_RUN 1) @@ -138,6 +127,33 @@ IF(NOT CMAKE_C_COMPILER_ID_RUN) ENDIF("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW") ENDIF(NOT CMAKE_C_COMPILER_ID_RUN) +# If we have a gcc cross compiler, they have usually some prefix, like +# e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc . +# The other tools of the toolchain usually have the same prefix +# NAME_WE cannot be used since then this test will fail for names lile +# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be +# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" +IF (CMAKE_CROSSCOMPILING + AND "${CMAKE_C_COMPILER_ID}" MATCHES "GNU" + AND NOT _CMAKE_TOOLCHAIN_PREFIX) + GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME) + IF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(\\.exe)?$") + SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(\\.exe)?$") + + # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils + # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.) + IF ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") + SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + ENDIF ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") + +ENDIF (CMAKE_CROSSCOMPILING + AND "${CMAKE_C_COMPILER_ID}" MATCHES "GNU" + AND NOT _CMAKE_TOOLCHAIN_PREFIX) + + + + INCLUDE(CMakeFindBinUtils) # configure variables set in this file for fast reload later on diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index b02403481..87abffa94 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -88,16 +88,6 @@ IF (NOT _CMAKE_TOOLCHAIN_LOCATION) GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH) ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION) -# if we have a g++ cross compiler, they have usually some prefix, like -# e.g. powerpc-linux-g++, arm-elf-g++ or i586-mingw32msvc-g++ -# the other tools of the toolchain usually have the same prefix -IF (NOT _CMAKE_TOOLCHAIN_PREFIX) - GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME_WE) - IF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+") - STRING(REGEX REPLACE "^(.+-)[gc]\\+\\+" "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}") - ENDIF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+") -ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX) - # This block was used before the compiler was identified by building a # source file. Unless g++ crashes when building a small C++ # executable this should no longer be needed. @@ -148,6 +138,30 @@ IF(NOT CMAKE_CXX_COMPILER_ID_RUN) ENDIF("${CMAKE_CXX_PLATFORM_ID}" MATCHES "MinGW") ENDIF(NOT CMAKE_CXX_COMPILER_ID_RUN) +# if we have a g++ cross compiler, they have usually some prefix, like +# e.g. powerpc-linux-g++, arm-elf-g++ or i586-mingw32msvc-g++ +# the other tools of the toolchain usually have the same prefix +# NAME_WE cannot be used since then this test will fail for names lile +# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be +# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" +IF (CMAKE_CROSSCOMPILING + AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" + AND NOT _CMAKE_TOOLCHAIN_PREFIX) + GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME) + IF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(\\.exe)?$") + SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + ENDIF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(\\.exe)?$") + + # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils + # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.) + IF ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") + SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + ENDIF ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") + +ENDIF (CMAKE_CROSSCOMPILING + AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" + AND NOT _CMAKE_TOOLCHAIN_PREFIX) + INCLUDE(CMakeFindBinUtils) # configure all variables set in this file diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 9d76e75e9..dc646730c 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -22,8 +22,7 @@ IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC" OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio") - FIND_PROGRAM(CMAKE_LINKER NAMES link PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH) - FIND_PROGRAM(CMAKE_LINKER NAMES link) + FIND_PROGRAM(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) MARK_AS_ADVANCED(CMAKE_LINKER) @@ -32,29 +31,18 @@ ELSE("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" OR "${CMAKE_C_COMPILER_ID}" MATCHES "MSVC" OR "${CMAKE_GENERATOR}" MATCHES "Visual Studio") - FIND_PROGRAM(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH) - FIND_PROGRAM(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar) + FIND_PROGRAM(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - FIND_PROGRAM(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH) - FIND_PROGRAM(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib) + FIND_PROGRAM(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) IF(NOT CMAKE_RANLIB) SET(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib") ENDIF(NOT CMAKE_RANLIB) - FIND_PROGRAM(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH) - FIND_PROGRAM(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip) - - FIND_PROGRAM(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH) - FIND_PROGRAM(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld) - - FIND_PROGRAM(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH) - FIND_PROGRAM(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm) - - FIND_PROGRAM(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH) - FIND_PROGRAM(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump) - - FIND_PROGRAM(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH) - FIND_PROGRAM(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy) + FIND_PROGRAM(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + FIND_PROGRAM(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + FIND_PROGRAM(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + FIND_PROGRAM(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + FIND_PROGRAM(CMAKE_OBJCOPY NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objcopy HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) MARK_AS_ADVANCED(CMAKE_AR CMAKE_RANLIB CMAKE_STRIP CMAKE_LINKER CMAKE_NM CMAKE_OBJDUMP CMAKE_OBJCOPY) @@ -65,8 +53,7 @@ ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" # on Apple there really should be install_name_tool IF(APPLE) - FIND_PROGRAM(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool PATHS ${_CMAKE_TOOLCHAIN_LOCATION} NO_DEFAULT_PATH) - FIND_PROGRAM(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool) + FIND_PROGRAM(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) IF(NOT CMAKE_INSTALL_NAME_TOOL) MESSAGE(FATAL_ERROR "Could not find install_name_tool, please check your installation.") diff --git a/Modules/CMakeFortranCompilerId.F90.in b/Modules/CMakeFortranCompilerId.F90.in index 870c204fc..0949b5051 100644 --- a/Modules/CMakeFortranCompilerId.F90.in +++ b/Modules/CMakeFortranCompilerId.F90.in @@ -8,6 +8,8 @@ PROGRAM CMakeFortranCompilerId PRINT *, 'INFO:compiler[GNU]' #elif defined(__IBM__) || defined(__IBMC__) PRINT *, 'INFO:compiler[VisualAge]' +#elif defined(__PGI) + PRINT *, 'INFO:compiler[PGI]' #elif defined(_COMPILER_VERSION) PRINT *, 'INFO:compiler[MIPSpro]' ! This compiler is either not known or is too old to define an diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index d760de39a..461573784 100755 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -119,7 +119,6 @@ INCLUDE(CMakeCommonLanguageInclude) # now define the following rule variables # CMAKE_Fortran_CREATE_SHARED_LIBRARY # CMAKE_Fortran_CREATE_SHARED_MODULE -# CMAKE_Fortran_CREATE_STATIC_LIBRARY # CMAKE_Fortran_COMPILE_OBJECT # CMAKE_Fortran_LINK_EXECUTABLE @@ -134,12 +133,11 @@ IF(NOT CMAKE_Fortran_CREATE_SHARED_MODULE) SET(CMAKE_Fortran_CREATE_SHARED_MODULE ${CMAKE_Fortran_CREATE_SHARED_LIBRARY}) ENDIF(NOT CMAKE_Fortran_CREATE_SHARED_MODULE) -# create a Fortran static library -IF(NOT CMAKE_Fortran_CREATE_STATIC_LIBRARY) - SET(CMAKE_Fortran_CREATE_STATIC_LIBRARY - " cr " - " ") -ENDIF(NOT CMAKE_Fortran_CREATE_STATIC_LIBRARY) +# Create a static archive incrementally for large object file counts. +# If CMAKE_Fortran_CREATE_STATIC_LIBRARY is set it will override these. +SET(CMAKE_Fortran_ARCHIVE_CREATE " cr ") +SET(CMAKE_Fortran_ARCHIVE_APPEND " r ") +SET(CMAKE_Fortran_ARCHIVE_FINISH " ") # compile a Fortran file into an object file IF(NOT CMAKE_Fortran_COMPILE_OBJECT) diff --git a/Modules/CMakeImportBuildSettings.cmake b/Modules/CMakeImportBuildSettings.cmake index cad78980b..529b2ed2a 100644 --- a/Modules/CMakeImportBuildSettings.cmake +++ b/Modules/CMakeImportBuildSettings.cmake @@ -95,7 +95,7 @@ MACRO(CMAKE_IMPORT_BUILD_SETTINGS SETTINGS_FILE) # Build tool must match on Windows. IF(WIN32) - IF(CMAKE_BUILD_TOOL_MISMATCH) + IF(CMAKE_BUILD_TOOL_MISMATCH AND NOT CMAKE_OVERRIDE_COMPILER_MISMATCH) MESSAGE(SEND_ERROR "This project, ${PROJECT_NAME}, depends on the project " "${CMAKE_BUILD_SETTING_PROJECT_NAME}. Unfortunately " @@ -115,7 +115,7 @@ MACRO(CMAKE_IMPORT_BUILD_SETTINGS SETTINGS_FILE) "${CMAKE_BUILD_SETTING_PROJECT_NAME} or rebuild " "${CMAKE_BUILD_SETTING_PROJECT_NAME} with the correct " "generator. ") - ENDIF(CMAKE_BUILD_TOOL_MISMATCH) + ENDIF(CMAKE_BUILD_TOOL_MISMATCH AND NOT CMAKE_OVERRIDE_COMPILER_MISMATCH) ENDIF(WIN32) # Enforce the C++ compiler setting. diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index cc8c565e6..c4e639574 100755 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -38,8 +38,7 @@ ENDIF(NOT CMAKE_Fortran_COMPILER_WORKS) IF(CMAKE_Fortran_COMPILER_WORKS) # Test for Fortran 90 support by using an f90-specific construct. - IF(DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) - ELSE(DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) + IF(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) MESSAGE(STATUS "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90") FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 " PROGRAM TESTFortran90 @@ -62,5 +61,5 @@ IF(CMAKE_Fortran_COMPILER_WORKS) "the following output:\n${OUTPUT}\n\n") SET(CMAKE_Fortran_COMPILER_SUPPORTS_F90 0 CACHE INTERNAL "") ENDIF(CMAKE_Fortran_COMPILER_SUPPORTS_F90) - ENDIF(DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) + ENDIF(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) ENDIF(CMAKE_Fortran_COMPILER_WORKS) diff --git a/Modules/CPack.Info.plist.in b/Modules/CPack.Info.plist.in index da4872b67..6e325001c 100644 --- a/Modules/CPack.Info.plist.in +++ b/Modules/CPack.Info.plist.in @@ -32,6 +32,6 @@ IFPkgFormatVersion 0.10000000149011612 CFBundleIdentifier -com.@CPACK_PACKAGE_VENDOR@.@CPACK_PACKAGE_NAME@.@CPACK_PACKAGE_VERSION@ +com.@CPACK_PACKAGE_VENDOR@.@CPACK_PACKAGE_NAME@@CPACK_MODULE_VERSION_SUFFIX@ diff --git a/Modules/CPack.RuntimeScript.in b/Modules/CPack.RuntimeScript.in index fc3444abf..72dd14ec4 100755 --- a/Modules/CPack.RuntimeScript.in +++ b/Modules/CPack.RuntimeScript.in @@ -6,7 +6,7 @@ CWD="`dirname \"$0\"`" TMP=/tmp/$UID/TemporaryItems version=`sw_vers -productVersion` -if [ "$?" == "0" ]; then +if [ "$?" = "0" ]; then major=${version%%\.*} rest=${version#*\.} minor=${rest%%\.*} @@ -36,7 +36,7 @@ cat << __END_OF_GETDISPLAY_SCRIPT__ > "$TMP/getdisplay.sh" #!/bin/sh mkdir -p "$TMP" -if [ "\$DISPLAY"x == "x" ]; then +if [ "\$DISPLAY"x = "x" ]; then echo :0 > "$TMP/display" else echo \$DISPLAY > "$TMP/display" @@ -48,7 +48,7 @@ open-x11 $TMP/getdisplay.sh || \ open -a XDarwin $TMP/getdisplay.sh || \ echo ":0" > $TMP/display -while [ "$?" == "0" -a ! -f $TMP/display ]; +while [ "$?" = "0" -a ! -f $TMP/display ]; do #echo "Waiting for display $TMP/display" sleep 1; diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 59e409fb1..75e0c2057 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -1,6 +1,390 @@ -# Default output files will be CPackConfig.cmake and CPackSourceConfig.cmake. -# This can be overwritten with CPACK_OUTPUT_CONFIG_FILE and -# CPACK_SOURCE_OUTPUT_CONFIG_FILE. +# - Build binary and source package installers +# +# The CPack module generates binary and source installers in a variety +# of formats using the cpack program. Inclusion of the CPack module +# adds two new targets to the resulting makefiles, package and +# package_source, which build the binary and source installers, +# respectively. The generated binary installers contain everything +# installed via CMake's INSTALL command (and the deprecated +# INSTALL_FILES, INSTALL_PROGRAMS, and INSTALL_TARGETS commands). +# +# 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. +# +# Before including the CPack module, there are a variety of variables +# that can be set to customize the resulting installers. The most +# commonly-used variables are: +# +# CPACK_PACKAGE_NAME - The name of the package (or application). If +# not specified, defaults to the project name. +# +# CPACK_PACKAGE_VENDOR - The name of the package vendor (e.g., +# "Kitware"). +# +# CPACK_PACKAGE_VERSION_MAJOR - Package major Version +# +# CPACK_PACKAGE_VERSION_MINOR - Package minor Version +# +# CPACK_PACKAGE_VERSION_PATCH - Package patch Version +# +# CPACK_PACKAGE_DESCRIPTION_FILE - A text file used to describe the +# project. Used, for example, the introduction screen of a +# CPack-generated Windows installer to describe the project. +# +# CPACK_PACKAGE_DESCRIPTION_SUMMARY - Short description of the +# project (only a few words). +# +# CPACK_PACKAGE_FILE_NAME - The name of the package file to generate, +# not including the extension. For example, cmake-2.6.1-Linux-i686. +# +# CPACK_PACKAGE_INSTALL_DIRECTORY - Installation directory on the +# target system, e.g., "CMake 2.5". +# +# CPACK_RESOURCE_FILE_LICENSE - License file for the project, which +# will typically be displayed to the user (often with an explicit +# "Accept" button, for graphical installers) prior to installation. +# +# CPACK_RESOURCE_FILE_README - ReadMe file for the project, which +# typically describes in some detail +# +# CPACK_RESOURCE_FILE_WELCOME - Welcome file for the project, which +# welcomes users to this installer. Typically used in the graphical +# installers on Windows and Mac OS X. +# +# CPACK_MONOLITHIC_INSTALL - Disables the component-based +# installation mechanism, so that all components are always installed. +# +# CPACK_GENERATOR - List of CPack generators to use. If not +# specified, CPack will create a set of options (e.g., +# CPACK_BINARY_NSIS) allowing the user to enable/disable individual +# generators. +# +# CPACK_OUTPUT_CONFIG_FILE - The name of the CPack configuration file +# for binary installers that will be generated by the CPack +# module. Defaults to CPackConfig.cmake. +# +# CPACK_PACKAGE_EXECUTABLES - Lists each of the executables along +# with a text label, to be used to create Start Menu shortcuts on +# Windows. For example, setting this to the list ccmake;CMake will +# create a shortcut named "CMake" that will execute the installed +# executable ccmake. +# +# CPACK_STRIP_FILES - List of files to be stripped. Starting with +# CMake 2.6.0 CPACK_STRIP_FILES will be a boolean variable which +# enables stripping of all files (a list of files evaluates to TRUE +# in CMake, so this change is compatible). +# +# The following CPack variables are specific to source packages, and +# will not affect binary packages: +# +# CPACK_SOURCE_PACKAGE_FILE_NAME - The name of the source package, +# e.g., cmake-2.6.1 +# +# CPACK_SOURCE_STRIP_FILES - List of files in the source tree that +# will be stripped. Starting with CMake 2.6.0 +# CPACK_SOURCE_STRIP_FILES will be a boolean variable which enables +# stripping of all files (a list of files evaluates to TRUE in CMake, +# so this change is compatible). +# +# CPACK_SOURCE_GENERATOR - List of generators used for the source +# packages. As with CPACK_GENERATOR, if this is not specified then +# CPack will create a set of options (e.g., CPACK_SOURCE_ZIP) +# allowing users to select which packages will be generated. +# +# CPACK_SOURCE_OUTPUT_CONFIG_FILE - The name of the CPack +# configuration file for source installers that will be generated by +# the CPack module. Defaults to CPackSourceConfig.cmake. +# +# CPACK_SOURCE_IGNORE_FILES - Pattern of files in the source tree +# that won't be packaged when building a source package. This is a +# list of patterns, e.g., /CVS/;/\\.svn/;\\.swp$;\\.#;/#;.*~;cscope.* +# +# 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_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 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. +# +# The following variable is specific to installers build on Mac OS X +# using PackageMaker: +# +# CPACK_OSX_PACKAGE_VERSION - The version of Mac OS X that the +# resulting PackageMaker archive should be compatible +# with. Different versions of Mac OS X support different +# features. For example, CPack can only build component-based +# installers for Mac OS X 10.4 or newer, and can only build +# installers that download component son-the-fly for Mac OS X 10.5 +# or newer. If left blank, this value will be set to the minimum +# version of Mac OS X that supports the requested features. Set this +# variable to some value (e.g., 10.4) only if you want to guarantee +# that your installer will work on that version of Mac OS X, and +# don't mind missing extra features available in the installer +# shipping with later versions of Mac OS X. +# +# The following variables are for advanced uses of CPack: +# +# CPACK_CMAKE_GENERATOR - What CMake generator should be used if the +# project is CMake project. Defaults to the value of CMAKE_GENERATOR; +# few users will want to change this setting. +# +# CPACK_INSTALL_CMAKE_PROJECTS - List of four values that specify +# what project to install. The four values are: Build directory, +# Project Name, Project Component, Directory. If omitted, CPack will +# build an installer that installers everything. +# +# CPACK_SYSTEM_NAME - System name, defaults to the value of +# ${CMAKE_SYSTEM_NAME}. +# +# CPACK_PACKAGE_VERSION - Package full version, used internally. By +# default, this is built from CPACK_PACKAGE_VERSION_MAJOR, +# CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH. +# +# CPACK_TOPLEVEL_TAG - Directory for the installed files. +# +# CPACK_INSTALL_COMMANDS - Extra commands to install components. +# +# 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. + # Pick a configuration file SET(cpack_input_file "${CMAKE_ROOT}/Templates/CPackConfig.cmake.in") @@ -12,6 +396,215 @@ 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) + # Macro for setting values if a user did not overwrite them MACRO(cpack_set_if_not_set name value) IF(NOT DEFINED "${name}") @@ -114,6 +707,7 @@ if(NOT CPACK_GENERATOR) option(CPACK_BINARY_CYGWIN "Enable to build Cygwin binary packages" ON) else(CYGWIN) if(APPLE) + option(CPACK_BINARY_BUNDLE "Enable to build OSX bundles" OFF) option(CPACK_BINARY_PACKAGEMAKER "Enable to build PackageMaker packages" ON) option(CPACK_BINARY_OSXX11 "Enable to build OSX X11 packages" OFF) else(APPLE) @@ -131,6 +725,7 @@ if(NOT CPACK_GENERATOR) option(CPACK_BINARY_ZIP "Enable to build ZIP packages" ON) endif(UNIX) + cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_BUNDLE Bundle) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_PACKAGEMAKER PackageMaker) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_OSXX11 OSXX11) cpack_optional_append(CPACK_GENERATOR CPACK_BINARY_CYGWIN CygwinBinary) @@ -171,7 +766,7 @@ endif(NOT CPACK_SOURCE_GENERATOR) mark_as_advanced(CPACK_BINARY_CYGWIN CPACK_BINARY_PACKAGEMAKER CPACK_BINARY_OSXX11 CPACK_BINARY_STGZ CPACK_BINARY_TGZ CPACK_BINARY_TBZ2 CPACK_BINARY_DEB CPACK_BINARY_RPM CPACK_BINARY_TZ - CPACK_BINARY_NSIS CPACK_BINARY_ZIP + CPACK_BINARY_NSIS CPACK_BINARY_ZIP CPACK_BINARY_BUNDLE CPACK_SOURCE_CYGWIN CPACK_SOURCE_TBZ2 CPACK_SOURCE_TGZ CPACK_SOURCE_TZ CPACK_SOURCE_ZIP) @@ -195,6 +790,39 @@ cpack_set_if_not_set(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") cpack_set_if_not_set(CPACK_NSIS_INSTALLER_ICON_CODE "") cpack_set_if_not_set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "") +IF(DEFINED CPACK_COMPONENTS_ALL) + IF(CPACK_MONOLITHIC_INSTALL) + MESSAGE("CPack warning: both CPACK_COMPONENTS_ALL and CPACK_MONOLITHIC_INSTALL have been set.\nDefaulting to a monolithic installation.") + SET(CPACK_COMPONENTS_ALL) + ELSE(CPACK_MONOLITHIC_INSTALL) + # The user has provided the set of components to be installed as + # part of a component-based installation; trust her. + SET(CPACK_COMPONENTS_ALL_SET_BY_USER TRUE) + ENDIF(CPACK_MONOLITHIC_INSTALL) +ELSE(DEFINED CPACK_COMPONENTS_ALL) + # If the user has not specifically requested a monolithic installer + # but has specified components in various "install" commands, tell + # CPack about those components. + IF(NOT CPACK_MONOLITHIC_INSTALL) + GET_CMAKE_PROPERTY(CPACK_COMPONENTS_ALL COMPONENTS) + LIST(LENGTH CPACK_COMPONENTS_ALL CPACK_COMPONENTS_LEN) + IF(CPACK_COMPONENTS_LEN EQUAL 1) + # Only one component: this is not a component-based installation + # (at least, it isn't a component-based installation, but may + # become one later if the user uses the cpack_add_* commands). + SET(CPACK_COMPONENTS_ALL) + ENDIF(CPACK_COMPONENTS_LEN EQUAL 1) + SET(CPACK_COMPONENTS_LEN) + ENDIF(NOT CPACK_MONOLITHIC_INSTALL) +ENDIF(DEFINED CPACK_COMPONENTS_ALL) + +# CMake always generates a component named "Unspecified", which is +# used to install everything that doesn't have an explicitly-provided +# component. Since these files should always be installed, we'll make +# them hidden and required. +set(CPACK_COMPONENT_UNSPECIFIED_HIDDEN TRUE) +set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED TRUE) + cpack_encode_variables() configure_file("${cpack_input_file}" "${CPACK_OUTPUT_CONFIG_FILE}" @ONLY IMMEDIATE) diff --git a/Modules/CPack.distribution.dist.in b/Modules/CPack.distribution.dist.in new file mode 100644 index 000000000..f20e66c17 --- /dev/null +++ b/Modules/CPack.distribution.dist.in @@ -0,0 +1,9 @@ + + + @CPACK_PACKAGE_NAME@ + + + + + @CPACK_PACKAGEMAKER_CHOICES@ + diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 3160a4a71..e441e69ea 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -68,11 +68,14 @@ IF(NOT CPACK_RPM_PACKAGE_VERSION) ENDIF(NOT CPACK_RPM_PACKAGE_VERSION) # CPACK_RPM_PACKAGE_ARCHITECTURE (optional) -IF(NOT CPACK_RPM_PACKAGE_ARCHITECTURE) - # FIXME This should be obtained through 'arch' command - # but is it --really necessary-- ? - SET(CPACK_RPM_PACKAGE_ARCHITECTURE i386) -ENDIF(NOT CPACK_RPM_PACKAGE_ARCHITECTURE) +IF(CPACK_RPM_PACKAGE_ARCHITECTURE) + SET(TMP_RPM_BUILDARCH "Buildarch: ${CPACK_RPM_PACKAGE_ARCHITECTURE}") + IF(CPACK_RPM_PACKAGE_DEBUG) + MESSAGE("CPackRPM:Debug: using user-specified build arch = ${CPACK_RPM_PACKAGE_ARCHITECTURE}") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) +ELSE(CPACK_RPM_PACKAGE_ARCHITECTURE) + SET(TMP_RPM_BUILDARCH "") +ENDIF(CPACK_RPM_PACKAGE_ARCHITECTURE) # CPACK_RPM_PACKAGE_RELEASE # The RPM release is the numbering of the RPM package ITSELF @@ -106,8 +109,7 @@ IF(NOT CPACK_RPM_PACKAGE_VENDOR) ENDIF(NOT CPACK_RPM_PACKAGE_VENDOR) # CPACK_RPM_PACKAGE_SOURCE -# The name of the source tarball in case we generate -# a source RPM +# The name of the source tarball in case we generate a source RPM # CPACK_RPM_PACKAGE_DESCRIPTION # The variable content may be either @@ -124,13 +126,29 @@ IF (NOT CPACK_RPM_PACKAGE_DESCRIPTION) ENDIF (CPACK_PACKAGE_DESCRIPTION_FILE) ENDIF (NOT CPACK_RPM_PACKAGE_DESCRIPTION) +# CPACK_RPM_SPEC_INSTALL_POST +# May be used to define a RPM post intallation script +# for example setting it to "/bin/true" may prevent +# rpmbuild from stripping binaries. +IF(CPACK_RPM_SPEC_INSTALL_POST) + SET(TMP_RPM_SPEC_INSTALL_POST "%define __spec_install_post ${CPACK_RPM_SPEC_INSTALL_POST}") +ENDIF(CPACK_RPM_SPEC_INSTALL_POST) + +# CPACK_RPM_SPEC_MORE_DEFINE +# This is a generated spec rpm file spaceholder +IF(CPACK_RPM_SPEC_MORE_DEFINE) + IF(CPACK_RPM_PACKAGE_DEBUG) + MESSAGE("CPackRPM:Debug: User defined more define spec line specified:\n ${CPACK_RPM_SPEC_MORE_DEFINE}") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) +ENDIF(CPACK_RPM_SPEC_MORE_DEFINE) + # CPACK_RPM_USER_BINARY_SPECFILE # FIXME when this is set then CPack should us the # user provided file. # Now we may create the RPM build tree structure SET(CPACK_RPM_ROOTDIR "${CPACK_TOPLEVEL_DIRECTORY}") -MESSAGE(STATUS "CPackRPM:: Using CPACK_RPM_ROOTDIR=${CPACK_RPM_ROOTDIR}") +MESSAGE(STATUS "CPackRPM:Debug: Using CPACK_RPM_ROOTDIR=${CPACK_RPM_ROOTDIR}") # Prepare RPM build tree FILE(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}) FILE(MAKE_DIRECTORY ${CPACK_RPM_ROOTDIR}/tmp) @@ -157,15 +175,16 @@ IF(CPACK_RPM_USER_BINARY_SPECFILE) ELSE(CPACK_RPM_USER_BINARY_SPECFILE) # No User specified spec file generate a valid one using var values IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}") - MESSAGE("CPackRPM:: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}") - MESSAGE("CPackRPM:: CPACK_TEMPORARY_DIRECTORY= ${PACK_TEMPORARY_DIRECTORY}") - MESSAGE("CPackRPM:: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}") - MESSAGE("CPackRPM:: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}") - MESSAGE("CPackRPM:: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}") - MESSAGE("CPackRPM:: CPACK_RPM_BINARY_SPECFILE = ${CPACK_RPM_BINARY_SPECFILE}") - MESSAGE("CPackRPM:: CPACK_PACKAGE_INSTALL_DIRECTORY = ${PACK_PACKAGE_INSTALL_DIRECTORY}") - MESSAGE("CPackRPM ::CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") + MESSAGE("CPackRPM:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}") + MESSAGE("CPackRPM:Debug: CPACK_TOPLEVEL_TAG = ${CPACK_TOPLEVEL_TAG}") + MESSAGE("CPackRPM:Debug: CPACK_TEMPORARY_DIRECTORY = ${PACK_TEMPORARY_DIRECTORY}") + MESSAGE("CPackRPM:Debug: CPACK_OUTPUT_FILE_NAME = ${CPACK_OUTPUT_FILE_NAME}") + MESSAGE("CPackRPM:Debug: CPACK_OUTPUT_FILE_PATH = ${CPACK_OUTPUT_FILE_PATH}") + MESSAGE("CPackRPM:Debug: CPACK_PACKAGE_FILE_NAME = ${CPACK_PACKAGE_FILE_NAME}") + MESSAGE("CPackRPM:Debug: CPACK_RPM_BINARY_SPECFILE = ${CPACK_RPM_BINARY_SPECFILE}") + MESSAGE("CPackRPM:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${PACK_PACKAGE_INSTALL_DIRECTORY}") + MESSAGE("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") + MESSAGE("CPackRPM:Debug: CPACK_RPM_SPEC_INSTALL_POST = ${CPACK_RPM_SPEC_INSTALL_POST}") ENDIF(CPACK_RPM_PACKAGE_DEBUG) FILE(WRITE ${CPACK_RPM_BINARY_SPECFILE} "# -*- rpm-spec -*- @@ -177,12 +196,15 @@ Release: ${CPACK_RPM_PACKAGE_RELEASE} License: ${CPACK_RPM_PACKAGE_LICENSE} Group: ${CPACK_RPM_PACKAGE_GROUP} Vendor: ${CPACK_RPM_PACKAGE_VENDOR} +${TMP_RPM_BUILDARCH} #%define prefix ${CMAKE_INSTALL_PREFIX} %define _rpmdir ${CPACK_RPM_DIRECTORY} %define _rpmfilename ${CPACK_RPM_FILE_NAME} %define _unpackaged_files_terminate_build 0 %define _topdir ${CPACK_RPM_DIRECTORY} +${TMP_RPM_SPEC_INSTALL_POST} +${CPACK_RPM_SPEC_MORE_DEFINE} %description ${CPACK_RPM_PACKAGE_DESCRIPTION} @@ -206,10 +228,11 @@ ${CPACK_RPM_PACKAGE_DESCRIPTION} /* %changelog +* Mon Aug 25 2008 Erk + Update generator to handle optional post-install * Tue Aug 16 2007 Erk Generated by CPack RPM Generator and associated macros ") - ENDIF(CPACK_RPM_USER_BINARY_SPECFILE) @@ -220,6 +243,11 @@ IF(RPMBUILD_EXECUTABLE) WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.err" OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.out") + IF(CPACK_RPM_PACKAGE_DEBUG) + MESSAGE("CPackRPM:Debug: You may consult rpmbuild logs in: ") + MESSAGE("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.err") + MESSAGE("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.out") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) ELSE(RPMBUILD_EXECUTABLE) IF(ALIEN_EXECUTABLE) MESSAGE(FATAL_ERROR "RPM packaging through alien not done (yet)") diff --git a/Modules/CheckCCompilerFlag.cmake b/Modules/CheckCCompilerFlag.cmake index b084399af..07fca64c3 100644 --- a/Modules/CheckCCompilerFlag.cmake +++ b/Modules/CheckCCompilerFlag.cmake @@ -3,6 +3,10 @@ # # FLAG - the compiler flag # VARIABLE - variable to store the result +# +# This actually calls the check_c_source_compiles macro. +# See help for CheckCSourceCompiles for a listing of variables +# that can modify the build. # Copyright (c) 2006, Alexander Neundorf, # diff --git a/Modules/CheckFortranFunctionExists.cmake b/Modules/CheckFortranFunctionExists.cmake index 4106a0693..49858812f 100644 --- a/Modules/CheckFortranFunctionExists.cmake +++ b/Modules/CheckFortranFunctionExists.cmake @@ -8,7 +8,6 @@ # modify the way the check is run: # # CMAKE_REQUIRED_LIBRARIES = list of libraries to link -# macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE) if(NOT DEFINED ${VARIABLE}) @@ -24,7 +23,8 @@ macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE) " program TESTFortran external ${FUNCTION} - end + call ${FUNCTION}() + end program TESTFortran " ) try_compile(${VARIABLE} @@ -33,6 +33,7 @@ macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE) CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}" OUTPUT_VARIABLE OUTPUT ) +# message(STATUS "${OUTPUT}") if(${VARIABLE}) set(${VARIABLE} 1 CACHE INTERNAL "Have Fortran function ${FUNCTION}") message(STATUS "Looking for Fortran ${FUNCTION} - found") diff --git a/Modules/CheckTypeSizeC.c.in b/Modules/CheckTypeSizeC.c.in index c25b69dcb..8bcf1a0cc 100644 --- a/Modules/CheckTypeSizeC.c.in +++ b/Modules/CheckTypeSizeC.c.in @@ -29,15 +29,16 @@ const char info_sizeof[] = {'I', 'N', 'F', 'O', ':', 's','i','z','e','o','f','[ ('0' + (SIZE % 10)), ']','\0'}; - #ifdef __CLASSIC_C__ -int main(){ - int ac; - char*av[]; +int main(argc, argv) int argc; char *argv[]; #else -int main(int ac, char*av[]){ +int main(int argc, char *argv[]) #endif - return (&info_sizeof[0] != &info_sizeof[0]); +{ + int require = 0; + require += info_sizeof[argc]; + (void)argv; + return require; } #else /* CHECK_TYPE_SIZE_TYPE */ diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index fca885a5f..b821a2325 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -1,6 +1,6 @@ # - Find BLAS library -# This module finds an installed fortran library that implements the BLAS -# linear-algebra interface (see http://www.netlib.org/blas/). +# This module finds an installed fortran library that implements the BLAS +# linear-algebra interface (see http://www.netlib.org/blas/). # The list of libraries searched for is taken # from the autoconf macro file, acx_blas.m4 (distributed at # http://ac-archive.sourceforge.net/ac-archive/acx_blas.html). @@ -10,22 +10,42 @@ # is found # BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l # and -L). -# BLAS_LIBRARIES - uncached list of libraries (using full path name) to +# BLAS_LIBRARIES - uncached list of libraries (using full path name) to # link against to use BLAS -# BLAS95_LIBRARIES - uncached list of libraries (using full path name) # to link against to use BLAS95 interface -# +# BLAS95_LIBRARIES - uncached list of libraries (using full path name) +# to link against to use BLAS95 interface +# BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface +# is found +# BLA_STATIC if set on this determines what kind of linkage we do (static) +# BLA_VENDOR if set checks only the specified vendor, if not set checks +# all the posibilities +# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK +########## +### 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 +# C/CXX should be enabled to use Intel mkl +get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES) +if(NOT _LANGUAGES_ MATCHES Fortran) + if(BLAS_FIND_REQUIRED) + message(FATAL_ERROR "FindBLAS is Fortran-only so Fortran must be enabled.") + else(BLAS_FIND_REQUIRED) + message(STATUS "Looking for BLAS... - NOT found (Fortran not enabled)") # + return() + endif(BLAS_FIND_REQUIRED) +endif(NOT _LANGUAGES_ MATCHES Fortran) include(CheckFortranFunctionExists) -macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list) +macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _threads) # This macro checks for the existence of the combination of fortran libraries -# given by _list. If the combination is found, this macro checks (using the +# given by _list. If the combination is found, this macro checks (using the # Check_Fortran_Function_Exists macro) whether can link against that library # combination using the name of a routine given by _name using the linker # flags given by _flags. If the combination of libraries is found and passes # the link test, LIBRARIES is set to the list of complete library paths that # have been found. Otherwise, LIBRARIES is set to FALSE. - + # N.B. _prefix is the prefix applied to the names of all cached variables that # are generated internally and marked advanced by this macro. @@ -36,24 +56,32 @@ foreach(_library ${_list}) set(_combined_name ${_combined_name}_${_library}) if(_libraries_work) - if ( WIN32 ) + if(BLA_STATIC) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") + endif(BLA_STATIC) find_library(${_prefix}_${_library}_LIBRARY NAMES ${_library} - PATHS ENV LIB + PATHS ENV LIB ) endif ( WIN32 ) - - if ( APPLE ) + + if ( APPLE ) + if(BLA_STATIC) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") + endif(BLA_STATIC) find_library(${_prefix}_${_library}_LIBRARY NAMES ${_library} - PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH + PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH ) - + else ( APPLE ) + if(BLA_STATIC) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so") + endif(BLA_STATIC) find_library(${_prefix}_${_library}_LIBRARY NAMES ${_library} - PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH + PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH ) endif( APPLE ) mark_as_advanced(${_prefix}_${_library}_LIBRARY) @@ -63,8 +91,8 @@ foreach(_library ${_list}) endforeach(_library ${_list}) if(_libraries_work) # Test this combination of libraries. - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}}) - #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_threads}) +# message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS) set(CMAKE_REQUIRED_LIBRARIES) mark_as_advanced(${_prefix}${_combined_name}_WORKS) @@ -79,10 +107,16 @@ endmacro(Check_Fortran_Libraries) set(BLAS_LINKER_FLAGS) set(BLAS_LIBRARIES) set(BLAS95_LIBRARIES) - - - -if(NOT BLAS_LIBRARIES) +if ($ENV{BLA_VENDOR} MATCHES ".+") + set(BLA_VENDOR $ENV{BLA_VENDOR}) +else ($ENV{BLA_VENDOR} MATCHES ".+") + if(NOT BLA_VENDOR) + set(BLA_VENDOR "All") + endif(NOT BLA_VENDOR) +endif ($ENV{BLA_VENDOR} MATCHES ".+") + +if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) check_fortran_libraries( BLAS_LIBRARIES @@ -90,197 +124,128 @@ if(NOT BLAS_LIBRARIES) cblas_dgemm "" "cblas;f77blas;atlas" + "" ) -endif(NOT BLAS_LIBRARIES) + endif(NOT BLAS_LIBRARIES) +endif (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All") # BLAS in PhiPACK libraries? (requires generic BLAS lib, too) -if(NOT BLAS_LIBRARIES) +if (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES BLAS sgemm "" "sgemm;dgemm;blas" + "" ) -endif(NOT BLAS_LIBRARIES) + endif(NOT BLAS_LIBRARIES) +endif (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All") # BLAS in Alpha CXML library? -if(NOT BLAS_LIBRARIES) +if (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES BLAS sgemm "" "cxml" + "" ) -endif(NOT BLAS_LIBRARIES) + endif(NOT BLAS_LIBRARIES) +endif (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All") # BLAS in Alpha DXML library? (now called CXML, see above) -if(NOT BLAS_LIBRARIES) +if (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES BLAS sgemm "" "dxml" + "" ) -endif(NOT BLAS_LIBRARIES) + endif(NOT BLAS_LIBRARIES) +endif (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All") # BLAS in Sun Performance library? -if(NOT BLAS_LIBRARIES) +if (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES BLAS sgemm "-xlic_lib=sunperf" "sunperf;sunmath" + "" ) if(BLAS_LIBRARIES) set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf") endif(BLAS_LIBRARIES) - -endif(NOT BLAS_LIBRARIES) + endif(NOT BLAS_LIBRARIES) +endif (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All") # BLAS in SCSL library? (SGI/Cray Scientific Library) -if(NOT BLAS_LIBRARIES) +if (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES BLAS sgemm "" "scsl" + "" ) -endif(NOT BLAS_LIBRARIES) + endif(NOT BLAS_LIBRARIES) +endif (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All") # BLAS in SGIMATH library? -if(NOT BLAS_LIBRARIES) +if (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES BLAS sgemm "" "complib.sgimath" + "" ) -endif(NOT BLAS_LIBRARIES) + endif(NOT BLAS_LIBRARIES) +endif (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All") # BLAS in IBM ESSL library? (requires generic BLAS lib, too) -if(NOT BLAS_LIBRARIES) +if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES BLAS sgemm "" "essl;blas" + "" ) -endif(NOT BLAS_LIBRARIES) - - - - -#BLAS in intel mkl 10 library? (em64t 64bit) -if(NOT BLAS_LIBRARIES) -check_fortran_libraries( -BLAS_LIBRARIES -BLAS -sgemm -"" -"mkl_intel_lp64;mkl_intel_thread;mkl_core;guide;pthread" -) -endif(NOT BLAS_LIBRARIES) -if(NOT BLAS95_LIBRARIES) -check_fortran_libraries( -BLAS95_LIBRARIES -BLAS -sgemm -"" -"mkl_blas95;mkl_intel_lp64;mkl_intel_thread;mkl_core;guide;pthread" -) -endif(NOT BLAS95_LIBRARIES) - -### windows version of intel mkl 10 - -if(NOT BLAS_LIBRARIES) -check_fortran_libraries( -BLAS_LIBRARIES -BLAS -SGEMM -"" -"mkl_c_dll;mkl_intel_thread_dll;mkl_core_dll;libguide40" -) -endif(NOT BLAS_LIBRARIES) - -if(NOT BLAS95_LIBRARIES) -check_fortran_libraries( -BLAS95_LIBRARIES -BLAS -sgemm -"" -"mkl_blas95;mkl_intel_c;mkl_intel_thread;mkl_core;libguide40" -) -endif(NOT BLAS95_LIBRARIES) - + endif(NOT BLAS_LIBRARIES) +endif (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") -# linux 32 bit -if(NOT BLAS95_LIBRARIES) -check_fortran_libraries( -BLAS95_LIBRARIES -BLAS -sgemm -"" -"mkl_blas95;mkl_intel;mkl_intel_thread;mkl_core;guide;pthread" -) -endif(NOT BLAS95_LIBRARIES) - - -#older vesions of intel mkl libs - -# BLAS in intel mkl library? (shared) -if(NOT BLAS_LIBRARIES) +#BLAS in acml library? +if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES BLAS sgemm "" - "mkl;guide;pthread" + "acml" + "" ) -endif(NOT BLAS_LIBRARIES) - - -#BLAS in intel mkl library? (static, 32bit) -if(NOT BLAS_LIBRARIES) -check_fortran_libraries( -BLAS_LIBRARIES -BLAS -sgemm -"" -"mkl_ia32;guide;pthread" -) -endif(NOT BLAS_LIBRARIES) - -#BLAS in intel mkl library? (static, em64t 64bit) -if(NOT BLAS_LIBRARIES) -check_fortran_libraries( -BLAS_LIBRARIES -BLAS -sgemm -"" -"mkl_em64t;guide;pthread" -) -endif(NOT BLAS_LIBRARIES) - - -#BLAS in acml library? -if(NOT BLAS_LIBRARIES) -check_fortran_libraries( -BLAS_LIBRARIES -BLAS -sgemm -"" -"acml" -) -endif(NOT BLAS_LIBRARIES) + endif(NOT BLAS_LIBRARIES) +endif (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") # Apple BLAS library? +if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES @@ -288,51 +253,201 @@ if(NOT BLAS_LIBRARIES) cblas_dgemm "" "Accelerate" + "" ) - - endif(NOT BLAS_LIBRARIES) - - if ( NOT BLAS_LIBRARIES ) + endif(NOT BLAS_LIBRARIES) +endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") + +if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") + if ( NOT BLAS_LIBRARIES ) check_fortran_libraries( BLAS_LIBRARIES BLAS cblas_dgemm "" "vecLib" + "" ) - endif ( NOT BLAS_LIBRARIES ) - - + endif ( NOT BLAS_LIBRARIES ) +endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") # Generic BLAS library? -if(NOT BLAS_LIBRARIES) +if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES BLAS sgemm "" "blas" + "" ) -endif(NOT BLAS_LIBRARIES) - - -if(BLAS_LIBRARIES) - set(BLAS_FOUND TRUE) -else(BLAS_LIBRARIES) - set(BLAS_FOUND FALSE) -endif(BLAS_LIBRARIES) + endif(NOT BLAS_LIBRARIES) +endif (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") -if(NOT BLAS_FIND_QUIETLY) - if(BLAS_FOUND) - message(STATUS "A library with BLAS API found.") - else(BLAS_FOUND) - if(BLAS_FIND_REQUIRED) - message(FATAL_ERROR - "A required library with BLAS API not found. Please specify library location." +#BLAS in intel mkl 10 library? (em64t 64bit) +if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") + if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) + if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) + find_package(Threads) + else(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) + find_package(Threads REQUIRED) + endif(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED) + if (WIN32) + if(BLA_F95) + if(NOT BLAS95_LIBRARIES) + check_fortran_libraries( + BLAS95_LIBRARIES + BLAS + sgemm + "" + "mkl_blas95;mkl_intel_c;mkl_intel_thread;mkl_core;libguide40" + "" + ) + endif(NOT BLAS95_LIBRARIES) + else(BLA_F95) + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + SGEMM + "" + "mkl_c_dll;mkl_intel_thread_dll;mkl_core_dll;libguide40" + "" + ) + endif(NOT BLAS_LIBRARIES) + endif(BLA_F95) + else(WIN32) + if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + if(BLA_F95) + if(NOT BLAS95_LIBRARIES) + check_fortran_libraries( + BLAS95_LIBRARIES + BLAS + sgemm + "" + "mkl_blas95;mkl_intel;mkl_intel_thread;mkl_core;guide" + "${CMAKE_THREAD_LIBS_INIT}" ) - else(BLAS_FIND_REQUIRED) - message(STATUS - "A library with BLAS API not found. Please specify library location." + endif(NOT BLAS95_LIBRARIES) + else(BLA_F95) + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "mkl_intel;mkl_intel_thread;mkl_core;guide" + "${CMAKE_THREAD_LIBS_INIT}" ) - endif(BLAS_FIND_REQUIRED) - endif(BLAS_FOUND) -endif(NOT BLAS_FIND_QUIETLY) + endif(NOT BLAS_LIBRARIES) + endif(BLA_F95) + endif (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All") + if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") + if(BLA_F95) + if(NOT BLAS95_LIBRARIES) + check_fortran_libraries( + BLAS95_LIBRARIES + BLAS + sgemm + "" + "mkl_blas95;mkl_intel_lp64;mkl_intel_thread;mkl_core;guide" + "${CMAKE_THREAD_LIBS_INIT}" + ) + endif(NOT BLAS95_LIBRARIES) + else(BLA_F95) + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "mkl_intel_lp64;mkl_intel_thread;mkl_core;guide" + "${CMAKE_THREAD_LIBS_INIT}" + ) + endif(NOT BLAS_LIBRARIES) + endif(BLA_F95) + endif (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All") + endif (WIN32) + #older vesions of intel mkl libs + # BLAS in intel mkl library? (shared) + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "mkl;guide" + "${CMAKE_THREAD_LIBS_INIT}" + ) + endif(NOT BLAS_LIBRARIES) + #BLAS in intel mkl library? (static, 32bit) + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "mkl_ia32;guide" + "${CMAKE_THREAD_LIBS_INIT}" + ) + endif(NOT BLAS_LIBRARIES) + #BLAS in intel mkl library? (static, em64t 64bit) + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "mkl_em64t;guide" + "${CMAKE_THREAD_LIBS_INIT}" + ) + endif(NOT BLAS_LIBRARIES) + endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) +endif (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") + + +if(BLA_F95) + if(BLAS95_LIBRARIES) + set(BLAS95_FOUND TRUE) + else(BLAS95_LIBRARIES) + set(BLAS95_FOUND FALSE) + endif(BLAS95_LIBRARIES) + + if(NOT BLAS_FIND_QUIETLY) + if(BLAS95_FOUND) + message(STATUS "A library with BLAS95 API found.") + else(BLAS95_FOUND) + if(BLAS_FIND_REQUIRED) + message(FATAL_ERROR + "A required library with BLAS95 API not found. Please specify library location.") + else(BLAS_FIND_REQUIRED) + message(STATUS + "A library with BLAS95 API not found. Please specify library location.") + endif(BLAS_FIND_REQUIRED) + endif(BLAS95_FOUND) + endif(NOT BLAS_FIND_QUIETLY) + set(BLAS_FOUND TRUE) + set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}") +else(BLA_F95) + if(BLAS_LIBRARIES) + set(BLAS_FOUND TRUE) + else(BLAS_LIBRARIES) + set(BLAS_FOUND FALSE) + endif(BLAS_LIBRARIES) + + if(NOT BLAS_FIND_QUIETLY) + if(BLAS_FOUND) + message(STATUS "A library with BLAS API found.") + else(BLAS_FOUND) + if(BLAS_FIND_REQUIRED) + message(FATAL_ERROR + "A required library with BLAS API not found. Please specify library location." + ) + else(BLAS_FIND_REQUIRED) + message(STATUS + "A library with BLAS API not found. Please specify library location." + ) + endif(BLAS_FIND_REQUIRED) + endif(BLAS_FOUND) + endif(NOT BLAS_FIND_QUIETLY) +endif(BLA_F95) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index ab00fcc72..c0f09b28a 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -12,8 +12,8 @@ # when new Boost versions are released. # # Currently this module searches for the following version numbers: -# 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1, 1.36.0, -# 1.36.1 +# 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1, 1.36, +# 1.36.0, 1.36.1 # # The components list needs to be the actual names of boost libraries, that is # the part of the actual library files that differ on different libraries. So @@ -36,12 +36,12 @@ # the boost include directory. The default list # of version numbers is: # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, -# 1.35, 1.35.0, 1.35.1, 1.36.0, 1.36.1 +# 1.35, 1.35.0, 1.35.1, 1.36, 1.36.0, 1.36.1 # If you want to look for an older or newer # version set this variable to a list of # strings, where each string contains a number, i.e. # SET(Boost_ADDITIONAL_VERSIONS "0.99.0" "1.35.0") -# BOOST_ROOT Preferred installation prefix for searching for Boost, +# BOOST_ROOT or BOOSTROOT Preferred installation prefix for searching for Boost, # set this if the module has problems finding the proper Boost installation # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the # module has problems finding the proper Boost installation @@ -91,20 +91,28 @@ # BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. # - -# this module required CMake 2.5 for the Boost_FIND_VERSION stuff - -# this must not be done in find modules, it changes the policy settings, which may have been -# set in the projects cmake files. -# beside that this module comes with cmake, so the cmake version is always correct, Alex -# CMAKE_MINIMUM_REQUIRED(VERSION "2.6" FATAL_ERROR) - -# MESSAGE(STATUS "Finding Boost libraries.... ") - -OPTION(Boost_USE_MULTITHREADED "Use the multithreaded versions of the boost libraries" ON) - -SET( _boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS} "1.36.1" "1.36.0" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" "1.34" "1.33.1" "1.33.0" "1.33" ) - +OPTION(Boost_USE_MULTITHREADED + "Use the multithreaded versions of the Boost libraries" ON) + +if (Boost_FIND_VERSION_EXACT) + if (Boost_FIND_VERSION_PATCH) + set( _boost_TEST_VERSIONS + "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.${Boost_FIND_VERSION_PATCH}") + else (Boost_FIND_VERSION_PATCH) + set( _boost_TEST_VERSIONS + "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}.0" + "${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") + endif (Boost_FIND_VERSION_PATCH) +else (Boost_FIND_VERSION_EXACT) + set( _boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS} + "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" + "1.34" "1.33.1" "1.33.0" "1.33" ) +endif (Boost_FIND_VERSION_EXACT) + +# The reason that we failed to find Boost. This will be set to a +# user-friendly message when we fail to find some necessary piece of +# Boost. +set(Boost_ERROR_REASON) ############################################ # @@ -119,8 +127,6 @@ SET( _boost_TEST_VERSIONS ${Boost_ADDITIONAL_VERSIONS} "1.36.1" "1.36.0" "1.35.1 MACRO (_Boost_ADJUST_LIB_VARS basename) IF (Boost_INCLUDE_DIR ) - #MESSAGE(STATUS "Adjusting ${basename} ") - IF (Boost_${basename}_LIBRARY_DEBUG AND Boost_${basename}_LIBRARY_RELEASE) # if the generator supports configuration types then set # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value @@ -152,7 +158,7 @@ MACRO (_Boost_ADJUST_LIB_VARS basename) SET(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library") GET_FILENAME_COMPONENT(Boost_LIBRARY_DIRS "${Boost_${basename}_LIBRARY}" PATH) SET(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIRS} CACHE FILEPATH "Boost library directory") - SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Was the boost boost ${basename} library found") + SET(Boost_${basename}_FOUND ON CACHE INTERNAL "Whether the Boost ${basename} library found") ENDIF (Boost_${basename}_LIBRARY) ENDIF (Boost_INCLUDE_DIR ) @@ -197,120 +203,120 @@ ELSE (_boost_IN_CACHE) # Need to search for boost IF(WIN32) - # In windows, automatic linking is performed, so you do not have to specify the libraries. - # If you are linking to a dynamic runtime, then you can choose to link to either a static or a - # dynamic Boost library, the default is to do a static link. You can alter this for a specific - # library "whatever" by defining BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to - # be linked dynamically. Alternatively you can force all Boost libraries to dynamic link by - # defining BOOST_ALL_DYN_LINK. + # In windows, automatic linking is performed, so you do not have + # to specify the libraries. If you are linking to a dynamic + # runtime, then you can choose to link to either a static or a + # dynamic Boost library, the default is to do a static link. You + # can alter this for a specific library "whatever" by defining + # BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to be + # linked dynamically. Alternatively you can force all Boost + # libraries to dynamic link by defining BOOST_ALL_DYN_LINK. - # This feature can be disabled for Boost library "whatever" by defining BOOST_WHATEVER_NO_LIB, - # or for all of Boost by defining BOOST_ALL_NO_LIB. + # This feature can be disabled for Boost library "whatever" by + # defining BOOST_WHATEVER_NO_LIB, or for all of Boost by defining + # BOOST_ALL_NO_LIB. - # If you want to observe which libraries are being linked against then defining - # BOOST_LIB_DIAGNOSTIC will cause the auto-linking code to emit a #pragma message each time - # a library is selected for linking. - SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define") + # If you want to observe which libraries are being linked against + # then defining BOOST_LIB_DIAGNOSTIC will cause the auto-linking + # code to emit a #pragma message each time a library is selected + # for linking. + SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS + "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define") ENDIF(WIN32) - SET(_boost_INCLUDE_SEARCH_DIRS C:/boost/include - "C:/Program Files/boost/boost_${Boost_FIND_VERSION_MAJOR}_${Boost_FIND_VERSION_MINOR}_${Boost_FIND_VERSION_PATCH}" - # D: is very often the cdrom drive, IF you don't have a - # cdrom inserted it will popup a very annoying dialog - #D:/boost/include + "C:/boost" + "$ENV{ProgramFiles}/boost/boost_${Boost_FIND_VERSION_MAJOR}_${Boost_FIND_VERSION_MINOR}_${Boost_FIND_VERSION_PATCH}" + "$ENV{ProgramFiles}/Boost" /sw/local/include ) SET(_boost_LIBRARIES_SEARCH_DIRS C:/boost/lib - "C:/Program Files/boost/boost_${Boost_FIND_VERSION_MAJOR}_${Boost_FIND_VERSION_MINOR}_${Boost_FIND_VERSION_PATCH}/lib" + "C:/boost" + "$ENV{ProgramFiles}/boost/boost_${Boost_FIND_VERSION_MAJOR}_${Boost_FIND_VERSION_MINOR}_${Boost_FIND_VERSION_PATCH}/lib" + "$ENV{ProgramFiles}/Boost" /sw/local/lib ) - IF( NOT $ENV{BOOST_ROOT} STREQUAL "" ) - SET(_boost_INCLUDE_SEARCH_DIRS $ENV{BOOST_ROOT}/include ${_boost_INCLUDE_SEARCH_DIRS}) - SET(_boost_LIBRARIES_SEARCH_DIRS $ENV{BOOST_ROOT}/lib ${_boost_INCLUDE_SEARCH_DIRS}) - ENDIF( NOT $ENV{BOOST_ROOT} STREQUAL "" ) + # If BOOST_ROOT was defined in the environment, use it. + if (NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") + set(BOOST_ROOT $ENV{BOOST_ROOT}) + endif(NOT BOOST_ROOT AND NOT $ENV{BOOST_ROOT} STREQUAL "") + # If BOOSTROOT was defined in the environment, use it. + if (NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "") + set(BOOST_ROOT $ENV{BOOSTROOT}) + endif(NOT BOOST_ROOT AND NOT $ENV{BOOSTROOT} STREQUAL "") + + # If BOOST_INCLUDEDIR was defined in the environment, use it. IF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" ) - SET(_boost_INCLUDE_SEARCH_DIRS $ENV{BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS}) + set(BOOST_INCLUDEDIR $ENV{BOOST_INCLUDEDIR}) ENDIF( NOT $ENV{BOOST_INCLUDEDIR} STREQUAL "" ) + # If BOOST_LIBRARYDIR was defined in the environment, use it. IF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" ) - SET(_boost_LIBRARIES_SEARCH_DIRS $ENV{BOOST_LIBRARYDIR} ${_boost_INCLUDE_SEARCH_DIRS}) + set(BOOST_LIBRARYDIR $ENV{BOOST_LIBRARYDIR}) ENDIF( NOT $ENV{BOOST_LIBRARYDIR} STREQUAL "" ) IF( BOOST_ROOT ) - IF( WIN32 ) - SET(_boost_INCLUDE_SEARCH_DIRS ${BOOST_ROOT} ${_boost_INCLUDE_SEARCH_DIRS}) - ELSE( WIN32 ) - SET(_boost_INCLUDE_SEARCH_DIRS ${BOOST_ROOT}/include ${_boost_INCLUDE_SEARCH_DIRS}) - ENDIF( WIN32 ) - SET(_boost_LIBRARIES_SEARCH_DIRS ${BOOST_ROOT}/lib ${_boost_LIBRARIES_SEARCH_DIRS}) + file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT) + SET(_boost_INCLUDE_SEARCH_DIRS + ${BOOST_ROOT}/include + ${BOOST_ROOT} + ${_boost_INCLUDE_SEARCH_DIRS}) + SET(_boost_LIBRARIES_SEARCH_DIRS + ${BOOST_ROOT}/lib + ${BOOST_ROOT}/stage/lib + ${_boost_LIBRARIES_SEARCH_DIRS}) ENDIF( BOOST_ROOT ) IF( BOOST_INCLUDEDIR ) - SET(_boost_INCLUDE_SEARCH_DIRS ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS}) + file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR) + SET(_boost_INCLUDE_SEARCH_DIRS + ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS}) ENDIF( BOOST_INCLUDEDIR ) IF( BOOST_LIBRARYDIR ) - SET(_boost_LIBRARIES_SEARCH_DIRS ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS}) + file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR) + SET(_boost_LIBRARIES_SEARCH_DIRS + ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS}) ENDIF( BOOST_LIBRARYDIR ) - #Try first in our own include search paths (e.g. BOOST_ROOT) - FOREACH(_boost_VER ${_boost_TEST_VERSIONS}) - IF( NOT Boost_INCLUDE_DIR ) - - # Add in a path suffix, based on the required version, ideally we could - # read this from version.hpp, but for that to work we'd need to know the include - # dir already - SET(_boost_PATH_SUFFIX - boost-${_boost_VER} - ) + # Try to find Boost by stepping backwards through the Boost versions + # we know about. + IF( NOT Boost_INCLUDE_DIR ) + # Build a list of path suffixes for each version. + SET(_boost_PATH_SUFFIXES) + FOREACH(_boost_VER ${_boost_TEST_VERSIONS}) + # Add in a path suffix, based on the required version, ideally + # we could read this from version.hpp, but for that to work we'd + # need to know the include dir already + if (WIN32 AND NOT CYGWIN) + set(_boost_PATH_SUFFIX boost_${_boost_VER}) + else (WIN32 AND NOT CYGWIN) + set(_boost_PATH_SUFFIX boost-${_boost_VER}) + endif (WIN32 AND NOT CYGWIN) IF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") - STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX}) + STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" + _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX}) ELSEIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+") - STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX}) + STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" + _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX}) ENDIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") - - - FIND_PATH(Boost_INCLUDE_DIR - NAMES boost/config.hpp - PATHS ${_boost_INCLUDE_SEARCH_DIRS} - PATH_SUFFIXES ${_boost_PATH_SUFFIX} - NO_DEFAULT_PATH - ) - - ENDIF( NOT Boost_INCLUDE_DIR ) - ENDFOREACH(_boost_VER) - - # If nothing is found search again using system default paths - FOREACH(_boost_VER ${_boost_TEST_VERSIONS}) - IF( NOT Boost_INCLUDE_DIR ) - - # Add in a path suffix, based on the required version, ideally we could - # read this from version.hpp, but for that to work we'd need to know the include - # dir already - SET(_boost_PATH_SUFFIX - boost-${_boost_VER} + LIST(APPEND _boost_PATH_SUFFIXES "${_boost_PATH_SUFFIX}") + ENDFOREACH(_boost_VER) + + # Look for a standard boost header file. + FIND_PATH(Boost_INCLUDE_DIR + NAMES boost/config.hpp + HINTS ${_boost_INCLUDE_SEARCH_DIRS} + PATH_SUFFIXES ${_boost_PATH_SUFFIXES} ) + ENDIF( NOT Boost_INCLUDE_DIR ) - IF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") - STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX}) - ELSEIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+") - STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2" _boost_PATH_SUFFIX ${_boost_PATH_SUFFIX}) - ENDIF(_boost_PATH_SUFFIX MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") - - FIND_PATH(Boost_INCLUDE_DIR - NAMES boost/config.hpp - PATH_SUFFIXES ${_boost_PATH_SUFFIX} - ) - - ENDIF( NOT Boost_INCLUDE_DIR ) - ENDFOREACH(_boost_VER) IF(Boost_INCLUDE_DIR) # Extract Boost_VERSION and Boost_LIB_VERSION from version.hpp # Read the whole file: @@ -329,56 +335,69 @@ ELSE (_boost_IN_CACHE) MATH(EXPR Boost_MAJOR_VERSION "${Boost_VERSION} / 100000") MATH(EXPR Boost_MINOR_VERSION "${Boost_VERSION} / 100 % 1000") MATH(EXPR Boost_SUBMINOR_VERSION "${Boost_VERSION} % 100") - + + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON}Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}\nBoost include path: ${Boost_INCLUDE_DIR}") ENDIF(NOT "${Boost_VERSION}" STREQUAL "0") + ELSE(Boost_INCLUDE_DIR) + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON}Unable to find the Boost header files. Please set BOOST_ROOT to the root directory containing Boost or BOOST_INCLUDEDIR to the directory containing Boost's headers.") ENDIF(Boost_INCLUDE_DIR) - - #Setting some more suffixes for the library + # Setting some more suffixes for the library SET (Boost_LIB_PREFIX "") IF ( WIN32 AND Boost_USE_STATIC_LIBS ) SET (Boost_LIB_PREFIX "lib") ENDIF ( WIN32 AND Boost_USE_STATIC_LIBS ) SET (_boost_COMPILER "-gcc") - IF (MSVC71) - SET (_boost_COMPILER "-vc71") - ENDIF(MSVC71) - IF (MSVC80) - SET (_boost_COMPILER "-vc80") - ENDIF(MSVC80) IF (MSVC90) SET (_boost_COMPILER "-vc90") - ENDIF (MSVC90) + ELSEIF (MSVC80) + SET (_boost_COMPILER "-vc80") + ELSEIF (MSVC71) + SET (_boost_COMPILER "-vc71") + ENDIF(MSVC90) IF (MINGW) EXEC_PROGRAM(${CMAKE_CXX_COMPILER} - ARGS --version + ARGS -dumpversion OUTPUT_VARIABLE _boost_COMPILER_VERSION ) - STRING(REGEX REPLACE ".* ([0-9])\\.([0-9])\\.[0-9] .*" "\\1\\2" + STRING(REGEX REPLACE "([0-9])\\.([0-9])\\.[0-9]" "\\1\\2" _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION}) SET (_boost_COMPILER "-mgw${_boost_COMPILER_VERSION}") ENDIF(MINGW) - IF (CYGWIN) - SET (_boost_COMPILER "-gcc") - ENDIF (CYGWIN) IF (UNIX) - IF (APPLE) - SET (_boost_COMPILER "") - ELSE (APPLE) - IF (NOT CMAKE_COMPILER_IS_GNUCC) - # This is for the intel compiler - SET (_boost_COMPILER "-il") - ELSE (NOT CMAKE_COMPILER_IS_GNUCC) - #find out the version of gcc being used. - EXEC_PROGRAM(${CMAKE_CXX_COMPILER} - ARGS --version - OUTPUT_VARIABLE _boost_COMPILER_VERSION + IF (NOT CMAKE_COMPILER_IS_GNUCC) + # We assume that we have the Intel compiler. + SET (_boost_COMPILER "-il") + ELSE (NOT CMAKE_COMPILER_IS_GNUCC) + # Determine which version of GCC we have. + EXEC_PROGRAM(${CMAKE_CXX_COMPILER} + ARGS -dumpversion + OUTPUT_VARIABLE _boost_COMPILER_VERSION ) - STRING(REGEX REPLACE ".* ([0-9])\\.([0-9])\\.[0-9] .*" "\\1\\2" - _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION}) + STRING(REGEX REPLACE "([0-9])\\.([0-9])\\.[0-9]" "\\1\\2" + _boost_COMPILER_VERSION ${_boost_COMPILER_VERSION}) + IF(APPLE) + IF(Boost_MINOR_VERSION) + IF(${Boost_MINOR_VERSION} GREATER 35) + # In Boost 1.36.0 and newer, the mangled compiler name used + # on Mac OS X/Darwin is "xgcc". + SET(_boost_COMPILER "-xgcc${_boost_COMPILER_VERSION}") + ELSE(${Boost_MINOR_VERSION} GREATER 35) + # In Boost <= 1.35.0, there is no mangled compiler name for + # the Mac OS X/Darwin version of GCC. + SET(_boost_COMPILER "") + ENDIF(${Boost_MINOR_VERSION} GREATER 35) + ELSE(Boost_MINOR_VERSION) + # We don't know the Boost version, so assume it's + # pre-1.36.0. + SET(_boost_COMPILER "") + ENDIF(Boost_MINOR_VERSION) + ELSE() SET (_boost_COMPILER "-gcc${_boost_COMPILER_VERSION}") - ENDIF (NOT CMAKE_COMPILER_IS_GNUCC) - ENDIF (APPLE) + ENDIF() + ENDIF (NOT CMAKE_COMPILER_IS_GNUCC) ENDIF(UNIX) SET (_boost_MULTITHREADED "-mt") @@ -423,39 +442,18 @@ ELSE (_boost_IN_CACHE) ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED} ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG} ${Boost_LIB_PREFIX}boost_${COMPONENT} - PATHS ${_boost_LIBRARIES_SEARCH_DIRS} - NO_DEFAULT_PATH + HINTS ${_boost_LIBRARIES_SEARCH_DIRS} ) - IF( NOT ${Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE} ) - FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE - NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT} - ) - ENDIF( NOT ${Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE} ) - FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION} ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG} ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG} ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG} - PATHS ${_boost_LIBRARIES_SEARCH_DIRS} - NO_DEFAULT_PATH + HINTS ${_boost_LIBRARIES_SEARCH_DIRS} ) - IF( NOT ${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG} ) - FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG - NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG} - ) - ENDIF( NOT ${Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG} ) _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT}) IF( Boost_USE_STATIC_LIBS ) SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) @@ -469,33 +467,103 @@ ELSE (_boost_IN_CACHE) ${Boost_INCLUDE_DIR} ) - # MESSAGE(STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}") - # MESSAGE(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}") - SET(Boost_FOUND FALSE) IF(Boost_INCLUDE_DIR) SET( Boost_FOUND TRUE ) - IF( Boost_FIND_VERSION_MAJOR AND Boost_VERSION_MAJOR LESS "${Boost_FIND_VERSION_MAJOR}" ) - SET( Boost_FOUND FALSE ) - ELSE( Boost_FIND_VERSION_MAJOR AND Boost_VERSION_MAJOR LESS "${Boost_FIND_VERSION_MAJOR}" ) - IF( Boost_FIND_VERSION_MINOR AND Boost_VERSION_MINOR LESS "${Boost_FIND_VERSION_MINOR}" ) - SET( Boost_FOUND FALSE ) - ELSE( Boost_FIND_VERSION_MINOR AND Boost_VERSION_MINOR LESS "${Boost_FIND_VERSION_MINOR}" ) - IF( Boost_FIND_VERSION_PATCH AND Boost_VERSION_SUBMINOR LESS "${Boost_FIND_VERSION_PATCH}" ) - SET( Boost_FOUND FALSE ) - ENDIF( Boost_FIND_VERSION_PATCH AND Boost_VERSION_SUBMINOR LESS "${Boost_FIND_VERSION_PATCH}" ) - ENDIF( Boost_FIND_VERSION_MINOR AND Boost_VERSION_MINOR LESS "${Boost_FIND_VERSION_MINOR}" ) - ENDIF( Boost_FIND_VERSION_MAJOR AND Boost_VERSION_MAJOR LESS "${Boost_FIND_VERSION_MAJOR}" ) - set(_boost_CHECKED_COMPONENT FALSE) - FOREACH(COMPONENT ${Boost_FIND_COMPONENTS}) - STRING(TOUPPER ${COMPONENT} COMPONENT) - set(_boost_CHECKED_COMPONENT TRUE) - IF(NOT Boost_${COMPONENT}_FOUND) - SET( Boost_FOUND FALSE) - ENDIF(NOT Boost_${COMPONENT}_FOUND) - ENDFOREACH(COMPONENT) + + # Check the version of Boost against the requested version. + if (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR) + message(SEND_ERROR "When requesting a specific version of Boost, you must provide at least the major and minor version numbers, e.g., 1.34") + endif (Boost_FIND_VERSION AND NOT Boost_FIND_VERSION_MINOR) + if(Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" ) + set( Boost_FOUND FALSE ) + set(_Boost_VERSION_AGE "old") + elseif(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" ) + if(Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" ) + set( Boost_FOUND FALSE ) + set(_Boost_VERSION_AGE "old") + elseif(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" ) + if( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" ) + set( Boost_FOUND FALSE ) + set(_Boost_VERSION_AGE "old") + endif( Boost_FIND_VERSION_PATCH AND Boost_SUBMINOR_VERSION LESS "${Boost_FIND_VERSION_PATCH}" ) + endif( Boost_MINOR_VERSION LESS "${Boost_FIND_VERSION_MINOR}" ) + endif( Boost_MAJOR_VERSION LESS "${Boost_FIND_VERSION_MAJOR}" ) + + if (Boost_FOUND AND Boost_FIND_VERSION_EXACT) + # If the user requested an exact version of Boost, check + # that. We already know that the Boost version we have is >= the + # requested version. + set(_Boost_VERSION_AGE "new") + + # If the user didn't specify a patchlevel, it's 0. + if (NOT Boost_FIND_VERSION_PATCH) + set(Boost_FIND_VERSION_PATCH 0) + endif (NOT Boost_FIND_VERSION_PATCH) + + # We'll set Boost_FOUND true again if we have an exact version match. + set(Boost_FOUND FALSE) + if(Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" ) + if(Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" ) + if(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" ) + set( Boost_FOUND TRUE ) + endif(Boost_SUBMINOR_VERSION EQUAL "${Boost_FIND_VERSION_PATCH}" ) + endif( Boost_MINOR_VERSION EQUAL "${Boost_FIND_VERSION_MINOR}" ) + endif( Boost_MAJOR_VERSION EQUAL "${Boost_FIND_VERSION_MAJOR}" ) + endif (Boost_FOUND AND Boost_FIND_VERSION_EXACT) + + if(NOT Boost_FOUND) + # State that we found a version of Boost that is too new or too old. + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON}\nDetected version of Boost is too ${_Boost_VERSION_AGE}. Requested version was ${Boost_FIND_VERSION_MAJOR}.${Boost_FIND_VERSION_MINOR}") + if (Boost_FIND_VERSION_PATCH) + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON}.${Boost_FIND_VERSION_PATCH}") + endif (Boost_FIND_VERSION_PATCH) + if (NOT Boost_FIND_VERSION_EXACT) + set(Boost_ERROR_REASON "${Boost_ERROR_REASON} (or newer)") + endif (NOT Boost_FIND_VERSION_EXACT) + set(Boost_ERROR_REASON "${Boost_ERROR_REASON}.") + endif (NOT Boost_FOUND) + + if (Boost_FOUND) + set(_boost_CHECKED_COMPONENT FALSE) + set(_Boost_MISSING_COMPONENTS) + foreach(COMPONENT ${Boost_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} COMPONENT) + set(_boost_CHECKED_COMPONENT TRUE) + if(NOT Boost_${COMPONENT}_FOUND) + string(TOLOWER ${COMPONENT} COMPONENT) + list(APPEND _Boost_MISSING_COMPONENTS ${COMPONENT}) + set( Boost_FOUND FALSE) + endif(NOT Boost_${COMPONENT}_FOUND) + endforeach(COMPONENT) + endif (Boost_FOUND) + + if (_Boost_MISSING_COMPONENTS) + # We were unable to find some libraries, so generate a sensible + # error message that lists the libraries we were unable to find. + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON}\nThe following Boost libraries could not be found:\n") + foreach(COMPONENT ${_Boost_MISSING_COMPONENTS}) + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON} boost_${COMPONENT}\n") + endforeach(COMPONENT) + + list(LENGTH Boost_FIND_COMPONENTS Boost_NUM_COMPONENTS_WANTED) + list(LENGTH _Boost_MISSING_COMPONENTS Boost_NUM_MISSING_COMPONENTS) + if (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON}No Boost libraries were found. You may need to set Boost_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") + else (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) + set(Boost_ERROR_REASON + "${Boost_ERROR_REASON}Some (but not all) of the required Boost libraries were found. You may need to install these additional Boost libraries. Alternatively, set Boost_LIBRARYDIR to the directory containing Boost libraries or BOOST_ROOT to the location of Boost.") + endif (${Boost_NUM_COMPONENTS_WANTED} EQUAL ${Boost_NUM_MISSING_COMPONENTS}) + endif (_Boost_MISSING_COMPONENTS) + IF( NOT Boost_LIBRARY_DIRS AND NOT _boost_CHECKED_COMPONENT ) - # Compatibility Code for backwards compatibility with CMake 2.4 + # Compatibility Code for backwards compatibility with CMake + # 2.4's FindBoost module. # Look for the boost library path. # Note that the user may not have installed any libraries @@ -549,8 +617,7 @@ ELSE (_boost_IN_CACHE) ENDFOREACH(COMPONENT) ELSE (Boost_FOUND) IF (Boost_FIND_REQUIRED) - MESSAGE(STATUS "Boost version required: ${Boost_FIND_VERSION}. Found: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") - MESSAGE(FATAL_ERROR "Couldn't find the Boost libraries and/or include directory, or the version found is too old. Please install the Boost libraries AND development packages. You can set BOOST_ROOT, BOOST_INCLUDEDIR and BOOST_LIBRARYDIR to help find Boost.") + message(SEND_ERROR "Unable to find the requested Boost libraries.\n${Boost_ERROR_REASON}") ENDIF(Boost_FIND_REQUIRED) ENDIF(Boost_FOUND) diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake index 3eb54e5f5..2a1df7465 100644 --- a/Modules/FindCurses.cmake +++ b/Modules/FindCurses.cmake @@ -12,15 +12,15 @@ # Set CURSES_NEED_NCURSES to TRUE before the FIND_PACKAGE() command if NCurses # functionality is required. -FIND_LIBRARY(CURSES_LIBRARY NAMES curses ) +FIND_LIBRARY(CURSES_CURSES_LIBRARY NAMES curses ) FIND_LIBRARY(CURSES_NCURSES_LIBRARY NAMES ncurses ) SET(CURSES_USE_NCURSES FALSE) -IF(CURSES_NCURSES_LIBRARY AND NOT CURSES_LIBRARY) +IF(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_LIBRARY) SET(CURSES_USE_NCURSES TRUE) -ENDIF(CURSES_NCURSES_LIBRARY AND NOT CURSES_LIBRARY) +ENDIF(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_LIBRARY) # Not sure the logic is correct here. @@ -34,26 +34,34 @@ ENDIF(CURSES_NCURSES_LIBRARY AND NOT CURSES_LIBRARY) # So at first try ncurses.h, if not found, try to find curses.h under the same # prefix as the library was found, if still not found, try curses.h with the # default search paths. -IF(CURSES_LIBRARY AND CURSES_NEED_NCURSES) +IF(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES) INCLUDE(CheckLibraryExists) - CHECK_LIBRARY_EXISTS("${CURSES_LIBRARY}" wsyncup "" CURSES_CURSES_HAS_WSYNCUP) + CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}" + wsyncup "" CURSES_CURSES_HAS_WSYNCUP) IF(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_HAS_WSYNCUP) - CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}" wsyncup "" CURSES_NCURSES_HAS_WSYNCUP) + CHECK_LIBRARY_EXISTS("${CURSES_NCURSES_LIBRARY}" + wsyncup "" CURSES_NCURSES_HAS_WSYNCUP) IF( CURSES_NCURSES_HAS_WSYNCUP) SET(CURSES_USE_NCURSES TRUE) ENDIF( CURSES_NCURSES_HAS_WSYNCUP) ENDIF(CURSES_NCURSES_LIBRARY AND NOT CURSES_CURSES_HAS_WSYNCUP) -ENDIF(CURSES_LIBRARY AND CURSES_NEED_NCURSES) +ENDIF(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES) IF(NOT CURSES_USE_NCURSES) FIND_FILE(CURSES_HAVE_CURSES_H curses.h ) - FIND_PATH(CURSES_INCLUDE_PATH curses.h ) - - GET_FILENAME_COMPONENT(_cursesLibDir "${CURSES_LIBRARY}" PATH) + FIND_PATH(CURSES_CURSES_H_PATH curses.h ) + GET_FILENAME_COMPONENT(_cursesLibDir "${CURSES_CURSES_LIBRARY}" PATH) GET_FILENAME_COMPONENT(_cursesParentDir "${_cursesLibDir}" PATH) + + # for compatibility with older FindCurses.cmake this has to be in the cache + # FORCE must not be used since this would break builds which preload a cache wqith these variables set + SET(CURSES_INCLUDE_PATH "${CURSES_CURSES_H_PATH}" + CACHE FILEPATH "The curses include path") + SET(CURSES_LIBRARY "${CURSES_CURSES_LIBRARY}" + CACHE FILEPATH "The curses library") ELSE(NOT CURSES_USE_NCURSES) # we need to find ncurses GET_FILENAME_COMPONENT(_cursesLibDir "${CURSES_NCURSES_LIBRARY}" PATH) @@ -62,28 +70,43 @@ ELSE(NOT CURSES_USE_NCURSES) FIND_FILE(CURSES_HAVE_NCURSES_H ncurses.h) FIND_FILE(CURSES_HAVE_NCURSES_NCURSES_H ncurses/ncurses.h) FIND_FILE(CURSES_HAVE_NCURSES_CURSES_H ncurses/curses.h) - FIND_FILE(CURSES_HAVE_CURSES_H curses.h PATHS "${_cursesParentDir}/include" NO_DEFAULT_PATH) - FIND_FILE(CURSES_HAVE_CURSES_H curses.h) - - FIND_PATH(CURSES_NCURSES_INCLUDE_PATH ncurses.h ncurses/ncurses.h ncurses/curses.h) - FIND_PATH(CURSES_NCURSES_INCLUDE_PATH curses.h PATHS "${_cursesParentDir}/include" NO_DEFAULT_PATH) - FIND_PATH(CURSES_NCURSES_INCLUDE_PATH curses.h) - - SET(CURSES_INCLUDE_PATH "${CURSES_NCURSES_INCLUDE_PATH}") - SET(FORCE_ARG "") - IF("${CURSES_LIBRARY}" STREQUAL "CURSES_LIBRARY-NOTFOUND") - SET(FORCE_ARG "FORCE") - ENDIF("${CURSES_LIBRARY}" STREQUAL "CURSES_LIBRARY-NOTFOUND") - SET(CURSES_LIBRARY "${CURSES_NCURSES_LIBRARY}" CACHE FILEPATH "path to curses" ${FORCE_ARG}) + FIND_FILE(CURSES_HAVE_CURSES_H curses.h + HINTS "${_cursesParentDir}/include") + + FIND_PATH(CURSES_NCURSES_INCLUDE_PATH ncurses.h ncurses/ncurses.h + ncurses/curses.h) + FIND_PATH(CURSES_NCURSES_INCLUDE_PATH curses.h + HINTS "${_cursesParentDir}/include") + + # for compatibility with older FindCurses.cmake this has to be in the cache + # FORCE must not be used since this would break builds which preload + # a cache wqith these variables set + # only put ncurses include and library into + # variables if they are found + IF(CURSES_NCURSES_INCLUDE_PATH AND CURSES_NCURSES_LIBRARY) + + SET(CURSES_INCLUDE_PATH "${CURSES_NCURSES_INCLUDE_PATH}" + CACHE FILEPATH "The curses include path") + SET(CURSES_LIBRARY "${CURSES_NCURSES_LIBRARY}" + CACHE FILEPATH "The curses library") + ENDIF(CURSES_NCURSES_INCLUDE_PATH AND CURSES_NCURSES_LIBRARY) + ENDIF(NOT CURSES_USE_NCURSES) -FIND_LIBRARY(CURSES_EXTRA_LIBRARY cur_colr PATHS "${_cursesLibDir}" NO_DEFAULT_PATH) + +FIND_LIBRARY(CURSES_EXTRA_LIBRARY cur_colr HINTS "${_cursesLibDir}") FIND_LIBRARY(CURSES_EXTRA_LIBRARY cur_colr ) -FIND_LIBRARY(CURSES_FORM_LIBRARY form PATHS "${_cursesLibDir}" NO_DEFAULT_PATH) +FIND_LIBRARY(CURSES_FORM_LIBRARY form HINTS "${_cursesLibDir}") FIND_LIBRARY(CURSES_FORM_LIBRARY form ) +# for compatibility with older FindCurses.cmake this has to be in the cache +# FORCE must not be used since this would break builds which preload a cache +# qith these variables set +SET(FORM_LIBRARY "${CURSES_FORM_LIBRARY}" + CACHE FILEPATH "The curses form library") + # Need to provide the *_LIBRARIES SET(CURSES_LIBRARIES ${CURSES_LIBRARY}) @@ -101,16 +124,14 @@ SET(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH}) # handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Curses DEFAULT_MSG CURSES_LIBRARY CURSES_INCLUDE_PATH) - -# for compatibility -SET(FORM_LIBRARY "${CURSES_FORM_LIBRARY}") +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Curses DEFAULT_MSG + CURSES_LIBRARY CURSES_INCLUDE_PATH) MARK_AS_ADVANCED( CURSES_INCLUDE_PATH CURSES_LIBRARY CURSES_CURSES_INCLUDE_PATH - CURSES_LIBRARY + CURSES_CURSES_LIBRARY CURSES_NCURSES_INCLUDE_PATH CURSES_NCURSES_LIBRARY CURSES_EXTRA_LIBRARY diff --git a/Modules/FindFLTK.cmake b/Modules/FindFLTK.cmake index d16cf737f..1dc4a59b0 100644 --- a/Modules/FindFLTK.cmake +++ b/Modules/FindFLTK.cmake @@ -11,6 +11,11 @@ # FLTK_FORMS_LIBRARY = the full path to fltk_forms.lib # FLTK_IMAGES_LIBRARY = the full path to fltk_images.lib +IF (FLTK_INCLUDE_DIR) + # Already in cache, be silent + SET(FLTK_FIND_QUIETLY TRUE) +ENDIF (FLTK_INCLUDE_DIR) + # Platform dependent libraries required by FLTK IF(WIN32) IF(NOT CYGWIN) @@ -24,7 +29,8 @@ ENDIF(WIN32) IF(UNIX) INCLUDE(${CMAKE_ROOT}/Modules/FindX11.cmake) - SET( FLTK_PLATFORM_DEPENDENT_LIBS ${X11_LIBRARIES} -lm) + FIND_LIBRARY(FLTK_MATH_LIBRARY m) + SET( FLTK_PLATFORM_DEPENDENT_LIBS ${X11_LIBRARIES} ${FLTK_MATH_LIBRARY}) ENDIF(UNIX) IF(APPLE) @@ -32,7 +38,8 @@ IF(APPLE) ENDIF(APPLE) IF(CYGWIN) - SET( FLTK_PLATFORM_DEPENDENT_LIBS ole32 uuid comctl32 wsock32 supc++ -lm -lgdi32) + FIND_LIBRARY(FLTK_MATH_LIBRARY m) + SET( FLTK_PLATFORM_DEPENDENT_LIBS ole32 uuid comctl32 wsock32 supc++ ${FLTK_MATH_LIBRARY} -lgdi32) ENDIF(CYGWIN) # If FLTK_INCLUDE_DIR is already defined we assigne its value to FLTK_DIR @@ -96,10 +103,6 @@ IF(NOT FLTK_DIR) ) ENDIF(NOT FLTK_DIR) -# If FLTK was found, load the configuration file to get the rest of the -# settings. -IF(FLTK_DIR) - # Check if FLTK was built using CMake IF(EXISTS ${FLTK_DIR}/FLTKConfig.cmake) SET(FLTK_BUILT_WITH_CMAKE 1) @@ -170,8 +173,6 @@ IF(FLTK_DIR) ENDIF(FLTK_FLUID_EXECUTABLE) SET(FLTK_INCLUDE_SEARCH_PATH ${FLTK_INCLUDE_SEARCH_PATH} - /usr/local/include - /usr/include /usr/local/fltk /usr/X11R6/include ) @@ -179,8 +180,6 @@ IF(FLTK_DIR) FIND_PATH(FLTK_INCLUDE_DIR FL/Fl.h ${FLTK_INCLUDE_SEARCH_PATH}) SET(FLTK_LIBRARY_SEARCH_PATH ${FLTK_LIBRARY_SEARCH_PATH} - /usr/lib - /usr/local/lib /usr/local/fltk/lib /usr/X11R6/lib ${FLTK_INCLUDE_DIR}/lib @@ -215,7 +214,6 @@ IF(FLTK_DIR) ENDIF(UNIX) ENDIF(FLTK_BUILT_WITH_CMAKE) -ENDIF(FLTK_DIR) SET(FLTK_FOUND 1) @@ -242,3 +240,6 @@ IF(FLTK_FOUND) SET (FLTK_FLUID_EXE ${FLTK_FLUID_EXECUTABLE}) SET (FLTK_LIBRARY ${FLTK_LIBRARIES}) ENDIF(FLTK_FOUND) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(FLTK DEFAULT_MSG FLTK_LIBRARIES FLTK_INCLUDE_DIR) diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index c128c47c8..3c83bfa7d 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -29,13 +29,9 @@ # I'm going to attempt to cut out the middleman and hope # everything still works. FIND_PATH(FREETYPE_INCLUDE_DIR_ft2build ft2build.h + HINTS $ENV{FREETYPE_DIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - - -FIND_PATH(FREETYPE_INCLUDE_DIR_ft2build ft2build.h PATHS /usr/local/X11R6/include /usr/local/X11/include @@ -46,11 +42,9 @@ FIND_PATH(FREETYPE_INCLUDE_DIR_ft2build ft2build.h ) FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h + HINTS $ENV{FREETYPE_DIR}/include/freetype2 - NO_DEFAULT_PATH -) - -FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h + PATHS /usr/local/X11R6/include /usr/local/X11/include /usr/X11/include @@ -62,21 +56,15 @@ FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h FIND_LIBRARY(FREETYPE_LIBRARY NAMES freetype libfreetype freetype219 - PATHS + HINTS $ENV{FREETYPE_DIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(FREETYPE_LIBRARY - NAMES freetype libfreetype freetype219 + PATH_SUFFIXES lib64 lib PATHS /usr/local/X11R6 /usr/local/X11 /usr/X11 /sw /usr/freeware - PATH_SUFFIXES lib64 lib ) # set the user variables diff --git a/Modules/FindGDAL.cmake b/Modules/FindGDAL.cmake index a92b04c63..e21fe833e 100644 --- a/Modules/FindGDAL.cmake +++ b/Modules/FindGDAL.cmake @@ -20,14 +20,9 @@ # #include "gdal.h" FIND_PATH(GDAL_INCLUDE_DIR gdal.h + HINTS $ENV{GDAL_DIR} - NO_DEFAULT_PATH - PATH_SUFFIXES include -) - - - -FIND_PATH(GDAL_INCLUDE_DIR gdal.h + PATH_SUFFIXES include PATHS ~/Library/Frameworks/gdal.framework/Headers /Library/Frameworks/gdal.framework/Headers @@ -53,14 +48,9 @@ FIND_PATH(GDAL_INCLUDE_DIR gdal.h FIND_LIBRARY(GDAL_LIBRARY NAMES gdal GDAL - PATHS + HINTS $ENV{GDAL_DIR} - NO_DEFAULT_PATH PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(GDAL_LIBRARY - NAMES gdal GDAL PATHS ~/Library/Frameworks /Library/Frameworks @@ -72,7 +62,6 @@ FIND_LIBRARY(GDAL_LIBRARY /opt /usr/freeware [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;GDAL_ROOT]/lib - PATH_SUFFIXES lib64 lib ) SET(GDAL_FOUND "NO") diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake index 305be6821..1d3a5ec1e 100644 --- a/Modules/FindGIF.cmake +++ b/Modules/FindGIF.cmake @@ -10,15 +10,9 @@ # Modifications by Alexander Neundorf FIND_PATH(GIF_INCLUDE_DIR gif_lib.h - PATHS + HINTS $ENV{GIF_DIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - - - -FIND_PATH(GIF_INCLUDE_DIR gif_lib.h PATHS ~/Library/Frameworks /Library/Frameworks @@ -32,16 +26,9 @@ SET(POTENTIAL_GIF_LIBS gif libgif ungif libungif giflib) FIND_LIBRARY(GIF_LIBRARY NAMES ${POTENTIAL_GIF_LIBS} - PATHS + HINTS $ENV{GIF_DIR} - NO_DEFAULT_PATH PATH_SUFFIXES lib64 lib -) - - - -FIND_LIBRARY(GIF_LIBRARY - NAMES ${POTENTIAL_GIF_LIBS} PATHS ~/Library/Frameworks /Library/Frameworks @@ -53,7 +40,6 @@ FIND_LIBRARY(GIF_LIBRARY /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] /usr/freeware - PATH_SUFFIXES lib64 lib ) # see readme.txt diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake index d1e3f9b93..99a270505 100644 --- a/Modules/FindGettext.cmake +++ b/Modules/FindGettext.cmake @@ -30,7 +30,7 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFile) SET(_firstPoFile) ENDIF(${_firstPoFile} STREQUAL "ALL") - FOREACH (_currentPoFile ${ARGN}) + FOREACH (_currentPoFile ${_firstPoFile} ${ARGN}) GET_FILENAME_COMPONENT(_absFile ${_currentPoFile} ABSOLUTE) GET_FILENAME_COMPONENT(_abs_PATH ${_absFile} PATH) GET_FILENAME_COMPONENT(_lang ${_absFile} NAME_WE) diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake index 66e54bcfe..bba9e411c 100644 --- a/Modules/FindImageMagick.cmake +++ b/Modules/FindImageMagick.cmake @@ -1,77 +1,190 @@ -# - Find Image Magick -# This module finds if ImageMagick tools are installed and determines -# where the executables are. This code sets the following variables: +# - Find the ImageMagick binary suite. +# This module will search for a set of ImageMagick tools specified +# as components in the FIND_PACKAGE call. Typical components include, +# but are not limited to (future versions of ImageMagick might have +# additional components not listed here): # -# IMAGEMAGICK_CONVERT_EXECUTABLE = -# the full path to the 'convert' utility -# IMAGEMAGICK_MOGRIFY_EXECUTABLE = -# the full path to the 'mogrify' utility -# IMAGEMAGICK_IMPORT_EXECUTABLE = -# the full path to the 'import' utility -# IMAGEMAGICK_MONTAGE_EXECUTABLE = -# the full path to the 'montage' utility -# IMAGEMAGICK_COMPOSITE_EXECUTABLE = -# the full path to the 'composite' utility +# animate +# compare +# composite +# conjure +# convert +# display +# identify +# import +# mogrify +# montage +# stream # +# If no component is specified in the FIND_PACKAGE call, then it only +# searches for the ImageMagick executable directory. This code defines +# the following variables: +# +# ImageMagick_FOUND - TRUE if all components are found. +# ImageMagick_EXECUTABLE_DIR - Full path to executables directory. +# ImageMagick__FOUND - TRUE if is found. +# ImageMagick__EXECUTABLE - Full path to executable. +# +# There are also components for the following ImageMagick APIs: +# +# Magick++ +# MagickWand +# MagickCore +# +# For these components the following variables are set: +# +# ImageMagick_FOUND - TRUE if all components are found. +# ImageMagick_INCLUDE_DIRS - Full paths to all include dirs. +# ImageMagick_LIBRARIES - Full paths to all libraries. +# ImageMagick__FOUND - TRUE if is found. +# ImageMagick__INCLUDE_DIRS - Full path to include dirs. +# ImageMagick__LIBRARIES - Full path to libraries. +# +# Example Usages: +# FIND_PACKAGE(ImageMagick) +# FIND_PACKAGE(ImageMagick COMPONENTS convert) +# FIND_PACKAGE(ImageMagick COMPONENTS convert mogrify display) +# FIND_PACKAGE(ImageMagick COMPONENTS Magick++) +# FIND_PACKAGE(ImageMagick COMPONENTS Magick++ convert) +# +# Note that the standard FIND_PACKAGE features are supported +# (i.e., QUIET, REQUIRED, etc.). -IF (WIN32) +# Copyright (c) 2007-2008, +# Miguel A. Figueroa-Villanueva, miguelf at ieee dot org. +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - # Try to find the ImageMagick binary path. +#--------------------------------------------------------------------- +# Helper functions +#--------------------------------------------------------------------- +FUNCTION(FIND_IMAGEMAGICK_API component header) + SET(ImageMagick_${component}_FOUND FALSE PARENT_SCOPE) - FIND_PATH(IMAGEMAGICK_BINARY_PATH mogrify.exe - [HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath] - DOC "Path to the ImageMagick binary directory where all executable should be found." - ) + FIND_PATH(ImageMagick_${component}_INCLUDE_DIR + NAMES ${header} + PATHS + ${ImageMagick_INCLUDE_DIRS} + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath]/include" + PATH_SUFFIXES + ImageMagick + DOC "Path to the ImageMagick include dir." + ) + FIND_LIBRARY(ImageMagick_${component}_LIBRARY + NAMES ${ARGN} + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath]/lib" + DOC "Path to the ImageMagick Magick++ library." + ) - # Be extra-careful here: we do NOT want CMake to look in the system's PATH - # env var to search for convert.exe, otherwise it is going to pick - # Window's own convert.exe, and you may say good-bye to your disk. + IF(ImageMagick_${component}_INCLUDE_DIR AND ImageMagick_${component}_LIBRARY) + SET(ImageMagick_${component}_FOUND TRUE PARENT_SCOPE) - FIND_PROGRAM(IMAGEMAGICK_CONVERT_EXECUTABLE - NAMES convert - PATHS ${IMAGEMAGICK_BINARY_PATH} - NO_SYSTEM_PATH - DOC "Path to ImageMagick's convert executable. WARNING: note that this tool, named convert.exe, conflicts with Microsoft Window's own convert.exe, which is used to convert FAT partitions to NTFS format ! Therefore, be extra-careful and make sure the right convert.exe has been picked." - ) + LIST(APPEND ImageMagick_INCLUDE_DIRS + ${ImageMagick_${component}_INCLUDE_DIR} + ) + LIST(REMOVE_DUPLICATES ImageMagick_INCLUDE_DIRS) + SET(ImageMagick_INCLUDE_DIRS ${ImageMagick_INCLUDE_DIRS} PARENT_SCOPE) -ELSE (WIN32) + LIST(APPEND ImageMagick_LIBRARIES + ${ImageMagick_${component}_LIBRARY} + ) + SET(ImageMagick_LIBRARIES ${ImageMagick_LIBRARIES} PARENT_SCOPE) + ENDIF(ImageMagick_${component}_INCLUDE_DIR AND ImageMagick_${component}_LIBRARY) +ENDFUNCTION(FIND_IMAGEMAGICK_API) - SET (IMAGEMAGICK_BINARY_PATH "") +FUNCTION(FIND_IMAGEMAGICK_EXE component) + SET(_IMAGEMAGICK_EXECUTABLE + ${ImageMagick_EXECUTABLE_DIR}/${component}${CMAKE_EXECUTABLE_SUFFIX}) + IF(EXISTS ${_IMAGEMAGICK_EXECUTABLE}) + SET(ImageMagick_${component}_EXECUTABLE + ${_IMAGEMAGICK_EXECUTABLE} + PARENT_SCOPE + ) + SET(ImageMagick_${component}_FOUND TRUE PARENT_SCOPE) + ELSE(EXISTS ${_IMAGEMAGICK_EXECUTABLE}) + SET(ImageMagick_${component}_FOUND FALSE PARENT_SCOPE) + ENDIF(EXISTS ${_IMAGEMAGICK_EXECUTABLE}) +ENDFUNCTION(FIND_IMAGEMAGICK_EXE) - FIND_PROGRAM(IMAGEMAGICK_CONVERT_EXECUTABLE - NAMES convert - PATHS ${IMAGEMAGICK_BINARY_PATH} - DOC "Path to ImageMagick's convert executable." +#--------------------------------------------------------------------- +# Start Actual Work +#--------------------------------------------------------------------- +# Try to find a ImageMagick installation binary path. +FIND_PATH(ImageMagick_EXECUTABLE_DIR + NAMES mogrify${CMAKE_EXECUTABLE_SUFFIX} + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath]" + DOC "Path to the ImageMagick binary directory." + NO_DEFAULT_PATH + ) +FIND_PATH(ImageMagick_EXECUTABLE_DIR + NAMES mogrify${CMAKE_EXECUTABLE_SUFFIX} ) -ENDIF (WIN32) - -# Find mogrify, import, montage, composite - -FIND_PROGRAM(IMAGEMAGICK_MOGRIFY_EXECUTABLE - NAMES mogrify - PATHS ${IMAGEMAGICK_BINARY_PATH} - DOC "Path to ImageMagick's mogrify executable." -) - -FIND_PROGRAM(IMAGEMAGICK_IMPORT_EXECUTABLE - NAMES import - PATHS ${IMAGEMAGICK_BINARY_PATH} - DOC "Path to ImageMagick's import executable." -) +# Find each component. Search for all tools in same dir +# ; otherwise they should be found +# independently and not in a cohesive module such as this one. +SET(ImageMagick_FOUND TRUE) +FOREACH(component ${ImageMagick_FIND_COMPONENTS} + # DEPRECATED: forced components for backward compatibility + convert mogrify import montage composite + ) + IF(component STREQUAL "Magick++") + FIND_IMAGEMAGICK_API(Magick++ Magick++.h + Magick++ CORE_RL_Magick++_ + ) + ELSEIF(component STREQUAL "MagickWand") + FIND_IMAGEMAGICK_API(MagickWand wand/MagickWand.h + Wand MagickWand CORE_RL_wand_ + ) + ELSEIF(component STREQUAL "MagickCore") + FIND_IMAGEMAGICK_API(MagickCore magick/MagickCore.h + Magick MagickCore CORE_RL_magick_ + ) + ELSE(component STREQUAL "Magick++") + IF(ImageMagick_EXECUTABLE_DIR) + FIND_IMAGEMAGICK_EXE(${component}) + ENDIF(ImageMagick_EXECUTABLE_DIR) + ENDIF(component STREQUAL "Magick++") + + IF(NOT ImageMagick_${component}_FOUND) + LIST(FIND ImageMagick_FIND_COMPONENTS ${component} is_requested) + IF(is_requested GREATER -1) + SET(ImageMagick_FOUND FALSE) + ENDIF(is_requested GREATER -1) + ENDIF(NOT ImageMagick_${component}_FOUND) +ENDFOREACH(component) -FIND_PROGRAM(IMAGEMAGICK_MONTAGE_EXECUTABLE - NAMES montage - PATHS ${IMAGEMAGICK_BINARY_PATH} - DOC "Path to ImageMagick's montage executable." -) +SET(ImageMagick_INCLUDE_DIRS ${ImageMagick_INCLUDE_DIRS}) +SET(ImageMagick_LIBRARIES ${ImageMagick_LIBRARIES}) -FIND_PROGRAM(IMAGEMAGICK_COMPOSITE_EXECUTABLE - NAMES composite - PATHS ${IMAGEMAGICK_BINARY_PATH} - DOC "Path to ImageMagick's composite executable." -) +#--------------------------------------------------------------------- +# Standard Package Output +#--------------------------------------------------------------------- +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( + ImageMagick DEFAULT_MSG ImageMagick_FOUND + ) +# Maintain consistency with all other variables. +SET(ImageMagick_FOUND ${IMAGEMAGICK_FOUND}) +#--------------------------------------------------------------------- +# DEPRECATED: Setting variables for backward compatibility. +#--------------------------------------------------------------------- +SET(IMAGEMAGICK_BINARY_PATH ${ImageMagick_EXECUTABLE_DIR} + CACHE PATH "Path to the ImageMagick binary directory.") +SET(IMAGEMAGICK_CONVERT_EXECUTABLE ${ImageMagick_convert_EXECUTABLE} + CACHE FILEPATH "Path to ImageMagick's convert executable.") +SET(IMAGEMAGICK_MOGRIFY_EXECUTABLE ${ImageMagick_mogrify_EXECUTABLE} + CACHE FILEPATH "Path to ImageMagick's mogrify executable.") +SET(IMAGEMAGICK_IMPORT_EXECUTABLE ${ImageMagick_import_EXECUTABLE} + CACHE FILEPATH "Path to ImageMagick's import executable.") +SET(IMAGEMAGICK_MONTAGE_EXECUTABLE ${ImageMagick_montage_EXECUTABLE} + CACHE FILEPATH "Path to ImageMagick's montage executable.") +SET(IMAGEMAGICK_COMPOSITE_EXECUTABLE ${ImageMagick_composite_EXECUTABLE} + CACHE FILEPATH "Path to ImageMagick's composite executable.") MARK_AS_ADVANCED( IMAGEMAGICK_BINARY_PATH IMAGEMAGICK_CONVERT_EXECUTABLE @@ -79,4 +192,4 @@ MARK_AS_ADVANCED( IMAGEMAGICK_IMPORT_EXECUTABLE IMAGEMAGICK_MONTAGE_EXECUTABLE IMAGEMAGICK_COMPOSITE_EXECUTABLE -) + ) diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 26f473473..bed0e1d0d 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -3,35 +3,47 @@ # include files and libraries are. It also determines what the name of # the library is. This code sets the following variables: # -# JAVA_AWT_LIB_PATH = the path to the jawt library -# JAVA_JVM_LIB_PATH = the path to the jvm library +# JNI_INCLUDE_DIRS = the include dirs to use +# JNI_LIBRARIES = the libraries to use +# JAVA_AWT_LIBRARY = the path to the jawt library +# JAVA_JVM_LIBRARY = the path to the jvm library # JAVA_INCLUDE_PATH = the include path to jni.h # JAVA_INCLUDE_PATH2 = the include path to jni_md.h # JAVA_AWT_INCLUDE_PATH = the include path to jawt.h -# +# + GET_FILENAME_COMPONENT(java_install_version "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME) + SET(JAVA_AWT_LIBRARY_DIRECTORIES "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib" $ENV{JAVA_HOME}/jre/lib/i386 $ENV{JAVA_HOME}/jre/lib/amd64 + $ENV{JAVA_HOME}/jre/lib/ppc /usr/lib /usr/local/lib + /usr/lib/jvm/java/lib /usr/lib/java/jre/lib/i386 /usr/local/lib/java/jre/lib/i386 /usr/local/share/java/jre/lib/i386 /usr/lib/j2sdk1.4-sun/jre/lib/i386 /usr/lib/j2sdk1.5-sun/jre/lib/i386 /opt/sun-jdk-1.5.0.04/jre/lib/amd64 - /usr/lib/java/jre/lib/amd64 /usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/amd64 + /usr/lib/java/jre/lib/amd64 /usr/local/lib/java/jre/lib/amd64 /usr/local/share/java/jre/lib/amd64 /usr/lib/j2sdk1.4-sun/jre/lib/amd64 /usr/lib/j2sdk1.5-sun/jre/lib/amd64 + /usr/lib/java/jre/lib/ppc + /usr/local/lib/java/jre/lib/ppc + /usr/local/share/java/jre/lib/ppc + /usr/lib/j2sdk1.4-sun/jre/lib/ppc + /usr/lib/j2sdk1.5-sun/jre/lib/ppc ) + SET(JAVA_JVM_LIBRARY_DIRECTORIES) FOREACH(dir ${JAVA_AWT_LIBRARY_DIRECTORIES}) SET(JAVA_JVM_LIBRARY_DIRECTORIES @@ -52,6 +64,7 @@ SET(JAVA_AWT_INCLUDE_DIRECTORIES /usr/local/include /usr/lib/java/include /usr/local/lib/java/include + /usr/lib/jvm/java/include /usr/lib/jvm/java-6-sun-1.6.0.00/include /usr/local/share/java/include /usr/lib/j2sdk1.4-sun/include @@ -130,6 +143,7 @@ FIND_PATH(JAVA_INCLUDE_PATH2 jni_md.h ${JAVA_AWT_INCLUDE_DIRECTORIES} ${JAVA_INCLUDE_PATH}/win32 ${JAVA_INCLUDE_PATH}/linux + ${JAVA_INCLUDE_PATH}/freebsd ) FIND_PATH(JAVA_AWT_INCLUDE_PATH jawt.h @@ -144,3 +158,15 @@ MARK_AS_ADVANCED( JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 ) + +SET(JNI_LIBRARIES + ${JAVA_AWT_LIBRARY} + ${JAVA_JVM_LIBRARY} +) + +SET(JNI_INCLUDE_DIRS + ${JAVA_INCLUDE_PATH} + ${JAVA_INCLUDE_PATH2} + ${JAVA_AWT_INCLUDE_PATH} +) + diff --git a/Modules/FindJPEG.cmake b/Modules/FindJPEG.cmake index 3692ee1eb..984929448 100644 --- a/Modules/FindJPEG.cmake +++ b/Modules/FindJPEG.cmake @@ -23,6 +23,8 @@ ENDIF(JPEG_FOUND) # Deprecated declarations. SET (NATIVE_JPEG_INCLUDE_PATH ${JPEG_INCLUDE_DIR} ) -GET_FILENAME_COMPONENT (NATIVE_JPEG_LIB_PATH ${JPEG_LIBRARY} PATH) +IF(JPEG_LIBRARY) + GET_FILENAME_COMPONENT (NATIVE_JPEG_LIB_PATH ${JPEG_LIBRARY} PATH) +ENDIF(JPEG_LIBRARY) MARK_AS_ADVANCED(JPEG_LIBRARY JPEG_INCLUDE_DIR ) diff --git a/Modules/FindKDE3.cmake b/Modules/FindKDE3.cmake index d8ef875c9..0cf8b2404 100644 --- a/Modules/FindKDE3.cmake +++ b/Modules/FindKDE3.cmake @@ -63,67 +63,44 @@ # # Author: Alexander Neundorf -IF(NOT UNIX) +IF(NOT UNIX AND KDE3_FIND_REQUIRED) MESSAGE(FATAL_ERROR "Compiling KDE3 applications and libraries under Windows is not supported") -ENDIF(NOT UNIX) +ENDIF(NOT UNIX AND KDE3_FIND_REQUIRED) + +# If Qt4 has already been found, fail. +IF(QT4_FOUND) + IF(KDE3_FIND_REQUIRED) + MESSAGE( FATAL_ERROR "KDE3/Qt3 and Qt4 cannot be used together in one project.") + ELSE(KDE3_FIND_REQUIRED) + IF(NOT KDE3_FIND_QUIETLY) + MESSAGE( STATUS "KDE3/Qt3 and Qt4 cannot be used together in one project.") + ENDIF(NOT KDE3_FIND_QUIETLY) + RETURN() + ENDIF(KDE3_FIND_REQUIRED) +ENDIF(QT4_FOUND) SET(QT_MT_REQUIRED TRUE) #SET(QT_MIN_VERSION "3.0.0") #this line includes FindQt.cmake, which searches the Qt library and headers -FIND_PACKAGE(Qt3 REQUIRED) -FIND_PACKAGE(X11 REQUIRED) - - -#add some KDE specific stuff -SET(KDE3_DEFINITIONS -DQT_CLEAN_NAMESPACE -D_GNU_SOURCE) - -#only on linux, but NOT e.g. on FreeBSD: -IF(CMAKE_SYSTEM_NAME MATCHES "Linux") - SET (KDE3_DEFINITIONS ${KDE3_DEFINITIONS} -D_XOPEN_SOURCE=500 -D_BSD_SOURCE) - SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common") - SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-exceptions -fno-check-new -fno-common") -ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") - -# works on FreeBSD, NOT tested on NetBSD and OpenBSD -IF (CMAKE_SYSTEM_NAME MATCHES BSD) - SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common") - SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common") -ENDIF (CMAKE_SYSTEM_NAME MATCHES BSD) - -# if no special buildtype is selected, add -O2 as default optimization -IF (NOT CMAKE_BUILD_TYPE) - SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2") - SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") -ENDIF (NOT CMAKE_BUILD_TYPE) - - -#SET(CMAKE_SHARED_LINKER_FLAGS "-avoid-version -module -Wl,--no-undefined -Wl,--allow-shlib-undefined") -#SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc") -#SET(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc") +IF(KDE3_FIND_REQUIRED) + SET(_REQ_STRING_KDE3 "REQUIRED") +ENDIF(KDE3_FIND_REQUIRED) + +FIND_PACKAGE(Qt3 ${_REQ_STRING_KDE3}) +FIND_PACKAGE(X11 ${_REQ_STRING_KDE3}) -# all calls to FIND_PROGRAM/PATH/LIBRARY() follow the same scheme: -# at first try some special paths with the argument "NO_DEFAULT_PATH" -# so only these paths are checked -# this is followed by a second call to FIND_PROGRAM/PATH/LIBRARY() -# but this time without any paths and without NO_DEFAULT_PATH -# this second call will do nothing if the first call already found -# what it was looking for, if not, it will search only in the default -# directories (/usr, /usr/local, etc.) #now try to find some kde stuff -FIND_PROGRAM(KDECONFIG_EXECUTABLE NAMES kde-config PATHS +FIND_PROGRAM(KDECONFIG_EXECUTABLE NAMES kde-config + HINTS $ENV{KDEDIR}/bin + PATHS /opt/kde3/bin /opt/kde/bin - NO_DEFAULT_PATH ) - -FIND_PROGRAM(KDECONFIG_EXECUTABLE kde-config) - - SET(KDE3PREFIX) IF(KDECONFIG_EXECUTABLE) EXECUTE_PROCESS(COMMAND ${KDECONFIG_EXECUTABLE} --version @@ -143,29 +120,26 @@ ENDIF(KDECONFIG_EXECUTABLE) # at first the KDE include direcory # kpassdlg.h comes from kdeui and doesn't exist in KDE4 anymore FIND_PATH(KDE3_INCLUDE_DIR kpassdlg.h + HINTS $ENV{KDEDIR}/include ${KDE3PREFIX}/include + PATHS /opt/kde3/include /opt/kde/include /usr/include/kde /usr/local/include/kde - NO_DEFAULT_PATH ) -FIND_PATH(KDE3_INCLUDE_DIR kpassdlg.h) - #now the KDE library directory FIND_LIBRARY(KDE3_KDECORE_LIBRARY NAMES kdecore - PATHS + HINTS $ENV{KDEDIR}/lib ${KDE3PREFIX}/lib + PATHS /opt/kde3/lib /opt/kde/lib - NO_DEFAULT_PATH ) -FIND_LIBRARY(KDE3_KDECORE_LIBRARY NAMES kdecore) - SET(QT_AND_KDECORE_LIBS ${QT_LIBRARIES} ${KDE3_KDECORE_LIBRARY}) GET_FILENAME_COMPONENT(KDE3_LIB_DIR ${KDE3_KDECORE_LIBRARY} PATH ) @@ -179,39 +153,33 @@ IF(NOT KDE3_LIBTOOL_DIR) ENDIF(NOT KDE3_LIBTOOL_DIR) #now search for the dcop utilities -FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAMES dcopidl PATHS +FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAMES dcopidl + HINTS $ENV{KDEDIR}/bin ${KDE3PREFIX}/bin + PATHS /opt/kde3/bin /opt/kde/bin - NO_DEFAULT_PATH ) -FIND_PROGRAM(KDE3_DCOPIDL_EXECUTABLE NAMES dcopidl) - -FIND_PROGRAM(KDE3_DCOPIDL2CPP_EXECUTABLE NAMES dcopidl2cpp PATHS +FIND_PROGRAM(KDE3_DCOPIDL2CPP_EXECUTABLE NAMES dcopidl2cpp + HINTS $ENV{KDEDIR}/bin ${KDE3PREFIX}/bin + PATHS /opt/kde3/bin /opt/kde/bin - NO_DEFAULT_PATH ) -FIND_PROGRAM(KDE3_DCOPIDL2CPP_EXECUTABLE NAMES dcopidl2cpp) - -FIND_PROGRAM(KDE3_KCFGC_EXECUTABLE NAMES kconfig_compiler PATHS +FIND_PROGRAM(KDE3_KCFGC_EXECUTABLE NAMES kconfig_compiler + HINTS $ENV{KDEDIR}/bin ${KDE3PREFIX}/bin + PATHS /opt/kde3/bin /opt/kde/bin - NO_DEFAULT_PATH ) -FIND_PROGRAM(KDE3_KCFGC_EXECUTABLE NAMES kconfig_compiler) - -# KDE3Macros.cmake contains all the KDE specific macros -INCLUDE(KDE3Macros) - #SET KDE3_FOUND IF (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE) @@ -220,6 +188,51 @@ ELSE (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCO SET(KDE3_FOUND FALSE) ENDIF (KDE3_INCLUDE_DIR AND KDE3_LIB_DIR AND KDE3_DCOPIDL_EXECUTABLE AND KDE3_DCOPIDL2CPP_EXECUTABLE AND KDE3_KCFGC_EXECUTABLE) +# add some KDE specific stuff +SET(KDE3_DEFINITIONS -DQT_CLEAN_NAMESPACE -D_GNU_SOURCE) + +# set compiler flags only if KDE3 has actually been found +IF(KDE3_FOUND) + SET(_KDE3_USE_FLAGS FALSE) + IF(CMAKE_COMPILER_IS_GNUCXX) + SET(_KDE3_USE_FLAGS TRUE) # use flags for gnu compiler + EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} --version + OUTPUT_VARIABLE out) + # gnu gcc 2.96 does not work with flags + # I guess 2.95 also doesn't then + IF("${out}" MATCHES "2.9[56]") + SET(_KDE3_USE_FLAGS FALSE) + ENDIF("${out}" MATCHES "2.9[56]") + ENDIF(CMAKE_COMPILER_IS_GNUCXX) + + #only on linux, but NOT e.g. on FreeBSD: + IF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND _KDE3_USE_FLAGS) + SET (KDE3_DEFINITIONS ${KDE3_DEFINITIONS} -D_XOPEN_SOURCE=500 -D_BSD_SOURCE) + SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common") + SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-exceptions -fno-check-new -fno-common") + ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND _KDE3_USE_FLAGS) + + # works on FreeBSD, NOT tested on NetBSD and OpenBSD + IF (CMAKE_SYSTEM_NAME MATCHES BSD AND _KDE3_USE_FLAGS) + SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -ansi -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common") + SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common") + ENDIF (CMAKE_SYSTEM_NAME MATCHES BSD AND _KDE3_USE_FLAGS) + + # if no special buildtype is selected, add -O2 as default optimization + IF (NOT CMAKE_BUILD_TYPE AND _KDE3_USE_FLAGS) + SET ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2") + SET ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") + ENDIF (NOT CMAKE_BUILD_TYPE AND _KDE3_USE_FLAGS) + +#SET(CMAKE_SHARED_LINKER_FLAGS "-avoid-version -module -Wl,--no-undefined -Wl,--allow-shlib-undefined") +#SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc") +#SET(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -avoid-version -Wl,--no-undefined -lc") +ENDIF(KDE3_FOUND) + + +# KDE3Macros.cmake contains all the KDE specific macros +INCLUDE(KDE3Macros) + MACRO (KDE3_PRINT_RESULTS) IF(KDE3_INCLUDE_DIR) diff --git a/Modules/FindKDE4.cmake b/Modules/FindKDE4.cmake index 3d32fcc0d..e6d0488bf 100644 --- a/Modules/FindKDE4.cmake +++ b/Modules/FindKDE4.cmake @@ -9,6 +9,18 @@ # # Author: Alexander Neundorf +# If Qt3 has already been found, fail. +IF(QT_QT_LIBRARY) + IF(KDE4_FIND_REQUIRED) + MESSAGE( FATAL_ERROR "KDE4/Qt4 and Qt3 cannot be used together in one project.") + ELSE(KDE4_FIND_REQUIRED) + IF(NOT KDE4_FIND_QUIETLY) + MESSAGE( STATUS "KDE4/Qt4 and Qt3 cannot be used together in one project.") + ENDIF(NOT KDE_FIND_QUIETLY) + RETURN() + ENDIF(KDE4_FIND_REQUIRED) +ENDIF(QT_QT_LIBRARY) + FILE(TO_CMAKE_PATH "$ENV{KDEDIRS}" _KDEDIRS) # when cross compiling, searching kde4-config in order to run it later on @@ -20,16 +32,13 @@ FILE(TO_CMAKE_PATH "$ENV{KDEDIRS}" _KDEDIRS) FIND_PROGRAM(KDE4_KDECONFIG_EXECUTABLE NAMES kde4-config # the suffix must be used since KDEDIRS can be a list of directories which don't have bin/ appended PATH_SUFFIXES bin - PATHS + HINTS ${CMAKE_INSTALL_PREFIX} ${_KDEDIRS} /opt/kde4 - NO_DEFAULT_PATH ONLY_CMAKE_FIND_ROOT_PATH ) -FIND_PROGRAM(KDE4_KDECONFIG_EXECUTABLE NAMES kde4-config ONLY_CMAKE_FIND_ROOT_PATH) - IF (NOT KDE4_KDECONFIG_EXECUTABLE) IF (KDE4_FIND_REQUIRED) MESSAGE(FATAL_ERROR "ERROR: Could not find KDE4 kde4-config") @@ -45,10 +54,13 @@ IF(NOT KDE4_DATA_DIR) GET_FILENAME_COMPONENT(KDE4_DATA_DIR "${KDE4_DATA_DIR}" PATH) ELSE(CMAKE_CROSSCOMPILING) # then ask kde4-config for the kde data dirs - EXECUTE_PROCESS(COMMAND "${KDE4_KDECONFIG_EXECUTABLE}" --path data OUTPUT_VARIABLE _data_DIR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - FILE(TO_CMAKE_PATH "${_data_DIR}" _data_DIR) - # then check the data dirs for FindKDE4Internal.cmake - FIND_PATH(KDE4_DATA_DIR cmake/modules/FindKDE4Internal.cmake ${_data_DIR}) + + IF(KDE4_KDECONFIG_EXECUTABLE) + EXECUTE_PROCESS(COMMAND "${KDE4_KDECONFIG_EXECUTABLE}" --path data OUTPUT_VARIABLE _data_DIR ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + FILE(TO_CMAKE_PATH "${_data_DIR}" _data_DIR) + # then check the data dirs for FindKDE4Internal.cmake + FIND_PATH(KDE4_DATA_DIR cmake/modules/FindKDE4Internal.cmake ${_data_DIR}) + ENDIF(KDE4_KDECONFIG_EXECUTABLE) ENDIF(CMAKE_CROSSCOMPILING) ENDIF(NOT KDE4_DATA_DIR) diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index 5d9b278e7..ca727af3a 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -10,25 +10,42 @@ # is found # LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l # and -L). -# LAPACK_LIBRARIES - uncached list of libraries (using full path name) to +# LAPACK_LIBRARIES - uncached list of libraries (using full path name) to # link against to use LAPACK -# LAPACK95_LIBRARIES - uncached list of libraries (using full path name) to +# LAPACK95_LIBRARIES - uncached list of libraries (using full path name) to # link against to use LAPACK95 +# LAPACK95_FOUND - set to true if a library implementing the LAPACK f95 +# interface is found +# BLA_STATIC if set on this determines what kind of linkage we do (static) +# BLA_VENDOR if set checks only the specified vendor, if not set checks +# all the posibilities +# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK +### List of vendors (BLA_VENDOR) valid in this module +## Intel(mkl), ACML,Apple, NAS, Generic +get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES) +if(NOT _LANGUAGES_ MATCHES Fortran) + if(LAPACK_FIND_REQUIRED) + message(FATAL_ERROR + "FindLAPACK is Fortran-only so Fortran must be enabled.") + else(LAPACK_FIND_REQUIRED) + message(STATUS "Looking for LAPACK... - NOT found (Fortran not enabled)") + return() + endif(LAPACK_FIND_REQUIRED) +endif(NOT _LANGUAGES_ MATCHES Fortran) -# - include(CheckFortranFunctionExists) set(LAPACK_FOUND FALSE) +set(LAPACK95_FOUND FALSE) -macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas) +macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas _threads) # This macro checks for the existence of the combination of fortran libraries -# given by _list. If the combination is found, this macro checks (using the +# given by _list. If the combination is found, this macro checks (using the # Check_Fortran_Function_Exists macro) whether can link against that library # combination using the name of a routine given by _name using the linker # flags given by _flags. If the combination of libraries is found and passes # the link test, LIBRARIES is set to the list of complete library paths that # have been found. Otherwise, LIBRARIES is set to FALSE. - + # N.B. _prefix is the prefix applied to the names of all cached variables that # are generated internally and marked advanced by this macro. @@ -39,20 +56,29 @@ foreach(_library ${_list}) set(_combined_name ${_combined_name}_${_library}) if(_libraries_work) -IF (WIN32) + IF (WIN32) + if(BLA_STATIC) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") + endif(BLA_STATIC) find_library(${_prefix}_${_library}_LIBRARY NAMES ${_library} - PATHS ENV LIB + PATHS ENV LIB ) -ENDIF (WIN32) + ENDIF (WIN32) if(APPLE) + if(BLA_STATIC) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so;.dylib") + endif(BLA_STATIC) find_library(${_prefix}_${_library}_LIBRARY NAMES ${_library} PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH ) else(APPLE) - find_library(${_prefix}_${_library}_LIBRARY + if(BLA_STATIC) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so") + endif(BLA_STATIC) + find_library(${_prefix}_${_library}_LIBRARY NAMES ${_library} PATHS /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH ) @@ -66,8 +92,12 @@ endforeach(_library ${_list}) if(_libraries_work) # Test this combination of libraries. - set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas}) - #message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") + if(UNIX AND BLA_STATIC) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group ${${LIBRARIES}} ${_blas};-Wl,--end-group" ${_threads}) + else(UNIX AND BLA_STATIC) + set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threads}) + endif(UNIX AND BLA_STATIC) +# message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}") check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS) set(CMAKE_REQUIRED_LIBRARIES) mark_as_advanced(${_prefix}${_combined_name}_WORKS) @@ -75,9 +105,11 @@ if(_libraries_work) #message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}") endif(_libraries_work) -if(NOT _libraries_work) - set(${LIBRARIES} FALSE) -endif(NOT _libraries_work) + if(_libraries_work) + set(${LIBRARIES} ${${LIBRARIES}} ${_blas}) + else(_libraries_work) + set(${LIBRARIES} FALSE) + endif(_libraries_work) endmacro(Check_Lapack_Libraries) @@ -93,49 +125,34 @@ else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) find_package(BLAS REQUIRED) endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) + if(BLAS_FOUND) set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS}) - -#intel lapack - if(NOT LAPACK_LIBRARIES) - - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "mkl_lapack" - "${BLAS_LIBRARIES}" - ) - endif(NOT LAPACK_LIBRARIES) - - if(NOT LAPACK95_LIBRARIES) - check_lapack_libraries( - LAPACK95_LIBRARIES - LAPACK - cheev - "" - "mkl_lapack95" - "${BLAS_LIBRARIES}" - ) - endif(NOT LAPACK95_LIBRARIES) - + if ($ENV{BLA_VENDOR} MATCHES ".+") + set(BLA_VENDOR $ENV{BLA_VENDOR}) + else ($ENV{BLA_VENDOR} MATCHES ".+") + if(NOT BLA_VENDOR) + set(BLA_VENDOR "All") + endif(NOT BLA_VENDOR) + endif ($ENV{BLA_VENDOR} MATCHES ".+") #acml lapack + if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") if(NOT LAPACK_LIBRARIES) - - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "acml" - "${BLAS_LIBRARIES}" - ) -endif(NOT LAPACK_LIBRARIES) - + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "acml" + "" + "" + ) + endif(NOT LAPACK_LIBRARIES) + endif (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") # Apple LAPACK library? -if(NOT LAPACK_LIBRARIES) +if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) check_lapack_libraries( LAPACK_LIBRARIES LAPACK @@ -143,9 +160,11 @@ if(NOT LAPACK_LIBRARIES) "" "Accelerate" "${BLAS_LIBRARIES}" + "" ) - endif(NOT LAPACK_LIBRARIES) - + endif(NOT LAPACK_LIBRARIES) +endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") +if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") if ( NOT LAPACK_LIBRARIES ) check_lapack_libraries( LAPACK_LIBRARIES @@ -154,10 +173,12 @@ if(NOT LAPACK_LIBRARIES) "" "vecLib" "${BLAS_LIBRARIES}" + "" ) endif ( NOT LAPACK_LIBRARIES ) - +endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") # Generic LAPACK library? +if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") if ( NOT LAPACK_LIBRARIES ) check_lapack_libraries( LAPACK_LIBRARIES @@ -166,25 +187,85 @@ if(NOT LAPACK_LIBRARIES) "" "lapack" "${BLAS_LIBRARIES}" + "" ) endif ( NOT LAPACK_LIBRARIES ) - +endif (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") +#intel lapack + if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") + if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) + if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) + find_PACKAGE(Threads) + else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) + find_package(Threads REQUIRED) + endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED) + if (BLA_F95) + if(NOT LAPACK95_LIBRARIES) + check_lapack_libraries( + LAPACK95_LIBRARIES + LAPACK + cheev + "" + "mkl_lapack95" + "${BLAS95_LIBRARIES}" + "${CMAKE_THREAD_LIBS_INIT}" + ) + endif(NOT LAPACK95_LIBRARIES) + else(BLA_F95) + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "mkl_lapack" + "${BLAS_LIBRARIES}" + "${CMAKE_THREAD_LIBS_INIT}" + ) + endif(NOT LAPACK_LIBRARIES) + endif(BLA_F95) + endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) + endif(BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") else(BLAS_FOUND) message(STATUS "LAPACK requires BLAS") endif(BLAS_FOUND) -if(LAPACK_LIBRARIES) +if(BLA_F95) + if(LAPACK95_LIBRARIES) + set(LAPACK95_FOUND TRUE) + else(LAPACK95_LIBRARIES) + set(LAPACK95_FOUND FALSE) + endif(LAPACK95_LIBRARIES) + if(NOT LAPACK_FIND_QUIETLY) + if(LAPACK95_FOUND) + message(STATUS "A library with LAPACK95 API found.") + else(LAPACK95_FOUND) + if(LAPACK_FIND_REQUIRED) + message(FATAL_ERROR + "A required library with LAPACK95 API not found. Please specify library location." + ) + else(LAPACK_FIND_REQUIRED) + message(STATUS + "A library with LAPACK95 API not found. Please specify library location." + ) + endif(LAPACK_FIND_REQUIRED) + endif(LAPACK95_FOUND) + endif(NOT LAPACK_FIND_QUIETLY) + set(LAPACK_FOUND "${LAPACK95_FOUND}") + set(LAPACK_LIBRARIES "${LAPACK95_LIBRARIES}") +else(BLA_F95) + if(LAPACK_LIBRARIES) set(LAPACK_FOUND TRUE) -else(LAPACK_LIBRARIES) + else(LAPACK_LIBRARIES) set(LAPACK_FOUND FALSE) -endif(LAPACK_LIBRARIES) + endif(LAPACK_LIBRARIES) -if(NOT LAPACK_FIND_QUIETLY) + if(NOT LAPACK_FIND_QUIETLY) if(LAPACK_FOUND) message(STATUS "A library with LAPACK API found.") else(LAPACK_FOUND) if(LAPACK_FIND_REQUIRED) - message(FATAL_ERROR + message(FATAL_ERROR "A required library with LAPACK API not found. Please specify library location." ) else(LAPACK_FIND_REQUIRED) @@ -193,4 +274,5 @@ if(NOT LAPACK_FIND_QUIETLY) ) endif(LAPACK_FIND_REQUIRED) endif(LAPACK_FOUND) -endif(NOT LAPACK_FIND_QUIETLY) + endif(NOT LAPACK_FIND_QUIETLY) +endif(BLA_F95) diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake index 0de0586ec..42c554ce3 100644 --- a/Modules/FindLibXml2.cmake +++ b/Modules/FindLibXml2.cmake @@ -1,10 +1,11 @@ # - Try to find LibXml2 # Once done this will define # -# LIBXML2_FOUND - system has LibXml2 -# LIBXML2_INCLUDE_DIR - the LibXml2 include directory -# LIBXML2_LIBRARIES - the libraries needed to use LibXml2 +# LIBXML2_FOUND - System has LibXml2 +# LIBXML2_INCLUDE_DIR - The LibXml2 include directory +# LIBXML2_LIBRARIES - The libraries needed to use LibXml2 # LIBXML2_DEFINITIONS - Compiler switches required for using LibXml2 +# LIBXML2_XMLLINT_EXECUTABLE - The XML checking tool xmllint coming with LibXml2 # Copyright (c) 2006, Alexander Neundorf, # @@ -36,11 +37,15 @@ FIND_LIBRARY(LIBXML2_LIBRARIES NAMES xml2 libxml2 ${_LibXml2LinkDir} ) +FIND_PROGRAM(LIBXML2_XMLLINT_EXECUTABLE xmllint) +# for backwards compat. with KDE 4.0.x: +SET(XMLLINT_EXECUTABLE "${LIBXML2_XMLLINT_EXECUTABLE}") + INCLUDE(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if # all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR) -MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES) +MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES LIBXML2_XMLLINT_EXECUTABLE) diff --git a/Modules/FindLua50.cmake b/Modules/FindLua50.cmake index dce483776..6da7aa134 100644 --- a/Modules/FindLua50.cmake +++ b/Modules/FindLua50.cmake @@ -1,7 +1,7 @@ # Locate Lua library # This module defines +# LUA50_FOUND, if false, do not try to link to Lua # LUA_LIBRARIES, both lua and lualib -# LUA_FOUND, if false, do not try to link to Lua # LUA_INCLUDE_DIR, where to find lua.h and lualib.h (and probably lauxlib.h) # # Note that the expected include convention is @@ -13,13 +13,9 @@ FIND_PATH(LUA_INCLUDE_DIR lua.h - PATHS + HINTS $ENV{LUA_DIR} - NO_DEFAULT_PATH PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include -) - -FIND_PATH(LUA_INCLUDE_DIR lua.h PATHS ~/Library/Frameworks /Library/Frameworks @@ -29,19 +25,13 @@ FIND_PATH(LUA_INCLUDE_DIR lua.h /opt/local # DarwinPorts /opt/csw # Blastwave /opt - PATH_SUFFIXES include/lua50 include/lua5.0 include/lua5 include/lua include ) FIND_LIBRARY(LUA_LIBRARY_lua NAMES lua50 lua5.0 lua5 lua - PATHS + HINTS $ENV{LUA_DIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(LUA_LIBRARY_lua - NAMES lua50 lua5.0 lua5 lua + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -51,7 +41,6 @@ FIND_LIBRARY(LUA_LIBRARY_lua /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) # In an OS X framework, lualib is usually included as part of the framework @@ -61,15 +50,10 @@ IF(${LUA_LIBRARY_lua} MATCHES "framework") ELSE(${LUA_LIBRARY_lua} MATCHES "framework") FIND_LIBRARY(LUA_LIBRARY_lualib NAMES lualib50 lualib5.0 lualib5 lualib - PATHS + HINTS $ENV{LUALIB_DIR} $ENV{LUA_DIR} - NO_DEFAULT_PATH PATH_SUFFIXES lib64 lib - ) - - FIND_LIBRARY(LUA_LIBRARY_lualib - NAMES lualib50 lualib5.0 lualib5 lualib PATHS /usr/local /usr @@ -77,7 +61,6 @@ ELSE(${LUA_LIBRARY_lua} MATCHES "framework") /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) IF(LUA_LIBRARY_lualib AND LUA_LIBRARY_lua) # include the math library for Unix diff --git a/Modules/FindLua51.cmake b/Modules/FindLua51.cmake index 0a82e8c66..5f50ec2ca 100644 --- a/Modules/FindLua51.cmake +++ b/Modules/FindLua51.cmake @@ -1,7 +1,7 @@ # Locate Lua library # This module defines +# LUA51_FOUND, if false, do not try to link to Lua # LUA_LIBRARIES -# LUA_FOUND, if false, do not try to link to Lua # LUA_INCLUDE_DIR, where to find lua.h # # Note that the expected include convention is @@ -13,13 +13,9 @@ FIND_PATH(LUA_INCLUDE_DIR lua.h - PATHS + HINTS $ENV{LUA_DIR} - NO_DEFAULT_PATH PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include -) - -FIND_PATH(LUA_INCLUDE_DIR lua.h PATHS ~/Library/Frameworks /Library/Frameworks @@ -29,19 +25,13 @@ FIND_PATH(LUA_INCLUDE_DIR lua.h /opt/local # DarwinPorts /opt/csw # Blastwave /opt - PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include ) FIND_LIBRARY(LUA_LIBRARY NAMES lua51 lua5.1 lua - PATHS + HINTS $ENV{LUA_DIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(LUA_LIBRARY - NAMES lua51 lua5.1 lua + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -51,7 +41,6 @@ FIND_LIBRARY(LUA_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) IF(LUA_LIBRARY) @@ -68,7 +57,7 @@ ENDIF(LUA_LIBRARY) INCLUDE(FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if # all listed variables are TRUE -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua50 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR) MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index d568c94d5..03e95ef71 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -210,11 +210,11 @@ elseif (MPI_COMPILE_CMDLINE) 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} PATHS ${MPI_LINK_PATH}) + find_library(MPI_LIB ${LIB} HINTS ${MPI_LINK_PATH}) if (MPI_LIB) list(APPEND MPI_LIBRARIES ${MPI_LIB}) else (MPI_LIB) - status(ERROR "Unable to find MPI library ${LIB}") + message(SEND_ERROR "Unable to find MPI library ${LIB}") endif (MPI_LIB) endforeach(LIB) set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI detection" FORCE) @@ -222,12 +222,13 @@ elseif (MPI_COMPILE_CMDLINE) # Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and # MPI_EXTRA_LIBRARY. list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) - if (MPI_NUMLIBS GREATER 0) + 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 GREATER 0) - set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND" CACHE STRING "MPI library to link against" FORCE) - endif (MPI_NUMLIBS GREATER 0) + 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) diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 17e6f367f..37619c22a 100755 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -21,7 +21,9 @@ IF(WIN32) # Same here, there are also: bcc50 and bcc51 directories SET(MATLAB_ROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.0;MATLABROOT]/extern/lib/win32/microsoft/bcc54") ELSE(${CMAKE_GENERATOR} MATCHES "Borland") - MESSAGE(FATAL_ERROR "Generator not compatible: ${CMAKE_GENERATOR}") + IF(MATLAB_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Generator not compatible: ${CMAKE_GENERATOR}") + ENDIF(MATLAB_FIND_REQUIRED) ENDIF(${CMAKE_GENERATOR} MATCHES "Borland") ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 7") ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6") diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake index 8d2933c5f..d9cb7c180 100755 --- a/Modules/FindOpenAL.cmake +++ b/Modules/FindOpenAL.cmake @@ -49,13 +49,9 @@ # CMAKE_INCLUDE_PATH to modify the search paths. FIND_PATH(OPENAL_INCLUDE_DIR al.h - PATHS + HINTS $ENV{OPENALDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include/AL include/OpenAL include -) - -FIND_PATH(OPENAL_INCLUDE_DIR al.h PATHS ~/Library/Frameworks /Library/Frameworks @@ -66,19 +62,13 @@ FIND_PATH(OPENAL_INCLUDE_DIR al.h /opt/csw # Blastwave /opt [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir] - PATH_SUFFIXES include/AL include/OpenAL include ) FIND_LIBRARY(OPENAL_LIBRARY NAMES OpenAL al openal OpenAL32 - PATHS + HINTS $ENV{OPENALDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 -) - -FIND_LIBRARY(OPENAL_LIBRARY - NAMES OpenAL al openal OpenAL32 + PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 PATHS ~/Library/Frameworks /Library/Frameworks @@ -89,7 +79,6 @@ FIND_LIBRARY(OPENAL_LIBRARY /opt/csw /opt [HKEY_LOCAL_MACHINE\\SOFTWARE\\Creative\ Labs\\OpenAL\ 1.1\ Software\ Development\ Kit\\1.00.0000;InstallDir] - PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 ) diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake index edea06af5..1c2648ab0 100644 --- a/Modules/FindOpenGL.cmake +++ b/Modules/FindOpenGL.cmake @@ -57,20 +57,20 @@ ELSE (WIN32) FIND_PATH(OPENGL_INCLUDE_DIR GL/gl.h /usr/share/doc/NVIDIA_GLX-1.0/include /usr/openwin/share/include - /opt/graphics/OpenGL/include + /opt/graphics/OpenGL/include /usr/X11R6/include ) FIND_PATH(OPENGL_xmesa_INCLUDE_DIR GL/xmesa.h /usr/share/doc/NVIDIA_GLX-1.0/include /usr/openwin/share/include - /opt/graphics/OpenGL/include + /opt/graphics/OpenGL/include /usr/X11R6/include ) FIND_LIBRARY(OPENGL_gl_LIBRARY NAMES GL MesaGL PATHS /opt/graphics/OpenGL/lib /usr/openwin/lib - /usr/shlib + /usr/shlib /usr/X11R6/lib ) # On Unix OpenGL most certainly always requires X11. @@ -94,7 +94,7 @@ ELSE (WIN32) PATHS ${OPENGL_gl_LIBRARY} /opt/graphics/OpenGL/lib /usr/openwin/lib - /usr/shlib + /usr/shlib /usr/X11R6/lib ) ENDIF(APPLE) diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 0172df83c..bc62286e5 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -1,70 +1,71 @@ -# - Try to find the OpenSSL encryption library -# Once done this will define -# -# OPENSSL_FOUND - system has the OpenSSL library -# OPENSSL_INCLUDE_DIR - the OpenSSL include directory -# OPENSSL_LIBRARIES - The libraries needed to use OpenSSL - -# Copyright (c) 2006, Alexander Neundorf, -# -# Redistribution and use is allowed according to the terms of the BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - - -IF(OPENSSL_LIBRARIES) - SET(OpenSSL_FIND_QUIETLY TRUE) -ENDIF(OPENSSL_LIBRARIES) - -IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) - SET(LIB_FOUND 1) -ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) - -FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h ) - -IF(WIN32 AND MSVC) - # /MD and /MDd are the standard values - if somone wants to use - # others, the libnames have to change here too - # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b - - FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssl ssleay32) - FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssl ssleay32) - - IF(MSVC_IDE) - IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) - SET(OPENSSL_LIBRARIES optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG}) - ELSE(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) - MESSAGE(FATAL_ERROR "Could not find the debug and release version of openssl") - ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) - ELSE(MSVC_IDE) - STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) - IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) - SET(OPENSSL_LIBRARIES ${SSL_EAY_DEBUG}) - ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) - SET(OPENSSL_LIBRARIES ${SSL_EAY_RELEASE}) - ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) - ENDIF(MSVC_IDE) - MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE) -ELSE(WIN32 AND MSVC) - - FIND_LIBRARY(OPENSSL_LIBRARIES NAMES ssl ssleay32 ssleay32MD ) - -ENDIF(WIN32 AND MSVC) - -IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES) - SET(OPENSSL_FOUND TRUE) -ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES) - SET(OPENSSL_FOUND FALSE) -ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES) - -IF (OPENSSL_FOUND) - IF (NOT OpenSSL_FIND_QUIETLY) - MESSAGE(STATUS "Found OpenSSL: ${OPENSSL_LIBRARIES}") - ENDIF (NOT OpenSSL_FIND_QUIETLY) -ELSE (OPENSSL_FOUND) - IF (OpenSSL_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could NOT find OpenSSL") - ENDIF (OpenSSL_FIND_REQUIRED) -ENDIF (OPENSSL_FOUND) - -MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES) - +# - Try to find the OpenSSL encryption library +# Once done this will define +# +# OPENSSL_FOUND - system has the OpenSSL library +# OPENSSL_INCLUDE_DIR - the OpenSSL include directory +# OPENSSL_LIBRARIES - The libraries needed to use OpenSSL + +# Copyright (c) 2006, Alexander Neundorf, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +IF(OPENSSL_LIBRARIES) + SET(OpenSSL_FIND_QUIETLY TRUE) +ENDIF(OPENSSL_LIBRARIES) + +IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) + SET(LIB_FOUND 1) +ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) + +FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h ) + +IF(WIN32 AND MSVC) + # /MD and /MDd are the standard values - if somone wants to use + # others, the libnames have to change here too + # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b + + FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssl ssleay32) + FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssl ssleay32) + + IF(MSVC_IDE) + IF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) + SET(OPENSSL_LIBRARIES optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG}) + ELSE(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) + SET(OPENSSL_LIBRARIES NOTFOUND) + MESSAGE(STATUS "Could not find the debug and release version of openssl") + ENDIF(SSL_EAY_DEBUG AND SSL_EAY_RELEASE) + ELSE(MSVC_IDE) + STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) + IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) + SET(OPENSSL_LIBRARIES ${SSL_EAY_DEBUG}) + ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) + SET(OPENSSL_LIBRARIES ${SSL_EAY_RELEASE}) + ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) + ENDIF(MSVC_IDE) + MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE) +ELSE(WIN32 AND MSVC) + + FIND_LIBRARY(OPENSSL_LIBRARIES NAMES ssl ssleay32 ssleay32MD ) + +ENDIF(WIN32 AND MSVC) + +IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES) + SET(OPENSSL_FOUND TRUE) +ELSE(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES) + SET(OPENSSL_FOUND FALSE) +ENDIF (OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES) + +IF (OPENSSL_FOUND) + IF (NOT OpenSSL_FIND_QUIETLY) + MESSAGE(STATUS "Found OpenSSL: ${OPENSSL_LIBRARIES}") + ENDIF (NOT OpenSSL_FIND_QUIETLY) +ELSE (OPENSSL_FOUND) + IF (OpenSSL_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could NOT find OpenSSL") + ENDIF (OpenSSL_FIND_REQUIRED) +ENDIF (OPENSSL_FOUND) + +MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES) + diff --git a/Modules/FindOpenThreads.cmake b/Modules/FindOpenThreads.cmake index fc5cd3659..75fdbdd36 100644 --- a/Modules/FindOpenThreads.cmake +++ b/Modules/FindOpenThreads.cmake @@ -39,7 +39,7 @@ # Explicit -DVAR=value arguments should still be able to override everything. FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread - PATHS + HINTS $ENV{OPENTHREADS_INCLUDE_DIR} $ENV{OPENTHREADS_DIR}/include $ENV{OPENTHREADS_DIR} @@ -48,12 +48,7 @@ FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread $ENV{OSG_DIR} $ENV{OSGDIR}/include $ENV{OSGDIR} - NO_DEFAULT_PATH -) - - - -FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread + PATHS ~/Library/Frameworks /Library/Frameworks /usr/local/include @@ -69,7 +64,7 @@ FIND_PATH(OPENTHREADS_INCLUDE_DIR OpenThreads/Thread FIND_LIBRARY(OPENTHREADS_LIBRARY NAMES OpenThreads OpenThreadsWin32 - PATHS + HINTS $ENV{OPENTHREADS_LIBRARY_DIR} $ENV{OPENTHREADS_DIR}/lib64 $ENV{OPENTHREADS_DIR}/lib @@ -81,13 +76,6 @@ FIND_LIBRARY(OPENTHREADS_LIBRARY $ENV{OSGDIR}/lib64 $ENV{OSGDIR}/lib $ENV{OSGDIR} - NO_DEFAULT_PATH -) - - - -FIND_LIBRARY(OPENTHREADS_LIBRARY - NAMES OpenThreads OpenThreadsWin32 PATHS ~/Library/Frameworks /Library/Frameworks @@ -110,7 +98,7 @@ FIND_LIBRARY(OPENTHREADS_LIBRARY FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG NAMES OpenThreadsd OpenThreadsWin32d - PATHS + HINTS $ENV{OPENTHREADS_DEBUG_LIBRARY_DIR} $ENV{OPENTHREADS_LIBRARY_DIR} $ENV{OPENTHREADS_DIR}/lib64 @@ -123,13 +111,6 @@ FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG $ENV{OSGDIR}/lib64 $ENV{OSGDIR}/lib $ENV{OSGDIR} - NO_DEFAULT_PATH -) - - - -FIND_LIBRARY(OPENTHREADS_LIBRARY_DEBUG - NAMES OpenThreadsd OpenThreadsWin32d PATHS /usr/local/lib64 /usr/local/lib diff --git a/Modules/FindPHP4.cmake b/Modules/FindPHP4.cmake index d4ccd1f00..185d6287d 100644 --- a/Modules/FindPHP4.cmake +++ b/Modules/FindPHP4.cmake @@ -68,3 +68,5 @@ IF(APPLE) ENDFOREACH(symbol) ENDIF(APPLE) +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PHP4 DEFAULT_MSG PHP4_EXECUTABLE PHP4_INCLUDE_PATH) diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index fa1bcd3ef..d64b074bb 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -16,7 +16,7 @@ IF(ZLIB_FOUND) /usr/local/include/libpng # OpenBSD ) - SET(PNG_NAMES ${PNG_NAMES} png libpng) + SET(PNG_NAMES ${PNG_NAMES} png libpng png12 libpng12) FIND_LIBRARY(PNG_LIBRARY NAMES ${PNG_NAMES} ) IF (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR) diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 091954f0e..47cf017ae 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -28,10 +28,14 @@ FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 ) STRING(TOUPPER ${_NAME} _NAME_UPPER) + # collect all variables which were not found, so they can be printed, so the + # user knows better what went wrong (#6375) + SET(MISSING_VARS "") SET(DETAILS "") SET(${_NAME_UPPER}_FOUND TRUE) IF(NOT ${_VAR1}) SET(${_NAME_UPPER}_FOUND FALSE) + SET(MISSING_VARS " ${_VAR1}") ELSE(NOT ${_VAR1}) SET(DETAILS "${DETAILS}[${${_VAR1}}]") ENDIF(NOT ${_VAR1}) @@ -40,6 +44,7 @@ FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 ) FOREACH(_CURRENT_VAR ${ARGN}) IF(NOT ${_CURRENT_VAR}) SET(${_NAME_UPPER}_FOUND FALSE) + SET(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}") ELSE(NOT ${_CURRENT_VAR}) SET(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]") ENDIF(NOT ${_CURRENT_VAR}) @@ -49,10 +54,10 @@ FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 ) FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_VAR1}}" "${DETAILS}") ELSE (${_NAME_UPPER}_FOUND) IF (${_NAME}_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE}") + MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE} (missing: ${MISSING_VARS})") ELSE (${_NAME}_FIND_REQUIRED) IF (NOT ${_NAME}_FIND_QUIETLY) - MESSAGE(STATUS "${_FAIL_MESSAGE}") + MESSAGE(STATUS "${_FAIL_MESSAGE} (missing: ${MISSING_VARS})") ENDIF (NOT ${_NAME}_FIND_QUIETLY) ENDIF (${_NAME}_FIND_REQUIRED) ENDIF (${_NAME_UPPER}_FOUND) diff --git a/Modules/FindPhysFS.cmake b/Modules/FindPhysFS.cmake index 93e3b9914..443ce3831 100755 --- a/Modules/FindPhysFS.cmake +++ b/Modules/FindPhysFS.cmake @@ -11,13 +11,9 @@ # Created by Eric Wing. FIND_PATH(PHYSFS_INCLUDE_DIR physfs.h - PATHS + HINTS $ENV{PHYSFSDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES include -) - -FIND_PATH(PHYSFS_INCLUDE_DIR physfs.h + PATH_SUFFIXES include/physfs include PATHS ~/Library/Frameworks /Library/Frameworks @@ -27,19 +23,13 @@ FIND_PATH(PHYSFS_INCLUDE_DIR physfs.h /opt/local # DarwinPorts /opt/csw # Blastwave /opt - PATH_SUFFIXES include/physfs include ) FIND_LIBRARY(PHYSFS_LIBRARY NAMES physfs - PATHS + HINTS $ENV{PHYSFSDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(PHYSFS_LIBRARY - NAMES physfs + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -49,7 +39,6 @@ FIND_LIBRARY(PHYSFS_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(PHYSFS_FOUND "NO") diff --git a/Modules/FindProducer.cmake b/Modules/FindProducer.cmake index 576eae240..db51d3a94 100644 --- a/Modules/FindProducer.cmake +++ b/Modules/FindProducer.cmake @@ -30,15 +30,11 @@ # Try the user's environment request before anything else. FIND_PATH(PRODUCER_INCLUDE_DIR Producer/CameraGroup - PATHS + HINTS $ENV{PRODUCER_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(PRODUCER_INCLUDE_DIR Producer/CameraGroup PATHS ~/Library/Frameworks /Library/Frameworks @@ -54,16 +50,11 @@ FIND_PATH(PRODUCER_INCLUDE_DIR Producer/CameraGroup FIND_LIBRARY(PRODUCER_LIBRARY NAMES Producer - PATHS + HINTS $ENV{PRODUCER_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(PRODUCER_LIBRARY - NAMES Producer + PATH_SUFFIXES lib64 lib PATHS /usr/local /usr @@ -71,7 +62,6 @@ FIND_LIBRARY(PRODUCER_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(PRODUCER_FOUND "NO") diff --git a/Modules/FindQt3.cmake b/Modules/FindQt3.cmake index 14c0ac4e3..dcfaad30c 100755 --- a/Modules/FindQt3.cmake +++ b/Modules/FindQt3.cmake @@ -20,6 +20,19 @@ # QT_WRAP_CPP, set true if QT_MOC_EXECUTABLE is found # QT_WRAP_UI set true if QT_UIC_EXECUTABLE is found +# If Qt4 has already been found, fail. +IF(QT4_FOUND) + IF(Qt3_FIND_REQUIRED) + MESSAGE( FATAL_ERROR "Qt3 and Qt4 cannot be used together in one project.") + ELSE(Qt3_FIND_REQUIRED) + IF(NOT Qt3_FIND_QUIETLY) + MESSAGE( STATUS "Qt3 and Qt4 cannot be used together in one project.") + ENDIF(NOT Qt3_FIND_QUIETLY) + RETURN() + ENDIF(Qt3_FIND_REQUIRED) +ENDIF(QT4_FOUND) + + FILE(GLOB GLOB_PATHS_BIN /usr/lib/qt-3*/bin/) FIND_PATH(QT_INCLUDE_DIR qt.h "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt" @@ -34,13 +47,12 @@ FIND_PATH(QT_INCLUDE_DIR qt.h /usr/share/qt3/include C:/Progra~1/qt/include /usr/include/qt3 - /usr/X11R6/include ) # if qglobal.h is not in the qt_include_dir then set # QT_INCLUDE_DIR to NOTFOUND IF(NOT EXISTS ${QT_INCLUDE_DIR}/qglobal.h) - SET(QT_INCLUDE_DIR QT_INCLUDE_DIR-NOTFOUND CACHE PATH "path to qt3 include directory" FORCE) + SET(QT_INCLUDE_DIR QT_INCLUDE_DIR-NOTFOUND CACHE PATH "path to Qt3 include directory" FORCE) ENDIF(NOT EXISTS ${QT_INCLUDE_DIR}/qglobal.h) IF(QT_INCLUDE_DIR) @@ -52,7 +64,6 @@ IF(QT_INCLUDE_DIR) # Under windows the qt library (MSVC) has the format qt-mtXYZ where XYZ is the # version X.Y.Z, so we need to remove the dots from version STRING(REGEX REPLACE "\\." "" qt_version_str_lib "${qt_version_str}") -ELSE(QT_INCLUDE_DIR) ENDIF(QT_INCLUDE_DIR) FILE(GLOB GLOB_PATHS_LIB /usr/lib/qt-3*/lib/) @@ -73,7 +84,6 @@ IF (QT_MT_REQUIRED) /usr/lib/qt3/lib64 /usr/share/qt3/lib C:/Progra~1/qt/lib - /usr/X11R6/lib ) ELSE (QT_MT_REQUIRED) @@ -94,14 +104,9 @@ ELSE (QT_MT_REQUIRED) /usr/lib/qt3/lib64 /usr/share/qt3/lib C:/Progra~1/qt/lib - /usr/X11R6/lib ) ENDIF (QT_MT_REQUIRED) -IF(QT_QT_LIBRARY) -ELSE(QT_QT_LIBRARY) -ENDIF(QT_QT_LIBRARY) - FIND_LIBRARY(QT_QASSISTANTCLIENT_LIBRARY NAMES qassistantclient @@ -116,19 +121,13 @@ FIND_LIBRARY(QT_QASSISTANTCLIENT_LIBRARY /usr/lib/qt3/lib64 /usr/share/qt3/lib C:/Progra~1/qt/lib - /usr/X11R6/lib ) # qt 3 should prefer QTDIR over the PATH FIND_PROGRAM(QT_MOC_EXECUTABLE NAMES moc moc-qt3 - PATHS + HINTS $ENV{QTDIR}/bin - NO_DEFAULT_PATH -) - -FIND_PROGRAM(QT_MOC_EXECUTABLE - NAMES moc moc-qt3 PATHS "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt" @@ -145,20 +144,16 @@ FIND_PROGRAM(QT_MOC_EXECUTABLE IF(QT_MOC_EXECUTABLE) SET ( QT_WRAP_CPP "YES") -ELSE(QT_MOC_EXECUTABLE) ENDIF(QT_MOC_EXECUTABLE) # qt 3 should prefer QTDIR over the PATH FIND_PROGRAM(QT_UIC_EXECUTABLE uic - PATHS + HINTS $ENV{QTDIR}/bin - NO_DEFAULT_PATH -) -FIND_PROGRAM(QT_UIC_EXECUTABLE uic + PATHS "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.1;InstallDir]/include/Qt" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.2.0;InstallDir]/include/Qt" "[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\3.1.0;InstallDir]/include/Qt" - $ENV{QTDIR}/bin ${GLOB_PATHS_BIN} /usr/local/qt/bin /usr/lib/qt/bin @@ -170,7 +165,6 @@ FIND_PROGRAM(QT_UIC_EXECUTABLE uic IF(QT_UIC_EXECUTABLE) SET ( QT_WRAP_UI "YES") -ELSE(QT_UIC_EXECUTABLE) ENDIF(QT_UIC_EXECUTABLE) IF (WIN32) @@ -194,7 +188,7 @@ IF (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. \"3.1.5\"") + error_message( "Invalid Qt version string given: \"${QT_MIN_VERSION}\", expected e.g. \"3.1.5\"") ENDIF (NOT req_qt_major_vers) STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers "${QT_MIN_VERSION}") @@ -202,21 +196,28 @@ IF (QT_MIN_VERSION) STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers "${QT_MIN_VERSION}") # req = "6.5.4", qt = "3.2.1" + MACRO(error_message msg) + IF(QT3_REQUIRED) + MESSAGE( FATAL_ERROR ${msg}) + ELSE(QT3_REQUIRED) + MESSAGE( STATUS ${msg}) + ENDIF(QT3_REQUIRED) + ENDMACRO(error_message) IF (req_qt_major_vers GREATER qt_major_vers) # (6 > 3) ? - MESSAGE( FATAL_ERROR "Qt major version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes + ERROR_MESSAGE( "Qt major version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes ELSE (req_qt_major_vers GREATER qt_major_vers) # no IF (req_qt_major_vers LESS qt_major_vers) # (6 < 3) ? SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes ELSE (req_qt_major_vers LESS qt_major_vers) # ( 6==3) ? IF (req_qt_minor_vers GREATER qt_minor_vers) # (5>2) ? - MESSAGE( FATAL_ERROR "Qt minor version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes + ERROR_MESSAGE( "Qt minor version not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes ELSE (req_qt_minor_vers GREATER qt_minor_vers) # no IF (req_qt_minor_vers LESS qt_minor_vers) # (5<2) ? SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes ELSE (req_qt_minor_vers LESS qt_minor_vers) # (5==2) IF (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ? - MESSAGE( FATAL_ERROR "Qt patch level not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes + ERROR_MESSAGE( "Qt patch level not matched (required: ${QT_MIN_VERSION}, found: ${qt_version_str})") # yes ELSE (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ? SET( QT_VERSION_BIG_ENOUGH "YES" ) # yes ENDIF (req_qt_patch_vers GREATER qt_patch_vers) # (4>1) ? @@ -227,11 +228,9 @@ IF (QT_MIN_VERSION) ENDIF (QT_MIN_VERSION) # if the include a library are found then we have it -IF(QT_INCLUDE_DIR) - IF(QT_QT_LIBRARY) - SET( QT_FOUND "YES" ) - ENDIF(QT_QT_LIBRARY) -ENDIF(QT_INCLUDE_DIR) +IF(QT_INCLUDE_DIR AND QT_QT_LIBRARY) + SET( QT_FOUND "YES" ) +ENDIF(QT_INCLUDE_DIR AND QT_QT_LIBRARY) IF(QT_FOUND) SET( QT_LIBRARIES ${QT_LIBRARIES} ${QT_QT_LIBRARY} ) @@ -294,18 +293,14 @@ IF("${QTVERSION_MOC}" MATCHES ".* 3..*") ENDIF("${QTVERSION_MOC}" MATCHES ".* 3..*") SET(QT_WRAP_CPP FALSE) -IF (QT_MOC_EXECUTABLE) - IF(_QT_MOC_VERSION_3) - SET ( QT_WRAP_CPP TRUE) - ENDIF(_QT_MOC_VERSION_3) -ENDIF (QT_MOC_EXECUTABLE) +IF (QT_MOC_EXECUTABLE AND _QT_MOC_VERSION_3) + SET ( QT_WRAP_CPP TRUE) +ENDIF (QT_MOC_EXECUTABLE AND _QT_MOC_VERSION_3) SET(QT_WRAP_UI FALSE) -IF (QT_UIC_EXECUTABLE) - IF(_QT_UIC_VERSION_3) - SET ( QT_WRAP_UI TRUE) - ENDIF(_QT_UIC_VERSION_3) -ENDIF (QT_UIC_EXECUTABLE) +IF (QT_UIC_EXECUTABLE AND _QT_UIC_VERSION_3) + SET ( QT_WRAP_UI TRUE) +ENDIF (QT_UIC_EXECUTABLE AND _QT_UIC_VERSION_3) MARK_AS_ADVANCED( QT_INCLUDE_DIR diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index ee1b2928b..8280fdf4e 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -48,8 +48,9 @@ # # macro QT4_WRAP_CPP(outfiles inputfile ... OPTIONS ...) # create moc code from a list of files containing Qt class with -# the Q_OBJECT declaration. Options may be given to moc, such as those found -# when executing "moc -help" +# the Q_OBJECT declaration. Per-direcotry preprocessor definitions +# are also added. Options may be given to moc, such as those found +# when executing "moc -help". # # macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...) # create code from a list of Qt designer ui files. @@ -102,11 +103,14 @@ # interface file is constructed from the basename of the header with # the suffix .xml appended. # -# macro QT4_CREATE_TRANSLATION( qm_files sources ... ts_files ... ) +# macro QT4_CREATE_TRANSLATION( qm_files directories ... sources ... +# ts_files ... OPTIONS ...) # out: qm_files -# in: sources ts_files +# in: directories sources ts_files +# options: flags to pass to lupdate, such as -extensions to specify +# extensions for a directory scan. # generates commands to create .ts (vie lupdate) and .qm -# (via lrelease) - files from sources. The ts files are +# (via lrelease) - files from directories and/or sources. The ts files are # created and/or updated in the source tree (unless given with full paths). # The qm files are generated in the build tree. # Updating the translations can be done by adding the qm_files @@ -256,6 +260,19 @@ # (They make no sense in Qt4) # QT_QT_LIBRARY Qt-Library is now split +# If Qt3 has already been found, fail. +IF(QT_QT_LIBRARY) + IF(Qt4_FIND_REQUIRED) + MESSAGE( FATAL_ERROR "Qt3 and Qt4 cannot be used together in one project.") + ELSE(Qt4_FIND_REQUIRED) + IF(NOT Qt4_FIND_QUIETLY) + MESSAGE( STATUS "Qt3 and Qt4 cannot be used together in one project.") + ENDIF(NOT Qt4_FIND_QUIETLY) + RETURN() + ENDIF(Qt4_FIND_REQUIRED) +ENDIF(QT_QT_LIBRARY) + + INCLUDE(CheckSymbolExists) INCLUDE(MacroAddFileDependencies) @@ -267,6 +284,7 @@ SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE) # macro for asking qmake to process pro files MACRO(QT_QUERY_QMAKE outvar invar) + IF(QT_QMAKE_EXECUTABLE) FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmpQmake/tmp.pro "message(CMAKE_MESSAGE<$$${invar}>)") @@ -289,6 +307,7 @@ MACRO(QT_QUERY_QMAKE outvar invar) STRING(REGEX REPLACE ".*CMAKE_MESSAGE<([^>]*).*" "\\1" ${outvar} "${_qmake_query_output}") ENDIF(_qmake_result) + ENDIF(QT_QMAKE_EXECUTABLE) ENDMACRO(QT_QUERY_QMAKE) GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME) @@ -455,6 +474,7 @@ IF (QT4_QMAKE_FOUND) ######################################## FIND_PATH(QT_QTCORE_INCLUDE_DIR QtGlobal + PATHS ${QT_HEADERS_DIR}/QtCore ${QT_LIBRARY_DIR}/QtCore.framework/Headers NO_DEFAULT_PATH @@ -471,9 +491,9 @@ IF (QT4_QMAKE_FOUND) ENDIF( QT_QTCORE_INCLUDE_DIR AND NOT QT_INCLUDE_DIR) IF( NOT QT_INCLUDE_DIR) - IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED) + IF(Qt4_FIND_REQUIRED) MESSAGE( FATAL_ERROR "Could NOT find QtGlobal header") - ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED) + ENDIF(Qt4_FIND_REQUIRED) ENDIF( NOT QT_INCLUDE_DIR) ############################################# @@ -509,10 +529,6 @@ IF (QT4_QMAKE_FOUND) # ############################################# - IF (QT_USE_FRAMEWORKS) - SET(QT_DEFINITIONS ${QT_DEFINITIONS} -F${QT_LIBRARY_DIR} -L${QT_LIBRARY_DIR} ) - ENDIF (QT_USE_FRAMEWORKS) - # Set QT_QT3SUPPORT_INCLUDE_DIR FIND_PATH(QT_QT3SUPPORT_INCLUDE_DIR Qt3Support PATHS @@ -701,11 +717,11 @@ IF (QT4_QMAKE_FOUND) # Set QT_QT3SUPPORT_LIBRARY FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_RELEASE NAMES Qt3Support Qt3Support4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Support_debug Qt3Supportd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QT3SUPPORT_LIBRARY_DEBUG NAMES Qt3Support_debug Qt3Supportd Qt3Supportd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTGUI_LIBRARY FIND_LIBRARY(QT_QTGUI_LIBRARY_RELEASE NAMES QtGui QtGui4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGui_debug QtGuid4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTGUI_LIBRARY_DEBUG NAMES QtGui_debug QtGuid QtGuid4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTMOTIF_LIBRARY IF(Q_WS_X11) @@ -715,7 +731,7 @@ IF (QT4_QMAKE_FOUND) # Set QT_QTNETWORK_LIBRARY FIND_LIBRARY(QT_QTNETWORK_LIBRARY_RELEASE NAMES QtNetwork QtNetwork4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetwork_debug QtNetworkd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTNETWORK_LIBRARY_DEBUG NAMES QtNetwork_debug QtNetworkd QtNetworkd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTNSPLUGIN_LIBRARY FIND_LIBRARY(QT_QTNSPLUGIN_LIBRARY_RELEASE NAMES QtNsPlugin PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) @@ -723,19 +739,19 @@ IF (QT4_QMAKE_FOUND) # Set QT_QTOPENGL_LIBRARY FIND_LIBRARY(QT_QTOPENGL_LIBRARY_RELEASE NAMES QtOpenGL QtOpenGL4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGL_debug QtOpenGLd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTOPENGL_LIBRARY_DEBUG NAMES QtOpenGL_debug QtOpenGLd QtOpenGLd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTSQL_LIBRARY FIND_LIBRARY(QT_QTSQL_LIBRARY_RELEASE NAMES QtSql QtSql4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSql_debug QtSqld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTSQL_LIBRARY_DEBUG NAMES QtSql_debug QtSqld QtSqld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTXML_LIBRARY FIND_LIBRARY(QT_QTXML_LIBRARY_RELEASE NAMES QtXml QtXml4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXml_debug QtXmld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTXML_LIBRARY_DEBUG NAMES QtXml_debug QtXmld QtXmld4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTSVG_LIBRARY FIND_LIBRARY(QT_QTSVG_LIBRARY_RELEASE NAMES QtSvg QtSvg4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTSVG_LIBRARY_DEBUG NAMES QtSvg_debug QtSvgd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTSVG_LIBRARY_DEBUG NAMES QtSvg_debug QtSvgd QtSvgd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTUITOOLS_LIBRARY FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools QtUiTools4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) @@ -747,22 +763,30 @@ IF (QT4_QMAKE_FOUND) # Set QT_QTTEST_LIBRARY FIND_LIBRARY(QT_QTTEST_LIBRARY_RELEASE NAMES QtTest QtTest4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTTEST_LIBRARY_DEBUG NAMES QtTest_debug QtTest_debug4 QtTestd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTTEST_LIBRARY_DEBUG NAMES QtTest_debug QtTestd QtTestd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTDBUS_LIBRARY # This was introduced with Qt 4.2, where also the naming scheme for debug libs was changed # So does any of the debug lib names listed here actually exist ? FIND_LIBRARY(QT_QTDBUS_LIBRARY_RELEASE NAMES QtDBus QtDBus4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTDBUS_LIBRARY_DEBUG NAMES QtDBus_debug QtDBus_debug4 QtDBusd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTDBUS_LIBRARY_DEBUG NAMES QtDBus_debug QtDBusd QtDBusd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTSCRIPT_LIBRARY FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_RELEASE NAMES QtScript QtScript4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_DEBUG NAMES QtScript_debug QtScriptd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTSCRIPT_LIBRARY_DEBUG NAMES QtScript_debug QtScriptd QtScriptd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) IF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE ) - IF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED) + + # try dropping a hint if trying to use Visual Studio with Qt built by mingw + IF(QT_LIBRARY_DIR AND MSVC) + IF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a) + MESSAGE( FATAL_ERROR "It appears you're trying to use Visual Studio with Qt built by mingw") + ENDIF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a) + ENDIF(QT_LIBRARY_DIR AND MSVC) + + IF(Qt4_FIND_REQUIRED) MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.") - ENDIF( NOT Qt4_FIND_QUIETLY AND Qt4_FIND_REQUIRED) + ENDIF(Qt4_FIND_REQUIRED) ENDIF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE ) # Set QT_QTASSISTANT_LIBRARY @@ -771,11 +795,11 @@ IF (QT4_QMAKE_FOUND) # Set QT_QTDESIGNER_LIBRARY FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_RELEASE NAMES QtDesigner QtDesigner4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG NAMES QtDesigner_debug QtDesignerd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTDESIGNER_LIBRARY_DEBUG NAMES QtDesigner_debug QtDesignerd QtDesignerd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTDESIGNERCOMPONENTS_LIBRARY FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents QtDesignerComponents4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NAMES QtDesignerComponents_debug QtDesignerComponentsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NAMES QtDesignerComponents_debug QtDesignerComponentsd QtDesignerComponentsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTMAIN_LIBRARY IF(WIN32) @@ -787,25 +811,29 @@ IF (QT4_QMAKE_FOUND) # Set QT_QTASSISTANTCLIENT_LIBRARY FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient QtAssistantClient4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NAMES QtAssistantClient_debug QtAssistantClientd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NAMES QtAssistantClient_debug QtAssistantClientd QtAssistantClientd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTHELP_LIBRARY FIND_LIBRARY(QT_QTHELP_LIBRARY_RELEASE NAMES QtHelp QtHelp4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTHELP_LIBRARY_DEBUG NAMES QtHelp_debug QtHelpd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTHELP_LIBRARY_DEBUG NAMES QtHelp_debug QtHelpd QtHelpd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene QtCLucene4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_DEBUG NAMES QtCLucene_debug QtCLucened4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_DEBUG NAMES QtCLucene_debug QtCLucened QtCLucened4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + # QtCLucene not with other frameworks with binary installation (in /usr/lib) + IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE) + FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene PATHS ${QT_LIBRARY_DIR}) + ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE) # Set QT_QTWEBKIT_LIBRARY FIND_LIBRARY(QT_QTWEBKIT_LIBRARY_RELEASE NAMES QtWebKit QtWebKit4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTWEBKIT_LIBRARY_DEBUG NAMES QtWebKit_debug QtWebKitd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTWEBKIT_LIBRARY_DEBUG NAMES QtWebKit_debug QtWebKitd QtWebKitd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTXMLPATTERNS_LIBRARY FIND_LIBRARY(QT_QTXMLPATTERNS_LIBRARY_RELEASE NAMES QtXmlPatterns QtXmlPatterns4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTXMLPATTERNS_LIBRARY_DEBUG NAMES QtXmlPatterns_debug QtXmlPatternsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTXMLPATTERNS_LIBRARY_DEBUG NAMES QtXmlPatterns_debug QtXmlPatternsd QtXmlPatternsd4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_PHONON_LIBRARY FIND_LIBRARY(QT_PHONON_LIBRARY_RELEASE NAMES phonon phonon4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_PHONON_LIBRARY_DEBUG NAMES phonon_debug phonond4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_PHONON_LIBRARY_DEBUG NAMES phonon_debug phonond phonond4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) ############################################ # @@ -1006,24 +1034,34 @@ IF (QT4_QMAKE_FOUND) FILE(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile}) ENDIF(CMAKE_CURRENT_BINARY_DIR MATCHES "${_checkinfile}") SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}") + STRING(REPLACE ".." "__" _outfile ${_outfile}) GET_FILENAME_COMPONENT(outpath ${_outfile} PATH) GET_FILENAME_COMPONENT(_outfile ${_outfile} NAME_WE) FILE(MAKE_DIRECTORY ${outpath}) SET(${outfile} ${outpath}/${prefix}${_outfile}.${ext}) ENDMACRO (QT4_MAKE_OUTPUT_FILE ) - MACRO (QT4_GET_MOC_INC_DIRS _moc_INC_DIRS) - SET(${_moc_INC_DIRS}) + MACRO (QT4_GET_MOC_FLAGS _moc_flags) + SET(${_moc_flags}) GET_DIRECTORY_PROPERTY(_inc_DIRS INCLUDE_DIRECTORIES) FOREACH(_current ${_inc_DIRS}) - SET(${_moc_INC_DIRS} ${${_moc_INC_DIRS}} "-I" ${_current}) + SET(${_moc_flags} ${${_moc_flags}} "-I${_current}") ENDFOREACH(_current ${_inc_DIRS}) + + GET_DIRECTORY_PROPERTY(_defines COMPILE_DEFINITIONS) + FOREACH(_current ${_defines}) + SET(${_moc_flags} ${${_moc_flags}} "-D${_current}") + ENDFOREACH(_current ${_defines}) + + IF(Q_WS_WIN) + SET(${_moc_flags} ${${_moc_flags}} -DWIN32) + ENDIF(Q_WS_WIN) - ENDMACRO(QT4_GET_MOC_INC_DIRS) + ENDMACRO(QT4_GET_MOC_FLAGS) # helper macro to set up a moc rule - MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_includes moc_options) + MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options) # For Windows, create a parameters file to work around command line length limit IF (WIN32) # Pass the parameters in a file. Set the working directory to @@ -1037,7 +1075,7 @@ IF (QT4_QMAKE_FOUND) SET(_moc_working_dir WORKING_DIRECTORY ${_moc_outfile_dir}) ENDIF(_moc_outfile_dir) SET (_moc_parameters_file ${outfile}_parameters) - SET (_moc_parameters ${moc_includes} ${moc_options} -o "${outfile}" "${infile}") + 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") @@ -1050,16 +1088,16 @@ IF (QT4_QMAKE_FOUND) ELSE (WIN32) ADD_CUSTOM_COMMAND(OUTPUT ${outfile} COMMAND ${QT_MOC_EXECUTABLE} - ARGS ${moc_includes} ${moc_options} -o ${outfile} ${infile} + ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile} DEPENDS ${infile}) ENDIF (WIN32) ENDMACRO (QT4_CREATE_MOC_COMMAND) MACRO (QT4_GENERATE_MOC infile outfile ) - QT4_GET_MOC_INC_DIRS(moc_includes) + QT4_GET_MOC_FLAGS(moc_flags) GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE) - QT4_CREATE_MOC_COMMAND(${abs_infile} ${outfile} "${moc_includes}" "") + QT4_CREATE_MOC_COMMAND(${abs_infile} ${outfile} "${moc_flags}" "") SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file ENDMACRO (QT4_GENERATE_MOC) @@ -1068,13 +1106,13 @@ IF (QT4_QMAKE_FOUND) MACRO (QT4_WRAP_CPP outfiles ) # get include dirs - QT4_GET_MOC_INC_DIRS(moc_includes) + QT4_GET_MOC_FLAGS(moc_flags) QT4_EXTRACT_OPTIONS(moc_files moc_options ${ARGN}) FOREACH (it ${moc_files}) GET_FILENAME_COMPONENT(it ${it} ABSOLUTE) QT4_MAKE_OUTPUT_FILE(${it} moc_ cxx outfile) - QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_includes}" "${moc_options}") + QT4_CREATE_MOC_COMMAND(${it} ${outfile} "${moc_flags}" "${moc_options}") SET(${outfiles} ${${outfiles}} ${outfile}) ENDFOREACH(it) @@ -1218,7 +1256,7 @@ IF (QT4_QMAKE_FOUND) ENDMACRO(QT4_ADD_DBUS_ADAPTOR) MACRO(QT4_AUTOMOC) - QT4_GET_MOC_INC_DIRS(_moc_INCS) + QT4_GET_MOC_FLAGS(_moc_INCS) SET(_matching_FILES ) FOREACH (_current_FILE ${ARGN}) @@ -1255,9 +1293,12 @@ IF (QT4_QMAKE_FOUND) ENDMACRO(QT4_AUTOMOC) MACRO(QT4_CREATE_TRANSLATION _qm_files) + QT4_EXTRACT_OPTIONS(_lupdate_files _lupdate_options ${ARGN}) + MESSAGE("lupdate_files ${_lupdate_files}") + MESSAGE("lupdate_options ${_lupdate_options}") SET(_my_sources) SET(_my_tsfiles) - FOREACH (_file ${ARGN}) + FOREACH (_file ${_lupdate_files}) GET_FILENAME_COMPONENT(_ext ${_file} EXT) GET_FILENAME_COMPONENT(_abs_FILE ${_file} ABSOLUTE) IF(_ext MATCHES "ts") @@ -1269,7 +1310,7 @@ IF (QT4_QMAKE_FOUND) FOREACH(_ts_file ${_my_tsfiles}) ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file} COMMAND ${QT_LUPDATE_EXECUTABLE} - ARGS ${_my_sources} -ts ${_ts_file} + ARGS ${_lupdate_options} ${_my_sources} -ts ${_ts_file} DEPENDS ${_my_sources}) ENDFOREACH(_ts_file) QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles}) @@ -1301,18 +1342,22 @@ IF (QT4_QMAKE_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) + 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}" "[${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) + 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) + 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}) @@ -1323,9 +1368,9 @@ IF (QT4_QMAKE_FOUND) ####################################### IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents) - STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG ${_qconfig_FILE_contents}) - STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG ${_qconfig_FILE_contents}) - STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION ${_qconfig_FILE_contents}) + STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG "${_qconfig_FILE_contents}") + STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG "${_qconfig_FILE_contents}") + STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION "${_qconfig_FILE_contents}") ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") IF("${QT_EDITION}" MATCHES "DesktopLight") SET(QT_EDITION_DESKTOPLIGHT 1) @@ -1337,6 +1382,13 @@ IF (QT4_QMAKE_FOUND) # configuration/system dependent settings # ############################################### + + # find dependencies for some Qt modules + # when doing builds against a static Qt, they are required + # when doing builds against a shared Qt, they are sometimes not required + # even some Linux distros do not require these dependencies + # if a user needs the dependencies, and they couldn't be found, they can set + # the variables themselves. SET(QT_QTGUI_LIB_DEPENDENCIES "") SET(QT_QTCORE_LIB_DEPENDENCIES "") @@ -1359,8 +1411,10 @@ IF (QT4_QMAKE_FOUND) ## system png IF(QT_QCONFIG MATCHES "system-png") FIND_LIBRARY(QT_PNG_LIBRARY NAMES png) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY}) MARK_AS_ADVANCED(QT_PNG_LIBRARY) + IF(QT_PNG_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY}) + ENDIF(QT_PNG_LIBRARY) ENDIF(QT_QCONFIG MATCHES "system-png") # for X11, get X11 library directory @@ -1373,78 +1427,100 @@ IF (QT4_QMAKE_FOUND) # ask qmake where the x11 libs are FIND_LIBRARY(QT_X11_SM_LIBRARY NAMES SM PATHS ${QMAKE_LIBDIR_X11}) FIND_LIBRARY(QT_X11_ICE_LIBRARY NAMES ICE PATHS ${QMAKE_LIBDIR_X11}) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY}) MARK_AS_ADVANCED(QT_X11_SM_LIBRARY) MARK_AS_ADVANCED(QT_X11_ICE_LIBRARY) + IF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_X11_SM_LIBRARY} ${QT_X11_ICE_LIBRARY}) + ENDIF(QT_X11_SM_LIBRARY AND QT_X11_ICE_LIBRARY) ENDIF(QT_QCONFIG MATCHES "x11sm") ## Xi IF(QT_QCONFIG MATCHES "tablet") FIND_LIBRARY(QT_XI_LIBRARY NAMES Xi PATHS ${QMAKE_LIBDIR_X11}) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY}) MARK_AS_ADVANCED(QT_XI_LIBRARY) + IF(QT_XI_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XI_LIBRARY}) + ENDIF(QT_XI_LIBRARY) ENDIF(QT_QCONFIG MATCHES "tablet") ## Xrender IF(QT_QCONFIG MATCHES "xrender") FIND_LIBRARY(QT_XRENDER_LIBRARY NAMES Xrender PATHS ${QMAKE_LIBDIR_X11}) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY}) MARK_AS_ADVANCED(QT_XRENDER_LIBRARY) + IF(QT_XRENDER_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRENDER_LIBRARY}) + ENDIF(QT_XRENDER_LIBRARY) ENDIF(QT_QCONFIG MATCHES "xrender") ## Xrandr IF(QT_QCONFIG MATCHES "xrandr") FIND_LIBRARY(QT_XRANDR_LIBRARY NAMES Xrandr PATHS ${QMAKE_LIBDIR_X11}) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY}) MARK_AS_ADVANCED(QT_XRANDR_LIBRARY) + IF(QT_XRANDR_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XRANDR_LIBRARY}) + ENDIF(QT_XRANDR_LIBRARY) ENDIF(QT_QCONFIG MATCHES "xrandr") ## Xcursor IF(QT_QCONFIG MATCHES "xcursor") FIND_LIBRARY(QT_XCURSOR_LIBRARY NAMES Xcursor PATHS ${QMAKE_LIBDIR_X11}) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY}) MARK_AS_ADVANCED(QT_XCURSOR_LIBRARY) + IF(QT_XCURSOR_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XCURSOR_LIBRARY}) + ENDIF(QT_XCURSOR_LIBRARY) ENDIF(QT_QCONFIG MATCHES "xcursor") ## Xinerama IF(QT_QCONFIG MATCHES "xinerama") FIND_LIBRARY(QT_XINERAMA_LIBRARY NAMES Xinerama PATHS ${QMAKE_LIBDIR_X11}) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY}) MARK_AS_ADVANCED(QT_XINERAMA_LIBRARY) + IF(QT_XINERAMA_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XINERAMA_LIBRARY}) + ENDIF(QT_XINERAMA_LIBRARY) ENDIF(QT_QCONFIG MATCHES "xinerama") ## Xfixes IF(QT_QCONFIG MATCHES "xfixes") FIND_LIBRARY(QT_XFIXES_LIBRARY NAMES Xfixes PATHS ${QMAKE_LIBDIR_X11}) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XFIXES_LIBRARY}) MARK_AS_ADVANCED(QT_XFIXES_LIBRARY) + IF(QT_XFIXES_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_XFIXES_LIBRARY}) + ENDIF(QT_XFIXES_LIBRARY) ENDIF(QT_QCONFIG MATCHES "xfixes") ## system-freetype IF(QT_QCONFIG MATCHES "system-freetype") FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY}) MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY) + IF(QT_FREETYPE_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY}) + ENDIF(QT_FREETYPE_LIBRARY) ENDIF(QT_QCONFIG MATCHES "system-freetype") ## fontconfig IF(QT_QCONFIG MATCHES "fontconfig") FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY}) MARK_AS_ADVANCED(QT_FONTCONFIG_LIBRARY) + IF(QT_FONTCONFIG_LIBRARY) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FONTCONFIG_LIBRARY}) + ENDIF(QT_FONTCONFIG_LIBRARY) ENDIF(QT_QCONFIG MATCHES "fontconfig") ## system-zlib IF(QT_QCONFIG MATCHES "system-zlib") FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z) - SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY}) MARK_AS_ADVANCED(QT_ZLIB_LIBRARY) + IF(QT_ZLIB_LIBRARY) + SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY}) + ENDIF(QT_ZLIB_LIBRARY) ENDIF(QT_QCONFIG MATCHES "system-zlib") ## openssl IF(QT_QCONFIG MATCHES "openssl" AND NOT Q_WS_WIN) FIND_PACKAGE(OpenSSL) - SET(QT_QTNETWORK_LIB_DEPENDENCIES ${QT_QTNETWORK_LIB_DEPENDENCIES} ${OPENSSL_LIBRARIES}) + IF(OPENSSL_LIBRARIES) + SET(QT_QTNETWORK_LIB_DEPENDENCIES ${QT_QTNETWORK_LIB_DEPENDENCIES} ${OPENSSL_LIBRARIES}) + ENDIF(OPENSSL_LIBRARIES) ENDIF(QT_QCONFIG MATCHES "openssl" AND NOT Q_WS_WIN) ## qdbus @@ -1517,8 +1593,10 @@ IF (QT4_QMAKE_FOUND) SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) IF(QT_POSIX_TIMERS) FIND_LIBRARY(QT_RT_LIBRARY NAMES rt) - SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY}) MARK_AS_ADVANCED(QT_RT_LIBRARY) + IF(QT_RT_LIBRARY) + SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_RT_LIBRARY}) + ENDIF(QT_RT_LIBRARY) ENDIF(QT_POSIX_TIMERS) ENDIF(QT_QCONFIG MATCHES "clock-monotonic") @@ -1530,8 +1608,10 @@ IF (QT4_QMAKE_FOUND) STRING(REGEX REPLACE "-l" "" QT_X11_LIB "${QT_X11_LIB}") SET(QT_TMP_STR "QT_X11_${QT_X11_LIB}_LIBRARY") FIND_LIBRARY(${QT_TMP_STR} NAMES "${QT_X11_LIB}" PATHS ${QMAKE_LIBDIR_X11}) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}}) MARK_AS_ADVANCED(${QT_TMP_STR}) + IF(${QT_TMP_STR}) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${${QT_TMP_STR}}) + ENDIF(${QT_TMP_STR}) ENDFOREACH(QT_X11_LIB) QT_QUERY_QMAKE(QT_LIBS_THREAD "QMAKE_LIBS_THREAD") diff --git a/Modules/FindQuickTime.cmake b/Modules/FindQuickTime.cmake index 00bc3ec72..5a4a580a3 100644 --- a/Modules/FindQuickTime.cmake +++ b/Modules/FindQuickTime.cmake @@ -17,20 +17,15 @@ IF(APPLE) FIND_LIBRARY(QUICKTIME_LIBRARY QuickTime) ELSE(APPLE) FIND_PATH(QUICKTIME_INCLUDE_DIR QuickTime.h + HINTS $ENV{QUICKTIME_DIR}/include $ENV{QUICKTIME_DIR} - NO_DEFAULT_PATH ) - - FIND_PATH(QUICKTIME_INCLUDE_DIR QuickTime.h) - FIND_LIBRARY(QUICKTIME_LIBRARY QuickTime + HINTS $ENV{QUICKTIME_DIR}/lib $ENV{QUICKTIME_DIR} - NO_DEFAULT_PATH ) - - FIND_LIBRARY(QUICKTIME_LIBRARY QuickTime) ENDIF(APPLE) SET(QUICKTIME_FOUND "NO") diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake index 75b42cca0..ee880a649 100644 --- a/Modules/FindSDL.cmake +++ b/Modules/FindSDL.cmake @@ -53,13 +53,9 @@ # reasons because not all systems place things in SDL/ (see FreeBSD). FIND_PATH(SDL_INCLUDE_DIR SDL.h - PATHS + HINTS $ENV{SDLDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(SDL_INCLUDE_DIR SDL.h PATHS ~/Library/Frameworks /Library/Frameworks @@ -86,14 +82,9 @@ FIND_PATH(SDL_INCLUDE_DIR SDL.h # don't confuse it for the version number. FIND_LIBRARY(SDL_LIBRARY_TEMP NAMES SDL SDL-1.1 - PATHS + HINTS $ENV{SDLDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(SDL_LIBRARY_TEMP - NAMES SDL SDL-1.1 + PATH_SUFFIXES lib64 lib PATHS /usr/local /usr @@ -101,7 +92,6 @@ FIND_LIBRARY(SDL_LIBRARY_TEMP /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) #MESSAGE("SDL_LIBRARY_TEMP is ${SDL_LIBRARY_TEMP}") @@ -114,14 +104,9 @@ IF(NOT SDL_BUILDING_LIBRARY) # necessarily need it. FIND_LIBRARY(SDLMAIN_LIBRARY NAMES SDLmain SDLmain-1.1 - PATHS + HINTS $ENV{SDLDIR} - NO_DEFAULT_PATH PATH_SUFFIXES lib64 lib - ) - - FIND_LIBRARY(SDLMAIN_LIBRARY - NAMES SDLmain SDLmain-1.1 PATHS /usr/local /usr @@ -129,7 +114,6 @@ IF(NOT SDL_BUILDING_LIBRARY) /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) ENDIF(NOT ${SDL_INCLUDE_DIR} MATCHES ".framework") ENDIF(NOT SDL_BUILDING_LIBRARY) diff --git a/Modules/FindSDL_image.cmake b/Modules/FindSDL_image.cmake index e39b3cbc1..e2481e1ab 100755 --- a/Modules/FindSDL_image.cmake +++ b/Modules/FindSDL_image.cmake @@ -13,14 +13,10 @@ # additional Unix paths (FreeBSD, etc). FIND_PATH(SDLIMAGE_INCLUDE_DIR SDL_image.h - PATHS + HINTS $ENV{SDLIMAGEDIR} $ENV{SDLDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(SDLIMAGE_INCLUDE_DIR SDL_image.h PATHS ~/Library/Frameworks /Library/Frameworks @@ -44,15 +40,10 @@ FIND_PATH(SDLIMAGE_INCLUDE_DIR SDL_image.h FIND_LIBRARY(SDLIMAGE_LIBRARY NAMES SDL_image - PATHS + HINTS $ENV{SDLIMAGEDIR} $ENV{SDLDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(SDLIMAGE_LIBRARY - NAMES SDL_image + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -62,7 +53,6 @@ FIND_LIBRARY(SDLIMAGE_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(SDLIMAGE_FOUND "NO") diff --git a/Modules/FindSDL_mixer.cmake b/Modules/FindSDL_mixer.cmake index 59b0f5ace..720a17a79 100755 --- a/Modules/FindSDL_mixer.cmake +++ b/Modules/FindSDL_mixer.cmake @@ -13,14 +13,10 @@ # additional Unix paths (FreeBSD, etc). FIND_PATH(SDLMIXER_INCLUDE_DIR SDL_mixer.h - PATHS + HINTS $ENV{SDLMIXERDIR} $ENV{SDLDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(SDLMIXER_INCLUDE_DIR SDL_mixer.h PATHS ~/Library/Frameworks /Library/Frameworks @@ -44,15 +40,10 @@ FIND_PATH(SDLMIXER_INCLUDE_DIR SDL_mixer.h FIND_LIBRARY(SDLMIXER_LIBRARY NAMES SDL_mixer - PATHS + HINTS $ENV{SDLMIXERDIR} $ENV{SDLDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(SDLMIXER_LIBRARY - NAMES SDL_mixer + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -62,7 +53,6 @@ FIND_LIBRARY(SDLMIXER_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(SDLMIXER_FOUND "NO") diff --git a/Modules/FindSDL_net.cmake b/Modules/FindSDL_net.cmake index 8d0ce8aed..6de1946fa 100755 --- a/Modules/FindSDL_net.cmake +++ b/Modules/FindSDL_net.cmake @@ -14,14 +14,10 @@ FIND_PATH(SDLNET_INCLUDE_DIR SDL_net.h - PATHS + HINTS $ENV{SDLNETDIR} $ENV{SDLDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(SDLNET_INCLUDE_DIR SDL_net.h PATHS ~/Library/Frameworks /Library/Frameworks @@ -44,15 +40,10 @@ FIND_PATH(SDLNET_INCLUDE_DIR SDL_net.h ) FIND_LIBRARY(SDLNET_LIBRARY NAMES SDL_net - PATHS + HINTS $ENV{SDLNETDIR} $ENV{SDLDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(SDLNET_LIBRARY - NAMES SDL_net + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -62,7 +53,6 @@ FIND_LIBRARY(SDLNET_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(SDLNET_FOUND "NO") diff --git a/Modules/FindSDL_sound.cmake b/Modules/FindSDL_sound.cmake index 71d7334ce..21d6b1c7d 100755 --- a/Modules/FindSDL_sound.cmake +++ b/Modules/FindSDL_sound.cmake @@ -62,16 +62,12 @@ MARK_AS_ADVANCED(SDL_SOUND_EXTRAS) # Find SDL_sound.h FIND_PATH(SDL_SOUND_INCLUDE_DIR SDL_sound.h + HINTS $ENV{SDLSOUNDDIR}/include $ENV{SDLSOUNDDIR} $ENV{SDLDIR}/include $ENV{SDLDIR} - NO_DEFAULT_PATH -) -FIND_PATH(SDL_SOUND_INCLUDE_DIR SDL_sound.h - NO_DEFAULT_PATH -) -FIND_PATH(SDL_SOUND_INCLUDE_DIR SDL_sound.h + PATHS /usr/local/include/SDL /usr/include/SDL /usr/local/include/SDL12 @@ -92,11 +88,12 @@ FIND_PATH(SDL_SOUND_INCLUDE_DIR SDL_sound.h FIND_LIBRARY(SDL_SOUND_LIBRARY NAMES SDL_sound - PATHS + HINTS $ENV{SDLSOUNDDIR}/lib $ENV{SDLSOUNDDIR} $ENV{SDLDIR}/lib $ENV{SDLDIR} + PATHS /usr/local/lib /usr/lib /sw/lib diff --git a/Modules/FindSDL_ttf.cmake b/Modules/FindSDL_ttf.cmake index e1113d636..20d3e5af8 100755 --- a/Modules/FindSDL_ttf.cmake +++ b/Modules/FindSDL_ttf.cmake @@ -12,16 +12,11 @@ # module, but with modifications to recognize OS X frameworks and # additional Unix paths (FreeBSD, etc). - FIND_PATH(SDLTTF_INCLUDE_DIR SDL_ttf.h - PATHS + HINTS $ENV{SDLTTFDIR} $ENV{SDLDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(SDLTTF_INCLUDE_DIR SDL_ttf.h PATHS ~/Library/Frameworks /Library/Frameworks @@ -45,15 +40,9 @@ FIND_PATH(SDLTTF_INCLUDE_DIR SDL_ttf.h FIND_LIBRARY(SDLTTF_LIBRARY NAMES SDL_ttf - PATHS + HINTS $ENV{SDLTTFDIR} $ENV{SDLDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(SDLTTF_LIBRARY - NAMES SDL_ttf PATHS ~/Library/Frameworks /Library/Frameworks diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake index e1f9d7449..e31aab570 100644 --- a/Modules/FindSWIG.cmake +++ b/Modules/FindSWIG.cmake @@ -20,8 +20,12 @@ IF(SWIG_EXECUTABLE) ERROR_VARIABLE SWIG_swiglib_error RESULT_VARIABLE SWIG_swiglib_result) - IF(SWIG_swiglib_result) - MESSAGE(SEND_ERROR "Command \"${SWIG_EXECUTABLE} -swiglib\" failed with output:\n${SWIG_swiglib_error}") + IF(SWIG_swiglib_result) + IF(SWIG_FIND_REQUIRED) + MESSAGE(SEND_ERROR "Command \"${SWIG_EXECUTABLE} -swiglib\" failed with output:\n${SWIG_swiglib_error}") + ELSE(SWIG_FIND_REQUIRED) + MESSAGE(STATUS "Command \"${SWIG_EXECUTABLE} -swiglib\" failed with output:\n${SWIG_swiglib_error}") + ENDIF(SWIG_FIND_REQUIRED) ELSE(SWIG_swiglib_result) STRING(REGEX REPLACE "[\n\r]+" ";" SWIG_swiglib_output ${SWIG_swiglib_output}) # force the path to be computed each time in case SWIG_EXECUTABLE has changed. diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake index cdac93f82..5717e3c5c 100644 --- a/Modules/FindSubversion.cmake +++ b/Modules/FindSubversion.cmake @@ -20,6 +20,8 @@ # IF(Subversion_FOUND) # Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project) # MESSAGE("Current revision is ${Project_WC_REVISION}") +# Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project) +# MESSAGE("Last changed log is ${Project_LAST_CHANGED_LOG}") # ENDIF(Subversion_FOUND) # Copyright (c) 2006, Tristan Carel @@ -47,16 +49,11 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# $Id: FindSubversion.cmake,v 1.2.2.2 2008-03-26 18:08:24 hoffman Exp $ +# $Id: FindSubversion.cmake,v 1.2.2.3 2008-05-23 20:09:34 hoffman Exp $ SET(Subversion_FOUND FALSE) SET(Subversion_SVN_FOUND FALSE) -# the subversion commands should be executed with the C locale, otherwise -# the message (which are parsed) may be translated, Alex -SET(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}" ) -SET(ENV{LC_ALL} C) - FIND_PROGRAM(Subversion_SVN_EXECUTABLE svn DOC "subversion command line client") MARK_AS_ADVANCED(Subversion_SVN_EXECUTABLE) @@ -66,6 +63,11 @@ IF(Subversion_SVN_EXECUTABLE) SET(Subversion_FOUND TRUE) MACRO(Subversion_WC_INFO dir prefix) + # the subversion commands should be executed with the C locale, otherwise + # the message (which are parsed) may be translated, Alex + SET(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}") + SET(ENV{LC_ALL} C) + EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} --version WORKING_DIRECTORY ${dir} OUTPUT_VARIABLE Subversion_VERSION_SVN @@ -96,9 +98,19 @@ IF(Subversion_SVN_EXECUTABLE) ENDIF(NOT ${Subversion_svn_info_result} EQUAL 0) + # restore the previous LC_ALL + SET(ENV{LC_ALL} ${_Subversion_SAVED_LC_ALL}) + + ENDMACRO(Subversion_WC_INFO) + + MACRO(Subversion_WC_LOG dir prefix) + # This macro can block if the certificate is not signed: + # svn ask you to accept the certificate and wait for your answer + # This macro requires a svn server network access (Internet most of the time) + # and can also be slow since it access the svn server EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} log -r BASE ${dir} - OUTPUT_VARIABLE Subversion_LAST_CHANGED_LOG + OUTPUT_VARIABLE ${prefix}_LAST_CHANGED_LOG ERROR_VARIABLE Subversion_svn_log_error RESULT_VARIABLE Subversion_svn_log_result OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -106,13 +118,10 @@ IF(Subversion_SVN_EXECUTABLE) IF(NOT ${Subversion_svn_log_result} EQUAL 0) MESSAGE(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} log -r BASE ${dir}\" failed with output:\n${Subversion_svn_log_error}") ENDIF(NOT ${Subversion_svn_log_result} EQUAL 0) - ENDMACRO(Subversion_WC_INFO) + ENDMACRO(Subversion_WC_LOG) ENDIF(Subversion_SVN_EXECUTABLE) -# restore the previous LC_ALL -SET(ENV{LC_ALL} ${_Subversion_SAVED_LC_ALL}) - IF(NOT Subversion_FOUND) IF(NOT Subversion_FIND_QUIETLY) MESSAGE(STATUS "Subversion was not found.") diff --git a/Modules/FindTCL.cmake b/Modules/FindTCL.cmake index 3810609b5..568ab0e05 100644 --- a/Modules/FindTCL.cmake +++ b/Modules/FindTCL.cmake @@ -174,22 +174,12 @@ ENDIF(WIN32) FIND_PATH(TCL_INCLUDE_PATH NAMES tcl.h - PATHS ${TCLTK_POSSIBLE_INCLUDE_PATHS} - NO_DEFAULT_PATH - ) -FIND_PATH(TCL_INCLUDE_PATH - NAMES tcl.h - PATHS ${TCLTK_POSSIBLE_INCLUDE_PATHS} + HINTS ${TCLTK_POSSIBLE_INCLUDE_PATHS} ) FIND_PATH(TK_INCLUDE_PATH NAMES tk.h - PATHS ${TCLTK_POSSIBLE_INCLUDE_PATHS} - NO_DEFAULT_PATH - ) -FIND_PATH(TK_INCLUDE_PATH - NAMES tk.h - PATHS ${TCLTK_POSSIBLE_INCLUDE_PATHS} + HINTS ${TCLTK_POSSIBLE_INCLUDE_PATHS} ) # handle the QUIETLY and REQUIRED arguments and set TCL_FOUND to TRUE if diff --git a/Modules/FindTIFF.cmake b/Modules/FindTIFF.cmake index fbf804468..2868bb9f3 100644 --- a/Modules/FindTIFF.cmake +++ b/Modules/FindTIFF.cmake @@ -9,14 +9,16 @@ FIND_PATH(TIFF_INCLUDE_DIR tiff.h) -SET(TIFF_NAMES ${TIFF_NAMES} tiff) +SET(TIFF_NAMES ${TIFF_NAMES} tiff libtiff libtiff3) FIND_LIBRARY(TIFF_LIBRARY NAMES ${TIFF_NAMES} ) # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if # all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(TIFF DEFAULT_MSG TIFF_LIBRARY TIFF_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(TIFF DEFAULT_MSG TIFF_LIBRARY TIFF_INCLUDE_DIR) IF(TIFF_FOUND) SET( TIFF_LIBRARIES ${TIFF_LIBRARY} ) ENDIF(TIFF_FOUND) + +MARK_AS_ADVANCED(TIFF_INCLUDE_DIR TIFF_LIBRARY) diff --git a/Modules/FindTclsh.cmake b/Modules/FindTclsh.cmake index d2cc86bf6..129c11ac2 100644 --- a/Modules/FindTclsh.cmake +++ b/Modules/FindTclsh.cmake @@ -66,11 +66,7 @@ SET(TCL_TCLSH_NAMES FIND_PROGRAM(TCL_TCLSH NAMES ${TCL_TCLSH_NAMES} - PATHS ${TCLTK_POSSIBLE_BIN_PATHS} NO_DEFAULT_PATH - ) -FIND_PROGRAM(TCL_TCLSH - NAMES ${TCL_TCLSH_NAMES} - PATHS ${TCLTK_POSSIBLE_BIN_PATHS} + HINTS ${TCLTK_POSSIBLE_BIN_PATHS} ) # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index 98031e2d0..6facb5155 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -8,6 +8,7 @@ INCLUDE (CheckIncludeFiles) INCLUDE (CheckLibraryExists) +SET(Threads_FOUND FALSE) # Do we have sproc? IF(CMAKE_SYSTEM MATCHES IRIX) @@ -30,11 +31,13 @@ ELSE(CMAKE_HAVE_SPROC_H) IF(CMAKE_HAVE_PTHREADS_CREATE) SET(CMAKE_THREAD_LIBS_INIT "-lpthreads") SET(CMAKE_HAVE_THREADS_LIBRARY 1) + SET(Threads_FOUND TRUE) ENDIF(CMAKE_HAVE_PTHREADS_CREATE) # Ok, how about -lpthread CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE) IF(CMAKE_HAVE_PTHREAD_CREATE) SET(CMAKE_THREAD_LIBS_INIT "-lpthread") + SET(Threads_FOUND TRUE) SET(CMAKE_HAVE_THREADS_LIBRARY 1) ENDIF(CMAKE_HAVE_PTHREAD_CREATE) IF(CMAKE_SYSTEM MATCHES "SunOS.*") @@ -43,6 +46,7 @@ ELSE(CMAKE_HAVE_SPROC_H) IF(CMAKE_HAVE_THR_CREATE) SET(CMAKE_THREAD_LIBS_INIT "-lthread") SET(CMAKE_HAVE_THREADS_LIBRARY 1) + SET(Threads_FOUND TRUE) ENDIF(CMAKE_HAVE_THR_CREATE) ENDIF(CMAKE_SYSTEM MATCHES "SunOS.*") ENDIF(NOT THREADS_HAVE_PTHREAD_ARG) @@ -58,6 +62,7 @@ ELSE(CMAKE_HAVE_SPROC_H) COMPILE_OUTPUT_VARIABLE OUTPUT) IF(THREADS_HAVE_PTHREAD_ARG) IF(THREADS_PTHREAD_ARG MATCHES "^2$") + SET(Threads_FOUND TRUE) MESSAGE(STATUS "Check if compiler accepts -pthread - yes") ELSE(THREADS_PTHREAD_ARG MATCHES "^2$") MESSAGE(STATUS "Check if compiler accepts -pthread - no") @@ -73,6 +78,7 @@ ELSE(CMAKE_HAVE_SPROC_H) ENDIF(THREADS_HAVE_PTHREAD_ARG) ENDIF("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG") IF(THREADS_HAVE_PTHREAD_ARG) + SET(Threads_FOUND TRUE) SET(CMAKE_THREAD_LIBS_INIT "-pthread") ENDIF(THREADS_HAVE_PTHREAD_ARG) ENDIF(NOT CMAKE_HAVE_THREADS_LIBRARY) @@ -81,10 +87,12 @@ ENDIF(CMAKE_HAVE_SPROC_H) IF(CMAKE_THREAD_LIBS_INIT) SET(CMAKE_USE_PTHREADS_INIT 1) + SET(Threads_FOUND TRUE) ENDIF(CMAKE_THREAD_LIBS_INIT) IF(CMAKE_SYSTEM MATCHES "Windows") SET(CMAKE_USE_WIN32_THREADS_INIT 1) + SET(Threads_FOUND TRUE) ENDIF(CMAKE_SYSTEM MATCHES "Windows") IF(CMAKE_USE_PTHREADS_INIT) @@ -101,6 +109,7 @@ IF(CMAKE_USE_PTHREADS_INIT) IF(CMAKE_HAVE_HP_CMA) SET(CMAKE_THREAD_LIBS_INIT "-lcma") SET(CMAKE_HP_PTHREADS_INIT 1) + SET(Threads_FOUND TRUE) ENDIF(CMAKE_HAVE_HP_CMA) SET(CMAKE_USE_PTHREADS_INIT 1) ENDIF(CMAKE_SYSTEM MATCHES "HP-UX-*") @@ -112,8 +121,11 @@ IF(CMAKE_USE_PTHREADS_INIT) IF(CMAKE_SYSTEM MATCHES "CYGWIN_NT*") SET(CMAKE_USE_PTHREADS_INIT 1) + SET(Threads_FOUND TRUE) SET(CMAKE_THREAD_LIBS_INIT ) SET(CMAKE_USE_WIN32_THREADS_INIT 0) ENDIF(CMAKE_SYSTEM MATCHES "CYGWIN_NT*") ENDIF(CMAKE_USE_PTHREADS_INIT) +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Threads DEFAULT_MSG Threads_FOUND) diff --git a/Modules/FindWish.cmake b/Modules/FindWish.cmake index 86e9c6761..0afd3c963 100644 --- a/Modules/FindWish.cmake +++ b/Modules/FindWish.cmake @@ -65,11 +65,7 @@ SET(TK_WISH_NAMES FIND_PROGRAM(TK_WISH NAMES ${TK_WISH_NAMES} - PATHS ${TCLTK_POSSIBLE_BIN_PATHS} NO_DEFAULT_PATH - ) -FIND_PROGRAM(TK_WISH - NAMES ${TK_WISH_NAMES} - PATHS ${TCLTK_POSSIBLE_BIN_PATHS} + HINTS ${TCLTK_POSSIBLE_BIN_PATHS} ) MARK_AS_ADVANCED(TK_WISH) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index 0db6abed1..3155aac82 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -46,20 +46,18 @@ IF (UNIX) SET(X11_INC_SEARCH_PATH /usr/pkg/xorg/include /usr/X11R6/include - /usr/local/include + /usr/X11R7/include /usr/include/X11 /usr/openwin/include /usr/openwin/share/include /opt/graphics/OpenGL/include - /usr/include ) SET(X11_LIB_SEARCH_PATH /usr/pkg/xorg/lib /usr/X11R6/lib - /usr/local/lib + /usr/X11R7/lib /usr/openwin/lib - /usr/lib ) FIND_PATH(X11_X11_INCLUDE_PATH X11/X.h ${X11_INC_SEARCH_PATH}) diff --git a/Modules/FindXMLRPC.cmake b/Modules/FindXMLRPC.cmake index 2e8f1ad0f..2eefd2f75 100644 --- a/Modules/FindXMLRPC.cmake +++ b/Modules/FindXMLRPC.cmake @@ -101,10 +101,8 @@ IF(XMLRPC_FOUND) # Look for this library. FIND_LIBRARY(XMLRPC_${name}_LIBRARY NAMES ${name} - PATHS ${XMLRPC_LIBRARY_DIRS} - NO_DEFAULT_PATH + HINTS ${XMLRPC_LIBRARY_DIRS} ) - FIND_LIBRARY(XMLRPC_${name}_LIBRARY NAMES ${name}) MARK_AS_ADVANCED(XMLRPC_${name}_LIBRARY) # If any library is not found then the whole package is not found. diff --git a/Modules/Findosg.cmake b/Modules/Findosg.cmake index 1a4598c8e..7804baee0 100644 --- a/Modules/Findosg.cmake +++ b/Modules/Findosg.cmake @@ -27,14 +27,10 @@ # Try the user's environment request before anything else. FIND_PATH(OSG_INCLUDE_DIR osg/PositionAttitudeTransform - PATHS + HINTS $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(OSG_INCLUDE_DIR osg/PositionAttitudeTransform PATHS ~/Library/Frameworks /Library/Frameworks @@ -46,20 +42,14 @@ FIND_PATH(OSG_INCLUDE_DIR osg/PositionAttitudeTransform /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] - PATH_SUFFIXES include ) FIND_LIBRARY(OSG_LIBRARY NAMES osg - PATHS + HINTS $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(OSG_LIBRARY - NAMES osg + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -69,7 +59,6 @@ FIND_LIBRARY(OSG_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(OSG_FOUND "NO") diff --git a/Modules/FindosgDB.cmake b/Modules/FindosgDB.cmake index 711e5f366..88da80761 100644 --- a/Modules/FindosgDB.cmake +++ b/Modules/FindosgDB.cmake @@ -27,15 +27,11 @@ # Try the user's environment request before anything else. FIND_PATH(OSGDB_INCLUDE_DIR osgDB/DatabasePager - PATHS + HINTS $ENV{OSGDB_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(OSGDB_INCLUDE_DIR osgDB/DatabasePager PATHS ~/Library/Frameworks /Library/Frameworks @@ -47,21 +43,15 @@ FIND_PATH(OSGDB_INCLUDE_DIR osgDB/DatabasePager /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] - PATH_SUFFIXES include ) FIND_LIBRARY(OSGDB_LIBRARY NAMES osgDB - PATHS + HINTS $ENV{OSGDB_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(OSGDB_LIBRARY - NAMES osgDB + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -71,7 +61,6 @@ FIND_LIBRARY(OSGDB_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(OSGDB_FOUND "NO") diff --git a/Modules/FindosgFX.cmake b/Modules/FindosgFX.cmake index cc1c3a692..9b45c3106 100644 --- a/Modules/FindosgFX.cmake +++ b/Modules/FindosgFX.cmake @@ -27,15 +27,11 @@ # Try the user's environment request before anything else. FIND_PATH(OSGFX_INCLUDE_DIR osgFX/BumpMapping - PATHS + HINTS $ENV{OSGFX_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(OSGFX_INCLUDE_DIR osgFX/BumpMapping PATHS ~/Library/Frameworks /Library/Frameworks @@ -47,21 +43,15 @@ FIND_PATH(OSGFX_INCLUDE_DIR osgFX/BumpMapping /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] - PATH_SUFFIXES include ) FIND_LIBRARY(OSGFX_LIBRARY NAMES osgFX - PATHS + HINTS $ENV{OSGFX_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(OSGFX_LIBRARY - NAMES osgFX + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -71,7 +61,6 @@ FIND_LIBRARY(OSGFX_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(OSGFX_FOUND "NO") diff --git a/Modules/FindosgGA.cmake b/Modules/FindosgGA.cmake index a9dc863b3..c1585d063 100644 --- a/Modules/FindosgGA.cmake +++ b/Modules/FindosgGA.cmake @@ -27,15 +27,11 @@ # Try the user's environment request before anything else. FIND_PATH(OSGGA_INCLUDE_DIR osgGA/FlightManipulator - PATHS + HINTS $ENV{OSGGA_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(OSGGA_INCLUDE_DIR osgGA/FlightManipulator PATHS ~/Library/Frameworks /Library/Frameworks @@ -47,21 +43,15 @@ FIND_PATH(OSGGA_INCLUDE_DIR osgGA/FlightManipulator /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] - PATH_SUFFIXES include ) FIND_LIBRARY(OSGGA_LIBRARY NAMES osgGA - PATHS + HINTS $ENV{OSGGA_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(OSGGA_LIBRARY - NAMES osgGA + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -71,7 +61,6 @@ FIND_LIBRARY(OSGGA_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(OSGGA_FOUND "NO") diff --git a/Modules/FindosgIntrospection.cmake b/Modules/FindosgIntrospection.cmake index 270f5f899..cf7ffac2f 100644 --- a/Modules/FindosgIntrospection.cmake +++ b/Modules/FindosgIntrospection.cmake @@ -27,15 +27,11 @@ # Try the user's environment request before anything else. FIND_PATH(OSGINTROSPECTION_INCLUDE_DIR osgIntrospection/Reflection - PATHS + HINTS $ENV{OSGINTROSPECTION_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(OSGINTROSPECTION_INCLUDE_DIR osgIntrospection/Reflection PATHS ~/Library/Frameworks /Library/Frameworks @@ -47,21 +43,15 @@ FIND_PATH(OSGINTROSPECTION_INCLUDE_DIR osgIntrospection/Reflection /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] - PATH_SUFFIXES include ) FIND_LIBRARY(OSGINTROSPECTION_LIBRARY NAMES osgIntrospection - PATHS + HINTS $ENV{OSGINTROSPECTION_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(OSGINTROSPECTION_LIBRARY - NAMES osgIntrospection + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -71,7 +61,6 @@ FIND_LIBRARY(OSGINTROSPECTION_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(OSGINTROSPECTION_FOUND "NO") diff --git a/Modules/FindosgManipulator.cmake b/Modules/FindosgManipulator.cmake index f76e7272a..17a6424dc 100644 --- a/Modules/FindosgManipulator.cmake +++ b/Modules/FindosgManipulator.cmake @@ -27,15 +27,11 @@ # Try the user's environment request before anything else. FIND_PATH(OSGMANIPULATOR_INCLUDE_DIR osgManipulator/TrackballDragger - PATHS + HINTS $ENV{OSGMANIPULATOR_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(OSGMANIPULATOR_INCLUDE_DIR osgManipulator/TrackballDragger PATHS ~/Library/Frameworks /Library/Frameworks @@ -47,21 +43,15 @@ FIND_PATH(OSGMANIPULATOR_INCLUDE_DIR osgManipulator/TrackballDragger /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] - PATH_SUFFIXES include ) FIND_LIBRARY(OSGMANIPULATOR_LIBRARY NAMES osgManipulator - PATHS + HINTS $ENV{OSGMANIPULATOR_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(OSGMANIPULATOR_LIBRARY - NAMES osgManipulator + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -71,7 +61,6 @@ FIND_LIBRARY(OSGMANIPULATOR_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(OSGMANIPULATOR_FOUND "NO") diff --git a/Modules/FindosgParticle.cmake b/Modules/FindosgParticle.cmake index a6b4bf99f..8514b2ff6 100644 --- a/Modules/FindosgParticle.cmake +++ b/Modules/FindosgParticle.cmake @@ -27,15 +27,11 @@ # Try the user's environment request before anything else. FIND_PATH(OSGPARTICLE_INCLUDE_DIR osgParticle/FireEffect - PATHS + HINTS $ENV{OSGPARTICLE_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(OSGPARTICLE_INCLUDE_DIR osgParticle/FireEffect PATHS ~/Library/Frameworks /Library/Frameworks @@ -47,21 +43,15 @@ FIND_PATH(OSGPARTICLE_INCLUDE_DIR osgParticle/FireEffect /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] - PATH_SUFFIXES include ) FIND_LIBRARY(OSGPARTICLE_LIBRARY NAMES osgParticle - PATHS + HINTS $ENV{OSGPARTICLE_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(OSGPARTICLE_LIBRARY - NAMES osgParticle + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -71,7 +61,6 @@ FIND_LIBRARY(OSGPARTICLE_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(OSGPARTICLE_FOUND "NO") diff --git a/Modules/FindosgProducer.cmake b/Modules/FindosgProducer.cmake index 7ff3292c7..0852527b6 100644 --- a/Modules/FindosgProducer.cmake +++ b/Modules/FindosgProducer.cmake @@ -27,15 +27,11 @@ # Try the user's environment request before anything else. FIND_PATH(OSGPRODUCER_INCLUDE_DIR osgProducer/OsgSceneHandler - PATHS + HINTS $ENV{OSGPRODUCER_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(OSGPRODUCER_INCLUDE_DIR osgProducer/OsgSceneHandler PATHS ~/Library/Frameworks /Library/Frameworks @@ -47,21 +43,15 @@ FIND_PATH(OSGPRODUCER_INCLUDE_DIR osgProducer/OsgSceneHandler /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] - PATH_SUFFIXES include ) FIND_LIBRARY(OSGPRODUCER_LIBRARY NAMES osgProducer - PATHS + HINTS $ENV{OSGPRODUCER_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(OSGPRODUCER_LIBRARY - NAMES osgProducer + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -71,7 +61,6 @@ FIND_LIBRARY(OSGPRODUCER_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(OSGPRODUCER_FOUND "NO") diff --git a/Modules/FindosgShadow.cmake b/Modules/FindosgShadow.cmake index 65a2336be..ddb59fb91 100644 --- a/Modules/FindosgShadow.cmake +++ b/Modules/FindosgShadow.cmake @@ -27,15 +27,11 @@ # Try the user's environment request before anything else. FIND_PATH(OSGSHADOW_INCLUDE_DIR osgShadow/ShadowTexture - PATHS + HINTS $ENV{OSGSHADOW_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(OSGSHADOW_INCLUDE_DIR osgShadow/ShadowTexture PATHS ~/Library/Frameworks /Library/Frameworks @@ -47,21 +43,15 @@ FIND_PATH(OSGSHADOW_INCLUDE_DIR osgShadow/ShadowTexture /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] - PATH_SUFFIXES include ) FIND_LIBRARY(OSGSHADOW_LIBRARY NAMES osgShadow - PATHS + HINTS $ENV{OSGSHADOW_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(OSGSHADOW_LIBRARY - NAMES osgShadow + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -71,7 +61,6 @@ FIND_LIBRARY(OSGSHADOW_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(OSGSHADOW_FOUND "NO") diff --git a/Modules/FindosgSim.cmake b/Modules/FindosgSim.cmake index 4bff3281a..1293af7cd 100644 --- a/Modules/FindosgSim.cmake +++ b/Modules/FindosgSim.cmake @@ -27,15 +27,11 @@ # Try the user's environment request before anything else. FIND_PATH(OSGSIM_INCLUDE_DIR osgSim/ImpostorSprite - PATHS + HINTS $ENV{OSGSIM_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(OSGSIM_INCLUDE_DIR osgSim/ImpostorSprite PATHS ~/Library/Frameworks /Library/Frameworks @@ -47,21 +43,15 @@ FIND_PATH(OSGSIM_INCLUDE_DIR osgSim/ImpostorSprite /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] - PATH_SUFFIXES include ) FIND_LIBRARY(OSGSIM_LIBRARY NAMES osgSim - PATHS + HINTS $ENV{OSGSIM_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(OSGSIM_LIBRARY - NAMES osgSim + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -71,7 +61,6 @@ FIND_LIBRARY(OSGSIM_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(OSGSIM_FOUND "NO") diff --git a/Modules/FindosgTerrain.cmake b/Modules/FindosgTerrain.cmake index fcf74896e..3f3a559d7 100644 --- a/Modules/FindosgTerrain.cmake +++ b/Modules/FindosgTerrain.cmake @@ -27,15 +27,11 @@ # Try the user's environment request before anything else. FIND_PATH(OSGTERRAIN_INCLUDE_DIR osgTerrain/Terrain - PATHS + HINTS $ENV{OSGTERRAIN_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(OSGTERRAIN_INCLUDE_DIR osgTerrain/Terrain PATHS ~/Library/Frameworks /Library/Frameworks @@ -47,21 +43,15 @@ FIND_PATH(OSGTERRAIN_INCLUDE_DIR osgTerrain/Terrain /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] - PATH_SUFFIXES include ) FIND_LIBRARY(OSGTERRAIN_LIBRARY NAMES osgTerrain - PATHS + HINTS $ENV{OSGTERRAIN_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(OSGTERRAIN_LIBRARY - NAMES osgTerrain + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -71,7 +61,6 @@ FIND_LIBRARY(OSGTERRAIN_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(OSGTERRAIN_FOUND "NO") diff --git a/Modules/FindosgText.cmake b/Modules/FindosgText.cmake index d6c3e1f25..7eef2a1c5 100644 --- a/Modules/FindosgText.cmake +++ b/Modules/FindosgText.cmake @@ -27,15 +27,11 @@ # Try the user's environment request before anything else. FIND_PATH(OSGTEXT_INCLUDE_DIR osgText/Text - PATHS + HINTS $ENV{OSGTEXT_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(OSGTEXT_INCLUDE_DIR osgText/Text PATHS ~/Library/Frameworks /Library/Frameworks @@ -47,21 +43,15 @@ FIND_PATH(OSGTEXT_INCLUDE_DIR osgText/Text /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] - PATH_SUFFIXES include ) FIND_LIBRARY(OSGTEXT_LIBRARY NAMES osgText - PATHS + HINTS $ENV{OSGTEXT_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(OSGTEXT_LIBRARY - NAMES osgText + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -71,7 +61,6 @@ FIND_LIBRARY(OSGTEXT_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(OSGTEXT_FOUND "NO") diff --git a/Modules/FindosgUtil.cmake b/Modules/FindosgUtil.cmake index cbd9b8c0c..f73d82bd3 100644 --- a/Modules/FindosgUtil.cmake +++ b/Modules/FindosgUtil.cmake @@ -27,15 +27,11 @@ # Try the user's environment request before anything else. FIND_PATH(OSGUTIL_INCLUDE_DIR osgUtil/SceneView - PATHS + HINTS $ENV{OSGUTIL_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(OSGUTIL_INCLUDE_DIR osgUtil/SceneView PATHS ~/Library/Frameworks /Library/Frameworks @@ -47,21 +43,15 @@ FIND_PATH(OSGUTIL_INCLUDE_DIR osgUtil/SceneView /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] - PATH_SUFFIXES include ) FIND_LIBRARY(OSGUTIL_LIBRARY NAMES osgUtil - PATHS + HINTS $ENV{OSGUTIL_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(OSGUTIL_LIBRARY - NAMES osgUtil + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -71,7 +61,6 @@ FIND_LIBRARY(OSGUTIL_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(OSGUTIL_FOUND "NO") diff --git a/Modules/FindosgViewer.cmake b/Modules/FindosgViewer.cmake index b9efd47ef..d240a8c03 100644 --- a/Modules/FindosgViewer.cmake +++ b/Modules/FindosgViewer.cmake @@ -27,15 +27,11 @@ # Try the user's environment request before anything else. FIND_PATH(OSGVIEWER_INCLUDE_DIR osgViewer/Viewer - PATHS + HINTS $ENV{OSGVIEWER_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH PATH_SUFFIXES include -) - -FIND_PATH(OSGVIEWER_INCLUDE_DIR osgViewer/Viewer PATHS ~/Library/Frameworks /Library/Frameworks @@ -47,21 +43,15 @@ FIND_PATH(OSGVIEWER_INCLUDE_DIR osgViewer/Viewer /opt [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OpenThreads_ROOT] [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] - PATH_SUFFIXES include ) FIND_LIBRARY(OSGVIEWER_LIBRARY NAMES osgViewer - PATHS + HINTS $ENV{OSGVIEWER_DIR} $ENV{OSG_DIR} $ENV{OSGDIR} - NO_DEFAULT_PATH - PATH_SUFFIXES lib64 lib -) - -FIND_LIBRARY(OSGVIEWER_LIBRARY - NAMES osgViewer + PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks /Library/Frameworks @@ -71,7 +61,6 @@ FIND_LIBRARY(OSGVIEWER_LIBRARY /opt/local /opt/csw /opt - PATH_SUFFIXES lib64 lib ) SET(OSGVIEWER_FOUND "NO") diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 0007ee3cc..ec82b520c 100755 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -174,21 +174,18 @@ ENDIF(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake") #===================================================================== #===================================================================== -IF(WIN32) - SET(WIN32_STYLE_FIND 1) -ENDIF(WIN32) -IF(MINGW) - SET(WIN32_STYLE_FIND 0) - SET(UNIX_STYLE_FIND 1) -ENDIF(MINGW) -IF(UNIX) - SET(UNIX_STYLE_FIND 1) -ENDIF(UNIX) +IF(WIN32 AND NOT CYGWIN AND NOT MSYS) + SET(wxWidgets_FIND_STYLE "win32") +ELSE(WIN32 AND NOT CYGWIN AND NOT MSYS) + IF(UNIX OR MSYS) + SET(wxWidgets_FIND_STYLE "unix") + ENDIF(UNIX OR MSYS) +ENDIF(WIN32 AND NOT CYGWIN AND NOT MSYS) #===================================================================== -# WIN32_STYLE_FIND +# WIN32_FIND_STYLE #===================================================================== -IF(WIN32_STYLE_FIND) +IF(wxWidgets_FIND_STYLE STREQUAL "win32") # Useful common wx libs needed by almost all components. SET(wxWidgets_COMMON_LIBRARIES png tiff jpeg zlib regex expat) @@ -283,7 +280,7 @@ IF(WIN32_STYLE_FIND) MARK_AS_ADVANCED(WX_mono${_DBG}) # Find wxWidgets multilib libraries. - FOREACH(LIB core adv aui html media xrc dbgrid gl qa) + FOREACH(LIB core adv aui html media xrc dbgrid gl qa richtext) FIND_LIBRARY(WX_${LIB}${_DBG} NAMES wxmsw${_UNV}29${_UCD}${_DBG}_${LIB} @@ -324,7 +321,7 @@ IF(WIN32_STYLE_FIND) WX_CLEAR_LIB(WX_mono${_DBG}) # Clear wxWidgets multilib libraries. - FOREACH(LIB core adv aui html media xrc dbgrid gl qa) + FOREACH(LIB core adv aui html media xrc dbgrid gl qa richtext) WX_CLEAR_LIB(WX_${LIB}${_DBG}) ENDFOREACH(LIB) ENDMACRO(WX_CLEAR_ALL_LIBS) @@ -398,6 +395,12 @@ IF(WIN32_STYLE_FIND) D:/ $ENV{ProgramFiles} PATH_SUFFIXES + wxWidgets-2.9.4 + wxWidgets-2.9.3 + wxWidgets-2.9.2 + wxWidgets-2.9.1 + wxWidgets-2.9.0 + wxWidgets-2.8.8 wxWidgets-2.8.7 wxWidgets-2.8.6 wxWidgets-2.8.5 @@ -412,6 +415,7 @@ IF(WIN32_STYLE_FIND) wxWidgest-2.7.1 wxWidgets-2.7.0 wxWidgets-2.7.0-1 + wxWidgets-2.6.4 wxWidgets-2.6.3 wxWidgets-2.6.2 wxWidgets-2.6.1 @@ -435,21 +439,26 @@ IF(WIN32_STYLE_FIND) # Select one default tree inside the already determined wx tree. # Prefer static/shared order usually consistent with build # settings. + IF(MINGW) + SET(WX_LIB_DIR_PREFIX gcc) + ELSE(MINGW) + SET(WX_LIB_DIR_PREFIX vc) + ENDIF(MINGW) IF(BUILD_SHARED_LIBS) FIND_PATH(wxWidgets_LIB_DIR - NAMES wxpng.lib wxpngd.lib + NAMES msw/build.cfg mswd/build.cfg PATHS - ${WX_ROOT_DIR}/lib/vc_dll # prefer shared - ${WX_ROOT_DIR}/lib/vc_lib + ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll # prefer shared + ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib DOC "Path to wxWidgets libraries?" NO_DEFAULT_PATH ) ELSE(BUILD_SHARED_LIBS) FIND_PATH(wxWidgets_LIB_DIR - NAMES wxpng.lib wxpngd.lib + NAMES msw/build.cfg mswd/build.cfg PATHS - ${WX_ROOT_DIR}/lib/vc_lib # prefer static - ${WX_ROOT_DIR}/lib/vc_dll + ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib # prefer static + ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll DOC "Path to wxWidgets libraries?" NO_DEFAULT_PATH ) @@ -543,10 +552,10 @@ IF(WIN32_STYLE_FIND) ENDIF(WX_ROOT_DIR) #===================================================================== -# UNIX_STYLE_FIND +# UNIX_FIND_STYLE #===================================================================== -ELSE(WIN32_STYLE_FIND) - IF(UNIX_STYLE_FIND) +ELSE(wxWidgets_FIND_STYLE STREQUAL "win32") + IF(wxWidgets_FIND_STYLE STREQUAL "unix") #----------------------------------------------------------------- # UNIX: Helper MACROS #----------------------------------------------------------------- @@ -572,7 +581,7 @@ ELSE(WIN32_STYLE_FIND) ELSE(_wx_result EQUAL 0) FOREACH(_upper_opt_name DEBUG STATIC UNICODE UNIVERSAL) SET(wxWidgets_DEFAULT_${_upper_opt_name} OFF) - ENDFOREACH(_opt_name) + ENDFOREACH(_upper_opt_name) ENDIF(_wx_result EQUAL 0) ENDMACRO(WX_CONFIG_SELECT_GET_DEFAULT) @@ -729,18 +738,18 @@ ELSE(WIN32_STYLE_FIND) ENDIF(wxWidgets_CONFIG_EXECUTABLE) #===================================================================== -# Neither UNIX_STYLE_FIND, nor WIN32_STYLE_FIND +# Neither UNIX_FIND_STYLE, nor WIN32_FIND_STYLE #===================================================================== - ELSE(UNIX_STYLE_FIND) + ELSE(wxWidgets_FIND_STYLE STREQUAL "unix") IF(NOT wxWidgets_FIND_QUIETLY) MESSAGE(STATUS "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): \n" " Platform unknown/unsupported. It's neither WIN32 nor UNIX " - "style find." + "find style." ) ENDIF(NOT wxWidgets_FIND_QUIETLY) - ENDIF(UNIX_STYLE_FIND) -ENDIF(WIN32_STYLE_FIND) + ENDIF(wxWidgets_FIND_STYLE STREQUAL "unix") +ENDIF(wxWidgets_FIND_STYLE STREQUAL "win32") # Debug output: DBG_MSG("wxWidgets_FOUND : ${wxWidgets_FOUND}") diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 8c29d4b8b..68b17bcd4 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -12,13 +12,16 @@ # gp_append_unique # gp_file_type # is_file_executable +# gp_item_default_embedded_path +# (projects can override with gp_item_default_embedded_path_override) +# gp_resolve_item +# (projects can override with gp_resolve_item_override) # get_prerequisites # list_prerequisites +# list_prerequisites_by_glob # -# Requires CMake 2.5 or greater because it uses function, break, return and +# Requires CMake 2.6 or greater because it uses function, break, return and # PARENT_SCOPE. -# -cmake_minimum_required(VERSION 2.5 FATAL_ERROR) # gp_append_unique list_var value @@ -135,7 +138,7 @@ function(is_file_executable file result_var) endif("${file_full_lower}" MATCHES "\\.(exe|dll)$") # A clause could be added here that uses output or return value of dumpbin - # to determine ${result_var}. In 95%+ practical cases, the exe|dll name + # to determine ${result_var}. In 99%+? practical cases, the exe|dll name # match will be sufficient... # endif(WIN32) @@ -184,7 +187,171 @@ function(is_file_executable file result_var) endfunction(is_file_executable) -# get_prerequisites target prerequisites_var exclude_system recurse +# gp_item_default_embedded_path item default_embedded_path_var +# +# Return the path that others should refer to the item by when the item +# is embedded inside a bundle. +# +# Override on a per-project basis by providing a project-specific +# gp_item_default_embedded_path_override function. +# +function(gp_item_default_embedded_path item default_embedded_path_var) + # + # The assumption here is that all executables in the bundle will be + # in same-level-directories inside the bundle. The parent directory + # of an executable inside the bundle should be MacOS or a sibling of + # MacOS and all embedded paths returned from here will begin with + # "@executable_path/../" and will work from all executables in all + # such same-level-directories inside the bundle. + # + + # By default, embed things right next to the main bundle executable: + # + set(path "@executable_path/../../Contents/MacOS") + + set(overridden 0) + + # Embed .dylibs right next to the main bundle executable: + # + if(item MATCHES "\\.dylib$") + set(path "@executable_path/../MacOS") + set(overridden 1) + endif(item MATCHES "\\.dylib$") + + # Embed frameworks in the embedded "Frameworks" directory (sibling of MacOS): + # + if(NOT overridden) + if(item MATCHES "[^/]+\\.framework/") + set(path "@executable_path/../Frameworks") + set(overridden 1) + endif(item MATCHES "[^/]+\\.framework/") + endif(NOT overridden) + + # Provide a hook so that projects can override the default embedded location of + # any given library by whatever logic they choose: + # + if(COMMAND gp_item_default_embedded_path_override) + gp_item_default_embedded_path_override("${item}" path) + endif(COMMAND gp_item_default_embedded_path_override) + + set(${default_embedded_path_var} "${path}" PARENT_SCOPE) +endfunction(gp_item_default_embedded_path) + + +# gp_resolve_item context item exepath dirs resolved_item_var +# +# Resolve an item into an existing full path file. +# +# Override on a per-project basis by providing a project-specific +# gp_resolve_item_override function. +# +function(gp_resolve_item context item exepath dirs resolved_item_var) + set(resolved 0) + set(resolved_item "${item}") + + # Is it already resolved? + # + if(EXISTS "${resolved_item}") + set(resolved 1) + endif(EXISTS "${resolved_item}") + + if(NOT resolved) + if(item MATCHES "@executable_path") + # + # @executable_path references are assumed relative to exepath + # + string(REPLACE "@executable_path" "${exepath}" ri "${item}") + get_filename_component(ri "${ri}" ABSOLUTE) + + if(EXISTS "${ri}") + #message(STATUS "info: embedded item exists (${ri})") + set(resolved 1) + set(resolved_item "${ri}") + else(EXISTS "${ri}") + message(STATUS "info: embedded item does not exist '${ri}'") + endif(EXISTS "${ri}") + endif(item MATCHES "@executable_path") + endif(NOT resolved) + + if(NOT resolved) + if(item MATCHES "@loader_path") + # + # @loader_path references are assumed relative to the + # PATH of the given "context" (presumably another library) + # + get_filename_component(contextpath "${context}" PATH) + string(REPLACE "@loader_path" "${contextpath}" ri "${item}") + get_filename_component(ri "${ri}" ABSOLUTE) + + if(EXISTS "${ri}") + #message(STATUS "info: embedded item exists (${ri})") + set(resolved 1) + set(resolved_item "${ri}") + else(EXISTS "${ri}") + message(STATUS "info: embedded item does not exist '${ri}'") + endif(EXISTS "${ri}") + endif(item MATCHES "@loader_path") + endif(NOT resolved) + + if(NOT resolved) + set(ri "ri-NOTFOUND") + find_file(ri "${item}" ${dirs}) + if(ri) + #message(STATUS "info: found item in dirs (${ri})") + set(resolved 1) + set(resolved_item "${ri}") + set(ri "ri-NOTFOUND") + endif(ri) + endif(NOT resolved) + + if(NOT resolved) + if(item MATCHES "[^/]+\\.framework/") + set(fw "fw-NOTFOUND") + find_file(fw "${item}" + "~/Library/Frameworks" + "/Library/Frameworks" + "/System/Library/Frameworks" + ) + if(fw) + #message(STATUS "info: found framework (${fw})") + set(resolved 1) + set(resolved_item "${fw}") + set(fw "fw-NOTFOUND") + endif(fw) + endif(item MATCHES "[^/]+\\.framework/") + endif(NOT resolved) + + # Using find_program on Windows will find dll files that are in the PATH. + # (Converting simple file names into full path names if found.) + # + if(WIN32) + if(NOT resolved) + set(ri "ri-NOTFOUND") + find_program(ri "${item}" PATHS "${dirs}") + if(ri) + set(resolved 1) + set(resolved_item "${ri}") + set(ri "ri-NOTFOUND") + endif(ri) + endif(NOT resolved) + endif(WIN32) + + # Provide a hook so that projects can override item resolution + # by whatever logic they choose: + # + if(COMMAND gp_resolve_item_override) + gp_resolve_item_override("${context}" "${item}" "${exepath}" "${dirs}" resolved_item resolved) + endif(COMMAND gp_resolve_item_override) + + if(NOT resolved) + message(STATUS "warning: cannot resolve item '${item}'") + endif(NOT resolved) + + set(${resolved_item_var} "${resolved_item}" PARENT_SCOPE) +endfunction(gp_resolve_item) + + +# get_prerequisites target prerequisites_var exclude_system recurse dirs # # Get the list of shared library files required by ${target}. The list in # the variable named ${prerequisites_var} should be empty on first entry to @@ -201,20 +368,25 @@ endfunction(is_file_executable) # recurse is 0 or 1: 0 for direct prerequisites only, 1 for all prerequisites # recursively # -# optional ARGV4 (verbose) is 0 or 1: 0 to skip informational message output, -# 1 to print it +# exepath is the path to the top level executable used for @executable_path +# replacment on the Mac +# +# dirs is a list of paths where libraries might be found: these paths are +# searched first when a target without any path info is given. Then standard +# system locations are also searched: PATH, Framework locations, /usr/lib... # -function(get_prerequisites target prerequisites_var exclude_system recurse) -# set(verbose 0) -# if(NOT "${ARGV4}" STREQUAL "") -# message(STATUS "ARGV4='${ARGV4}'") -# set(verbose "${ARGV4}") -# endif(NOT "${ARGV4}" STREQUAL "") -# message(STATUS "verbose='${verbose}'") +function(get_prerequisites target prerequisites_var exclude_system recurse exepath dirs) set(verbose 0) - set(eol_char "E") + if(NOT IS_ABSOLUTE "${target}") + message("warning: target '${target}' is not absolute...") + endif(NOT IS_ABSOLUTE "${target}") + + if(NOT EXISTS "${target}") + message("warning: target '${target}' does not exist...") + endif(NOT EXISTS "${target}") + # # # Try to choose the right tool by default. Caller can set gp_tool prior to @@ -288,7 +460,10 @@ function(get_prerequisites target prerequisites_var exclude_system recurse) get_filename_component(gp_cmd_dir "${gp_cmd}" PATH) get_filename_component(gp_cmd_dlls_dir "${gp_cmd_dir}/../../Common7/IDE" ABSOLUTE) if(EXISTS "${gp_cmd_dlls_dir}") - set(ENV{PATH} "$ENV{PATH};${gp_cmd_dlls_dir}") + # only add to the path if it is not already in the path + if(NOT "$ENV{PATH}" MATCHES "${gp_cmd_dlls_dir}") + set(ENV{PATH} "$ENV{PATH};${gp_cmd_dlls_dir}") + endif(NOT "$ENV{PATH}" MATCHES "${gp_cmd_dlls_dir}") endif(EXISTS "${gp_cmd_dlls_dir}") endif("${gp_tool}" STREQUAL "dumpbin") # @@ -340,19 +515,11 @@ function(get_prerequisites target prerequisites_var exclude_system recurse) string(REGEX REPLACE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$" "\\3" current_patch_version "${raw_current_version}") endif(gp_regex_cmp_count GREATER 2) - # Using find_program on Windows will find dll files that are in the PATH. - # (Converting simple file names into full path names if found.) + # Use the raw_item as the list entries returned by this function. Use the + # gp_resolve_item function to resolve it to an actual full path file if + # necessary. # - set(item "item-NOTFOUND") - find_program(item "${raw_item}" PATHS "${target_dir}") - if(NOT item) - set(item "${raw_item}") - endif(NOT item) - - if(verbose) - message(STATUS "raw_item='${raw_item}'") - message(STATUS "item='${item}'") - endif(verbose) + set(item "${raw_item}") # Add each item unless it is excluded: # @@ -377,8 +544,12 @@ function(get_prerequisites target prerequisites_var exclude_system recurse) # Add it to unseen_prereqs so that we can recursively add *its* # prerequisites... # + # But first: resolve its name to an absolute full path name such + # that the analysis tools can simply accept it as input. + # if(NOT list_length_before_append EQUAL list_length_after_append) - set(unseen_prereqs ${unseen_prereqs} "${item}") + gp_resolve_item("${target}" "${item}" "${exepath}" "${dirs}" resolved_item) + set(unseen_prereqs ${unseen_prereqs} "${resolved_item}") endif(NOT list_length_before_append EQUAL list_length_after_append) endif(${recurse}) endif(add_item) @@ -394,7 +565,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse) if(${recurse}) set(more_inputs ${unseen_prereqs}) foreach(input ${more_inputs}) - get_prerequisites("${input}" ${prerequisites_var} ${exclude_system} ${recurse}) + get_prerequisites("${input}" ${prerequisites_var} ${exclude_system} ${recurse} "${exepath}" "${dirs}") endforeach(input) endif(${recurse}) @@ -441,8 +612,10 @@ function(list_prerequisites target) set(print_target "${verbose}") set(type_str "") + get_filename_component(exepath "${target}" PATH) + set(prereqs "") - get_prerequisites("${target}" prereqs ${exclude_system} ${all}) + get_prerequisites("${target}" prereqs ${exclude_system} ${all} "${exepath}" "") if(print_target) message(STATUS "File '${target}' depends on:") diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 2b963bf83..7744dfa19 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -26,13 +26,20 @@ IF(MSVC) "${SYSTEMROOT}/system32/msvcr71.dll" ) ENDIF(MSVC71) + + IF(CMAKE_CL_64) + SET(CMAKE_MSVC_ARCH amd64) + ELSE(CMAKE_CL_64) + SET(CMAKE_MSVC_ARCH x86) + ENDIF(CMAKE_CL_64) + IF(MSVC80) # Find the runtime library redistribution directory. - FIND_PATH(MSVC80_REDIST_DIR NAMES x86/Microsoft.VC80.CRT/Microsoft.VC80.CRT.manifest + 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" ) MARK_AS_ADVANCED(MSVC80_REDIST_DIR) - SET(MSVC80_CRT_DIR "${MSVC80_REDIST_DIR}/x86/Microsoft.VC80.CRT") + SET(MSVC80_CRT_DIR "${MSVC80_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.CRT") # Install the manifest that allows DLLs to be loaded from the # directory containing the executable. @@ -45,7 +52,7 @@ IF(MSVC) IF(CMAKE_INSTALL_DEBUG_LIBRARIES) SET(MSVC80_CRT_DIR - "${MSVC80_REDIST_DIR}/Debug_NonRedist/x86/Microsoft.VC80.DebugCRT") + "${MSVC80_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC80.DebugCRT") SET(__install__libs ${__install__libs} "${MSVC80_CRT_DIR}/Microsoft.VC80.DebugCRT.manifest" "${MSVC80_CRT_DIR}/msvcm80d.dll" @@ -57,13 +64,13 @@ IF(MSVC) ENDIF(MSVC80) IF(MSVC90) # Find the runtime library redistribution directory. - FIND_PATH(MSVC90_REDIST_DIR NAMES x86/Microsoft.VC90.CRT/Microsoft.VC90.CRT.manifest + 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" ) MARK_AS_ADVANCED(MSVC90_REDIST_DIR) - SET(MSVC90_CRT_DIR "${MSVC90_REDIST_DIR}/x86/Microsoft.VC90.CRT") + SET(MSVC90_CRT_DIR "${MSVC90_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.CRT") # Install the manifest that allows DLLs to be loaded from the # directory containing the executable. @@ -75,7 +82,7 @@ IF(MSVC) ) IF(CMAKE_INSTALL_DEBUG_LIBRARIES) SET(MSVC90_CRT_DIR - "${MSVC90_REDIST_DIR}/Debug_NonRedist/x86/Microsoft.VC90.DebugCRT") + "${MSVC90_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC90.DebugCRT") SET(__install__libs ${__install__libs} "${MSVC90_CRT_DIR}/Microsoft.VC90.DebugCRT.manifest" "${MSVC90_CRT_DIR}/msvcm90d.dll" @@ -98,7 +105,7 @@ IF(MSVC) IF(MSVC80) IF(CMAKE_INSTALL_DEBUG_LIBRARIES) SET(MSVC80_MFC_DIR - "${MSVC80_REDIST_DIR}/Debug_NonRedist/x86/Microsoft.VC80.DebugMFC") + "${MSVC80_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC80.DebugMFC") SET(__install__libs ${__install__libs} "${MSVC80_MFC_DIR}/Microsoft.VC80.DebugMFC.manifest" "${MSVC80_MFC_DIR}/mfc80d.dll" @@ -108,7 +115,7 @@ IF(MSVC) ) ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES) - SET(MSVC80_MFC_DIR "${MSVC80_REDIST_DIR}/x86/Microsoft.VC80.MFC") + SET(MSVC80_MFC_DIR "${MSVC80_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.MFC") # Install the manifest that allows DLLs to be loaded from the # directory containing the executable. SET(__install__libs ${__install__libs} @@ -119,7 +126,7 @@ IF(MSVC) "${MSVC80_MFC_DIR}/mfcm80u.dll" ) # include the language dll's for vs8 as well as the actuall dll's - SET(MSVC80_MFCLOC_DIR "${MSVC80_REDIST_DIR}/x86/Microsoft.VC80.MFCLOC") + SET(MSVC80_MFCLOC_DIR "${MSVC80_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC80.MFCLOC") # Install the manifest that allows DLLs to be loaded from the # directory containing the executable. SET(__install__libs ${__install__libs} @@ -138,7 +145,7 @@ IF(MSVC) IF(MSVC90) IF(CMAKE_INSTALL_DEBUG_LIBRARIES) SET(MSVC90_MFC_DIR - "${MSVC90_REDIST_DIR}/Debug_NonRedist/x86/Microsoft.VC90.DebugMFC") + "${MSVC90_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC90.DebugMFC") SET(__install__libs ${__install__libs} "${MSVC90_MFC_DIR}/Microsoft.VC90.DebugMFC.manifest" "${MSVC90_MFC_DIR}/mfc90d.dll" @@ -148,7 +155,7 @@ IF(MSVC) ) ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES) - SET(MSVC90_MFC_DIR "${MSVC90_REDIST_DIR}/x86/Microsoft.VC90.MFC") + SET(MSVC90_MFC_DIR "${MSVC90_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.MFC") # Install the manifest that allows DLLs to be loaded from the # directory containing the executable. SET(__install__libs ${__install__libs} @@ -159,7 +166,7 @@ IF(MSVC) "${MSVC90_MFC_DIR}/mfcm90u.dll" ) # include the language dll's for vs9 as well as the actuall dll's - SET(MSVC90_MFCLOC_DIR "${MSVC90_REDIST_DIR}/x86/Microsoft.VC90.MFCLOC") + SET(MSVC90_MFCLOC_DIR "${MSVC90_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC90.MFCLOC") # Install the manifest that allows DLLs to be loaded from the # directory containing the executable. SET(__install__libs ${__install__libs} diff --git a/Modules/MacOSXBundleInfo.plist.in b/Modules/MacOSXBundleInfo.plist.in new file mode 100644 index 000000000..a466dc7c4 --- /dev/null +++ b/Modules/MacOSXBundleInfo.plist.in @@ -0,0 +1,36 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${MACOSX_BUNDLE_EXECUTABLE_NAME} + CFBundleGetInfoString + ${MACOSX_BUNDLE_INFO_STRING} + CFBundleIconFile + ${MACOSX_BUNDLE_ICON_FILE} + CFBundleIdentifier + ${MACOSX_BUNDLE_GUI_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleLongVersionString + ${MACOSX_BUNDLE_LONG_VERSION_STRING} + CFBundleName + ${MACOSX_BUNDLE_BUNDLE_NAME} + CFBundlePackageType + APPL + CFBundleShortVersionString + ${MACOSX_BUNDLE_SHORT_VERSION_STRING} + CFBundleSignature + ???? + CFBundleVersion + ${MACOSX_BUNDLE_BUNDLE_VERSION} + CSResourcesFileMapped + + LSRequiresCarbon + + NSHumanReadableCopyright + ${MACOSX_BUNDLE_COPYRIGHT} + + diff --git a/Modules/MacOSXFrameworkInfo.plist.in b/Modules/MacOSXFrameworkInfo.plist.in new file mode 100644 index 000000000..18eaef2f7 --- /dev/null +++ b/Modules/MacOSXFrameworkInfo.plist.in @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${MACOSX_FRAMEWORK_NAME} + CFBundleIconFile + ${MACOSX_FRAMEWORK_ICON_FILE} + CFBundleIdentifier + ${MACOSX_FRAMEWORK_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleSignature + ???? + CFBundleVersion + ${MACOSX_FRAMEWORK_BUNDLE_VERSION} + CFBundleShortVersionString + ${MACOSX_FRAMEWORK_SHORT_VERSION_STRING} + CSResourcesFileMapped + + + diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in index 2bdca5f28..19017c89b 100755 --- a/Modules/NSIS.template.in +++ b/Modules/NSIS.template.in @@ -36,58 +36,124 @@ ;Set compression SetCompressor @CPACK_NSIS_COMPRESSOR@ + +@CPACK_NSIS_DEFINES@ + + !include Sections.nsh + +;--- Component support macros: --- +; The code for the add/remove functionality is from: +; http://nsis.sourceforge.net/Add/Remove_Functionality +; It has been modified slightly and extended to provide +; inter-component dependencies. +Var AR_SecFlags +Var AR_RegFlags +@CPACK_NSIS_SECTION_SELECTED_VARS@ + +; Loads the "selected" flag for the section named SecName into the +; variable VarName. +!macro LoadSectionSelectedIntoVar SecName VarName + SectionGetFlags ${${SecName}} $${VarName} + IntOp $${VarName} $${VarName} & ${SF_SELECTED} ;Turn off all other bits +!macroend -;-------------------------------- -; determine admin versus local install -; Is install for "AllUsers" or "JustMe"? -; Default to "JustMe" - set to "AllUsers" if admin or on Win9x -; This function is used for the very first "custom page" of the installer. -; This custom page does not show up visibly, but it executes prior to the -; first visible page and sets up $INSTDIR properly... -; Choose different default installation folder based on SV_ALLUSERS... -; "Program Files" for AllUsers, "My Documents" for JustMe... +; Loads the value of a variable... can we get around this? +!macro LoadVar VarName + IntOp $R0 0 + $${VarName} +!macroend -Function .onInit - StrCpy $SV_ALLUSERS "JustMe" - StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@" +; Sets the value of a variable +!macro StoreVar VarName IntValue + IntOp $${VarName} 0 + ${IntValue} +!macroend +!macro InitSection SecName + ; This macro reads component installed flag from the registry and + ;changes checked state of the section on the components page. + ;Input: section index constant name specified in Section command. + ClearErrors - UserInfo::GetName - IfErrors noLM - Pop $0 - UserInfo::GetAccountType - Pop $1 - StrCmp $1 "Admin" 0 +3 - SetShellVarContext all - ;MessageBox MB_OK 'User "$0" is in the Admin group' - StrCpy $SV_ALLUSERS "AllUsers" - Goto done - StrCmp $1 "Power" 0 +3 - SetShellVarContext all - ;MessageBox MB_OK 'User "$0" is in the Power Users group' - StrCpy $SV_ALLUSERS "AllUsers" - Goto done - - noLM: - StrCpy $SV_ALLUSERS "AllUsers" - ;Get installation folder from registry if available - - done: - StrCmp $SV_ALLUSERS "AllUsers" 0 +2 - StrCpy $INSTDIR "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@" - - StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage - !insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini" + ;Reading component status from registry + ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@\Components\${SecName}" "Installed" + IfErrors "default_${SecName}" + ;Status will stay default if registry value not found + ;(component was never installed) + IntOp $AR_RegFlags $AR_RegFlags & ${SF_SELECTED} ;Turn off all other bits + SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading default section flags + IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE ;Turn lowest (enabled) bit off + IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags ;Change lowest bit + + ; Note whether this component was installed before + !insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags + IntOp $R0 $AR_RegFlags & $AR_RegFlags + + ;Writing modified flags + SectionSetFlags ${${SecName}} $AR_SecFlags + + "default_${SecName}:" + !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected +!macroend + +!macro FinishSection SecName + ; This macro reads section flag set by user and removes the section + ;if it is not selected. + ;Then it writes component installed flag to registry + ;Input: section index constant name specified in Section command. + + SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags + ;Checking lowest bit: + IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED} + IntCmp $AR_SecFlags 1 "leave_${SecName}" + ;Section is not selected: + ;Calling Section uninstall macro and writing zero installed flag + !insertmacro "Remove_${${SecName}}" + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@\Components\${SecName}" \ + "Installed" 0 + Goto "exit_${SecName}" + + "leave_${SecName}:" + ;Section is selected: + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@\Components\${SecName}" \ + "Installed" 1 + + "exit_${SecName}:" +!macroend + +!macro RemoveSection SecName + ; This macro is used to call section's Remove_... macro + ;from the uninstaller. + ;Input: section index constant name specified in Section command. + + !insertmacro "Remove_${${SecName}}" +!macroend - noOptionsPage: -FunctionEnd +; Determine whether the selection of SecName changed +!macro MaybeSelectionChanged SecName + !insertmacro LoadVar ${SecName}_selected + SectionGetFlags ${${SecName}} $R1 + IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits + + ; See if the status has changed: + IntCmp $R0 $R1 "${SecName}_unchanged" + !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected + + IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected" + !insertmacro "Deselect_required_by_${SecName}" + goto "${SecName}_unchanged" + + "${SecName}_was_selected:" + !insertmacro "Select_${SecName}_depends" + + "${SecName}_unchanged:" +!macroend +;--- End of Add/Remove macros --- ;-------------------------------- ;Interface Settings !define MUI_HEADERIMAGE !define MUI_ABORTWARNING - + ;-------------------------------- ; path functions @@ -289,7 +355,6 @@ Function un.RemoveFromPath Pop $0 FunctionEnd - ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Uninstall sutff ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -406,10 +471,46 @@ Function ConditionalAddToRegisty ConditionalAddToRegisty_EmptyString: FunctionEnd +;-------------------------------- + +!ifdef CPACK_USES_DOWNLOAD +Function DownloadFile + IfFileExists $INSTDIR\* +2 + CreateDirectory $INSTDIR + Pop $0 + + ; Skip if already downloaded + IfFileExists $INSTDIR\$0 0 +2 + Return + + StrCpy $1 "@CPACK_DOWNLOAD_SITE@" + + try_again: + NSISdl::download "$1/$0" "$INSTDIR\$0" + + Pop $1 + StrCmp $1 "success" success + StrCmp $1 "Cancelled" cancel + MessageBox MB_OK "Download failed: $1" + cancel: + Return + success: +FunctionEnd +!endif + +;-------------------------------- +; Installation types +@CPACK_NSIS_INSTALLATION_TYPES@ + +;-------------------------------- +; Component sections +@CPACK_NSIS_COMPONENT_SECTIONS@ + ;-------------------------------- ; Define some macro setting for the gui @CPACK_NSIS_INSTALLER_MUI_ICON_CODE@ @CPACK_NSIS_INSTALLER_ICON_CODE@ +@CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@ ;-------------------------------- ;Pages @@ -425,16 +526,69 @@ FunctionEnd !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER + @CPACK_NSIS_PAGE_COMPONENTS@ + !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES - + ;-------------------------------- ;Languages - - !insertmacro MUI_LANGUAGE "English" + + !insertmacro MUI_LANGUAGE "English" ;first language is the default language + !insertmacro MUI_LANGUAGE "Albanian" + !insertmacro MUI_LANGUAGE "Arabic" + !insertmacro MUI_LANGUAGE "Basque" + !insertmacro MUI_LANGUAGE "Belarusian" + !insertmacro MUI_LANGUAGE "Bosnian" + !insertmacro MUI_LANGUAGE "Breton" + !insertmacro MUI_LANGUAGE "Bulgarian" + !insertmacro MUI_LANGUAGE "Croatian" + !insertmacro MUI_LANGUAGE "Czech" + !insertmacro MUI_LANGUAGE "Danish" + !insertmacro MUI_LANGUAGE "Dutch" + !insertmacro MUI_LANGUAGE "Estonian" + !insertmacro MUI_LANGUAGE "Farsi" + !insertmacro MUI_LANGUAGE "Finnish" + !insertmacro MUI_LANGUAGE "French" + !insertmacro MUI_LANGUAGE "German" + !insertmacro MUI_LANGUAGE "Greek" + !insertmacro MUI_LANGUAGE "Hebrew" + !insertmacro MUI_LANGUAGE "Hungarian" + !insertmacro MUI_LANGUAGE "Icelandic" + !insertmacro MUI_LANGUAGE "Indonesian" + !insertmacro MUI_LANGUAGE "Irish" + !insertmacro MUI_LANGUAGE "Italian" + !insertmacro MUI_LANGUAGE "Japanese" + !insertmacro MUI_LANGUAGE "Korean" + !insertmacro MUI_LANGUAGE "Kurdish" + !insertmacro MUI_LANGUAGE "Latvian" + !insertmacro MUI_LANGUAGE "Lithuanian" + !insertmacro MUI_LANGUAGE "Luxembourgish" + !insertmacro MUI_LANGUAGE "Macedonian" + !insertmacro MUI_LANGUAGE "Malay" + !insertmacro MUI_LANGUAGE "Mongolian" + !insertmacro MUI_LANGUAGE "Norwegian" + !insertmacro MUI_LANGUAGE "Polish" + !insertmacro MUI_LANGUAGE "Portuguese" + !insertmacro MUI_LANGUAGE "PortugueseBR" + !insertmacro MUI_LANGUAGE "Romanian" + !insertmacro MUI_LANGUAGE "Russian" + !insertmacro MUI_LANGUAGE "Serbian" + !insertmacro MUI_LANGUAGE "SerbianLatin" + !insertmacro MUI_LANGUAGE "SimpChinese" + !insertmacro MUI_LANGUAGE "Slovak" + !insertmacro MUI_LANGUAGE "Slovenian" + !insertmacro MUI_LANGUAGE "Spanish" + !insertmacro MUI_LANGUAGE "Swedish" + !insertmacro MUI_LANGUAGE "Thai" + !insertmacro MUI_LANGUAGE "TradChinese" + !insertmacro MUI_LANGUAGE "Turkish" + !insertmacro MUI_LANGUAGE "Ukrainian" + !insertmacro MUI_LANGUAGE "Welsh" + ;-------------------------------- ;Reserve Files @@ -446,17 +600,15 @@ FunctionEnd ReserveFile "NSIS.InstallOptions.ini" !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS - ;-------------------------------- ;Installer Sections -Section "Installer Section" InstSection - +Section "-Core installation" ;Use the entire tree produced by the INSTALL target. Keep the ;list of directories here in sync with the RMDir commands below. SetOutPath "$INSTDIR" - File /r "${INST_DIR}\*.*" - + @CPACK_NSIS_FULL_INSTALL@ + ;Store installation folder WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR @@ -474,7 +626,21 @@ Section "Installer Section" InstSection Push "UninstallString" Push "$INSTDIR\Uninstall.exe" Call ConditionalAddToRegisty - + Push "NoRepair" + Push "1" + Call ConditionalAddToRegisty + + !ifdef CPACK_NSIS_ADD_REMOVE + ;Create add/remove functionality + Push "ModifyPath" + Push "$INSTDIR\AddRemove.exe" + Call ConditionalAddToRegisty + !else + Push "NoModify" + Push "1" + Call ConditionalAddToRegisty + !endif + ; Optional registration Push "DisplayIcon" Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@" @@ -520,18 +686,18 @@ Section "Installer Section" InstSection SectionEnd -Section "Add to path" +Section "-Add to path" Push $INSTDIR\bin ;Read a value from an InstallOptions INI file !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State" !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State" !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State" - StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0 + StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath + StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0 Call AddToPath doNotAddToPath: SectionEnd - ;-------------------------------- ; Create custom pages Function InstallOptionsPage @@ -563,6 +729,43 @@ Function un.onInit ;Get installation folder from registry if available done: + +FunctionEnd + +;--- Add/Remove callback functions: --- +!macro SectionList MacroName + ;This macro used to perform operation on multiple sections. + ;List all of your components in following manner here. +@CPACK_NSIS_COMPONENT_SECTION_LIST@ +!macroend + +Section -FinishComponents + ;Removes unselected components and writes component status to registry + !insertmacro SectionList "FinishSection" + +!ifdef CPACK_NSIS_ADD_REMOVE + ; Get the name of the installer executable + System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1' + StrCpy $R3 $R0 + + ; Strip off the last 13 characters, to see if we have AddRemove.exe + StrLen $R1 $R0 + IntOp $R1 $R0 - 13 + StrCpy $R2 $R0 13 $R1 + StrCmp $R2 "AddRemove.exe" addremove_installed + + ; We're not running AddRemove.exe, so install it + CopyFiles $R3 $INSTDIR\AddRemove.exe + + addremove_installed: +!endif +SectionEnd +;--- End of Add/Remove callback functions --- + +;-------------------------------- +; Component dependencies +Function .onSelChange + !insertmacro SectionList MaybeSelectionChanged FunctionEnd ;-------------------------------- @@ -590,6 +793,11 @@ Section "Uninstall" @CPACK_NSIS_DELETE_FILES@ @CPACK_NSIS_DELETE_DIRECTORIES@ +!ifdef CPACK_NSIS_ADD_REMOVE + ;Remove the add/remove program + Delete "$INSTDIR\AddRemove.exe" +!endif + ;Remove the uninstaller itself. Delete "$INSTDIR\Uninstall.exe" DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_DIRECTORY@" @@ -600,6 +808,9 @@ Section "Uninstall" ; Remove the registry entries. DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" + ; Removes all optional components + !insertmacro SectionList "RemoveSection" + !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" @@ -646,4 +857,50 @@ Section "Uninstall" doNotRemoveFromPath: SectionEnd +;-------------------------------- +; determine admin versus local install +; Is install for "AllUsers" or "JustMe"? +; Default to "JustMe" - set to "AllUsers" if admin or on Win9x +; This function is used for the very first "custom page" of the installer. +; This custom page does not show up visibly, but it executes prior to the +; first visible page and sets up $INSTDIR properly... +; Choose different default installation folder based on SV_ALLUSERS... +; "Program Files" for AllUsers, "My Documents" for JustMe... + +Function .onInit + ; Reads components status for registry + !insertmacro SectionList "InitSection" + StrCpy $SV_ALLUSERS "JustMe" + StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@" + + ClearErrors + UserInfo::GetName + IfErrors noLM + Pop $0 + UserInfo::GetAccountType + Pop $1 + StrCmp $1 "Admin" 0 +3 + SetShellVarContext all + ;MessageBox MB_OK 'User "$0" is in the Admin group' + StrCpy $SV_ALLUSERS "AllUsers" + Goto done + StrCmp $1 "Power" 0 +3 + SetShellVarContext all + ;MessageBox MB_OK 'User "$0" is in the Power Users group' + StrCpy $SV_ALLUSERS "AllUsers" + Goto done + + noLM: + StrCpy $SV_ALLUSERS "AllUsers" + ;Get installation folder from registry if available + + done: + StrCmp $SV_ALLUSERS "AllUsers" 0 +2 + StrCpy $INSTDIR "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@" + + StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage + !insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini" + + noOptionsPage: +FunctionEnd diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index ecc465ca1..97472cb96 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -27,6 +27,11 @@ SET(CMAKE_SHARED_MODULE_SUFFIX ".so") SET(CMAKE_MODULE_EXISTS 1) SET(CMAKE_DL_LIBS "") +SET(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG -Wl,-compatibility_version,) +SET(CMAKE_C_OSX_CURRENT_VERSION_FLAG -Wl,-current_version,) +SET(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}") +SET(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") + SET(CMAKE_C_LINK_FLAGS "-headerpad_max_install_names") SET(CMAKE_CXX_LINK_FLAGS "-headerpad_max_install_names") @@ -62,7 +67,7 @@ IF(_CMAKE_OSX_SDKS) IF(NOT "$ENV{CMAKE_OSX_SYSROOT}" STREQUAL "") SET(_CMAKE_OSX_SDKS "$ENV{CMAKE_OSX_SYSROOT}") ENDIF(NOT "$ENV{CMAKE_OSX_SYSROOT}" STREQUAL "") - SET(CMAKE_OSX_SYSROOT ${_CMAKE_OSX_SDKS} CACHE STRING + SET(CMAKE_OSX_SYSROOT ${_CMAKE_OSX_SDKS} CACHE PATH "isysroot used for universal binary support") # set _CMAKE_OSX_MACHINE to umame -m EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE _CMAKE_OSX_MACHINE) diff --git a/Modules/Platform/Linux-Intel-C.cmake b/Modules/Platform/Linux-Intel-C.cmake index bde187e15..4b8f6ad75 100755 --- a/Modules/Platform/Linux-Intel-C.cmake +++ b/Modules/Platform/Linux-Intel-C.cmake @@ -4,6 +4,9 @@ SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") SET (CMAKE_C_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") +SET (CMAKE_C_CREATE_PREPROCESSED_SOURCE " -E > ") +SET (CMAKE_C_CREATE_ASSEMBLY_SOURCE " -S -o ") + FIND_PROGRAM(XIAR xiar) IF(XIAR) SET(CMAKE_C_CREATE_STATIC_LIBRARY diff --git a/Modules/Platform/Linux-Intel-CXX.cmake b/Modules/Platform/Linux-Intel-CXX.cmake index bcc3d7877..6ce7f4632 100755 --- a/Modules/Platform/Linux-Intel-CXX.cmake +++ b/Modules/Platform/Linux-Intel-CXX.cmake @@ -4,6 +4,9 @@ SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-Os -DNDEBUG") SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-O3 -DNDEBUG") SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") +SET (CMAKE_CXX_CREATE_PREPROCESSED_SOURCE " -E > ") +SET (CMAKE_CXX_CREATE_ASSEMBLY_SOURCE " -S -o ") + FIND_PROGRAM(XIAR xiar) IF(XIAR) SET(CMAKE_CXX_CREATE_STATIC_LIBRARY diff --git a/Modules/Platform/Linux-PGI-Fortran.cmake b/Modules/Platform/Linux-PGI-Fortran.cmake new file mode 100644 index 000000000..7c99e793e --- /dev/null +++ b/Modules/Platform/Linux-PGI-Fortran.cmake @@ -0,0 +1,9 @@ +SET(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "") + +SET(CMAKE_Fortran_MODDIR_FLAG "-module ") +SET(CMAKE_Fortran_FLAGS_INIT "-Mpreprocess -Kieee -fpic") +SET(CMAKE_Fortran_FLAGS_DEBUG_INIT "-g -O0 -Mbounds") +SET(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-O2 -s") +SET(CMAKE_Fortran_FLAGS_RELEASE_INIT "-fast -O3 -Mipa=fast") +SET(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -gopt") + diff --git a/Modules/Platform/Windows-icl.cmake b/Modules/Platform/Windows-icl.cmake index d6db61bd7..dc40c87c1 100755 --- a/Modules/Platform/Windows-icl.cmake +++ b/Modules/Platform/Windows-icl.cmake @@ -8,7 +8,7 @@ ELSE(CMAKE_VERBOSE_MAKEFILE) ENDIF(CMAKE_VERBOSE_MAKEFILE) # create a shared C++ library SET(CMAKE_CXX_CREATE_SHARED_LIBRARY - "link ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out: /dll ${CMAKE_END_TEMP_FILE}") + "xilink ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out: /dll ${CMAKE_END_TEMP_FILE}") SET(CMAKE_CXX_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) diff --git a/Modules/TestEndianess.c.in b/Modules/TestEndianess.c.in index 68094d4ac..c924f7858 100644 --- a/Modules/TestEndianess.c.in +++ b/Modules/TestEndianess.c.in @@ -10,11 +10,14 @@ const cmakeint16 info_little[] = {0x4854, 0x5349, 0x4920, 0x2053, 0x494c, 0x545 const cmakeint16 info_big[] = {0x5448, 0x4953, 0x2049, 0x5320, 0x4249, 0x4720, 0x454e, 0x4449, 0x414e, 0x2e2e, 0x0000}; #ifdef __CLASSIC_C__ -int main(){ - int ac; - char*av[]; +int main(argc, argv) int argc; char *argv[]; #else -int main(int ac, char*av[]){ +int main(int argc, char *argv[]) #endif - return (&info_little[0] != &info_big[0]); +{ + int require = 0; + require += info_little[argc]; + require += info_big[argc]; + (void)argv; + return require; } diff --git a/Modules/UsePkgConfig.cmake b/Modules/UsePkgConfig.cmake index 23519e80e..5d7d65c08 100644 --- a/Modules/UsePkgConfig.cmake +++ b/Modules/UsePkgConfig.cmake @@ -12,10 +12,10 @@ -FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config PATHS /usr/local/bin ) +FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config ) MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags) - message(STATUS + MESSAGE(STATUS "WARNING: you are using the obsolete 'PKGCONFIG' macro use FindPkgConfig") # reset the variables at the beginning SET(${_include_DIR}) @@ -33,20 +33,24 @@ MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags) EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=includedir OUTPUT_VARIABLE ${_include_DIR} ) - string(REGEX REPLACE "[\r\n]" " " ${_include_DIR} "${${_include_DIR}}") + STRING(REGEX REPLACE "[\r\n]" " " ${_include_DIR} "${${_include_DIR}}") EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=libdir OUTPUT_VARIABLE ${_link_DIR} ) - string(REGEX REPLACE "[\r\n]" " " ${_link_DIR} "${${_link_DIR}}") + STRING(REGEX REPLACE "[\r\n]" " " ${_link_DIR} "${${_link_DIR}}") EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --libs OUTPUT_VARIABLE ${_link_FLAGS} ) - string(REGEX REPLACE "[\r\n]" " " ${_link_FLAGS} "${${_link_FLAGS}}") + STRING(REGEX REPLACE "[\r\n]" " " ${_link_FLAGS} "${${_link_FLAGS}}") EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --cflags OUTPUT_VARIABLE ${_cflags} ) - string(REGEX REPLACE "[\r\n]" " " ${_cflags} "${${_cflags}}") + STRING(REGEX REPLACE "[\r\n]" " " ${_cflags} "${${_cflags}}") + + ELSE( NOT _return_VALUE) + + MESSAGE(STATUS "PKGCONFIG() indicates that ${_package} is not installed (install the package which contains ${_package}.pc if you want to support this feature)") ENDIF(NOT _return_VALUE) diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index 1a6071446..495b999f2 100755 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -36,7 +36,7 @@ IF (QT_USE_QT3SUPPORT) ADD_DEFINITIONS(-DQT3_SUPPORT) ENDIF (QT_USE_QT3SUPPORT) -# list dependent modules, so their modules are automatically on +# list dependent modules, so dependent libraries are added SET(QT_QT3SUPPORT_MODULE_DEPENDS QTGUI QTSQL QTXML QTNETWORK QTCORE) SET(QT_QTSVG_MODULE_DEPENDS QTGUI QTXML QTCORE) SET(QT_QTUITOOLS_MODULE_DEPENDS QTGUI QTXML QTCORE) @@ -50,7 +50,7 @@ FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN QTSCRIPT QTSVG QTUITOOLS QTHELP QTWEBKIT PHONON QTGUI QTTEST QTDBUS QTXML QTSQL QTXMLPATTERNS QTNETWORK QTCORE) - IF (QT_USE_${module}) + IF (QT_USE_${module} OR QT_USE_${module}_DEPENDS) IF (QT_${module}_FOUND) IF(QT_USE_${module}) STRING(REPLACE "QT" "" qt_module_def "${module}") @@ -59,12 +59,12 @@ FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN ENDIF(QT_USE_${module}) SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY} ${QT_${module}_LIB_DEPENDENCIES}) FOREACH(depend_module ${QT_${module}_MODULE_DEPENDS}) - SET(QT_USE_${depend_module} 1) + SET(QT_USE_${depend_module}_DEPENDS 1) ENDFOREACH(depend_module ${QT_${module}_MODULE_DEPENDS}) ELSE (QT_${module}_FOUND) MESSAGE("Qt ${module} library not found.") ENDIF (QT_${module}_FOUND) - ENDIF (QT_USE_${module}) + ENDIF (QT_USE_${module} OR QT_USE_${module}_DEPENDS) ENDFOREACH(module) diff --git a/Modules/readme.txt b/Modules/readme.txt index 8d4615a2c..8e4474ead 100644 --- a/Modules/readme.txt +++ b/Modules/readme.txt @@ -67,20 +67,25 @@ line. A FindXXX.cmake module will typically be loaded by the command - FIND_PACKAGE(XXX [major[.minor[.patch]]] [EXACT] + FIND_PACKAGE(XXX [major[.minor[.patch[.tweak]]]] [EXACT] [QUIET] [REQUIRED [components...]]) If any version numbers are given to the command it will set the -variable XXX_FIND_VERSION to contain the whole version. The variables -XXX_FIND_VERSION_MAJOR, XXX_FIND_VERSION_MINOR, and -XXX_FIND_VERSION_PATCH will be set to contain the corresponding -portions of the version number. The variable XXX_FIND_VERSION_EXACT -will indicate whether an exact version is requested. +following variables before loading the module: + + XXX_FIND_VERSION = full requested version string + XXX_FIND_VERSION_MAJOR = major version if requested, else 0 + XXX_FIND_VERSION_MINOR = minor version if requested, else 0 + XXX_FIND_VERSION_PATCH = patch version if requested, else 0 + XXX_FIND_VERSION_TWEAK = tweak version if requested, else 0 + XXX_FIND_VERSION_COUNT = number of version components, 0 to 4 + XXX_FIND_VERSION_EXACT = true if EXACT option was given + If the find module supports versioning it should locate a version of the package that is compatible with the version requested. If a compatible version of the package cannot be found the module should not report success. The version of the package found should be stored -in the version variables named above. +in "XXX_VERSION..." version variables docmented by the module. If the QUIET option is given to the command it will set the variable XXX_FIND_QUIETLY to true before loading the FindXXX.cmake module. If diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 89e5d4674..b4a04f522 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -302,6 +302,19 @@ IF(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW) TARGET_LINK_LIBRARIES(CMakeLib rpcrt4) ENDIF(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW) +# With the Microsoft compiler (for _bstr_t support used from +# cmCallVisualStudioMacro) we need the comsupp lib. Needed when +# _MSC_VER and HAVE_COMDEF_H are defined... +# +IF(MSVC) + IF(MSVC60) + # comsuppd did not yet exist in VS6 + TARGET_LINK_LIBRARIES(CMakeLib comsupp) + ELSE(MSVC60) + TARGET_LINK_LIBRARIES(CMakeLib optimized comsupp debug comsuppd) + ENDIF(MSVC60) +ENDIF(MSVC) + # # CTestLib # @@ -347,6 +360,7 @@ TARGET_LINK_LIBRARIES(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES} ${CMAKE_XMLRPC_L # Sources for CPack # SET(CPACK_SRCS + CPack/cmCPackComponentGroup.cxx CPack/cmCPackGeneratorFactory.cxx CPack/cmCPackGenerator.cxx CPack/cmCPackLog.cxx @@ -374,6 +388,7 @@ ENDIF(UNIX) IF(APPLE) SET(CPACK_SRCS ${CPACK_SRCS} + CPack/cmCPackBundleGenerator.cxx CPack/cmCPackOSXX11Generator.cxx CPack/cmCPackPackageMakerGenerator.cxx ) diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx new file mode 100644 index 000000000..d23618016 --- /dev/null +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -0,0 +1,359 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmCPackBundleGenerator.cxx,v $ + Language: C++ + Date: $Date: 2008-07-22 18:04:24 $ + Version: $Revision: 1.2.2.3 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "cmCPackBundleGenerator.h" +#include "cmCPackLog.h" +#include "cmSystemTools.h" + +//---------------------------------------------------------------------- +cmCPackBundleGenerator::cmCPackBundleGenerator() +{ +} + +//---------------------------------------------------------------------- +cmCPackBundleGenerator::~cmCPackBundleGenerator() +{ +} + +//---------------------------------------------------------------------- +int cmCPackBundleGenerator::InitializeInternal() +{ + const std::string hdiutil_path = cmSystemTools::FindProgram("hdiutil", + std::vector(), false); + if(hdiutil_path.empty()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot locate hdiutil command" + << std::endl); + return 0; + } + this->SetOptionIfNotSet("CPACK_COMMAND_HDIUTIL", hdiutil_path.c_str()); + + const std::string setfile_path = cmSystemTools::FindProgram("SetFile", + std::vector(1, "/Developer/Tools"), false); + if(setfile_path.empty()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot locate SetFile command" + << std::endl); + return 0; + } + this->SetOptionIfNotSet("CPACK_COMMAND_SETFILE", setfile_path.c_str()); + + return this->Superclass::InitializeInternal(); +} + +//---------------------------------------------------------------------- +const char* cmCPackBundleGenerator::GetOutputExtension() +{ + return ".dmg"; +} + +//---------------------------------------------------------------------- +const char* cmCPackBundleGenerator::GetPackagingInstallPrefix() +{ + this->InstallPrefix = "/"; + this->InstallPrefix += this->GetOption("CPACK_BUNDLE_NAME"); + this->InstallPrefix += ".app/Contents/Resources"; + + return this->InstallPrefix.c_str(); +} + +//---------------------------------------------------------------------- +int cmCPackBundleGenerator::CompressFiles(const char* outFileName, + const char* toplevel, const std::vector& files) +{ + (void) files; + + // Get required arguments ... + const std::string cpack_bundle_name = this->GetOption("CPACK_BUNDLE_NAME") ? this->GetOption("CPACK_BUNDLE_NAME") : ""; + if(cpack_bundle_name.empty()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_BUNDLE_NAME must be set." + << std::endl); + + return 0; + } + + const std::string cpack_bundle_plist = this->GetOption("CPACK_BUNDLE_PLIST") ? this->GetOption("CPACK_BUNDLE_PLIST") : ""; + if(cpack_bundle_plist.empty()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_BUNDLE_PLIST must be set." + << std::endl); + + return 0; + } + + const std::string cpack_bundle_icon = this->GetOption("CPACK_BUNDLE_ICON") ? this->GetOption("CPACK_BUNDLE_ICON") : ""; + if(cpack_bundle_icon.empty()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_BUNDLE_ICON must be set." + << std::endl); + + return 0; + } + + const std::string cpack_bundle_startup_command = this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND") ? this->GetOption("CPACK_BUNDLE_STARTUP_COMMAND") : ""; + if(cpack_bundle_startup_command.empty()) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "CPACK_BUNDLE_STARTUP_COMMAND must be set." + << std::endl); + + return 0; + } + + // Get optional arguments ... + const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON") ? this->GetOption("CPACK_PACKAGE_ICON") : ""; + + // The staging directory contains everything that will end-up inside the + // final disk image ... + cmOStringStream staging; + staging << toplevel; + + cmOStringStream contents; + contents << staging.str() << "/" << cpack_bundle_name + << ".app/" << "Contents"; + + cmOStringStream application; + application << contents.str() << "/" << "MacOS"; + + cmOStringStream resources; + resources << contents.str() << "/" << "Resources"; + + // Install a required, user-provided bundle metadata file ... + cmOStringStream plist_source; + plist_source << cpack_bundle_plist; + + cmOStringStream plist_target; + plist_target << contents.str() << "/" << "Info.plist"; + + if(!this->CopyFile(plist_source, plist_target)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error copying plist. Check the value of CPACK_BUNDLE_PLIST." + << std::endl); + + return 0; + } + + // Install a user-provided bundle icon ... + cmOStringStream icon_source; + icon_source << cpack_bundle_icon; + + cmOStringStream icon_target; + icon_target << resources.str() << "/" << cpack_bundle_name << ".icns"; + + if(!this->CopyFile(icon_source, icon_target)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error copying bundle icon. Check the value of CPACK_BUNDLE_ICON." + << std::endl); + + return 0; + } + + // Install a user-provided startup command (could be an executable or a + // script) ... + cmOStringStream command_source; + command_source << cpack_bundle_startup_command; + + cmOStringStream command_target; + command_target << application.str() << "/" << cpack_bundle_name; + + if(!this->CopyFile(command_source, command_target)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error copying startup command. Check the value of CPACK_BUNDLE_STARTUP_COMMAND." + << std::endl); + + return 0; + } + + cmSystemTools::SetPermissions(command_target.str().c_str(), 0777); + + // Add a symlink to /Applications so users can drag-and-drop the bundle + // into it + cmOStringStream application_link; + application_link << staging.str() << "/Applications"; + cmSystemTools::CreateSymlink("/Applications", + application_link.str().c_str()); + + // Optionally add a custom volume icon ... + if(!cpack_package_icon.empty()) + { + cmOStringStream package_icon_source; + package_icon_source << cpack_package_icon; + + cmOStringStream package_icon_destination; + package_icon_destination << staging.str() << "/.VolumeIcon.icns"; + + if(!this->CopyFile(package_icon_source, package_icon_destination)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error copying disk volume icon. Check the value of CPACK_PACKAGE_ICON." + << std::endl); + + return 0; + } + } + + // Create a temporary read-write disk image ... + cmOStringStream temp_image; + temp_image << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/temp.dmg"; + + cmOStringStream temp_image_command; + temp_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); + temp_image_command << " create"; + temp_image_command << " -ov"; + temp_image_command << " -srcfolder \"" << staging.str() << "\""; + temp_image_command << " -volname \"" + << this->GetOption("CPACK_PACKAGE_FILE_NAME") << "\""; + temp_image_command << " -format UDRW"; + temp_image_command << " \"" << temp_image.str() << "\""; + + if(!this->RunCommand(temp_image_command)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error generating temporary disk image." + << std::endl); + + return 0; + } + + // Optionally set the custom icon flag for the image ... + if(!cpack_package_icon.empty()) + { + cmOStringStream temp_mount; + temp_mount << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/mnt"; + cmSystemTools::MakeDirectory(temp_mount.str().c_str()); + + cmOStringStream attach_command; + attach_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); + attach_command << " attach"; + attach_command << " -mountpoint \"" << temp_mount.str() << "\""; + attach_command << " \"" << temp_image.str() << "\""; + + if(!this->RunCommand(attach_command)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error attaching temporary disk image." + << std::endl); + + return 0; + } + + cmOStringStream setfile_command; + setfile_command << this->GetOption("CPACK_COMMAND_SETFILE"); + setfile_command << " -a C"; + setfile_command << " \"" << temp_mount.str() << "\""; + + if(!this->RunCommand(setfile_command)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error assigning custom icon to temporary disk image." + << std::endl); + + return 0; + } + + cmOStringStream detach_command; + detach_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); + detach_command << " detach"; + detach_command << " \"" << temp_mount.str() << "\""; + + if(!this->RunCommand(detach_command)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error detaching temporary disk image." + << std::endl); + + return 0; + } + } + + // Create the final compressed read-only disk image ... + cmOStringStream final_image_command; + final_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL"); + final_image_command << " convert \"" << temp_image.str() << "\""; + final_image_command << " -format UDZO"; + final_image_command << " -imagekey"; + final_image_command << " zlib-level=9"; + final_image_command << " -o \"" << outFileName << "\""; + + if(!this->RunCommand(final_image_command)) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error compressing disk image." + << std::endl); + + return 0; + } + + return 1; +} + +//---------------------------------------------------------------------- +bool cmCPackBundleGenerator::CopyFile(cmOStringStream& source, + cmOStringStream& target) +{ + if(!cmSystemTools::CopyFileIfDifferent( + source.str().c_str(), + target.str().c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error copying " + << source.str() + << " to " + << target.str() + << std::endl); + + return false; + } + + return true; +} + +//---------------------------------------------------------------------- +bool cmCPackBundleGenerator::RunCommand(cmOStringStream& command) +{ + std::string output; + int exit_code = 1; + + bool result = cmSystemTools::RunSingleCommand( + command.str().c_str(), + &output, + &exit_code, + 0, + this->GeneratorVerbose, + 0); + + if(!result || exit_code) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error executing: " + << command.str() + << std::endl); + + return false; + } + + return true; +} diff --git a/Source/CPack/cmCPackBundleGenerator.h b/Source/CPack/cmCPackBundleGenerator.h new file mode 100644 index 000000000..a41efa9c0 --- /dev/null +++ b/Source/CPack/cmCPackBundleGenerator.h @@ -0,0 +1,49 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmCPackBundleGenerator.h,v $ + Language: C++ + Date: $Date: 2008-06-25 13:51:33 $ + Version: $Revision: 1.1.2.2 $ + + Copyright (c) 2002 Kitware, Inc. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef cmCPackBundleGenerator_h +#define cmCPackBundleGenerator_h + +#include "cmCPackGenerator.h" + +/** \class cmCPackBundleGenerator + * \brief A generator for OSX bundles + * + * Based on Gimp.app + */ +class cmCPackBundleGenerator : public cmCPackGenerator +{ +public: + cmCPackTypeMacro(cmCPackBundleGenerator, cmCPackGenerator); + + cmCPackBundleGenerator(); + virtual ~cmCPackBundleGenerator(); + +protected: + virtual int InitializeInternal(); + virtual const char* GetOutputExtension(); + virtual const char* GetPackagingInstallPrefix(); + int CompressFiles(const char* outFileName, const char* toplevel, + const std::vector& files); + + bool CopyFile(cmOStringStream& source, cmOStringStream& target); + bool RunCommand(cmOStringStream& command); + + std::string InstallPrefix; +}; + +#endif diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx new file mode 100644 index 000000000..052adcd4b --- /dev/null +++ b/Source/CPack/cmCPackComponentGroup.cxx @@ -0,0 +1,49 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmCPackComponentGroup.cxx,v $ + Language: C++ + Date: $Date: 2008-07-14 13:22:45 $ + Version: $Revision: 1.1.2.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "cmCPackComponentGroup.h" +#include "cmSystemTools.h" +#include +#include + +//---------------------------------------------------------------------- +unsigned long cmCPackComponent::GetInstalledSize(const char* installDir) const +{ + if (this->TotalSize != 0) + { + return this->TotalSize; + } + + std::vector::const_iterator fileIt; + for (fileIt = this->Files.begin(); fileIt != this->Files.end(); ++fileIt) + { + std::string path = installDir; + path += '/'; + path += *fileIt; + this->TotalSize += cmSystemTools::FileLength(path.c_str()); + } + + return this->TotalSize; +} + +//---------------------------------------------------------------------- +unsigned long +cmCPackComponent::GetInstalledSizeInKbytes(const char* installDir) const +{ + unsigned long result = (GetInstalledSize(installDir) + 512) / 1024; + return result? result : 1; +} diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h new file mode 100644 index 000000000..74b4f9967 --- /dev/null +++ b/Source/CPack/cmCPackComponentGroup.h @@ -0,0 +1,143 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: cmCPackComponentGroup.h,v $ + Language: C++ + Date: $Date: 2008-07-13 21:55:24 $ + Version: $Revision: 1.1.2.3 $ + + Copyright (c) 2002 Kitware, Inc. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef cmCPackComponentGroup_h +#define cmCPackComponentGroup_h + +#include "cmStandardIncludes.h" + +class cmCPackComponentGroup; + +/** \class cmCPackInstallationType + * \brief A certain type of installation, which encompasses a + * set of components. + */ +class cmCPackInstallationType +{ +public: + /// The name of the installation type (used to reference this + /// installation type). + std::string Name; + + /// The name of the installation type as displayed to the user. + std::string DisplayName; + + /// The index number of the installation type. This is an arbitrary + /// numbering from 1 to the number of installation types. + unsigned Index; +}; + +/** \class cmCPackComponent + * \brief A single component to be installed by CPack. + */ +class cmCPackComponent +{ +public: + cmCPackComponent() : Group(0), TotalSize(0) { } + + /// The name of the component (used to reference the component). + std::string Name; + + /// The name of the component as displayed to the user. + std::string DisplayName; + + /// The component group that contains this component (if any). + cmCPackComponentGroup *Group; + + /// Whether this component group must always be installed. + bool IsRequired : 1; + + /// Whether this component group is hidden. A hidden component group + /// is always installed. However, it may still be shown to the user. + bool IsHidden : 1; + + /// Whether this component defaults to "disabled". + bool IsDisabledByDefault : 1; + + /// Whether this component should be downloaded on-the-fly. If false, + /// the component will be a part of the installation package. + bool IsDownloaded : 1; + + /// A description of this component. + std::string Description; + + /// The installation types that this component is a part of. + std::vector InstallationTypes; + + /// If IsDownloaded is true, the name of the archive file that + /// contains the files that are part of this component. + std::string ArchiveFile; + + /// The components that this component depends on. + std::vector Dependencies; + + /// The components that depend on this component. + std::vector ReverseDependencies; + + /// The list of installed files that are part of this component. + std::vector Files; + + /// The list of installed directories that are part of this component. + std::vector Directories; + + /// Get the total installed size of all of the files in this + /// component, in bytes. installDir is the directory into which the + /// component was installed. + unsigned long GetInstalledSize(const char* installDir) const; + + /// Identical to GetInstalledSize, but returns the result in + /// kilobytes. + unsigned long GetInstalledSizeInKbytes(const char* installDir) const; + + private: + mutable unsigned long TotalSize; +}; + +/** \class cmCPackComponentGroup + * \brief A component group to be installed by CPack. + */ +class cmCPackComponentGroup +{ +public: + cmCPackComponentGroup() : ParentGroup(0) { } + + /// The name of the group (used to reference the group). + std::string Name; + + /// The name of the component as displayed to the user. + std::string DisplayName; + + /// The description of this component group. + std::string Description; + + /// Whether the name of the component will be shown in bold. + bool IsBold : 1; + + /// Whether the section should be expanded by default + bool IsExpandedByDefault : 1; + + /// The components within this group. + std::vector Components; + + /// The parent group of this component group (if any). + cmCPackComponentGroup *ParentGroup; + + /// The subgroups of this group. + std::vector Subgroups; +}; + +#endif diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index b34d2f9e9..30f5e08e3 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCPackDebGenerator.cxx,v $ Language: C++ - Date: $Date: 2008-04-02 13:16:12 $ - Version: $Revision: 1.20.2.2 $ + Date: $Date: 2008-09-12 14:56:21 $ + Version: $Revision: 1.20.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -116,6 +116,17 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName, { out << "Suggests: " << debian_pkg_sug << "\n"; } + unsigned long totalSize = 0; + { + std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); + dirName += '/'; + for (std::vector::const_iterator fileIt = files.begin(); + fileIt != files.end(); ++ fileIt ) + { + totalSize += cmSystemTools::FileLength(fileIt->c_str()); + } + } + out << "Installed-Size: " << totalSize << "\n"; out << "Maintainer: " << maintainer << "\n"; out << "Description: " << desc << "\n"; out << std::endl; diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index c161b6282..54b6c01f7 100755 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCPackGenerator.cxx,v $ Language: C++ - Date: $Date: 2008-03-13 01:54:27 $ - Version: $Revision: 1.6 $ + Date: $Date: 2008-09-24 14:07:49 $ + Version: $Revision: 1.6.2.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -23,6 +23,7 @@ #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" #include "cmGeneratedFileStream.h" +#include "cmCPackComponentGroup.h" #include #include @@ -101,13 +102,6 @@ int cmCPackGenerator::PrepareNames() std::string destFile = pdir; destFile += "/" + outName; std::string outFile = topDirectory + "/" + outName; - bool setDestDir = cmSystemTools::IsOn(this->GetOption("CPACK_SET_DESTDIR")); - std::string installPrefix = tempDirectory; - if (!setDestDir) - { - installPrefix += this->GetPackagingInstallPrefix(); - } - this->SetOptionIfNotSet("CPACK_TOPLEVEL_DIRECTORY", topDirectory.c_str()); this->SetOptionIfNotSet("CPACK_TEMPORARY_DIRECTORY", tempDirectory.c_str()); this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_NAME", outName.c_str()); @@ -118,7 +112,7 @@ int cmCPackGenerator::PrepareNames() this->SetOptionIfNotSet("CPACK_NATIVE_INSTALL_DIRECTORY", cmsys::SystemTools::ConvertToOutputPath(this->GetInstallPath()).c_str()); this->SetOptionIfNotSet("CPACK_TEMPORARY_INSTALL_DIRECTORY", - installPrefix.c_str()); + tempDirectory.c_str()); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for: CPACK_PACKAGE_DESCRIPTION_FILE" << std::endl); @@ -172,11 +166,19 @@ int cmCPackGenerator::InstallProject() { cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Install projects" << std::endl); this->CleanTemporaryDirectory(); - std::string tempInstallDirectoryWithPostfix + + std::string bareTempInstallDirectory = this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY"); - const char* tempInstallDirectory = tempInstallDirectoryWithPostfix.c_str(); + std::string tempInstallDirectoryStr = bareTempInstallDirectory; + bool setDestDir = cmSystemTools::IsOn(this->GetOption("CPACK_SET_DESTDIR")); + if (!setDestDir) + { + tempInstallDirectoryStr += this->GetPackagingInstallPrefix(); + } + + const char* tempInstallDirectory = tempInstallDirectoryStr.c_str(); int res = 1; - if ( !cmsys::SystemTools::MakeDirectory(tempInstallDirectory)) + if ( !cmsys::SystemTools::MakeDirectory(bareTempInstallDirectory.c_str())) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem creating temporary directory: " @@ -185,7 +187,6 @@ int cmCPackGenerator::InstallProject() return 0; } - bool setDestDir = cmSystemTools::IsOn(this->GetOption("CPACK_SET_DESTDIR")); if ( setDestDir ) { std::string destDir = "DESTDIR="; @@ -227,7 +228,7 @@ int cmCPackGenerator::InstallProject() // If the project is a CMAKE project then run pre-install // and then read the cmake_install script to run it if ( !this->InstallProjectViaInstallCMakeProjects( - setDestDir, tempInstallDirectory) ) + setDestDir, bareTempInstallDirectory.c_str()) ) { return 0; } @@ -244,8 +245,7 @@ int cmCPackGenerator::InstallProject() int cmCPackGenerator::InstallProjectViaInstallCommands( bool setDestDir, const char* tempInstallDirectory) { - (void)setDestDir; - (void)tempInstallDirectory; + (void) setDestDir; const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS"); if ( installCommands && *installCommands ) { @@ -454,7 +454,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript( //---------------------------------------------------------------------- int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( - bool setDestDir, const char* tempInstallDirectory) + bool setDestDir, const char* baseTempInstallDirectory) { const char* cmakeProjects = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS"); @@ -502,6 +502,51 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( std::string installSubDirectory = it->c_str(); std::string installFile = installDirectory + "/cmake_install.cmake"; + std::vector componentsVector; + + bool componentInstall = false; + if (this->SupportsComponentInstallation()) + { + // Determine the installation types for this project (if provided). + std::string installTypesVar = "CPACK_" + + cmSystemTools::UpperCase(installComponent) + "_INSTALL_TYPES"; + const char *installTypes = this->GetOption(installTypesVar.c_str()); + if (installTypes && *installTypes) + { + std::vector installTypesVector; + cmSystemTools::ExpandListArgument(installTypes, installTypesVector); + std::vector::iterator installTypeIt; + for (installTypeIt = installTypesVector.begin(); + installTypeIt != installTypesVector.end(); + ++installTypeIt) + { + this->GetInstallationType(installProjectName.c_str(), + installTypeIt->c_str()); + } + } + + // Determine the set of components that will be used in this project + std::string componentsVar + = "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(installComponent); + const char *components = this->GetOption(componentsVar.c_str()); + if (components && *components) + { + cmSystemTools::ExpandListArgument(components, componentsVector); + std::vector::iterator compIt; + for (compIt = componentsVector.begin(); + compIt != componentsVector.end(); + ++compIt) + { + GetComponent(installProjectName.c_str(), compIt->c_str()); + } + componentInstall = true; + } + } + if (componentsVector.empty()) + { + componentsVector.push_back(installComponent); + } + const char* buildConfig = this->GetOption("CPACK_BUILD_CONFIG"); cmGlobalGenerator* globalGenerator = this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator( @@ -555,72 +600,116 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install project: " << installProjectName << std::endl); - cmake cm; - cm.AddCMakePaths(); - cm.SetProgressCallback(cmCPackGeneratorProgress, this); - cmGlobalGenerator gg; - gg.SetCMakeInstance(&cm); - std::auto_ptr lg(gg.CreateLocalGenerator()); - lg->SetGlobalGenerator(&gg); - cmMakefile *mf = lg->GetMakefile(); - std::string realInstallDirectory = tempInstallDirectory; - if ( !installSubDirectory.empty() && installSubDirectory != "/" ) - { - realInstallDirectory += installSubDirectory; - } - if ( setDestDir ) + // Run the installation for each component + std::vector::iterator componentIt; + for (componentIt = componentsVector.begin(); + componentIt != componentsVector.end(); + ++componentIt) { - // For DESTDIR based packaging, use the *project* CMAKE_INSTALL_PREFIX - // underneath the tempInstallDirectory. The value of the project's - // CMAKE_INSTALL_PREFIX is sent in here as the value of the - // CPACK_INSTALL_PREFIX variable. - std::string dir; - if (this->GetOption("CPACK_INSTALL_PREFIX")) + std::string tempInstallDirectory = baseTempInstallDirectory; + installComponent = *componentIt; + if (componentInstall) { - dir += this->GetOption("CPACK_INSTALL_PREFIX"); + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Install component: " << installComponent + << std::endl); + } + + cmake cm; + cm.AddCMakePaths(); + cm.SetProgressCallback(cmCPackGeneratorProgress, this); + cmGlobalGenerator gg; + gg.SetCMakeInstance(&cm); + std::auto_ptr lg(gg.CreateLocalGenerator()); + lg->SetGlobalGenerator(&gg); + cmMakefile *mf = lg->GetMakefile(); + std::string realInstallDirectory = tempInstallDirectory; + if ( !installSubDirectory.empty() && installSubDirectory != "/" ) + { + realInstallDirectory += installSubDirectory; + } + if (componentInstall) + { + tempInstallDirectory += "/"; + tempInstallDirectory += installComponent; } - mf->AddDefinition("CMAKE_INSTALL_PREFIX", dir.c_str()); - cmCPackLogger(cmCPackLog::LOG_DEBUG, - "- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf->AddDefinition)" - << std::endl); - cmCPackLogger(cmCPackLog::LOG_DEBUG, - "- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'" << std::endl); - } - else - { - mf->AddDefinition("CMAKE_INSTALL_PREFIX", tempInstallDirectory); + if (!setDestDir) + { + tempInstallDirectory += this->GetPackagingInstallPrefix(); + } - cmCPackLogger(cmCPackLog::LOG_DEBUG, - "- Using non-DESTDIR install... (mf->AddDefinition)" << std::endl); - cmCPackLogger(cmCPackLog::LOG_DEBUG, - "- Setting CMAKE_INSTALL_PREFIX to '" << tempInstallDirectory - << "'" << std::endl); - } + if ( setDestDir ) + { + // For DESTDIR based packaging, use the *project* CMAKE_INSTALL_PREFIX + // underneath the tempInstallDirectory. The value of the project's + // CMAKE_INSTALL_PREFIX is sent in here as the value of the + // CPACK_INSTALL_PREFIX variable. + std::string dir; + if (this->GetOption("CPACK_INSTALL_PREFIX")) + { + dir += this->GetOption("CPACK_INSTALL_PREFIX"); + } + mf->AddDefinition("CMAKE_INSTALL_PREFIX", dir.c_str()); - if ( buildConfig && *buildConfig ) - { - mf->AddDefinition("BUILD_TYPE", buildConfig); - } - std::string installComponentLowerCase - = cmSystemTools::LowerCase(installComponent); - if ( installComponentLowerCase != "all" ) - { - mf->AddDefinition("CMAKE_INSTALL_COMPONENT", - installComponent.c_str()); - } + if ( !cmsys::SystemTools::MakeDirectory(dir.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem creating temporary directory: " + << dir << std::endl); + return 0; + } - // strip on TRUE, ON, 1, one or several file names, but not on - // FALSE, OFF, 0 and an empty string - if (!cmSystemTools::IsOff(this->GetOption("CPACK_STRIP_FILES"))) - { - mf->AddDefinition("CMAKE_INSTALL_DO_STRIP", "1"); - } - int res = mf->ReadListFile(0, installFile.c_str()); - if ( cmSystemTools::GetErrorOccuredFlag() || !res ) - { - return 0; + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "- Using DESTDIR + CPACK_INSTALL_PREFIX... (mf->AddDefinition)" + << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "- Setting CMAKE_INSTALL_PREFIX to '" << dir << "'" + << std::endl); + } + else + { + mf->AddDefinition("CMAKE_INSTALL_PREFIX", tempInstallDirectory.c_str()); + + if ( !cmsys::SystemTools::MakeDirectory(tempInstallDirectory.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem creating temporary directory: " + << tempInstallDirectory << std::endl); + return 0; + } + + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "- Using non-DESTDIR install... (mf->AddDefinition)" << std::endl); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "- Setting CMAKE_INSTALL_PREFIX to '" << tempInstallDirectory + << "'" << std::endl); + } + + if ( buildConfig && *buildConfig ) + { + mf->AddDefinition("BUILD_TYPE", buildConfig); + } + std::string installComponentLowerCase + = cmSystemTools::LowerCase(installComponent); + if ( installComponentLowerCase != "all" ) + { + mf->AddDefinition("CMAKE_INSTALL_COMPONENT", + installComponent.c_str()); + } + + // strip on TRUE, ON, 1, one or several file names, but not on + // FALSE, OFF, 0 and an empty string + if (!cmSystemTools::IsOff(this->GetOption("CPACK_STRIP_FILES"))) + { + mf->AddDefinition("CMAKE_INSTALL_DO_STRIP", "1"); + } + int res = mf->ReadListFile(0, installFile.c_str()); + if ( cmSystemTools::GetErrorOccuredFlag() || !res ) + { + return 0; + } } } } @@ -709,7 +798,6 @@ int cmCPackGenerator::DoPackage() const char* packageFileName = this->GetOption("CPACK_OUTPUT_FILE_PATH"); const char* tempDirectory = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl); cmsys::Glob gl; std::string findExpr = tempDirectory; @@ -736,8 +824,33 @@ int cmCPackGenerator::DoPackage() { tempDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); } + + // The files to be installed + std::vector 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 ) + { + std::string fileN = cmSystemTools::RelativePath(tempDirectory, + 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); + } + } + if ( !this->CompressFiles(tempPackageFileName, - tempDirectory, gl.GetFiles()) || cmSystemTools::GetErrorOccuredFlag()) + tempDirectory, files) || cmSystemTools::GetErrorOccuredFlag()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory" << std::endl); @@ -768,12 +881,11 @@ int cmCPackGenerator::DoPackage() } //---------------------------------------------------------------------- -int cmCPackGenerator::Initialize(const char* name, cmMakefile* mf, - const char* argv0) +int cmCPackGenerator::Initialize(const char* name, cmMakefile* mf) { this->MakefileMap = mf; this->Name = name; - if ( !this->FindRunningCMake(argv0) ) + if ( !this->SetCMakeRoot() ) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot initialize the generator" << std::endl); @@ -829,165 +941,29 @@ const char* cmCPackGenerator::GetOption(const char* op) } //---------------------------------------------------------------------- -int cmCPackGenerator::FindRunningCMake(const char* arg0) +int cmCPackGenerator::SetCMakeRoot() { - int found = 0; - // Find our own executable. - std::vector failures; - this->CPackSelf = arg0; - cmSystemTools::ConvertToUnixSlashes(this->CPackSelf); - failures.push_back(this->CPackSelf); - this->CPackSelf = cmSystemTools::FindProgram(this->CPackSelf.c_str()); - if(!cmSystemTools::FileExists(this->CPackSelf.c_str())) - { - failures.push_back(this->CPackSelf); - this->CPackSelf = "/usr/local/bin/ctest"; - } - if(!cmSystemTools::FileExists(this->CPackSelf.c_str())) - { - failures.push_back(this->CPackSelf); - cmOStringStream msg; - msg << "CPack can not find the command line program ctest.\n"; - msg << " argv[0] = \"" << arg0 << "\"\n"; - msg << " Attempted paths:\n"; - std::vector::iterator i; - for(i=failures.begin(); i != failures.end(); ++i) - { - msg << " \"" << i->c_str() << "\"\n"; - } - cmCPackLogger(cmCPackLog::LOG_ERROR, msg.str().c_str() - << std::endl); - return 0; - } - std::string dir; - std::string file; - if(cmSystemTools::SplitProgramPath(this->CPackSelf.c_str(), - dir, file, true)) - { - this->CMakeSelf = dir += "/cmake"; - this->CMakeSelf += cmSystemTools::GetExecutableExtension(); - if(cmSystemTools::FileExists(this->CMakeSelf.c_str())) - { - found = 1; - } - } - if ( !found ) - { - failures.push_back(this->CMakeSelf); -#ifdef CMAKE_BUILD_DIR - std::string intdir = "."; -#ifdef CMAKE_INTDIR - intdir = CMAKE_INTDIR; -#endif - this->CMakeSelf = CMAKE_BUILD_DIR; - this->CMakeSelf += "/bin/"; - this->CMakeSelf += intdir; - this->CMakeSelf += "/cmake"; - this->CMakeSelf += cmSystemTools::GetExecutableExtension(); -#endif - if(!cmSystemTools::FileExists(this->CMakeSelf.c_str())) - { - failures.push_back(this->CMakeSelf); - cmOStringStream msg; - msg << "CPack can not find the command line program cmake.\n"; - msg << " argv[0] = \"" << arg0 << "\"\n"; - msg << " Attempted paths:\n"; - std::vector::iterator i; - for(i=failures.begin(); i != failures.end(); ++i) - { - msg << " \"" << i->c_str() << "\"\n"; - } - cmCPackLogger(cmCPackLog::LOG_ERROR, msg.str().c_str() - << std::endl); - return 0; - } - } - // do CMAKE_ROOT, look for the environment variable first - std::string cMakeRoot; - std::string modules; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT" << std::endl); - if (getenv("CMAKE_ROOT")) - { - cMakeRoot = getenv("CMAKE_ROOT"); - modules = cMakeRoot + "/Modules/CMake.cmake"; - } - if(modules.empty() || !cmSystemTools::FileExists(modules.c_str())) - { - // next try exe/.. - cMakeRoot = cmSystemTools::GetProgramPath(this->CMakeSelf.c_str()); - std::string::size_type slashPos = cMakeRoot.rfind("/"); - if(slashPos != std::string::npos) - { - cMakeRoot = cMakeRoot.substr(0, slashPos); - } - // is there no Modules direcory there? - modules = cMakeRoot + "/Modules/CMake.cmake"; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " - << modules.c_str() << std::endl); - } + // use the CMAKE_ROOT from cmake which should have been + // found by now + const char* root= + this->MakefileMap->GetDefinition("CMAKE_ROOT"); - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try exe/../share/cmake - cMakeRoot += CMAKE_DATA_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " - << modules.c_str() << std::endl); - } -#ifdef CMAKE_ROOT_DIR - if (!cmSystemTools::FileExists(modules.c_str())) + if(root) { - // try compiled in root directory - cMakeRoot = CMAKE_ROOT_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " - << modules.c_str() << std::endl); + this->CMakeRoot = root; + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " + << this->CMakeRoot.c_str() << std::endl); + this->SetOption("CMAKE_ROOT", this->CMakeRoot.c_str()); + return 1; } -#endif -#ifdef CMAKE_PREFIX - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try compiled in install prefix - cMakeRoot = CMAKE_PREFIX CMAKE_DATA_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " - << modules.c_str() << std::endl); - } -#endif - if (!cmSystemTools::FileExists(modules.c_str())) - { - // try - cMakeRoot = cmSystemTools::GetProgramPath(this->CMakeSelf.c_str()); - cMakeRoot += CMAKE_DATA_DIR; - modules = cMakeRoot + "/Modules/CMake.cmake"; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " - << modules.c_str() << std::endl); - } - if(!cmSystemTools::FileExists(modules.c_str())) - { - // next try exe - cMakeRoot = cmSystemTools::GetProgramPath(this->CMakeSelf.c_str()); - // is there no Modules direcory there? - modules = cMakeRoot + "/Modules/CMake.cmake"; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " - << modules.c_str() << std::endl); - } - if (!cmSystemTools::FileExists(modules.c_str())) - { - // couldn't find modules - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Could not find CMAKE_ROOT !!!" << std::endl - << "CMake has most likely not been installed correctly." << std::endl - <<"Modules directory not found in" << std::endl - << cMakeRoot.c_str() - << std::endl); - return 0; - } - this->CMakeRoot = cMakeRoot; - cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " - << this->CMakeRoot.c_str() << std::endl); - this->SetOption("CMAKE_ROOT", this->CMakeRoot.c_str()); - return 1; + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Could not find CMAKE_ROOT !!!" + << std::endl + << "CMake has most likely not been installed correctly." + << std::endl + <<"Modules directory not found in" + << std::endl); + return 0; } //---------------------------------------------------------------------- @@ -1092,3 +1068,182 @@ int cmCPackGenerator::CleanTemporaryDirectory() } return 1; } + +//---------------------------------------------------------------------- +bool cmCPackGenerator::SupportsComponentInstallation() const +{ + return false; +} + +//---------------------------------------------------------------------- +cmCPackInstallationType* +cmCPackGenerator::GetInstallationType(const char *projectName, const char *name) +{ + (void) projectName; + bool hasInstallationType = this->InstallationTypes.count(name) != 0; + cmCPackInstallationType *installType = &this->InstallationTypes[name]; + if (!hasInstallationType) + { + // Define the installation type + std::string macroPrefix = "CPACK_INSTALL_TYPE_" + + cmsys::SystemTools::UpperCase(name); + installType->Name = name; + + const char* displayName + = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str()); + if (displayName && *displayName) + { + installType->DisplayName = displayName; + } + else + { + installType->DisplayName = installType->Name; + } + + installType->Index = static_cast( + this->InstallationTypes.size()); + } + return installType; +} + +//---------------------------------------------------------------------- +cmCPackComponent* +cmCPackGenerator::GetComponent(const char *projectName, const char *name) +{ + bool hasComponent = this->Components.count(name) != 0; + cmCPackComponent *component = &this->Components[name]; + if (!hasComponent) + { + // Define the component + std::string macroPrefix = "CPACK_COMPONENT_" + + cmsys::SystemTools::UpperCase(name); + component->Name = name; + const char* displayName + = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str()); + if (displayName && *displayName) + { + component->DisplayName = displayName; + } + else + { + component->DisplayName = component->Name; + } + component->IsHidden + = this->IsSet((macroPrefix + "_HIDDEN").c_str()); + component->IsRequired + = this->IsSet((macroPrefix + "_REQUIRED").c_str()); + component->IsDisabledByDefault + = this->IsSet((macroPrefix + "_DISABLED").c_str()); + component->IsDownloaded + = this->IsSet((macroPrefix + "_DOWNLOADED").c_str()) + || cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL")); + + const char* archiveFile = this->GetOption((macroPrefix + "_ARCHIVE_FILE").c_str()); + if (archiveFile && *archiveFile) + { + component->ArchiveFile = archiveFile; + } + + const char* groupName = this->GetOption((macroPrefix + "_GROUP").c_str()); + if (groupName && *groupName) + { + component->Group = GetComponentGroup(projectName, groupName); + component->Group->Components.push_back(component); + } + else + { + component->Group = 0; + } + + const char* description + = this->GetOption((macroPrefix + "_DESCRIPTION").c_str()); + if (description && *description) + { + component->Description = description; + } + + // Determine the installation types. + const char *installTypes + = this->GetOption((macroPrefix + "_INSTALL_TYPES").c_str()); + if (installTypes && *installTypes) + { + std::vector installTypesVector; + cmSystemTools::ExpandListArgument(installTypes, installTypesVector); + std::vector::iterator installTypesIt; + for (installTypesIt = installTypesVector.begin(); + installTypesIt != installTypesVector.end(); + ++installTypesIt) + { + component->InstallationTypes.push_back( + this->GetInstallationType(projectName, installTypesIt->c_str())); + } + } + + // Determine the component dependencies. + const char *depends = this->GetOption((macroPrefix + "_DEPENDS").c_str()); + if (depends && *depends) + { + std::vector dependsVector; + cmSystemTools::ExpandListArgument(depends, dependsVector); + std::vector::iterator dependIt; + for (dependIt = dependsVector.begin(); + dependIt != dependsVector.end(); + ++dependIt) + { + cmCPackComponent *child = GetComponent(projectName, dependIt->c_str()); + component->Dependencies.push_back(child); + child->ReverseDependencies.push_back(component); + } + } + } + return component; +} + +//---------------------------------------------------------------------- +cmCPackComponentGroup* +cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name) +{ + (void) projectName; + std::string macroPrefix = "CPACK_COMPONENT_GROUP_" + + cmsys::SystemTools::UpperCase(name); + bool hasGroup = this->ComponentGroups.count(name) != 0; + cmCPackComponentGroup *group = &this->ComponentGroups[name]; + if (!hasGroup) + { + // Define the group + group->Name = name; + const char* displayName + = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str()); + if (displayName && *displayName) + { + group->DisplayName = displayName; + } + else + { + group->DisplayName = group->Name; + } + + const char* description + = this->GetOption((macroPrefix + "_DESCRIPTION").c_str()); + if (description && *description) + { + group->Description = description; + } + group->IsBold + = this->IsSet((macroPrefix + "_BOLD_TITLE").c_str()); + group->IsExpandedByDefault + = this->IsSet((macroPrefix + "_EXPANDED").c_str()); + const char* parentGroupName + = this->GetOption((macroPrefix + "_PARENT_GROUP").c_str()); + if (parentGroupName && *parentGroupName) + { + group->ParentGroup = GetComponentGroup(projectName, parentGroupName); + group->ParentGroup->Subgroups.push_back(group); + } + else + { + group->ParentGroup = 0; + } + } + return group; +} diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index a82e4cb9f..9838f6aed 100755 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCPackGenerator.h,v $ Language: C++ - Date: $Date: 2007-11-06 13:28:26 $ - Version: $Revision: 1.2 $ + Date: $Date: 2008-09-24 14:07:50 $ + Version: $Revision: 1.2.2.3 $ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -19,6 +19,12 @@ #define cmCPackGenerator_h #include "cmObject.h" +#include +#include + +#include "cmCPackComponentGroup.h" // cmCPackComponent and friends + // Forward declarations are insufficient since we use them in + // std::map data members below... #define cmCPackTypeMacro(class, superclass) \ cmTypeMacro(class, superclass); \ @@ -67,7 +73,7 @@ public: /** * Initialize generator */ - int Initialize(const char* name, cmMakefile* mf, const char* argv0); + int Initialize(const char* name, cmMakefile* mf); /** * Construct generator @@ -82,7 +88,7 @@ public: bool IsSet(const char* name) const; //! Set all the variables - int FindRunningCMake(const char* arg0); + int SetCMakeRoot(); //! Set the logger void SetLogger(cmCPackLog* log) { this->Logger = log; } @@ -120,6 +126,11 @@ protected: virtual int InstallProjectViaInstallCMakeProjects( bool setDestDir, const char* tempInstallDirectory); + virtual bool SupportsComponentInstallation() const; + virtual cmCPackInstallationType* GetInstallationType(const char *projectName, const char* name); + virtual cmCPackComponent* GetComponent(const char *projectName, const char* name); + virtual cmCPackComponentGroup* GetComponentGroup(const char *projectName, const char* name); + bool GeneratorVerbose; std::string Name; @@ -129,6 +140,10 @@ protected: std::string CMakeSelf; std::string CMakeRoot; + std::map InstallationTypes; + std::map Components; + std::map ComponentGroups; + cmCPackLog* Logger; private: cmMakefile* MakefileMap; diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx index a02f3f6bc..2f821756d 100755 --- a/Source/CPack/cmCPackGeneratorFactory.cxx +++ b/Source/CPack/cmCPackGeneratorFactory.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCPackGeneratorFactory.cxx,v $ Language: C++ - Date: $Date: 2007-11-05 21:55:45 $ - Version: $Revision: 1.2 $ + Date: $Date: 2008-06-25 13:51:39 $ + Version: $Revision: 1.2.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -25,6 +25,7 @@ #include "cmCPackSTGZGenerator.h" #include "cmCPackNSISGenerator.h" #ifdef __APPLE__ +# include "cmCPackBundleGenerator.h" # include "cmCPackPackageMakerGenerator.h" # include "cmCPackOSXX11Generator.h" #endif @@ -66,6 +67,8 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory() this->RegisterGenerator("TZ", "Tar Compress compression", cmCPackTarCompressGenerator::CreateGenerator); #ifdef __APPLE__ + this->RegisterGenerator("Bundle", "Mac OSX bundle", + cmCPackBundleGenerator::CreateGenerator); this->RegisterGenerator("PackageMaker", "Mac OSX Package Maker installer", cmCPackPackageMakerGenerator::CreateGenerator); this->RegisterGenerator("OSXX11", "Mac OSX X11 bundle", diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index fcc35c450..6a30a29fa 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCPackNSISGenerator.cxx,v $ Language: C++ - Date: $Date: 2008-02-15 15:40:55 $ - Version: $Revision: 1.31 $ + Date: $Date: 2008-07-13 21:55:24 $ + Version: $Revision: 1.31.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -23,6 +23,7 @@ #include "cmMakefile.h" #include "cmGeneratedFileStream.h" #include "cmCPackLog.h" +#include "cmCPackComponentGroup.h" #include #include @@ -79,7 +80,12 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, for ( it = files.begin(); it != files.end(); ++ it ) { std::string fileN = cmSystemTools::RelativePath(toplevel, - it->c_str()); + it->c_str()); + if (!this->Components.empty()) + { + // Strip off the component part of the path. + fileN = fileN.substr(fileN.find('/')+1, std::string::npos); + } cmSystemTools::ReplaceString(fileN, "/", "\\"); str << " Delete \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl; } @@ -92,14 +98,32 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, cmOStringStream dstr; for ( sit = dirs.begin(); sit != dirs.end(); ++ sit ) { - std::string fileN = cmSystemTools::RelativePath(toplevel, - sit->c_str()); + std::string componentName; + std::string fileN = cmSystemTools::RelativePath(toplevel, sit->c_str()); if ( fileN.empty() ) { continue; } + if (!Components.empty()) + { + // If this is a component installation, strip off the component + // part of the path. + std::string::size_type slash = fileN.find('/'); + if (slash != std::string::npos) + { + // If this is a component installation, determine which component it is. + componentName = fileN.substr(0, slash); + + // Strip off the component part of the path. + fileN = fileN.substr(slash+1, std::string::npos); + } + } cmSystemTools::ReplaceString(fileN, "/", "\\"); dstr << " RMDir \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl; + if (!componentName.empty()) + { + this->Components[componentName].Directories.push_back(fileN); + } } cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: " << dstr.str().c_str() << std::endl); @@ -128,6 +152,147 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_ICON_CODE", installerIconCode.c_str()); } + + // Setup all of the component sections + if (this->Components.empty()) + { + this->SetOptionIfNotSet("CPACK_NSIS_INSTALLATION_TYPES", ""); + this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC", ""); + this->SetOptionIfNotSet("CPACK_NSIS_PAGE_COMPONENTS", ""); + this->SetOptionIfNotSet("CPACK_NSIS_FULL_INSTALL", + "File /r \"${INST_DIR}\\*.*\""); + this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTIONS", ""); + this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTION_LIST", ""); + this->SetOptionIfNotSet("CPACK_NSIS_SECTION_SELECTED_VARS", ""); + } + else + { + std::string componentCode; + std::string sectionList; + std::string selectedVarsList; + std::string componentDescriptions; + std::string groupDescriptions; + std::string installTypesCode; + std::string defines; + cmOStringStream macrosOut; + bool anyDownloadedComponents = false; + + // Create installation types. The order is significant, so we first fill + // in a vector based on the indices, and print them in that order. + std::vector + installTypes(this->InstallationTypes.size()); + std::map::iterator installTypeIt; + for (installTypeIt = this->InstallationTypes.begin(); + installTypeIt != this->InstallationTypes.end(); + ++installTypeIt) + { + installTypes[installTypeIt->second.Index-1] = &installTypeIt->second; + } + std::vector::iterator installTypeIt2; + for (installTypeIt2 = installTypes.begin(); + installTypeIt2 != installTypes.end(); + ++installTypeIt2) + { + installTypesCode += "InstType \""; + installTypesCode += (*installTypeIt2)->DisplayName; + installTypesCode += "\"\n"; + } + + // Create installation groups first + std::map::iterator groupIt; + for (groupIt = this->ComponentGroups.begin(); + groupIt != this->ComponentGroups.end(); + ++groupIt) + { + if (groupIt->second.ParentGroup == 0) + { + componentCode += + this->CreateComponentGroupDescription(&groupIt->second, macrosOut); + } + + // Add the group description, if any. + if (!groupIt->second.Description.empty()) + { + groupDescriptions += " !insertmacro MUI_DESCRIPTION_TEXT ${" + + groupIt->first + "} \"" + + this->TranslateNewlines(groupIt->second.Description) + "\"\n"; + } + } + + // Create the remaining components, which aren't associated with groups. + std::map::iterator compIt; + for (compIt = this->Components.begin(); + compIt != this->Components.end(); + ++compIt) + { + if (compIt->second.Files.empty()) + { + // NSIS cannot cope with components that have no files. + continue; + } + + anyDownloadedComponents = + anyDownloadedComponents || compIt->second.IsDownloaded; + + if (!compIt->second.Group) + { + componentCode + += this->CreateComponentDescription(&compIt->second, macrosOut); + } + + // Add this component to the various section lists. + sectionList += " !insertmacro \"${MacroName}\" \""; + sectionList += compIt->first; + sectionList += "\"\n"; + selectedVarsList += "Var " + compIt->first + "_selected\n"; + selectedVarsList += "Var " + compIt->first + "_was_installed\n"; + + // Add the component description, if any. + if (!compIt->second.Description.empty()) + { + componentDescriptions += " !insertmacro MUI_DESCRIPTION_TEXT ${" + + compIt->first + "} \"" + + this->TranslateNewlines(compIt->second.Description) + "\"\n"; + } + } + + componentCode += macrosOut.str(); + + if (componentDescriptions.empty() && groupDescriptions.empty()) + { + // Turn off the "Description" box + this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC", + "!define MUI_COMPONENTSPAGE_NODESC"); + } + else + { + componentDescriptions = + "!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN\n" + + componentDescriptions + + groupDescriptions + + "!insertmacro MUI_FUNCTION_DESCRIPTION_END\n"; + this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC", + componentDescriptions.c_str()); + } + + if (anyDownloadedComponents) + { + defines += "!define CPACK_USES_DOWNLOAD\n"; + if (cmSystemTools::IsOn(this->GetOption("CPACK_ADD_REMOVE"))) + { + defines += "!define CPACK_NSIS_ADD_REMOVE\n"; + } + } + + this->SetOptionIfNotSet("CPACK_NSIS_INSTALLATION_TYPES", installTypesCode.c_str()); + this->SetOptionIfNotSet("CPACK_NSIS_PAGE_COMPONENTS", "!insertmacro MUI_PAGE_COMPONENTS"); + this->SetOptionIfNotSet("CPACK_NSIS_FULL_INSTALL", ""); + this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTIONS", componentCode.c_str()); + this->SetOptionIfNotSet("CPACK_NSIS_COMPONENT_SECTION_LIST", sectionList.c_str()); + this->SetOptionIfNotSet("CPACK_NSIS_SECTION_SELECTED_VARS", selectedVarsList.c_str()); + this->SetOption("CPACK_NSIS_DEFINES", defines.c_str()); + } + this->ConfigureFile(nsisInInstallOptions.c_str(), nsisInstallOptions.c_str()); this->ConfigureFile(nsisInFileName.c_str(), nsisFileName.c_str()); @@ -174,7 +339,8 @@ int cmCPackNSISGenerator::InitializeInternal() #ifdef _WIN32 if ( !cmsys::SystemTools::ReadRegistryValue( - "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath) ) + "HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS", nsisPath, + cmsys::SystemTools::KeyWOW64_32) ) { cmCPackLogger (cmCPackLog::LOG_ERROR, @@ -252,9 +418,8 @@ int cmCPackNSISGenerator::InitializeInternal() } else { - cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: " - << "not set" << std::endl); - + cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: " + << "not set" << std::endl); } if ( cpackPackageExecutables ) { @@ -274,8 +439,8 @@ int cmCPackNSISGenerator::InitializeInternal() } std::vector::iterator it; for ( it = cpackPackageExecutablesVector.begin(); - it != cpackPackageExecutablesVector.end(); - ++it ) + it != cpackPackageExecutablesVector.end(); + ++it ) { std::string execName = *it; ++ it; @@ -415,3 +580,355 @@ bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir, dirs.push_back(topdir); return true; } + +//---------------------------------------------------------------------- +bool cmCPackNSISGenerator::SupportsComponentInstallation() const +{ + return true; +} + +//---------------------------------------------------------------------- +std::string +cmCPackNSISGenerator:: +CreateComponentDescription(cmCPackComponent *component, cmOStringStream& macrosOut) +{ + // Basic description of the component + std::string componentCode = "Section "; + if (component->IsDisabledByDefault) + { + componentCode += "/o "; + } + componentCode += "\""; + if (component->IsHidden) + { + componentCode += "-"; + } + componentCode += component->DisplayName + "\" " + component->Name + "\n"; + if (component->IsRequired) + { + componentCode += " SectionIn RO\n"; + } + else if (!component->InstallationTypes.empty()) + { + cmOStringStream out; + std::vector::iterator installTypeIter; + for (installTypeIter = component->InstallationTypes.begin(); + installTypeIter != component->InstallationTypes.end(); + ++installTypeIter) + { + out << " " << (*installTypeIter)->Index; + } + componentCode += " SectionIn" + out.str() + "\n"; + } + componentCode += " SetOutPath \"$INSTDIR\"\n"; + + componentCode += " IntCmp $" + component->Name + + "_was_installed ${SF_SELECTED} noinstall_" + component->Name + "\n"; + + // Create the actual installation commands + if (component->IsDownloaded) + { + if (component->ArchiveFile.empty()) + { + // Compute the name of the archive. + std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); + packagesDir += ".dummy"; + cmOStringStream out; + out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) + << "-" << component->Name << ".zip"; + component->ArchiveFile = out.str(); + } + + // Create the directory for the upload area + const char* userUploadDirectory = this->GetOption("CPACK_UPLOAD_DIRECTORY"); + std::string uploadDirectory; + if (userUploadDirectory && *userUploadDirectory) + { + uploadDirectory = userUploadDirectory; + } + else + { + uploadDirectory= this->GetOption("CPACK_PACKAGE_DIRECTORY"); + uploadDirectory += "/CPackUploads"; + } + if(!cmSystemTools::FileExists(uploadDirectory.c_str())) + { + if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Unable to create NSIS upload directory " << uploadDirectory + << std::endl); + return ""; + } + } + + // Remove the old archive, if one exists + std::string archiveFile = uploadDirectory + '/' + component->ArchiveFile; + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Building downloaded component archive: " + << archiveFile << std::endl); + if (cmSystemTools::FileExists(archiveFile.c_str(), true)) + { + if (!cmSystemTools::RemoveFile(archiveFile.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Unable to remove archive file " << archiveFile + << std::endl); + return ""; + } + } + + // Find a ZIP program + if (!this->IsSet("ZIP_EXECUTABLE")) + { + this->ReadListFile("CPackZIP.cmake"); + + if (!this->IsSet("ZIP_EXECUTABLE")) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Unable to find ZIP program" + << std::endl); + return ""; + } + } + + // The directory where this component's files reside + std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); + dirName += '/'; + dirName += component->Name; + dirName += '/'; + + // Build the list of files to go into this archive, and determine the + // size of the installed component. + std::string zipListFileName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); + zipListFileName += "/winZip.filelist"; + bool needQuotesInFile + = cmSystemTools::IsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES")); + unsigned long totalSize = 0; + { // the scope is needed for cmGeneratedFileStream + cmGeneratedFileStream out(zipListFileName.c_str()); + std::vector::iterator fileIt; + for (fileIt = component->Files.begin(); + fileIt != component->Files.end(); + ++fileIt) + { + if ( needQuotesInFile ) + { + out << "\""; + } + out << *fileIt; + if ( needQuotesInFile ) + { + out << "\""; + } + out << std::endl; + + totalSize += cmSystemTools::FileLength((dirName + *fileIt).c_str()); + } + } + + // Build the archive in the upload area + std::string cmd = this->GetOption("CPACK_ZIP_COMMAND"); + cmsys::SystemTools::ReplaceString(cmd, "", archiveFile.c_str()); + cmsys::SystemTools::ReplaceString(cmd, "", + zipListFileName.c_str()); + std::string output; + int retVal = -1; + int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &retVal, + dirName.c_str(), false, 0); + if ( !res || retVal ) + { + std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + tmpFile += "/CompressZip.log"; + cmGeneratedFileStream ofs(tmpFile.c_str()); + ofs << "# Run command: " << cmd.c_str() << std::endl + << "# Output:" << std::endl + << output.c_str() << std::endl; + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running zip command: " + << cmd.c_str() << std::endl + << "Please check " << tmpFile.c_str() << " for errors" << std::endl); + return ""; + } + + // Create the NSIS code to download this file on-the-fly. + unsigned totalSizeInKbytes = (totalSize + 512) / 1024; + if (totalSizeInKbytes == 0) + { + totalSizeInKbytes = 1; + } + cmOStringStream out; + out << " AddSize " << totalSizeInKbytes << "\n" + << " Push \"" << component->ArchiveFile << "\"\n" + << " Call DownloadFile\n" + << " ZipDLL::extractall \"$INSTDIR\\" + << component->ArchiveFile << "\" \"$INSTDIR\"\n" + << " Pop $2 ; error message\n" + " StrCmp $2 \"success\" +2 0\n" + " MessageBox MB_OK \"Failed to unzip $2\"\n" + " Delete $INSTDIR\\$0\n"; + componentCode += out.str(); + } + else + { + componentCode += " File /r \"${INST_DIR}\\" + component->Name + "\\*.*\"\n"; + } + componentCode += " noinstall_" + component->Name + ":\n"; + componentCode += "SectionEnd\n"; + + // Macro used to remove the component + macrosOut << "!macro Remove_${" << component->Name << "}\n"; + macrosOut << " IntCmp $" << component->Name << "_was_installed 0 noremove_" + << component->Name << "\n"; + std::vector::iterator pathIt; + for (pathIt = component->Files.begin(); + pathIt != component->Files.end(); + ++pathIt) + { + macrosOut << " Delete \"$INSTDIR\\" + << cmSystemTools::ConvertToWindowsOutputPath(pathIt->c_str()) + << "\"\n"; + } + for (pathIt = component->Directories.begin(); + pathIt != component->Directories.end(); + ++pathIt) + { + macrosOut << " RMDir \"$INSTDIR\\" + << cmSystemTools::ConvertToWindowsOutputPath(pathIt->c_str()) + << "\"\n"; + } + macrosOut << " noremove_" << component->Name << ":\n"; + macrosOut << "!macroend\n"; + + // Macro used to select each of the components that this component + // depends on. + std::set visited; + macrosOut << "!macro Select_" << component->Name << "_depends\n"; + macrosOut << CreateSelectionDependenciesDescription(component, visited); + macrosOut << "!macroend\n"; + + // Macro used to deselect each of the components that depend on this + // component. + visited.clear(); + macrosOut << "!macro Deselect_required_by_" << component->Name << "\n"; + macrosOut << CreateDeselectionDependenciesDescription(component, visited); + macrosOut << "!macroend\n"; + return componentCode; +} + +//---------------------------------------------------------------------- +std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription + (cmCPackComponent *component, + std::set& visited) +{ + // Don't visit a component twice + if (visited.count(component)) + { + return std::string(); + } + visited.insert(component); + + cmOStringStream out; + std::vector::iterator dependIt; + for (dependIt = component->Dependencies.begin(); + dependIt != component->Dependencies.end(); + ++dependIt) + { + // Write NSIS code to select this dependency + out << " SectionGetFlags ${" << (*dependIt)->Name << "} $0\n"; + out << " IntOp $0 $0 | ${SF_SELECTED}\n"; + out << " SectionSetFlags ${" << (*dependIt)->Name << "} $0\n"; + out << " IntOp $" << (*dependIt)->Name << "_selected 0 + ${SF_SELECTED}\n"; + // Recurse + out << CreateSelectionDependenciesDescription(*dependIt, visited).c_str(); + } + + return out.str(); +} + + +//---------------------------------------------------------------------- +std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription + (cmCPackComponent *component, + std::set& visited) +{ + // Don't visit a component twice + if (visited.count(component)) + { + return std::string(); + } + visited.insert(component); + + cmOStringStream out; + std::vector::iterator dependIt; + for (dependIt = component->ReverseDependencies.begin(); + dependIt != component->ReverseDependencies.end(); + ++dependIt) + { + // Write NSIS code to deselect this dependency + out << " SectionGetFlags ${" << (*dependIt)->Name << "} $0\n"; + out << " IntOp $1 ${SF_SELECTED} ~\n"; + out << " IntOp $0 $0 & $1\n"; + out << " SectionSetFlags ${" << (*dependIt)->Name << "} $0\n"; + out << " IntOp $" << (*dependIt)->Name << "_selected 0 + 0\n"; + + // Recurse + out << CreateDeselectionDependenciesDescription(*dependIt, visited).c_str(); + } + + return out.str(); +} + +//---------------------------------------------------------------------- +std::string +cmCPackNSISGenerator:: +CreateComponentGroupDescription(cmCPackComponentGroup *group, + cmOStringStream& macrosOut) +{ + if (group->Components.empty() && group->Subgroups.empty()) + { + // Silently skip empty groups. NSIS doesn't support them. + return std::string(); + } + + std::string code = "SectionGroup "; + if (group->IsExpandedByDefault) + { + code += "/e "; + } + if (group->IsBold) + { + code += "\"!" + group->DisplayName + "\" " + group->Name + "\n"; + } + else + { + code += "\"" + group->DisplayName + "\" " + group->Name + "\n"; + } + + std::vector::iterator groupIt; + for (groupIt = group->Subgroups.begin(); groupIt != group->Subgroups.end(); + ++groupIt) + { + code += this->CreateComponentGroupDescription(*groupIt, macrosOut); + } + + std::vector::iterator comp; + for (comp = group->Components.begin(); + comp != group->Components.end(); + ++comp) + { + if ((*comp)->Files.empty()) + { + continue; + } + + code += this->CreateComponentDescription(*comp, macrosOut); + } + code += "SectionGroupEnd\n"; + return code; +} + +std::string cmCPackNSISGenerator::TranslateNewlines(std::string str) +{ + cmSystemTools::ReplaceString(str, "\n", "$\\r$\\n"); + return str; +} diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index bec85f14e..8a7bb02cb 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCPackNSISGenerator.h,v $ Language: C++ - Date: $Date: 2007-11-05 21:55:45 $ - Version: $Revision: 1.11 $ + Date: $Date: 2008-07-13 21:55:24 $ + Version: $Revision: 1.11.2.2 $ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -20,6 +20,7 @@ #include "cmCPackGenerator.h" +#include /** \class cmCPackNSISGenerator * \brief A generator for NSIS files @@ -48,6 +49,38 @@ protected: bool GetListOfSubdirectories(const char* dir, std::vector& dirs); + + virtual bool SupportsComponentInstallation() const; + + /// Produce a string that contains the NSIS code to describe a + /// particular component. Any added macros will be emitted via + /// macrosOut. + std::string + CreateComponentDescription(cmCPackComponent *component, + cmOStringStream& macrosOut); + + /// Produce NSIS code that selects all of the components that this component + /// depends on, recursively. + std::string CreateSelectionDependenciesDescription + (cmCPackComponent *component, + std::set& visited); + + /// Produce NSIS code that de-selects all of the components that are dependent + /// on this component, recursively. + std::string CreateDeselectionDependenciesDescription + (cmCPackComponent *component, + std::set& visited); + + /// Produce a string that contains the NSIS code to describe a + /// particular component group, including its components. Any + /// added macros will be emitted via macrosOut. + std::string + CreateComponentGroupDescription(cmCPackComponentGroup *group, + cmOStringStream& macrosOut); + + /// Translations any newlines found in the string into \r\n, so that the + /// resulting string can be used within NSIS. + static std::string TranslateNewlines(std::string str); }; #endif diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 588fdb469..4f8e055ed 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCPackPackageMakerGenerator.cxx,v $ Language: C++ - Date: $Date: 2008-02-19 19:26:19 $ - Version: $Revision: 1.23 $ + Date: $Date: 2008-07-30 18:54:49 $ + Version: $Revision: 1.23.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -22,6 +22,7 @@ #include "cmSystemTools.h" #include "cmMakefile.h" #include "cmGeneratedFileStream.h" +#include "cmCPackComponentGroup.h" #include "cmCPackLog.h" #include @@ -31,6 +32,7 @@ cmCPackPackageMakerGenerator::cmCPackPackageMakerGenerator() { this->PackageMakerVersion = 0.0; + this->PackageCompatibilityVersion = 10.4; } //---------------------------------------------------------------------- @@ -38,6 +40,13 @@ cmCPackPackageMakerGenerator::~cmCPackPackageMakerGenerator() { } +//---------------------------------------------------------------------- +bool cmCPackPackageMakerGenerator::SupportsComponentInstallation() const +{ + return this->PackageCompatibilityVersion >= 10.4; +} + +//---------------------------------------------------------------------- int cmCPackPackageMakerGenerator::CopyInstallScript(const char* resdir, const char* script, const char* name) @@ -61,9 +70,51 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, { (void) files; // TODO: Fix api to not need files. (void) toplevel; // TODO: Use toplevel + + std::string resDir; // Where this package's resources will go. + std::string packageDirFileName + = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); + if (this->Components.empty()) + { + packageDirFileName += ".pkg"; + resDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + resDir += "/Resources"; + } + else + { + packageDirFileName += ".mpkg"; + if ( !cmsys::SystemTools::MakeDirectory(packageDirFileName.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "unable to create package directory " + << packageDirFileName << std::endl); + return 0; + } + + resDir = packageDirFileName; + resDir += "/Contents"; + if ( !cmsys::SystemTools::MakeDirectory(resDir.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "unable to create package subdirectory " << resDir + << std::endl); + return 0; + } + + resDir += "/Resources"; + if ( !cmsys::SystemTools::MakeDirectory(resDir.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "unable to create package subdirectory " << resDir + << std::endl); + return 0; + } + + resDir += "/en.lproj"; + } + + // Create directory structure - std::string resDir = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - resDir += "/Resources"; std::string preflightDirName = resDir + "/PreFlight"; std::string postflightDirName = resDir + "/PostFlight"; const char* preflight = this->GetOption("CPACK_PREFLIGHT_SCRIPT"); @@ -96,98 +147,180 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, // them executable if(preflight) { - this->CopyInstallScript(resDir.c_str(), - preflight, - "preflight"); + this->CopyInstallScript(resDir.c_str(), + preflight, + "preflight"); } if(postflight) { - this->CopyInstallScript(resDir.c_str(), - postflight, - "postflight"); + this->CopyInstallScript(resDir.c_str(), + postflight, + "postflight"); } if(postupgrade) { - this->CopyInstallScript(resDir.c_str(), - postupgrade, - "postupgrade"); + this->CopyInstallScript(resDir.c_str(), + postupgrade, + "postupgrade"); } - if ( !this->CopyCreateResourceFile("License") - || !this->CopyCreateResourceFile("ReadMe") - || !this->CopyCreateResourceFile("Welcome") - || !this->CopyResourcePlistFile("Info.plist") - || !this->CopyResourcePlistFile("Description.plist") ) + if (!this->Components.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files" - << std::endl); - return 0; - } + // Create the directory where component packages will be built. + std::string basePackageDir = packageDirFileName; + basePackageDir += "/Contents/Packages"; + if (!cmsys::SystemTools::MakeDirectory(basePackageDir.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem creating component packages directory: " + << basePackageDir.c_str() << std::endl); + return 0; + } - std::string packageDirFileName - = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); - packageDirFileName += ".pkg"; + // Create the directory where downloaded component packages will + // be placed. + const char* userUploadDirectory = this->GetOption("CPACK_UPLOAD_DIRECTORY"); + std::string uploadDirectory; + if (userUploadDirectory && *userUploadDirectory) + { + uploadDirectory = userUploadDirectory; + } + else + { + uploadDirectory= this->GetOption("CPACK_PACKAGE_DIRECTORY"); + uploadDirectory += "/CPackUploads"; + } - std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - tmpFile += "/PackageMakerOutput.log"; - cmOStringStream pkgCmd; - pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM") - << "\" -build -p \"" << packageDirFileName << "\" -f \"" - << this->GetOption("CPACK_TEMPORARY_DIRECTORY") - << "\" -r \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") - << "/Resources\" -i \"" - << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/Info.plist\" -d \"" - << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") << "/Description.plist\""; - if ( this->PackageMakerVersion > 2.0 ) - { - pkgCmd << " -v"; - } - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << pkgCmd.str().c_str() - << std::endl); - std::string output; - int retVal = 1; - //bool res = cmSystemTools::RunSingleCommand(pkgCmd.str().c_str(), &output, - //&retVal, 0, this->GeneratorVerbose, 0); - bool res = true; - retVal = system(pkgCmd.str().c_str()); - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker" - << std::endl); - if ( !res || retVal ) + // Create packages for each component + bool warnedAboutDownloadCompatibility = false; + + std::map::iterator compIt; + for (compIt = this->Components.begin(); compIt != this->Components.end(); + ++compIt) + { + std::string packageFile; + if (compIt->second.IsDownloaded) + { + if (this->PackageCompatibilityVersion >= 10.5 && + this->PackageMakerVersion >= 3.0) + { + // Build this package within the upload directory. + packageFile = uploadDirectory; + + if(!cmSystemTools::FileExists(uploadDirectory.c_str())) + { + if (!cmSystemTools::MakeDirectory(uploadDirectory.c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Unable to create package upload directory " + << uploadDirectory << std::endl); + return 0; + } + } + } + else if (!warnedAboutDownloadCompatibility) + { + if (this->PackageCompatibilityVersion < 10.5) + { + cmCPackLogger(cmCPackLog::LOG_WARNING, + "CPack warning: please set CPACK_OSX_PACKAGE_VERSION to 10.5 or greater enable downloaded packages. CPack will build a non-downloaded package." + << std::endl); + } + + if (this->PackageMakerVersion < 3) + { + cmCPackLogger(cmCPackLog::LOG_WARNING, + "CPack warning: unable to build downloaded packages with PackageMaker versions prior to 3.0. CPack will build a non-downloaded package." + << std::endl); + } + + warnedAboutDownloadCompatibility = true; + } + } + + if (packageFile.empty()) + { + // Build this package within the overall distribution + // metapackage. + packageFile = basePackageDir; + + // We're not downloading this component, even if the user + // requested it. + compIt->second.IsDownloaded = false; + } + + packageFile += '/'; + packageFile += GetPackageName(compIt->second); + + std::string packageDir = toplevel; + packageDir += '/'; + packageDir += compIt->first; + if (!this->GenerateComponentPackage(packageFile.c_str(), + packageDir.c_str(), + compIt->second)) + { + return 0; + } + } + } + this->SetOption("CPACK_MODULE_VERSION_SUFFIX", ""); + + // Copy or create all of the resource files we need. + if ( !this->CopyCreateResourceFile("License", resDir.c_str()) + || !this->CopyCreateResourceFile("ReadMe", resDir.c_str()) + || !this->CopyCreateResourceFile("Welcome", resDir.c_str()) + || !this->CopyResourcePlistFile("Info.plist") + || !this->CopyResourcePlistFile("Description.plist") ) { - cmGeneratedFileStream ofs(tmpFile.c_str()); - ofs << "# Run command: " << pkgCmd.str().c_str() << std::endl - << "# Output:" << std::endl - << output.c_str() << std::endl; - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Problem running PackageMaker command: " << pkgCmd.str().c_str() - << std::endl << "Please check " << tmpFile.c_str() << " for errors" + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files" << std::endl); return 0; } - // sometimes the pkgCmd finishes but the directory is not yet - // created, so try 10 times to see if it shows up - int tries = 10; - while(tries > 0 && - !cmSystemTools::FileExists(packageDirFileName.c_str())) + + if (this->Components.empty()) { - cmSystemTools::Delay(500); - tries--; + // Use PackageMaker to build the package. + cmOStringStream pkgCmd; + pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM") + << "\" -build -p \"" << packageDirFileName << "\""; + if (this->Components.empty()) + { + pkgCmd << " -f \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY"); + } + else + { + pkgCmd << " -mi \"" << this->GetOption("CPACK_TEMPORARY_DIRECTORY") + << "/packages/"; + } + pkgCmd << "\" -r \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") + << "/Resources\" -i \"" + << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") + << "/Info.plist\" -d \"" + << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") + << "/Description.plist\""; + if ( this->PackageMakerVersion > 2.0 ) + { + pkgCmd << " -v"; + } + if (!RunPackageMaker(pkgCmd.str().c_str(), packageDirFileName.c_str())) + return 0; } - if(!cmSystemTools::FileExists(packageDirFileName.c_str())) + else { - cmCPackLogger( - cmCPackLog::LOG_ERROR, - "Problem running PackageMaker command: " << pkgCmd.str().c_str() - << std::endl << "Package not created: " << packageDirFileName.c_str() - << std::endl); + // We have built the package in place. Generate the + // distribution.dist file to describe it for the installer. + WriteDistributionFile(packageDirFileName.c_str()); } - tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + + std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); tmpFile += "/hdiutilOutput.log"; cmOStringStream dmgCmd; dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") << "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName << "\" \"" << outFileName << "\""; - res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, + std::string output; + int retVal = 1; + bool res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &retVal, 0, this->GeneratorVerbose, 0); if ( !res || retVal ) { @@ -273,6 +406,30 @@ int cmCPackPackageMakerGenerator::InitializeInternal() cmCPackLogger(cmCPackLog::LOG_DEBUG, "PackageMaker version is: " << this->PackageMakerVersion << std::endl); + // Determine the package compatibility version. If it wasn't + // specified by the user, we define it based on which features the + // user requested. + const char *packageCompat = this->GetOption("CPACK_OSX_PACKAGE_VERSION"); + if (packageCompat && *packageCompat) + { + this->PackageCompatibilityVersion = atof(packageCompat); + } + else if (this->GetOption("CPACK_DOWNLOAD_SITE")) + { + this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.5"); + this->PackageCompatibilityVersion = 10.5; + } + else if (this->GetOption("CPACK_COMPONENTS_ALL")) + { + this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.4"); + this->PackageCompatibilityVersion = 10.4; + } + else + { + this->SetOption("CPACK_OSX_PACKAGE_VERSION", "10.3"); + this->PackageCompatibilityVersion = 10.3; + } + pkgPath += "/MacOS"; path.push_back(pkgPath); pkgPath = cmSystemTools::FindProgram("PackageMaker", path, false); @@ -297,7 +454,8 @@ int cmCPackPackageMakerGenerator::InitializeInternal() } //---------------------------------------------------------------------- -bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name) +bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name, + const char* dirName) { std::string uname = cmSystemTools::UpperCase(name); std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname; @@ -327,10 +485,14 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name) return false; } - std::string destFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); - destFileName += "/Resources/"; + std::string destFileName = dirName; + destFileName += '/'; destFileName += name + ext; + // Set this so that distribution.dist gets the right name (without + // the path). + this->SetOption(("CPACK_RESOURCE_FILE_" + uname + "_NOPATH").c_str(), + (name + ext).c_str()); cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << (inFileName ? inFileName : "(NULL)") @@ -339,8 +501,14 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name) return true; } -bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(const char* name) +bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(const char* name, + const char* outName) { + if (!outName) + { + outName = name; + } + std::string inFName = "CPack."; inFName += name; inFName += ".in"; @@ -354,10 +522,403 @@ bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(const char* name) std::string destFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); destFileName += "/"; - destFileName += name; + destFileName += outName; cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << inFileName.c_str() << " to " << destFileName.c_str() << std::endl); this->ConfigureFile(inFileName.c_str(), destFileName.c_str()); return true; } + +//---------------------------------------------------------------------- +bool cmCPackPackageMakerGenerator::RunPackageMaker(const char *command, + const char *packageFile) +{ + std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + tmpFile += "/PackageMakerOutput.log"; + + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << command << std::endl); + std::string output; + int retVal = 1; + bool res = cmSystemTools::RunSingleCommand(command, &output, &retVal, 0, + this->GeneratorVerbose, 0); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Done running package maker" + << std::endl); + if ( !res || retVal ) + { + cmGeneratedFileStream ofs(tmpFile.c_str()); + ofs << "# Run command: " << command << std::endl + << "# Output:" << std::endl + << output.c_str() << std::endl; + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Problem running PackageMaker command: " << command + << std::endl << "Please check " << tmpFile.c_str() << " for errors" + << std::endl); + return false; + } + // sometimes the command finishes but the directory is not yet + // created, so try 10 times to see if it shows up + int tries = 10; + while(tries > 0 && + !cmSystemTools::FileExists(packageFile)) + { + cmSystemTools::Delay(500); + tries--; + } + if(!cmSystemTools::FileExists(packageFile)) + { + cmCPackLogger( + cmCPackLog::LOG_ERROR, + "Problem running PackageMaker command: " << command + << std::endl << "Package not created: " << packageFile + << std::endl); + return false; + } + + return true; +} + +//---------------------------------------------------------------------- +std::string +cmCPackPackageMakerGenerator::GetPackageName(const cmCPackComponent& component) +{ + if (component.ArchiveFile.empty()) + { + std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); + packagesDir += ".dummy"; + cmOStringStream out; + out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir) + << "-" << component.Name << ".pkg"; + return out.str(); + } + else + { + return component.ArchiveFile + ".pkg"; + } +} + +//---------------------------------------------------------------------- +bool +cmCPackPackageMakerGenerator:: +GenerateComponentPackage(const char *packageFile, + const char *packageDir, + const cmCPackComponent& component) +{ + cmCPackLogger(cmCPackLog::LOG_OUTPUT, + "- Building component package: " << packageFile << std::endl); + + // The command that will be used to run PackageMaker + cmOStringStream pkgCmd; + + if (this->PackageCompatibilityVersion < 10.5 || + this->PackageMakerVersion < 3.0) + { + // Create Description.plist and Info.plist files for normal Mac OS + // X packages, which work on Mac OS X 10.3 and newer. + std::string descriptionFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); + descriptionFile += '/' + component.Name + "-Description.plist"; + std::ofstream out(descriptionFile.c_str()); + out << "" << std::endl + << "" << std::endl + << "" << std::endl + << "" << std::endl + << " IFPkgDescriptionTitle" << std::endl + << " " << component.DisplayName << "" << std::endl + << " IFPkgDescriptionVersion" << std::endl + << " " << this->GetOption("CPACK_PACKAGE_VERSION") + << "" << std::endl + << " IFPkgDescriptionDescription" << std::endl + << " " + this->EscapeForXML(component.Description) + << "" << std::endl + << "" << std::endl + << "" << std::endl; + out.close(); + + // Create the Info.plist file for this component + std::string moduleVersionSuffix = "."; + moduleVersionSuffix += component.Name; + this->SetOption("CPACK_MODULE_VERSION_SUFFIX", moduleVersionSuffix.c_str()); + std::string infoFileName = component.Name; + infoFileName += "-Info.plist"; + if (!this->CopyResourcePlistFile("Info.plist", infoFileName.c_str())) + { + return false; + } + + pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM") + << "\" -build -p \"" << packageFile << "\"" + << " -f \"" << packageDir << "\"" + << " -i \"" << this->GetOption("CPACK_TOPLEVEL_DIRECTORY") + << "/" << infoFileName << "\"" + << " -d \"" << descriptionFile << "\""; + } + else + { + // Create a "flat" package on Mac OS X 10.5 and newer. Flat + // packages are stored in a single file, rather than a directory + // like normal packages, and can be downloaded by the installer + // on-the-fly in Mac OS X 10.5 or newer. Thus, we need to create + // flat packages when the packages will be downloaded on the fly. + std::string pkgId = "com."; + pkgId += this->GetOption("CPACK_PACKAGE_VENDOR"); + pkgId += '.'; + pkgId += this->GetOption("CPACK_PACKAGE_NAME"); + pkgId += '.'; + pkgId += component.Name; + + pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM") + << "\" --root \"" << packageDir << "\"" + << " --id " << pkgId + << " --target " << this->GetOption("CPACK_OSX_PACKAGE_VERSION") + << " --out \"" << packageFile << "\""; + } + + // Run PackageMaker + return RunPackageMaker(pkgCmd.str().c_str(), packageFile); +} + +//---------------------------------------------------------------------- +void +cmCPackPackageMakerGenerator:: +WriteDistributionFile(const char* metapackageFile) +{ + std::string distributionTemplate + = this->FindTemplate("CPack.distribution.dist.in"); + if ( distributionTemplate.empty() ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find input file: " + << distributionTemplate << std::endl); + return; + } + + std::string distributionFile = metapackageFile; + distributionFile += "/Contents/distribution.dist"; + + // Create the choice outline, which provides a tree-based view of + // the components in their groups. + cmOStringStream choiceOut; + choiceOut << "" << std::endl; + + // Emit the outline for the groups + std::map::iterator groupIt; + for (groupIt = this->ComponentGroups.begin(); + groupIt != this->ComponentGroups.end(); + ++groupIt) + { + if (groupIt->second.ParentGroup == 0) + { + CreateChoiceOutline(groupIt->second, choiceOut); + } + } + + // Emit the outline for the non-grouped components + std::map::iterator compIt; + for (compIt = this->Components.begin(); compIt != this->Components.end(); + ++compIt) + { + if (!compIt->second.Group) + { + choiceOut << "first << "Choice\">" + << std::endl; + } + } + choiceOut << "" << std::endl; + + // Create the actual choices + for (groupIt = this->ComponentGroups.begin(); + groupIt != this->ComponentGroups.end(); + ++groupIt) + { + CreateChoice(groupIt->second, choiceOut); + } + for (compIt = this->Components.begin(); compIt != this->Components.end(); + ++compIt) + { + CreateChoice(compIt->second, choiceOut); + } + this->SetOption("CPACK_PACKAGEMAKER_CHOICES", choiceOut.str().c_str()); + + // Create the distribution.dist file in the metapackage to turn it + // into a distribution package. + this->ConfigureFile(distributionTemplate.c_str(), + distributionFile.c_str()); +} + +//---------------------------------------------------------------------- +void +cmCPackPackageMakerGenerator:: +CreateChoiceOutline(const cmCPackComponentGroup& group, cmOStringStream& out) +{ + out << "" << std::endl; + std::vector::const_iterator groupIt; + for (groupIt = group.Subgroups.begin(); groupIt != group.Subgroups.end(); + ++groupIt) + { + CreateChoiceOutline(**groupIt, out); + } + + std::vector::const_iterator compIt; + for (compIt = group.Components.begin(); compIt != group.Components.end(); + ++compIt) + { + out << " Name << "Choice\">" + << std::endl; + } + out << "" << std::endl; +} + +//---------------------------------------------------------------------- +void +cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponentGroup& group, + cmOStringStream& out) +{ + out << "" << std::endl; +} + +//---------------------------------------------------------------------- +void +cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component, + cmOStringStream& out) +{ + std::string packageId = "com."; + packageId += this->GetOption("CPACK_PACKAGE_VENDOR"); + packageId += '.'; + packageId += this->GetOption("CPACK_PACKAGE_NAME"); + packageId += '.'; + packageId += component.Name; + + out << " visited; + AddDependencyAttributes(component, visited, out); + visited.clear(); + AddReverseDependencyAttributes(component, visited, out); + out << "\""; + } + out << ">" << std::endl; + out << " " << std::endl; + out << "" << std::endl; + + // Create a description of the package associated with this + // component. + std::string relativePackageLocation = "Contents/Packages/"; + relativePackageLocation += this->GetPackageName(component); + + // Determine the installed size of the package. + std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); + dirName += '/'; + dirName += component.Name; + unsigned long installedSize + = component.GetInstalledSizeInKbytes(dirName.c_str()); + + out << "GetOption("CPACK_PACKAGE_VERSION") << "\" " + << "installKBytes=\"" << installedSize << "\" " + << "auth=\"Admin\" onConclusion=\"None\">"; + if (component.IsDownloaded) + { + out << this->GetOption("CPACK_DOWNLOAD_SITE") + << this->GetPackageName(component); + } + else + { + out << "file:./" << relativePackageLocation; + } + out << "" << std::endl; +} + +//---------------------------------------------------------------------- +void +cmCPackPackageMakerGenerator:: +AddDependencyAttributes(const cmCPackComponent& component, + std::set& visited, + cmOStringStream& out) +{ + if (visited.find(&component) != visited.end()) + { + return; + } + visited.insert(&component); + + std::vector::const_iterator dependIt; + for (dependIt = component.Dependencies.begin(); + dependIt != component.Dependencies.end(); + ++dependIt) + { + out << " && choices['" << (*dependIt)->Name << "Choice'].selected"; + AddDependencyAttributes(**dependIt, visited, out); + } +} + +//---------------------------------------------------------------------- +void +cmCPackPackageMakerGenerator:: +AddReverseDependencyAttributes(const cmCPackComponent& component, + std::set& visited, + cmOStringStream& out) +{ + if (visited.find(&component) != visited.end()) + { + return; + } + visited.insert(&component); + + std::vector::const_iterator dependIt; + for (dependIt = component.ReverseDependencies.begin(); + dependIt != component.ReverseDependencies.end(); + ++dependIt) + { + out << " || choices['" << (*dependIt)->Name << "Choice'].selected"; + AddReverseDependencyAttributes(**dependIt, visited, out); + } +} + +//---------------------------------------------------------------------- +std::string cmCPackPackageMakerGenerator::EscapeForXML(std::string str) +{ + cmSystemTools::ReplaceString(str, "&", "&"); + cmSystemTools::ReplaceString(str, "<", "<"); + cmSystemTools::ReplaceString(str, ">", ">"); + cmSystemTools::ReplaceString(str, "\"", """); + return str; +} diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index 39b21d3af..a09742856 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCPackPackageMakerGenerator.h,v $ Language: C++ - Date: $Date: 2008-02-19 19:26:19 $ - Version: $Revision: 1.12 $ + Date: $Date: 2008-07-30 18:54:50 $ + Version: $Revision: 1.12.2.3 $ Copyright (c) 2002 Kitware, Inc. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -21,6 +21,8 @@ #include "cmCPackGenerator.h" +class cmCPackComponent; + /** \class cmCPackPackageMakerGenerator * \brief A generator for PackageMaker files * @@ -38,6 +40,8 @@ public: cmCPackPackageMakerGenerator(); virtual ~cmCPackPackageMakerGenerator(); + virtual bool SupportsComponentInstallation() const; + protected: int CopyInstallScript(const char* resdir, const char* script, @@ -48,10 +52,74 @@ protected: virtual const char* GetOutputExtension() { return ".dmg"; } virtual const char* GetOutputPostfix() { return "darwin"; } - bool CopyCreateResourceFile(const char* name); - bool CopyResourcePlistFile(const char* name); + // Copies or creates the resource file with the given name to the + // package or package staging directory dirName. The variable + // CPACK_RESOURCE_FILE_${NAME} (where ${NAME} is the uppercased + // version of name) specifies the input file to use for this file, + // which will be configured via ConfigureFile. + bool CopyCreateResourceFile(const char* name, const char *dirName); + bool CopyResourcePlistFile(const char* name, const char* outName = 0); + + // Run PackageMaker with the given command line, which will (if + // successful) produce the given package file. Returns true if + // PackageMaker succeeds, false otherwise. + bool RunPackageMaker(const char *command, const char *packageFile); + + // Retrieve the name of package file that will be generated for this + // component. The name is just the file name with extension, and + // does not include the subdirectory. + std::string GetPackageName(const cmCPackComponent& component); + + // Generate a package in the file packageFile for the given + // component. All of the files within this component are stored in + // the directory packageDir. Returns true if successful, false + // otherwise. + bool GenerateComponentPackage(const char *packageFile, + const char *packageDir, + const cmCPackComponent& component); + + // Writes a distribution.dist file, which turns a metapackage into a + // full-fledged distribution. This file is used to describe + // inter-component dependencies. metapackageFile is the name of the + // metapackage for the distribution. Only valid for a + // component-based install. + void WriteDistributionFile(const char* metapackageFile); + + // Subroutine of WriteDistributionFile that writes out the + // dependency attributes for inter-component dependencies. + void AddDependencyAttributes(const cmCPackComponent& component, + std::set& visited, + cmOStringStream& out); + + // Subroutine of WriteDistributionFile that writes out the + // reverse dependency attributes for inter-component dependencies. + void + AddReverseDependencyAttributes(const cmCPackComponent& component, + std::set& visited, + cmOStringStream& out); + + // Generates XML that encodes the hierarchy of component groups and + // their components in a form that can be used by distribution + // metapackages. + void CreateChoiceOutline(const cmCPackComponentGroup& group, + cmOStringStream& out); + + /// Create the "choice" XML element to describe a component group + /// for the installer GUI. + void CreateChoice(const cmCPackComponentGroup& group, + cmOStringStream& out); + + /// Create the "choice" XML element to describe a component for the + /// installer GUI. + void CreateChoice(const cmCPackComponent& component, + cmOStringStream& out); + // Escape the given string to make it usable as an XML attribute + // value. + std::string EscapeForXML(std::string str); + double PackageMakerVersion; + double PackageCompatibilityVersion; }; #endif diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 20c5b4518..a8444f988 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cpack.cxx,v $ Language: C++ - Date: $Date: 2008-04-21 00:44:53 $ - Version: $Revision: 1.42.2.1 $ + Date: $Date: 2008-09-24 14:07:50 $ + Version: $Revision: 1.42.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -382,7 +382,7 @@ int main (int argc, char *argv[]) << gen << std::endl); parsed = 0; } - if ( parsed && !cpackGenerator->Initialize(gen, mf, argv[0]) ) + if ( parsed && !cpackGenerator->Initialize(gen, mf) ) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot initialize the generator " << gen << std::endl); diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx index 2dd3df7f3..d9977eaad 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.cxx +++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestBuildAndTestHandler.cxx,v $ Language: C++ - Date: $Date: 2007-09-17 14:40:57 $ - Version: $Revision: 1.20 $ + Date: $Date: 2008-09-04 21:10:45 $ + Version: $Revision: 1.20.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -79,7 +79,10 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring, config = this->CTest->GetConfigType().c_str(); } #ifdef CMAKE_INTDIR - config = CMAKE_INTDIR; + if(!config) + { + config = CMAKE_INTDIR; + } #endif if ( config ) @@ -143,6 +146,13 @@ void CMakeMessageCallback(const char* m, const char*, bool&, void* s) *out += "\n"; } +void CMakeProgressCallback(const char*msg, float , void * s) +{ + std::string* out = (std::string*)s; + *out += msg; + *out += "\n"; +} + //---------------------------------------------------------------------- void CMakeStdoutCallback(const char* m, int len, void* s) { @@ -210,6 +220,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) // should we cmake? cmake cm; + cm.SetProgressCallback(CMakeProgressCallback, &cmakeOutString); cm.SetGlobalGenerator(cm.CreateGlobalGenerator( this->BuildGenerator.c_str())); @@ -251,7 +262,10 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring) config = this->CTest->GetConfigType().c_str(); } #ifdef CMAKE_INTDIR - config = CMAKE_INTDIR; + if(!config) + { + config = CMAKE_INTDIR; + } #endif if(!config) { diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h index e6195dbbf..245b71099 100755 --- a/Source/CTest/cmCTestBuildCommand.h +++ b/Source/CTest/cmCTestBuildCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestBuildCommand.h,v $ Language: C++ - Date: $Date: 2006-03-29 17:01:24 $ - Version: $Revision: 1.5 $ + Date: $Date: 2008-05-15 19:39:57 $ + Version: $Revision: 1.5.12.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -47,7 +47,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() { return "CTEST_BUILD";} + virtual const char* GetName() { return "ctest_build";} /** * Succinct documentation. @@ -63,7 +63,7 @@ public: virtual const char* GetFullDocumentation() { return - " CTEST_BUILD([BUILD build_dir] [RETURN_VALUE res])\n" + " ctest_build([BUILD build_dir] [RETURN_VALUE res])\n" "Builds the given build directory and stores results in Build.xml."; } diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h index 3f860ae4f..530d28796 100755 --- a/Source/CTest/cmCTestConfigureCommand.h +++ b/Source/CTest/cmCTestConfigureCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestConfigureCommand.h,v $ Language: C++ - Date: $Date: 2006-03-29 17:01:24 $ - Version: $Revision: 1.5 $ + Date: $Date: 2008-05-15 19:39:58 $ + Version: $Revision: 1.5.12.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -44,7 +44,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() { return "CTEST_CONFIGURE";} + virtual const char* GetName() { return "ctest_configure";} /** * Succinct documentation. @@ -60,7 +60,7 @@ public: virtual const char* GetFullDocumentation() { return - " CTEST_CONFIGURE(BUILD build_dir RETURN_VALUE res)\n" + " ctest_configure(BUILD build_dir RETURN_VALUE res)\n" "Configures the given build directory and stores results in " "Configure.xml. The second argument is a variable that will hold " "return value."; diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h index f4149cc81..3d9bb1c5c 100644 --- a/Source/CTest/cmCTestCoverageCommand.h +++ b/Source/CTest/cmCTestCoverageCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestCoverageCommand.h,v $ Language: C++ - Date: $Date: 2006-03-29 17:01:24 $ - Version: $Revision: 1.4 $ + Date: $Date: 2008-05-15 19:39:58 $ + Version: $Revision: 1.4.12.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -44,7 +44,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() { return "CTEST_COVERAGE";} + virtual const char* GetName() { return "ctest_coverage";} /** * Succinct documentation. @@ -60,7 +60,7 @@ public: virtual const char* GetFullDocumentation() { return - " CTEST_COVERAGE([BUILD build_dir] [RETURN_VALUE res])\n" + " ctest_coverage([BUILD build_dir] [RETURN_VALUE res])\n" "Perform the coverage of the given build directory and stores results " "in Coverage.xml. The second argument is a variable that will hold " "value."; diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 920978d43..be4848a59 100755 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestCoverageHandler.cxx,v $ Language: C++ - Date: $Date: 2008-01-30 16:17:36 $ - Version: $Revision: 1.51 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.51.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -538,7 +538,7 @@ int cmCTestCoverageHandler::ProcessHandler() covSumFile << "\tCTest->MakeXMLSafe(fileName) << "\" FullPath=\"" << this->CTest->MakeXMLSafe( this->CTest->GetShortPathToFile(fullFileName.c_str())) - << "\" Covered=\"" << (tested==0?"true":"false") << "\">\n" + << "\" Covered=\"" << (tested > 0 ? "true":"false") << "\">\n" << "\t\t" << tested << "\n" << "\t\t" << untested << "\n" << "\t\t"; @@ -639,6 +639,18 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf) } } +//---------------------------------------------------------------------- +// Fix for issue #4971 where the case of the drive letter component of +// the filenames might be different when analyzing gcov output. +// +// Compare file names: fnc(fn1) == fnc(fn2) // fnc == file name compare +// +#ifdef _WIN32 +#define fnc(s) cmSystemTools::LowerCase(s) +#else +#define fnc(s) s +#endif + //---------------------------------------------------------------------- int cmCTestCoverageHandler::HandleGCovCoverage( cmCTestCoverageHandlerContainer* cont) @@ -673,6 +685,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( cmsys::Glob gl; gl.RecurseOn(); + gl.RecurseThroughSymlinksOff(); std::string daGlob = cont->BinaryDir + "/*.da"; gl.FindFiles(daGlob); std::vector files = gl.GetFiles(); @@ -706,6 +719,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage( " Processing coverage (each . represents one file):" << std::endl); cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); int file_count = 0; + // make sure output from gcov is in English! + cmSystemTools::PutEnv("LC_ALL=POSIX"); for ( it = files.begin(); it != files.end(); ++ it ) { cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush); @@ -967,9 +982,11 @@ int cmCTestCoverageHandler::HandleGCovCoverage( if ( !sourceFile.empty() && actualSourceFile.empty() ) { gcovFile = ""; + // Is it in the source dir? if ( sourceFile.size() > cont->SourceDir.size() && - sourceFile.substr(0, cont->SourceDir.size()) == cont->SourceDir && + (fnc(sourceFile.substr(0, cont->SourceDir.size())) == + fnc(cont->SourceDir)) && sourceFile[cont->SourceDir.size()] == '/' ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " produced s: " @@ -979,9 +996,11 @@ int cmCTestCoverageHandler::HandleGCovCoverage( actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); } + // Binary dir? if ( sourceFile.size() > cont->BinaryDir.size() && - sourceFile.substr(0, cont->BinaryDir.size()) == cont->BinaryDir && + (fnc(sourceFile.substr(0, cont->BinaryDir.size())) == + fnc(cont->BinaryDir)) && sourceFile[cont->BinaryDir.size()] == '/' ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " produced b: " @@ -991,21 +1010,25 @@ int cmCTestCoverageHandler::HandleGCovCoverage( actualSourceFile = cmSystemTools::CollapseFullPath(sourceFile.c_str()); } + if ( actualSourceFile.empty() ) { if ( missingFiles.find(actualSourceFile) == missingFiles.end() ) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Something went wrong" << std::endl); - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "File: [" + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Cannot find file: [" << sourceFile.c_str() << "]" << std::endl); - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "s: [" - << sourceFile.substr(0, cont->SourceDir.size()) << "]" + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " in source dir: [" + << cont->SourceDir.c_str() << "]" << std::endl); - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "b: [" - << sourceFile.substr(0, cont->BinaryDir.size()) << "]" + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " or binary dir: [" + << cont->BinaryDir.size() << "]" << std::endl); - *cont->OFS << " Something went wrong. Cannot find: " + *cont->OFS << " Something went wrong. Cannot find file: " << sourceFile.c_str() << " in source dir: " << cont->SourceDir.c_str() << " or binary dir: " << cont->BinaryDir.c_str() << std::endl; @@ -1032,6 +1055,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage( { cmsys::Glob gl; gl.RecurseOn(); + gl.RecurseThroughSymlinksOff(); std::string daGlob = cont->BinaryDir + "/*.cover"; gl.FindFiles(daGlob); std::vector files = gl.GetFiles(); diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h index 9b23216b8..6494b95c0 100755 --- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h +++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestEmptyBinaryDirectoryCommand.h,v $ Language: C++ - Date: $Date: 2008-01-23 15:28:01 $ - Version: $Revision: 1.4 $ + Date: $Date: 2008-05-15 19:39:59 $ + Version: $Revision: 1.4.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -53,7 +53,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() { return "CTEST_EMPTY_BINARY_DIRECTORY";} + virtual const char* GetName() { return "ctest_empty_binary_directory";} /** * Succinct documentation. @@ -69,7 +69,7 @@ public: virtual const char* GetFullDocumentation() { return - " CTEST_EMPTY_BINARY_DIRECTORY( directory )\n" + " ctest_empty_binary_directory( directory )\n" "Removes a binary directory. This command will perform some checks " "prior to deleting the directory in an attempt to avoid malicious " "or accidental directory deletion."; diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h index 3c790cdad..bf35f323a 100644 --- a/Source/CTest/cmCTestMemCheckCommand.h +++ b/Source/CTest/cmCTestMemCheckCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestMemCheckCommand.h,v $ Language: C++ - Date: $Date: 2006-03-10 20:03:09 $ - Version: $Revision: 1.4 $ + Date: $Date: 2008-05-15 19:39:59 $ + Version: $Revision: 1.4.12.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -46,7 +46,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() { return "CTEST_MEMCHECK";} + virtual const char* GetName() { return "ctest_memcheck";} /** * Succinct documentation. @@ -62,7 +62,7 @@ public: virtual const char* GetFullDocumentation() { return - " CTEST_MEMCHECK([BUILD build_dir] [RETURN_VALUE res])\n" + " ctest_memcheck([BUILD build_dir] [RETURN_VALUE res])\n" "Performs a memory checking of tests in the given build directory and " "stores results in MemCheck.xml. The second argument is a variable " "that will hold value."; diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.h b/Source/CTest/cmCTestReadCustomFilesCommand.h index b964b54f4..81dc5f10f 100755 --- a/Source/CTest/cmCTestReadCustomFilesCommand.h +++ b/Source/CTest/cmCTestReadCustomFilesCommand.h @@ -51,7 +51,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() { return "CTEST_READ_CUSTOM_FILES";} + virtual const char* GetName() { return "ctest_read_custom_files";} /** * Succinct documentation. @@ -67,7 +67,7 @@ public: virtual const char* GetFullDocumentation() { return - " CTEST_READ_CUSTOM_FILES( directory ... )\n" + " ctest_read_custom_files( directory ... )\n" "Read all the CTestCustom.ctest or CTestCustom.cmake files from " "the given directory."; } diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h index 28398ac09..fcdbff8dd 100755 --- a/Source/CTest/cmCTestRunScriptCommand.h +++ b/Source/CTest/cmCTestRunScriptCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestRunScriptCommand.h,v $ Language: C++ - Date: $Date: 2008-01-23 15:28:01 $ - Version: $Revision: 1.4 $ + Date: $Date: 2008-05-15 19:39:59 $ + Version: $Revision: 1.4.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -52,7 +52,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() { return "CTEST_RUN_SCRIPT";} + virtual const char* GetName() { return "ctest_run_script";} /** * Succinct documentation. @@ -68,7 +68,7 @@ public: virtual const char* GetFullDocumentation() { return - " CTEST_RUN_SCRIPT([NEW_PROCESS] script_file_name script_file_name1 \n" + " ctest_run_script([NEW_PROCESS] script_file_name script_file_name1 \n" " script_file_name2 ...)\n" "Runs a script or scripts much like if it was run from ctest -S. " "If no argument is provided then the current script is run using " diff --git a/Source/CTest/cmCTestSleepCommand.h b/Source/CTest/cmCTestSleepCommand.h index efa7d0611..978a819d7 100755 --- a/Source/CTest/cmCTestSleepCommand.h +++ b/Source/CTest/cmCTestSleepCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestSleepCommand.h,v $ Language: C++ - Date: $Date: 2008-01-23 15:28:01 $ - Version: $Revision: 1.3 $ + Date: $Date: 2008-05-15 19:39:59 $ + Version: $Revision: 1.3.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -52,7 +52,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() { return "CTEST_SLEEP";} + virtual const char* GetName() { return "ctest_sleep";} /** * Succinct documentation. @@ -68,8 +68,8 @@ public: virtual const char* GetFullDocumentation() { return - " CTEST_SLEEP( seconds )\n" - " CTEST_SLEEP( time1 duration time2 )\n" + " ctest_sleep( seconds )\n" + " ctest_sleep( time1 duration time2 )\n" "With one argument it will sleep for a given number of seconds. " "With three arguments it will wait for time2 - time1 - duration " "seconds."; diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h index 48d79c7e6..57ecd8b1c 100755 --- a/Source/CTest/cmCTestStartCommand.h +++ b/Source/CTest/cmCTestStartCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestStartCommand.h,v $ Language: C++ - Date: $Date: 2008-01-23 15:28:01 $ - Version: $Revision: 1.5 $ + Date: $Date: 2008-05-15 19:39:59 $ + Version: $Revision: 1.5.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -51,7 +51,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() { return "CTEST_START";} + virtual const char* GetName() { return "ctest_start";} /** * Succinct documentation. @@ -67,7 +67,7 @@ public: virtual const char* GetFullDocumentation() { return - " CTEST_START(Model [TRACK ] [source [binary]])\n" + " ctest_start(Model [TRACK ] [source [binary]])\n" "Starts the testing for a given model. The command should be called " "after the binary directory is initialized. If the 'source' and " "'binary' directory are not specified, it reads the " diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index 2c5370b04..bf7fcfa06 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestSubmitCommand.h,v $ Language: C++ - Date: $Date: 2006-03-29 17:01:24 $ - Version: $Revision: 1.5 $ + Date: $Date: 2008-05-15 19:40:00 $ + Version: $Revision: 1.5.12.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -45,7 +45,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() { return "CTEST_SUBMIT";} + virtual const char* GetName() { return "ctest_submit";} /** * Succinct documentation. @@ -61,7 +61,7 @@ public: virtual const char* GetFullDocumentation() { return - " CTEST_SUBMIT([RETURN_VALUE res])\n" + " ctest_submit([RETURN_VALUE res])\n" "Submits the test results for the project."; } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index f2ef4ac26..bba857ef4 100755 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestTestHandler.cxx,v $ Language: C++ - Date: $Date: 2008-01-31 21:33:07 $ - Version: $Revision: 1.68 $ + Date: $Date: 2008-06-25 13:51:45 $ + Version: $Revision: 1.68.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -1165,7 +1165,7 @@ std::string cmCTestTestHandler::FindTheExecutable(const char *exe) failedPaths); } -// add additional configuraitons to the search path +// add additional configurations to the search path void cmCTestTestHandler ::AddConfigurations(cmCTest *ctest, std::vector &attempted, @@ -1175,7 +1175,8 @@ void cmCTestTestHandler { std::string tempPath; - if (filepath.size()) + if (filepath.size() && + filepath[filepath.size()-1] != '/') { filepath += "/"; } @@ -1259,6 +1260,16 @@ std::string cmCTestTestHandler attemptedConfigs, filepath,filename); + // even if a fullpath was specified also try it relative to the current directory + if (filepath.size() && filepath[0] == '/') + { + std::string localfilepath = filepath.substr(1,filepath.size()-1); + cmCTestTestHandler::AddConfigurations(ctest, attempted, + 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) @@ -1274,8 +1285,8 @@ std::string cmCTestTestHandler filepathExtra, filenameExtra); } - } - + } + // store the final location in fullPath std::string fullPath; @@ -1543,6 +1554,15 @@ std::string cmCTestTestHandler::GenerateRegressionImages( SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\"" SPACE_REGEX "*>([^<]*)"); + cmsys::RegularExpression cdatastart( + "" + SPACE_REGEX "*" + SPACE_REGEX "*"); cmsys::RegularExpression measurementfile( "" + << std::endl; + cxml.erase(cdatastart.start(), + cdataend.end() - cdatastart.start()); + } else if ( measurementfile.find(cxml) ) { const std::string& filename = diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h index 6217743df..dc07a4061 100755 --- a/Source/CTest/cmCTestUpdateCommand.h +++ b/Source/CTest/cmCTestUpdateCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCTestUpdateCommand.h,v $ Language: C++ - Date: $Date: 2006-03-29 17:01:24 $ - Version: $Revision: 1.5 $ + Date: $Date: 2008-05-15 19:40:00 $ + Version: $Revision: 1.5.12.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -44,7 +44,7 @@ public: /** * The name of the command as specified in CMakeList.txt. */ - virtual const char* GetName() { return "CTEST_UPDATE";} + virtual const char* GetName() { return "ctest_update";} /** * Succinct documentation. @@ -60,7 +60,7 @@ public: virtual const char* GetFullDocumentation() { return - " CTEST_UPDATE([SOURCE source] [RETURN_VALUE res])\n" + " ctest_update([SOURCE source] [RETURN_VALUE res])\n" "Updates the given source directory and stores results in Update.xml. " "The second argument is a variable that will hold the number of files " "modified. If there is a problem, the variable will be -1."; diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx index 09ba9eafa..80e2d1a71 100644 --- a/Source/CursesDialog/cmCursesStringWidget.cxx +++ b/Source/CursesDialog/cmCursesStringWidget.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCursesStringWidget.cxx,v $ Language: C++ - Date: $Date: 2006-03-16 15:44:55 $ - Version: $Revision: 1.13 $ + Date: $Date: 2008-09-03 13:43:19 $ + Version: $Revision: 1.13.12.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -170,14 +170,21 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm, { form_driver(form, REQ_END_FIELD); } - else if ( key == ctrl('d') || key == 127 || - key == KEY_BACKSPACE || key == KEY_DC ) + else if ( key == 127 || + key == KEY_BACKSPACE ) { if ( form->curcol > 0 ) { form_driver(form, REQ_DEL_PREV); } } + else if ( key == ctrl('d') ||key == KEY_DC ) + { + if ( form->curcol > 0 ) + { + form_driver(form, REQ_DEL_CHAR); + } + } else { this->OnType(key, fm, w); diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx index b758702ec..7f6ef9e10 100644 --- a/Source/QtDialog/AddCacheEntry.cxx +++ b/Source/QtDialog/AddCacheEntry.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: AddCacheEntry.cxx,v $ Language: C++ - Date: $Date: 2007-11-17 02:18:48 $ - Version: $Revision: 1.3 $ + Date: $Date: 2008-05-23 20:09:41 $ + Version: $Revision: 1.3.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -21,9 +21,9 @@ static const int NumTypes = 4; static const QString TypeStrings[NumTypes] = { "BOOL", "PATH", "FILEPATH", "STRING" }; -static const QCMakeCacheProperty::PropertyType Types[NumTypes] = - { QCMakeCacheProperty::BOOL, QCMakeCacheProperty::PATH, - QCMakeCacheProperty::FILEPATH, QCMakeCacheProperty::STRING}; +static const QCMakeProperty::PropertyType Types[NumTypes] = + { QCMakeProperty::BOOL, QCMakeProperty::PATH, + QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; AddCacheEntry::AddCacheEntry(QWidget* p) : QWidget(p) @@ -34,8 +34,8 @@ AddCacheEntry::AddCacheEntry(QWidget* p) this->Type->addItem(TypeStrings[i]); } QWidget* cb = new QCheckBox(); - QWidget* path = new QCMakeCachePathEditor(); - QWidget* filepath = new QCMakeCacheFilePathEditor(); + QWidget* path = new QCMakePathEditor(); + QWidget* filepath = new QCMakeFilePathEditor(); QWidget* string = new QLineEdit(); this->StackedWidget->addWidget(cb); this->StackedWidget->addWidget(path); @@ -73,14 +73,14 @@ QString AddCacheEntry::description() const return this->Description->text(); } -QCMakeCacheProperty::PropertyType AddCacheEntry::type() const +QCMakeProperty::PropertyType AddCacheEntry::type() const { int idx = this->Type->currentIndex(); if(idx >= 0 && idx < NumTypes) { return Types[idx]; } - return QCMakeCacheProperty::BOOL; + return QCMakeProperty::BOOL; } diff --git a/Source/QtDialog/AddCacheEntry.h b/Source/QtDialog/AddCacheEntry.h index 0d6579621..528dc3671 100644 --- a/Source/QtDialog/AddCacheEntry.h +++ b/Source/QtDialog/AddCacheEntry.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: AddCacheEntry.h,v $ Language: C++ - Date: $Date: 2007-11-13 04:59:25 $ - Version: $Revision: 1.2 $ + Date: $Date: 2008-05-23 20:09:42 $ + Version: $Revision: 1.2.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -33,7 +33,7 @@ public: QString name() const; QVariant value() const; QString description() const; - QCMakeCacheProperty::PropertyType type() const; + QCMakeProperty::PropertyType type() const; }; #endif diff --git a/Source/QtDialog/AddCacheEntry.ui b/Source/QtDialog/AddCacheEntry.ui index 3ed9b490b..a81587473 100644 --- a/Source/QtDialog/AddCacheEntry.ui +++ b/Source/QtDialog/AddCacheEntry.ui @@ -65,14 +65,14 @@ - QCMakeCachePathEditor + QCMakePathEditor QLineEdit -
QCMakeCacheView.h
+
QCMakeWidgets.h
- QCMakeCacheFilePathEditor + QCMakeFilePathEditor QLineEdit -
QCMakeCacheView.h
+
QCMakeWidgets.h
diff --git a/Source/QtDialog/CMakeFirstConfigure.cxx b/Source/QtDialog/CMakeFirstConfigure.cxx new file mode 100644 index 000000000..8e81956c3 --- /dev/null +++ b/Source/QtDialog/CMakeFirstConfigure.cxx @@ -0,0 +1,244 @@ + +#include "CMakeFirstConfigure.h" + +#include + +CMakeFirstConfigure::CMakeFirstConfigure() +{ + this->UI.setupUi(this); + this->UI.useDefaults->setChecked(true); + this->updatePage(); + + this->UI.useToolChainFile->setChecked(true); + this->updateToolChainPage(); + + QObject::connect(this->UI.useDefaults, SIGNAL(toggled(bool)), + this, SLOT(updatePage())); + QObject::connect(this->UI.compilerSetup, SIGNAL(toggled(bool)), + this, SLOT(updatePage())); + QObject::connect(this->UI.crossCompilerSetup, SIGNAL(toggled(bool)), + this, SLOT(updatePage())); + + QObject::connect(this->UI.useToolChainFile, SIGNAL(toggled(bool)), + this, SLOT(updateToolChainPage())); +} + +CMakeFirstConfigure::~CMakeFirstConfigure() +{ +} + +void CMakeFirstConfigure::setGenerators(const QStringList& gens) +{ + this->UI.generators->clear(); + this->UI.generators->addItems(gens); +} + +QString CMakeFirstConfigure::getGenerator() const +{ + return this->UI.generators->currentText(); +} + +void CMakeFirstConfigure::loadFromSettings() +{ + QSettings settings; + settings.beginGroup("Settings/StartPath"); + + // restore generator + QString lastGen = settings.value("LastGenerator").toString(); + int idx = this->UI.generators->findText(lastGen); + if(idx != -1) + { + this->UI.generators->setCurrentIndex(idx); + } + settings.endGroup(); + + // restore compiler setup + settings.beginGroup("Settings/Compiler"); + this->UI.CCompiler->setText(settings.value("CCompiler").toString()); + this->UI.CXXCompiler->setText(settings.value("CXXCompiler").toString()); + this->UI.FortranCompiler->setText(settings.value("FortranCompiler").toString()); + settings.endGroup(); + + // restore cross compiler setup + settings.beginGroup("Settings/CrossCompiler"); + this->UI.crossCCompiler->setText(settings.value("CCompiler").toString()); + this->UI.crossCXXCompiler->setText(settings.value("CXXCompiler").toString()); + this->UI.crossFortranCompiler->setText(settings.value("FortranCompiler").toString()); + this->UI.useToolChainFile->setChecked(settings.value("UseToolChainFile", true).toBool()); + this->UI.toolChainFile->setText(settings.value("ToolChainFile").toString()); + this->UI.systemName->setText(settings.value("SystemName").toString()); + this->UI.systemVersion->setText(settings.value("SystemVersion").toString()); + this->UI.systemProcessor->setText(settings.value("SystemProcessor").toString()); + this->UI.crossFindRoot->setText(settings.value("FindRoot").toString()); + this->UI.crossProgramMode->setCurrentIndex(settings.value("ProgramMode", 0).toInt()); + this->UI.crossLibraryMode->setCurrentIndex(settings.value("LibraryMode", 0).toInt()); + this->UI.crossIncludeMode->setCurrentIndex(settings.value("IncludeMode", 0).toInt()); + settings.endGroup(); +} + +void CMakeFirstConfigure::saveToSettings() +{ + QSettings settings; + settings.beginGroup("Settings/StartPath"); + + // save generator + QString lastGen = this->UI.generators->currentText(); + settings.setValue("LastGenerator", lastGen); + + settings.endGroup(); + + // save compiler setup + settings.beginGroup("Settings/Compiler"); + settings.setValue("CCompiler", this->UI.CCompiler->text()); + settings.setValue("CXXCompiler", this->UI.CXXCompiler->text()); + settings.setValue("FortranCompiler", this->UI.FortranCompiler->text()); + settings.endGroup(); + + // save cross compiler setup + settings.beginGroup("Settings/CrossCompiler"); + settings.setValue("CCompiler", this->UI.crossCCompiler->text()); + settings.setValue("CXXCompiler", this->UI.crossCXXCompiler->text()); + settings.setValue("FortranCompiler", this->UI.crossFortranCompiler->text()); + settings.setValue("UseToolChainFile", this->UI.useToolChainFile->isChecked()); + settings.setValue("ToolChainFile", this->UI.toolChainFile->text()); + settings.setValue("SystemName", this->UI.systemName->text()); + settings.setValue("SystemVersion", this->UI.systemVersion->text()); + settings.setValue("SystemProcessor", this->UI.systemProcessor->text()); + settings.setValue("FindRoot", this->UI.crossFindRoot->text()); + settings.setValue("ProgramMode", this->UI.crossProgramMode->currentIndex()); + settings.setValue("LibraryMode", this->UI.crossLibraryMode->currentIndex()); + settings.setValue("IncludeMode", this->UI.crossIncludeMode->currentIndex()); + settings.endGroup(); +} + +void CMakeFirstConfigure::updatePage() +{ + if(this->UI.useDefaults->isChecked()) + { + this->UI.stackedWidget->setCurrentIndex(0); + } + else if(this->UI.compilerSetup->isChecked()) + { + this->UI.stackedWidget->setCurrentIndex(1); + } + else if(this->UI.crossCompilerSetup->isChecked()) + { + this->UI.stackedWidget->setCurrentIndex(2); + } +} + +void CMakeFirstConfigure::updateToolChainPage() +{ + if(this->UI.useToolChainFile->isChecked()) + { + this->UI.toolChainStack->setCurrentIndex(0); + } + else + { + this->UI.toolChainStack->setCurrentIndex(1); + } +} + +bool CMakeFirstConfigure::defaultSetup() const +{ + return this->UI.useDefaults->isChecked(); +} + +bool CMakeFirstConfigure::compilerSetup() const +{ + return this->UI.compilerSetup->isChecked(); +} + +bool CMakeFirstConfigure::crossCompilerSetup() const +{ + return this->UI.crossCompilerSetup->isChecked(); +} + +QString CMakeFirstConfigure::crossCompilerToolChainFile() const +{ + if(this->UI.useToolChainFile->isChecked()) + { + return this->UI.toolChainFile->text(); + } + return QString(); +} + +QString CMakeFirstConfigure::getSystemName() const +{ + return this->UI.systemName->text(); +} + +QString CMakeFirstConfigure::getCCompiler() const +{ + if(this->compilerSetup()) + { + return this->UI.CCompiler->text(); + } + else if(this->crossCompilerSetup()) + { + return this->UI.crossCCompiler->text(); + } + return QString(); +} + +QString CMakeFirstConfigure::getCXXCompiler() const +{ + if(this->compilerSetup()) + { + return this->UI.CXXCompiler->text(); + } + else if(this->crossCompilerSetup()) + { + return this->UI.crossCXXCompiler->text(); + } + return QString(); +} + +QString CMakeFirstConfigure::getFortranCompiler() const +{ + if(this->compilerSetup()) + { + return this->UI.FortranCompiler->text(); + } + else if(this->crossCompilerSetup()) + { + return this->UI.crossFortranCompiler->text(); + } + return QString(); +} + + +QString CMakeFirstConfigure::getSystemVersion() const +{ + return this->UI.systemVersion->text(); +} + +QString CMakeFirstConfigure::getSystemProcessor() const +{ + return this->UI.systemProcessor->text(); +} + + +QString CMakeFirstConfigure::getCrossRoot() const +{ + return this->UI.crossFindRoot->text(); +} + +static const char* crossModes[3] = {"BOTH", "ONLY", "NEVER" }; + +QString CMakeFirstConfigure::getCrossProgramMode() const +{ + return crossModes[this->UI.crossProgramMode->currentIndex()]; +} + +QString CMakeFirstConfigure::getCrossLibraryMode() const +{ + return crossModes[this->UI.crossLibraryMode->currentIndex()]; +} + +QString CMakeFirstConfigure::getCrossIncludeMode() const +{ + return crossModes[this->UI.crossIncludeMode->currentIndex()]; +} + + diff --git a/Source/QtDialog/CMakeFirstConfigure.h b/Source/QtDialog/CMakeFirstConfigure.h new file mode 100644 index 000000000..2cb6220c0 --- /dev/null +++ b/Source/QtDialog/CMakeFirstConfigure.h @@ -0,0 +1,48 @@ + +#ifndef CMakeFirstConfigure_h +#define CMakeFirstConfigure_h + +#include +#include "ui_CMakeFirstConfigure.h" + +class CMakeFirstConfigure : public QDialog +{ + Q_OBJECT +public: + CMakeFirstConfigure(); + ~CMakeFirstConfigure(); + + void setGenerators(const QStringList& gens); + QString getGenerator() const; + + bool defaultSetup() const; + bool compilerSetup() const; + bool crossCompilerSetup() const; + QString crossCompilerToolChainFile() const; + + QString getCCompiler() const; + QString getCXXCompiler() const; + QString getFortranCompiler() const; + + QString getSystemName() const; + QString getSystemVersion() const; + QString getSystemProcessor() const; + + QString getCrossRoot() const; + QString getCrossProgramMode() const; + QString getCrossLibraryMode() const; + QString getCrossIncludeMode() const; + + void loadFromSettings(); + void saveToSettings(); + +protected slots: + void updatePage(); + void updateToolChainPage(); + +protected: + Ui::CMakeFirstConfigure UI; +}; + +#endif // CMakeFirstConfigure_h + diff --git a/Source/QtDialog/CMakeFirstConfigure.ui b/Source/QtDialog/CMakeFirstConfigure.ui new file mode 100644 index 000000000..d5413f393 --- /dev/null +++ b/Source/QtDialog/CMakeFirstConfigure.ui @@ -0,0 +1,606 @@ + + CMakeFirstConfigure + + + + 0 + 0 + 609 + 547 + + + + First Configure Setup + + + + + + + 0 + 0 + + + + Please select what build system you want CMake to generate files for. You should select the tool that you will use to build the project. + + + true + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Use Defaults + + + true + + + + + + + Compiler Setup + + + + + + + Cross Compiler Setup + + + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + 2 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + The default compilers will be used. + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Compilers + + + + + + C + + + + + + + + + + C++ + + + + + + + + + + Fortran + + + + + + + + + + + + + Qt::Vertical + + + + 566 + 71 + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + 1 + + + + + 9 + + + 9 + + + 9 + + + 9 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Tool Chain File + + + true + + + + + + + + + + + + 0 + 0 + + + + System + + + + + + + + + 0 + 0 + + + + Name + + + + + + + + + + + 0 + 0 + + + + Version + + + true + + + + + + + + + + + 0 + 0 + + + + Processor + + + true + + + + + + + + + + + + + + + + 0 + 0 + + + + Compilers + + + + + + C + + + + + + + + + + C++ + + + + + + + + + + Fortran + + + + + + + + + + + + + + 0 + 0 + + + + Find Program/Library/Include + + + + + + + 0 + 0 + + + + Root + + + true + + + + + + + + + + + 0 + 0 + + + + Program Mode + + + + + + + + Find from Root then system + + + + + Only find from Root + + + + + Don't find from Root + + + + + + + + + 0 + 0 + + + + Library Mode + + + + + + + + Find from Root then system + + + + + Only find from Root + + + + + Don't find from Root + + + + + + + + + 0 + 0 + + + + Include Mode + + + + + + + + Find from Root then system + + + + + Only find from Root + + + + + Don't find from Root + + + + + + + + + + + + + + + Use ToolChain File + + + true + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 0 + 20 + + + + + + + + + QCMakeFilePathEditor + QLineEdit +
QCMakeWidgets.h
+
+ + QCMakePathEditor + QLineEdit +
QCMakeWidgets.h
+
+
+ + + + buttonBox + accepted() + CMakeFirstConfigure + accept() + + + 227 + 284 + + + 157 + 274 + + + + + buttonBox + rejected() + CMakeFirstConfigure + reject() + + + 295 + 290 + + + 286 + 274 + + + + +
diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 37f96ed6f..b74987ef5 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -1,5 +1,5 @@ PROJECT(QtDialog) -SET(QT_MIN_VERSION "4.2.0") +SET(QT_MIN_VERSION "4.3.0") FIND_PACKAGE(Qt4 REQUIRED) IF(NOT QT4_FOUND) @@ -16,6 +16,8 @@ ELSE(NOT QT4_FOUND) SET(SRCS AddCacheEntry.cxx AddCacheEntry.h + CMakeFirstConfigure.cxx + CMakeFirstConfigure.h CMakeSetup.cxx CMakeSetupDialog.cxx CMakeSetupDialog.h @@ -23,19 +25,24 @@ ELSE(NOT QT4_FOUND) QCMake.h QCMakeCacheView.cxx QCMakeCacheView.h + QCMakeWidgets.cxx + QCMakeWidgets.h QMacInstallDialog.cxx QMacInstallDialog.h ) QT4_WRAP_UI(UI_SRCS + CMakeFirstConfigure.ui CMakeSetupDialog.ui AddCacheEntry.ui MacInstallDialog.ui ) QT4_WRAP_CPP(MOC_SRCS AddCacheEntry.h + CMakeFirstConfigure.h CMakeSetupDialog.h QCMake.h QCMakeCacheView.h + QCMakeWidgets.h QMacInstallDialog.h ) QT4_ADD_RESOURCES(RC_SRCS CMakeSetup.qrc) diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index cb52351e3..e815c193c 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: CMakeSetupDialog.cxx,v $ Language: C++ - Date: $Date: 2008-04-21 00:44:53 $ - Version: $Revision: 1.40.2.4 $ + Date: $Date: 2008-07-13 21:55:25 $ + Version: $Revision: 1.40.2.7 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -36,6 +36,7 @@ #include "QCMake.h" #include "QCMakeCacheView.h" #include "AddCacheEntry.h" +#include "CMakeFirstConfigure.h" QCMakeThread::QCMakeThread(QObject* p) : QThread(p), CMakeInstance(NULL) @@ -60,7 +61,6 @@ void QCMakeThread::run() CMakeSetupDialog::CMakeSetupDialog() : ExitAfterGenerate(true), CacheModified(false), CurrentState(Interrupting) { - this->SuppressDevWarnings = false; // create the GUI QSettings settings; settings.beginGroup("Settings/StartPath"); @@ -77,6 +77,13 @@ CMakeSetupDialog::CMakeSetupDialog() this->RemoveEntry->setEnabled(false); this->AddEntry->setEnabled(false); + bool groupView = settings.value("GroupView", false).toBool(); + if(groupView) + { + this->setViewType(2); + this->ViewType->setCurrentIndex(2); + } + QMenu* FileMenu = this->menuBar()->addMenu(tr("&File")); this->ReloadCacheAction = FileMenu->addAction(tr("&Reload Cache")); QObject::connect(this->ReloadCacheAction, SIGNAL(triggered(bool)), @@ -104,15 +111,21 @@ CMakeSetupDialog::CMakeSetupDialog() this, SLOT(doInstallForCommandLine())); #endif QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options")); - QAction* supressDevWarningsAction = OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)")); - QObject::connect(supressDevWarningsAction, SIGNAL(triggered(bool)), - this, SLOT(doSuppressDev())); + this->SuppressDevWarningsAction = OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)")); + this->SuppressDevWarningsAction->setCheckable(true); - supressDevWarningsAction->setCheckable(true); QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output")); debugAction->setCheckable(true); QObject::connect(debugAction, SIGNAL(toggled(bool)), this, SLOT(setDebugOutput(bool))); + + OptionsMenu->addSeparator(); + QAction* expandAction = OptionsMenu->addAction(tr("&Expand Grouped Entries")); + QObject::connect(expandAction, SIGNAL(triggered(bool)), + this->CacheValues, SLOT(expandAll())); + QAction* collapseAction = OptionsMenu->addAction(tr("&Collapse Grouped Entries")); + QObject::connect(collapseAction, SIGNAL(triggered(bool)), + this->CacheValues, SLOT(collapseAll())); QMenu* HelpMenu = this->menuBar()->addMenu(tr("&Help")); QAction* a = HelpMenu->addAction(tr("About")); @@ -153,9 +166,9 @@ void CMakeSetupDialog::initialize() { // now the cmake worker thread is running, lets make our connections to it QObject::connect(this->CMakeThread->cmakeInstance(), - SIGNAL(propertiesChanged(const QCMakeCachePropertyList&)), + SIGNAL(propertiesChanged(const QCMakePropertyList&)), this->CacheValues->cacheModel(), - SLOT(setProperties(const QCMakeCachePropertyList&))); + SLOT(setProperties(const QCMakePropertyList&))); QObject::connect(this->ConfigureButton, SIGNAL(clicked(bool)), this, SLOT(doConfigure())); @@ -198,8 +211,8 @@ void CMakeSetupDialog::initialize() SIGNAL(outputMessage(QString)), this, SLOT(message(QString))); - QObject::connect(this->Advanced, SIGNAL(clicked(bool)), - this->CacheValues, SLOT(setShowAdvanced(bool))); + QObject::connect(this->ViewType, SIGNAL(currentIndexChanged(int)), + this, SLOT(setViewType(int))); QObject::connect(this->Search, SIGNAL(textChanged(QString)), this->CacheValues, SLOT(setSearchFilter(QString))); @@ -220,6 +233,8 @@ void CMakeSetupDialog::initialize() QObject::connect(this->AddEntry, SIGNAL(clicked(bool)), this, SLOT(addCacheEntry())); + QObject::connect(this->SuppressDevWarningsAction, SIGNAL(triggered(bool)), + this->CMakeThread->cmakeInstance(), SLOT(setSuppressDevWarnings(bool))); if(!this->SourceDirectory->text().isEmpty() || !this->BinaryDirectory->lineEdit()->text().isEmpty()) @@ -275,10 +290,10 @@ void CMakeSetupDialog::doConfigure() dir.mkpath("."); } - // prompt for generator if it hasn't been set + // if no generator, prompt for it and other setup stuff if(this->CMakeThread->cmakeInstance()->generator().isEmpty()) { - if(!this->promptForGenerator()) + if(!this->setupFirstConfigure()) { return; } @@ -292,7 +307,7 @@ void CMakeSetupDialog::doConfigure() this->CacheValues->selectionModel()->clear(); QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "setProperties", Qt::QueuedConnection, - Q_ARG(QCMakeCachePropertyList, + Q_ARG(QCMakePropertyList, this->CacheValues->cacheModel()->properties())); QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "configure", Qt::QueuedConnection); @@ -300,7 +315,7 @@ void CMakeSetupDialog::doConfigure() void CMakeSetupDialog::finishConfigure(int err) { - if(0 == err && 0 == this->CacheValues->cacheModel()->newCount()) + if(0 == err && !this->CacheValues->cacheModel()->newPropertyCount()) { this->enterState(ReadyGenerate); } @@ -329,13 +344,6 @@ void CMakeSetupDialog::finishGenerate(int err) } } -void CMakeSetupDialog::doSuppressDev() -{ - this->SuppressDevWarnings = !this->SuppressDevWarnings; - this->CMakeThread->cmakeInstance()-> - SetSuppressDevWarnings(this->SuppressDevWarnings); -} - void CMakeSetupDialog::doInstallForCommandLine() { QMacInstallDialog setupdialog(0); @@ -542,41 +550,89 @@ void CMakeSetupDialog::setEnabledState(bool enabled) this->RemoveEntry->setEnabled(false); // let selection re-enable it } -bool CMakeSetupDialog::promptForGenerator() +bool CMakeSetupDialog::setupFirstConfigure() { - QSettings settings; - settings.beginGroup("Settings/StartPath"); - QString lastGen = settings.value("LastGenerator").toString(); + CMakeFirstConfigure dialog; - QStringList gens = this->CMakeThread->cmakeInstance()->availableGenerators(); - QDialog dialog; - dialog.setWindowTitle(tr("Choose Generator")); - QLabel* lab = new QLabel(&dialog); - lab->setText(tr("Please select what build system you want CMake to generate files for.\n" - "You should select the tool that you will use to build the project.\n" - "Press OK once you have made your selection.")); - QComboBox* combo = new QComboBox(&dialog); - combo->addItems(gens); - int idx = combo->findText(lastGen); - if(idx != -1) - { - combo->setCurrentIndex(idx); - } - QDialogButtonBox* btns = new QDialogButtonBox(QDialogButtonBox::Ok | - QDialogButtonBox::Cancel, - Qt::Horizontal, &dialog); - QObject::connect(btns, SIGNAL(accepted()), &dialog, SLOT(accept())); - QObject::connect(btns, SIGNAL(rejected()), &dialog, SLOT(reject())); + // initialize dialog and restore saved settings + + // add generators + dialog.setGenerators(this->CMakeThread->cmakeInstance()->availableGenerators()); + + // restore from settings + dialog.loadFromSettings(); - QVBoxLayout* l = new QVBoxLayout(&dialog); - l->addWidget(lab); - l->addWidget(combo); - l->addWidget(btns); if(dialog.exec() == QDialog::Accepted) { - lastGen = combo->currentText(); - settings.setValue("LastGenerator", lastGen); - this->CMakeThread->cmakeInstance()->setGenerator(combo->currentText()); + dialog.saveToSettings(); + this->CMakeThread->cmakeInstance()->setGenerator(dialog.getGenerator()); + + QCMakeCacheModel* m = this->CacheValues->cacheModel(); + + if(dialog.compilerSetup()) + { + QString fortranCompiler = dialog.getFortranCompiler(); + if(!fortranCompiler.isEmpty()) + { + m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER", + "Fortran compiler.", fortranCompiler, false); + } + QString cxxCompiler = dialog.getCXXCompiler(); + if(!cxxCompiler.isEmpty()) + { + m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER", + "CXX compiler.", cxxCompiler, false); + } + + QString cCompiler = dialog.getCCompiler(); + if(!cCompiler.isEmpty()) + { + m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER", + "C compiler.", cCompiler, false); + } + } + else if(dialog.crossCompilerSetup()) + { + QString toolchainFile = dialog.crossCompilerToolChainFile(); + if(!toolchainFile.isEmpty()) + { + m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_TOOLCHAIN_FILE", + "Cross Compile ToolChain File", toolchainFile, false); + } + else + { + QString fortranCompiler = dialog.getFortranCompiler(); + if(!fortranCompiler.isEmpty()) + { + m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER", + "Fortran compiler.", fortranCompiler, false); + } + + QString mode = dialog.getCrossIncludeMode(); + m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE", + "CMake Find Include Mode", mode, false); + mode = dialog.getCrossLibraryMode(); + m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY", + "CMake Find Library Mode", mode, false); + mode = dialog.getCrossProgramMode(); + m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM", + "CMake Find Program Mode", mode, false); + + QString rootPath = dialog.getCrossRoot(); + m->insertProperty(QCMakeProperty::PATH, "CMAKE_FIND_ROOT_PATH", + "CMake Find Root Path", rootPath, false); + + QString systemName = dialog.getSystemName(); + m->insertProperty(QCMakeProperty::STRING, "CMAKE_SYSTEM_NAME", + "CMake System Name", systemName, false); + QString cxxCompiler = dialog.getCXXCompiler(); + m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER", + "CXX compiler.", cxxCompiler, false); + QString cCompiler = dialog.getCCompiler(); + m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER", + "C compiler.", cCompiler, false); + } + } return true; } @@ -767,7 +823,7 @@ void CMakeSetupDialog::removeSelectedCacheEntries() } foreach(QPersistentModelIndex pi, pidxs) { - this->CacheValues->model()->removeRow(pi.row()); + this->CacheValues->model()->removeRow(pi.row(), pi.parent()); } } @@ -856,20 +912,7 @@ void CMakeSetupDialog::addCacheEntry() if(QDialog::Accepted == dialog.exec()) { QCMakeCacheModel* m = this->CacheValues->cacheModel(); - m->insertRows(0, 1, QModelIndex()); - m->setData(m->index(0, 0), w->type(), QCMakeCacheModel::TypeRole); - m->setData(m->index(0, 0), w->name(), Qt::DisplayRole); - m->setData(m->index(0, 0), w->description(), QCMakeCacheModel::HelpRole); - m->setData(m->index(0, 0), 0, QCMakeCacheModel::AdvancedRole); - if(w->type() == QCMakeCacheProperty::BOOL) - { - m->setData(m->index(0, 1), w->value().toBool() ? - Qt::Checked : Qt::Unchecked, Qt::CheckStateRole); - } - else - { - m->setData(m->index(0, 1), w->value(), Qt::DisplayRole); - } + m->insertProperty(w->type(), w->name(), w->description(), w->value(), false); } } @@ -885,3 +928,30 @@ void CMakeSetupDialog::setDebugOutput(bool flag) "setDebugOutput", Qt::QueuedConnection, Q_ARG(bool, flag)); } +void CMakeSetupDialog::setViewType(int v) +{ + if(v == 0) // simple view + { + this->CacheValues->cacheModel()->setViewType(QCMakeCacheModel::FlatView); + this->CacheValues->setRootIsDecorated(false); + this->CacheValues->setShowAdvanced(false); + } + else if(v == 1) // advanced view + { + this->CacheValues->cacheModel()->setViewType(QCMakeCacheModel::FlatView); + this->CacheValues->setRootIsDecorated(false); + this->CacheValues->setShowAdvanced(true); + } + else if(v == 2) // grouped view + { + this->CacheValues->cacheModel()->setViewType(QCMakeCacheModel::GroupView); + this->CacheValues->setRootIsDecorated(true); + this->CacheValues->setShowAdvanced(true); + } + + QSettings settings; + settings.beginGroup("Settings/StartPath"); + settings.setValue("GroupView", v == 2); + +} + diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index c35cf2e78..37ac628b0 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: CMakeSetupDialog.h,v $ Language: C++ - Date: $Date: 2008-04-21 00:44:54 $ - Version: $Revision: 1.21.2.2 $ + Date: $Date: 2008-07-13 21:55:25 $ + Version: $Revision: 1.21.2.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -44,7 +44,6 @@ protected slots: void initialize(); void doConfigure(); void doGenerate(); - void doSuppressDev(); void doInstallForCommandLine(); void doHelp(); void doAbout(); @@ -62,7 +61,7 @@ protected slots: void updateBinaryDirectory(const QString& dir); void showProgress(const QString& msg, float percent); void setEnabledState(bool); - bool promptForGenerator(); + bool setupFirstConfigure(); void updateGeneratorLabel(const QString& gen); void setExitAfterGenerate(bool); void addBinaryPath(const QString&); @@ -76,6 +75,7 @@ protected slots: void addCacheEntry(); void startSearch(); void setDebugOutput(bool); + void setViewType(int); protected: @@ -89,7 +89,6 @@ protected: QCMakeThread* CMakeThread; bool ExitAfterGenerate; bool CacheModified; - bool SuppressDevWarnings; QAction* ReloadCacheAction; QAction* DeleteCacheAction; QAction* ExitAction; diff --git a/Source/QtDialog/CMakeSetupDialog.ui b/Source/QtDialog/CMakeSetupDialog.ui index 12984b24e..8fab9d58b 100644 --- a/Source/QtDialog/CMakeSetupDialog.ui +++ b/Source/QtDialog/CMakeSetupDialog.ui @@ -127,10 +127,22 @@ - + + - Show Ad&vanced Entries + Simple View + + + + Advanced View + + + + + Grouped View + + @@ -295,7 +307,7 @@ QCMakeCacheView - QTableView + QTreeView
QCMakeCacheView.h
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index 3f1586e89..eebd7e256 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: QCMake.cxx,v $ Language: C++ - Date: $Date: 2008-04-08 16:22:51 $ - Version: $Revision: 1.21.2.1 $ + Date: $Date: 2008-05-23 20:09:43 $ + Version: $Revision: 1.21.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -29,8 +29,8 @@ QCMake::QCMake(QObject* p) : QObject(p) { this->SuppressDevWarnings = false; - qRegisterMetaType(); - qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); QDir execDir(QCoreApplication::applicationDirPath()); @@ -111,7 +111,7 @@ void QCMake::setBinaryDirectory(const QString& dir) } } - QCMakeCachePropertyList props = this->properties(); + QCMakePropertyList props = this->properties(); emit this->propertiesChanged(props); cmCacheManager::CacheIterator itm = cachem->NewIterator(); if ( itm.Find("CMAKE_HOME_DIRECTORY")) @@ -165,9 +165,9 @@ void QCMake::generate() emit this->generateDone(err); } -void QCMake::setProperties(const QCMakeCachePropertyList& newProps) +void QCMake::setProperties(const QCMakePropertyList& newProps) { - QCMakeCachePropertyList props = newProps; + QCMakePropertyList props = newProps; QStringList toremove; @@ -183,7 +183,7 @@ void QCMake::setProperties(const QCMakeCachePropertyList& newProps) continue; } - QCMakeCacheProperty prop; + QCMakeProperty prop; prop.Key = i.GetName(); int idx = props.indexOf(prop); if(idx == -1) @@ -213,30 +213,30 @@ void QCMake::setProperties(const QCMakeCachePropertyList& newProps) } // add some new properites - foreach(QCMakeCacheProperty s, props) + foreach(QCMakeProperty s, props) { - if(s.Type == QCMakeCacheProperty::BOOL) + if(s.Type == QCMakeProperty::BOOL) { this->CMakeInstance->AddCacheEntry(s.Key.toAscii().data(), s.Value.toBool() ? "ON" : "OFF", s.Help.toAscii().data(), cmCacheManager::BOOL); } - else if(s.Type == QCMakeCacheProperty::STRING) + else if(s.Type == QCMakeProperty::STRING) { this->CMakeInstance->AddCacheEntry(s.Key.toAscii().data(), s.Value.toString().toAscii().data(), s.Help.toAscii().data(), cmCacheManager::STRING); } - else if(s.Type == QCMakeCacheProperty::PATH) + else if(s.Type == QCMakeProperty::PATH) { this->CMakeInstance->AddCacheEntry(s.Key.toAscii().data(), s.Value.toString().toAscii().data(), s.Help.toAscii().data(), cmCacheManager::PATH); } - else if(s.Type == QCMakeCacheProperty::FILEPATH) + else if(s.Type == QCMakeProperty::FILEPATH) { this->CMakeInstance->AddCacheEntry(s.Key.toAscii().data(), s.Value.toString().toAscii().data(), @@ -248,9 +248,9 @@ void QCMake::setProperties(const QCMakeCachePropertyList& newProps) cachem->SaveCache(this->BinaryDirectory.toAscii().data()); } -QCMakeCachePropertyList QCMake::properties() const +QCMakePropertyList QCMake::properties() const { - QCMakeCachePropertyList ret; + QCMakePropertyList ret; cmCacheManager *cachem = this->CMakeInstance->GetCacheManager(); for(cmCacheManager::CacheIterator i = cachem->NewIterator(); @@ -264,7 +264,7 @@ QCMakeCachePropertyList QCMake::properties() const continue; } - QCMakeCacheProperty prop; + QCMakeProperty prop; prop.Key = i.GetName(); prop.Help = i.GetProperty("HELPSTRING"); prop.Value = i.GetValue(); @@ -272,20 +272,20 @@ QCMakeCachePropertyList QCMake::properties() const if(i.GetType() == cmCacheManager::BOOL) { - prop.Type = QCMakeCacheProperty::BOOL; + prop.Type = QCMakeProperty::BOOL; prop.Value = cmSystemTools::IsOn(i.GetValue()); } else if(i.GetType() == cmCacheManager::PATH) { - prop.Type = QCMakeCacheProperty::PATH; + prop.Type = QCMakeProperty::PATH; } else if(i.GetType() == cmCacheManager::FILEPATH) { - prop.Type = QCMakeCacheProperty::FILEPATH; + prop.Type = QCMakeProperty::FILEPATH; } else if(i.GetType() == cmCacheManager::STRING) { - prop.Type = QCMakeCacheProperty::STRING; + prop.Type = QCMakeProperty::STRING; } ret.append(prop); @@ -349,14 +349,14 @@ void QCMake::deleteCache() this->CMakeInstance->GetCacheManager()->LoadCache(this->BinaryDirectory.toAscii().data()); // emit no generator and no properties this->setGenerator(QString()); - QCMakeCachePropertyList props = this->properties(); + QCMakePropertyList props = this->properties(); emit this->propertiesChanged(props); } void QCMake::reloadCache() { // emit that the cache was cleaned out - QCMakeCachePropertyList props; + QCMakePropertyList props; emit this->propertiesChanged(props); // reload this->CMakeInstance->GetCacheManager()->LoadCache(this->BinaryDirectory.toAscii().data()); @@ -380,7 +380,7 @@ bool QCMake::getDebugOutput() const } -void QCMake::SetSuppressDevWarnings(bool value) +void QCMake::setSuppressDevWarnings(bool value) { this->SuppressDevWarnings = value; } diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h index dbe7c7aed..041b9338a 100644 --- a/Source/QtDialog/QCMake.h +++ b/Source/QtDialog/QCMake.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: QCMake.h,v $ Language: C++ - Date: $Date: 2008-04-08 16:22:51 $ - Version: $Revision: 1.9.2.1 $ + Date: $Date: 2008-05-23 20:09:43 $ + Version: $Revision: 1.9.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -31,9 +31,9 @@ class cmake; -/// struct to represent cache properties in Qt +/// struct to represent cmake properties in Qt /// Value is of type String or Bool -struct QCMakeCacheProperty +struct QCMakeProperty { enum PropertyType { BOOL, PATH, FILEPATH, STRING }; QString Key; @@ -41,20 +41,22 @@ struct QCMakeCacheProperty QString Help; PropertyType Type; bool Advanced; - bool operator==(const QCMakeCacheProperty& other) const + bool operator==(const QCMakeProperty& other) const { return this->Key == other.Key; } - bool operator<(const QCMakeCacheProperty& other) const + bool operator<(const QCMakeProperty& other) const { return this->Key < other.Key; } }; -// make types usable with QVariant -Q_DECLARE_METATYPE(QCMakeCacheProperty) -typedef QList QCMakeCachePropertyList; -Q_DECLARE_METATYPE(QCMakeCachePropertyList) +// list of properties +typedef QList QCMakePropertyList; + +// allow QVariant to be a property or list of properties +Q_DECLARE_METATYPE(QCMakeProperty) +Q_DECLARE_METATYPE(QCMakePropertyList) /// Qt API for CMake library. /// Wrapper like class allows for easier integration with @@ -65,7 +67,6 @@ class QCMake : public QObject public: QCMake(QObject* p=0); ~QCMake(); - void SetSuppressDevWarnings(bool value); public slots: /// load the cache file in a directory void loadCache(const QString& dir); @@ -80,7 +81,7 @@ public slots: /// generate the files void generate(); /// set the property values - void setProperties(const QCMakeCachePropertyList&); + void setProperties(const QCMakePropertyList&); /// interrupt the configure or generate process void interrupt(); /// delete the cache in binary directory @@ -89,10 +90,12 @@ public slots: void reloadCache(); /// set whether to do debug output void setDebugOutput(bool); + /// set whether to do suppress dev warnings + void setSuppressDevWarnings(bool value); public: /// get the list of cache properties - QCMakeCachePropertyList properties() const; + QCMakePropertyList properties() const; /// get the current binary directory QString binaryDirectory() const; /// get the current source directory @@ -106,7 +109,7 @@ public: signals: /// signal when properties change (during read from disk or configure process) - void propertiesChanged(const QCMakeCachePropertyList& vars); + void propertiesChanged(const QCMakePropertyList& vars); /// signal when the generator changes void generatorChanged(const QString& gen); /// signal when the source directory changes (binary directory already diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 20e9ba5ef..f1556ac2e 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: QCMakeCacheView.cxx,v $ Language: C++ - Date: $Date: 2008-04-08 16:22:51 $ - Version: $Revision: 1.26.2.1 $ + Date: $Date: 2008-07-13 21:55:25 $ + Version: $Revision: 1.26.2.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -17,18 +17,14 @@ #include "QCMakeCacheView.h" -#include -#include #include #include #include -#include #include #include -#include -#include +#include -static QRegExp AdvancedRegExp[2] = { QRegExp("(false)"), QRegExp("(true|false)") }; +#include "QCMakeWidgets.h" // filter for searches class QCMakeSearchFilter : public QSortFilterProxyModel @@ -38,26 +34,99 @@ public: protected: bool filterAcceptsRow(int row, const QModelIndex& p) const { - // accept row if either column matches - QModelIndex idx0 = this->sourceModel()->index(row, 0, p); - QModelIndex idx1 = this->sourceModel()->index(row, 1, p); - QString str0 = this->sourceModel()->data(idx0).toString(); - QString str1 = this->sourceModel()->data(idx1).toString(); - - return str0.contains(this->filterRegExp()) || - str1.contains(this->filterRegExp()); + QStringList strs; + const QAbstractItemModel* m = this->sourceModel(); + QModelIndex idx = m->index(row, 0, p); + + // if there are no children, get strings for column 0 and 1 + if(!m->hasChildren(idx)) + { + strs.append(m->data(idx).toString()); + idx = m->index(row, 1, p); + strs.append(m->data(idx).toString()); + } + else + { + // get strings for children entries to compare with + // instead of comparing with the parent + int num = m->rowCount(idx); + for(int i=0; iindex(i, 0, idx); + strs.append(m->data(tmpidx).toString()); + tmpidx = m->index(i, 1, idx); + strs.append(m->data(tmpidx).toString()); + } + } + + // check all strings for a match + foreach(QString str, strs) + { + if(str.contains(this->filterRegExp())) + { + return true; + } + } + + return false; + } +}; + +// filter for searches +class QCMakeAdvancedFilter : public QSortFilterProxyModel +{ +public: + QCMakeAdvancedFilter(QObject* o) + : QSortFilterProxyModel(o), ShowAdvanced(false) {} + + void setShowAdvanced(bool f) + { + this->ShowAdvanced = f; + this->invalidate(); + } + bool showAdvanced() const { return this->ShowAdvanced; } + +protected: + + bool ShowAdvanced; + + bool filterAcceptsRow(int row, const QModelIndex& p) const + { + const QAbstractItemModel* m = this->sourceModel(); + QModelIndex idx = m->index(row, 0, p); + + // if there are no children + if(!m->hasChildren(idx)) + { + bool adv = m->data(idx, QCMakeCacheModel::AdvancedRole).toBool(); + if(!adv || (adv && this->ShowAdvanced)) + { + return true; + } + return false; + } + + // check children + int num = m->rowCount(idx); + for(int i=0; ifilterAcceptsRow(i, idx); + if(accept) + { + return true; + } + } + return false; } }; QCMakeCacheView::QCMakeCacheView(QWidget* p) - : QTableView(p), Init(false) + : QTreeView(p) { // hook up our model and search/filter proxies this->CacheModel = new QCMakeCacheModel(this); - this->AdvancedFilter = new QSortFilterProxyModel(this); + this->AdvancedFilter = new QCMakeAdvancedFilter(this); this->AdvancedFilter->setSourceModel(this->CacheModel); - this->AdvancedFilter->setFilterRole(QCMakeCacheModel::AdvancedRole); - this->AdvancedFilter->setFilterRegExp(AdvancedRegExp[0]); this->AdvancedFilter->setDynamicSortFilter(true); this->SearchFilter = new QCMakeSearchFilter(this); this->SearchFilter->setSourceModel(this->AdvancedFilter); @@ -77,26 +146,16 @@ QCMakeCacheView::QCMakeCacheView(QWidget* p) // tab, backtab doesn't step through items this->setTabKeyNavigation(false); - // set up headers and sizes - int h = 0; - QFontMetrics met(this->font()); - h = qMax(met.height(), this->style()->pixelMetric(QStyle::PM_IndicatorHeight)); - this->verticalHeader()->setDefaultSectionSize(h + 4); - this->horizontalHeader()->setStretchLastSection(true); - this->verticalHeader()->hide(); + this->setRootIsDecorated(false); } -void QCMakeCacheView::showEvent(QShowEvent* e) +bool QCMakeCacheView::event(QEvent* e) { - if(!this->Init) + if(e->type() == QEvent::Show) { - // initialize the table view column size - int colWidth = this->columnWidth(0) + this->columnWidth(1); - this->setColumnWidth(0, colWidth/2); - this->setColumnWidth(1, colWidth/2); - this->Init = true; + this->header()->setDefaultSectionSize(this->viewport()->width()/2); } - return QTableView::showEvent(e); + return QTreeView::event(e); } QCMakeCacheModel* QCMakeCacheView::cacheModel() const @@ -116,18 +175,22 @@ QModelIndex QCMakeCacheView::moveCursor(CursorAction act, { return this->model()->index(this->model()->rowCount()-1, 1); } - return QTableView::moveCursor(act, mod); + return QTreeView::moveCursor(act, mod); } void QCMakeCacheView::setShowAdvanced(bool s) { - this->AdvancedFilter->setFilterRegExp( - s ? AdvancedRegExp[1] : AdvancedRegExp[0]); +#if QT_VERSION >= 040300 + // new 4.3 api that needs to be called. what about an older Qt? + this->SearchFilter->invalidate(); +#endif + + this->AdvancedFilter->setShowAdvanced(s); } bool QCMakeCacheView::showAdvanced() const { - return this->AdvancedFilter->filterRegExp() == AdvancedRegExp[1]; + return this->AdvancedFilter->showAdvanced(); } void QCMakeCacheView::setSearchFilter(const QString& s) @@ -136,239 +199,340 @@ void QCMakeCacheView::setSearchFilter(const QString& s) } QCMakeCacheModel::QCMakeCacheModel(QObject* p) - : QAbstractTableModel(p), - NewCount(0), EditEnabled(true) + : QStandardItemModel(p), + EditEnabled(true), + NewPropertyCount(0), + View(FlatView) { + QStringList labels; + labels << tr("Name") << tr("Value"); + this->setHorizontalHeaderLabels(labels); } QCMakeCacheModel::~QCMakeCacheModel() { } -static uint qHash(const QCMakeCacheProperty& p) +static uint qHash(const QCMakeProperty& p) { return qHash(p.Key); } void QCMakeCacheModel::clear() { - this->setProperties(QCMakeCachePropertyList()); + this->QStandardItemModel::clear(); + this->NewPropertyCount = 0; + + QStringList labels; + labels << tr("Name") << tr("Value"); + this->setHorizontalHeaderLabels(labels); } -void QCMakeCacheModel::setProperties(const QCMakeCachePropertyList& props) +void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) { - QSet newProps = props.toSet(); - QSet newProps2 = props.toSet(); - QSet oldProps = this->Properties.toSet(); + QSet newProps = props.toSet(); + QSet newProps2 = newProps; + QSet oldProps = this->properties().toSet(); oldProps.intersect(newProps); newProps.subtract(oldProps); newProps2.subtract(newProps); - this->NewCount = newProps.count(); - this->Properties.clear(); + bool b = this->blockSignals(true); + + this->clear(); + this->NewPropertyCount = newProps.size(); - this->Properties = newProps.toList(); - qSort(this->Properties); - QCMakeCachePropertyList tmp = newProps2.toList(); - qSort(tmp); - this->Properties += tmp; + if(View == FlatView) + { + QCMakePropertyList newP = newProps.toList(); + QCMakePropertyList newP2 = newProps2.toList(); + qSort(newP); + qSort(newP2); + int rowCount = 0; + foreach(QCMakeProperty p, newP) + { + this->insertRow(rowCount); + this->setPropertyData(this->index(rowCount, 0), p, true); + rowCount++; + } + foreach(QCMakeProperty p, newP2) + { + this->insertRow(rowCount); + this->setPropertyData(this->index(rowCount, 0), p, false); + rowCount++; + } + } + else if(this->View == GroupView) + { + QMap newPropsTree; + this->breakProperties(newProps, newPropsTree); + QMap newPropsTree2; + this->breakProperties(newProps2, newPropsTree2); + + QStandardItem* root = this->invisibleRootItem(); + + foreach(QString key, newPropsTree.keys()) + { + QCMakePropertyList props = newPropsTree[key]; + + QList parentItems; + parentItems.append( + new QStandardItem(key.isEmpty() ? tr("Ungrouped Entries") : key) + ); + parentItems.append(new QStandardItem()); + parentItems[0]->setData(QBrush(QColor(255,100,100)), Qt::BackgroundColorRole); + parentItems[1]->setData(QBrush(QColor(255,100,100)), Qt::BackgroundColorRole); + root->appendRow(parentItems); + + foreach(QCMakeProperty prop, props) + { + QList items; + items.append(new QStandardItem()); + items.append(new QStandardItem()); + parentItems[0]->appendRow(items); + this->setPropertyData(this->indexFromItem(items[0]), prop, true); + } + } + + foreach(QString key, newPropsTree2.keys()) + { + QCMakePropertyList props = newPropsTree2[key]; + + QStandardItem* parentItem = + new QStandardItem(key.isEmpty() ? tr("Ungrouped Entries") : key); + root->appendRow(parentItem); + + foreach(QCMakeProperty prop, props) + { + QList items; + items.append(new QStandardItem()); + items.append(new QStandardItem()); + parentItem->appendRow(items); + this->setPropertyData(this->indexFromItem(items[0]), prop, false); + } + } + } + this->blockSignals(b); this->reset(); } - -QCMakeCachePropertyList QCMakeCacheModel::properties() const -{ - return this->Properties; -} -void QCMakeCacheModel::setEditEnabled(bool e) +QCMakeCacheModel::ViewType QCMakeCacheModel::viewType() const { - this->EditEnabled = e; + return this->View; } -bool QCMakeCacheModel::editEnabled() const +void QCMakeCacheModel::setViewType(QCMakeCacheModel::ViewType t) { - return this->EditEnabled; + this->View = t; + + QCMakePropertyList props = this->properties(); + QCMakePropertyList oldProps; + int numNew = this->NewPropertyCount; + int numTotal = props.count(); + for(int i=numNew; iblockSignals(true); + this->clear(); + this->setProperties(oldProps); + this->setProperties(props); + this->blockSignals(b); + this->reset(); } -int QCMakeCacheModel::newCount() const +void QCMakeCacheModel::setPropertyData(const QModelIndex& idx1, + const QCMakeProperty& prop, bool isNew) { - return this->NewCount; + QModelIndex idx2 = idx1.sibling(idx1.row(), 1); + + this->setData(idx1, prop.Key, Qt::DisplayRole); + this->setData(idx1, prop.Help, QCMakeCacheModel::HelpRole); + this->setData(idx1, prop.Type, QCMakeCacheModel::TypeRole); + this->setData(idx1, prop.Advanced, QCMakeCacheModel::AdvancedRole); + + if(prop.Type == QCMakeProperty::BOOL) + { + int check = prop.Value.toBool() ? Qt::Checked : Qt::Unchecked; + this->setData(idx2, check, Qt::CheckStateRole); + } + else + { + this->setData(idx2, prop.Value, Qt::DisplayRole); + } + this->setData(idx2, prop.Help, QCMakeCacheModel::HelpRole); + + if(isNew) + { + this->setData(idx1, QBrush(QColor(255,100,100)), Qt::BackgroundColorRole); + this->setData(idx2, QBrush(QColor(255,100,100)), Qt::BackgroundColorRole); + } } -int QCMakeCacheModel::columnCount (const QModelIndex& /*p*/ ) const +void QCMakeCacheModel::getPropertyData(const QModelIndex& idx1, + QCMakeProperty& prop) const { - return 2; + QModelIndex idx2 = idx1.sibling(idx1.row(), 1); + + prop.Key = this->data(idx1, Qt::DisplayRole).toString(); + prop.Help = this->data(idx1, HelpRole).toString(); + prop.Type = static_cast(this->data(idx1, TypeRole).toInt()); + prop.Advanced = this->data(idx1, AdvancedRole).toBool(); + if(prop.Type == QCMakeProperty::BOOL) + { + int check = this->data(idx2, Qt::CheckStateRole).toInt(); + prop.Value = check == Qt::Checked; + } + else + { + prop.Value = this->data(idx2, Qt::DisplayRole).toString(); + } } -QVariant QCMakeCacheModel::data (const QModelIndex& idx, int role) const +QString QCMakeCacheModel::prefix(const QString& s) { - if(idx.column() == 0 && (role == Qt::DisplayRole || role == Qt::EditRole)) + QString prefix = s.section('_', 0, 0); + if(prefix == s) { - return this->Properties[idx.row()].Key; + prefix = QString(); } - else if(idx.column() == 0 && role == Qt::ToolTipRole) + return prefix; +} + +void QCMakeCacheModel::breakProperties(const QSet& props, + QMap& result) +{ + QMap tmp; + // return a map of properties grouped by prefixes, and sorted + foreach(QCMakeProperty p, props) { - return this->data(idx, Qt::DisplayRole).toString() + "\n" + - this->data(idx, QCMakeCacheModel::HelpRole).toString(); + QString prefix = QCMakeCacheModel::prefix(p.Key); + tmp[prefix].append(p); } - else if(idx.column() == 1 && (role == Qt::DisplayRole || role == Qt::EditRole)) + // sort it and re-org any properties with only one sub item + QCMakePropertyList reorgProps; + QMap::iterator iter; + for(iter = tmp.begin(); iter != tmp.end();) { - if(this->Properties[idx.row()].Type != QCMakeCacheProperty::BOOL) + if(iter->count() == 1) { - return this->Properties[idx.row()].Value; + reorgProps.append((*iter)[0]); + iter = tmp.erase(iter); } - } - else if(idx.column() == 1 && role == Qt::CheckStateRole) - { - if(this->Properties[idx.row()].Type == QCMakeCacheProperty::BOOL) + else { - return this->Properties[idx.row()].Value.toBool() ? Qt::Checked : Qt::Unchecked; + qSort(*iter); + ++iter; } } - else if(role == QCMakeCacheModel::HelpRole) - { - return this->Properties[idx.row()].Help; - } - else if(role == QCMakeCacheModel::TypeRole) - { - return this->Properties[idx.row()].Type; - } - else if(role == QCMakeCacheModel::AdvancedRole) - { - return this->Properties[idx.row()].Advanced; - } - else if(role == Qt::BackgroundRole && idx.row()+1 <= this->NewCount) + if(reorgProps.count()) { - return QBrush(QColor(255,100,100)); + tmp[QString()] += reorgProps; } - return QVariant(); + result = tmp; } - -QModelIndex QCMakeCacheModel::parent (const QModelIndex& /*idx*/) const + +QCMakePropertyList QCMakeCacheModel::properties() const { - return QModelIndex(); -} + QCMakePropertyList props; -int QCMakeCacheModel::rowCount (const QModelIndex& p) const -{ - if(p.isValid()) + if(!this->rowCount()) { - return 0; + return props; } - return this->Properties.count(); -} -QVariant QCMakeCacheModel::headerData (int section, Qt::Orientation orient, int role) const -{ - // return header labels - if(role == Qt::DisplayRole && orient == Qt::Horizontal) + QList idxs; + idxs.append(this->index(0,0)); + + // walk the entire model for property entries + // this works regardless of a flat view or a tree view + while(!idxs.isEmpty()) + { + QModelIndex idx = idxs.last(); + if(this->hasChildren(idx) && this->rowCount(idx)) { - return section == 0 ? "Name" : "Value"; + idxs.append(this->index(0,0, idx)); } - return QVariant(); -} - -Qt::ItemFlags QCMakeCacheModel::flags (const QModelIndex& idx) const -{ - Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable; - // all column 1's are editable - if(idx.column() == 1 && this->EditEnabled) + else { - f |= Qt::ItemIsEditable; - // booleans are editable in place - if(this->Properties[idx.row()].Type == QCMakeCacheProperty::BOOL) + // 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()) + { + idxs.removeLast(); + } + if(!idxs.isEmpty()) { - f |= Qt::ItemIsUserCheckable; + idxs.last() = idxs.last().sibling(idxs.last().row()+1, 0); } } - return f; + } + + return props; +} + +bool QCMakeCacheModel::insertProperty(QCMakeProperty::PropertyType t, + const QString& name, const QString& description, + const QVariant& value, bool advanced) +{ + QCMakeProperty prop; + prop.Key = name; + prop.Value = value; + prop.Help = description; + prop.Type = t; + prop.Advanced = advanced; + + //insert at beginning + this->insertRow(0); + this->setPropertyData(this->index(0,0), prop, true); + this->NewPropertyCount++; + return true; } +void QCMakeCacheModel::setEditEnabled(bool e) +{ + this->EditEnabled = e; +} -bool QCMakeCacheModel::setData (const QModelIndex& idx, const QVariant& value, int role) +bool QCMakeCacheModel::editEnabled() const { - if(idx.column() == 0 && (role == Qt::DisplayRole || role == Qt::EditRole)) - { - this->Properties[idx.row()].Key = value.toString(); - emit this->dataChanged(idx, idx); - } - else if(idx.column() == 1 && (role == Qt::DisplayRole || role == Qt::EditRole)) - { - this->Properties[idx.row()].Value = value.toString(); - emit this->dataChanged(idx, idx); - } - else if(idx.column() == 1 && (role == Qt::CheckStateRole)) - { - this->Properties[idx.row()].Value = value.toInt() == Qt::Checked; - emit this->dataChanged(idx, idx); - } - else if(role == QCMakeCacheModel::HelpRole) - { - this->Properties[idx.row()].Help = value.toString(); - emit this->dataChanged(idx, idx); - } - else if(role == QCMakeCacheModel::TypeRole) - { - this->Properties[idx.row()].Type = static_cast(value.toInt()); - } - else if(role == QCMakeCacheModel::AdvancedRole) - { - this->Properties[idx.row()].Advanced = value.toBool(); - } - return false; + return this->EditEnabled; } -QModelIndex QCMakeCacheModel::buddy(const QModelIndex& idx) const +int QCMakeCacheModel::newPropertyCount() const { - if(idx.column() == 0) - { - if(this->Properties[idx.row()].Type != QCMakeCacheProperty::BOOL) - { - return this->index(idx.row(), 1); - } - } - return idx; + return this->NewPropertyCount; } - -bool QCMakeCacheModel::removeRows(int row, int num, const QModelIndex&) + +Qt::ItemFlags QCMakeCacheModel::flags (const QModelIndex& idx) const { - if(row < 0 || row+num > this->Properties.count()) + Qt::ItemFlags f = QStandardItemModel::flags(idx); + if(!this->EditEnabled) { - return false; + f &= ~Qt::ItemIsEditable; } - this->beginRemoveRows(QModelIndex(), row, row+num-1); - for(int i=0; idata(idx, TypeRole).toInt()) { - this->Properties.removeAt(row); - if(this->NewCount >= row+1) - { - this->NewCount--; - } + f |= Qt::ItemIsUserCheckable; } - this->endRemoveRows(); - return true; + return f; } -bool QCMakeCacheModel::insertRows(int row, int num, const QModelIndex&) +QModelIndex QCMakeCacheModel::buddy(const QModelIndex& idx) const { - if(row < 0) - row = 0; - if(row > this->rowCount()) - row = this->rowCount(); - - this->beginInsertRows(QModelIndex(), row, row+num-1); - for(int i=0; iProperties.insert(row+i, QCMakeCacheProperty()); - if(this->NewCount >= row) - { - this->NewCount++; - } - } - this->endInsertRows(); - return true; + if(!this->hasChildren(idx) && + this->data(idx, TypeRole).toInt() != QCMakeProperty::BOOL) + { + return this->index(idx.row(), 1, idx.parent()); + } + return idx; } QCMakeCacheModelDelegate::QCMakeCacheModelDelegate(QObject* p) @@ -384,26 +548,25 @@ void QCMakeCacheModelDelegate::setFileDialogFlag(bool f) QWidget* QCMakeCacheModelDelegate::createEditor(QWidget* p, const QStyleOptionViewItem&, const QModelIndex& idx) const { - const QAbstractItemModel* model = idx.model(); - QModelIndex var = model->index(idx.row(), 0); - QVariant type = idx.data(QCMakeCacheModel::TypeRole); - if(type == QCMakeCacheProperty::BOOL) + QModelIndex var = idx.sibling(idx.row(), 0); + int type = var.data(QCMakeCacheModel::TypeRole).toInt(); + if(type == QCMakeProperty::BOOL) { return NULL; } - else if(type == QCMakeCacheProperty::PATH) + else if(type == QCMakeProperty::PATH) { - QCMakeCachePathEditor* editor = - new QCMakeCachePathEditor(p, + QCMakePathEditor* editor = + new QCMakePathEditor(p, var.data(Qt::DisplayRole).toString()); QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this, SLOT(setFileDialogFlag(bool))); return editor; } - else if(type == QCMakeCacheProperty::FILEPATH) + else if(type == QCMakeProperty::FILEPATH) { - QCMakeCacheFilePathEditor* editor = - new QCMakeCacheFilePathEditor(p, + QCMakeFilePathEditor* editor = + new QCMakeFilePathEditor(p, var.data(Qt::DisplayRole).toString()); QObject::connect(editor, SIGNAL(fileDialogExists(bool)), this, SLOT(setFileDialogFlag(bool))); @@ -459,109 +622,13 @@ bool QCMakeCacheModelDelegate::editorEvent(QEvent* e, QAbstractItemModel* model, bool QCMakeCacheModelDelegate::eventFilter(QObject* object, QEvent* event) { // workaround for what looks like a bug in Qt on Mac OS X + // where it doesn't create a QWidget wrapper for the native file dialog + // so the Qt library ends up assuming the focus was lost to something else if(event->type() == QEvent::FocusOut && this->FileDialogFlag) - { + { return false; - } + } return QItemDelegate::eventFilter(object, event); } -QCMakeCacheFileEditor::QCMakeCacheFileEditor(QWidget* p, const QString& var) - : QLineEdit(p), Variable(var) -{ - // this *is* instead of has a line edit so QAbstractItemView - // doesn't get confused with what the editor really is - this->setContentsMargins(0, 0, 0, 0); - this->ToolButton = new QToolButton(this); - this->ToolButton->setText("..."); - this->ToolButton->setCursor(QCursor(Qt::ArrowCursor)); - QObject::connect(this->ToolButton, SIGNAL(clicked(bool)), - this, SLOT(chooseFile())); -} - -QCMakeCacheFilePathEditor::QCMakeCacheFilePathEditor(QWidget* p, const QString& var) - : QCMakeCacheFileEditor(p, var) -{ - this->setCompleter(new QCMakeFileCompleter(this, false)); -} - -QCMakeCachePathEditor::QCMakeCachePathEditor(QWidget* p, const QString& var) - : QCMakeCacheFileEditor(p, var) -{ -this->setCompleter(new QCMakeFileCompleter(this, true)); -} - -void QCMakeCacheFileEditor::resizeEvent(QResizeEvent* e) -{ - // make the tool button fit on the right side - int h = e->size().height(); - this->ToolButton->resize(h, h); - this->ToolButton->move(this->width() - h, 0); - this->setContentsMargins(0, 0, h, 0); -} - -void QCMakeCacheFilePathEditor::chooseFile() -{ - // choose a file and set it - QString path; - QFileInfo info(this->text()); - QString title; - if(this->Variable.isEmpty()) - { - title = tr("Select File"); - } - else - { - title = tr("Select File for %1"); - title = title.arg(this->Variable); - } - this->fileDialogExists(true); - path = QFileDialog::getOpenFileName(this, title, info.absolutePath()); - this->fileDialogExists(false); - - if(!path.isEmpty()) - { - this->setText(QDir::fromNativeSeparators(path)); - } -} - -void QCMakeCachePathEditor::chooseFile() -{ - // choose a file and set it - QString path; - QString title; - if(this->Variable.isEmpty()) - { - title = tr("Select Path"); - } - else - { - title = tr("Select Path for %1"); - title = title.arg(this->Variable); - } - this->fileDialogExists(true); - path = QFileDialog::getExistingDirectory(this, title, this->text()); - this->fileDialogExists(false); - if(!path.isEmpty()) - { - this->setText(QDir::fromNativeSeparators(path)); - } -} - -QCMakeFileCompleter::QCMakeFileCompleter(QObject* o, bool dirs) - : QCompleter(o) -{ - QDirModel* model = new QDirModel(this); - if(dirs) - { - model->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot); - } - this->setModel(model); -} - -QString QCMakeFileCompleter::pathFromIndex(const QModelIndex& idx) const -{ - return QDir::fromNativeSeparators(QCompleter::pathFromIndex(idx)); -} - diff --git a/Source/QtDialog/QCMakeCacheView.h b/Source/QtDialog/QCMakeCacheView.h index bff6a5104..a122c76cc 100644 --- a/Source/QtDialog/QCMakeCacheView.h +++ b/Source/QtDialog/QCMakeCacheView.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: QCMakeCacheView.h,v $ Language: C++ - Date: $Date: 2008-04-08 16:22:51 $ - Version: $Revision: 1.17.2.1 $ + Date: $Date: 2008-06-25 13:51:50 $ + Version: $Revision: 1.17.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -19,81 +19,118 @@ #define QCMakeCacheView_h #include "QCMake.h" -#include -#include -#include -#include +#include +#include #include -#include -#include +class QSortFilterProxyModel; class QCMakeCacheModel; -class QToolButton; - +class QCMakeAdvancedFilter; /// Qt view class for cache properties -class QCMakeCacheView : public QTableView +class QCMakeCacheView : public QTreeView { Q_OBJECT public: QCMakeCacheView(QWidget* p); + // retrieve the QCMakeCacheModel storing all the pointers + // this isn't necessarily the model one would get from model() QCMakeCacheModel* cacheModel() const; + + // get whether to show advanced entries bool showAdvanced() const; + QSize sizeHint(int) { return QSize(200,200); } + public slots: + // set whether to show advanced entries void setShowAdvanced(bool); + // set the search filter string. any property key or value not matching will + // be filtered out void setSearchFilter(const QString&); protected: QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers); - void showEvent(QShowEvent* e); - bool Init; + bool event(QEvent* e); QCMakeCacheModel* CacheModel; - QSortFilterProxyModel* AdvancedFilter; + QCMakeAdvancedFilter* AdvancedFilter; QSortFilterProxyModel* SearchFilter; }; /// Qt model class for cache properties -class QCMakeCacheModel : public QAbstractTableModel +class QCMakeCacheModel : public QStandardItemModel { Q_OBJECT public: QCMakeCacheModel(QObject* parent); ~QCMakeCacheModel(); - enum { HelpRole = Qt::UserRole, TypeRole, AdvancedRole }; + // roles used to retrieve extra data such has help strings, types of + // properties, and the advanced flag + enum { HelpRole = Qt::ToolTipRole, + TypeRole = Qt::UserRole, + AdvancedRole }; + + enum ViewType { FlatView, GroupView }; public slots: - void setProperties(const QCMakeCachePropertyList& props); + // set a list of properties. This list will be sorted and grouped according + // to prefix. Any property that existed already and which is found in this + // list of properties to set will become an old property. All others will + // become new properties and be marked red. + void setProperties(const QCMakePropertyList& props); + + // clear everything from the model void clear(); + + // set flag whether the model can currently be edited. void setEditEnabled(bool); - bool removeRows(int row, int count, const QModelIndex& idx = QModelIndex()); - bool insertRows(int row, int num, const QModelIndex&); -public: - // satisfy [pure] virtuals - int columnCount (const QModelIndex& parent) const; - QVariant data (const QModelIndex& index, int role = Qt::DisplayRole) const; - QModelIndex parent (const QModelIndex& index) const; - int rowCount (const QModelIndex& parent = QModelIndex()) const; - QVariant headerData (int section, Qt::Orientation orient, int role) const; - Qt::ItemFlags flags (const QModelIndex& index) const; - bool setData (const QModelIndex& index, const QVariant& value, int role); - QModelIndex buddy (const QModelIndex& index) const; + // insert a new property at a row specifying all the information about the + // property + bool insertProperty(QCMakeProperty::PropertyType t, + const QString& name, const QString& description, + const QVariant& value, bool advanced); + + // set the view type + void setViewType(ViewType t); + ViewType viewType() const; +public: // get the properties - QCMakeCachePropertyList properties() const; + QCMakePropertyList properties() const; // editing enabled bool editEnabled() const; - int newCount() const; + // returns how many new properties there are + int newPropertyCount() const; + + // return flags (overloaded to modify flag based on EditEnabled flag) + Qt::ItemFlags flags (const QModelIndex& index) const; + QModelIndex buddy(const QModelIndex& idx) const; protected: - QCMakeCachePropertyList Properties; - int NewCount; bool EditEnabled; + int NewPropertyCount; + ViewType View; + + // set the data in the model for this property + void setPropertyData(const QModelIndex& idx1, + const QCMakeProperty& p, bool isNew); + // get the data in the model for this property + void getPropertyData(const QModelIndex& idx1, + QCMakeProperty& prop) const; + + // breaks up he property list into groups + // where each group has the same prefix up to the first underscore + static void breakProperties(const QSet& props, + QMap& result); + + // gets the prefix of a string up to the first _ + static QString prefix(const QString& s); + }; /// Qt delegate class for interaction (or other customization) @@ -115,45 +152,5 @@ protected: bool FileDialogFlag; }; -/// Editor widget for editing paths or file paths -class QCMakeCacheFileEditor : public QLineEdit -{ - Q_OBJECT -public: - QCMakeCacheFileEditor(QWidget* p, const QString& var); -protected slots: - virtual void chooseFile() = 0; -signals: - void fileDialogExists(bool); -protected: - void resizeEvent(QResizeEvent* e); - QToolButton* ToolButton; - QString Variable; -}; - -class QCMakeCachePathEditor : public QCMakeCacheFileEditor -{ - Q_OBJECT -public: - QCMakeCachePathEditor(QWidget* p = NULL, const QString& var = QString()); - void chooseFile(); -}; - -class QCMakeCacheFilePathEditor : public QCMakeCacheFileEditor -{ - Q_OBJECT -public: - QCMakeCacheFilePathEditor(QWidget* p = NULL, const QString& var = QString()); - void chooseFile(); -}; - -/// completer class that returns native cmake paths -class QCMakeFileCompleter : public QCompleter -{ -public: - QCMakeFileCompleter(QObject* o, bool dirs); - virtual QString pathFromIndex(const QModelIndex& idx) const; -}; - #endif diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx new file mode 100644 index 000000000..afd00e638 --- /dev/null +++ b/Source/QtDialog/QCMakeWidgets.cxx @@ -0,0 +1,122 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: QCMakeWidgets.cxx,v $ + Language: C++ + Date: $Date: 2008-05-23 20:09:44 $ + Version: $Revision: 1.1.2.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#include "QCMakeWidgets.h" + +#include +#include +#include +#include +#include + +QCMakeFileEditor::QCMakeFileEditor(QWidget* p, const QString& var) + : QLineEdit(p), Variable(var) +{ + this->ToolButton = new QToolButton(this); + this->ToolButton->setText("..."); + this->ToolButton->setCursor(QCursor(Qt::ArrowCursor)); + QObject::connect(this->ToolButton, SIGNAL(clicked(bool)), + this, SLOT(chooseFile())); +} + +QCMakeFilePathEditor::QCMakeFilePathEditor(QWidget* p, const QString& var) + : QCMakeFileEditor(p, var) +{ + this->setCompleter(new QCMakeFileCompleter(this, false)); +} + +QCMakePathEditor::QCMakePathEditor(QWidget* p, const QString& var) + : QCMakeFileEditor(p, var) +{ + this->setCompleter(new QCMakeFileCompleter(this, true)); +} + +void QCMakeFileEditor::resizeEvent(QResizeEvent* e) +{ + // make the tool button fit on the right side + int h = e->size().height(); + // move the line edit to make room for the tool button + this->setContentsMargins(0, 0, h, 0); + // put the tool button in its place + this->ToolButton->resize(h, h); + this->ToolButton->move(this->width() - h, 0); +} + +void QCMakeFilePathEditor::chooseFile() +{ + // choose a file and set it + QString path; + QFileInfo info(this->text()); + QString title; + if(this->Variable.isEmpty()) + { + title = tr("Select File"); + } + else + { + title = tr("Select File for %1"); + title = title.arg(this->Variable); + } + this->fileDialogExists(true); + path = QFileDialog::getOpenFileName(this, title, info.absolutePath()); + this->fileDialogExists(false); + + if(!path.isEmpty()) + { + this->setText(QDir::fromNativeSeparators(path)); + } +} + +void QCMakePathEditor::chooseFile() +{ + // choose a file and set it + QString path; + QString title; + if(this->Variable.isEmpty()) + { + title = tr("Select Path"); + } + else + { + title = tr("Select Path for %1"); + title = title.arg(this->Variable); + } + this->fileDialogExists(true); + path = QFileDialog::getExistingDirectory(this, title, this->text()); + this->fileDialogExists(false); + if(!path.isEmpty()) + { + this->setText(QDir::fromNativeSeparators(path)); + } +} + +QCMakeFileCompleter::QCMakeFileCompleter(QObject* o, bool dirs) + : QCompleter(o) +{ + QDirModel* model = new QDirModel(this); + if(dirs) + { + model->setFilter(QDir::AllDirs | QDir::Drives | QDir::NoDotAndDotDot); + } + this->setModel(model); +} + +QString QCMakeFileCompleter::pathFromIndex(const QModelIndex& idx) const +{ + return QDir::fromNativeSeparators(QCompleter::pathFromIndex(idx)); +} + diff --git a/Source/QtDialog/QCMakeWidgets.h b/Source/QtDialog/QCMakeWidgets.h new file mode 100644 index 000000000..d7cf280f1 --- /dev/null +++ b/Source/QtDialog/QCMakeWidgets.h @@ -0,0 +1,71 @@ +/*========================================================================= + + Program: CMake - Cross-Platform Makefile Generator + Module: $RCSfile: QCMakeWidgets.h,v $ + Language: C++ + Date: $Date: 2008-05-23 20:09:44 $ + Version: $Revision: 1.1.2.2 $ + + Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. + See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + +#ifndef QCMakeWidgets_h +#define QCMakeWidgets_h + +#include +#include +class QToolButton; + +// common widgets for Qt based CMake + +/// Editor widget for editing paths or file paths +class QCMakeFileEditor : public QLineEdit +{ + Q_OBJECT +public: + QCMakeFileEditor(QWidget* p, const QString& var); +protected slots: + virtual void chooseFile() = 0; +signals: + void fileDialogExists(bool); +protected: + void resizeEvent(QResizeEvent* e); + QToolButton* ToolButton; + QString Variable; +}; + +/// editor widget for editing files +class QCMakePathEditor : public QCMakeFileEditor +{ + Q_OBJECT +public: + QCMakePathEditor(QWidget* p = NULL, const QString& var = QString()); + void chooseFile(); +}; + +/// editor widget for editing paths +class QCMakeFilePathEditor : public QCMakeFileEditor +{ + Q_OBJECT +public: + QCMakeFilePathEditor(QWidget* p = NULL, const QString& var = QString()); + void chooseFile(); +}; + +/// completer class that returns native cmake paths +class QCMakeFileCompleter : public QCompleter +{ + Q_OBJECT +public: + QCMakeFileCompleter(QObject* o, bool dirs); + virtual QString pathFromIndex(const QModelIndex& idx) const; +}; + +#endif + diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 04366bd41..7e4e38a90 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddCustomCommandCommand.cxx,v $ Language: C++ - Date: $Date: 2008-01-30 16:22:10 $ - Version: $Revision: 1.37 $ + Date: $Date: 2008-06-13 12:55:16 $ + Version: $Revision: 1.37.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h index f6cbaa7a3..27bb0091d 100644 --- a/Source/cmAddCustomCommandCommand.h +++ b/Source/cmAddCustomCommandCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddCustomCommandCommand.h,v $ Language: C++ - Date: $Date: 2008-01-30 16:22:10 $ - Version: $Revision: 1.33 $ + Date: $Date: 2008-06-13 12:55:17 $ + Version: $Revision: 1.33.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index e9ddcd61b..94960d2da 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddLibraryCommand.cxx,v $ Language: C++ - Date: $Date: 2008-02-11 22:33:46 $ - Version: $Revision: 1.36 $ + Date: $Date: 2008-09-03 13:43:16 $ + Version: $Revision: 1.36.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -68,6 +68,12 @@ bool cmAddLibraryCommand type = cmTarget::MODULE_LIBRARY; haveSpecifiedType = true; } + else if(libType == "UNKNOWN") + { + ++s; + type = cmTarget::UNKNOWN_LIBRARY; + haveSpecifiedType = true; + } else if(*s == "EXCLUDE_FROM_ALL") { ++s; @@ -127,6 +133,16 @@ bool cmAddLibraryCommand return true; } + // A non-imported target may not have UNKNOWN type. + if(type == cmTarget::UNKNOWN_LIBRARY) + { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + "The UNKNOWN library type may be used only for IMPORTED libraries." + ); + return true; + } + // Enforce name uniqueness. { std::string msg; diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h index e0c98de57..189947795 100644 --- a/Source/cmAddLibraryCommand.h +++ b/Source/cmAddLibraryCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddLibraryCommand.h,v $ Language: C++ - Date: $Date: 2008-02-11 18:35:39 $ - Version: $Revision: 1.22 $ + Date: $Date: 2008-09-03 13:43:16 $ + Version: $Revision: 1.22.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -100,7 +100,7 @@ public: "\n" "The add_library command can also create IMPORTED library " "targets using this signature:\n" - " add_library( IMPORTED)\n" + " add_library( IMPORTED)\n" "An IMPORTED library target references a library file located " "outside the project. " "No rules are generated to build it. " diff --git a/Source/cmAddSubDirectoryCommand.h b/Source/cmAddSubDirectoryCommand.h index ffd976ad5..8733c975f 100644 --- a/Source/cmAddSubDirectoryCommand.h +++ b/Source/cmAddSubDirectoryCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmAddSubDirectoryCommand.h,v $ Language: C++ - Date: $Date: 2008-01-23 15:27:59 $ - Version: $Revision: 1.7 $ + Date: $Date: 2008-09-03 13:43:16 $ + Version: $Revision: 1.7.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -79,13 +79,21 @@ public: "be processed immediately by CMake before processing in the current " "input file continues beyond this command.\n" - "If the EXCLUDE_FROM_ALL argument is provided then this subdirectory " - "will not be included in build by default. Users will have to " - "explicitly start a build in the generated output directory. " - "This is useful for having cmake create a build system for a " - "set of examples in a project. One would want cmake to generate " - "a single build system for all the examples, but one may not want " - "the targets to show up in the main build system."; + "If the EXCLUDE_FROM_ALL argument is provided then targets in the " + "subdirectory will not be included in the ALL target of the parent " + "directory by default, and will be excluded from IDE project files. " + "Users must explicitly build targets in the subdirectory. " + "This is meant for use when the subdirectory contains a separate part " + "of the project that is useful but not necessary, such as a set of " + "examples. " + "Typically the subdirectory should contain its own project() command " + "invocation so that a full build system will be generated in the " + "subdirectory (such as a VS IDE solution file). " + "Note that inter-target dependencies supercede this exclusion. " + "If a target built by the parent project depends on a target in the " + "subdirectory, the dependee target will be included in the parent " + "project build system to satisfy the dependency." + ; } cmTypeMacro(cmAddSubDirectoryCommand, cmCommand); diff --git a/Source/cmBootstrapCommands.cxx b/Source/cmBootstrapCommands.cxx index 8a636509c..56ab238eb 100644 --- a/Source/cmBootstrapCommands.cxx +++ b/Source/cmBootstrapCommands.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmBootstrapCommands.cxx,v $ Language: C++ - Date: $Date: 2008-03-01 20:20:35 $ - Version: $Revision: 1.27 $ + Date: $Date: 2008-07-13 21:55:23 $ + Version: $Revision: 1.27.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -86,6 +86,7 @@ #include "cmSetSourceFilesPropertiesCommand.cxx" #include "cmSetTargetPropertiesCommand.cxx" #include "cmSetTestsPropertiesCommand.cxx" +#include "cmGetTestPropertyCommand.cxx" #include "cmSiteNameCommand.cxx" #include "cmStringCommand.cxx" #include "cmSubdirCommand.cxx" @@ -154,6 +155,7 @@ void GetBootstrapCommands(std::list& commands) commands.push_back(new cmSetPropertyCommand); commands.push_back(new cmSetSourceFilesPropertiesCommand); commands.push_back(new cmSetTargetPropertiesCommand); + commands.push_back(new cmGetTestPropertyCommand); commands.push_back(new cmSetTestsPropertiesCommand); commands.push_back(new cmSiteNameCommand); commands.push_back(new cmStringCommand); diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx index 6504f5198..37f1c1d5e 100755 --- a/Source/cmCMakePolicyCommand.cxx +++ b/Source/cmCMakePolicyCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCMakePolicyCommand.cxx,v $ Language: C++ - Date: $Date: 2008-03-24 22:23:26 $ - Version: $Revision: 1.2.2.1 $ + Date: $Date: 2008-09-03 13:43:16 $ + Version: $Revision: 1.2.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -32,6 +32,10 @@ bool cmCMakePolicyCommand { return this->HandleSetMode(args); } + else if(args[0] == "GET") + { + return this->HandleGetMode(args); + } else if(args[0] == "PUSH") { if(args.size() > 1) @@ -103,6 +107,63 @@ bool cmCMakePolicyCommand::HandleSetMode(std::vector const& args) return true; } +//---------------------------------------------------------------------------- +bool cmCMakePolicyCommand::HandleGetMode(std::vector const& args) +{ + if(args.size() != 3) + { + this->SetError("GET must be given exactly 2 additional arguments."); + return false; + } + + // Get arguments. + std::string const& id = args[1]; + std::string const& var = args[2]; + + // Lookup the policy number. + cmPolicies::PolicyID pid; + if(!this->Makefile->GetPolicies()->GetPolicyID(id.c_str(), pid)) + { + cmOStringStream e; + e << "GET given policy \"" << id << "\" which is not known to this " + << "version of CMake."; + this->SetError(e.str().c_str()); + return false; + } + + // Lookup the policy setting. + cmPolicies::PolicyStatus status = this->Makefile->GetPolicyStatus(pid); + switch (status) + { + case cmPolicies::OLD: + // Report that the policy is set to OLD. + this->Makefile->AddDefinition(var.c_str(), "OLD"); + break; + case cmPolicies::WARN: + // Report that the policy is not set. + this->Makefile->AddDefinition(var.c_str(), ""); + break; + case cmPolicies::NEW: + // Report that the policy is set to NEW. + this->Makefile->AddDefinition(var.c_str(), "NEW"); + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + // The policy is required to be set before anything needs it. + { + cmOStringStream e; + e << this->Makefile->GetPolicies()->GetRequiredPolicyError(pid) + << "\n" + << "The call to cmake_policy(GET " << id << " ...) at which this " + << "error appears requests the policy, and this version of CMake " + << "requires that the policy be set to NEW before it is checked."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + } + } + + return true; +} + //---------------------------------------------------------------------------- bool cmCMakePolicyCommand::HandleVersionMode(std::vector const& args) diff --git a/Source/cmCMakePolicyCommand.h b/Source/cmCMakePolicyCommand.h index 229b1fe5c..b82f98a1f 100755 --- a/Source/cmCMakePolicyCommand.h +++ b/Source/cmCMakePolicyCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCMakePolicyCommand.h,v $ Language: C++ - Date: $Date: 2008-03-18 14:23:54 $ - Version: $Revision: 1.4.2.1 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.4.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -108,6 +108,11 @@ public: "Alternatively one may fix the project to work with the new behavior " "and set the policy state to NEW." "\n" + " cmake_policy(GET CMP )\n" + "Check whether a given policy is set to OLD or NEW behavior. " + "The output variable value will be \"OLD\" or \"NEW\" if the " + "policy is set, and empty otherwise." + "\n" " cmake_policy(PUSH)\n" " cmake_policy(POP)\n" "Push and pop the current policy setting state on a stack. " @@ -123,6 +128,7 @@ public: cmTypeMacro(cmCMakePolicyCommand, cmCommand); private: bool HandleSetMode(std::vector const& args); + bool HandleGetMode(std::vector const& args); bool HandleVersionMode(std::vector const& args); }; diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 42232f7eb..98103d9b8 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCacheManager.cxx,v $ Language: C++ - Date: $Date: 2008-01-29 22:30:48 $ - Version: $Revision: 1.100 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.100.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -714,10 +714,6 @@ void cmCacheManager::RemoveCacheEntry(const char* key) { this->Cache.erase(i); } - else - { - std::cerr << "Failed to remove entry:" << key << std::endl; - } } diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx index 248dbcc79..fd5b69ebe 100644 --- a/Source/cmCallVisualStudioMacro.cxx +++ b/Source/cmCallVisualStudioMacro.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCallVisualStudioMacro.cxx,v $ Language: C++ - Date: $Date: 2008-02-15 16:49:58 $ - Version: $Revision: 1.3 $ + Date: $Date: 2008-07-31 15:52:24 $ + Version: $Revision: 1.3.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -24,6 +24,11 @@ #endif +// Just for this file: +// +static bool LogErrorsAsMessages; + + #if defined(HAVE_COMDEF_H) @@ -31,17 +36,20 @@ //---------------------------------------------------------------------------- -///! Use ReportHRESULT to make a cmSystemTools::Error after calling +///! Use ReportHRESULT to make a cmSystemTools::Message after calling ///! a COM method that may have failed. #define ReportHRESULT(hr, context) \ if (FAILED(hr)) \ { \ - std::ostringstream oss; \ - oss.flags(std::ios::hex); \ - oss << context << " failed HRESULT, hr = 0x" << hr << std::endl; \ - oss.flags(std::ios::dec); \ - oss << __FILE__ << "(" << __LINE__ << ")"; \ - cmSystemTools::Error(oss.str().c_str()); \ + if (LogErrorsAsMessages) \ + { \ + std::ostringstream oss; \ + oss.flags(std::ios::hex); \ + oss << context << " failed HRESULT, hr = 0x" << hr << std::endl; \ + oss.flags(std::ios::dec); \ + oss << __FILE__ << "(" << __LINE__ << ")"; \ + cmSystemTools::Message(oss.str().c_str()); \ + } \ } @@ -404,6 +412,8 @@ int cmCallVisualStudioMacro::GetNumberOfRunningVisualStudioInstances( { int count = 0; + LogErrorsAsMessages = false; + #if defined(HAVE_COMDEF_H) HRESULT hr = CoInitialize(0); ReportHRESULT(hr, "CoInitialize"); @@ -438,10 +448,13 @@ int cmCallVisualStudioMacro::GetNumberOfRunningVisualStudioInstances( int cmCallVisualStudioMacro::CallMacro( const std::string& slnFile, const std::string& macro, - const std::string& args) + const std::string& args, + const bool logErrorsAsMessages) { int err = 1; // no comdef.h + LogErrorsAsMessages = logErrorsAsMessages; + #if defined(HAVE_COMDEF_H) err = 2; // error initializing @@ -489,16 +502,19 @@ int cmCallVisualStudioMacro::CallMacro( (void)slnFile; (void)macro; (void)args; - cmSystemTools::Error("cmCallVisualStudioMacro::CallMacro is not " - "supported on this platform"); + if (LogErrorsAsMessages) + { + cmSystemTools::Message("cmCallVisualStudioMacro::CallMacro is not " + "supported on this platform"); + } #endif - if (err) + if (err && LogErrorsAsMessages) { std::ostringstream oss; oss << "cmCallVisualStudioMacro::CallMacro failed, err = " << err; - cmSystemTools::Error(oss.str().c_str()); + cmSystemTools::Message(oss.str().c_str()); } - return err; + return 0; } diff --git a/Source/cmCallVisualStudioMacro.h b/Source/cmCallVisualStudioMacro.h index fa4ab4248..3bfcf527c 100644 --- a/Source/cmCallVisualStudioMacro.h +++ b/Source/cmCallVisualStudioMacro.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCallVisualStudioMacro.h,v $ Language: C++ - Date: $Date: 2007-11-16 12:01:58 $ - Version: $Revision: 1.1 $ + Date: $Date: 2008-07-31 15:52:24 $ + Version: $Revision: 1.1.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -33,7 +33,8 @@ public: ///! macro in each Visual Studio instance. static int CallMacro(const std::string& slnFile, const std::string& macro, - const std::string& args); + const std::string& args, + const bool logErrorsAsMessages); ///! Count the number of running instances of Visual Studio with the ///! given solution file open. Pass "ALL" for slnFile to count all diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index 636451c50..36f5c371d 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCommands.cxx,v $ Language: C++ - Date: $Date: 2008-02-16 18:05:03 $ - Version: $Revision: 1.123 $ + Date: $Date: 2008-07-13 21:55:23 $ + Version: $Revision: 1.123.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -24,7 +24,6 @@ #include "cmExportCommand.cxx" #include "cmExportLibraryDependencies.cxx" #include "cmFLTKWrapUICommand.cxx" -#include "cmGetTestPropertyCommand.cxx" #include "cmIncludeExternalMSProjectCommand.cxx" #include "cmInstallProgramsCommand.cxx" #include "cmLinkLibrariesCommand.cxx" @@ -66,7 +65,6 @@ void GetPredefinedCommands(std::list& commands.push_back(new cmExportCommand); commands.push_back(new cmExportLibraryDependenciesCommand); commands.push_back(new cmFLTKWrapUICommand); - commands.push_back(new cmGetTestPropertyCommand); commands.push_back(new cmIncludeExternalMSProjectCommand); commands.push_back(new cmInstallProgramsCommand); commands.push_back(new cmLinkLibrariesCommand); diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index ecc28d822..faf2c8885 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmComputeLinkDepends.cxx,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:39 $ - Version: $Revision: 1.12.2.4 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.12.2.6 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -24,7 +24,6 @@ #include "cmake.h" #include -#include #include @@ -34,10 +33,10 @@ This file computes an ordered list of link items to use when linking a single target in one configuration. Each link item is identified by the string naming it. A graph of dependencies is created in which each node corresponds to one item and directed eges lead from nodes to -those which must *precede* them on the link line. For example, the +those which must *follow* them on the link line. For example, the graph - C -> B -> A + A -> B -> C will lead to the link line order @@ -51,7 +50,9 @@ those without known dependencies. We will call the two types "known items" and "unknown items", respecitvely. Known items are those whose names correspond to targets (built or imported) and those for which an old-style _LIB_DEPENDS variable is defined. All other items are -unknown and we must infer dependencies for them. +unknown and we must infer dependencies for them. For items that look +like flags (beginning with '-') we trivially infer no dependencies, +and do not include them in the dependencies of other items. Known items have dependency lists ordered based on how the user specified them. We can use this order to infer potential dependencies @@ -64,11 +65,11 @@ lists: The explicitly known dependencies form graph edges - X <- Y , X <- A , X <- B , Y <- A , Y <- B + X -> Y , X -> A , X -> B , Y -> A , Y -> B We can also infer the edge - A <- B + A -> B because *every* time A appears B is seen on its right. We do not know whether A really needs symbols from B to link, but it *might* so we @@ -92,12 +93,12 @@ considering these dependency lists: The explicit edges are - X <- Y , X <- A , X <- B , X <- C , Y <- A , Y <- B , Y <- C + X -> Y , X -> A , X -> B , X -> C , Y -> A , Y -> B , Y -> C For the unknown items, we infer dependencies by looking at the "follow" sets: - A: intersect( {B,Y,C} , {C,B} ) = {B,C} ; infer edges A <- B , A <- C + A: intersect( {B,Y,C} , {C,B} ) = {B,C} ; infer edges A -> B , A -> C B: intersect( {Y,C} , {} ) = {} ; infer no edges C: intersect( {} , {B} ) = {} ; infer no edges @@ -106,57 +107,71 @@ libraries should not depend on them. ------------------------------------------------------------------------------ -Once the complete graph is formed from all known and inferred -dependencies we must use it to produce a valid link line. If the -dependency graph were known to be acyclic a simple depth-first-search -would produce a correct link line. Unfortunately we cannot make this -assumption so the following technique is used. +The initial exploration of dependencies using a BFS associates an +integer index with each link item. When the graph is built outgoing +edges are sorted by this index. +After the initial exploration of the link interface tree, any +transitive (dependent) shared libraries that were encountered and not +included in the interface are processed in their own BFS. This BFS +follows only the dependent library lists and not the link interfaces. +They are added to the link items with a mark indicating that the are +transitive dependencies. Then cmComputeLinkInformation deals with +them on a per-platform basis. + +The complete graph formed from all known and inferred dependencies may +not be acyclic, so an acyclic version must be created. The original graph is converted to a directed acyclic graph in which each node corresponds to a strongly connected component of the original graph. For example, the dependency graph - X <- A <- B <- C <- A <- Y + X -> A -> B -> C -> A -> Y contains strongly connected components {X}, {A,B,C}, and {Y}. The implied directed acyclic graph (DAG) is - {X} <- {A,B,C} <- {Y} - -The final list of link items is constructed by a series of -depth-first-searches through this DAG of components. When visiting a -component all outgoing edges are followed first because the neighbors -must precede it. Once neighbors across all edges have been emitted it -is safe to emit the current component. - -Trivial components (those with one item) are handled simply by -emitting the item. Non-trivial components (those with more than one -item) are assumed to consist only of static libraries that may be -safely repeated on the link line. We emit members of the component -multiple times (see code below for details). The final link line for -the example graph might be + {X} -> {A,B,C} -> {Y} - X A B C A B C Y +We then compute a topological order for the DAG nodes to serve as a +reference for satisfying dependencies efficiently. We perform the DFS +in reverse order and assign topological order indices counting down so +that the result is as close to the original BFS order as possible +without violating dependencies. ------------------------------------------------------------------------------ -The initial exploration of dependencies using a BFS associates an -integer index with each link item. When the graph is built outgoing -edges are sorted by this index. - -This preserves the original link order as much as possible subject to -the dependencies. We then further preserve the original link line by -appending items to make sure all those that might be static libraries -appear in the order and multiplicity that they do in the original -line. - -After the initial exploration of the link interface tree, any -transitive (dependent) shared libraries that were encountered and not -included in the interface are processed in their own BFS. This BFS -follows only the dependent library lists and not the link interfaces. -They are added to the link items with a mark indicating that the are -transitive dependencies. Then cmComputeLinkInformation deals with -them on a per-platform basis. +The final link entry order is constructed as follows. We first walk +through and emit the *original* link line as specified by the user. +As each item is emitted, a set of pending nodes in the component DAG +is maintained. When a pending component has been completely seen, it +is removed from the pending set and its dependencies (following edges +of the DAG) are added. A trivial component (those with one item) is +complete as soon as its item is seen. A non-trivial component (one +with more than one item; assumed to be static libraries) is complete +when *all* its entries have been seen *twice* (all entries seen once, +then all entries seen again, not just each entry twice). A pending +component tracks which items have been seen and a count of how many +times the component needs to be seen (once for trivial components, +twice for non-trivial). If at any time another component finishes and +re-adds an already pending component, the pending component is reset +so that it needs to be seen in its entirety again. This ensures that +all dependencies of a component are satisified no matter where it +appears. + +After the original link line has been completed, we append to it the +remaining pending components and their dependencies. This is done by +repeatedly emitting the first item from the first pending component +and following the same update rules as when traversing the original +link line. Since the pending components are kept in topological order +they are emitted with minimal repeats (we do not want to emit a +component just to have it added again when another component is +completed later). This process continues until no pending components +remain. We know it will terminate because the component graph is +guaranteed to be acyclic. + +The final list of items produced by this procedure consists of the +original user link line followed by minimal additional items needed to +satisfy dependencies. */ @@ -172,13 +187,16 @@ cmComputeLinkDepends this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. - this->Config = config; + this->Config = (config && *config)? config : 0; // Enable debug mode if requested. this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE"); // Assume no compatibility until set. this->OldLinkDirMode = false; + + // No computation has been done. + this->CCG = 0; } //---------------------------------------------------------------------------- @@ -190,6 +208,7 @@ cmComputeLinkDepends::~cmComputeLinkDepends() { delete *i; } + delete this->CCG; } //---------------------------------------------------------------------------- @@ -198,12 +217,6 @@ void cmComputeLinkDepends::SetOldLinkDirMode(bool b) this->OldLinkDirMode = b; } -//---------------------------------------------------------------------------- -void cmComputeLinkDepends::SetSharedRegex(std::string const& regex) -{ - this->SharedRegexString = regex; -} - //---------------------------------------------------------------------------- std::vector const& cmComputeLinkDepends::Compute() @@ -249,7 +262,6 @@ cmComputeLinkDepends::Compute() // Compute the final ordering. this->OrderLinkEntires(); - this->PreserveOriginalEntries(); // Compute the final set of link entries. for(std::vector::const_iterator li = this->FinalLinkOrder.begin(); @@ -299,7 +311,9 @@ int cmComputeLinkDepends::AddLinkEntry(std::string const& item) int index = lei->second; LinkEntry& entry = this->EntryList[index]; entry.Item = item; - entry.Target = this->Makefile->FindTargetToUse(entry.Item.c_str()); + entry.Target = this->FindTargetToLink(entry.Item.c_str()); + entry.IsFlag = (!entry.Target && item[0] == '-' && item[1] != 'l' && + item.substr(0, 10) != "-framework"); // If the item has dependencies queue it to follow them. if(entry.Target) @@ -319,7 +333,7 @@ int cmComputeLinkDepends::AddLinkEntry(std::string const& item) BFSEntry qe = {index, val}; this->BFSQueue.push(qe); } - else + else if(!entry.IsFlag) { // The item dependencies are not known. We need to infer them. this->InferredDependSets[index] = new DependSetList; @@ -394,7 +408,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) // Initialize the item entry. LinkEntry& entry = this->EntryList[lei->second]; entry.Item = dep.Item; - entry.Target = this->Makefile->FindTargetToUse(dep.Item.c_str()); + entry.Target = this->FindTargetToLink(dep.Item.c_str()); // This item was added specifically because it is a dependent // shared library. It may get special treatment @@ -406,9 +420,9 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) int index = lei->second; LinkEntry& entry = this->EntryList[index]; - // This shared library dependency must be preceded by the item that - // listed it. - this->EntryConstraintGraph[index].push_back(dep.DependerIndex); + // This shared library dependency must follow the item that listed + // it. + this->EntryConstraintGraph[dep.DependerIndex].push_back(index); // Target items may have their own dependencies. if(entry.Target) @@ -559,10 +573,10 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index, // Add a link entry for this item. int dependee_index = this->AddLinkEntry(item); - // The depender must come before the dependee. + // The dependee must come after the depender. if(depender_index >= 0) { - this->EntryConstraintGraph[dependee_index].push_back(depender_index); + this->EntryConstraintGraph[depender_index].push_back(dependee_index); } else { @@ -579,6 +593,7 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index, // items are outside libraries that should not be depending on // targets. if(!this->EntryList[dependee_index].Target && + !this->EntryList[dependee_index].IsFlag && dependee_index != dsi->first) { dsi->second.insert(dependee_index); @@ -661,6 +676,25 @@ std::string cmComputeLinkDepends::CleanItemName(std::string const& item) return lib; } +//---------------------------------------------------------------------------- +cmTarget* cmComputeLinkDepends::FindTargetToLink(const char* name) +{ + // Look for a target. + cmTarget* tgt = this->Makefile->FindTargetToUse(name); + + // Skip targets that will not really be linked. This is probably a + // name conflict between an external library and an executable + // within the project. + if(tgt && tgt->GetType() == cmTarget::EXECUTABLE && + !tgt->IsExecutableWithExports()) + { + tgt = 0; + } + + // Return the target found, if any. + return tgt; +} + //---------------------------------------------------------------------------- void cmComputeLinkDepends::InferDependencies() { @@ -694,7 +728,7 @@ void cmComputeLinkDepends::InferDependencies() for(DependSet::const_iterator j = common.begin(); j != common.end(); ++j) { int dependee_index = *j; - this->EntryConstraintGraph[dependee_index].push_back(depender_index); + this->EntryConstraintGraph[depender_index].push_back(dependee_index); } } } @@ -726,7 +760,7 @@ void cmComputeLinkDepends::DisplayConstraintGraph() e << "item " << i << " is [" << this->EntryList[i].Item << "]\n"; for(NodeList::const_iterator j = nl.begin(); j != nl.end(); ++j) { - e << " item " << *j << " must precede it\n"; + e << " item " << *j << " must follow it\n"; } } fprintf(stderr, "%s\n", e.str().c_str()); @@ -740,30 +774,55 @@ void cmComputeLinkDepends::OrderLinkEntires() // the same order in which the items were originally discovered in // the BFS. This should preserve the original order when no // constraints disallow it. - cmComputeComponentGraph ccg(this->EntryConstraintGraph); - Graph const& cgraph = ccg.GetComponentGraph(); + this->CCG = new cmComputeComponentGraph(this->EntryConstraintGraph); + + // The component graph is guaranteed to be acyclic. Start a DFS + // from every entry to compute a topological order for the + // components. + Graph const& cgraph = this->CCG->GetComponentGraph(); + int n = static_cast(cgraph.size()); + this->ComponentVisited.resize(cgraph.size(), 0); + this->ComponentOrder.resize(cgraph.size(), n); + this->ComponentOrderId = n; + // Run in reverse order so the topological order will preserve the + // original order where there are no constraints. + for(int c = n-1; c >= 0; --c) + { + this->VisitComponent(c); + } + + // Display the component graph. if(this->DebugMode) { - this->DisplayComponents(ccg); + this->DisplayComponents(); } - // Setup visit tracking. - this->ComponentVisited.resize(cgraph.size(), 0); + // Start with the original link line. + for(std::vector::const_iterator i = this->OriginalEntries.begin(); + i != this->OriginalEntries.end(); ++i) + { + this->VisitEntry(*i); + } - // The component graph is guaranteed to be acyclic. Start a DFS - // from every entry. - for(unsigned int c=0; c < cgraph.size(); ++c) + // Now explore anything left pending. Since the component graph is + // guaranteed to be acyclic we know this will terminate. + while(!this->PendingComponents.empty()) { - this->VisitComponent(ccg, c); + // Visit one entry from the first pending component. The visit + // logic will update the pending components accordingly. Since + // the pending components are kept in topological order this will + // not repeat one. + int e = *this->PendingComponents.begin()->second.Entries.begin(); + this->VisitEntry(e); } } //---------------------------------------------------------------------------- void -cmComputeLinkDepends::DisplayComponents(cmComputeComponentGraph const& ccg) +cmComputeLinkDepends::DisplayComponents() { fprintf(stderr, "The strongly connected components are:\n"); - std::vector const& components = ccg.GetComponents(); + std::vector const& components = this->CCG->GetComponents(); for(unsigned int c=0; c < components.size(); ++c) { fprintf(stderr, "Component (%u):\n", c); @@ -774,14 +833,19 @@ cmComputeLinkDepends::DisplayComponents(cmComputeComponentGraph const& ccg) fprintf(stderr, " item %d [%s]\n", i, this->EntryList[i].Item.c_str()); } + NodeList const& ol = this->CCG->GetComponentGraphEdges(c); + for(NodeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi) + { + fprintf(stderr, " followed by Component (%d)\n", *oi); + } + fprintf(stderr, " topo order index %d\n", + this->ComponentOrder[c]); } fprintf(stderr, "\n"); } //---------------------------------------------------------------------------- -void -cmComputeLinkDepends::VisitComponent(cmComputeComponentGraph const& ccg, - unsigned int c) +void cmComputeLinkDepends::VisitComponent(unsigned int c) { // Check if the node has already been visited. if(this->ComponentVisited[c]) @@ -793,49 +857,126 @@ cmComputeLinkDepends::VisitComponent(cmComputeComponentGraph const& ccg, this->ComponentVisited[c] = 1; // Visit the neighbors of the component first. - NodeList const& nl = ccg.GetComponentGraphEdges(c); - for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) + // Run in reverse order so the topological order will preserve the + // original order where there are no constraints. + NodeList const& nl = this->CCG->GetComponentGraphEdges(c); + for(NodeList::const_reverse_iterator ni = nl.rbegin(); + ni != nl.rend(); ++ni) { - this->VisitComponent(ccg, *ni); + this->VisitComponent(*ni); } - // Now that all items required to come before this one have been - // emmitted, emit this component's items. - this->EmitComponent(ccg.GetComponent(c)); + // Assign an ordering id to this component. + this->ComponentOrder[c] = --this->ComponentOrderId; } //---------------------------------------------------------------------------- -void cmComputeLinkDepends::EmitComponent(NodeList const& nl) +void cmComputeLinkDepends::VisitEntry(int index) { - assert(!nl.empty()); + // Include this entry on the link line. + this->FinalLinkOrder.push_back(index); + + // This entry has now been seen. Update its component. + bool completed = false; + int component = this->CCG->GetComponentMap()[index]; + std::map::iterator mi = + this->PendingComponents.find(this->ComponentOrder[component]); + if(mi != this->PendingComponents.end()) + { + // The entry is in an already pending component. + PendingComponent& pc = mi->second; + + // Remove the entry from those pending in its component. + pc.Entries.erase(index); + if(pc.Entries.empty()) + { + // The complete component has been seen since it was last needed. + --pc.Count; - // Handle trivial components. - if(nl.size() == 1) + if(pc.Count == 0) + { + // The component has been completed. + this->PendingComponents.erase(mi); + completed = true; + } + else + { + // The whole component needs to be seen again. + NodeList const& nl = this->CCG->GetComponent(component); + assert(nl.size() > 1); + pc.Entries.insert(nl.begin(), nl.end()); + } + } + } + else { - this->FinalLinkOrder.push_back(nl[0]); - return; + // The entry is not in an already pending component. + NodeList const& nl = this->CCG->GetComponent(component); + if(nl.size() > 1) + { + // This is a non-trivial component. It is now pending. + PendingComponent& pc = this->MakePendingComponent(component); + + // The starting entry has already been seen. + pc.Entries.erase(index); + } + else + { + // This is a trivial component, so it is already complete. + completed = true; + } } - // This is a non-trivial strongly connected component of the - // original graph. It consists of two or more libraries (archives) - // that mutually require objects from one another. In the worst - // case we may have to repeat the list of libraries as many times as - // there are object files in the biggest archive. For now we just - // list them twice. - // - // The list of items in the component has been sorted by the order - // of discovery in the original BFS of dependencies. This has the - // advantage that the item directly linked by a target requiring - // this component will come first which minimizes the number of - // repeats needed. - for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) + // If the entry completed a component, the component's dependencies + // are now pending. + if(completed) { - this->FinalLinkOrder.push_back(*ni); + NodeList const& ol = this->CCG->GetComponentGraphEdges(component); + for(NodeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi) + { + // This entire component is now pending no matter whether it has + // been partially seen already. + this->MakePendingComponent(*oi); + } } - for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) +} + +//---------------------------------------------------------------------------- +cmComputeLinkDepends::PendingComponent& +cmComputeLinkDepends::MakePendingComponent(unsigned int component) +{ + // Create an entry (in topological order) for the component. + PendingComponent& pc = + this->PendingComponents[this->ComponentOrder[component]]; + pc.Id = component; + NodeList const& nl = this->CCG->GetComponent(component); + + if(nl.size() == 1) { - this->FinalLinkOrder.push_back(*ni); + // Trivial components need be seen only once. + pc.Count = 1; } + else + { + // This is a non-trivial strongly connected component of the + // original graph. It consists of two or more libraries + // (archives) that mutually require objects from one another. In + // the worst case we may have to repeat the list of libraries as + // many times as there are object files in the biggest archive. + // For now we just list them twice. + // + // The list of items in the component has been sorted by the order + // of discovery in the original BFS of dependencies. This has the + // advantage that the item directly linked by a target requiring + // this component will come first which minimizes the number of + // repeats needed. + pc.Count = 2; + } + + // Store the entries to be seen. + pc.Entries.insert(nl.begin(), nl.end()); + + return pc; } //---------------------------------------------------------------------------- @@ -869,7 +1010,7 @@ void cmComputeLinkDepends::CheckWrongConfigItem(std::string const& item) // For CMake 2.4 bug-compatibility we need to consider the output // directories of targets linked in another configuration as link // directories. - if(cmTarget* tgt = this->Makefile->FindTargetToUse(item.c_str())) + if(cmTarget* tgt = this->FindTargetToLink(item.c_str())) { if(!tgt->IsImported()) { @@ -877,54 +1018,3 @@ void cmComputeLinkDepends::CheckWrongConfigItem(std::string const& item) } } } - -//---------------------------------------------------------------------------- -void cmComputeLinkDepends::PreserveOriginalEntries() -{ - // Regular expression to match shared libraries. - cmsys::RegularExpression shared_lib(this->SharedRegexString.c_str()); - - // Skip the part of the input sequence that already appears in the - // output. - std::vector::const_iterator in = this->OriginalEntries.begin(); - std::vector::const_iterator out = this->FinalLinkOrder.begin(); - while(in != this->OriginalEntries.end() && - out != this->FinalLinkOrder.end()) - { - cmTarget* tgt = this->EntryList[*in].Target; - if((tgt && tgt->GetType() != cmTarget::STATIC_LIBRARY) || - (!tgt && shared_lib.find(this->EntryList[*in].Item))) - { - // Skip input items known to not be static libraries. - ++in; - } - else if(*in == *out) - { - // The input and output items match. Move on to the next items. - ++in; - ++out; - } - else - { - // The output item does not match the next input item. Skip it. - ++out; - } - } - - // Append the part of the input sequence that does not already - // appear in the output. - while(in != this->OriginalEntries.end()) - { - cmTarget* tgt = this->EntryList[*in].Target; - if((tgt && tgt->GetType() != cmTarget::STATIC_LIBRARY) || - (!tgt && shared_lib.find(this->EntryList[*in].Item))) - { - // Skip input items known to not be static libraries. - ++in; - } - else - { - this->FinalLinkOrder.push_back(*in++); - } - } -} diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 9a7b1cdde..925fe3d06 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmComputeLinkDepends.h,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:39 $ - Version: $Revision: 1.5.2.4 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.5.2.6 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -46,9 +46,11 @@ public: std::string Item; cmTarget* Target; bool IsSharedDep; - LinkEntry(): Item(), Target(0), IsSharedDep(false) {} + bool IsFlag; + LinkEntry(): Item(), Target(0), IsSharedDep(false), IsFlag(false) {} LinkEntry(LinkEntry const& r): - Item(r.Item), Target(r.Target), IsSharedDep(r.IsSharedDep) {} + Item(r.Item), Target(r.Target), IsSharedDep(r.IsSharedDep), + IsFlag(r.IsFlag) {} }; typedef std::vector EntryVector; @@ -58,10 +60,6 @@ public: std::set const& GetOldWrongConfigItems() const { return this->OldWrongConfigItems; } - /** Set a regular expression that matches strings ending in a shared - library extension. */ - void SetSharedRegex(std::string const& regex); - private: // Context information. @@ -89,6 +87,7 @@ private: void AddLinkEntries(int depender_index, std::vector const& libs); std::string CleanItemName(std::string const& item); + cmTarget* FindTargetToLink(const char* name); // One entry for each unique item. std::vector EntryList; @@ -132,16 +131,33 @@ private: // Ordering algorithm. void OrderLinkEntires(); std::vector ComponentVisited; + std::vector ComponentOrder; + int ComponentOrderId; + struct PendingComponent + { + // The real component id. Needed because the map is indexed by + // component topological index. + int Id; + + // The number of times the component needs to be seen. This is + // always 1 for trivial components and is initially 2 for + // non-trivial components. + int Count; + + // The entries yet to be seen to complete the component. + std::set Entries; + }; + std::map PendingComponents; + cmComputeComponentGraph* CCG; std::vector FinalLinkOrder; - void DisplayComponents(cmComputeComponentGraph const& ccg); - void VisitComponent(cmComputeComponentGraph const& ccg, unsigned int i); - void EmitComponent(NodeList const& nl); + void DisplayComponents(); + void VisitComponent(unsigned int c); + void VisitEntry(int index); + PendingComponent& MakePendingComponent(unsigned int component); void DisplayFinalEntries(); - // Preservation of original link line. + // Record of the original link line. std::vector OriginalEntries; - void PreserveOriginalEntries(); - std::string SharedRegexString; // Compatibility help. bool OldLinkDirMode; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e1c6556b4..7a58994db 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmComputeLinkInformation.cxx,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:39 $ - Version: $Revision: 1.24.2.6 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.24.2.10 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -256,10 +256,10 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->GetName(), + new cmOrderDirectories(this->GlobalGenerator, target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->GetName(), + new cmOrderDirectories(this->GlobalGenerator, target, "runtime search path"); this->OrderDependentRPath = 0; @@ -362,7 +362,7 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target->GetName(), + new cmOrderDirectories(this->GlobalGenerator, target, "dependent library path"); } @@ -511,7 +511,6 @@ bool cmComputeLinkInformation::Compute() // Compute the ordered link line items. cmComputeLinkDepends cld(this->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); - cld.SetSharedRegex(this->SharedRegexString); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); // Add the link line items. @@ -582,10 +581,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) return; } - if(tgt && (tgt->GetType() == cmTarget::STATIC_LIBRARY || - tgt->GetType() == cmTarget::SHARED_LIBRARY || - tgt->GetType() == cmTarget::MODULE_LIBRARY || - impexe)) + if(tgt && tgt->IsLinkable()) { // This is a CMake target. Ask the target for its real name. if(impexe && this->LoaderFlag) @@ -637,7 +633,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, cmTarget* tgt) else { // This is a library or option specified by the user. - this->AddUserItem(item); + this->AddUserItem(item, true); } } } @@ -1042,6 +1038,20 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) return; } + // Full path libraries should specify a valid library file name. + // See documentation of CMP0008. + if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && + (strstr(this->GlobalGenerator->GetName(), "Visual Studio") || + strstr(this->GlobalGenerator->GetName(), "Xcode"))) + { + std::string file = cmSystemTools::GetFilenameName(item); + if(!this->ExtractAnyLibraryName.find(file.c_str())) + { + this->HandleBadFullItem(item, file); + return; + } + } + // This is called to handle a link item that is a full path. // If the target is not a static library make sure the link type is // shared. This is because dynamic-mode linking can handle both @@ -1116,12 +1126,17 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) // directory then just report the file name without the directory // portion. This will allow the system linker to locate the proper // library for the architecture at link time. - this->AddUserItem(file); + this->AddUserItem(file, false); + + // Make sure the link directory ordering will find the library. + this->OrderLinkerSearchPath->AddLinkLibrary(item); + return true; } //---------------------------------------------------------------------------- -void cmComputeLinkInformation::AddUserItem(std::string const& item) +void cmComputeLinkInformation::AddUserItem(std::string const& item, + bool pathNotKnown) { // This is called to handle a link item that does not match a CMake // target and is not a full path. We check here if it looks like a @@ -1211,7 +1226,10 @@ void cmComputeLinkInformation::AddUserItem(std::string const& item) else { // This is a name specified by the user. - this->OldUserFlagItems.push_back(item); + if(pathNotKnown) + { + this->OldUserFlagItems.push_back(item); + } // We must ask the linker to search for a library with this name. // Restore the target link type since this item does not specify @@ -1334,12 +1352,73 @@ void cmComputeLinkInformation::AddSharedLibNoSOName(std::string const& item) // runtime the dynamic linker will search for the library using the // path instead of just the name. std::string file = cmSystemTools::GetFilenameName(item); - this->AddUserItem(file); + this->AddUserItem(file, false); // Make sure the link directory ordering will find the library. this->OrderLinkerSearchPath->AddLinkLibrary(item); } +//---------------------------------------------------------------------------- +void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, + std::string const& file) +{ + // Do not depend on things that do not exist. + std::vector::iterator i = + std::find(this->Depends.begin(), this->Depends.end(), item); + if(i != this->Depends.end()) + { + this->Depends.erase(i); + } + + // Tell the linker to search for the item and provide the proper + // path for it. Do not contribute to any CMP0003 warning (do not + // put in OldLinkDirItems or OldUserFlagItems). + this->AddUserItem(file, false); + this->OrderLinkerSearchPath->AddLinkLibrary(item); + + // Produce any needed message. + switch(this->Target->GetPolicyStatusCMP0008()) + { + case cmPolicies::WARN: + { + // Print the warning at most once for this item. + std::string wid = "CMP0008-WARNING-GIVEN-"; + wid += item; + if(!this->CMakeInstance->GetPropertyAsBool(wid.c_str())) + { + this->CMakeInstance->SetProperty(wid.c_str(), "1"); + cmOStringStream w; + w << (this->Makefile->GetPolicies() + ->GetPolicyWarning(cmPolicies::CMP0008)) << "\n" + << "Target \"" << this->Target->GetName() << "\" links to item\n" + << " " << item << "\n" + << "which is a full-path but not a valid library file name."; + this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), + this->Target->GetBacktrace()); + } + } + case cmPolicies::OLD: + // OLD behavior does not warn. + break; + case cmPolicies::NEW: + // NEW behavior will not get here. + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + { + cmOStringStream e; + e << (this->Makefile->GetPolicies()-> + GetRequiredPolicyError(cmPolicies::CMP0008)) << "\n" + << "Target \"" << this->Target->GetName() << "\" links to item\n" + << " " << item << "\n" + << "which is a full-path but not a valid library file name."; + this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Target->GetBacktrace()); + } + break; + } +} + //---------------------------------------------------------------------------- bool cmComputeLinkInformation::FinishLinkerSearchDirectories() { @@ -1473,6 +1552,14 @@ void cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, cmTarget* target) { + // Libraries with unknown type must be handled using just the file + // on disk. + if(target->GetType() == cmTarget::UNKNOWN_LIBRARY) + { + this->AddLibraryRuntimeInfo(fullPath); + return; + } + // Skip targets that are not shared libraries (modules cannot be linked). if(target->GetType() != cmTarget::SHARED_LIBRARY) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 853f36932..2d9c54981 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmComputeLinkInformation.h,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:39 $ - Version: $Revision: 1.15.2.2 $ + Date: $Date: 2008-07-28 15:31:35 $ + Version: $Revision: 1.15.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -139,12 +139,13 @@ private: void AddTargetItem(std::string const& item, cmTarget* target); void AddFullItem(std::string const& item); bool CheckImplicitDirItem(std::string const& item); - void AddUserItem(std::string const& item); + void AddUserItem(std::string const& item, bool pathNotKnown); void AddDirectoryItem(std::string const& item); void AddFrameworkItem(std::string const& item); void DropDirectoryItem(std::string const& item); bool CheckSharedLibNoSOName(std::string const& item); void AddSharedLibNoSOName(std::string const& item); + void HandleBadFullItem(std::string const& item, std::string const& file); // Framework info. void ComputeFrameworkInfo(); diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 5ec9ce31a..5362041e1 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmComputeTargetDepends.cxx,v $ Language: C++ - Date: $Date: 2008-02-07 21:14:05 $ - Version: $Revision: 1.2 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.2.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -214,7 +214,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Don't emit the same library twice for this target. if(emitted.insert(lib->first).second) { - this->AddTargetDepend(depender_index, lib->first.c_str()); + this->AddTargetDepend(depender_index, lib->first.c_str(), true); } } @@ -226,14 +226,15 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Don't emit the same utility twice for this target. if(emitted.insert(*util).second) { - this->AddTargetDepend(depender_index, util->c_str()); + this->AddTargetDepend(depender_index, util->c_str(), false); } } } //---------------------------------------------------------------------------- void cmComputeTargetDepends::AddTargetDepend(int depender_index, - const char* dependee_name) + const char* dependee_name, + bool linking) { // Get the depender. cmTarget* depender = this->Targets[depender_index]; @@ -248,6 +249,16 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, dependee = this->GlobalGenerator->FindTarget(0, dependee_name); } + // Skip targets that will not really be linked. This is probably a + // name conflict between an external library and an executable + // within the project. + if(linking && dependee && + dependee->GetType() == cmTarget::EXECUTABLE && + !dependee->IsExecutableWithExports()) + { + dependee = 0; + } + // If not found then skip then the dependee. if(!dependee) { @@ -365,7 +376,7 @@ cmComputeTargetDepends cmTarget* depender = this->Targets[i]; // Describe the depender. - e << " " << depender->GetName() << " of type " + e << " \"" << depender->GetName() << "\" of type " << cmTarget::TargetTypeNames[depender->GetType()] << "\n"; // List its dependencies that are inside the component. @@ -376,7 +387,7 @@ cmComputeTargetDepends if(cmap[j] == c) { cmTarget* dependee = this->Targets[j]; - e << " depends on " << dependee->GetName() << "\n"; + e << " depends on \"" << dependee->GetName() << "\"\n"; } } } diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index 24bce0928..b0a1a7052 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmComputeTargetDepends.h,v $ Language: C++ - Date: $Date: 2008-02-07 21:14:05 $ - Version: $Revision: 1.2 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.2.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -48,7 +48,8 @@ private: void CollectTargets(); void CollectDepends(); void CollectTargetDepends(int depender_index); - void AddTargetDepend(int depender_index, const char* dependee_name); + void AddTargetDepend(int depender_index, const char* dependee_name, + bool linking); void ComputeFinalDepends(cmComputeComponentGraph const& ccg); cmGlobalGenerator* GlobalGenerator; diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx index 2b5f0bbed..b86a37a11 100644 --- a/Source/cmCustomCommand.cxx +++ b/Source/cmCustomCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCustomCommand.cxx,v $ Language: C++ - Date: $Date: 2007-09-17 14:50:46 $ - Version: $Revision: 1.24 $ + Date: $Date: 2008-06-13 12:55:17 $ + Version: $Revision: 1.24.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 91ef23026..38c3c061a 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmCustomCommand.h,v $ Language: C++ - Date: $Date: 2007-09-17 14:50:46 $ - Version: $Revision: 1.23 $ + Date: $Date: 2008-06-13 12:55:17 $ + Version: $Revision: 1.23.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index 7f3b491f9..40b11ce2a 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDepends.cxx,v $ Language: C++ - Date: $Date: 2007-12-28 16:49:59 $ - Version: $Revision: 1.17 $ + Date: $Date: 2008-05-15 19:39:50 $ + Version: $Revision: 1.17.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -24,11 +24,12 @@ #include //---------------------------------------------------------------------------- -cmDepends::cmDepends(): +cmDepends::cmDepends(cmLocalGenerator* lg, const char* targetDir): CompileDirectory(), - LocalGenerator(0), + LocalGenerator(lg), Verbose(false), FileComparison(0), + TargetDirectory(targetDir), MaxPath(cmSystemTools::GetMaximumFilePathLength()), Dependee(new char[MaxPath]), Depender(new char[MaxPath]) @@ -231,4 +232,15 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends) return okay; } - +//---------------------------------------------------------------------------- +void cmDepends::SetIncludePathFromLanguage(const char* lang) +{ + std::string includePathVar = "CMAKE_"; + includePathVar += lang; + includePathVar += "_INCLUDE_PATH"; + cmMakefile* mf = this->LocalGenerator->GetMakefile(); + if(const char* includePath = mf->GetDefinition(includePathVar.c_str())) + { + cmSystemTools::ExpandListArgument(includePath, this->IncludePath); + } +} diff --git a/Source/cmDepends.h b/Source/cmDepends.h index fcde6ea3a..de882a710 100644 --- a/Source/cmDepends.h +++ b/Source/cmDepends.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDepends.h,v $ Language: C++ - Date: $Date: 2007-12-28 16:49:59 $ - Version: $Revision: 1.14 $ + Date: $Date: 2008-05-15 19:39:50 $ + Version: $Revision: 1.14.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -34,7 +34,7 @@ class cmDepends public: /** Instances need to know the build directory name and the relative path from the build directory to the target file. */ - cmDepends(); + cmDepends(cmLocalGenerator* lg=0, const char* targetDir=""); /** at what level will the compile be done from */ void SetCompileDirectory(const char *dir) {this->CompileDirectory = dir;}; @@ -108,6 +108,11 @@ protected: char* Dependee; char* Depender; + // The include file search path. + std::vector IncludePath; + + void SetIncludePathFromLanguage(const char* lang); + private: cmDepends(cmDepends const&); // Purposely not implemented. void operator=(cmDepends const&); // Purposely not implemented. diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 70d5e057e..df5a9dd04 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDependsC.cxx,v $ Language: C++ - Date: $Date: 2007-12-15 01:31:27 $ - Version: $Revision: 1.33 $ + Date: $Date: 2008-05-15 19:39:50 $ + Version: $Revision: 1.33.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -18,6 +18,7 @@ #include "cmFileTimeComparison.h" #include "cmLocalGenerator.h" +#include "cmMakefile.h" #include "cmSystemTools.h" #include // isspace @@ -29,27 +30,58 @@ #define INCLUDE_REGEX_LINE_MARKER "#IncludeRegexLine: " #define INCLUDE_REGEX_SCAN_MARKER "#IncludeRegexScan: " #define INCLUDE_REGEX_COMPLAIN_MARKER "#IncludeRegexComplain: " +#define INCLUDE_REGEX_TRANSFORM_MARKER "#IncludeRegexTransform: " //---------------------------------------------------------------------------- -cmDependsC::cmDependsC(): - IncludePath(0) +cmDependsC::cmDependsC() { } + //---------------------------------------------------------------------------- -// yummy look at all those constructor arguments -cmDependsC::cmDependsC(std::vector const& includes, - const char* scanRegex, const char* complainRegex, - const cmStdString& cacheFileName): - IncludePath(&includes), - IncludeRegexLine(INCLUDE_REGEX_LINE), - IncludeRegexScan(scanRegex), - IncludeRegexComplain(complainRegex), - IncludeRegexLineString(INCLUDE_REGEX_LINE_MARKER INCLUDE_REGEX_LINE), - IncludeRegexScanString(std::string(INCLUDE_REGEX_SCAN_MARKER)+scanRegex), - IncludeRegexComplainString( - std::string(INCLUDE_REGEX_COMPLAIN_MARKER)+complainRegex), - CacheFileName(cacheFileName) +cmDependsC::cmDependsC(cmLocalGenerator* lg, const char* targetDir, + const char* lang): cmDepends(lg, targetDir) { + cmMakefile* mf = lg->GetMakefile(); + + // Configure the include file search path. + this->SetIncludePathFromLanguage(lang); + + // Configure regular expressions. + std::string scanRegex = "^.*$"; + std::string complainRegex = "^$"; + { + std::string scanRegexVar = "CMAKE_"; + scanRegexVar += lang; + scanRegexVar += "_INCLUDE_REGEX_SCAN"; + if(const char* sr = mf->GetDefinition(scanRegexVar.c_str())) + { + scanRegex = sr; + } + std::string complainRegexVar = "CMAKE_"; + complainRegexVar += lang; + complainRegexVar += "_INCLUDE_REGEX_COMPLAIN"; + if(const char* cr = mf->GetDefinition(complainRegexVar.c_str())) + { + complainRegex = cr; + } + } + + this->IncludeRegexLine.compile(INCLUDE_REGEX_LINE); + this->IncludeRegexScan.compile(scanRegex.c_str()); + this->IncludeRegexComplain.compile(complainRegex.c_str()); + this->IncludeRegexLineString = INCLUDE_REGEX_LINE_MARKER INCLUDE_REGEX_LINE; + this->IncludeRegexScanString = INCLUDE_REGEX_SCAN_MARKER; + this->IncludeRegexScanString += scanRegex; + this->IncludeRegexComplainString = INCLUDE_REGEX_COMPLAIN_MARKER; + this->IncludeRegexComplainString += complainRegex; + + this->SetupTransforms(); + + this->CacheFileName = this->TargetDirectory; + this->CacheFileName += "/"; + this->CacheFileName += lang; + this->CacheFileName += ".includecache"; + this->ReadCacheFile(); } @@ -80,11 +112,6 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj, cmSystemTools::Error("Cannot scan dependencies without an object file."); return false; } - if(!this->IncludePath) - { - cmSystemTools::Error("Cannot scan dependencies without an include path."); - return false; - } // Walk the dependency graph starting with the source file. bool first = true; @@ -138,7 +165,7 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj, cacheKey += current.FileName; for(std::vector::const_iterator i = - this->IncludePath->begin(); i != this->IncludePath->end(); ++i) + this->IncludePath.begin(); i != this->IncludePath.end(); ++i) { cacheKey+=*i; } @@ -149,7 +176,7 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj, fullName=headerLocationIt->second; } else for(std::vector::const_iterator i = - this->IncludePath->begin(); i != this->IncludePath->end(); ++i) + this->IncludePath.begin(); i != this->IncludePath.end(); ++i) { // Construct the name of the file as if it were in the current // include directory. Avoid using a leading "./". @@ -317,6 +344,13 @@ void cmDependsC::ReadCacheFile() return; } } + else if (line.find(INCLUDE_REGEX_TRANSFORM_MARKER) == 0) + { + if (line != this->IncludeRegexTransformString) + { + return; + } + } } } else if (cacheEntry!=0) @@ -351,6 +385,7 @@ void cmDependsC::WriteCacheFile() const cacheOut << this->IncludeRegexLineString << "\n\n"; cacheOut << this->IncludeRegexScanString << "\n\n"; cacheOut << this->IncludeRegexComplainString << "\n\n"; + cacheOut << this->IncludeRegexTransformString << "\n\n"; for (std::map::const_iterator fileIt= this->FileCache.begin(); @@ -391,6 +426,12 @@ void cmDependsC::Scan(std::istream& is, const char* directory, std::string line; while(cmSystemTools::GetLineFromStream(is, line)) { + // Transform the line content first. + if(!this->TransformRules.empty()) + { + this->TransformLine(line); + } + // Match include directives. if(this->IncludeRegexLine.find(line.c_str())) { @@ -427,3 +468,100 @@ void cmDependsC::Scan(std::istream& is, const char* directory, } } } + +//---------------------------------------------------------------------------- +void cmDependsC::SetupTransforms() +{ + // Get the transformation rules. + std::vector transformRules; + cmMakefile* mf = this->LocalGenerator->GetMakefile(); + if(const char* xform = + mf->GetDefinition("CMAKE_INCLUDE_TRANSFORMS")) + { + cmSystemTools::ExpandListArgument(xform, transformRules, true); + } + for(std::vector::const_iterator tri = transformRules.begin(); + tri != transformRules.end(); ++tri) + { + this->ParseTransform(*tri); + } + + this->IncludeRegexTransformString = INCLUDE_REGEX_TRANSFORM_MARKER; + if(!this->TransformRules.empty()) + { + // Construct the regular expression to match lines to be + // transformed. + std::string xform = "^([ \t]*#[ \t]*(include|import)[ \t]*)("; + const char* sep = ""; + for(TransformRulesType::const_iterator tri = this->TransformRules.begin(); + tri != this->TransformRules.end(); ++tri) + { + xform += sep; + xform += tri->first; + sep = "|"; + } + xform += ")[ \t]*\\(([^),]*)\\)"; + this->IncludeRegexTransform.compile(xform.c_str()); + + // Build a string that encodes all transformation rules and will + // change when rules are changed. + this->IncludeRegexTransformString += xform; + for(TransformRulesType::const_iterator tri = this->TransformRules.begin(); + tri != this->TransformRules.end(); ++tri) + { + this->IncludeRegexTransformString += " "; + this->IncludeRegexTransformString += tri->first; + this->IncludeRegexTransformString += "(%)="; + this->IncludeRegexTransformString += tri->second; + } + } +} + +//---------------------------------------------------------------------------- +void cmDependsC::ParseTransform(std::string const& xform) +{ + // A transform rule is of the form SOME_MACRO(%)=value-with-% + // We can simply separate with "(%)=". + std::string::size_type pos = xform.find("(%)="); + if(pos == xform.npos || pos == 0) + { + return; + } + std::string name = xform.substr(0, pos); + std::string value = xform.substr(pos+4, xform.npos); + this->TransformRules[name] = value; +} + +//---------------------------------------------------------------------------- +void cmDependsC::TransformLine(std::string& line) +{ + // Check for a transform rule match. Return if none. + if(!this->IncludeRegexTransform.find(line.c_str())) + { + return; + } + TransformRulesType::const_iterator tri = + this->TransformRules.find(this->IncludeRegexTransform.match(3)); + if(tri == this->TransformRules.end()) + { + return; + } + + // Construct the transformed line. + std::string newline = this->IncludeRegexTransform.match(1); + std::string arg = this->IncludeRegexTransform.match(4); + for(const char* c = tri->second.c_str(); *c; ++c) + { + if(*c == '%') + { + newline += arg; + } + else + { + newline += *c; + } + } + + // Return the transformed line. + line = newline; +} diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h index 41db42081..9190c8730 100644 --- a/Source/cmDependsC.h +++ b/Source/cmDependsC.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDependsC.h,v $ Language: C++ - Date: $Date: 2007-02-05 14:48:38 $ - Version: $Revision: 1.20 $ + Date: $Date: 2008-05-15 19:39:50 $ + Version: $Revision: 1.20.10.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -30,9 +30,7 @@ public: /** Checking instances need to know the build directory name and the relative path from the build directory to the target file. */ cmDependsC(); - cmDependsC(std::vector const& includes, - const char* scanRegex, const char* complainRegex, - const cmStdString& cachFileName); + cmDependsC(cmLocalGenerator* lg, const char* targetDir, const char* lang); /** Virtual destructor to cleanup subclasses properly. */ virtual ~cmDependsC(); @@ -50,9 +48,6 @@ protected: void Scan(std::istream& is, const char* directory, const cmStdString& fullName); - // The include file search path. - std::vector const* IncludePath; - // Regular expression to identify C preprocessor include directives. cmsys::RegularExpression IncludeRegexLine; @@ -60,9 +55,18 @@ protected: // recursively and which to complain about not finding. cmsys::RegularExpression IncludeRegexScan; cmsys::RegularExpression IncludeRegexComplain; - const std::string IncludeRegexLineString; - const std::string IncludeRegexScanString; - const std::string IncludeRegexComplainString; + std::string IncludeRegexLineString; + std::string IncludeRegexScanString; + std::string IncludeRegexComplainString; + + // Regex to transform #include lines. + std::string IncludeRegexTransformString; + cmsys::RegularExpression IncludeRegexTransform; + typedef std::map TransformRulesType; + TransformRulesType TransformRules; + void SetupTransforms(); + void ParseTransform(std::string const& xform); + void TransformLine(std::string& line); public: // Data structures for dependency graph walk. diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 9347966cf..307b0f565 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDependsFortran.cxx,v $ Language: C++ - Date: $Date: 2008-04-21 19:21:57 $ - Version: $Revision: 1.46.2.1 $ + Date: $Date: 2008-05-15 19:39:50 $ + Version: $Revision: 1.46.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -131,17 +131,25 @@ public: //---------------------------------------------------------------------------- cmDependsFortran::cmDependsFortran(): - IncludePath(0), PPDefinitions(0), Internal(0) + PPDefinitions(0), Internal(0) { } //---------------------------------------------------------------------------- cmDependsFortran -::cmDependsFortran(std::vector const& includes, - std::vector const& definitions): - IncludePath(&includes), +::cmDependsFortran(cmLocalGenerator* lg): + cmDepends(lg), Internal(new cmDependsFortranInternals) { + // Get the list of definitions. + std::vector definitions; + cmMakefile* mf = this->LocalGenerator->GetMakefile(); + if(const char* c_defines = + mf->GetDefinition("CMAKE_TARGET_DEFINITIONS")) + { + cmSystemTools::ExpandListArgument(c_defines, definitions); + } + // translate i.e. FOO=BAR to FOO and add it to the list of defined // preprocessor symbols for(std::vector::const_iterator @@ -178,11 +186,6 @@ bool cmDependsFortran::WriteDependencies(const char *src, const char *obj, cmSystemTools::Error("Cannot scan dependencies without an object file."); return false; } - if(!this->IncludePath) - { - cmSystemTools::Error("Cannot scan dependencies without an include path."); - return false; - } // Get the information object for this source. cmDependsFortranSourceInfo& info = @@ -595,7 +598,7 @@ bool cmDependsFortran::FindModule(std::string const& name, // Search the include path for the module. std::string fullName; for(std::vector::const_iterator i = - this->IncludePath->begin(); i != this->IncludePath->end(); ++i) + this->IncludePath.begin(); i != this->IncludePath.end(); ++i) { // Try the lower-case name. fullName = *i; @@ -887,7 +890,7 @@ bool cmDependsFortran::FindIncludeFile(const char* dir, // Search the include path for the file. for(std::vector::const_iterator i = - this->IncludePath->begin(); i != this->IncludePath->end(); ++i) + this->IncludePath.begin(); i != this->IncludePath.end(); ++i) { fullName = *i; fullName += "/"; diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h index dae8ad780..3a9913e60 100644 --- a/Source/cmDependsFortran.h +++ b/Source/cmDependsFortran.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDependsFortran.h,v $ Language: C++ - Date: $Date: 2008-01-09 15:30:10 $ - Version: $Revision: 1.14 $ + Date: $Date: 2008-05-15 19:39:53 $ + Version: $Revision: 1.14.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -36,8 +36,7 @@ public: path from the build directory to the target file, the source file from which to start scanning, the include file search path, and the target directory. */ - cmDependsFortran(std::vector const& includes, - std::vector const& defines); + cmDependsFortran(cmLocalGenerator* lg); /** Virtual destructor to cleanup subclasses properly. */ virtual ~cmDependsFortran(); @@ -85,8 +84,6 @@ protected: // The source file from which to start scanning. std::string SourceFile; - // The include file search path. - std::vector const* IncludePath; std::vector PPDefinitions; // Internal implementation details. diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index a644749d4..25ef0b2ab 100755 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -78,6 +78,13 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "useful for adding special flags and commands based" " on the final build environment. ", false, "Variables that Provide Information"); + cm->DefineProperty + ("CMAKE_CROSSCOMPILING", cmProperty::VARIABLE, + "Is CMake currently cross compiling.", + "This variable will be set to true by CMake if CMake is cross " + "compiling. Specifically if the build platform is different " + "from the target platform.", false, + "Variables that Provide Information"); cm->DefineProperty ("CMAKE_CACHEFILE_DIR", cmProperty::VARIABLE, "The directory with the CMakeCache.txt file.", @@ -417,14 +424,6 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "CMakeLists file.",false, "Variables That Change Behavior"); - cm->DefineProperty - ("CMAKE_CROSSCOMPILING", cmProperty::VARIABLE, - "Is CMake currently cross compiling.", - "This variable will be set to true by CMake if CMake is cross " - "compiling. Specifically if the build platform is different " - "from the target platform.", false, - "Variables That Change Behavior"); - cm->DefineProperty ("CMAKE_INSTALL_PREFIX", cmProperty::VARIABLE, "Install directory used by install.", @@ -443,6 +442,97 @@ void cmDocumentVariables::DefineVariables(cmake* cm) false, "Variables That Change Behavior"); + cm->DefineProperty + ("CMAKE_PREFIX_PATH", cmProperty::VARIABLE, + "Path used for searching by FIND_XXX(), with appropriate suffixes added.", + "Specifies a path which will be used by the FIND_XXX() commands. It " + "contains the \"base\" directories, the FIND_XXX() commands append " + "appropriate subdirectories to the base directories. So FIND_PROGRAM() " + "adds /bin to each of the directories in the path, FIND_LIBRARY() " + "appends /lib to each of the directories, and FIND_PATH() and " + "FIND_FILE() append /include . By default it is empty, it is intended " + "to be set by the project. See also CMAKE_SYSTEM_PREFIX_PATH, " + "CMAKE_INCLUDE_PATH, CMAKE_LIBRARY_PATH, CMAKE_PROGRAM_PATH.", false, + "Variables That Change Behavior"); + + cm->DefineProperty + ("CMAKE_INCLUDE_PATH", cmProperty::VARIABLE, + "Path used for searching by FIND_FILE() and FIND_PATH().", + "Specifies a path which will be used both by FIND_FILE() and " + "FIND_PATH(). Both commands will check each of the contained directories " + "for the existence of the file which is currently searched. By default " + "it is empty, it is intended to be set by the project. See also " + "CMAKE_SYSTEM_INCLUDE_PATH, CMAKE_PREFIX_PATH.", false, + "Variables That Change Behavior"); + + cm->DefineProperty + ("CMAKE_LIBRARY_PATH", cmProperty::VARIABLE, + "Path used for searching by FIND_LIBRARY().", + "Specifies a path which will be used by FIND_LIBRARY(). FIND_LIBRARY() " + "will check each of the contained directories for the existence of the " + "library which is currently searched. By default it is empty, it is " + "intended to be set by the project. See also CMAKE_SYSTEM_LIBRARY_PATH, " + "CMAKE_PREFIX_PATH.", false, + "Variables That Change Behavior"); + + cm->DefineProperty + ("CMAKE_PROGRAM_PATH", cmProperty::VARIABLE, + "Path used for searching by FIND_PROGRAM().", + "Specifies a path which will be used by FIND_PROGRAM(). FIND_PROGRAM() " + "will check each of the contained directories for the existence of the " + "program which is currently searched. By default it is empty, it is " + "intended to be set by the project. See also CMAKE_SYSTEM_PROGRAM_PATH, " + " CMAKE_PREFIX_PATH.", false, + "Variables That Change Behavior"); + + cm->DefineProperty + ("CMAKE_SYSTEM_PREFIX_PATH", cmProperty::VARIABLE, + "Path used for searching by FIND_XXX(), with appropriate suffixes added.", + "Specifies a path which will be used by the FIND_XXX() commands. It " + "contains the \"base\" directories, the FIND_XXX() commands append " + "appropriate subdirectories to the base directories. So FIND_PROGRAM() " + "adds /bin to each of the directories in the path, FIND_LIBRARY() " + "appends /lib to each of the directories, and FIND_PATH() and " + "FIND_FILE() append /include . By default this contains the standard " + "directories for the current system. It is NOT intended " + "to be modified by the project, use CMAKE_PREFIX_PATH for this. See also " + "CMAKE_SYSTEM_INCLUDE_PATH, CMAKE_SYSTEM_LIBRARY_PATH, " + "CMAKE_SYSTEM_PROGRAM_PATH.", false, + "Variables That Change Behavior"); + + cm->DefineProperty + ("CMAKE_SYSTEM_INCLUDE_PATH", cmProperty::VARIABLE, + "Path used for searching by FIND_FILE() and FIND_PATH().", + "Specifies a path which will be used both by FIND_FILE() and " + "FIND_PATH(). Both commands will check each of the contained directories " + "for the existence of the file which is currently searched. By default " + "it contains the standard directories for the current system. It is " + "NOT intended to be modified by the project, use CMAKE_INCLUDE_PATH " + "for this. See also CMAKE_SYSTEM_PREFIX_PATH.", false, + "Variables That Change Behavior"); + + cm->DefineProperty + ("CMAKE_SYSTEM_LIBRARY_PATH", cmProperty::VARIABLE, + "Path used for searching by FIND_LIBRARY().", + "Specifies a path which will be used by FIND_LIBRARY(). FIND_LIBRARY() " + "will check each of the contained directories for the existence of the " + "library which is currently searched. By default it contains the " + "standard directories for the current system. It is NOT intended to be " + "modified by the project, use CMAKE_SYSTEM_LIBRARY_PATH for this. See " + "also CMAKE_SYSTEM_PREFIX_PATH.", false, + "Variables That Change Behavior"); + + cm->DefineProperty + ("CMAKE_SYSTEM_PROGRAM_PATH", cmProperty::VARIABLE, + "Path used for searching by FIND_PROGRAM().", + "Specifies a path which will be used by FIND_PROGRAM(). FIND_PROGRAM() " + "will check each of the contained directories for the existence of the " + "program which is currently searched. By default it contains the " + "standard directories for the current system. It is NOT intended to be " + "modified by the project, use CMAKE_PROGRAM_PATH for this. See also " + "CMAKE_SYSTEM_PREFIX_PATH.", false, + "Variables That Change Behavior"); + cm->DefineProperty ("CMAKE_USER_MAKE_RULES_OVERRIDE", cmProperty::VARIABLE, "Specify a file that can change the build rule variables.", @@ -646,6 +736,24 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Set to true when the host system is Windows and on cygwin.",false, "Variables That Describe the System"); + cm->DefineProperty + ("CMAKE_OBJECT_PATH_MAX", cmProperty::VARIABLE, + "Maximum object file full-path length allowed by native build tools.", + "CMake computes for every source file an object file name that is " + "unique to the source file and deterministic with respect to the " + "full path to the source file. " + "This allows multiple source files in a target to share the same name " + "if they lie in different directories without rebuilding when one is " + "added or removed. " + "However, it can produce long full paths in a few cases, so CMake " + "shortens the path using a hashing scheme when the full path to an " + "object file exceeds a limit. " + "CMake has a built-in limit for each platform that is sufficient for " + "common tools, but some native tools may have a lower limit. " + "This variable may be set to specify the limit explicitly. " + "The value must be an integer no less than 128.",false, + "Variables That Describe the System"); + // Variables that affect the building of object files and // targets. // diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 937260bd9..4270fbff3 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDocumentation.cxx,v $ Language: C++ - Date: $Date: 2008-03-05 16:05:20 $ - Version: $Revision: 1.69 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.69.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -656,7 +656,8 @@ cmDocumentation::Form cmDocumentation::GetFormFromFilename( } //---------------------------------------------------------------------------- -bool cmDocumentation::CheckOptions(int argc, const char* const* argv) +bool cmDocumentation::CheckOptions(int argc, const char* const* argv, + const char* exitOpt) { // Providing zero arguments gives usage information. if(argc == 1) @@ -673,6 +674,10 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv) bool result = false; for(int i=1; i < argc; ++i) { + if(exitOpt && strcmp(argv[i], exitOpt) == 0) + { + return result; + } RequestedHelpItem help; // Check if this is a supported help option. if((strcmp(argv[i], "-help") == 0) || @@ -1350,7 +1355,9 @@ void cmDocumentation ::PrintDocumentationCommand(std::ostream& os, const cmDocumentationEntry &entry) { - cmDocumentationSection *sec = new cmDocumentationSection("",""); + // the string "SingleItem" will be used in a few places to detect the case + // that only the documentation for a single item is printed + cmDocumentationSection *sec = new cmDocumentationSection("SingleItem",""); sec->Append(entry); this->AllSections["temp"] = sec; this->ClearSections(); diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index f57bcf8ba..e4594a658 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDocumentation.h,v $ Language: C++ - Date: $Date: 2008-03-04 14:16:33 $ - Version: $Revision: 1.33 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.33.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -45,9 +45,12 @@ public: * Check command line arguments for documentation options. Returns * true if documentation options are found, and false otherwise. * When true is returned, PrintRequestedDocumentation should be - * called. + * called. exitOpt can be used for things like cmake -E, so that + * all arguments after the -E are ignored and not searched for + * help arguments. */ - bool CheckOptions(int argc, const char* const* argv); + bool CheckOptions(int argc, const char* const* argv, + const char* exitOpt =0); /** * Print help requested on the command line. Call after diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx index 06d5d26fe..6372184e7 100644 --- a/Source/cmDocumentationFormatter.cxx +++ b/Source/cmDocumentationFormatter.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDocumentationFormatter.cxx,v $ Language: C++ - Date: $Date: 2008-05-05 17:38:19 $ - Version: $Revision: 1.1.2.1 $ + Date: $Date: 2008-07-22 18:04:24 $ + Version: $Revision: 1.1.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -146,6 +146,10 @@ cmDocumentationFormatter::ComputeSectionLinkPrefix(std::string const& name) { return "see"; } + else if(name.find("SingleItem") != name.npos) + { + return "single_item"; + } else { std::cerr diff --git a/Source/cmDocumentationFormatterDocbook.cxx b/Source/cmDocumentationFormatterDocbook.cxx index 85ede318a..4bfc60f69 100644 --- a/Source/cmDocumentationFormatterDocbook.cxx +++ b/Source/cmDocumentationFormatterDocbook.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDocumentationFormatterDocbook.cxx,v $ Language: C++ - Date: $Date: 2008-05-05 17:38:19 $ - Version: $Revision: 1.1.2.1 $ + Date: $Date: 2008-05-15 19:39:54 $ + Version: $Revision: 1.1.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -144,7 +144,7 @@ void cmDocumentationFormatterDocbook cmDocumentationPrintDocbookEscapes(os, op->Name.c_str()); os << "\">"; cmDocumentationPrintDocbookEscapes(os, op->Name.c_str()); - os << ""; + os << "\n"; } } os << "\n" ; diff --git a/Source/cmDocumentationFormatterHTML.cxx b/Source/cmDocumentationFormatterHTML.cxx index a4b76ada7..793fd15bd 100644 --- a/Source/cmDocumentationFormatterHTML.cxx +++ b/Source/cmDocumentationFormatterHTML.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmDocumentationFormatterHTML.cxx,v $ Language: C++ - Date: $Date: 2008-05-05 17:38:19 $ - Version: $Revision: 1.11.2.1 $ + Date: $Date: 2008-07-22 18:04:24 $ + Version: $Revision: 1.11.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -117,30 +117,37 @@ void cmDocumentationFormatterHTML const cmDocumentationSection §ion, const char* name) { - if(name) - { - os << "

" << name << "

\n"; - } - std::string prefix = this->ComputeSectionLinkPrefix(name); const std::vector &entries = section.GetEntries(); - os << "\n" ; for(std::vector::const_iterator op = entries.begin(); op != entries.end();) @@ -240,6 +247,14 @@ void cmDocumentationFormatterHTML ::PrintIndex(std::ostream& os, std::vector& sections) { + // skip the index if only the help for a single item is printed + if ((sections.size() == 1) + && (sections[0]->GetName(this->GetForm()) != 0 ) + && (std::string(sections[0]->GetName(this->GetForm())) == "SingleItem")) + { + return; + } + os << "

Master Index

\n"; os << "
    \n"; for(unsigned int i=0; i < sections.size(); ++i) diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 1a06e608f..dbb7950f7 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmELF.cxx,v $ Language: C++ - Date: $Date: 2008-04-21 00:44:51 $ - Version: $Revision: 1.8.2.1 $ + Date: $Date: 2008-08-06 21:04:19 $ + Version: $Revision: 1.8.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -20,6 +20,7 @@ #include // Need the native byte order of the running CPU. +#define cmsys_CPU_UNKNOWN_OKAY // We can decide at runtime if not known. #include // Include the ELF format information system header. @@ -84,6 +85,8 @@ public: this->NeedSwap = (this->ByteOrder == ByteOrderMSB); #elif cmsys_CPU_ENDIAN_ID == cmsys_CPU_ENDIAN_ID_BIG this->NeedSwap = (this->ByteOrder == ByteOrderLSB); +#else + this->NeedSwap = false; // Final decision is at runtime anyway. #endif // We have not yet loaded the section info. @@ -881,8 +884,8 @@ cmELF::StringEntry const* cmELF::GetSOName() cmELF::StringEntry const* cmELF::GetRPath() { if(this->Valid() && - this->Internal->GetFileType() == cmELF::FileTypeExecutable || - this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary) + (this->Internal->GetFileType() == cmELF::FileTypeExecutable || + this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) { return this->Internal->GetRPath(); } @@ -896,8 +899,8 @@ cmELF::StringEntry const* cmELF::GetRPath() cmELF::StringEntry const* cmELF::GetRunPath() { if(this->Valid() && - this->Internal->GetFileType() == cmELF::FileTypeExecutable || - this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary) + (this->Internal->GetFileType() == cmELF::FileTypeExecutable || + this->Internal->GetFileType() == cmELF::FileTypeSharedLibrary)) { return this->Internal->GetRunPath(); } diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 08869d651..ed31d3fe8 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmExtraCodeBlocksGenerator.cxx,v $ Language: C++ - Date: $Date: 2007-11-25 12:45:18 $ - Version: $Revision: 1.18 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.18.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2004 Alexander Neundorf neundorf@kde.org, All rights reserved. @@ -93,14 +93,12 @@ void cmExtraCodeBlocksGenerator::Generate() } -/* create the project file, if it already exists, merge it with the -existing one, otherwise create a new one */ +/* create the project file */ void cmExtraCodeBlocksGenerator::CreateProjectFile( const std::vector& lgs) { const cmMakefile* mf=lgs[0]->GetMakefile(); std::string outputDir=mf->GetStartOutputDirectory(); - std::string projectDir=mf->GetHomeDirectory(); std::string projectName=mf->GetProjectName(); std::string filename=outputDir+"/"; @@ -108,16 +106,7 @@ void cmExtraCodeBlocksGenerator::CreateProjectFile( std::string sessionFilename=outputDir+"/"; sessionFilename+=projectName+".layout"; -/* if (cmSystemTools::FileExists(filename.c_str())) - { - this->MergeProjectFiles(outputDir, projectDir, filename, - cmakeFilePattern, sessionFilename); - } - else */ - { - this->CreateNewProjectFile(lgs, filename); - } - + this->CreateNewProjectFile(lgs, filename); } diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index d43fe7c88..19c563348 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmExtraEclipseCDT4Generator.cxx,v $ Language: C++ - Date: $Date: 2008-04-08 16:22:48 $ - Version: $Revision: 1.13.2.1 $ + Date: $Date: 2008-08-06 21:04:19 $ + Version: $Revision: 1.13.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2004 Alexander Neundorf neundorf@kde.org, All rights reserved. @@ -351,7 +351,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() } } // for EXECUTABLE_OUTPUT_PATH when not in binary dir - std::string outputPath = mf->GetDefinition("EXECUTABLE_OUTPUT_PATH"); + std::string outputPath = mf->GetSafeDefinition("EXECUTABLE_OUTPUT_PATH"); if (!outputPath.empty() && !cmSystemTools::IsSubDirectory( outputPath.c_str(), this->HomeOutputDirectory.c_str())) { @@ -368,9 +368,9 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() this->OutLinkedResources.push_back(name); } // for LIBRARY_OUTPUT_PATH when not in binary dir - if (outputPath != mf->GetDefinition("LIBRARY_OUTPUT_PATH")) + if (outputPath != mf->GetSafeDefinition("LIBRARY_OUTPUT_PATH")) { - outputPath = mf->GetDefinition("LIBRARY_OUTPUT_PATH"); + outputPath = mf->GetSafeDefinition("LIBRARY_OUTPUT_PATH"); if (!outputPath.empty() && !cmSystemTools::IsSubDirectory( outputPath.c_str(), this->HomeOutputDirectory.c_str())) { diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index e0bd0b6b3..dd5c13717 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFLTKWrapUICommand.cxx,v $ Language: C++ - Date: $Date: 2008-01-23 15:27:59 $ - Version: $Revision: 1.38 $ + Date: $Date: 2008-06-25 13:51:32 $ + Version: $Revision: 1.38.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -121,8 +121,20 @@ void cmFLTKWrapUICommand::FinalPass() // people should add the srcs to the target themselves, but the old command // didn't support that, so check and see if they added the files in and if // they didn;t then print a warning and add then anyhow + cmTarget* target = this->Makefile->FindTarget(this->Target.c_str()); + if(!target) + { + std::string msg = + "FLTK_WRAP_UI was called with a target that was never created: "; + msg += this->Target; + msg +=". The problem was found while processing the source directory: "; + msg += this->Makefile->GetStartDirectory(); + msg += ". This FLTK_WRAP_UI call will be ignored."; + cmSystemTools::Message(msg.c_str(),"Warning"); + return; + } std::vector const& srcs = - this->Makefile->GetTargets()[this->Target].GetSourceFiles(); + target->GetSourceFiles(); bool found = false; for (unsigned int i = 0; i < srcs.size(); ++i) { diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 55463598b..aaf765ad8 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFileCommand.cxx,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:39 $ - Version: $Revision: 1.103.2.3 $ + Date: $Date: 2008-09-12 14:56:20 $ + Version: $Revision: 1.103.2.7 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -578,7 +578,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) { // Ignore CR character to make output always have UNIX newlines. } - else if(c >= 0x20 && c < 0x7F || c == '\t' || + else if(c >= 0x20 && c < 0x7F || c == '\t' || c == '\f' || (c == '\n' && newline_consume)) { // This is an ASCII character that may be part of a string. @@ -668,10 +668,43 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, i++; cmsys::Glob g; g.SetRecurse(recurse); + + bool explicitFollowSymlinks = false; + cmPolicies::PolicyStatus status = + this->Makefile->GetPolicyStatus(cmPolicies::CMP0009); + if(recurse) + { + switch(status) + { + case cmPolicies::NEW: + g.RecurseThroughSymlinksOff(); + break; + case cmPolicies::OLD: + case cmPolicies::WARN: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + g.RecurseThroughSymlinksOn(); + break; + } + } + std::string output = ""; bool first = true; for ( ; i != args.end(); ++i ) { + if ( recurse && (*i == "FOLLOW_SYMLINKS") ) + { + explicitFollowSymlinks = true; + g.RecurseThroughSymlinksOn(); + ++i; + if ( i == args.end() ) + { + this->SetError( + "GLOB_RECURSE requires a glob expression after FOLLOW_SYMLINKS"); + return false; + } + } + if ( *i == "RELATIVE" ) { ++i; // skip RELATIVE @@ -688,6 +721,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, return false; } } + if ( !cmsys::SystemTools::FileIsFullPath(i->c_str()) ) { std::string expr = this->Makefile->GetCurrentDirectory(); @@ -706,6 +740,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, { g.FindFiles(*i); } + std::vector::size_type cc; std::vector& files = g.GetFiles(); for ( cc = 0; cc < files.size(); cc ++ ) @@ -718,6 +753,37 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, first = false; } } + + if(recurse && !explicitFollowSymlinks) + { + switch (status) + { + case cmPolicies::NEW: + // Correct behavior, yay! + break; + case cmPolicies::OLD: + // Probably not really the expected behavior, but the author explicitly + // asked for the old behavior... no warning. + case cmPolicies::WARN: + // Possibly unexpected old behavior *and* we actually traversed + // symlinks without being explicitly asked to: warn the author. + if(g.GetFollowedSymlinkCount() != 0) + { + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, + this->Makefile->GetPolicies()-> + GetPolicyWarning(cmPolicies::CMP0009)); + } + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + this->SetError("policy CMP0009 error"); + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + this->Makefile->GetPolicies()-> + GetRequiredPolicyError(cmPolicies::CMP0009)); + return false; + } + } + this->Makefile->AddDefinition(variable.c_str(), output.c_str()); return true; } @@ -1411,7 +1477,8 @@ cmFileCommand::HandleRPathChangeCommand(std::vector const& args) cmSystemToolsFileTime* ft = cmSystemTools::FileTimeNew(); bool have_ft = cmSystemTools::FileTimeGet(file, ft); std::string emsg; - if(!cmSystemTools::ChangeRPath(file, oldRPath, newRPath, &emsg)) + bool changed; + if(!cmSystemTools::ChangeRPath(file, oldRPath, newRPath, &emsg, &changed)) { cmOStringStream e; e << "RPATH_CHANGE could not write new RPATH:\n" @@ -1422,9 +1489,21 @@ cmFileCommand::HandleRPathChangeCommand(std::vector const& args) this->SetError(e.str().c_str()); success = false; } - if(success && have_ft) + if(success) { - cmSystemTools::FileTimeSet(file, ft); + if(changed) + { + std::string message = "Set runtime path of \""; + message += file; + message += "\" to \""; + message += newRPath; + message += "\""; + this->Makefile->DisplayStatus(message.c_str(), -1); + } + if(have_ft) + { + cmSystemTools::FileTimeSet(file, ft); + } } cmSystemTools::FileTimeDelete(ft); return success; @@ -1473,7 +1552,8 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector const& args) cmSystemToolsFileTime* ft = cmSystemTools::FileTimeNew(); bool have_ft = cmSystemTools::FileTimeGet(file, ft); std::string emsg; - if(!cmSystemTools::RemoveRPath(file, &emsg)) + bool removed; + if(!cmSystemTools::RemoveRPath(file, &emsg, &removed)) { cmOStringStream e; e << "RPATH_REMOVE could not remove RPATH from file:\n" @@ -1482,9 +1562,19 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector const& args) this->SetError(e.str().c_str()); success = false; } - if(success && have_ft) + if(success) { - cmSystemTools::FileTimeSet(file, ft); + if(removed) + { + std::string message = "Removed runtime path from \""; + message += file; + message += "\""; + this->Makefile->DisplayStatus(message.c_str(), -1); + } + if(have_ft) + { + cmSystemTools::FileTimeSet(file, ft); + } } cmSystemTools::FileTimeDelete(ft); return success; diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index 89ff7ba7a..96ee8ba41 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFileCommand.h,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:39 $ - Version: $Revision: 1.35.2.2 $ + Date: $Date: 2008-09-12 14:56:20 $ + Version: $Revision: 1.35.2.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -77,7 +77,7 @@ public: " [NO_HEX_CONVERSION])\n" " file(GLOB variable [RELATIVE path] [globbing expressions]...)\n" " file(GLOB_RECURSE variable [RELATIVE path] \n" - " [globbing expressions]...)\n" + " [FOLLOW_SYMLINKS] [globbing expressions]...)\n" " file(REMOVE [file1 ...])\n" " file(REMOVE_RECURSE [file1 ...])\n" " file(MAKE_DIRECTORY [directory1 directory2 ...])\n" @@ -124,9 +124,11 @@ public: " *.cxx - match all files with extension cxx\n" " *.vt? - match all files with extension vta,...,vtz\n" " f[3-5].txt - match files f3.txt, f4.txt, f5.txt\n" - "GLOB_RECURSE will generate similar list as the regular GLOB, except " + "GLOB_RECURSE will generate a list similar to the regular GLOB, except " "it will traverse all the subdirectories of the matched directory and " - "match the files.\n" + "match the files. Subdirectories that are symlinks are only traversed " + "if FOLLOW_SYMLINKS is given or cmake policy CMP0009 is not set to NEW. " + "See cmake --help-policy CMP0009 for more information.\n" "Examples of recursive globbing include:\n" " /dir/*.py - match all python files in /dir and subdirectories\n" "MAKE_DIRECTORY will create the given directories, also if their parent " diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index 868008fae..af71497e3 100755 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindBase.cxx,v $ Language: C++ - Date: $Date: 2008-04-08 16:22:49 $ - Version: $Revision: 1.35.2.1 $ + Date: $Date: 2008-06-13 12:55:17 $ + Version: $Revision: 1.35.2.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -30,6 +30,7 @@ cmFindBase::cmFindBase() " FIND_XXX(\n" " \n" " name | NAMES name1 [name2 ...]\n" + " [HINTS path1 [path2 ... ENV var]]\n" " [PATHS path1 [path2 ... ENV var]]\n" " [PATH_SUFFIXES suffix1 [suffix2 ...]]\n" " [DOC \"cache documentation string\"]\n" @@ -55,7 +56,7 @@ cmFindBase::cmFindBase() "is searched for is specified by the names listed " "after the NAMES argument. Additional search locations " "can be specified after the PATHS argument. If ENV var is " - "found in the PATHS section the environment variable var " + "found in the HINTS or PATHS section the environment variable var " "will be read and converted from a system environment variable to " "a cmake style list of paths. For example ENV PATH would be a way " "to list the system path variable. The argument " @@ -65,33 +66,35 @@ cmFindBase::cmFindBase() "If NO_DEFAULT_PATH is specified, then no additional paths are " "added to the search. " "If NO_DEFAULT_PATH is not specified, the search process is as follows:\n" - "1. Search cmake specific environment variables. This " - "can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.\n" - "" + "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_SUBDIR for each in CMAKE_PREFIX_PATH\n" " CMAKE_XXX_PATH\n" " CMAKE_XXX_MAC_PATH\n" - "2. Search cmake variables with the same names as " - "the cmake specific environment 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" - "" + "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_SUBDIR for each in CMAKE_PREFIX_PATH\n" " CMAKE_XXX_PATH\n" " CMAKE_XXX_MAC_PATH\n" - "3. Search the standard system environment variables. " + "3. Search the paths specified by the HINTS option. " + "These should be paths computed by system introspection, such as a " + "hint provided by the location of another item already found. " + "Hard-coded guesses should be specified with the PATHS option.\n" + "4. Search the standard system environment variables. " "This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is an argument.\n" " PATH\n" " XXX_SYSTEM\n" // replace with "", LIB, or INCLUDE - "4. Search cmake variables defined in the Platform files " + "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_SUBDIR for each in CMAKE_SYSTEM_PREFIX_PATH\n" " CMAKE_SYSTEM_XXX_PATH\n" " CMAKE_SYSTEM_XXX_MAC_PATH\n" - "5. Search the paths specified after PATHS or in the short-hand version " - "of the command.\n" + "6. Search the paths specified by the PATHS option " + "or in the short-hand version of the command. " + "These are typically hard-coded guesses.\n" ; this->GenericDocumentation += this->GenericDocumentationMacPolicy; this->GenericDocumentation += this->GenericDocumentationRootPath; @@ -161,65 +164,61 @@ bool cmFindBase::ParseArguments(std::vector const& argsIn) // Find the current bundle/framework search policy. this->SelectDefaultMacMode(); - std::vector userPaths; - std::string doc; - bool doingNames = true; // assume it starts with a name - bool doingPaths = false; - bool doingPathSuf = false; bool newStyle = false; - + enum Doing { DoingNone, DoingNames, DoingPaths, DoingPathSuffixes, + DoingHints }; + Doing doing = DoingNames; // assume it starts with a name for (unsigned int j = 1; j < args.size(); ++j) { if(args[j] == "NAMES") { - doingNames = true; + doing = DoingNames; newStyle = true; - doingPathSuf = false; - doingPaths = false; } else if (args[j] == "PATHS") { - doingPaths = true; + doing = DoingPaths; + newStyle = true; + } + else if (args[j] == "HINTS") + { + doing = DoingHints; newStyle = true; - doingNames = false; - doingPathSuf = false; } else if (args[j] == "PATH_SUFFIXES") { + doing = DoingPathSuffixes; compatibility = false; - doingPathSuf = true; newStyle = true; - doingNames = false; - doingPaths = false; } else if (args[j] == "NO_SYSTEM_PATH") { - doingPaths = false; - doingPathSuf = false; - doingNames = false; + doing = DoingNone; this->NoDefaultPath = true; } else if (this->CheckCommonArgument(args[j])) { + doing = DoingNone; compatibility = false; - doingPaths = false; - doingPathSuf = false; - doingNames = false; + // Some common arguments were accidentally supported by CMake + // 2.4 and 2.6.0 in the short-hand form of the command, so we + // must support it even though it is not documented. } - else + else if(doing == DoingNames) { - if(doingNames) - { - this->Names.push_back(args[j]); - } - else if(doingPaths) - { - userPaths.push_back(args[j]); - } - else if(doingPathSuf) - { - this->AddPathSuffix(args[j]); - } + this->Names.push_back(args[j]); + } + else if(doing == DoingPaths) + { + this->AddUserPath(args[j], this->UserPaths); + } + else if(doing == DoingHints) + { + this->AddUserPath(args[j], this->UserHints); + } + else if(doing == DoingPathSuffixes) + { + this->AddPathSuffix(args[j]); } } @@ -262,96 +261,42 @@ bool cmFindBase::ParseArguments(std::vector const& argsIn) // FIND_*(VAR name path1 path2 ...) if(!newStyle) { + // All the short-hand arguments have been recorded as names. + std::vector shortArgs = this->Names; this->Names.clear(); // clear out any values in Names - this->Names.push_back(args[1]); - for(unsigned int j = 2; j < args.size(); ++j) + this->Names.push_back(shortArgs[0]); + for(unsigned int j = 1; j < shortArgs.size(); ++j) { - userPaths.push_back(args[j]); + this->AddUserPath(shortArgs[j], this->UserPaths); } } - this->ExpandPaths(userPaths); + this->ExpandPaths(); // Handle search root stuff. this->RerootPaths(this->SearchPaths); + + // Add a trailing slash to all prefixes to aid the search process. + this->AddTrailingSlashes(this->SearchPaths); + return true; } -void cmFindBase::ExpandPaths(std::vector userPaths) +void cmFindBase::ExpandPaths() { - // if NO Default paths was not specified add the - // standard search paths. - if(!this->NoDefaultPath) - { - if(this->SearchFrameworkFirst || this->SearchFrameworkOnly) - { - this->AddFrameWorkPaths(); - } - if(this->SearchAppBundleFirst || this->SearchAppBundleOnly) - { - this->AddAppBundlePaths(); - } - if(!this->NoCMakeEnvironmentPath && - !(this->SearchFrameworkOnly || this->SearchAppBundleOnly)) - { - // Add CMAKE_*_PATH environment variables - this->AddEnvironmentVariables(); - } - if(!this->NoCMakePath && - !(this->SearchFrameworkOnly || this->SearchAppBundleOnly)) - { - // Add CMake varibles of the same name as the previous environment - // varibles CMAKE_*_PATH to be used most of the time with -D - // command line options - this->AddCMakeVariables(); - } - if(!this->NoSystemEnvironmentPath && - !(this->SearchFrameworkOnly || this->SearchAppBundleOnly)) - { - // add System environment PATH and (LIB or INCLUDE) - this->AddSystemEnvironmentVariables(); - } - if(!this->NoCMakeSystemPath && - !(this->SearchFrameworkOnly || this->SearchAppBundleOnly)) - { - // Add CMAKE_SYSTEM_*_PATH variables which are defined in platform files - this->AddCMakeSystemVariables(); - } - if(this->SearchAppBundleLast) - { - this->AddAppBundlePaths(); - } - if(this->SearchFrameworkLast) - { - this->AddFrameWorkPaths(); - } - } - std::vector paths; - // add the paths specified in the FIND_* call - for(unsigned int i =0; i < userPaths.size(); ++i) - { - paths.push_back(userPaths[i]); - } - this->AddPaths(paths); -} + this->AddCMakeVariablePath(); + this->AddCMakeEnvironmentPath(); + this->AddUserHintsPath(); + this->AddSystemEnvironmentPath(); + this->AddCMakeSystemVariablePath(); + this->AddUserGuessPath(); -//---------------------------------------------------------------------------- -void cmFindBase::AddEnvironmentVariables() -{ - std::vector paths; - - std::vector prefixPaths; - cmSystemTools::GetPath(prefixPaths, "CMAKE_PREFIX_PATH"); - this->AddFindPrefix(paths, prefixPaths); - - std::string var = "CMAKE_"; - var += this->CMakePathName; - var += "_PATH"; - cmSystemTools::GetPath(paths, var.c_str()); - this->AddPaths(paths); + // Add suffixes and clean up paths. + this->AddPathSuffixes(); } -void cmFindBase::AddFindPrefix(std::vector& dest, - const std::vector& src) +//---------------------------------------------------------------------------- +void cmFindBase::AddPrefixPaths(std::vector const& in_paths, + PathType pathType) { // default for programs std::string subdir = "bin"; @@ -369,118 +314,154 @@ void cmFindBase::AddFindPrefix(std::vector& dest, subdir = ""; // ? what to do for frameworks ? } - for (std::vector::const_iterator it = src.begin(); - it != src.end(); - ++it) + for(std::vector::const_iterator it = in_paths.begin(); + it != in_paths.end(); ++it) { std::string dir = it->c_str(); if(!subdir.empty() && !dir.empty() && dir[dir.size()-1] != '/') { dir += "/"; } - dest.push_back(dir + subdir); + std::string add = dir + subdir; + if(add != "/") + { + this->AddPathInternal(add, pathType); + } if (subdir == "bin") { - dest.push_back(dir + "sbin"); + this->AddPathInternal(dir+"sbin", pathType); } - if(!subdir.empty()) + if(!subdir.empty() && *it != "/") { - dest.push_back(*it); + this->AddPathInternal(*it, pathType); } } } -void cmFindBase::AddFrameWorkPaths() +//---------------------------------------------------------------------------- +void cmFindBase::AddCMakePrefixPath(const char* variable) { - std::vector paths; - this->GetFrameworkPaths(paths); - this->AddPaths(paths); + // Get a path from a CMake variable. + if(const char* varPath = this->Makefile->GetDefinition(variable)) + { + std::vector tmp; + cmSystemTools::ExpandListArgument(varPath, tmp); + this->AddPrefixPaths(tmp, CMakePath); + } } -void cmFindBase::AddPaths(std::vector & paths) +//---------------------------------------------------------------------------- +void cmFindBase::AddEnvPrefixPath(const char* variable) { - // add suffixes and clean up paths - this->ExpandRegistryAndCleanPath(paths); - // add the paths to the search paths - this->SearchPaths.insert(this->SearchPaths.end(), - paths.begin(), - paths.end()); + // Get a path from the environment. + std::vector tmp; + cmSystemTools::GetPath(tmp, variable); + this->AddPrefixPaths(tmp, EnvPath); } -void cmFindBase::AddAppBundlePaths() +//---------------------------------------------------------------------------- +void cmFindBase::AddCMakeEnvironmentPath() { - std::vector paths; - this->GetAppBundlePaths(paths); - this->AddPaths(paths); -} - -void cmFindBase::AddCMakeVariables() -{ - std::string var = "CMAKE_"; - var += this->CMakePathName; - var += "_PATH"; - std::vector paths; - - if(const char* prefixPath = - this->Makefile->GetDefinition("CMAKE_PREFIX_PATH")) + if(!this->NoCMakeEnvironmentPath && !this->NoDefaultPath) { - std::vector prefixPaths; - cmSystemTools::ExpandListArgument(prefixPath, prefixPaths); - this->AddFindPrefix(paths, prefixPaths); + // Add CMAKE_*_PATH environment variables + std::string var = "CMAKE_"; + var += this->CMakePathName; + var += "_PATH"; + this->AddEnvPrefixPath("CMAKE_PREFIX_PATH"); + this->AddEnvPath(var.c_str()); + + if(this->CMakePathName == "PROGRAM") + { + this->AddEnvPath("CMAKE_APPBUNDLE_PATH"); + } + else + { + this->AddEnvPath("CMAKE_FRAMEWORK_PATH"); + } } +} - if(const char* path = this->Makefile->GetDefinition(var.c_str())) +//---------------------------------------------------------------------------- +void cmFindBase::AddCMakeVariablePath() +{ + if(!this->NoCMakePath && !this->NoDefaultPath) { - cmSystemTools::ExpandListArgument(path, paths); - } - this->AddPaths(paths); + // Add CMake varibles of the same name as the previous environment + // varibles CMAKE_*_PATH to be used most of the time with -D + // command line options + std::string var = "CMAKE_"; + var += this->CMakePathName; + var += "_PATH"; + this->AddCMakePrefixPath("CMAKE_PREFIX_PATH"); + this->AddCMakePath(var.c_str()); + + if(this->CMakePathName == "PROGRAM") + { + this->AddCMakePath("CMAKE_APPBUNDLE_PATH"); + } + else + { + this->AddCMakePath("CMAKE_FRAMEWORK_PATH"); + } + } } -void cmFindBase::AddSystemEnvironmentVariables() +//---------------------------------------------------------------------------- +void cmFindBase::AddSystemEnvironmentPath() { - // Add LIB or INCLUDE - std::vector paths; - if(this->EnvironmentPath.size()) + if(!this->NoSystemEnvironmentPath && !this->NoDefaultPath) { - cmSystemTools::GetPath(paths, this->EnvironmentPath.c_str()); + // Add LIB or INCLUDE + if(!this->EnvironmentPath.empty()) + { + this->AddEnvPath(this->EnvironmentPath.c_str()); + } + // Add PATH + this->AddEnvPath(0); } - // Add PATH - cmSystemTools::GetPath(paths); - this->AddPaths(paths); } -void cmFindBase::AddCMakeSystemVariables() -{ - std::string var = "CMAKE_SYSTEM_"; - var += this->CMakePathName; - var += "_PATH"; - std::vector paths; - if(const char* prefixPath = - this->Makefile->GetDefinition("CMAKE_SYSTEM_PREFIX_PATH")) +//---------------------------------------------------------------------------- +void cmFindBase::AddCMakeSystemVariablePath() +{ + if(!this->NoCMakeSystemPath && !this->NoDefaultPath) { - std::vector prefixPaths; - cmSystemTools::ExpandListArgument(prefixPath, prefixPaths); - this->AddFindPrefix(paths, prefixPaths); + std::string var = "CMAKE_SYSTEM_"; + var += this->CMakePathName; + var += "_PATH"; + this->AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH"); + this->AddCMakePath(var.c_str()); + + if(this->CMakePathName == "PROGRAM") + { + this->AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH"); + } + else + { + this->AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH"); + } } - if(const char* path = this->Makefile->GetDefinition(var.c_str())) - { - cmSystemTools::ExpandListArgument(path, paths); - } - this->AddPaths(paths); } -void cmFindBase::ExpandRegistryAndCleanPath(std::vector& paths) +//---------------------------------------------------------------------------- +void cmFindBase::AddUserHintsPath() +{ + this->AddPathsInternal(this->UserHints, CMakePath); +} + +//---------------------------------------------------------------------------- +void cmFindBase::AddUserGuessPath() { - std::vector finalPath; + this->AddPathsInternal(this->UserPaths, CMakePath); +} + +//---------------------------------------------------------------------------- +void cmFindBase::AddPathSuffixes() +{ + std::vector& paths = this->SearchPaths; + std::vector finalPath = paths; std::vector::iterator i; - // glob and expand registry stuff from paths and put - // into finalPath - for(i = paths.begin(); - i != paths.end(); ++i) - { - cmSystemTools::ExpandRegistryValues(*i); - cmSystemTools::GlobDirs(i->c_str(), finalPath); - } // clear the path paths.clear(); // convert all paths to unix slashes and add search path suffixes diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h index 52ac2070c..8ee310176 100755 --- a/Source/cmFindBase.h +++ b/Source/cmFindBase.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindBase.h,v $ Language: C++ - Date: $Date: 2008-01-17 14:02:31 $ - Version: $Revision: 1.13 $ + Date: $Date: 2008-06-13 12:55:17 $ + Version: $Revision: 1.13.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -41,19 +41,9 @@ public: protected: void PrintFindStuff(); - void ExpandPaths(std::vector userPaths); + void ExpandPaths(); + void AddPathSuffixes(); - // add to the SearchPaths - void AddPaths(std::vector& paths); - void AddFrameWorkPaths(); - void AddAppBundlePaths(); - void AddEnvironmentVariables(); - void AddFindPrefix(std::vector& dest, - const std::vector& src); - void AddCMakeVariables(); - void AddSystemEnvironmentVariables(); - void AddCMakeSystemVariables(); - void ExpandRegistryAndCleanPath(std::vector& paths); // see if the VariableName is already set in the cache, // also copy the documentation from the cache to VariableDocumentation // if it has documentation in the cache @@ -64,13 +54,26 @@ protected: cmStdString VariableDocumentation; cmStdString VariableName; std::vector Names; - std::vector SearchPaths; // CMAKE_*_PATH CMAKE_SYSTEM_*_PATH FRAMEWORK|LIBRARY|INCLUDE|PROGRAM cmStdString EnvironmentPath; // LIB,INCLUDE bool AlreadyInCache; bool AlreadyInCacheWithoutMetaInfo; +private: + // Add pieces of the search. + void AddCMakeEnvironmentPath(); + void AddCMakeVariablePath(); + void AddSystemEnvironmentPath(); + void AddCMakeSystemVariablePath(); + void AddUserHintsPath(); + void AddUserGuessPath(); + + // Helpers. + void AddCMakePrefixPath(const char* variable); + void AddEnvPrefixPath(const char* variable); + void AddPrefixPaths(std::vector const& in_paths, + PathType pathType); }; diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index b242eb385..ebbb8120c 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindCommon.cxx,v $ Language: C++ - Date: $Date: 2008-01-17 14:02:31 $ - Version: $Revision: 1.1 $ + Date: $Date: 2008-06-13 12:55:17 $ + Version: $Revision: 1.1.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -76,14 +76,14 @@ cmFindCommon::cmFindCommon() "then CMAKE_FIND_ROOT_PATH will not be used. If ONLY_CMAKE_FIND_ROOT_PATH " "is used then only the re-rooted directories will be searched.\n"; this->GenericDocumentationPathsOrder = - "The reason the paths listed in the call to the command are searched " - "last is that most users of CMake would expect things to be found " - "first in the locations specified by their environment. Projects may " - "override this behavior by simply calling the command twice:\n" + "The default search order is designed to be most-specific to " + "least-specific for common use cases. " + "Projects may override the order by simply calling the command " + "multiple times and using the NO_* options:\n" " FIND_XXX(FIND_ARGS_XXX PATHS paths... NO_DEFAULT_PATH)\n" " FIND_XXX(FIND_ARGS_XXX)\n" - "Once one of these calls succeeds the result variable will be set " - "and stored in the cache so that neither call will search again."; + "Once one of the calls succeeds the result variable will be set " + "and stored in the cache so that no call will search again."; } //---------------------------------------------------------------------------- @@ -322,93 +322,40 @@ void cmFindCommon::AddPathSuffix(std::string const& arg) } //---------------------------------------------------------------------------- -void cmFindCommon::GetAppBundlePaths(std::vector& paths) +void cmFindCommon::AddUserPath(std::string const& p, + std::vector& paths) { - if(this->NoDefaultPath) - { - return; - } - std::vector tmp; - - // first environment variables - if(!this->NoCMakeEnvironmentPath) - { - cmSystemTools::GetPath(tmp, "CMAKE_APPBUNDLE_PATH"); - this->AddPathsInternal(paths, tmp, EnvPath); - tmp.clear(); - } - - // add cmake variables - if(!this->NoCMakePath) - { - if(const char* path = - this->Makefile->GetDefinition("CMAKE_APPBUNDLE_PATH")) - { - cmSystemTools::ExpandListArgument(path, tmp); - this->AddPathsInternal(paths, tmp, CMakePath); - tmp.clear(); - } - } - - // add cmake system variables - if(!this->NoCMakeSystemPath) - { - if(const char* path = - this->Makefile->GetDefinition("CMAKE_SYSTEM_APPBUNDLE_PATH")) + // We should view the registry as the target application would view + // it. + cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32; + cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64; + if(const char* psize = + this->Makefile->GetDefinition("CMAKE_SIZEOF_VOID_P")) + { + if(atoi(psize) == 8) { - cmSystemTools::ExpandListArgument(path, tmp); - this->AddPathsInternal(paths, tmp, CMakePath); - tmp.clear(); + view = cmSystemTools::KeyWOW64_64; + other_view = cmSystemTools::KeyWOW64_32; } } -} - -//---------------------------------------------------------------------------- -void cmFindCommon::GetFrameworkPaths(std::vector& paths) -{ - if(this->NoDefaultPath) - { - return; - } - std::vector tmp; - - // first environment variables - if(!this->NoCMakeEnvironmentPath) - { - cmSystemTools::GetPath(tmp, "CMAKE_FRAMEWORK_PATH"); - this->AddPathsInternal(paths, tmp, EnvPath); - tmp.clear(); - } - // add cmake variables - if(!this->NoCMakePath) - { - if(const char* path = - this->Makefile->GetDefinition("CMAKE_FRAMEWORK_PATH")) - { - cmSystemTools::ExpandListArgument(path, tmp); - this->AddPathsInternal(paths, tmp, CMakePath); - tmp.clear(); - } - } + // Expand using the view of the target application. + std::string expanded = p; + cmSystemTools::ExpandRegistryValues(expanded, view); + cmSystemTools::GlobDirs(expanded.c_str(), paths); - // add cmake system variables - if(!this->NoCMakeSystemPath) + // Executables can be either 32-bit or 64-bit, so expand using the + // alternative view. + if(expanded != p && this->CMakePathName == "PROGRAM") { - if(const char* path = - this->Makefile->GetDefinition("CMAKE_SYSTEM_FRAMEWORK_PATH")) - { - cmSystemTools::ExpandListArgument(path, tmp); - this->AddPathsInternal(paths, tmp, CMakePath); - tmp.clear(); - } + expanded = p; + cmSystemTools::ExpandRegistryValues(expanded, other_view); + cmSystemTools::GlobDirs(expanded.c_str(), paths); } } //---------------------------------------------------------------------------- -void cmFindCommon::AddCMakePath(std::vector& out_paths, - const char* variable, - std::set* emmitted) +void cmFindCommon::AddCMakePath(const char* variable) { // Get a path from a CMake variable. if(const char* varPath = this->Makefile->GetDefinition(variable)) @@ -418,14 +365,12 @@ void cmFindCommon::AddCMakePath(std::vector& out_paths, // Relative paths are interpreted with respect to the current // source directory. - this->AddPathsInternal(out_paths, tmp, CMakePath, emmitted); + this->AddPathsInternal(tmp, CMakePath); } } //---------------------------------------------------------------------------- -void cmFindCommon::AddEnvPath(std::vector& out_paths, - const char* variable, - std::set* emmitted) +void cmFindCommon::AddEnvPath(const char* variable) { // Get a path from the environment. std::vector tmp; @@ -433,27 +378,23 @@ void cmFindCommon::AddEnvPath(std::vector& out_paths, // Relative paths are interpreted with respect to the current // working directory. - this->AddPathsInternal(out_paths, tmp, EnvPath, emmitted); + this->AddPathsInternal(tmp, EnvPath); } //---------------------------------------------------------------------------- -void cmFindCommon::AddPathsInternal(std::vector& out_paths, - std::vector const& in_paths, - PathType pathType, - std::set* emmitted) +void cmFindCommon::AddPathsInternal(std::vector const& in_paths, + PathType pathType) { for(std::vector::const_iterator i = in_paths.begin(); i != in_paths.end(); ++i) { - this->AddPathInternal(out_paths, *i, pathType, emmitted); + this->AddPathInternal(*i, pathType); } } //---------------------------------------------------------------------------- -void cmFindCommon::AddPathInternal(std::vector& out_paths, - std::string const& in_path, - PathType pathType, - std::set* emmitted) +void cmFindCommon::AddPathInternal(std::string const& in_path, + PathType pathType) { if(in_path.empty()) { @@ -471,9 +412,24 @@ void cmFindCommon::AddPathInternal(std::vector& out_paths, std::string fullPath = cmSystemTools::CollapseFullPath(in_path.c_str(), relbase); - // Insert the path if has not already been emmitted. - if(!emmitted || emmitted->insert(fullPath).second) + // Insert the path if has not already been emitted. + if(this->SearchPathsEmitted.insert(fullPath).second) + { + this->SearchPaths.push_back(fullPath.c_str()); + } +} + +//---------------------------------------------------------------------------- +void cmFindCommon::AddTrailingSlashes(std::vector& paths) +{ + // Add a trailing slash to all paths to aid the search process. + for(std::vector::iterator i = paths.begin(); + i != paths.end(); ++i) { - out_paths.push_back(fullPath.c_str()); + std::string& p = *i; + if(!p.empty() && p[p.size()-1] != '/') + { + p += "/"; + } } } diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index 831b068cb..ac44750fb 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindCommon.h,v $ Language: C++ - Date: $Date: 2008-01-17 14:02:31 $ - Version: $Revision: 1.1 $ + Date: $Date: 2008-06-13 12:55:17 $ + Version: $Revision: 1.1.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -44,6 +44,9 @@ protected: /** Place a set of search paths under the search roots. */ void RerootPaths(std::vector& paths); + /** Add trailing slashes to all search paths. */ + void AddTrailingSlashes(std::vector& paths); + /** Compute the current default root path mode. */ void SelectDefaultRootPathMode(); @@ -55,21 +58,13 @@ protected: bool CheckCommonArgument(std::string const& arg); void AddPathSuffix(std::string const& arg); - void GetAppBundlePaths(std::vector& paths); - void GetFrameworkPaths(std::vector& paths); - - void AddCMakePath(std::vector& out_paths, - const char* variable, std::set* emmitted = 0); - void AddEnvPath(std::vector& out_paths, - const char* variable, std::set* emmitted = 0); - void AddPathsInternal(std::vector& out_paths, - std::vector const& in_paths, - PathType pathType, - std::set* emmitted = 0); - void AddPathInternal(std::vector& out_paths, - std::string const& in_path, - PathType pathType, - std::set* emmitted = 0); + void AddUserPath(std::string const& p, + std::vector& paths); + void AddCMakePath(const char* variable); + void AddEnvPath(const char* variable); + void AddPathsInternal(std::vector const& in_paths, + PathType pathType); + void AddPathInternal(std::string const& in_path, PathType pathType); bool NoDefaultPath; bool NoCMakePath; @@ -78,6 +73,10 @@ protected: bool NoCMakeSystemPath; std::vector SearchPathSuffixes; + std::vector UserPaths; + std::vector UserHints; + std::vector SearchPaths; + std::set SearchPathsEmitted; std::string GenericDocumentationMacPolicy; std::string GenericDocumentationRootPath; diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index f5bb2d7c9..5cbb963fc 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindLibraryCommand.cxx,v $ Language: C++ - Date: $Date: 2008-02-11 22:00:45 $ - Version: $Revision: 1.58 $ + Date: $Date: 2008-06-13 12:55:17 $ + Version: $Revision: 1.58.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -96,19 +96,15 @@ bool cmFindLibraryCommand this->AddLib64Paths(); } - std::string library; - for(std::vector::iterator i = this->Names.begin(); - i != this->Names.end() ; ++i) + std::string library = this->FindLibrary(); + if(library != "") { - library = this->FindLibrary(i->c_str()); - if(library != "") - { - this->Makefile->AddCacheDefinition(this->VariableName.c_str(), - library.c_str(), - this->VariableDocumentation.c_str(), - cmCacheManager::FILEPATH); - return true; - } + // Save the value in the cache + this->Makefile->AddCacheDefinition(this->VariableName.c_str(), + library.c_str(), + this->VariableDocumentation.c_str(), + cmCacheManager::FILEPATH); + return true; } std::string notfound = this->VariableName + "-NOTFOUND"; this->Makefile->AddCacheDefinition(this->VariableName.c_str(), @@ -211,21 +207,29 @@ void cmFindLibraryCommand::AddLib64Paths() } } -std::string cmFindLibraryCommand::FindLibrary(const char* name) +//---------------------------------------------------------------------------- +std::string cmFindLibraryCommand::FindLibrary() { - bool supportFrameworks = false; - bool onlyFrameworks = false; - std::string ff = this->Makefile->GetSafeDefinition("CMAKE_FIND_FRAMEWORK"); - if(ff == "FIRST" || ff == "LAST") + std::string library; + if(this->SearchFrameworkFirst || this->SearchFrameworkOnly) + { + library = this->FindFrameworkLibrary(); + } + if(library.empty() && !this->SearchFrameworkOnly) { - supportFrameworks = true; + library = this->FindNormalLibrary(); } - if(ff == "ONLY") + if(library.empty() && this->SearchFrameworkLast) { - onlyFrameworks = true; - supportFrameworks = true; + library = this->FindFrameworkLibrary(); } - + return library; +} + +//---------------------------------------------------------------------------- +std::string cmFindLibraryCommand::FindNormalLibrary() +{ + // Collect the list of library name prefixes/suffixes to try. const char* prefixes_list = this->Makefile->GetRequiredDefinition("CMAKE_FIND_LIBRARY_PREFIXES"); const char* suffixes_list = @@ -235,51 +239,29 @@ std::string cmFindLibraryCommand::FindLibrary(const char* name) cmSystemTools::ExpandListArgument(prefixes_list, prefixes, true); cmSystemTools::ExpandListArgument(suffixes_list, suffixes, true); - // If the original library name provided by the user matches one of - // the suffixes, try it first. - bool tryOrig = false; - { - std::string nm = name; - for(std::vector::const_iterator si = suffixes.begin(); - !tryOrig && si != suffixes.end(); ++si) - { - std::string const& suffix = *si; - if(nm.length() > suffix.length() && - nm.substr(nm.size()-suffix.length()) == suffix) - { - tryOrig = true; - } - } - } - - // Add a trailing slash to all paths to aid the search process. - for(std::vector::iterator i = this->SearchPaths.begin(); - i != this->SearchPaths.end(); ++i) - { - std::string& p = *i; - if(p.empty() || p[p.size()-1] != '/') - { - p += "/"; - } - } + // Search the entire path for each name. std::string tryPath; - for(std::vector::const_iterator p = this->SearchPaths.begin(); - p != this->SearchPaths.end(); ++p) + for(std::vector::const_iterator ni = this->Names.begin(); + ni != this->Names.end() ; ++ni) { - if(supportFrameworks) + // If the original library name provided by the user matches one of + // the suffixes, try it first. + bool tryOrig = false; + std::string const& name = *ni; + for(std::vector::const_iterator si = suffixes.begin(); + !tryOrig && si != suffixes.end(); ++si) { - tryPath = *p; - tryPath += name; - tryPath += ".framework"; - if(cmSystemTools::FileExists(tryPath.c_str()) - && cmSystemTools::FileIsDirectory(tryPath.c_str())) + std::string const& suffix = *si; + if(name.length() > suffix.length() && + name.substr(name.size()-suffix.length()) == suffix) { - tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str()); - cmSystemTools::ConvertToUnixSlashes(tryPath); - return tryPath; + tryOrig = true; } } - if(!onlyFrameworks) + + for(std::vector::const_iterator + p = this->SearchPaths.begin(); + p != this->SearchPaths.end(); ++p) { // Try the original library name as specified by the user. if(tryOrig) @@ -319,3 +301,26 @@ std::string cmFindLibraryCommand::FindLibrary(const char* name) // Couldn't find the library. return ""; } + +//---------------------------------------------------------------------------- +std::string cmFindLibraryCommand::FindFrameworkLibrary() +{ + // Search for a framework of each name in the entire search path. + for(std::vector::const_iterator ni = this->Names.begin(); + ni != this->Names.end() ; ++ni) + { + // Search the paths for a framework with this name. + std::string fwName = *ni; + fwName += ".framework"; + std::string fwPath = cmSystemTools::FindDirectory(fwName.c_str(), + this->SearchPaths, + true); + if(!fwPath.empty()) + { + return fwPath; + } + } + + // No framework found. + return ""; +} diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h index 5c82b84c8..584977963 100644 --- a/Source/cmFindLibraryCommand.h +++ b/Source/cmFindLibraryCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindLibraryCommand.h,v $ Language: C++ - Date: $Date: 2008-01-31 12:50:40 $ - Version: $Revision: 1.27 $ + Date: $Date: 2008-06-13 12:55:17 $ + Version: $Revision: 1.27.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -68,7 +68,10 @@ public: protected: void AddArchitecturePaths(const char* suffix); void AddLib64Paths(); - std::string FindLibrary(const char* name); + std::string FindLibrary(); +private: + std::string FindNormalLibrary(); + std::string FindFrameworkLibrary(); }; diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 6d6d7c6e4..932ddd740 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindPackageCommand.cxx,v $ Language: C++ - Date: $Date: 2008-01-29 14:57:39 $ - Version: $Revision: 1.36 $ + Date: $Date: 2008-09-12 14:56:20 $ + Version: $Revision: 1.36.2.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -63,17 +63,20 @@ cmFindPackageCommand::cmFindPackageCommand() this->NoBuilds = false; this->NoModule = false; this->DebugMode = false; + this->UseLib64Paths = false; this->VersionMajor = 0; this->VersionMinor = 0; this->VersionPatch = 0; + this->VersionTweak = 0; this->VersionCount = 0; this->VersionExact = false; this->VersionFoundMajor = 0; this->VersionFoundMinor = 0; this->VersionFoundPatch = 0; + this->VersionFoundTweak = 0; this->VersionFoundCount = 0; this->CommandDocumentation = - " find_package( [major[.minor[.patch]]] [EXACT] [QUIET]\n" + " find_package( [version] [EXACT] [QUIET]\n" " [[REQUIRED|COMPONENTS] [components...]])\n" "Finds and loads settings from an external project. " "_FOUND will be set to indicate whether the package was found. " @@ -85,8 +88,8 @@ cmFindPackageCommand::cmFindPackageCommand() "A package-specific list of components may be listed after the " "REQUIRED option or after the COMPONENTS option if no REQUIRED " "option is given. " - "The \"[major[.minor[.patch]]]\" version argument specifies a desired " - "version with which the package found should be compatible. " + "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. " "Version support is currently provided only on a package-by-package " "basis (details below).\n" @@ -108,10 +111,11 @@ cmFindPackageCommand::cmFindPackageCommand() "check the module documentation. " "If no module is found the command proceeds to Config mode.\n" "The complete Config mode command signature is:\n" - " find_package( [major[.minor[.patch]]] [EXACT] [QUIET]\n" + " find_package( [version] [EXACT] [QUIET]\n" " [[REQUIRED|COMPONENTS] [components...]] [NO_MODULE]\n" " [NAMES name1 [name2 ...]]\n" " [CONFIGS config1 [config2 ...]]\n" + " [HINTS path1 [path2 ... ]]\n" " [PATHS path1 [path2 ... ]]\n" " [PATH_SUFFIXES suffix1 [suffix2 ...]]\n" " [NO_DEFAULT_PATH]\n" @@ -151,9 +155,9 @@ cmFindPackageCommand::cmFindPackageCommand() "a configuration file a fatal error is always generated because user " "intervention is required." "\n" - "When the \"[major[.minor[.patch]]]\" version argument is specified " - "Config mode will only find a version of the package that claims " - "compatibility with the requested version. " + "When the [version] argument is given Config mode will only find a " + "version of the package that claims compatibility with the requested " + "version (format is major[.minor[.patch[.tweak]]]). " "If the EXACT option is given only a version of the package claiming " "an exact match of the requested version may be found. " "CMake does not establish any convention for the meaning of version " @@ -171,22 +175,26 @@ cmFindPackageCommand::cmFindPackageCommand() "variables have been defined:\n" " PACKAGE_FIND_NAME = the name\n" " PACKAGE_FIND_VERSION = full requested version string\n" - " PACKAGE_FIND_VERSION_MAJOR = requested major version, if any\n" - " PACKAGE_FIND_VERSION_MINOR = requested minor version, if any\n" - " PACKAGE_FIND_VERSION_PATCH = requested patch version, if any\n" + " PACKAGE_FIND_VERSION_MAJOR = major version if requested, else 0\n" + " PACKAGE_FIND_VERSION_MINOR = minor version if requested, else 0\n" + " PACKAGE_FIND_VERSION_PATCH = patch version if requested, else 0\n" + " PACKAGE_FIND_VERSION_TWEAK = tweak version if requested, else 0\n" + " PACKAGE_FIND_VERSION_COUNT = number of version components, 0 to 4\n" "The version file checks whether it satisfies the requested version " "and sets these variables:\n" - " PACKAGE_VERSION = package version (major[.minor[.patch]])\n" + " PACKAGE_VERSION = full provided version string\n" " PACKAGE_VERSION_EXACT = true if version is exact match\n" " PACKAGE_VERSION_COMPATIBLE = true if version is compatible\n" "These variables are checked by the find_package command to determine " "whether the configuration file provides an acceptable version. " "They are not available after the find_package call returns. " "If the version is acceptable the following variables are set:\n" - " _VERSION = package version (major[.minor[.patch]])\n" - " _VERSION_MAJOR = major from major[.minor[.patch]], if any\n" - " _VERSION_MINOR = minor from major[.minor[.patch]], if any\n" - " _VERSION_PATCH = patch from major[.minor[.patch]], if any\n" + " _VERSION = full provided version string\n" + " _VERSION_MAJOR = major version if provided, else 0\n" + " _VERSION_MINOR = minor version if provided, else 0\n" + " _VERSION_PATCH = patch version if provided, else 0\n" + " _VERSION_TWEAK = tweak version if provided, else 0\n" + " _VERSION_COUNT = number of version components, 0 to 4\n" "and the corresponding package configuration file is loaded. " "When multiple package configuration files are available whose version " "files claim compatibility with the version requested it is unspecified " @@ -238,35 +246,40 @@ cmFindPackageCommand::cmFindPackageCommand() "CMAKE_FIND_APPBUNDLE determine the order of preference " "as specified below.\n" "The set of installation prefixes is constructed using the following " - "steps. If NO_DEFAULT_PATH is specified steps 1-5 are skipped.\n" - "1. Search cmake specific environment variables. This " - "can be skipped if NO_CMAKE_ENVIRONMENT_PATH is passed.\n" + "steps. If NO_DEFAULT_PATH is specified all NO_* options are enabled.\n" + "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" " CMAKE_PREFIX_PATH\n" " CMAKE_FRAMEWORK_PATH\n" " CMAKE_APPBUNDLE_PATH\n" - "2. Search cmake variables with the same names as the cmake specific " - "environment 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" + "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" " CMAKE_PREFIX_PATH\n" " CMAKE_FRAMEWORK_PATH\n" " CMAKE_APPBUNDLE_PATH\n" - "3. Search the standard system environment variables. " + "3. Search paths specified by the HINTS option. " + "These should be paths computed by system introspection, such as a " + "hint provided by the location of another item already found. " + "Hard-coded guesses should be specified with the PATHS option.\n" + "4. Search the standard system environment variables. " "This can be skipped if NO_SYSTEM_ENVIRONMENT_PATH is passed. " "Path entries ending in \"/bin\" or \"/sbin\" are automatically " "converted to their parent directories.\n" " PATH\n" - "4. Search project build trees recently configured in a CMake GUI. " + "5. Search project build trees recently configured in a CMake GUI. " "This can be skipped if NO_CMAKE_BUILDS_PATH is passed. " "It is intended for the case when a user is building multiple " "dependent projects one after another.\n" - "5. Search cmake variables defined in the Platform files " + "6. Search cmake variables defined in the Platform files " "for the current system. This can be skipped if NO_CMAKE_SYSTEM_PATH " "is passed.\n" " CMAKE_SYSTEM_PREFIX_PATH\n" " CMAKE_SYSTEM_FRAMEWORK_PATH\n" " CMAKE_SYSTEM_APPBUNDLE_PATH\n" - "6. Search paths specified by the PATHS option.\n" + "7. Search paths specified by the PATHS option. " + "These are typically hard-coded guesses.\n" ; this->CommandDocumentation += this->GenericDocumentationMacPolicy; this->CommandDocumentation += this->GenericDocumentationRootPath; @@ -292,6 +305,18 @@ bool cmFindPackageCommand // Check for debug mode. this->DebugMode = this->Makefile->IsOn("CMAKE_FIND_DEBUG_MODE"); + // Lookup whether lib64 paths should be used. + if(const char* sizeof_dptr = + this->Makefile->GetDefinition("CMAKE_SIZEOF_VOID_P")) + { + if(atoi(sizeof_dptr) == 8 && + this->Makefile->GetCMakeInstance() + ->GetPropertyAsBool("FIND_LIBRARY_USE_LIB64_PATHS")) + { + this->UseLib64Paths = true; + } + } + // Find the current root path mode. this->SelectDefaultRootPathMode(); @@ -313,7 +338,7 @@ bool cmFindPackageCommand // Parse the arguments. enum Doing { DoingNone, DoingComponents, DoingNames, DoingPaths, - DoingPathSuffixes, DoingConfigs }; + DoingPathSuffixes, DoingConfigs, DoingHints }; Doing doing = DoingNone; cmsys::RegularExpression version("^[0-9.]+$"); bool haveVersion = false; @@ -357,6 +382,12 @@ bool cmFindPackageCommand this->Compatibility_1_6 = false; doing = DoingPaths; } + else if(args[i] == "HINTS") + { + this->NoModule = true; + this->Compatibility_1_6 = false; + doing = DoingHints; + } else if(args[i] == "PATH_SUFFIXES") { this->NoModule = true; @@ -386,7 +417,7 @@ bool cmFindPackageCommand { // Set a variable telling the find script this component // is required. - std::string req_var = Name + "_FIND_REQUIRED_" + args[i]; + std::string req_var = this->Name + "_FIND_REQUIRED_" + args[i]; this->Makefile->AddDefinition(req_var.c_str(), "1"); // Append to the list of required components. @@ -400,7 +431,11 @@ bool cmFindPackageCommand } else if(doing == DoingPaths) { - this->AddUserPath(args[i]); + this->AddUserPath(args[i], this->UserPaths); + } + else if(doing == DoingHints) + { + this->AddUserPath(args[i], this->UserHints); } else if(doing == DoingPathSuffixes) { @@ -440,10 +475,13 @@ bool cmFindPackageCommand unsigned int parsed_major; unsigned int parsed_minor; unsigned int parsed_patch; - this->VersionCount = sscanf(this->Version.c_str(), "%u.%u.%u", - &parsed_major, &parsed_minor, &parsed_patch); + unsigned int parsed_tweak; + this->VersionCount = sscanf(this->Version.c_str(), "%u.%u.%u.%u", + &parsed_major, &parsed_minor, + &parsed_patch, &parsed_tweak); switch(this->VersionCount) { + case 4: this->VersionTweak = parsed_tweak; // no break! case 3: this->VersionPatch = parsed_patch; // no break! case 2: this->VersionMinor = parsed_minor; // no break! case 1: this->VersionMajor = parsed_major; // no break! @@ -451,9 +489,7 @@ bool cmFindPackageCommand } } - // Store the list of components. - std::string components_var = Name + "_FIND_COMPONENTS"; - this->Makefile->AddDefinition(components_var.c_str(), components.c_str()); + this->SetModuleVariables(components); // See if there is a Find.cmake module. if(!this->NoModule) @@ -504,6 +540,60 @@ bool cmFindPackageCommand return result; } + +//---------------------------------------------------------------------------- +void cmFindPackageCommand::SetModuleVariables(const std::string& components) +{ + // Store the list of components. + std::string components_var = this->Name + "_FIND_COMPONENTS"; + this->Makefile->AddDefinition(components_var.c_str(), components.c_str()); + + if(this->Quiet) + { + // Tell the module that is about to be read that it should find + // quietly. + std::string quietly = this->Name; + quietly += "_FIND_QUIETLY"; + this->Makefile->AddDefinition(quietly.c_str(), "1"); + } + + if(this->Required) + { + // Tell the module that is about to be read that it should report + // a fatal error if the package is not found. + std::string req = this->Name; + req += "_FIND_REQUIRED"; + this->Makefile->AddDefinition(req.c_str(), "1"); + } + + if(!this->Version.empty()) + { + // Tell the module that is about to be read what version of the + // package has been requested. + std::string ver = this->Name; + ver += "_FIND_VERSION"; + this->Makefile->AddDefinition(ver.c_str(), this->Version.c_str()); + char buf[64]; + sprintf(buf, "%u", this->VersionMajor); + this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf); + sprintf(buf, "%u", this->VersionMinor); + this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf); + sprintf(buf, "%u", this->VersionPatch); + this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf); + sprintf(buf, "%u", this->VersionTweak); + this->Makefile->AddDefinition((ver+"_TWEAK").c_str(), buf); + sprintf(buf, "%u", this->VersionCount); + this->Makefile->AddDefinition((ver+"_COUNT").c_str(), buf); + + // Tell the module whether an exact version has been requested. + std::string exact = this->Name; + exact += "_FIND_VERSION_EXACT"; + this->Makefile->AddDefinition(exact.c_str(), + this->VersionExact? "1":"0"); + } +} + + //---------------------------------------------------------------------------- bool cmFindPackageCommand::FindModule(bool& found) { @@ -513,59 +603,6 @@ bool cmFindPackageCommand::FindModule(bool& found) std::string mfile = this->Makefile->GetModulesFile(module.c_str()); if ( mfile.size() ) { - if(this->Quiet) - { - // Tell the module that is about to be read that it should find - // quietly. - std::string quietly = this->Name; - quietly += "_FIND_QUIETLY"; - this->Makefile->AddDefinition(quietly.c_str(), "1"); - } - - if(this->Required) - { - // Tell the module that is about to be read that it should report - // a fatal error if the package is not found. - std::string req = this->Name; - req += "_FIND_REQUIRED"; - this->Makefile->AddDefinition(req.c_str(), "1"); - } - - if(!this->Version.empty()) - { - // Tell the module that is about to be read what version of the - // package has been requested. - std::string ver = this->Name; - ver += "_FIND_VERSION"; - this->Makefile->AddDefinition(ver.c_str(), this->Version.c_str()); - char buf[64]; - switch(this->VersionCount) - { - case 3: - { - sprintf(buf, "%u", this->VersionPatch); - this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf); - } // no break - case 2: - { - sprintf(buf, "%u", this->VersionMinor); - this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf); - } // no break - case 1: - { - sprintf(buf, "%u", this->VersionMajor); - this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf); - } // no break - default: break; - } - - // Tell the module whether an exact version has been requested. - std::string exact = this->Name; - exact += "_FIND_VERSION_EXACT"; - this->Makefile->AddDefinition(exact.c_str(), - this->VersionExact? "1":"0"); - } - // Load the module we found. found = true; return this->ReadListFile(mfile.c_str()); @@ -662,7 +699,7 @@ bool cmFindPackageCommand::HandlePackageMode() { // The variable is not set. cmOStringStream e; - e << "could not find "; + e << "Could not find "; if(!this->NoModule) { e << "module Find" << this->Name << ".cmake or "; @@ -692,15 +729,8 @@ bool cmFindPackageCommand::HandlePackageMode() e << " " << *ci << "\n"; } } - if(this->Required) - { - this->SetError(e.str().c_str()); - result = false; - } - else - { - cmSystemTools::Error("find_package ", e.str().c_str()); - } + this->Makefile->IssueMessage( + this->Required? cmake::FATAL_ERROR : cmake::WARNING, e.str()); } // Set a variable marking whether the package was found. @@ -821,8 +851,9 @@ void cmFindPackageCommand::FindConfig() //---------------------------------------------------------------------------- bool cmFindPackageCommand::FindPrefixedConfig() { - for(std::vector::const_iterator pi = this->Prefixes.begin(); - pi != this->Prefixes.end(); ++pi) + std::vector& prefixes = this->SearchPaths; + for(std::vector::const_iterator pi = prefixes.begin(); + pi != prefixes.end(); ++pi) { if(this->SearchPrefix(*pi)) { @@ -835,8 +866,9 @@ bool cmFindPackageCommand::FindPrefixedConfig() //---------------------------------------------------------------------------- bool cmFindPackageCommand::FindFrameworkConfig() { - for(std::vector::const_iterator i = this->Prefixes.begin(); - i != this->Prefixes.end(); ++i) + std::vector& prefixes = this->SearchPaths; + for(std::vector::const_iterator i = prefixes.begin(); + i != prefixes.end(); ++i) { if(this->SearchFrameworkPrefix(*i)) { @@ -849,8 +881,9 @@ bool cmFindPackageCommand::FindFrameworkConfig() //---------------------------------------------------------------------------- bool cmFindPackageCommand::FindAppBundleConfig() { - for(std::vector::const_iterator i = this->Prefixes.begin(); - i != this->Prefixes.end(); ++i) + std::vector& prefixes = this->SearchPaths; + for(std::vector::const_iterator i = prefixes.begin(); + i != prefixes.end(); ++i) { if(this->SearchAppBundlePrefix(*i)) { @@ -939,19 +972,21 @@ void cmFindPackageCommand::AppendSuccessInformation() } //---------------------------------------------------------------------------- -void cmFindPackageCommand::AddUserPath(std::string const& p) +void cmFindPackageCommand::ComputePrefixes() { - std::string userPath = p; - cmSystemTools::ExpandRegistryValues(userPath); - this->UserPaths.push_back(userPath); + this->AddPrefixesCMakeVariable(); + this->AddPrefixesCMakeEnvironment(); + this->AddPrefixesUserHints(); + this->AddPrefixesSystemEnvironment(); + this->AddPrefixesBuilds(); + this->AddPrefixesCMakeSystemVariable(); + this->AddPrefixesUserGuess(); + this->ComputeFinalPrefixes(); } //---------------------------------------------------------------------------- -void cmFindPackageCommand::ComputePrefixes() +void cmFindPackageCommand::AddPrefixesCMakeEnvironment() { - std::vector& prefixes = this->Prefixes; - std::set emmitted; - if(!this->NoCMakeEnvironmentPath && !this->NoDefaultPath) { // Check the environment variable with the same name as the cache @@ -960,21 +995,29 @@ void cmFindPackageCommand::ComputePrefixes() if(cmSystemTools::GetEnv(this->Variable.c_str(), env) && env.length() > 0) { cmSystemTools::ConvertToUnixSlashes(env); - this->AddPathInternal(prefixes, env, EnvPath, &emmitted); + this->AddPathInternal(env, EnvPath); } - this->AddEnvPath(prefixes, "CMAKE_PREFIX_PATH", &emmitted); - this->AddEnvPath(prefixes, "CMAKE_FRAMEWORK_PATH", &emmitted); - this->AddEnvPath(prefixes, "CMAKE_APPBUNDLE_PATH", &emmitted); + this->AddEnvPath("CMAKE_PREFIX_PATH"); + this->AddEnvPath("CMAKE_FRAMEWORK_PATH"); + this->AddEnvPath("CMAKE_APPBUNDLE_PATH"); } +} +//---------------------------------------------------------------------------- +void cmFindPackageCommand::AddPrefixesCMakeVariable() +{ if(!this->NoCMakePath && !this->NoDefaultPath) { - this->AddCMakePath(prefixes, "CMAKE_PREFIX_PATH", &emmitted); - this->AddCMakePath(prefixes, "CMAKE_FRAMEWORK_PATH", &emmitted); - this->AddCMakePath(prefixes, "CMAKE_APPBUNDLE_PATH", &emmitted); + this->AddCMakePath("CMAKE_PREFIX_PATH"); + this->AddCMakePath("CMAKE_FRAMEWORK_PATH"); + this->AddCMakePath("CMAKE_APPBUNDLE_PATH"); } +} +//---------------------------------------------------------------------------- +void cmFindPackageCommand::AddPrefixesSystemEnvironment() +{ if(!this->NoSystemEnvironmentPath && !this->NoDefaultPath) { // Use the system search path to generate prefixes. @@ -991,17 +1034,19 @@ void cmFindPackageCommand::ComputePrefixes() if(d.size() >= 4 && strcmp(d.c_str()+d.size()-4, "/bin") == 0 || d.size() >= 5 && strcmp(d.c_str()+d.size()-5, "/sbin") == 0) { - this->AddPathInternal(prefixes, - cmSystemTools::GetFilenamePath(d), - EnvPath, &emmitted); + this->AddPathInternal(cmSystemTools::GetFilenamePath(d), EnvPath); } else { - this->AddPathInternal(prefixes, d, EnvPath, &emmitted); + this->AddPathInternal(d, EnvPath); } } } +} +//---------------------------------------------------------------------------- +void cmFindPackageCommand::AddPrefixesBuilds() +{ if(!this->NoBuilds && !this->NoDefaultPath) { // It is likely that CMake will have recently built the project. @@ -1017,37 +1062,47 @@ void cmFindPackageCommand::ComputePrefixes() if(cmSystemTools::FileIsFullPath(f.c_str()) && cmSystemTools::FileIsDirectory(f.c_str())) { - this->AddPathInternal(prefixes, f, FullPath, &emmitted); + this->AddPathInternal(f, FullPath); } } } +} +//---------------------------------------------------------------------------- +void cmFindPackageCommand::AddPrefixesCMakeSystemVariable() +{ if(!this->NoCMakeSystemPath && !this->NoDefaultPath) { - this->AddCMakePath(prefixes, "CMAKE_SYSTEM_PREFIX_PATH", &emmitted); - this->AddCMakePath(prefixes, "CMAKE_SYSTEM_FRAMEWORK_PATH", &emmitted); - this->AddCMakePath(prefixes, "CMAKE_SYSTEM_APPBUNDLE_PATH", &emmitted); + this->AddCMakePath("CMAKE_SYSTEM_PREFIX_PATH"); + this->AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH"); + this->AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH"); } +} - if(!this->UserPaths.empty()) - { - // Add paths specified by the caller. - this->AddPathsInternal(prefixes, this->UserPaths, CMakePath, &emmitted); - } +//---------------------------------------------------------------------------- +void cmFindPackageCommand::AddPrefixesUserGuess() +{ + // Add guesses specified by the caller. + this->AddPathsInternal(this->UserPaths, CMakePath); +} + +//---------------------------------------------------------------------------- +void cmFindPackageCommand::AddPrefixesUserHints() +{ + // Add hints specified by the caller. + this->AddPathsInternal(this->UserHints, CMakePath); +} + +//---------------------------------------------------------------------------- +void cmFindPackageCommand::ComputeFinalPrefixes() +{ + std::vector& prefixes = this->SearchPaths; // Construct the final set of prefixes. this->RerootPaths(prefixes); // Add a trailing slash to all prefixes to aid the search process. - for(std::vector::iterator i = prefixes.begin(); - i != prefixes.end(); ++i) - { - std::string& prefix = *i; - if(prefix[prefix.size()-1] != '/') - { - prefix += "/"; - } - } + this->AddTrailingSlashes(prefixes); } //---------------------------------------------------------------------------- @@ -1179,36 +1234,17 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file) this->Makefile->AddDefinition("PACKAGE_FIND_NAME", this->Name.c_str()); this->Makefile->AddDefinition("PACKAGE_FIND_VERSION", this->Version.c_str()); - if(this->VersionCount >= 3) - { - char buf[64]; - sprintf(buf, "%u", this->VersionPatch); - this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_PATCH", buf); - } - else - { - this->Makefile->RemoveDefinition("PACKAGE_FIND_VERSION_PATCH"); - } - if(this->VersionCount >= 2) - { - char buf[64]; - sprintf(buf, "%u", this->VersionMinor); - this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_MINOR", buf); - } - else - { - this->Makefile->RemoveDefinition("PACKAGE_FIND_VERSION_MINOR"); - } - if(this->VersionCount >= 1) - { - char buf[64]; - sprintf(buf, "%u", this->VersionMajor); - this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_MAJOR", buf); - } - else - { - this->Makefile->RemoveDefinition("PACKAGE_FIND_VERSION_MAJOR"); - } + char buf[64]; + sprintf(buf, "%u", this->VersionMajor); + this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_MAJOR", buf); + sprintf(buf, "%u", this->VersionMinor); + this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_MINOR", buf); + sprintf(buf, "%u", this->VersionPatch); + this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_PATCH", buf); + sprintf(buf, "%u", this->VersionTweak); + this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_TWEAK", buf); + sprintf(buf, "%u", this->VersionCount); + this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_COUNT", buf); // Load the version check file. bool found = false; @@ -1231,11 +1267,14 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file) unsigned int parsed_major; unsigned int parsed_minor; unsigned int parsed_patch; + unsigned int parsed_tweak; this->VersionFoundCount = - sscanf(this->VersionFound.c_str(), "%u.%u.%u", - &parsed_major, &parsed_minor, &parsed_patch); + sscanf(this->VersionFound.c_str(), "%u.%u.%u.%u", + &parsed_major, &parsed_minor, + &parsed_patch, &parsed_tweak); switch(this->VersionFoundCount) { + case 4: this->VersionFoundTweak = parsed_tweak; // no break! case 3: this->VersionFoundPatch = parsed_patch; // no break! case 2: this->VersionFoundMinor = parsed_minor; // no break! case 1: this->VersionFoundMajor = parsed_major; // no break! @@ -1266,27 +1305,18 @@ void cmFindPackageCommand::StoreVersionFound() this->Makefile->AddDefinition(ver.c_str(), this->VersionFound.c_str()); } - // Store the portions that could be parsed. + // Store the version components. char buf[64]; - switch(this->VersionFoundCount) - { - case 3: - { - sprintf(buf, "%u", this->VersionFoundPatch); - this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf); - } // no break - case 2: - { - sprintf(buf, "%u", this->VersionFoundMinor); - this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf); - } // no break - case 1: - { - sprintf(buf, "%u", this->VersionFoundMajor); - this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf); - } // no break - default: break; - } + sprintf(buf, "%u", this->VersionFoundMajor); + this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf); + sprintf(buf, "%u", this->VersionFoundMinor); + this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf); + sprintf(buf, "%u", this->VersionFoundPatch); + this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf); + sprintf(buf, "%u", this->VersionFoundTweak); + this->Makefile->AddDefinition((ver+"_TWEAK").c_str(), buf); + sprintf(buf, "%u", this->VersionFoundCount); + this->Makefile->AddDefinition((ver+"_COUNT").c_str(), buf); } //---------------------------------------------------------------------------- @@ -1416,16 +1446,12 @@ private: class cmFileListGeneratorEnumerate: public cmFileListGeneratorBase { public: - cmFileListGeneratorEnumerate(const char* p1, const char* p2): - cmFileListGeneratorBase() - { - this->Vector.push_back(p1); - this->Vector.push_back(p2); - } + cmFileListGeneratorEnumerate(std::vector const& v): + cmFileListGeneratorBase(), Vector(v) {} cmFileListGeneratorEnumerate(cmFileListGeneratorEnumerate const& r): cmFileListGeneratorBase(), Vector(r.Vector) {} private: - std::vector Vector; + std::vector const& Vector; virtual bool Search(std::string const& parent, cmFileList& lister) { for(std::vector::const_iterator i = this->Vector.begin(); @@ -1675,12 +1701,21 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) } } + // Construct list of common install locations (lib and share). + std::vector common; + if(this->UseLib64Paths) + { + common.push_back("lib64"); + } + common.push_back("lib"); + common.push_back("share"); + // PREFIX/(share|lib)/(Foo|foo|FOO).*/ { cmFindPackageFileList lister(this); lister / cmFileListGeneratorFixed(prefix) - / cmFileListGeneratorEnumerate("lib", "share") + / cmFileListGeneratorEnumerate(common) / cmFileListGeneratorProject(this->Names); if(lister.Search()) { @@ -1693,7 +1728,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in) cmFindPackageFileList lister(this); lister / cmFileListGeneratorFixed(prefix) - / cmFileListGeneratorEnumerate("lib", "share") + / cmFileListGeneratorEnumerate(common) / cmFileListGeneratorProject(this->Names) / cmFileListGeneratorCaseInsensitive("cmake"); if(lister.Search()) diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 8a7010fe5..75b2cc3ca 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindPackageCommand.h,v $ Language: C++ - Date: $Date: 2008-01-29 01:38:48 $ - Version: $Revision: 1.19 $ + Date: $Date: 2008-09-12 14:56:21 $ + Version: $Revision: 1.19.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -73,6 +73,7 @@ public: private: void AppendSuccessInformation(); void AppendToProperty(const char* propertyName); + void SetModuleVariables(const std::string& components); bool FindModule(bool& found); bool HandlePackageMode(); void FindConfig(); @@ -82,8 +83,15 @@ private: bool ReadListFile(const char* f); void StoreVersionFound(); - void AddUserPath(std::string const& p); void ComputePrefixes(); + void AddPrefixesCMakeEnvironment(); + void AddPrefixesCMakeVariable(); + void AddPrefixesSystemEnvironment(); + void AddPrefixesBuilds(); + void AddPrefixesCMakeSystemVariable(); + void AddPrefixesUserGuess(); + void AddPrefixesUserHints(); + void ComputeFinalPrefixes(); bool SearchDirectory(std::string const& dir); bool CheckDirectory(std::string const& dir); bool FindConfigFile(std::string const& dir, std::string& file); @@ -103,6 +111,7 @@ private: unsigned int VersionMajor; unsigned int VersionMinor; unsigned int VersionPatch; + unsigned int VersionTweak; unsigned int VersionCount; bool VersionExact; cmStdString FileFound; @@ -110,6 +119,7 @@ private: unsigned int VersionFoundMajor; unsigned int VersionFoundMinor; unsigned int VersionFoundPatch; + unsigned int VersionFoundTweak; unsigned int VersionFoundCount; bool Quiet; bool Required; @@ -117,10 +127,9 @@ private: bool NoModule; bool NoBuilds; bool DebugMode; + bool UseLib64Paths; std::vector Names; std::vector Configs; - std::vector Prefixes; - std::vector UserPaths; }; #endif diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx index 8eb93c871..839521a26 100644 --- a/Source/cmFindPathCommand.cxx +++ b/Source/cmFindPathCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindPathCommand.cxx,v $ Language: C++ - Date: $Date: 2008-01-23 15:27:59 $ - Version: $Revision: 1.41 $ + Date: $Date: 2008-06-13 12:55:17 $ + Version: $Revision: 1.41.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -95,67 +95,16 @@ bool cmFindPathCommand } return true; } - std::string ff = this->Makefile->GetSafeDefinition("CMAKE_FIND_FRAMEWORK"); - bool supportFrameworks = true; - if( ff.size() == 0 || ff == "NEVER" ) - { - supportFrameworks = false; - } - std::string framework; - // Add a trailing slash to all paths to aid the search process. - for(std::vector::iterator i = this->SearchPaths.begin(); - i != this->SearchPaths.end(); ++i) - { - std::string& p = *i; - if(p.empty() || p[p.size()-1] != '/') - { - p += "/"; - } - } - // Use the search path to find the file. - unsigned int k; - std::string result; - for(k=0; k < this->SearchPaths.size(); k++) + + std::string result = this->FindHeader(); + if(result.size() != 0) { - for(unsigned int j =0; j < this->Names.size(); ++j) - { - // if frameworks are supported try to find the header in a framework - std::string tryPath; - if(supportFrameworks) - { - tryPath = this->FindHeaderInFramework(this->Names[j], - this->SearchPaths[k]); - if(tryPath.size()) - { - result = tryPath; - } - } - if(result.size() == 0) - { - tryPath = this->SearchPaths[k]; - tryPath += this->Names[j]; - if(cmSystemTools::FileExists(tryPath.c_str())) - { - if(this->IncludeFileInPath) - { - result = tryPath; - } - else - { - result = this->SearchPaths[k]; - } - } - } - if(result.size() != 0) - { - this->Makefile->AddCacheDefinition - (this->VariableName.c_str(), result.c_str(), - this->VariableDocumentation.c_str(), - (this->IncludeFileInPath) ? - cmCacheManager::FILEPATH :cmCacheManager::PATH); - return true; - } - } + this->Makefile->AddCacheDefinition + (this->VariableName.c_str(), result.c_str(), + this->VariableDocumentation.c_str(), + (this->IncludeFileInPath) ? + cmCacheManager::FILEPATH :cmCacheManager::PATH); + return true; } this->Makefile->AddCacheDefinition (this->VariableName.c_str(), @@ -166,8 +115,28 @@ bool cmFindPathCommand return true; } -std::string cmFindPathCommand::FindHeaderInFramework(std::string& file, - std::string& dir) +//---------------------------------------------------------------------------- +std::string cmFindPathCommand::FindHeader() +{ + std::string header; + if(this->SearchFrameworkFirst || this->SearchFrameworkOnly) + { + header = this->FindFrameworkHeader(); + } + if(header.empty() && !this->SearchFrameworkOnly) + { + header = this->FindNormalHeader(); + } + if(header.empty() && this->SearchFrameworkLast) + { + header = this->FindFrameworkHeader(); + } + return header; +} + +std::string +cmFindPathCommand::FindHeaderInFramework(std::string const& file, + std::string const& dir) { cmStdString fileName = file; cmStdString frameWorkName; @@ -207,9 +176,9 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string& file, } } // if it is not found yet or not a framework header, then do a glob search - // for all files in dir/*/Headers/ + // for all frameworks in the directory: dir/*.framework/Headers/ cmStdString glob = dir; - glob += "*/Headers/"; + glob += "*.framework/Headers/"; glob += file; cmsys::Glob globIt; globIt.FindFiles(glob); @@ -227,3 +196,51 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string& file, return ""; } +//---------------------------------------------------------------------------- +std::string cmFindPathCommand::FindNormalHeader() +{ + std::string tryPath; + for(std::vector::const_iterator ni = this->Names.begin(); + ni != this->Names.end() ; ++ni) + { + for(std::vector::const_iterator + p = this->SearchPaths.begin(); + p != this->SearchPaths.end(); ++p) + { + tryPath = *p; + tryPath += *ni; + if(cmSystemTools::FileExists(tryPath.c_str())) + { + if(this->IncludeFileInPath) + { + return tryPath; + } + else + { + return *p; + } + } + } + } + return ""; +} + +//---------------------------------------------------------------------------- +std::string cmFindPathCommand::FindFrameworkHeader() +{ + for(std::vector::const_iterator ni = this->Names.begin(); + ni != this->Names.end() ; ++ni) + { + for(std::vector::const_iterator + p = this->SearchPaths.begin(); + p != this->SearchPaths.end(); ++p) + { + std::string fwPath = this->FindHeaderInFramework(*ni, *p); + if(!fwPath.empty()) + { + return fwPath; + } + } + } + return ""; +} diff --git a/Source/cmFindPathCommand.h b/Source/cmFindPathCommand.h index cd0060f8c..3aaac3174 100644 --- a/Source/cmFindPathCommand.h +++ b/Source/cmFindPathCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindPathCommand.h,v $ Language: C++ - Date: $Date: 2008-01-23 15:27:59 $ - Version: $Revision: 1.18 $ + Date: $Date: 2008-06-13 12:55:17 $ + Version: $Revision: 1.18.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -64,12 +64,16 @@ public: return "Find the directory containing a file."; } - std::string FindHeaderInFramework( std::string& file, - std::string& dir); virtual const char* GetFullDocumentation(); cmTypeMacro(cmFindPathCommand, cmFindBase); bool IncludeFileInPath; bool ExtraDocAdded; +private: + std::string FindHeaderInFramework(std::string const& file, + std::string const& dir); + std::string FindHeader(); + std::string FindNormalHeader(); + std::string FindFrameworkHeader(); }; diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index e15d9e28f..77edb07dd 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmFindProgramCommand.cxx,v $ Language: C++ - Date: $Date: 2008-01-23 15:27:59 $ - Version: $Revision: 1.42 $ + Date: $Date: 2008-06-13 12:55:17 $ + Version: $Revision: 1.42.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -97,8 +97,7 @@ std::string cmFindProgramCommand::FindProgram(std::vector names) { std::string program = ""; - // First/last order taken care of in cmFindBase when the paths are setup. - if(this->SearchAppBundleFirst || this->SearchAppBundleLast) + if(this->SearchAppBundleFirst || this->SearchAppBundleOnly) { program = FindAppBundle(names); } @@ -107,6 +106,10 @@ std::string cmFindProgramCommand::FindProgram(std::vector names) program = cmSystemTools::FindProgram(names, this->SearchPaths, true); } + if(program.empty() && this->SearchAppBundleLast) + { + program = this->FindAppBundle(names); + } return program; } diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx index 1b79eb915..0dd341e04 100644 --- a/Source/cmGetCMakePropertyCommand.cxx +++ b/Source/cmGetCMakePropertyCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGetCMakePropertyCommand.cxx,v $ Language: C++ - Date: $Date: 2008-01-23 15:27:59 $ - Version: $Revision: 1.8 $ + Date: $Date: 2008-07-13 21:55:23 $ + Version: $Revision: 1.8.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -49,6 +49,22 @@ bool cmGetCMakePropertyCommand { this->Makefile->GetListOfMacros(output); } + else if ( args[1] == "COMPONENTS" ) + { + const std::set* components + = this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->GetInstallComponents(); + std::set::const_iterator compIt; + output = ""; + for (compIt = components->begin(); compIt != components->end(); ++compIt) + { + if (compIt != components->begin()) + { + output += ";"; + } + output += *compIt; + } + } else { const char *prop = diff --git a/Source/cmGetCMakePropertyCommand.h b/Source/cmGetCMakePropertyCommand.h index ff8cb3829..051f8f60e 100644 --- a/Source/cmGetCMakePropertyCommand.h +++ b/Source/cmGetCMakePropertyCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGetCMakePropertyCommand.h,v $ Language: C++ - Date: $Date: 2008-01-23 15:27:59 $ - Version: $Revision: 1.8 $ + Date: $Date: 2008-07-13 21:55:23 $ + Version: $Revision: 1.8.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -62,7 +62,8 @@ public: "Get a property from the CMake instance. The value of the " "property is stored in the variable VAR. If the property is " "not found, CMake will report an error. Some supported properties " - "include: VARIABLES, CACHE_VARIABLES, COMMANDS, and MACROS."; + "include: VARIABLES, CACHE_VARIABLES, COMMANDS, MACROS, and " + "COMPONENTS."; } cmTypeMacro(cmGetCMakePropertyCommand, cmCommand); diff --git a/Source/cmGetPropertyCommand.h b/Source/cmGetPropertyCommand.h index 50cd1f4bf..f3e0dceac 100755 --- a/Source/cmGetPropertyCommand.h +++ b/Source/cmGetPropertyCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGetPropertyCommand.h,v $ Language: C++ - Date: $Date: 2008-04-02 13:16:03 $ - Version: $Revision: 1.6.2.1 $ + Date: $Date: 2008-09-04 21:10:44 $ + Version: $Revision: 1.6.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -86,7 +86,7 @@ public: "of the property to get. " "If the property is not set an empty value is returned. " "If the SET option is given the variable is set to a boolean " - "value indicating whether the property has been set." + "value indicating whether the property has been set. " "If the DEFINED option is given the variable is set to a boolean " "value indicating whether the property has been defined " "such as with define_property. " diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ba4e4edbd..44f9cfcde 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalGenerator.cxx,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:39 $ - Version: $Revision: 1.227.2.1 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.227.2.7 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -27,9 +27,14 @@ #include "cmVersion.h" #include "cmExportInstallFileGenerator.h" #include "cmComputeTargetDepends.h" +#include "cmGeneratedFileStream.h" #include +#if defined(CMAKE_BUILD_WITH_CMAKE) +# include +#endif + #include // required for atof #include @@ -72,16 +77,7 @@ cmGlobalGenerator::~cmGlobalGenerator() delete this->ExtraGenerator; } - for (std::map >::iterator - setIt = this->ExportSets.begin(); - setIt != this->ExportSets.end(); - ++setIt) - { - for (unsigned int i = 0; i < setIt->second.size(); ++i) - { - delete setIt->second[i]; - } - } + this->ClearExportSets(); } // Find the make program for the generator, required for try compiles @@ -414,23 +410,43 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, fpath = "CMake"; fpath += lang; fpath += "Information.cmake"; - fpath = mf->GetModulesFile(fpath.c_str()); - if(!mf->ReadListFile(0,fpath.c_str())) + std::string informationFile = mf->GetModulesFile(fpath.c_str()); + if (informationFile.empty()) { cmSystemTools::Error("Could not find cmake module file:", fpath.c_str()); } + else if(!mf->ReadListFile(0, informationFile.c_str())) + { + cmSystemTools::Error("Could not process cmake module file:", + informationFile.c_str()); + } } if (needSetLanguageEnabledMaps[lang]) { this->SetLanguageEnabledMaps(lang, mf); } + std::string compilerName = "CMAKE_"; + compilerName += lang; + compilerName += "_COMPILER"; + std::string compilerLangFile = rootBin; + compilerLangFile += "/CMake"; + compilerLangFile += lang; + compilerLangFile += "Compiler.cmake"; // Test the compiler for the language just setup + // (but only if a compiler has been actually found) // At this point we should have enough info for a try compile // which is used in the backward stuff // If the language is untested then test it now with a try compile. - if(needTestLanguage[lang]) + if (!mf->IsSet(compilerName.c_str())) + { + // if the compiler did not work, then remove the + // CMake(LANG)Compiler.cmake file so that it will get tested the + // next time cmake is run + cmSystemTools::RemoveFile(compilerLangFile.c_str()); + } + else if(needTestLanguage[lang]) { if (!this->CMakeInstance->GetIsInTryCompile()) { @@ -451,11 +467,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, // next time cmake is run if(!mf->IsOn(compilerWorks.c_str())) { - fpath = rootBin; - fpath += "/CMake"; - fpath += lang; - fpath += "Compiler.cmake"; - cmSystemTools::RemoveFile(fpath.c_str()); + cmSystemTools::RemoveFile(compilerLangFile.c_str()); } else { @@ -547,6 +559,11 @@ for checking whether the language is already enabled. After setting this flag still the values from the cmake variables have to be copied into the internal maps, this is done in SetLanguageEnabledMaps() which is called after the system- and compiler specific files have been loaded. + +This split was done originally so that compiler-specific configuration +files could change the object file extension +(CMAKE__OUTPUT_EXTENSION) before the CMake variables were copied +to the C++ maps. */ void cmGlobalGenerator::SetLanguageEnabled(const char* l, cmMakefile* mf) { @@ -554,9 +571,16 @@ void cmGlobalGenerator::SetLanguageEnabled(const char* l, cmMakefile* mf) this->SetLanguageEnabledMaps(l, mf); } -void cmGlobalGenerator::SetLanguageEnabledFlag(const char* l, cmMakefile*) +void cmGlobalGenerator::SetLanguageEnabledFlag(const char* l, cmMakefile* mf) { this->LanguageEnabled[l] = true; + + // Fill the language-to-extension map with the current variable + // settings to make sure it is available for the try_compile() + // command source file signature. In SetLanguageEnabledMaps this + // will be done again to account for any compiler- or + // platform-specific entries. + this->FillExtensionToLanguageMap(l, mf); } void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf) @@ -615,26 +639,37 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf) } } - std::string extensionsVar = std::string("CMAKE_") + - std::string(l) + std::string("_SOURCE_FILE_EXTENSIONS"); + // The map was originally filled by SetLanguageEnabledFlag, but + // since then the compiler- and platform-specific files have been + // loaded which might have added more entries. + this->FillExtensionToLanguageMap(l, mf); + std::string ignoreExtensionsVar = std::string("CMAKE_") + std::string(l) + std::string("_IGNORE_EXTENSIONS"); std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar.c_str()); - std::string exts = mf->GetSafeDefinition(extensionsVar.c_str()); std::vector extensionList; - cmSystemTools::ExpandListArgument(exts, extensionList); + cmSystemTools::ExpandListArgument(ignoreExts, extensionList); for(std::vector::iterator i = extensionList.begin(); i != extensionList.end(); ++i) { - this->ExtensionToLanguage[*i] = l; + this->IgnoreExtensions[*i] = true; } - cmSystemTools::ExpandListArgument(ignoreExts, extensionList); + +} + +void cmGlobalGenerator::FillExtensionToLanguageMap(const char* l, + cmMakefile* mf) +{ + std::string extensionsVar = std::string("CMAKE_") + + std::string(l) + std::string("_SOURCE_FILE_EXTENSIONS"); + std::string exts = mf->GetSafeDefinition(extensionsVar.c_str()); + std::vector extensionList; + cmSystemTools::ExpandListArgument(exts, extensionList); for(std::vector::iterator i = extensionList.begin(); i != extensionList.end(); ++i) { - this->IgnoreExtensions[*i] = true; + this->ExtensionToLanguage[*i] = l; } - } bool cmGlobalGenerator::IgnoreFile(const char* l) @@ -683,6 +718,7 @@ bool cmGlobalGenerator::IsDependedOn(const char* project, void cmGlobalGenerator::Configure() { this->FirstTimeProgress = 0.0f; + this->ClearExportSets(); // Delete any existing cmLocalGenerators unsigned int i; for (i = 0; i < this->LocalGenerators.size(); ++i) @@ -694,6 +730,7 @@ void cmGlobalGenerator::Configure() this->TotalTargets.clear(); this->LocalGeneratorToTargetMap.clear(); this->ProjectMap.clear(); + this->RuleHashes.clear(); // start with this directory cmLocalGenerator *lg = this->CreateLocalGenerator(); @@ -727,7 +764,12 @@ void cmGlobalGenerator::Configure() if ( !this->CMakeInstance->GetScriptMode() ) { - this->CMakeInstance->UpdateProgress("Configuring done", -1); + const char* msg = "Configuring done"; + if(cmSystemTools::GetErrorOccuredFlag()) + { + msg = "Configuring incomplete, errors occurred!"; + } + this->CMakeInstance->UpdateProgress(msg, -1); } } @@ -764,6 +806,12 @@ void cmGlobalGenerator::Generate() return; } + // Check that all targets are valid. + if(!this->CheckTargets()) + { + return; + } + // For each existing cmLocalGenerator unsigned int i; @@ -817,7 +865,10 @@ void cmGlobalGenerator::Generate() // Compute the inter-target dependencies. { cmComputeTargetDepends ctd(this); - ctd.Compute(); + if(!ctd.Compute()) + { + return; + } std::vector const& targets = ctd.GetTargets(); for(std::vector::const_iterator ti = targets.begin(); ti != targets.end(); ++ti) @@ -842,6 +893,9 @@ void cmGlobalGenerator::Generate() } this->SetCurrentLocalGenerator(0); + // Update rule hashes. + this->CheckRuleHashes(); + if (this->ExtraGenerator != 0) { this->ExtraGenerator->Generate(); @@ -850,6 +904,34 @@ void cmGlobalGenerator::Generate() this->CMakeInstance->UpdateProgress("Generating done", -1); } +//---------------------------------------------------------------------------- +bool cmGlobalGenerator::CheckTargets() +{ + // Make sure all targets can find their source files. + for(unsigned int i=0; i < this->LocalGenerators.size(); ++i) + { + cmTargets& targets = + this->LocalGenerators[i]->GetMakefile()->GetTargets(); + for(cmTargets::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + cmTarget& target = ti->second; + if(target.GetType() == cmTarget::EXECUTABLE || + target.GetType() == cmTarget::STATIC_LIBRARY || + target.GetType() == cmTarget::SHARED_LIBRARY || + target.GetType() == cmTarget::MODULE_LIBRARY || + target.GetType() == cmTarget::UTILITY) + { + if(!target.FindSourceFiles()) + { + return false; + } + } + } + } + return true; +} + void cmGlobalGenerator::CheckLocalGenerators() { std::map notFoundMap; @@ -1198,6 +1280,21 @@ void cmGlobalGenerator::AddTargetToExports(const char* exportSetName, } } +//---------------------------------------------------------------------------- +void cmGlobalGenerator::ClearExportSets() +{ + for(std::map >::iterator + setIt = this->ExportSets.begin(); + setIt != this->ExportSets.end(); ++setIt) + { + for(unsigned int i = 0; i < setIt->second.size(); ++i) + { + delete setIt->second[i]; + } + } + this->ExportSets.clear(); +} + const std::vector* cmGlobalGenerator::GetExportSet( const char* name) const { @@ -1476,7 +1573,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) cpackCommandLines.push_back(singleLine); if ( this->GetPreinstallTargetName() ) { - depends.push_back("preinstall"); + depends.push_back(this->GetPreinstallTargetName()); } else { @@ -1890,3 +1987,128 @@ cmGlobalGenerator::GetDirectoryContent(std::string const& dir, bool needDisk) return dc; } +//---------------------------------------------------------------------------- +void +cmGlobalGenerator::AddRuleHash(const std::vector& outputs, + std::vector::const_iterator first, + std::vector::const_iterator last) +{ +#if defined(CMAKE_BUILD_WITH_CMAKE) + // Ignore if there are no outputs. + if(outputs.empty()) + { + return; + } + + // Compute a hash of the rule. + RuleHash hash; + { + unsigned char const* data; + int length; + cmsysMD5* sum = cmsysMD5_New(); + cmsysMD5_Initialize(sum); + for(std::vector::const_iterator i = first; i != last; ++i) + { + data = reinterpret_cast(i->c_str()); + length = static_cast(i->length()); + cmsysMD5_Append(sum, data, length); + } + cmsysMD5_FinalizeHex(sum, hash.Data); + cmsysMD5_Delete(sum); + } + + // Shorten the output name (in expected use case). + cmLocalGenerator* lg = this->GetLocalGenerators()[0]; + std::string fname = lg->Convert(outputs[0].c_str(), + cmLocalGenerator::HOME_OUTPUT); + + // Associate the hash with this output. + this->RuleHashes[fname] = hash; +#else + (void)outputs; + (void)first; + (void)last; +#endif +} + +//---------------------------------------------------------------------------- +void cmGlobalGenerator::CheckRuleHashes() +{ +#if defined(CMAKE_BUILD_WITH_CMAKE) + std::string home = this->GetCMakeInstance()->GetHomeOutputDirectory(); + std::string pfile = home; + pfile += this->GetCMakeInstance()->GetCMakeFilesDirectory(); + pfile += "/CMakeRuleHashes.txt"; + +#if defined(_WIN32) || defined(__CYGWIN__) + std::ifstream fin(pfile.c_str(), std::ios::in | std::ios::binary); +#else + std::ifstream fin(pfile.c_str(), std::ios::in); +#endif + std::string line; + std::string fname; + while(cmSystemTools::GetLineFromStream(fin, line)) + { + // Line format is a 32-byte hex string followed by a space + // followed by a file name (with no escaping). + + // Skip blank and comment lines. + if(line.size() < 34 || line[0] == '#') + { + continue; + } + + // Get the filename. + fname = line.substr(33, line.npos); + + // Look for a hash for this file's rule. + std::map::const_iterator rhi = + this->RuleHashes.find(fname); + if(rhi != this->RuleHashes.end()) + { + // Compare the rule hash in the file to that we were given. + if(strncmp(line.c_str(), rhi->second.Data, 32) != 0) + { + // The rule has changed. Delete the output so it will be + // built again. + fname = cmSystemTools::CollapseFullPath(fname.c_str(), home.c_str()); + cmSystemTools::RemoveFile(fname.c_str()); + } + } + else + { + // We have no hash for a rule previously listed. This may be a + // case where a user has turned off a build option and might + // want to turn it back on later, so do not delete the file. + // Instead, we keep the rule hash as long as the file exists so + // that if the feature is turned back on and the rule has + // changed the file is still rebuilt. + std::string fpath = + cmSystemTools::CollapseFullPath(fname.c_str(), home.c_str()); + if(cmSystemTools::FileExists(fpath.c_str())) + { + RuleHash hash; + strncpy(hash.Data, line.c_str(), 32); + this->RuleHashes[fname] = hash; + } + } + } + + // Now generate a new persistence file with the current hashes. + if(this->RuleHashes.empty()) + { + cmSystemTools::RemoveFile(pfile.c_str()); + } + else + { + cmGeneratedFileStream fout(pfile.c_str()); + fout << "# Hashes of file build rules.\n"; + for(std::map::const_iterator + rhi = this->RuleHashes.begin(); rhi != this->RuleHashes.end(); ++rhi) + { + fout.write(rhi->second.Data, 32); + fout << " " << rhi->first << "\n"; + } + } +#endif +} diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index a0bea8dfb..97fd53466 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalGenerator.h,v $ Language: C++ - Date: $Date: 2008-02-14 21:42:29 $ - Version: $Revision: 1.107 $ + Date: $Date: 2008-07-17 14:14:25 $ + Version: $Revision: 1.107.2.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -139,6 +139,9 @@ public: void AddInstallComponent(const char* component); + const std::set* GetInstallComponents() const + { return &InstallComponents; } + ///! Add one installed target to the sets of the exports void AddTargetToExports(const char* exportSet, cmTarget* target, cmInstallTargetGenerator* archive, @@ -245,6 +248,10 @@ public: void FileReplacedDuringGenerate(const std::string& filename); void GetFilesReplacedDuringGenerate(std::vector& filenames); + void AddRuleHash(const std::vector& outputs, + std::vector::const_iterator first, + std::vector::const_iterator last); + protected: // for a project collect all its targets by following depend // information, and also collect all the targets @@ -257,9 +264,12 @@ protected: projectTargets); void SetLanguageEnabledFlag(const char* l, cmMakefile* mf); void SetLanguageEnabledMaps(const char* l, cmMakefile* mf); + void FillExtensionToLanguageMap(const char* l, cmMakefile* mf); virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS(); + bool CheckTargets(); + // Fill the ProjectMap, this must be called after LocalGenerators // has been populated. void FillProjectMap(); @@ -291,6 +301,7 @@ protected: bool InstallTargetEnabled; // Sets of named target exports std::map > ExportSets; + void ClearExportSets(); // Manifest of all targets that will be built for each configuration. // This is computed just before local generators generate. @@ -310,6 +321,11 @@ private: // this is used to improve performance std::map TotalTargets; + // Record hashes for rules and outputs. + struct RuleHash { char Data[32]; }; + std::map RuleHashes; + void CheckRuleHashes(); + cmExternalMakefileProjectGenerator* ExtraGenerator; // track files replaced during a Generate diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 91343aff2..491642bed 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalKdevelopGenerator.cxx,v $ Language: C++ - Date: $Date: 2008-03-30 13:09:22 $ - Version: $Revision: 1.29.2.1 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.29.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. Copyright (c) 2004 Alexander Neundorf neundorf@kde.org, All rights reserved. @@ -280,9 +280,9 @@ void cmGlobalKdevelopGenerator } else { - // add all subdirectories to the kdevelop blacklist - // so they are not monitored for added or removed files - // since this is basically handled by adding files to the cmake files + // add all subdirectories which are cmake build directories to the + // kdevelop blacklist so they are not monitored for added or removed files + // since this is handled by adding files to the cmake files cmsys::Directory d; if (d.Load(projectDir.c_str())) { @@ -297,7 +297,12 @@ void cmGlobalKdevelopGenerator tmp += nextFile; if (cmSystemTools::FileIsDirectory(tmp.c_str())) { - this->Blacklist.push_back(nextFile); + tmp += "/CMakeCache.txt"; + if ((nextFile == "CMakeFiles") + || (cmSystemTools::FileExists(tmp.c_str()))) + { + this->Blacklist.push_back(nextFile); + } } } } @@ -471,10 +476,12 @@ void cmGlobalKdevelopGenerator " false\n" " " << this->GlobalGenerator->GetLocalGenerators()[0]-> GetMakefile()->GetRequiredDefinition("CMAKE_BUILD_TOOL") - << " VERBOSE=1 \n" + << " \n" " default\n" " \n" - " \n" + " \n" + " \n" + " \n" " \n" " \n"; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index c0136cc54..2e8c87301 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator3 Module: $RCSfile: cmGlobalUnixMakefileGenerator3.cxx,v $ Language: C++ - Date: $Date: 2008-03-24 22:23:26 $ - Version: $Revision: 1.126.2.1 $ + Date: $Date: 2008-08-06 21:04:19 $ + Version: $Revision: 1.126.2.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -59,8 +59,11 @@ void cmGlobalUnixMakefileGenerator3 if(!mf->GetDefinition(langComp.c_str())) { - cmSystemTools::Error(langComp.c_str(), - " not set, after EnableLanguage"); + if(!optional) + { + cmSystemTools::Error(langComp.c_str(), + " not set, after EnableLanguage"); + } continue; } const char* name = mf->GetRequiredDefinition(langComp.c_str()); @@ -90,7 +93,7 @@ void cmGlobalUnixMakefileGenerator3 const char* cname = this->GetCMakeInstance()-> GetCacheManager()->GetCacheValue(langComp.c_str()); std::string changeVars; - if(cname && (path != cname)) + if(cname && (path != cname) && (optional==false)) { const char* cvars = this->GetCMakeInstance()->GetProperty( @@ -771,7 +774,7 @@ cmGlobalUnixMakefileGenerator3 cmLocalGenerator::FULL, cmLocalGenerator::SHELL); // - std::set emitted; + std::set emitted; progCmd << " " << this->GetTargetTotalNumberOfActions(t->second, emitted); @@ -848,13 +851,13 @@ cmGlobalUnixMakefileGenerator3 //---------------------------------------------------------------------------- int cmGlobalUnixMakefileGenerator3 -::GetTargetTotalNumberOfActions(cmTarget & target, - std::set &emitted) +::GetTargetTotalNumberOfActions(cmTarget &target, + std::set &emitted) { // do not double count int result = 0; - if(emitted.insert(target.GetName()).second) + if(emitted.insert(&target).second) { cmLocalUnixMakefileGenerator3 *lg = static_cast @@ -877,7 +880,7 @@ unsigned long cmGlobalUnixMakefileGenerator3 ::GetNumberOfProgressActionsInAll(cmLocalUnixMakefileGenerator3 *lg) { unsigned long result = 0; - std::set emitted; + std::set emitted; std::set& targets = this->LocalGeneratorToTargetMap[lg]; for(std::set::iterator t = targets.begin(); t != targets.end(); ++t) @@ -956,16 +959,16 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule } } } - std::vector const& localHelp = lg->GetLocalHelp(); - for(std::vector::const_iterator o = localHelp.begin(); - o != localHelp.end(); ++o) - { - path = "... "; - path += *o; - lg->AppendEcho(commands, path.c_str()); - } } } + std::vector const& localHelp = lg->GetLocalHelp(); + for(std::vector::const_iterator o = localHelp.begin(); + o != localHelp.end(); ++o) + { + path = "... "; + path += *o; + lg->AppendEcho(commands, path.c_str()); + } lg->WriteMakeRule(ruleFileStream, "Help Target", "help", no_depends, commands, true); diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 8c4fdcd6e..45f4ab413 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator3 Module: $RCSfile: cmGlobalUnixMakefileGenerator3.h,v $ Language: C++ - Date: $Date: 2008-02-14 21:42:29 $ - Version: $Revision: 1.55 $ + Date: $Date: 2008-06-13 12:55:17 $ + Version: $Revision: 1.55.2.1 $ Copyright (c) 2005 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -115,7 +115,7 @@ public: // returns some progress informaiton int GetTargetTotalNumberOfActions(cmTarget & target, - std::set &emitted); + std::set &emitted); unsigned long GetNumberOfProgressActionsInAll (cmLocalUnixMakefileGenerator3 *lg); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 27dea766d..113e96304 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalVisualStudio7Generator.cxx,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:39 $ - Version: $Revision: 1.99.2.1 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.99.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -743,6 +743,7 @@ static cmVS7FlagTable cmVS7ExtraFlagTable[] = cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, {"PrecompiledHeaderThrough", "Yu", "Precompiled Header Name", "", cmVS7FlagTable::UserValueRequired}, + {"WholeProgramOptimization", "LTCG", "WholeProgramOptimization", "TRUE", 0}, // Exception handling mode. If no entries match, it will be FALSE. {"ExceptionHandling", "GX", "enable c++ exceptions", "TRUE", 0}, diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index fa7185df3..5ff32878e 100755 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalVisualStudioGenerator.cxx,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:39 $ - Version: $Revision: 1.11.2.1 $ + Date: $Date: 2008-07-31 15:52:24 $ + Version: $Revision: 1.11.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -178,14 +178,16 @@ cmGlobalVisualStudioGenerator projects += ";"; projects += *it; } - cmCallVisualStudioMacro::CallMacro - (topLevelSlnName, CMAKE_VSMACROS_RELOAD_MACRONAME, projects); + cmCallVisualStudioMacro::CallMacro(topLevelSlnName, + CMAKE_VSMACROS_RELOAD_MACRONAME, projects, + this->GetCMakeInstance()->GetDebugOutput()); } } else if(m == MacroStop) { cmCallVisualStudioMacro::CallMacro(topLevelSlnName, - CMAKE_VSMACROS_STOP_MACRONAME, ""); + CMAKE_VSMACROS_STOP_MACRONAME, "", + this->GetCMakeInstance()->GetDebugOutput()); } } } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8265dd384..e04ed4dbe 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalXCodeGenerator.cxx,v $ Language: C++ -Date: $Date: 2008-05-01 16:35:39 $ -Version: $Revision: 1.186.2.2 $ +Date: $Date: 2008-09-12 14:56:21 $ +Version: $Revision: 1.186.2.8 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -452,7 +452,6 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, lg->AppendFlags(flags, cmtarget.GetProperty("COMPILE_FLAGS")); } lg->AppendFlags(flags, sf->GetProperty("COMPILE_FLAGS")); - cmSystemTools::ReplaceString(flags, "\"", "\\\""); // Add per-source definitions. this->AppendDefines(flags, sf->GetProperty("COMPILE_DEFINITIONS"), true); @@ -527,11 +526,13 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, buildFile->AddAttribute("settings", settings); fileRef->AddAttribute("fileEncoding", this->CreateString("4")); + const char* lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf); std::string sourcecode = "sourcecode"; std::string ext = sf->GetExtension(); ext = cmSystemTools::LowerCase(ext); + if(ext == "o") { sourcecode = "compiled.mach-o.objfile"; @@ -542,41 +543,50 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, } else if(ext == "m") { - sourcecode += ".cpp.objc"; + sourcecode += ".c.objc"; } else if(ext == "plist") { sourcecode += ".text.plist"; } - else if(!lang) - { - sourcecode += ext; - sourcecode += "."; - sourcecode += ext; - } - else if(strcmp(lang, "C") == 0) + else if(ext == "h" || ext == "hxx" || ext == "hpp") { - sourcecode += ".c.c"; + const char* linkLanguage = cmtarget.GetLinkerLanguage(this); + if(linkLanguage && (std::string(linkLanguage) == "CXX")) + { + sourcecode += ".cpp.h"; + } + else + { + sourcecode += ".c.h"; + } } - else if(strcmp(lang, "CXX") == 0) + else if(lang && strcmp(lang, "CXX") == 0) { sourcecode += ".cpp.cpp"; } - else + else if(lang && strcmp(lang, "C") == 0) { - sourcecode += ext; - sourcecode += "."; - sourcecode += ext; + sourcecode += ".c.c"; } + //else + // { + // // Already specialized above or we leave sourcecode == "sourcecode" + // // which is probably the most correct choice. Extensionless headers, + // // for example... Or file types unknown to Xcode that do not map to a + // // valid lastKnownFileType value. + // } + fileRef->AddAttribute("lastKnownFileType", this->CreateString(sourcecode.c_str())); - std::string path = + + std::string path = this->ConvertToRelativeForXCode(sf->GetFullPath().c_str()); std::string dir; std::string file; cmSystemTools::SplitProgramPath(sf->GetFullPath().c_str(), dir, file); - + fileRef->AddAttribute("name", this->CreateString(file.c_str())); fileRef->AddAttribute("path", this->CreateString(path.c_str())); if(this->XcodeVersion == 15) @@ -591,6 +601,7 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, { fileRef->AddAttribute("sourceTree", this->CreateString("")); } + return buildFile; } @@ -690,11 +701,13 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, cmTarget::SourceFileFlags tsFlags = cmtarget.GetTargetSourceFileFlags(*i); - if(strcmp(filetype->GetString(), "\"compiled.mach-o.objfile\"") == 0) + if(strcmp(filetype->GetString(), "compiled.mach-o.objfile") == 0) { externalObjFiles.push_back(xsf); } - else if((*i)->GetPropertyAsBool("HEADER_FILE_ONLY")) + else if((*i)->GetPropertyAsBool("HEADER_FILE_ONLY") || + (tsFlags.Type == cmTarget::SourceFileTypePrivateHeader) || + (tsFlags.Type == cmTarget::SourceFileTypePublicHeader)) { headerFiles.push_back(xsf); } @@ -704,7 +717,14 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, } else { - sourceFiles.push_back(xsf); + // Include this file in the build if it has a known language + // and has not been listed as an ignored extension for this + // generator. + if(this->CurrentLocalGenerator->GetSourceFileLanguage(**i) && + !this->IgnoreFile((*i)->GetExtension().c_str())) + { + sourceFiles.push_back(xsf); + } } } @@ -997,7 +1017,7 @@ std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag, { std::string retFlag; std::string::size_type pos = flags.find(flag); - if(pos != flags.npos) + if(pos != flags.npos && (pos ==0 || flags[pos-1]==' ')) { while(pos < flags.size() && flags[pos] != ' ') { @@ -1290,9 +1310,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CurrentLocalGenerator-> AppendFlags(defFlags, this->CurrentMakefile->GetDefineFlags()); - cmSystemTools::ReplaceString(defFlags, "\"", "\\\""); - cmSystemTools::ReplaceString(flags, "\"", "\\\""); - cmSystemTools::ReplaceString(cflags, "\"", "\\\""); // Add preprocessor definitions for this target and configuration. std::string ppDefs; @@ -1433,6 +1450,18 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string version = target.GetFrameworkVersion(); buildSettings->AddAttribute("FRAMEWORK_VERSION", this->CreateString(version.c_str())); + + 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 + // a per-configuration Info.plist file. + this->CurrentLocalGenerator + ->GenerateFrameworkInfoPList(&target, "$(EXECUTABLE_NAME)", + plist.c_str()); + std::string path = + this->ConvertToRelativeForXCode(plist.c_str()); + buildSettings->AddAttribute("INFOPLIST_FILE", + this->CreateString(path.c_str())); } else { @@ -1452,10 +1481,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("DYNAMIC")); - buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION", - this->CreateString("1")); - buildSettings->AddAttribute("DYLIB_CURRENT_VERSION", - this->CreateString("1")); break; } case cmTarget::EXECUTABLE: @@ -1475,13 +1500,13 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, if(target.GetPropertyAsBool("MACOSX_BUNDLE")) { productType = "com.apple.product-type.application"; - std::string plist = this->CurrentMakefile->GetCurrentOutputDirectory(); - plist += cmake::GetCMakeFilesDirectory(); - plist += "/"; - plist += target.GetName(); - plist += "Info.plist"; + std::string plist = this->ComputeInfoPListLocation(target); + // Xcode will create the final version of Info.plist at build time, + // so let it replace the executable name. This avoids creating + // a per-configuration Info.plist file. this->CurrentLocalGenerator - ->GenerateAppleInfoPList(&target, productName.c_str(), plist.c_str()); + ->GenerateAppleInfoPList(&target, "$(EXECUTABLE_NAME)", + plist.c_str()); std::string path = this->ConvertToRelativeForXCode(plist.c_str()); buildSettings->AddAttribute("INFOPLIST_FILE", @@ -1673,6 +1698,38 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString( "-Wmost -Wno-four-char-constants" " -Wno-unknown-pragmas")); + + // Runtime version information. + if(target.GetType() == cmTarget::SHARED_LIBRARY) + { + int major; + int minor; + int patch; + + // VERSION -> current_version + target.GetTargetVersion(false, major, minor, patch); + if(major == 0 && minor == 0 && patch == 0) + { + // Xcode always wants at least 1.0.0 + major = 1; + } + cmOStringStream v; + v << major << "." << minor << "." << patch; + buildSettings->AddAttribute("DYLIB_CURRENT_VERSION", + this->CreateString(v.str().c_str())); + + // SOVERSION -> compatibility_version + target.GetTargetVersion(true, major, minor, patch); + if(major == 0 && minor == 0 && patch == 0) + { + // Xcode always wants at least 1.0.0 + major = 1; + } + cmOStringStream vso; + vso << major << "." << minor << "." << patch; + buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION", + this->CreateString(vso.str().c_str())); + } } //---------------------------------------------------------------------------- @@ -1926,22 +1983,8 @@ void cmGlobalXCodeGenerator::AppendOrAddBuildSetting(cmXCodeObject* settings, else { std::string oldValue = attr->GetString(); - - // unescape escaped quotes internal to the string: - cmSystemTools::ReplaceString(oldValue, "\\\"", "\""); - - // remove surrounding quotes, if any: - std::string::size_type len = oldValue.length(); - if(oldValue[0] == '\"' && oldValue[len-1] == '\"') - { - oldValue = oldValue.substr(1, len-2); - } - oldValue += " "; oldValue += value; - - // SetString automatically escapes internal quotes and then surrounds - // the result with quotes if necessary... attr->SetString(oldValue.c_str()); } } @@ -2209,11 +2252,8 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, // MACOSX_BUNDLE file if(cmtarget.GetPropertyAsBool("MACOSX_BUNDLE")) { - std::string plistFile = - this->CurrentMakefile->GetCurrentOutputDirectory(); - plistFile += "/Info.plist"; - cmSourceFile* sf = - this->CurrentMakefile->GetOrCreateSource(plistFile.c_str(), true); + std::string plist = this->ComputeInfoPListLocation(cmtarget); + cmSourceFile* sf = mf->GetOrCreateSource(plist.c_str(), true); cmtarget.AddSourceFile(sf); } @@ -2402,6 +2442,13 @@ void cmGlobalXCodeGenerator this->RootObject->AddAttribute("buildStyles", listObjs); this->RootObject->AddAttribute("hasScannedForEncodings", this->CreateString("0")); + // Point Xcode at the top of the source tree. + { + std::string proot = root->GetMakefile()->GetCurrentDirectory(); + proot = this->ConvertToRelativeForXCode(proot.c_str()); + this->RootObject->AddAttribute("projectRoot", + this->CreateString(proot.c_str())); + } cmXCodeObject* configlist = this->CreateObject(cmXCodeObject::XCConfigurationList); cmXCodeObject* buildConfigurations = @@ -2582,9 +2629,14 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( t->GetType() == cmTarget::SHARED_LIBRARY || t->GetType() == cmTarget::MODULE_LIBRARY) { + std::string tfull = t->GetFullPath(configName); + if(t->IsAppBundleOnApple()) + { + tfull += ".app/Contents/MacOS/"; + tfull += t->GetFullName(configName); + } makefileStream << "\\\n\t" << - this->ConvertToRelativeForMake( - t->GetFullPath(configName).c_str()); + this->ConvertToRelativeForMake(tfull.c_str()); } } makefileStream << "\n\n"; @@ -2640,6 +2692,11 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( { // Create a rule for this target. std::string tfull = t->GetFullPath(configName); + if(t->IsAppBundleOnApple()) + { + tfull += ".app/Contents/MacOS/"; + tfull += t->GetFullName(configName); + } makefileStream << this->ConvertToRelativeForMake(tfull.c_str()) << ":"; @@ -2961,3 +3018,15 @@ void cmGlobalXCodeGenerator::AppendDefines(std::string& defs, defs += "'"; } } + +//---------------------------------------------------------------------------- +std::string +cmGlobalXCodeGenerator::ComputeInfoPListLocation(cmTarget& target) +{ + std::string plist = target.GetMakefile()->GetCurrentOutputDirectory(); + plist += cmake::GetCMakeFilesDirectory(); + plist += "/"; + plist += target.GetName(); + plist += ".dir/Info.plist"; + return plist; +} diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index a9eadf2b7..c2599d999 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmGlobalXCodeGenerator.h,v $ Language: C++ - Date: $Date: 2008-01-14 14:20:57 $ - Version: $Revision: 1.52 $ + Date: $Date: 2008-07-13 21:55:23 $ + Version: $Revision: 1.52.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -103,6 +103,8 @@ private: cmXCodeObject* frameworkBuildPhase, cmTarget& cmtarget); + std::string ComputeInfoPListLocation(cmTarget& target); + void AddCommandsToBuildPhase(cmXCodeObject* buildphase, cmTarget& target, std::vector diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 09281d41e..f6cc35d39 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmIfCommand.cxx,v $ Language: C++ - Date: $Date: 2008-03-24 22:23:26 $ - Version: $Revision: 1.84.2.1 $ + Date: $Date: 2008-09-12 14:56:21 $ + Version: $Revision: 1.84.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -235,6 +235,33 @@ namespace } } } + + enum Op { OpLess, OpEqual, OpGreater }; + bool HandleVersionCompare(Op op, const char* lhs_str, const char* rhs_str) + { + // Parse out up to 4 components. + unsigned int lhs[4] = {0,0,0,0}; + unsigned int rhs[4] = {0,0,0,0}; + sscanf(lhs_str, "%u.%u.%u.%u", &lhs[0], &lhs[1], &lhs[2], &lhs[3]); + sscanf(rhs_str, "%u.%u.%u.%u", &rhs[0], &rhs[1], &rhs[2], &rhs[3]); + + // Do component-wise comparison. + for(unsigned int i=0; i < 4; ++i) + { + if(lhs[i] < rhs[i]) + { + // lhs < rhs, so true if operation is LESS + return op == OpLess; + } + else if(lhs[i] > rhs[i]) + { + // lhs > rhs, so true if operation is GREATER + return op == OpGreater; + } + } + // lhs == rhs, so true if operation is EQUAL + return op == OpEqual; + } } @@ -340,7 +367,7 @@ bool cmIfCommand::IsTrue(const std::vector &args, argP1 = arg; IncrementArguments(newArgs,argP1,argP2); reducible = 1; - } + } // does a command exist if (*arg == "COMMAND" && argP1 != newArgs.end()) { @@ -357,6 +384,22 @@ bool cmIfCommand::IsTrue(const std::vector &args, IncrementArguments(newArgs,argP1,argP2); reducible = 1; } + // does a target exist + if (*arg == "TARGET" && argP1 != newArgs.end()) + { + if(makefile->FindTargetToUse((argP1)->c_str())) + { + *arg = "1"; + } + else + { + *arg = "0"; + } + newArgs.erase(argP1); + argP1 = arg; + IncrementArguments(newArgs,argP1,argP2); + reducible = 1; + } // does a policy exist if (*arg == "POLICY" && argP1 != newArgs.end()) { @@ -549,6 +592,37 @@ bool cmIfCommand::IsTrue(const std::vector &args, reducible = 1; } + if (argP1 != newArgs.end() && argP2 != newArgs.end() && + (*(argP1) == "VERSION_LESS" || *(argP1) == "VERSION_GREATER" || + *(argP1) == "VERSION_EQUAL")) + { + def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile); + def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile); + Op op = OpEqual; + if(*argP1 == "VERSION_LESS") + { + op = OpLess; + } + else if(*argP1 == "VERSION_GREATER") + { + op = OpGreater; + } + bool result = HandleVersionCompare(op, def, def2); + if(result) + { + *arg = "1"; + } + else + { + *arg = "0"; + } + newArgs.erase(argP2); + newArgs.erase(argP1); + argP1 = arg; + IncrementArguments(newArgs,argP1,argP2); + reducible = 1; + } + // is file A newer than file B if (argP1 != newArgs.end() && argP2 != newArgs.end() && *(argP1) == "IS_NEWER_THAN") diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index 9201d62f6..28bc36b90 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmIfCommand.h,v $ Language: C++ - Date: $Date: 2008-03-24 22:23:26 $ - Version: $Revision: 1.46.2.1 $ + Date: $Date: 2008-09-12 14:56:21 $ + Version: $Revision: 1.46.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -142,6 +142,8 @@ public: " if(POLICY policy-id)\n" "True if the given name is an existing policy " "(of the form CMP).\n" + " if(TARGET target-name)\n" + "True if the given name is an existing target, built or imported.\n" " if(EXISTS file-name)\n" " if(EXISTS directory-name)\n" "True if the named file or directory exists. " @@ -175,6 +177,11 @@ public: " if(string STREQUAL string)\n" "True if the given string or variable's value is lexicographically " "less (or greater, or equal) than the string on the right.\n" + " if(version1 VERSION_LESS version2)\n" + " if(version1 VERSION_EQUAL version2)\n" + " if(version1 VERSION_GREATER version2)\n" + "Component-wise integer version number comparison (version format is " + "major[.minor[.patch[.tweak]]]).\n" " if(DEFINED variable)\n" "True if the given variable is defined. It does not matter if the " "variable is true or false just if it has been set."; diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 01be56c27..1de7f849e 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmInstallCommand.cxx,v $ Language: C++ - Date: $Date: 2008-04-23 16:14:33 $ - Version: $Revision: 1.45.2.2 $ + Date: $Date: 2008-07-13 21:55:23 $ + Version: $Revision: 1.45.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -384,6 +384,17 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) } } + // Keep track of whether we will be performing an installation of + // any files of the given type. + bool installsArchive = false; + bool installsLibrary = false; + bool installsRuntime = false; + bool installsFramework = false; + bool installsBundle = false; + bool installsPrivateHeader = false; + bool installsPublicHeader = false; + bool installsResource = false; + // Generate install script code to install the given targets. for(std::vector::iterator ti = targets.begin(); ti != targets.end(); ++ti) @@ -691,6 +702,16 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) } } + // Keep track of whether we're installing anything in each category + installsArchive = installsArchive || archiveGenerator != 0; + installsLibrary = installsLibrary || libraryGenerator != 0; + installsRuntime = installsRuntime || runtimeGenerator != 0; + installsFramework = installsFramework || frameworkGenerator != 0; + installsBundle = installsBundle || bundleGenerator != 0; + installsPrivateHeader = installsPrivateHeader || privateHeaderGenerator != 0; + installsPublicHeader = installsPublicHeader || publicHeaderGenerator != 0; + installsResource = installsResource || resourceGenerator; + this->Makefile->AddInstallGenerator(archiveGenerator); this->Makefile->AddInstallGenerator(libraryGenerator); this->Makefile->AddInstallGenerator(runtimeGenerator); @@ -713,22 +734,46 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) } // Tell the global generator about any installation component names specified - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(archiveArgs.GetComponent().c_str()); - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(libraryArgs.GetComponent().c_str()); - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(runtimeArgs.GetComponent().c_str()); - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(frameworkArgs.GetComponent().c_str()); - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(bundleArgs.GetComponent().c_str()); - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(privateHeaderArgs.GetComponent().c_str()); - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(publicHeaderArgs.GetComponent().c_str()); - this->Makefile->GetLocalGenerator()->GetGlobalGenerator() - ->AddInstallComponent(resourceArgs.GetComponent().c_str()); + if (installsArchive) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(archiveArgs.GetComponent().c_str()); + } + if (installsLibrary) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(libraryArgs.GetComponent().c_str()); + } + if (installsRuntime) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(runtimeArgs.GetComponent().c_str()); + } + if (installsFramework) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(frameworkArgs.GetComponent().c_str()); + } + if (installsBundle) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(bundleArgs.GetComponent().c_str()); + } + if (installsPrivateHeader) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(privateHeaderArgs.GetComponent().c_str()); + } + if (installsPublicHeader) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(publicHeaderArgs.GetComponent().c_str()); + } + if (installsResource) + { + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent(resourceArgs.GetComponent().c_str()); + } return true; } diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx index 4d9f77749..9af993e01 100644 --- a/Source/cmInstallFilesCommand.cxx +++ b/Source/cmInstallFilesCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmInstallFilesCommand.cxx,v $ Language: C++ - Date: $Date: 2008-01-28 13:38:35 $ - Version: $Revision: 1.29 $ + Date: $Date: 2008-07-13 21:55:24 $ + Version: $Revision: 1.29.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -59,6 +59,9 @@ bool cmInstallFilesCommand } } + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent("Unspecified"); + return true; } @@ -126,7 +129,7 @@ void cmInstallFilesCommand::CreateInstallGenerator() const // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; - const char* no_component = ""; + const char* no_component = "Unspecified"; std::vector no_configurations; this->Makefile->AddInstallGenerator( new cmInstallFilesGenerator(this->Files, diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx index 9b46c23d9..02aedb813 100644 --- a/Source/cmInstallProgramsCommand.cxx +++ b/Source/cmInstallProgramsCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmInstallProgramsCommand.cxx,v $ Language: C++ - Date: $Date: 2008-02-16 18:05:03 $ - Version: $Revision: 1.22 $ + Date: $Date: 2008-07-13 21:55:24 $ + Version: $Revision: 1.22.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -38,6 +38,9 @@ bool cmInstallProgramsCommand this->FinalArgs.push_back(*s); } + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent("Unspecified"); + return true; } @@ -87,7 +90,7 @@ void cmInstallProgramsCommand::FinalPass() // Use a file install generator. const char* no_permissions = ""; const char* no_rename = ""; - const char* no_component = ""; + const char* no_component = "Unspecified"; std::vector no_configurations; this->Makefile->AddInstallGenerator( new cmInstallFilesGenerator(this->Files, diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index a349c8bde..8aa60feb5 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmInstallTargetGenerator.cxx,v $ Language: C++ - Date: $Date: 2008-04-21 00:44:51 $ - Version: $Revision: 1.62.2.2 $ + Date: $Date: 2008-05-29 13:15:30 $ + Version: $Revision: 1.62.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -200,6 +200,12 @@ cmInstallTargetGenerator } else { + // Operations done at install time on the installed file should + // be done on the real file and not any of the symlinks. + toInstallPath = this->GetInstallDestination(); + toInstallPath += "/"; + toInstallPath += targetNameReal; + files.push_back(from1); if(targetNameReal != targetName) { diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index a6e89b277..1530346f5 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmInstallTargetGenerator.h,v $ Language: C++ - Date: $Date: 2008-04-21 00:44:52 $ - Version: $Revision: 1.24.2.1 $ + Date: $Date: 2008-07-13 21:55:24 $ + Version: $Revision: 1.24.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -31,7 +31,7 @@ public: const char* file_permissions = "", std::vector const& configurations = std::vector(), - const char* component = "", + const char* component = "Unspecified", bool optional = false ); virtual ~cmInstallTargetGenerator(); diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx index 911fe11c7..41712ad4b 100644 --- a/Source/cmInstallTargetsCommand.cxx +++ b/Source/cmInstallTargetsCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmInstallTargetsCommand.cxx,v $ Language: C++ - Date: $Date: 2008-01-23 15:27:59 $ - Version: $Revision: 1.15 $ + Date: $Date: 2008-07-13 21:55:24 $ + Version: $Revision: 1.15.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -62,6 +62,9 @@ bool cmInstallTargetsCommand } } + this->Makefile->GetLocalGenerator()->GetGlobalGenerator() + ->AddInstallComponent("Unspecified"); + return true; } diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 988cd358d..9ef9ef874 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmListCommand.cxx,v $ Language: C++ - Date: $Date: 2008-04-23 16:14:33 $ - Version: $Revision: 1.18.2.3 $ + Date: $Date: 2008-05-23 20:09:36 $ + Version: $Revision: 1.18.2.5 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -212,13 +212,12 @@ bool cmListCommand::HandleGetCommand(std::vector const& args) std::string value; size_t cc; + const char* sep = ""; for ( cc = 2; cc < args.size()-1; cc ++ ) { int item = atoi(args[cc].c_str()); - if (value.size()) - { - value += ";"; - } + value += sep; + sep = ";"; size_t nitem = varArgsExpanded.size(); if ( item < 0 ) { @@ -262,7 +261,7 @@ bool cmListCommand::HandleAppendCommand(std::vector const& args) size_t cc; for ( cc = 2; cc < args.size(); ++ cc ) { - if ( listString.size() ) + if(listString.size()) { listString += ";"; } @@ -358,13 +357,12 @@ bool cmListCommand::HandleInsertCommand(std::vector const& args) } std::string value; + const char* sep = ""; for ( cc = 0; cc < varArgsExpanded.size(); cc ++ ) { - if (value.size()) - { - value += ";"; - } + value += sep; value += varArgsExpanded[cc]; + sep = ";"; } this->Makefile->AddDefinition(listName.c_str(), value.c_str()); @@ -408,13 +406,12 @@ bool cmListCommand } std::string value; + const char* sep = ""; for ( cc = 0; cc < varArgsExpanded.size(); cc ++ ) { - if (value.size()) - { - value += ";"; - } + value += sep; value += varArgsExpanded[cc]; + sep = ";"; } this->Makefile->AddDefinition(listName.c_str(), value.c_str()); @@ -442,13 +439,12 @@ bool cmListCommand std::string value; std::vector::reverse_iterator it; + const char* sep = ""; for ( it = varArgsExpanded.rbegin(); it != varArgsExpanded.rend(); ++ it ) { - if (value.size()) - { - value += ";"; - } + value += sep; value += it->c_str(); + sep = ";"; } this->Makefile->AddDefinition(listName.c_str(), value.c_str()); @@ -478,26 +474,10 @@ bool cmListCommand std::string value; -#if 0 - // Fast version, but does not keep the ordering - - std::set unique(varArgsExpanded.begin(), varArgsExpanded.end()); - std::set::iterator it; - for ( it = unique.begin(); it != unique.end(); ++ it ) - { - if (value.size()) - { - value += ";"; - } - value += it->c_str(); - } - -#else - - // Slower version, keep the ordering std::set unique; std::vector::iterator it; + const char* sep = ""; for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it ) { if (unique.find(*it) != unique.end()) @@ -505,14 +485,10 @@ bool cmListCommand continue; } unique.insert(*it); - - if (value.size()) - { - value += ";"; - } + value += sep; value += it->c_str(); + sep = ";"; } -#endif this->Makefile->AddDefinition(listName.c_str(), value.c_str()); @@ -542,13 +518,12 @@ bool cmListCommand std::string value; std::vector::iterator it; + const char* sep = ""; for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it ) { - if (value.size()) - { - value += ";"; - } + value += sep; value += it->c_str(); + sep = ";"; } this->Makefile->AddDefinition(listName.c_str(), value.c_str()); @@ -598,6 +573,7 @@ bool cmListCommand::HandleRemoveAtCommand( } std::string value; + const char* sep = ""; for ( cc = 0; cc < varArgsExpanded.size(); ++ cc ) { size_t kk; @@ -612,11 +588,9 @@ bool cmListCommand::HandleRemoveAtCommand( if ( !found ) { - if (value.size()) - { - value += ";"; - } + value += sep; value += varArgsExpanded[cc]; + sep = ";"; } } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 1428951d6..2d4dd3952 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalGenerator.cxx,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:39 $ - Version: $Revision: 1.269.2.2 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.269.2.7 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -101,6 +101,43 @@ void cmLocalGenerator::Configure() // relative paths. this->UseRelativePaths = this->Makefile->IsOn("CMAKE_USE_RELATIVE_PATHS"); + // Choose a maximum object file name length. + { +#if defined(_WIN32) || defined(__CYGWIN__) + this->ObjectPathMax = 250; +#else + this->ObjectPathMax = 1000; +#endif + const char* plen = this->Makefile->GetDefinition("CMAKE_OBJECT_PATH_MAX"); + if(plen && *plen) + { + unsigned int pmax; + if(sscanf(plen, "%u", &pmax) == 1) + { + if(pmax >= 128) + { + this->ObjectPathMax = pmax; + } + else + { + cmOStringStream w; + w << "CMAKE_OBJECT_PATH_MAX is set to " << pmax + << ", which is less than the minimum of 128. " + << "The value will be ignored."; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } + } + else + { + cmOStringStream w; + w << "CMAKE_OBJECT_PATH_MAX is set to \"" << plen + << "\", which fails to parse as a positive integer. " + << "The value will be ignored."; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } + } + } + this->Configured = true; this->GetGlobalGenerator()->SetCurrentLocalGenerator(previousLg); @@ -723,11 +760,7 @@ void cmLocalGenerator } } break; - case cmTarget::UTILITY: - case cmTarget::GLOBAL_TARGET: - case cmTarget::INSTALL_FILES: - case cmTarget::INSTALL_PROGRAMS: - case cmTarget::INSTALL_DIRECTORY: + default: break; } } @@ -1441,11 +1474,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } } break; - case cmTarget::UTILITY: - case cmTarget::GLOBAL_TARGET: - case cmTarget::INSTALL_FILES: - case cmTarget::INSTALL_PROGRAMS: - case cmTarget::INSTALL_DIRECTORY: + default: break; } } @@ -1573,7 +1602,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, ri != runtimeDirs.end(); ++ri) { rpath += cli.GetRuntimeFlag(); - rpath += this->Convert(ri->c_str(), FULL, SHELL, false); + rpath += this->Convert(ri->c_str(), NONE, SHELL, false); rpath += " "; } fout << rpath; @@ -1630,7 +1659,7 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, const char* sysrootDefault = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT"); bool flagsUsed = false; - if(osxArch && sysroot && lang && lang[0] =='C') + if(osxArch && sysroot && lang && (lang[0] =='C' || lang[0] == 'F')) { std::vector archs; cmSystemTools::ExpandListArgument(std::string(osxArch), @@ -1714,6 +1743,7 @@ std::string cmLocalGenerator::GetRealDependency(const char* inName, case cmTarget::STATIC_LIBRARY: case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: + case cmTarget::UNKNOWN_LIBRARY: { // Get the location of the target's output file and depend on it. if(const char* location = target->GetLocation(config)) @@ -1740,6 +1770,15 @@ std::string cmLocalGenerator::GetRealDependency(const char* inName, // This is a full path. Return it as given. return inName; } + + // Check for a source file in this directory that matches the + // dependency. + if(cmSourceFile* sf = this->Makefile->GetSource(inName)) + { + name = sf->GetFullPath(); + return name; + } + // Treat the name as relative to the source directory in which it // was given. name = this->Makefile->GetCurrentDirectory(); @@ -2312,16 +2351,11 @@ cmLocalGeneratorShortenObjectName(std::string& objName, } } -static bool cmLocalGeneratorCheckObjectName(std::string& objName, - std::string::size_type dir_len) +static +bool cmLocalGeneratorCheckObjectName(std::string& objName, + std::string::size_type dir_len, + std::string::size_type max_total_len) { - // Choose a maximum file name length. -#if defined(_WIN32) || defined(__CYGWIN__) - std::string::size_type const max_total_len = 250; -#else - std::string::size_type const max_total_len = 1000; -#endif - // Enforce the maximum file name length if possible. std::string::size_type max_obj_len = max_total_len; if(dir_len < max_total_len) @@ -2365,7 +2399,9 @@ cmLocalGenerator // Avoid full paths by removing leading slashes. std::string::size_type pos = 0; - for(;pos < ssin.size() && ssin[pos] == '/'; ++pos); + for(;pos < ssin.size() && ssin[pos] == '/'; ++pos) + { + } ssin = ssin.substr(pos); // Avoid full paths by removing colons. @@ -2410,7 +2446,7 @@ cmLocalGenerator } #if defined(CM_LG_ENCODE_OBJECT_NAMES) - cmLocalGeneratorCheckObjectName(ssin, dir_len); + cmLocalGeneratorCheckObjectName(ssin, dir_len, this->ObjectPathMax); #else (void)dir_len; #endif @@ -2577,7 +2613,7 @@ std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars, { flags |= cmsysSystem_Shell_Flag_VSIDE; } - else + else if(!this->LinkScriptShell) { flags |= cmsysSystem_Shell_Flag_Make; } @@ -2776,16 +2812,11 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const } //---------------------------------------------------------------------------- -static std::string cmLGInfoProp(cmTarget* target, const char* prop) +static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, const char* prop) { if(const char* val = target->GetProperty(prop)) { - return val; - } - else - { - // For compatibility check for a variable. - return target->GetMakefile()->GetSafeDefinition(prop); + mf->AddDefinition(prop, val); } } @@ -2794,66 +2825,81 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target, const char* targetName, const char* fname) { - std::string info_EXECUTABLE_NAME = targetName; - - // Lookup the properties. - std::string info_INFO_STRING = - cmLGInfoProp(target, "MACOSX_BUNDLE_INFO_STRING"); - std::string info_ICON_FILE = - cmLGInfoProp(target, "MACOSX_BUNDLE_ICON_FILE"); - std::string info_GUI_IDENTIFIER = - cmLGInfoProp(target, "MACOSX_BUNDLE_GUI_IDENTIFIER"); - std::string info_LONG_VERSION_STRING = - cmLGInfoProp(target, "MACOSX_BUNDLE_LONG_VERSION_STRING"); - std::string info_BUNDLE_NAME = - cmLGInfoProp(target, "MACOSX_BUNDLE_BUNDLE_NAME"); - std::string info_SHORT_VERSION_STRING = - cmLGInfoProp(target, "MACOSX_BUNDLE_SHORT_VERSION_STRING"); - std::string info_BUNDLE_VERSION = - cmLGInfoProp(target, "MACOSX_BUNDLE_BUNDLE_VERSION"); - std::string info_COPYRIGHT = - cmLGInfoProp(target, "MACOSX_BUNDLE_COPYRIGHT"); - - // Generate the file. - cmGeneratedFileStream fout(fname); - fout.SetCopyIfDifferent(true); - fout << - "\n" - "\n" - "\n" - "\n" - "\tCFBundleDevelopmentRegion\n" - "\tEnglish\n" - "\tCFBundleExecutable\n" - "\t" << info_EXECUTABLE_NAME << "\n" - "\tCFBundleGetInfoString\n" - "\t" << info_INFO_STRING << "\n" - "\tCFBundleIconFile\n" - "\t" << info_ICON_FILE << "\n" - "\tCFBundleIdentifier\n" - "\t" << info_GUI_IDENTIFIER << "\n" - "\tCFBundleInfoDictionaryVersion\n" - "\t6.0\n" - "\tCFBundleLongVersionString\n" - "\t" << info_LONG_VERSION_STRING << "\n" - "\tCFBundleName\n" - "\t" << info_BUNDLE_NAME << "\n" - "\tCFBundlePackageType\n" - "\tAPPL\n" - "\tCFBundleShortVersionString\n" - "\t" << info_SHORT_VERSION_STRING << "\n" - "\tCFBundleSignature\n" - "\t????" /* break string to avoid trigraph */ "\n" - "\tCFBundleVersion\n" - "\t" << info_BUNDLE_VERSION << "\n" - "\tCSResourcesFileMapped\n" - "\t\n" - "\tLSRequiresCarbon\n" - "\t\n" - "\tNSHumanReadableCopyright\n" - "\t" << info_COPYRIGHT << "\n" - "\n" - "\n" - ; + // Find the Info.plist template. + const char* in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST"); + std::string inFile = (in && *in)? in : "MacOSXBundleInfo.plist.in"; + if(!cmSystemTools::FileIsFullPath(inFile.c_str())) + { + std::string inMod = this->Makefile->GetModulesFile(inFile.c_str()); + if(!inMod.empty()) + { + inFile = inMod; + } + } + if(!cmSystemTools::FileExists(inFile.c_str(), true)) + { + cmOStringStream e; + e << "Target " << target->GetName() << " Info.plist template \"" + << inFile << "\" could not be found."; + cmSystemTools::Error(e.str().c_str()); + return; + } + + // Convert target properties to variables in an isolated makefile + // scope to configure the file. If properties are set they will + // override user make variables. If not the configuration will fall + // back to the directory-level values set by the user. + cmMakefile* mf = this->Makefile; + mf->PushScope(); + mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName); + cmLGInfoProp(mf, target, "MACOSX_BUNDLE_INFO_STRING"); + cmLGInfoProp(mf, target, "MACOSX_BUNDLE_ICON_FILE"); + cmLGInfoProp(mf, target, "MACOSX_BUNDLE_GUI_IDENTIFIER"); + cmLGInfoProp(mf, target, "MACOSX_BUNDLE_LONG_VERSION_STRING"); + cmLGInfoProp(mf, target, "MACOSX_BUNDLE_BUNDLE_NAME"); + cmLGInfoProp(mf, target, "MACOSX_BUNDLE_SHORT_VERSION_STRING"); + cmLGInfoProp(mf, target, "MACOSX_BUNDLE_BUNDLE_VERSION"); + cmLGInfoProp(mf, target, "MACOSX_BUNDLE_COPYRIGHT"); + mf->ConfigureFile(inFile.c_str(), fname, false, false, false); + mf->PopScope(); +} + +//---------------------------------------------------------------------------- +void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target, + const char* targetName, + const char* fname) +{ + // Find the Info.plist template. + const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST"); + std::string inFile = (in && *in)? in : "MacOSXFrameworkInfo.plist.in"; + if(!cmSystemTools::FileIsFullPath(inFile.c_str())) + { + std::string inMod = this->Makefile->GetModulesFile(inFile.c_str()); + if(!inMod.empty()) + { + inFile = inMod; + } + } + if(!cmSystemTools::FileExists(inFile.c_str(), true)) + { + cmOStringStream e; + e << "Target " << target->GetName() << " Info.plist template \"" + << inFile << "\" could not be found."; + cmSystemTools::Error(e.str().c_str()); + return; + } + + // Convert target properties to variables in an isolated makefile + // scope to configure the file. If properties are set they will + // override user make variables. If not the configuration will fall + // back to the directory-level values set by the user. + cmMakefile* mf = this->Makefile; + mf->PushScope(); + mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName); + cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_ICON_FILE"); + cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER"); + cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING"); + cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_BUNDLE_VERSION"); + mf->ConfigureFile(inFile.c_str(), fname, false, false, false); + mf->PopScope(); } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 9f29d7249..aa2db182e 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalGenerator.h,v $ Language: C++ - Date: $Date: 2008-02-14 20:31:08 $ - Version: $Revision: 1.103 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.103.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -275,6 +275,13 @@ public: */ void GenerateAppleInfoPList(cmTarget* target, const char* targetName, const char* fname); + + /** + * Generate a Mac OS X framework Info.plist file. + */ + void GenerateFrameworkInfoPList(cmTarget* target, + const char* targetName, + const char* fname); protected: /** Construct a comment for a custom command. */ std::string ConstructComment(const cmCustomCommand& cc, @@ -348,6 +355,7 @@ protected: std::vector Children; std::map LanguageToIncludeFlags; std::map UniqueObjectNamesMap; + std::string::size_type ObjectPathMax; bool WindowsShell; bool WindowsVSIDE; bool WatcomWMake; diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index d0a9df1ce..bbf8e9236 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalUnixMakefileGenerator3.cxx,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:39 $ - Version: $Revision: 1.240.2.5 $ + Date: $Date: 2008-05-15 19:39:55 $ + Version: $Revision: 1.240.2.6 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -1110,8 +1110,8 @@ cmLocalUnixMakefileGenerator3 for(std::vector::const_iterator f = files.begin(); f != files.end(); ++f) { - fout << "\"" << this->Convert(f->c_str(),START_OUTPUT,UNCHANGED) - << "\"\n"; + std::string fc = this->Convert(f->c_str(),START_OUTPUT,UNCHANGED); + fout << " " << this->EscapeForCMake(fc.c_str()) << "\n"; } fout << ")\n"; commands.push_back(remove); @@ -1437,9 +1437,9 @@ cmLocalUnixMakefileGenerator3 // create the file stream for the depends file std::string dir = targetDir; - - // Open the rule file. This should be copy-if-different because the - // rules may depend on this file itself. + + // Open the make depends file. This should be copy-if-different + // because the make tool may try to reload it needlessly otherwise. std::string ruleFileNameFull = dir; ruleFileNameFull += "/depend.make"; cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str()); @@ -1448,11 +1448,14 @@ cmLocalUnixMakefileGenerator3 { return false; } + + // Open the cmake dependency tracking file. This should not be + // copy-if-different because dependencies are re-scanned when it is + // older than the DependInfo.cmake. std::string internalRuleFileNameFull = dir; internalRuleFileNameFull += "/depend.internal"; - cmGeneratedFileStream + cmGeneratedFileStream internalRuleFileStream(internalRuleFileNameFull.c_str()); - internalRuleFileStream.SetCopyIfDifferent(true); if(!internalRuleFileStream) { return false; @@ -1470,68 +1473,18 @@ cmLocalUnixMakefileGenerator3 { // construct the checker std::string lang = li->c_str(); - - // Get the set of include directories. - std::vector includes; - if(haveDirectoryInfo) - { - std::string includePathVar = "CMAKE_"; - includePathVar += lang; - includePathVar += "_INCLUDE_PATH"; - if(const char* includePath = mf->GetDefinition(includePathVar.c_str())) - { - cmSystemTools::ExpandListArgument(includePath, includes); - } - } - - // Get the include file regular expression. - std::string includeRegexScan = "^.*$"; - std::string includeRegexComplain = "^$"; - if(haveDirectoryInfo) - { - std::string scanRegexVar = "CMAKE_"; - scanRegexVar += lang; - scanRegexVar += "_INCLUDE_REGEX_SCAN"; - if(const char* scanRegex = mf->GetDefinition(scanRegexVar.c_str())) - { - includeRegexScan = scanRegex; - } - std::string complainRegexVar = "CMAKE_"; - complainRegexVar += lang; - complainRegexVar += "_INCLUDE_REGEX_COMPLAIN"; - if(const char* complainRegex = - mf->GetDefinition(complainRegexVar.c_str())) - { - includeRegexComplain = complainRegex; - } - } // Create the scanner for this language cmDepends *scanner = 0; if(lang == "C" || lang == "CXX" || lang == "RC") { - std::string includeCacheFileName = dir; - includeCacheFileName += "/"; - includeCacheFileName += lang; - includeCacheFileName += ".includecache"; - // TODO: Handle RC (resource files) dependencies correctly. - scanner = new cmDependsC(includes, - includeRegexScan.c_str(), - includeRegexComplain.c_str(), - includeCacheFileName); + scanner = new cmDependsC(this, targetDir, lang.c_str()); } #ifdef CMAKE_BUILD_WITH_CMAKE else if(lang == "Fortran") { - std::vector defines; - if(const char* c_defines = - mf->GetDefinition("CMAKE_TARGET_DEFINITIONS")) - { - cmSystemTools::ExpandListArgument(c_defines, defines); - } - - scanner = new cmDependsFortran(includes, defines); + scanner = new cmDependsFortran(this); } else if(lang == "Java") { @@ -1572,28 +1525,25 @@ void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose) std::vector pairs; cmSystemTools::ExpandListArgument(pairs_string, pairs, true); for(std::vector::const_iterator i = pairs.begin(); - i != pairs.end(); ++i) + i != pairs.end() && (i+1) != pairs.end();) { - const std::string& depender = *i; - if(++i != pairs.end()) - { - const std::string& dependee = *i; + const std::string& depender = *i++; + const std::string& dependee = *i++; - // If the depender is missing then delete the dependee to make - // sure both will be regenerated. - if(cmSystemTools::FileExists(dependee.c_str()) && - !cmSystemTools::FileExists(depender.c_str())) + // If the depender is missing then delete the dependee to make + // sure both will be regenerated. + if(cmSystemTools::FileExists(dependee.c_str()) && + !cmSystemTools::FileExists(depender.c_str())) + { + if(verbose) { - if(verbose) - { - cmOStringStream msg; - msg << "Deleting primary custom command output \"" << dependee - << "\" because another output \"" - << depender << "\" does not exist." << std::endl; - cmSystemTools::Stdout(msg.str().c_str()); - } - cmSystemTools::RemoveFile(dependee.c_str()); + cmOStringStream msg; + msg << "Deleting primary custom command output \"" << dependee + << "\" because another output \"" + << depender << "\" does not exist." << std::endl; + cmSystemTools::Stdout(msg.str().c_str()); } + cmSystemTools::RemoveFile(dependee.c_str()); } } } @@ -1925,6 +1875,32 @@ void cmLocalUnixMakefileGenerator3 cmakefileStream << " )\n"; } + + // Store include transform rule properties. Write the directory + // rules first because they may be overridden by later target rules. + std::vector transformRules; + if(const char* xform = + this->Makefile->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) + { + cmSystemTools::ExpandListArgument(xform, transformRules); + } + if(const char* xform = + target.GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) + { + cmSystemTools::ExpandListArgument(xform, transformRules); + } + if(!transformRules.empty()) + { + cmakefileStream + << "SET(CMAKE_INCLUDE_TRANSFORMS\n"; + for(std::vector::const_iterator tri = transformRules.begin(); + tri != transformRules.end(); ++tri) + { + cmakefileStream << " " << this->EscapeForCMake(tri->c_str()) << "\n"; + } + cmakefileStream + << " )\n"; + } } //---------------------------------------------------------------------------- diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index f8ca676f9..4c4b1b2ad 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalVisualStudio6Generator.cxx,v $ Language: C++ - Date: $Date: 2008-04-23 02:05:39 $ - Version: $Revision: 1.141.2.1 $ + Date: $Date: 2008-09-12 14:56:21 $ + Version: $Revision: 1.141.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -532,7 +532,7 @@ void cmLocalVisualStudio6Generator } } - std::vector children = sg->GetGroupChildren(); + std::vector const& children = sg->GetGroupChildren(); for(unsigned int i=0;iMakefile->GetDefinition("CMAKE_MFC_FLAG"); @@ -1322,7 +1329,7 @@ void cmLocalVisualStudio6Generator mfcFlag = "0"; } cmSystemTools::ReplaceString(line, "OUTPUT_LIBNAME_EXPORTS", - exportSymbol.c_str()); + libnameExports.c_str()); cmSystemTools::ReplaceString(line, "CMAKE_MFC_FLAG", mfcFlag); if(target.GetType() == cmTarget::STATIC_LIBRARY ) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index f4633402a..c6bddbd17 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmLocalVisualStudio7Generator.cxx,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:39 $ - Version: $Revision: 1.217.2.5 $ + Date: $Date: 2008-09-12 14:56:21 $ + Version: $Revision: 1.217.2.11 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -399,6 +399,7 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = {"StructMemberAlignment", "Zp2", "struct align 2 byte ", "2", 0}, {"StructMemberAlignment", "Zp4", "struct align 4 byte ", "3", 0}, {"StructMemberAlignment", "Zp8", "struct align 8 byte ", "4", 0}, + {"WarningLevel", "W0", "Warning level", "0", 0}, {"WarningLevel", "W1", "Warning level", "1", 0}, {"WarningLevel", "W2", "Warning level", "2", 0}, {"WarningLevel", "W3", "Warning level", "3", 0}, @@ -423,7 +424,7 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = {"BufferSecurityCheck", "GS-", "Turn off Buffer security check", "FALSE", 0}, {"Detect64BitPortabilityProblems", "Wp64", "Detect 64-bit Portability Problems", "TRUE", 0}, - {"EnableFiberSafeOptimization", "GT", "Enable Fiber-safe Optimizations", + {"EnableFiberSafeOptimizations", "GT", "Enable Fiber-safe Optimizations", "TRUE", 0}, {"EnableFunctionLevelLinking", "Gy", "EnableFunctionLevelLinking", "TRUE", 0}, @@ -459,7 +460,8 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = {"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "ignore all default libs", "TRUE", 0}, {"ModuleDefinitionFile", "DEF:", "add an export def file", "", - cmVS7FlagTable::UserValue}, + cmVS7FlagTable::UserValue}, + {"GenerateMapFile", "MAP", "enable generation of map file", "TRUE", 0}, {0,0,0,0,0} }; @@ -1473,7 +1475,7 @@ void cmLocalVisualStudio7Generator } } - std::vector children = sg->GetGroupChildren(); + std::vector const& children = sg->GetGroupChildren(); for(unsigned int i=0;i\n"; + fout << "\tProjectType=\"" << projectType << "\"\n"; } fout<< "\tKeyword=\"" << keyword << "\">\n" << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\">\n" @@ -2173,8 +2175,10 @@ void cmLocalVisualStudio7GeneratorOptions::HandleFlag(const char* flag) // This option is not known. Store it in the output flags. this->FlagString += " "; this->FlagString += - cmSystemTools::EscapeWindowsShellArgument(flag, - cmsysSystem_Shell_Flag_VSIDE); + cmSystemTools::EscapeWindowsShellArgument( + flag, + cmsysSystem_Shell_Flag_AllowMakeVariables | + cmsysSystem_Shell_Flag_VSIDE); } //---------------------------------------------------------------------------- diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index c5048183c..299293719 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMakefile.cxx,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:39 $ - Version: $Revision: 1.463.2.3 $ + Date: $Date: 2008-09-03 13:43:17 $ + Version: $Revision: 1.463.2.8 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -395,6 +395,21 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, if(pcmd->GetEnabled() && !cmSystemTools::GetFatalErrorOccured() && (!this->GetCMakeInstance()->GetScriptMode() || pcmd->IsScriptable())) { + // if trace is one, print out invoke information + if(this->GetCMakeInstance()->GetTrace()) + { + cmOStringStream msg; + msg << lff.FilePath << "(" << lff.Line << "): "; + msg << lff.Name << "("; + for(std::vector::const_iterator i = + lff.Arguments.begin(); i != lff.Arguments.end(); ++i) + { + msg << i->Value; + msg << " "; + } + msg << ")"; + cmSystemTools::Message(msg.str().c_str()); + } // Try invoking the command. if(!pcmd->InvokeInitialPass(lff.Arguments,status) || status.GetNestedError()) @@ -487,13 +502,14 @@ bool cmMakefile::ReadListFile(const char* filename_in, { this->cmCurrentListFile = filename; } - // loop over current function blockers and record them - std::list::iterator pos; - for (pos = this->FunctionBlockers.begin(); - pos != this->FunctionBlockers.end(); ++pos) - { - originalBlockers.insert(*pos); - } + } + + // loop over current function blockers and record them + for (std::list::iterator pos + = this->FunctionBlockers.begin(); + pos != this->FunctionBlockers.end(); ++pos) + { + originalBlockers.insert(*pos); } // Now read the input file @@ -542,7 +558,7 @@ bool cmMakefile::ReadListFile(const char* filename_in, } // add this list file to the list of dependencies this->ListFiles.push_back( filenametoread); - bool endScopeNicely = filename? true: false; + bool endScopeNicely = true; const size_t numberFunctions = cacheFile.Functions.size(); for(size_t i =0; i < numberFunctions; ++i) { @@ -561,8 +577,8 @@ bool cmMakefile::ReadListFile(const char* filename_in, if (endScopeNicely) { // loop over all function blockers to see if any block this command - std::list::iterator pos; - for (pos = this->FunctionBlockers.begin(); + for (std::list::iterator pos + = this->FunctionBlockers.begin(); pos != this->FunctionBlockers.end(); ++pos) { // if this blocker was not in the original then send a @@ -720,6 +736,7 @@ cmMakefile::AddCustomCommandToTarget(const char* target, std::vector no_output; cmCustomCommand cc(no_output, depends, commandLines, comment, workingDir); cc.SetEscapeOldStyle(escapeOldStyle); + cc.SetEscapeAllowMakeVars(true); switch(type) { case cmTarget::PRE_BUILD: @@ -833,6 +850,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector& outputs, new cmCustomCommand(outputs, depends2, commandLines, comment, workingDir); cc->SetEscapeOldStyle(escapeOldStyle); + cc->SetEscapeAllowMakeVars(true); file->SetCustomCommand(cc); } } @@ -1015,12 +1033,21 @@ void cmMakefile::AddDefineFlag(const char* flag) return; } + // Update the string used for the old DEFINITIONS property. + this->AddDefineFlag(flag, this->DefineFlagsOrig); + // If this is really a definition, update COMPILE_DEFINITIONS. if(this->ParseDefineFlag(flag, false)) { return; } + // Add this flag that does not look like a definition. + this->AddDefineFlag(flag, this->DefineFlags); +} + +void cmMakefile::AddDefineFlag(const char* flag, std::string& dflags) +{ // remove any \n\r std::string ret = flag; std::string::size_type pos = 0; @@ -1036,8 +1063,8 @@ void cmMakefile::AddDefineFlag(const char* flag) pos++; } - this->DefineFlags += " "; - this->DefineFlags += ret; + dflags += " "; + dflags += ret; } @@ -1050,22 +1077,33 @@ void cmMakefile::RemoveDefineFlag(const char* flag) return; } + // Update the string used for the old DEFINITIONS property. + this->RemoveDefineFlag(flag, len, this->DefineFlagsOrig); + // If this is really a definition, update COMPILE_DEFINITIONS. if(this->ParseDefineFlag(flag, true)) { return; } + // Remove this flag that does not look like a definition. + this->RemoveDefineFlag(flag, len, this->DefineFlags); +} + +void cmMakefile::RemoveDefineFlag(const char* flag, + std::string::size_type len, + std::string& dflags) +{ // Remove all instances of the flag that are surrounded by // whitespace or the beginning/end of the string. - for(std::string::size_type lpos = this->DefineFlags.find(flag, 0); - lpos != std::string::npos; lpos = this->DefineFlags.find(flag, lpos)) + for(std::string::size_type lpos = dflags.find(flag, 0); + lpos != std::string::npos; lpos = dflags.find(flag, lpos)) { std::string::size_type rpos = lpos + len; - if((lpos <= 0 || isspace(this->DefineFlags[lpos-1])) && - (rpos >= this->DefineFlags.size() || isspace(this->DefineFlags[rpos]))) + if((lpos <= 0 || isspace(dflags[lpos-1])) && + (rpos >= dflags.size() || isspace(dflags[rpos]))) { - this->DefineFlags.erase(lpos, len); + dflags.erase(lpos, len); } else { @@ -1184,24 +1222,27 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target, if(tgt) { // CMake versions below 2.4 allowed linking to modules. - bool allowModules = this->NeedBackwardsCompatibility(2,3); + bool allowModules = this->NeedBackwardsCompatibility(2,2); // if it is not a static or shared library then you can not link to it if(!((tgt->GetType() == cmTarget::STATIC_LIBRARY) || (tgt->GetType() == cmTarget::SHARED_LIBRARY) || tgt->IsExecutableWithExports())) { cmOStringStream e; - e << "Attempt to add link target " << lib << " of type: " + e << "Target \"" << lib << "\" of type " << cmTarget::TargetTypeNames[static_cast(tgt->GetType())] - << "\nto target " << target - << ". One can only link to STATIC or SHARED libraries, or " + << " may not be linked into another target. " + << "One may link only to STATIC or SHARED libraries, or " << "to executables with the ENABLE_EXPORTS property set."; // in older versions of cmake linking to modules was allowed if( tgt->GetType() == cmTarget::MODULE_LIBRARY ) { - e << - "\nTo allow linking of modules set " - "CMAKE_BACKWARDS_COMPATIBILITY to 2.2 or lower\n"; + e << "\n" + << "If you are developing a new project, re-organize it to avoid " + << "linking to modules. " + << "If you are just trying to build an existing project, " + << "set CMAKE_BACKWARDS_COMPATIBILITY to 2.2 or lower to allow " + << "linking to modules."; } // if no modules are allowed then this is always an error if(!allowModules || @@ -1209,7 +1250,7 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target, // still an error (allowModules && tgt->GetType() != cmTarget::MODULE_LIBRARY)) { - cmSystemTools::Error(e.str().c_str()); + this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); } } } @@ -1294,6 +1335,12 @@ void cmMakefile::InitializeFromParent() // define flags this->DefineFlags = parent->DefineFlags; + // Include transform property. There is no per-config version. + { + const char* prop = "IMPLICIT_DEPENDS_INCLUDE_TRANSFORM"; + this->SetProperty(prop, parent->GetProperty(prop)); + } + // compile definitions property and per-config versions { this->SetProperty("COMPILE_DEFINITIONS", @@ -2899,8 +2946,10 @@ const char *cmMakefile::GetProperty(const char* prop, output = ""; if (!strcmp("PARENT_DIRECTORY",prop)) { - output = this->LocalGenerator->GetParent() - ->GetMakefile()->GetStartDirectory(); + if(cmLocalGenerator* plg = this->LocalGenerator->GetParent()) + { + output = plg->GetMakefile()->GetStartDirectory(); + } return output.c_str(); } else if (!strcmp("INCLUDE_REGULAR_EXPRESSION",prop) ) @@ -2945,8 +2994,8 @@ const char *cmMakefile::GetProperty(const char* prop, return output.c_str(); } else if (!strcmp("DEFINITIONS",prop)) - { - output = this->GetDefineFlags(); + { + output += this->DefineFlagsOrig; return output.c_str(); } else if (!strcmp("INCLUDE_DIRECTORIES",prop) ) @@ -3167,7 +3216,7 @@ void cmMakefile::DefineProperties(cmake *cm) "in your CMake scripts. It returns a list of what list files " "are currently being processed, in order. So if one listfile " "does an INCLUDE command then that is effectively pushing " - "the included listfile onto the stack."); + "the included listfile onto the stack.", false); cm->DefineProperty ("TEST_INCLUDE_FILE", cmProperty::DIRECTORY, @@ -3208,6 +3257,26 @@ void cmMakefile::DefineProperties(cmake *cm) "This property will be initialized in each directory by its value " "in the directory's parent.\n"); + cm->DefineProperty + ("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM", cmProperty::DIRECTORY, + "Specify #include line transforms for dependencies in a directory.", + "This property specifies rules to transform macro-like #include lines " + "during implicit dependency scanning of C and C++ source files. " + "The list of rules must be semicolon-separated with each entry of " + "the form \"A_MACRO(%)=value-with-%\" (the % must be literal). " + "During dependency scanning occurrences of A_MACRO(...) on #include " + "lines will be replaced by the value given with the macro argument " + "substituted for '%'. For example, the entry\n" + " MYDIR(%)=\n" + "will convert lines of the form\n" + " #include MYDIR(myheader.h)\n" + "to\n" + " #include \n" + "allowing the dependency to be followed.\n" + "This property applies to sources in all targets within a directory. " + "The property value is initialized in each directory by its value " + "in the directory's parent."); + cm->DefineProperty ("EXCLUDE_FROM_ALL", cmProperty::DIRECTORY, "Exclude the directory from the all target of its parent.", @@ -3216,6 +3285,64 @@ void cmMakefile::DefineProperties(cmake *cm) "for example typing make will cause the targets to be built. " "The same concept applies to the default build of other generators.", false); + + cm->DefineProperty + ("PARENT_DIRECTORY", cmProperty::DIRECTORY, + "Source directory that added current subdirectory.", + "This read-only property specifies the source directory that " + "added the current source directory as a subdirectory of the build. " + "In the top-level directory the value is the empty-string.", false); + + cm->DefineProperty + ("INCLUDE_REGULAR_EXPRESSION", cmProperty::DIRECTORY, + "Include file scanning regular expression.", + "This read-only property specifies the regular expression used " + "during dependency scanning to match include files that should " + "be followed. See the include_regular_expression command.", false); + + cm->DefineProperty + ("VARIABLES", cmProperty::DIRECTORY, + "List of variables defined in the current directory.", + "This read-only property specifies the list of CMake variables " + "currently defined. " + "It is intended for debugging purposes.", false); + + cm->DefineProperty + ("CACHE_VARIABLES", cmProperty::DIRECTORY, + "List of cache variables available in the current directory.", + "This read-only property specifies the list of CMake cache " + "variables currently defined. " + "It is intended for debugging purposes.", false); + + cm->DefineProperty + ("MACROS", cmProperty::DIRECTORY, + "List of macro commands available in the current directory.", + "This read-only property specifies the list of CMake macros " + "currently defined. " + "It is intended for debugging purposes. " + "See the macro command.", false); + + cm->DefineProperty + ("DEFINITIONS", cmProperty::DIRECTORY, + "For CMake 2.4 compatibility only. Use COMPILE_DEFINITIONS instead.", + "This read-only property specifies the list of flags given so far " + "to the add_definitions command. " + "It is intended for debugging purposes. " + "Use the COMPILE_DEFINITIONS instead.", false); + + cm->DefineProperty + ("INCLUDE_DIRECTORIES", cmProperty::DIRECTORY, + "List of preprocessor include file search directories.", + "This read-only property specifies the list of directories given " + "so far to the include_directories command. " + "It is intended for debugging purposes.", false); + + cm->DefineProperty + ("LINK_DIRECTORIES", cmProperty::DIRECTORY, + "List of linker search directories.", + "This read-only property specifies the list of directories given " + "so far to the link_directories command. " + "It is intended for debugging purposes.", false); } //---------------------------------------------------------------------------- @@ -3336,50 +3463,59 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, return true; } -cmPolicies::PolicyStatus cmMakefile -::GetPolicyStatus(cmPolicies::PolicyID id) +//---------------------------------------------------------------------------- +cmPolicies::PolicyStatus +cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) { - cmPolicies::PolicyStatus status = cmPolicies::REQUIRED_IF_USED; - PolicyMap::iterator mappos; - int vecpos; - bool done = false; + // Get the current setting of the policy. + cmPolicies::PolicyStatus cur = this->GetPolicyStatusInternal(id); - // check our policy stack first - for (vecpos = static_cast(this->PolicyStack.size()) - 1; - vecpos >= 0 && !done; vecpos--) - { - mappos = this->PolicyStack[vecpos].find(id); - if (mappos != this->PolicyStack[vecpos].end()) + // If the policy is required to be set to NEW but is not, ignore the + // current setting and tell the caller. + if(cur != cmPolicies::NEW) { - status = mappos->second; - done = true; + if(cur == cmPolicies::REQUIRED_ALWAYS || + cur == cmPolicies::REQUIRED_IF_USED) + { + return cur; + } + cmPolicies::PolicyStatus def = this->GetPolicies()->GetPolicyStatus(id); + if(def == cmPolicies::REQUIRED_ALWAYS || + def == cmPolicies::REQUIRED_IF_USED) + { + return def; + } } - } - - // if not found then - if (!done) - { - // pass the buck to our parent if we have one - if (this->LocalGenerator->GetParent()) + + // The current setting is okay. + return cur; +} + +//---------------------------------------------------------------------------- +cmPolicies::PolicyStatus +cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) +{ + // Is the policy set in our stack? + for(std::vector::reverse_iterator + psi = this->PolicyStack.rbegin(); + psi != this->PolicyStack.rend(); ++psi) { - cmMakefile *parent = - this->LocalGenerator->GetParent()->GetMakefile(); - return parent->GetPolicyStatus(id); + PolicyMap::const_iterator pse = psi->find(id); + if(pse != psi->end()) + { + return pse->second; + } } - // otherwise use the default - else + + // If we have a parent directory, recurse up to it. + if(this->LocalGenerator->GetParent()) { - status = this->GetPolicies()->GetPolicyStatus(id); + cmMakefile* parent = this->LocalGenerator->GetParent()->GetMakefile(); + return parent->GetPolicyStatusInternal(id); } - } - - // warn if we see a REQUIRED_IF_USED above a OLD or WARN - if (!this->GetPolicies()->IsValidUsedPolicyStatus(id,status)) - { - return cmPolicies::REQUIRED_IF_USED; - } - - return status; + + // The policy is not set. Use the default for this CMake version. + return this->GetPolicies()->GetPolicyStatus(id); } bool cmMakefile::SetPolicy(const char *id, @@ -3396,37 +3532,44 @@ bool cmMakefile::SetPolicy(const char *id, return this->SetPolicy(pid,status); } -bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, +//---------------------------------------------------------------------------- +bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status) { - // setting a REQUIRED_ALWAYS policy to WARN or OLD is an insta error - if (this->GetPolicies()-> - IsValidPolicyStatus(id,status)) - { - this->PolicyStack.back()[id] = status; + // A REQUIRED_ALWAYS policy may be set only to NEW. + if(status != cmPolicies::NEW && + this->GetPolicies()->GetPolicyStatus(id) == + cmPolicies::REQUIRED_ALWAYS) + { + std::string msg = + this->GetPolicies()->GetRequiredAlwaysPolicyError(id); + this->IssueMessage(cmake::FATAL_ERROR, msg.c_str()); + return false; + } + + // Store the setting. + this->PolicyStack.back()[id] = status; - // Special hook for presenting compatibility variable as soon as - // the user requests it. - if(id == cmPolicies::CMP0001 && - (status == cmPolicies::WARN || status == cmPolicies::OLD)) + // Special hook for presenting compatibility variable as soon as + // the user requests it. + if(id == cmPolicies::CMP0001 && + (status == cmPolicies::WARN || status == cmPolicies::OLD)) + { + if(!(this->GetCacheManager() + ->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))) { - if(!(this->GetCacheManager() - ->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY"))) - { - // Set it to 2.4 because that is the last version where the - // variable had meaning. - this->AddCacheDefinition - ("CMAKE_BACKWARDS_COMPATIBILITY", "2.4", - "For backwards compatibility, what version of CMake " - "commands and " - "syntax should this version of CMake try to support.", - cmCacheManager::STRING); - } + // Set it to 2.4 because that is the last version where the + // variable had meaning. + this->AddCacheDefinition + ("CMAKE_BACKWARDS_COMPATIBILITY", "2.4", + "For backwards compatibility, what version of CMake " + "commands and " + "syntax should this version of CMake try to support.", + cmCacheManager::STRING); } + } - return true; - } - return false; + return true; } bool cmMakefile::PushPolicy() diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index cd835b309..475958714 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMakefile.h,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:40 $ - Version: $Revision: 1.230.2.2 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.230.2.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -829,6 +829,11 @@ protected: std::vector HeaderFileExtensions; std::string DefineFlags; + // Track the value of the computed DEFINITIONS property. + void AddDefineFlag(const char*, std::string&); + void RemoveDefineFlag(const char*, std::string::size_type, std::string&); + std::string DefineFlagsOrig; + #if defined(CMAKE_BUILD_WITH_CMAKE) std::vector SourceGroups; #endif @@ -895,6 +900,7 @@ private: typedef std::map PolicyMap; std::vector PolicyStack; + cmPolicies::PolicyStatus GetPolicyStatusInternal(cmPolicies::PolicyID id); bool CheckCMP0000; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 7934d564f..e8730f709 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMakefileExecutableTargetGenerator.cxx,v $ Language: C++ - Date: $Date: 2008-04-08 16:22:50 $ - Version: $Revision: 1.46.2.1 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.46.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -504,6 +504,7 @@ cmMakefileExecutableTargetGenerator::CreateAppBundle(std::string& targetName, outpath += "MacOS"; cmSystemTools::MakeDirectory(outpath.c_str()); outpath += "/"; + this->Makefile->AddCMakeDependFile(outpath.c_str()); // Configure the Info.plist file. Note that it needs the executable name // to be set. @@ -511,4 +512,5 @@ cmMakefileExecutableTargetGenerator::CreateAppBundle(std::string& targetName, this->LocalGenerator->GenerateAppleInfoPList(this->Target, targetName.c_str(), plist.c_str()); + this->Makefile->AddCMakeDependFile(plist.c_str()); } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 5552293e4..936e04a64 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMakefileLibraryTargetGenerator.cxx,v $ Language: C++ - Date: $Date: 2008-04-21 00:44:52 $ - Version: $Revision: 1.58.2.2 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.58.2.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -235,8 +235,17 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) } //---------------------------------------------------------------------------- -void cmMakefileLibraryTargetGenerator::CreateFramework() +void +cmMakefileLibraryTargetGenerator +::CreateFramework(std::string const& targetName) { + // Configure the Info.plist file into the Resources directory. + this->MacContentFolders.insert("Resources"); + std::string plist = this->MacContentDirectory + "Resources/Info.plist"; + this->LocalGenerator->GenerateFrameworkInfoPList(this->Target, + targetName.c_str(), + plist.c_str()); + // TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to // drive rules to create these files at build time. std::string oldName; @@ -364,6 +373,14 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string linkFlags; this->LocalGenerator->AppendFlags(linkFlags, extraFlags); + // Add OSX version flags, if any. + if(this->Target->GetType() == cmTarget::SHARED_LIBRARY || + this->Target->GetType() == cmTarget::MODULE_LIBRARY) + { + this->AppendOSXVerFlag(linkFlags, linkLanguage, "COMPATIBILITY", true); + this->AppendOSXVerFlag(linkFlags, linkLanguage, "CURRENT", false); + } + // Construct the name of the library. std::string targetName; std::string targetNameSO; @@ -380,7 +397,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules if(this->Target->IsFrameworkOnApple()) { outpath = this->MacContentDirectory; - this->CreateFramework(); + this->CreateFramework(targetName); } else if(relink) { @@ -604,12 +621,15 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } // For static libraries there might be archiving rules. + bool haveStaticLibraryRule = false; std::vector archiveCreateCommands; std::vector archiveAppendCommands; std::vector archiveFinishCommands; std::string::size_type archiveCommandLimit = std::string::npos; if(this->Target->GetType() == cmTarget::STATIC_LIBRARY) { + haveStaticLibraryRule = + this->Makefile->GetDefinition(linkRuleVar)? true:false; std::string arCreateVar = "CMAKE_"; arCreateVar += linkLanguage; arCreateVar += "_ARCHIVE_CREATE"; @@ -635,6 +655,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Decide whether to use archiving rules. bool useArchiveRules = + !haveStaticLibraryRule && !archiveCreateCommands.empty() && !archiveAppendCommands.empty(); if(useArchiveRules) { @@ -905,3 +926,37 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules this->CleanFiles.insert(this->CleanFiles.end(), libCleanFiles.begin(),libCleanFiles.end()); } + +//---------------------------------------------------------------------------- +void +cmMakefileLibraryTargetGenerator +::AppendOSXVerFlag(std::string& flags, const char* lang, + const char* name, bool so) +{ + // Lookup the flag to specify the version. + std::string fvar = "CMAKE_"; + fvar += lang; + fvar += "_OSX_"; + fvar += name; + fvar += "_VERSION_FLAG"; + const char* flag = this->Makefile->GetDefinition(fvar.c_str()); + + // Skip if no such flag. + if(!flag) + { + return; + } + + // Lookup the target version information. + int major; + int minor; + int patch; + this->Target->GetTargetVersion(so, major, minor, patch); + if(major > 0 || minor > 0 || patch > 0) + { + // Append the flag since a non-zero version is specified. + cmOStringStream vflag; + vflag << flag << major << "." << minor << "." << patch; + this->LocalGenerator->AppendFlags(flags, vflag.str().c_str()); + } +} diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h index 0f3e57d1c..160f04ec9 100644 --- a/Source/cmMakefileLibraryTargetGenerator.h +++ b/Source/cmMakefileLibraryTargetGenerator.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMakefileLibraryTargetGenerator.h,v $ Language: C++ - Date: $Date: 2008-04-08 16:22:50 $ - Version: $Revision: 1.6.2.1 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.6.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -37,10 +37,13 @@ protected: bool relink); // MacOSX Framework support methods void WriteFrameworkRules(bool relink); - void CreateFramework(); + void CreateFramework(std::string const& targetName); // Store the computd framework version for OS X Frameworks. std::string FrameworkVersion; + + void AppendOSXVerFlag(std::string& flags, const char* lang, + const char* name, bool so); }; #endif diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index bda3d087f..49d1f5e47 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmMakefileTargetGenerator.cxx,v $ Language: C++ - Date: $Date: 2008-04-23 02:05:40 $ - Version: $Revision: 1.93.2.3 $ + Date: $Date: 2008-06-13 12:55:17 $ + Version: $Revision: 1.93.2.6 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -24,6 +24,7 @@ #include "cmSourceFile.h" #include "cmTarget.h" #include "cmake.h" +#include "cmComputeLinkInformation.h" #include "cmMakefileExecutableTargetGenerator.h" #include "cmMakefileLibraryTargetGenerator.h" @@ -933,8 +934,10 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() this->MultipleOutputPairs.begin(); pi != this->MultipleOutputPairs.end(); ++pi) { - *this->InfoFileStream << " \"" << pi->first << "\" \"" - << pi->second << "\"\n"; + *this->InfoFileStream + << " " << this->LocalGenerator->EscapeForCMake(pi->first.c_str()) + << " " << this->LocalGenerator->EscapeForCMake(pi->second.c_str()) + << "\n"; } *this->InfoFileStream << " )\n\n"; } @@ -1113,16 +1116,16 @@ void cmMakefileTargetGenerator ->AppendEcho(commands, comment.c_str(), cmLocalUnixMakefileGenerator3::EchoGenerate); } + // Below we need to skip over the echo and progress commands. + unsigned int skip = static_cast(commands.size()); + + // Now append the actual user-specified commands. this->LocalGenerator->AppendCustomCommand(commands, cc); // Collect the dependencies. std::vector depends; this->LocalGenerator->AppendCustomDepend(depends, cc); - // Add a dependency on the rule file itself. - this->LocalGenerator->AppendRuleDepend(depends, - this->BuildFileNameFull.c_str()); - // Check whether we need to bother checking for a symbolic output. bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark(); @@ -1141,6 +1144,14 @@ void cmMakefileTargetGenerator this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, o->c_str(), depends, commands, symbolic); + + // If the rule has changed make sure the output is rebuilt. + if(!symbolic) + { + this->GlobalGenerator->AddRuleHash(cc.GetOutputs(), + commands.begin()+skip, + commands.end()); + } } // Write rules to drive building any outputs beyond the first. @@ -1458,48 +1469,16 @@ void cmMakefileTargetGenerator { return; } - // Compute which library configuration to link. - cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED; - if(cmSystemTools::UpperCase( - this->LocalGenerator->ConfigurationName.c_str()) == "DEBUG") - { - linkType = cmTarget::DEBUG; - } - // Keep track of dependencies already listed. - std::set emitted; - - // A target should not depend on itself. - emitted.insert(this->Target->GetName()); // Loop over all library dependencies. - const cmTarget::LinkLibraryVectorType& tlibs = - this->Target->GetLinkLibraries(); - for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin(); - lib != tlibs.end(); ++lib) + const char* cfg = this->LocalGenerator->ConfigurationName.c_str(); + if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) { - // skip the library if it is not general and the link type - // does not match the current target - if(lib->second != cmTarget::GENERAL && - lib->second != linkType) - { - continue; - } - - // Don't emit the same library twice for this target. - if(emitted.insert(lib->first).second) + std::vector const& libDeps = cli->GetDepends(); + for(std::vector::const_iterator j = libDeps.begin(); + j != libDeps.end(); ++j) { - // Depend on other CMake targets. - if(cmTarget* tgt = - this->GlobalGenerator->FindTarget(0, lib->first.c_str())) - { - const char* config = this->LocalGenerator->ConfigurationName.c_str(); - depends.push_back(tgt->GetFullPath(config, false)); - } - // depend on full path libs as well - else if(cmSystemTools::FileIsFullPath(lib->first.c_str())) - { - depends.push_back(lib->first.c_str()); - } + depends.push_back(*j); } } } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index 35d3e883d..395503e3d 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmOrderDirectories.cxx,v $ Language: C++ - Date: $Date: 2008-02-22 14:44:11 $ - Version: $Revision: 1.4 $ + Date: $Date: 2008-07-30 18:54:49 $ + Version: $Revision: 1.4.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -18,6 +18,7 @@ #include "cmGlobalGenerator.h" #include "cmSystemTools.h" +#include "cmake.h" #include @@ -56,7 +57,7 @@ public: { for(unsigned int i=0; i < this->OD->OriginalDirectories.size(); ++i) { - // Check if this directory conflicts with they entry. + // Check if this directory conflicts with the entry. std::string const& dir = this->OD->OriginalDirectories[i]; if(dir != this->Directory && this->FindConflict(dir)) { @@ -68,6 +69,29 @@ public: } } } + + void FindImplicitConflicts(cmOStringStream& w) + { + bool first = true; + for(unsigned int i=0; i < this->OD->OriginalDirectories.size(); ++i) + { + // Check if this directory conflicts with the entry. + std::string const& dir = this->OD->OriginalDirectories[i]; + if(dir != this->Directory && this->FindConflict(dir)) + { + // The library will be found in this directory but it is + // supposed to be found in an implicit search directory. + if(first) + { + first = false; + w << " "; + this->Report(w); + w << " in " << this->Directory << " may be hidden by files in:\n"; + } + w << " " << dir << "\n"; + } + } + } protected: virtual bool FindConflict(std::string const& dir) = 0; @@ -239,11 +263,11 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) //---------------------------------------------------------------------------- cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg, - const char* name, + cmTarget* target, const char* purpose) { this->GlobalGenerator = gg; - this->Name = name; + this->Target = target; this->Purpose = purpose; this->Computed = false; } @@ -257,6 +281,12 @@ cmOrderDirectories::~cmOrderDirectories() { delete *i; } + for(std::vector::iterator + i = this->ImplicitDirEntries.begin(); + i != this->ImplicitDirEntries.end(); ++i) + { + delete *i; + } } //---------------------------------------------------------------------------- @@ -279,13 +309,15 @@ void cmOrderDirectories::AddRuntimeLibrary(std::string const& fullPath, // Add the runtime library at most once. if(this->EmmittedConstraintSOName.insert(fullPath).second) { - // Avoid dealing with implicit directories. + // Implicit link directories need special handling. if(!this->ImplicitDirectories.empty()) { std::string dir = cmSystemTools::GetFilenamePath(fullPath); if(this->ImplicitDirectories.find(dir) != this->ImplicitDirectories.end()) { + this->ImplicitDirEntries.push_back( + new cmOrderDirectoriesConstraintSOName(this, fullPath, soname)); return; } } @@ -312,13 +344,15 @@ void cmOrderDirectories::AddLinkLibrary(std::string const& fullPath) // Add the link library at most once. if(this->EmmittedConstraintLibrary.insert(fullPath).second) { - // Avoid dealing with implicit directories. + // Implicit link directories need special handling. if(!this->ImplicitDirectories.empty()) { std::string dir = cmSystemTools::GetFilenamePath(fullPath); if(this->ImplicitDirectories.find(dir) != this->ImplicitDirectories.end()) { + this->ImplicitDirEntries.push_back( + new cmOrderDirectoriesConstraintLibrary(this, fullPath)); return; } } @@ -366,7 +400,7 @@ void cmOrderDirectories::CollectOriginalDirectories() di = this->UserDirectories.begin(); di != this->UserDirectories.end(); ++di) { - // Avoid dealing with implicit directories. + // We never explicitly specify implicit link directories. if(this->ImplicitDirectories.find(*di) != this->ImplicitDirectories.end()) { @@ -449,6 +483,39 @@ void cmOrderDirectories::FindConflicts() std::unique(i->begin(), i->end(), cmOrderDirectoriesCompare()); i->erase(last, i->end()); } + + // Check items in implicit link directories. + this->FindImplicitConflicts(); +} + +//---------------------------------------------------------------------------- +void cmOrderDirectories::FindImplicitConflicts() +{ + // Check for items in implicit link directories that have conflicts + // in the explicit directories. + cmOStringStream conflicts; + for(unsigned int i=0; i < this->ImplicitDirEntries.size(); ++i) + { + this->ImplicitDirEntries[i]->FindImplicitConflicts(conflicts); + } + + // Skip warning if there were no conflicts. + std::string text = conflicts.str(); + if(text.empty()) + { + return; + } + + // Warn about the conflicts. + cmOStringStream w; + w << "Cannot generate a safe " << this->Purpose + << " for target " << this->Target->GetName() + << " because files in some directories may conflict with " + << " libraries in implicit directories:\n" + << text + << "Some of these libraries may not be found correctly."; + this->GlobalGenerator->GetCMakeInstance() + ->IssueMessage(cmake::WARNING, w.str(), this->Target->GetBacktrace()); } //---------------------------------------------------------------------------- @@ -510,22 +577,24 @@ void cmOrderDirectories::DiagnoseCycle() // Construct the message. cmOStringStream e; - e << "WARNING: Cannot generate a safe " << this->Purpose - << " for target " << this->Name + e << "Cannot generate a safe " << this->Purpose + << " for target " << this->Target->GetName() << " because there is a cycle in the constraint graph:\n"; // Display the conflict graph. for(unsigned int i=0; i < this->ConflictGraph.size(); ++i) { ConflictList const& clist = this->ConflictGraph[i]; - e << "dir " << i << " is [" << this->OriginalDirectories[i] << "]\n"; + e << " dir " << i << " is [" << this->OriginalDirectories[i] << "]\n"; for(ConflictList::const_iterator j = clist.begin(); j != clist.end(); ++j) { - e << " dir " << j->first << " must precede it due to "; + e << " dir " << j->first << " must precede it due to "; this->ConstraintEntries[j->second]->Report(e); e << "\n"; } } - cmSystemTools::Message(e.str().c_str()); + e << "Some of these libraries may not be found correctly."; + this->GlobalGenerator->GetCMakeInstance() + ->IssueMessage(cmake::WARNING, e.str(), this->Target->GetBacktrace()); } diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index 03c82672b..744894111 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmOrderDirectories.h,v $ Language: C++ - Date: $Date: 2008-02-21 16:41:11 $ - Version: $Revision: 1.1 $ + Date: $Date: 2008-07-30 18:54:49 $ + Version: $Revision: 1.1.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -24,6 +24,7 @@ class cmGlobalGenerator; class cmOrderDirectoriesConstraint; class cmOrderDirectoriesConstraintLibrary; +class cmTarget; /** \class cmOrderDirectories * \brief Compute a safe runtime path order for a set of shared libraries. @@ -31,7 +32,7 @@ class cmOrderDirectoriesConstraintLibrary; class cmOrderDirectories { public: - cmOrderDirectories(cmGlobalGenerator* gg, const char* name, + cmOrderDirectories(cmGlobalGenerator* gg, cmTarget* target, const char* purpose); ~cmOrderDirectories(); void AddRuntimeLibrary(std::string const& fullPath, const char* soname = 0); @@ -44,7 +45,7 @@ public: std::vector const& GetOrderedDirectories(); private: cmGlobalGenerator* GlobalGenerator; - std::string Name; + cmTarget* Target; std::string Purpose; bool Computed; @@ -53,6 +54,7 @@ private: bool OrderedDirectoriesComputed; std::vector ConstraintEntries; + std::vector ImplicitDirEntries; std::vector UserDirectories; cmsys::RegularExpression RemoveLibraryExtension; std::vector LinkExtensions; @@ -65,6 +67,7 @@ private: void CollectOriginalDirectories(); int AddOriginalDirectory(std::string const& dir); void FindConflicts(); + void FindImplicitConflicts(); void OrderDirectories(); void VisitDirectory(unsigned int i); void DiagnoseCycle(); diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 64caf25f8..5d8c71f8c 100755 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -281,6 +281,48 @@ cmPolicies::cmPolicies() "The NEW behavior for this policy is to correctly count empty " "elements in a list. ", 2,6,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0008, "CMP0008", + "Libraries linked by full-path must have a valid library file name.", + "In CMake 2.4 and below it is possible to write code like\n" + " target_link_libraries(myexe /full/path/to/somelib)\n" + "where \"somelib\" is supposed to be a valid library file name " + "such as \"libsomelib.a\" or \"somelib.lib\". " + "For Makefile generators this produces an error at build time " + "because the dependency on the full path cannot be found. " + "For VS IDE and Xcode generators this used to work by accident because " + "CMake would always split off the library directory and ask the " + "linker to search for the library by name (-lsomelib or somelib.lib). " + "Despite the failure with Makefiles, some projects have code like this " + "and build only with VS and/or Xcode. " + "This version of CMake prefers to pass the full path directly to the " + "native build tool, which will fail in this case because it does " + "not name a valid library file." + "\n" + "This policy determines what to do with full paths that do not appear " + "to name a valid library file. " + "The OLD behavior for this policy is to split the library name from the " + "path and ask the linker to search for it. " + "The NEW behavior for this policy is to trust the given path and " + "pass it directly to the native build tool unchanged.", + 2,6,1, cmPolicies::WARN); + + this->DefinePolicy( + CMP0009, "CMP0009", + "FILE GLOB_RECURSE calls should not follow symlinks by default.", + "In CMake 2.6.1 and below, FILE GLOB_RECURSE calls would follow " + "through symlinks, sometimes coming up with unexpectedly large " + "result sets because of symlinks to top level directories that " + "contain hundreds of thousands of files." + "\n" + "This policy determines whether or not to follow symlinks " + "encountered during a FILE GLOB_RECURSE call. " + "The OLD behavior for this policy is to follow the symlinks. " + "The NEW behavior for this policy is not to follow the symlinks " + "by default, but only if FOLLOW_SYMLINKS is given as an additional " + "argument to the FILE command.", + 2,6,2, cmPolicies::WARN); } cmPolicies::~cmPolicies() @@ -321,6 +363,7 @@ void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD, this->PolicyStringMap[idString] = iD; } +//---------------------------------------------------------------------------- bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, const char *version) { @@ -357,7 +400,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, "In order to get compatibility features supporting versions earlier " "than 2.4 set policy CMP0001 to OLD to tell CMake to check the " "CMAKE_BACKWARDS_COMPATIBILITY variable. " - "One way to so this is to set the policy version to 2.4 exactly." + "One way to do this is to set the policy version to 2.4 exactly." ); return false; } @@ -382,13 +425,18 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, } // now loop over all the policies and set them as appropriate + std::vector ancientPolicies; std::map::iterator i = this->Policies.begin(); for (;i != this->Policies.end(); ++i) { if (i->second->IsPolicyNewerThan(majorVer,minorVer,patchVer)) { - if (!mf->SetPolicy(i->second->ID, cmPolicies::WARN)) + if(i->second->Status == cmPolicies::REQUIRED_ALWAYS) + { + ancientPolicies.push_back(i->first); + } + else if (!mf->SetPolicy(i->second->ID, cmPolicies::WARN)) { return false; } @@ -401,105 +449,16 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, } } } - return true; -} -// is this a valid status the listfile can set this policy to? -bool cmPolicies::IsValidPolicyStatus(cmPolicies::PolicyID id, - cmPolicies::PolicyStatus status) -{ - // if they are setting a feature to anything other than OLD or WARN and the - // feature is not known about then that is an error - if (this->Policies.find(id) == this->Policies.end()) - { - if (status == cmPolicies::WARN || - status == cmPolicies::OLD) + // Make sure the project does not use any ancient policies. + if(!ancientPolicies.empty()) { - return true; - } - cmOStringStream error; - error << - "Error: an attempt was made to enable the new behavior for " << - "a new feature that is in a later version of CMake than " - "what you are runing, please upgrade to a newer version " - "of CMake."; - cmSystemTools::Error(error.str().c_str()); - return false; - } - - // now we know the feature is defined, so the only issue is if someone is - // setting it to WARN or OLD when the feature is REQUIRED_ALWAYS - if ((status == cmPolicies::WARN || - status == cmPolicies::OLD) && - this->Policies[id]->Status == cmPolicies::REQUIRED_ALWAYS) - { - cmOStringStream error; - error << - "Error: an attempt was made to enable the old behavior for " << - "a feature that is no longer supported. The feature in " << - "question is feature " << - id << - " which had new behavior introduced in CMake version " << - this->Policies[id]->GetVersionString() << - " please either update your CMakeLists files to conform to " << - "the new behavior " << - "or use an older version of CMake that still supports " << - "the old behavior. Run cmake --help-policies " << - id << " for more information."; - cmSystemTools::Error(error.str().c_str()); + this->DiagnoseAncientPolicies(ancientPolicies, + majorVer, minorVer, patchVer, mf); + cmSystemTools::SetFatalErrorOccured(); return false; - } - - return true; -} - -// is this a valid status the listfile can set this policy to? -bool cmPolicies::IsValidUsedPolicyStatus(cmPolicies::PolicyID id, - cmPolicies::PolicyStatus status) -{ - // if they are setting a feature to anything other than OLD or WARN and the - // feature is not known about then that is an error - if (this->Policies.find(id) == this->Policies.end()) - { - if (status == cmPolicies::WARN || - status == cmPolicies::OLD) - { - return true; } - cmOStringStream error; - error << - "Error: an attempt was made to enable the new behavior for " << - "a new feature that is in a later version of CMake than " - "what you are runing, please upgrade to a newer version " - "of CMake."; - cmSystemTools::Error(error.str().c_str()); - return false; - } - // now we know the feature is defined, so the only issue is if someone is - // setting it to WARN or OLD when the feature is REQUIRED_ALWAYS - if ((status == cmPolicies::WARN || - status == cmPolicies::OLD) && - (this->Policies[id]->Status == cmPolicies::REQUIRED_ALWAYS || - this->Policies[id]->Status == cmPolicies::REQUIRED_IF_USED)) - { - cmOStringStream error; - error << - "Error: an attempt was made to enable the old behavior for " << - "a feature that is no longer supported. The feature in " << - "question is feature " << - id << - " which had new behavior introduced in CMake version " << - this->Policies[id]->GetVersionString() << - " please either update your CMakeLists files to conform to " << - "the new behavior " << - "or use an older version of CMake that still supports " << - "the old behavior. Run cmake --help-policies " << - id << " for more information."; - cmSystemTools::Error(error.str().c_str()); - return false; - } - return true; } @@ -645,3 +604,48 @@ void cmPolicies::GetDocumentation(std::vector& v) v.push_back(e); } } + +//---------------------------------------------------------------------------- +std::string +cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id) +{ + std::string pid = this->GetPolicyIDString(id); + cmOStringStream e; + e << "Policy " << pid << " may not be set to OLD behavior because this " + << "version of CMake no longer supports it. " + << "The policy was introduced in " + << "CMake version " << this->Policies[id]->GetVersionString() + << ", and use of NEW behavior is now required." + << "\n" + << "Please either update your CMakeLists.txt files to conform to " + << "the new behavior or use an older version of CMake that still " + << "supports the old behavior. " + << "Run cmake --help-policy " << pid << " for more information."; + return e.str(); +} + +//---------------------------------------------------------------------------- +void +cmPolicies::DiagnoseAncientPolicies(std::vector const& ancient, + unsigned int majorVer, + unsigned int minorVer, + unsigned int patchVer, + cmMakefile* mf) +{ + cmOStringStream e; + e << "The project requests behavior compatible with CMake version \"" + << majorVer << "." << minorVer << "." << patchVer + << "\", which requires OLD the behavior for some policies:\n"; + for(std::vector::const_iterator + i = ancient.begin(); i != ancient.end(); ++i) + { + cmPolicy const* policy = this->Policies[*i]; + e << " " << policy->IDString << ": " << policy->ShortDescription << "\n"; + } + e << "However, this version of CMake no longer supports the OLD " + << "behavior for these policies. " + << "Please either update your CMakeLists.txt files to conform to " + << "the new behavior or use an older version of CMake that still " + << "supports the old behavior."; + mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); +} diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 2b141d1ad..f09eaf3c3 100755 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmPolicies.h,v $ Language: C++ - Date: $Date: 2008-04-23 02:05:40 $ - Version: $Revision: 1.10.2.3 $ + Date: $Date: 2008-09-12 14:56:21 $ + Version: $Revision: 1.10.2.6 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -48,6 +48,8 @@ public: CMP0005, // Definition value escaping CMP0006, // BUNDLE install rules needed for MACOSX_BUNDLE targets CMP0007, // list command handling of empty elements + CMP0008, // Full-path libraries must be a valid library file name + CMP0009, // GLOB_RECURSE should not follow symlinks by default // Always the last entry. Useful mostly to avoid adding a comma // the last policy when adding a new one. @@ -74,20 +76,15 @@ public: ///! Set a policy level for this listfile bool ApplyPolicyVersion(cmMakefile *mf, const char *version); - ///! test to see if setting a policy to a specific value is valid - bool IsValidPolicyStatus(cmPolicies::PolicyID id, - cmPolicies::PolicyStatus status); - - ///! test to see if setting a policy to a specific value is valid, when used - bool IsValidUsedPolicyStatus(cmPolicies::PolicyID id, - cmPolicies::PolicyStatus status); - ///! return a warning string for a given policy std::string GetPolicyWarning(cmPolicies::PolicyID id); ///! return an error string for when a required policy is unspecified std::string GetRequiredPolicyError(cmPolicies::PolicyID id); + ///! return an error string for when a required policy is unspecified + std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id); + ///! Get docs for policies void GetDocumentation(std::vector& v); @@ -95,7 +92,10 @@ public: // might have to make these internal for VS6 not sure yet std::map Policies; std::map PolicyStringMap; - + + void DiagnoseAncientPolicies(std::vector const& ancient, + unsigned int majorVer, unsigned int minorVer, + unsigned int patchVer, cmMakefile* mf); }; #endif diff --git a/Source/cmReturnCommand.h b/Source/cmReturnCommand.h index adb2701c0..373461298 100755 --- a/Source/cmReturnCommand.h +++ b/Source/cmReturnCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmReturnCommand.h,v $ Language: C++ - Date: $Date: 2008-01-23 23:34:19 $ - Version: $Revision: 1.2 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.2.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -57,7 +57,7 @@ public: */ virtual const char* GetTerseDocumentation() { - return "Return from a directory or function."; + return "Return from a file, directory or function."; } /** @@ -67,10 +67,14 @@ public: { return " return()\n" - "Returns from a directory or function. When this command is " - "encountered, it caused process of the current function or " - "directory to stop and control is return to the caller of the " - "function, or the parent directory if any. Note that a macro " + "Returns from a file, directory or function. When this command is " + "encountered in an included file (via include() or find_package()), " + "it causes processing of the current file to stop and control is " + "returned to the including file. If it is encountered in a file which " + "is not included by another file, e.g. a CMakeLists.txt, control is " + "returned to the parent directory if there is one. " + "If return is called in a function, control is returned to the caller " + "of the function. Note that a macro " "is not a function and does not handle return like a function does."; } diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index f9504ed5c..c2ab1e9f9 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSetPropertyCommand.cxx,v $ Language: C++ - Date: $Date: 2008-04-02 13:16:05 $ - Version: $Revision: 1.6.2.1 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.6.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -271,6 +271,9 @@ bool cmSetPropertyCommand::HandleTarget(cmTarget* target) target->SetProperty(name, value); } + // Check the resulting value. + target->CheckProperty(name, this->Makefile); + return true; } diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx index 09bf0de14..64734c0ef 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.cxx +++ b/Source/cmSetSourceFilesPropertiesCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSetSourceFilesPropertiesCommand.cxx,v $ Language: C++ - Date: $Date: 2008-02-15 16:22:23 $ - Version: $Revision: 1.19 $ + Date: $Date: 2008-05-15 19:39:57 $ + Version: $Revision: 1.19.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -33,7 +33,8 @@ bool cmSetSourceFilesPropertiesCommand std::vector::const_iterator j; j = args.begin(); // old style allows for specifier before PROPERTIES keyword - while (*j != "ABSTRACT" && + while (j != args.end() && + *j != "ABSTRACT" && *j != "WRAP_EXCLUDE" && *j != "GENERATED" && *j != "COMPILE_FLAGS" && diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index 8fbcce016..0b124c64d 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSetTargetPropertiesCommand.cxx,v $ Language: C++ - Date: $Date: 2008-01-28 13:38:36 $ - Version: $Revision: 1.9 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.9.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -103,6 +103,7 @@ bool cmSetTargetPropertiesCommand { target->SetProperty(propertyPairs[k].c_str(), propertyPairs[k+1].c_str()); + target->CheckProperty(propertyPairs[k].c_str(), mf); } } // if file is not already in the makefile, then add it diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index d2e57150d..3c5d3b19b 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSourceFile.cxx,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:40 $ - Version: $Revision: 1.47.2.2 $ + Date: $Date: 2008-05-29 13:15:31 $ + Version: $Revision: 1.47.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -55,7 +55,13 @@ const char* cmSourceFile::GetLanguage() // Perform computation needed to get the language if necessary. if(this->FullPath.empty() && this->Language.empty()) { - if(this->Location.ExtensionIsAmbiguous()) + // If a known extension is given or a known full path is given + // then trust that the current extension is sufficient to + // determine the language. This will fail only if the user + // specifies a full path to the source but leaves off the + // extension, which is kind of weird. + if(this->Location.ExtensionIsAmbiguous() && + this->Location.DirectoryIsAmbiguous()) { // Finalize the file location to get the extension and set the // language. @@ -185,16 +191,6 @@ bool cmSourceFile::FindFullPath() } } - // If the user provided a full path, trust it. If the file is not - // there the native tool will complain at build time. - if(!this->Location.DirectoryIsAmbiguous()) - { - this->FullPath = this->Location.GetDirectory(); - this->FullPath += "/"; - this->FullPath += this->Location.GetName(); - return true; - } - cmOStringStream e; e << "Cannot find source file \"" << this->Location.GetName() << "\""; e << ". Tried extensions"; diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 1f3b9e440..f3f57edaa 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSourceFileLocation.cxx,v $ Language: C++ - Date: $Date: 2008-03-18 14:23:54 $ - Version: $Revision: 1.3.2.1 $ + Date: $Date: 2008-08-06 21:04:19 $ + Version: $Revision: 1.3.2.4 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -17,6 +17,8 @@ #include "cmSourceFileLocation.h" #include "cmMakefile.h" +#include "cmLocalGenerator.h" +#include "cmGlobalGenerator.h" #include "cmSystemTools.h" //---------------------------------------------------------------------------- @@ -89,17 +91,53 @@ void cmSourceFileLocation::UpdateExtension(const char* name) std::string ext = cmSystemTools::GetFilenameLastExtension(name); if(!ext.empty()) { ext = ext.substr(1); } - // TODO: Let enable-language specify extensions for each language. - cmMakefile const* mf = this->Makefile; + // The global generator checks extensions of enabled languages. + cmGlobalGenerator* gg = + this->Makefile->GetLocalGenerator()->GetGlobalGenerator(); + cmMakefile* mf = this->Makefile; const std::vector& srcExts = mf->GetSourceExtensions(); const std::vector& hdrExts = mf->GetHeaderExtensions(); - if(std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end() || + if(gg->GetLanguageFromExtension(ext.c_str()) || + std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end() || std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end()) { // This is a known extension. Use the given filename with extension. this->Name = cmSystemTools::GetFilenameName(name); this->AmbiguousExtension = false; } + else + { + // This is not a known extension. See if the file exists on disk as + // named. + std::string tryPath; + if(this->AmbiguousDirectory) + { + // Check the source tree only because a file in the build tree should + // be specified by full path at least once. We do not want this + // detection to depend on whether the project has already been built. + tryPath = this->Makefile->GetCurrentDirectory(); + tryPath += "/"; + } + if(!this->Directory.empty()) + { + tryPath += this->Directory; + tryPath += "/"; + } + tryPath += this->Name; + if(cmSystemTools::FileExists(tryPath.c_str(), true)) + { + // We found a source file named by the user on disk. Trust it's + // extension. + this->Name = cmSystemTools::GetFilenameName(name); + this->AmbiguousExtension = false; + + // If the directory was ambiguous, it isn't anymore. + if(this->AmbiguousDirectory) + { + this->DirectoryUseSource(); + } + } + } } //---------------------------------------------------------------------------- @@ -113,38 +151,76 @@ void cmSourceFileLocation::UpdateDirectory(const char* name) } } +//---------------------------------------------------------------------------- +bool +cmSourceFileLocation +::MatchesAmbiguousExtension(cmSourceFileLocation const& loc) const +{ + // This location's extension is not ambiguous but loc's extension + // is. See if the names match as-is. + if(this->Name == loc.Name) + { + return true; + } + + // Check if loc's name could possibly be extended to our name by + // adding an extension. + if(!(this->Name.size() > loc.Name.size() && + this->Name.substr(0, loc.Name.size()) == loc.Name && + this->Name[loc.Name.size()] == '.')) + { + return false; + } + + // Only a fixed set of extensions will be tried to match a file on + // disk. One of these must match if loc refers to this source file. + std::string ext = this->Name.substr(loc.Name.size()+1); + cmMakefile* mf = this->Makefile; + const std::vector& srcExts = mf->GetSourceExtensions(); + if(std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end()) + { + return true; + } + const std::vector& hdrExts = mf->GetHeaderExtensions(); + if(std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end()) + { + return true; + } + return false; +} + //---------------------------------------------------------------------------- bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc) { - if(this->AmbiguousExtension || loc.AmbiguousExtension) + if(this->AmbiguousExtension && loc.AmbiguousExtension) { - // Need to compare without the file extension. - std::string thisName; - if(this->AmbiguousExtension) - { - thisName = this->Name; - } - else - { - thisName = cmSystemTools::GetFilenameWithoutLastExtension(this->Name); - } - std::string locName; - if(loc.AmbiguousExtension) + // Both extensions are ambiguous. Since only the old fixed set of + // extensions will be tried, the names must match at this point to + // be the same file. + if(this->Name != loc.Name) { - locName = loc.Name; + return false; } - else + } + else if(this->AmbiguousExtension) + { + // Only "this" extension is ambiguous. + if(!loc.MatchesAmbiguousExtension(*this)) { - locName = cmSystemTools::GetFilenameWithoutLastExtension(loc.Name); + return false; } - if(thisName != locName) + } + else if(loc.AmbiguousExtension) + { + // Only "loc" extension is ambiguous. + if(!this->MatchesAmbiguousExtension(loc)) { return false; } } else { - // Compare with extension. + // Neither extension is ambiguous. if(this->Name != loc.Name) { return false; diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h index 3e030230e..8fb648b7b 100644 --- a/Source/cmSourceFileLocation.h +++ b/Source/cmSourceFileLocation.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSourceFileLocation.h,v $ Language: C++ - Date: $Date: 2007-06-18 15:59:23 $ - Version: $Revision: 1.2 $ + Date: $Date: 2008-08-06 21:04:19 $ + Version: $Revision: 1.2.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -94,6 +94,8 @@ private: std::string Directory; std::string Name; + bool MatchesAmbiguousExtension(cmSourceFileLocation const& loc) const; + // Update the location with additional knowledge. void Update(cmSourceFileLocation const& loc); void Update(const char* name); diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx index 187a87e02..83656370c 100644 --- a/Source/cmSourceGroup.cxx +++ b/Source/cmSourceGroup.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSourceGroup.cxx,v $ Language: C++ - Date: $Date: 2007-08-24 18:21:49 $ - Version: $Revision: 1.19 $ + Date: $Date: 2008-05-23 20:09:38 $ + Version: $Revision: 1.19.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -16,12 +16,46 @@ =========================================================================*/ #include "cmSourceGroup.h" +class cmSourceGroupInternals +{ +public: + std::vector GroupChildren; +}; + //---------------------------------------------------------------------------- cmSourceGroup::cmSourceGroup(const char* name, const char* regex): Name(name) { + this->Internal = new cmSourceGroupInternals; this->SetGroupRegex(regex); } +//---------------------------------------------------------------------------- +cmSourceGroup::~cmSourceGroup() +{ + delete this->Internal; +} + +//---------------------------------------------------------------------------- +cmSourceGroup::cmSourceGroup(cmSourceGroup const& r) +{ + this->Name = r.Name; + this->GroupRegex = r.GroupRegex; + this->GroupFiles = r.GroupFiles; + this->SourceFiles = r.SourceFiles; + this->Internal = new cmSourceGroupInternals(*r.Internal); +} + +//---------------------------------------------------------------------------- +cmSourceGroup& cmSourceGroup::operator=(cmSourceGroup const& r) +{ + this->Name = r.Name; + this->GroupRegex = r.GroupRegex; + this->GroupFiles = r.GroupFiles; + this->SourceFiles = r.SourceFiles; + *(this->Internal) = *(r.Internal); + return *this; +} + //---------------------------------------------------------------------------- void cmSourceGroup::SetGroupRegex(const char* regex) { @@ -85,15 +119,17 @@ std::vector& cmSourceGroup::GetSourceFiles() //---------------------------------------------------------------------------- void cmSourceGroup::AddChild(cmSourceGroup child) { - this->GroupChildren.push_back(child); + this->Internal->GroupChildren.push_back(child); } //---------------------------------------------------------------------------- cmSourceGroup *cmSourceGroup::lookupChild(const char* name) { // initializing iterators - std::vector::iterator iter = this->GroupChildren.begin(); - std::vector::iterator end = this->GroupChildren.end(); + std::vector::iterator iter = + this->Internal->GroupChildren.begin(); + std::vector::iterator end = + this->Internal->GroupChildren.end(); // st for(;iter!=end; ++iter) @@ -114,8 +150,10 @@ cmSourceGroup *cmSourceGroup::lookupChild(const char* name) cmSourceGroup *cmSourceGroup::MatchChildrenFiles(const char *name) { // initializing iterators - std::vector::iterator iter = this->GroupChildren.begin(); - std::vector::iterator end = this->GroupChildren.end(); + std::vector::iterator iter = + this->Internal->GroupChildren.begin(); + std::vector::iterator end = + this->Internal->GroupChildren.end(); if(this->MatchesFiles(name)) { @@ -136,8 +174,10 @@ cmSourceGroup *cmSourceGroup::MatchChildrenFiles(const char *name) cmSourceGroup *cmSourceGroup::MatchChildrenRegex(const char *name) { // initializing iterators - std::vector::iterator iter = this->GroupChildren.begin(); - std::vector::iterator end = this->GroupChildren.end(); + std::vector::iterator iter = + this->Internal->GroupChildren.begin(); + std::vector::iterator end = + this->Internal->GroupChildren.end(); if(this->MatchesRegex(name)) { @@ -154,7 +194,8 @@ cmSourceGroup *cmSourceGroup::MatchChildrenRegex(const char *name) return 0; } -std::vector cmSourceGroup::GetGroupChildren() const +std::vector const& +cmSourceGroup::GetGroupChildren() const { - return this->GroupChildren; + return this->Internal->GroupChildren; } diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h index 65959d7c4..adfd4bc6a 100644 --- a/Source/cmSourceGroup.h +++ b/Source/cmSourceGroup.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSourceGroup.h,v $ Language: C++ - Date: $Date: 2006-03-15 16:02:07 $ - Version: $Revision: 1.19 $ + Date: $Date: 2008-05-23 20:09:39 $ + Version: $Revision: 1.19.12.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -22,6 +22,8 @@ class cmSourceFile; +class cmSourceGroupInternals; + /** \class cmSourceGroup * \brief Hold a group of sources as specified by a SOURCE_GROUP command. * @@ -36,7 +38,9 @@ class cmSourceGroup { public: cmSourceGroup(const char* name, const char* regex); - ~cmSourceGroup() {} + cmSourceGroup(cmSourceGroup const& r); + ~cmSourceGroup(); + cmSourceGroup& operator=(cmSourceGroup const&); /** * Set the regular expression for this group. @@ -97,7 +101,7 @@ public: const std::vector& GetSourceFiles() const; std::vector& GetSourceFiles(); - std::vector GetGroupChildren() const; + std::vector const& GetGroupChildren() const; private: /** * The name of the source group. @@ -120,7 +124,7 @@ private: */ std::vector SourceFiles; - std::vector GroupChildren; + cmSourceGroupInternals* Internal; }; #endif diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 33a72ab7f..b1bfeeaaf 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmStringCommand.cxx,v $ Language: C++ - Date: $Date: 2008-01-23 15:27:59 $ - Version: $Revision: 1.27 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.27.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -222,7 +222,7 @@ bool cmStringCommand::HandleRegexCommand(std::vector const& args) { if(args.size() < 6) { - this->SetError("sub-command REGEX, mode MATCH needs " + this->SetError("sub-command REGEX, mode REPLACE needs " "at least 6 arguments total to command."); return false; } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 96e0e0bf3..1757060ba 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSystemTools.cxx,v $ Language: C++ - Date: $Date: 2008-04-21 00:44:52 $ - Version: $Revision: 1.368.2.4 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.368.2.6 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -26,6 +26,7 @@ #if defined(CMAKE_BUILD_WITH_CMAKE) # include #endif +#include #if defined(_WIN32) # include @@ -130,7 +131,7 @@ void* cmSystemTools::s_StdoutCallbackClientData = 0; // replace replace with with as many times as it shows up in source. // write the result into source. #if defined(_WIN32) && !defined(__CYGWIN__) -void cmSystemTools::ExpandRegistryValues(std::string& source) +void cmSystemTools::ExpandRegistryValues(std::string& source, KeyWOW64 view) { // Regular expression to match anything inside [...] that begins in HKEY. // Note that there is a special rule for regular expressions to match a @@ -146,7 +147,7 @@ void cmSystemTools::ExpandRegistryValues(std::string& source) // the arguments are the second match std::string key = regEntry.match(1); std::string val; - if (ReadRegistryValue(key.c_str(), val)) + if (ReadRegistryValue(key.c_str(), val, view)) { std::string reg = "["; reg += key + "]"; @@ -161,7 +162,7 @@ void cmSystemTools::ExpandRegistryValues(std::string& source) } } #else -void cmSystemTools::ExpandRegistryValues(std::string& source) +void cmSystemTools::ExpandRegistryValues(std::string& source, KeyWOW64) { cmsys::RegularExpression regEntry("\\[(HKEY[^]]*)\\]"); while (regEntry.find(source)) @@ -1392,7 +1393,9 @@ cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext) } //std::string ext = cmSystemTools::LowerCase(cext); std::string ext = cext; - if ( ext == "c" || ext == ".c" ) { return cmSystemTools::C_FILE_FORMAT; } + if ( ext == "c" || ext == ".c" || + ext == "m" || ext == ".m" + ) { return cmSystemTools::C_FILE_FORMAT; } if ( ext == "C" || ext == ".C" || ext == "M" || ext == ".M" || @@ -1400,7 +1403,6 @@ cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext) ext == "cc" || ext == ".cc" || ext == "cpp" || ext == ".cpp" || ext == "cxx" || ext == ".cxx" || - ext == "m" || ext == ".m" || ext == "mm" || ext == ".mm" ) { return cmSystemTools::CXX_FILE_FORMAT; } if ( @@ -2328,44 +2330,93 @@ std::string::size_type cmSystemToolsFindRPath(std::string const& have, } #endif +#if defined(CMAKE_USE_ELF_PARSER) +struct cmSystemToolsRPathInfo +{ + unsigned long Position; + unsigned long Size; + std::string Name; + std::string Value; +}; +#endif + //---------------------------------------------------------------------------- bool cmSystemTools::ChangeRPath(std::string const& file, std::string const& oldRPath, std::string const& newRPath, - std::string* emsg) + std::string* emsg, + bool* changed) { #if defined(CMAKE_USE_ELF_PARSER) - unsigned long rpathPosition = 0; - unsigned long rpathSize = 0; - std::string rpathPrefix; - std::string rpathSuffix; + if(changed) + { + *changed = false; + } + int rp_count = 0; + cmSystemToolsRPathInfo rp[2]; { // Parse the ELF binary. cmELF elf(file.c_str()); - // Get the RPATH or RUNPATH entry from it. - cmELF::StringEntry const* se = elf.GetRPath(); - if(!se) + // Get the RPATH and RUNPATH entries from it. + int se_count = 0; + cmELF::StringEntry const* se[2] = {0, 0}; + const char* se_name[2] = {0, 0}; + if(cmELF::StringEntry const* se_rpath = elf.GetRPath()) { - se = elf.GetRunPath(); + se[se_count] = se_rpath; + se_name[se_count] = "RPATH"; + ++se_count; + } + if(cmELF::StringEntry const* se_runpath = elf.GetRunPath()) + { + se[se_count] = se_runpath; + se_name[se_count] = "RUNPATH"; + ++se_count; + } + if(se_count == 0) + { + if(newRPath.empty()) + { + // The new rpath is empty and there is no rpath anyway so it is + // okay. + return true; + } + else + { + if(emsg) + { + *emsg = "No valid ELF RPATH or RUNPATH entry exists in the file; "; + *emsg += elf.GetErrorMessage(); + } + return false; + } } - if(se) + for(int i=0; i < se_count; ++i) { + // If both RPATH and RUNPATH refer to the same string literal it + // needs to be changed only once. + if(rp_count && rp[0].Position == se[i]->Position) + { + continue; + } + // Make sure the current rpath contains the old rpath. - std::string::size_type pos = cmSystemToolsFindRPath(se->Value, oldRPath); + std::string::size_type pos = + cmSystemToolsFindRPath(se[i]->Value, oldRPath); if(pos == std::string::npos) { // If it contains the new rpath instead then it is okay. - if(cmSystemToolsFindRPath(se->Value, newRPath) != std::string::npos) + if(cmSystemToolsFindRPath(se[i]->Value, newRPath) != std::string::npos) { - return true; + continue; } if(emsg) { cmOStringStream e; - e << "The current RPATH is:\n" - << " " << se->Value << "\n" + e << "The current " << se_name[i] << " is:\n" + << " " << se[i]->Value << "\n" << "which does not contain:\n" << " " << oldRPath << "\n" << "as was expected."; @@ -2374,47 +2425,44 @@ bool cmSystemTools::ChangeRPath(std::string const& file, return false; } - // Store information about the entry. - rpathPosition = se->Position; - rpathSize = se->Size; + // Store information about the entry in the file. + rp[rp_count].Position = se[i]->Position; + rp[rp_count].Size = se[i]->Size; + rp[rp_count].Name = se_name[i]; - // Store the part of the path we must preserve. - rpathPrefix = se->Value.substr(0, pos); - rpathSuffix = se->Value.substr(pos+oldRPath.length(), oldRPath.npos); - } - else if(newRPath.empty()) - { - // The new rpath is empty and there is no rpath anyway so it is - // okay. - return true; - } - else - { - if(emsg) + // Construct the new value which preserves the part of the path + // not being changed. + rp[rp_count].Value = se[i]->Value.substr(0, pos); + rp[rp_count].Value += newRPath; + rp[rp_count].Value += se[i]->Value.substr(pos+oldRPath.length(), + oldRPath.npos); + + // Make sure there is enough room to store the new rpath and at + // least one null terminator. + if(rp[rp_count].Size < rp[rp_count].Value.length()+1) { - *emsg = "No valid ELF RPATH entry exists in the file; "; - *emsg += elf.GetErrorMessage(); + if(emsg) + { + *emsg = "The replacement path is too long for the "; + *emsg += se_name[i]; + *emsg += " entry."; + } + return false; } - return false; + + // This entry is ready for update. + ++rp_count; } } - // Compute the full new rpath. - std::string rpath = rpathPrefix; - rpath += newRPath; - rpath += rpathSuffix; - // Make sure there is enough room to store the new rpath and at - // least one null terminator. - if(rpathSize < rpath.length()+1) + // If no runtime path needs to be changed, we are done. + if(rp_count == 0) { - if(emsg) - { - *emsg = "The replacement RPATH is too long."; - } - return false; + return true; } - // Open the file for update and seek to the RPATH position. + { + // Open the file for update. std::ofstream f(file.c_str(), std::ios::in | std::ios::out | std::ios::binary); if(!f) @@ -2425,97 +2473,150 @@ bool cmSystemTools::ChangeRPath(std::string const& file, } return false; } - if(!f.seekp(rpathPosition)) + + // Store the new RPATH and RUNPATH strings. + for(int i=0; i < rp_count; ++i) { - if(emsg) + // Seek to the RPATH position. + if(!f.seekp(rp[i].Position)) { - *emsg = "Error seeking to RPATH position."; + if(emsg) + { + *emsg = "Error seeking to "; + *emsg += rp[i].Name; + *emsg += " position."; + } + return false; } - return false; - } - // Write the new rpath. Follow it with enough null terminators to - // fill the string table entry. - f << rpath; - for(unsigned long i=rpath.length(); i < rpathSize; ++i) - { - f << '\0'; - } + // Write the new rpath. Follow it with enough null terminators to + // fill the string table entry. + f << rp[i].Value; + for(unsigned long j=rp[i].Value.length(); j < rp[i].Size; ++j) + { + f << '\0'; + } - // Make sure everything was okay. - if(f) - { - return true; - } - else - { - if(emsg) + // Make sure it wrote correctly. + if(!f) { - *emsg = "Error writing the new rpath to the file."; + if(emsg) + { + *emsg = "Error writing the new "; + *emsg += rp[i].Name; + *emsg += " string to the file."; + } + return false; } - return false; } + } + + // Everything was updated successfully. + if(changed) + { + *changed = true; + } + return true; #else (void)file; (void)oldRPath; (void)newRPath; (void)emsg; + (void)changed; return false; #endif } //---------------------------------------------------------------------------- -bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg) +bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg, + bool* removed) { #if defined(CMAKE_USE_ELF_PARSER) - unsigned long rpathPosition = 0; - unsigned long rpathSize = 0; - unsigned long rpathEntryPosition = 0; + if(removed) + { + *removed = false; + } + int zeroCount = 0; + unsigned long zeroPosition[2] = {0,0}; + unsigned long zeroSize[2] = {0,0}; + unsigned long bytesBegin = 0; std::vector bytes; { // Parse the ELF binary. cmELF elf(file.c_str()); - // Get the RPATH or RUNPATH entry from it. - cmELF::StringEntry const* se = elf.GetRPath(); - if(!se) + // Get the RPATH and RUNPATH entries from it and sort them by index + // in the dynamic section header. + int se_count = 0; + cmELF::StringEntry const* se[2] = {0, 0}; + if(cmELF::StringEntry const* se_rpath = elf.GetRPath()) { - se = elf.GetRunPath(); + se[se_count++] = se_rpath; } - - if(se) + if(cmELF::StringEntry const* se_runpath = elf.GetRunPath()) + { + se[se_count++] = se_runpath; + } + if(se_count == 0) { - // Store information about the entry. - rpathPosition = se->Position; - rpathSize = se->Size; - rpathEntryPosition = elf.GetDynamicEntryPosition(se->IndexInSection); + // There is no RPATH or RUNPATH anyway. + return true; + } + if(se_count == 2 && se[1]->IndexInSection < se[0]->IndexInSection) + { + cmsys_stl::swap(se[0], se[1]); + } - // Get the file range containing the rest of the DYNAMIC table - // after the RPATH entry. - unsigned long nextEntryPosition = - elf.GetDynamicEntryPosition(se->IndexInSection+1); - unsigned int count = elf.GetDynamicEntryCount(); - if(count == 0) + // Get the size of the dynamic section header. + unsigned int count = elf.GetDynamicEntryCount(); + if(count == 0) + { + // This should happen only for invalid ELF files where a DT_NULL + // appears before the end of the table. + if(emsg) { - // This should happen only for invalid ELF files where a DT_NULL - // appears before the end of the table. - if(emsg) - { - *emsg = "DYNAMIC section contains a DT_NULL before the end."; - } - return false; + *emsg = "DYNAMIC section contains a DT_NULL before the end."; } - unsigned long nullEntryPosition = elf.GetDynamicEntryPosition(count); + return false; + } + + // Save information about the string entries to be zeroed. + zeroCount = se_count; + for(int i=0; i < se_count; ++i) + { + zeroPosition[i] = se[i]->Position; + zeroSize[i] = se[i]->Size; + } + + // Get the range of file positions corresponding to each entry and + // the rest of the table after them. + unsigned long entryBegin[3] = {0,0,0}; + unsigned long entryEnd[2] = {0,0}; + for(int i=0; i < se_count; ++i) + { + entryBegin[i] = elf.GetDynamicEntryPosition(se[i]->IndexInSection); + entryEnd[i] = elf.GetDynamicEntryPosition(se[i]->IndexInSection+1); + } + entryBegin[se_count] = elf.GetDynamicEntryPosition(count); + + // The data are to be written over the old table entries starting at + // the first one being removed. + bytesBegin = entryBegin[0]; + unsigned long bytesEnd = entryBegin[se_count]; - // Allocate and fill a buffer with zeros. - bytes.resize(nullEntryPosition - rpathEntryPosition, 0); + // Allocate a buffer to hold the part of the file to be written. + // Initialize it with zeros. + bytes.resize(bytesEnd - bytesBegin, 0); - // Read the part of the DYNAMIC section header that will move. - // The remainder of the buffer will be left with zeros which - // represent a DT_NULL entry. - if(!elf.ReadBytes(nextEntryPosition, - nullEntryPosition - nextEntryPosition, - &bytes[0])) + // Read the part of the DYNAMIC section header that will move. + // The remainder of the buffer will be left with zeros which + // represent a DT_NULL entry. + char* data = &bytes[0]; + for(int i=0; i < se_count; ++i) + { + // Read data between the entries being removed. + unsigned long sz = entryBegin[i+1] - entryEnd[i]; + if(sz > 0 && !elf.ReadBytes(entryEnd[i], sz, data)) { if(emsg) { @@ -2523,11 +2624,7 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg) } return false; } - } - else - { - // There is no RPATH or RUNPATH anyway. - return true; + data += sz; } } @@ -2544,7 +2641,7 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg) } // Write the new DYNAMIC table header. - if(!f.seekp(rpathEntryPosition)) + if(!f.seekp(bytesBegin)) { if(emsg) { @@ -2561,36 +2658,41 @@ bool cmSystemTools::RemoveRPath(std::string const& file, std::string* emsg) return false; } - // Fill the RPATH string with zero bytes. - if(!f.seekp(rpathPosition)) + // Fill the RPATH and RUNPATH strings with zero bytes. + for(int i=0; i < zeroCount; ++i) { - if(emsg) + if(!f.seekp(zeroPosition[i])) { - *emsg = "Error seeking to RPATH position."; + if(emsg) + { + *emsg = "Error seeking to RPATH position."; + } + return false; + } + for(unsigned long j=0; j < zeroSize[i]; ++j) + { + f << '\0'; + } + if(!f) + { + if(emsg) + { + *emsg = "Error writing the empty rpath string to the file."; + } + return false; } - return false; - } - for(unsigned long i=0; i < rpathSize; ++i) - { - f << '\0'; } - // Make sure everything was okay. - if(f) + // Everything was updated successfully. + if(removed) { - return true; - } - else - { - if(emsg) - { - *emsg = "Error writing the empty rpath to the file."; - } - return false; + *removed = true; } + return true; #else (void)file; (void)emsg; + (void)removed; return false; #endif } diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 42de13fb7..e898812cc 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmSystemTools.h,v $ Language: C++ - Date: $Date: 2008-04-21 00:44:53 $ - Version: $Revision: 1.150.2.1 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.150.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -48,7 +48,8 @@ public: /** * Look for and replace registry values in a string */ - static void ExpandRegistryValues(std::string& source); + static void ExpandRegistryValues(std::string& source, + KeyWOW64 view = KeyWOW64_Default); /** * Platform independent escape spaces, unix uses backslash, @@ -391,10 +392,12 @@ public: static bool ChangeRPath(std::string const& file, std::string const& oldRPath, std::string const& newRPath, - std::string* emsg = 0); + std::string* emsg = 0, + bool* changed = 0); /** Try to remove the RPATH from an ELF binary. */ - static bool RemoveRPath(std::string const& file, std::string* emsg = 0); + static bool RemoveRPath(std::string const& file, std::string* emsg = 0, + bool* removed = 0); /** Check whether the RPATH in an ELF binary contains the path given. */ diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 93d164510..98917fe4b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmTarget.cxx,v $ Language: C++ - Date: $Date: 2008-04-21 00:44:53 $ - Version: $Revision: 1.207.2.5 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.207.2.10 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -22,6 +22,7 @@ #include "cmGlobalGenerator.h" #include "cmComputeLinkInformation.h" #include "cmListFileCache.h" +#include #include #include #include @@ -30,7 +31,8 @@ const char* cmTarget::TargetTypeNames[] = { "EXECUTABLE", "STATIC_LIBRARY", "SHARED_LIBRARY", "MODULE_LIBRARY", "UTILITY", "GLOBAL_TARGET", - "INSTALL_FILES", "INSTALL_PROGRAMS", "INSTALL_DIRECTORY" + "INSTALL_FILES", "INSTALL_PROGRAMS", "INSTALL_DIRECTORY", + "UNKNOWN_LIBRARY" }; //---------------------------------------------------------------------------- @@ -55,6 +57,7 @@ cmTarget::cmTarget() this->Makefile = 0; this->PolicyStatusCMP0003 = cmPolicies::WARN; this->PolicyStatusCMP0004 = cmPolicies::WARN; + this->PolicyStatusCMP0008 = cmPolicies::WARN; this->LinkLibrariesAnalyzed = false; this->HaveInstallRule = false; this->DLLPlatform = false; @@ -158,6 +161,24 @@ void cmTarget::DefineProperties(cmake *cm) "C++ linker (and C++ runtime libraries) for linking even if the " "target has no C++ code in it."); + cm->DefineProperty + ("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM", cmProperty::TARGET, + "Specify #include line transforms for dependencies in a target.", + "This property specifies rules to transform macro-like #include lines " + "during implicit dependency scanning of C and C++ source files. " + "The list of rules must be semicolon-separated with each entry of " + "the form \"A_MACRO(%)=value-with-%\" (the % must be literal). " + "During dependency scanning occurrences of A_MACRO(...) on #include " + "lines will be replaced by the value given with the macro argument " + "substituted for '%'. For example, the entry\n" + " MYDIR(%)=\n" + "will convert lines of the form\n" + " #include MYDIR(myheader.h)\n" + "to\n" + " #include \n" + "allowing the dependency to be followed.\n" + "This property applies to sources in the target on which it is set."); + cm->DefineProperty ("IMPORT_PREFIX", cmProperty::TARGET, "What comes before the import library name.", @@ -226,7 +247,9 @@ void cmTarget::DefineProperties(cmake *cm) "This property is used when loading settings for the " "configuration of an imported target. " "Configuration names correspond to those provided by the project " - "from which the target is imported."); + "from which the target is imported. " + "If set, this property completely overrides the generic property " + "for the named configuration."); cm->DefineProperty ("IMPORTED_LINK_INTERFACE_LIBRARIES", cmProperty::TARGET, @@ -234,7 +257,9 @@ void cmTarget::DefineProperties(cmake *cm) "Lists libraries whose interface is included when an IMPORTED library " "target is linked to another target. " "The libraries will be included on the link line for the target. " - "Ignored for non-imported targets."); + "Unlike the LINK_INTERFACE_LIBRARIES property, this property applies " + "to all imported target types, including STATIC libraries. " + "This property is ignored for non-imported targets."); cm->DefineProperty ("IMPORTED_LINK_INTERFACE_LIBRARIES_", cmProperty::TARGET, @@ -242,7 +267,9 @@ void cmTarget::DefineProperties(cmake *cm) "This property is used when loading settings for the " "configuration of an imported target. " "Configuration names correspond to those provided by the project " - "from which the target is imported."); + "from which the target is imported. " + "If set, this property completely overrides the generic property " + "for the named configuration."); cm->DefineProperty ("IMPORTED_LOCATION", cmProperty::TARGET, @@ -258,6 +285,7 @@ void cmTarget::DefineProperties(cmake *cm) "For frameworks on OS X this is the location of the library file " "symlink just inside the framework folder. " "For DLLs this is the location of the \".dll\" part of the library. " + "For UNKNOWN libraries this is the location of the file to be linked. " "Ignored for non-imported targets."); cm->DefineProperty @@ -379,13 +407,16 @@ void cmTarget::DefineProperties(cmake *cm) "provided to the other target also. " "If the list is empty then no transitive link dependencies will be " "incorporated when this target is linked into another target even if " - "the default set is non-empty."); + "the default set is non-empty. " + "This property is ignored for STATIC libraries."); cm->DefineProperty ("LINK_INTERFACE_LIBRARIES_", cmProperty::TARGET, "Per-configuration list of public interface libraries for a target.", "This is the configuration-specific version of " - "LINK_INTERFACE_LIBRARIES."); + "LINK_INTERFACE_LIBRARIES. " + "If set, this property completely overrides the generic property " + "for the named configuration."); cm->DefineProperty ("MAP_IMPORTED_CONFIG_", cmProperty::TARGET, @@ -529,10 +560,21 @@ void cmTarget::DefineProperties(cmake *cm) "When this property is set to true the executable when built " "on Mac OS X will be created as an application bundle. " "This makes it a GUI executable that can be launched from " - "the Finder.\n" - "The bundle Info.plist file is generated automatically. " - "The following target properties may be set to specify " - "its content:" + "the Finder. " + "See the MACOSX_BUNDLE_INFO_PLIST target property for information " + "about creation of the Info.plist file for the application bundle."); + + cm->DefineProperty + ("MACOSX_BUNDLE_INFO_PLIST", cmProperty::TARGET, + "Specify a custom Info.plist template for a Mac OS X App Bundle.", + "An executable target with MACOSX_BUNDLE enabled will be built as an " + "application bundle on Mac OS X. " + "By default its Info.plist file is created by configuring a template " + "called MacOSXBundleInfo.plist.in located in the CMAKE_MODULE_PATH. " + "This property specifies an alternative template file name which " + "may be a full path.\n" + "The following target properties may be set to specify content to " + "be configured into the file:\n" " MACOSX_BUNDLE_INFO_STRING\n" " MACOSX_BUNDLE_ICON_FILE\n" " MACOSX_BUNDLE_GUI_IDENTIFIER\n" @@ -541,7 +583,30 @@ void cmTarget::DefineProperties(cmake *cm) " MACOSX_BUNDLE_SHORT_VERSION_STRING\n" " MACOSX_BUNDLE_BUNDLE_VERSION\n" " MACOSX_BUNDLE_COPYRIGHT\n" - ); + "CMake variables of the same name may be set to affect all targets " + "in a directory that do not have each specific property set. " + "If a custom Info.plist is specified by this property it may of course " + "hard-code all the settings instead of using the target properties."); + + cm->DefineProperty + ("MACOSX_FRAMEWORK_INFO_PLIST", cmProperty::TARGET, + "Specify a custom Info.plist template for a Mac OS X Framework.", + "An library target with FRAMEWORK enabled will be built as a " + "framework on Mac OS X. " + "By default its Info.plist file is created by configuring a template " + "called MacOSXFrameworkInfo.plist.in located in the CMAKE_MODULE_PATH. " + "This property specifies an alternative template file name which " + "may be a full path.\n" + "The following target properties may be set to specify content to " + "be configured into the file:\n" + " MACOSX_FRAMEWORK_ICON_FILE\n" + " MACOSX_FRAMEWORK_IDENTIFIER\n" + " MACOSX_FRAMEWORK_SHORT_VERSION_STRING\n" + " MACOSX_FRAMEWORK_BUNDLE_VERSION\n" + "CMake variables of the same name may be set to affect all targets " + "in a directory that do not have each specific property set. " + "If a custom Info.plist is specified by this property it may of course " + "hard-code all the settings instead of using the target properties."); cm->DefineProperty ("ENABLE_EXPORTS", cmProperty::TARGET, @@ -736,6 +801,8 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->Makefile->GetPolicyStatus(cmPolicies::CMP0003); this->PolicyStatusCMP0004 = this->Makefile->GetPolicyStatus(cmPolicies::CMP0004); + this->PolicyStatusCMP0008 = + this->Makefile->GetPolicyStatus(cmPolicies::CMP0008); } //---------------------------------------------------------------------------- @@ -751,6 +818,16 @@ bool cmTarget::IsExecutableWithExports() this->GetPropertyAsBool("ENABLE_EXPORTS")); } +//---------------------------------------------------------------------------- +bool cmTarget::IsLinkable() +{ + return (this->GetType() == cmTarget::STATIC_LIBRARY || + this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY || + this->GetType() == cmTarget::UNKNOWN_LIBRARY || + this->IsExecutableWithExports()); +} + //---------------------------------------------------------------------------- bool cmTarget::IsFrameworkOnApple() { @@ -1005,6 +1082,21 @@ void cmTarget::TraceDependencies(const char* vsProjectFile) tracer.Trace(); } +//---------------------------------------------------------------------------- +bool cmTarget::FindSourceFiles() +{ + for(std::vector::const_iterator + si = this->SourceFiles.begin(); + si != this->SourceFiles.end(); ++si) + { + if((*si)->GetFullPath().empty()) + { + return false; + } + } + return true; +} + //---------------------------------------------------------------------------- void cmTarget::AddSources(std::vector const& srcs) { @@ -1619,6 +1711,69 @@ void cmTarget::AppendProperty(const char* prop, const char* value) } } +//---------------------------------------------------------------------------- +static void cmTargetCheckLINK_INTERFACE_LIBRARIES( + const char* prop, const char* value, cmMakefile* context, bool imported + ) +{ + // Look for link-type keywords in the value. + static cmsys::RegularExpression + keys("(^|;)(debug|optimized|general)(;|$)"); + if(!keys.find(value)) + { + return; + } + + // Support imported and non-imported versions of the property. + const char* base = (imported? + "IMPORTED_LINK_INTERFACE_LIBRARIES" : + "LINK_INTERFACE_LIBRARIES"); + + // Report an error. + cmOStringStream e; + e << "Property " << prop << " may not contain link-type keyword \"" + << keys.match(2) << "\". " + << "The " << base << " property has a per-configuration " + << "version called " << base << "_ which may be " + << "used to specify per-configuration rules."; + if(!imported) + { + e << " " + << "Alternatively, an IMPORTED library may be created, configured " + << "with a per-configuration location, and then named in the " + << "property value. " + << "See the add_library command's IMPORTED mode for details." + << "\n" + << "If you have a list of libraries that already contains the " + << "keyword, use the target_link_libraries command with its " + << "LINK_INTERFACE_LIBRARIES mode to set the property. " + << "The command automatically recognizes link-type keywords and sets " + << "the LINK_INTERFACE_LIBRARIES and LINK_INTERFACE_LIBRARIES_DEBUG " + << "properties accordingly."; + } + context->IssueMessage(cmake::FATAL_ERROR, e.str()); +} + +//---------------------------------------------------------------------------- +void cmTarget::CheckProperty(const char* prop, cmMakefile* context) +{ + // Certain properties need checking. + if(strncmp(prop, "LINK_INTERFACE_LIBRARIES", 24) == 0) + { + if(const char* value = this->GetProperty(prop)) + { + cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, false); + } + } + if(strncmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES", 33) == 0) + { + if(const char* value = this->GetProperty(prop)) + { + cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, value, context, true); + } + } +} + //---------------------------------------------------------------------------- void cmTarget::MarkAsImported() { @@ -1708,20 +1863,33 @@ const char* cmTarget::NormalGetLocation(const char* config) //---------------------------------------------------------------------------- void cmTarget::GetTargetVersion(int& major, int& minor) +{ + int patch; + this->GetTargetVersion(false, major, minor, patch); +} + +//---------------------------------------------------------------------------- +void cmTarget::GetTargetVersion(bool soversion, + int& major, int& minor, int& patch) { // Set the default values. major = 0; minor = 0; + patch = 0; - // Look for a VERSION property. - if(const char* version = this->GetProperty("VERSION")) + // Look for a VERSION or SOVERSION property. + const char* prop = soversion? "SOVERSION" : "VERSION"; + if(const char* version = this->GetProperty(prop)) { // Try to parse the version number and store the results that were // successfully parsed. int parsed_major; int parsed_minor; - switch(sscanf(version, "%d.%d", &parsed_major, &parsed_minor)) + int parsed_patch; + switch(sscanf(version, "%d.%d.%d", + &parsed_major, &parsed_minor, &parsed_patch)) { + case 3: patch = parsed_patch; // no break! case 2: minor = parsed_minor; // no break! case 1: major = parsed_major; // no break! default: break; @@ -1797,7 +1965,8 @@ const char *cmTarget::GetProperty(const char* prop, if(this->GetType() == cmTarget::EXECUTABLE || this->GetType() == cmTarget::STATIC_LIBRARY || this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) + this->GetType() == cmTarget::MODULE_LIBRARY || + this->GetType() == cmTarget::UNKNOWN_LIBRARY) { if(!this->IsImported() && strcmp(prop,"LOCATION") == 0) { @@ -1894,6 +2063,9 @@ const char *cmTarget::GetProperty(const char* prop, case cmTarget::INSTALL_DIRECTORY: return "INSTALL_DIRECTORY"; // break; /* unreachable */ + case cmTarget::UNKNOWN_LIBRARY: + return "UNKNOWN_LIBRARY"; + // break; /* unreachable */ } return 0; } @@ -1980,11 +2152,7 @@ const char* cmTarget::GetCreateRuleVariable() return "_CREATE_SHARED_MODULE"; case cmTarget::EXECUTABLE: return "_LINK_EXECUTABLE"; - case cmTarget::UTILITY: - case cmTarget::GLOBAL_TARGET: - case cmTarget::INSTALL_FILES: - case cmTarget::INSTALL_PROGRAMS: - case cmTarget::INSTALL_DIRECTORY: + default: break; } return ""; @@ -2010,11 +2178,7 @@ const char* cmTarget::GetSuffixVariableInternal(TargetType type, return (implib ? "CMAKE_IMPORT_LIBRARY_SUFFIX" : "CMAKE_EXECUTABLE_SUFFIX"); - case cmTarget::UTILITY: - case cmTarget::GLOBAL_TARGET: - case cmTarget::INSTALL_FILES: - case cmTarget::INSTALL_PROGRAMS: - case cmTarget::INSTALL_DIRECTORY: + default: break; } return ""; @@ -2039,11 +2203,7 @@ const char* cmTarget::GetPrefixVariableInternal(TargetType type, : "CMAKE_SHARED_MODULE_PREFIX"); case cmTarget::EXECUTABLE: return (implib? "CMAKE_IMPORT_LIBRARY_PREFIX" : ""); - case cmTarget::UTILITY: - case cmTarget::GLOBAL_TARGET: - case cmTarget::INSTALL_FILES: - case cmTarget::INSTALL_PROGRAMS: - case cmTarget::INSTALL_DIRECTORY: + default: break; } return ""; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 92de4a937..419adb1dd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmTarget.h,v $ Language: C++ - Date: $Date: 2008-04-08 20:26:07 $ - Version: $Revision: 1.109.2.3 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.109.2.7 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -80,7 +80,8 @@ public: cmTarget(); enum TargetType { EXECUTABLE, STATIC_LIBRARY, SHARED_LIBRARY, MODULE_LIBRARY, UTILITY, GLOBAL_TARGET, - INSTALL_FILES, INSTALL_PROGRAMS, INSTALL_DIRECTORY}; + INSTALL_FILES, INSTALL_PROGRAMS, INSTALL_DIRECTORY, + UNKNOWN_LIBRARY}; static const char* TargetTypeNames[]; enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD }; @@ -114,6 +115,10 @@ public: cmPolicies::PolicyStatus GetPolicyStatusCMP0004() const { return this->PolicyStatusCMP0004; } + /** Get the status of policy CMP0008 when the target was created. */ + cmPolicies::PolicyStatus GetPolicyStatusCMP0008() const + { return this->PolicyStatusCMP0008; } + /** * Get the list of the custom commands for this target */ @@ -240,6 +245,7 @@ public: const char *GetProperty(const char *prop); const char *GetProperty(const char *prop, cmProperty::ScopeType scope); bool GetPropertyAsBool(const char *prop); + void CheckProperty(const char* prop, cmMakefile* context); bool IsImported() const {return this->IsImportedTarget;} @@ -265,12 +271,22 @@ public: not set or cannot be parsed. */ void GetTargetVersion(int& major, int& minor); + /** Get the target major, minor, and patch version numbers + interpreted from the VERSION or SOVERSION property. Version 0 + is returned if the property is not set or cannot be parsed. */ + void GetTargetVersion(bool soversion, int& major, int& minor, int& patch); + /** * Trace through the source files in this target and add al source files * that they depend on, used by all generators */ void TraceDependencies(const char* vsProjectFile); + /** + * Make sure the full path to all source files is known. + */ + bool FindSourceFiles(); + ///! Return the prefered linker language for this target const char* GetLinkerLanguage(cmGlobalGenerator*); @@ -379,6 +395,9 @@ public: enabled. */ bool IsExecutableWithExports(); + /** Return whether this target may be used to link another target. */ + bool IsLinkable(); + /** Return whether this target is a shared library Framework on Apple. */ bool IsFrameworkOnApple(); @@ -542,6 +561,7 @@ private: // Policy status recorded when target was created. cmPolicies::PolicyStatus PolicyStatusCMP0003; cmPolicies::PolicyStatus PolicyStatusCMP0004; + cmPolicies::PolicyStatus PolicyStatusCMP0008; // Internal representation details. friend class cmTargetInternals; diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 5f5c9614e..96eb4c45e 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmTargetLinkLibrariesCommand.cxx,v $ Language: C++ - Date: $Date: 2008-01-23 15:27:59 $ - Version: $Revision: 1.25 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.25.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -16,6 +16,13 @@ =========================================================================*/ #include "cmTargetLinkLibrariesCommand.h" +const char* cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[3] = +{ + "general", + "debug", + "optimized" +}; + // cmTargetLinkLibrariesCommand bool cmTargetLinkLibrariesCommand ::InitialPass(std::vector const& args, cmExecutionStatus &) @@ -32,57 +39,88 @@ bool cmTargetLinkLibrariesCommand { return true; } + + // Lookup the target for which libraries are specified. + this->Target = + this->Makefile->GetCMakeInstance() + ->GetGlobalGenerator()->FindTarget(0, args[0].c_str()); + if(!this->Target) + { + cmOStringStream e; + e << "Cannot specify link libraries for target \"" << args[0] << "\" " + << "which is not built by this project."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + cmSystemTools::SetFatalErrorOccured(); + return true; + } + + // Keep track of link configuration specifiers. + cmTarget::LinkLibraryType llt = cmTarget::GENERAL; + bool haveLLT = false; + + // Start with primary linking and switch to link interface + // specification when the keyword is encountered. + this->DoingInterface = false; + // add libraries, nothe that there is an optional prefix // of debug and optimized than can be used - std::vector::const_iterator i = args.begin(); - - for(++i; i != args.end(); ++i) + for(unsigned int i=1; i < args.size(); ++i) { - if (*i == "debug") + if(args[i] == "LINK_INTERFACE_LIBRARIES") + { + this->DoingInterface = true; + if(i != 1) + { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + "The LINK_INTERFACE_LIBRARIES option must appear as the second " + "argument, just after the target name." + ); + return true; + } + } + else if(args[i] == "debug") { - ++i; - if(i == args.end()) + if(haveLLT) { - this->SetError - ("The \"debug\" argument must be followed by a library"); - return false; + this->LinkLibraryTypeSpecifierWarning(llt, cmTarget::DEBUG); } - this->Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(), - cmTarget::DEBUG); + llt = cmTarget::DEBUG; + haveLLT = true; } - else if (*i == "optimized") + else if(args[i] == "optimized") { - ++i; - if(i == args.end()) + if(haveLLT) { - this->SetError( - "The \"optimized\" argument must be followed by a library"); - return false; + this->LinkLibraryTypeSpecifierWarning(llt, cmTarget::OPTIMIZED); } - this->Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(), - cmTarget::OPTIMIZED); + llt = cmTarget::OPTIMIZED; + haveLLT = true; } - else if (*i == "general") + else if(args[i] == "general") { - ++i; - if(i == args.end()) + if(haveLLT) { - this->SetError( - "The \"general\" argument must be followed by a library"); - return false; + this->LinkLibraryTypeSpecifierWarning(llt, cmTarget::GENERAL); } - this->Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(), - cmTarget::GENERAL); + llt = cmTarget::GENERAL; + haveLLT = true; + } + else if(haveLLT) + { + // The link type was specified by the previous argument. + haveLLT = false; + this->HandleLibrary(args[i].c_str(), llt); } else { - // make sure the type is correct if it is currently general. So if you + // Lookup old-style cache entry if type is unspecified. So if you // do a target_link_libraries(foo optimized bar) it will stay optimized // and not use the lookup. As there maybe the case where someone has // specifed that a library is both debug and optimized. (this check is // only there for backwards compatibility when mixing projects built // with old versions of CMake and new) - cmTarget::LinkLibraryType llt = cmTarget::GENERAL; + llt = cmTarget::GENERAL; std::string linkType = args[0]; linkType += "_LINK_TYPE"; const char* linkTypeString = @@ -98,8 +136,80 @@ bool cmTargetLinkLibrariesCommand llt = cmTarget::OPTIMIZED; } } - this->Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),llt); + this->HandleLibrary(args[i].c_str(), llt); } } + + // Make sure the last argument was not a library type specifier. + if(haveLLT) + { + cmOStringStream e; + e << "The \"" << this->LinkLibraryTypeNames[llt] + << "\" argument must be followed by a library."; + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + cmSystemTools::SetFatalErrorOccured(); + } + + // If the INTERFACE option was given, make sure the + // LINK_INTERFACE_LIBRARIES property exists. This allows the + // command to be used to specify an empty link interface. + if(this->DoingInterface && + !this->Target->GetProperty("LINK_INTERFACE_LIBRARIES")) + { + this->Target->SetProperty("LINK_INTERFACE_LIBRARIES", ""); + } + return true; } + +//---------------------------------------------------------------------------- +void +cmTargetLinkLibrariesCommand +::LinkLibraryTypeSpecifierWarning(int left, int right) +{ + cmOStringStream w; + w << "Link library type specifier \"" + << this->LinkLibraryTypeNames[left] << "\" is followed by specifier \"" + << this->LinkLibraryTypeNames[right] << "\" instead of a library name. " + << "The first specifier will be ignored."; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); +} + +//---------------------------------------------------------------------------- +void +cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, + cmTarget::LinkLibraryType llt) +{ + // Handle normal case first. + if(!this->DoingInterface) + { + this->Makefile + ->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt); + return; + } + + // Include this library in the link interface for the target. + if(llt == cmTarget::DEBUG) + { + // Put in only the DEBUG configuration interface. + this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES_DEBUG", lib); + } + else if(llt == cmTarget::OPTIMIZED) + { + // Put in only the non-DEBUG configuration interface. + this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib); + + // Make sure the DEBUG configuration interface exists so that this + // one will not be used as a fall-back. + if(!this->Target->GetProperty("LINK_INTERFACE_LIBRARIES_DEBUG")) + { + this->Target->SetProperty("LINK_INTERFACE_LIBRARIES_DEBUG", ""); + } + } + else + { + // Put in both the DEBUG and non-DEBUG configuration interfaces. + this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib); + this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES_DEBUG", lib); + } +} diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index 2b58aae0a..e4161f620 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmTargetLinkLibrariesCommand.h,v $ Language: C++ - Date: $Date: 2008-02-06 20:23:36 $ - Version: $Revision: 1.15 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.15.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -64,21 +64,55 @@ public: virtual const char* GetFullDocumentation() { return - " target_link_libraries(target library1\n" - " library2\n" - " ...)\n" + " target_link_libraries( [lib1 [lib2 [...]]]\n" + " [[debug|optimized|general] ] ...)\n" "Specify a list of libraries to be linked into the specified target. " - "The debug and optimized strings may be used to indicate that " - "the next library listed is to be used only for that specific " - "type of build. general indicates it is used for all build types " - "and is assumed if not specified.\n" "If any library name matches that of a target in the current project " "a dependency will automatically be added in the build system to make " - "sure the library being linked is up-to-date before the target links."; + "sure the library being linked is up-to-date before the target links." + "\n" + "A \"debug\", \"optimized\", or \"general\" keyword indicates that " + "the library immediately following it is to be used only for the " + "corresponding build configuration. " + "The \"debug\" keyword corresponds to the Debug configuration. " + "The \"optimized\" keyword corresponds to all other configurations. " + "The \"general\" keyword corresponds to all configurations, and is " + "purely optional (assumed if omitted). " + "Higher granularity may be achieved for per-configuration rules " + "by creating and linking to IMPORTED library targets. " + "See the IMPORTED mode of the add_library command for more " + "information. " + "\n" + "Library dependencies are transitive by default. " + "When this target is linked into another target then the libraries " + "linked to this target will appear on the link line for the other " + "target too. " + "See the LINK_INTERFACE_LIBRARIES target property to override the " + "set of transitive link dependencies for a target." + "\n" + " target_link_libraries( LINK_INTERFACE_LIBRARIES\n" + " [[debug|optimized|general] ] ...)\n" + "The LINK_INTERFACE_LIBRARIES mode appends the libraries " + "to the LINK_INTERFACE_LIBRARIES and LINK_INTERFACE_LIBRARIES_DEBUG " + "target properties instead of using them for linking. " + "Libraries specified as \"debug\" are appended to the " + "the LINK_INTERFACE_LIBRARIES_DEBUG property. " + "Libraries specified as \"optimized\" are appended to the " + "the LINK_INTERFACE_LIBRARIES property. " + "Libraries specified as \"general\" (or without any keyword) are " + "appended to both properties." + ; } cmTypeMacro(cmTargetLinkLibrariesCommand, cmCommand); private: + void LinkLibraryTypeSpecifierWarning(int left, int right); + static const char* LinkLibraryTypeNames[3]; + + cmTarget* Target; + bool DoingInterface; + + void HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt); }; diff --git a/Source/cmVersion.cxx b/Source/cmVersion.cxx index 75e3d912a..0215b2750 100644 --- a/Source/cmVersion.cxx +++ b/Source/cmVersion.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmVersion.cxx,v $ Language: C++ - Date: $Date: 2007-11-15 02:17:53 $ - Version: $Revision: 1.1027 $ + Date: $Date: 2008-05-21 14:50:13 $ + Version: $Revision: 1.1027.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -23,15 +23,11 @@ std::string cmVersion::GetReleaseVersion() #if CMake_VERSION_MINOR & 1 return cmsys_DATE_STAMP_STRING_FULL; #else -# if CMake_VERSION_PATCH == 1 - return "1-beta"; -# else -# ifdef CMake_VERSION_RC +# ifdef CMake_VERSION_RC return "patch " CMAKE_TO_STRING(CMake_VERSION_PATCH) " RC-" CMAKE_TO_STRING(CMake_VERSION_RC); -# else +# else return "patch " CMAKE_TO_STRING(CMake_VERSION_PATCH); -# endif # endif #endif } diff --git a/Source/cmWin32ProcessExecution.cxx b/Source/cmWin32ProcessExecution.cxx index 4cdc8903c..7a8388fb0 100644 --- a/Source/cmWin32ProcessExecution.cxx +++ b/Source/cmWin32ProcessExecution.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmWin32ProcessExecution.cxx,v $ Language: C++ - Date: $Date: 2007-09-27 18:16:20 $ - Version: $Revision: 1.32 $ + Date: $Date: 2008-09-04 21:10:45 $ + Version: $Revision: 1.32.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -715,18 +715,24 @@ bool cmWin32ProcessExecution::CloseHandles() { if(this->pStdErr != -1 ) { + // this will close this as well: this->hChildStderrRdDup _close(this->pStdErr); this->pStdErr = -1; + this->hChildStderrRdDup = 0; } if(this->pStdIn != -1 ) { + // this will close this as well: this->hChildStdinWrDup _close(this->pStdIn); this->pStdIn = -1; + this->hChildStdinWrDup = 0; } if(this->pStdOut != -1 ) { + // this will close this as well: this->hChildStdoutRdDup _close(this->pStdOut); this->pStdOut = -1; + this->hChildStdoutRdDup = 0; } bool ret = true; @@ -735,21 +741,7 @@ bool cmWin32ProcessExecution::CloseHandles() ret = false; } this->hChildStdinRd = 0; - if(this->hChildStdoutRdDup && !CloseHandle(this->hChildStdoutRdDup)) - { - ret = false; - } - this->hChildStdoutRdDup = 0; - if(this->hChildStderrRdDup && !CloseHandle(this->hChildStderrRdDup)) - { - ret = false; - } - this->hChildStderrRdDup = 0; - if(this->hChildStdinWrDup && !CloseHandle(this->hChildStdinWrDup)) - { - ret = false; - } - this->hChildStdinWrDup = 0; + // now close these two if (this->hChildStdoutWr && !CloseHandle(this->hChildStdoutWr)) { ret = false; diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 660a77e0b..93c01ec07 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmXCodeObject.cxx,v $ Language: C++ - Date: $Date: 2007-08-14 15:45:14 $ - Version: $Revision: 1.24 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.24.2.2 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -69,6 +69,10 @@ cmXCodeObject::cmXCodeObject(PBXType ptype, Type type) this->Id += "0"; } } + if(this->Id.size() > 24) + { + this->Id = this->Id.substr(0,24); + } this->TypeValue = type; if(this->TypeValue == OBJECT) { @@ -147,7 +151,9 @@ void cmXCodeObject::Print(std::ostream& out) if(j->second->TypeValue == STRING) { - out << j->first << " = " << j->second->String << ";"; + out << j->first << " = "; + j->second->PrintString(out); + out << ";"; } else if(j->second->TypeValue == OBJECT_LIST) { @@ -156,7 +162,8 @@ void cmXCodeObject::Print(std::ostream& out) { if(j->second->List[k]->TypeValue == STRING) { - out << j->second->List[k]->String << ", "; + j->second->List[k]->PrintString(out); + out << ", "; } else { @@ -188,7 +195,9 @@ void cmXCodeObject::Print(std::ostream& out) } else if(object->TypeValue == STRING) { - out << i->first << " = " << object->String << ";" << separator; + out << i->first << " = "; + object->PrintString(out); + out << ";" << separator; } else { @@ -226,29 +235,32 @@ void cmXCodeObject::CopyAttributes(cmXCodeObject* copy) } //---------------------------------------------------------------------------- -void cmXCodeObject::SetString(const char* s) +void cmXCodeObject::PrintString(std::ostream& os) const { - std::string ss = s; - if(ss.size() == 0) - { - this->String = "\"\""; - return; - } - // escape quotes - cmSystemTools::ReplaceString(ss, "\"", "\\\""); - bool needQuote = false; - this->String = ""; - if(ss.find_first_of(" <>.+-=@") != ss.npos) - { - needQuote = true; - } - if(needQuote) - { - this->String = "\""; - } - this->String += ss; - if(needQuote) + // 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); + 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) { - this->String += "\""; + if(*i == '"') + { + // Escape double-quotes. + os << '\\'; + } + os << *i; } + os << quote; +} + +//---------------------------------------------------------------------------- +void cmXCodeObject::SetString(const char* s) +{ + this->String = s; } diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index 7dd104a4a..3d2858b4f 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmXCodeObject.h,v $ Language: C++ - Date: $Date: 2007-07-27 14:55:24 $ - Version: $Revision: 1.18 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.18.2.1 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -147,6 +147,8 @@ public: std::vector const& GetObjectList() { return this->List;} void SetComment(const char* c) { this->Comment = c;} protected: + void PrintString(std::ostream& os) const; + cmTarget* Target; Type TypeValue; cmStdString Id; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 255a6925d..cd8974b1a 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmake.cxx,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:40 $ - Version: $Revision: 1.375.2.5 $ + Date: $Date: 2008-09-04 21:10:45 $ + Version: $Revision: 1.375.2.13 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -140,6 +140,7 @@ void cmNeedBackwardsCompatibility(const std::string& variable, cmake::cmake() { + this->Trace = false; this->SuppressDevWarnings = false; this->DoSuppressDevWarnings = false; this->DebugOutput = false; @@ -592,12 +593,10 @@ void cmake::SetArgs(const std::vector& args) else if(arg.find("-Wno-dev",0) == 0) { // skip for now - i++; } else if(arg.find("-Wdev",0) == 0) { // skip for now - i++; } else if(arg.find("--graphviz=",0) == 0) { @@ -620,6 +619,11 @@ void cmake::SetArgs(const std::vector& args) std::cout << "Running with debug output on.\n"; this->SetDebugOutputOn(true); } + else if(arg.find("--trace",0) == 0) + { + std::cout << "Running with trace output on.\n"; + this->SetTrace(true); + } else if(arg.find("-G",0) == 0) { std::string value = arg.substr(2); @@ -853,7 +857,7 @@ int cmake::AddCMakePaths() } std::string cpackCommand = cmSystemTools::GetFilenamePath(cMakeSelf) + "/cpack" + cmSystemTools::GetFilenameExtension(cMakeSelf); - if(cmSystemTools::FileExists(ctestCommand.c_str())) + if(cmSystemTools::FileExists(cpackCommand.c_str())) { this->CacheManager->AddCacheEntry ("CMAKE_CPACK_COMMAND", cpackCommand.c_str(), @@ -1183,7 +1187,7 @@ int cmake::ExecuteCMakeCommand(std::vector& args) << " s. (clock)" << "\n"; return 0; - } + } // Command to calculate the md5sum of a file else if (args[1] == "md5sum" && args.size() >= 3) @@ -1424,7 +1428,8 @@ int cmake::ExecuteCMakeCommand(std::vector& args) } } - return cmCallVisualStudioMacro::CallMacro(args[2], args[3], macroArgs); + return cmCallVisualStudioMacro::CallMacro(args[2], args[3], + macroArgs, true); } #endif @@ -1866,7 +1871,10 @@ int cmake::HandleDeleteCacheVariables(const char* var) cmSystemTools::ExpandListArgument(std::string(var), argsSplit); // erase the property to avoid infinite recursion this->SetProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_", ""); - + if(this->GetIsInTryCompile()) + { + return 0; + } cmCacheManager::CacheIterator ci = this->CacheManager->NewIterator(); std::vector saved; cmOStringStream warning; @@ -2093,22 +2101,30 @@ int cmake::ActualConfigure() // Before saving the cache // if the project did not define one of the entries below, add them now // so users can edit the values in the cache: - // LIBRARY_OUTPUT_PATH - // EXECUTABLE_OUTPUT_PATH - if(!this->CacheManager->GetCacheValue("LIBRARY_OUTPUT_PATH")) - { - this->CacheManager->AddCacheEntry - ("LIBRARY_OUTPUT_PATH", "", - "Single output directory for building all libraries.", - cmCacheManager::PATH); - } - if(!this->CacheManager->GetCacheValue("EXECUTABLE_OUTPUT_PATH")) + + // We used to always present LIBRARY_OUTPUT_PATH and + // EXECUTABLE_OUTPUT_PATH. They are now documented as old-style and + // should no longer be used. Therefore we present them only if the + // project requires compatibility with CMake 2.4. We detect this + // here by looking for the old CMAKE_BACKWARDS_COMPATABILITY + // variable created when CMP0001 is not set to NEW. + if(this->GetCacheManager()->GetCacheValue("CMAKE_BACKWARDS_COMPATIBILITY")) { - this->CacheManager->AddCacheEntry - ("EXECUTABLE_OUTPUT_PATH", "", - "Single output directory for building all executables.", - cmCacheManager::PATH); - } + if(!this->CacheManager->GetCacheValue("LIBRARY_OUTPUT_PATH")) + { + this->CacheManager->AddCacheEntry + ("LIBRARY_OUTPUT_PATH", "", + "Single output directory for building all libraries.", + cmCacheManager::PATH); + } + if(!this->CacheManager->GetCacheValue("EXECUTABLE_OUTPUT_PATH")) + { + this->CacheManager->AddCacheEntry + ("EXECUTABLE_OUTPUT_PATH", "", + "Single output directory for building all executables.", + cmCacheManager::PATH); + } + } if(!this->CacheManager->GetCacheValue("CMAKE_USE_RELATIVE_PATHS")) { this->CacheManager->AddCacheEntry @@ -3377,6 +3393,11 @@ void cmake::DefineProperties(cmake *cm) ("IN_TRY_COMPILE", cmProperty::GLOBAL, "Read-only property that is true during a try-compile configuration.", "True when building a project inside a TRY_COMPILE or TRY_RUN command."); + cm->DefineProperty + ("ENABLED_LANGUAGES", cmProperty::GLOBAL, + "Read-only property that contains the list of currently " + "enabled languages", + "Set to list of currently enabled lanauges."); // ================================================================ // define variables as well @@ -3507,7 +3528,7 @@ void cmake::ReportUndefinedPropertyAccesses(const char *filename) scopeStr = "unknown"; break; } - fprintf(progFile,"%s with scope %s\n",ap->first.c_str(),scopeStr); + fprintf(progFile, "%s with scope %s\n", ap->first.c_str(), scopeStr); } } fclose(progFile); @@ -3529,10 +3550,6 @@ void cmake::SetProperty(const char* prop, const char* value) { return; } - if (!value) - { - value = "NOTFOUND"; - } this->Properties.SetProperty(prop, value, cmProperty::GLOBAL); } @@ -3592,6 +3609,24 @@ const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope) this->SetProperty("IN_TRY_COMPILE", this->GetIsInTryCompile()? "1":"0"); } + else if ( propname == "ENABLED_LANGUAGES" ) + { + std::string lang; + if(this->GlobalGenerator) + { + std::vector enLangs; + this->GlobalGenerator->GetEnabledLanguages(enLangs); + const char* sep = ""; + for(std::vector::iterator i = enLangs.begin(); + i != enLangs.end(); ++i) + { + lang += sep; + sep = ";"; + lang += *i; + } + } + this->SetProperty("ENABLED_LANGUAGES", lang.c_str()); + } return this->Properties.GetPropertyValue(prop, scope, chain); } @@ -3742,7 +3777,7 @@ static bool cmakeCheckStampFile(const char* stampName) // Notify the user why CMake is re-running. It is safe to // just print to stdout here because this code is only reachable // through an undocumented flag used by the VS generator. - std::cout << "CMake is re-running due to explicit user request.\n"; + std::cout << "CMake is re-running because build system is out-of-date.\n"; return false; } @@ -3762,6 +3797,8 @@ static bool cmakeCheckStampFile(const char* stampName) { // The stamp dependencies file cannot be read. Just assume the // build system is really out of date. + std::cout << "CMake is re-running because " << stampName + << " dependency file is missing.\n"; return false; } @@ -3777,6 +3814,8 @@ static bool cmakeCheckStampFile(const char* stampName) { // The stamp depends file is older than this dependency. The // build system is really out of date. + std::cout << "CMake is re-running because " << stampName + << " is out-of-date.\n"; return false; } } @@ -3850,7 +3889,7 @@ int cmake::VisualStudioLink(std::vector& args, int type) i != args.end(); ++i) { // check for nmake temporary files - if((*i)[0] == '@') + if((*i)[0] == '@' && i->find("@CMakeFiles") != 0 ) { std::ifstream fin(i->substr(1).c_str()); std::string line; @@ -3865,25 +3904,40 @@ int cmake::VisualStudioLink(std::vector& args, int type) expandedArgs.push_back(*i); } } - // figure out if this is an incremental link or not and run the correct - // link function. + bool hasIncremental = false; + bool hasManifest = true; for(std::vector::iterator i = expandedArgs.begin(); i != expandedArgs.end(); ++i) { if(cmSystemTools::Strucmp(i->c_str(), "/INCREMENTAL:YES") == 0) { - if(verbose) - { - std::cout << "Visual Studio Incremental Link\n"; - } - return cmake::VisualStudioLinkIncremental(expandedArgs, type, verbose); + hasIncremental = true; + } + if(cmSystemTools::Strucmp(i->c_str(), "/MANIFEST:NO") == 0) + { + hasManifest = false; } } + if(hasIncremental && hasManifest) + { + if(verbose) + { + std::cout << "Visual Studio Incremental Link with embeded manifests\n"; + } + return cmake::VisualStudioLinkIncremental(expandedArgs, type, verbose); + } if(verbose) { - std::cout << "Visual Studio Non-Incremental Link\n"; + if(!hasIncremental) + { + std::cout << "Visual Studio Non-Incremental Link\n"; + } + else + { + std::cout << "Visual Studio Incremental Link without manifests\n"; + } } - return cmake::VisualStudioLinkNonIncremental(expandedArgs, type, verbose); + return cmake::VisualStudioLinkNonIncremental(expandedArgs, type, hasManifest, verbose); } int cmake::ParseVisualStudioLinkCommand(std::vector& args, @@ -4088,6 +4142,7 @@ int cmake::VisualStudioLinkIncremental(std::vector& args, int cmake::VisualStudioLinkNonIncremental(std::vector& args, int type, + bool hasManifest, bool verbose) { std::vector linkCommand; @@ -4101,6 +4156,10 @@ int cmake::VisualStudioLinkNonIncremental(std::vector& args, { return -1; } + if(!hasManifest) + { + return 0; + } std::vector mtCommand; mtCommand.push_back(cmSystemTools::FindProgram("mt.exe")); mtCommand.push_back("/nologo"); diff --git a/Source/cmake.h b/Source/cmake.h index 767fac1d8..a1550c450 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmake.h,v $ Language: C++ - Date: $Date: 2008-05-01 16:35:40 $ - Version: $Revision: 1.109.2.4 $ + Date: $Date: 2008-08-06 21:04:20 $ + Version: $Revision: 1.109.2.6 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -314,6 +314,9 @@ class cmake bool GetDebugOutput() { return this->DebugOutput; } void SetDebugOutputOn(bool b) { this->DebugOutput = b;} + // Do we want trace output during the cmake run. + bool GetTrace() { return this->Trace;} + void SetTrace(bool b) { this->Trace = b;} // Define a property void DefineProperty(const char *name, cmProperty::ScopeType scope, const char *ShortDescription, @@ -416,6 +419,7 @@ protected: bool verbose); static int VisualStudioLinkNonIncremental(std::vector& args, int type, + bool hasManifest, bool verbose); static int ParseVisualStudioLinkCommand(std::vector& args, std::vector& command, @@ -428,13 +432,16 @@ protected: ///! Find the full path to one of the cmake programs like ctest, cpack, etc. std::string FindCMakeProgram(const char* name) const; -private: +private: + cmake(const cmake&); // Not implemented. + void operator=(const cmake&); // Not implemented. ProgressCallbackType ProgressCallback; void* ProgressCallbackClientData; bool Verbose; bool InTryCompile; bool ScriptMode; bool DebugOutput; + bool Trace; std::string CMakeEditCommand; std::string CMakeCommand; std::string CXXEnvironment; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 91e3226df..4f1751eac 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -3,8 +3,8 @@ Program: CMake - Cross-Platform Makefile Generator Module: $RCSfile: cmakemain.cxx,v $ Language: C++ - Date: $Date: 2008-03-11 20:02:10 $ - Version: $Revision: 1.80 $ + Date: $Date: 2008-09-03 13:43:18 $ + Version: $Revision: 1.80.2.3 $ Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details. @@ -101,6 +101,9 @@ static const char * cmDocumentationOptions[][3] = {"--debug-output", "Put cmake in a debug mode.", "Print extra stuff during the cmake run like stack traces with " "message(send_error ) calls."}, + {"--trace", "Put cmake in trace mode.", + "Print a trace of all calls made and from where with " + "message(send_error ) calls."}, {"--help-command cmd [file]", "Print help for a single command and exit.", "Full documentation specific to the given command is displayed. " "If a file is specified, the documentation is written into and the output " @@ -144,6 +147,17 @@ static const char * cmDocumentationOptions[][3] = "If a file is specified, the documentation is written into and the output " "format is determined depending on the filename suffix. Supported are man " "page, HTML, DocBook and plain text."}, + {"--help-policy cmp [file]", + "Print help for a single policy and exit.", + "Full documentation specific to the given policy is displayed." + "If a file is specified, the documentation is written into and the output " + "format is determined depending on the filename suffix. Supported are man " + "page, HTML, DocBook and plain text."}, + {"--help-policies [file]", "Print help for all policies and exit.", + "Full documentation for all policies is displayed." + "If a file is specified, the documentation is written into and the output " + "format is determined depending on the filename suffix. Supported are man " + "page, HTML, DocBook and plain text."}, {"--help-property prop [file]", "Print help for a single property and exit.", "Full documentation specific to the given property is displayed." @@ -289,9 +303,6 @@ int main(int ac, char** av) int do_cmake(int ac, char** av) { -#ifdef CMAKE_BUILD_WITH_CMAKE - cmDocumentation doc; -#endif int nocwd = 0; if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 ) @@ -302,7 +313,8 @@ int do_cmake(int ac, char** av) } #ifdef CMAKE_BUILD_WITH_CMAKE - if(doc.CheckOptions(ac, av) || nocwd) + cmDocumentation doc; + if(doc.CheckOptions(ac, av, "-E") || nocwd) { // Construct and print requested documentation. cmake hcm; @@ -404,29 +416,29 @@ int do_cmake(int ac, char** av) { command = true; } - else if (strcmp(av[i], "-N") == 0) + else if (!command && strcmp(av[i], "-N") == 0) { view_only = true; } - else if (strcmp(av[i], "-L") == 0) + else if (!command && strcmp(av[i], "-L") == 0) { list_cached = true; } - else if (strcmp(av[i], "-LA") == 0) + else if (!command && strcmp(av[i], "-LA") == 0) { list_all_cached = true; } - else if (strcmp(av[i], "-LH") == 0) + else if (!command && strcmp(av[i], "-LH") == 0) { list_cached = true; list_help = true; } - else if (strcmp(av[i], "-LAH") == 0) + else if (!command && strcmp(av[i], "-LAH") == 0) { list_all_cached = true; list_help = true; } - else if (strncmp(av[i], "-P", strlen("-P")) == 0) + else if (!command && strncmp(av[i], "-P", strlen("-P")) == 0) { if ( i == ac -1 ) { @@ -445,7 +457,6 @@ int do_cmake(int ac, char** av) args.push_back(av[i]); } } - if(command) { int ret = cmake::ExecuteCMakeCommand(args); diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 44042d93c..1a11b66d4 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -122,6 +122,14 @@ ENDIF(KWSYS_STANDALONE) # The project name is that of the specified namespace. PROJECT(${KWSYS_NAMESPACE}) +# 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) + # Select library components. IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET(KWSYS_ENABLE_C 1) diff --git a/Source/kwsys/CPU.h.in b/Source/kwsys/CPU.h.in index cabc398d0..a7ac86313 100644 --- a/Source/kwsys/CPU.h.in +++ b/Source/kwsys/CPU.h.in @@ -32,6 +32,14 @@ #elif defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA) # define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE +/* Arm */ +#elif defined(__arm__) +# if !defined(__ARMEB__) +# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE +# else +# define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_BIG +# endif + /* Intel x86 */ #elif defined(__i386) || defined(__i386__) || defined(_M_IX86) # define @KWSYS_NAMESPACE@_CPU_ENDIAN_ID @KWSYS_NAMESPACE@_CPU_ENDIAN_ID_LITTLE diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx index 1aac58c2a..28fb208cb 100644 --- a/Source/kwsys/DynamicLoader.cxx +++ b/Source/kwsys/DynamicLoader.cxx @@ -305,7 +305,7 @@ const char* DynamicLoader::LibExtension() //---------------------------------------------------------------------------- const char* DynamicLoader::LastError() { - LPVOID lpMsgBuf; + LPVOID lpMsgBuf=NULL; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, @@ -317,6 +317,11 @@ const char* DynamicLoader::LastError() NULL ); + if(!lpMsgBuf) + { + return NULL; + } + static char* str = 0; delete [] str; str = strcpy(new char[strlen((char*)lpMsgBuf)+1], (char*)lpMsgBuf); diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx index e558908dd..bc9a902eb 100644 --- a/Source/kwsys/Glob.cxx +++ b/Source/kwsys/Glob.cxx @@ -63,6 +63,11 @@ Glob::Glob() this->Internals = new GlobInternals; this->Recurse = false; this->Relative = ""; + + this->RecurseThroughSymlinks = true; + // RecurseThroughSymlinks is true by default for backwards compatibility, + // not because it's a good idea... + this->FollowedSymlinkCount = 0; } //---------------------------------------------------------------------------- @@ -262,7 +267,15 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start, } if ( kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) { - this->RecurseDirectory(start+1, realname, dir_only); + bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str()); + if (!isSymLink || this->RecurseThroughSymlinks) + { + if (isSymLink) + { + ++this->FollowedSymlinkCount; + } + this->RecurseDirectory(start+1, realname, dir_only); + } } } } diff --git a/Source/kwsys/Glob.hxx.in b/Source/kwsys/Glob.hxx.in index 2a588afdb..dc4ad58db 100644 --- a/Source/kwsys/Glob.hxx.in +++ b/Source/kwsys/Glob.hxx.in @@ -57,6 +57,16 @@ public: void SetRecurse(bool i) { this->Recurse = i; } bool GetRecurse() { return this->Recurse; } + //! Set recurse through symlinks to true if recursion should traverse the + // linked-to directories + void RecurseThroughSymlinksOn() { this->SetRecurseThroughSymlinks(true); } + void RecurseThroughSymlinksOff() { this->SetRecurseThroughSymlinks(false); } + void SetRecurseThroughSymlinks(bool i) { this->RecurseThroughSymlinks = i; } + bool GetRecurseThroughSymlinks() { return this->RecurseThroughSymlinks; } + + //! Get the number of symlinks followed through recursion + unsigned int GetFollowedSymlinkCount() { return this->FollowedSymlinkCount; } + //! Set relative to true to only show relative path to files. void SetRelative(const char* dir); const char* GetRelative(); @@ -90,6 +100,8 @@ protected: GlobInternals* Internals; bool Recurse; kwsys_stl::string Relative; + bool RecurseThroughSymlinks; + unsigned int FollowedSymlinkCount; private: Glob(const Glob&); // Not implemented. diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c index 02e35020e..02b703e45 100644 --- a/Source/kwsys/ProcessUNIX.c +++ b/Source/kwsys/ProcessUNIX.c @@ -770,14 +770,14 @@ void kwsysProcess_Execute(kwsysProcess* cp) return; } -#if !KWSYSPE_USE_SELECT + /* Set to non-blocking in case select lies, or for the polling + implementation. */ if(!kwsysProcessSetNonBlocking(p[0])) { kwsysProcessCleanup(cp, 1); kwsysProcessCleanupDescriptor(&si.StdErr); return; } -#endif } /* Replace the stderr pipe with a file if requested. In this case @@ -830,14 +830,12 @@ void kwsysProcess_Execute(kwsysProcess* cp) failed = 1; } -#if !KWSYSPE_USE_SELECT - /* Set the output pipe of the last process to be non-blocking so - we can poll it. */ - if(i == cp->NumberOfCommands-1 && !kwsysProcessSetNonBlocking(readEnd)) + /* Set the output pipe of the last process to be non-blocking in + case select lies, or for the polling implementation. */ + if(i == (cp->NumberOfCommands-1) && !kwsysProcessSetNonBlocking(readEnd)) { failed = 1; } -#endif if(failed) { @@ -1057,6 +1055,11 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length, return 1; } } + else if(n < 0 && errno == EAGAIN) + { + /* No data are really ready. The select call lied. See the + "man select" page on Linux for cases when this occurs. */ + } else { /* We are done reading from this pipe. */ @@ -2807,7 +2810,7 @@ static char** kwsysProcessParseVerbatimCommand(const char* command) } } } - else if(isspace(*c)) + else if(isspace((unsigned char) *c)) { if(in_argument) { diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c index 7bd0e83b2..94de585a1 100644 --- a/Source/kwsys/ProcessWin32.c +++ b/Source/kwsys/ProcessWin32.c @@ -379,7 +379,7 @@ kwsysProcess* kwsysProcess_New(void) /* Construct the executable name from the process id and kwsysProcess instance. This should be unique. */ - sprintf(fwdName, KWSYS_NAMESPACE_STRING "pew9xfwd_%u_%p.exe", + sprintf(fwdName, KWSYS_NAMESPACE_STRING "pew9xfwd_%ld_%p.exe", GetCurrentProcessId(), cp); /* If we have a temp directory, use it. */ diff --git a/Source/kwsys/RegularExpression.cxx b/Source/kwsys/RegularExpression.cxx index b66bb73b2..45fd5429d 100644 --- a/Source/kwsys/RegularExpression.cxx +++ b/Source/kwsys/RegularExpression.cxx @@ -74,6 +74,43 @@ RegularExpression::RegularExpression (const RegularExpression& rxp) { this->regmlen = rxp.regmlen; // Copy remaining private data } +// operator= -- Copies the given regular expression. +RegularExpression& RegularExpression::operator= (const RegularExpression& rxp) +{ + if(this == &rxp) + { + return *this; + } + if ( !rxp.program ) + { + this->program = 0; + return *this; + } + int ind; + this->progsize = rxp.progsize; // Copy regular expression size + delete [] this->program; + this->program = new char[this->progsize]; // Allocate storage + for(ind=this->progsize; ind-- != 0;) // Copy regular expresion + this->program[ind] = rxp.program[ind]; + this->startp[0] = rxp.startp[0]; // Copy pointers into last + this->endp[0] = rxp.endp[0]; // Successful "find" operation + this->regmust = rxp.regmust; // Copy field + if (rxp.regmust != 0) { + char* dum = rxp.program; + ind = 0; + while (dum != rxp.regmust) { + ++dum; + ++ind; + } + this->regmust = this->program + ind; + } + this->regstart = rxp.regstart; // Copy starting index + this->reganch = rxp.reganch; // Copy remaining private data + this->regmlen = rxp.regmlen; // Copy remaining private data + + return *this; +} + // operator== -- Returns true if two regular expressions have the same // compiled program for pattern matching. bool RegularExpression::operator== (const RegularExpression& rxp) const { diff --git a/Source/kwsys/RegularExpression.hxx.in b/Source/kwsys/RegularExpression.hxx.in index 8febf6eda..8459e078e 100644 --- a/Source/kwsys/RegularExpression.hxx.in +++ b/Source/kwsys/RegularExpression.hxx.in @@ -233,6 +233,11 @@ public: */ inline kwsys_stl::string::size_type end() const; + /** + * Copy the given regular expression. + */ + RegularExpression& operator= (const RegularExpression& rxp); + /** * Returns true if two regular expressions have the same * compiled program for pattern matching. diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index dc3c955c6..5eb16a96e 100755 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -3,8 +3,8 @@ Program: BatchMake Module: $RCSfile: SystemInformation.cxx,v $ Language: C++ - Date: $Date: 2008-05-04 22:07:27 $ - Version: $Revision: 1.22.2.2 $ + Date: $Date: 2008-06-13 12:55:18 $ + Version: $Revision: 1.22.2.4 $ Copyright (c) 2005 Insight Consortium. All rights reserved. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. @@ -218,7 +218,7 @@ protected: unsigned int IsHyperThreadingSupported(); LongLong GetCyclesDifference(DELAY_FUNC, unsigned int); - // For Linux + // For Linux and Cygwin, /proc/cpuinfo formats are slightly different int RetreiveInformationFromCpuInfoFile(); kwsys_stl::string ExtractValueFromCpuInfoFile(kwsys_stl::string buffer, const char* word, size_t init=0); @@ -2158,41 +2158,60 @@ int SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() fileSize++; } fclose( fd ); - buffer.resize(fileSize-2); - - // Number of CPUs + // Number of logical CPUs (combination of multiple processors, multi-core + // and hyperthreading) size_t pos = buffer.find("processor\t"); while(pos != buffer.npos) { this->NumberOfLogicalCPU++; - this->NumberOfPhysicalCPU++; pos = buffer.find("processor\t",pos+1); } - // Count the number of physical ids that are the same - int currentId = -1; - kwsys_stl::string idc = this->ExtractValueFromCpuInfoFile(buffer,"physical id"); - +#ifdef __linux + // Find the largest physical id. + int maxId = -1; + kwsys_stl::string idc = + this->ExtractValueFromCpuInfoFile(buffer,"physical id"); while(this->CurrentPositionInFile != buffer.npos) { - int id = atoi(idc.c_str()); - if(id == currentId) + int id = atoi(idc.c_str()); + if(id > maxId) { - this->NumberOfPhysicalCPU--; + maxId=id; } - currentId = id; - idc = this->ExtractValueFromCpuInfoFile(buffer,"physical id",this->CurrentPositionInFile+1); + idc = this->ExtractValueFromCpuInfoFile(buffer,"physical id", + this->CurrentPositionInFile+1); + } + // Physical ids returned by Linux don't distinguish cores. + // We want to record the total number of cores in this->NumberOfPhysicalCPU + // (checking only the first proc) + kwsys_stl::string cores = + this->ExtractValueFromCpuInfoFile(buffer,"cpu cores"); + int numberOfCoresPerCPU=atoi(cores.c_str()); + this->NumberOfPhysicalCPU=numberOfCoresPerCPU*(maxId+1); + +#else // __CYGWIN__ + // does not have "physical id" entries, neither "cpu cores" + // this has to be fixed for hyper-threading. + kwsys_stl::string cpucount = + this->ExtractValueFromCpuInfoFile(buffer,"cpu count"); + this->NumberOfPhysicalCPU= + this->NumberOfLogicalCPU = atoi(cpucount.c_str()); +#endif + // gotta have one, and if this is 0 then we get a / by 0n + // beter to have a bad answer than a crash + if(this->NumberOfPhysicalCPU <= 0) + { + this->NumberOfPhysicalCPU = 1; } - - if(this->NumberOfPhysicalCPU>0) - { - this->NumberOfLogicalCPU /= this->NumberOfPhysicalCPU; - } + // LogicalProcessorsPerPhysical>1 => hyperthreading. + this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical= + this->NumberOfLogicalCPU/this->NumberOfPhysicalCPU; // CPU speed (checking only the first proc kwsys_stl::string CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer,"cpu MHz"); - this->CPUSpeedInMHz = (float)atof(CPUSpeed.c_str()); + this->CPUSpeedInMHz = static_cast(atof(CPUSpeed.c_str())); // Chip family this->ChipID.Family = atoi(this->ExtractValueFromCpuInfoFile(buffer,"cpu family").c_str()); @@ -2213,8 +2232,6 @@ int SystemInformationImplementation::RetreiveInformationFromCpuInfoFile() cacheSize = cacheSize.substr(0,pos); } this->Features.L1CacheSize = atoi(cacheSize.c_str()); - - return 1; } @@ -2998,7 +3015,7 @@ bool SystemInformationImplementation::QueryOSInformation() } } - sprintf (operatingSystem, "%s(Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); + sprintf (operatingSystem, "%s(Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); this->OSVersion = operatingSystem; } else @@ -3047,7 +3064,7 @@ bool SystemInformationImplementation::QueryOSInformation() if (osvi.dwMajorVersion <= 4) { // NB: NT 4.0 and earlier. - sprintf (operatingSystem, "version %d.%d %s (Build %d)", + sprintf (operatingSystem, "version %ld.%ld %s (Build %ld)", osvi.dwMajorVersion, osvi.dwMinorVersion, osvi.szCSDVersion, @@ -3078,7 +3095,7 @@ bool SystemInformationImplementation::QueryOSInformation() else { // Windows 2000 and everything else. - sprintf (operatingSystem,"%s(Build %d)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); + sprintf (operatingSystem,"%s(Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF); this->OSVersion = operatingSystem; } break; diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index c48a136d6..077dfcd5a 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -493,6 +493,30 @@ void SystemTools::ReplaceString(kwsys_stl::string& source, free(orig); } +#if defined(KEY_WOW64_32KEY) && defined(KEY_WOW64_64KEY) +# define KWSYS_ST_KEY_WOW64_32KEY KEY_WOW64_32KEY +# define KWSYS_ST_KEY_WOW64_64KEY KEY_WOW64_64KEY +#else +# define KWSYS_ST_KEY_WOW64_32KEY 0x0200 +# define KWSYS_ST_KEY_WOW64_64KEY 0x0100 +#endif + +#if defined(_WIN32) && !defined(__CYGWIN__) +static DWORD SystemToolsMakeRegistryMode(DWORD mode, + SystemTools::KeyWOW64 view) +{ + if(view == SystemTools::KeyWOW64_32) + { + return mode | KWSYS_ST_KEY_WOW64_32KEY; + } + else if(view == SystemTools::KeyWOW64_64) + { + return mode | KWSYS_ST_KEY_WOW64_64KEY; + } + return mode; +} +#endif + // Read a registry value. // Example : // HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath @@ -501,7 +525,8 @@ void SystemTools::ReplaceString(kwsys_stl::string& source, // => will return the data of the "Root" value of the key #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value) +bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, + KeyWOW64 view) { bool valueset = false; kwsys_stl::string primary = key; @@ -549,7 +574,7 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value) if(RegOpenKeyEx(primaryKey, second.c_str(), 0, - KEY_READ, + SystemToolsMakeRegistryMode(KEY_READ, view), &hKey) != ERROR_SUCCESS) { return false; @@ -589,7 +614,8 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value) return valueset; } #else -bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &) +bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &, + KeyWOW64) { return false; } @@ -604,7 +630,8 @@ bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &) // => will set the data of the "Root" value of the key #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::WriteRegistryValue(const char *key, const char *value) +bool SystemTools::WriteRegistryValue(const char *key, const char *value, + KeyWOW64 view) { kwsys_stl::string primary = key; kwsys_stl::string second; @@ -654,7 +681,7 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value) 0, "", REG_OPTION_NON_VOLATILE, - KEY_WRITE, + SystemToolsMakeRegistryMode(KEY_WRITE, view), NULL, &hKey, &dwDummy) != ERROR_SUCCESS) @@ -674,7 +701,7 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value) return false; } #else -bool SystemTools::WriteRegistryValue(const char *, const char *) +bool SystemTools::WriteRegistryValue(const char *, const char *, KeyWOW64) { return false; } @@ -688,7 +715,7 @@ bool SystemTools::WriteRegistryValue(const char *, const char *) // => will delete the data of the "Root" value of the key #if defined(_WIN32) && !defined(__CYGWIN__) -bool SystemTools::DeleteRegistryValue(const char *key) +bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) { kwsys_stl::string primary = key; kwsys_stl::string second; @@ -735,7 +762,7 @@ bool SystemTools::DeleteRegistryValue(const char *key) if(RegOpenKeyEx(primaryKey, second.c_str(), 0, - KEY_WRITE, + SystemToolsMakeRegistryMode(KEY_WRITE, view), &hKey) != ERROR_SUCCESS) { return false; @@ -752,7 +779,7 @@ bool SystemTools::DeleteRegistryValue(const char *key) return false; } #else -bool SystemTools::DeleteRegistryValue(const char *) +bool SystemTools::DeleteRegistryValue(const char *, KeyWOW64) { return false; } @@ -3125,9 +3152,9 @@ void SystemTools::SplitPath(const char* p, if(root.size() == 1) { #if defined(_WIN32) && !defined(__CYGWIN__) - if(const char* p = getenv("USERPROFILE")) + if(const char* userp = getenv("USERPROFILE")) { - homedir = p; + homedir = userp; } else #endif @@ -4279,10 +4306,10 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() } res += " "; - sprintf(buffer, "%d", osvi.dwMajorVersion); + sprintf(buffer, "%ld", osvi.dwMajorVersion); res += buffer; res += "."; - sprintf(buffer, "%d", osvi.dwMinorVersion); + sprintf(buffer, "%ld", osvi.dwMinorVersion); res += buffer; } @@ -4304,7 +4331,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() if (lRet == ERROR_SUCCESS) { res += " Service Pack 6a (Build "; - sprintf(buffer, "%d", osvi.dwBuildNumber & 0xFFFF); + sprintf(buffer, "%ld", osvi.dwBuildNumber & 0xFFFF); res += buffer; res += ")"; } @@ -4313,7 +4340,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() res += " "; res += osvi.szCSDVersion; res += " (Build "; - sprintf(buffer, "%d", osvi.dwBuildNumber & 0xFFFF); + sprintf(buffer, "%ld", osvi.dwBuildNumber & 0xFFFF); res += buffer; res += ")"; } @@ -4325,7 +4352,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() res += " "; res += osvi.szCSDVersion; res += " (Build "; - sprintf(buffer, "%d", osvi.dwBuildNumber & 0xFFFF); + sprintf(buffer, "%ld", osvi.dwBuildNumber & 0xFFFF); res += buffer; res += ")"; } diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 58e692b36..986708f2a 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -707,20 +707,30 @@ public: * ----------------------------------------------------------------- */ + /** + * Specify access to the 32-bit or 64-bit application view of + * registry values. The default is to match the currently running + * binary type. + */ + enum KeyWOW64 { KeyWOW64_Default, KeyWOW64_32, KeyWOW64_64 }; + /** * Read a registry value */ - static bool ReadRegistryValue(const char *key, kwsys_stl::string &value); + static bool ReadRegistryValue(const char *key, kwsys_stl::string &value, + KeyWOW64 view = KeyWOW64_Default); /** * Write a registry value */ - static bool WriteRegistryValue(const char *key, const char *value); + static bool WriteRegistryValue(const char *key, const char *value, + KeyWOW64 view = KeyWOW64_Default); /** * Delete a registry value */ - static bool DeleteRegistryValue(const char *key); + static bool DeleteRegistryValue(const char *key, + KeyWOW64 view = KeyWOW64_Default); /** ----------------------------------------------------------------- * Environment Manipulation Routines diff --git a/Source/kwsys/Terminal.c b/Source/kwsys/Terminal.c index 335d89452..77ea47f58 100644 --- a/Source/kwsys/Terminal.c +++ b/Source/kwsys/Terminal.c @@ -141,20 +141,38 @@ static const char* kwsysTerminalVT100Names[] = "con80x43", "con80x50", "con80x60", + "cons25", "console", "cygwin", + "dtterm", + "eterm-color", + "gnome", + "gnome-256color", "konsole", "konsole-256color", + "kterm", "linux", "msys", + "linux-c", + "mach-color", + "mlterm", + "putty", "rxvt", + "rxvt-cygwin", + "rxvt-cygwin-native", "rxvt-unicode", "screen", "screen-256color", + "screen-bce", + "screen-w", + "screen.linux", "vt100", "xterm", - "xterm-color", + "xterm-16color", "xterm-256color", + "xterm-88color", + "xterm-color", + "xterm-debian", 0 }; diff --git a/Templates/DLLHeader.dsptemplate b/Templates/DLLHeader.dsptemplate index 1058fd02c..dcc51eaef 100644 --- a/Templates/DLLHeader.dsptemplate +++ b/Templates/DLLHeader.dsptemplate @@ -57,9 +57,9 @@ RSC=rc.exe # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "OUTPUT_LIBNAME_EXPORTS" /FD /c +# ADD BASE CPP /nologo /D "WIN32" /D "_WINDOWS" /D "_USRDLL" OUTPUT_LIBNAME_EXPORTS /FD /c # ADD CPP /nologo /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c -# ADD CPP BUILD_INCLUDES EXTRA_DEFINES /D "OUTPUT_LIBNAME_EXPORTS" +# ADD CPP BUILD_INCLUDES EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS # ADD CPP CMAKE_CXX_FLAGS # ADD CPP CMAKE_CXX_FLAGS_RELEASE # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -89,9 +89,9 @@ CMAKE_CUSTOM_RULE_CODE_RELEASE # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OUTPUT_LIBNAME_EXPORTS" /FD /c +# ADD BASE CPP /nologo /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" OUTPUT_LIBNAME_EXPORTS /FD /c # ADD CPP /nologo /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_USRDLL" /FD /c -# ADD CPP BUILD_INCLUDES EXTRA_DEFINES /D "OUTPUT_LIBNAME_EXPORTS" +# ADD CPP BUILD_INCLUDES EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS # ADD CPP CMAKE_CXX_FLAGS # ADD CPP CMAKE_CXX_FLAGS_DEBUG # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -122,10 +122,10 @@ CMAKE_CUSTOM_RULE_CODE_DEBUG # PROP Intermediate_Dir "MinSizeRel" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c +# ADD BASE CPP /nologo /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c OUTPUT_LIBNAME_EXPORTS # SUBTRACT BASE CPP /YX # ADD CPP /nologo /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c -# ADD CPP BUILD_INCLUDES EXTRA_DEFINES /D "OUTPUT_LIBNAME_EXPORTS" +# ADD CPP BUILD_INCLUDES EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS # ADD CPP CMAKE_CXX_FLAGS # ADD CPP CMAKE_CXX_FLAGS_MINSIZEREL # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -155,9 +155,9 @@ CMAKE_CUSTOM_RULE_CODE_MINSIZEREL # PROP Intermediate_Dir "RelWithDebInfo" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /D "OUTPUT_LIBNAME_EXPORTS" /FD /c +# ADD BASE CPP /nologo /D "WIN32" /D "_WINDOWS" /D "_USRDLL" OUTPUT_LIBNAME_EXPORTS /FD /c # ADD CPP /nologo /D "WIN32" /D "_WINDOWS" /D "_USRDLL" /FD /c -# ADD CPP BUILD_INCLUDES EXTRA_DEFINES /D "OUTPUT_LIBNAME_EXPORTS" +# ADD CPP BUILD_INCLUDES EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS # ADD CPP CMAKE_CXX_FLAGS # ADD CPP CMAKE_CXX_FLAGS_RELWITHDEBINFO # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 diff --git a/Templates/EXEHeader.dsptemplate b/Templates/EXEHeader.dsptemplate index 5b6cfb71e..d05fb4b01 100644 --- a/Templates/EXEHeader.dsptemplate +++ b/Templates/EXEHeader.dsptemplate @@ -58,7 +58,7 @@ RSC=rc.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FD /c # ADD CPP /nologo /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FD /c -# ADD CPP BUILD_INCLUDES EXTRA_DEFINES /D "OUTPUT_LIBNAME_EXPORTS" +# ADD CPP BUILD_INCLUDES EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS # ADD CPP CMAKE_CXX_FLAGS # ADD CPP CMAKE_CXX_FLAGS_RELEASE # ADD BASE RSC /l 0x409 /d "NDEBUG" @@ -88,7 +88,7 @@ CMAKE_CUSTOM_RULE_CODE_RELEASE # PROP Target_Dir "" # ADD BASE CPP /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FD /GZ /c # ADD CPP /nologo /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /FD /GZ /c -# ADD CPP BUILD_INCLUDES EXTRA_DEFINES /D "OUTPUT_LIBNAME_EXPORTS" +# ADD CPP BUILD_INCLUDES EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS # ADD CPP CMAKE_CXX_FLAGS # ADD CPP CMAKE_CXX_FLAGS_DEBUG # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -119,7 +119,7 @@ CMAKE_CUSTOM_RULE_CODE_DEBUG # PROP Target_Dir "" # ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FD /c # ADD CPP /nologo /D "WIN32" BUILD_INCLUDES EXTRA_DEFINES /D "NDEBUG" /D "_CONSOLE" /FD /c -# ADD CPP BUILD_INCLUDES EXTRA_DEFINES /D "OUTPUT_LIBNAME_EXPORTS" +# ADD CPP BUILD_INCLUDES EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS # ADD CPP CMAKE_CXX_FLAGS # ADD CPP CMAKE_CXX_FLAGS_MINSIZEREL # ADD BASE RSC /l 0x409 /d "NDEBUG" @@ -149,7 +149,7 @@ CMAKE_CUSTOM_RULE_CODE_MINSIZEREL # PROP Target_Dir "" # ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FD /c # ADD CPP /nologo /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /FD /c -# ADD CPP BUILD_INCLUDES EXTRA_DEFINES /D "OUTPUT_LIBNAME_EXPORTS" +# ADD CPP BUILD_INCLUDES EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS # ADD CPP CMAKE_CXX_FLAGS # ADD CPP CMAKE_CXX_FLAGS_RELWITHDEBINFO # ADD BASE RSC /l 0x409 /d "NDEBUG" diff --git a/Templates/EXEWinHeader.dsptemplate b/Templates/EXEWinHeader.dsptemplate index 698811faf..77e1116ea 100644 --- a/Templates/EXEWinHeader.dsptemplate +++ b/Templates/EXEWinHeader.dsptemplate @@ -58,7 +58,7 @@ RSC=rc.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c # ADD CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP BUILD_INCLUDES EXTRA_DEFINES /D "OUTPUT_LIBNAME_EXPORTS" +# ADD CPP BUILD_INCLUDES EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS # ADD CPP CMAKE_CXX_FLAGS # ADD CPP CMAKE_CXX_FLAGS_RELEASE # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -90,7 +90,7 @@ CMAKE_CUSTOM_RULE_CODE_RELEASE # PROP Target_Dir "" # ADD BASE CPP /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c # ADD CPP /nologo /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /GZ /c -# ADD CPP BUILD_INCLUDES EXTRA_DEFINES /D "OUTPUT_LIBNAME_EXPORTS" +# ADD CPP BUILD_INCLUDES EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS # ADD CPP CMAKE_CXX_FLAGS # ADD CPP CMAKE_CXX_FLAGS_DEBUG # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -121,7 +121,7 @@ CMAKE_CUSTOM_RULE_CODE_DEBUG # PROP Target_Dir "" # ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c # ADD CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP BUILD_INCLUDES EXTRA_DEFINES /D "OUTPUT_LIBNAME_EXPORTS" +# ADD CPP BUILD_INCLUDES EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS # ADD CPP CMAKE_CXX_FLAGS # ADD CPP CMAKE_CXX_FLAGS_MINSIZEREL # ADD BASE RSC /l 0x409 /d "NDEBUG" @@ -151,7 +151,7 @@ CMAKE_CUSTOM_RULE_CODE_MINSIZEREL # PROP Target_Dir "" # ADD BASE CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c # ADD CPP /nologo /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP BUILD_INCLUDES EXTRA_DEFINES /D "OUTPUT_LIBNAME_EXPORTS" +# ADD CPP BUILD_INCLUDES EXTRA_DEFINES OUTPUT_LIBNAME_EXPORTS # ADD CPP CMAKE_CXX_FLAGS # ADD CPP CMAKE_CXX_FLAGS_RELWITHDEBINFO # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index 0d143ca17..d8f83605a 100755 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -12,6 +12,22 @@ project(BuildDepends) # project is built. set(CMAKE_SUPPRESS_REGENERATION 1) +# Xcode needs some help with the fancy dependencies in this test. +if("${CMAKE_GENERATOR}" MATCHES "Xcode") + set(HELP_XCODE 1) +endif("${CMAKE_GENERATOR}" MATCHES "Xcode") +function(help_xcode_depends) + if(HELP_XCODE) + file(GLOB_RECURSE MACRO_OBJS + ${BuildDepends_BINARY_DIR}/Project/zot_macro_*.o* + ) + if(MACRO_OBJS) + message("Helping Xcode by removing objects [${MACRO_OBJS}]") + file(REMOVE ${MACRO_OBJS}) + endif(MACRO_OBJS) + endif(HELP_XCODE) +endfunction(help_xcode_depends) + file(MAKE_DIRECTORY ${BuildDepends_BINARY_DIR}/Project) message("Creating Project/foo.cxx") write_file(${BuildDepends_BINARY_DIR}/Project/foo.cxx @@ -21,6 +37,12 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot.hxx.in "static const char* zot = \"zot\";\n") file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_custom.hxx.in "static const char* zot_custom = \"zot_custom\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx + "static const char* zot_macro_dir = \"zot_macro_dir\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx + "static const char* zot_macro_tgt = \"zot_macro_tgt\";\n") + +help_xcode_depends() message("Building project first time") try_compile(RESULT @@ -28,7 +50,7 @@ try_compile(RESULT ${BuildDepends_SOURCE_DIR}/Project testRebuild OUTPUT_VARIABLE OUTPUT) -if("${CMAKE_GENERATOR}" MATCHES "Xcode") +if(HELP_XCODE) try_compile(RESULT ${BuildDepends_BINARY_DIR}/Project ${BuildDepends_SOURCE_DIR}/Project @@ -39,7 +61,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Xcode") ${BuildDepends_SOURCE_DIR}/Project testRebuild OUTPUT_VARIABLE OUTPUT) -endif("${CMAKE_GENERATOR}" MATCHES "Xcode") +endif(HELP_XCODE) if(NOT RESULT) message(SEND_ERROR "Could not build test project: ${OUTPUT}") @@ -78,11 +100,12 @@ execute_process(COMMAND ${zot} OUTPUT_VARIABLE out RESULT_VARIABLE runResult) string(REGEX REPLACE "[\r\n]" " " out "${out}") message("Run result: ${runResult} Output: \"${out}\"") -if("${out}" STREQUAL "[zot] [zot_custom] ") +set(VALUE_UNCHANGED "[zot] [zot_custom] [zot_macro_dir] [zot_macro_tgt] ") +if("${out}" STREQUAL "${VALUE_UNCHANGED}") message("Worked!") -else("${out}" STREQUAL "[zot] [zot_custom] ") +else("${out}" STREQUAL "${VALUE_UNCHANGED}") message(SEND_ERROR "Project did not initially build properly: ${out}") -endif("${out}" STREQUAL "[zot] [zot_custom] ") +endif("${out}" STREQUAL "${VALUE_UNCHANGED}") message("Waiting 3 seconds...") # any additional argument will cause ${bar} to wait forever @@ -95,6 +118,12 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot.hxx.in "static const char* zot = \"zot changed\";\n") file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_custom.hxx.in "static const char* zot_custom = \"zot_custom changed\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx + "static const char* zot_macro_dir = \"zot_macro_dir changed\";\n") +file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx + "static const char* zot_macro_tgt = \"zot_macro_tgt changed\";\n") + +help_xcode_depends() message("Building project second time") try_compile(RESULT @@ -104,7 +133,7 @@ try_compile(RESULT OUTPUT_VARIABLE OUTPUT) # Xcode is in serious need of help here -if("${CMAKE_GENERATOR}" MATCHES "Xcode") +if(HELP_XCODE) try_compile(RESULT ${BuildDepends_BINARY_DIR}/Project ${BuildDepends_SOURCE_DIR}/Project @@ -115,7 +144,7 @@ if("${CMAKE_GENERATOR}" MATCHES "Xcode") ${BuildDepends_SOURCE_DIR}/Project testRebuild OUTPUT_VARIABLE OUTPUT) -endif("${CMAKE_GENERATOR}" MATCHES "Xcode") +endif(HELP_XCODE) if(NOT RESULT) message(SEND_ERROR "Could not build test project: ${OUTPUT}") @@ -147,8 +176,11 @@ execute_process(COMMAND ${zot} OUTPUT_VARIABLE out RESULT_VARIABLE runResult) string(REGEX REPLACE "[\r\n]" " " out "${out}") message("Run result: ${runResult} Output: \"${out}\"") -if("${out}" STREQUAL "[zot changed] [zot_custom changed] ") +set(VALUE_CHANGED + "[zot changed] [zot_custom changed] [zot_macro_dir changed] [zot_macro_tgt changed] " + ) +if("${out}" STREQUAL "${VALUE_CHANGED}") message("Worked!") -else("${out}" STREQUAL "[zot changed] [zot_custom changed] ") +else("${out}" STREQUAL "${VALUE_CHANGED}") message(SEND_ERROR "Project did not rebuild properly!") -endif("${out}" STREQUAL "[zot changed] [zot_custom changed] ") +endif("${out}" STREQUAL "${VALUE_CHANGED}") diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index 01bbf44ee..23aac4d25 100755 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 2.6) project(testRebuild) add_library(foo STATIC ${testRebuild_BINARY_DIR}/foo.cxx) @@ -57,5 +58,17 @@ add_custom_command( add_custom_target(zot_custom ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/zot_custom.hxx) -add_executable(zot zot.cxx ${CMAKE_CURRENT_BINARY_DIR}/zot.hxx) +add_executable(zot zot.cxx ${CMAKE_CURRENT_BINARY_DIR}/zot.hxx + zot_macro_dir.cxx zot_macro_tgt.cxx) add_dependencies(zot zot_custom) + +# Test the #include line macro transformation rule support. +set_property( + TARGET zot + PROPERTY IMPLICIT_DEPENDS_INCLUDE_TRANSFORM "ZOT_TGT(%)=" + ) + +set_property( + DIRECTORY + PROPERTY IMPLICIT_DEPENDS_INCLUDE_TRANSFORM "ZOT_DIR(%)=" + ) diff --git a/Tests/BuildDepends/Project/zot.cxx b/Tests/BuildDepends/Project/zot.cxx index 356b0787b..775fd3b43 100644 --- a/Tests/BuildDepends/Project/zot.cxx +++ b/Tests/BuildDepends/Project/zot.cxx @@ -2,9 +2,13 @@ #include #include +const char* zot_macro_dir_f(); +const char* zot_macro_tgt_f(); + int main() { - printf("[%s] [%s]\n", zot, zot_custom); + printf("[%s] [%s] [%s] [%s]\n", zot, zot_custom, + zot_macro_dir_f(), zot_macro_tgt_f()); fflush(stdout); return 0; } diff --git a/Tests/BuildDepends/Project/zot_macro_dir.cxx b/Tests/BuildDepends/Project/zot_macro_dir.cxx new file mode 100644 index 000000000..733a4b37f --- /dev/null +++ b/Tests/BuildDepends/Project/zot_macro_dir.cxx @@ -0,0 +1,7 @@ +#define ZOT_DIR(x) +#include ZOT_DIR(macro) + +const char* zot_macro_dir_f() +{ + return zot_macro_dir; +} diff --git a/Tests/BuildDepends/Project/zot_macro_tgt.cxx b/Tests/BuildDepends/Project/zot_macro_tgt.cxx new file mode 100644 index 000000000..182ee16fd --- /dev/null +++ b/Tests/BuildDepends/Project/zot_macro_tgt.cxx @@ -0,0 +1,7 @@ +#define ZOT_TGT(x) +#include ZOT_TGT(macro) + +const char* zot_macro_tgt_f() +{ + return zot_macro_tgt; +} diff --git a/Tests/BundleGeneratorTest/BundleIcon.icns b/Tests/BundleGeneratorTest/BundleIcon.icns new file mode 100644 index 0000000000000000000000000000000000000000..00c74e1c108b220d377957626ec02bc3c083449a GIT binary patch literal 33478 zcmeHOdvILkb^rD$De@z>LkCi)?&LA!e*~?sN$faS4un@Bp>&+4bvi8}?SctT7@W8S zNW81}Tb3nRy4KUSd zf~yOzW?sv@w*Hg#pM>x?o__UOV-ak6tK1ILDssC9eO9Q@?J^B3RN(du8u))O-|aDJ z!^(4uLBHWLL)KufTbOb)WaU5_Fx+Mc;%q4fls_b_ENSjEyRql61_M&(^qE!wO269) z^nh>}ra$Di2HkEmS9lG-6$-fr3k{bKc*TPvM8r%YW*AINm`qF=Ooyq1N4n>Hhhwh$}H z$nqBm7wGtk3L9g}jNv}}I zPcMYGn_jL^=n}nBLZSERH9Hi#O0Na{x|SIVU0WXteM0{W`_DgZ{#QRr*R=Z!`-FJC zPB{C0|Fc=pWoHU^zhPPfwZiQ)d?Bkwc>4|77}zAdKH3Ud)k5?K44kbsP$h&9o46pY zN=UN|H*F4VggDE<1&oWh0`hFR?XU(mK!F{TuI_Rua^yA?Wl&(pp9MuJ6uD4jVMQ1y zkqU>;%7&&`9^&)`u?Jm|Lh}c6pe&S*9A-D|LR$cBmVy01Fc<24A*^h}<1@RvgAl+V z4+a5TGA_dx?9PKpE=&SOj&K@2OIlzP=Ugb@o;+j=CobL+=y`q0hQioDTAb(r)+x)V z1e$4Ce&HA}Yv6nkDZW}e*d%nI4H;-$xL}Jlg9D9|t&#g!o)BnU@mQ#YPX!v+wF)%A zd>m&uFjSav-TOGmv{I@NXF*5-&Xvoj3U4-q6x=)`i!60$eI&O-YvQbo$k0L=8Cudt zgjOJ4!biak7~pNWDZG%uisFk?^krMlV7Gzb`Y6D(Q08G#%O#T>;X;71YC24blPz3` zuvu(5O&^#GgF@`vKx&-346(1uLQ=3Mx&}v=z9tB_=eS~^MfN}Iu>Jb3O(GO7%0~kj? zOg#i(9Q_FDD1dSFBdQ|+#?gu?+NOH~RmpfB5j1 zgmB&!ZQ=0KKJ`udo%$y3p160?@62!fb#T+dk?st$LA1Z3;l@Am(j|H;a6T(fCob7A!ERtF&rGAsmtr9b1sM zAx5hW%iRw3<(pMLzYXC<&ASBwP?UU0DzK-^bN}mRFSm zHNUzL3=-RQ;3HMI4rK2fQ3kY6{k&ZUK6KmBRbW#89Z?08sHh@Ua_ zN&)q4VI-o{)5R8-g2knPVUxDF7`Tx~IZzbn0~}Qn*rqaRh8)el?CRyh zfo(1gd@RG;vOLh@Q!kGKL5-`vUM?Nj<}$&>VcCTu2g_R67QhclWwBtJ3aA>3qFKm0 zvSNy`%>^SBj&8eP3N2@Mx2hND@L3au#HX;g!3Lys{HqqLlY6j+*Ki~`VbW6Bw5H^Gc6$3qn z5FcX3)q>M(gaRwjAkt=EdP*IiRGais|{Y zo4*OV$Ng}EmTVTIJ?0gZ$UJ6y`+$kThtFW5_R7J8%@b}P ztAm(s`I9qV{ZksOzkGy_4%z<>2v6v>SL!Qv|5

    |K`7%YYYA?QqKMQrOg{#4u<|D zQi?Z}KK`>{*TD}&TIjW%Pe1vS|9tjvJ9f_hrtjN#t>N zWac&f?+1GtTlVd~B4!hYVSL@U{>s&JFSH%l_KujtIEJzGfuH~3E zbY!kU30XJCAquz1P+m+?edVqa$L zT*Gd_TjN8ZJs|zJ`B=;lpBv zzo6m63WkS*;gzC5!Czqba=@bs3N`$BhKHDn0AhxJNyAqdj(dLxF@r zN?9^R8u=U}R~jxV85_9|$md&7k5Eu;*w|2 zE`o9m-^1__Qwc!K@W(Vf6jTLJFgz3tuM`^;{4s{FWAh3P-^K7@F~fIi_^^WEpk`=21?^bFDhqVLG(p9UQf`5X7T|B2Hs zyLLxsS6eXH`Tj>$+Al10a=ZX|uCt@vA9NjjvHxT3y^XzB8)=J|eErt@HnjpHz$P|{ zXPHE`k-Bu%!<$>4Indso6?DSSCe38OW>RU$fIYE0UmI`$V8BFRK!Mx!Y(6{Lq@u8& zdDzDn23;Lze)Um}4#Ym@U>_dVb1e2~1{H>f!(VJ8Fa=mJg$lzhb5OztwTi(WW>A6j zsXQnIQ*+qG94ZWoB_%^4z<^2Y&?HJ_I5Y2+DJf+?uwo*xVj`s!(ErHaco1nRW24QA z%nl|~Zlo+-x>xz@643+nb*zF{QJr+``fy@+6scs zj-wyeE0WuoWGPI&xnkyLJPVgRRn*uLY!3zl?Kwe5=Z6iND?Zz$MN69IiCNy%IXB#L zH?EO3$vIouGUF!AxX|z{x-lbTp{G#H@+^$v?N>)IYaGF>@o9U;48ONn%=JbS$7S(h zqoUo!v~iPLbmKx#rAW1TOVlRKxq&(3Gy9Ag-fA(!CQV?lVzzafE$+#LXUaej*@i9q z-uF<;`A^`R&BFfDs!tY%u$=75BmHRpOJ zW-pSJnpi*+>xd>+risCli3OP0bJ4`~T?SvXp?IN{qu6&vQ?qZG6-*6}2aw5Q(cECf zi7XfC95llqtP|11@-(q>$eEd80PR#XFWu9Wi!|cJP<_#~?Eb7&q*5X!&beq-cC%KD z-dv`VI9(9)s8&@HWk0*W?+>9uk;;s~=M|KGIDgbNZ~N_g1BK}OUwr;f!gy88=JXwT z>)k(JY2Eh5<=+(w?^9V%-h!hq(xr*CePvC~slMihgNND+h3AoVKUtPB<4tec+?79i zroEq8JkI^YJMTKsk*iVVV|!!?iBX1@a~tyN)XZu*;BzqM2iEfo8k9<_%Sit^`MB8CMh?|`X1H?Ib@_{ zcs&bme28WiHDEv@yw}&#$YKu{Bom)2Yp#ckd&GbtWvR<s7*K)47HLI%`ALbS&e9F1>zGNe7FK$xW<2Q;L-BJqVPf`pJEwU8j~=>$h- zYe;)GfiOowzM&!UWRjMA2?-%XY9T?|6A4{$cs{^1!vhIbqDH-_QR$weQ6XehEhJPm zh^QNm0###(y0vgP`!%GL<}*0F3x!WzjT=%}q#z?_jSSqhBxK~IA%z5K4;p|h){yp`0bz-P>;p?RWI$TV zkPu>hkOKw_3DTY}q)4$m!?(O@qF$yTPie?%xqOx}CZvpsse+OTSA?pD3X=dzHBmKE zNTEhOu2H45oIxREP%R`#HAvJEWVwb^V}ulLP(+VuNGZjdPZ@%cA+?Yo)$q_jkQEwI zjSf<{Q9*WwAu%Q{O2O@hKq1zk7%ErJfS6#ThlU4d;U31xj~*H-ud7n<&uMtmNad!r ze!jPgeL$yUk;Ws#mgUr~NKf|6kgj{xt+!=(ZGZOEkglf&Qfsem+G~w5Gdwns1#aPV zdN5$uHL}xHQ-d;~6K&%TYUt3g_0GQqggWODhXz;cKi`(NNu51r0$r>2(BRtsuXoM- z4B8Fi0R!e?cl{U|cK-OEWu|MQ^_4C1l{zq~Ju^*K4wBRDkL7K;`qjeFfIc z&zw2aN2oO4WCvYzA!yD`nlpxlo0s2H)q1j&?8B@v?^5L|)-Y$*FbDjxQ+;L3I-OYu zgUXml+k=8auC~$@X=SDI3~U;1Y{*TTF{3rA@FE>t@3}?_hHYf4^<wy|v5;c3>oD1eNI>R(jv5 z6GslU?|I^(uP*ec%Mt$(E6g06}zxM0nr6ly|3q%Qkz zzZw*d{=*$>e%bS?HTz_%rjx$#_VY9-q&$_CTfFgb&sk_Ah@^jEn;I3Ku4?Rg^JH32 zW7$1R=l%6&8Wr4+tb4l39B4{4Ys&H-cyOZ{6rOIl+~R5ag*_XIfkDHQzOy?fQ9@ND7w+wN>ulR|&}2H(HjttN$+x7V)ux5f6PP}_av@l|u}N#WVT zir!;uSIw{|h5q`66C~hC0gpFc-rjn$`{xhLc)USaT1fTqj+n=ITF97h(_%7y%eW{cGQ@qSp1B@k z!iJc!@hgnB1sFWk;`NsBFnG4*I`qwj9*sVLYf!SzwOohqpjks!HpGk`785$ejBbk+ z{F@qHDfD#mhK9%2%?Mu2ClE7ySWNH`Gd#pc?pc(Qt=Ye>;h{K&1yWxS7d3n#W_Vky*uSdbl_F0q<^3AI7+<|Y?jt7*N-D&Ze|4F|n&Ba)3dq;&U(xVN z5jAU2W=r{i$Z3P%!(w88LBo?6br3OgsMJD1l@K*|5PXH@XuBbD?jUe2BxnpH%)CMt zO_3&kP7|--qS455{MZZRO3tdnmIKJIfE^YSI>hH*?!)C{i&faq0KU8i1+Nr(^*x2K zpC|ZgE(0~+Kz#lp!9z?%V9z27p2VnuhP5OYD`g1YH-^+efsQ~?yffK zuWV->`dnaedf(oo#}2m3)=D=5Z93sK*37=sy?b^)Pfs}1BtmBg15SO7!i8p9?OB2Zy@PVc4Y<6*|o`Gh!BSnjh&`7uV+bfQQUqnARr zaroG=qa)8JDg(vVOzJ=HUGvo5(I*t*Q*6!c>+LLiYDv^n0fc_&ghJ$st$Do_PkwPu zYVLC%_SpG=>Z+iZzZv`#pb_GiQV+8^fm+;!jRG_xbKi zAL-G?uz`h60!MUyFLPeHqey&i*u#yep+%iXKDpSDxzJM)^@Kx#s}g9?C6I5qJHNMl z7B0>3!kTsr7|Zec1$8_GOF{&BEP+hG1>^WZjpg4c=LZej38gN2EuAyMp0iAB#>)0PY!eD<;ab90mZm@2# z8#+j)?*hAlg55yDS%QMxREnAG#2JBgG7M zp(6U49wE}nK}!!u51kCdmm=VV-_s%k_PRosgF;7bL+7E=b)Q9V7BLxIXsmhyGo%yJ zh*{wD=HegRmyY(%6P^G9kNx2KbjNQ2X}A49dvN94%U&0K7LWGhk#&!)_}WdEGhE9` z?56^6-{bnn8vB{R+poG_8|RV0Pvv*JS4`J;yC?TWtWS^nGy;(kaLr$^V7@C-lHBe2 zy_YWa&QGq-NN)=+g+c?%rY{2I|JuNGMZh(G*#LcS_0odKm?Up|e(%7w>GV(0r@!f{ z0PTNzDnMtSA}}2lptC<+{&n=p|8!J9r2phsKxFo(BLk7ypAP?#(VvbA80tT{6)-gW z$?hm*(C8<-0!H$myb2g8`^n6}NZC)O|B<4f%nBIIe{w2dwCpD<1EXa>S^h_h zezGcHEdPnGfU&Zlj0}vG{bcwbEBeW(fbsk%wgSe>exfrlUiK61f4t}?x&kKRKXDZ> zk?bcj0~5)9BK=P!`iZQ7iTY1W1xz&iiORr4v!5vc6ODeNDj*jB@vnebvY&_y#FG6) z_>U#}iKu{B{l~WgV$FWMGZ1U`6X$1?+y$$mWjPbT{Dtbob- zk52_mHv93)z+|%@FaMK`e!MDRD*mTl0aM9-JTfqq?8n3ZRH7e`3Ye<@sa3#Kvp>}g zOf~yc^*`0kj(6p|Dh2`X7tJb(BI5_>Yt;My!Yte uEG4`ChUP!n*WXb8LeOt1lleFFSBvyp(q#Tk->){4_Y28SJ^jCr!2bc)z`qdy literal 0 HcmV?d00001 diff --git a/Tests/BundleGeneratorTest/CMakeLists.txt b/Tests/BundleGeneratorTest/CMakeLists.txt new file mode 100644 index 000000000..e413b094d --- /dev/null +++ b/Tests/BundleGeneratorTest/CMakeLists.txt @@ -0,0 +1,24 @@ +PROJECT(BundleGeneratorTest) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +# Build a shared library and install it in lib/ +ADD_LIBRARY(Library SHARED Library.cxx) +INSTALL(TARGETS Library DESTINATION lib) + +# Build an executable and install it in bin/ +ADD_EXECUTABLE(Executable Executable.cxx) +TARGET_LINK_LIBRARIES(Executable Library) +INSTALL(TARGETS Executable DESTINATION bin) + +# Use the bundle-generator for packaging ... +SET(CPACK_GENERATOR "Bundle") +SET(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/BundleIcon.icns") +SET(CPACK_BUNDLE_NAME "BundleGeneratorTest") +SET(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist") +SET(CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/StartupCommand") +SET(CPACK_PACKAGE_DESCRIPTION "Project for testing OSX bundle generation") +SET(CPACK_PACKAGE_NAME "BundleGeneratorTest") +SET(CPACK_PACKAGE_VERSION "0.1") +INCLUDE(CPack) + diff --git a/Tests/BundleGeneratorTest/Executable.cxx b/Tests/BundleGeneratorTest/Executable.cxx new file mode 100644 index 000000000..8107f783a --- /dev/null +++ b/Tests/BundleGeneratorTest/Executable.cxx @@ -0,0 +1,8 @@ +extern void print_message(const char* const Message); + +int main(int argc, char* argv[]) +{ + print_message("Howdy, World!\n"); + return 0; +} + diff --git a/Tests/BundleGeneratorTest/Info.plist b/Tests/BundleGeneratorTest/Info.plist new file mode 100644 index 000000000..e5a7d0047 --- /dev/null +++ b/Tests/BundleGeneratorTest/Info.plist @@ -0,0 +1,14 @@ + + + + + CFBundleExecutable + BundleGeneratorTest + CFBundleIconFile + BundleGeneratorTest.icns + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + + diff --git a/Tests/BundleGeneratorTest/Library.cxx b/Tests/BundleGeneratorTest/Library.cxx new file mode 100644 index 000000000..1403c6824 --- /dev/null +++ b/Tests/BundleGeneratorTest/Library.cxx @@ -0,0 +1,7 @@ +#include + +void print_message(const char* const Message) +{ + std::cout << Message; +} + diff --git a/Tests/BundleGeneratorTest/StartupCommand b/Tests/BundleGeneratorTest/StartupCommand new file mode 100644 index 000000000..5bc5ad237 --- /dev/null +++ b/Tests/BundleGeneratorTest/StartupCommand @@ -0,0 +1,12 @@ +#!/bin/sh + +BUNDLE="`echo "$0" | sed -e 's/\/Contents\/MacOS\/.*//'`" +RESOURCES="$BUNDLE/Contents/Resources" + +echo "BUNDLE: $BUNDLE" +echo "RESOURCES: $RESOURCES" + +export DYLD_LIBRARY_PATH=$RESOURCES/lib + +exec "$RESOURCES/bin/Executable" + diff --git a/Tests/BundleTest/BundleLib.cxx b/Tests/BundleTest/BundleLib.cxx index 4f353fba8..bab745e46 100644 --- a/Tests/BundleTest/BundleLib.cxx +++ b/Tests/BundleTest/BundleLib.cxx @@ -3,6 +3,8 @@ #include #include +#include + int fileExists(char* filename) { #ifndef R_OK @@ -49,6 +51,11 @@ int findBundleFile(char* exec, const char* file) int foo(char *exec) { + // Call a "Carbon" function... + // + CFBundleRef br = CFBundleGetMainBundle(); + (void) br; + int res1 = findBundleFile(exec, "Resources/randomResourceFile.plist"); int res2 = findBundleFile(exec, "MacOS/SomeRandomFile.txt"); int res3 = findBundleFile(exec, "MacOS/ChangeLog.txt"); diff --git a/Tests/BundleTest/BundleSubDir/CMakeLists.txt b/Tests/BundleTest/BundleSubDir/CMakeLists.txt index 3f7a5f169..322b2a7d2 100644 --- a/Tests/BundleTest/BundleSubDir/CMakeLists.txt +++ b/Tests/BundleTest/BundleSubDir/CMakeLists.txt @@ -12,7 +12,7 @@ SET_SOURCE_FILES_PROPERTIES( SET_SOURCE_FILES_PROPERTIES( "${BundleTest_SOURCE_DIR}/SomeRandomFile.txt" - "${CMake_SOURCE_DIR}/ChangeLog.txt" + "${BundleTest_SOURCE_DIR}/../../ChangeLog.txt" PROPERTIES MACOSX_PACKAGE_LOCATION MacOS ) @@ -21,11 +21,11 @@ ADD_EXECUTABLE(SecondBundle MACOSX_BUNDLE "${BundleTest_SOURCE_DIR}/BundleTest.cxx" "${BundleTest_SOURCE_DIR}/SomeRandomFile.txt" - "${CMake_SOURCE_DIR}/ChangeLog.txt" + "${BundleTest_SOURCE_DIR}/../../ChangeLog.txt" "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist" ) TARGET_LINK_LIBRARIES(SecondBundle BundleTestLib) - + # Test bundle installation. INSTALL(TARGETS SecondBundle DESTINATION Applications) diff --git a/Tests/BundleTest/BundleTest.cxx b/Tests/BundleTest/BundleTest.cxx index 1e508ac09..29d17dbbe 100644 --- a/Tests/BundleTest/BundleTest.cxx +++ b/Tests/BundleTest/BundleTest.cxx @@ -1,9 +1,20 @@ #include +#include + extern int foo(char* exec); 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 + // verify that the chaining mechanism works with "-framework blah" style + // link dependencies. + // + CFBundleRef br = CFBundleGetMainBundle(); + (void) br; + return foo(argv[0]); } diff --git a/Tests/BundleTest/CMakeLists.txt b/Tests/BundleTest/CMakeLists.txt index 3f95afb51..5ccf2bf85 100644 --- a/Tests/BundleTest/CMakeLists.txt +++ b/Tests/BundleTest/CMakeLists.txt @@ -17,24 +17,35 @@ SET_SOURCE_FILES_PROPERTIES( SET_SOURCE_FILES_PROPERTIES( SomeRandomFile.txt - "${CMake_SOURCE_DIR}/ChangeLog.txt" + "${BundleTest_SOURCE_DIR}/../../ChangeLog.txt" PROPERTIES MACOSX_PACKAGE_LOCATION MacOS ) SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}/foobar") -# Test building a bundle linking to a shared library. +# 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 +# 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") + ADD_EXECUTABLE(BundleTest MACOSX_BUNDLE BundleTest.cxx SomeRandomFile.txt - "${CMake_SOURCE_DIR}/ChangeLog.txt" + "${BundleTest_SOURCE_DIR}/../../ChangeLog.txt" "${CMAKE_CURRENT_BINARY_DIR}/randomResourceFile.plist" ) - TARGET_LINK_LIBRARIES(BundleTest BundleTestLib) +# +# DO NOT: TARGET_LINK_LIBRARIES(BundleTest "-framework Carbon") +# (see above comments about Carbon) +# # Test bundle installation. #INSTALL(TARGETS BundleTestLib DESTINATION Applications/BundleTestExe.app/Contents/Plugins) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 0af70f7b1..f2ff228fb 100755 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -19,7 +19,7 @@ IF(BUILD_TESTING) OPTION(CMAKE_RUN_LONG_TESTS "Should the long tests be run (such as Bootstrap)." ON) MARK_AS_ADVANCED(CMAKE_RUN_LONG_TESTS) - + IF (CMAKE_RUN_LONG_TESTS) OPTION(CTEST_TEST_CTEST "Should the tests that run a full sub ctest process be run?" @@ -27,6 +27,34 @@ IF(BUILD_TESTING) MARK_AS_ADVANCED(CTEST_TEST_CTEST) ENDIF (CMAKE_RUN_LONG_TESTS) + # Should CPack tests be run? By default, yes, but... + # + # Disable packaging test on Apple 10.3 and below. PackageMaker starts + # DiskManagementTool as root and disowns it + # (http://lists.apple.com/archives/installer-dev/2005/Jul/msg00005.html). + # It is left holding open pipe handles and preventing ProcessUNIX from + # detecting end-of-data even after its immediate child exits. Then + # the test hangs until it times out and is killed. This is a + # well-known bug in kwsys process execution that I would love to get + # time to fix. + # + OPTION(CTEST_TEST_CPACK + "Should the tests that use '--build-target package' be run?" + ON) + MARK_AS_ADVANCED(CTEST_TEST_CPACK) + IF(APPLE AND CTEST_TEST_CPACK) + EXECUTE_PROCESS( + COMMAND sw_vers -productVersion + OUTPUT_VARIABLE OSX_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + IF(OSX_VERSION MATCHES "^10\\.[0123]" OR OSX_VERSION MATCHES "ProductVersion:\t10\\.[0123]") + MESSAGE(STATUS "Forcing CTEST_TEST_CPACK=OFF on OSX < 10.4") + MESSAGE(STATUS "OSX_VERSION='${OSX_VERSION}'") + SET(CTEST_TEST_CPACK OFF) + ENDIF(OSX_VERSION MATCHES "^10\\.[0123]" OR OSX_VERSION MATCHES "ProductVersion:\t10\\.[0123]") + ENDIF(APPLE AND CTEST_TEST_CPACK) + # Use 1500 or CTEST_TEST_TIMEOUT for long test timeout value, # whichever is greater. SET(CMAKE_LONG_TEST_TIMEOUT 1500) @@ -40,6 +68,7 @@ IF(BUILD_TESTING) # add a bunch of standard build-and-test style tests ADD_TEST_MACRO(CommandLineTest CommandLineTest) ADD_TEST_MACRO(FindPackageTest FindPackageTest) + ADD_TEST_MACRO(FindModulesExecuteAll FindModulesExecuteAll) ADD_TEST_MACRO(StringFileTest StringFileTest) ADD_TEST_MACRO(TryCompile TryCompile) ADD_TEST_MACRO(TarTest TarTest) @@ -258,6 +287,41 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel "-DSTAGE2:BOOL=1" --test-command ${SimpleInstallInstallDir}/MyTest/bin/SimpleInstExeS2) + # By default, run the CPackComponents test if the CTEST_TEST_CPACK + # option is ON: + # + set(CTEST_RUN_CPackComponents ${CTEST_TEST_CPACK}) + + # But on Windows, only run the CPackComponents test if the NSIS + # installer builder is available: + # + if(WIN32) + find_program(NSIS_MAKENSIS_EXECUTABLE NAMES makensis + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS] + DOC "makensis.exe location" + ) + if(NSIS_MAKENSIS_EXECUTABLE) + set(CTEST_RUN_CPackComponents ON) + else(NSIS_MAKENSIS_EXECUTABLE) + set(CTEST_RUN_CPackComponents OFF) + endif(NSIS_MAKENSIS_EXECUTABLE) + endif(WIN32) + + IF(CTEST_RUN_CPackComponents) + ADD_TEST(CPackComponents ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CPackComponents" + "${CMake_BINARY_DIR}/Tests/CPackComponents" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project CPackComponents + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + --build-target package + --test-command ${CMAKE_CMAKE_COMMAND} + "-DCPackComponents_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackComponents" + -P "${CMake_SOURCE_DIR}/Tests/CPackComponents/VerifyResult.cmake") + ENDIF(CTEST_RUN_CPackComponents) + ADD_TEST(X11 ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/X11" @@ -641,6 +705,20 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=CVS -P ${CMake_SOURCE_DIR}/Utilities/Rel ADD_TEST_MACRO(ObjC++ ObjC++) ENDIF (APPLE AND CMAKE_COMPILER_IS_GNUCXX) + IF(APPLE AND CTEST_TEST_CPACK) + ADD_TEST(BundleGeneratorTest ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/BundleGeneratorTest" + "${CMake_BINARY_DIR}/Tests/BundleGeneratorTest" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-project BundleGeneratorTest + --build-target package + --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${CMake_BINARY_DIR}/Tests/BundleGeneratorTest/InstallDirectory" + ) + ENDIF(APPLE AND CTEST_TEST_CPACK) + IF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS) CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestTest/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTest/test.cmake" @ONLY ESCAPE_QUOTES) diff --git a/Tests/CMakeTests/A/include/cmake_i_do_not_exist_in_the_system.h b/Tests/CMakeTests/A/include/cmake_i_do_not_exist_in_the_system.h new file mode 100644 index 000000000..2392aee71 --- /dev/null +++ b/Tests/CMakeTests/A/include/cmake_i_do_not_exist_in_the_system.h @@ -0,0 +1 @@ +/* empty header file */ diff --git a/Tests/CMakeTests/FindBaseTest.cmake.in b/Tests/CMakeTests/FindBaseTest.cmake.in index 703084711..02f700152 100644 --- a/Tests/CMakeTests/FindBaseTest.cmake.in +++ b/Tests/CMakeTests/FindBaseTest.cmake.in @@ -1,7 +1,12 @@ set(MY_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@") +# The find_* commands do path normalization so we should do so too +# before comparing results. +get_filename_component(MY_SOURCE_DIR "${MY_SOURCE_DIR}" ABSOLUTE) + set(_HEADER cmake_i_do_not_exist_in_the_system.h) set(_HEADER_FULL "${MY_SOURCE_DIR}/include/${_HEADER}") +set(_HEADER_FULL_A "${MY_SOURCE_DIR}/A/include/${_HEADER}") # at first check that the header isn't found without special measures find_file(FOO_H_1 ${_HEADER}) @@ -9,6 +14,19 @@ if(FOO_H_1) message(FATAL_ERROR "${_HEADER} found: ${FOO_H_1}, it should not exist !") endif(FOO_H_1) +# The HINTS option should override the system but the PATHS option +# should not. +set(CMAKE_SYSTEM_PREFIX_PATH ${MY_SOURCE_DIR}) +find_file(TEST_H_1 ${_HEADER} HINTS ${MY_SOURCE_DIR}/A/include) +find_file(TEST_H_2 ${_HEADER} PATHS ${MY_SOURCE_DIR}/A/include) +if(NOT "${TEST_H_1}" STREQUAL "${_HEADER_FULL_A}") + message(FATAL_ERROR "Did not find \"${_HEADER_FULL_A}\"\ngot \"${TEST_H_1}\" instead!") +endif(NOT "${TEST_H_1}" STREQUAL "${_HEADER_FULL_A}") +if(NOT "${TEST_H_2}" STREQUAL "${_HEADER_FULL}") + message(FATAL_ERROR "Did not find \"${_HEADER_FULL}\"\ngot \"${TEST_H_2}\" instead!") +endif(NOT "${TEST_H_2}" STREQUAL "${_HEADER_FULL}") +set(CMAKE_SYSTEM_PREFIX_PATH) + # with this it still should not be found, since the include/ subdir is still missing set(CMAKE_INCLUDE_PATH "${MY_SOURCE_DIR}") find_file(FOO_H_2 ${_HEADER}) diff --git a/Tests/CMakeTests/ToolchainTest.cmake.in b/Tests/CMakeTests/ToolchainTest.cmake.in index 90c45d016..e4a2e4813 100644 --- a/Tests/CMakeTests/ToolchainTest.cmake.in +++ b/Tests/CMakeTests/ToolchainTest.cmake.in @@ -5,7 +5,6 @@ # which will complain that it can"t be used in script mode macro(MARK_AS_ADVANCED) endmacro(MARK_AS_ADVANCED) - # set this to a place where we are allowed to write set(CMAKE_PLATFORM_ROOT_BIN "${CMAKE_CURRENT_BINARY_DIR}") @@ -62,6 +61,9 @@ set(CMAKE_HOST_SYSTEM_PROCESSOR) set(CMAKE_TOOLCHAIN_FILE "${MY_SOURCE_DIR}/DummyToolchain.cmake") include(CMakeDetermineSystem) +# make cmake think we are cross compiling for test to work +set(CMAKE_CROSSCOMPILING TRUE) +set(CMAKE_C_COMPILER_ID "GNU") include(CMakeDetermineCCompiler) include(CMakeDetermineCXXCompiler) diff --git a/Tests/CPackComponents/CMakeLists.txt b/Tests/CPackComponents/CMakeLists.txt new file mode 100644 index 000000000..d34490af2 --- /dev/null +++ b/Tests/CPackComponents/CMakeLists.txt @@ -0,0 +1,72 @@ +# CPack Example: User-selectable Installation Components +# +# In this example, we have a simple library (mylib) with an example +# application (mylibapp). We create a binary installer that allows +# users to select which pieces will be installed: the example +# application, the library binaries, and/or the header file. +cmake_minimum_required(VERSION 2.6) +project(CPackComponents) + +# Create the mylib library +add_library(mylib mylib.cpp) + +# Create the mylibapp application +add_executable(mylibapp mylibapp.cpp) +target_link_libraries(mylibapp mylib) + +# Create installation targets. Note that we put each kind of file +# into a different component via COMPONENT. These components will +# be used to create the installation components. +install(TARGETS mylib + ARCHIVE + DESTINATION lib + COMPONENT libraries) +install(TARGETS mylibapp + RUNTIME + DESTINATION bin + COMPONENT applications) +install(FILES mylib.h + DESTINATION include + COMPONENT headers) + +# CPack boilerplate for this project +set(CPACK_PACKAGE_NAME "MyLib") +set(CPACK_PACKAGE_VENDOR "CMake.org") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MyLib - CPack Component Installation Example") +set(CPACK_PACKAGE_VERSION "1.0.0") +set(CPACK_PACKAGE_VERSION_MAJOR "1") +set(CPACK_PACKAGE_VERSION_MINOR "0") +set(CPACK_PACKAGE_VERSION_PATCH "0") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example") + +# Include CPack to introduce the appropriate targets +include(CPack) + +# Installation types +cpack_add_install_type(Full + DISPLAY_NAME "Everything") +cpack_add_install_type(Developer) + +# Component groups +cpack_add_component_group(Runtime) +cpack_add_component_group(Development + EXPANDED + DESCRIPTION "All of the tools you'll ever need to develop software") + +# Components +cpack_add_component(applications + DISPLAY_NAME "MyLib Application" + DESCRIPTION "An extremely useful application that makes use of MyLib" + GROUP Runtime + INSTALL_TYPES Full) +cpack_add_component(libraries + DISPLAY_NAME "Libraries" + DESCRIPTION "Static libraries used to build programs with MyLib" + GROUP Development + INSTALL_TYPES Developer Full) +cpack_add_component(headers + DISPLAY_NAME "C++ Headers" + DESCRIPTION "C/C++ header files for use with MyLib" + GROUP Development + DEPENDS libraries + INSTALL_TYPES Developer Full) diff --git a/Tests/CPackComponents/VerifyResult.cmake b/Tests/CPackComponents/VerifyResult.cmake new file mode 100644 index 000000000..850ec0022 --- /dev/null +++ b/Tests/CPackComponents/VerifyResult.cmake @@ -0,0 +1,48 @@ +message(STATUS "=============================================================================") +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +message(STATUS "") + +if(NOT CPackComponents_BINARY_DIR) + message(FATAL_ERROR "CPackComponents_BINARY_DIR not set") +endif(NOT CPackComponents_BINARY_DIR) + +set(expected_file_mask "") + +if(WIN32) + # Only expect the *.exe installer if it looks like NSIS is + # installed on this machine: + # + find_program(NSIS_MAKENSIS_EXECUTABLE NAMES makensis + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS] + DOC "makensis.exe location" + ) + if(NSIS_MAKENSIS_EXECUTABLE) + set(expected_file_mask "${CPackComponents_BINARY_DIR}/MyLib-*.exe") + endif(NSIS_MAKENSIS_EXECUTABLE) +endif(WIN32) + +if(APPLE) + # Always expect the *.dmg installer - PackageMaker should always + # be installed on a development Mac: + # + set(expected_file_mask "${CPackComponents_BINARY_DIR}/MyLib-*.dmg") +endif(APPLE) + +if(expected_file_mask) + set(expected_count 1) + file(GLOB expected_file "${expected_file_mask}") + + message(STATUS "expected_count='${expected_count}'") + message(STATUS "expected_file='${expected_file}'") + message(STATUS "expected_file_mask='${expected_file_mask}'") + + if(NOT expected_file) + message(FATAL_ERROR "error: expected_file does not exist: CPackComponents test fails.") + endif(NOT expected_file) + + list(LENGTH expected_file actual_count) + message(STATUS "actual_count='${actual_count}'") + if(NOT actual_count EQUAL expected_count) + message(FATAL_ERROR "error: expected_count does not match actual_count: CPackComponents test fails.") + endif(NOT actual_count EQUAL expected_count) +endif(expected_file_mask) diff --git a/Tests/CPackComponents/mylib.cpp b/Tests/CPackComponents/mylib.cpp new file mode 100644 index 000000000..8ddac198c --- /dev/null +++ b/Tests/CPackComponents/mylib.cpp @@ -0,0 +1,7 @@ +#include "mylib.h" +#include "stdio.h" + +void mylib_function() +{ + printf("This is mylib"); +} diff --git a/Tests/CPackComponents/mylib.h b/Tests/CPackComponents/mylib.h new file mode 100644 index 000000000..5d0a822db --- /dev/null +++ b/Tests/CPackComponents/mylib.h @@ -0,0 +1 @@ +void mylib_function(); diff --git a/Tests/CPackComponents/mylibapp.cpp b/Tests/CPackComponents/mylibapp.cpp new file mode 100644 index 000000000..a438ac77f --- /dev/null +++ b/Tests/CPackComponents/mylibapp.cpp @@ -0,0 +1,6 @@ +#include "mylib.h" + +int main() +{ + mylib_function(); +} diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index 1814528cd..d77e89602 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -7,6 +7,11 @@ PROJECT (Complex) # Try setting a new policy. The IF test is for coverage. IF(POLICY CMP0003) CMAKE_POLICY(SET CMP0003 NEW) + + CMAKE_POLICY(GET CMP0003 P3) + IF(NOT "${P3}" STREQUAL "NEW") + MESSAGE(FATAL_ERROR "CMAKE_POLICY(GET) did not report NEW!") + ENDIF(NOT "${P3}" STREQUAL "NEW") ENDIF(POLICY CMP0003) # Choose whether to test CMakeLib. diff --git a/Tests/Complex/Executable/CMakeLists.txt b/Tests/Complex/Executable/CMakeLists.txt index 1c406b90e..9f64cbb15 100644 --- a/Tests/Complex/Executable/CMakeLists.txt +++ b/Tests/Complex/Executable/CMakeLists.txt @@ -16,6 +16,23 @@ IF(COMPLEX_TEST_CMAKELIB) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmtar) ENDIF(COMPLEX_TEST_CMAKELIB) +# Create an imported target for if(TARGET) test below. +ADD_LIBRARY(ExeImportedTarget UNKNOWN IMPORTED) + +# Test if(TARGET) command. +IF(NOT TARGET CMakeTestLibrary) + MESSAGE(FATAL_ERROR "IF(NOT TARGET CMakeTestLibrary) returned true!") +ENDIF(NOT TARGET CMakeTestLibrary) +IF(NOT TARGET ExeImportedTarget) + MESSAGE(FATAL_ERROR "IF(NOT TARGET ExeImportedTarget) returned true!") +ENDIF(NOT TARGET ExeImportedTarget) +IF(TARGET LibImportedTarget) + MESSAGE(FATAL_ERROR "IF(TARGET LibImportedTarget) returned true!") +ENDIF(TARGET LibImportedTarget) +IF(TARGET NotATarget) + MESSAGE(FATAL_ERROR "IF(TARGET NotATarget) returned true!") +ENDIF(TARGET NotATarget) + # Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) LINK_LIBRARIES(${COMPLEX_LIBS}) diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt index 0fae1ec1e..4f2e5a4ae 100644 --- a/Tests/Complex/Library/CMakeLists.txt +++ b/Tests/Complex/Library/CMakeLists.txt @@ -114,6 +114,10 @@ INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h) # Test creating a library that is not built by default. ADD_LIBRARY(notInAllLib EXCLUDE_FROM_ALL notInAllLib.cxx) +# Create an imported target for if(TARGET) test in Executable dir. +# That test should not see this target. +ADD_LIBRARY(LibImportedTarget UNKNOWN IMPORTED) + # Test generation of preprocessed sources. IF("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) IF(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE) diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt index 1814528cd..d77e89602 100644 --- a/Tests/ComplexOneConfig/CMakeLists.txt +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -7,6 +7,11 @@ PROJECT (Complex) # Try setting a new policy. The IF test is for coverage. IF(POLICY CMP0003) CMAKE_POLICY(SET CMP0003 NEW) + + CMAKE_POLICY(GET CMP0003 P3) + IF(NOT "${P3}" STREQUAL "NEW") + MESSAGE(FATAL_ERROR "CMAKE_POLICY(GET) did not report NEW!") + ENDIF(NOT "${P3}" STREQUAL "NEW") ENDIF(POLICY CMP0003) # Choose whether to test CMakeLib. diff --git a/Tests/ComplexOneConfig/Executable/CMakeLists.txt b/Tests/ComplexOneConfig/Executable/CMakeLists.txt index 1c406b90e..9f64cbb15 100644 --- a/Tests/ComplexOneConfig/Executable/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Executable/CMakeLists.txt @@ -16,6 +16,23 @@ IF(COMPLEX_TEST_CMAKELIB) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmtar) ENDIF(COMPLEX_TEST_CMAKELIB) +# Create an imported target for if(TARGET) test below. +ADD_LIBRARY(ExeImportedTarget UNKNOWN IMPORTED) + +# Test if(TARGET) command. +IF(NOT TARGET CMakeTestLibrary) + MESSAGE(FATAL_ERROR "IF(NOT TARGET CMakeTestLibrary) returned true!") +ENDIF(NOT TARGET CMakeTestLibrary) +IF(NOT TARGET ExeImportedTarget) + MESSAGE(FATAL_ERROR "IF(NOT TARGET ExeImportedTarget) returned true!") +ENDIF(NOT TARGET ExeImportedTarget) +IF(TARGET LibImportedTarget) + MESSAGE(FATAL_ERROR "IF(TARGET LibImportedTarget) returned true!") +ENDIF(TARGET LibImportedTarget) +IF(TARGET NotATarget) + MESSAGE(FATAL_ERROR "IF(TARGET NotATarget) returned true!") +ENDIF(TARGET NotATarget) + # Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) LINK_LIBRARIES(${COMPLEX_LIBS}) diff --git a/Tests/ComplexOneConfig/Library/CMakeLists.txt b/Tests/ComplexOneConfig/Library/CMakeLists.txt index 0fae1ec1e..4f2e5a4ae 100644 --- a/Tests/ComplexOneConfig/Library/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Library/CMakeLists.txt @@ -114,6 +114,10 @@ INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h) # Test creating a library that is not built by default. ADD_LIBRARY(notInAllLib EXCLUDE_FROM_ALL notInAllLib.cxx) +# Create an imported target for if(TARGET) test in Executable dir. +# That test should not see this target. +ADD_LIBRARY(LibImportedTarget UNKNOWN IMPORTED) + # Test generation of preprocessed sources. IF("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) IF(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE) diff --git a/Tests/ComplexRelativePaths/CMakeLists.txt b/Tests/ComplexRelativePaths/CMakeLists.txt index 1814528cd..d77e89602 100644 --- a/Tests/ComplexRelativePaths/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/CMakeLists.txt @@ -7,6 +7,11 @@ PROJECT (Complex) # Try setting a new policy. The IF test is for coverage. IF(POLICY CMP0003) CMAKE_POLICY(SET CMP0003 NEW) + + CMAKE_POLICY(GET CMP0003 P3) + IF(NOT "${P3}" STREQUAL "NEW") + MESSAGE(FATAL_ERROR "CMAKE_POLICY(GET) did not report NEW!") + ENDIF(NOT "${P3}" STREQUAL "NEW") ENDIF(POLICY CMP0003) # Choose whether to test CMakeLib. diff --git a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt index 1c406b90e..9f64cbb15 100644 --- a/Tests/ComplexRelativePaths/Executable/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/Executable/CMakeLists.txt @@ -16,6 +16,23 @@ IF(COMPLEX_TEST_CMAKELIB) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmtar) ENDIF(COMPLEX_TEST_CMAKELIB) +# Create an imported target for if(TARGET) test below. +ADD_LIBRARY(ExeImportedTarget UNKNOWN IMPORTED) + +# Test if(TARGET) command. +IF(NOT TARGET CMakeTestLibrary) + MESSAGE(FATAL_ERROR "IF(NOT TARGET CMakeTestLibrary) returned true!") +ENDIF(NOT TARGET CMakeTestLibrary) +IF(NOT TARGET ExeImportedTarget) + MESSAGE(FATAL_ERROR "IF(NOT TARGET ExeImportedTarget) returned true!") +ENDIF(NOT TARGET ExeImportedTarget) +IF(TARGET LibImportedTarget) + MESSAGE(FATAL_ERROR "IF(TARGET LibImportedTarget) returned true!") +ENDIF(TARGET LibImportedTarget) +IF(TARGET NotATarget) + MESSAGE(FATAL_ERROR "IF(TARGET NotATarget) returned true!") +ENDIF(TARGET NotATarget) + # Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) LINK_LIBRARIES(${COMPLEX_LIBS}) diff --git a/Tests/ComplexRelativePaths/Library/CMakeLists.txt b/Tests/ComplexRelativePaths/Library/CMakeLists.txt index 0fae1ec1e..4f2e5a4ae 100644 --- a/Tests/ComplexRelativePaths/Library/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/Library/CMakeLists.txt @@ -114,6 +114,10 @@ INSTALL_FILES(/tmp .cxx ${Complex_BINARY_DIR}/cmTestConfigure.h) # Test creating a library that is not built by default. ADD_LIBRARY(notInAllLib EXCLUDE_FROM_ALL notInAllLib.cxx) +# Create an imported target for if(TARGET) test in Executable dir. +# That test should not see this target. +ADD_LIBRARY(LibImportedTarget UNKNOWN IMPORTED) + # Test generation of preprocessed sources. IF("${CMAKE_GENERATOR}" MATCHES "Makefile" AND CMAKE_MAKE_PROGRAM) IF(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE) diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 7e9f29c04..b8410e183 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -42,6 +42,8 @@ ADD_CUSTOM_COMMAND( MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/wrapped.h COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/wrapper ${PROJECT_BINARY_DIR}/wrapped.c ${PROJECT_BINARY_DIR}/wrapped_help.c + ${CMAKE_CFG_INTDIR} # this argument tests passing of the configuration + VERBATIM # passing of configuration should work in this mode ) ################################################################ @@ -81,12 +83,22 @@ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/foo.h # Add the location of foo.h to the include path. INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}) +# Test generation of a file to the build tree without full path. As +# of CMake 2.6 custom command outputs specified by relative path go in +# the build tree. +ADD_CUSTOM_COMMAND( + OUTPUT doc1.txt + COMMAND ${CMAKE_COMMAND} -E echo "Example Document Target" > doc1.txt + DEPENDS doc1.tex + VERBATIM + ) + # Add a custom target to drive generation of doc1.h. 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 + DEPENDS ${PROJECT_BINARY_DIR}/doc1.h doc1.txt COMMENT "Running top-level TDocument commands" ) diff --git a/Tests/CustomCommand/wrapper.cxx b/Tests/CustomCommand/wrapper.cxx index 3ad0794a9..93cb079fe 100644 --- a/Tests/CustomCommand/wrapper.cxx +++ b/Tests/CustomCommand/wrapper.cxx @@ -1,4 +1,5 @@ #include +#include int main(int argc, char *argv[]) { @@ -14,5 +15,22 @@ int main(int argc, char *argv[]) fp = fopen(argv[2],"w"); fprintf(fp,"int wrapped_help() { return 5; }\n"); fclose(fp); +#ifdef CMAKE_INTDIR + /* The VS6 IDE passes a leading ".\\" in its variable expansion. */ +# if defined(_MSC_VER) && _MSC_VER == 1200 +# define CFG_DIR ".\\" CMAKE_INTDIR +# else +# define CFG_DIR CMAKE_INTDIR +# endif + const char* cfg = (argc >= 4)? argv[3] : ""; + if(strcmp(cfg, CFG_DIR) != 0) + { + fprintf(stderr, + "Did not receive expected configuration argument:\n" + " expected [" CFG_DIR "]\n" + " received [%s]\n", cfg); + return 1; + } +#endif return 0; } diff --git a/Tests/Dependency/CMakeLists.txt b/Tests/Dependency/CMakeLists.txt index d2c1c1a25..d700374b0 100644 --- a/Tests/Dependency/CMakeLists.txt +++ b/Tests/Dependency/CMakeLists.txt @@ -52,3 +52,4 @@ ADD_SUBDIRECTORY(Exec4) ADD_SUBDIRECTORY(Case1) ADD_SUBDIRECTORY(Case2) ADD_SUBDIRECTORY(Case3) +ADD_SUBDIRECTORY(Case4) diff --git a/Tests/Dependency/Case4/CMakeLists.txt b/Tests/Dependency/Case4/CMakeLists.txt new file mode 100644 index 000000000..87ab50722 --- /dev/null +++ b/Tests/Dependency/Case4/CMakeLists.txt @@ -0,0 +1,23 @@ +project(CASE4 C) + +IF(CMAKE_ANSI_CFLAGS) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}") +ENDIF(CMAKE_ANSI_CFLAGS) + +# This is not really a circular dependency. "case4Bar" refers to a +# third-party library that happens to match the executable name, which +# is okay when the executable is not a linkable target (ENABLE_EXPORTS +# is not set). This tests whether CMake avoids incorrectly reporting +# a circular dependency. In practice case4Foo may be a shared +# library, but we skip that here because we do not want it to actually +# have to find the third-party library. +add_library(case4Foo STATIC foo.c) +target_link_libraries(case4Foo case4Bar) + +# The executable avoids linking to a library with its own name, which +# has been a CMake-ism for a long time, so we will not get a link +# failure. An imported target or executable with an OUTPUT_NAME set +# may be used if the user really wants to link a third-party library +# into an executable of the same name. +add_executable(case4Bar bar.c) +target_link_libraries(case4Bar case4Foo) diff --git a/Tests/Dependency/Case4/bar.c b/Tests/Dependency/Case4/bar.c new file mode 100644 index 000000000..d0bb0c43c --- /dev/null +++ b/Tests/Dependency/Case4/bar.c @@ -0,0 +1,2 @@ +extern int foo(); +int main() { return foo(); } diff --git a/Tests/Dependency/Case4/foo.c b/Tests/Dependency/Case4/foo.c new file mode 100644 index 000000000..9fe07f82f --- /dev/null +++ b/Tests/Dependency/Case4/foo.c @@ -0,0 +1 @@ +int foo() { return 0; } diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 9f1bab3bf..595530795 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -35,6 +35,29 @@ set_property(TARGET testLib3 PROPERTY SOVERSION 3) add_library(testLib4 SHARED testLib4.c) set_property(TARGET testLib4 PROPERTY FRAMEWORK 1) +# Work-around: Visual Studio 6 does not support per-target object files. +set(VS6) +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6") + set(VS6 1) +endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6") + +# Test using the target_link_libraries command to set the +# LINK_INTERFACE_LIBRARIES* properties. We construct two libraries +# providing the same two symbols. In each library one of the symbols +# will work and the other one will fail to link. The import part of +# this test will try to use the symbol corresponding to the +# configuration in which it is built. If the proper library is not +# used via the link interface the import test will fail to link. +add_library(testLib4lib STATIC testLib4lib.c) +add_library(testLib4libdbg STATIC testLib4libopt.c testLib4libdbg${VS6}.c) +add_library(testLib4libopt STATIC testLib4libdbg.c testLib4libopt${VS6}.c) +set_property(TARGET testLib4libdbg PROPERTY COMPILE_DEFINITIONS LIB_DBG) +set_property(TARGET testLib4libopt PROPERTY COMPILE_DEFINITIONS LIB_OPT) +target_link_libraries(testLib4 + LINK_INTERFACE_LIBRARIES + testLib4lib debug testLib4libdbg optimized testLib4libopt + ) + add_executable(testExe3 testExe3.c) set_property(TARGET testExe3 PROPERTY MACOSX_BUNDLE 1) @@ -42,7 +65,7 @@ set_property(TARGET testExe3 PROPERTY MACOSX_BUNDLE 1) install( TARGETS testExe1 testLib1 testLib2 testExe2 testLib3 testLib4 testExe3 - testExe2lib + testExe2lib testLib4lib testLib4libdbg testLib4libopt EXPORT exp RUNTIME DESTINATION bin LIBRARY DESTINATION lib NAMELINK_SKIP @@ -67,6 +90,7 @@ export(TARGETS testExe1 testLib1 testLib2 testLib3 FILE ExportBuildTree.cmake ) export(TARGETS testExe2 testLib4 testExe3 testExe2lib + testLib4lib testLib4libdbg testLib4libopt NAMESPACE bld_ APPEND FILE ExportBuildTree.cmake ) diff --git a/Tests/ExportImport/Export/testLib4lib.c b/Tests/ExportImport/Export/testLib4lib.c new file mode 100644 index 000000000..bf3c11ec6 --- /dev/null +++ b/Tests/ExportImport/Export/testLib4lib.c @@ -0,0 +1,4 @@ +int testLib4lib(void) +{ + return 0; +} diff --git a/Tests/ExportImport/Export/testLib4libdbg.c b/Tests/ExportImport/Export/testLib4libdbg.c new file mode 100644 index 000000000..453f26282 --- /dev/null +++ b/Tests/ExportImport/Export/testLib4libdbg.c @@ -0,0 +1,14 @@ +#ifdef LIB_DBG +/* We are building in testLib4libdbg. Provide the correct symbol. */ +int testLib4libdbg(void) +{ + return 0; +} +#else +/* We are not building in testLib4libdbg. Poison the symbol. */ +extern int testLib4libdbg_noexist(void); +int testLib4libdbg(void) +{ + return testLib4libdbg_noexist(); +} +#endif diff --git a/Tests/ExportImport/Export/testLib4libdbg1.c b/Tests/ExportImport/Export/testLib4libdbg1.c new file mode 100644 index 000000000..cc56cf933 --- /dev/null +++ b/Tests/ExportImport/Export/testLib4libdbg1.c @@ -0,0 +1 @@ +#include "testLib4libdbg.c" diff --git a/Tests/ExportImport/Export/testLib4libopt.c b/Tests/ExportImport/Export/testLib4libopt.c new file mode 100644 index 000000000..605edd05b --- /dev/null +++ b/Tests/ExportImport/Export/testLib4libopt.c @@ -0,0 +1,14 @@ +#ifdef LIB_OPT +/* We are building in testLib4libopt. Provide the correct symbol. */ +int testLib4libopt(void) +{ + return 0; +} +#else +/* We are not building in testLib4libopt. Poison the symbol. */ +extern int testLib4libopt_noexist(void); +int testLib4libopt(void) +{ + return testLib4libopt_noexist(); +} +#endif diff --git a/Tests/ExportImport/Export/testLib4libopt1.c b/Tests/ExportImport/Export/testLib4libopt1.c new file mode 100644 index 000000000..d9b55879d --- /dev/null +++ b/Tests/ExportImport/Export/testLib4libopt1.c @@ -0,0 +1 @@ +#include "testLib4libopt.c" diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt index 5a946edab..1ac9d3a57 100644 --- a/Tests/ExportImport/Import/CMakeLists.txt +++ b/Tests/ExportImport/Import/CMakeLists.txt @@ -32,6 +32,7 @@ add_executable(imp_testExe1 # Try linking to a library imported from the install tree. target_link_libraries(imp_testExe1 exp_testLib2 exp_testLib3 exp_testLib4) +set_property(TARGET imp_testExe1 PROPERTY COMPILE_DEFINITIONS_DEBUG EXE_DBG) # Try building a plugin to an executable imported from the install tree. add_library(imp_mod1 MODULE imp_mod1.c) @@ -57,6 +58,7 @@ add_executable(imp_testExe1b # Try linking to a library imported from the build tree. target_link_libraries(imp_testExe1b bld_testLib2 bld_testLib3 bld_testLib4) +set_property(TARGET imp_testExe1b PROPERTY COMPILE_DEFINITIONS_DEBUG EXE_DBG) # Try building a plugin to an executable imported from the build tree. add_library(imp_mod1b MODULE imp_mod1.c) diff --git a/Tests/ExportImport/Import/imp_testExe1.c b/Tests/ExportImport/Import/imp_testExe1.c index 0fbb689ff..6424d3399 100644 --- a/Tests/ExportImport/Import/imp_testExe1.c +++ b/Tests/ExportImport/Import/imp_testExe1.c @@ -3,9 +3,19 @@ extern int generated_by_testExe3(); extern int testLib2(); extern int testLib3(); extern int testLib4(); +extern int testLib4lib(); + +/* Switch a symbol between debug and optimized builds to make sure the + proper library is found from the testLib4 link interface. */ +#ifdef EXE_DBG +# define testLib4libcfg testLib4libdbg +#else +# define testLib4libcfg testLib4libopt +#endif +extern testLib4libcfg(void); int main() { return (testLib2() + generated_by_testExe1() + testLib3() + testLib4() - + generated_by_testExe3()); + + generated_by_testExe3() + testLib4lib() + testLib4libcfg()); } diff --git a/Tests/FindModulesExecuteAll/CMakeLists.txt b/Tests/FindModulesExecuteAll/CMakeLists.txt new file mode 100644 index 000000000..725222d21 --- /dev/null +++ b/Tests/FindModulesExecuteAll/CMakeLists.txt @@ -0,0 +1,30 @@ +# This file includes all FindXXX.cmake modules, so they are all executed. +# As it is it doesn't test a lot. +# It makes sure that the modules don't contain basic syntax errors. +# It also makes sure that modules don't fail with an error if something +# wasn't found but REQUIRED was not given. +# +# I guess more things could be added, like checking whether variables are +# defined after running the modules (e.g. FOO_FOUND etc.). +project(FindModulesExecuteAll) +cmake_minimum_required(VERSION 2.6) + +file(GLOB all_modules "${CMAKE_CURRENT_SOURCE_DIR}/../../Modules/Find*cmake") + +foreach(module ${all_modules}) + message(STATUS "module: ${module}") + include("${module}") + + # get the "basename" of the package, so the existence of variables like + # FOO_FOUND could be tested later on, Alex + string(REGEX REPLACE ".+Find([^\\.]+)\\.cmake" "\\1" packageName "${module}") + string(TOUPPER "${packageName}" packageNameUpper) + +# disabled for now, since too many modules break: +# if(NOT DEFINED ${packageNameUpper}_FOUND) +# message(SEND_ERROR "${packageNameUpper}_FOUND not defined !") +# endif(NOT DEFINED ${packageNameUpper}_FOUND) + +endforeach(module ${all_modules}) + +add_executable(FindModulesExecuteAll main.c) diff --git a/Tests/FindModulesExecuteAll/main.c b/Tests/FindModulesExecuteAll/main.c new file mode 100644 index 000000000..c13815cea --- /dev/null +++ b/Tests/FindModulesExecuteAll/main.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/FindPackageTest/A/wibble-config.cmake b/Tests/FindPackageTest/A/wibble-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/A/wibble-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/B/wibble-config.cmake b/Tests/FindPackageTest/B/wibble-config.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/B/wibble-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index e19c7098a..1703fe7af 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -27,6 +27,7 @@ LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}) FIND_PACKAGE(VersionTestA 1) FIND_PACKAGE(VersionTestB 1.2) FIND_PACKAGE(VersionTestC 1.2.3) +FIND_PACKAGE(VersionTestD 1.2.3.4) #----------------------------------------------------------------------------- @@ -36,6 +37,7 @@ FIND_PACKAGE(VersionTestC 1.2.3) SET(PACKAGES foo Foo Bar TFramework Tframework TApp Tapp Special VersionedA VersionedB + wibbleA wibbleB ) FOREACH(p ${PACKAGES}) SET(${p}_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) @@ -58,6 +60,11 @@ FIND_PACKAGE(Special NAMES Suffix SuffixTest PATH_SUFFIXES test) FIND_PACKAGE(VersionedA 2 NAMES zot) FIND_PACKAGE(VersionedB 3.1 EXACT NAMES zot) +# HINTS should override the system but PATHS should not +LIST(INSERT CMAKE_SYSTEM_PREFIX_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/A") +FIND_PACKAGE(wibbleA NAMES wibble PATHS B) +FIND_PACKAGE(wibbleB NAMES wibble HINTS B) + # 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") @@ -73,6 +80,8 @@ SET(Tapp_EXPECTED "TApp.app/Contents/Resources/cmake/tapp-config.cmake") SET(VersionedA_EXPECTED "lib/zot-2.0/zot-config.cmake") SET(VersionedB_EXPECTED "lib/zot-3.1/zot-config.cmake") +SET(wibbleA_EXPECTED "A/wibble-config.cmake") +SET(wibbleB_EXPECTED "B/wibble-config.cmake") # Check the results. FOREACH(p ${PACKAGES}) @@ -136,3 +145,20 @@ IF(NOT "${Special_VERSION_MINOR}" STREQUAL "2") MESSAGE(SEND_ERROR "Package Special is minor version [${Special_VERSION_MINOR}], not [2]") ENDIF(NOT "${Special_VERSION_MINOR}" STREQUAL "2") + +# Test version number comparison. +IF(NOT "1.2.3.4" VERSION_LESS "1.2.3.5") + MESSAGE(SEND_ERROR "1.2.3.4 VERSION_LESS 1.2.3.5 is not true!") +ENDIF() +IF(NOT "1.2" VERSION_LESS "1.10") + MESSAGE(SEND_ERROR "1.2 VERSION_LESS 1.10 is not true!") +ENDIF() +IF(NOT "1.02" VERSION_GREATER "1.1") + MESSAGE(SEND_ERROR "1.02 VERSION_GREATER 1.1 is not true!") +ENDIF() +IF("1.2.3" VERSION_GREATER "1.2.3.4") + MESSAGE(SEND_ERROR "1.2.3 VERSION_GREATER 1.2.3.4 is not false!") +ENDIF() +IF(NOT "1.2" VERSION_EQUAL "1.2.0.0") + MESSAGE(SEND_ERROR "1.2 VERSION_EQUAL 1.2.0.0 is not true!") +ENDIF() diff --git a/Tests/FindPackageTest/FindVersionTestA.cmake b/Tests/FindPackageTest/FindVersionTestA.cmake index eedf37141..55c67e257 100644 --- a/Tests/FindPackageTest/FindVersionTestA.cmake +++ b/Tests/FindPackageTest/FindVersionTestA.cmake @@ -4,9 +4,15 @@ ENDIF(NOT "${VersionTestA_FIND_VERSION}" STREQUAL "1") IF(NOT "${VersionTestA_FIND_VERSION_MAJOR}" STREQUAL "1") MESSAGE(SEND_ERROR "VersionTestA_FIND_VERSION_MAJOR=${VersionTestA_FIND_VERSION_MAJOR} is not 1") ENDIF(NOT "${VersionTestA_FIND_VERSION_MAJOR}" STREQUAL "1") -IF(DEFINED VersionTestA_FIND_VERSION_MINOR) - MESSAGE(SEND_ERROR "VersionTestA_FIND_VERSION_MINOR should not be defined") -ENDIF(DEFINED VersionTestA_FIND_VERSION_MINOR) -IF(DEFINED VersionTestA_FIND_VERSION_PATCH) - MESSAGE(SEND_ERROR "VersionTestA_FIND_VERSION_PATCH should not be defined") -ENDIF(DEFINED VersionTestA_FIND_VERSION_PATCH) +IF(NOT "${VersionTestA_FIND_VERSION_MINOR}" STREQUAL "0") + MESSAGE(SEND_ERROR "VersionTestA_FIND_VERSION_MINOR=${VersionTestA_FIND_VERSION_MINOR} is not 0") +ENDIF(NOT "${VersionTestA_FIND_VERSION_MINOR}" STREQUAL "0") +IF(NOT "${VersionTestA_FIND_VERSION_PATCH}" STREQUAL "0") + MESSAGE(SEND_ERROR "VersionTestA_FIND_VERSION_PATCH=${VersionTestA_FIND_VERSION_PATCH} is not 0") +ENDIF(NOT "${VersionTestA_FIND_VERSION_PATCH}" STREQUAL "0") +IF(NOT "${VersionTestA_FIND_VERSION_TWEAK}" STREQUAL "0") + MESSAGE(SEND_ERROR "VersionTestA_FIND_VERSION_TWEAK=${VersionTestA_FIND_VERSION_TWEAK} is not 0") +ENDIF(NOT "${VersionTestA_FIND_VERSION_TWEAK}" STREQUAL "0") +IF(NOT "${VersionTestA_FIND_VERSION_COUNT}" STREQUAL "1") + MESSAGE(SEND_ERROR "VersionTestA_FIND_VERSION_COUNT=${VersionTestA_FIND_VERSION_COUNT} is not 1") +ENDIF(NOT "${VersionTestA_FIND_VERSION_COUNT}" STREQUAL "1") diff --git a/Tests/FindPackageTest/FindVersionTestB.cmake b/Tests/FindPackageTest/FindVersionTestB.cmake index 787d2006d..03173c65a 100644 --- a/Tests/FindPackageTest/FindVersionTestB.cmake +++ b/Tests/FindPackageTest/FindVersionTestB.cmake @@ -7,6 +7,12 @@ ENDIF(NOT "${VersionTestB_FIND_VERSION_MAJOR}" STREQUAL "1") IF(NOT "${VersionTestB_FIND_VERSION_MINOR}" STREQUAL "2") MESSAGE(SEND_ERROR "VersionTestB_FIND_VERSION_MINOR=${VersionTestB_FIND_VERSION_MINOR} is not 2") ENDIF(NOT "${VersionTestB_FIND_VERSION_MINOR}" STREQUAL "2") -IF(DEFINED VersionTestB_FIND_VERSION_PATCH) - MESSAGE(SEND_ERROR "VersionTestB_FIND_VERSION_PATCH should not be defined") -ENDIF(DEFINED VersionTestB_FIND_VERSION_PATCH) +IF(NOT "${VersionTestB_FIND_VERSION_PATCH}" STREQUAL "0") + MESSAGE(SEND_ERROR "VersionTestB_FIND_VERSION_PATCH=${VersionTestB_FIND_VERSION_PATCH} is not 0") +ENDIF(NOT "${VersionTestB_FIND_VERSION_PATCH}" STREQUAL "0") +IF(NOT "${VersionTestB_FIND_VERSION_TWEAK}" STREQUAL "0") + MESSAGE(SEND_ERROR "VersionTestB_FIND_VERSION_TWEAK=${VersionTestB_FIND_VERSION_TWEAK} is not 0") +ENDIF(NOT "${VersionTestB_FIND_VERSION_TWEAK}" STREQUAL "0") +IF(NOT "${VersionTestB_FIND_VERSION_COUNT}" STREQUAL "2") + MESSAGE(SEND_ERROR "VersionTestB_FIND_VERSION_COUNT=${VersionTestB_FIND_VERSION_COUNT} is not 2") +ENDIF(NOT "${VersionTestB_FIND_VERSION_COUNT}" STREQUAL "2") diff --git a/Tests/FindPackageTest/FindVersionTestC.cmake b/Tests/FindPackageTest/FindVersionTestC.cmake index 26ce05069..1344cbc22 100644 --- a/Tests/FindPackageTest/FindVersionTestC.cmake +++ b/Tests/FindPackageTest/FindVersionTestC.cmake @@ -10,3 +10,9 @@ ENDIF(NOT "${VersionTestC_FIND_VERSION_MINOR}" STREQUAL "2") IF(NOT "${VersionTestC_FIND_VERSION_PATCH}" STREQUAL "3") MESSAGE(SEND_ERROR "VersionTestC_FIND_VERSION_PATCH=${VersionTestC_FIND_VERSION_PATCH} is not 3") ENDIF(NOT "${VersionTestC_FIND_VERSION_PATCH}" STREQUAL "3") +IF(NOT "${VersionTestC_FIND_VERSION_TWEAK}" STREQUAL "0") + MESSAGE(SEND_ERROR "VersionTestC_FIND_VERSION_TWEAK=${VersionTestC_FIND_VERSION_TWEAK} is not 0") +ENDIF(NOT "${VersionTestC_FIND_VERSION_TWEAK}" STREQUAL "0") +IF(NOT "${VersionTestC_FIND_VERSION_COUNT}" STREQUAL "3") + MESSAGE(SEND_ERROR "VersionTestC_FIND_VERSION_COUNT=${VersionTestC_FIND_VERSION_COUNT} is not 3") +ENDIF(NOT "${VersionTestC_FIND_VERSION_COUNT}" STREQUAL "3") diff --git a/Tests/FindPackageTest/FindVersionTestD.cmake b/Tests/FindPackageTest/FindVersionTestD.cmake new file mode 100644 index 000000000..d3e3f509e --- /dev/null +++ b/Tests/FindPackageTest/FindVersionTestD.cmake @@ -0,0 +1,18 @@ +IF(NOT "${VersionTestD_FIND_VERSION}" STREQUAL "1.2.3.4") + MESSAGE(SEND_ERROR "VersionTestD_FIND_VERSION=${VersionTestD_FIND_VERSION} is not 1.2.3.4") +ENDIF(NOT "${VersionTestD_FIND_VERSION}" STREQUAL "1.2.3.4") +IF(NOT "${VersionTestD_FIND_VERSION_MAJOR}" STREQUAL "1") + MESSAGE(SEND_ERROR "VersionTestD_FIND_VERSION_MAJOR=${VersionTestD_FIND_VERSION_MAJOR} is not 1") +ENDIF(NOT "${VersionTestD_FIND_VERSION_MAJOR}" STREQUAL "1") +IF(NOT "${VersionTestD_FIND_VERSION_MINOR}" STREQUAL "2") + MESSAGE(SEND_ERROR "VersionTestD_FIND_VERSION_MINOR=${VersionTestD_FIND_VERSION_MINOR} is not 2") +ENDIF(NOT "${VersionTestD_FIND_VERSION_MINOR}" STREQUAL "2") +IF(NOT "${VersionTestD_FIND_VERSION_PATCH}" STREQUAL "3") + MESSAGE(SEND_ERROR "VersionTestD_FIND_VERSION_PATCH=${VersionTestD_FIND_VERSION_PATCH} is not 3") +ENDIF(NOT "${VersionTestD_FIND_VERSION_PATCH}" STREQUAL "3") +IF(NOT "${VersionTestD_FIND_VERSION_TWEAK}" STREQUAL "4") + MESSAGE(SEND_ERROR "VersionTestD_FIND_VERSION_TWEAK=${VersionTestD_FIND_VERSION_TWEAK} is not 4") +ENDIF(NOT "${VersionTestD_FIND_VERSION_TWEAK}" STREQUAL "4") +IF(NOT "${VersionTestD_FIND_VERSION_COUNT}" STREQUAL "4") + MESSAGE(SEND_ERROR "VersionTestD_FIND_VERSION_COUNT=${VersionTestD_FIND_VERSION_COUNT} is not 4") +ENDIF(NOT "${VersionTestD_FIND_VERSION_COUNT}" STREQUAL "4") diff --git a/Tests/Framework/CMakeLists.txt b/Tests/Framework/CMakeLists.txt index 397e970f5..29f983810 100644 --- a/Tests/Framework/CMakeLists.txt +++ b/Tests/Framework/CMakeLists.txt @@ -5,8 +5,11 @@ add_library(foo SHARED foo.cxx foo.h foo2.h + fooExtensionlessResource fooPublic.h + fooPublicExtensionlessHeader fooPrivate.h + fooPrivateExtensionlessHeader fooNeither.h fooBoth.h test.lua @@ -20,9 +23,9 @@ set(foo_ver ver4) set_target_properties(foo PROPERTIES FRAMEWORK TRUE FRAMEWORK_VERSION ${foo_ver} - PRIVATE_HEADER "fooPrivate.h;fooBoth.h" - PUBLIC_HEADER "foo.h;foo2.h;fooPublic.h;fooBoth.h" - RESOURCE "test.lua" + PRIVATE_HEADER "fooPrivate.h;fooBoth.h;fooPrivateExtensionlessHeader" + PUBLIC_HEADER "foo.h;foo2.h;fooPublic.h;fooBoth.h;fooPublicExtensionlessHeader" + RESOURCE "fooExtensionlessResource;test.lua" INSTALL_NAME_DIR "@executable_path/../../../Library/Frameworks" DEBUG_POSTFIX -d ) @@ -57,11 +60,15 @@ add_library(fooStatic STATIC foo.cxx foo.h foo2.h + fooExtensionlessResource fooPublic.h + fooPublicExtensionlessHeader fooPrivate.h + fooPrivateExtensionlessHeader fooNeither.h fooBoth.h test.lua + fooDeepPublic.h ) set_target_properties(fooStatic PROPERTIES FRAMEWORK TRUE diff --git a/Tests/Framework/fooExtensionlessResource b/Tests/Framework/fooExtensionlessResource new file mode 100644 index 000000000..5122750ee --- /dev/null +++ b/Tests/Framework/fooExtensionlessResource @@ -0,0 +1 @@ +fooExtensionlessResource diff --git a/Tests/Framework/fooPrivateExtensionlessHeader b/Tests/Framework/fooPrivateExtensionlessHeader new file mode 100644 index 000000000..ac97b929e --- /dev/null +++ b/Tests/Framework/fooPrivateExtensionlessHeader @@ -0,0 +1 @@ +fooPrivateExtensionlessHeader diff --git a/Tests/Framework/fooPublicExtensionlessHeader b/Tests/Framework/fooPublicExtensionlessHeader new file mode 100644 index 000000000..972d9898d --- /dev/null +++ b/Tests/Framework/fooPublicExtensionlessHeader @@ -0,0 +1 @@ +fooPublicExtensionlessHeader diff --git a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt index 57c429e53..9f7b86873 100755 --- a/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt +++ b/Tests/OutOfSource/OutOfSourceSubdir/CMakeLists.txt @@ -10,8 +10,11 @@ IF ("${PROJECT_SOURCE_DIR}" STREQUAL "${ANOTHER_PROJ_SOURCE_DIR}") GET_FILENAME_COMPONENT(DEEPDIR ${OutOfSource_BINARY_DIR}/../OutOfSourceDeep/deeper ABSOLUTE) - # The maximum allowed path length on Windows is near this value. - SET(MAXPATH "250") + # Test giving the generator a custom limit. + SET(CMAKE_OBJECT_PATH_MAX 220) + + # Use a separate variable for computation. + SET(MAXPATH "${CMAKE_OBJECT_PATH_MAX}") # VS8 adds "OutOfSource/SubDir/OutOfSourceSubdir/../../../" to the # path of the source file for no good reason. Reduce the length diff --git a/Tests/ReturnTest/CMakeLists.txt b/Tests/ReturnTest/CMakeLists.txt index bd0966e01..7c9156bf8 100755 --- a/Tests/ReturnTest/CMakeLists.txt +++ b/Tests/ReturnTest/CMakeLists.txt @@ -84,6 +84,14 @@ else ("${subdirResult}" EQUAL 1) failed ("subdir got: ${subdirResult}") endif ("${subdirResult}" EQUAL 1) +# check return from a file +include(include_return.cmake) +if ("${include_returnResult}" EQUAL 1) + pass ("include_return") +else ("${include_returnResult}" EQUAL 1) + failed ("include_return got: ${include_returnResult}") +endif ("${include_returnResult}" EQUAL 1) + # check return from within a macro macro (mymacro) set (foo 1) diff --git a/Tests/ReturnTest/include_return.cmake b/Tests/ReturnTest/include_return.cmake new file mode 100644 index 000000000..7cea1fb2d --- /dev/null +++ b/Tests/ReturnTest/include_return.cmake @@ -0,0 +1,3 @@ +set(include_returnResult 1) +return() +set(include_returnResult 0) diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index 23d3d2720..c204e6410 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -66,9 +66,13 @@ IF(STAGE2) PATHS ${LIBPATHS} DOC "Fourth library") + # Test importing a library found on disk. + ADD_LIBRARY(lib_test4 UNKNOWN IMPORTED) + SET_PROPERTY(TARGET lib_test4 PROPERTY IMPORTED_LOCATION ${TEST4_LIBRARY}) + INCLUDE_DIRECTORIES(${CMAKE_INSTALL_PREFIX}/MyTest/include) ADD_EXECUTABLE (SimpleInstExeS2 inst2.cxx foo.c foo.h) - TARGET_LINK_LIBRARIES(SimpleInstExeS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} ${TEST4_LIBRARY}) + TARGET_LINK_LIBRARIES(SimpleInstExeS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} lib_test4) SET(install_target SimpleInstExeS2) IF("${TEST1_LIBRARY}" MATCHES "static") @@ -355,27 +359,11 @@ SET(CMAKE_INSTALL_DEBUG_LIBRARIES 1) INCLUDE(InstallRequiredSystemLibraries) INCLUDE(CPack) -# Disable packaging test on Apple 10.3 and below. PackageMaker starts -# DiskManagementTool as root and disowns it -# (http://lists.apple.com/archives/installer-dev/2005/Jul/msg00005.html). -# It is left holding open pipe handles and preventing ProcessUNIX from -# detecting end-of-data even after its immediate child exits. Then -# the test hangs until it times out and is killed. This is a -# well-known bug in kwsys process execution that I would love to get -# time to fix. -SET(PACKAGE_TARGET --build-target package) -IF(APPLE AND NOT CTEST_TEST_CPACK) - EXECUTE_PROCESS( - COMMAND sw_vers -productVersion - OUTPUT_VARIABLE OSX_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - IF("${OSX_VERSION}" MATCHES "^10\\.[0123]" OR "${OSX_VERSION}" MATCHES "ProductVersion:\t10\\.[0123]") - MESSAGE(STATUS "Disabling package test on OSX < 10.4") - MESSAGE(STATUS "OSX_VERSION='${OSX_VERSION}'") - SET(PACKAGE_TARGET) - ENDIF("${OSX_VERSION}" MATCHES "^10\\.[0123]" OR "${OSX_VERSION}" MATCHES "ProductVersion:\t10\\.[0123]") -ENDIF(APPLE AND NOT CTEST_TEST_CPACK) +IF(CTEST_TEST_CPACK) + SET(PACKAGE_TARGET --build-target package) +ELSE(CTEST_TEST_CPACK) + SET(PACKAGE_TARGET) +ENDIF(CTEST_TEST_CPACK) ADD_CUSTOM_COMMAND( TARGET ${install_target} diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index 23d3d2720..c204e6410 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -66,9 +66,13 @@ IF(STAGE2) PATHS ${LIBPATHS} DOC "Fourth library") + # Test importing a library found on disk. + ADD_LIBRARY(lib_test4 UNKNOWN IMPORTED) + SET_PROPERTY(TARGET lib_test4 PROPERTY IMPORTED_LOCATION ${TEST4_LIBRARY}) + INCLUDE_DIRECTORIES(${CMAKE_INSTALL_PREFIX}/MyTest/include) ADD_EXECUTABLE (SimpleInstExeS2 inst2.cxx foo.c foo.h) - TARGET_LINK_LIBRARIES(SimpleInstExeS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} ${TEST4_LIBRARY}) + TARGET_LINK_LIBRARIES(SimpleInstExeS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} lib_test4) SET(install_target SimpleInstExeS2) IF("${TEST1_LIBRARY}" MATCHES "static") @@ -355,27 +359,11 @@ SET(CMAKE_INSTALL_DEBUG_LIBRARIES 1) INCLUDE(InstallRequiredSystemLibraries) INCLUDE(CPack) -# Disable packaging test on Apple 10.3 and below. PackageMaker starts -# DiskManagementTool as root and disowns it -# (http://lists.apple.com/archives/installer-dev/2005/Jul/msg00005.html). -# It is left holding open pipe handles and preventing ProcessUNIX from -# detecting end-of-data even after its immediate child exits. Then -# the test hangs until it times out and is killed. This is a -# well-known bug in kwsys process execution that I would love to get -# time to fix. -SET(PACKAGE_TARGET --build-target package) -IF(APPLE AND NOT CTEST_TEST_CPACK) - EXECUTE_PROCESS( - COMMAND sw_vers -productVersion - OUTPUT_VARIABLE OSX_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - IF("${OSX_VERSION}" MATCHES "^10\\.[0123]" OR "${OSX_VERSION}" MATCHES "ProductVersion:\t10\\.[0123]") - MESSAGE(STATUS "Disabling package test on OSX < 10.4") - MESSAGE(STATUS "OSX_VERSION='${OSX_VERSION}'") - SET(PACKAGE_TARGET) - ENDIF("${OSX_VERSION}" MATCHES "^10\\.[0123]" OR "${OSX_VERSION}" MATCHES "ProductVersion:\t10\\.[0123]") -ENDIF(APPLE AND NOT CTEST_TEST_CPACK) +IF(CTEST_TEST_CPACK) + SET(PACKAGE_TARGET --build-target package) +ELSE(CTEST_TEST_CPACK) + SET(PACKAGE_TARGET) +ENDIF(CTEST_TEST_CPACK) ADD_CUSTOM_COMMAND( TARGET ${install_target} diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 4667345bf..a4a3ad78d 100755 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -25,6 +25,7 @@ MACRO(TEST_EXPECT_CONTAINS command expected) ENDIF(NOT "${result}" MATCHES "${expected}") ENDMACRO(TEST_EXPECT_CONTAINS command expected) + # try to compile a file that should compile # also check that COPY_FILE works TRY_COMPILE(SHOULD_PASS diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 7cc35e41f..5d75422b4 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -16,6 +16,7 @@ MACRO(ADD_DOCS target dependency) ARGS --help-full ${CMake_BINARY_DIR}/Docs/${target}.txt --help-full ${CMake_BINARY_DIR}/Docs/${target}.html --help-full ${CMake_BINARY_DIR}/Docs/${target}.1 + --help-full ${CMake_BINARY_DIR}/Docs/${target}.docbook DEPENDS ${target} MAIN_DEPENDENCY ${dependency} ) @@ -23,6 +24,7 @@ MACRO(ADD_DOCS target dependency) INSTALL_FILES(${CMAKE_DOC_DIR} FILES ${CMake_BINARY_DIR}/Docs/${target}.txt ${CMake_BINARY_DIR}/Docs/${target}.html + ${CMake_BINARY_DIR}/Docs/${target}.docbook ) SET(DOC_FILES ${DOC_FILES} ${CMake_BINARY_DIR}/Docs/${target}.txt) ENDIF(CMD) @@ -44,6 +46,10 @@ ADD_CUSTOM_COMMAND( --help-full ${CMake_BINARY_DIR}/Docs/cmake.txt --help-full ${CMake_BINARY_DIR}/Docs/cmake.html --help-full ${CMake_BINARY_DIR}/Docs/cmake.1 + --help-full ${CMake_BINARY_DIR}/Docs/cmake.docbook + --help-policies ${CMake_BINARY_DIR}/Docs/cmake-policies.txt + --help-policies ${CMake_BINARY_DIR}/Docs/cmake-policies.html + --help-policies ${CMake_BINARY_DIR}/Docs/cmakepolicies.1 --help-properties ${CMake_BINARY_DIR}/Docs/cmake-properties.txt --help-properties ${CMake_BINARY_DIR}/Docs/cmake-properties.html --help-properties ${CMake_BINARY_DIR}/Docs/cmakeprops.1 @@ -68,17 +74,21 @@ INSTALL_FILES(${CMAKE_MAN_DIR}/man1 FILES ${CMake_BINARY_DIR}/Docs/cmakecommands.1 ${CMake_BINARY_DIR}/Docs/cmakecompat.1 ${CMake_BINARY_DIR}/Docs/cmakeprops.1 + ${CMake_BINARY_DIR}/Docs/cmakepolicies.1 ${CMake_BINARY_DIR}/Docs/cmakevars.1 ${CMake_BINARY_DIR}/Docs/cmakemodules.1) INSTALL_FILES(${CMAKE_DOC_DIR} FILES ${CMake_BINARY_DIR}/Docs/cmake.txt ${CMake_BINARY_DIR}/Docs/cmake.html + ${CMake_BINARY_DIR}/Docs/cmake.docbook + ${CMake_BINARY_DIR}/Docs/cmake-policies.txt + ${CMake_BINARY_DIR}/Docs/cmake-policies.html ${CMake_BINARY_DIR}/Docs/cmake-properties.txt ${CMake_BINARY_DIR}/Docs/cmake-properties.html ${CMake_BINARY_DIR}/Docs/cmake-variables.txt ${CMake_BINARY_DIR}/Docs/cmake-variables.html - ${CMake_BINARY_DIR}/Docs/cmake-modules.txt + ${CMake_BINARY_DIR}/Docs/cmake-modules.txt ${CMake_BINARY_DIR}/Docs/cmake-modules.html ${CMake_BINARY_DIR}/Docs/cmake-commands.txt ${CMake_BINARY_DIR}/Docs/cmake-commands.html diff --git a/Utilities/cmcurl/CMake/CurlCheckCSourceCompiles.cmake b/Utilities/cmcurl/CMake/CurlCheckCSourceCompiles.cmake new file mode 100644 index 000000000..d025769aa --- /dev/null +++ b/Utilities/cmcurl/CMake/CurlCheckCSourceCompiles.cmake @@ -0,0 +1,75 @@ +# - Check if the source code provided in the SOURCE argument compiles. +# CURL_CHECK_C_SOURCE_COMPILES(SOURCE VAR) +# - macro which checks if the source code compiles +# SOURCE - source code to try to compile +# VAR - variable to store whether the source code compiled +# +# 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(CURL_CHECK_C_SOURCE_COMPILES SOURCE VAR) + IF("${VAR}" MATCHES "^${VAR}$" OR "${VAR}" MATCHES "UNKNOWN") + SET(message "${VAR}") + # If the number of arguments is greater than 2 (SOURCE VAR) + IF(${ARGC} GREATER 2) + # then add the third argument as a message + SET(message "${ARGV2} (${VAR})") + ENDIF(${ARGC} GREATER 2) + SET(MACRO_CHECK_FUNCTION_DEFINITIONS + "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") + IF(CMAKE_REQUIRED_LIBRARIES) + SET(CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ELSE(CMAKE_REQUIRED_LIBRARIES) + SET(CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES) + ENDIF(CMAKE_REQUIRED_LIBRARIES) + IF(CMAKE_REQUIRED_INCLUDES) + SET(CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + ELSE(CMAKE_REQUIRED_INCLUDES) + SET(CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES) + ENDIF(CMAKE_REQUIRED_INCLUDES) + SET(src "") + FOREACH(def ${EXTRA_DEFINES}) + SET(src "${src}#define ${def} 1\n") + ENDFOREACH(def) + FOREACH(inc ${HEADER_INCLUDES}) + SET(src "${src}#include <${inc}>\n") + ENDFOREACH(inc) + + SET(src "${src}\nint main() { ${SOURCE} ; return 0; }") + SET(CMAKE_CONFIGURABLE_FILE_CONTENT "${src}") + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CMakeConfigurableFile.in + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" + IMMEDIATE) + MESSAGE(STATUS "Performing Test ${message}") + TRY_COMPILE(${VAR} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + "${CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}" + "${CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}" + OUTPUT_VARIABLE OUTPUT) + IF(${VAR}) + SET(${VAR} 1 CACHE INTERNAL "Test ${message}") + MESSAGE(STATUS "Performing Test ${message} - Success") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Performing C SOURCE FILE Test ${message} succeded with the following output:\n" + "${OUTPUT}\n" + "Source file was:\n${src}\n") + ELSE(${VAR}) + MESSAGE(STATUS "Performing Test ${message} - Failed") + SET(${VAR} "" CACHE INTERNAL "Test ${message}") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Performing C SOURCE FILE Test ${message} failed with the following output:\n" + "${OUTPUT}\n" + "Source file was:\n${src}\n") + ENDIF(${VAR}) + ENDIF("${VAR}" MATCHES "^${VAR}$" OR "${VAR}" MATCHES "UNKNOWN") +ENDMACRO(CURL_CHECK_C_SOURCE_COMPILES) diff --git a/Utilities/cmcurl/CMake/CurlCheckCSourceRuns.cmake b/Utilities/cmcurl/CMake/CurlCheckCSourceRuns.cmake new file mode 100644 index 000000000..19681bd85 --- /dev/null +++ b/Utilities/cmcurl/CMake/CurlCheckCSourceRuns.cmake @@ -0,0 +1,83 @@ +# - Check if the source code provided in the SOURCE argument compiles and runs. +# CURL_CHECK_C_SOURCE_RUNS(SOURCE VAR) +# - macro which checks if the source code runs +# 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(CURL_CHECK_C_SOURCE_RUNS SOURCE VAR) + IF("${VAR}" MATCHES "^${VAR}$" OR "${VAR}" MATCHES "UNKNOWN") + SET(message "${VAR}") + # If the number of arguments is greater than 2 (SOURCE VAR) + IF(${ARGC} GREATER 2) + # then add the third argument as a message + SET(message "${ARGV2} (${VAR})") + ENDIF(${ARGC} GREATER 2) + SET(MACRO_CHECK_FUNCTION_DEFINITIONS + "-D${VAR} ${CMAKE_REQUIRED_FLAGS}") + IF(CMAKE_REQUIRED_LIBRARIES) + SET(CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ELSE(CMAKE_REQUIRED_LIBRARIES) + SET(CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES) + ENDIF(CMAKE_REQUIRED_LIBRARIES) + IF(CMAKE_REQUIRED_INCLUDES) + SET(CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + ELSE(CMAKE_REQUIRED_INCLUDES) + SET(CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES) + ENDIF(CMAKE_REQUIRED_INCLUDES) + SET(src "") + FOREACH(def ${EXTRA_DEFINES}) + SET(src "${src}#define ${def} 1\n") + ENDFOREACH(def) + FOREACH(inc ${HEADER_INCLUDES}) + SET(src "${src}#include <${inc}>\n") + ENDFOREACH(inc) + + SET(src "${src}\nint main() { ${SOURCE} ; return 0; }") + SET(CMAKE_CONFIGURABLE_FILE_CONTENT "${src}") + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/CMake/CMakeConfigurableFile.in + "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" + IMMEDIATE) + MESSAGE(STATUS "Performing Test ${message}") + TRY_RUN(${VAR} ${VAR}_COMPILED + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + "${CURL_CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}" + "${CURL_CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}" + OUTPUT_VARIABLE OUTPUT) + # if it did not compile make the return value fail code of 1 + IF(NOT ${VAR}_COMPILED) + SET(${VAR} 1) + ENDIF(NOT ${VAR}_COMPILED) + # if the return value was 0 then it worked + SET(result_var ${${VAR}}) + IF("${result_var}" EQUAL 0) + SET(${VAR} 1 CACHE INTERNAL "Test ${message}") + MESSAGE(STATUS "Performing Test ${message} - Success") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Performing C SOURCE FILE Test ${message} succeded with the following output:\n" + "${OUTPUT}\n" + "Return value: ${${VAR}}\n" + "Source file was:\n${src}\n") + ELSE("${result_var}" EQUAL 0) + MESSAGE(STATUS "Performing Test ${message} - Failed") + SET(${VAR} "" CACHE INTERNAL "Test ${message}") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Performing C SOURCE FILE Test ${message} failed with the following output:\n" + "${OUTPUT}\n" + "Return value: ${result_var}\n" + "Source file was:\n${src}\n") + ENDIF("${result_var}" EQUAL 0) + ENDIF("${VAR}" MATCHES "^${VAR}$" OR "${VAR}" MATCHES "UNKNOWN") +ENDMACRO(CURL_CHECK_C_SOURCE_RUNS) diff --git a/Utilities/cmcurl/CMake/OtherTests.cmake b/Utilities/cmcurl/CMake/OtherTests.cmake index 953337c7d..ea1613d37 100644 --- a/Utilities/cmcurl/CMake/OtherTests.cmake +++ b/Utilities/cmcurl/CMake/OtherTests.cmake @@ -1,4 +1,4 @@ -INCLUDE(CheckCSourceCompiles) +INCLUDE(CurlCheckCSourceCompiles) SET(EXTRA_DEFINES "__unused1\n#undef inline\n#define __unused2") SET(HEADER_INCLUDES) SET(headers_hack) @@ -28,7 +28,7 @@ ENDIF(HAVE_WINDOWS_H) SET(EXTRA_DEFINES_BACKUP "${EXTRA_DEFINES}") SET(EXTRA_DEFINES "${EXTRA_DEFINES_BACKUP}\n${headers_hack}\n${extern_line}\n#define __unused5") -CHECK_C_SOURCE_COMPILES("recv(0, 0, 0, 0)" curl_cv_recv) +CURL_CHECK_C_SOURCE_COMPILES("recv(0, 0, 0, 0)" curl_cv_recv) IF(curl_cv_recv) # AC_CACHE_CHECK([types of arguments and return type for recv], #[curl_cv_func_recv_args], [ @@ -44,7 +44,7 @@ IF(curl_cv_recv) SET(curl_cv_func_recv_test "UNKNOWN") SET(extern_line "extern ${recv_retv} ${signature_call_conv} recv(${recv_arg1}, ${recv_arg2}, ${recv_arg3}, ${recv_arg4})\;") SET(EXTRA_DEFINES "${EXTRA_DEFINES_BACKUP}\n${headers_hack}\n${extern_line}\n#define __unused5") - CHECK_C_SOURCE_COMPILES(" + CURL_CHECK_C_SOURCE_COMPILES(" ${recv_arg1} s=0; ${recv_arg2} buf=0; ${recv_arg3} len=0; @@ -91,7 +91,7 @@ ENDIF(curl_cv_recv) SET(curl_cv_func_recv_args "${curl_cv_func_recv_args}" CACHE INTERNAL "Arguments for recv") SET(HAVE_RECV 1) -CHECK_C_SOURCE_COMPILES("send(0, 0, 0, 0)" curl_cv_send) +CURL_CHECK_C_SOURCE_COMPILES("send(0, 0, 0, 0)" curl_cv_send) IF(curl_cv_send) # AC_CACHE_CHECK([types of arguments and return type for send], #[curl_cv_func_send_args], [ @@ -107,7 +107,7 @@ IF(curl_cv_send) SET(curl_cv_func_send_test "UNKNOWN") SET(extern_line "extern ${send_retv} ${signature_call_conv} send(${send_arg1}, ${send_arg2}, ${send_arg3}, ${send_arg4})\;") SET(EXTRA_DEFINES "${EXTRA_DEFINES_BACKUP}\n${headers_hack}\n${extern_line}\n#define __unused5") - CHECK_C_SOURCE_COMPILES(" + CURL_CHECK_C_SOURCE_COMPILES(" ${send_arg1} s=0; ${send_arg2} buf=0; ${send_arg3} len=0; @@ -161,7 +161,7 @@ SET(curl_cv_func_send_args "${curl_cv_func_send_args}" CACHE INTERNAL "Arguments SET(HAVE_SEND 1) SET(EXTRA_DEFINES "${EXTRA_DEFINES}\n${headers_hack}\n#define __unused5") -CHECK_C_SOURCE_COMPILES("int flag = MSG_NOSIGNAL" HAVE_MSG_NOSIGNAL) +CURL_CHECK_C_SOURCE_COMPILES("int flag = MSG_NOSIGNAL" HAVE_MSG_NOSIGNAL) SET(EXTRA_DEFINES "__unused1\n#undef inline\n#define __unused2") SET(HEADER_INCLUDES) @@ -190,16 +190,16 @@ ELSE(HAVE_WINDOWS_H) add_header_include(HAVE_TIME_H "time.h") ENDIF(HAVE_WINDOWS_H) SET(EXTRA_DEFINES "${EXTRA_DEFINES}\n${headers_hack}\n#define __unused5") -CHECK_C_SOURCE_COMPILES("struct timeval ts;\nts.tv_sec = 0;\nts.tv_usec = 0" HAVE_STRUCT_TIMEVAL) +CURL_CHECK_C_SOURCE_COMPILES("struct timeval ts;\nts.tv_sec = 0;\nts.tv_usec = 0" HAVE_STRUCT_TIMEVAL) -INCLUDE(CheckCSourceRuns) +INCLUDE(CurlCheckCSourceRuns) SET(EXTRA_DEFINES) SET(HEADER_INCLUDES) IF(HAVE_SYS_POLL_H) SET(HEADER_INCLUDES "sys/poll.h") ENDIF(HAVE_SYS_POLL_H) -CHECK_C_SOURCE_RUNS("return poll((void *)0, 0, 10 /*ms*/)" HAVE_POLL_FINE) +CURL_CHECK_C_SOURCE_RUNS("return poll((void *)0, 0, 10 /*ms*/)" HAVE_POLL_FINE) SET(HAVE_SIG_ATOMIC_T 1) SET(EXTRA_DEFINES) @@ -210,7 +210,7 @@ IF(HAVE_SIGNAL_H) ENDIF(HAVE_SIGNAL_H) CHECK_TYPE_SIZE("sig_atomic_t" SIZEOF_SIG_ATOMIC_T) IF(HAVE_SIZEOF_SIG_ATOMIC_T) - CHECK_C_SOURCE_COMPILES("static volatile sig_atomic_t dummy = 0" HAVE_SIG_ATOMIC_T_NOT_VOLATILE) + CURL_CHECK_C_SOURCE_COMPILES("static volatile sig_atomic_t dummy = 0" HAVE_SIG_ATOMIC_T_NOT_VOLATILE) IF(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE) SET(HAVE_SIG_ATOMIC_T_VOLATILE 1) ENDIF(NOT HAVE_SIG_ATOMIC_T_NOT_VOLATILE) diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt index 3ed177ff3..d2f319de2 100644 --- a/Utilities/cmcurl/CMakeLists.txt +++ b/Utilities/cmcurl/CMakeLists.txt @@ -675,15 +675,19 @@ ELSE(RETSIGTYPE_TEST) ENDIF(RETSIGTYPE_TEST) IF(CMAKE_COMPILER_IS_GNUCC AND APPLE) - # The Mac version of GCC warns about use of long double. Disable it. - GET_SOURCE_FILE_PROPERTY(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS) - IF(MPRINTF_COMPILE_FLAGS) - SET(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double") - ELSE(MPRINTF_COMPILE_FLAGS) - SET(MPRINTF_COMPILE_FLAGS "-Wno-long-double") - ENDIF(MPRINTF_COMPILE_FLAGS) - SET_SOURCE_FILES_PROPERTIES(mprintf.c PROPERTIES - COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS}) + INCLUDE(CheckCCompilerFlag) + CHECK_C_COMPILER_FLAG(-Wno-long-double HAVE_C_FLAG_Wno_long_double) + IF(HAVE_C_FLAG_Wno_long_double) + # The Mac version of GCC warns about use of long double. Disable it. + GET_SOURCE_FILE_PROPERTY(MPRINTF_COMPILE_FLAGS mprintf.c COMPILE_FLAGS) + IF(MPRINTF_COMPILE_FLAGS) + SET(MPRINTF_COMPILE_FLAGS "${MPRINTF_COMPILE_FLAGS} -Wno-long-double") + ELSE(MPRINTF_COMPILE_FLAGS) + SET(MPRINTF_COMPILE_FLAGS "-Wno-long-double") + ENDIF(MPRINTF_COMPILE_FLAGS) + SET_SOURCE_FILES_PROPERTIES(mprintf.c PROPERTIES + COMPILE_FLAGS ${MPRINTF_COMPILE_FLAGS}) + ENDIF(HAVE_C_FLAG_Wno_long_double) ENDIF(CMAKE_COMPILER_IS_GNUCC AND APPLE) INCLUDE(CMake/OtherTests.cmake) diff --git a/Utilities/cmtar/CMakeLists.txt b/Utilities/cmtar/CMakeLists.txt index 328a9009e..b8e511833 100644 --- a/Utilities/cmtar/CMakeLists.txt +++ b/Utilities/cmtar/CMakeLists.txt @@ -1,5 +1,10 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.0) +CMAKE_MINIMUM_REQUIRED(VERSION 2.4) +IF(COMMAND CMAKE_POLICY) + CMAKE_POLICY(SET CMP0003 NEW) +ENDIF(COMMAND CMAKE_POLICY) + PROJECT(LIBTAR C) + INCLUDE_REGULAR_EXPRESSION("^.*$") # We need ansi c-flags, especially on HP