diff --git a/.gitattributes b/.gitattributes index 43676a97f..d21f1dda0 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ .gitattributes export-ignore +.hooks* export-ignore bootstrap crlf=input configure crlf=input @@ -7,6 +8,7 @@ configure crlf=input *.sh.in crlf=input *.bat -crlf +*.bat.in -crlf *.dsp -crlf *.dsptemplate -crlf *.dsw -crlf diff --git a/.hooks-config.bash b/.hooks-config.bash new file mode 100644 index 000000000..97152f651 --- /dev/null +++ b/.hooks-config.bash @@ -0,0 +1,18 @@ +#============================================================================= +# CMake - Cross Platform Makefile Generator +# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +# Loaded by .git/hooks/(pre-commit|commit-msg|prepare-commit-msg) +# during git commit after local hooks have been installed. + +hooks_chain_pre_commit="Utilities/Git/pre-commit" +hooks_chain_commit_msg="Utilities/Git/commit-msg" +hooks_chain_prepare_commit_msg="Utilities/Git/prepare-commit-msg" diff --git a/CMakeLists.txt b/CMakeLists.txt index 15620a3f7..278bfa531 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,6 +213,12 @@ ENDMACRO(CMAKE_SET_TARGET_FOLDER) # Simply to improve readability of the main script. #----------------------------------------------------------------------- MACRO (CMAKE_BUILD_UTILITIES) + #--------------------------------------------------------------------- + # Create the KWIML library for CMake. + SET(KWIML cmIML) + SET(KWIML_HEADER_ROOT ${CMake_BINARY_DIR}/Utilities) + ADD_SUBDIRECTORY(Utilities/KWIML) + #--------------------------------------------------------------------- # Create the kwsys library for CMake. SET(KWSYS_NAMESPACE cmsys) @@ -231,11 +237,13 @@ MACRO (CMAKE_BUILD_UTILITIES) CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}_c "${kwsys_folder}") CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}EncodeExecutable "${kwsys_folder}") CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}ProcessFwd9x "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestDynload "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestProcess "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsC "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsCxx "${kwsys_folder}") - CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestSharedForward "${kwsys_folder}") + if(BUILD_TESTING) + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestDynload "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestProcess "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsC "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsCxx "${kwsys_folder}") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestSharedForward "${kwsys_folder}") + endif() #--------------------------------------------------------------------- # Setup third-party libraries. @@ -416,9 +424,9 @@ ENDIF() # The CMake version number. SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 8) -SET(CMake_VERSION_PATCH 5) +SET(CMake_VERSION_PATCH 7) SET(CMake_VERSION_TWEAK 0) -#SET(CMake_VERSION_RC 3) +#SET(CMake_VERSION_RC 2) # Releases define a tweak level. IF(DEFINED CMake_VERSION_TWEAK) @@ -598,7 +606,9 @@ ADD_SUBDIRECTORY(Source) ADD_SUBDIRECTORY(Utilities) ADD_SUBDIRECTORY(Tests) -CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests") +if(BUILD_TESTING) + CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests") +endif() CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat") CMAKE_SET_TARGET_FOLDER(documentation "Documentation") diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index 0047e68ce..1a466889b 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -42,6 +42,12 @@ SET(CTEST_CUSTOM_WARNING_EXCEPTION "warning:.*is.*misused, please use.*" "CMakeSetupManifest.xml.*manifest authoring warning.*Unrecognized Element" "cc-3968 CC: WARNING File.*" # "implicit" truncation by static_cast + "ld: warning: directory not found for option .-(F|L)" + "warning.*This version of Mac OS X is unsupported" + + # Ignore clang's summary warning, assuming prior text has matched some + # other warning expression: + "[0-9,]+ warnings? generated." ) IF(NOT "@CMAKE_GENERATOR@" MATCHES "Xcode") diff --git a/ChangeLog.manual b/ChangeLog.manual index a00ce000c..f672b80ed 100644 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,3 +1,756 @@ +Changes in CMake 2.8.7 (since 2.8.7-rc2) +-------------------------------------------- +None + +Changes in CMake 2.8.7-rc2 (since 2.8.7-rc1) +-------------------------------------------- +Alex Neundorf (5): + automoc: default to strict mode, use CMAKE_AUTOMOC_RELAXED_MODE + automoc: improved warning message in relaxed mode + Remove trailing whitespace + Add comment about one more problem of the C depency scanner. + fix #12262: dependency scanning for ASM files + +Bill Hoffman (1): + Fix the case where cmake --build failed with two project cmds in one file. + +Brad King (11): + KWSys: Correctly handle empty environment variables + FortranCInterface: Work around mingw32-make trouble with parens + Xcode: Create separate rerun dependencies for subprojects (#12616) + Fix Intel Fortran .vfproj files for VS 10 + HP: Drive shared library linking with compiler front end + Follow all dependencies of shared library private dependencies + Do not link private dependent shared libraries on OS X > 10.4 + Avoid clobbering variable 'OUTPUT' in compiler tests (#12628) + Fix and simplify Fortran test compiler compatibility check + CTest: Recognize Intel errors without space before colon (#12627) + Windows-GNU: Remove extra quotes in GNUtoMS rule variable + +David Cole (4): + Release: Increase timeout for slow-testing cygwin build + Modules: Use "windres" as rc compiler base name for cross-compiles (#12480) + Tests: Only really run MFC test if we can build MFC apps (#11213) + FindBoost: Quote possibly empty string argument (#12273) + +Eric NOULARD (1): + CPackRPM fix #0012608 and unoticed related bug + +Johan Fänge (1): + CMake: Fix progress reporting for custom targets (#12441) + +Mike McQuaid (2): + Unset configurations variable when no build type. + Improve component support and output indentation. + +Raphael Kubo da Costa (2): + Remove the apparently outdated README in Source/QtDialog. + QtDialog: Set Ctrl+Q as the shortcut for quitting the program. + +Tim Gallagher (2): + FindLAPACK: Correct CMAKE_FIND_LIBRARY_SUFFIXES spelling (#12624) + FindLAPACK: List thread libs to avoid link errors (#12625) + +Valat Sébastien (1): + CTest: Do not get CDash version without drop site (#12618) + +Changes in CMake 2.8.7-rc1 (since 2.8.6) +---------------------------------------- +Aaron Ten Clay (1): + VS: Add support for three new project properties (#12586) + +Alex Neundorf (60): + fix #12392: handle CMAKE_CXX_COMPILER_ARG1 for Eclipse projects + fix #12262: use the C dependency scanner also for ASM files + fix #12465: detect the masm compiler ID ("MSVC") + Silence make on OpenBSD in FindPackageModeTest(#12508) + Remove trailing whitespace + Find Ruby on OpenBSD when installed from ports (#12507) + Eclipse generator: detect Eclipse version + Detect whether the current Eclipse version supports VirtualFolders + Eclipse: don't create VirtualFolders if not supported + Eclipse: better message when Eclipse version could not be determined + automoc:run moc on the header if the source file contains include "foo.moc" + Add copyright notices + automoc: always run moc on the cpp file if there is a foo.moc included + Eclipse: add virtual folder for each target + Eclipse: move code for generating links to projects into separate function + Eclipse: move code for generating links to targets into separate function + Eclipse: add Build and Clean targets to targets + Eclipse: detect number of CPUs, set CMAKE_ECLIPSE_MAKE_ARGUMENTS accordigly + Eclipse: fix #12417, don't create wrong src pathentries + FindLibXslt: also search libexslt and xsltproc + don't crash in automoc with empty COMPILE_DEFINITIONS property + Automoc: fix the fix, need to use std::string, not just char* pointer + automoc: fix #12541, support moc options + add documentation for the AUTOMOC_MOC_OPTIONS property + Eclipse: warn if CMAKE_BINARY_DIR is subdir of CMAKE_SOURCE_DIR + Eclipse: make targets work from any directory + Eclipse: quote the build dir (to make it work with spaces) + make automoc work when using ccmake via PATH (#12551) + Strip trailing whitespace + -make GETTEXT_PROCESS_PO_FILES() work with files with multiple dots + FindGettext: two more fixes for files with multiple dots + FindPNG: provide PNG_INCLUDE_DIRS, as the readme.txt says (#11312) + Eclipse: create links to subprojects also in the source-project (#12579) + Eclipse: use new variable CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT + install(EXPORT): Enforce existence of imported target files + Remove trailing whitespace + cmake-gui: add completion for the names when adding cache entries + automoc: stricter checking for what file is included + automoc: rework the checking for the matching header, to give better warnings + automoc: handle the case when the developer includes the wrong mocfile + automoc: add more test cases + automoc: improved diagnostics + automoc: minor optimization + automoc: another runtime optimization + Automoc: modified handling of included .moc files + automoc: add a test for including both abc.moc and moc_abc.cpp + automoc: add test for including the moc file from another header + automoc: add test for including a moc_abc_p.cpp file + automoc: move some code from the big parsing loop into separate functions + automoc: add special handling for including basename_p.moc, with test + automoc: add extra check whether the header contains Q_PRIVATE_SLOT + automoc: some more linebreaks for the warnings for better readability + automoc: fix handling of included _p.moc files + automoc: move the code for finding headers into separate function + automoc: add a StrictParseCppFile(), which is only qmake-compatible + automoc: also accept other files when .moc is included in non-strict mode + automoc: accept even more .moc files in non-strict mode + automoc: add variable CMAKE_AUTOMOC_STRICT_MODE, to enable strict parsing + automoc: fix line length + automoc: add documentation for CMAKE_AUTOMOC_STRICT_MODE + +Alexey Ozeritsky (1): + FindLAPACK: Fix linking to static LAPACK on Unix (#12477) + +Bernhard Walle (1): + Source/cmCTest.cxx: Add missing newline (#12538) + +Brad King (65): + Refactor find_* command final path list computation + Constify XCode generator getters to match cmGlobalGenerator + Fix line-too-long style violations + KWSys: Fix Doxygen warnings + Add pre-commit|commit-msg|prepare-commit-msg hook placeholders + pre-commit: Reject changes to KWSys through Git + Fix CTest.UpdateSVN with Subversion 1.7 (#12535) + Teach CTest.UpdateSVN to detect svn add --depth before using it + KWSys: Address Intel compiler remarks + Fix linking to OS X Frameworks named with spaces (#12550) + Watcom: Use shortpath to CMake if full path has parens (#12548) + KWSys: Remove trailing whitespace in SystemTools.cxx + KWSys: Fix wrong spelling of __INTEL_COMPILER + Update main Copyright.txt year range for 2011 + KWIML: The Kitware Information Macro Library + Configure KWIML inside CMake as cmIML + KWIML: Avoid redefining _CRT_SECURE_NO_DEPRECATE in test.h + KWIML: Suppress printf/scanf format warnings in test + KWIML: No INT_SCN*8 on SunPro compiler + KWIML: No INT_SCN*8 on Intel for Windows + KWIML: Create test output dir for Xcode + Order VS local generator Version ivar values consistently + Enumerate VS11 version explicitly in local generators + KWIML: Test header inclusion after system headers + KWIML: Ignore _LONGLONG on MS compiler + KWIML: Teach ABI.h about PGI compiler + KWIML: Avoid MSVC linker warning about not using C++ runtime + Factor Compute(File|String)MD5 into cmCryptoHash helper + Add file(MD5) command to compute cryptographic hash + Import sha2 implementation 1.0 from Aaron D. Gifford + Import sha2 implementation 1.1 from Aaron D. Gifford + sha2: Use KWIML fixed-size integer types and endian-ness + sha2: Build as part of CMakeLib + Add file(SHA*) commands to compute cryptographic hashes + sha2: Use "static const" instead of "const static" declarations + cmCryptoHash: Provide factory "New" method + Add string(MD5) and string(SHA*) commands to compute hashes + sha2: Use KWIML fixed-size integer constant macros + sha2: Suppress Borland warnings in third-party code + Disable file() and string() hash commands during bootstrap + sha2: Wrap long lines in third-party declarations + Fix CMake.File hash test for CRLF checkouts + cmCryptoHash: Add virtual destructor + sha2: Cast safe conversions to smaller integer types + sha2: Suppress -Wcast-align warning from Clang + sha2: Zero entire SHA_CTX structure during cleanup + target_link_libraries: Add missing space in documentation + target_link_libraries: Simplify argument processing state tests + install(EXPORT): Improve target import failure message format + Remove trailing whitespace from cmLocalGenerator + bootstrap: Include cmNewLineStyle in build + cmNewLineStyle: Remove trailing comma in enum + cmNewLineStyle: Use cmStandardIncludes.h + Provide std::ios_base typedef on GCC < 3 + FindZLIB: Search under ZLIB_ROOT if it is set + Factor out target location undefined behavior helper macro + export(): Document undefined behavior of location properties + Recognize the Tiny C Compiler (#12605) + TinyCC: Add compiler info for shared libs on Linux (#12605) + Fortran: Detect pointer size in gfortran on MinGW + Load platform files that need to know the ABI when possible + Factor makefile generator link rule lookup into helper function + Add CMAKE_GNUtoMS option to convert GNU .dll.a to MS .lib + Test CMAKE_GNUtoMS option in ExportImport on MinGW and MSys + cmTarget: Create helper method for versioned library names + +Clinton Stimpson (2): + Fix XML safety issue with adding preprocessor defines in CodeBlocks project. + Qt4: Fix dependencies of QtDeclartive. + +Dan Kegel (1): + Modules: Add XRes to FindX11.cmake + +David Cole (17): + Begin post-2.8.6 development + CTest: Fix crash when variables are not defined + VS11: Fix comment generated at the top of *.sln files + CTest: Add COVERAGE_EXTRA_FLAGS cache variable (#12490) + CTest: Clear custom vectors before populating (#12383) + Tests: Add the MFC test (#11213) + Tests: Avoid MFC test automatically for VCExpress builds (#11213) + Tests: Fix MFC test w/ Make-based generators (#11213) + Tests: Fix MFC test for old vs6 dashboards (#11213) + Tests: Avoid MFC test automatically for Watcom WMake builds (#11213) + Tests: Fix MFC test to work with VS 10 and later (#11213) + VS10: Use expected values for UseOfMfc (#11213) + Tests: Add environment logging to the MFC test (#11213) + VS11: Update InstallRequiredSystemLibraries.cmake for VS11 (#11213) + Tests: Nudge MFC test to pass on VS 6 dashboards (#11213) + VS: Use "call " keyword with .cmd and .bat file custom commands (#12445) + CTest: Disallow problem chars in build and site names (#11792) + +Eric NOULARD (3): + CPackRPM support component specific variables for spec files + Fix old reference to CMAKE_MAKE_PROGRAM inside CMAKE_BUILD_TOOL doc. + CPackRPM fix #12556 and enhance documentation + +James Bigler (6): + Added support for CUDA_PATH which is present in the CUDA toolkit 3.2 onward. + Reset dependency file list when a dependency disappeared. + Add work around for CUDA in UNC paths. + Fixes for handling quotes in args and other places (Fix Bug 11726 and 12099). + Make CUDA working directory unique for each target. + Miscellaneous fixes. + +Jean-Christophe Fillion-Robin (1): + CTest: Look for CTestConfig.cmake in build dir first, then source dir + +Johan Bjork (1): + Xcode: Avoid spewing the environment on every script run (#12522) + +Mateusz Loskot (1): + FindBoost: Use MSVC11 to find Boost on Windows (#12568) + +Mathieu Malaterre (1): + TinyCC: Add default compilation flags (#12605) + +Mike McQuaid (6): + Add QT_LIBRARIES_PLUGINS variable to UseQt4. + Add DeployQt4 module. + Match fixup_qt4_executable with documentation. + Don't resolve directories; are never relative. + Check plugin variables are defined before warning. + Check QtCore without warning. + +Nicolas Despres (17): + Refactor TargetTypeNames. + Add const versions of some getters. + Constify many getters of cmGlobalGenerator. + Remove trailing white-spaces. + Fix typo. + Doxygen: Improve code documentation. + Doxygen: Generate call graph and relationships. + Doxygen: Fix warnings. + Doxygen: Remove dependency on VTK when building doxygen. + Usage: Document -j|--parallel option in help message. + Usage: Document all options printing usage information. + Usage: Document all options printing the version number. + Usage: Print help, version and copyright options in usage information. + Usage: Add missing exepath argument in get_prerequisites documentation. + ccmake: Align 'g' and 'q' key instructions. + ccmake: Document '/' key. + ccmake: Factor toggle key help instructions. + +Niels Dekker (1): + Fix CMAKE_VERBOSE_MAKEFILE for VS10 vcxproj files (#12504) + +Ondrej Balaz (1): + FindBISON: Fix bison++ version parsing to avoid "Offending entry" + +Peter Collingbourne (4): + Make cmLocalGenerator::ConvertToLinkReference virtual + Introduce a cmLocalGenerator::ConvertToIncludeReference function + Introduce a cmGlobalGenerator::ResolveLanguageCompiler function + Fix configuration-dependent flag lookup in cmLocalGenerator::GetTargetFlags + +Peter Kuemmel (1): + Add NEWLINE_STYLE option to configure_file (#3957) + +Philip Lowman (1): + FindProtoBuf: Documented limitation of the public macro + +Pierre-Francois Laquerre (1): + Fix path quoting in Qt4 macros + +Robert Dailey (1): + VS: Add VS_SCC_AUXPATH target property (#12549) + +Rolf Eike Beer (4): + libarchive: fix typo in CheckFileOffsetBits.cmake + Tell people that link_directories() is not what they are searching for + FindBISON: Fix matching output of "bison --version" + Tests: ExternalProject: Remove unnecessary 'svn --version' call + +Stephen Kelly (13): + Add features from KDE for arguments to qdbusxml2cpp. + Remove unused define. + Build each library only once instead of once for each test. + Initialize LINK_INTERFACE_LIBRARIES target property with a variable + Also run moc automatically with Qt5. + Fix typo. + Don't assume the existence of QT_MAJOR_VERSION. + Update comments and method names to not be Qt4 specific. + Fix style. + target_link_libraries: Trim trailing whitespace + target_link_libraries: Add LINK_(PUBLIC|PRIVATE) options + moc is now part of the Qt5Core module + Add a test case for the use of Q_PRIVATE_SLOT. + +Changes in CMake 2.8.6 (since 2.8.6-rc4) +---------------------------------------- +Alex Neundorf (5): + Remove trailing whitespace + Minor improvements to the UsePkgConfig.cmake docs + Remove trailing whitespace + Improve behaviour of --find-package mode with try_run/try_compile + Use makefile->IssueMessage() for better error messages + +Bill Hoffman (2): + Use version 11.0 for 12.x and 9.10 for 10.x intel versions to fix 12.1 vsIDE. + Also, check for 11.x as an intel fortran version. + +Brad King (2): + Add Visual Studio 11 generator for x86 and x64 tools + Teach our tests about special cases for VS 11 + +David Cole (1): + CTestCustom.cmake: Ignore clang's summary warning + +Philip Lowman (1): + FindBullet: Also search for _Debug postfixed library names + +Raphael Kubo da Costa (1): + Fix typo in set_target_properties' documentation. + +Rolf Eike Beer (1): + Fix typo in UsePkgConfig.cmake + +Changes in CMake 2.8.6-rc4 (since 2.8.6-rc3) +-------------------------------------------- +Alex Neundorf (3): + FindFLEX.cmake: also search the include dir + Fix typos in FeatureSummary.cmake (#12462) + Don't warn when setting a property multiple times to the same value #12464 + +Bill Hoffman (2): + For VS Intel Fortran IDE builds, add a check to find the Fortran library PATH. + Enable Fortran tests for IDE builds. + +Brad King (5): + FortranCInterface: Compile separate Fortran lib in VerifyC[XX] + Move IntelVSImplicitPath project to better location + Simplify IntelVSImplicitPath detection project + libarchive: Fix ssize_t detection with mingwrt 3.20 + Make file(DOWNLOAD) fail on http error + +David Cole (8): + Tests: Add a KWStyle test, equivalent to the make StyleCheck target + KWStyle Test: Activate by default if KWStyle is found + Xcode: Use EFFECTIVE_PLATFORM_NAME reference in ComputeOutputDir + Xcode: Add test to demonstrate iOS project in Xcode + CMake: Reference test targets only when BUILD_TESTING is ON + Tests: Add the more modern Mac64 nightly build + Release Scripts: Use Qt 4.7.4 on dashmacmini5 (#12460) + Revert "FindThreads: Try pthreads with no special option first (#11333)" + +Eric NOULARD (4): + CPack fix #12449 doc mispelled + CPack fix template too + CPackDeb fix #10325 automagically use fakeroot for DEB if fakeroot is found + CPackRPM authorize per-component pre/post-[un]install scripts (#0012063) + +Marcus D. Hanwell (4): + Just code style changes. + Don't warn when nothing to do in visibility function. + Made ADD_COMPILER_EXPORT_FLAGS into a macro. + Make add_compiler_export_flags a function again. + +Rolf Eike Beer (1): + remove stray brace in CPackDeb documentation + +Changes in CMake 2.8.6-rc3 (since 2.8.6-rc2) +-------------------------------------------- +Alexey Ozeritsky (2): + FindBLAS/LAPACK fixes + FindBLAS/LAPACK fixes + +Andreas Schneider (1): + Modules: Add support for more java archives in add_jar(). + +Björn Ricks (4): + Search for the installed python interpreter first + Determine python version + Update documentation of FindPythonInterp.cmake + Use FIND_PACKAGE_HANDLE_STANDARD_ARGS second mode + +Brad King (5): + VS: Map per-source Fortran flags to IDE options + VS: Map Fortran free- and fixed-format flags to IDE options + Fortran: Add support for free- and fixed-form flags + Xcode: Honor Fortran_FORMAT target and source file property + Set CMAKE__COMPILER_ID for VS generators + +David Cole (8): + KWSys: Remove always-true dir_only parameter + KWSys: Add symlinks to directories as files (#12284) + FindPackageMessage: Eliminate new lines in cache entries + FindPackageMessage: Eliminate new lines using REGEX REPLACE + CMake: Add SaveCache at the end of successful Generate calls + Suppress Qt warning for dashmacmini5 builds + Suppress Qt warning for dashmacmini5 builds + Tests: Look for "Illegal" or "SegFault" in the output + +Eric NOULARD (2): + CPack fix #12366 components RPM packages have the same package name + CPackRPM fix #12305, include directories in RPM package + +Johan Björk (5): + Xcode: No spaces in makefile target names (#12370) + CMake: Write symlinks to directories as files in archives (#12284) + CPack: Do not recurse through directory symlinks (#12284) + Xcode: Do not emit the ZERO_CHECK target more than once + Xcode: Honor -g0 to disable debugging (#12377) + +Johannes Stallkamp (1): + CTest: Fixed valgrind output parsing (#12260) + +Matt McCormick (1): + CMake: Remove documentation for -E build (#12446) + +Stephen Kelly (2): + Add some more unit tests. + Don't put what some compilers consider junk at the end of the line. + +Thomas Jarosch (3): + CTest: Fix memory leaks on error + Fix file() command descriptor leak on error + ccmake: Fix off-by-one memory access error + +Changes in CMake 2.8.6-rc2 (since 2.8.6-rc1) +-------------------------------------------- +Brad King (2): + KWSys: Add hash function for std::string + KWSys: Fix std::string hash function for Borland + +Clinton Stimpson (1): + qt4: also find QtUiTools when cross compiling with mingw. + +David Cole (3): + Xcode4: Requires more quoting of single quote char + cmake.m4: Use modern signature of install(FILES ...) + CMake Release Scripts: Changes for next release candidate... + +David Faure (1): + Don't use a variable name that might be used in other files. + +Stephen Kelly (73): + Create moc files in the current binary dir, not the top level. + Make the formatting of feature_summary output a little better. + Add the GenerateExportMacro with unit tests. + Handle the case where the user changes the DEFINE_SYMBOL property. + Add a newline at the end of the file. + Add a newline at the end of the file. + Add missing licence header. + Remove the fatal_warnings option which is no longer used. + Test for features, not specific compilers. + Simplify. We already know we have hidden visibility at this point. + Simplify the compiler feature check + Add some debug output. + Short-circuit the tests on unsupported compilers. + Test expected no-op instead of aborting the build. + Fix tests with clang. + Fix typo and tests failing as a result. + Only run the failure tests with gcc >= 4.2 + Set the CMAKE_RUNTIME_OUTPUT_DIRECTORY for windows builds. + Only set the COMPILER_HAS_HIDDEN_VISIBILITY if GCC >= 4.2 + Disable all export macros on Borland. + Another attempt to fix the tests on Borland. + Use the correct project name compiletest not compilefail + Fix off-by-not in test for Borland. + Another attempt at fixing Borland. + Add some debug output to narrow down deprecation test issues + Export deprecated free methods too. + Remember to surround the other deprecated test in the Borland check. + Only set the deprecated attribute if hidden visibilty is enabled. + Make sure the hidden visibility variables never get set on MINGW. + Don't use hidden visibility on non-mingw windows either. + Don't export methods on already exported classes. + Split the deprecated available check from setting macro values. + Test for compiler features, instead of for specific platforms. + Exclude the XL compiler from the hidden-visibility test. + Add the COMPILER_HAS_DEPRECATED only if it has a declspec variant + Don't change the expected build result based on the platform. + Expect the tests to pass if hidden visibilty is not enabled. + Test -Werror instead of enabling it per compiler. + Add some messaging output to make remaining issues findable. + Perform the -Werror test only once. + Test for deprecated attribute before declspec. + Try to error on deprecated on Intel and SunCC. + Borland can't do deprecated. + Fixup forgotten part of aed84517c942a4c40f493fcf997cdf6a047349f8 + Disable testing of deprecated macros. + Don't enable deprecated on HP. + Don't enable deprecated on old GCC + Exclude cygwin from the hidden visibility feature. + Exclude PGI from exports and deprecated. + Start testing expected values for compiler flags. + Exclude win32 from hidden visibility checks. + Comment the test assertion for now + Test the correct cxx variable. + Fix the version extraction regex for clang. + Hopefully add version extraction for Intel. + Add some settings for non-truncation of test output. + Fix up the regex command for Intel. + Test for too-old-intel compilers. + Possibly fix test on HPUX. + Possibly fix configuration test on AIX. + Try to make the macros do almost nothing for Watcom. + More consistency in the macro options. + Add missing NO_EXPORT macro variant. + Look for errors reported by PGI too. + Quote paths in case there is a space in one of them. + Disable the tests for Watcom. + Fix Compiler id variable name. + Add quotes in case cmake is installed in a prefix with a space. + Fix the feature of using a specific prefix for macros. + Add documentation about the prefix and no_deprecated options. + Remove blank line at the start of the file. + Don't start a line with a dash(-) + Fix up verbatim code sections of the dox. + +Todd Gamblin (3): + FindBoost: Call find_package with NO_MODULE first + Fix XL compilers on non-AIX machines. + Fixed link bugs in BlueGeneP build. + +Changes in CMake 2.8.6-rc1 (since 2.8.5) +-------------------------------------------- +Aaron C. Meadows (1): + FindSubversion: Invoke svn non-interactively (#12304) + +Alex Neundorf (92): + Add a switch to disable a find_package() call completely + Add documentation for the CMAKE_DISABLE_FIND_PACKAGE_ switch + Add a basic test for CMAKE_DISABLE_FIND_PACKAGE_ + Add macros cmake_push/pop_check_state() as discussed on the list. + Fix copyright notice test + Add CheckCXXSymbolExists.cmake, so this can be used also for C++ + Minor fix to try_compile() docs (#12333) + Fix #12342: Add APPEND_STRING option to set_property() + Extend FeatureSummary: add PURPOSE of package and TYPE + FeatureSummary.cmake: remove "comment" field + FeatureSummary.cmake: add INCLUDE_QUIET_PACKAGES keyword + FeatureSummary.cmake: error out when a REQUIRED package is missing + FeatureSummary.cmake: only higher TYPEs can override previous TYPEs + FeatureSummary.cmake: cosmetics + FeatureSummary.cmake: update documentation + Remove debug output from CheckSymbolExists + Don't put files from CMAKE_ROOT into CodeBlocks projects (#12110) + More PATH_SUFFIXES for finding Postgresql and also search catalog/pg_type.h + Use FPHSA(), remove unnecessary stuff and don't recommend link_directories() + Mark the results from find() as advanced + FindPostgreSQL: fix PATH_SUFFIXES, better output for FPHSA + Strip trailing whitespace + FindGIF/FindFreetype.cmake: remove standard search paths from find-calls + FindGif: add giflib4 as one more name for the library under Windows + Add basic version check for giflib + Patch by Campbell Barton: puts definitions into C::B project file + Remove useless line of code + Also put builtin include dirs into CodeBlocks project file + Remove trailing whitespace + Also search for libxkbfile, XSync and SM include dir + Provide macro write_basic_config_version_file() + Add example to documentation + Add some tests for write_basic_config_version_file() + Fix copyright notice + Really fix copyright notice + Set UNSUITABLE instead of not COMPATIBLE + Improve documentation for WriteBasicConfigVersionFile.cmake + Add macros GETTEXT_PROCESS_POT() and GETTEXT_PROCESS_PO_FILES() + Support REQUIRED in FindGettext.cmake (using FPHSA.cmake) + Fix #12358: make optionally enabling ASM work again + Start work on automoc: add empty cmQtAutomoc class + Start implementing skeleton for automoc in cmake + Add actual automoc code from automoc + Remove the need to check for .h/.cxx during buildtime + Add the cmake module required currently for automoc + Add AUTOMOC to the add_library() command + Fix line lengths + Move code for parsing a cpp-file from the big loop to separate function + Initialize verbose based onb the env.var. + Color output when running moc + Add the generated automoc.cpp file to the cleaned files + Use cout instead of printf() + Remove trailing whitespace + Refactor SetupAutomocTarget() so it can be run after creating the target + Remove trailing whitespace + Move automoc processing from add_executable/library to cmGlobalGenerator + Nicer progress message for the automoc target + Add a test for automoc + Add documentation for AUTOMOC, add initialization via CMAKE_AUTOMOC + Fix logic which decides when to execute automoc test + Automoc.cmake is not needed anymore + Fix build: non-void function must return a value + Fix warnings + Fix bootstrap test with automoc + Only enable the automoc test after checking that Qt4 works + Fix build: use std::ios::out|ios::trunc instead of std::ios_base::out + Silence warning in automoc: use long instead of int + Fix automoc with VS builds: apply patch from Bill + Make clLocalGenerator::GetTargetFlags() public + Add find-package mode, which does nothing yet + Implement find-package mode of cmake + Replace cmake::GetScriptMode() with GetWorkingMode() + Fix copyright notice in new CMakeFindPackageMode.cmake + Better support for lib64 and Debian multiarch + Use the file-utility to test for 64bit if there is no /usr/lib64 + Add a cmake.m4 for using cmake in autoconf projects instead of pkgconfig + Improve documentation for --find-package mode + Add a test for the new --find-package mode + Only run the test if we are using a makefile generator under UNIX + The makefile for the test was kindof wrong + Fix test on OpenBSD with BSD make + Rename helper macros print_compile_flags() to set_compile_flags_var() + Dont check for -isysroot and -mmacosx-version on OSX in --find-package mode + Disable any STATUS output in --find-package mode + Much improved test, should now be executed on all UNIXes + Make the --find-package test harder + Make the test harder by always having a space in the include dirs + Only enable the test when using GNU make + Fix line length + Use $(CXXFLAGS) and $(LDFLAGS) in the --find-package test Makefile + Require the current cmake version in --find-package mode + Fix --find-package mode on Cygwin, where enable_language(RC) is called + +Alexey Ozeritsky (5): + fixed: search of acml libraries + gotoblas supported + ACML-GPU supported + ACML-GPU supportede + fixed: search of ATLAS library for C/C++-only projects + +Andreas Schneider (6): + FindJava: Find missing java development executables. + Modules: Added CMake Java support. + Tests: Java tests should test UseJava.cmake + Tests: Check for the new Java exeutable variables. + Java: Use set_property/get_property for target variables. + Java: Fix documentation format and indentation + +Arnaud Gelas (1): + Search for the ASPELL executable + +Bill Hoffman (5): + Only pay for unused variable checking if it is on. + Initial support for Intel Fortran VS2010. + Fix custom commands in VS2010 Fortran projects using CFG_INTDIR and test. + Use MSBuild when devenv is not around, since VCExpress seems broken. + Fix for bug #12413, nmake did not handle targets with + in the name. + +Brad King (13): + MinGW: Remove old workaround and use native echo (#12283) + Document caveat of custom commands in multiple targets (#12311) + cmSystemTools: Remove trailing whitespace + RunSingleCommand: Fix indentation + RunSingleCommand: Avoid assignment in condition + Documentation: WIN32 not defined on Cygwin (#12334) + KWSys: Simplify SystemTools::GetTime implementation (#12261) + KWSys: Avoid conversion warning in SystemTools::GetTime + KWSys: Fix using long long and __int64 with hash_(set|map) + KWSys: __int64 and long long may be same type in specialization + XL: Fix old VisualAge branding of Fortran compiler + Do not crash when an imported target depends on a missing target + Fix CHECK_(C|CXX)_COMPILER_FLAG for Clang (#12394) + +Clinton Stimpson (5): + Add -DQT_NO_DEBUG if no build type is specified so Qt plugins will work. + Add qt4/QtCore to help find Qt headers when cross-compiling. + Qt4: Fix reference of undefined variable when detecting frameworks on Mac OS X + Remove C compiler requirement from FindQt4.cmake + CPack/NSIS: Fix reinstall and multiple install issues when using components. + +David Cole (26): + Begin post-2.8.5 development + Fix Architecture test to work with Xcode 4 + Fix BuildDepends test to work with Xcode 4 + Base architecture choice logic on Xcode version + Use correct default multiple architecture values in test + Add use of EFFECTIVE_PLATFORM_NAME to generated Xcode projects. + Correct KWStyle line too long error + Add fail regex to detect supported warning flags correctly. + Add support for Visual Studio project-specific globals (#8707) + Fix machine-specific UpdateGIT test failures + Ensure libgmp-10.dll is in the PATH for CMakeTestAllGenerators + Watcom: Add -c flag to wlib calls (#12245) + Add Watcom support to InstallRequiredSystemLibraries (#11866) + Watcom: Use correct args for execute_process call (#11866) + CTest: print failed tests in index order (#11746) + Fix line too long style violation + Documentation: Fix comments in the source code (#10941) + Add more find_path locations for DCMTK header files (#12323) + VS9: Add include_directories to midl command lines + KWSys: Remove translation path for "/tmp_mnt/" (#10595) + VS10: Avoid unnecessary rebuilds for custom commands + QtAutomoc test: Pass QT_QMAKE_EXECUTABLE + QtAutomoc: Eliminate compiler warning + CheckSymbolExists: Use IMMEDIATE flag for configure_file (#11333) + Xcode: Suppress same-old warning again. + Xcode: Save object id values in CMakeCache.txt (#11690) + +Johan Björk (5): + Xcode: Remove PREBINDING attribute for Xcode 4 and above + RunSingleCommand: Replace verbose boolean with enum + RunSingleCommand: Add a OUTPUT_NORMAL flag. + Xcode: Quote ',' in Xcode string values (#12259) + Xcode: Rearrange CMakeReRun to enable parallel builds + +Matej Hribernik (2): + VS: Factor Find64BitTools out of Win64 generator to parent + Add VisualStudio 9 and 10 generators for Itanium platform + +Modestas Vainius (1): + multiarch: Treat lib/ as implicit link dir (#12326) + +Oliver Buchtala (3): + Java: Create java_class_filelist only if it does't exist. + Java: Added some dependency magic to avoid recompilations. + Java: Create correct jar archive dependencies. + +Rolf Eike Beer (2): + remove extra output message from FindJava.cmake + FindThreads: Try pthreads with no special option first (#11333) + +Steven Velez (1): + VS10: Add SCC support + +Todd Gamblin (2): + Try regular compiler when no MPI compiler. + Fix issues with removing try_compile input file. + +Will Dicharry (1): + Added HDF5 high level Fortran bindings to available components. + Changes in CMake 2.8.5 (since 2.8.5-rc3) -------------------------------------------- Brad King (1): diff --git a/Copyright.txt b/Copyright.txt index 35f7e4b6c..83a2482c0 100644 --- a/Copyright.txt +++ b/Copyright.txt @@ -1,5 +1,5 @@ CMake - Cross Platform Makefile Generator -Copyright 2000-2009 Kitware, Inc., Insight Software Consortium +Copyright 2000-2011 Kitware, Inc., Insight Software Consortium All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/Modules/AutomocInfo.cmake.in b/Modules/AutomocInfo.cmake.in new file mode 100644 index 000000000..29dab9759 --- /dev/null +++ b/Modules/AutomocInfo.cmake.in @@ -0,0 +1,16 @@ +set(AM_SOURCES "@_moc_files@" ) +set(AM_HEADERS "@_moc_headers@" ) +set(AM_MOC_COMPILE_DEFINITIONS "@_moc_compile_defs@") +set(AM_MOC_DEFINITIONS "@_moc_defs@") +set(AM_MOC_INCLUDES "@_moc_incs@") +set(AM_MOC_OPTIONS "@_moc_options@") +set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE@") +set(AM_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@/") +set(AM_CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@/") +set(AM_QT_MOC_EXECUTABLE "@QT_MOC_EXECUTABLE@") +set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/") +set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/") +set(AM_QT_VERSION_MAJOR "@QT_VERSION_MAJOR@" ) +set(AM_Qt5Core_VERSION_MAJOR "@Qt5Core_VERSION_MAJOR@" ) +set(AM_TARGET_NAME "@_moc_target_name@") +set(AM_RELAXED_MODE "@_moc_relaxed_mode@") diff --git a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in new file mode 100644 index 000000000..cf53db84a --- /dev/null +++ b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in @@ -0,0 +1,26 @@ +# This is a basic version file for the Config-mode of find_package(). +# It is used by WriteBasicConfigVersionFile.cmake as input file for configure_file() +# to create a version-file which can be installed along a config.cmake file. +# +# The created file sets PACKAGE_VERSION_EXACT if the current version string and +# the requested version string are exactly the same and it sets +# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version. +# The variable CVF_VERSION must be set before calling configure_file(). + +set(PACKAGE_VERSION "@CVF_VERSION@") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() + +# check that the installed version has the same 32/64bit-ness as the one which is currently searching: +if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@") + math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in new file mode 100644 index 000000000..2317fdbb3 --- /dev/null +++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in @@ -0,0 +1,41 @@ +# This is a basic version file for the Config-mode of find_package(). +# It is used by WriteBasicConfigVersionFile.cmake as input file for configure_file() +# to create a version-file which can be installed along a config.cmake file. +# +# The created file sets PACKAGE_VERSION_EXACT if the current version string and +# the requested version string are exactly the same and it sets +# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version, +# but only if the requested major version is the same as the current one. +# The variable CVF_VERSION must be set before calling configure_file(). + + +set(PACKAGE_VERSION "@CVF_VERSION@") + +if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + + if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.") + set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}") + else() + set(CVF_VERSION_MAJOR "@CVF_VERSION@") + endif() + + if("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "${CVF_VERSION_MAJOR}") + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() + + if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() + + +# check that the installed version has the same 32/64bit-ness as the one which is currently searching: +if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@") + math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8") + set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)") + set(PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake index d50f351e5..b5f242033 100644 --- a/Modules/CMakeASMInformation.cmake +++ b/Modules/CMakeASMInformation.cmake @@ -33,7 +33,7 @@ IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) IF(NOT _INCLUDED_FILE) IF("ASM${ASM_DIALECT}" STREQUAL "ASM") - MESSAGE(FATAL_ERROR "Did not find file Compiler/${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT}") + MESSAGE(STATUS "Warning: Did not find file Compiler/${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT}") ENDIF("ASM${ASM_DIALECT}" STREQUAL "ASM") INCLUDE(Platform/${CMAKE_BASE_NAME} OPTIONAL) ENDIF(NOT _INCLUDED_FILE) diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index c91553a95..4cc690a26 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -48,6 +48,9 @@ #elif defined(__TI_COMPILER_VERSION__) # define COMPILER_ID "TI_DSP" +#elif defined(__TINYC__) +# define COMPILER_ID "TinyCC" + #elif defined(__SCO_VERSION__) # define COMPILER_ID "SCO" diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index 9285fefb2..6b5efba9d 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -68,6 +68,12 @@ IF (NOT _INCLUDED_FILE) INCLUDE(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL) ENDIF (NOT _INCLUDED_FILE) +IF(CMAKE_C_SIZEOF_DATA_PTR) + FOREACH(f ${CMAKE_C_ABI_FILES}) + INCLUDE(${f}) + ENDFOREACH() + UNSET(CMAKE_C_ABI_FILES) +ENDIF() # This should be included before the _INIT variables are # used to initialize the cache. Since the rule variables diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 620de634e..b97a69c3b 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -67,6 +67,12 @@ IF (NOT _INCLUDED_FILE) INCLUDE(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL) ENDIF (NOT _INCLUDED_FILE) +IF(CMAKE_CXX_SIZEOF_DATA_PTR) + FOREACH(f ${CMAKE_CXX_ABI_FILES}) + INCLUDE(${f}) + ENDFOREACH() + UNSET(CMAKE_CXX_ABI_FILES) +ENDIF() # This should be included before the _INIT variables are # used to initialize the cache. Since the rule variables diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 171e31f92..0a70d0a82 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -107,6 +107,10 @@ IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_XL "-qversion") SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_XL "XL C") + LIST(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS MSVC ) + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_MSVC "/?") + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_MSVC "Microsoft") + LIST(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS TI_DSP ) SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_TI_DSP "-h") SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_TI_DSP "Texas Instruments") diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 06664c10f..e2e268fb3 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -105,10 +105,7 @@ ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION) IF(${CMAKE_GENERATOR} MATCHES "Visual Studio") SET(CMAKE_C_COMPILER_ID_RUN 1) SET(CMAKE_C_PLATFORM_ID "Windows") - - # TODO: Set the compiler id. It is probably MSVC but - # the user may be using an integrated Intel compiler. - # SET(CMAKE_C_COMPILER_ID "MSVC") + SET(CMAKE_C_COMPILER_ID "MSVC") ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio") IF(NOT CMAKE_C_COMPILER_ID_RUN) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index e77672dca..829836933 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -117,10 +117,7 @@ ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION) IF(${CMAKE_GENERATOR} MATCHES "Visual Studio") SET(CMAKE_CXX_COMPILER_ID_RUN 1) SET(CMAKE_CXX_PLATFORM_ID "Windows") - - # TODO: Set the compiler id. It is probably MSVC but - # the user may be using an integrated Intel compiler. - # SET(CMAKE_CXX_COMPILER_ID "MSVC") + SET(CMAKE_CXX_COMPILER_ID "MSVC") ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio") IF(NOT CMAKE_CXX_COMPILER_ID_RUN) SET(CMAKE_CXX_COMPILER_ID_RUN 1) diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 39d1f17b7..1c9899e64 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -57,6 +57,8 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src) IF(ABI_SIZEOF_DPTR) SET(CMAKE_${lang}_SIZEOF_DATA_PTR "${ABI_SIZEOF_DPTR}" PARENT_SCOPE) + ELSEIF(CMAKE_${lang}_SIZEOF_DATA_PTR_DEFAULT) + SET(CMAKE_${lang}_SIZEOF_DATA_PTR "${CMAKE_${lang}_SIZEOF_DATA_PTR_DEFAULT}" PARENT_SCOPE) ENDIF(ABI_SIZEOF_DPTR) IF(ABI_NAME) @@ -83,6 +85,29 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src) FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Parsed ${lang} implicit link information from above output:\n${log}\n\n") ENDIF() + # for VS IDE Intel Fortran we have to figure out the + # implicit link path for the fortran run time using + # a try-compile + IF("${lang}" MATCHES "Fortran" + AND "${CMAKE_GENERATOR}" MATCHES "Visual Studio") + SET(_desc "Determine Intel Fortran Compiler Implicit Link Path") + MESSAGE(STATUS "${_desc}") + # Build a sample project which reports symbols. + TRY_COMPILE(IFORT_LIB_PATH_COMPILED + ${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath + ${CMAKE_ROOT}/Modules/IntelVSImplicitPath + IntelFortranImplicit + CMAKE_FLAGS + "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" + OUTPUT_VARIABLE _output) + FILE(WRITE + "${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/output.txt" + "${_output}") + INCLUDE(${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/output.cmake OPTIONAL) + SET(_desc "Determine Intel Fortran Compiler Implicit Link Path -- done") + MESSAGE(STATUS "${_desc}") + ENDIF() + SET(CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES "${implicit_libs}" PARENT_SCOPE) SET(CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES "${implicit_dirs}" PARENT_SCOPE) diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index ed4e98335..efcba29cf 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -146,10 +146,7 @@ MARK_AS_ADVANCED(CMAKE_Fortran_COMPILER) IF(${CMAKE_GENERATOR} MATCHES "Visual Studio") SET(CMAKE_Fortran_COMPILER_ID_RUN 1) SET(CMAKE_Fortran_PLATFORM_ID "Windows") - - # TODO: Set the compiler id. It is probably MSVC but - # the user may be using an integrated Intel compiler. - # SET(CMAKE_Fortran_COMPILER_ID "MSVC") + SET(CMAKE_Fortran_COMPILER_ID "Intel") ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio") IF(NOT CMAKE_Fortran_COMPILER_ID_RUN) diff --git a/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake new file mode 100644 index 000000000..1b4532deb --- /dev/null +++ b/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake @@ -0,0 +1,120 @@ + +#============================================================================= +# Copyright 2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This file is included by CMakeFindEclipseCDT4.cmake and CMakeFindCodeBlocks.cmake + +# The Eclipse and the CodeBlocks generators need to know the standard include path +# so that they can find the headers at runtime and parsing etc. works better +# This is done here by actually running gcc with the options so it prints its +# system include directories, which are parsed then and stored in the cache. +MACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines) + SET(${_resultIncludeDirs}) + SET(_gccOutput) + FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy" "\n" ) + + IF (${_lang} STREQUAL "c++") + SET(_compilerExecutable "${CMAKE_CXX_COMPILER}") + SET(_arg1 "${CMAKE_CXX_COMPILER_ARG1}") + ELSE () + SET(_compilerExecutable "${CMAKE_C_COMPILER}") + SET(_arg1 "${CMAKE_C_COMPILER_ARG1}") + ENDIF () + EXECUTE_PROCESS(COMMAND ${_compilerExecutable} ${_arg1} -v -E -x ${_lang} -dD dummy + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles + ERROR_VARIABLE _gccOutput + OUTPUT_VARIABLE _gccStdout ) + FILE(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy") + + # First find the system include dirs: + IF( "${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+ *\n) *End of (search) list" ) + + # split the output into lines and then remove leading and trailing spaces from each of them: + STRING(REGEX MATCHALL "[^\n]+\n" _includeLines "${CMAKE_MATCH_1}") + FOREACH(nextLine ${_includeLines}) + STRING(STRIP "${nextLine}" _includePath) + LIST(APPEND ${_resultIncludeDirs} "${_includePath}") + ENDFOREACH(nextLine) + + ENDIF() + + + # now find the builtin macros: + STRING(REGEX MATCHALL "#define[^\n]+\n" _defineLines "${_gccStdout}") +# A few example lines which the regexp below has to match properly: +# #define MAX(a,b) ((a) > (b) ? (a) : (b)) +# #define __fastcall __attribute__((__fastcall__)) +# #define FOO (23) +# #define __UINTMAX_TYPE__ long long unsigned int +# #define __UINTMAX_TYPE__ long long unsigned int +# #define __i386__ 1 + + FOREACH(nextLine ${_defineLines}) + STRING(REGEX MATCH "^#define +([A-Za-z_][A-Za-z0-9_]*)(\\([^\\)]+\\))? +(.+) *$" _dummy "${nextLine}") + SET(_name "${CMAKE_MATCH_1}${CMAKE_MATCH_2}") + STRING(STRIP "${CMAKE_MATCH_3}" _value) + #MESSAGE(STATUS "m1: -${CMAKE_MATCH_1}- m2: -${CMAKE_MATCH_2}- m3: -${CMAKE_MATCH_3}-") + + LIST(APPEND ${_resultDefines} "${_name}") + IF(_value) + LIST(APPEND ${_resultDefines} "${_value}") + ELSE() + LIST(APPEND ${_resultDefines} " ") + ENDIF() + ENDFOREACH(nextLine) + +ENDMACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang) + +# Save the current LC_ALL, LC_MESSAGES, and LANG environment variables and set them +# to "C" that way GCC's "search starts here" text is in English and we can grok it. +SET(_orig_lc_all $ENV{LC_ALL}) +SET(_orig_lc_messages $ENV{LC_MESSAGES}) +SET(_orig_lang $ENV{LANG}) +IF(_orig_lc_all) + SET(ENV{LC_ALL} C) +ENDIF() +IF(_orig_lc_messages) + SET(ENV{LC_MESSAGES} C) +ENDIF() +IF(_orig_lang) + SET(ENV{LANG} C) +ENDIF() + +# Now check for C, works for gcc and Intel compiler at least +IF (NOT CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS) + IF ("${CMAKE_C_COMPILER_ID}" MATCHES GNU OR "${CMAKE_C_COMPILER_ID}" MATCHES Intel) + _DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c _dirs _defines) + SET(CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS "${_dirs}" CACHE INTERNAL "C compiler system include directories") + SET(CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS "${_defines}" CACHE INTERNAL "C compiler system defined macros") + ENDIF () +ENDIF () + +# And now the same for C++ +IF (NOT CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS) + IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Intel) + _DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c++ _dirs _defines) + SET(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS "${_dirs}" CACHE INTERNAL "CXX compiler system include directories") + SET(CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_DEFINED_MACROS "${_defines}" CACHE INTERNAL "CXX compiler system defined macros") + ENDIF () +ENDIF () + +# Restore original LC_ALL, LC_MESSAGES, and LANG +IF(_orig_lc_all) + SET(ENV{LC_ALL} ${_orig_lc_all}) +ENDIF() +IF(_orig_lc_messages) + SET(ENV{LC_MESSAGES} ${_orig_lc_messages}) +ENDIF() +IF(_orig_lang) + SET(ENV{LANG} ${_orig_lang}) +ENDIF() diff --git a/Modules/CMakeFindCodeBlocks.cmake b/Modules/CMakeFindCodeBlocks.cmake index c72c8f7b8..23f2c821d 100644 --- a/Modules/CMakeFindCodeBlocks.cmake +++ b/Modules/CMakeFindCodeBlocks.cmake @@ -21,3 +21,5 @@ IF(CMAKE_CODEBLOCKS_EXECUTABLE) SET(CMAKE_OPEN_PROJECT_COMMAND "${CMAKE_CODEBLOCKS_EXECUTABLE} " ) ENDIF(CMAKE_CODEBLOCKS_EXECUTABLE) +# Determine builtin macros and include dirs: +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake) diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake index a756e6454..dd061280f 100644 --- a/Modules/CMakeFindEclipseCDT4.cmake +++ b/Modules/CMakeFindEclipseCDT4.cmake @@ -17,112 +17,61 @@ FIND_PROGRAM(CMAKE_ECLIPSE_EXECUTABLE NAMES eclipse DOC "The Eclipse executable") -# This variable is used by the Eclipse generator and appended to the make invocation commands. -SET(CMAKE_ECLIPSE_MAKE_ARGUMENTS "" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j to get parallel builds") - -# This variable is used by the Eclipse generator in out-of-source builds only. -SET(ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR") -MARK_AS_ADVANCED(ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT) - -# The Eclipse generator needs to know the standard include path -# so that Eclipse ca find the headers at runtime and parsing etc. works better -# This is done here by actually running gcc with the options so it prints its -# system include directories, which are parsed then and stored in the cache. -MACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines) - SET(${_resultIncludeDirs}) - SET(_gccOutput) - FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy" "\n" ) - - IF (${_lang} STREQUAL "c++") - SET(_compilerExecutable "${CMAKE_CXX_COMPILER}") - ELSE (${_lang} STREQUAL "c++") - SET(_compilerExecutable "${CMAKE_C_COMPILER}") - ENDIF (${_lang} STREQUAL "c++") - EXECUTE_PROCESS(COMMAND ${_compilerExecutable} -v -E -x ${_lang} -dD dummy - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/CMakeFiles - ERROR_VARIABLE _gccOutput - OUTPUT_VARIABLE _gccStdout ) - FILE(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy") - - # First find the system include dirs: - IF( "${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+ *\n) *End of (search) list" ) - - # split the output into lines and then remove leading and trailing spaces from each of them: - STRING(REGEX MATCHALL "[^\n]+\n" _includeLines "${CMAKE_MATCH_1}") - FOREACH(nextLine ${_includeLines}) - STRING(STRIP "${nextLine}" _includePath) - LIST(APPEND ${_resultIncludeDirs} "${_includePath}") - ENDFOREACH(nextLine) - - ENDIF( "${_gccOutput}" MATCHES "> search starts here[^\n]+\n *(.+ *\n) *End of (search) list" ) - - - # now find the builtin macros: - STRING(REGEX MATCHALL "#define[^\n]+\n" _defineLines "${_gccStdout}") -# A few example lines which the regexp below has to match properly: -# #define MAX(a,b) ((a) > (b) ? (a) : (b)) -# #define __fastcall __attribute__((__fastcall__)) -# #define FOO (23) -# #define __UINTMAX_TYPE__ long long unsigned int -# #define __UINTMAX_TYPE__ long long unsigned int -# #define __i386__ 1 - - FOREACH(nextLine ${_defineLines}) - STRING(REGEX MATCH "^#define +([A-Za-z_][A-Za-z0-9_]*)(\\([^\\)]+\\))? +(.+) *$" _dummy "${nextLine}") - SET(_name "${CMAKE_MATCH_1}${CMAKE_MATCH_2}") - STRING(STRIP "${CMAKE_MATCH_3}" _value) - #MESSAGE(STATUS "m1: -${CMAKE_MATCH_1}- m2: -${CMAKE_MATCH_2}- m3: -${CMAKE_MATCH_3}-") - - LIST(APPEND ${_resultDefines} "${_name}") - IF(_value) - LIST(APPEND ${_resultDefines} "${_value}") - ELSE() - LIST(APPEND ${_resultDefines} " ") +FUNCTION(_FIND_ECLIPSE_VERSION) + # This code is in a function so the variables used here have only local scope + IF(CMAKE_ECLIPSE_EXECUTABLE) + GET_FILENAME_COMPONENT(_ECLIPSE_DIR "${CMAKE_ECLIPSE_EXECUTABLE}" PATH) + FILE(GLOB _ECLIPSE_FEATURE_DIR "${_ECLIPSE_DIR}/features/org.eclipse.platform*") + IF("${_ECLIPSE_FEATURE_DIR}" MATCHES ".+org.eclipse.platform_([0-9]+\\.[0-9]+).+") + SET(_ECLIPSE_VERSION ${CMAKE_MATCH_1}) ENDIF() - ENDFOREACH(nextLine) + ENDIF() + + # Set up a map with the names of the Eclipse releases: + SET(_ECLIPSE_VERSION_NAME_ "Unknown" ) + SET(_ECLIPSE_VERSION_NAME_3.2 "Callisto" ) + SET(_ECLIPSE_VERSION_NAME_3.3 "Europa" ) + SET(_ECLIPSE_VERSION_NAME_3.4 "Ganymede" ) + SET(_ECLIPSE_VERSION_NAME_3.5 "Galileo" ) + SET(_ECLIPSE_VERSION_NAME_3.6 "Helios" ) + SET(_ECLIPSE_VERSION_NAME_3.7 "Indigo" ) + + IF(_ECLIPSE_VERSION) + MESSAGE(STATUS "Found Eclipse version ${_ECLIPSE_VERSION} (${_ECLIPSE_VERSION_NAME_${_ECLIPSE_VERSION}})") + ELSE() + SET(_ECLIPSE_VERSION "3.6" ) + MESSAGE(STATUS "Could not determine Eclipse version, assuming at least ${_ECLIPSE_VERSION} (${_ECLIPSE_VERSION_NAME_${_ECLIPSE_VERSION}}). Adjust CMAKE_ECLIPSE_VERSION if this is wrong.") + ENDIF() + + SET(CMAKE_ECLIPSE_VERSION "${_ECLIPSE_VERSION} (${_ECLIPSE_VERSION_NAME_${_ECLIPSE_VERSION}})" CACHE STRING "The version of Eclipse. If Eclipse has not been found, 3.6 (Helios) is assumed.") + SET_PROPERTY(CACHE CMAKE_ECLIPSE_VERSION PROPERTY STRINGS "3.2 (${_ECLIPSE_VERSION_NAME_3.2})" + "3.3 (${_ECLIPSE_VERSION_NAME_3.3})" + "3.4 (${_ECLIPSE_VERSION_NAME_3.4})" + "3.5 (${_ECLIPSE_VERSION_NAME_3.5})" + "3.6 (${_ECLIPSE_VERSION_NAME_3.6})" + "3.7 (${_ECLIPSE_VERSION_NAME_3.7})") +ENDFUNCTION() + +_FIND_ECLIPSE_VERSION() + +# Try to find out how many CPUs we have and set the -j argument for make accordingly +SET(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "") + +INCLUDE(ProcessorCount) +PROCESSORCOUNT(_CMAKE_ECLIPSE_PROCESSOR_COUNT) + +# Only set -j if we are under UNIX and if the make-tool used actually has "make" in the name +# (we may also get here in the future e.g. for ninja) +IF("${_CMAKE_ECLIPSE_PROCESSOR_COUNT}" GREATER 1 AND UNIX AND "${CMAKE_MAKE_PROGRAM}" MATCHES make) + SET(_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS "-j${_CMAKE_ECLIPSE_PROCESSOR_COUNT}") +ENDIF() -ENDMACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang) - -# Save the current LC_ALL, LC_MESSAGES, and LANG environment variables and set them -# to "C" that way GCC's "search starts here" text is in English and we can grok it. -SET(_orig_lc_all $ENV{LC_ALL}) -SET(_orig_lc_messages $ENV{LC_MESSAGES}) -SET(_orig_lang $ENV{LANG}) -IF(_orig_lc_all) - SET(ENV{LC_ALL} C) -ENDIF(_orig_lc_all) -IF(_orig_lc_messages) - SET(ENV{LC_MESSAGES} C) -ENDIF(_orig_lc_messages) -IF(_orig_lang) - SET(ENV{LANG} C) -ENDIF(_orig_lang) - -# Now check for C, works for gcc and Intel compiler at least -IF (NOT CMAKE_ECLIPSE_C_SYSTEM_INCLUDE_DIRS) - IF ("${CMAKE_C_COMPILER_ID}" MATCHES GNU OR "${CMAKE_C_COMPILER_ID}" MATCHES Intel) - _DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c _dirs _defines) - SET(CMAKE_ECLIPSE_C_SYSTEM_INCLUDE_DIRS "${_dirs}" CACHE INTERNAL "C compiler system include directories") - SET(CMAKE_ECLIPSE_C_SYSTEM_DEFINED_MACROS "${_defines}" CACHE INTERNAL "C compiler system defined macros") - ENDIF ("${CMAKE_C_COMPILER_ID}" MATCHES GNU OR "${CMAKE_C_COMPILER_ID}" MATCHES Intel) -ENDIF (NOT CMAKE_ECLIPSE_C_SYSTEM_INCLUDE_DIRS) +# This variable is used by the Eclipse generator and appended to the make invocation commands. +SET(CMAKE_ECLIPSE_MAKE_ARGUMENTS "${_CMAKE_ECLIPSE_INITIAL_MAKE_ARGS}" CACHE STRING "Additional command line arguments when Eclipse invokes make. Enter e.g. -j to get parallel builds") -# And now the same for C++ -IF (NOT CMAKE_ECLIPSE_CXX_SYSTEM_INCLUDE_DIRS) - IF ("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Intel) - _DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c++ _dirs _defines) - SET(CMAKE_ECLIPSE_CXX_SYSTEM_INCLUDE_DIRS "${_dirs}" CACHE INTERNAL "CXX compiler system include directories") - SET(CMAKE_ECLIPSE_CXX_SYSTEM_DEFINED_MACROS "${_defines}" CACHE INTERNAL "CXX compiler system defined macros") - ENDIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Intel) -ENDIF (NOT CMAKE_ECLIPSE_CXX_SYSTEM_INCLUDE_DIRS) +# This variable is used by the Eclipse generator in out-of-source builds only. +SET(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT FALSE CACHE BOOL "If enabled, CMake will generate a source project for Eclipse in CMAKE_SOURCE_DIR") +MARK_AS_ADVANCED(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT) -# Restore original LC_ALL, LC_MESSAGES, and LANG -IF(_orig_lc_all) - SET(ENV{LC_ALL} ${_orig_lc_all}) -ENDIF(_orig_lc_all) -IF(_orig_lc_messages) - SET(ENV{LC_MESSAGES} ${_orig_lc_messages}) -ENDIF(_orig_lc_messages) -IF(_orig_lang) - SET(ENV{LANG} ${_orig_lang}) -ENDIF(_orig_lang) +# Determine builtin macros and include dirs: +INCLUDE(${CMAKE_CURRENT_LIST_DIR}/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake) diff --git a/Modules/CMakeFindPackageMode.cmake b/Modules/CMakeFindPackageMode.cmake new file mode 100644 index 000000000..42965773a --- /dev/null +++ b/Modules/CMakeFindPackageMode.cmake @@ -0,0 +1,187 @@ +# This file is executed by cmake when invoked with --find-package. +# It expects that the following variables are set using -D: +# NAME = name of the package +# COMPILER_ID = the CMake compiler ID for which the result is, i.e. GNU/Intel/Clang/MSVC, etc. +# LANGUAGE = language for which the result will be used, i.e. C/CXX/Fortan/ASM +# MODE = EXIST : only check for existance of the given package +# COMPILE : print the flags needed for compiling an object file which uses the given package +# LINK : print the flags needed for linking when using the given package +# QUIET = if TRUE, don't print anything + +#============================================================================= +# Copyright 2006-2011 Alexander Neundorf, +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +if(NOT NAME) + message(FATAL_ERROR "Name of the package to be searched not specified. Set the CMake variable NAME, e.g. -DNAME=JPEG .") +endif() + +if(NOT COMPILER_ID) + message(FATAL_ERROR "COMPILER_ID argument not specified. In doubt, use GNU.") +endif() + +if(NOT LANGUAGE) + message(FATAL_ERROR "LANGUAGE argument not specified. Use C, CXX or Fortran.") +endif() + +if(NOT MODE) + message(FATAL_ERROR "MODE argument not specified. Use either EXIST, COMPILE or LINK.") +endif() + +# require the current version. If we don't do this, Platforms/CYGWIN.cmake complains because +# it doesn't know whether it should set WIN32 or not: +cmake_minimum_required(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} ) + +macro(ENABLE_LANGUAGE) + # disable the enable_language() command, otherwise --find-package breaks on Windows. + # On Windows, enable_language(RC) is called in the platform files unconditionally. + # But in --find-package mode, we don't want (and can't) enable any language. +endmacro() + +include(CMakeDetermineSystem) + +# short-cut some tests on Darwin, see Darwin-GNU.cmake: +if("${CMAKE_SYSTEM_NAME}" MATCHES Darwin AND "${COMPILER_ID}" MATCHES GNU) + set(${CMAKE_${LANGUAGE}_HAS_ISYSROOT} 0 ) + set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "") +endif() + +# Also load the system specific file, which sets up e.g. the search paths. +# This makes the FIND_XXX() calls work much better +include(CMakeSystemSpecificInformation) + +if(UNIX) + + # try to guess whether we have a 64bit system, if it has not been set + # from the outside + if(NOT CMAKE_SIZEOF_VOID_P) + set(CMAKE_SIZEOF_VOID_P 4) + if(EXISTS /usr/lib64) + set(CMAKE_SIZEOF_VOID_P 8) + else() + # use the file utility to check whether itself is 64 bit: + find_program(FILE_EXECUTABLE file) + if(FILE_EXECUTABLE) + execute_process(COMMAND "${FILE_EXECUTABLE}" "${FILE_EXECUTABLE}" OUTPUT_VARIABLE fileOutput ERROR_QUIET) + if("${fileOutput}" MATCHES "64-bit") + set(CMAKE_SIZEOF_VOID_P 8) + endif() + endif() + endif() + endif() + + # guess Debian multiarch if it has not been set: + if(EXISTS /etc/debian_version) + if(NOT CMAKE_${LANGUAGE}_LANGUAGE_ARCHITECTURE ) + file(GLOB filesInLib RELATIVE /lib /lib/*-linux-gnu* ) + foreach(file ${filesInLib}) + if("${file}" MATCHES "${CMAKE_LIBRARY_ARCHITECTURE_REGEX}") + set(CMAKE_${LANGUAGE}_LANGUAGE_ARCHITECTURE ${file}) + break() + endif() + endforeach() + endif() + endif() + +endif() + +set(CMAKE_${LANGUAGE}_COMPILER "dummy") +set(CMAKE_${LANGUAGE}_COMPILER_ID "${COMPILER_ID}") +include(CMake${LANGUAGE}Information) + + +function(set_compile_flags_var _packageName) + string(TOUPPER "${_packageName}" PACKAGE_NAME) + # Check the following variables: + # FOO_INCLUDE_DIRS + # Foo_INCLUDE_DIRS + # FOO_INCLUDES + # Foo_INCLUDES + # FOO_INCLUDE_DIR + # Foo_INCLUDE_DIR + set(includes) + if(DEFINED ${_packageName}_INCLUDE_DIRS) + set(includes ${_packageName}_INCLUDE_DIRS) + elseif(DEFINED ${PACKAGE_NAME}_INCLUDE_DIRS) + set(includes ${PACKAGE_NAME}_INCLUDE_DIRS) + elseif(DEFINED ${_packageName}_INCLUDES) + set(includes ${_packageName}_INCLUDES) + elseif(DEFINED ${PACKAGE_NAME}_INCLUDES) + set(includes ${PACKAGE_NAME}_INCLUDES) + elseif(DEFINED ${_packageName}_INCLUDE_DIR) + set(includes ${_packageName}_INCLUDE_DIR) + elseif(DEFINED ${PACKAGE_NAME}_INCLUDE_DIR) + set(includes ${PACKAGE_NAME}_INCLUDE_DIR) + endif() + + set(PACKAGE_INCLUDE_DIRS "${${includes}}" PARENT_SCOPE) + + # Check the following variables: + # FOO_DEFINITIONS + # Foo_DEFINITIONS + set(definitions) + if(DEFINED ${_packageName}_DEFINITIONS) + set(definitions ${_packageName}_DEFINITIONS) + elseif(DEFINED ${PACKAGE_NAME}_DEFINITIONS) + set(definitions ${PACKAGE_NAME}_DEFINITIONS) + endif() + + set(PACKAGE_DEFINITIONS "${${definitions}}" ) + +endfunction() + + +function(set_link_flags_var _packageName) + string(TOUPPER "${_packageName}" PACKAGE_NAME) + # Check the following variables: + # FOO_LIBRARIES + # Foo_LIBRARIES + # FOO_LIBS + # Foo_LIBS + set(libs) + if(DEFINED ${_packageName}_LIBRARIES) + set(libs ${_packageName}_LIBRARIES) + elseif(DEFINED ${PACKAGE_NAME}_LIBRARIES) + set(libs ${PACKAGE_NAME}_LIBRARIES) + elseif(DEFINED ${_packageName}_LIBS) + set(libs ${_packageName}_LIBS) + elseif(DEFINED ${PACKAGE_NAME}_LIBS) + set(libs ${PACKAGE_NAME}_LIBS) + endif() + + set(PACKAGE_LIBRARIES "${${libs}}" PARENT_SCOPE ) + +endfunction() + + +find_package("${NAME}" QUIET) + +set(PACKAGE_FOUND FALSE) + +string(TOUPPER "${NAME}" UPPERCASE_NAME) + +if(${NAME}_FOUND OR ${UPPERCASE_NAME}_FOUND) + set(PACKAGE_FOUND TRUE) + + if("${MODE}" STREQUAL "EXIST") + # do nothing + elseif("${MODE}" STREQUAL "COMPILE") + set_compile_flags_var(${NAME}) + elseif("${MODE}" STREQUAL "LINK") + set_link_flags_var(${NAME}) + else("${MODE}" STREQUAL "LINK") + message(FATAL_ERROR "Invalid mode argument ${MODE} given.") + endif() + +endif() + +set(PACKAGE_QUIET ${SILENT} ) diff --git a/Modules/CMakeFortranCompilerABI.F b/Modules/CMakeFortranCompilerABI.F index b8efb426e..7e24553fb 100644 --- a/Modules/CMakeFortranCompilerABI.F +++ b/Modules/CMakeFortranCompilerABI.F @@ -15,6 +15,11 @@ PRINT *, 'INFO:sizeof_dptr[4]' #elif defined(_M_IX86) PRINT *, 'INFO:sizeof_dptr[4]' + +#elif defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8 + PRINT *, 'INFO:sizeof_dptr[8]' +#elif defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 4 + PRINT *, 'INFO:sizeof_dptr[4]' #endif #if 0 diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index dc15e556e..aed1fd2df 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -44,6 +44,12 @@ IF (NOT _INCLUDED_FILE) INCLUDE(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL) ENDIF (NOT _INCLUDED_FILE) +IF(CMAKE_Fortran_SIZEOF_DATA_PTR) + FOREACH(f ${CMAKE_Fortran_ABI_FILES}) + INCLUDE(${f}) + ENDFOREACH() + UNSET(CMAKE_Fortran_ABI_FILES) +ENDIF() # This should be included before the _INIT variables are # used to initialize the cache. Since the rule variables diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index 6615849b2..6cd8fe6a4 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -73,7 +73,7 @@ function(GetDefaultWindowsPrefixBase var) # the architecture of the targets being built to choose the right # default value for CMAKE_INSTALL_PREFIX. # - if("${CMAKE_GENERATOR}" MATCHES "Win64") + if("${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)") set(arch_hint "x64") elseif("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8") set(arch_hint "x64") diff --git a/Modules/CMakePushCheckState.cmake b/Modules/CMakePushCheckState.cmake new file mode 100644 index 000000000..0a4212818 --- /dev/null +++ b/Modules/CMakePushCheckState.cmake @@ -0,0 +1,61 @@ +# This module defines two macros: +# CMAKE_PUSH_CHECK_STATE() +# and +# CMAKE_POP_CHECK_STATE() +# These two macros can be used to save and restore the state of the variables +# CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS, CMAKE_REQUIRED_LIBRARIES +# and CMAKE_REQUIRED_INCLUDES used by the various Check-files coming with CMake, +# like e.g. check_function_exists() etc. +# The variable contents are pushed on a stack, pushing multiple times is supported. +# This is useful e.g. when executing such tests in a Find-module, where they have to be set, +# but after the Find-module has been executed they should have the same value +# as they had before. +# +# Usage: +# cmake_push_check_state() +# set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF) +# check_function_exists(...) +# cmake_pop_check_state() + +#============================================================================= +# Copyright 2006-2011 Alexander Neundorf, +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + + +MACRO(CMAKE_PUSH_CHECK_STATE) + + IF(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER) + SET(_CMAKE_PUSH_CHECK_STATE_COUNTER 0) + ENDIF() + + MATH(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1") + + SET(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES}) + SET(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS}) + SET(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES}) + SET(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS}) +ENDMACRO(CMAKE_PUSH_CHECK_STATE) + +MACRO(CMAKE_POP_CHECK_STATE) + +# don't pop more than we pushed + IF("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0") + + SET(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + SET(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + SET(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + SET(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + + MATH(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1") + ENDIF() + +ENDMACRO(CMAKE_POP_CHECK_STATE) diff --git a/Modules/CMakeRCInformation.cmake b/Modules/CMakeRCInformation.cmake index fcd00999a..859fe1158 100644 --- a/Modules/CMakeRCInformation.cmake +++ b/Modules/CMakeRCInformation.cmake @@ -20,6 +20,9 @@ # make sure we don't use CMAKE_BASE_NAME from somewhere else SET(CMAKE_BASE_NAME) GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_RC_COMPILER} NAME_WE) +IF("${CMAKE_BASE_NAME}" MATCHES "windres") + SET(CMAKE_BASE_NAME "windres") +ENDIF() SET(CMAKE_SYSTEM_AND_RC_COMPILER_INFO_FILE ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake) INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL) diff --git a/Modules/CMakeTestASMCompiler.cmake b/Modules/CMakeTestASMCompiler.cmake index 56cf3325e..294511d89 100644 --- a/Modules/CMakeTestASMCompiler.cmake +++ b/Modules/CMakeTestASMCompiler.cmake @@ -18,8 +18,18 @@ # because otherwise there would have to be a separate assembler source file # for each assembler on every architecture. + +SET(_ASM_COMPILER_WORKS 0) + IF(CMAKE_ASM${ASM_DIALECT}_COMPILER) - SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_WORKS 1 CACHE INTERNAL "") -ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER) - SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_WORKS 0 CACHE INTERNAL "") -ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER) + SET(_ASM_COMPILER_WORKS 1) +ENDIF() + +# when using generic "ASM" support, we must have detected the compiler ID, fail otherwise: +IF("ASM${ASM_DIALECT}" STREQUAL "ASM") + IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + SET(_ASM_COMPILER_WORKS 0) + ENDIF() +ENDIF() + +SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_WORKS ${_ASM_COMPILER_WORKS} CACHE INTERNAL "") diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index 038c2fd47..779b2f007 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -35,7 +35,7 @@ IF(NOT CMAKE_C_COMPILER_WORKS) "{ (void)argv; return argc-1;}\n") TRY_COMPILE(CMAKE_C_COMPILER_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c - OUTPUT_VARIABLE OUTPUT) + OUTPUT_VARIABLE __CMAKE_C_COMPILER_OUTPUT) SET(C_TEST_WAS_RUN 1) ENDIF(NOT CMAKE_C_COMPILER_WORKS) @@ -43,7 +43,7 @@ IF(NOT CMAKE_C_COMPILER_WORKS) PrintTestCompilerStatus("C" " -- broken") FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the C compiler works failed with " - "the following output:\n${OUTPUT}\n\n") + "the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n") # if the compiler is broken make sure to remove the platform file # since Windows-cl configures both c/cxx files both need to be removed # when c or c++ fails @@ -51,14 +51,14 @@ IF(NOT CMAKE_C_COMPILER_WORKS) FILE(REMOVE ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake ) MESSAGE(FATAL_ERROR "The C compiler \"${CMAKE_C_COMPILER}\" " "is not able to compile a simple test program.\nIt fails " - "with the following output:\n ${OUTPUT}\n\n" + "with the following output:\n ${__CMAKE_C_COMPILER_OUTPUT}\n\n" "CMake will not be able to correctly generate this project.") ELSE(NOT CMAKE_C_COMPILER_WORKS) IF(C_TEST_WAS_RUN) PrintTestCompilerStatus("C" " -- works") FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the C compiler works passed with " - "the following output:\n${OUTPUT}\n\n") + "the following output:\n${__CMAKE_C_COMPILER_OUTPUT}\n\n") ENDIF(C_TEST_WAS_RUN) SET(CMAKE_C_COMPILER_WORKS 1 CACHE INTERNAL "") @@ -76,5 +76,12 @@ ELSE(NOT CMAKE_C_COMPILER_WORKS) ) INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCCompiler.cmake) ENDIF(CMAKE_C_COMPILER_FORCED) + IF(CMAKE_C_SIZEOF_DATA_PTR) + FOREACH(f ${CMAKE_C_ABI_FILES}) + INCLUDE(${f}) + ENDFOREACH() + UNSET(CMAKE_C_ABI_FILES) + ENDIF() ENDIF(NOT CMAKE_C_COMPILER_WORKS) +UNSET(__CMAKE_C_COMPILER_OUTPUT) diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index c1a3b3a10..87022e9f9 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -28,7 +28,7 @@ IF(NOT CMAKE_CXX_COMPILER_WORKS) "int main(){return 0;}\n") TRY_COMPILE(CMAKE_CXX_COMPILER_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx - OUTPUT_VARIABLE OUTPUT) + OUTPUT_VARIABLE __CMAKE_CXX_COMPILER_OUTPUT) SET(CXX_TEST_WAS_RUN 1) ENDIF(NOT CMAKE_CXX_COMPILER_WORKS) @@ -41,17 +41,17 @@ IF(NOT CMAKE_CXX_COMPILER_WORKS) FILE(REMOVE ${CMAKE_PLATFORM_ROOT_BIN}/CMakeCXXPlatform.cmake ) FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the CXX compiler works failed with " - "the following output:\n${OUTPUT}\n\n") + "the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n") MESSAGE(FATAL_ERROR "The C++ compiler \"${CMAKE_CXX_COMPILER}\" " "is not able to compile a simple test program.\nIt fails " - "with the following output:\n ${OUTPUT}\n\n" + "with the following output:\n ${__CMAKE_CXX_COMPILER_OUTPUT}\n\n" "CMake will not be able to correctly generate this project.") ELSE(NOT CMAKE_CXX_COMPILER_WORKS) IF(CXX_TEST_WAS_RUN) PrintTestCompilerStatus("CXX" " -- works") FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the CXX compiler works passed with " - "the following output:\n${OUTPUT}\n\n") + "the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n") ENDIF(CXX_TEST_WAS_RUN) SET(CMAKE_CXX_COMPILER_WORKS 1 CACHE INTERNAL "") @@ -69,4 +69,12 @@ ELSE(NOT CMAKE_CXX_COMPILER_WORKS) ) INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCXXCompiler.cmake) ENDIF(CMAKE_CXX_COMPILER_FORCED) + IF(CMAKE_CXX_SIZEOF_DATA_PTR) + FOREACH(f ${CMAKE_CXX_ABI_FILES}) + INCLUDE(${f}) + ENDFOREACH() + UNSET(CMAKE_CXX_ABI_FILES) + ENDIF() ENDIF(NOT CMAKE_CXX_COMPILER_WORKS) + +UNSET(__CMAKE_CXX_COMPILER_OUTPUT) diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index 33f62eb50..b4dcea634 100644 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -92,4 +92,10 @@ ELSE(NOT CMAKE_Fortran_COMPILER_WORKS) ) INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeFortranCompiler.cmake) ENDIF(CMAKE_Fortran_COMPILER_FORCED) + IF(CMAKE_Fortran_SIZEOF_DATA_PTR) + FOREACH(f ${CMAKE_Fortran_ABI_FILES}) + INCLUDE(${f}) + ENDFOREACH() + UNSET(CMAKE_Fortran_ABI_FILES) + ENDIF() ENDIF(NOT CMAKE_Fortran_COMPILER_WORKS) diff --git a/Modules/CMakeTestWatcomVersion.c b/Modules/CMakeTestWatcomVersion.c new file mode 100644 index 000000000..0343fb127 --- /dev/null +++ b/Modules/CMakeTestWatcomVersion.c @@ -0,0 +1 @@ +VERSION=__WATCOMC__ diff --git a/Modules/CMakeVS10FindMake.cmake b/Modules/CMakeVS10FindMake.cmake index 388203cab..695e92f52 100644 --- a/Modules/CMakeVS10FindMake.cmake +++ b/Modules/CMakeVS10FindMake.cmake @@ -12,14 +12,11 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -# VCExpress does not support cross compiling, which is necessary for Win CE -SET( _CMAKE_MAKE_PROGRAM_NAMES devenv) -IF(NOT CMAKE_CROSSCOMPILING) - SET( _CMAKE_MAKE_PROGRAM_NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} VCExpress) -ENDIF(NOT CMAKE_CROSSCOMPILING) - +# Look for devenv as a build program. We need to use this to support +# Intel Fortran integration into VS. MSBuild can not be used for that case +# since Intel Fortran uses the older devenv file format. FIND_PROGRAM(CMAKE_MAKE_PROGRAM - NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} + NAMES devenv HINTS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VS;EnvironmentDirectory] [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup;Dbghelp_path] @@ -34,6 +31,24 @@ FIND_PROGRAM(CMAKE_MAKE_PROGRAM "/Program Files/Microsoft Visual Studio 10.0/Common7/IDE/" "/Program Files/Microsoft Visual Studio 10/Common7/IDE/" ) + +# if devenv is not found, then use MSBuild. +# it is expected that if devenv is not found, then we are +# dealing with Visual Studio Express. VCExpress has random +# failures when being run as a command line build tool which +# causes the compiler checks and try-compile stuff to fail. MSbuild +# is a better choice for this. However, VCExpress does not support +# cross compiling needed for Win CE. +IF(NOT CMAKE_CROSSCOMPILING) + FIND_PROGRAM(CMAKE_MAKE_PROGRAM + NAMES MSBuild + HINTS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VS;ProductDir] + "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;CLR Version]/" + "c:/WINDOWS/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;CLR Version]/" + "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\10.0;CLR Version]/") +ENDIF() + MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) SET(MSVC10 1) SET(MSVC_VERSION 1600) diff --git a/Modules/CMakeVS11FindMake.cmake b/Modules/CMakeVS11FindMake.cmake new file mode 100644 index 000000000..302efaa59 --- /dev/null +++ b/Modules/CMakeVS11FindMake.cmake @@ -0,0 +1,54 @@ + +#============================================================================= +# Copyright 2007-2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# Look for devenv as a build program. We need to use this to support +# Intel Fortran integration into VS. MSBuild can not be used for that case +# since Intel Fortran uses the older devenv file format. +FIND_PROGRAM(CMAKE_MAKE_PROGRAM + NAMES devenv + HINTS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VS;EnvironmentDirectory] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup;Dbghelp_path] + "$ENV{ProgramFiles}/Microsoft Visual Studio 11.0/Common7/IDE" + "$ENV{ProgramFiles}/Microsoft Visual Studio11.0/Common7/IDE" + "$ENV{ProgramFiles}/Microsoft Visual Studio 11/Common7/IDE" + "$ENV{ProgramFiles}/Microsoft Visual Studio11/Common7/IDE" + "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 11.0/Common7/IDE" + "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio11.0/Common7/IDE" + "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 11/Common7/IDE" + "$ENV{ProgramFiles} (x86)/Microsoft Visual Studio11/Common7/IDE" + "/Program Files/Microsoft Visual Studio 11.0/Common7/IDE/" + "/Program Files/Microsoft Visual Studio 11/Common7/IDE/" + ) + +# if devenv is not found, then use MSBuild. +# it is expected that if devenv is not found, then we are +# dealing with Visual Studio Express. VCExpress has random +# failures when being run as a command line build tool which +# causes the compiler checks and try-compile stuff to fail. MSbuild +# is a better choice for this. However, VCExpress does not support +# cross compiling needed for Win CE. +IF(NOT CMAKE_CROSSCOMPILING) + FIND_PROGRAM(CMAKE_MAKE_PROGRAM + NAMES MSBuild + HINTS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VS;ProductDir] + "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;CLR Version]/" + "c:/WINDOWS/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0;CLR Version]/" + "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\11.0;CLR Version]/") +ENDIF() + +MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) +SET(MSVC11 1) +SET(MSVC_VERSION 1700) diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index bf52b2526..2cc27cf11 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -215,7 +215,7 @@ # # CPACK_INSTALL_COMMANDS - Extra commands to install components. # -# CPACK_INSTALL_DIRECTORIES - Extra directories to install. +# CPACK_INSTALLED_DIRECTORIES - Extra directories to install. # #============================================================================= @@ -322,7 +322,7 @@ cpack_set_if_not_set(CPACK_PACKAGE_FILE_NAME cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY - "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}") + "${CPACK_PACKAGE_INSTALL_DIRECTORY}") cpack_set_if_not_set(CPACK_PACKAGE_DEFAULT_LOCATION "/") cpack_set_if_not_set(CPACK_PACKAGE_RELOCATABLE "true") diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index 90c80a4dc..26433bb97 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -20,7 +20,7 @@ # Mandatory : YES # Default : CPACK_PACKAGE_VERSION # The debian package version -# CPACK_DEBIAN_PACKAGE_ARCHITECTURE) +# CPACK_DEBIAN_PACKAGE_ARCHITECTURE # Mandatory : YES # Default : Output of dpkg --print-architecture (or i386 if dpkg is not found) # The debian package architecture @@ -133,6 +133,11 @@ IF(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS) SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) ENDIF(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS) +FIND_PROGRAM(FAKEROOT_EXECUTABLE fakeroot) +IF(FAKEROOT_EXECUTABLE) + SET(CPACK_DEBIAN_FAKEROOT_EXECUTABLE ${FAKEROOT_EXECUTABLE}) +ENDIF(FAKEROOT_EXECUTABLE) + IF(CPACK_DEBIAN_PACKAGE_SHLIBDEPS) # dpkg-shlibdeps is a Debian utility for generating dependency list FIND_PROGRAM(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps) diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 729d8dfbc..bf476ad89 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -4,7 +4,12 @@ # used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration # # However CPackRPM has specific features which are controlled by -# the specifics CPACK_RPM_XXX variables. +# the specifics CPACK_RPM_XXX variables. CPackRPM is a component aware +# generator so when CPACK_RPM_COMPONENT_INSTALL is ON some more +# CPACK_RPM__XXXX variables may be used in order +# to have component specific values. Note however that +# refers to the **grouping name**. This may be either a component name +# or a component GROUP name. # Usually those vars correspond to RPM spec file entities, one may find # information about spec files here http://www.rpm.org/wiki/Docs. # You'll find a detailed usage of CPackRPM on the wiki: @@ -98,9 +103,11 @@ # If CPACK_SET_DESTDIR is set then you will get a warning message # but if there is file installed with absolute path you'll get # unexpected behavior. -# CPACK_RPM_SPEC_INSTALL_POST +# CPACK_RPM_SPEC_INSTALL_POST [deprecated] # Mandatory : NO # Default : - +# This way of specifying post-install script is deprecated use +# CPACK_RPM_POST_INSTALL_SCRIPT_FILE # May be used to set an RPM post-install command inside the spec file. # For example setting it to "/bin/true" may be used to prevent # rpmbuild to strip binaries. @@ -132,25 +139,42 @@ # CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE # Mandatory : NO # Default : - -# May be used to embbed a pre (un)installation script in the spec file. +# May be used to embed a pre (un)installation script in the spec file. # The refered script file(s) will be read and directly # put after the %pre or %preun section +# If CPACK_RPM_COMPONENT_INSTALL is set to ON the (un)install script for +# each component can be overriden with +# CPACK_RPM__PRE_INSTALL_SCRIPT_FILE and +# CPACK_RPM__PRE_UNINSTALL_SCRIPT_FILE # One may verify which scriptlet has been included with # rpm -qp --scripts package.rpm # CPACK_RPM_POST_INSTALL_SCRIPT_FILE # CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE # Mandatory : NO # Default : - -# May be used to embbed a post (un)installation script in the spec file. +# May be used to embed a post (un)installation script in the spec file. # The refered script file(s) will be read and directly # put after the %post or %postun section +# If CPACK_RPM_COMPONENT_INSTALL is set to ON the (un)install script for +# each component can be overriden with +# CPACK_RPM__POST_INSTALL_SCRIPT_FILE and +# CPACK_RPM__POST_UNINSTALL_SCRIPT_FILE # One may verify which scriptlet has been included with # rpm -qp --scripts package.rpm +# CPACK_RPM_USER_FILELIST +# CPACK_RPM__USER_FILELIST +# Mandatory : NO +# Default : - +# May be used to explicitely specify %() file line +# in the spec file. Like %config(noreplace) or any other directive +# that be found in the %files section. Since CPackRPM is generating +# the list of files (and directories) the user specified files of +# the CPACK_RPM__USER_FILELIST list will be removed from the generated list. # CPACK_RPM_CHANGELOG_FILE # Mandatory : NO # Default : - -# May be used to embbed a changelog in the spec file. -# The refered file will be read and directly put after the %changelog +# May be used to embed a changelog in the spec file. +# The refered file will be read and directly put after the %changelog # section. #============================================================================= @@ -237,6 +261,17 @@ IF(ALIEN_EXECUTABLE) MESSAGE(STATUS "alien found, we may be on a Debian based distro.") ENDIF(ALIEN_EXECUTABLE) +# Are we packaging components ? +IF(CPACK_RPM_PACKAGE_COMPONENT) + SET(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}") + SET(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "/${CPACK_RPM_PACKAGE_COMPONENT}") + SET(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${CPACK_RPM_PACKAGE_COMPONENT}") +ELSE(CPACK_RPM_PACKAGE_COMPONENT) + SET(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "") + SET(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "") + SET(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}") +ENDIF(CPACK_RPM_PACKAGE_COMPONENT) + # # Use user-defined RPM specific variables value # or generate reasonable default value from @@ -369,9 +404,33 @@ if(CPACK_RPM_PACKAGE_RELOCATABLE) endif(CPACK_SET_DESTDIR AND (NOT CPACK_SET_DESTDIR STREQUAL "I_ON")) endif(CPACK_RPM_PACKAGE_RELOCATABLE) -# check if additional fields for RPM spec header are given +# Check if additional fields for RPM spec header are given +# There may be some COMPONENT specific variables as well FOREACH(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV) - IF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) + IF(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: processing ${_RPM_SPEC_HEADER}") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) + if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}) + IF(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: using CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) + set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER}}) + else() + IF(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${_RPM_SPEC_HEADER} not defined") + message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) + set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) + endif() + else() + IF(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: using CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) + set(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}) + endif() + + IF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) STRING(LENGTH ${_RPM_SPEC_HEADER} _PACKAGE_HEADER_STRLENGTH) MATH(EXPR _PACKAGE_HEADER_STRLENGTH "${_PACKAGE_HEADER_STRLENGTH} - 1") STRING(SUBSTRING ${_RPM_SPEC_HEADER} 1 ${_PACKAGE_HEADER_STRLENGTH} _PACKAGE_HEADER_TAIL) @@ -379,10 +438,10 @@ FOREACH(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLIC STRING(SUBSTRING ${_RPM_SPEC_HEADER} 0 1 _PACKAGE_HEADER_NAME) SET(_PACKAGE_HEADER_NAME "${_PACKAGE_HEADER_NAME}${_PACKAGE_HEADER_TAIL}") IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}") + MESSAGE("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") ENDIF(CPACK_RPM_PACKAGE_DEBUG) - SET(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}}") - ENDIF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) + SET(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") +ENDIF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) ENDFOREACH(_RPM_SPEC_HEADER) # CPACK_RPM_SPEC_INSTALL_POST @@ -396,47 +455,99 @@ 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_POST_INSTALL_SCRIPT_FILE -# CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE -# May be used to embbed a post (un)installation script in the spec file. +# CPACK_RPM_POST_INSTALL_SCRIPT_FILE (or CPACK_RPM__POST_INSTALL_SCRIPT_FILE) +# CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE (or CPACK_RPM__POST_UNINSTALL_SCRIPT_FILE) +# May be used to embed a post (un)installation script in the spec file. # The refered script file(s) will be read and directly # put after the %post or %postun section -if(CPACK_RPM_POST_INSTALL_SCRIPT_FILE) - if(EXISTS ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) - file(READ ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE} CPACK_RPM_SPEC_POSTINSTALL) - else(EXISTS ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) - message("CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE <${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}> does not exists - ignoring") - endif(EXISTS ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) -endif(CPACK_RPM_POST_INSTALL_SCRIPT_FILE) - -if(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE) - if(EXISTS ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) - file(READ ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE} CPACK_RPM_SPEC_POSTUNINSTALL) - else(EXISTS ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) - message("CPackRPM:Warning: CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}> does not exists - ignoring") - endif(EXISTS ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) -endif(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE) - -# CPACK_RPM_PRE_INSTALL_SCRIPT_FILE -# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE +if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_INSTALL_SCRIPT_FILE) + set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_INSTALL_SCRIPT_FILE}) + else() + set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) + endif() + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE) + set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE}) + else(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE) + set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) + endif(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_POST_UNINSTALL_SCRIPT_FILE) +else(CPACK_RPM_PACKAGE_COMPONENT) + set(CPACK_RPM_POST_INSTALL_READ_FILE ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE}) + set(CPACK_RPM_POST_UNINSTALL_READ_FILE ${CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE}) +endif(CPACK_RPM_PACKAGE_COMPONENT) + +# Handle post-install file if it has been specified +if(CPACK_RPM_POST_INSTALL_READ_FILE) + if(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE}) + file(READ ${CPACK_RPM_POST_INSTALL_READ_FILE} CPACK_RPM_SPEC_POSTINSTALL) + else(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE}) + message("CPackRPM:Warning: CPACK_RPM_POST_INSTALL_SCRIPT_FILE <${CPACK_RPM_POST_INSTALL_READ_FILE}> does not exists - ignoring") + endif(EXISTS ${CPACK_RPM_POST_INSTALL_READ_FILE}) +else(CPACK_RPM_POST_INSTALL_READ_FILE) + # reset SPEC var value if no post install file has been specified + # (either globally or component-wise) + set(CPACK_RPM_SPEC_POSTINSTALL "") +endif(CPACK_RPM_POST_INSTALL_READ_FILE) + +# Handle post-uninstall file if it has been specified +if(CPACK_RPM_POST_UNINSTALL_READ_FILE) + if(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE}) + file(READ ${CPACK_RPM_POST_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_POSTUNINSTALL) + else(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE}) + message("CPackRPM:Warning: CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_POST_UNINSTALL_READ_FILE}> does not exists - ignoring") + endif(EXISTS ${CPACK_RPM_POST_UNINSTALL_READ_FILE}) +else(CPACK_RPM_POST_UNINSTALL_READ_FILE) + # reset SPEC var value if no post uninstall file has been specified + # (either globally or component-wise) + set(CPACK_RPM_SPEC_POSTUNINSTALL "") +endif(CPACK_RPM_POST_UNINSTALL_READ_FILE) + +# CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM__PRE_INSTALL_SCRIPT_FILE) +# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE (or CPACK_RPM__PRE_UNINSTALL_SCRIPT_FILE) # May be used to embed a pre (un)installation script in the spec file. # The refered script file(s) will be read and directly # put after the %pre or %preun section -if(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE) - if(EXISTS ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) - file(READ ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE} CPACK_RPM_SPEC_PREINSTALL) - else(EXISTS ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) - message("CPackRPM:Warning: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}> does not exists - ignoring") - endif(EXISTS ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) -endif(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE) - -if(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE) - if(EXISTS ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) - file(READ ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE} CPACK_RPM_SPEC_PREUNINSTALL) - else(EXISTS ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) - message("CPackRPM:Warning: CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}> does not exists - ignoring") - endif(EXISTS ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) -endif(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE) +if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE) + set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE}) + else(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE) + set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) + endif(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_INSTALL_SCRIPT_FILE) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE) + set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE}) + else(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE) + set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) + endif(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PRE_UNINSTALL_SCRIPT_FILE) +else(CPACK_RPM_PACKAGE_COMPONENT) + set(CPACK_RPM_PRE_INSTALL_READ_FILE ${CPACK_RPM_PRE_INSTALL_SCRIPT_FILE}) + set(CPACK_RPM_PRE_UNINSTALL_READ_FILE ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) +endif(CPACK_RPM_PACKAGE_COMPONENT) + +# Handle pre-install file if it has been specified +if(CPACK_RPM_PRE_INSTALL_READ_FILE) + if(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE}) + file(READ ${CPACK_RPM_PRE_INSTALL_READ_FILE} CPACK_RPM_SPEC_PREINSTALL) + else(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE}) + message("CPackRPM:Warning: CPACK_RPM_PRE_INSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_INSTALL_READ_FILE}> does not exists - ignoring") + endif(EXISTS ${CPACK_RPM_PRE_INSTALL_READ_FILE}) +else(CPACK_RPM_PRE_INSTALL_READ_FILE) + # reset SPEC var value if no pre-install file has been specified + # (either globally or component-wise) + set(CPACK_RPM_SPEC_PREINSTALL "") +endif(CPACK_RPM_PRE_INSTALL_READ_FILE) + +# Handle pre-uninstall file if it has been specified +if(CPACK_RPM_PRE_UNINSTALL_READ_FILE) + if(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE}) + file(READ ${CPACK_RPM_PRE_UNINSTALL_READ_FILE} CPACK_RPM_SPEC_PREUNINSTALL) + else(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE}) + message("CPackRPM:Warning: CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE <${CPACK_RPM_PRE_UNINSTALL_READ_FILE}> does not exists - ignoring") + endif(EXISTS ${CPACK_RPM_PRE_UNINSTALL_READ_FILE}) +else(CPACK_RPM_PRE_UNINSTALL_READ_FILE) + # reset SPEC var value if no pre-uninstall file has been specified + # (either globally or component-wise) + set(CPACK_RPM_SPEC_PREUNINSTALL "") +endif(CPACK_RPM_PRE_UNINSTALL_READ_FILE) # CPACK_RPM_CHANGELOG_FILE # May be used to embed a changelog in the spec file. @@ -478,46 +589,103 @@ SET(CPACK_RPM_FILE_NAME "${CPACK_OUTPUT_FILE_NAME}") #STRING(REGEX REPLACE " " "\\\\ " CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") SET(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") - -# Are we packaging components ? -IF(CPACK_RPM_PACKAGE_COMPONENT) - SET(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "-${CPACK_RPM_PACKAGE_COMPONENT}") - SET(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "/${CPACK_RPM_PACKAGE_COMPONENT}") - SET(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/${CPACK_RPM_PACKAGE_COMPONENT}") -ELSE(CPACK_RPM_PACKAGE_COMPONENT) - SET(CPACK_RPM_PACKAGE_COMPONENT_PART_NAME "") - SET(CPACK_RPM_PACKAGE_COMPONENT_PART_PATH "") - SET(WDIR "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}") -ENDIF(CPACK_RPM_PACKAGE_COMPONENT) # Use files tree to construct files command (spec file) # We should not forget to include symlinks (thus -o -type l) +# We should include directory as well (thus -type d) +# but not the main local dir "." (thus -a -not -name ".") # We must remove the './' due to the local search and escape the # file name by enclosing it between double quotes (thus the sed) # Then we must authorize any man pages extension (adding * at the end) # because rpmbuild may automatically compress those files -EXECUTE_PROCESS(COMMAND find . -type f -o -type l +EXECUTE_PROCESS(COMMAND find . -type f -o -type l -o (-type d -a -not -name ".") COMMAND sed s:.*/man.*/.*:&*: COMMAND sed s/\\.\\\(.*\\\)/\"\\1\"/ WORKING_DIRECTORY "${WDIR}" OUTPUT_VARIABLE CPACK_RPM_INSTALL_FILES) -# In component case, replace CPACK_ABSOLUTE_DESTINATION_FILES -# with the content of CPACK_ABSOLUTE_DESTINATION_FILES_ -# This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES handling +# In component case, put CPACK_ABSOLUTE_DESTINATION_FILES_ +# into CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL +# otherwise, put CPACK_ABSOLUTE_DESTINATION_FILES +# This must be done BEFORE the CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL handling if(CPACK_RPM_PACKAGE_COMPONENT) if(CPACK_ABSOLUTE_DESTINATION_FILES) set(COMPONENT_FILES_TAG "CPACK_ABSOLUTE_DESTINATION_FILES_${CPACK_RPM_PACKAGE_COMPONENT}") - set(CPACK_ABSOLUTE_DESTINATION_FILES "${${COMPONENT_FILES_TAG}}") + set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${${COMPONENT_FILES_TAG}}") if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: Handling Absolute Destination Files ${CPACK_ABSOLUTE_DESTINATION_FILES}") + message("CPackRPM:Debug: Handling Absolute Destination Files: <${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}>") message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") endif(CPACK_RPM_PACKAGE_DEBUG) endif() +else() + if(CPACK_ABSOLUTE_DESTINATION_FILES) + set(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL "${CPACK_ABSOLUTE_DESTINATION_FILES}") + endif() +endif() + +# In component case, set CPACK_RPM_USER_FILELIST_INTERNAL with CPACK_RPM__USER_FILELIST. +if(CPACK_RPM_PACKAGE_COMPONENT) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST) + set(CPACK_RPM_USER_FILELIST_INTERNAL ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_USER_FILELIST}) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>") + message("CPackRPM:Debug: in component = ${CPACK_RPM_PACKAGE_COMPONENT}") + endif(CPACK_RPM_PACKAGE_DEBUG) + else() + set(CPACK_RPM_USER_FILELIST_INTERNAL "") + endif() +else() + if(CPACK_RPM_USER_FILELIST) + set(CPACK_RPM_USER_FILELIST_INTERNAL "${CPACK_RPM_USER_FILELIST}") + else() + set(CPACK_RPM_USER_FILELIST_INTERNAL "") + endif() +endif() + +# Handle user specified file line list in CPACK_RPM_USER_FILELIST_INTERNAL +# Remove those files from CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL +# or CPACK_RPM_INSTALL_FILES, +# hence it must be done before these auto-generated lists are processed. +if(CPACK_RPM_USER_FILELIST_INTERNAL) + IF(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Handling User Filelist: <${CPACK_RPM_USER_FILELIST_INTERNAL}>") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) + + # Create CMake list from CPACK_RPM_INSTALL_FILES + string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST) + string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST + "${CPACK_RPM_INSTALL_FILES_LIST}") + string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST + "${CPACK_RPM_INSTALL_FILES_LIST}") + + set(CPACK_RPM_USER_INSTALL_FILES "") + foreach(F IN LISTS CPACK_RPM_USER_FILELIST_INTERNAL) + string(REGEX REPLACE "%[A-Za-z\(\)]* " "" F_PATH ${F}) + string(REGEX MATCH "%[A-Za-z\(\)]*" F_PREFIX ${F}) + + if(F_PREFIX) + set(F_PREFIX "${F_PREFIX} ") + endif() + # Rebuild the user list file + set(CPACK_RPM_USER_INSTALL_FILES "${CPACK_RPM_USER_INSTALL_FILES}${F_PREFIX}\"${F_PATH}\"\n") + + # Remove from CPACK_RPM_INSTALL_FILES and CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL + list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${F_PATH}) + list(REMOVE_ITEM CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL ${F_PATH}) + + endforeach() + + # Rebuild CPACK_RPM_INSTALL_FILES + set(CPACK_RPM_INSTALL_FILES "") + foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST) + set(CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES}\"${F}\"\n") + endforeach(F) +else() + set(CPACK_RPM_USER_INSTALL_FILES "") endif() -if (CPACK_ABSOLUTE_DESTINATION_FILES) +if (CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) IF(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: Handling Absolute Destination Files: ${CPACK_ABSOLUTE_DESTINATION_FILES}") + message("CPackRPM:Debug: Handling Absolute Destination Files: ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}") ENDIF(CPACK_RPM_PACKAGE_DEBUG) # Remove trailing space string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST) @@ -526,7 +694,7 @@ if (CPACK_ABSOLUTE_DESTINATION_FILES) # Remove unecessary quotes string(REPLACE "\"" "" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}") # Remove ABSOLUTE install file from INSTALL FILE LIST - list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${CPACK_ABSOLUTE_DESTINATION_FILES}) + list(REMOVE_ITEM CPACK_RPM_INSTALL_FILES_LIST ${CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL}) # Rebuild INSTALL_FILES set(CPACK_RPM_INSTALL_FILES "") foreach(F IN LISTS CPACK_RPM_INSTALL_FILES_LIST) @@ -534,14 +702,17 @@ if (CPACK_ABSOLUTE_DESTINATION_FILES) endforeach(F) # Build ABSOLUTE_INSTALL_FILES set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "") - foreach(F IN LISTS CPACK_ABSOLUTE_DESTINATION_FILES) + foreach(F IN LISTS CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "${CPACK_RPM_ABSOLUTE_INSTALL_FILES}%config \"${F}\"\n") endforeach(F) IF(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: CPACK_RPM_ABSOLUTE_INSTALL_FILES=${CPACK_RPM_ABSOLUTE_INSTALL_FILES}") message("CPackRPM:Debug: CPACK_RPM_INSTALL_FILES=${CPACK_RPM_INSTALL_FILES}") ENDIF(CPACK_RPM_PACKAGE_DEBUG) -endif(CPACK_ABSOLUTE_DESTINATION_FILES) +else() + # reset vars in order to avoid leakage of value(s) from one component to another + set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "") +endif(CPACK_ABSOLUTE_DESTINATION_FILES_INTERNAL) # The name of the final spec file to be used by rpmbuild SET(CPACK_RPM_BINARY_SPECFILE "${CPACK_RPM_ROOTDIR}/SPECS/${CPACK_RPM_PACKAGE_NAME}${CPACK_RPM_PACKAGE_COMPONENT_PART_NAME}.spec") @@ -569,7 +740,7 @@ IF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY "# -*- rpm-spec -*- BuildRoot: \@CPACK_RPM_DIRECTORY\@/\@CPACK_PACKAGE_FILE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_PATH\@ Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ -Name: \@CPACK_RPM_PACKAGE_NAME\@ +Name: \@CPACK_RPM_PACKAGE_NAME\@\@CPACK_RPM_PACKAGE_COMPONENT_PART_NAME\@ Version: \@CPACK_RPM_PACKAGE_VERSION\@ Release: \@CPACK_RPM_PACKAGE_RELEASE\@ License: \@CPACK_RPM_PACKAGE_LICENSE\@ @@ -631,6 +802,7 @@ mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT %defattr(-,root,root,-) ${CPACK_RPM_INSTALL_FILES} ${CPACK_RPM_ABSOLUTE_INSTALL_FILES} +${CPACK_RPM_USER_INSTALL_FILES} %changelog \@CPACK_RPM_SPEC_CHANGELOG\@ diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake index c261eb385..ec9dbeb79 100644 --- a/Modules/CTest.cmake +++ b/Modules/CTest.cmake @@ -189,6 +189,8 @@ IF(BUILD_TESTING) FIND_PROGRAM(COVERAGE_COMMAND gcov DOC "Path to the coverage program that CTest uses for performing coverage inspection" ) + SET(COVERAGE_EXTRA_FLAGS "-l" CACHE STRING + "Extra command line flags to pass to the coverage tool") # set the site name SITE_NAME(SITE) @@ -257,6 +259,7 @@ IF(BUILD_TESTING) BZRCOMMAND BZR_UPDATE_OPTIONS COVERAGE_COMMAND + COVERAGE_EXTRA_FLAGS CTEST_SUBMIT_RETRY_DELAY CTEST_SUBMIT_RETRY_COUNT CVSCOMMAND diff --git a/Modules/CheckCCompilerFlag.cmake b/Modules/CheckCCompilerFlag.cmake index a03b64d56..ec0a773e3 100644 --- a/Modules/CheckCCompilerFlag.cmake +++ b/Modules/CheckCCompilerFlag.cmake @@ -27,7 +27,10 @@ MACRO (CHECK_C_COMPILER_FLAG _FLAG _RESULT) SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${_RESULT} # Some compilers do not fail with a bad flag + FAIL_REGEX "warning: command line option .* is valid for .* but not for C" + # Apple gcc FAIL_REGEX "unrecognized .*option" # GNU + FAIL_REGEX "unknown .*option" # Clang FAIL_REGEX "ignoring unknown option" # MSVC FAIL_REGEX "warning D9002" # MSVC, any lang FAIL_REGEX "[Uu]nknown option" # HP @@ -36,4 +39,3 @@ MACRO (CHECK_C_COMPILER_FLAG _FLAG _RESULT) ) SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") ENDMACRO (CHECK_C_COMPILER_FLAG) - diff --git a/Modules/CheckCXXCompilerFlag.cmake b/Modules/CheckCXXCompilerFlag.cmake index 788bf35b4..3da04b478 100644 --- a/Modules/CheckCXXCompilerFlag.cmake +++ b/Modules/CheckCXXCompilerFlag.cmake @@ -28,11 +28,14 @@ MACRO (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT) CHECK_CXX_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT} # Some compilers do not fail with a bad flag FAIL_REGEX "unrecognized .*option" # GNU + FAIL_REGEX "unknown .*option" # Clang FAIL_REGEX "ignoring unknown option" # MSVC FAIL_REGEX "warning D9002" # MSVC, any lang FAIL_REGEX "[Uu]nknown option" # HP FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro FAIL_REGEX "command option .* is not recognized" # XL + FAIL_REGEX "not supported in this configuration; ignored" # AIX + FAIL_REGEX "File with unknown suffix passed to linker" # PGI ) SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") ENDMACRO (CHECK_CXX_COMPILER_FLAG) diff --git a/Modules/CheckCXXSymbolExists.cmake b/Modules/CheckCXXSymbolExists.cmake new file mode 100644 index 000000000..1b012aefd --- /dev/null +++ b/Modules/CheckCXXSymbolExists.cmake @@ -0,0 +1,42 @@ +# - Check if a symbol exists as a function, variable, or macro in C++ +# CHECK_CXX_SYMBOL_EXISTS( ) +# +# Check that the is available after including given header +# and store the result in a . Specify the list +# of files in one argument as a semicolon-separated list. +# CHECK_CXX_SYMBOL_EXISTS() can be used to check in C++ files, as opposed +# to CHECK_SYMBOL_EXISTS(), which works only for C. +# +# If the header files define the symbol as a macro it is considered +# available and assumed to work. If the header files declare the +# symbol as a function or variable then the symbol must also be +# available for linking. If the symbol is a type or enum value +# it will not be recognized (consider using CheckTypeSize or +# CheckCSourceCompiles). +# +# The following variables may be set before calling this macro to +# modify the way the check is run: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link + +#============================================================================= +# Copyright 2003-2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +INCLUDE(CheckSymbolExists) + +MACRO(CHECK_CXX_SYMBOL_EXISTS SYMBOL FILES VARIABLE) + _CHECK_SYMBOL_EXISTS("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.cxx" "${SYMBOL}" "${FILES}" "${VARIABLE}" ) +ENDMACRO(CHECK_CXX_SYMBOL_EXISTS) diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index e86604bef..183b2bbe6 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -11,6 +11,8 @@ # available for linking. If the symbol is a type or enum value # it will not be recognized (consider using CheckTypeSize or # CheckCSourceCompiles). +# If the check needs to be done in C++, consider using CHECK_CXX_SYMBOL_EXISTS(), +# which does the same as CHECK_SYMBOL_EXISTS(), but in C++. # # The following variables may be set before calling this macro to # modify the way the check is run: @@ -34,11 +36,15 @@ # License text for the above reference.) MACRO(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE) + _CHECK_SYMBOL_EXISTS("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c" "${SYMBOL}" "${FILES}" "${VARIABLE}" ) +ENDMACRO(CHECK_SYMBOL_EXISTS) + +MACRO(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE) IF("${VARIABLE}" MATCHES "^${VARIABLE}$") SET(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n") SET(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS}) IF(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_SYMBOL_EXISTS_LIBS + SET(CHECK_SYMBOL_EXISTS_LIBS "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") ELSE(CMAKE_REQUIRED_LIBRARIES) SET(CHECK_SYMBOL_EXISTS_LIBS) @@ -57,14 +63,14 @@ MACRO(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE) "${CMAKE_CONFIGURABLE_FILE_CONTENT}\nvoid cmakeRequireSymbol(int dummy,...){(void)dummy;}\nint main()\n{\n#ifndef ${SYMBOL}\n cmakeRequireSymbol(0,&${SYMBOL});\n#endif\n return 0;\n}\n") CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c" @ONLY) + "${SOURCEFILE}" @ONLY IMMEDIATE) MESSAGE(STATUS "Looking for ${SYMBOL}") TRY_COMPILE(${VARIABLE} ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c + "${SOURCEFILE}" COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_SYMBOL_EXISTS_FLAGS} "${CHECK_SYMBOL_EXISTS_LIBS}" "${CMAKE_SYMBOL_EXISTS_INCLUDES}" @@ -72,19 +78,19 @@ MACRO(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE) IF(${VARIABLE}) MESSAGE(STATUS "Looking for ${SYMBOL} - found") SET(${VARIABLE} 1 CACHE INTERNAL "Have symbol ${SYMBOL}") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the ${SYMBOL} " "exist passed with the following output:\n" - "${OUTPUT}\nFile ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c:\n" + "${OUTPUT}\nFile ${SOURCEFILE}:\n" "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") ELSE(${VARIABLE}) MESSAGE(STATUS "Looking for ${SYMBOL} - not found.") SET(${VARIABLE} "" CACHE INTERNAL "Have symbol ${SYMBOL}") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the ${SYMBOL} " "exist failed with the following output:\n" - "${OUTPUT}\nFile ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c:\n" + "${OUTPUT}\nFile ${SOURCEFILE}:\n" "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") ENDIF(${VARIABLE}) ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$") -ENDMACRO(CHECK_SYMBOL_EXISTS) +ENDMACRO(_CHECK_SYMBOL_EXISTS) diff --git a/Modules/Compiler/Absoft-Fortran.cmake b/Modules/Compiler/Absoft-Fortran.cmake index bb7d3dc71..1bb7b1f82 100644 --- a/Modules/Compiler/Absoft-Fortran.cmake +++ b/Modules/Compiler/Absoft-Fortran.cmake @@ -6,3 +6,5 @@ SET(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") SET(CMAKE_Fortran_MODDIR_FLAG "-YMOD_OUT_DIR=") SET(CMAKE_Fortran_MODPATH_FLAG "-p") SET(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree") diff --git a/Modules/Compiler/Cray-Fortran.cmake b/Modules/Compiler/Cray-Fortran.cmake index 4f45176d2..5d81bb02c 100644 --- a/Modules/Compiler/Cray-Fortran.cmake +++ b/Modules/Compiler/Cray-Fortran.cmake @@ -2,3 +2,5 @@ set(CMAKE_Fortran_VERBOSE_FLAG "-v") set(CMAKE_Fortran_MODOUT_FLAG -em) set(CMAKE_Fortran_MODDIR_FLAG -J) set(CMAKE_Fortran_MODDIR_DEFAULT .) +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-f fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-f free") diff --git a/Modules/Compiler/G95-Fortran.cmake b/Modules/Compiler/G95-Fortran.cmake index cbd466118..fd84848b4 100644 --- a/Modules/Compiler/G95-Fortran.cmake +++ b/Modules/Compiler/G95-Fortran.cmake @@ -5,3 +5,5 @@ set(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") set(CMAKE_Fortran_MODDIR_FLAG "-fmod=") set(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") diff --git a/Modules/Compiler/GNU-Fortran.cmake b/Modules/Compiler/GNU-Fortran.cmake index 6e0f5f3d5..c710e8698 100644 --- a/Modules/Compiler/GNU-Fortran.cmake +++ b/Modules/Compiler/GNU-Fortran.cmake @@ -1,6 +1,9 @@ include(Compiler/GNU) __compiler_gnu(Fortran) +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form") + # No -DNDEBUG for Fortran. SET(CMAKE_Fortran_FLAGS_MINSIZEREL_INIT "-Os") SET(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") diff --git a/Modules/Compiler/HP-Fortran.cmake b/Modules/Compiler/HP-Fortran.cmake index 7f7c1289a..04fb96ea4 100644 --- a/Modules/Compiler/HP-Fortran.cmake +++ b/Modules/Compiler/HP-Fortran.cmake @@ -1 +1,3 @@ SET(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "+source=fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "+source=free") diff --git a/Modules/Compiler/Intel-Fortran.cmake b/Modules/Compiler/Intel-Fortran.cmake index f38b32e0e..467abdcf5 100644 --- a/Modules/Compiler/Intel-Fortran.cmake +++ b/Modules/Compiler/Intel-Fortran.cmake @@ -5,3 +5,5 @@ SET(CMAKE_Fortran_FLAGS_RELEASE_INIT "-O3") SET(CMAKE_Fortran_FLAGS_RELWITHDEBINFO_INIT "-O2 -g") SET(CMAKE_Fortran_MODDIR_FLAG "-module ") SET(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") diff --git a/Modules/Compiler/MIPSpro-Fortran.cmake b/Modules/Compiler/MIPSpro-Fortran.cmake index 7f7c1289a..9220d3bf0 100644 --- a/Modules/Compiler/MIPSpro-Fortran.cmake +++ b/Modules/Compiler/MIPSpro-Fortran.cmake @@ -1 +1,3 @@ SET(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixedform") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-freeform") diff --git a/Modules/Compiler/NAG-Fortran.cmake b/Modules/Compiler/NAG-Fortran.cmake index b68c47994..9a89746b5 100644 --- a/Modules/Compiler/NAG-Fortran.cmake +++ b/Modules/Compiler/NAG-Fortran.cmake @@ -30,3 +30,5 @@ endif() set(CMAKE_Fortran_MODDIR_FLAG "-mdir ") set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-PIC") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") diff --git a/Modules/Compiler/PGI-Fortran.cmake b/Modules/Compiler/PGI-Fortran.cmake index 1d2631552..aebc7b1c2 100644 --- a/Modules/Compiler/PGI-Fortran.cmake +++ b/Modules/Compiler/PGI-Fortran.cmake @@ -1,6 +1,9 @@ include(Compiler/PGI) __compiler_pgi(Fortran) +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-Mnofreeform") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-Mfreeform") + SET(CMAKE_Fortran_FLAGS_INIT "${CMAKE_Fortran_FLAGS_INIT} -Mpreprocess -Kieee") SET(CMAKE_Fortran_FLAGS_DEBUG_INIT "${CMAKE_Fortran_FLAGS_DEBUG_INIT} -Mbounds") diff --git a/Modules/Compiler/PathScale-Fortran.cmake b/Modules/Compiler/PathScale-Fortran.cmake index 20c9d7efb..e05bf2afc 100644 --- a/Modules/Compiler/PathScale-Fortran.cmake +++ b/Modules/Compiler/PathScale-Fortran.cmake @@ -2,3 +2,5 @@ include(Compiler/PathScale) __compiler_pathscale(Fortran) SET(CMAKE_Fortran_MODDIR_FLAG "-module ") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixedform") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-freeform") diff --git a/Modules/Compiler/SunPro-Fortran.cmake b/Modules/Compiler/SunPro-Fortran.cmake index a41b45456..86d6def34 100644 --- a/Modules/Compiler/SunPro-Fortran.cmake +++ b/Modules/Compiler/SunPro-Fortran.cmake @@ -1,4 +1,6 @@ SET(CMAKE_Fortran_VERBOSE_FLAG "-v") +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed") +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free") SET(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-KPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-G") diff --git a/Modules/Compiler/TinyCC-C.cmake b/Modules/Compiler/TinyCC-C.cmake new file mode 100644 index 000000000..4a48c0af5 --- /dev/null +++ b/Modules/Compiler/TinyCC-C.cmake @@ -0,0 +1,8 @@ +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") + +# no optimization in tcc: +SET (CMAKE_C_FLAGS_INIT "") +SET (CMAKE_C_FLAGS_DEBUG_INIT "-g") +SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-DNDEBUG") +SET (CMAKE_C_FLAGS_RELEASE_INIT "-DNDEBUG") +SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g") diff --git a/Modules/Compiler/XL-Fortran.cmake b/Modules/Compiler/XL-Fortran.cmake index d88b3f32f..e7026f11a 100644 --- a/Modules/Compiler/XL-Fortran.cmake +++ b/Modules/Compiler/XL-Fortran.cmake @@ -1,6 +1,9 @@ include(Compiler/XL) __compiler_xl(Fortran) +set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-qfixed") # [=] +set(CMAKE_Fortran_FORMAT_FREE_FLAG "-qfree") # [=f90|ibm] + SET(CMAKE_Fortran_MODDIR_FLAG "-qmoddir=") SET(CMAKE_Fortran_DEFINE_FLAG "-WF,-D") diff --git a/Modules/Compiler/XL.cmake b/Modules/Compiler/XL.cmake index d07890f39..d2567d513 100644 --- a/Modules/Compiler/XL.cmake +++ b/Modules/Compiler/XL.cmake @@ -35,14 +35,19 @@ macro(__compiler_xl lang) set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE " -E > ") set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE " -S -o ") - # The compiler front-end passes all object files, archive files, and shared - # library files named on the command line to CreateExportList to create a - # list of all symbols to be exported from the shared library. This causes - # all archive members to be copied into the shared library whether they are - # needed or not. Instead we run the tool ourselves to pass only the object - # files so that we export only the symbols actually provided by the sources. - set(CMAKE_${lang}_CREATE_SHARED_LIBRARY - "${CMAKE_XL_CreateExportList} /objects.exp " - " -Wl,-bE:/objects.exp -o " - ) + # CMAKE_XL_CreateExportList is part of the AIX XL compilers but not the linux ones. + # If we found the tool, we'll use it to create exports, otherwise stick with the regular + # create shared library compile line. + if (CMAKE_XL_CreateExportList) + # The compiler front-end passes all object files, archive files, and shared + # library files named on the command line to CreateExportList to create a + # list of all symbols to be exported from the shared library. This causes + # all archive members to be copied into the shared library whether they are + # needed or not. Instead we run the tool ourselves to pass only the object + # files so that we export only the symbols actually provided by the sources. + set(CMAKE_${lang}_CREATE_SHARED_LIBRARY + "${CMAKE_XL_CreateExportList} /objects.exp " + " -Wl,-bE:/objects.exp -o " + ) + endif() endmacro() diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in index caf0afe23..ad7f80517 100644 --- a/Modules/DartConfiguration.tcl.in +++ b/Modules/DartConfiguration.tcl.in @@ -59,14 +59,17 @@ UpdateType: @UPDATE_TYPE@ # Compiler info Compiler: @CMAKE_CXX_COMPILER@ -# Dynamic analysis and coverage +# Dynamic analysis (MemCheck) PurifyCommand: @PURIFYCOMMAND@ ValgrindCommand: @VALGRIND_COMMAND@ ValgrindCommandOptions: @VALGRIND_COMMAND_OPTIONS@ MemoryCheckCommand: @MEMORYCHECK_COMMAND@ MemoryCheckCommandOptions: @MEMORYCHECK_COMMAND_OPTIONS@ MemoryCheckSuppressionFile: @MEMORYCHECK_SUPPRESSIONS_FILE@ + +# Coverage CoverageCommand: @COVERAGE_COMMAND@ +CoverageExtraFlags: @COVERAGE_EXTRA_FLAGS@ # Cluster commands SlurmBatchCommand: @SLURM_SBATCH_COMMAND@ diff --git a/Modules/DeployQt4.cmake b/Modules/DeployQt4.cmake new file mode 100644 index 000000000..83f322c2d --- /dev/null +++ b/Modules/DeployQt4.cmake @@ -0,0 +1,285 @@ +# - Functions to help assemble a standalone Qt4 executable. +# A collection of CMake utility functions useful for deploying +# Qt4 executables. +# +# The following functions are provided by this module: +# write_qt4_conf +# resolve_qt4_paths +# fixup_qt4_executable +# install_qt4_plugin_path +# install_qt4_plugin +# install_qt4_executable +# Requires CMake 2.6 or greater because it uses function and +# PARENT_SCOPE. Also depends on BundleUtilities.cmake. +# +# WRITE_QT4_CONF( ) +# Writes a qt.conf file with the into . +# +# RESOLVE_QT4_PATHS( []) +# Loop through list and if any don't exist resolve them +# relative to the (if supplied) or the CMAKE_INSTALL_PREFIX. +# +# FIXUP_QT4_EXECUTABLE( [ ]) +# Copies Qt plugins, writes a Qt configuration file (if needed) and fixes up a +# Qt4 executable using BundleUtilities so it is standalone and can be +# drag-and-drop copied to another machine as long as all of the system +# libraries are compatible. +# +# should point to the executable to be fixed-up. +# +# should contain a list of the names or paths of any Qt plugins +# to be installed. +# +# will be passed to BundleUtilities and should be a list of any already +# installed plugins, libraries or executables to also be fixed-up. +# +# will be passed to BundleUtilities and should contain and directories +# to be searched to find library dependencies. +# +# allows an custom plugins directory to be used. +# +# will force a qt.conf file to be written even if not needed. +# +# INSTALL_QT4_PLUGIN_PATH(plugin executable copy installed_plugin_path_var ) +# Install (or copy) a resolved to the default plugins directory +# (or ) relative to and store the result in +# . +# +# If is set to TRUE then the plugins will be copied rather than +# installed. This is to allow this module to be used at CMake time rather than +# install time. +# +# If is set then anything installed will use this COMPONENT. +# +# INSTALL_QT4_PLUGIN(plugin executable copy installed_plugin_path_var ) +# Install (or copy) an unresolved to the default plugins directory +# (or ) relative to and store the result in +# . See documentation of INSTALL_QT4_PLUGIN_PATH. +# +# INSTALL_QT4_EXECUTABLE( [ ]) +# Installs Qt plugins, writes a Qt configuration file (if needed) and fixes up +# a Qt4 executable using BundleUtilities so it is standalone and can be +# drag-and-drop copied to another machine as long as all of the system +# libraries are compatible. The executable will be fixed-up at install time. +# is the COMPONENT used for bundle fixup and plugin installation. +# See documentation of FIXUP_QT4_BUNDLE. + +#============================================================================= +# Copyright 2011 Mike McQuaid +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# The functions defined in this file depend on the fixup_bundle function +# (and others) found in BundleUtilities.cmake + +include(BundleUtilities) +set(DeployQt4_cmake_dir "${CMAKE_CURRENT_LIST_DIR}") + +function(write_qt4_conf qt_conf_dir qt_conf_contents) + set(qt_conf_path "${qt_conf_dir}/qt.conf") + message(STATUS "Writing ${qt_conf_path}") + file(WRITE "${qt_conf_path}" "${qt_conf_contents}") +endfunction() + +function(resolve_qt4_paths paths_var) + set(executable_path ${ARGV1}) + + set(paths_resolved) + foreach(path ${${paths_var}}) + if(EXISTS "${path}") + list(APPEND paths_resolved "${path}") + else() + if(${executable_path}) + list(APPEND paths_resolved "${executable_path}/${path}") + else() + list(APPEND paths_resolved "\${CMAKE_INSTALL_PREFIX}/${path}") + endif() + endif() + endforeach() + set(${paths_var} ${paths_resolved} PARENT_SCOPE) +endfunction() + +function(fixup_qt4_executable executable) + set(qtplugins ${ARGV1}) + set(libs ${ARGV2}) + set(dirs ${ARGV3}) + set(plugins_dir ${ARGV4}) + set(request_qt_conf ${ARGV5}) + + message(STATUS "fixup_qt4_executable") + message(STATUS " executable='${executable}'") + message(STATUS " qtplugins='${qtplugins}'") + message(STATUS " libs='${libs}'") + message(STATUS " dirs='${dirs}'") + message(STATUS " plugins_dir='${plugins_dir}'") + message(STATUS " request_qt_conf='${request_qt_conf}'") + + if(QT_LIBRARY_DIR) + list(APPEND dirs "${QT_LIBRARY_DIR}") + endif() + + if(APPLE) + set(qt_conf_dir "${executable}/Contents/Resources") + set(executable_path "${executable}") + set(write_qt_conf TRUE) + else() + get_filename_component(executable_path "${executable}" PATH) + if(NOT executable_path) + set(executable_path ".") + endif() + set(qt_conf_dir "${executable_path}") + set(write_qt_conf ${request_qt_conf}) + endif() + + foreach(plugin ${qtplugins}) + set(installed_plugin_path "") + install_qt4_plugin("${plugin}" "${plugins_dir}" "${executable}" 1 installed_plugin_path) + list(APPEND libs ${installed_plugin_path}) + endforeach() + + foreach(lib ${libs}) + if(NOT EXISTS "${lib}") + message(FATAL_ERROR "Library does not exist: ${lib}") + endif() + endforeach() + + resolve_qt4_paths(libs "${executable_path}") + + if(write_qt_conf) + set(qt_conf_contents "[Paths]\nPlugins = ${plugins_dir}") + write_qt4_conf("${qt_conf_dir}" "${qt_conf_contents}") + endif() + + fixup_bundle("${executable}" "${libs}" "${dirs}") +endfunction() + +function(install_qt4_plugin_path plugin executable copy installed_plugin_path_var) + set(plugins_dir ${ARGV4}) + set(component ${ARGV5}) + set(configurations ${ARGV6}) + if(EXISTS "${plugin}") + if(plugins_dir) + set(plugins_dir "${plugins_dir}") + else() + if(APPLE) + set(plugins_dir "PlugIns") + else() + set(plugins_dir "plugins") + endif() + endif() + if(APPLE) + set(plugins_path "${executable}/Contents/${plugins_dir}") + else() + get_filename_component(executable_path "${executable}" PATH) + if(NOT executable_path) + set(executable_path ".") + endif() + set(plugins_path "${executable_path}/${plugins_dir}") + endif() + + set(plugin_group "") + + get_filename_component(plugin_path "${plugin}" PATH) + get_filename_component(plugin_parent_path "${plugin_path}" PATH) + get_filename_component(plugin_parent_dir_name "${plugin_parent_path}" NAME) + get_filename_component(plugin_name "${plugin}" NAME) + string(TOLOWER "${plugin_parent_dir_name}" plugin_parent_dir_name) + + if("${plugin_parent_dir_name}" STREQUAL "plugins") + get_filename_component(plugin_group "${plugin_path}" NAME) + set(${plugin_group_var} "${plugin_group}") + endif() + set(plugins_path "${plugins_path}/${plugin_group}") + + if(${copy}) + file(MAKE_DIRECTORY "${plugins_path}") + file(COPY "${plugin}" DESTINATION "${plugins_path}") + else() + if(configurations AND (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)) + set(configurations CONFIGURATIONS ${configurations}) + else() + unset(configurations) + endif() + install(FILES "${plugin}" DESTINATION "${plugins_path}" ${configurations} ${component}) + endif() + set(${installed_plugin_path_var} ${${installed_path_var}} "${plugins_path}/${plugin_name}" PARENT_SCOPE) + endif() +endfunction() + +function(install_qt4_plugin plugin executable copy installed_plugin_path_var) + set(plugins_dir ${ARGV4}) + set(component ${ARGV5}) + if(EXISTS "${plugin}") + install_qt4_plugin_path("${plugin}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}") + else() + if(QT_IS_STATIC) + string(TOUPPER "QT_${plugin}_LIBRARY" plugin_var) + else() + string(TOUPPER "QT_${plugin}_PLUGIN" plugin_var) + endif() + set(plugin_release_var "${plugin_var}_RELEASE") + set(plugin_debug_var "${plugin_var}_DEBUG") + set(plugin_release "${${plugin_release_var}}") + set(plugin_debug "${${plugin_debug_var}}") + if(DEFINED "${plugin_release_var}" AND DEFINED "${plugin_debug_var}" AND NOT EXISTS "${plugin_release}" AND NOT EXISTS "${plugin_debug}") + message(WARNING "Qt plugin \"${plugin}\" not recognized or found.") + endif() + install_qt4_plugin_path("${plugin_release}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}" "Release|RelWithDebInfo|MinSizeRel") + install_qt4_plugin_path("${plugin_debug}" "${executable}" "${copy}" "${installed_plugin_path_var}" "${plugins_dir}" "${component}" "Debug") + endif() + set(installed_plugin_path_var "${installed_plugin_path_var}" PARENT_SCOPE) +endfunction() + +function(install_qt4_executable executable) + set(qtplugins ${ARGV1}) + set(libs ${ARGV2}) + set(dirs ${ARGV3}) + set(plugins_dir ${ARGV4}) + set(request_qt_conf ${ARGV5}) + set(component ${ARGV6}) + if(QT_LIBRARY_DIR) + list(APPEND dirs "${QT_LIBRARY_DIR}") + endif() + if(component) + set(component COMPONENT ${component}) + else() + unset(component) + endif() + + get_filename_component(executable_absolute "${executable}" ABSOLUTE) + if(EXISTS "${QT_QTCORE_LIBRARY_RELEASE}") + gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_RELEASE}" qtcore_type) + elseif(EXISTS "${QT_QTCORE_LIBRARY_DEBUG}") + gp_file_type("${executable_absolute}" "${QT_QTCORE_LIBRARY_DEBUG}" qtcore_type) + endif() + if(qtcore_type STREQUAL "system") + set(qt_plugins_dir "") + endif() + + if(NOT qtplugins AND QT_LIBRARIES_PLUGINS) + set(qtplugins "${QT_LIBRARIES_PLUGINS}") + endif() + + foreach(plugin ${qtplugins}) + set(installed_plugin_paths "") + install_qt4_plugin("${plugin}" "${executable}" 0 installed_plugin_paths "${plugins_dir}" "${component}") + list(APPEND libs ${installed_plugin_paths}) + endforeach() + + resolve_qt4_paths(libs) + + install(CODE + "INCLUDE(\"${DeployQt4_cmake_dir}/DeployQt4.cmake\") + SET(BU_CHMOD_BUNDLE_ITEMS TRUE) + FIXUP_QT4_EXECUTABLE(\"\${CMAKE_INSTALL_PREFIX}/${executable}\" \"\" \"${libs}\" \"${dirs}\" \"${plugins_dir}\" \"${request_qt_conf}\")" + ${component} + ) +endfunction() diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index f7bfe27e7..eb10cbc94 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -1,44 +1,57 @@ # - Macros for generating a summary of enabled/disabled features # -# This module provides the macros feature_summary(), set_package_info() and +# This module provides the macros feature_summary(), set_package_properties() and # add_feature_info(). -# For compatiblity it also still provides set_feature_info(), -# print_enabled_features() and print_disabled_features. +# For compatibility it also still provides set_package_info(), set_feature_info(), +# print_enabled_features() and print_disabled_features(). # # These macros can be used to generate a summary of enabled and disabled # packages and/or feature for a build tree: # -# -- Enabled features: +# -- The following OPTIONAL packages have been found: # LibXml2 (required version >= 2.4) , XML processing library. , +# * Enables HTML-import in MyWordProcessor +# * Enables odt-export in MyWordProcessor # PNG , A PNG image library. , -# -- Disabled features: +# * Enables saving screenshots +# -- The following OPTIONAL packages have not been found: # Lua51 , The Lua scripting language. , +# * Enables macros in MyWordProcessor # Foo , Foo provides cool stuff. # # # FEATURE_SUMMARY( [FILENAME ] # [APPEND] # [VAR ] +# [INCLUDE_QUIET_PACKAGES] +# [FATAL_ON_MISSING_REQUIRED_PACKAGES] # [DESCRIPTION "Found packages:"] # WHAT (ALL | PACKAGES_FOUND | PACKAGES_NOT_FOUND # | ENABLED_FEATURES | DISABLED_FEATURES] # ) # # The FEATURE_SUMMARY() macro can be used to print information about enabled -# or disabled features or packages of a project. +# or disabled packages or features of a project. # By default, only the names of the features/packages will be printed and their -# required version when one was specified. Use SET_FEATURE_INFO() to add more -# useful information, like e.g. a download URL for the respective package. +# required version when one was specified. Use SET_PACKAGE_PROPERTIES() to add more +# useful information, like e.g. a download URL for the respective package or their +# purpose in the project. # # The WHAT option is the only mandatory option. Here you specify what information # will be printed: -# ENABLED_FEATURES: the list of all features and packages which are enabled, -# excluding the QUIET packages -# DISABLED_FEATURES: the list of all features and packages which are disabled, -# excluding the QUIET packages +# ALL: print everything +# ENABLED_FEATURES: the list of all features which are enabled +# DISABLED_FEATURES: the list of all features which are disabled # PACKAGES_FOUND: the list of all packages which have been found # PACKAGES_NOT_FOUND: the list of all packages which have not been found -# ALL: this will give all packages which have or have not been found +# OPTIONAL_PACKAGES_FOUND: only those packages which have been found which have the type OPTIONAL +# OPTIONAL_PACKAGES_NOT_FOUND: only those packages which have not been found which have the type OPTIONAL +# RECOMMENDED_PACKAGES_FOUND: only those packages which have been found which have the type RECOMMENDED +# RECOMMENDED_PACKAGES_NOT_FOUND: only those packages which have not been found which have the type RECOMMENDED +# REQUIRED_PACKAGES_FOUND: only those packages which have been found which have the type REQUIRED +# REQUIRED_PACKAGES_NOT_FOUND: only those packages which have not been found which have the type REQUIRED +# RUNTIME_PACKAGES_FOUND: only those packages which have been found which have the type RUNTIME +# RUNTIME_PACKAGES_NOT_FOUND: only those packages which have not been found which have the type RUNTIME # # If a FILENAME is given, the information is printed into this file. If APPEND # is used, it is appended to this file, otherwise the file is overwritten if @@ -48,19 +61,29 @@ # If FILENAME is not used, the information is printed to the terminal. # Using the DESCRIPTION option a description or headline can be set which will # be printed above the actual content. +# If INCLUDE_QUIET_PACKAGES is given, packages which have been searched with find_package(... QUIET) will +# also be listed. By default they are skipped. +# If FATAL_ON_MISSING_REQUIRED_PACKAGES is given, CMake will abort if a package which is marked as REQUIRED +# has not been found. # # Example 1, append everything to a file: # feature_summary(WHAT ALL # FILENAME ${CMAKE_BINARY_DIR}/all.log APPEND) # -# Example 2, print the enabled features into the variable enabledFeaturesText: +# Example 2, print the enabled features into the variable enabledFeaturesText, including QUIET packages: # feature_summary(WHAT ENABLED_FEATURES +# INCLUDE_QUIET_PACKAGES # DESCRIPTION "Enabled Features:" # VAR enabledFeaturesText) # message(STATUS "${enabledFeaturesText}") # # -# SET_PACKAGE_INFO( [ [] ] ) +# SET_PACKAGE_PROPERTIES( PROPERTIES [ URL ] +# [ DESCRIPTION ] +# [ TYPE (RUNTIME|OPTIONAL|RECOMMENDED|REQUIRED) ] +# [ PURPOSE ] +# ) +# # Use this macro to set up information about the named package, which can # then be displayed via FEATURE_SUMMARY(). # This can be done either directly in the Find-module or in the project @@ -68,15 +91,52 @@ # The features for which information can be set are added automatically by the # find_package() command. # +# URL: this should be the homepage of the package, or something similar. Ideally this is set +# already directly in the Find-module. +# +# DESCRIPTION: A short description what that package is, at most one sentence. +# Ideally this is set already directly in the Find-module. +# +# TYPE: What type of dependency has the using project on that package. Default is OPTIONAL. +# In this case it is a package which can be used by the project when available at buildtime, +# but it also work without. RECOMMENDED is similar to OPTIONAL, i.e. the project will build +# if the package is not present, but the functionality of the resulting binaries will be severly +# limited. If a REQUIRED package is not available at buildtime, the project may not even build. This +# can be combined with the FATAL_ON_MISSING_REQUIRED_PACKAGES argument for feature_summary(). +# Last, a RUNTIME package is a package which is actually not used at all during the build, but +# which is required for actually running the resulting binaries. So if such a package is missing, +# the project can still be built, but it may not work later on. If set_package_properties() is called +# multiple times for the same package with different TYPEs, the TYPE is only changed to higher +# TYPEs ( RUNTIME < OPTIONAL < RECOMMENDED < REQUIRED ), lower TYPEs are ignored. +# The TYPE property is project-specific, so it cannot be set by the Find-module, but must be set in the project. +# +# PURPOSE: This describes which features this package enables in the project, i.e. it tells the user +# what functionality he gets in the resulting binaries. +# If set_package_properties() is called multiple times for a package, all PURPOSE properties are appended +# to a list of purposes of the package in the project. +# As the TYPE property, also the PURPOSE property +# is project-specific, so it cannot be set by the Find-module, but must be set in the project. +# +# # Example for setting the info for a package: # find_package(LibXml2) -# set_package_info(LibXml2 "XML processing library." "http://xmlsoft.org/") +# set_package_properties(LibXml2 PROPERTIES DESCRIPTION "A XML processing library." +# URL "http://xmlsoft.org/") # +# set_package_properties(LibXml2 PROPERTIES TYPE RECOMMENDED +# PURPOSE "Enables HTML-import in MyWordProcessor") +# ... +# set_package_properties(LibXml2 PROPERTIES TYPE OPTIONAL +# PURPOSE "Enables odt-export in MyWordProcessor") +# +# find_package(DBUS) +# set_package_properties(DBUS PROPERTIES TYPE RUNTIME +# PURPOSE "Necessary to disable the screensaver during a presentation" ) # # ADD_FEATURE_INFO( ) # Use this macro to add information about a feature with the given . # contains whether this feature is enabled or not, -# is a text descibing the feature. +# is a text describing the feature. # The information can be displayed using feature_summary() for ENABLED_FEATURES # and DISABLED_FEATURES respectively. # @@ -87,14 +147,22 @@ # # The following macros are provided for compatibility with previous CMake versions: # +# SET_PACKAGE_INFO( [ [] ] ) +# Use this macro to set up information about the named package, which can +# then be displayed via FEATURE_SUMMARY(). +# This can be done either directly in the Find-module or in the project +# which uses the module after the FIND_PACKAGE() call. +# The features for which information can be set are added automatically by the +# find_package() command. +# # PRINT_ENABLED_FEATURES() # Does the same as FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:") # # PRINT_DISABLED_FEATURES() # Does the same as FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:") # -# SET_FEATURE_INFO( [ [] ] ) -# Does the same as SET_PACKAGE_INFO( ) +# SET_FEATURE_INFO( [] ) +# Does the same as SET_PACKAGE_INFO( ) #============================================================================= # Copyright 2007-2009 Kitware, Inc. @@ -123,64 +191,149 @@ FUNCTION(ADD_FEATURE_INFO _name _enabled _desc) ENDFUNCTION(ADD_FEATURE_INFO) -FUNCTION(SET_FEATURE_INFO) - SET_PACKAGE_INFO(${ARGN}) -ENDFUNCTION(SET_FEATURE_INFO) +FUNCTION(SET_PACKAGE_PROPERTIES _name _props) + IF(NOT "${_props}" STREQUAL "PROPERTIES") + MESSAGE(FATAL_ERROR "PROPERTIES keyword is missing in SET_PACKAGE_PROPERTIES() call.") + ENDIF() -FUNCTION(SET_PACKAGE_INFO _name _desc) - SET(_url "${ARGV2}") - SET(_comment "${ARGV3}") - SET_PROPERTY(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_desc}" ) - IF(_url MATCHES ".+") - SET_PROPERTY(GLOBAL PROPERTY _CMAKE_${_name}_URL "${_url}" ) - ENDIF(_url MATCHES ".+") - IF(_comment MATCHES ".+") - SET_PROPERTY(GLOBAL PROPERTY _CMAKE_${_name}_COMMENT "${_comment}" ) - ENDIF(_comment MATCHES ".+") -ENDFUNCTION(SET_PACKAGE_INFO) + SET(options ) # none + SET(oneValueArgs DESCRIPTION URL TYPE PURPOSE ) + SET(multiValueArgs ) # none + + CMAKE_PARSE_ARGUMENTS(_SPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + IF(_SPP_UNPARSED_ARGUMENTS) + MESSAGE(FATAL_ERROR "Unknown keywords given to SET_PACKAGE_PROPERTIES(): \"${_SPP_UNPARSED_ARGUMENTS}\"") + ENDIF() + + IF(_SPP_DESCRIPTION) + GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION) + IF(_info AND NOT "${_info}" STREQUAL "${_SPP_DESCRIPTION}") + MESSAGE(STATUS "Warning: Property DESCRIPTION for package ${_name} already set to \"${_info}\", overriding it with \"${_SPP_DESCRIPTION}\"") + ENDIF() + + SET_PROPERTY(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_SPP_DESCRIPTION}" ) + ENDIF() + + + IF(_SPP_URL) + GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_name}_URL) + IF(_info AND NOT "${_info}" STREQUAL "${_SPP_URL}") + MESSAGE(STATUS "Warning: Property URL already set to \"${_info}\", overriding it with \"${_SPP_URL}\"") + ENDIF() + + SET_PROPERTY(GLOBAL PROPERTY _CMAKE_${_name}_URL "${_SPP_URL}" ) + ENDIF() + + + # handle the PURPOSE: use APPEND, since there can be multiple purposes for one package inside a project + IF(_SPP_PURPOSE) + SET_PROPERTY(GLOBAL APPEND PROPERTY _CMAKE_${_name}_PURPOSE "${_SPP_PURPOSE}" ) + ENDIF() + + # handle the TYPE + IF(NOT _SPP_TYPE) + SET(_SPP_TYPE OPTIONAL) + ENDIF() + + # List the supported types, according to their priority + SET(validTypes "RUNTIME" "OPTIONAL" "RECOMMENDED" "REQUIRED" ) + LIST(FIND validTypes ${_SPP_TYPE} _typeIndexInList) + IF("${_typeIndexInList}" STREQUAL "-1" ) + MESSAGE(FATAL_ERROR "Bad package property type ${_SPP_TYPE} used in SET_PACKAGE_PROPERTIES(). " + "Valid types are OPTIONAL, RECOMMENDED, REQUIRED and RUNTIME." ) + ENDIF() + + GET_PROPERTY(_previousType GLOBAL PROPERTY _CMAKE_${_name}_TYPE) + LIST(FIND validTypes "${_previousType}" _prevTypeIndexInList) + + # make sure a previously set TYPE is not overridden with a lower new TYPE: + IF("${_typeIndexInList}" GREATER "${_prevTypeIndexInList}") + SET_PROPERTY(GLOBAL PROPERTY _CMAKE_${_name}_TYPE "${_SPP_TYPE}" ) + ENDIF() + +ENDFUNCTION(SET_PACKAGE_PROPERTIES) + + + +FUNCTION(_FS_GET_FEATURE_SUMMARY _property _var _includeQuiet) + + SET(_type "ANY") + IF("${_property}" MATCHES "REQUIRED_") + SET(_type "REQUIRED") + ELSEIF("${_property}" MATCHES "RECOMMENDED_") + SET(_type "RECOMMENDED") + ELSEIF("${_property}" MATCHES "RUNTIME_") + SET(_type "RUNTIME") + ELSEIF("${_property}" MATCHES "OPTIONAL_") + SET(_type "OPTIONAL") + ENDIF() + + IF("${_property}" MATCHES "PACKAGES_FOUND") + SET(_property "PACKAGES_FOUND") + ELSEIF("${_property}" MATCHES "PACKAGES_NOT_FOUND") + SET(_property "PACKAGES_NOT_FOUND") + ENDIF() -FUNCTION(_FS_GET_FEATURE_SUMMARY _property _var) SET(_currentFeatureText "") GET_PROPERTY(_EnabledFeatures GLOBAL PROPERTY ${_property}) + FOREACH(_currentFeature ${_EnabledFeatures}) - SET(_currentFeatureText "${_currentFeatureText}\n${_currentFeature}") - GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_REQUIRED_VERSION) - IF(_info) - SET(_currentFeatureText "${_currentFeatureText} (required version ${_info})") - ENDIF(_info) - GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_DESCRIPTION) - IF(_info) - SET(_currentFeatureText "${_currentFeatureText} , ${_info}") - ENDIF(_info) - GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_URL) - IF(_info) - SET(_currentFeatureText "${_currentFeatureText} , <${_info}>") - ENDIF(_info) - GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_COMMENT) - IF(_info) - SET(_currentFeatureText "${_currentFeatureText} , ${_info}") - ENDIF(_info) - ENDFOREACH(_currentFeature) - SET(${_var} "${_currentFeatureText}" PARENT_SCOPE) -ENDFUNCTION(_FS_GET_FEATURE_SUMMARY) + # does this package belong to the type we currently want to list ? + GET_PROPERTY(_currentType GLOBAL PROPERTY _CMAKE_${_currentFeature}_TYPE) + IF(NOT _currentType) + SET(_currentType OPTIONAL) + ENDIF() -FUNCTION(PRINT_ENABLED_FEATURES) - FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:") -ENDFUNCTION(PRINT_ENABLED_FEATURES) + IF("${_type}" STREQUAL ANY OR "${_type}" STREQUAL "${_currentType}") + # check whether the current feature/package should be in the output depending on whether it was QUIET or not + SET(includeThisOne TRUE) + # skip QUIET packages, except if they are REQUIRED or INCLUDE_QUIET_PACKAGES has been set + IF((NOT "${_currentType}" STREQUAL "REQUIRED") AND NOT _includeQuiet) + GET_PROPERTY(_isQuiet GLOBAL PROPERTY _CMAKE_${_currentFeature}_QUIET) + IF(_isQuiet) + SET(includeThisOne FALSE) + ENDIF() + ENDIF() -FUNCTION(PRINT_DISABLED_FEATURES) - FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:") -ENDFUNCTION(PRINT_DISABLED_FEATURES) + IF(includeThisOne) + + SET(_currentFeatureText "${_currentFeatureText}\n * ${_currentFeature}") + GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_REQUIRED_VERSION) + IF(_info) + SET(_currentFeatureText "${_currentFeatureText} (required version ${_info})") + ENDIF(_info) + GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_DESCRIPTION) + IF(_info) + SET(_currentFeatureText "${_currentFeatureText} , ${_info}") + ENDIF(_info) + GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_URL) + IF(_info) + SET(_currentFeatureText "${_currentFeatureText} , <${_info}>") + ENDIF(_info) + + GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_PURPOSE) + FOREACH(_purpose ${_info}) + SET(_currentFeatureText "${_currentFeatureText}\n * ${_purpose}") + ENDFOREACH() + + ENDIF(includeThisOne) + + ENDIF("${_type}" STREQUAL ANY OR "${_type}" STREQUAL "${_currentType}") + + ENDFOREACH(_currentFeature) + SET(${_var} "${_currentFeatureText}" PARENT_SCOPE) +ENDFUNCTION(_FS_GET_FEATURE_SUMMARY) FUNCTION(FEATURE_SUMMARY) # CMAKE_PARSE_ARGUMENTS( args...) - SET(options APPEND) + SET(options APPEND INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) SET(oneValueArgs FILENAME VAR DESCRIPTION WHAT) SET(multiValueArgs ) # none @@ -188,27 +341,70 @@ FUNCTION(FEATURE_SUMMARY) IF(_FS_UNPARSED_ARGUMENTS) MESSAGE(FATAL_ERROR "Unknown keywords given to FEATURE_SUMMARY(): \"${_FS_UNPARSED_ARGUMENTS}\"") - ENDIF(_FS_UNPARSED_ARGUMENTS) + ENDIF() IF(NOT _FS_WHAT) - MESSAGE(FATAL_ERROR "The call to FEATURE_SUMMAY() doesn't set the required WHAT argument.") - ENDIF(NOT _FS_WHAT) - - IF( "${_FS_WHAT}" STREQUAL "ENABLED_FEATURES" - OR "${_FS_WHAT}" STREQUAL "DISABLED_FEATURES" - OR "${_FS_WHAT}" STREQUAL "PACKAGES_FOUND" - OR "${_FS_WHAT}" STREQUAL "PACKAGES_NOT_FOUND") - _FS_GET_FEATURE_SUMMARY( ${_FS_WHAT} _featureSummary) + MESSAGE(FATAL_ERROR "The call to FEATURE_SUMMARY() doesn't set the required WHAT argument.") + ENDIF() + + SET(validWhatParts "ENABLED_FEATURES" + "DISABLED_FEATURES" + "PACKAGES_FOUND" + "PACKAGES_NOT_FOUND" + "OPTIONAL_PACKAGES_FOUND" + "OPTIONAL_PACKAGES_NOT_FOUND" + "RECOMMENDED_PACKAGES_FOUND" + "RECOMMENDED_PACKAGES_NOT_FOUND" + "REQUIRED_PACKAGES_FOUND" + "REQUIRED_PACKAGES_NOT_FOUND" + "RUNTIME_PACKAGES_FOUND" + "RUNTIME_PACKAGES_NOT_FOUND") + + LIST(FIND validWhatParts "${_FS_WHAT}" indexInList) + IF(NOT "${indexInList}" STREQUAL "-1") + _FS_GET_FEATURE_SUMMARY( ${_FS_WHAT} _featureSummary ${_FS_INCLUDE_QUIET_PACKAGES} ) SET(_fullText "${_FS_DESCRIPTION}${_featureSummary}\n") + IF (("${_FS_WHAT}" STREQUAL "REQUIRED_PACKAGES_NOT_FOUND") AND _featureSummary) + SET(requiredPackagesNotFound TRUE) + ENDIF() + ELSEIF("${_FS_WHAT}" STREQUAL "ALL") - _FS_GET_FEATURE_SUMMARY( PACKAGES_FOUND _tmp1) - _FS_GET_FEATURE_SUMMARY( PACKAGES_NOT_FOUND _tmp2) - SET(_featureSummary "${_tmp1}${_tmp2}") - IF(_FS_DESCRIPTION) - SET(_fullText "${_FS_DESCRIPTION}${_tmp1}${_tmp2}\n") - ELSE(_FS_DESCRIPTION) - SET(_fullText "-- Found the following packages:${_tmp1}\n-- Did not find the following packages:${_tmp2}\n") - ENDIF(_FS_DESCRIPTION) + + SET(allWhatParts "ENABLED_FEATURES" + "RUNTIME_PACKAGES_FOUND" + "OPTIONAL_PACKAGES_FOUND" + "RECOMMENDED_PACKAGES_FOUND" + "REQUIRED_PACKAGES_FOUND" + + "DISABLED_FEATURES" + "RUNTIME_PACKAGES_NOT_FOUND" + "OPTIONAL_PACKAGES_NOT_FOUND" + "RECOMMENDED_PACKAGES_NOT_FOUND" + "REQUIRED_PACKAGES_NOT_FOUND" + ) + + SET(title_ENABLED_FEATURES "The following features have been enabled:") + SET(title_DISABLED_FEATURES "The following features have been disabled:") + SET(title_OPTIONAL_PACKAGES_FOUND "The following OPTIONAL packages have been found:") + SET(title_OPTIONAL_PACKAGES_NOT_FOUND "The following OPTIONAL packages have not been found:") + SET(title_RECOMMENDED_PACKAGES_FOUND "The following RECOMMENDED packages have been found:") + SET(title_RECOMMENDED_PACKAGES_NOT_FOUND "The following RECOMMENDED packages have not been found:") + SET(title_REQUIRED_PACKAGES_FOUND "The following REQUIRED packages have been found:") + SET(title_REQUIRED_PACKAGES_NOT_FOUND "The following REQUIRED packages have not been found:") + SET(title_RUNTIME_PACKAGES_FOUND "The following RUNTIME packages have been found:") + SET(title_RUNTIME_PACKAGES_NOT_FOUND "The following RUNTIME packages have not been found:") + + SET(_fullText "${_FS_DESCRIPTION}") + FOREACH(part ${allWhatParts}) + SET(_tmp) + _FS_GET_FEATURE_SUMMARY( ${part} _tmp ${_FS_INCLUDE_QUIET_PACKAGES}) + IF(_tmp) + SET(_fullText "${_fullText}\n\n-- ${title_${part}}\n${_tmp}") + IF("${part}" STREQUAL "REQUIRED_PACKAGES_NOT_FOUND") + SET(requiredPackagesNotFound TRUE) + ENDIF() + ENDIF() + ENDFOREACH() ELSE() MESSAGE(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() is set to ${_FS_WHAT}, which is not a valid value.") ENDIF() @@ -218,16 +414,53 @@ FUNCTION(FEATURE_SUMMARY) FILE(APPEND "${_FS_FILENAME}" "${_fullText}") ELSE(_FS_APPEND) FILE(WRITE "${_FS_FILENAME}" "${_fullText}") - ENDIF(_FS_APPEND) + ENDIF() ELSE(_FS_FILENAME) IF(NOT _FS_VAR) MESSAGE(STATUS "${_fullText}") - ENDIF(NOT _FS_VAR) - ENDIF(_FS_FILENAME) + ENDIF() + ENDIF() IF(_FS_VAR) SET(${_FS_VAR} "${_fullText}" PARENT_SCOPE) - ENDIF(_FS_VAR) + ENDIF() + + IF(requiredPackagesNotFound AND _FS_FATAL_ON_MISSING_REQUIRED_PACKAGES) + MESSAGE(FATAL_ERROR "feature_summary() Error: REQUIRED package(s) are missing, aborting CMake run.") + ENDIF() ENDFUNCTION(FEATURE_SUMMARY) + + +# The stuff below is only kept for compatibility + +FUNCTION(SET_PACKAGE_INFO _name _desc) + SET(_url "${ARGV2}") + SET(_purpose "${ARGV3}") + SET_PROPERTY(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_desc}" ) + IF(_url MATCHES ".+") + SET_PROPERTY(GLOBAL PROPERTY _CMAKE_${_name}_URL "${_url}" ) + ENDIF() + IF(_purpose MATCHES ".+") + SET_PROPERTY(GLOBAL APPEND PROPERTY _CMAKE_${_name}_PURPOSE "${_purpose}" ) + ENDIF() +ENDFUNCTION(SET_PACKAGE_INFO) + + + +FUNCTION(SET_FEATURE_INFO) + SET_PACKAGE_INFO(${ARGN}) +ENDFUNCTION(SET_FEATURE_INFO) + + + +FUNCTION(PRINT_ENABLED_FEATURES) + FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:") +ENDFUNCTION(PRINT_ENABLED_FEATURES) + + + +FUNCTION(PRINT_DISABLED_FEATURES) + FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:") +ENDFUNCTION(PRINT_DISABLED_FEATURES) diff --git a/Modules/FindASPELL.cmake b/Modules/FindASPELL.cmake index d19fab4dc..713ab7e19 100644 --- a/Modules/FindASPELL.cmake +++ b/Modules/FindASPELL.cmake @@ -2,6 +2,7 @@ # Once done this will define # # ASPELL_FOUND - system has ASPELL +# ASPELL_EXECUTABLE - the ASPELL executable # ASPELL_INCLUDE_DIR - the ASPELL include directory # ASPELL_LIBRARIES - The libraries needed to use ASPELL # ASPELL_DEFINITIONS - Compiler switches required for using ASPELL @@ -22,11 +23,15 @@ FIND_PATH(ASPELL_INCLUDE_DIR aspell.h ) +FIND_PROGRAM(ASPELL_EXECUTABLE + NAMES aspell +) + FIND_LIBRARY(ASPELL_LIBRARIES NAMES aspell aspell-15 libaspell-15 libaspell) -# handle the QUIETLY and REQUIRED arguments and set ASPELL_FOUND to TRUE if +# handle the QUIETLY and REQUIRED arguments and set ASPELL_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(ASPELL DEFAULT_MSG ASPELL_LIBRARIES ASPELL_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(ASPELL DEFAULT_MSG ASPELL_LIBRARIES ASPELL_INCLUDE_DIR ASPELL_EXECUTABLE) -MARK_AS_ADVANCED(ASPELL_INCLUDE_DIR ASPELL_LIBRARIES) +MARK_AS_ADVANCED(ASPELL_INCLUDE_DIR ASPELL_LIBRARIES ASPELL_EXECUTABLE) diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index e855a27eb..edde9eb96 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -67,8 +67,17 @@ IF(BISON_EXECUTABLE) IF(NOT ${BISON_version_result} EQUAL 0) MESSAGE(SEND_ERROR "Command \"${BISON_EXECUTABLE} --version\" failed with output:\n${BISON_version_error}") ELSE() - STRING(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1" - BISON_VERSION "${BISON_version_output}") + # Bison++ + IF("${BISON_version_output}" MATCHES "^bison\\+\\+") + STRING(REGEX REPLACE "^bison\\+\\+ Version ([^,]+).*" "\\1" + BISON_VERSION "${BISON_version_output}") + # GNU Bison + ELSEIF("${BISON_version_output}" MATCHES "^bison[^+]") + STRING(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1" + BISON_VERSION "${BISON_version_output}") + ELSE() + SET(BISON_VERSION "unknown") + ENDIF() ENDIF() # internal macro diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index ae4a13f50..9b76d909c 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -22,8 +22,8 @@ # 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,ACML_MP,Apple, NAS, Generic +## Goto,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,ACML_MP,ACML_GPU,Apple, NAS, Generic # C/CXX should be enabled to use Intel mkl #============================================================================= @@ -42,6 +42,8 @@ include(CheckFunctionExists) include(CheckFortranFunctionExists) +set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + # Check the language being used get_property( _LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES ) if( _LANGUAGES_ MATCHES Fortran ) @@ -57,7 +59,7 @@ else() endif(BLAS_FIND_REQUIRED) endif( ) -macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _threads) +macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread) # 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 # Check_Fortran_Function_Exists macro) whether can link against that library @@ -69,41 +71,43 @@ macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _threads) # N.B. _prefix is the prefix applied to the names of all cached variables that # are generated internally and marked advanced by this macro. +set(_libdir ${ARGN}) + set(_libraries_work TRUE) set(${LIBRARIES}) set(_combined_name) +if (NOT _libdir) + if (WIN32) + set(_libdir ENV LIB) + elseif (APPLE) + set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH) + else () + set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH) + endif () +endif () 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 - ) - endif ( WIN32 ) - - if ( APPLE ) - if(BLA_STATIC) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib;.dll") - endif(BLA_STATIC) + if (BLA_STATIC) + if (WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif ( WIN32 ) + if (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif (APPLE) + else (BLA_STATIC) + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif () + 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 ) - 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 - ) - endif( APPLE ) + NAMES ${_library} + PATHS ${_libdir} + ) mark_as_advanced(${_prefix}_${_library}_LIBRARY) set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) @@ -139,15 +143,29 @@ else ($ENV{BLA_VENDOR} MATCHES ".+") endif(NOT BLA_VENDOR) endif ($ENV{BLA_VENDOR} MATCHES ".+") +if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") + if(NOT BLAS_LIBRARIES) + # gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "goto2" + "" + ) + endif(NOT BLAS_LIBRARIES) +endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") + 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 BLAS - cblas_dgemm + dgemm "" - "cblas;f77blas;atlas" + "f77blas;atlas" "" ) endif(NOT BLAS_LIBRARIES) @@ -255,15 +273,24 @@ if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") endif (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All") #BLAS in acml library? -if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR STREQUAL "All") -# the patch from Chuck Atkins: - if( ((_BLAS_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR - ((_BLAS_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) ) +if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") + if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR + ((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR + ((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS)) + ) + # try to find acml in "standard" paths if( WIN32 ) file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" ) else() file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" ) endif() + if( WIN32 ) + file( GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples" ) + else() + file( GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples" ) + endif() + list(GET _ACML_ROOT 0 _ACML_ROOT) + list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT) if( _ACML_ROOT ) get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH ) if( SIZEOF_INTEGER EQUAL 8 ) @@ -297,7 +324,7 @@ if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR ST set( _ACML_COMPILER64 "gfortran64" ) endif() - if( _BLAS_VENDOR STREQUAL "ACML_MP" ) + if( BLA_VENDOR STREQUAL "ACML_MP" ) set(_ACML_MP_LIB_DIRS "${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib" "${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" ) @@ -307,19 +334,43 @@ if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR ST "${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" ) endif() endif() + elseif(BLAS_${BLA_VENDOR}_LIB_DIRS) + set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS}) endif() - if( _BLAS_VENDOR STREQUAL "ACML_MP" ) - foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS} ) - _BLAS_LOCATE_AND_TEST( ${_BLAS_VENDOR} "acml_mp;acml_mv" "" ) - if( BLAS_${_BLAS_VENDOR}_FOUND ) + if( BLA_VENDOR STREQUAL "ACML_MP" ) + foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS}) + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) + break() + endif() + endforeach() + elseif( BLA_VENDOR STREQUAL "ACML_GPU" ) + foreach( BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS}) + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) break() endif() endforeach() else() #if( _BLAS_VENDOR STREQUAL "ACML" ) foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} ) - _BLAS_LOCATE_AND_TEST( ${_BLAS_VENDOR} "acml;acml_mv" "" ) - if( BLAS_${_BLAS_VENDOR}_FOUND ) + check_fortran_libraries ( + BLAS_LIBRARIES + BLAS + sgemm + "" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS} + ) + if( BLAS_LIBRARIES ) break() endif() endforeach() @@ -346,6 +397,16 @@ if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "ACML_MP" OR BLA_VENDOR ST "" ) endif(NOT BLAS_LIBRARIES) + if(NOT BLAS_LIBRARIES) + check_fortran_libraries( + BLAS_LIBRARIES + BLAS + sgemm + "" + "acml;acml_mv;CALBLAS" + "" + ) + endif(NOT BLAS_LIBRARIES) endif () # ACML # Apple BLAS library? @@ -354,7 +415,7 @@ if(NOT BLAS_LIBRARIES) check_fortran_libraries( BLAS_LIBRARIES BLAS - cblas_dgemm + dgemm "" "Accelerate" "" @@ -367,7 +428,7 @@ if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") check_fortran_libraries( BLAS_LIBRARIES BLAS - cblas_dgemm + dgemm "" "vecLib" "" @@ -559,3 +620,5 @@ else(BLA_F95) endif(BLAS_FOUND) endif(NOT BLAS_FIND_QUIETLY) endif(BLA_F95) + +set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index c3ac4247d..9c03b3d1d 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -34,7 +34,7 @@ # Boost that contain header files only (e.g. foreach) you do not need to # specify COMPONENTS. # -# You should provide a minimum version number that should be used. If you provide this +# You should provide a minimum version number that should be used. If you provide this # version number and specify the REQUIRED attribute, this module will fail if it # can't find the specified or a later version. If you specify a version number this is # automatically put into the considered list of version numbers and thus doesn't need @@ -65,7 +65,7 @@ # 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, 1.37, 1.37.0, 1.38, 1.38.0, 1.39, 1.39.0, # 1.40, 1.40.0, 1.41, 1.41.0, 1.42, 1.42.0, 1.43, 1.43.0, 1.44, 1.44.0, -# 1.45, 1.45.0, 1.46, 1.46.0, 1.46.1 +# 1.45, 1.45.0, 1.46, 1.46.0, 1.46.1, 1.47, 1.47.0, 1.48, 1.48.0 # # NOTE: If you add a new major 1.x version in Boost_ADDITIONAL_VERSIONS you should # add both 1.x and 1.x.0 as shown above. Official Boost include directories @@ -92,6 +92,12 @@ # BOOST_ROOT. Defaults to OFF. # [Since CMake 2.8.3] # +# Boost_NO_BOOST_CMAKE Do not do a find_package call in config mode +# before searching for a regular boost install. +# This will avoid finding boost-cmake installs. +# Defaults to OFF. +# [Since CMake 2.8.6] +# # Boost_USE_STATIC_RUNTIME If enabled, searches for boost libraries # linked against a static C++ standard library # ('s' ABI tag). This option should be set to @@ -134,7 +140,7 @@ # unless this is set to TRUE or the REQUIRED # keyword is specified in find_package(). # [Since CMake 2.8.0] -# +# # Boost_COMPILER Set this to the compiler suffix used by Boost # (e.g. "-gcc43") if FindBoost has problems finding # the proper Boost installation @@ -164,13 +170,27 @@ # # These last three variables are available also as environment variables: -# Also, note they are completely UPPERCASE. +# Also, note they are completely UPPERCASE, except Boost_DIR. +# +# Boost_DIR or The preferred installation prefix for searching for +# BOOST_ROOT or BOOSTROOT Boost. Set this if the module has problems finding +# the proper Boost installation. # -# BOOST_ROOT or BOOSTROOT The preferred installation prefix for searching for -# Boost. Set this if the module has problems finding -# the proper Boost installation. To prevent falling -# back on the system paths, set Boost_NO_SYSTEM_PATHS -# to true. +# Note that Boost_DIR behaves exactly as _DIR +# variables are documented to behave in find_package's +# Config mode. That is, if it is set as a -D argument +# to CMake, it must point to the location of the +# BoostConfig.cmake or Boost-config.cmake file. If it +# is set as an environment variable, it must point to +# the root of the boost installation. BOOST_ROOT and +# BOOSTROOT, on the other hand, will point to the root +# in either case. +# +# To prevent falling back on the system paths, set +# Boost_NO_SYSTEM_PATHS to true. +# +# To avoid finding boost-cmake installations, set +# Boost_NO_BOOST_CMAKE to true. # # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the # module has problems finding the proper Boost installation @@ -237,6 +257,43 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) + +#------------------------------------------------------------------------------- +# Before we go searching, check whether boost-cmake is avaialble, unless the +# user specifically asked NOT to search for boost-cmake. +# +# If Boost_DIR is set, this behaves as any find_package call would. If not, +# it looks at BOOST_ROOT and BOOSTROOT to find Boost. +# +if (NOT Boost_NO_BOOST_CMAKE) + # If Boost_DIR is not set, look for BOOSTROOT and BOOST_ROOT as alternatives, + # since these are more conventional for Boost. + if ("$ENV{Boost_DIR}" STREQUAL "") + if (NOT "$ENV{BOOST_ROOT}" STREQUAL "") + set(ENV{Boost_DIR} $ENV{BOOST_ROOT}) + elseif (NOT "$ENV{BOOSTROOT}" STREQUAL "") + set(ENV{Boost_DIR} $ENV{BOOSTROOT}) + endif() + endif() + + # Do the same find_package call but look specifically for the CMake version. + # Note that args are passed in the Boost_FIND_xxxxx variables, so there is no + # need to delegate them to this find_package call. + find_package(Boost QUIET NO_MODULE) + + # If we found boost-cmake, then we're done. Print out what we found. + # Otherwise let the rest of the module try to find it. + if (Boost_FOUND) + message("Boost ${Boost_FIND_VERSION} found.") + if (Boost_FIND_COMPONENTS) + message("Found Boost components:") + message(" ${Boost_FIND_COMPONENTS}") + endif() + return() + endif() +endif() + + #------------------------------------------------------------------------------- # FindBoost functions & macros # @@ -287,7 +344,7 @@ macro(_Boost_ADJUST_LIB_VARS basename) set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY_RELEASE} ) set(Boost_${basename}_LIBRARIES ${Boost_${basename}_LIBRARY_RELEASE} ) endif() - + if(Boost_${basename}_LIBRARY) set(Boost_${basename}_LIBRARY ${Boost_${basename}_LIBRARY} CACHE FILEPATH "The Boost ${basename} library") @@ -348,7 +405,7 @@ endfunction() # function(_Boost_PREPEND_LIST_WITH_THREADAPI _output) set(_orig_libnames ${ARGN}) - string(REPLACE "thread" "thread_${Boost_THREADAPI}" _threadapi_libnames ${_orig_libnames}) + string(REPLACE "thread" "thread_${Boost_THREADAPI}" _threadapi_libnames "${_orig_libnames}") set(${_output} ${_threadapi_libnames} ${_orig_libnames} PARENT_SCOPE) endfunction() @@ -372,7 +429,7 @@ endfunction() # # End functions/macros -# +# #------------------------------------------------------------------------------- @@ -392,7 +449,7 @@ else(Boost_FIND_VERSION_EXACT) # The user has not requested an exact version. Among known # versions, find those that are acceptable to the user request. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} - "1.46.1" + "1.48.0" "1.48" "1.47.0" "1.47" "1.46.1" "1.46.0" "1.46" "1.45.0" "1.45" "1.44.0" "1.44" "1.43.0" "1.43" "1.42.0" "1.42" "1.41.0" "1.41" "1.40.0" "1.40" "1.39.0" "1.39" "1.38.0" "1.38" "1.37.0" "1.37" "1.36.1" "1.36.0" "1.36" "1.35.1" "1.35.0" "1.35" "1.34.1" "1.34.0" @@ -516,6 +573,11 @@ else(_boost_IN_CACHE) _Boost_CHECK_SPELLING(Boost_LIBRARYDIR) _Boost_CHECK_SPELLING(Boost_INCLUDEDIR) + # If BOOST_ROOT was defined in the environment, use it. + if (NOT BOOST_ROOT AND NOT $ENV{Boost_DIR} STREQUAL "") + set(BOOST_ROOT $ENV{Boost_DIR}) + endif() + # 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}) @@ -688,10 +750,12 @@ else(_boost_IN_CACHE) else() set (_boost_COMPILER "-il") endif() - elseif (MSVC90) - set(_boost_COMPILER "-vc90") + elseif (MSVC11) + set(_boost_COMPILER "-vc110") elseif (MSVC10) set(_boost_COMPILER "-vc100") + elseif (MSVC90) + set(_boost_COMPILER "-vc90") elseif (MSVC80) set(_boost_COMPILER "-vc80") elseif (MSVC71) diff --git a/Modules/FindBullet.cmake b/Modules/FindBullet.cmake index cebb8282a..aea9158e8 100644 --- a/Modules/FindBullet.cmake +++ b/Modules/FindBullet.cmake @@ -59,13 +59,13 @@ find_path(BULLET_INCLUDE_DIR NAMES btBulletCollisionCommon.h # Find the libraries _FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY BulletDynamics) -_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG BulletDynamics_d) +_FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG BulletDynamics_Debug BulletDynamics_d) _FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY BulletCollision) -_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_d) -_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY LinearMath BulletMath) -_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG LinearMath_d BulletMath_d) +_FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_Debug BulletCollision_d) +_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY BulletMath LinearMath) +_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG BulletMath_Debug BulletMath_d LinearMath_d) _FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY BulletSoftBody) -_FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG BulletSoftBody_d) +_FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG BulletSoftBody_Debug BulletSoftBody_d) # handle the QUIETLY and REQUIRED arguments and set BULLET_FOUND to TRUE if diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index d5ef43029..18f7442cc 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -266,17 +266,17 @@ macro(CUDA_FIND_HELPER_FILE _name _extension) # processed. Using this variable, we can pull out the current path, and # provide a way to get access to the other files we need local to here. get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) - find_file(CUDA_${_name} ${_full_name} PATHS ${CMAKE_CURRENT_LIST_DIR}/FindCUDA NO_DEFAULT_PATH) - if(NOT CUDA_${_name}) - set(error_message "${_full_name} not found in CMAKE_MODULE_PATH") + set(CUDA_${_name} "${CMAKE_CURRENT_LIST_DIR}/FindCUDA/${_full_name}") + if(NOT EXISTS "${CUDA_${_name}}") + set(error_message "${_full_name} not found in ${CMAKE_CURRENT_LIST_DIR}/FindCUDA") if(CUDA_FIND_REQUIRED) message(FATAL_ERROR "${error_message}") - else(CUDA_FIND_REQUIRED) + else() if(NOT CUDA_FIND_QUIETLY) message(STATUS "${error_message}") - endif(NOT CUDA_FIND_QUIETLY) - endif(CUDA_FIND_REQUIRED) - endif(NOT CUDA_${_name}) + endif() + endif() + endif() # Set this variable as internal, so the user isn't bugged with it. set(CUDA_${_name} ${CUDA_${_name}} CACHE INTERNAL "Location of ${_full_name}" FORCE) endmacro(CUDA_FIND_HELPER_FILE) @@ -320,9 +320,9 @@ macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file) # message("CUDA_NVCC_DEPEND NOT set") # endif() if(CUDA_NVCC_DEPEND) - #message("CUDA_NVCC_DEPEND true") + #message("CUDA_NVCC_DEPEND found") foreach(f ${CUDA_NVCC_DEPEND}) - #message("searching for ${f}") + # message("searching for ${f}") if(NOT EXISTS ${f}) #message("file ${f} not found") set(CUDA_NVCC_DEPEND_REGENERATE TRUE) @@ -339,6 +339,8 @@ macro(CUDA_INCLUDE_NVCC_DEPENDENCIES dependency_file) # output depend on the dependency file itself, which should cause the # rule to re-run. if(CUDA_NVCC_DEPEND_REGENERATE) + set(CUDA_NVCC_DEPEND ${dependency_file}) + #message("Generating an empty dependency_file: ${dependency_file}") file(WRITE ${dependency_file} "#FindCUDA.cmake generated file. Do not edit.\n") endif(CUDA_NVCC_DEPEND_REGENERATE) @@ -415,13 +417,14 @@ endforeach() # if they have then clear the cache variables, so that will be detected again. if(NOT "${CUDA_TOOLKIT_ROOT_DIR}" STREQUAL "${CUDA_TOOLKIT_ROOT_DIR_INTERNAL}") unset(CUDA_NVCC_EXECUTABLE CACHE) - unset(CUDA_VERSION CACHE) unset(CUDA_TOOLKIT_INCLUDE CACHE) unset(CUDA_CUDART_LIBRARY CACHE) + # Make sure you run this before you unset CUDA_VERSION. if(CUDA_VERSION VERSION_EQUAL "3.0") # This only existed in the 3.0 version of the CUDA toolkit unset(CUDA_CUDARTEMU_LIBRARY CACHE) endif() + unset(CUDA_VERSION CACHE) unset(CUDA_CUDA_LIBRARY CACHE) unset(CUDA_cublas_LIBRARY CACHE) unset(CUDA_cublasemu_LIBRARY CACHE) @@ -443,7 +446,10 @@ if(NOT CUDA_TOOLKIT_ROOT_DIR) # Search in the CUDA_BIN_PATH first. find_path(CUDA_TOOLKIT_ROOT_DIR NAMES nvcc nvcc.exe - PATHS ENV CUDA_BIN_PATH + PATHS + ENV CUDA_PATH + ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 DOC "Toolkit location." NO_DEFAULT_PATH ) @@ -472,9 +478,10 @@ endif (NOT CUDA_TOOLKIT_ROOT_DIR) # CUDA_NVCC_EXECUTABLE find_program(CUDA_NVCC_EXECUTABLE NAMES nvcc - PATHS "${CUDA_TOOLKIT_ROOT_DIR}/bin" - "${CUDA_TOOLKIT_ROOT_DIR}/bin64" + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH ENV CUDA_BIN_PATH + PATH_SUFFIXES bin bin64 NO_DEFAULT_PATH ) # Search default search paths, after we search our own set of paths. @@ -500,8 +507,10 @@ set(CUDA_VERSION_STRING "${CUDA_VERSION}") # CUDA_TOOLKIT_INCLUDE find_path(CUDA_TOOLKIT_INCLUDE device_functions.h # Header included in toolkit - PATHS "${CUDA_TOOLKIT_ROOT_DIR}/include" + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH ENV CUDA_INC_PATH + PATH_SUFFIXES include NO_DEFAULT_PATH ) # Search default search paths, after we search our own set of paths. @@ -516,19 +525,16 @@ macro(FIND_LIBRARY_LOCAL_FIRST _var _names _doc) if(CMAKE_SIZEOF_VOID_P EQUAL 8) # CUDA 3.2+ on Windows moved the library directoryies, so we need the new # and old paths. - set(_cuda_64bit_lib_dir - "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" - "${CUDA_TOOLKIT_ROOT_DIR}/lib64" - ) + set(_cuda_64bit_lib_dir "lib/x64" "lib64" ) endif() # CUDA 3.2+ on Windows moved the library directories, so we need to new # (lib/Win32) and the old path (lib). find_library(${_var} NAMES ${_names} - PATHS ${_cuda_64bit_lib_dir} - "${CUDA_TOOLKIT_ROOT_DIR}/lib/Win32" - "${CUDA_TOOLKIT_ROOT_DIR}/lib" + PATHS "${CUDA_TOOLKIT_ROOT_DIR}" + ENV CUDA_PATH ENV CUDA_LIB_PATH + PATH_SUFFIXES ${_cuda_64bit_lib_dir} "lib/Win32" "lib" DOC ${_doc} NO_DEFAULT_PATH ) @@ -707,7 +713,7 @@ find_package_handle_standard_args(CUDA # Add include directories to pass to the nvcc command. macro(CUDA_INCLUDE_DIRECTORIES) foreach(dir ${ARGN}) - list(APPEND CUDA_NVCC_INCLUDE_ARGS_USER "-I${dir}") + list(APPEND CUDA_NVCC_INCLUDE_ARGS_USER -I${dir}) endforeach(dir ${ARGN}) endmacro(CUDA_INCLUDE_DIRECTORIES) @@ -736,13 +742,13 @@ macro(CUDA_GET_SOURCES_AND_OPTIONS _sources _cmake_options _options) arg STREQUAL "SHARED" OR arg STREQUAL "MODULE" ) - list(APPEND ${_cmake_options} "${arg}") + list(APPEND ${_cmake_options} ${arg}) else() if ( _found_options ) - list(APPEND ${_options} "${arg}") + list(APPEND ${_options} ${arg}) else() # Assume this is a file - list(APPEND ${_sources} "${arg}") + list(APPEND ${_sources} ${arg}) endif() endif() endforeach() @@ -808,6 +814,43 @@ function(CUDA_BUILD_SHARED_LIBRARY shared_flag) set(${shared_flag} ${_cuda_build_shared_libs} PARENT_SCOPE) endfunction() +############################################################################## +# Helper to avoid clashes of files with the same basename but different paths. +# This doesn't attempt to do exactly what CMake internals do, which is to only +# add this path when there is a conflict, since by the time a second collision +# in names is detected it's already too late to fix the first one. For +# consistency sake the relative path will be added to all files. +function(CUDA_COMPUTE_BUILD_PATH path build_path) + #message("CUDA_COMPUTE_BUILD_PATH([${path}] ${build_path})") + # Only deal with CMake style paths from here on out + file(TO_CMAKE_PATH "${path}" bpath) + if (IS_ABSOLUTE "${bpath}") + # Absolute paths are generally unnessary, especially if something like + # FILE(GLOB_RECURSE) is used to pick up the files. + file(RELATIVE_PATH bpath "${CMAKE_CURRENT_SOURCE_DIR}" "${bpath}") + endif() + + # This recipie is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the + # CMake source. + + # Remove leading / + string(REGEX REPLACE "^[/]+" "" bpath "${bpath}") + # Avoid absolute paths by removing ':' + string(REPLACE ":" "_" bpath "${bpath}") + # Avoid relative paths that go up the tree + string(REPLACE "../" "__/" bpath "${bpath}") + # Avoid spaces + string(REPLACE " " "_" bpath "${bpath}") + + # Strip off the filename. I wait until here to do it, since removin the + # basename can make a path that looked like path/../basename turn into + # path/.. (notice the trailing slash). + get_filename_component(bpath "${bpath}" PATH) + + set(${build_path} "${bpath}" PARENT_SCOPE) + #message("${build_path} = ${bpath}") +endfunction() + ############################################################################## # This helper macro populates the following variables and setups up custom # commands and targets to invoke the nvcc compiler to generate C or PTX source @@ -890,7 +933,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) get_directory_property(CUDA_NVCC_INCLUDE_DIRECTORIES INCLUDE_DIRECTORIES) if(CUDA_NVCC_INCLUDE_DIRECTORIES) foreach(dir ${CUDA_NVCC_INCLUDE_DIRECTORIES}) - list(APPEND CUDA_NVCC_INCLUDE_ARGS "-I${dir}") + list(APPEND CUDA_NVCC_INCLUDE_ARGS -I${dir}) endforeach() endif() @@ -956,7 +999,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) # Note that if we ever want CUDA_NVCC_FLAGS_ to be string (instead of a list # like it is currently), we can remove the quotes around the # ${CUDA_NVCC_FLAGS_${config_upper}} variable like the CMAKE_HOST_FLAGS_ variable. - set(CUDA_NVCC_FLAGS_CONFIG "${CUDA_NVCC_FLAGS_CONFIG}\nset(CUDA_NVCC_FLAGS_${config_upper} \"${CUDA_NVCC_FLAGS_${config_upper}};;${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}}\")") + set(CUDA_NVCC_FLAGS_CONFIG "${CUDA_NVCC_FLAGS_CONFIG}\nset(CUDA_NVCC_FLAGS_${config_upper} ${CUDA_NVCC_FLAGS_${config_upper}} ;; ${CUDA_WRAP_OPTION_NVCC_FLAGS_${config_upper}})") endforeach() if(compile_to_ptx) @@ -977,13 +1020,6 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) list(APPEND nvcc_flags "-D${cuda_target}_EXPORTS") endif() - # Determine output directory - if(CUDA_GENERATED_OUTPUT_DIR) - set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}") - else() - set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}") - endif() - # Reset the output variable set(_cuda_wrap_generated_files "") @@ -994,6 +1030,19 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) get_source_file_property(_is_header ${file} HEADER_FILE_ONLY) if(${file} MATCHES ".*\\.cu$" AND NOT _is_header) + # Determine output directory + cuda_compute_build_path("${file}" cuda_build_path) + set(cuda_compile_intermediate_directory "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${cuda_target}.dir/${cuda_build_path}") + if(CUDA_GENERATED_OUTPUT_DIR) + set(cuda_compile_output_dir "${CUDA_GENERATED_OUTPUT_DIR}") + else() + if ( compile_to_ptx ) + set(cuda_compile_output_dir "${CMAKE_CURRENT_BINARY_DIR}") + else() + set(cuda_compile_output_dir "${cuda_compile_intermediate_directory}") + endif() + endif() + # Add a custom target to generate a c or ptx file. ###################### get_filename_component( basename ${file} NAME ) @@ -1013,10 +1062,10 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) # argument, so that the ${CMAKE_CFG_INTDIR} gets expanded at run time # instead of configure time. set(generated_file "${generated_file_path}/${generated_file_basename}") - set(cmake_dependency_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${generated_file_basename}.depend") - set(NVCC_generated_dependency_file "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${generated_file_basename}.NVCC-depend") + set(cmake_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.depend") + set(NVCC_generated_dependency_file "${cuda_compile_intermediate_directory}/${generated_file_basename}.NVCC-depend") set(generated_cubin_file "${generated_file_path}/${generated_file_basename}.cubin.txt") - set(custom_target_script "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${generated_file_basename}.cmake") + set(custom_target_script "${cuda_compile_intermediate_directory}/${generated_file_basename}.cmake") # Setup properties for obj files: if( NOT compile_to_ptx ) @@ -1096,6 +1145,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) -D "generated_file:STRING=${generated_file}" -D "generated_cubin_file:STRING=${generated_cubin_file}" -P "${custom_target_script}" + WORKING_DIRECTORY "${cuda_compile_intermediate_directory}" COMMENT "${cuda_build_comment_string}" ) diff --git a/Modules/FindCUDA/make2cmake.cmake b/Modules/FindCUDA/make2cmake.cmake index 7fce167c2..d41b72dc2 100644 --- a/Modules/FindCUDA/make2cmake.cmake +++ b/Modules/FindCUDA/make2cmake.cmake @@ -54,13 +54,27 @@ if (${depend_text} MATCHES ".+") string(REGEX REPLACE "^ +" "" file ${file}) - if(NOT IS_DIRECTORY ${file}) + # OK, now if we had a UNC path, nvcc has a tendency to only output the first '/' + # instead of '//'. Here we will test to see if the file exists, if it doesn't then + # try to prepend another '/' to the path and test again. If it still fails remove the + # path. + + if(NOT EXISTS "${file}") + if (EXISTS "/${file}") + set(file "/${file}") + else() + message(WARNING " Removing non-existant dependency file: ${file}") + set(file "") + endif() + endif() + + if(NOT IS_DIRECTORY "${file}") # If softlinks start to matter, we should change this to REALPATH. For now we need # to flatten paths, because nvcc can generate stuff like /bin/../include instead of # just /include. get_filename_component(file_absolute "${file}" ABSOLUTE) list(APPEND dependency_list "${file_absolute}") - endif(NOT IS_DIRECTORY ${file}) + endif() endforeach(file) diff --git a/Modules/FindCUDA/run_nvcc.cmake b/Modules/FindCUDA/run_nvcc.cmake index 7349da322..b31011c0e 100644 --- a/Modules/FindCUDA/run_nvcc.cmake +++ b/Modules/FindCUDA/run_nvcc.cmake @@ -55,25 +55,25 @@ if(NOT generated_file) endif() # Set these up as variables to make reading the generated file easier -set(CMAKE_COMMAND "@CMAKE_COMMAND@") -set(source_file "@source_file@") -set(NVCC_generated_dependency_file "@NVCC_generated_dependency_file@") -set(cmake_dependency_file "@cmake_dependency_file@") -set(CUDA_make2cmake "@CUDA_make2cmake@") -set(CUDA_parse_cubin "@CUDA_parse_cubin@") -set(build_cubin @build_cubin@) +set(CMAKE_COMMAND "@CMAKE_COMMAND@") # path +set(source_file "@source_file@") # path +set(NVCC_generated_dependency_file "@NVCC_generated_dependency_file@") # path +set(cmake_dependency_file "@cmake_dependency_file@") # path +set(CUDA_make2cmake "@CUDA_make2cmake@") # path +set(CUDA_parse_cubin "@CUDA_parse_cubin@") # path +set(build_cubin @build_cubin@) # bool # We won't actually use these variables for now, but we need to set this, in # order to force this file to be run again if it changes. -set(generated_file_path "@generated_file_path@") -set(generated_file_internal "@generated_file@") -set(generated_cubin_file_internal "@generated_cubin_file@") +set(generated_file_path "@generated_file_path@") # path +set(generated_file_internal "@generated_file@") # path +set(generated_cubin_file_internal "@generated_cubin_file@") # path -set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@") -set(CUDA_NVCC_FLAGS "@CUDA_NVCC_FLAGS@;;@CUDA_WRAP_OPTION_NVCC_FLAGS@") +set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@") # path +set(CUDA_NVCC_FLAGS @CUDA_NVCC_FLAGS@ ;; @CUDA_WRAP_OPTION_NVCC_FLAGS@) # list @CUDA_NVCC_FLAGS_CONFIG@ -set(nvcc_flags "@nvcc_flags@") -set(CUDA_NVCC_INCLUDE_ARGS "@CUDA_NVCC_INCLUDE_ARGS@") -set(format_flag "@format_flag@") +set(nvcc_flags @nvcc_flags@) # list +set(CUDA_NVCC_INCLUDE_ARGS "@CUDA_NVCC_INCLUDE_ARGS@") # list (needs to be in quotes to handle spaces properly). +set(format_flag "@format_flag@") # string if(build_cubin AND NOT generated_cubin_file) message(FATAL_ERROR "You must specify generated_cubin_file on the command line") diff --git a/Modules/FindDCMTK.cmake b/Modules/FindDCMTK.cmake index 0ac22f8fc..361d09e8b 100644 --- a/Modules/FindDCMTK.cmake +++ b/Modules/FindDCMTK.cmake @@ -108,8 +108,10 @@ foreach(dir PATHS ${DCMTK_DIR}/${dir}/include ${DCMTK_DIR}/${dir} - ${DCMTK_DIR}/include/${dir}) - + ${DCMTK_DIR}/include/${dir} + ${DCMTK_DIR}/include/dcmtk/${dir} + ${DCMTK_DIR}/${dir}/include/dcmtk/${dir} + ) mark_as_advanced(DCMTK_${dir}_INCLUDE_DIR) if(DCMTK_${dir}_INCLUDE_DIR) diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index 3cc3da58c..6a70b4030 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -5,6 +5,7 @@ # FLEX_EXECUTABLE - the path to the flex executable # FLEX_VERSION - the version of flex # FLEX_LIBRARIES - The flex libraries +# FLEX_INCLUDE_DIRS - The path to the flex headers # # The minimum required version of flex can be specified using the # standard syntax, e.g. FIND_PACKAGE(FLEX 2.5.13) @@ -66,8 +67,14 @@ FIND_PROGRAM(FLEX_EXECUTABLE flex DOC "path to the flex executable") MARK_AS_ADVANCED(FLEX_EXECUTABLE) FIND_LIBRARY(FL_LIBRARY NAMES fl - DOC "path to the fl library") -MARK_AS_ADVANCED(FL_LIBRARY) + DOC "Path to the fl library") + +FIND_PATH(FLEX_INCLUDE_DIR FlexLexer.h + DOC "Path to the flex headers") + +MARK_AS_ADVANCED(FL_LIBRARY FLEX_INCLUDE_DIR) + +SET(FLEX_INCLUDE_DIRS ${FLEX_INCLUDE_DIR}) SET(FLEX_LIBRARIES ${FL_LIBRARY}) IF(FLEX_EXECUTABLE) diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index 8957b6484..6251805df 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -24,45 +24,38 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -# Created by Eric Wing. +# Created by Eric Wing. # Modifications by Alexander Neundorf. # This file has been renamed to "FindFreetype.cmake" instead of the correct # "FindFreeType.cmake" in order to be compatible with the one from KDE4, Alex. -# Ugh, FreeType seems to use some #include trickery which +# Ugh, FreeType seems to use some #include trickery which # makes this harder than it should be. It looks like they # put ft2build.h in a common/easier-to-find location which -# then contains a #include to a more specific header in a +# then contains a #include to a more specific header in a # more specific location (#include ). -# Then from there, they need to set a bunch of #define's +# Then from there, they need to set a bunch of #define's # so you can do something like: # #include FT_FREETYPE_H # Unfortunately, using CMake's mechanisms like INCLUDE_DIRECTORIES() # wants explicit full paths and this trickery doesn't work too well. -# I'm going to attempt to cut out the middleman and hope +# I'm going to attempt to cut out the middleman and hope # everything still works. -FIND_PATH(FREETYPE_INCLUDE_DIR_ft2build ft2build.h +FIND_PATH(FREETYPE_INCLUDE_DIR_ft2build ft2build.h HINTS $ENV{FREETYPE_DIR} - PATH_SUFFIXES include PATHS /usr/local/X11R6/include /usr/local/X11/include - /usr/X11/include - /sw/include - /opt/local/include /usr/freeware/include ) -FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h +FIND_PATH(FREETYPE_INCLUDE_DIR_freetype2 freetype/config/ftheader.h HINTS $ENV{FREETYPE_DIR}/include/freetype2 PATHS /usr/local/X11R6/include /usr/local/X11/include - /usr/X11/include - /sw/include - /opt/local/include /usr/freeware/include PATH_SUFFIXES freetype2 ) @@ -75,8 +68,6 @@ FIND_LIBRARY(FREETYPE_LIBRARY PATHS /usr/local/X11R6 /usr/local/X11 - /usr/X11 - /sw /usr/freeware ) @@ -86,7 +77,7 @@ IF(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2) ENDIF(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2) SET(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}") -# handle the QUIETLY and REQUIRED arguments and set FREETYPE_FOUND to TRUE if +# handle the QUIETLY and REQUIRED arguments and set FREETYPE_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype DEFAULT_MSG FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS) diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake index 1fad07ddd..41e909805 100644 --- a/Modules/FindGIF.cmake +++ b/Modules/FindGIF.cmake @@ -1,7 +1,11 @@ -# This module defines +# This module searches giflib and defines # GIF_LIBRARIES - libraries to link to in order to use GIF -# GIF_FOUND, if false, do not try to link +# GIF_FOUND, if false, do not try to link # GIF_INCLUDE_DIR, where to find the headers +# GIF_VERSION, reports either version 4 or 3 (for everything before version 4) +# +# The minimum required version of giflib can be specified using the +# standard syntax, e.g. FIND_PACKAGE(GIF 4) # # $GIF_DIR is an environment variable that would # correspond to the ./configure --prefix=$GIF_DIR @@ -19,7 +23,7 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -# Created by Eric Wing. +# Created by Eric Wing. # Modifications by Alexander Neundorf FIND_PATH(GIF_INCLUDE_DIR gif_lib.h @@ -28,39 +32,49 @@ FIND_PATH(GIF_INCLUDE_DIR gif_lib.h PATH_SUFFIXES include PATHS ~/Library/Frameworks - /Library/Frameworks - /sw/include # Fink - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/include - /usr/freeware/include + /usr/freeware ) # the gif library can have many names :-/ -SET(POTENTIAL_GIF_LIBS gif libgif ungif libungif giflib) +SET(POTENTIAL_GIF_LIBS gif libgif ungif libungif giflib giflib4) -FIND_LIBRARY(GIF_LIBRARY +FIND_LIBRARY(GIF_LIBRARY NAMES ${POTENTIAL_GIF_LIBS} HINTS $ENV{GIF_DIR} PATH_SUFFIXES lib64 lib PATHS ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw - /opt/local - /opt/csw - /opt - [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT] /usr/freeware ) # see readme.txt SET(GIF_LIBRARIES ${GIF_LIBRARY}) -# handle the QUIETLY and REQUIRED arguments and set GIF_FOUND to TRUE if +# Very basic version detection. +# The GIF_LIB_VERSION string in gif_lib.h seems to be unreliable, since it seems +# to be always " Version 2.0, " in versions 3.x of giflib. +# In version 4 the member UserData was added to GifFileType, so we check for this +# one. +# http://giflib.sourcearchive.com/documentation/4.1.4/files.html +IF(GIF_INCLUDE_DIR) + INCLUDE(CMakePushCheckState) + INCLUDE(CheckStructHasMember) + CMAKE_PUSH_CHECK_STATE() + SET(GIF_VERSION 3) + SET(CMAKE_REQUIRED_INCLUDES "${GIF_INCLUDE_DIR}") + CHECK_STRUCT_HAS_MEMBER(GifFileType UserData gif_lib.h GIF_GifFileType_UserData ) + IF(GIF_GifFileType_UserData) + SET(GIF_VERSION 4) + ENDIF() + CMAKE_POP_CHECK_STATE() +ENDIF() + + +# handle the QUIETLY and REQUIRED arguments and set GIF_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GIF DEFAULT_MSG GIF_LIBRARY GIF_INCLUDE_DIR) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GIF REQUIRED_VARS GIF_LIBRARY GIF_INCLUDE_DIR + VERSION_VAR GIF_VERSION ) MARK_AS_ADVANCED(GIF_INCLUDE_DIR GIF_LIBRARY) diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake index 9398b5473..c44adb46c 100644 --- a/Modules/FindGettext.cmake +++ b/Modules/FindGettext.cmake @@ -1,5 +1,5 @@ # - Find GNU gettext tools -# This module looks for the GNU gettext tools. This module defines the +# This module looks for the GNU gettext tools. This module defines the # following values: # GETTEXT_MSGMERGE_EXECUTABLE: the full path to the msgmerge tool. # GETTEXT_MSGFMT_EXECUTABLE: the full path to the msgfmt tool. @@ -7,13 +7,26 @@ # # Additionally it provides the following macros: # GETTEXT_CREATE_TRANSLATIONS ( outputFile [ALL] file1 ... fileN ) -# This will create a target "translations" which will convert the -# given input po files into the binary output mo file. If the +# This will create a target "translations" which will convert the +# given input po files into the binary output mo file. If the # ALL option is used, the translations will also be created when # building the default target. +# GETTEXT_PROCESS_POT( [ALL] [INSTALL_DESTINATION ] LANGUAGES ... ) +# Process the given pot file to mo files. +# If INSTALL_DESTINATION is given then automatically install rules will be created, +# the language subdirectory will be taken into account (by default use share/locale/). +# If ALL is specified, the pot file is processed when building the all traget. +# It creates a custom target "potfile". +# GETTEXT_PROCESS_PO_FILES( [ALL] [INSTALL_DESTINATION ] PO_FILES ... ) +# Process the given po files to mo files for the given language. +# If INSTALL_DESTINATION is given then automatically install rules will be created, +# the language subdirectory will be taken into account (by default use share/locale/). +# If ALL is specified, the po files are processed when building the all traget. +# It creates a custom target "pofiles". #============================================================================= # Copyright 2007-2009 Kitware, Inc. +# Copyright 2007 Alexander Neundorf # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -29,12 +42,18 @@ FIND_PROGRAM(GETTEXT_MSGMERGE_EXECUTABLE msgmerge) FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt) +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gettext REQUIRED_VARS GETTEXT_MSGMERGE_EXECUTABLE GETTEXT_MSGFMT_EXECUTABLE) + +INCLUDE(CMakeParseArguments) + MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg) # make it a real variable, so we can modify it here SET(_firstPoFile "${_firstPoFileArg}") SET(_gmoFiles) - GET_FILENAME_COMPONENT(_potBasename ${_potFile} NAME_WE) + GET_FILENAME_COMPONENT(_potName ${_potFile} NAME) + STRING(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName}) GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE) SET(_addToAll) @@ -49,14 +68,14 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg) GET_FILENAME_COMPONENT(_lang ${_absFile} NAME_WE) SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo) - ADD_CUSTOM_COMMAND( - OUTPUT ${_gmoFile} + ADD_CUSTOM_COMMAND( + OUTPUT ${_gmoFile} COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_absFile} ${_absPotFile} COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_absFile} - DEPENDS ${_absPotFile} ${_absFile} + DEPENDS ${_absPotFile} ${_absFile} ) - INSTALL(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo) + INSTALL(FILES ${_gmoFile} DESTINATION share/locale/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo) SET(_gmoFiles ${_gmoFiles} ${_gmoFile}) ENDFOREACH (_currentPoFile ) @@ -65,6 +84,80 @@ MACRO(GETTEXT_CREATE_TRANSLATIONS _potFile _firstPoFileArg) ENDMACRO(GETTEXT_CREATE_TRANSLATIONS ) + +FUNCTION(GETTEXT_PROCESS_POT_FILE _potFile) + SET(_gmoFiles) + SET(_options ALL) + SET(_oneValueArgs INSTALL_DESTINATION) + SET(_multiValueArgs LANGUAGES) + + CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + + GET_FILENAME_COMPONENT(_potName ${_potFile} NAME) + STRING(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _potBasename ${_potName}) + GET_FILENAME_COMPONENT(_absPotFile ${_potFile} ABSOLUTE) + + FOREACH (_lang ${_parsedArguments_LANGUAGES}) + SET(_poFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.po") + SET(_gmoFile "${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo") + + ADD_CUSTOM_COMMAND( + OUTPUT "${_poFile}" + COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${_poFile} ${_absPotFile} + DEPENDS ${_absPotFile} + ) + + ADD_CUSTOM_COMMAND( + OUTPUT "${_gmoFile}" + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_poFile} + DEPENDS ${_absPotFile} ${_poFile} + ) + + IF(_parsedArguments_INSTALL_DESTINATION) + INSTALL(FILES ${_gmoFile} DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES RENAME ${_potBasename}.mo) + ENDIF(_parsedArguments_INSTALL_DESTINATION) + LIST(APPEND _gmoFiles ${_gmoFile}) + ENDFOREACH (_lang ) + + IF(_parsedArguments_ALL) + ADD_CUSTOM_TARGET(potfiles ALL DEPENDS ${_gmoFiles}) + ELSE(_parsedArguments_ALL) + ADD_CUSTOM_TARGET(potfiles DEPENDS ${_gmoFiles}) + ENDIF(_parsedArguments_ALL) +ENDFUNCTION(GETTEXT_PROCESS_POT_FILE) + + +FUNCTION(GETTEXT_PROCESS_PO_FILES _lang) + SET(_options ALL) + SET(_oneValueArgs INSTALL_DESTINATION) + SET(_multiValueArgs PO_FILES) + SET(_gmoFiles) + + CMAKE_PARSE_ARGUMENTS(_parsedArguments "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN}) + + FOREACH(_current_PO_FILE ${_parsedArguments_PO_FILES}) + GET_FILENAME_COMPONENT(_name ${_current_PO_FILE} NAME) + STRING(REGEX REPLACE "^(.+)(\\.[^.]+)$" "\\1" _basename ${_name}) + SET(_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo) + ADD_CUSTOM_COMMAND(OUTPUT ${_gmoFile} + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + DEPENDS ${_current_PO_FILE} + ) + + IF(_parsedArguments_INSTALL_DESTINATION) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.gmo DESTINATION ${_parsedArguments_INSTALL_DESTINATION}/${_lang}/LC_MESSAGES/ RENAME ${_basename}.mo) + ENDIF(_parsedArguments_INSTALL_DESTINATION) + LIST(APPEND _gmoFiles ${_gmoFile}) + ENDFOREACH(_current_PO_FILE) + + IF(_parsedArguments_ALL) + ADD_CUSTOM_TARGET(pofiles ALL DEPENDS ${_gmoFiles}) + ELSE(_parsedArguments_ALL) + ADD_CUSTOM_TARGET(pofiles DEPENDS ${_gmoFiles}) + ENDIF(_parsedArguments_ALL) +ENDFUNCTION(GETTEXT_PROCESS_PO_FILES) + IF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE ) SET(GETTEXT_FOUND TRUE) ELSE (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE ) @@ -73,6 +166,3 @@ ELSE (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE ) MESSAGE(FATAL_ERROR "GetText not found") ENDIF (GetText_REQUIRED) ENDIF (GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE ) - - - diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index 6f01ea0b2..bc606389b 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -10,8 +10,8 @@ # are specified, then the find module will default to finding only the HDF5 C # library. If one or more COMPONENTS are specified, the module will attempt to # find the language bindings for the specified components. The only valid -# components are C, CXX, Fortran, and HL. If the COMPONENTS argument is not -# given, the module will attempt to find only the C bindings. +# components are C, CXX, Fortran, HL, and Fortran_HL. If the COMPONENTS +# argument is not given, the module will attempt to find only the C bindings. # # On UNIX systems, this module will read the variable HDF5_USE_STATIC_LIBRARIES # to determine whether or not to prefer a static link to a dynamic link for HDF5 @@ -34,6 +34,8 @@ # HDF5_CXX_LIBRARIES - Required libraries for the HDF5 C++ bindings # HDF5_Fortran_LIBRARIES - Required libraries for the HDF5 Fortran bindings # HDF5_HL_LIBRARIES - Required libraries for the HDF5 high level API +# HDF5_Fortran_HL_LIBRARIES - Required libraries for the high level Fortran +# bindings. # HDF5_LIBRARIES - Required libraries for all requested bindings # HDF5_FOUND - true if HDF5 was found on the system # HDF5_LIBRARY_DIRS - the full set of library directories @@ -67,6 +69,7 @@ set( HDF5_VALID_COMPONENTS CXX Fortran HL + Fortran_HL ) # Validate the list of find components. @@ -189,6 +192,7 @@ if( NOT HDF5_FOUND ) set( HDF5_CXX_TARGET hdf5_cpp ) set( HDF5_HL_TARGET hdf5_hl ) set( HDF5_Fortran_TARGET hdf5_fortran ) + set( HDF5_Fortran_HL_TARGET hdf5_hl_fortran ) foreach( _component ${HDF5_LANGUAGE_BINDINGS} ) list( FIND HDF5_VALID_COMPONENTS ${_component} _component_location ) get_target_property( _comp_location ${HDF5_${_component}_TARGET} LOCATION ) @@ -211,7 +215,10 @@ if( NOT HDF5_FOUND ) set( HDF5_C_LIBRARY_NAMES_INIT hdf5 ) set( HDF5_HL_LIBRARY_NAMES_INIT hdf5_hl ${HDF5_C_LIBRARY_NAMES_INIT} ) set( HDF5_CXX_LIBRARY_NAMES_INIT hdf5_cpp ${HDF5_C_LIBRARY_NAMES_INIT} ) - set( HDF5_Fortran_LIBRARY_NAMES_INIT hdf5_fortran ${HDF5_C_LIBRARY_NAMES_INIT} ) + set( HDF5_Fortran_LIBRARY_NAMES_INIT hdf5_fortran + ${HDF5_C_LIBRARY_NAMES_INIT} ) + set( HDF5_Fortran_HL_LIBRARY_NAMES_INIT hdf5hl_fortran + ${HDF5_Fortran_LIBRARY_NAMES_INIT} ) foreach( LANGUAGE ${HDF5_LANGUAGE_BINDINGS} ) if( HDF5_${LANGUAGE}_COMPILE_LINE ) @@ -222,8 +229,8 @@ if( NOT HDF5_FOUND ) HDF5_${LANGUAGE}_LIBRARY_NAMES ) - # take a guess that the includes may be in the 'include' sibling directory - # of a library directory. + # take a guess that the includes may be in the 'include' sibling + # directory of a library directory. foreach( dir ${HDF5_${LANGUAGE}_LIBRARY_DIRS} ) list( APPEND HDF5_${LANGUAGE}_INCLUDE_FLAGS ${dir}/../include ) endforeach() @@ -233,7 +240,7 @@ if( NOT HDF5_FOUND ) list( APPEND HDF5_DEFINITIONS ${HDF5_${LANGUAGE}_DEFINITIONS} ) # find the HDF5 include directories - if(${LANGUAGE} STREQUAL "Fortran") + if(${LANGUAGE} MATCHES "Fortran.*") set(HDF5_INCLUDE_FILENAME hdf5.mod) else() set(HDF5_INCLUDE_FILENAME hdf5.h) diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index 6431836bf..34a7077e8 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -5,6 +5,8 @@ # # Java_JAVA_EXECUTABLE = the full path to the Java runtime # Java_JAVAC_EXECUTABLE = the full path to the Java compiler +# Java_JAVAH_EXECUTABLE = the full path to the Java header generator +# Java_JAVADOC_EXECUTABLE = the full path to the Java documention generator # Java_JAR_EXECUTABLE = the full path to the Java archiver # Java_VERSION_STRING = Version of the package found (java version), eg. 1.6.0_12 # Java_VERSION_MAJOR = The major version of the package found. @@ -128,11 +130,6 @@ IF(Java_JAVA_EXECUTABLE) else( ) set(Java_VERSION ${Java_VERSION_MAJOR}.${Java_VERSION_MINOR}.${Java_VERSION_PATCH}.${Java_VERSION_TWEAK}) endif( ) - # display info - #MESSAGE( STATUS "Java version ${Java_VERSION_STRING} configured successfully!" ) # keep me, used for debug - IF(NOT Java_FIND_QUIETLY) - MESSAGE( STATUS "Java version ${Java_VERSION} configured successfully!" ) - ENDIF(NOT Java_FIND_QUIETLY) ENDIF() ENDIF(Java_JAVA_EXECUTABLE) @@ -150,6 +147,18 @@ FIND_PROGRAM(Java_JAVAC_EXECUTABLE PATHS ${_JAVA_PATHS} ) +FIND_PROGRAM(Java_JAVAH_EXECUTABLE + NAMES javah + HINTS ${_JAVA_HINTS} + PATHS ${_JAVA_PATHS} +) + +FIND_PROGRAM(Java_JAVADOC_EXECUTABLE + NAMES javadoc + HINTS ${_JAVA_HINTS} + PATHS ${_JAVA_PATHS} +) + include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) if(Java_FIND_COMPONENTS) foreach(component ${Java_FIND_COMPONENTS}) @@ -162,6 +171,7 @@ if(Java_FIND_COMPONENTS) elseif(component STREQUAL "Development") find_package_handle_standard_args(Java REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE + Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE VERSION_VAR Java_VERSION ) else() @@ -173,6 +183,7 @@ else() # Check for everything find_package_handle_standard_args(Java REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE + Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE VERSION_VAR Java_VERSION ) endif() @@ -182,6 +193,8 @@ MARK_AS_ADVANCED( Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE + Java_JAVAH_EXECUTABLE + Java_JAVADOC_EXECUTABLE ) # LEGACY diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index bf4540677..884266fc9 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -36,6 +36,8 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES) if (NOT _LANGUAGES_ MATCHES Fortran) include(CheckFunctionExists) @@ -46,6 +48,8 @@ endif (NOT _LANGUAGES_ MATCHES Fortran) set(LAPACK_FOUND FALSE) set(LAPACK95_FOUND FALSE) +# TODO: move this stuff to separate module + 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 @@ -61,38 +65,38 @@ macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas _threads set(_libraries_work TRUE) set(${LIBRARIES}) set(_combined_name) +if (NOT _libdir) + if (WIN32) + set(_libdir ENV LIB) + elseif (APPLE) + set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH) + else () + set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH) + endif () +endif () 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 - ) - ENDIF (WIN32) - - if(APPLE) - if(BLA_STATIC) - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so;.dylib") - endif(BLA_STATIC) + if (BLA_STATIC) + if (WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif ( WIN32 ) + if (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else (APPLE) + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + endif (APPLE) + else (BLA_STATIC) + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + # for ubuntu's libblas3gf and liblapack3gf packages + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf) + endif () + 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) - 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 - ) - endif(APPLE) - + NAMES ${_library} + PATHS ${_libdir} + ) mark_as_advanced(${_prefix}_${_library}_LIBRARY) set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY}) set(_libraries_work ${${_prefix}_${_library}_LIBRARY}) @@ -102,7 +106,7 @@ endforeach(_library ${_list}) if(_libraries_work) # Test this combination of libraries. if(UNIX AND BLA_STATIC) - set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group ${${LIBRARIES}} ${_blas};-Wl,--end-group" ${_threads}) + 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) @@ -119,7 +123,7 @@ if(_libraries_work) endif(_libraries_work) if(_libraries_work) - set(${LIBRARIES} ${${LIBRARIES}} ${_blas}) + set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threads}) else(_libraries_work) set(${LIBRARIES} FALSE) endif(_libraries_work) @@ -148,31 +152,28 @@ if(BLAS_FOUND) set(BLA_VENDOR "All") endif(NOT BLA_VENDOR) endif ($ENV{BLA_VENDOR} MATCHES ".+") + +if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") + if(NOT LAPACK_LIBRARIES) + check_lapack_libraries( + LAPACK_LIBRARIES + LAPACK + cheev + "" + "goto2" + "${BLAS_LIBRARIES}" + "" + ) + endif(NOT LAPACK_LIBRARIES) +endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All") + + #acml lapack - if (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "acml;acml_mv" - "" - "" - ) - endif(NOT LAPACK_LIBRARIES) - if(NOT LAPACK_LIBRARIES) - check_lapack_libraries( - LAPACK_LIBRARIES - LAPACK - cheev - "" - "acml_mp;acml_mv" - "" - "" - ) - endif(NOT LAPACK_LIBRARIES) - endif (BLA_VENDOR STREQUAL "ACML" OR BLA_VENDOR STREQUAL "All") + if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All") + if (BLAS_LIBRARIES MATCHES ".+acml.+") + set (LAPACK_LIBRARIES ${BLAS_LIBRARIES}) + endif () + endif () # Apple LAPACK library? if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All") @@ -202,7 +203,9 @@ if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All") 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 (BLA_VENDOR STREQUAL "Generic" OR + BLA_VENDOR STREQUAL "ATLAS" OR + BLA_VENDOR STREQUAL "All") if ( NOT LAPACK_LIBRARIES ) check_lapack_libraries( LAPACK_LIBRARIES @@ -214,7 +217,7 @@ if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") "" ) endif ( NOT LAPACK_LIBRARIES ) -endif (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All") +endif () #intel lapack if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All") if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX) @@ -300,3 +303,5 @@ else(BLA_F95) endif(LAPACK_FOUND) endif(NOT LAPACK_FIND_QUIETLY) endif(BLA_F95) + +set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) diff --git a/Modules/FindLibXslt.cmake b/Modules/FindLibXslt.cmake index 462835a51..1f49c3bda 100644 --- a/Modules/FindLibXslt.cmake +++ b/Modules/FindLibXslt.cmake @@ -5,6 +5,9 @@ # LIBXSLT_INCLUDE_DIR - the LibXslt include directory # LIBXSLT_LIBRARIES - Link these to LibXslt # LIBXSLT_DEFINITIONS - Compiler switches required for using LibXslt +# Additionally, the following two variables are set (but not required for using xslt): +# LIBXSLT_EXSLT_LIBRARIES - Link to these if you need to link against the exslt library +# LIBXSLT_XSLTPROC_EXECUTABLE - Contains the full path to the xsltproc executable if found #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -23,7 +26,7 @@ # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls FIND_PACKAGE(PkgConfig) -PKG_CHECK_MODULES(PC_LIBXSLT libxslt) +PKG_CHECK_MODULES(PC_LIBXSLT QUIET libxslt) SET(LIBXSLT_DEFINITIONS ${PC_LIBXSLT_CFLAGS_OTHER}) FIND_PATH(LIBXSLT_INCLUDE_DIR NAMES libxslt/xslt.h @@ -38,10 +41,22 @@ FIND_LIBRARY(LIBXSLT_LIBRARIES NAMES xslt libxslt ${PC_LIBXSLT_LIBRARY_DIRS} ) -# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if +FIND_LIBRARY(LIBXSLT_EXSLT_LIBRARY NAMES exslt libexslt + HINTS + ${PC_LIBXSLT_LIBDIR} + ${PC_LIBXSLT_LIBRARY_DIRS} + ) + +SET(LIBXSLT_EXSLT_LIBRARIES ${LIBXSLT_EXSLT_LIBRARY} ) + +FIND_PROGRAM(LIBXSLT_XSLTPROC_EXECUTABLE xsltproc) + +# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if # all listed variables are TRUE INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXslt DEFAULT_MSG LIBXSLT_LIBRARIES LIBXSLT_INCLUDE_DIR) -MARK_AS_ADVANCED(LIBXSLT_INCLUDE_DIR LIBXSLT_LIBRARIES) - +MARK_AS_ADVANCED(LIBXSLT_INCLUDE_DIR + LIBXSLT_LIBRARIES + LIBXSLT_EXSLT_LIBRARY + LIBXSLT_XSLTPROC_EXECUTABLE) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 1d42a91d2..250d8a6b3 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -184,8 +184,15 @@ endforeach() # (Windows implementations) do not have compiler wrappers, so this approach must be used. # function (interrogate_mpi_compiler lang try_libs) - # if it's already in the cache, don't bother with any of this stuff - if ((NOT MPI_${lang}_INCLUDE_PATH) OR (NOT MPI_${lang}_LIBRARIES)) + # MPI_${lang}_NO_INTERROGATE will be set to a compiler name when the *regular* compiler was + # discovered to be the MPI compiler. This happens on machines like the Cray XE6 that use + # modules to set cc, CC, and ftn to the MPI compilers. If the user force-sets another MPI + # compiler, MPI_${lang}_COMPILER won't be equal to MPI_${lang}_NO_INTERROGATE, and we'll + # inspect that compiler anew. This allows users to set new compilers w/o rm'ing cache. + string(COMPARE NOTEQUAL "${MPI_${lang}_NO_INTERROGATE}" "${MPI_${lang}_COMPILER}" interrogate) + + # If MPI is set already in the cache, don't bother with interrogating the compiler. + if (interrogate AND ((NOT MPI_${lang}_INCLUDE_PATH) OR (NOT MPI_${lang}_LIBRARIES))) if (MPI_${lang}_COMPILER) # Check whether the -showme:compile option works. This indicates that we have either OpenMPI # or a newer version of LAM-MPI, and implies that -showme:link will also work. @@ -436,6 +443,47 @@ function (interrogate_mpi_compiler lang try_libs) endfunction() +# This function attempts to compile with the regular compiler, to see if MPI programs +# work with it. This is a last ditch attempt after we've tried interrogating mpicc and +# friends, and after we've tried to find generic libraries. Works on machines like +# Cray XE6, where the modules environment changes what MPI version cc, CC, and ftn use. +function(try_regular_compiler lang success) + set(scratch_directory ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}) + if (${lang} STREQUAL Fortran) + set(test_file ${scratch_directory}/cmake_mpi_test.f90) + file(WRITE ${test_file} + "program hello\n" + "include 'mpif.h'\n" + "integer ierror\n" + "call MPI_INIT(ierror)\n" + "call MPI_FINALIZE(ierror)\n" + "end\n") + else() + if (${lang} STREQUAL CXX) + set(test_file ${scratch_directory}/cmake_mpi_test.cpp) + else() + set(test_file ${scratch_directory}/cmake_mpi_test.c) + endif() + file(WRITE ${test_file} + "#include \n" + "int main(int argc, char **argv) {\n" + " MPI_Init(&argc, &argv);\n" + " MPI_Finalize();\n" + "}\n") + endif() + try_compile(compiler_has_mpi ${scratch_directory} ${test_file}) + if (compiler_has_mpi) + set(MPI_${lang}_NO_INTERROGATE ${CMAKE_${lang}_COMPILER} CACHE STRING "Whether to interrogate MPI ${lang} compiler" FORCE) + set(MPI_${lang}_COMPILER ${CMAKE_${lang}_COMPILER} CACHE STRING "MPI ${lang} compiler" FORCE) + set(MPI_${lang}_COMPILE_FLAGS "" CACHE STRING "MPI ${lang} compilation flags" FORCE) + set(MPI_${lang}_INCLUDE_PATH "" CACHE STRING "MPI ${lang} include path" FORCE) + set(MPI_${lang}_LINK_FLAGS "" CACHE STRING "MPI ${lang} linking flags" FORCE) + set(MPI_${lang}_LIBRARIES "" CACHE STRING "MPI ${lang} libraries to link against" FORCE) + endif() + set(${success} ${compiler_has_mpi} PARENT_SCOPE) + unset(compiler_has_mpi CACHE) +endfunction() + # End definitions, commence real work here. # Most mpi distros have some form of mpiexec which gives us something we can reliably look for. @@ -507,8 +555,18 @@ foreach (lang C CXX Fortran) interrogate_mpi_compiler(${lang} ${try_libs}) mark_as_advanced(MPI_${lang}_COMPILER) - # Treat each language separately as far as outputting whether we found support for it and setting MPI__FOUND. - find_package_handle_standard_args(MPI_${lang} DEFAULT_MSG MPI_${lang}_LIBRARIES MPI_${lang}_INCLUDE_PATH) + # last ditch try -- if nothing works so far, just try running the regular compiler and + # see if we can create an MPI executable. + set(regular_compiler_worked 0) + if (NOT MPI_${lang}_LIBRARIES OR NOT MPI_${lang}_INCLUDE_PATH) + try_regular_compiler(${lang} regular_compiler_worked) + endif() + + if (regular_compiler_worked) + find_package_handle_standard_args(MPI_${lang} DEFAULT_MSG MPI_${lang}_COMPILER) + else() + find_package_handle_standard_args(MPI_${lang} DEFAULT_MSG MPI_${lang}_LIBRARIES MPI_${lang}_INCLUDE_PATH) + endif() endif() endforeach() diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index f607dc669..f61697309 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -1,14 +1,18 @@ # - Find the native PNG includes and library # -# This module defines -# PNG_INCLUDE_DIR, where to find png.h, etc. +# This module searches libpng, the library for working with PNG images. +# +# It defines the following variables +# PNG_INCLUDE_DIRS, where to find png.h, etc. # PNG_LIBRARIES, the libraries to link against to use PNG. # PNG_DEFINITIONS - You should add_definitons(${PNG_DEFINITIONS}) before compiling code that includes png library files. # PNG_FOUND, If false, do not try to use PNG. -# also defined, but not for general use are +# Also defined, but not for general use are # PNG_LIBRARY, where to find the PNG library. -# None of the above will be defined unles zlib can be found. -# PNG depends on Zlib +# For backward compatiblity the variable PNG_INCLUDE_DIR is also set. It has the same value as PNG_INCLUDE_DIRS. +# +# Since PNG depends on the ZLib compression library, none of the above will be +# defined unless ZLib can be found. #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -38,7 +42,8 @@ if(ZLIB_FOUND) if (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR) # png.h includes zlib.h. Sigh. - SET(PNG_INCLUDE_DIR ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ) + SET(PNG_INCLUDE_DIRS ${PNG_PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ) + SET(PNG_INCLUDE_DIR ${PNG_INCLUDE_DIRS} ) # for backward compatiblity SET(PNG_LIBRARIES ${PNG_LIBRARY} ${ZLIB_LIBRARY}) if (CYGWIN) diff --git a/Modules/FindPackageMessage.cmake b/Modules/FindPackageMessage.cmake index eb398b2ae..48d3472b5 100644 --- a/Modules/FindPackageMessage.cmake +++ b/Modules/FindPackageMessage.cmake @@ -34,6 +34,7 @@ FUNCTION(FIND_PACKAGE_MESSAGE pkg msg details) # Avoid printing a message repeatedly for the same find result. IF(NOT ${pkg}_FIND_QUIETLY) + STRING(REGEX REPLACE "[\n]" "" details "${details}") SET(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) IF(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") # The message has not yet been printed. diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index 96b674112..55f95c617 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -7,7 +7,6 @@ # ... # if( PostgreSQL_FOUND ) # include_directories(${PostgreSQL_INCLUDE_DIRS}) -# link_directories(${PostgreSQL_LIBRARY_DIRS}) # endif( PostgreSQL_FOUND ) # ... # Remember to include ${PostgreSQL_LIBRARIES} in the target_link_libraries() statement. @@ -113,12 +112,26 @@ find_path(PostgreSQL_INCLUDE_DIR # Look in other places. ${PostgreSQL_ROOT_DIRECTORIES} PATH_SUFFIXES + pgsql postgresql include # Help the user find it if we cannot. DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}" ) +find_path(PostgreSQL_TYPE_INCLUDE_DIR + NAMES catalog/pg_type.h + PATHS + # Look in other places. + ${PostgreSQL_ROOT_DIRECTORIES} + PATH_SUFFIXES + pgsql/server + postgresql/server + include/server + # Help the user find it if we cannot. + DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}" +) + # The PostgreSQL library. set (PostgreSQL_LIBRARY_TO_FIND pq) # Setting some more prefixes for the library @@ -138,42 +151,22 @@ find_library( PostgreSQL_LIBRARY get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH) # Did we find anything? -set( PostgreSQL_FOUND 0 ) -if ( EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" ) - set( PostgreSQL_FOUND 1 ) -else ( EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" ) - if ( POSTGRES_REQUIRED ) - message( FATAL_ERROR "PostgreSQL is required. ${PostgreSQL_ROOT_DIR_MESSAGE}" ) - endif ( POSTGRES_REQUIRED ) -endif (EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" ) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PostgreSQL DEFAULT_MSG + PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR) + +set( PostgreSQL_FOUND ${POSTGRESQL_FOUND}) # Now try to get the include and library path. if(PostgreSQL_FOUND) - if(EXISTS "${PostgreSQL_INCLUDE_DIR}") - set(PostgreSQL_INCLUDE_DIRS - ${PostgreSQL_INCLUDE_DIR} - ) - endif(EXISTS "${PostgreSQL_INCLUDE_DIR}") - - if(EXISTS "${PostgreSQL_LIBRARY_DIR}") - set(PostgreSQL_LIBRARY_DIRS - ${PostgreSQL_LIBRARY_DIR} - ) - set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND}) - endif(EXISTS "${PostgreSQL_LIBRARY_DIR}") + set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} ${PostgreSQL_TYPE_INCLUDE_DIR} ) + set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} ) + set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND}) #message("Final PostgreSQL include dir: ${PostgreSQL_INCLUDE_DIRS}") #message("Final PostgreSQL library dir: ${PostgreSQL_LIBRARY_DIRS}") #message("Final PostgreSQL libraries: ${PostgreSQL_LIBRARIES}") endif(PostgreSQL_FOUND) -if(NOT PostgreSQL_FOUND) - if(NOT PostgreSQL_FIND_QUIETLY) - message(STATUS "PostgreSQL was not found. ${PostgreSQL_DIR_MESSAGE}") - else(NOT PostgreSQL_FIND_QUIETLY) - if(PostgreSQL_FIND_REQUIRED) - message(FATAL_ERROR "PostgreSQL was not found. ${PostgreSQL_DIR_MESSAGE}") - endif(PostgreSQL_FIND_REQUIRED) - endif(NOT PostgreSQL_FIND_QUIETLY) -endif(NOT PostgreSQL_FOUND) +mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR PostgreSQL_LIBRARY ) diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index 38f5a7572..53443040d 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -39,7 +39,11 @@ # target_link_libraries(bar ${PROTOBUF_LIBRARIES}) # # NOTE: You may need to link against pthreads, depending -# on the platform. +# on the platform. +# +# NOTE: The PROTOBUF_GENERATE_CPP macro & add_executable() or add_library() +# calls only work properly within the same directory. +# # ==================================================================== # # PROTOBUF_GENERATE_CPP (public function) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 46cde437f..a10ec2371 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -4,11 +4,17 @@ # # PYTHONINTERP_FOUND - Was the Python executable found # PYTHON_EXECUTABLE - path to the Python interpreter -# Python_ADDITIONAL_VERSIONS - list of additional Python versions to search for # +# PYTHON_VERSION_STRING - Python version found e.g. 2.5.2 +# PYTHON_VERSION_MAJOR - Python major version found e.g. 2 +# PYTHON_VERSION_MINOR - Python minor version found e.g. 5 +# PYTHON_VERSION_PATCH - Python patch version found e.g. 2 +# +# Python_ADDITIONAL_VERSIONS - list of additional Python versions to search for #============================================================================= # Copyright 2005-2010 Kitware, Inc. +# Copyright 2011 Bjoern Ricks # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -20,32 +26,41 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +# Search for the current active python version first +find_program(PYTHON_EXECUTABLE NAMES python) + # Set up the versions we know about, in the order we will search. Always add # the user supplied additional versions to the front. set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS} 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) -# Run first with the Python version in the executable -foreach(_CURRENT_VERSION ${_Python_VERSIONS}) - set(_Python_NAMES python${_CURRENT_VERSION}) - if(WIN32) - list(APPEND _Python_NAMES python) - endif() - find_program(PYTHON_EXECUTABLE - NAMES ${_Python_NAMES} - PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] - ) -endforeach() -# Now without any version if we still haven't found it +# Search for newest python version if python executable isn't found if(NOT PYTHON_EXECUTABLE) - find_program(PYTHON_EXECUTABLE NAMES python) + foreach(_CURRENT_VERSION ${_Python_VERSIONS}) + set(_Python_NAMES python${_CURRENT_VERSION}) + if(WIN32) + list(APPEND _Python_NAMES python) + endif() + find_program(PYTHON_EXECUTABLE + NAMES ${_Python_NAMES} + PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] + ) + endforeach() endif() +# determine python version string +if(PYTHON_EXECUTABLE) + execute_process(COMMAND "${PYTHON_EXECUTABLE}" --version ERROR_VARIABLE _VERSION OUTPUT_QUIET ERROR_STRIP_TRAILING_WHITESPACE) + string(REPLACE "Python " "" PYTHON_VERSION_STRING "${_VERSION}") + string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}") + string(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}") + string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PYTHON_VERSION_PATCH "${PYTHON_VERSION_STRING}") +endif() # handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if # all listed variables are TRUE include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonInterp DEFAULT_MSG PYTHON_EXECUTABLE) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonInterp REQUIRED_VARS PYTHON_EXECUTABLE VERSION_VAR PYTHON_VERSION_STRING) mark_as_advanced(PYTHON_EXECUTABLE) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 86fce9df6..c56827eaa 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -352,7 +352,7 @@ IF(QT_QT_LIBRARY) ENDIF(QT_QT_LIBRARY) -INCLUDE(CheckSymbolExists) +INCLUDE(CheckCXXSymbolExists) INCLUDE(MacroAddFileDependencies) INCLUDE(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) @@ -578,19 +578,6 @@ IF (QT_QMAKE_EXECUTABLE AND QTVERSION) ENDIF () - IF (APPLE) - SET(CMAKE_FIND_FRAMEWORK_OLD ${CMAKE_FIND_FRAMEWORK}) - IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - SET(QT_USE_FRAMEWORKS ON CACHE INTERNAL "" FORCE) - SET(CMAKE_FIND_FRAMEWORK FIRST) - ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - SET(QT_USE_FRAMEWORKS OFF CACHE INTERNAL "" FORCE) - SET(CMAKE_FIND_FRAMEWORK LAST) - ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - ENDIF (APPLE) - - _QT4_ADJUST_LIB_VARS(QtCore) - # set QT_LIBRARY_DIR based on location of QtCore found. IF(QT_QTCORE_LIBRARY_RELEASE) GET_FILENAME_COMPONENT(QT_LIBRARY_DIR_TMP "${QT_QTCORE_LIBRARY_RELEASE}" PATH) @@ -614,13 +601,24 @@ IF (QT_QMAKE_EXECUTABLE AND QTVERSION) SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "" FORCE) ENDIF (NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) + IF (APPLE) + SET(CMAKE_FIND_FRAMEWORK_OLD ${CMAKE_FIND_FRAMEWORK}) + IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) + SET(QT_USE_FRAMEWORKS ON CACHE INTERNAL "" FORCE) + SET(CMAKE_FIND_FRAMEWORK FIRST) + ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) + SET(QT_USE_FRAMEWORKS OFF CACHE INTERNAL "" FORCE) + SET(CMAKE_FIND_FRAMEWORK LAST) + ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) + ENDIF (APPLE) + # ask qmake for the include dir IF (QT_LIBRARY_DIR AND (NOT QT_QTCORE_INCLUDE_DIR OR NOT QT_HEADERS_DIR OR QT_QMAKE_CHANGED)) _qt4_query_qmake(QT_INSTALL_HEADERS qt_headers) SET(QT_QTCORE_INCLUDE_DIR NOTFOUND) FIND_PATH(QT_QTCORE_INCLUDE_DIR QtCore HINTS ${qt_headers} ${QT_LIBRARY_DIR} - PATH_SUFFIXES QtCore + PATH_SUFFIXES QtCore qt4/QtCore ) # Set QT_HEADERS_DIR based on finding QtCore header @@ -717,19 +715,19 @@ IF (QT_QMAKE_EXECUTABLE AND QTVERSION) # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}") # Check for Window system symbols (note: only one should end up being set) - CHECK_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11) - CHECK_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN) - CHECK_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS) - CHECK_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC) + CHECK_CXX_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11) + CHECK_CXX_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN) + CHECK_CXX_SYMBOL_EXISTS(Q_WS_QWS "QtCore/qglobal.h" Q_WS_QWS) + CHECK_CXX_SYMBOL_EXISTS(Q_WS_MAC "QtCore/qglobal.h" Q_WS_MAC) IF(Q_WS_MAC) IF(QT_QMAKE_CHANGED) UNSET(QT_MAC_USE_COCOA CACHE) ENDIF(QT_QMAKE_CHANGED) - CHECK_SYMBOL_EXISTS(QT_MAC_USE_COCOA "QtCore/qconfig.h" QT_MAC_USE_COCOA) + CHECK_CXX_SYMBOL_EXISTS(QT_MAC_USE_COCOA "QtCore/qconfig.h" QT_MAC_USE_COCOA) ENDIF(Q_WS_MAC) IF (QT_QTCOPY_REQUIRED) - CHECK_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY) + CHECK_CXX_SYMBOL_EXISTS(QT_IS_QTCOPY "QtCore/qglobal.h" QT_KDE_QT_COPY) IF (NOT QT_IS_QTCOPY) MESSAGE(FATAL_ERROR "qt-copy is required, but hasn't been found") ENDIF (NOT QT_IS_QTCOPY) @@ -864,10 +862,11 @@ IF (QT_QMAKE_EXECUTABLE AND QTVERSION) ) ENDFOREACH(QT_MODULE) - # QtUiTools not with other frameworks with binary installation (in /usr/lib) - IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) + # QtUiTools is sometimes not in the same directory as the other found libraries + # e.g. on Mac, its never a framework like the others are + IF(QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) FIND_LIBRARY(QT_QTUITOOLS_LIBRARY_RELEASE NAMES QtUiTools${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR}) - ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) + ENDIF(QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTUITOOLS_LIBRARY_RELEASE) # Set QT_QTDESIGNERCOMPONENTS_LIBRARY FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents${QT_LIBINFIX} QtDesignerComponents${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) @@ -904,6 +903,8 @@ IF (QT_QMAKE_EXECUTABLE AND QTVERSION) # Set QT_xyz_LIBRARY variable and add # library include path to QT_INCLUDES + _QT4_ADJUST_LIB_VARS(QtCore) + FOREACH(QT_MODULE ${QT_MODULES}) _QT4_ADJUST_LIB_VARS(${QT_MODULE}) ENDFOREACH(QT_MODULE) @@ -1061,6 +1062,14 @@ IF (QT_QMAKE_EXECUTABLE AND QTVERSION) SET( QT_SCRIPT_PLUGINS qtscriptdbus ) SET( QT_SQLDRIVERS_PLUGINS qsqldb2 qsqlibase qsqlite qsqlite2 qsqlmysql qsqloci qsqlodbc qsqlpsql qsqltds ) + SET( QT_PHONON_PLUGINS ${QT_PHONON_BACKEND_PLUGINS} ) + SET( QT_QT3SUPPORT_PLUGINS qtaccessiblecompatwidgets ) + SET( QT_QTCORE_PLUGINS ${QT_BEARER_PLUGINS} ${QT_CODECS_PLUGINS} ) + SET( QT_QTGUI_PLUGINS qtaccessiblewidgets qgif qjpeg qmng qico qtiff ${QT_DECORATIONS_PLUGINS} ${QT_GRAPHICSDRIVERS_PLUGINS} ${QT_GRAPHICSSYSTEMS_PLUGINS} ${QT_INPUTMETHODS_PLUGINS} ${QT_MOUSEDRIVERS_PLUGINS} ) + SET( QT_QTSCRIPT_PLUGINS ${QT_SCRIPT_PLUGINS} ) + SET( QT_QTSQL_PLUGINS ${QT_SQLDRIVERS_PLUGINS} ) + SET( QT_QTSVG_PLUGINS qsvg qsvgicon ) + IF(QT_QMAKE_CHANGED) FOREACH(QT_PLUGIN_TYPE ${QT_PLUGIN_TYPES}) STRING(TOUPPER ${QT_PLUGIN_TYPE} _upper_qt_plugin_type) diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index 80fb216e9..ae2ea2e33 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -137,7 +137,7 @@ IF(RUBY_EXECUTABLE AND NOT RUBY_MAJOR_VERSION) ) ENDIF(RUBY_EXECUTABLE AND NOT RUBY_MAJOR_VERSION) -# In case RUBY_EXECUTABLE could not be executed (e.g. cross compiling) +# In case RUBY_EXECUTABLE could not be executed (e.g. cross compiling) # try to detect which version we found. This is not too good. IF(NOT RUBY_VERSION_MAJOR) # by default assume 1.8.0 @@ -170,9 +170,9 @@ SET(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIR} ) IF( ${Ruby_FIND_VERSION_SHORT_NODOT} GREATER 18 OR ${_RUBY_VERSION_SHORT_NODOT} GREATER 18 OR RUBY_HDR_DIR) FIND_PATH(RUBY_CONFIG_INCLUDE_DIR NAMES ruby/config.h config.h - HINTS + HINTS ${RUBY_HDR_DIR}/${RUBY_ARCH} - ${RUBY_ARCH_DIR} + ${RUBY_ARCH_DIR} ) SET(RUBY_INCLUDE_DIRS ${RUBY_INCLUDE_DIRS} ${RUBY_CONFIG_INCLUDE_DIR} ) @@ -180,7 +180,7 @@ ENDIF( ${Ruby_FIND_VERSION_SHORT_NODOT} GREATER 18 OR ${_RUBY_VERSION_SHORT_NO # Determine the list of possible names for the ruby library -SET(_RUBY_POSSIBLE_LIB_NAMES ruby ruby-static ruby${_RUBY_VERSION_SHORT}) +SET(_RUBY_POSSIBLE_LIB_NAMES ruby ruby-static ruby${_RUBY_VERSION_SHORT} ruby${_RUBY_VERSION_SHORT_NODOT}) IF(WIN32) SET( _RUBY_MSVC_RUNTIME "" ) @@ -202,7 +202,7 @@ IF(WIN32) LIST(APPEND _RUBY_POSSIBLE_LIB_NAMES "msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}" - "msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}-static" + "msvcr${_RUBY_MSVC_RUNTIME}-ruby${_RUBY_NODOT_VERSION}-static" "msvcrt-ruby${_RUBY_NODOT_VERSION}" "msvcrt-ruby${_RUBY_NODOT_VERSION}-static" ) ENDIF(WIN32) diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake index d8cdacb56..4166d99ab 100644 --- a/Modules/FindSubversion.cmake +++ b/Modules/FindSubversion.cmake @@ -109,7 +109,7 @@ IF(Subversion_SVN_EXECUTABLE) # 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} + ${Subversion_SVN_EXECUTABLE} --non-interactive log -r BASE ${dir} OUTPUT_VARIABLE ${prefix}_LAST_CHANGED_LOG ERROR_VARIABLE Subversion_svn_log_error RESULT_VARIABLE Subversion_svn_log_result diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index df4497923..04646c0af 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -6,6 +6,7 @@ # # and also the following more fine grained variables: # Include paths: X11_ICE_INCLUDE_PATH, X11_ICE_LIB, X11_ICE_FOUND +# X11_SM_INCLUDE_PATH, X11_SM_LIB, X11_SM_FOUND # X11_X11_INCLUDE_PATH, X11_X11_LIB # X11_Xaccessrules_INCLUDE_PATH, X11_Xaccess_FOUND # X11_Xaccessstr_INCLUDE_PATH, X11_Xaccess_FOUND @@ -27,6 +28,7 @@ # X11_Xinput_INCLUDE_PATH, X11_Xinput_LIB, X11_Xinput_FOUND # X11_Xkb_INCLUDE_PATH, X11_Xkb_FOUND # X11_Xkblib_INCLUDE_PATH, X11_Xkb_FOUND +# X11_Xkbfile_INCLUDE_PATH, X11_Xkbfile_LIB, X11_Xkbfile_FOUND # X11_Xpm_INCLUDE_PATH, X11_Xpm_LIB, X11_Xpm_FOUND # X11_XTest_INCLUDE_PATH, X11_XTest_LIB, X11_XTest_FOUND # X11_Xrandr_INCLUDE_PATH, X11_Xrandr_LIB, X11_Xrandr_FOUND @@ -35,6 +37,8 @@ # X11_Xt_INCLUDE_PATH, X11_Xt_LIB, X11_Xt_FOUND # X11_Xutil_INCLUDE_PATH, X11_Xutil_FOUND # X11_Xv_INCLUDE_PATH, X11_Xv_LIB, X11_Xv_FOUND +# X11_XSync_INCLUDE_PATH, (in X11_Xext_LIB), X11_XSync_FOUND + #============================================================================= # Copyright 2001-2009 Kitware, Inc. @@ -57,11 +61,11 @@ IF (UNIX) SET(CMAKE_FIND_FRAMEWORK NEVER) SET(X11_INC_SEARCH_PATH /usr/pkg/xorg/include - /usr/X11R6/include - /usr/X11R7/include + /usr/X11R6/include + /usr/X11R7/include /usr/include/X11 - /usr/openwin/include - /usr/openwin/share/include + /usr/openwin/include + /usr/openwin/share/include /opt/graphics/OpenGL/include ) @@ -69,7 +73,7 @@ IF (UNIX) /usr/pkg/xorg/lib /usr/X11R6/lib /usr/X11R7/lib - /usr/openwin/lib + /usr/openwin/lib ) FIND_PATH(X11_X11_INCLUDE_PATH X11/X.h ${X11_INC_SEARCH_PATH}) @@ -77,9 +81,10 @@ IF (UNIX) # Look for includes; keep the list sorted by name of the cmake *_INCLUDE_PATH # variable (which doesn't need to match the include file name). - + # Solaris lacks XKBrules.h, so we should skip kxkbd there. FIND_PATH(X11_ICE_INCLUDE_PATH X11/ICE/ICE.h ${X11_INC_SEARCH_PATH}) + FIND_PATH(X11_SM_INCLUDE_PATH X11/SM/SM.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xaccessrules_INCLUDE_PATH X11/extensions/XKBrules.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xaccessstr_INCLUDE_PATH X11/extensions/XKBstr.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xau_INCLUDE_PATH X11/Xauth.h ${X11_INC_SEARCH_PATH}) @@ -97,16 +102,19 @@ IF (UNIX) FIND_PATH(X11_Xinput_INCLUDE_PATH X11/extensions/XInput.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xkb_INCLUDE_PATH X11/extensions/XKB.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xkblib_INCLUDE_PATH X11/XKBlib.h ${X11_INC_SEARCH_PATH}) + FIND_PATH(X11_Xkbfile_INCLUDE_PATH X11/extensions/XKBfile.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xpm_INCLUDE_PATH X11/xpm.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_XTest_INCLUDE_PATH X11/extensions/XTest.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_XShm_INCLUDE_PATH X11/extensions/XShm.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xrandr_INCLUDE_PATH X11/extensions/Xrandr.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xrender_INCLUDE_PATH X11/extensions/Xrender.h ${X11_INC_SEARCH_PATH}) + FIND_PATH(X11_XRes_INCLUDE_PATH X11/extensions/XRes.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xscreensaver_INCLUDE_PATH X11/extensions/scrnsaver.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xshape_INCLUDE_PATH X11/extensions/shape.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xutil_INCLUDE_PATH X11/Xutil.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xt_INCLUDE_PATH X11/Intrinsic.h ${X11_INC_SEARCH_PATH}) FIND_PATH(X11_Xv_INCLUDE_PATH X11/extensions/Xvlib.h ${X11_INC_SEARCH_PATH}) + FIND_PATH(X11_XSync_INCLUDE_PATH X11/extensions/sync.h ${X11_INC_SEARCH_PATH}) FIND_LIBRARY(X11_X11_LIB X11 ${X11_LIB_SEARCH_PATH}) @@ -125,9 +133,11 @@ IF (UNIX) FIND_LIBRARY(X11_Xi_LIB Xi ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xinerama_LIB Xinerama ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xinput_LIB Xi ${X11_LIB_SEARCH_PATH}) + FIND_LIBRARY(X11_Xkbfile_LIB xkbfile ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xpm_LIB Xpm ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xrandr_LIB Xrandr ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xrender_LIB Xrender ${X11_LIB_SEARCH_PATH}) + FIND_LIBRARY(X11_XRes_LIB XRes ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xscreensaver_LIB Xss ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_Xt_LIB Xt ${X11_LIB_SEARCH_PATH}) FIND_LIBRARY(X11_XTest_LIB Xtst ${X11_LIB_SEARCH_PATH}) @@ -242,6 +252,11 @@ IF (UNIX) SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xrender_INCLUDE_PATH}) ENDIF (X11_Xrender_INCLUDE_PATH AND X11_Xrender_LIB) + IF (X11_XRes_INCLUDE_PATH AND X11_XRes_LIB) + SET(X11_XRes_FOUND TRUE) + SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_XRes_INCLUDE_PATH}) + ENDIF (X11_XRes_INCLUDE_PATH AND X11_XRes_LIB) + IF (X11_Xrandr_INCLUDE_PATH AND X11_Xrandr_LIB) SET(X11_Xrandr_FOUND TRUE) SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xrandr_INCLUDE_PATH}) @@ -277,15 +292,30 @@ IF (UNIX) SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xkb_INCLUDE_PATH} ) ENDIF (X11_Xkb_INCLUDE_PATH AND X11_Xkblib_INCLUDE_PATH AND X11_Xlib_INCLUDE_PATH) + IF (X11_Xkbfile_INCLUDE_PATH AND X11_Xkbfile_LIB AND X11_Xlib_INCLUDE_PATH) + SET(X11_Xkbfile_FOUND TRUE) + SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xkbfile_INCLUDE_PATH} ) + ENDIF (X11_Xkbfile_INCLUDE_PATH AND X11_Xkbfile_LIB AND X11_Xlib_INCLUDE_PATH) + IF (X11_Xinput_INCLUDE_PATH AND X11_Xinput_LIB) SET(X11_Xinput_FOUND TRUE) SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xinput_INCLUDE_PATH}) ENDIF (X11_Xinput_INCLUDE_PATH AND X11_Xinput_LIB) + IF (X11_XSync_INCLUDE_PATH) + SET(X11_XSync_FOUND TRUE) + SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_XSync_INCLUDE_PATH}) + ENDIF (X11_XSync_INCLUDE_PATH) + IF(X11_ICE_LIB AND X11_ICE_INCLUDE_PATH) SET(X11_ICE_FOUND TRUE) ENDIF(X11_ICE_LIB AND X11_ICE_INCLUDE_PATH) + IF(X11_SM_LIB AND X11_SM_INCLUDE_PATH) + SET(X11_SM_FOUND TRUE) + ENDIF(X11_SM_LIB AND X11_SM_INCLUDE_PATH) + + # Deprecated variable for backwards compatibility with CMake 1.4 IF (X11_X11_INCLUDE_PATH AND X11_LIBRARIES) SET(X11_FOUND 1) @@ -306,11 +336,11 @@ IF (UNIX) CHECK_LIBRARY_EXISTS("${X11_LIBRARIES}" "XOpenDisplay" "${X11_LIBRARY_DIR}" X11_LIB_X11_SOLO) IF(NOT X11_LIB_X11_SOLO) # Find library needed for dnet_ntoa. - CHECK_LIBRARY_EXISTS("dnet" "dnet_ntoa" "" X11_LIB_DNET_HAS_DNET_NTOA) + CHECK_LIBRARY_EXISTS("dnet" "dnet_ntoa" "" X11_LIB_DNET_HAS_DNET_NTOA) IF (X11_LIB_DNET_HAS_DNET_NTOA) SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -ldnet) ELSE (X11_LIB_DNET_HAS_DNET_NTOA) - CHECK_LIBRARY_EXISTS("dnet_stub" "dnet_ntoa" "" X11_LIB_DNET_STUB_HAS_DNET_NTOA) + CHECK_LIBRARY_EXISTS("dnet_stub" "dnet_ntoa" "" X11_LIB_DNET_STUB_HAS_DNET_NTOA) IF (X11_LIB_DNET_STUB_HAS_DNET_NTOA) SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -ldnet_stub) ENDIF (X11_LIB_DNET_STUB_HAS_DNET_NTOA) @@ -320,11 +350,11 @@ IF (UNIX) # Find library needed for gethostbyname. CHECK_FUNCTION_EXISTS("gethostbyname" CMAKE_HAVE_GETHOSTBYNAME) IF(NOT CMAKE_HAVE_GETHOSTBYNAME) - CHECK_LIBRARY_EXISTS("nsl" "gethostbyname" "" CMAKE_LIB_NSL_HAS_GETHOSTBYNAME) + CHECK_LIBRARY_EXISTS("nsl" "gethostbyname" "" CMAKE_LIB_NSL_HAS_GETHOSTBYNAME) IF (CMAKE_LIB_NSL_HAS_GETHOSTBYNAME) SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lnsl) ELSE (CMAKE_LIB_NSL_HAS_GETHOSTBYNAME) - CHECK_LIBRARY_EXISTS("bsd" "gethostbyname" "" CMAKE_LIB_BSD_HAS_GETHOSTBYNAME) + CHECK_LIBRARY_EXISTS("bsd" "gethostbyname" "" CMAKE_LIB_BSD_HAS_GETHOSTBYNAME) IF (CMAKE_LIB_BSD_HAS_GETHOSTBYNAME) SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lbsd) ENDIF (CMAKE_LIB_BSD_HAS_GETHOSTBYNAME) @@ -334,7 +364,7 @@ IF (UNIX) # Find library needed for connect. CHECK_FUNCTION_EXISTS("connect" CMAKE_HAVE_CONNECT) IF(NOT CMAKE_HAVE_CONNECT) - CHECK_LIBRARY_EXISTS("socket" "connect" "" CMAKE_LIB_SOCKET_HAS_CONNECT) + CHECK_LIBRARY_EXISTS("socket" "connect" "" CMAKE_LIB_SOCKET_HAS_CONNECT) IF (CMAKE_LIB_SOCKET_HAS_CONNECT) SET (X11_X_EXTRA_LIBS -lsocket ${X11_X_EXTRA_LIBS}) ENDIF (CMAKE_LIB_SOCKET_HAS_CONNECT) @@ -343,7 +373,7 @@ IF (UNIX) # Find library needed for remove. CHECK_FUNCTION_EXISTS("remove" CMAKE_HAVE_REMOVE) IF(NOT CMAKE_HAVE_REMOVE) - CHECK_LIBRARY_EXISTS("posix" "remove" "" CMAKE_LIB_POSIX_HAS_REMOVE) + CHECK_LIBRARY_EXISTS("posix" "remove" "" CMAKE_LIB_POSIX_HAS_REMOVE) IF (CMAKE_LIB_POSIX_HAS_REMOVE) SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lposix) ENDIF (CMAKE_LIB_POSIX_HAS_REMOVE) @@ -352,7 +382,7 @@ IF (UNIX) # Find library needed for shmat. CHECK_FUNCTION_EXISTS("shmat" CMAKE_HAVE_SHMAT) IF(NOT CMAKE_HAVE_SHMAT) - CHECK_LIBRARY_EXISTS("ipc" "shmat" "" CMAKE_LIB_IPS_HAS_SHMAT) + CHECK_LIBRARY_EXISTS("ipc" "shmat" "" CMAKE_LIB_IPS_HAS_SHMAT) IF (CMAKE_LIB_IPS_HAS_SHMAT) SET (X11_X_EXTRA_LIBS ${X11_X_EXTRA_LIBS} -lipc) ENDIF (CMAKE_LIB_IPS_HAS_SHMAT) @@ -401,6 +431,8 @@ IF (UNIX) X11_Xdamage_INCLUDE_PATH X11_Xrender_LIB X11_Xrender_INCLUDE_PATH + X11_XRes_LIB + X11_XRes_INCLUDE_PATH X11_Xxf86misc_LIB X11_xf86misc_INCLUDE_PATH X11_xf86vmode_INCLUDE_PATH @@ -422,6 +454,8 @@ IF (UNIX) X11_Xdmcp_INCLUDE_PATH X11_Xkb_INCLUDE_PATH X11_Xkblib_INCLUDE_PATH + X11_Xkbfile_INCLUDE_PATH + X11_Xkbfile_LIB X11_Xscreensaver_INCLUDE_PATH X11_Xscreensaver_LIB X11_Xpm_INCLUDE_PATH @@ -437,6 +471,8 @@ IF (UNIX) X11_ICE_LIB X11_ICE_INCLUDE_PATH X11_SM_LIB + X11_SM_INCLUDE_PATH + X11_XSync_INCLUDE_PATH ) SET(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_SAVE}) ENDIF (UNIX) diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index 77f9fda0c..166e29181 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -17,9 +17,12 @@ # ZLIB_MAJOR_VERSION - The major version of zlib # ZLIB_MINOR_VERSION - The minor version of zlib # ZLIB_PATCH_VERSION - The patch version of zlib +# +# An includer may set ZLIB_ROOT to a zlib installation root to tell +# this module where to look. #============================================================================= -# Copyright 2001-2009 Kitware, Inc. +# Copyright 2001-2011 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -31,17 +34,29 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -FIND_PATH(ZLIB_INCLUDE_DIR zlib.h - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/include" -) +SET(_ZLIB_SEARCHES) + +# Search ZLIB_ROOT first if it is set. +IF(ZLIB_ROOT) + SET(_ZLIB_SEARCH_ROOT PATHS ${ZLIB_ROOT} NO_DEFAULT_PATH) + LIST(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_ROOT) +ENDIF() + +# Normal search. +SET(_ZLIB_SEARCH_NORMAL + PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]" + "$ENV{PROGRAMFILES}/zlib" + ) +LIST(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL) SET(ZLIB_NAMES z zlib zdll zlib1 zlibd zlibd1) -FIND_LIBRARY(ZLIB_LIBRARY - NAMES - ${ZLIB_NAMES} - PATHS - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/lib" -) + +# Try each search configuration. +FOREACH(search ${_ZLIB_SEARCHES}) + FIND_PATH(ZLIB_INCLUDE_DIR NAMES zlib.h ${${search}} PATH_SUFFIXES include) + FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} ${${search}} PATH_SUFFIXES lib) +ENDFOREACH() + MARK_AS_ADVANCED(ZLIB_LIBRARY ZLIB_INCLUDE_DIR) IF(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake index 90ef59be1..2455c5f8b 100644 --- a/Modules/FortranCInterface.cmake +++ b/Modules/FortranCInterface.cmake @@ -116,6 +116,14 @@ endforeach() #----------------------------------------------------------------------------- set(FortranCInterface_SOURCE_DIR ${CMAKE_ROOT}/Modules/FortranCInterface) +# MinGW's make tool does not always like () in the path +if("${CMAKE_GENERATOR}" MATCHES "MinGW" AND + "${FortranCInterface_SOURCE_DIR}" MATCHES "[()]") + file(COPY ${FortranCInterface_SOURCE_DIR}/ + DESTINATION ${CMAKE_BINARY_DIR}/CMakeFiles/FortranCInterfaceMinGW) + set(FortranCInterface_SOURCE_DIR ${CMAKE_BINARY_DIR}/CMakeFiles/FortranCInterfaceMinGW) +endif() + # Create the interface detection project if it does not exist. if(NOT FortranCInterface_BINARY_DIR) set(FortranCInterface_BINARY_DIR ${CMAKE_BINARY_DIR}/CMakeFiles/FortranCInterface) diff --git a/Modules/FortranCInterface/Verify/CMakeLists.txt b/Modules/FortranCInterface/Verify/CMakeLists.txt index 052dd599f..e969f2408 100644 --- a/Modules/FortranCInterface/Verify/CMakeLists.txt +++ b/Modules/FortranCInterface/Verify/CMakeLists.txt @@ -24,7 +24,9 @@ include(FortranCInterface) FortranCInterface_HEADER(VerifyFortran.h SYMBOLS VerifyFortran) include_directories(${VerifyFortranC_BINARY_DIR}) -add_executable(VerifyFortranC main.c VerifyC.c VerifyFortran.f ${VerifyCXX}) +add_library(VerifyFortran STATIC VerifyFortran.f) +add_executable(VerifyFortranC main.c VerifyC.c ${VerifyCXX}) +target_link_libraries(VerifyFortranC VerifyFortran) if(NOT VERIFY_CXX) # The entry point (main) is defined in C; link with the C compiler. diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake new file mode 100644 index 000000000..7df274e4f --- /dev/null +++ b/Modules/GenerateExportHeader.cmake @@ -0,0 +1,377 @@ +# - Function for generation of export macros for libraries +# This module provides the function GENERATE_EXPORT_HEADER() and the +# accompanying ADD_COMPILER_EXPORT_FLAGS() function. +# +# The GENERATE_EXPORT_HEADER function can be used to generate a file suitable +# for preprocessor inclusion which contains EXPORT macros to be used in +# library classes. +# +# GENERATE_EXPORT_HEADER( LIBRARY_TARGET +# [BASE_NAME ] +# [EXPORT_MACRO_NAME ] +# [EXPORT_FILE_NAME ] +# [DEPRECATED_MACRO_NAME ] +# [NO_EXPORT_MACRO_NAME ] +# [STATIC_DEFINE ] +# [NO_DEPRECATED_MACRO_NAME ] +# [DEFINE_NO_DEPRECATED] +# [PREFIX_NAME ] +# ) +# +# ADD_COMPILER_EXPORT_FLAGS( [FATAL_WARNINGS] ) +# +# By default GENERATE_EXPORT_HEADER() generates macro names in a file name +# determined by the name of the library. The ADD_COMPILER_EXPORT_FLAGS function +# adds -fvisibility=hidden to CMAKE_CXX_FLAGS if supported, and is a no-op on +# Windows which does not need extra compiler flags for exporting support. You +# may optionally pass a single argument to ADD_COMPILER_EXPORT_FLAGS that will +# be populated with the required CXX_FLAGS required to enable visibility support +# for the compiler/architecture in use. +# +# This means that in the simplest case, users of these functions will be +# equivalent to: +# +# add_compiler_export_flags() +# add_library(somelib someclass.cpp) +# generate_export_header(somelib) +# install(TARGETS somelib DESTINATION ${LIBRARY_INSTALL_DIR}) +# install(FILES +# someclass.h +# ${PROJECT_BINARY_DIR}/somelib_export.h DESTINATION ${INCLUDE_INSTALL_DIR} +# ) +# +# And in the ABI header files: +# +# #include "somelib_export.h" +# class SOMELIB_EXPORT SomeClass { +# ... +# }; +# +# The CMake fragment will generate a file in the ${CMAKE_CURRENT_BUILD_DIR} +# called somelib_export.h containing the macros SOMELIB_EXPORT, SOMELIB_NO_EXPORT, +# SOMELIB_DEPRECATED, SOMELIB_DEPRECATED_EXPORT and SOMELIB_DEPRECATED_NO_EXPORT. +# The resulting file should be installed with other headers in the library. +# +# The BASE_NAME argument can be used to override the file name and the names +# used for the macros +# +# add_library(somelib someclass.cpp) +# generate_export_header(somelib +# BASE_NAME other_name +# ) +# +# Generates a file called other_name_export.h containing the macros +# OTHER_NAME_EXPORT, OTHER_NAME_NO_EXPORT and OTHER_NAME_DEPRECATED etc. +# +# The BASE_NAME may be overridden by specifiying other options in the function. +# For example: +# +# add_library(somelib someclass.cpp) +# generate_export_header(somelib +# EXPORT_MACRO_NAME OTHER_NAME_EXPORT +# ) +# +# creates the macro OTHER_NAME_EXPORT instead of SOMELIB_EXPORT, but other macros +# and the generated file name is as default. +# +# add_library(somelib someclass.cpp) +# generate_export_header(somelib +# DEPRECATED_MACRO_NAME KDE_DEPRECATED +# ) +# +# creates the macro KDE_DEPRECATED instead of SOMELIB_DEPRECATED. +# +# If LIBRARY_TARGET is a static library, macros are defined without values. +# +# If the same sources are used to create both a shared and a static library, the +# uppercased symbol ${BASE_NAME}_STATIC_DEFINE should be used when building the +# static library +# +# add_library(shared_variant SHARED ${lib_SRCS}) +# add_library(static_variant ${lib_SRCS}) +# generate_export_header(shared_variant BASE_NAME libshared_and_static) +# set_target_properties(static_variant PROPERTIES +# COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) +# +# This will cause the export macros to expand to nothing when building the +# static library. +# +# If DEFINE_NO_DEPRECATED is specified, then a macro ${BASE_NAME}_NO_DEPRECATED +# will be defined +# This macro can be used to remove deprecated code from preprocessor output. +# +# option(EXCLUDE_DEPRECATED "Exclude deprecated parts of the library" FALSE) +# if (EXCLUDE_DEPRECATED) +# set(NO_BUILD_DEPRECATED DEFINE_NO_DEPRECATED) +# endif() +# generate_export_header(somelib ${NO_BUILD_DEPRECATED}) +# +# And then in somelib: +# +# class SOMELIB_EXPORT SomeClass +# { +# public: +# #ifndef SOMELIB_NO_DEPRECATED +# SOMELIB_DEPRECATED void oldMethod(); +# #endif +# }; +# +# #ifndef SOMELIB_NO_DEPRECATED +# void SomeClass::oldMethod() { } +# #endif +# +# If PREFIX_NAME is specified, the argument will be used as a prefix to all +# generated macros. +# +# For example: +# +# generate_export_header(somelib PREFIX_NAME VTK_) +# +# Generates the macros VTK_SOMELIB_EXPORT etc. + +#============================================================================= +# Copyright 2011 Stephen Kelly +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +include(CMakeParseArguments) +include(CheckCXXCompilerFlag) + +# TODO: Install this macro separately? +macro(_check_cxx_compiler_attribute _ATTRIBUTE _RESULT) + check_cxx_source_compiles("${_ATTRIBUTE} int somefunc() { return 0; } + int main() { return somefunc();}" ${_RESULT} + # Some compilers do not fail with a bad flag + FAIL_REGEX "unrecognized .*option" # GNU + FAIL_REGEX "ignoring unknown option" # MSVC + FAIL_REGEX "warning D9002" # MSVC, any lang + FAIL_REGEX "[Uu]nknown option" # HP + FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro + FAIL_REGEX "command option .* is not recognized" # XL + ) +endmacro() + +macro(_test_compiler_hidden_visibility) + + if(CMAKE_COMPILER_IS_GNUCXX) + exec_program(${CMAKE_C_COMPILER} ARGS --version + OUTPUT_VARIABLE _gcc_version_info) + string(REGEX MATCH "[345]\\.[0-9]\\.[0-9]" + _gcc_version "${_gcc_version_info}") + # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the + # patch level, handle this here: + if(NOT _gcc_version) + string(REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" + _gcc_version "${_gcc_version_info}") + endif() + + if(${_gcc_version} VERSION_LESS "4.2") + set(GCC_TOO_OLD TRUE) + message(WARNING "GCC version older than 4.2") + endif() + endif() + + if(CMAKE_CXX_COMPILER_ID MATCHES Intel) + exec_program(${CMAKE_CXX_COMPILER} ARGS -V + OUTPUT_VARIABLE _intel_version_info) + string(REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" "\\1" + _intel_version "${_intel_version_info}") + + if(${_intel_version} VERSION_LESS "12.0") + set(_INTEL_TOO_OLD TRUE) + message(WARNING "Intel compiler older than 12.0") + endif() + endif() + + + # Exclude XL here because it misinterprets -fvisibility=hidden even though + # the check_cxx_compiler_flag passes + # http://www.cdash.org/CDash/testDetails.php?test=109109951&build=1419259 + if(NOT GCC_TOO_OLD + AND NOT _INTEL_TOO_OLD + AND NOT WIN32 + AND NOT CYGWIN + AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES XL + AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES PGI + AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES Watcom) + check_cxx_compiler_flag(-fvisibility=hidden COMPILER_HAS_HIDDEN_VISIBILITY) + check_cxx_compiler_flag(-fvisibility-inlines-hidden + COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) + option(USE_COMPILER_HIDDEN_VISIBILITY + "Use HIDDEN visibility support if available." ON) + mark_as_advanced(USE_COMPILER_HIDDEN_VISIBILITY) + endif() +endmacro() + +macro(_test_compiler_has_deprecated) + if("${CMAKE_CXX_COMPILER_ID}" MATCHES Borland + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES HP + OR GCC_TOO_OLD + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES PGI + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Watcom) + set(COMPILER_HAS_DEPRECATED "" CACHE INTERNAL + "Compiler support for a deprecated attribute") + else() + _check_cxx_compiler_attribute("__attribute__((__deprecated__))" + COMPILER_HAS_DEPRECATED_ATTR) + if(COMPILER_HAS_DEPRECATED_ATTR) + set(COMPILER_HAS_DEPRECATED "${COMPILER_HAS_DEPRECATED_ATTR}" + CACHE INTERNAL "Compiler support for a deprecated attribute") + else() + _check_cxx_compiler_attribute("__declspec(deprecated)" + COMPILER_HAS_DEPRECATED) + endif() + endif() +endmacro() + +get_filename_component(_GENERATE_EXPORT_HEADER_MODULE_DIR + "${CMAKE_CURRENT_LIST_FILE}" PATH) + +macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY) + set(DEFINE_DEPRECATED) + set(DEFINE_EXPORT) + set(DEFINE_IMPORT) + set(DEFINE_NO_EXPORT) + + if (COMPILER_HAS_DEPRECATED_ATTR) + set(DEFINE_DEPRECATED "__attribute__ ((__deprecated__))") + elseif(COMPILER_HAS_DEPRECATED) + set(DEFINE_DEPRECATED "__declspec(deprecated)") + endif() + + get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE) + + if(NOT ${type} STREQUAL "STATIC_LIBRARY") + if(WIN32) + set(DEFINE_EXPORT "__declspec(dllexport)") + set(DEFINE_IMPORT "__declspec(dllimport)") + elseif(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY) + set(DEFINE_EXPORT "__attribute__((visibility(\"default\")))") + set(DEFINE_IMPORT "__attribute__((visibility(\"default\")))") + set(DEFINE_NO_EXPORT "__attribute__((visibility(\"hidden\")))") + endif() + endif() +endmacro() + +macro(_DO_GENERATE_EXPORT_HEADER TARGET_LIBRARY) + # Option overrides + set(options DEFINE_NO_DEPRECATED) + set(oneValueArgs PREFIX_NAME BASE_NAME EXPORT_MACRO_NAME EXPORT_FILE_NAME + DEPRECATED_MACRO_NAME NO_EXPORT_MACRO_NAME STATIC_DEFINE + NO_DEPRECATED_MACRO_NAME) + set(multiValueArgs) + + cmake_parse_arguments(_GEH "${options}" "${oneValueArgs}" "${multiValueArgs}" + ${ARGN}) + + set(BASE_NAME "${TARGET_LIBRARY}") + + if(_GEH_BASE_NAME) + set(BASE_NAME ${_GEH_BASE_NAME}) + endif() + + string(TOUPPER ${BASE_NAME} BASE_NAME_UPPER) + string(TOLOWER ${BASE_NAME} BASE_NAME_LOWER) + + # Default options + set(EXPORT_MACRO_NAME "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_EXPORT") + set(NO_EXPORT_MACRO_NAME "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_NO_EXPORT") + set(EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${BASE_NAME_LOWER}_export.h") + set(DEPRECATED_MACRO_NAME "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_DEPRECATED") + set(STATIC_DEFINE "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_STATIC_DEFINE") + set(NO_DEPRECATED_MACRO_NAME + "${_GEH_PREFIX_NAME}${BASE_NAME_UPPER}_NO_DEPRECATED") + + if(_GEH_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to GENERATE_EXPORT_HEADER(): \"${_GEH_UNPARSED_ARGUMENTS}\"") + endif() + + if(_GEH_EXPORT_MACRO_NAME) + set(EXPORT_MACRO_NAME ${_GEH_PREFIX_NAME}${_GEH_EXPORT_MACRO_NAME}) + endif() + if(_GEH_EXPORT_FILE_NAME) + if(IS_ABSOLUTE _GEH_EXPORT_FILE_NAME) + set(EXPORT_FILE_NAME ${_GEH_EXPORT_FILE_NAME}) + else() + set(EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/${_GEH_EXPORT_FILE_NAME}") + endif() + endif() + if(_GEH_DEPRECATED_MACRO_NAME) + set(DEPRECATED_MACRO_NAME ${_GEH_PREFIX_NAME}${_GEH_DEPRECATED_MACRO_NAME}) + endif() + if(_GEH_NO_EXPORT_MACRO_NAME) + set(NO_EXPORT_MACRO_NAME ${_GEH_PREFIX_NAME}${_GEH_NO_EXPORT_MACRO_NAME}) + endif() + if(_GEH_STATIC_DEFINE) + set(STATIC_DEFINE ${_GEH_PREFIX_NAME}${_GEH_STATIC_DEFINE}) + endif() + + if(_GEH_DEFINE_NO_DEPRECATED) + set(DEFINE_NO_DEPRECATED TRUE) + endif() + + if(_GEH_NO_DEPRECATED_MACRO_NAME) + set(NO_DEPRECATED_MACRO_NAME + ${_GEH_PREFIX_NAME}${_GEH_NO_DEPRECATED_MACRO_NAME}) + endif() + + set(INCLUDE_GUARD_NAME "${EXPORT_MACRO_NAME}_H") + + get_target_property(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY} DEFINE_SYMBOL) + + if(NOT EXPORT_IMPORT_CONDITION) + set(EXPORT_IMPORT_CONDITION ${TARGET_LIBRARY}_EXPORTS) + endif() + + configure_file("${_GENERATE_EXPORT_HEADER_MODULE_DIR}/exportheader.cmake.in" + "${EXPORT_FILE_NAME}" @ONLY) +endmacro() + +function(GENERATE_EXPORT_HEADER TARGET_LIBRARY) + get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE) + if(${type} STREQUAL "MODULE") + message(WARNING "This macro should not be used with libraries of type MODULE") + return() + endif() + if(NOT ${type} STREQUAL "STATIC_LIBRARY" AND NOT ${type} STREQUAL "SHARED_LIBRARY") + message(WARNING "This macro can only be used with libraries") + return() + endif() + _test_compiler_hidden_visibility() + _test_compiler_has_deprecated() + _do_set_macro_values(${TARGET_LIBRARY}) + _do_generate_export_header(${TARGET_LIBRARY} ${ARGN}) +endfunction() + +function(add_compiler_export_flags) + + _test_compiler_hidden_visibility() + _test_compiler_has_deprecated() + + if(NOT (USE_COMPILER_HIDDEN_VISIBILITY AND COMPILER_HAS_HIDDEN_VISIBILITY)) + # Just return if there are no flags to add. + return() + endif() + + set (EXTRA_FLAGS "-fvisibility=hidden") + + if(COMPILER_HAS_HIDDEN_INLINE_VISIBILITY) + set (EXTRA_FLAGS "${EXTRA_FLAGS} -fvisibility-inlines-hidden") + endif() + + # Either return the extra flags needed in the supplied argument, or to the + # CMAKE_CXX_FLAGS if no argument is supplied. + if(ARGV0) + set(${ARGV0} "${EXTRA_FLAGS}" PARENT_SCOPE) + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_FLAGS}" PARENT_SCOPE) + endif() +endfunction() diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 023b8b560..2efa07999 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -24,7 +24,7 @@ # PARENT_SCOPE. # # GET_PREREQUISITES( -# ) +# ) # Get the list of shared library files required by . The list in # the variable named should be empty on first entry to # this function. On exit, will contain the list of diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 59e5ec168..65d254a4a 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -141,36 +141,46 @@ IF(MSVC) ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES) ENDIF(MSVC90) - IF(MSVC10) + MACRO(MSVCRT_FILES_FOR_VERSION version) + SET(v "${version}") + # Find the runtime library redistribution directory. GET_FILENAME_COMPONENT(msvc_install_dir - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0;InstallDir]" ABSOLUTE) - FIND_PATH(MSVC10_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\${v}.0;InstallDir]" ABSOLUTE) + FIND_PATH(MSVC${v}_REDIST_DIR NAMES ${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT PATHS "${msvc_install_dir}/../../VC/redist" "${base_dir}/VC/redist" - "$ENV{ProgramFiles}/Microsoft Visual Studio 10.0/VC/redist" - "$ENV{ProgramFiles(x86)}/Microsoft Visual Studio 10.0/VC/redist" + "$ENV{ProgramFiles}/Microsoft Visual Studio ${v}.0/VC/redist" + "$ENV{ProgramFiles(x86)}/Microsoft Visual Studio ${v}.0/VC/redist" ) - MARK_AS_ADVANCED(MSVC10_REDIST_DIR) - SET(MSVC10_CRT_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.CRT") + MARK_AS_ADVANCED(MSVC${v}_REDIST_DIR) + SET(MSVC${v}_CRT_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.CRT") IF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY) SET(__install__libs - "${MSVC10_CRT_DIR}/msvcp100.dll" - "${MSVC10_CRT_DIR}/msvcr100.dll" + "${MSVC${v}_CRT_DIR}/msvcp${v}0.dll" + "${MSVC${v}_CRT_DIR}/msvcr${v}0.dll" ) ENDIF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY) IF(CMAKE_INSTALL_DEBUG_LIBRARIES) - SET(MSVC10_CRT_DIR - "${MSVC10_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC100.DebugCRT") + SET(MSVC${v}_CRT_DIR + "${MSVC${v}_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.DebugCRT") SET(__install__libs ${__install__libs} - "${MSVC10_CRT_DIR}/msvcp100d.dll" - "${MSVC10_CRT_DIR}/msvcr100d.dll" + "${MSVC${v}_CRT_DIR}/msvcp${v}0d.dll" + "${MSVC${v}_CRT_DIR}/msvcr${v}0d.dll" ) ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES) - ENDIF(MSVC10) + ENDMACRO() + + IF(MSVC10) + MSVCRT_FILES_FOR_VERSION(10) + ENDIF() + + IF(MSVC11) + MSVCRT_FILES_FOR_VERSION(11) + ENDIF() IF(CMAKE_INSTALL_MFC_LIBRARIES) IF(MSVC70) @@ -273,42 +283,52 @@ IF(MSVC) ) ENDIF(MSVC90) - IF(MSVC10) + MACRO(MFC_FILES_FOR_VERSION version) + SET(v "${version}") + IF(CMAKE_INSTALL_DEBUG_LIBRARIES) - SET(MSVC10_MFC_DIR - "${MSVC10_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC100.DebugMFC") + SET(MSVC${v}_MFC_DIR + "${MSVC${v}_REDIST_DIR}/Debug_NonRedist/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.DebugMFC") SET(__install__libs ${__install__libs} - "${MSVC10_MFC_DIR}/mfc100d.dll" - "${MSVC10_MFC_DIR}/mfc100ud.dll" - "${MSVC10_MFC_DIR}/mfcm100d.dll" - "${MSVC10_MFC_DIR}/mfcm100ud.dll" + "${MSVC${v}_MFC_DIR}/mfc${v}0d.dll" + "${MSVC${v}_MFC_DIR}/mfc${v}0ud.dll" + "${MSVC${v}_MFC_DIR}/mfcm${v}0d.dll" + "${MSVC${v}_MFC_DIR}/mfcm${v}0ud.dll" ) ENDIF(CMAKE_INSTALL_DEBUG_LIBRARIES) - SET(MSVC10_MFC_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.MFC") + SET(MSVC${v}_MFC_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.MFC") IF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY) SET(__install__libs ${__install__libs} - "${MSVC10_MFC_DIR}/mfc100.dll" - "${MSVC10_MFC_DIR}/mfc100u.dll" - "${MSVC10_MFC_DIR}/mfcm100.dll" - "${MSVC10_MFC_DIR}/mfcm100u.dll" + "${MSVC${v}_MFC_DIR}/mfc${v}0.dll" + "${MSVC${v}_MFC_DIR}/mfc${v}0u.dll" + "${MSVC${v}_MFC_DIR}/mfcm${v}0.dll" + "${MSVC${v}_MFC_DIR}/mfcm${v}0u.dll" ) ENDIF(NOT CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY) - # include the language dll's for vs10 as well as the actuall dll's - SET(MSVC10_MFCLOC_DIR "${MSVC10_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC100.MFCLOC") + # include the language dll's as well as the actuall dll's + SET(MSVC${v}_MFCLOC_DIR "${MSVC${v}_REDIST_DIR}/${CMAKE_MSVC_ARCH}/Microsoft.VC${v}0.MFCLOC") SET(__install__libs ${__install__libs} - "${MSVC10_MFCLOC_DIR}/mfc100chs.dll" - "${MSVC10_MFCLOC_DIR}/mfc100cht.dll" - "${MSVC10_MFCLOC_DIR}/mfc100enu.dll" - "${MSVC10_MFCLOC_DIR}/mfc100esp.dll" - "${MSVC10_MFCLOC_DIR}/mfc100deu.dll" - "${MSVC10_MFCLOC_DIR}/mfc100fra.dll" - "${MSVC10_MFCLOC_DIR}/mfc100ita.dll" - "${MSVC10_MFCLOC_DIR}/mfc100jpn.dll" - "${MSVC10_MFCLOC_DIR}/mfc100kor.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0chs.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0cht.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0enu.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0esp.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0deu.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0fra.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0ita.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0jpn.dll" + "${MSVC${v}_MFCLOC_DIR}/mfc${v}0kor.dll" ) - ENDIF(MSVC10) + ENDMACRO() + + IF(MSVC10) + MFC_FILES_FOR_VERSION(10) + ENDIF() + + IF(MSVC11) + MFC_FILES_FOR_VERSION(11) + ENDIF() ENDIF(CMAKE_INSTALL_MFC_LIBRARIES) FOREACH(lib @@ -330,6 +350,40 @@ IF(MSVC) ENDFOREACH(lib) ENDIF(MSVC) +IF(WATCOM) + GET_FILENAME_COMPONENT( CompilerPath ${CMAKE_C_COMPILER} PATH ) + IF(WATCOM17) + SET( __install__libs ${CompilerPath}/clbr17.dll + ${CompilerPath}/mt7r17.dll ${CompilerPath}/plbr17.dll ) + ENDIF() + IF(WATCOM18) + SET( __install__libs ${CompilerPath}/clbr18.dll + ${CompilerPath}/mt7r18.dll ${CompilerPath}/plbr18.dll ) + ENDIF() + IF(WATCOM19) + SET( __install__libs ${CompilerPath}/clbr19.dll + ${CompilerPath}/mt7r19.dll ${CompilerPath}/plbr19.dll ) + ENDIF() + FOREACH(lib + ${__install__libs} + ) + IF(EXISTS ${lib}) + SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS + ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} ${lib}) + ELSE() + IF(NOT CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS) + MESSAGE(WARNING "system runtime library file does not exist: '${lib}'") + # This warning indicates an incomplete Watcom installation + # or a bug somewhere above here in this file. + # If you would like to avoid this warning, fix the real problem, or + # set CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS before including + # this file. + ENDIF() + ENDIF() + ENDFOREACH() +ENDIF() + + # Include system runtime libraries in the installation if any are # specified by CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS. IF(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS) diff --git a/Modules/IntelVSImplicitPath/CMakeLists.txt b/Modules/IntelVSImplicitPath/CMakeLists.txt new file mode 100644 index 000000000..96dc4e612 --- /dev/null +++ b/Modules/IntelVSImplicitPath/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required (VERSION 2.8) +project(IntelFortranImplicit Fortran) +add_custom_command( + OUTPUT output.cmake + COMMAND ${CMAKE_COMMAND} -P ${IntelFortranImplicit_SOURCE_DIR}/detect.cmake + ) +add_library(FortranLib hello.f output.cmake) diff --git a/Modules/IntelVSImplicitPath/detect.cmake b/Modules/IntelVSImplicitPath/detect.cmake new file mode 100644 index 000000000..20753bef4 --- /dev/null +++ b/Modules/IntelVSImplicitPath/detect.cmake @@ -0,0 +1,9 @@ +# look at each path and try to find ifconsol.lib +set(LIB "$ENV{LIB}") +foreach(dir ${LIB}) + file(TO_CMAKE_PATH "${dir}" dir) + if(EXISTS "${dir}/ifconsol.lib") + file(WRITE output.cmake "list(APPEND implicit_dirs \"${dir}\")\n") + break() + endif() +endforeach() diff --git a/Modules/IntelVSImplicitPath/hello.f b/Modules/IntelVSImplicitPath/hello.f new file mode 100644 index 000000000..e69de29bb diff --git a/Modules/NSIS.template.in b/Modules/NSIS.template.in index df9d2d39d..6259a5bdf 100644 --- a/Modules/NSIS.template.in +++ b/Modules/NSIS.template.in @@ -74,7 +74,7 @@ Var AR_RegFlags ClearErrors ;Reading component status from registry - ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@\Components\${SecName}" "Installed" + ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" "Installed" IfErrors "default_${SecName}" ;Status will stay default if registry value not found ;(component was never installed) @@ -107,13 +107,13 @@ Var AR_RegFlags ;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_NAME@\Components\${SecName}" \ + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \ "Installed" 0 Goto "exit_${SecName}" "leave_${SecName}:" ;Section is selected: - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@\Components\${SecName}" \ + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \ "Installed" 1 "exit_${SecName}:" @@ -493,7 +493,7 @@ Function ConditionalAddToRegisty Pop $0 Pop $1 StrCmp "$0" "" ConditionalAddToRegisty_EmptyString - WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" \ + WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" \ "$1" "$0" ;MessageBox MB_OK "Set Registry: '$1' to '$0'" DetailPrint "Set install registry entry: '$1' to '$0'" @@ -804,17 +804,17 @@ FunctionEnd Section "Uninstall" ReadRegStr $START_MENU SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "StartMenu" + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu" ;MessageBox MB_OK "Start menu is in: $START_MENU" ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "DoNotAddToPath" + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "DoNotAddToPath" ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "AddToPathAllUsers" + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathAllUsers" ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "AddToPathCurrentUser" + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathCurrentUser" ;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS" ReadRegStr $INSTALL_DESKTOP SHCTX \ - "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" "InstallToDesktop" + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "InstallToDesktop" ;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP " @CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@ @@ -831,7 +831,7 @@ Section "Uninstall" ;Remove the uninstaller itself. Delete "$INSTDIR\Uninstall.exe" - DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_NAME@" + DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" ;Remove the installation directory if it is empty. RMDir "$INSTDIR" diff --git a/Modules/Platform/AIX-VisualAge-Fortran.cmake b/Modules/Platform/AIX-VisualAge-Fortran.cmake new file mode 100644 index 000000000..19e59d666 --- /dev/null +++ b/Modules/Platform/AIX-VisualAge-Fortran.cmake @@ -0,0 +1 @@ +include(Platform/AIX-XL-Fortran) diff --git a/Modules/Platform/BlueGeneP-base.cmake b/Modules/Platform/BlueGeneP-base.cmake index 2ca920ff0..926dbc01e 100644 --- a/Modules/Platform/BlueGeneP-base.cmake +++ b/Modules/Platform/BlueGeneP-base.cmake @@ -85,20 +85,23 @@ set(CMAKE_DL_LIBS "dl") macro(__BlueGeneP_set_dynamic_flags compiler_id lang) if (${compiler_id} STREQUAL XL) # Flags for XL compilers if we explicitly detected XL - set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-qpic") # -pic - set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj -qnostaticlink") # -shared - set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,") # -rpath - set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-qnostaticlink -qnostaticlink=libgcc") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-qpic") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj -qnostaticlink") + set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-qnostaticlink -qnostaticlink=libgcc") else() # Assume flags for GNU compilers (if the ID is GNU *or* anything else). - set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") # -pic - set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") # -shared - set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,") # -rpath - set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-dynamic") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") + set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-dynamic") endif() - set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "") # +s, flag for exe link to use shared lib - set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") # : or empty + # Both toolchains use the GNU linker on BG/P, so these options are shared. + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,-rpath,") + set(CMAKE_SHARED_LIBRARY_RPATH_LINK_${lang}_FLAG "-Wl,-rpath-link,") + set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,-soname,") + set(CMAKE_EXE_EXPORTS_${lang}_FLAG "-Wl,--export-dynamic") + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "") # +s, flag for exe link to use shared lib + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") # : or empty set(BGP_${lang}_DEFAULT_EXE_FLAGS " -o ") diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index c11c8fbaa..867c788fa 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -187,11 +187,13 @@ IF(XCODE) SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX) ENDIF(XCODE) -# Need to list dependent shared libraries on link line. When building -# with -isysroot (for universal binaries), the linker always looks for -# dependent libraries under the sysroot. Listing them on the link -# line works around the problem. -SET(CMAKE_LINK_DEPENDENT_LIBRARY_FILES 1) +IF("${_CURRENT_OSX_VERSION}" VERSION_LESS "10.5") + # Need to list dependent shared libraries on link line. When building + # with -isysroot (for universal binaries), the linker always looks for + # dependent libraries under the sysroot. Listing them on the link + # line works around the problem. + SET(CMAKE_LINK_DEPENDENT_LIBRARY_FILES 1) +ENDIF() SET(CMAKE_C_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS -w) SET(CMAKE_CXX_CREATE_SHARED_LIBRARY_FORBIDDEN_FLAGS -w) diff --git a/Modules/Platform/GNUtoMS_lib.bat.in b/Modules/Platform/GNUtoMS_lib.bat.in new file mode 100644 index 000000000..2da920ab0 --- /dev/null +++ b/Modules/Platform/GNUtoMS_lib.bat.in @@ -0,0 +1,3 @@ +@echo off +call "@CMAKE_GNUtoMS_BAT@" +lib /machine:"@CMAKE_GNUtoMS_ARCH@" %* diff --git a/Modules/Platform/GNUtoMS_lib.cmake b/Modules/Platform/GNUtoMS_lib.cmake new file mode 100644 index 000000000..ca9b0f8da --- /dev/null +++ b/Modules/Platform/GNUtoMS_lib.cmake @@ -0,0 +1,10 @@ +# Usage: cmake -Dlib=lib.bat -Ddef=out.def -Ddll=out.dll -Dimp=out.dll.a -P GNUtoMS_lib.cmake +get_filename_component(name ${dll} NAME) # .dll file name +string(REGEX REPLACE "\\.dll\\.a$" ".lib" out "${imp}") # .dll.a -> .lib +execute_process( + COMMAND ${lib} /def:${def} /name:${name} /out:${out} + RESULT_VARIABLE res + ) +if(res) + message(FATAL_ERROR "lib failed: ${res}") +endif() diff --git a/Modules/Platform/HP-UX-HP-ASM.cmake b/Modules/Platform/HP-UX-HP-ASM.cmake index 0a85905eb..05c69e41b 100644 --- a/Modules/Platform/HP-UX-HP-ASM.cmake +++ b/Modules/Platform/HP-UX-HP-ASM.cmake @@ -1,6 +1,2 @@ include(Platform/HP-UX-HP) __hpux_compiler_hp(ASM) - -set(CMAKE_SHARED_LIBRARY_CREATE_ASM_FLAGS "-E -b +nodefaultrpath -L/usr/lib") - -set(CMAKE_ASM_CREATE_SHARED_LIBRARY "ld -o ") diff --git a/Modules/Platform/HP-UX-HP-C.cmake b/Modules/Platform/HP-UX-HP-C.cmake index d83e01b26..100093590 100644 --- a/Modules/Platform/HP-UX-HP-C.cmake +++ b/Modules/Platform/HP-UX-HP-C.cmake @@ -1,11 +1,6 @@ include(Platform/HP-UX-HP) __hpux_compiler_hp(C) -set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-E -b +nodefaultrpath -L/usr/lib") - set(CMAKE_C_CREATE_PREPROCESSED_SOURCE " -E > ") set(CMAKE_C_CREATE_ASSEMBLY_SOURCE " -S -o ") set(CMAKE_C_COMPILE_OBJECT " -Aa -Ae -o -c ") - -# use ld directly to create shared libraries for hp cc -set(CMAKE_C_CREATE_SHARED_LIBRARY "ld -o ") diff --git a/Modules/Platform/HP-UX-HP-CXX.cmake b/Modules/Platform/HP-UX-HP-CXX.cmake index 8f3c70c3e..dfa1e4e45 100644 --- a/Modules/Platform/HP-UX-HP-CXX.cmake +++ b/Modules/Platform/HP-UX-HP-CXX.cmake @@ -1,8 +1,6 @@ include(Platform/HP-UX-HP) __hpux_compiler_hp(CXX) -set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "+Z -Wl,-E,+nodefaultrpath -b -L/usr/lib") - set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE " -E > ") set(CMAKE_CXX_CREATE_ASSEMBLY_SOURCE " -S " diff --git a/Modules/Platform/HP-UX-HP-Fortran.cmake b/Modules/Platform/HP-UX-HP-Fortran.cmake index 5a3ab199c..30acab807 100644 --- a/Modules/Platform/HP-UX-HP-Fortran.cmake +++ b/Modules/Platform/HP-UX-HP-Fortran.cmake @@ -1,7 +1,2 @@ include(Platform/HP-UX-HP) __hpux_compiler_hp(Fortran) - -set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-E -b -L/usr/lib") - -set(CMAKE_Fortran_CREATE_SHARED_LIBRARY - "ld -o ") diff --git a/Modules/Platform/HP-UX-HP.cmake b/Modules/Platform/HP-UX-HP.cmake index 5e70d3175..bce0a8bce 100644 --- a/Modules/Platform/HP-UX-HP.cmake +++ b/Modules/Platform/HP-UX-HP.cmake @@ -17,18 +17,14 @@ if(__HPUX_COMPILER_HP) return() endif() set(__HPUX_COMPILER_HP 1) -set(_Wl_C "") -set(_Wl_CXX "-Wl,") -set(_Wl_Fortran "") -set(_Wl_ASM "") macro(__hpux_compiler_hp lang) set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "+Z") + set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-Wl,-E,+nodefaultrpath -b -L/usr/lib") set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,+s,-E,+nodefaultrpath") - set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "${_Wl_${lang}}+b") + set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG "-Wl,+b") set(CMAKE_SHARED_LIBRARY_RUNTIME_${lang}_FLAG_SEP ":") - set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "${_Wl_${lang}}+h") - set(CMAKE_EXECUTABLE_RUNTIME_${lang}_FLAG "-Wl,+b") + set(CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG "-Wl,+h") set(CMAKE_${lang}_FLAGS_INIT "") endmacro() diff --git a/Modules/Platform/Linux-TinyCC-C.cmake b/Modules/Platform/Linux-TinyCC-C.cmake new file mode 100644 index 000000000..b753268ea --- /dev/null +++ b/Modules/Platform/Linux-TinyCC-C.cmake @@ -0,0 +1,4 @@ +SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") +SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP "") +SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "") +SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-soname ") diff --git a/Modules/Platform/Windows-GNU-C-ABI.cmake b/Modules/Platform/Windows-GNU-C-ABI.cmake new file mode 100644 index 000000000..1189263fa --- /dev/null +++ b/Modules/Platform/Windows-GNU-C-ABI.cmake @@ -0,0 +1 @@ +__windows_compiler_gnu_abi(C) diff --git a/Modules/Platform/Windows-GNU-CXX-ABI.cmake b/Modules/Platform/Windows-GNU-CXX-ABI.cmake new file mode 100644 index 000000000..f3c701c3c --- /dev/null +++ b/Modules/Platform/Windows-GNU-CXX-ABI.cmake @@ -0,0 +1 @@ +__windows_compiler_gnu_abi(CXX) diff --git a/Modules/Platform/Windows-GNU-Fortran-ABI.cmake b/Modules/Platform/Windows-GNU-Fortran-ABI.cmake new file mode 100644 index 000000000..179280b4d --- /dev/null +++ b/Modules/Platform/Windows-GNU-Fortran-ABI.cmake @@ -0,0 +1 @@ +__windows_compiler_gnu_abi(Fortran) diff --git a/Modules/Platform/Windows-GNU-Fortran.cmake b/Modules/Platform/Windows-GNU-Fortran.cmake index c66feedbb..b81b79679 100644 --- a/Modules/Platform/Windows-GNU-Fortran.cmake +++ b/Modules/Platform/Windows-GNU-Fortran.cmake @@ -1,2 +1,5 @@ include(Platform/Windows-GNU) __windows_compiler_gnu(Fortran) + +# gfortran on 64-bit MinGW defines __SIZEOF_POINTER__ +set(CMAKE_Fortran_SIZEOF_DATA_PTR_DEFAULT 4) diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index 1d3e4b5a9..dd476920b 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -108,6 +108,8 @@ macro(__windows_compiler_gnu lang) set(CMAKE_${lang}_LINK_EXECUTABLE " -o -Wl,--out-implib, ${CMAKE_GNULD_IMAGE_VERSION} ") + list(APPEND CMAKE_${lang}_ABI_FILES "Platform/Windows-GNU-${lang}-ABI") + # Support very long lists of object files. if("${CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG}" STREQUAL "@") foreach(rule CREATE_SHARED_MODULE CREATE_SHARED_LIBRARY LINK_EXECUTABLE) @@ -125,3 +127,55 @@ macro(__windows_compiler_gnu lang) endforeach() endif() endmacro() + +macro(__windows_compiler_gnu_abi lang) + if(CMAKE_NO_GNUtoMS) + set(CMAKE_GNUtoMS 0) + else() + option(CMAKE_GNUtoMS "Convert GNU import libraries to MS format (requires Visual Studio)" OFF) + endif() + + if(CMAKE_GNUtoMS AND NOT CMAKE_GNUtoMS_LIB) + # Find MS development environment setup script for this architecture. + if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4) + find_program(CMAKE_GNUtoMS_VCVARS NAMES vcvars32.bat + DOC "Visual Studio vcvars32.bat" + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VC;ProductDir]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VC;ProductDir]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VC;ProductDir]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VC;ProductDir]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1\\Setup\\VC;ProductDir]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\6.0\\Setup\\Microsoft Visual C++;ProductDir]/bin" + ) + set(CMAKE_GNUtoMS_ARCH x86) + elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) + find_program(CMAKE_GNUtoMS_VCVARS NAMES vcvarsamd64.bat + DOC "Visual Studio vcvarsamd64.bat" + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VC;ProductDir]/bin/amd64" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VC;ProductDir]/bin/amd64" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VC;ProductDir]/bin/amd64" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VC;ProductDir]/bin/amd64" + ) + set(CMAKE_GNUtoMS_ARCH amd64) + endif() + set_property(CACHE CMAKE_GNUtoMS_VCVARS PROPERTY ADVANCED 1) + if(CMAKE_GNUtoMS_VCVARS) + # Create helper script to run lib.exe from MS environment. + string(REPLACE "/" "\\" CMAKE_GNUtoMS_BAT "${CMAKE_GNUtoMS_VCVARS}") + set(CMAKE_GNUtoMS_LIB ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeGNUtoMS_lib.bat) + configure_file(${CMAKE_ROOT}/Modules/Platform/GNUtoMS_lib.bat.in ${CMAKE_GNUtoMS_LIB}) + else() + message(WARNING "Disabling CMAKE_GNUtoMS option because CMAKE_GNUtoMS_VCVARS is not set.") + set(CMAKE_GNUtoMS 0) + endif() + endif() + + if(CMAKE_GNUtoMS) + # Teach CMake how to create a MS import library at link time. + set(CMAKE_${lang}_GNUtoMS_RULE " -Wl,--output-def,.def" + " -Dlib=\"${CMAKE_GNUtoMS_LIB}\" -Ddef=.def -Ddll= -Dimp= -P \"${CMAKE_ROOT}/Modules/Platform/GNUtoMS_lib.cmake\"" + ) + endif() +endmacro() diff --git a/Modules/Platform/Windows-cl.cmake b/Modules/Platform/Windows-cl.cmake index 56582ff5d..ccccbc926 100644 --- a/Modules/Platform/Windows-cl.cmake +++ b/Modules/Platform/Windows-cl.cmake @@ -132,9 +132,9 @@ IF(MSVC_C_ARCHITECTURE_ID MATCHES 64) ELSE(MSVC_C_ARCHITECTURE_ID MATCHES 64) SET(CMAKE_CL_64 0) ENDIF(MSVC_C_ARCHITECTURE_ID MATCHES 64) -IF(CMAKE_FORCE_WIN64) +IF(CMAKE_FORCE_WIN64 OR CMAKE_FORCE_IA64) SET(CMAKE_CL_64 1) -ENDIF(CMAKE_FORCE_WIN64) +ENDIF(CMAKE_FORCE_WIN64 OR CMAKE_FORCE_IA64) IF("${MSVC_VERSION}" GREATER 1599) SET(MSVC_INCREMENTAL_DEFAULT ON) diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index e96ebb5cd..e1140df84 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -39,7 +39,7 @@ SET (CMAKE_C_STANDARD_LIBRARIES_INIT "library clbrdll.lib library plbrdll.lib l SET (CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") SET(CMAKE_C_CREATE_IMPORT_LIBRARY - "wlib -q -n -b +''") + "wlib -c -q -n -b +''") SET(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY}) SET(CMAKE_C_LINK_EXECUTABLE @@ -77,7 +77,45 @@ SET(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY}) SET(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_MODULE}) # create a C++ static library -SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -n -b '' ") +SET(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -c -n -b '' ") # create a C static library SET(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY}) + +IF(NOT CMAKE_WATCOM_COMPILER_TESTS_RUN) + SET(CMAKE_WATCOM_COMPILER_TESTS_RUN 1) + SET(testWatcomVersionFile + "${CMAKE_ROOT}/Modules/CMakeTestWatcomVersion.c") + STRING(REGEX REPLACE "/" "\\\\" testWatcomVersionFile "${testWatcomVersionFile}") + MESSAGE(STATUS "Check for Watcom compiler version") + SET(CMAKE_TEST_COMPILER ${CMAKE_C_COMPILER}) + IF (NOT CMAKE_C_COMPILER) + SET(CMAKE_TEST_COMPILER ${CMAKE_CXX_COMPILER}) + ENDIF() + EXECUTE_PROCESS(COMMAND ${CMAKE_TEST_COMPILER} + -q -pc \"${testWatcomVersionFile}\" + OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT + RESULT_VARIABLE CMAKE_COMPILER_RETURN + ) + STRING(REGEX REPLACE "\n" " " compilerVersion "${CMAKE_COMPILER_OUTPUT}") + STRING(REGEX REPLACE ".*VERSION=(.*)" "\\1" + compilerVersion "${compilerVersion}") + IF("${CMAKE_COMPILER_RETURN}" STREQUAL "0") + SET(WATCOM16) + SET(WATCOM17) + SET(WATCOM18) + SET(WATCOM19) + IF("${compilerVersion}" LESS 1270) + SET(WATCOM16 1) + ENDIF() + IF("${compilerVersion}" EQUAL 1270) + SET(WATCOM17 1) + ENDIF() + IF("${compilerVersion}" EQUAL 1280) + SET(WATCOM18 1) + ENDIF() + IF("${compilerVersion}" EQUAL 1290) + SET(WATCOM19 1) + ENDIF() + ENDIF() +ENDIF() diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index 6d7a3ec21..4da1a3fb4 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -118,7 +118,7 @@ MACRO (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options) ADD_CUSTOM_COMMAND(OUTPUT ${outfile} COMMAND ${QT_MOC_EXECUTABLE} ARGS ${moc_flags} ${moc_options} -o ${outfile} ${infile} - DEPENDS ${infile}) + DEPENDS ${infile} VERBATIM) ENDIF (WIN32) ENDMACRO (QT4_CREATE_MOC_COMMAND) @@ -165,7 +165,7 @@ MACRO (QT4_WRAP_UI outfiles ) ADD_CUSTOM_COMMAND(OUTPUT ${outfile} COMMAND ${QT_UIC_EXECUTABLE} ARGS ${ui_options} -o ${outfile} ${infile} - MAIN_DEPENDENCY ${infile}) + MAIN_DEPENDENCY ${infile} VERBATIM) SET(${outfiles} ${${outfiles}} ${outfile}) ENDFOREACH (it) @@ -203,7 +203,7 @@ MACRO (QT4_ADD_RESOURCES outfiles ) COMMAND ${QT_RCC_EXECUTABLE} ARGS ${rcc_options} -name ${outfilename} -o ${outfile} ${infile} MAIN_DEPENDENCY ${infile} - DEPENDS ${_RC_DEPENDS} "${out_depends}") + DEPENDS ${_RC_DEPENDS} "${out_depends}" VERBATIM) SET(${outfiles} ${${outfiles}} ${outfile}) ENDFOREACH (it) @@ -216,13 +216,26 @@ MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename) SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp) SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc) - # handling more arguments (as in FindQt4.cmake from KDE4) will come soon, then - # _params will be used for more than just -m - SET(_params -m) + GET_SOURCE_FILE_PROPERTY(_nonamespace ${_interface} NO_NAMESPACE) + IF(_nonamespace) + SET(_params -N -m) + ELSE(_nonamespace) + SET(_params -m) + ENDIF(_nonamespace) + + GET_SOURCE_FILE_PROPERTY(_classname ${_interface} CLASSNAME) + IF(_classname) + SET(_params ${_params} -c ${_classname}) + ENDIF(_classname) + + GET_SOURCE_FILE_PROPERTY(_include ${_interface} INCLUDE) + IF(_include) + SET(_params ${_params} -i ${_include}) + ENDIF(_include) ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile} - DEPENDS ${_infile}) + DEPENDS ${_infile} VERBATIM) SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE) @@ -267,7 +280,7 @@ MACRO(QT4_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options ADD_CUSTOM_COMMAND(OUTPUT ${_target} COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target} - DEPENDS ${_in_file} + DEPENDS ${_in_file} VERBATIM ) ENDMACRO(QT4_GENERATE_DBUS_INTERFACE) @@ -291,12 +304,12 @@ MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optional IF(_optionalClassName) ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile} - DEPENDS ${_infile} + DEPENDS ${_infile} VERBATIM ) ELSE(_optionalClassName) ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header} COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile} - DEPENDS ${_infile} + DEPENDS ${_infile} VERBATIM ) ENDIF(_optionalClassName) @@ -385,7 +398,7 @@ MACRO(QT4_CREATE_TRANSLATION _qm_files) ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file} COMMAND ${QT_LUPDATE_EXECUTABLE} ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file} - DEPENDS ${_my_sources} ${_ts_pro}) + DEPENDS ${_my_sources} ${_ts_pro} VERBATIM) ENDFOREACH(_ts_file) QT4_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles}) ENDMACRO(QT4_CREATE_TRANSLATION) @@ -406,7 +419,7 @@ MACRO(QT4_ADD_TRANSLATION _qm_files) ADD_CUSTOM_COMMAND(OUTPUT ${qm} COMMAND ${QT_LRELEASE_EXECUTABLE} ARGS ${_abs_FILE} -qm ${qm} - DEPENDS ${_abs_FILE} + DEPENDS ${_abs_FILE} VERBATIM ) SET(${_qm_files} ${${_qm_files}} ${qm}) ENDFOREACH (_current_FILE) diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake new file mode 100644 index 000000000..b78278c71 --- /dev/null +++ b/Modules/UseJava.cmake @@ -0,0 +1,861 @@ +# - Use Module for Java +# This file provides functions for Java. It is assumed that FindJava.cmake +# has already been loaded. See FindJava.cmake for information on how to +# load Java into your CMake project. +# +# add_jar(TARGET_NAME SRC1 SRC2 .. SRCN RCS1 RCS2 .. RCSN) +# +# This command creates a .jar. It compiles the given source +# files (SRC) and adds the given resource files (RCS) to the jar file. +# If only resource files are given then just a jar file is created. +# +# Additional instructions: +# To add compile flags to the target you can set these flags with +# the following variable: +# +# set(CMAKE_JAVA_COMPILE_FLAGS -nowarn) +# +# To add a path or a jar file to the class path you can do this +# with the CMAKE_JAVA_INCLUDE_PATH variable. +# +# set(CMAKE_JAVA_INCLUDE_PATH /usr/share/java/shibboleet.jar) +# +# To use a different output name for the target you can set it with: +# +# set(CMAKE_JAVA_TARGET_OUTPUT_NAME shibboleet.jar) +# add_jar(foobar foobar.java) +# +# To add a VERSION to the target output name you can set it using +# CMAKE_JAVA_TARGET_VERSION. This will create a jar file with the name +# shibboleet-1.0.0.jar and will create a symlink shibboleet.jar +# pointing to the jar with the version information. +# +# set(CMAKE_JAVA_TARGET_VERSION 1.2.0) +# add_jar(shibboleet shibbotleet.java) +# +# If the target is a JNI library, utilize the following commands to +# create a JNI symbolic link: +# +# set(CMAKE_JNI_TARGET TRUE) +# set(CMAKE_JAVA_TARGET_VERSION 1.2.0) +# add_jar(shibboleet shibbotleet.java) +# install_jar(shibboleet ${LIB_INSTALL_DIR}/shibboleet) +# install_jni_symlink(shibboleet ${JAVA_LIB_INSTALL_DIR}) +# +# If a single target needs to produce more than one jar from its +# java source code, to prevent the accumulation of duplicate class +# files in subsequent jars, set/reset CMAKE_JAR_CLASSES_PREFIX prior +# to calling the add_jar() function: +# +# set(CMAKE_JAR_CLASSES_PREFIX com/redhat/foo) +# add_jar(foo foo.java) +# +# set(CMAKE_JAR_CLASSES_PREFIX com/redhat/bar) +# add_jar(bar bar.java) +# +# Target Properties: +# The add_jar() functions sets some target properties. You can get these +# properties with the +# get_property(TARGET PROPERTY ) +# command. +# +# INSTALL_FILES The files which should be installed. This is used by +# install_jar(). +# JNI_SYMLINK The JNI symlink which should be installed. +# This is used by install_jni_symlink(). +# JAR_FILE The location of the jar file so that you can include +# it. +# CLASS_DIR The directory where the class files can be found. For +# example to use them with javah. +# +# find_jar( +# name | NAMES name1 [name2 ...] +# [PATHS path1 [path2 ... ENV var]] +# [VERSIONS version1 [version2]] +# [DOC "cache documentation string"] +# ) +# +# This command is used to find a full path to the named jar. A cache +# entry named by is created to stor the result of this command. If +# the full path to a jar is found the result is stored in the variable +# and the search will not repeated unless the variable is cleared. If +# nothing is found, the result will be -NOTFOUND, and the search +# will be attempted again next time find_jar is invoked with the same +# variable. +# The name of the full path to a file that is searched for is specified +# by the names listed after NAMES argument. Additional search locations +# can be specified after the PATHS argument. If you require special a +# version of a jar file you can specify it with the VERSIONS argument. +# The argument after DOC will be used for the documentation string in +# the cache. +# +# install_jar(TARGET_NAME DESTINATION) +# +# This command installs the TARGET_NAME files to the given DESTINATION. +# It should be called in the same scope as add_jar() or it will fail. +# +# install_jni_symlink(TARGET_NAME DESTINATION) +# +# This command installs the TARGET_NAME JNI symlinks to the given +# DESTINATION. It should be called in the same scope as add_jar() +# or it will fail. +# +# create_javadoc( +# PACKAGES pkg1 [pkg2 ...] +# [SOURCEPATH ] +# [CLASSPATH ] +# [INSTALLPATH ] +# [DOCTITLE "the documentation title"] +# [WINDOWTITLE "the title of the document"] +# [AUTHOR TRUE|FALSE] +# [USE TRUE|FALSE] +# [VERSION TRUE|FALSE] +# ) +# +# Create jave documentation based on files or packages. For more +# details please read the javadoc manpage. +# +# There are two main signatures for create_javadoc. The first +# signature works with package names on a path with source files: +# +# Example: +# create_javadoc(my_example_doc +# PACKAGES com.exmaple.foo com.example.bar +# SOURCEPATH ${CMAKE_CURRENT_SOURCE_PATH} +# CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH} +# WINDOWTITLE "My example" +# DOCTITLE "

My example

" +# AUTHOR TRUE +# USE TRUE +# VERSION TRUE +# ) +# +# The second signature for create_javadoc works on a given list of +# files. +# +# create_javadoc( +# FILES file1 [file2 ...] +# [CLASSPATH ] +# [INSTALLPATH ] +# [DOCTITLE "the documentation title"] +# [WINDOWTITLE "the title of the document"] +# [AUTHOR TRUE|FALSE] +# [USE TRUE|FALSE] +# [VERSION TRUE|FALSE] +# ) +# +# Example: +# create_javadoc(my_example_doc +# FILES ${example_SRCS} +# CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH} +# WINDOWTITLE "My example" +# DOCTITLE "

My example

" +# AUTHOR TRUE +# USE TRUE +# VERSION TRUE +# ) +# +# Both signatures share most of the options. These options are the +# same as what you can find in the javadoc manpage. Please look at +# the manpage for CLASSPATH, DOCTITLE, WINDOWTITLE, AUTHOR, USE and +# VERSION. +# +# The documentation will be by default installed to +# +# ${CMAKE_INSTALL_PREFIX}/share/javadoc/ +# +# if you don't set the INSTALLPATH. +# + +#============================================================================= +# Copyright 2010-2011 Andreas schneider +# Copyright 2010 Ben Boeckel +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +function (__java_copy_file src dest comment) + add_custom_command( + OUTPUT ${dest} + COMMAND cmake -E copy_if_different + ARGS ${src} + ${dest} + DEPENDS ${src} + COMMENT ${comment}) +endfunction (__java_copy_file src dest comment) + +# define helper scripts +set(_JAVA_CLASS_FILELIST_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaClassFilelist.cmake) +set(_JAVA_SYMLINK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaSymlinks.cmake) + +function(add_jar _TARGET_NAME) + set(_JAVA_SOURCE_FILES ${ARGN}) + + if (LIBRARY_OUTPUT_PATH) + set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH}) + else (LIBRARY_OUTPUT_PATH) + set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}) + endif (LIBRARY_OUTPUT_PATH) + + set(CMAKE_JAVA_INCLUDE_PATH + ${CMAKE_JAVA_INCLUDE_PATH} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_JAVA_OBJECT_OUTPUT_PATH} + ${CMAKE_JAVA_LIBRARY_OUTPUT_PATH} + ) + + if (WIN32 AND NOT CYGWIN) + set(CMAKE_JAVA_INCLUDE_FLAG_SEP ";") + else (WIN32 AND NOT CYGWIN) + set(CMAKE_JAVA_INCLUDE_FLAG_SEP ":") + endif(WIN32 AND NOT CYGWIN) + + foreach (JAVA_INCLUDE_DIR ${CMAKE_JAVA_INCLUDE_PATH}) + set(CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_PATH_FINAL}${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}") + endforeach(JAVA_INCLUDE_DIR) + + set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir") + + set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}.jar") + if (CMAKE_JAVA_TARGET_OUTPUT_NAME AND CMAKE_JAVA_TARGET_VERSION) + set(_JAVA_TARGET_OUTPUT_NAME "${CMAKE_JAVA_TARGET_OUTPUT_NAME}-${CMAKE_JAVA_TARGET_VERSION}.jar") + set(_JAVA_TARGET_OUTPUT_LINK "${CMAKE_JAVA_TARGET_OUTPUT_NAME}.jar") + elseif (CMAKE_JAVA_TARGET_VERSION) + set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}-${CMAKE_JAVA_TARGET_VERSION}.jar") + set(_JAVA_TARGET_OUTPUT_LINK "${_TARGET_NAME}.jar") + elseif (CMAKE_JAVA_TARGET_OUTPUT_NAME) + set(_JAVA_TARGET_OUTPUT_NAME "${CMAKE_JAVA_TARGET_OUTPUT_NAME}.jar") + endif (CMAKE_JAVA_TARGET_OUTPUT_NAME AND CMAKE_JAVA_TARGET_VERSION) + # reset + set(CMAKE_JAVA_TARGET_OUTPUT_NAME) + + set(_JAVA_CLASS_FILES) + set(_JAVA_COMPILE_FILES) + set(_JAVA_DEPENDS) + set(_JAVA_RESOURCE_FILES) + foreach(_JAVA_SOURCE_FILE ${_JAVA_SOURCE_FILES}) + get_filename_component(_JAVA_EXT ${_JAVA_SOURCE_FILE} EXT) + get_filename_component(_JAVA_FILE ${_JAVA_SOURCE_FILE} NAME_WE) + get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH) + get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE) + + file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${CMAKE_CURRENT_BINARY_DIR} ${_JAVA_FULL}) + file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL}) + string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN) + string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN) + if (${_BIN_LEN} LESS ${_SRC_LEN}) + set(_JAVA_REL_PATH ${_JAVA_REL_BINARY_PATH}) + else (${_BIN_LEN} LESS ${_SRC_LEN}) + set(_JAVA_REL_PATH ${_JAVA_REL_SOURCE_PATH}) + endif (${_BIN_LEN} LESS ${_SRC_LEN}) + get_filename_component(_JAVA_REL_PATH ${_JAVA_REL_PATH} PATH) + + if (_JAVA_EXT MATCHES ".java") + list(APPEND _JAVA_COMPILE_FILES ${_JAVA_SOURCE_FILE}) + set(_JAVA_CLASS_FILE "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_REL_PATH}/${_JAVA_FILE}.class") + set(_JAVA_CLASS_FILES ${_JAVA_CLASS_FILES} ${_JAVA_CLASS_FILE}) + + elseif (_JAVA_EXT MATCHES ".jar" + OR _JAVA_EXT MATCHES ".war" + OR _JAVA_EXT MATCHES ".ear" + OR _JAVA_EXT MATCHES ".sar") + list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_SOURCE_FILE}) + + elseif (_JAVA_EXT STREQUAL "") + list(APPEND CMAKE_JAVA_INCLUDE_PATH ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}} ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}_CLASSPATH}) + list(APPEND _JAVA_DEPENDS ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}}) + + else (_JAVA_EXT MATCHES ".java") + __java_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/${_JAVA_SOURCE_FILE} + ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE} + "Copying ${_JAVA_SOURCE_FILE} to the build directory") + list(APPEND _JAVA_RESOURCE_FILES ${_JAVA_SOURCE_FILE}) + endif (_JAVA_EXT MATCHES ".java") + endforeach(_JAVA_SOURCE_FILE) + + # create an empty java_class_filelist + if (NOT EXISTS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist) + file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "") + endif() + + if (_JAVA_COMPILE_FILES) + # Compile the java files and create a list of class files + add_custom_command( + # NOTE: this command generates an artificial dependency file + OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} + COMMAND ${Java_JAVAC_EXECUTABLE} + ${CMAKE_JAVA_COMPILE_FLAGS} + -classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}" + -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH} + ${_JAVA_COMPILE_FILES} + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} + DEPENDS ${_JAVA_COMPILE_FILES} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Building Java objects for ${_TARGET_NAME}.jar" + ) + add_custom_command( + OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist + COMMAND ${CMAKE_COMMAND} + -DCMAKE_JAVA_CLASS_OUTPUT_PATH=${CMAKE_JAVA_CLASS_OUTPUT_PATH} + -DCMAKE_JAR_CLASSES_PREFIX="${CMAKE_JAR_CLASSES_PREFIX}" + -P ${_JAVA_CLASS_FILELIST_SCRIPT} + DEPENDS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + endif (_JAVA_COMPILE_FILES) + + # create the jar file + if (CMAKE_JNI_TARGET) + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME} + COMMAND ${Java_JAR_EXECUTABLE} + -cf ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME} + ${_JAVA_RESOURCE_FILES} @java_class_filelist + COMMAND ${CMAKE_COMMAND} + -D_JAVA_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} + -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME} + -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK} + -P ${_JAVA_SYMLINK_SCRIPT} + COMMAND ${CMAKE_COMMAND} + -D_JAVA_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} + -D_JAVA_TARGET_OUTPUT_NAME=${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME} + -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK} + -P ${_JAVA_SYMLINK_SCRIPT} + DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist + WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH} + COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}" + ) + else () + add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME} + COMMAND ${Java_JAR_EXECUTABLE} + -cf ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME} + ${_JAVA_RESOURCE_FILES} @java_class_filelist + COMMAND ${CMAKE_COMMAND} + -D_JAVA_TARGET_DIR=${CMAKE_CURRENT_BINARY_DIR} + -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME} + -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK} + -P ${_JAVA_SYMLINK_SCRIPT} + WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH} + DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist + COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}" + ) + endif (CMAKE_JNI_TARGET) + + # Add the target and make sure we have the latest resource files. + add_custom_target(${_TARGET_NAME} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME}) + + set_property( + TARGET + ${_TARGET_NAME} + PROPERTY + INSTALL_FILES + ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME} + ) + + if (_JAVA_TARGET_OUTPUT_LINK) + set_property( + TARGET + ${_TARGET_NAME} + PROPERTY + INSTALL_FILES + ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME} + ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_LINK} + ) + + if (CMAKE_JNI_TARGET) + set_property( + TARGET + ${_TARGET_NAME} + PROPERTY + JNI_SYMLINK + ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_LINK} + ) + endif (CMAKE_JNI_TARGET) + endif (_JAVA_TARGET_OUTPUT_LINK) + + set_property( + TARGET + ${_TARGET_NAME} + PROPERTY + JAR_FILE + ${CMAKE_CURRENT_BINARY_DIR}/${_JAVA_TARGET_OUTPUT_NAME} + ) + + set_property( + TARGET + ${_TARGET_NAME} + PROPERTY + CLASSDIR + ${CMAKE_JAVA_CLASS_OUTPUT_PATH} + ) + +endfunction(add_jar) + +function(INSTALL_JAR _TARGET_NAME _DESTINATION) + get_property(__FILES + TARGET + ${_TARGET_NAME} + PROPERTY + INSTALL_FILES + ) + + if (__FILES) + install( + FILES + ${__FILES} + DESTINATION + ${_DESTINATION} + ) + else (__FILES) + message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.") + endif (__FILES) +endfunction(INSTALL_JAR _TARGET_NAME _DESTINATION) + +function(INSTALL_JNI_SYMLINK _TARGET_NAME _DESTINATION) + get_property(__SYMLINK + TARGET + ${_TARGET_NAME} + PROPERTY + JNI_SYMLINK + ) + + if (__SYMLINK) + install( + FILES + ${__SYMLINK} + DESTINATION + ${_DESTINATION} + ) + else (__SYMLINK) + message(SEND_ERROR "The target ${_TARGET_NAME} is not known in this scope.") + endif (__SYMLINK) +endfunction(INSTALL_JNI_SYMLINK _TARGET_NAME _DESTINATION) + +function (find_jar VARIABLE) + set(_jar_names) + set(_jar_files) + set(_jar_versions) + set(_jar_paths + /usr/share/java/ + /usr/local/share/java/ + ${Java_JAR_PATHS}) + set(_jar_doc "NOTSET") + + set(_state "name") + + foreach (arg ${ARGN}) + if (${_state} STREQUAL "name") + if (${arg} STREQUAL "VERSIONS") + set(_state "versions") + elseif (${arg} STREQUAL "NAMES") + set(_state "names") + elseif (${arg} STREQUAL "PATHS") + set(_state "paths") + elseif (${arg} STREQUAL "DOC") + set(_state "doc") + else (${arg} STREQUAL "NAMES") + set(_jar_names ${arg}) + if (_jar_doc STREQUAL "NOTSET") + set(_jar_doc "Finding ${arg} jar") + endif (_jar_doc STREQUAL "NOTSET") + endif (${arg} STREQUAL "VERSIONS") + elseif (${_state} STREQUAL "versions") + if (${arg} STREQUAL "NAMES") + set(_state "names") + elseif (${arg} STREQUAL "PATHS") + set(_state "paths") + elseif (${arg} STREQUAL "DOC") + set(_state "doc") + else (${arg} STREQUAL "NAMES") + set(_jar_versions ${_jar_versions} ${arg}) + endif (${arg} STREQUAL "NAMES") + elseif (${_state} STREQUAL "names") + if (${arg} STREQUAL "VERSIONS") + set(_state "versions") + elseif (${arg} STREQUAL "PATHS") + set(_state "paths") + elseif (${arg} STREQUAL "DOC") + set(_state "doc") + else (${arg} STREQUAL "VERSIONS") + set(_jar_names ${_jar_names} ${arg}) + if (_jar_doc STREQUAL "NOTSET") + set(_jar_doc "Finding ${arg} jar") + endif (_jar_doc STREQUAL "NOTSET") + endif (${arg} STREQUAL "VERSIONS") + elseif (${_state} STREQUAL "paths") + if (${arg} STREQUAL "VERSIONS") + set(_state "versions") + elseif (${arg} STREQUAL "NAMES") + set(_state "names") + elseif (${arg} STREQUAL "DOC") + set(_state "doc") + else (${arg} STREQUAL "VERSIONS") + set(_jar_paths ${_jar_paths} ${arg}) + endif (${arg} STREQUAL "VERSIONS") + elseif (${_state} STREQUAL "doc") + if (${arg} STREQUAL "VERSIONS") + set(_state "versions") + elseif (${arg} STREQUAL "NAMES") + set(_state "names") + elseif (${arg} STREQUAL "PATHS") + set(_state "paths") + else (${arg} STREQUAL "VERSIONS") + set(_jar_doc ${arg}) + endif (${arg} STREQUAL "VERSIONS") + endif (${_state} STREQUAL "name") + endforeach (arg ${ARGN}) + + if (${_jar_names} STREQUAL "") + message(FATAL_ERROR "find_jar: No name to search for given") + endif (${_jar_names} STREQUAL "") + + foreach (jar_name ${_jar_names}) + foreach (version ${_jar_versions}) + set(_jar_files ${_jar_files} ${jar_name}-${version}.jar) + endforeach (version ${_jar_versions}) + set(_jar_files ${_jar_files} ${jar_name}.jar) + endforeach (jar_name ${_jar_names}) + + find_file(${VARIABLE} + NAMES ${_jar_files} + PATHS ${_jar_paths} + DOC ${_jar_doc} + NO_DEFAULT_PATH) +endfunction (find_jar VARIABLE) + +function(create_javadoc _target) + set(_javadoc_packages) + set(_javadoc_files) + set(_javadoc_sourcepath) + set(_javadoc_classpath) + set(_javadoc_installpath "${CMAKE_INSTALL_PREFIX}/share/javadoc") + set(_javadoc_doctitle) + set(_javadoc_windowtitle) + set(_javadoc_author FALSE) + set(_javadoc_version FALSE) + set(_javadoc_use FALSE) + + set(_state "package") + + foreach (arg ${ARGN}) + if (${_state} STREQUAL "package") + if (${arg} STREQUAL "PACKAGES") + set(_state "packages") + elseif (${arg} STREQUAL "FILES") + set(_state "files") + elseif (${arg} STREQUAL "SOURCEPATH") + set(_state "sourcepath") + elseif (${arg} STREQUAL "CLASSPATH") + set(_state "classpath") + elseif (${arg} STREQUAL "INSTALLPATH") + set(_state "installpath") + elseif (${arg} STREQUAL "DOCTITLE") + set(_state "doctitle") + elseif (${arg} STREQUAL "WINDOWTITLE") + set(_state "windowtitle") + elseif (${arg} STREQUAL "AUTHOR") + set(_state "author") + elseif (${arg} STREQUAL "USE") + set(_state "use") + elseif (${arg} STREQUAL "VERSION") + set(_state "version") + else () + set(_javadoc_packages ${arg}) + set(_state "packages") + endif () + elseif (${_state} STREQUAL "packages") + if (${arg} STREQUAL "FILES") + set(_state "files") + elseif (${arg} STREQUAL "SOURCEPATH") + set(_state "sourcepath") + elseif (${arg} STREQUAL "CLASSPATH") + set(_state "classpath") + elseif (${arg} STREQUAL "INSTALLPATH") + set(_state "installpath") + elseif (${arg} STREQUAL "DOCTITLE") + set(_state "doctitle") + elseif (${arg} STREQUAL "WINDOWTITLE") + set(_state "windowtitle") + elseif (${arg} STREQUAL "AUTHOR") + set(_state "author") + elseif (${arg} STREQUAL "USE") + set(_state "use") + elseif (${arg} STREQUAL "VERSION") + set(_state "version") + else () + list(APPEND _javadoc_packages ${arg}) + endif () + elseif (${_state} STREQUAL "files") + if (${arg} STREQUAL "PACKAGES") + set(_state "packages") + elseif (${arg} STREQUAL "SOURCEPATH") + set(_state "sourcepath") + elseif (${arg} STREQUAL "CLASSPATH") + set(_state "classpath") + elseif (${arg} STREQUAL "INSTALLPATH") + set(_state "installpath") + elseif (${arg} STREQUAL "DOCTITLE") + set(_state "doctitle") + elseif (${arg} STREQUAL "WINDOWTITLE") + set(_state "windowtitle") + elseif (${arg} STREQUAL "AUTHOR") + set(_state "author") + elseif (${arg} STREQUAL "USE") + set(_state "use") + elseif (${arg} STREQUAL "VERSION") + set(_state "version") + else () + list(APPEND _javadoc_files ${arg}) + endif () + elseif (${_state} STREQUAL "sourcepath") + if (${arg} STREQUAL "PACKAGES") + set(_state "packages") + elseif (${arg} STREQUAL "FILES") + set(_state "files") + elseif (${arg} STREQUAL "CLASSPATH") + set(_state "classpath") + elseif (${arg} STREQUAL "INSTALLPATH") + set(_state "installpath") + elseif (${arg} STREQUAL "DOCTITLE") + set(_state "doctitle") + elseif (${arg} STREQUAL "WINDOWTITLE") + set(_state "windowtitle") + elseif (${arg} STREQUAL "AUTHOR") + set(_state "author") + elseif (${arg} STREQUAL "USE") + set(_state "use") + elseif (${arg} STREQUAL "VERSION") + set(_state "version") + else () + list(APPEND _javadoc_sourcepath ${arg}) + endif () + elseif (${_state} STREQUAL "classpath") + if (${arg} STREQUAL "PACKAGES") + set(_state "packages") + elseif (${arg} STREQUAL "FILES") + set(_state "files") + elseif (${arg} STREQUAL "SOURCEPATH") + set(_state "sourcepath") + elseif (${arg} STREQUAL "INSTALLPATH") + set(_state "installpath") + elseif (${arg} STREQUAL "DOCTITLE") + set(_state "doctitle") + elseif (${arg} STREQUAL "WINDOWTITLE") + set(_state "windowtitle") + elseif (${arg} STREQUAL "AUTHOR") + set(_state "author") + elseif (${arg} STREQUAL "USE") + set(_state "use") + elseif (${arg} STREQUAL "VERSION") + set(_state "version") + else () + list(APPEND _javadoc_classpath ${arg}) + endif () + elseif (${_state} STREQUAL "installpath") + if (${arg} STREQUAL "PACKAGES") + set(_state "packages") + elseif (${arg} STREQUAL "FILES") + set(_state "files") + elseif (${arg} STREQUAL "SOURCEPATH") + set(_state "sourcepath") + elseif (${arg} STREQUAL "DOCTITLE") + set(_state "doctitle") + elseif (${arg} STREQUAL "WINDOWTITLE") + set(_state "windowtitle") + elseif (${arg} STREQUAL "AUTHOR") + set(_state "author") + elseif (${arg} STREQUAL "USE") + set(_state "use") + elseif (${arg} STREQUAL "VERSION") + set(_state "version") + else () + set(_javadoc_installpath ${arg}) + endif () + elseif (${_state} STREQUAL "doctitle") + if (${arg} STREQUAL "PACKAGES") + set(_state "packages") + elseif (${arg} STREQUAL "FILES") + set(_state "files") + elseif (${arg} STREQUAL "SOURCEPATH") + set(_state "sourcepath") + elseif (${arg} STREQUAL "INSTALLPATH") + set(_state "installpath") + elseif (${arg} STREQUAL "CLASSPATH") + set(_state "classpath") + elseif (${arg} STREQUAL "WINDOWTITLE") + set(_state "windowtitle") + elseif (${arg} STREQUAL "AUTHOR") + set(_state "author") + elseif (${arg} STREQUAL "USE") + set(_state "use") + elseif (${arg} STREQUAL "VERSION") + set(_state "version") + else () + set(_javadoc_doctitle ${arg}) + endif () + elseif (${_state} STREQUAL "windowtitle") + if (${arg} STREQUAL "PACKAGES") + set(_state "packages") + elseif (${arg} STREQUAL "FILES") + set(_state "files") + elseif (${arg} STREQUAL "SOURCEPATH") + set(_state "sourcepath") + elseif (${arg} STREQUAL "CLASSPATH") + set(_state "classpath") + elseif (${arg} STREQUAL "INSTALLPATH") + set(_state "installpath") + elseif (${arg} STREQUAL "DOCTITLE") + set(_state "doctitle") + elseif (${arg} STREQUAL "AUTHOR") + set(_state "author") + elseif (${arg} STREQUAL "USE") + set(_state "use") + elseif (${arg} STREQUAL "VERSION") + set(_state "version") + else () + set(_javadoc_windowtitle ${arg}) + endif () + elseif (${_state} STREQUAL "author") + if (${arg} STREQUAL "PACKAGES") + set(_state "packages") + elseif (${arg} STREQUAL "FILES") + set(_state "files") + elseif (${arg} STREQUAL "SOURCEPATH") + set(_state "sourcepath") + elseif (${arg} STREQUAL "CLASSPATH") + set(_state "classpath") + elseif (${arg} STREQUAL "INSTALLPATH") + set(_state "installpath") + elseif (${arg} STREQUAL "DOCTITLE") + set(_state "doctitle") + elseif (${arg} STREQUAL "WINDOWTITLE") + set(_state "windowtitle") + elseif (${arg} STREQUAL "AUTHOR") + set(_state "author") + elseif (${arg} STREQUAL "USE") + set(_state "use") + elseif (${arg} STREQUAL "VERSION") + set(_state "version") + else () + set(_javadoc_author ${arg}) + endif () + elseif (${_state} STREQUAL "use") + if (${arg} STREQUAL "PACKAGES") + set(_state "packages") + elseif (${arg} STREQUAL "FILES") + set(_state "files") + elseif (${arg} STREQUAL "SOURCEPATH") + set(_state "sourcepath") + elseif (${arg} STREQUAL "CLASSPATH") + set(_state "classpath") + elseif (${arg} STREQUAL "INSTALLPATH") + set(_state "installpath") + elseif (${arg} STREQUAL "DOCTITLE") + set(_state "doctitle") + elseif (${arg} STREQUAL "WINDOWTITLE") + set(_state "windowtitle") + elseif (${arg} STREQUAL "AUTHOR") + set(_state "author") + elseif (${arg} STREQUAL "USE") + set(_state "use") + elseif (${arg} STREQUAL "VERSION") + set(_state "version") + else () + set(_javadoc_use ${arg}) + endif () + elseif (${_state} STREQUAL "version") + if (${arg} STREQUAL "PACKAGES") + set(_state "packages") + elseif (${arg} STREQUAL "FILES") + set(_state "files") + elseif (${arg} STREQUAL "SOURCEPATH") + set(_state "sourcepath") + elseif (${arg} STREQUAL "CLASSPATH") + set(_state "classpath") + elseif (${arg} STREQUAL "INSTALLPATH") + set(_state "installpath") + elseif (${arg} STREQUAL "DOCTITLE") + set(_state "doctitle") + elseif (${arg} STREQUAL "WINDOWTITLE") + set(_state "windowtitle") + elseif (${arg} STREQUAL "AUTHOR") + set(_state "author") + elseif (${arg} STREQUAL "USE") + set(_state "use") + elseif (${arg} STREQUAL "VERSION") + set(_state "version") + else () + set(_javadoc_version ${arg}) + endif () + endif (${_state} STREQUAL "package") + endforeach (arg ${ARGN}) + + set(_javadoc_builddir ${CMAKE_CURRENT_BINARY_DIR}/javadoc/${_target}) + set(_javadoc_options -d ${_javadoc_builddir}) + + if (_javadoc_sourcepath) + set(_start TRUE) + foreach(_path ${_javadoc_sourcepath}) + if (_start) + set(_sourcepath ${_path}) + set(_start FALSE) + else (_start) + set(_sourcepath ${_sourcepath}:${_path}) + endif (_start) + endforeach(_path ${_javadoc_sourcepath}) + set(_javadoc_options ${_javadoc_options} -sourcepath ${_sourcepath}) + endif (_javadoc_sourcepath) + + if (_javadoc_classpath) + set(_start TRUE) + foreach(_path ${_javadoc_classpath}) + if (_start) + set(_classpath ${_path}) + set(_start FALSE) + else (_start) + set(_classpath ${_classpath}:${_path}) + endif (_start) + endforeach(_path ${_javadoc_classpath}) + set(_javadoc_options ${_javadoc_options} -classpath "${_classpath}") + endif (_javadoc_classpath) + + if (_javadoc_doctitle) + set(_javadoc_options ${_javadoc_options} -doctitle '${_javadoc_doctitle}') + endif (_javadoc_doctitle) + + if (_javadoc_windowtitle) + set(_javadoc_options ${_javadoc_options} -windowtitle '${_javadoc_windowtitle}') + endif (_javadoc_windowtitle) + + if (_javadoc_author) + set(_javadoc_options ${_javadoc_options} -author) + endif (_javadoc_author) + + if (_javadoc_use) + set(_javadoc_options ${_javadoc_options} -use) + endif (_javadoc_use) + + if (_javadoc_version) + set(_javadoc_options ${_javadoc_options} -version) + endif (_javadoc_version) + + add_custom_target(${_target}_javadoc ALL + COMMAND ${Java_JAVADOC_EXECUTABLE} ${_javadoc_options} + ${_javadoc_files} + ${_javadoc_packages} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + + install( + DIRECTORY ${_javadoc_builddir} + DESTINATION ${_javadoc_installpath} + ) +endfunction(create_javadoc) diff --git a/Modules/UseJavaClassFilelist.cmake b/Modules/UseJavaClassFilelist.cmake new file mode 100644 index 000000000..c842bf71a --- /dev/null +++ b/Modules/UseJavaClassFilelist.cmake @@ -0,0 +1,52 @@ +# +# This script create a list of compiled Java class files to be added to a +# jar file. This avoids including cmake files which get created in the +# binary directory. +# + +#============================================================================= +# Copyright 2010-2011 Andreas schneider +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +if (CMAKE_JAVA_CLASS_OUTPUT_PATH) + if (EXISTS "${CMAKE_JAVA_CLASS_OUTPUT_PATH}") + + set(_JAVA_GLOBBED_FILES) + if (CMAKE_JAR_CLASSES_PREFIX) + foreach(JAR_CLASS_PREFIX ${CMAKE_JAR_CLASSES_PREFIX}) + message(STATUS "JAR_CLASS_PREFIX: ${JAR_CLASS_PREFIX}") + + file(GLOB_RECURSE _JAVA_GLOBBED_TMP_FILES "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${JAR_CLASS_PREFIX}/*.class") + if (_JAVA_GLOBBED_TMP_FILES) + list(APPEND _JAVA_GLOBBED_FILES ${_JAVA_GLOBBED_TMP_FILES}) + endif (_JAVA_GLOBBED_TMP_FILES) + endforeach(JAR_CLASS_PREFIX ${CMAKE_JAR_CLASSES_PREFIX}) + else() + file(GLOB_RECURSE _JAVA_GLOBBED_FILES "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/*.class") + endif (CMAKE_JAR_CLASSES_PREFIX) + + set(_JAVA_CLASS_FILES) + # file(GLOB_RECURSE foo RELATIVE) is broken so we need this. + foreach(_JAVA_GLOBBED_FILE ${_JAVA_GLOBBED_FILES}) + file(RELATIVE_PATH _JAVA_CLASS_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH} ${_JAVA_GLOBBED_FILE}) + set(_JAVA_CLASS_FILES ${_JAVA_CLASS_FILES}${_JAVA_CLASS_FILE}\n) + endforeach(_JAVA_GLOBBED_FILE ${_JAVA_GLOBBED_FILES}) + + # write to file + file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist ${_JAVA_CLASS_FILES}) + + else (EXISTS "${CMAKE_JAVA_CLASS_OUTPUT_PATH}") + message(SEND_ERROR "FATAL: Java class output path doesn't exist") + endif (EXISTS "${CMAKE_JAVA_CLASS_OUTPUT_PATH}") +else (CMAKE_JAVA_CLASS_OUTPUT_PATH) + message(SEND_ERROR "FATAL: Can't find CMAKE_JAVA_CLASS_OUTPUT_PATH") +endif (CMAKE_JAVA_CLASS_OUTPUT_PATH) diff --git a/Modules/UseJavaSymlinks.cmake b/Modules/UseJavaSymlinks.cmake new file mode 100644 index 000000000..c66ee1ea1 --- /dev/null +++ b/Modules/UseJavaSymlinks.cmake @@ -0,0 +1,32 @@ +# +# Helper script for UseJava.cmake +# + +#============================================================================= +# Copyright 2010-2011 Andreas schneider +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +if (UNIX AND _JAVA_TARGET_OUTPUT_LINK) + if (_JAVA_TARGET_OUTPUT_NAME) + find_program(LN_EXECUTABLE + NAMES + ln + ) + + execute_process( + COMMAND ${LN_EXECUTABLE} -sf "${_JAVA_TARGET_OUTPUT_NAME}" "${_JAVA_TARGET_OUTPUT_LINK}" + WORKING_DIRECTORY ${_JAVA_TARGET_DIR} + ) + else (_JAVA_TARGET_OUTPUT_NAME) + message(SEND_ERROR "FATAL: Can't find _JAVA_TARGET_OUTPUT_NAME") + endif (_JAVA_TARGET_OUTPUT_NAME) +endif (UNIX AND _JAVA_TARGET_OUTPUT_LINK) diff --git a/Modules/UsePkgConfig.cmake b/Modules/UsePkgConfig.cmake index d101e61d0..7f4318f05 100644 --- a/Modules/UsePkgConfig.cmake +++ b/Modules/UsePkgConfig.cmake @@ -1,13 +1,14 @@ -# - obsolete pkg-config module for CMake +# - Obsolete pkg-config module for CMake, use FindPkgConfig instead. # -# Defines the following macros: +# This module defines the following macro: # # PKGCONFIG(package includedir libdir linkflags cflags) # # Calling PKGCONFIG will fill the desired information into the 4 given arguments, # e.g. PKGCONFIG(libart-2.0 LIBART_INCLUDE_DIR LIBART_LINK_DIR LIBART_LINK_FLAGS LIBART_CFLAGS) # if pkg-config was NOT found or the specified software package doesn't exist, the -# variable will be empty when the function returns, otherwise they will contain the respective information +# variable will be empty when the function returns, otherwise they will contain +# the respective information # #============================================================================= @@ -27,7 +28,7 @@ FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config ) MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags) MESSAGE(STATUS - "WARNING: you are using the obsolete 'PKGCONFIG' macro use FindPkgConfig") + "WARNING: you are using the obsolete 'PKGCONFIG' macro, use FindPkgConfig") # reset the variables at the beginning SET(${_include_DIR}) SET(${_link_DIR}) @@ -42,20 +43,20 @@ MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags) # and if the package of interest also exists for pkg-config, then get the information IF(NOT _return_VALUE) - EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=includedir + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=includedir OUTPUT_VARIABLE ${_include_DIR} ) STRING(REGEX REPLACE "[\r\n]" " " ${_include_DIR} "${${_include_DIR}}") - - EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=libdir + + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --variable=libdir OUTPUT_VARIABLE ${_link_DIR} ) STRING(REGEX REPLACE "[\r\n]" " " ${_link_DIR} "${${_link_DIR}}") - EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --libs + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --libs OUTPUT_VARIABLE ${_link_FLAGS} ) STRING(REGEX REPLACE "[\r\n]" " " ${_link_FLAGS} "${${_link_FLAGS}}") - EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --cflags + EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS ${_package} --cflags OUTPUT_VARIABLE ${_cflags} ) STRING(REGEX REPLACE "[\r\n]" " " ${_cflags} "${${_cflags}}") @@ -64,10 +65,10 @@ MACRO(PKGCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags) 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) - + # if pkg-config has NOT been found, INFORM the user ELSE(PKGCONFIG_EXECUTABLE) - + MESSAGE(STATUS "WARNING: PKGCONFIG() indicates that the tool pkg-config has not been found on your system. You should install it.") ENDIF(PKGCONFIG_EXECUTABLE) diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index 9ce475cb7..027504fc5 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -21,10 +21,14 @@ SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG QT_DEBUG) SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE QT_NO_DEBUG) SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO QT_NO_DEBUG) SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL QT_NO_DEBUG) +IF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) + SET_PROPERTY(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS QT_NO_DEBUG) +ENDIF() INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}) SET(QT_LIBRARIES "") +SET(QT_LIBRARIES_PLUGINS "") IF (QT_USE_QTMAIN) IF (Q_WS_WIN) @@ -64,7 +68,7 @@ SET(QT_QAXCONTAINER_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QAXSERVER_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTSCRIPTTOOLS_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTWEBKIT_MODULE_DEPENDS QTXMLPATTERNS QTGUI QTCORE) -SET(QT_QTDECLARATIVE_MODULE_DEPENDS QTWEBKIT QTSCRIPT QTSVG QTSQL QTXMLPATTERNS QTXML QTOPENGL QTGUI QTNETWORK QTCORE) +SET(QT_QTDECLARATIVE_MODULE_DEPENDS QTSCRIPT QTSVG QTSQL QTXMLPATTERNS QTGUI QTCORE) SET(QT_QTMULTIMEDIA_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTOPENGL_MODULE_DEPENDS QTGUI QTCORE) SET(QT_QTSCRIPT_MODULE_DEPENDS QTCORE) @@ -77,8 +81,8 @@ SET(QT_QTNETWORK_MODULE_DEPENDS QTCORE) # Qt modules (in order of dependence) FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN QAXSERVER QAXCONTAINER QTDECLARATIVE QTSCRIPT QTSVG QTUITOOLS QTHELP - QTWEBKIT PHONON QTSCRIPTTOOLS QTMULTIMEDIA QTGUI QTTEST QTDBUS QTXML QTSQL - QTXMLPATTERNS QTNETWORK QTCORE) + QTWEBKIT PHONON QTSCRIPTTOOLS QTMULTIMEDIA QTXMLPATTERNS QTGUI QTTEST + QTDBUS QTXML QTSQL QTNETWORK QTCORE) IF (QT_USE_${module} OR QT_USE_${module}_DEPENDS) IF (QT_${module}_FOUND) @@ -88,6 +92,7 @@ FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN INCLUDE_DIRECTORIES(${QT_${module}_INCLUDE_DIR}) ENDIF(QT_USE_${module}) SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY}) + SET(QT_LIBRARIES_PLUGINS ${QT_LIBRARIES_PLUGINS} ${QT_${module}_PLUGINS}) IF(QT_IS_STATIC) SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIB_DEPENDENCIES}) ENDIF(QT_IS_STATIC) diff --git a/Modules/WriteBasicConfigVersionFile.cmake b/Modules/WriteBasicConfigVersionFile.cmake new file mode 100644 index 000000000..0b6519d41 --- /dev/null +++ b/Modules/WriteBasicConfigVersionFile.cmake @@ -0,0 +1,69 @@ +# WRITE_BASIC_CONFIG_VERSION_FILE( filename VERSION major.minor.patch COMPATIBILITY (AnyNewerVersion|SameMajorVersion) ) +# +# Writes a file for use as ConfigVersion.cmake file to . +# See the documentation of FIND_PACKAGE() for details on this. +# filename is the output filename, it should be in the build tree. +# major.minor.patch is the version number of the project to be installed +# The COMPATIBILITY mode AnyNewerVersion means that the installed package version +# will be considered compatible if it is newer or exactly the same as the requested version. +# If SameMajorVersion is used instead, then the behaviour differs from AnyNewerVersion +# in that the major version number must be the same as requested, e.g. version 2.0 will +# not be considered compatible if 1.0 is requested. +# If your project has more elaborated version matching rules, you will need to write your +# own custom ConfigVersion.cmake file instead of using this macro. +# +# Example: +# write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake +# VERSION 1.2.3 +# COMPATIBILITY SameMajorVersion ) +# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake +# ${CMAKE_CURRENT_BINARY_DIR}/FooConfig.cmake +# DESTINATION lib/cmake/Foo ) +# +# Internally, this macro executes configure_file() to create the resulting +# version file. Depending on the COMPATIBLITY, either the file +# BasicConfigVersion-SameMajorVersion.cmake.in or BasicConfigVersion-AnyNewerVersion.cmake.in +# is used. Please note that these two files are internal to CMake and you should +# not call configure_file() on them yourself, but they can be used as starting +# point to create more sophisticted custom ConfigVersion.cmake files. + +#============================================================================= +# Copyright 2008-2011 Alexander Neundorf, +# Copyright 2004-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +include(CMakeParseArguments) + +function(WRITE_BASIC_CONFIG_VERSION_FILE _filename) + + set(options ) + set(oneValueArgs VERSION COMPATIBILITY ) + set(multiValueArgs ) + + cmake_parse_arguments(CVF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(CVF_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to WRITE_BASIC_CONFIG_VERSION_FILE(): \"${CVF_UNPARSED_ARGUMENTS}\"") + endif(CVF_UNPARSED_ARGUMENTS) + + set(versionTemplateFile "${CMAKE_ROOT}/Modules/BasicConfigVersion-${CVF_COMPATIBILITY}.cmake.in") + if(NOT EXISTS "${versionTemplateFile}") + message(FATAL_ERROR "Bad COMPATIBILITY value used for WRITE_BASIC_CONFIG_VERSION_FILE(): \"${CVF_COMPATIBILITY}\"") + endif() + + if("${CVF_VERSION}" STREQUAL "") + message(FATAL_ERROR "No VERSION specified for WRITE_BASIC_CONFIG_VERSION_FILE()") + endif() + + configure_file("${versionTemplateFile}" "${_filename}" @ONLY) + +endfunction(WRITE_BASIC_CONFIG_VERSION_FILE) diff --git a/Modules/exportheader.cmake.in b/Modules/exportheader.cmake.in new file mode 100644 index 000000000..80a879d7e --- /dev/null +++ b/Modules/exportheader.cmake.in @@ -0,0 +1,35 @@ + +#ifndef @INCLUDE_GUARD_NAME@ +#define @INCLUDE_GUARD_NAME@ + +#ifdef @STATIC_DEFINE@ +# define @EXPORT_MACRO_NAME@ +# define @NO_EXPORT_MACRO_NAME@ +#else +# ifndef @EXPORT_MACRO_NAME@ +# ifdef @EXPORT_IMPORT_CONDITION@ + /* We are building this library */ +# define @EXPORT_MACRO_NAME@ @DEFINE_EXPORT@ +# else + /* We are using this library */ +# define @EXPORT_MACRO_NAME@ @DEFINE_IMPORT@ +# endif +# endif + +# ifndef @NO_EXPORT_MACRO_NAME@ +# define @NO_EXPORT_MACRO_NAME@ @DEFINE_NO_EXPORT@ +# endif +#endif + +#ifndef @DEPRECATED_MACRO_NAME@ +# define @DEPRECATED_MACRO_NAME@ @DEFINE_DEPRECATED@ +# define @DEPRECATED_MACRO_NAME@_EXPORT @EXPORT_MACRO_NAME@ @DEFINE_DEPRECATED@ +# define @DEPRECATED_MACRO_NAME@_NO_EXPORT @NO_EXPORT_MACRO_NAME@ @DEFINE_DEPRECATED@ +#endif + +#cmakedefine01 DEFINE_NO_DEPRECATED +#if DEFINE_NO_DEPRECATED +# define @NO_DEPRECATED_MACRO_NAME@ +#endif + +#endif diff --git a/Source/.gitattributes b/Source/.gitattributes new file mode 100644 index 000000000..cf4dabd86 --- /dev/null +++ b/Source/.gitattributes @@ -0,0 +1,2 @@ +# Preserve upstream indentation style. +cm_sha2.* whitespace=indent-with-non-tab diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ca063d54c..b5115b78b 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -129,6 +129,8 @@ SET(SRCS cmComputeLinkInformation.h cmComputeTargetDepends.h cmComputeTargetDepends.cxx + cmCryptoHash.cxx + cmCryptoHash.h cmCustomCommand.cxx cmCustomCommand.h cmCustomCommandGenerator.cxx @@ -160,6 +162,7 @@ SET(SRCS cmDocumentationSection.cxx cmDocumentCompileDefinitions.h cmDocumentGeneratorExpressions.h + cmDocumentLocationUndefined.h cmDocumentVariables.cxx cmDynamicLoader.cxx cmDynamicLoader.h @@ -214,6 +217,8 @@ SET(SRCS cmMakefileExecutableTargetGenerator.cxx cmMakefileLibraryTargetGenerator.cxx cmMakefileUtilityTargetGenerator.cxx + cmNewLineStyle.h + cmNewLineStyle.cxx cmOrderDirectories.cxx cmOrderDirectories.h cmPolicies.h @@ -228,6 +233,8 @@ SET(SRCS cmPropertyDefinitionMap.h cmPropertyMap.cxx cmPropertyMap.h + cmQtAutomoc.cxx + cmQtAutomoc.h cmScriptGenerator.h cmScriptGenerator.cxx cmSourceFile.cxx @@ -257,6 +264,8 @@ SET(SRCS cmakewizard.cxx cmakewizard.h + cm_sha2.h + cm_sha2.c cm_utf8.h cm_utf8.c ) @@ -308,6 +317,8 @@ IF (WIN32) cmGlobalVisualStudio8Win64Generator.h cmGlobalVisualStudio9Win64Generator.cxx cmGlobalVisualStudio9Win64Generator.h + cmGlobalVisualStudio9IA64Generator.cxx + cmGlobalVisualStudio9IA64Generator.h cmVisualStudioGeneratorOptions.h cmVisualStudioGeneratorOptions.cxx cmVisualStudio10TargetGenerator.h @@ -318,6 +329,12 @@ IF (WIN32) cmGlobalVisualStudio10Generator.cxx cmGlobalVisualStudio10Win64Generator.h cmGlobalVisualStudio10Win64Generator.cxx + cmGlobalVisualStudio10IA64Generator.h + cmGlobalVisualStudio10IA64Generator.cxx + cmGlobalVisualStudio11Generator.h + cmGlobalVisualStudio11Generator.cxx + cmGlobalVisualStudio11Win64Generator.h + cmGlobalVisualStudio11Win64Generator.cxx cmGlobalVisualStudioGenerator.cxx cmGlobalVisualStudioGenerator.h cmGlobalWatcomWMakeGenerator.cxx diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 8c19bbd96..b707e96aa 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -392,7 +392,10 @@ int cmCPackDebGenerator::createDeb() } std::string cmd; - cmd = "\""; + if (NULL != this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE")) { + cmd += this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE"); + } + cmd += " \""; cmd += cmakeExecutable; cmd += "\" -E tar cfz data.tar.gz "; diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 7e5b26d62..083279fdd 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -33,7 +33,7 @@ //---------------------------------------------------------------------- cmCPackGenerator::cmCPackGenerator() { - this->GeneratorVerbose = false; + this->GeneratorVerbose = cmSystemTools::OUTPUT_NONE; this->MakefileMap = 0; this->Logger = 0; this->componentPackageMethod = ONE_PACKAGE_PER_GROUP; @@ -1000,6 +1000,7 @@ int cmCPackGenerator::DoPackage() std::string findExpr = tempDirectory; findExpr += "/*"; gl.RecurseOn(); + gl.SetRecurseThroughSymlinks(false); if ( !gl.FindFiles(findExpr) ) { cmCPackLogger(cmCPackLog::LOG_ERROR, diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 05d95b874..52def9da7 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -14,6 +14,7 @@ #define cmCPackGenerator_h #include "cmObject.h" +#include "cmSystemTools.h" #include #include @@ -57,7 +58,9 @@ public: /** * If verbose then more information is printed out */ - void SetVerbose(bool val) { this->GeneratorVerbose = val; } + void SetVerbose(bool val) + { this->GeneratorVerbose = val ? + cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE; } /** * Do the actual whole package processing. @@ -194,7 +197,7 @@ protected: virtual cmCPackComponentGroup* GetComponentGroup(const char *projectName, const char* name); - bool GeneratorVerbose; + cmSystemTools::OutputOption GeneratorVerbose; std::string Name; std::string InstallPath; diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index e5fe5759b..2b940673b 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -672,9 +672,6 @@ CreateComponentDescription(cmCPackComponent *component, } componentCode += " SetOutPath \"$INSTDIR\"\n"; - componentCode += " IntCmp $" + component->Name - + "_was_installed ${SF_SELECTED} noinstall_" + component->Name + "\n"; - // Create the actual installation commands if (component->IsDownloaded) { @@ -786,7 +783,8 @@ CreateComponentDescription(cmCPackComponent *component, std::string output; int retVal = -1; int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, &retVal, - dirName.c_str(), false, 0); + dirName.c_str(), + cmSystemTools::OUTPUT_NONE, 0); if ( !res || retVal ) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); @@ -824,7 +822,6 @@ CreateComponentDescription(cmCPackComponent *component, componentCode += " File /r \"${INST_DIR}\\" + component->Name + "\\*.*\"\n"; } - componentCode += " noinstall_" + component->Name + ":\n"; componentCode += "SectionEnd\n"; // Macro used to remove the component diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index 6ad103f11..7bccb89fb 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -46,10 +46,10 @@ protected: virtual bool SupportsComponentInstallation() const; - /// Produce a string that contains the NSIS code to describe a - /// particular component. Any added macros will be emitted via + /// Produce a string that contains the NSIS code to describe a + /// particular component. Any added macros will be emitted via /// macrosOut. - std::string + std::string CreateComponentDescription(cmCPackComponent *component, cmOStringStream& macrosOut); @@ -65,14 +65,14 @@ protected: (cmCPackComponent *component, std::set& visited); - /// Produce a string that contains the NSIS code to describe a + /// 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 + std::string CreateComponentGroupDescription(cmCPackComponentGroup *group, cmOStringStream& macrosOut); - /// Translations any newlines found in the string into \r\n, so that the + /// 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); }; diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 9163af811..b1706e3eb 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -244,7 +244,7 @@ int main (int argc, char *argv[]) // find out which system cpack is running on, so it can setup the search // paths, so FIND_XXX() commands can be used in scripts cminst.AddCMakePaths(); - std::string systemFile = + std::string systemFile = globalMF->GetModulesFile("CMakeDetermineSystem.cmake"); if (!globalMF->ReadListFile(0, systemFile.c_str())) { @@ -253,7 +253,7 @@ int main (int argc, char *argv[]) return 1; } - systemFile = + systemFile = globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake"); if (!globalMF->ReadListFile(0, systemFile.c_str())) { @@ -264,7 +264,7 @@ int main (int argc, char *argv[]) if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) ) { - cpackConfigFile = + cpackConfigFile = cmSystemTools::CollapseFullPath(cpackConfigFile.c_str()); cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Read CPack configuration file: " << cpackConfigFile.c_str() @@ -410,7 +410,7 @@ int main (int argc, char *argv[]) cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: " << projName << std::endl); - const char* projVersion = + const char* projVersion = mf->GetDefinition("CPACK_PACKAGE_VERSION"); if ( !projVersion ) { @@ -423,7 +423,7 @@ int main (int argc, char *argv[]) cmOStringStream ostr; ostr << projVersionMajor << "." << projVersionMinor << "." << projVersionPatch; - mf->AddDefinition("CPACK_PACKAGE_VERSION", + mf->AddDefinition("CPACK_PACKAGE_VERSION", ostr.str().c_str()); } @@ -448,7 +448,7 @@ int main (int argc, char *argv[]) doc.SetSection("Name",cmDocumentationName); doc.SetSection("Usage",cmDocumentationUsage); doc.SetSection("Description",cmDocumentationDescription); - doc.SetSection("Options",cmDocumentationOptions); + doc.PrependSection("Options",cmDocumentationOptions); std::vector v; cmCPackGeneratorFactory::DescriptionsMap::const_iterator generatorIt; diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 86bd85d94..34a3e60c3 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -57,7 +57,7 @@ static const char* cmCTestErrorMatches[] = { "^ild:([ \\t])*\\(undefined symbol\\)", "([^ :]+) : (error|fatal error|catastrophic error)", "([^:]+): (Error:|error|undefined reference|multiply defined)", - "([^:]+)\\(([^\\)]+)\\) : (error|fatal error|catastrophic error)", + "([^:]+)\\(([^\\)]+)\\) ?: (error|fatal error|catastrophic error)", "^fatal error C[0-9]+:", ": syntax error ", "^collect2: ld returned 1 exit status", diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 9a668bce1..7a99ddfa0 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -41,7 +41,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() { this->CTest->SetCTestConfiguration("BuildDirectory", cmSystemTools::CollapseFullPath( - this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY")).c_str()); + this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY")).c_str()); } if ( this->Values[ct_SOURCE] ) @@ -54,7 +54,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() { this->CTest->SetCTestConfiguration("SourceDirectory", cmSystemTools::CollapseFullPath( - this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")).c_str()); + this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY")).c_str()); } if ( this->CTest->GetCTestConfiguration("BuildDirectory").empty() ) diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 005651f84..0b1c9fef8 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -751,12 +751,15 @@ int cmCTestCoverageHandler::HandlePHPCoverage( } return static_cast(cont->TotalCoverage.size()); } + //---------------------------------------------------------------------- int cmCTestCoverageHandler::HandleGCovCoverage( cmCTestCoverageHandlerContainer* cont) { std::string gcovCommand = this->CTest->GetCTestConfiguration("CoverageCommand"); + std::string gcovExtraFlags + = this->CTest->GetCTestConfiguration("CoverageExtraFlags"); // Style 1 std::string st1gcovOutputRex1 @@ -825,8 +828,10 @@ int cmCTestCoverageHandler::HandleGCovCoverage( // Call gcov to get coverage data for this *.gcda file: // std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str()); - std::string command = "\"" + gcovCommand + "\" -l -p -o \"" + fileDir - + "\" \"" + *it + "\""; + std::string command = "\"" + gcovCommand + "\" " + + gcovExtraFlags + " " + + "-o \"" + fileDir + "\" " + + "\"" + *it + "\""; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str() << std::endl); diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx index 8c3c22acf..fd75e45e8 100644 --- a/Source/CTest/cmCTestGenericHandler.cxx +++ b/Source/CTest/cmCTestGenericHandler.cxx @@ -18,7 +18,7 @@ //---------------------------------------------------------------------- cmCTestGenericHandler::cmCTestGenericHandler() { - this->HandlerVerbose = false; + this->HandlerVerbose = cmSystemTools::OUTPUT_NONE; this->CTest = 0; this->SubmitIndex = 0; this->AppendXML = false; diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h index 739314521..18189ec2b 100644 --- a/Source/CTest/cmCTestGenericHandler.h +++ b/Source/CTest/cmCTestGenericHandler.h @@ -16,6 +16,7 @@ #include "cmObject.h" #include "cmCTest.h" +#include "cmSystemTools.h" //OutputOption class cmMakefile; class cmCTestCommand; @@ -31,7 +32,9 @@ public: /** * If verbose then more informaiton is printed out */ - void SetVerbose(bool val) { this->HandlerVerbose = val; } + void SetVerbose(bool val) + { this->HandlerVerbose = val ? + cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE; } /** * Populate internals from CTest custom scripts @@ -91,7 +94,7 @@ protected: bool StartLogFile(const char* name, cmGeneratedFileStream& xofs); bool AppendXML; - bool HandlerVerbose; + cmSystemTools::OutputOption HandlerVerbose; cmCTest *CTest; t_StringToString Options; t_StringToString PersistentOptions; diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h index cd876d085..7457e8357 100644 --- a/Source/CTest/cmCTestLaunch.h +++ b/Source/CTest/cmCTestLaunch.h @@ -24,7 +24,7 @@ class cmCTestLaunch { public: /** Entry point from ctest executable main(). */ - static int Main(int argc, const char* const* argv); + static int Main(int argc, const char* const argv[]); private: // Initialize the launcher from its command line. cmCTestLaunch(int argc, const char* const* argv); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 06124491a..f0a98f9fd 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -672,30 +672,30 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput( cmsys::RegularExpression vgFMM( "== .*Mismatched free\\(\\) / delete / delete \\[\\]"); cmsys::RegularExpression vgMLK1( - "== .*[0-9][0-9]* bytes in [0-9][0-9]* blocks are definitely lost" - " in loss record [0-9][0-9]* of [0-9]"); + "== .*[0-9,]+ bytes in [0-9,]+ blocks are definitely lost" + " in loss record [0-9,]+ of [0-9,]+"); cmsys::RegularExpression vgMLK2( - "== .*[0-9][0-9]* \\([0-9]*,?[0-9]* direct, [0-9]*,?[0-9]* indirect\\)" - " bytes in [0-9][0-9]* blocks are definitely lost" - " in loss record [0-9][0-9]* of [0-9]"); + "== .*[0-9,]+ \\([0-9,]+ direct, [0-9,]+ indirect\\)" + " bytes in [0-9,]+ blocks are definitely lost" + " in loss record [0-9,]+ of [0-9,]+"); cmsys::RegularExpression vgPAR( "== .*Syscall param .* contains unaddressable byte\\(s\\)"); cmsys::RegularExpression vgMPK1( - "== .*[0-9][0-9]* bytes in [0-9][0-9]* blocks are possibly lost in" - " loss record [0-9][0-9]* of [0-9]"); + "== .*[0-9,]+ bytes in [0-9,]+ blocks are possibly lost in" + " loss record [0-9,]+ of [0-9,]+"); cmsys::RegularExpression vgMPK2( - "== .*[0-9][0-9]* bytes in [0-9][0-9]* blocks are still reachable" - " in loss record [0-9][0-9]* of [0-9]"); + "== .*[0-9,]+ bytes in [0-9,]+ blocks are still reachable" + " in loss record [0-9,]+ of [0-9,]+"); cmsys::RegularExpression vgUMC( "== .*Conditional jump or move depends on uninitialised value\\(s\\)"); cmsys::RegularExpression vgUMR1( - "== .*Use of uninitialised value of size [0-9][0-9]*"); - cmsys::RegularExpression vgUMR2("== .*Invalid read of size [0-9][0-9]*"); + "== .*Use of uninitialised value of size [0-9,]+"); + cmsys::RegularExpression vgUMR2("== .*Invalid read of size [0-9,]+"); cmsys::RegularExpression vgUMR3("== .*Jump to the invalid address "); cmsys::RegularExpression vgUMR4("== .*Syscall param .* contains " "uninitialised or unaddressable byte\\(s\\)"); cmsys::RegularExpression vgUMR5("== .*Syscall param .* uninitialised"); - cmsys::RegularExpression vgIPW("== .*Invalid write of size [0-9]"); + cmsys::RegularExpression vgIPW("== .*Invalid write of size [0-9,]+"); cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is " "locked by a different thread"); std::vector nonValGrindOutput; diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 60695daa1..81f18b05c 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -93,6 +93,7 @@ void cmCTestRunTest::CompressOutput() ret = deflateInit(&strm, -1); //default compression level if (ret != Z_OK) { + delete[] out; return; } @@ -106,6 +107,7 @@ void cmCTestRunTest::CompressOutput() { cmCTestLog(this->CTest, ERROR_MESSAGE, "Error during output " "compression. Sending uncompressed output." << std::endl); + delete[] out; return; } diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index e7755b138..14eac80b5 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -18,7 +18,7 @@ * \brief Helper class for CTest * * Submit testing results - * + * */ class cmCTestSubmitHandler : public cmCTestGenericHandler { @@ -47,35 +47,37 @@ private: /** * Submit file using various ways */ - bool SubmitUsingFTP(const cmStdString& localprefix, + bool SubmitUsingFTP(const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url); - bool SubmitUsingHTTP(const cmStdString& localprefix, + bool SubmitUsingHTTP(const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url); bool SubmitUsingSCP(const cmStdString& scp_command, - const cmStdString& localprefix, + const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url); - bool SubmitUsingCP( const cmStdString& localprefix, + bool SubmitUsingCP( const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url); bool TriggerUsingHTTP(const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url); - bool SubmitUsingXMLRPC(const cmStdString& localprefix, + bool SubmitUsingXMLRPC(const cmStdString& localprefix, const std::set& files, - const cmStdString& remoteprefix, + const cmStdString& remoteprefix, const cmStdString& url); - void ParseResponse(std::vector); + typedef std::vector cmCTestSubmitHandlerVectorOfChar; + + void ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk); std::string GetSubmitResultsPrefix(); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index e3b81df88..9b12393c5 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -33,6 +33,7 @@ #include #include // auto_ptr +#include //---------------------------------------------------------------------- class cmCTestSubdirCommand : public cmCommand @@ -617,9 +618,13 @@ int cmCTestTestHandler::ProcessHandler() << "The following tests FAILED:" << std::endl); this->StartLogFile("TestsFailed", ofs); - std::vector::iterator ftit; - for(ftit = this->TestResults.begin(); - ftit != this->TestResults.end(); ++ftit) + typedef std::set SetOfTests; + SetOfTests resultsSet(this->TestResults.begin(), + this->TestResults.end()); + + for(SetOfTests::iterator ftit = resultsSet.begin(); + ftit != resultsSet.end(); ++ftit) { if ( ftit->Status != cmCTestTestHandler::COMPLETED ) { @@ -1301,7 +1306,8 @@ int cmCTestTestHandler::ExecuteCommands(std::vector& vec) int retVal = 0; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run command: " << *it << std::endl); - if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0, true + if ( !cmSystemTools::RunSingleCommand(it->c_str(), 0, &retVal, 0, + cmSystemTools::OUTPUT_MERGE /*this->Verbose*/) || retVal != 0 ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem running command: " diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 3089d35d4..8e59e5915 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -125,7 +125,16 @@ public: cmCTestTestProperties* Properties; }; - // add configuraitons to a search path for an executable + struct cmCTestTestResultLess + { + bool operator() (const cmCTestTestResult &lhs, + const cmCTestTestResult &rhs) const + { + return lhs.TestCount < rhs.TestCount; + } + }; + + // add configurations to a search path for an executable static void AddConfigurations(cmCTest *ctest, std::vector &attempted, std::vector &attemptedConfigs, @@ -141,7 +150,7 @@ public: typedef std::vector ListOfTests; protected: - // comput a final test list + // compute a final test list virtual int PreProcessHandler(); virtual int PostProcessHandler(); virtual void GenerateTestCommand(std::vector& args); diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx index 32c1ec110..593b2d1a8 100644 --- a/Source/CTest/cmParsePHPCoverage.cxx +++ b/Source/CTest/cmParsePHPCoverage.cxx @@ -159,6 +159,7 @@ bool cmParsePHPCoverage::ReadFileInformation(std::ifstream& in) // read open quote if(in.get(c) && c != '"') { + delete[] s; return false; } // read the string data diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx index 9ede7a6cc..b1a72afa4 100644 --- a/Source/CursesDialog/ccmake.cxx +++ b/Source/CursesDialog/ccmake.cxx @@ -76,11 +76,11 @@ void onsig(int) if (cmCursesForm::CurrentForm) { endwin(); - initscr(); /* Initialization */ - noecho(); /* Echo off */ - cbreak(); /* nl- or cr not needed */ - keypad(stdscr,TRUE); /* Use key symbols as - KEY_DOWN*/ + initscr(); /* Initialization */ + noecho(); /* Echo off */ + cbreak(); /* nl- or cr not needed */ + keypad(stdscr,TRUE); /* Use key symbols as + KEY_DOWN*/ refresh(); int x,y; getmaxyx(stdscr, y, x); @@ -89,7 +89,7 @@ void onsig(int) } signal(SIGWINCH, onsig); } - + } void CMakeErrorHandler(const char* message, const char* title, bool&, void* clientData) @@ -116,13 +116,13 @@ int main(int argc, char** argv) doc.SetSection("Usage",cmDocumentationUsage); doc.SetSection("Description",cmDocumentationDescription); doc.SetSection("Generators",generators); - doc.SetSection("Options",cmDocumentationOptions); + doc.PrependSection("Options",cmDocumentationOptions); doc.SetSection("Command",commands); doc.SetSection("Compatibility Commands",compatCommands); doc.SetSeeAlsoList(cmDocumentationSeeAlso); return doc.PrintRequestedDocumentation(std::cout)? 0:1; - } - + } + bool debug = false; unsigned int i; int j; @@ -156,22 +156,22 @@ int main(int argc, char** argv) cmCursesForm::DebugStart(); } - initscr(); /* Initialization */ - noecho(); /* Echo off */ - cbreak(); /* nl- or cr not needed */ - keypad(stdscr,TRUE); /* Use key symbols as - KEY_DOWN*/ + initscr(); /* Initialization */ + noecho(); /* Echo off */ + cbreak(); /* nl- or cr not needed */ + keypad(stdscr,TRUE); /* Use key symbols as + KEY_DOWN*/ signal(SIGWINCH, onsig); int x,y; getmaxyx(stdscr, y, x); - if ( x < cmCursesMainForm::MIN_WIDTH || + if ( x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT ) { endwin(); std::cerr << "Window is too small. A size of at least " - << cmCursesMainForm::MIN_WIDTH << " x " + << cmCursesMainForm::MIN_WIDTH << " x " << cmCursesMainForm::MIN_HEIGHT << " is required to run ccmake." << std::endl; return 1; @@ -201,7 +201,7 @@ int main(int argc, char** argv) myform->Render(1, 1, x, y); myform->HandleInput(); } - + // Need to clean-up better curses_clear(); touchwin(stdscr); @@ -210,7 +210,7 @@ int main(int argc, char** argv) cmCursesForm::CurrentForm = 0; std::cout << std::endl << std::endl; - + return 0; } diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index 1c48d8c7c..0e2cd229f 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -68,7 +68,7 @@ void cmCursesLongMessageForm::UpdateStatusBar() } else { - width = cmCursesMainForm::MAX_WIDTH; + width = cmCursesMainForm::MAX_WIDTH-1; } bar[width] = '\0'; diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index e1876b902..6c7627f92 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -27,7 +27,7 @@ inline int ctrl(int z) { return (z&037); -} +} cmCursesMainForm::cmCursesMainForm(std::vector const& args, int initWidth) : @@ -80,7 +80,7 @@ cmCursesMainForm::~cmCursesMainForm() { delete this->CMakeInstance; this->CMakeInstance = 0; - } + } } // See if a cache entry is in the list of entries in the ui. @@ -99,7 +99,7 @@ bool cmCursesMainForm::LookForCacheEntry(const char* key) return true; } } - + return false; } @@ -114,7 +114,7 @@ void cmCursesMainForm::InitializeUI() // Count non-internal and non-static entries int count=0; - for(cmCacheManager::CacheIterator i = + for(cmCacheManager::CacheIterator i = this->CMakeInstance->GetCacheManager()->NewIterator(); !i.IsAtEnd(); i.Next()) { @@ -142,12 +142,12 @@ void cmCursesMainForm::InitializeUI() // Create the composites. // First add entries which are new - for(cmCacheManager::CacheIterator i = + for(cmCacheManager::CacheIterator i = this->CMakeInstance->GetCacheManager()->NewIterator(); !i.IsAtEnd(); i.Next()) { const char* key = i.GetName(); - if ( i.GetType() == cmCacheManager::INTERNAL || + if ( i.GetType() == cmCacheManager::INTERNAL || i.GetType() == cmCacheManager::STATIC || i.GetType() == cmCacheManager::UNINITIALIZED ) { @@ -164,12 +164,12 @@ void cmCursesMainForm::InitializeUI() } // then add entries which are old - for(cmCacheManager::CacheIterator i = + for(cmCacheManager::CacheIterator i = this->CMakeInstance->GetCacheManager()->NewIterator(); !i.IsAtEnd(); i.Next()) { const char* key = i.GetName(); - if ( i.GetType() == cmCacheManager::INTERNAL || + if ( i.GetType() == cmCacheManager::INTERNAL || i.GetType() == cmCacheManager::STATIC || i.GetType() == cmCacheManager::UNINITIALIZED ) { @@ -184,7 +184,7 @@ void cmCursesMainForm::InitializeUI() } } } - + // Clean old entries if (this->Entries) { @@ -197,7 +197,7 @@ void cmCursesMainForm::InitializeUI() } delete this->Entries; this->Entries = newEntries; - + // Compute fields from composites this->RePost(); } @@ -224,7 +224,7 @@ void cmCursesMainForm::RePost() std::vector::iterator it; for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - cmCacheManager::CacheIterator mit = + cmCacheManager::CacheIterator mit = this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); if (mit.IsAtEnd() || (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) @@ -253,7 +253,7 @@ void cmCursesMainForm::RePost() std::vector::iterator it; for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - cmCacheManager::CacheIterator mit = + cmCacheManager::CacheIterator mit = this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); if (mit.IsAtEnd() || (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) @@ -301,7 +301,7 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) } // Wrong window size - if ( width < cmCursesMainForm::MIN_WIDTH || + if ( width < cmCursesMainForm::MIN_WIDTH || width < this->InitialWidth || height < cmCursesMainForm::MIN_HEIGHT ) { @@ -322,7 +322,7 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) std::vector::iterator it; for (it = this->Entries->begin(); it != this->Entries->end(); ++it) { - cmCacheManager::CacheIterator mit = + cmCacheManager::CacheIterator mit = this->CMakeInstance->GetCacheManager()->GetCacheIterator((*it)->GetValue()); if (mit.IsAtEnd() || (!this->AdvancedMode && mit.GetPropertyAsBool("ADVANCED"))) @@ -372,7 +372,7 @@ void cmCursesMainForm::Render(int left, int top, int width, int height) this->UpdateStatusBar(); this->PrintKeys(); - touchwin(stdscr); + touchwin(stdscr); refresh(); } @@ -380,7 +380,7 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) { int x,y; getmaxyx(stdscr, y, x); - if ( x < cmCursesMainForm::MIN_WIDTH || + if ( x < cmCursesMainForm::MIN_WIDTH || x < this->InitialWidth || y < cmCursesMainForm::MIN_HEIGHT ) { @@ -399,7 +399,7 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) { cw->PrintKeys(); } - + // { // } // else @@ -409,35 +409,34 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) char thirdLine[512]=""; if (process) { - sprintf(firstLine, - " "); - sprintf(secondLine, - " "); - sprintf(thirdLine, - " "); + sprintf(firstLine, + " "); + sprintf(secondLine, + " "); + sprintf(thirdLine, + " "); } else { if (this->OkToGenerate) { - sprintf(firstLine, - "Press [c] to configure Press [g] to generate and exit"); + sprintf(firstLine, + "Press [c] to configure Press [g] to generate and exit"); } else { sprintf(firstLine, "Press [c] to configure "); } - if (this->AdvancedMode) - { - sprintf(thirdLine, "Press [t] to toggle advanced mode (Currently On)"); - } - else - { - sprintf(thirdLine, "Press [t] to toggle advanced mode (Currently Off)"); - } - - sprintf(secondLine, - "Press [h] for help Press [q] to quit without generating"); + { + const char* toggleKeyInstruction = + "Press [t] to toggle advanced mode (Currently %s)"; + sprintf(thirdLine, + toggleKeyInstruction, + this->AdvancedMode ? "On" : "Off"); + } + sprintf(secondLine, + "Press [h] for help " + "Press [q] to quit without generating"); } curses_move(y-4,0); @@ -463,7 +462,7 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) // } pos_form_cursor(this->Form); - + } // Print the key of the current entry and the CMake version @@ -473,7 +472,7 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) int x,y; getmaxyx(stdscr, y, x); // If window size is too small, display error and return - if ( x < cmCursesMainForm::MIN_WIDTH || + if ( x < cmCursesMainForm::MIN_WIDTH || x < this->InitialWidth || y < cmCursesMainForm::MIN_HEIGHT ) { @@ -482,10 +481,10 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) char fmt[] = "Window is too small. A size of at least %dx%d is required."; printw(fmt, (cmCursesMainForm::MIN_WIDTH < this->InitialWidth ? - this->InitialWidth : cmCursesMainForm::MIN_WIDTH), + this->InitialWidth : cmCursesMainForm::MIN_WIDTH), cmCursesMainForm::MIN_HEIGHT); - touchwin(stdscr); - wrefresh(stdscr); + touchwin(stdscr); + wrefresh(stdscr); return; } @@ -502,10 +501,10 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) if ( lbl ) { curField = lbl->GetValue(); - + // Get the help string of the current entry // and add it to the help string - cmCacheManager::CacheIterator it = + cmCacheManager::CacheIterator it = this->CMakeInstance->GetCacheManager()->GetCacheIterator(curField); if (!it.IsAtEnd()) { @@ -549,9 +548,9 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) if ( curFieldLen < width ) { strcpy(bar, curField); - for(i=curFieldLen; i < width; ++i) - { - bar[i] = ' '; + for(i=curFieldLen; i < width; ++i) + { + bar[i] = ' '; } } else @@ -578,14 +577,14 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) else { strcpy(bar+curFieldLen+2, help); - for(i=curFieldLen+helpLen+2; i < width; ++i) - { - bar[i] = ' '; + for(i=curFieldLen+helpLen+2; i < width; ++i) + { + bar[i] = ' '; } } } } - + bar[width] = '\0'; @@ -605,7 +604,7 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) attron(A_STANDOUT); char format[] = "%s"; printw(format, bar); - attroff(A_STANDOUT); + attroff(A_STANDOUT); curses_move(y-4,0); printw(version); pos_form_cursor(this->Form); @@ -631,7 +630,7 @@ void cmCursesMainForm::UpdateProgress(const char *msg, float prog, void* vp) cm->UpdateStatusBar(cmsg); cm->PrintKeys(1); curses_move(1,1); - touchwin(stdscr); + touchwin(stdscr); refresh(); } @@ -643,7 +642,7 @@ int cmCursesMainForm::Configure(int noconfigure) curses_move(1,1); this->UpdateStatusBar("Configuring, please wait..."); this->PrintKeys(1); - touchwin(stdscr); + touchwin(stdscr); refresh(); this->CMakeInstance->SetProgressCallback(cmCursesMainForm::UpdateProgress, this); @@ -652,7 +651,7 @@ int cmCursesMainForm::Configure(int noconfigure) this->CMakeInstance->GetCacheManager()->SaveCache( this->CMakeInstance->GetHomeOutputDirectory()); this->LoadCache(0); - + // Get rid of previous errors this->Errors = std::vector(); @@ -674,8 +673,8 @@ int cmCursesMainForm::Configure(int noconfigure) } this->CMakeInstance->SetProgressCallback(0, 0); - keypad(stdscr,TRUE); /* Use key symbols as - KEY_DOWN*/ + keypad(stdscr,TRUE); /* Use key symbols as + KEY_DOWN*/ if( retVal != 0 || !this->Errors.empty()) { @@ -705,10 +704,10 @@ int cmCursesMainForm::Configure(int noconfigure) CurrentForm = this; this->Render(1,1,xx,yy); } - + this->InitializeUI(); this->Render(1, 1, xi, yi); - + return 0; } @@ -731,8 +730,8 @@ int cmCursesMainForm::Generate() int retVal = this->CMakeInstance->Generate(); this->CMakeInstance->SetProgressCallback(0, 0); - keypad(stdscr,TRUE); /* Use key symbols as - KEY_DOWN*/ + keypad(stdscr,TRUE); /* Use key symbols as + KEY_DOWN*/ if( retVal != 0 || !this->Errors.empty()) { @@ -764,10 +763,10 @@ int cmCursesMainForm::Generate() CurrentForm = this; this->Render(1,1,xx,yy); } - + this->InitializeUI(); this->Render(1, 1, xi, yi); - + return 0; } @@ -798,11 +797,11 @@ void cmCursesMainForm::RemoveEntry(const char* value) // copy from the list box to the cache manager void cmCursesMainForm::FillCacheManagerFromUI() -{ +{ size_t size = this->Entries->size(); for(size_t i=0; i < size; i++) { - cmCacheManager::CacheIterator it = + cmCacheManager::CacheIterator it = this->CMakeInstance->GetCacheManager()->GetCacheIterator( (*this->Entries)[i]->Key.c_str()); if (!it.IsAtEnd()) @@ -872,14 +871,14 @@ void cmCursesMainForm::HandleInput() this->PrintKeys(1); curses_move(y-5,static_cast(searchstr.size())); //curses_move(1,1); - touchwin(stdscr); + touchwin(stdscr); refresh(); } int key = getch(); getmaxyx(stdscr, y, x); // If window too small, handle 'q' only - if ( x < cmCursesMainForm::MIN_WIDTH || + if ( x < cmCursesMainForm::MIN_WIDTH || y < cmCursesMainForm::MIN_HEIGHT ) { // quit @@ -948,7 +947,7 @@ void cmCursesMainForm::HandleInput() } if ((!currentWidget || !widgetHandled) && !this->SearchMode) { - // If the current widget does not want to handle input, + // If the current widget does not want to handle input, // we handle it. sprintf(debugMessage, "Main form handling input, key: %d", key); cmCursesForm::LogMessage(debugMessage); @@ -1028,7 +1027,7 @@ void cmCursesMainForm::HandleInput() this->Fields[findex-2])); const char* curField = lbl->GetValue(); const char* helpString=0; - cmCacheManager::CacheIterator it = + cmCacheManager::CacheIterator it = this->CMakeInstance->GetCacheManager()->GetCacheIterator(curField); if (!it.IsAtEnd()) { @@ -1052,7 +1051,7 @@ void cmCursesMainForm::HandleInput() CurrentForm = msgs; msgs->Render(1,1,x,y); msgs->HandleInput(); - CurrentForm = this; + CurrentForm = this; this->Render(1,1,x,y); set_current_field(this->Form, cur); } @@ -1137,7 +1136,7 @@ void cmCursesMainForm::HandleInput() // each entry consists of fields: label, isnew, value // therefore, the label field for the is findex-2 // (findex always corresponds to the value field) - cmCursesWidget* lbl + cmCursesWidget* lbl = reinterpret_cast( field_userptr(this->Fields[findex-2])); if ( lbl ) @@ -1177,15 +1176,15 @@ void cmCursesMainForm::HandleInput() } } - touchwin(stdscr); - wrefresh(stdscr); + touchwin(stdscr); + wrefresh(stdscr); } } int cmCursesMainForm::LoadCache(const char *) { - int r = this->CMakeInstance->LoadCache(); + int r = this->CMakeInstance->LoadCache(); if(r < 0) { return r; @@ -1194,7 +1193,7 @@ int cmCursesMainForm::LoadCache(const char *) this->CMakeInstance->PreLoadCMakeFiles(); return r; } - + void cmCursesMainForm::JumpToCacheEntry(const char* astr) { std::string str; @@ -1247,7 +1246,7 @@ void cmCursesMainForm::JumpToCacheEntry(const char* astr) /* char buffer[1024]; sprintf(buffer, "Line: %d != %d / %d\n", findex, idx, this->NumberOfVisibleEntries); - touchwin(stdscr); + touchwin(stdscr); refresh(); this->UpdateStatusBar( buffer ); usleep(100000); @@ -1262,7 +1261,7 @@ void cmCursesMainForm::JumpToCacheEntry(const char* astr) } -const char* cmCursesMainForm::s_ConstHelpMessage = +const char* cmCursesMainForm::s_ConstHelpMessage = "CMake is used to configure and generate build files for software projects. " "The basic steps for configuring a project with ccmake are as follows:\n\n" "1. Run ccmake in the directory where you want the object and executable files to be placed (build directory). If the source directory is not the same as this build directory, you have to specify it as an argument on the command line.\n\n" @@ -1301,6 +1300,5 @@ const char* cmCursesMainForm::s_ConstHelpMessage = " g : generate build files and exit, only available when there are no " "new options and no errors have been detected during last configuration.\n" " l : shows last errors\n" -" t : toggles advanced mode. In normal mode, only the most important options are shown. In advanced mode, all options are shown. We recommend using normal mode unless you are an expert.\n"; - - +" t : toggles advanced mode. In normal mode, only the most important options are shown. In advanced mode, all options are shown. We recommend using normal mode unless you are an expert.\n" +" / : search for a variable name.\n"; diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx index b4d919193..00aaf69da 100644 --- a/Source/QtDialog/AddCacheEntry.cxx +++ b/Source/QtDialog/AddCacheEntry.cxx @@ -12,15 +12,16 @@ #include "AddCacheEntry.h" #include +#include static const int NumTypes = 4; -static const QString TypeStrings[NumTypes] = +static const QString TypeStrings[NumTypes] = { "BOOL", "PATH", "FILEPATH", "STRING" }; -static const QCMakeProperty::PropertyType Types[NumTypes] = - { QCMakeProperty::BOOL, QCMakeProperty::PATH, - QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; +static const QCMakeProperty::PropertyType Types[NumTypes] = + { QCMakeProperty::BOOL, QCMakeProperty::PATH, + QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; -AddCacheEntry::AddCacheEntry(QWidget* p) +AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& completions) : QWidget(p) { this->setupUi(this); @@ -42,6 +43,7 @@ AddCacheEntry::AddCacheEntry(QWidget* p) this->setTabOrder(path, filepath); this->setTabOrder(filepath, string); this->setTabOrder(string, this->Description); + this->Name->setCompleter(new QCompleter(completions, this)); } QString AddCacheEntry::name() const diff --git a/Source/QtDialog/AddCacheEntry.h b/Source/QtDialog/AddCacheEntry.h index db6baf9b1..e219d4ee7 100644 --- a/Source/QtDialog/AddCacheEntry.h +++ b/Source/QtDialog/AddCacheEntry.h @@ -15,6 +15,7 @@ #include #include +#include #include "QCMake.h" #include "ui_AddCacheEntry.h" @@ -23,7 +24,7 @@ class AddCacheEntry : public QWidget, public Ui::AddCacheEntry { Q_OBJECT public: - AddCacheEntry(QWidget* p); + AddCacheEntry(QWidget* p, const QStringList& completions); QString name() const; QVariant value() const; diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index c8c4bfa5b..338eaffb4 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "QCMake.h" @@ -68,6 +69,9 @@ CMakeSetupDialog::CMakeSetupDialog() int w = settings.value("Width", 700).toInt(); this->resize(w, h); + this->AddVariableCompletions = settings.value("AddVariableCompletionEntries", + QStringList("CMAKE_INSTALL_PREFIX")).toStringList(); + QWidget* cont = new QWidget(this); this->setupUi(cont); this->Splitter->setStretchFactor(0, 3); @@ -96,6 +100,7 @@ CMakeSetupDialog::CMakeSetupDialog() QObject::connect(this->DeleteCacheAction, SIGNAL(triggered(bool)), this, SLOT(doDeleteCache())); this->ExitAction = FileMenu->addAction(tr("E&xit")); + this->ExitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); QObject::connect(this->ExitAction, SIGNAL(triggered(bool)), this, SLOT(close())); @@ -1008,7 +1013,7 @@ void CMakeSetupDialog::addCacheEntry() dialog.resize(400, 200); dialog.setWindowTitle(tr("Add Cache Entry")); QVBoxLayout* l = new QVBoxLayout(&dialog); - AddCacheEntry* w = new AddCacheEntry(&dialog); + AddCacheEntry* w = new AddCacheEntry(&dialog, this->AddVariableCompletions); QDialogButtonBox* btns = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog); @@ -1021,6 +1026,26 @@ void CMakeSetupDialog::addCacheEntry() { QCMakeCacheModel* m = this->CacheValues->cacheModel(); m->insertProperty(w->type(), w->name(), w->description(), w->value(), false); + + // only add variable names to the completion which are new + if (!this->AddVariableCompletions.contains(w->name())) + { + this->AddVariableCompletions << w->name(); + // limit to at most 100 completion items + if (this->AddVariableCompletions.size() > 100) + { + this->AddVariableCompletions.removeFirst(); + } + // make sure CMAKE_INSTALL_PREFIX is always there + if (!this->AddVariableCompletions.contains("CMAKE_INSTALL_PREFIX")) + { + this->AddVariableCompletions << QString("CMAKE_INSTALL_PREFIX"); + } + QSettings settings; + settings.beginGroup("Settings/StartPath"); + settings.setValue("AddVariableCompletionEntries", + this->AddVariableCompletions); + } } } diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index 51217592a..259967580 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -36,7 +36,7 @@ public slots: void setBinaryDirectory(const QString& dir); void setSourceDirectory(const QString& dir); -protected slots: +protected slots: void initialize(); void doConfigure(); void doGenerate(); @@ -46,7 +46,7 @@ protected slots: void doInterrupt(); void error(const QString& message); void message(const QString& message); - + void doSourceBrowse(); void doBinaryBrowse(); void doReloadCache(); @@ -105,6 +105,8 @@ protected: QTextCharFormat ErrorFormat; QTextCharFormat MessageFormat; + QStringList AddVariableCompletions; + QEventLoop LocalLoop; float ProgressOffset; @@ -118,8 +120,8 @@ class QCMakeThread : public QThread public: QCMakeThread(QObject* p); QCMake* cmakeInstance() const; - -signals: + +signals: void cmakeInitialized(); protected: diff --git a/Source/QtDialog/README b/Source/QtDialog/README deleted file mode 100644 index 0701a2be0..000000000 --- a/Source/QtDialog/README +++ /dev/null @@ -1,3 +0,0 @@ -This is the Qt interface to CMake. It has a BSD license compatible with the -Qt license exception. Only developers with a paid QT license are permitted -to make changes to this code. Small patches and bug fixes can diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h index 47b542c81..05e7dc28e 100644 --- a/Source/cmAddCustomCommandCommand.h +++ b/Source/cmAddCustomCommandCommand.h @@ -75,6 +75,10 @@ public: "A target created in the same directory (CMakeLists.txt file) that " "specifies any output of the custom command as a source file is given " "a rule to generate the file using the command at build time. " + "Do not list the output in more than one independent target that may " + "build in parallel or the two instances of the rule may conflict " + "(instead use add_custom_target to drive the command and make the " + "other targets depend on that one). " "If an output name is a relative path it will be interpreted " "relative to the build tree directory corresponding to the current " "source directory. " diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index a625c47e8..bac243039 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -58,7 +58,8 @@ bool cmAddExecutableCommand } // Special modifiers are not allowed with IMPORTED signature. - if(importTarget && (use_win32 || use_macbundle || excludeFromAll)) + if(importTarget + && (use_win32 || use_macbundle || excludeFromAll)) { if(use_win32) { diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index f522cee9e..efa29e6c9 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -31,13 +31,13 @@ bool cmAddLibraryCommand } bool excludeFromAll = false; bool importTarget = false; - + std::vector::const_iterator s = args.begin(); std::string libName = *s; ++s; - + // If the second argument is "SHARED" or "STATIC", then it controls // the type of library. Otherwise, it is treated as a source or // source list name. There may be two keyword arguments, check for them @@ -85,11 +85,11 @@ bool cmAddLibraryCommand } } - /* ideally we should check whether for the linker language of the target + /* ideally we should check whether for the linker language of the target CMAKE_${LANG}_CREATE_SHARED_LIBRARY is defined and if not default to - STATIC. But at this point we know only the name of the target, but not + STATIC. But at this point we know only the name of the target, but not yet its linker language. */ - if ((type != cmTarget::STATIC_LIBRARY) && + if ((type != cmTarget::STATIC_LIBRARY) && (this->Makefile->GetCMakeInstance()->GetPropertyAsBool( "TARGET_SUPPORTS_SHARED_LIBS") == false)) { @@ -103,16 +103,16 @@ bool cmAddLibraryCommand type = cmTarget::STATIC_LIBRARY; } - // The IMPORTED signature requires a type to be specified explicitly. - if(importTarget && !haveSpecifiedType) - { - this->SetError("called with IMPORTED argument but no library type."); - return false; - } - // Handle imported target creation. if(importTarget) { + // The IMPORTED signature requires a type to be specified explicitly. + if (!haveSpecifiedType) + { + this->SetError("called with IMPORTED argument but no library type."); + return false; + } + // Make sure the target does not already exist. if(this->Makefile->FindTargetToUse(libName.c_str())) { @@ -158,15 +158,14 @@ bool cmAddLibraryCommand } std::vector srclists; - while (s != args.end()) + while (s != args.end()) { - srclists.push_back(*s); + srclists.push_back(*s); ++s; } - this->Makefile->AddLibrary(libName.c_str(), type, srclists, - excludeFromAll); - + this->Makefile->AddLibrary(libName.c_str(), type, srclists, excludeFromAll); + return true; } diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index 25dc8ba48..eab8a592a 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -180,7 +180,8 @@ bool cmArchiveWrite::AddPath(const char* path, { return false; } - if(!cmSystemTools::FileIsDirectory(path)) + if(!cmSystemTools::FileIsDirectory(path) || + cmSystemTools::FileIsSymlink(path)) { return true; } diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h index 703ff882c..1d247d2f2 100644 --- a/Source/cmBuildCommand.h +++ b/Source/cmBuildCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmBuildCommand - * \brief Build a CMAKE variable + * \brief build_command command * - * cmBuildCommand sets a variable to a value with expansion. + * cmBuildCommand implements the build_command CMake command */ class cmBuildCommand : public cmCommand { diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h index 35c0ae04d..29a680fcd 100644 --- a/Source/cmBuildNameCommand.h +++ b/Source/cmBuildNameCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmBuildNameCommand - * \brief BuildName a CMAKE variable + * \brief build_name command * - * cmBuildNameCommand sets a variable to a value with expansion. + * cmBuildNameCommand implements the build_name CMake command */ class cmBuildNameCommand : public cmCommand { diff --git a/Source/cmCMakeMinimumRequired.h b/Source/cmCMakeMinimumRequired.h index 9bf7ef87f..112138644 100644 --- a/Source/cmCMakeMinimumRequired.h +++ b/Source/cmCMakeMinimumRequired.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmCMakeMinimumRequired - * \brief Build a CMAKE variable + * \brief cmake_minimum_required command * - * cmCMakeMinimumRequired sets a variable to a value with expansion. + * cmCMakeMinimumRequired implements the cmake_minimum_required CMake command */ class cmCMakeMinimumRequired : public cmCommand { diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 75a564e78..3f7fdc7a2 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -440,8 +440,12 @@ std::string cmCTest::GetCDashVersion() std::string cdashUri = this->GetCTestConfiguration("DropLocation"); cdashUri = cdashUri.substr(0, cdashUri.find("/submit.php")); - url += cdashUri + "/api/getversion.php"; - int res = cmCTest::HTTPRequest(url, cmCTest::HTTP_GET, response, "", "", 3); + int res = 1; + if ( ! cdashUri.empty() ) + { + url += cdashUri + "/api/getversion.php"; + res = cmCTest::HTTPRequest(url, cmCTest::HTTP_GET, response, "", "", 3); + } return res ? this->GetCTestConfiguration("CDashVersion") : response; #else @@ -655,10 +659,26 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) } cmMakefile* mf = command->GetMakefile(); - std::string fname = src_dir; - fname += "/CTestConfig.cmake"; - cmSystemTools::ConvertToUnixSlashes(fname); - if ( cmSystemTools::FileExists(fname.c_str()) ) + std::string fname; + + std::string src_dir_fname = src_dir; + src_dir_fname += "/CTestConfig.cmake"; + cmSystemTools::ConvertToUnixSlashes(src_dir_fname); + + std::string bld_dir_fname = bld_dir; + bld_dir_fname += "/CTestConfig.cmake"; + cmSystemTools::ConvertToUnixSlashes(bld_dir_fname); + + if ( cmSystemTools::FileExists(bld_dir_fname.c_str()) ) + { + fname = bld_dir_fname; + } + else if ( cmSystemTools::FileExists(src_dir_fname.c_str()) ) + { + fname = src_dir_fname; + } + + if ( !fname.empty() ) { cmCTestLog(this, OUTPUT, " Reading ctest configuration file: " << fname.c_str() << std::endl); @@ -674,8 +694,12 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) } else { - cmCTestLog(this, WARNING, "Cannot locate CTest configuration: " - << fname.c_str() << std::endl); + cmCTestLog(this, WARNING, + "Cannot locate CTest configuration: in BuildDirectory: " + << bld_dir_fname.c_str() << std::endl); + cmCTestLog(this, WARNING, + "Cannot locate CTest configuration: in SourceDirectory: " + << src_dir_fname.c_str() << std::endl); } this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime", @@ -1420,6 +1444,43 @@ int cmCTest::RunTest(std::vector argv, return result; } +//---------------------------------------------------------------------- +std::string cmCTest::SafeBuildIdField(const std::string& value) +{ + std::string safevalue(value); + + if (safevalue != "") + { + // Disallow non-filename and non-space whitespace characters. + // If they occur, replace them with "" + // + const char *disallowed = "\\/:*?\"<>|\n\r\t\f\v"; + + if (safevalue.find_first_of(disallowed) != value.npos) + { + std::string::size_type i = 0; + std::string::size_type n = strlen(disallowed); + char replace[2]; + replace[1] = 0; + + for (i= 0; iGetCTestConfiguration("BuildName")); + std::string stamp = cmCTest::SafeBuildIdField( + this->CurrentTag + "-" + this->GetTestModelString()); + std::string site = cmCTest::SafeBuildIdField( + this->GetCTestConfiguration("Site")); + ostr << "\n" - << "GetCTestConfiguration("BuildName") - << "\"\n\tBuildStamp=\"" << this->CurrentTag << "-" - << this->GetTestModelString() << "\"\n\tName=\"" - << this->GetCTestConfiguration("Site") << "\"\n\tGenerator=\"ctest-" - << cmVersion::GetCMakeVersion() << "\"\n" + << "GetCTestConfiguration("Compiler") + << "\tCompilerName=\"" << this->GetCTestConfiguration("Compiler") << "\"\n" #ifdef _COMPILER_VERSION << "\tCompilerVersion=\"_COMPILER_VERSION\"\n" @@ -2526,6 +2595,8 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def, cmSystemTools::ExpandListArgument(dval, slist); std::vector::iterator it; + vec.clear(); + for ( it = slist.begin(); it != slist.end(); ++it ) { cmCTestLog(this, DEBUG, " -- " << it->c_str() << std::endl); @@ -2801,7 +2872,7 @@ bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf, } cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "SetCTestConfigurationFromCMakeVariable:" - << dconfig << ":" << cmake_var); + << dconfig << ":" << cmake_var << std::endl); this->SetCTestConfiguration(dconfig, ctvar); return true; } @@ -3096,6 +3167,7 @@ bool cmCTest::CompressString(std::string& str) ret = deflateInit(&strm, -1); //default compression level if (ret != Z_OK) { + delete[] out; return false; } @@ -3109,6 +3181,7 @@ bool cmCTest::CompressString(std::string& str) { cmCTestLog(this, ERROR_MESSAGE, "Error during gzip compression." << std::endl); + delete[] out; return false; } diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 44a534907..7c71b00ea 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -259,6 +259,10 @@ public: std::string* stdOut, std::string* stdErr, int* retVal = 0, const char* dir = 0, double timeout = 0.0); + //! Clean/make safe for xml the given value such that it may be used as + // one of the key fields by CDash when computing the buildid. + static std::string SafeBuildIdField(const std::string& value); + //! Start CTest XML output file void StartXML(std::ostream& ostr, bool append); diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index c8374db3f..ab0bb79b5 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -849,7 +849,8 @@ void cmCacheManager::CacheEntry::SetProperty(const char* prop, //---------------------------------------------------------------------------- void cmCacheManager::CacheEntry::AppendProperty(const char* prop, - const char* value) + const char* value, + bool asString) { if(strcmp(prop, "TYPE") == 0) { @@ -859,7 +860,7 @@ void cmCacheManager::CacheEntry::AppendProperty(const char* prop, { if(value) { - if(!this->Value.empty() && *value) + if(!this->Value.empty() && *value && !asString) { this->Value += ";"; } @@ -868,7 +869,7 @@ void cmCacheManager::CacheEntry::AppendProperty(const char* prop, } else { - this->Properties.AppendProperty(prop, value, cmProperty::CACHE); + this->Properties.AppendProperty(prop, value, cmProperty::CACHE, asString); } } @@ -893,11 +894,12 @@ void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v) //---------------------------------------------------------------------------- void cmCacheManager::CacheIterator::AppendProperty(const char* p, - const char* v) + const char* v, + bool asString) { if(!this->IsAtEnd()) { - this->GetEntry().AppendProperty(p, v); + this->GetEntry().AppendProperty(p, v, asString); } } diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index 314017bf5..9c94d214c 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -41,7 +41,8 @@ private: cmPropertyMap Properties; const char* GetProperty(const char*) const; void SetProperty(const char* property, const char* value); - void AppendProperty(const char* property, const char* value); + void AppendProperty(const char* property, const char* value, + bool asString=false); bool Initialized; CacheEntry() : Value(""), Type(UNINITIALIZED), Initialized(false) {} @@ -61,7 +62,8 @@ public: bool GetPropertyAsBool(const char*) const ; bool PropertyExists(const char*) const; void SetProperty(const char* property, const char* value); - void AppendProperty(const char* property, const char* value); + void AppendProperty(const char* property, const char* value, + bool asString=false); void SetProperty(const char* property, bool value); const char* GetValue() const { return this->GetEntry().Value.c_str(); } bool GetValueAsBool() const; diff --git a/Source/cmCommandArgumentLexer.cxx b/Source/cmCommandArgumentLexer.cxx index 13679453d..1d7140bb2 100644 --- a/Source/cmCommandArgumentLexer.cxx +++ b/Source/cmCommandArgumentLexer.cxx @@ -47,7 +47,7 @@ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -64,7 +64,7 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; @@ -189,7 +189,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) - + /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ @@ -251,7 +251,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -832,25 +832,25 @@ YY_RULE_SETUP case 2: YY_RULE_SETUP #line 72 "cmCommandArgumentLexer.in.l" -{ +{ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; - yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2); - return cal_NCURLY; -} + yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2); + return cal_NCURLY; +} case 3: YY_RULE_SETUP #line 78 "cmCommandArgumentLexer.in.l" -{ +{ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; - yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2); - return cal_ATNAME; -} + yyextra->AllocateParserType(yylvalp, yytext+1, strlen(yytext)-2); + return cal_ATNAME; +} case 4: YY_RULE_SETUP #line 84 "cmCommandArgumentLexer.in.l" { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; - //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->DCURLYVariable; return cal_DCURLY; } @@ -859,7 +859,7 @@ YY_RULE_SETUP #line 91 "cmCommandArgumentLexer.in.l" { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; - //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->RCURLYVariable; return cal_RCURLY; } @@ -868,17 +868,17 @@ YY_RULE_SETUP #line 98 "cmCommandArgumentLexer.in.l" { //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; - //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->ATVariable; return cal_AT; } case 7: YY_RULE_SETUP #line 105 "cmCommandArgumentLexer.in.l" -{ +{ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; - yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); - return cal_NAME; + yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + return cal_NAME; } case 8: YY_RULE_SETUP @@ -888,40 +888,40 @@ YY_RULE_SETUP { return cal_ERROR; } - return cal_SYMBOL; + return cal_SYMBOL; } case 9: /* rule 9 can match eol */ YY_RULE_SETUP #line 119 "cmCommandArgumentLexer.in.l" -{ +{ //std::cerr << __LINE__ << " here: [" << yytext << "]" << std::endl; - yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); - return cal_SYMBOL; + yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + return cal_SYMBOL; } case 10: YY_RULE_SETUP #line 125 "cmCommandArgumentLexer.in.l" { - //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->DOLLARVariable; - return cal_DOLLAR; + return cal_DOLLAR; } case 11: YY_RULE_SETUP #line 131 "cmCommandArgumentLexer.in.l" { - //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->LCURLYVariable; - return cal_LCURLY; + return cal_LCURLY; } case 12: YY_RULE_SETUP #line 137 "cmCommandArgumentLexer.in.l" { - //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + //yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); yylvalp->str = yyextra->BSLASHVariable; - return cal_BSLASH; + return cal_BSLASH; } case 13: YY_RULE_SETUP @@ -1419,7 +1419,7 @@ static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner) YY_BUFFER_STATE cmCommandArgument_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) cmCommandArgument_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yy_create_buffer()" ); @@ -1463,7 +1463,7 @@ static void cmCommandArgument_yy_load_buffer_state (yyscan_t yyscanner) #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ - + /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a cmCommandArgument_yyrestart() or at EOF. @@ -1489,7 +1489,7 @@ extern int isatty (int ); } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - + errno = oerrno; } @@ -1595,9 +1595,9 @@ static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner) , yyscanner); if ( ! yyg->yy_buffer_stack ) YY_FATAL_ERROR( "out of dynamic memory in cmCommandArgument_yyensure_buffer_stack()" ); - + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + yyg->yy_buffer_stack_max = num_to_alloc; yyg->yy_buffer_stack_top = 0; return; @@ -1626,12 +1626,12 @@ static void cmCommandArgument_yyensure_buffer_stack (yyscan_t yyscanner) * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -1667,14 +1667,14 @@ YY_BUFFER_STATE cmCommandArgument_yy_scan_buffer (char * base, yy_size_t size */ YY_BUFFER_STATE cmCommandArgument_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) { - + return cmCommandArgument_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner); } /** Setup the input buffer state to scan the given bytes. The next call to cmCommandArgument_yylex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * scan from a @e copy of @a yybytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ @@ -1684,7 +1684,7 @@ YY_BUFFER_STATE cmCommandArgument_yy_scan_bytes (yyconst char * yybytes, int _ char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) cmCommandArgument_yyalloc(n ,yyscanner ); @@ -1752,10 +1752,10 @@ YY_EXTRA_TYPE cmCommandArgument_yyget_extra (yyscan_t yyscanner) int cmCommandArgument_yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yylineno; } @@ -1765,10 +1765,10 @@ int cmCommandArgument_yyget_lineno (yyscan_t yyscanner) int cmCommandArgument_yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yycolumn; } @@ -1829,13 +1829,13 @@ void cmCommandArgument_yyset_lineno (int line_number , yyscan_t yyscanner) /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "cmCommandArgument_yyset_lineno called with no buffer" , yyscanner); - + yy_fatal_error( "cmCommandArgument_yyset_lineno called with no buffer" , yyscanner); + yylineno = line_number; } /** Set the current column. - * @param line_number + * @param column_no * @param yyscanner The scanner object. */ void cmCommandArgument_yyset_column (int column_no , yyscan_t yyscanner) @@ -1844,8 +1844,8 @@ void cmCommandArgument_yyset_column (int column_no , yyscan_t yyscanner) /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "cmCommandArgument_yyset_column called with no buffer" , yyscanner); - + yy_fatal_error( "cmCommandArgument_yyset_column called with no buffer" , yyscanner); + yycolumn = column_no; } @@ -1928,20 +1928,20 @@ int cmCommandArgument_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* p errno = EINVAL; return 1; } - + *ptr_yy_globals = (yyscan_t) cmCommandArgument_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); - + if (*ptr_yy_globals == NULL){ errno = ENOMEM; return 1; } - + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); - + cmCommandArgument_yyset_extra (yy_user_defined, *ptr_yy_globals); - + return yy_init_globals ( *ptr_yy_globals ); } diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 1021bf2ef..802cfcf70 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -429,7 +429,8 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) if(cmTarget::LinkInterface const* iface = entry.Target->GetLinkInterface(this->Config)) { - // We use just the shared dependencies, not the interface. + // Follow public and private dependencies transitively. + this->QueueSharedDependencies(index, iface->Libraries); this->QueueSharedDependencies(index, iface->SharedDeps); } } diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e3c33a2ff..edf6c35f6 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -161,7 +161,9 @@ listed on the command line. - On Windows, DLLs are not directly linked, and the import libraries have no transitive dependencies. - - On Mac, we need to actually list the transitive dependencies. + - On Mac OS X 10.5 and above transitive dependencies are not needed. + + - On Mac OS X 10.4 and below we need to actually list the dependencies. Otherwise when using -isysroot for universal binaries it cannot find the dependent libraries. Listing them on the command line tells the linker where to find them, but unfortunately also links @@ -1318,8 +1320,9 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item) this->AddFrameworkPath(this->SplitFramework.match(1)); // Add the item using the -framework option. - std::string fw = "-framework "; - fw += this->SplitFramework.match(2); + this->Items.push_back(Item("-framework", false)); + std::string fw = this->SplitFramework.match(2); + fw = this->LocalGenerator->EscapeForShell(fw.c_str()); this->Items.push_back(Item(fw, false)); } @@ -1603,6 +1606,18 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() cmSystemTools::ExpandListArgument(implicitLinks, implicitDirVec); } + // Append library architecture to all implicit platform directories + // and add them to the set + if(const char* libraryArch = + this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) + { + for (std::vector::const_iterator i = implicitDirVec.begin(); + i != implicitDirVec.end(); ++i) + { + this->ImplicitLinkDirs.insert(*i + "/" + libraryArch); + } + } + // Get language-specific implicit directories. std::string implicitDirVar = "CMAKE_"; implicitDirVar += this->LinkLanguage; diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index a4ca363a8..8e701c402 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -276,9 +276,11 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, for(std::set::const_iterator i = utils.begin(); i != utils.end(); ++i) { - cmTarget* transitive_dependee = - dependee->GetMakefile()->FindTargetToUse(i->c_str()); - this->AddTargetDepend(depender_index, transitive_dependee, false); + if(cmTarget* transitive_dependee = + dependee->GetMakefile()->FindTargetToUse(i->c_str())) + { + this->AddTargetDepend(depender_index, transitive_dependee, false); + } } } else @@ -402,7 +404,7 @@ cmComputeTargetDepends // Describe the depender. e << " \"" << depender->GetName() << "\" of type " - << cmTarget::TargetTypeNames[depender->GetType()] << "\n"; + << cmTarget::GetTargetTypeName(depender->GetType()) << "\n"; // List its dependencies that are inside the component. EdgeList const& nl = this->InitialGraph[i]; diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx index c1327fbf1..ea98326e2 100644 --- a/Source/cmConfigureFileCommand.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -65,6 +65,12 @@ bool cmConfigureFileCommand cmSystemTools::SetFatalErrorOccured(); return false; } + std::string errorMessage; + if (!this->NewLineStyle.ReadFromArguments(args, errorMessage)) + { + this->SetError(errorMessage.c_str()); + return false; + } this->CopyOnly = false; this->EscapeQuotes = false; @@ -78,6 +84,12 @@ bool cmConfigureFileCommand if(args[i] == "COPYONLY") { this->CopyOnly = true; + if (this->NewLineStyle.IsValid()) + { + this->SetError("COPYONLY could not be used in combination " + "with NEWLINE_STYLE"); + return false; + } } else if(args[i] == "ESCAPE_QUOTES") { @@ -122,7 +134,8 @@ int cmConfigureFileCommand::ConfigureFile() this->OutputFile.c_str(), this->CopyOnly, this->AtOnly, - this->EscapeQuotes); + this->EscapeQuotes, + this->NewLineStyle); } diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h index 844a23cda..be33569fe 100644 --- a/Source/cmConfigureFileCommand.h +++ b/Source/cmConfigureFileCommand.h @@ -56,7 +56,8 @@ public: { return " configure_file( \n" - " [COPYONLY] [ESCAPE_QUOTES] [@ONLY])\n" + " [COPYONLY] [ESCAPE_QUOTES] [@ONLY] \n" + " [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])\n" "Copies a file to file and substitutes variable " "values referenced in the file content. " "If is a relative path it is evaluated with respect to " @@ -81,14 +82,20 @@ public: "either #define VAR or /* #undef VAR */ depending on " "the setting of VAR in CMake. Any occurrences of #cmakedefine01 VAR " "will be replaced with either #define VAR 1 or #define VAR 0 " - "depending on whether VAR evaluates to TRUE or FALSE in CMake"; + "depending on whether VAR evaluates to TRUE or FALSE in CMake.\n" + "With NEWLINE_STYLE the line ending could be adjusted: \n" + " 'UNIX' or 'LF' for \\n, 'DOS', 'WIN32' or 'CRLF' for \\r\\n.\n" + "COPYONLY must not be used with NEWLINE_STYLE.\n"; } virtual void FinalPass(); virtual bool HasFinalPass() const { return !this->Immediate; } + private: int ConfigureFile(); + cmNewLineStyle NewLineStyle; + std::string InputFile; std::string OutputFile; bool CopyOnly; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 96a214e75..dca2fb3d5 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -22,12 +22,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) // which signature were we called with ? this->SrcFileSignature = false; unsigned int i; - + const char* sourceDirectory = argv[2].c_str(); const char* projectName = 0; const char* targetName = 0; int extraArgs = 0; - + // look for CMAKE_FLAGS and store them std::vector cmakeFlags; for (i = 3; i < argv.size(); ++i) @@ -37,8 +37,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) // CMAKE_FLAGS is the first argument because we need an argv[0] that // is not used, so it matches regular command line parsing which has // the program name as arg 0 - for (; i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" && - argv[i] != "OUTPUT_VARIABLE"; + for (; i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" && + argv[i] != "OUTPUT_VARIABLE"; ++i) { extraArgs++; @@ -73,8 +73,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) if (argv[i] == "COMPILE_DEFINITIONS") { extraArgs++; - for (i = i + 1; i < argv.size() && argv[i] != "CMAKE_FLAGS" && - argv[i] != "OUTPUT_VARIABLE"; + for (i = i + 1; i < argv.size() && argv[i] != "CMAKE_FLAGS" && + argv[i] != "OUTPUT_VARIABLE"; ++i) { extraArgs++; @@ -101,7 +101,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) break; } } - + // do we have a srcfile signature if (argv.size() - extraArgs == 3) { @@ -133,7 +133,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) } // make sure the binary directory exists cmSystemTools::MakeDirectory(this->BinaryDirectory.c_str()); - + // do not allow recursive try Compiles if (this->BinaryDirectory == this->Makefile->GetHomeOutputDirectory()) { @@ -143,7 +143,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); return -1; } - + std::string outFileName = this->BinaryDirectory + "/CMakeLists.txt"; // which signature are we using? If we are using var srcfile bindir if (this->SrcFileSignature) @@ -151,7 +151,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) // remove any CMakeCache.txt files so we will have a clean test std::string ccFile = this->BinaryDirectory + "/CMakeCache.txt"; cmSystemTools::RemoveFile(ccFile.c_str()); - + // we need to create a directory and CMakeList file etc... // first create the directories sourceDirectory = this->BinaryDirectory.c_str(); @@ -226,7 +226,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) langFlags += "_FLAGS"; fprintf(fout, "SET(CMAKE_VERBOSE_MAKEFILE 1)\n"); fprintf(fout, "SET(CMAKE_%s_FLAGS \"", lang); - const char* flags = this->Makefile->GetDefinition(langFlags.c_str()); + const char* flags = this->Makefile->GetDefinition(langFlags.c_str()); if(flags) { fprintf(fout, " %s ", flags); @@ -247,10 +247,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) } /* for the TRY_COMPILEs we want to be able to specify the architecture. - So the user can set CMAKE_OSX_ARCHITECTURE to i386;ppc and then set + So the user can set CMAKE_OSX_ARCHITECTURE to i386;ppc and then set CMAKE_TRY_COMPILE_OSX_ARCHITECTURE first to i386 and then to ppc to - have the tests run for each specific architecture. Since - cmLocalGenerator doesn't allow building for "the other" + have the tests run for each specific architecture. Since + cmLocalGenerator doesn't allow building for "the other" architecture only via CMAKE_OSX_ARCHITECTURES. */ if(this->Makefile->GetDefinition("CMAKE_TRY_COMPILE_OSX_ARCHITECTURES")!=0) @@ -286,45 +286,45 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) this->BinaryDirectory.c_str()); /* Create the actual executable. */ fprintf(fout, "ADD_EXECUTABLE(cmTryCompileExec \"%s\")\n",source.c_str()); - fprintf(fout, + fprintf(fout, "TARGET_LINK_LIBRARIES(cmTryCompileExec ${LINK_LIBRARIES})\n"); fclose(fout); projectName = "CMAKE_TRY_COMPILE"; targetName = "cmTryCompileExec"; - // if the source is not in CMakeTmp + // if the source is not in CMakeTmp if(source.find("CMakeTmp") == source.npos) { this->Makefile->AddCMakeDependFile(source.c_str()); } - + } // else the srcdir bindir project target signature else { projectName = argv[3].c_str(); - + if (argv.size() - extraArgs == 5) { targetName = argv[4].c_str(); } } - + bool erroroc = cmSystemTools::GetErrorOccuredFlag(); cmSystemTools::ResetErrorOccuredFlag(); std::string output; // actually do the try compile now that everything is setup - int res = this->Makefile->TryCompile(sourceDirectory, + int res = this->Makefile->TryCompile(sourceDirectory, this->BinaryDirectory.c_str(), - projectName, - targetName, + projectName, + targetName, this->SrcFileSignature, - &cmakeFlags, + &cmakeFlags, &output); if ( erroroc ) { cmSystemTools::SetErrorOccured(); } - + // set the result var to the return value to indicate success or failure this->Makefile->AddCacheDefinition(argv[0].c_str(), (res == 0 ? "TRUE" : "FALSE"), @@ -335,7 +335,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) { this->Makefile->AddDefinition(outputVariable.c_str(), output.c_str()); } - + if (this->SrcFileSignature) { this->FindOutputFile(targetName); @@ -369,7 +369,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) { return; } - + std::string bdir = binDir; if(bdir.find("CMakeTmp") == std::string::npos) { @@ -378,7 +378,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) "CMakeTmp:", binDir); return; } - + cmsys::Directory dir; dir.Load(binDir); size_t fileNum; @@ -388,8 +388,8 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir) if (strcmp(dir.GetFile(static_cast(fileNum)),".") && strcmp(dir.GetFile(static_cast(fileNum)),"..")) { - - if(deletedFiles.find( dir.GetFile(static_cast(fileNum))) + + if(deletedFiles.find( dir.GetFile(static_cast(fileNum))) == deletedFiles.end()) { deletedFiles.insert(dir.GetFile(static_cast(fileNum))); diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h index e29dde8ac..5c67f1355 100644 --- a/Source/cmCoreTryCompile.h +++ b/Source/cmCoreTryCompile.h @@ -28,27 +28,27 @@ public: /** * This is the core code for try compile. It is here so that other * commands, such as TryRun can access the same logic without - * duplication. + * duplication. */ int TryCompileCode(std::vector const& argv); - /** - * This deletes all the files created by TryCompileCode. + /** + * This deletes all the files created by TryCompileCode. * This way we do not have to rely on the timing and * dependencies of makefiles. */ void CleanupFiles(const char* binDir); - /** - * This tries to find the (executable) file created by + /** + * This tries to find the (executable) file created by TryCompileCode. The result is stored in OutputFile. If nothing is found, the error message is stored in FindErrorMessage. */ void FindOutputFile(const char* targetName); - + cmTypeMacro(cmCoreTryCompile, cmCommand); - + std::string BinaryDirectory; std::string OutputFile; std::string FindErrorMessage; diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx new file mode 100644 index 000000000..a1505bd65 --- /dev/null +++ b/Source/cmCryptoHash.cxx @@ -0,0 +1,130 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmCryptoHash.h" + +#include +#include "cm_sha2.h" + +//---------------------------------------------------------------------------- +cmsys::auto_ptr cmCryptoHash::New(const char* algo) +{ + if(strcmp(algo,"MD5") == 0) + { return cmsys::auto_ptr(new cmCryptoHashMD5); } + else if(strcmp(algo,"SHA1") == 0) + { return cmsys::auto_ptr(new cmCryptoHashSHA1); } + else if(strcmp(algo,"SHA224") == 0) + { return cmsys::auto_ptr(new cmCryptoHashSHA224); } + else if(strcmp(algo,"SHA256") == 0) + { return cmsys::auto_ptr(new cmCryptoHashSHA256); } + else if(strcmp(algo,"SHA384") == 0) + { return cmsys::auto_ptr(new cmCryptoHashSHA384); } + else if(strcmp(algo,"SHA512") == 0) + { return cmsys::auto_ptr(new cmCryptoHashSHA512); } + else + { return cmsys::auto_ptr(0); } +} + +//---------------------------------------------------------------------------- +std::string cmCryptoHash::HashString(const char* input) +{ + this->Initialize(); + this->Append(reinterpret_cast(input), + static_cast(strlen(input))); + return this->Finalize(); +} + +//---------------------------------------------------------------------------- +std::string cmCryptoHash::HashFile(const char* file) +{ + std::ifstream fin(file, std::ios::in | cmsys_ios_binary); + if(!fin) + { + return ""; + } + + this->Initialize(); + + // Should be efficient enough on most system: + const int bufferSize = 4096; + char buffer[bufferSize]; + unsigned char const* buffer_uc = + reinterpret_cast(buffer); + // This copy loop is very sensitive on certain platforms with + // slightly broken stream libraries (like HPUX). Normally, it is + // incorrect to not check the error condition on the fin.read() + // before using the data, but the fin.gcount() will be zero if an + // error occurred. Therefore, the loop should be safe everywhere. + while(fin) + { + fin.read(buffer, bufferSize); + if(int gcount = static_cast(fin.gcount())) + { + this->Append(buffer_uc, gcount); + } + } + if(fin.eof()) + { + return this->Finalize(); + } + return ""; +} + +//---------------------------------------------------------------------------- +cmCryptoHashMD5::cmCryptoHashMD5(): MD5(cmsysMD5_New()) +{ +} + +//---------------------------------------------------------------------------- +cmCryptoHashMD5::~cmCryptoHashMD5() +{ + cmsysMD5_Delete(this->MD5); +} + +//---------------------------------------------------------------------------- +void cmCryptoHashMD5::Initialize() +{ + cmsysMD5_Initialize(this->MD5); +} + +//---------------------------------------------------------------------------- +void cmCryptoHashMD5::Append(unsigned char const* buf, int sz) +{ + cmsysMD5_Append(this->MD5, buf, sz); +} + +//---------------------------------------------------------------------------- +std::string cmCryptoHashMD5::Finalize() +{ + char md5out[32]; + cmsysMD5_FinalizeHex(this->MD5, md5out); + return std::string(md5out, 32); +} + + +#define cmCryptoHash_SHA_CLASS_IMPL(SHA) \ +cmCryptoHash##SHA::cmCryptoHash##SHA(): SHA(new SHA_CTX) {} \ +cmCryptoHash##SHA::~cmCryptoHash##SHA() { delete this->SHA; } \ +void cmCryptoHash##SHA::Initialize() { SHA##_Init(this->SHA); } \ +void cmCryptoHash##SHA::Append(unsigned char const* buf, int sz) \ +{ SHA##_Update(this->SHA, buf, sz); } \ +std::string cmCryptoHash##SHA::Finalize() \ +{ \ + char out[SHA##_DIGEST_STRING_LENGTH]; \ + SHA##_End(this->SHA, out); \ + return std::string(out, SHA##_DIGEST_STRING_LENGTH-1); \ +} + +cmCryptoHash_SHA_CLASS_IMPL(SHA1) +cmCryptoHash_SHA_CLASS_IMPL(SHA224) +cmCryptoHash_SHA_CLASS_IMPL(SHA256) +cmCryptoHash_SHA_CLASS_IMPL(SHA384) +cmCryptoHash_SHA_CLASS_IMPL(SHA512) diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h new file mode 100644 index 000000000..1bea9abcb --- /dev/null +++ b/Source/cmCryptoHash.h @@ -0,0 +1,65 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmCryptoHash_h +#define cmCryptoHash_h + +#include "cmStandardIncludes.h" + +#include + +class cmCryptoHash +{ +public: + virtual ~cmCryptoHash() {} + static cmsys::auto_ptr New(const char* algo); + std::string HashString(const char* input); + std::string HashFile(const char* file); +protected: + virtual void Initialize()=0; + virtual void Append(unsigned char const*, int)=0; + virtual std::string Finalize()=0; +}; + +class cmCryptoHashMD5: public cmCryptoHash +{ + struct cmsysMD5_s* MD5; +public: + cmCryptoHashMD5(); + ~cmCryptoHashMD5(); +protected: + virtual void Initialize(); + virtual void Append(unsigned char const* buf, int sz); + virtual std::string Finalize(); +}; + +#define cmCryptoHash_SHA_CLASS_DECL(SHA) \ + class cmCryptoHash##SHA: public cmCryptoHash \ + { \ + union _SHA_CTX* SHA; \ + public: \ + cmCryptoHash##SHA(); \ + ~cmCryptoHash##SHA(); \ + protected: \ + virtual void Initialize(); \ + virtual void Append(unsigned char const* buf, int sz); \ + virtual std::string Finalize(); \ + } + +cmCryptoHash_SHA_CLASS_DECL(SHA1); +cmCryptoHash_SHA_CLASS_DECL(SHA224); +cmCryptoHash_SHA_CLASS_DECL(SHA256); +cmCryptoHash_SHA_CLASS_DECL(SHA384); +cmCryptoHash_SHA_CLASS_DECL(SHA512); + +#undef cmCryptoHash_SHA_CLASS_DECL + +#endif diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index a76b3af5f..44841a900 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -237,10 +237,10 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj, fileIt->second->Used=true; dependencies.insert(fullName); for (std::vector::const_iterator incIt= - fileIt->second->UnscannedEntries.begin(); + fileIt->second->UnscannedEntries.begin(); incIt!=fileIt->second->UnscannedEntries.end(); ++incIt) { - if (this->Encountered.find(incIt->FileName) == + if (this->Encountered.find(incIt->FileName) == this->Encountered.end()) { this->Encountered.insert(incIt->FileName); @@ -278,7 +278,7 @@ bool cmDependsC::WriteDependencies(const char *src, const char *obj, for(std::set::iterator i=dependencies.begin(); i != dependencies.end(); ++i) { - makeDepends << obj << ": " << + makeDepends << obj << ": " << this->LocalGenerator->Convert(i->c_str(), cmLocalGenerator::HOME_OUTPUT, cmLocalGenerator::MAKEFILE) @@ -321,9 +321,9 @@ void cmDependsC::ReadCacheFile() haveFileName=true; int newer=0; cmFileTimeComparison comp; - bool res=comp.FileTimeCompare(this->CacheFileName.c_str(), + bool res=comp.FileTimeCompare(this->CacheFileName.c_str(), line.c_str(), &newer); - + if ((res==true) && (newer==1)) //cache is newer than the parsed file { cacheEntry=new cmIncludeLines; @@ -391,7 +391,7 @@ void cmDependsC::WriteCacheFile() const { return; } - + cacheOut << this->IncludeRegexLineString << "\n\n"; cacheOut << this->IncludeRegexScanString << "\n\n"; cacheOut << this->IncludeRegexComplainString << "\n\n"; @@ -406,7 +406,7 @@ void cmDependsC::WriteCacheFile() const cacheOut<first.c_str()<::const_iterator - incIt=fileIt->second->UnscannedEntries.begin(); + incIt=fileIt->second->UnscannedEntries.begin(); incIt!=fileIt->second->UnscannedEntries.end(); ++incIt) { cacheOut<FileName.c_str()<Used=true; this->FileCache[fullName]=newCacheEntry; - + // Read one line at a time. std::string line; while(cmSystemTools::GetLineFromStream(is, line)) @@ -465,6 +465,9 @@ void cmDependsC::Scan(std::istream& is, const char* directory, // that this check does not account for the possibility of two // headers with the same name in different directories when one // is included by double-quotes and the other by angle brackets. + // It also does not work properly if two header files with the same + // name exist in different directories, and both are included from a + // file their own directory by simply using "filename.h" (#12619) // This kind of problem will be fixed when a more // preprocessor-like implementation of this scanner is created. if (this->IncludeRegexScan.find(entry.FileName.c_str())) diff --git a/Source/cmDependsFortranLexer.cxx b/Source/cmDependsFortranLexer.cxx index a488884de..438af2df5 100644 --- a/Source/cmDependsFortranLexer.cxx +++ b/Source/cmDependsFortranLexer.cxx @@ -1991,9 +1991,9 @@ YY_BUFFER_STATE cmDependsFortran_yy_scan_string (yyconst char * yystr , yyscan_t } /** Setup the input buffer state to scan the given bytes. The next call to cmDependsFortran_yylex() will - * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. + * scan from a @e copy of @a yybytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. * @param yyscanner The scanner object. * @return the newly allocated buffer state object. */ @@ -2154,7 +2154,7 @@ void cmDependsFortran_yyset_lineno (int line_number , yyscan_t yyscanner) } /** Set the current column. - * @param line_number + * @param column_no * @param yyscanner The scanner object. */ void cmDependsFortran_yyset_column (int column_no , yyscan_t yyscanner) diff --git a/Source/cmDependsJavaLexer.cxx b/Source/cmDependsJavaLexer.cxx index d7149c7ed..63cfebcd7 100644 --- a/Source/cmDependsJavaLexer.cxx +++ b/Source/cmDependsJavaLexer.cxx @@ -48,7 +48,7 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; #endif /* ! C99 */ @@ -169,7 +169,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) - + /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ @@ -234,7 +234,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -1428,9 +1428,9 @@ YY_RULE_SETUP case 107: YY_RULE_SETUP #line 200 "cmDependsJavaLexer.in.l" -{ - yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); - return jp_NAME; +{ + yyextra->AllocateParserType(yylvalp, yytext, strlen(yytext)); + return jp_NAME; } case 108: /* rule 108 can match eol */ @@ -1447,11 +1447,11 @@ YY_RULE_SETUP case 110: YY_RULE_SETUP #line 207 "cmDependsJavaLexer.in.l" -{ - std::cerr << "Unknown character: " << yytext[0] - << " (" << (int)yytext[0] << ")" << std::endl; - yyextra->Error("Unknown character"); - return jp_ERROR; +{ + std::cerr << "Unknown character: " << yytext[0] + << " (" << (int)yytext[0] << ")" << std::endl; + yyextra->Error("Unknown character"); + return jp_ERROR; } case 111: YY_RULE_SETUP @@ -1933,7 +1933,7 @@ static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner) YY_BUFFER_STATE cmDependsJava_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) cmDependsJava_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in cmDependsJava_yy_create_buffer()" ); @@ -1977,7 +1977,7 @@ static void cmDependsJava_yy_load_buffer_state (yyscan_t yyscanner) #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ - + /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a cmDependsJava_yyrestart() or at EOF. @@ -2003,7 +2003,7 @@ extern int isatty (int ); } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - + errno = oerrno; } @@ -2107,9 +2107,9 @@ static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner) yyg->yy_buffer_stack = (struct yy_buffer_state**)cmDependsJava_yyalloc (nuto_alloc * sizeof(struct yy_buffer_state*) , yyscanner); - + memset(yyg->yy_buffer_stack, 0, nuto_alloc * sizeof(struct yy_buffer_state*)); - + yyg->yy_buffer_stack_max = nuto_alloc; yyg->yy_buffer_stack_top = 0; return; @@ -2136,12 +2136,12 @@ static void cmDependsJava_yyensure_buffer_stack (yyscan_t yyscanner) * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -2168,8 +2168,8 @@ YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char * base, yy_size_t size , yy } /** Setup the input buffer state to scan a string. The next call to cmDependsJava_yylex() will - * scan from a @e copy of @a str. - * @param str a NUL-terminated string to scan + * scan from a @e copy of @a yy_str. + * @param yy_str a NUL-terminated string to scan * @param yyscanner The scanner object. * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use @@ -2177,7 +2177,7 @@ YY_BUFFER_STATE cmDependsJava_yy_scan_buffer (char * base, yy_size_t size , yy */ YY_BUFFER_STATE cmDependsJava_yy_scan_string (yyconst char * yy_str , yyscan_t yyscanner) { - + return cmDependsJava_yy_scan_bytes(yy_str,strlen(yy_str) ,yyscanner); } @@ -2194,7 +2194,7 @@ YY_BUFFER_STATE cmDependsJava_yy_scan_bytes (yyconst char * bytes, int len , y char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ n = len + 2; buf = (char *) cmDependsJava_yyalloc(n ,yyscanner ); @@ -2262,10 +2262,10 @@ YY_EXTRA_TYPE cmDependsJava_yyget_extra (yyscan_t yyscanner) int cmDependsJava_yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yylineno; } @@ -2275,10 +2275,10 @@ int cmDependsJava_yyget_lineno (yyscan_t yyscanner) int cmDependsJava_yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yycolumn; } @@ -2339,13 +2339,13 @@ void cmDependsJava_yyset_lineno (int line_number , yyscan_t yyscanner) /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "cmDependsJava_yyset_lineno called with no buffer" , yyscanner); - + yy_fatal_error( "cmDependsJava_yyset_lineno called with no buffer" , yyscanner); + yylineno = line_number; } /** Set the current column. - * @param line_number + * @param column_no * @param yyscanner The scanner object. */ void cmDependsJava_yyset_column (int column_no , yyscan_t yyscanner) @@ -2354,8 +2354,8 @@ void cmDependsJava_yyset_column (int column_no , yyscan_t yyscanner) /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "cmDependsJava_yyset_column called with no buffer" , yyscanner); - + yy_fatal_error( "cmDependsJava_yyset_column called with no buffer" , yyscanner); + yycolumn = column_no; } diff --git a/Source/cmDocumentLocationUndefined.h b/Source/cmDocumentLocationUndefined.h new file mode 100644 index 000000000..d1be77abf --- /dev/null +++ b/Source/cmDocumentLocationUndefined.h @@ -0,0 +1,24 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmDocumentLocationUndefined_h +#define cmDocumentLocationUndefined_h + +#define CM_LOCATION_UNDEFINED_BEHAVIOR(action) \ + "\n" \ + "Do not set properties that affect the location of a target after " \ + action ". These include properties whose names match " \ + "\"(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_)?\" " \ + "or \"(IMPLIB_)?(PREFIX|SUFFIX)\". " \ + "Failure to follow this rule is not diagnosed and leaves the location " \ + "of the target undefined." + +#endif diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index ea25e60fd..fe29df9be 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -126,7 +126,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "This variable is set to the program that will be" " needed to build the output of CMake. If the " "generator selected was Visual Studio 6, the " - "CMAKE_MAKE_PROGRAM will be set to msdev, for " + "CMAKE_BUILD_TOOL will be set to msdev, for " "Unix makefiles it will be set to make or gmake, " "and for Visual Studio 7 it set to devenv. For " "Nmake Makefiles the value is nmake. This can be " @@ -507,6 +507,19 @@ void cmDocumentVariables::DefineVariables(cmake* cm) false, "Variables That Change Behavior"); + cm->DefineProperty + ("CMAKE_AUTOMOC_RELAXED_MODE", cmProperty::VARIABLE, + "Switch between strict and relaxed automoc mode.", + "By default, automoc behaves exactly as described in the documentation " + "of the AUTOMOC target property. " + "When set to TRUE, it accepts more input and tries to find the correct " + "input file for moc even if it differs from the documented behaviour. " + "In this mode it e.g. also checks whether a header file is intended to " + "be processed by moc when a \"foo.moc\" file has been included.\n" + "Relaxed mode has to be enabled for KDE4 compatibility.", + false, + "Variables That Change Behavior"); + cm->DefineProperty ("CMAKE_FIND_LIBRARY_PREFIXES", cmProperty::VARIABLE, "Prefixes to prepend when looking for libraries.", @@ -718,6 +731,20 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "CMAKE_SYSTEM_PREFIX_PATH.", false, "Variables That Change Behavior"); + cm->DefineProperty + ("CMAKE_DISABLE_FIND_PACKAGE_", cmProperty::VARIABLE, + "Variable for disabling find_package() calls.", + "Every non-REQUIRED find_package() call in a project can be disabled " + "by setting the variable CMAKE_DISABLE_FIND_PACKAGE_ to " + "TRUE. This can be used to build a project without an optional package, " + "although that package is installed.\n" + "This switch should be used during the initial CMake run. Otherwise if " + "the package has already been found in a previous CMake run, the " + "variables which have been stored in the cache will still be there. " + "In the case it is recommended to remove the cache variables for " + "this package from the cache using the cache editor or cmake -U", false, + "Variables That Change Behavior"); + cm->DefineProperty ("CMAKE_USER_MAKE_RULES_OVERRIDE", cmProperty::VARIABLE, "Specify a CMake file that overrides platform information.", @@ -939,7 +966,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) cm->DefineProperty ("WIN32", cmProperty::VARIABLE, "True on windows systems, including win64.", - "Set to true when the target system is Windows and on cygwin.",false, + "Set to true when the target system is Windows.",false, "Variables That Describe the System"); cm->DefineProperty @@ -1034,6 +1061,15 @@ void cmDocumentVariables::DefineVariables(cmake* cm) false, "Variables that Control the Build"); + cm->DefineProperty + ("CMAKE_Fortran_FORMAT", cmProperty::VARIABLE, + "Set to FIXED or FREE to indicate the Fortran source layout.", + "This variable is used to initialize the Fortran_FORMAT " + "property on all the targets. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); + cm->DefineProperty ("CMAKE_Fortran_MODULE_DIRECTORY", cmProperty::VARIABLE, "Fortran module output directory.", @@ -1070,6 +1106,33 @@ void cmDocumentVariables::DefineVariables(cmake* cm) false, "Variables that Control the Build"); + cm->DefineProperty + ("CMAKE_AUTOMOC", cmProperty::VARIABLE, + "Whether to handle moc automatically for Qt targets.", + "This variable is used to initialize the " + "AUTOMOC property on all the targets. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); + + cm->DefineProperty + ("CMAKE_AUTOMOC_MOC_OPTIONS", cmProperty::VARIABLE, + "Additional options for moc when using automoc (see CMAKE_AUTOMOC).", + "This variable is used to initialize the " + "AUTOMOC_MOC_OPTIONS property on all the targets. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); + + cm->DefineProperty + ("CMAKE_GNUtoMS", cmProperty::VARIABLE, + "Convert GNU import libraries (.dll.a) to MS format (.lib).", + "This variable is used to initialize the GNUtoMS property on targets " + "when they are created. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); + cm->DefineProperty ("CMAKE_DEBUG_POSTFIX", cmProperty::VARIABLE, "See variable CMAKE__POSTFIX.", @@ -1187,7 +1250,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Therefore a specific build configuration must be chosen even " "if the generated build system supports multiple configurations.",false, "Variables that Control the Build"); - + cm->DefineProperty + ("CMAKE_LINK_INTERFACE_LIBRARIES", cmProperty::VARIABLE, + "Default value for LINK_INTERFACE_LIBRARIES of targets.", + "This variable is used to initialize the " + "LINK_INTERFACE_LIBRARIES property on all the targets. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); // Variables defined when the a language is enabled These variables will // also be defined whenever CMake has loaded its support for compiling (LANG) @@ -1467,6 +1537,8 @@ void cmDocumentVariables::DefineVariables(cmake* cm) cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE__COMPILER_ID_RUN", cmProperty::VARIABLE,0,0); + cm->DefineProperty("CMAKE__ABI_FILES", + cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE__CREATE_ASSEMBLY_SOURCE", cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE__CREATE_PREPROCESSED_SOURCE", diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index bfe11c194..07683d084 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -21,7 +21,7 @@ static const char *cmDocumentationStandardOptions[][3] = { {"--copyright [file]", "Print the CMake copyright and exit.", "If a file is specified, the copyright is written into it."}, - {"--help", "Print usage information and exit.", + {"--help,-help,-usage,-h,-H,/?", "Print usage information and exit.", "Usage describes the basic command line interface and its options."}, {"--help-full [file]", "Print full help and exit.", "Full help displays most of the documentation provided by the UNIX " @@ -34,7 +34,8 @@ static const char *cmDocumentationStandardOptions[][3] = {"--help-man [file]", "Print full help as a UNIX man page and exit.", "This option is used by the cmake build to generate the UNIX man page. " "If a file is specified, the help is written into it."}, - {"--version [file]", "Show program name/version banner and exit.", + {"--version,-version,/V [file]", + "Show program name/version banner and exit.", "If a file is specified, the version is written into it."}, {0,0,0} }; @@ -235,24 +236,24 @@ cmDocumentation::cmDocumentation() sec = new cmDocumentationSection("See Also","SEE ALSO"); sec->Append(cmDocumentationStandardSeeAlso); - this->AllSections["Standard See Also"] = sec; + this->AllSections["Standard See Also"] = sec; sec = new cmDocumentationSection("Options","OPTIONS"); sec->Append(cmDocumentationStandardOptions); - this->AllSections["Options"] = sec; + this->AllSections["Options"] = sec; sec = new cmDocumentationSection("Properties","PROPERTIES"); sec->Append(cmPropertiesDocumentationDescription); - this->AllSections["Properties Description"] = sec; + this->AllSections["Properties Description"] = sec; sec = new cmDocumentationSection("Generators","GENERATORS"); sec->Append(cmDocumentationGeneratorsHeader); - this->AllSections["Generators"] = sec; + this->AllSections["Generators"] = sec; sec = new cmDocumentationSection("Compatibility Commands", "COMPATIBILITY COMMANDS"); sec->Append(cmCompatCommandsDocumentationDescription); - this->AllSections["Compatibility Commands"] = sec; + this->AllSections["Compatibility Commands"] = sec; this->PropertySections.push_back("Properties of Global Scope"); @@ -279,7 +280,7 @@ cmDocumentation::~cmDocumentation() { delete [] *i; } - for(std::map::iterator i = + for(std::map::iterator i = this->AllSections.begin(); i != this->AllSections.end(); ++i) { @@ -314,7 +315,7 @@ bool cmDocumentation::PrintCopyright(std::ostream& os) //---------------------------------------------------------------------------- bool cmDocumentation::PrintVersion(std::ostream& os) { - os << this->GetNameString() << " version " + os << this->GetNameString() << " version " << cmVersion::GetCMakeVersion() << "\n"; return true; } @@ -331,7 +332,7 @@ void cmDocumentation::AddSectionToPrint(const char *section) //---------------------------------------------------------------------------- void cmDocumentation::ClearSections() { - this->PrintSections.erase(this->PrintSections.begin(), + this->PrintSections.erase(this->PrintSections.begin(), this->PrintSections.end()); this->ModulesFound.clear(); } @@ -359,7 +360,7 @@ void cmDocumentation::AddDocumentIntroToPrint(const char* intro[2]) bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os, const char* docname) { - if ((this->CurrentFormatter->GetForm() != HTMLForm) + if ((this->CurrentFormatter->GetForm() != HTMLForm) && (this->CurrentFormatter->GetForm() != DocbookForm) && (this->CurrentFormatter->GetForm() != ManForm)) { @@ -394,8 +395,8 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os, this->PrintDocumentationList(os,"Commands"); this->PrintDocumentationList(os,"Compatibility Commands"); return true; - case cmDocumentation::ModuleList: - // find the modules first, print the custom module docs only if + case cmDocumentation::ModuleList: + // find the modules first, print the custom module docs only if // any custom modules have been found actually, Alex this->CreateCustomModulesSection(); this->CreateModulesSection(); @@ -406,43 +407,43 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os, } this->PrintDocumentationList(os,"Modules"); return true; - case cmDocumentation::PropertyList: + case cmDocumentation::PropertyList: this->PrintDocumentationList(os,"Properties Description"); - for (std::vector::iterator i = + for (std::vector::iterator i = this->PropertySections.begin(); i != this->PropertySections.end(); ++i) { this->PrintDocumentationList(os,i->c_str()); } return true; - case cmDocumentation::VariableList: - for (std::vector::iterator i = + case cmDocumentation::VariableList: + for (std::vector::iterator i = this->VariableSections.begin(); i != this->VariableSections.end(); ++i) { this->PrintDocumentationList(os,i->c_str()); } return true; - case cmDocumentation::Full: + case cmDocumentation::Full: return this->PrintDocumentationFull(os); - case cmDocumentation::Modules: + case cmDocumentation::Modules: return this->PrintDocumentationModules(os); - case cmDocumentation::CustomModules: + case cmDocumentation::CustomModules: return this->PrintDocumentationCustomModules(os); - case cmDocumentation::Policies: + case cmDocumentation::Policies: return this->PrintDocumentationPolicies(os); - case cmDocumentation::Properties: + case cmDocumentation::Properties: return this->PrintDocumentationProperties(os); - case cmDocumentation::Variables: + case cmDocumentation::Variables: return this->PrintDocumentationVariables(os); - case cmDocumentation::Commands: + case cmDocumentation::Commands: return this->PrintDocumentationCurrentCommands(os); - case cmDocumentation::CompatCommands: + case cmDocumentation::CompatCommands: return this->PrintDocumentationCompatCommands(os); - case cmDocumentation::Copyright: + case cmDocumentation::Copyright: return this->PrintCopyright(os); - case cmDocumentation::Version: + case cmDocumentation::Version: return true; default: return false; } @@ -451,7 +452,7 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os, //---------------------------------------------------------------------------- bool cmDocumentation::CreateModulesSection() { - cmDocumentationSection *sec = + cmDocumentationSection *sec = new cmDocumentationSection("Standard CMake Modules", "MODULES"); this->AllSections["Modules"] = sec; std::string cmakeModules = this->CMakeRoot; @@ -485,7 +486,7 @@ bool cmDocumentation::CreateCustomModulesSection() { if (!sectionHasHeader) { - cmDocumentationSection *sec = + cmDocumentationSection *sec = new cmDocumentationSection("Custom CMake Modules","CUSTOM MODULES"); this->AllSections["Custom CMake Modules"] = sec; sec->Append(cmDocumentationCustomModulesHeader[0]); @@ -502,10 +503,10 @@ bool cmDocumentation::CreateCustomModulesSection() //---------------------------------------------------------------------------- void cmDocumentation -::CreateModuleDocsForDir(cmsys::Directory& dir, +::CreateModuleDocsForDir(cmsys::Directory& dir, cmDocumentationSection &moduleSection) { - // sort the files alphabetically, so the docs for one module are easier + // sort the files alphabetically, so the docs for one module are easier // to find than if they are in random order std::vector sortedFiles; for(unsigned int i = 0; i < dir.GetNumberOfFiles(); ++i) @@ -530,7 +531,7 @@ void cmDocumentation std::string path = dir.GetPath(); path += "/"; path += (*fname); - this->CreateSingleModule(path.c_str(), moduleName.c_str(), + this->CreateSingleModule(path.c_str(), moduleName.c_str(), moduleSection); } } @@ -539,7 +540,7 @@ void cmDocumentation } //---------------------------------------------------------------------------- -bool cmDocumentation::CreateSingleModule(const char* fname, +bool cmDocumentation::CreateSingleModule(const char* fname, const char* moduleName, cmDocumentationSection &moduleSection) { @@ -548,7 +549,7 @@ bool cmDocumentation::CreateSingleModule(const char* fname, { std::cerr << "Internal error: can not open module." << fname << std::endl; return false; - } + } std::string line; std::string text; std::string brief; @@ -561,14 +562,14 @@ bool cmDocumentation::CreateSingleModule(const char* fname, // blank line if(line.size() <= 2) { - text += "\n"; + text += "\n"; newParagraph = true; } - else if(line[2] == '-') + else if(line[2] == '-') { brief = line.c_str()+4; } - else + else { // two spaces if(line[1] == ' ' && line[2] == ' ') @@ -630,11 +631,11 @@ bool cmDocumentation::CreateSingleModule(const char* fname, bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) { bool result = true; - + // Loop over requested documentation types. - for(std::vector::const_iterator + for(std::vector::const_iterator i = this->RequestedHelpItems.begin(); - i != this->RequestedHelpItems.end(); + i != this->RequestedHelpItems.end(); ++i) { this->SetForm(i->HelpForm); @@ -660,13 +661,13 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) docname = cmSystemTools::GetFilenameWithoutLastExtension(i->Filename); } } - + // Print this documentation type to the stream. if(!this->PrintDocumentation(i->HelpType, *s, docname.c_str()) || !*s) { result = false; } - + // Close the file if we wrote one. if(fout) { @@ -876,8 +877,8 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv, GET_OPT_ARGUMENT(help.Filename); help.HelpForm = cmDocumentation::UsageForm; } - else if((strcmp(argv[i], "--version") == 0) || - (strcmp(argv[i], "-version") == 0) || + else if((strcmp(argv[i], "--version") == 0) || + (strcmp(argv[i], "-version") == 0) || (strcmp(argv[i], "/V") == 0)) { help.HelpType = cmDocumentation::Version; @@ -904,14 +905,14 @@ void cmDocumentation::Print(Form f, std::ostream& os) //---------------------------------------------------------------------------- void cmDocumentation::Print(std::ostream& os) { - // if the formatter supports it, print a master index for + // if the formatter supports it, print a master index for // all sections this->CurrentFormatter->PrintIndex(os, this->PrintSections); for(unsigned int i=0; i < this->PrintSections.size(); ++i) { std::string name = this->PrintSections[i]-> GetName((this->CurrentFormatter->GetForm())); - this->CurrentFormatter->PrintSection(os,*this->PrintSections[i], + this->CurrentFormatter->PrintSection(os,*this->PrintSections[i], name.c_str()); } } @@ -929,7 +930,7 @@ void cmDocumentation::SetDocName(const char *docname) } //---------------------------------------------------------------------------- -void cmDocumentation::SetSection(const char *name, +void cmDocumentation::SetSection(const char *name, cmDocumentationSection *section) { if (this->AllSections.find(name) != this->AllSections.end()) @@ -940,22 +941,22 @@ void cmDocumentation::SetSection(const char *name, } //---------------------------------------------------------------------------- -void cmDocumentation::SetSection(const char *name, +void cmDocumentation::SetSection(const char *name, std::vector &docs) { - cmDocumentationSection *sec = - new cmDocumentationSection(name, + cmDocumentationSection *sec = + new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str()); sec->Append(docs); this->SetSection(name,sec); } //---------------------------------------------------------------------------- -void cmDocumentation::SetSection(const char *name, +void cmDocumentation::SetSection(const char *name, const char *docs[][3]) { - cmDocumentationSection *sec = - new cmDocumentationSection(name, + cmDocumentationSection *sec = + new cmDocumentationSection(name, cmSystemTools::UpperCase(name).c_str()); sec->Append(docs); this->SetSection(name,sec); @@ -965,15 +966,15 @@ void cmDocumentation::SetSection(const char *name, void cmDocumentation ::SetSections(std::map §ions) { - for (std::map::const_iterator + for (std::map::const_iterator it = sections.begin(); it != sections.end(); ++it) { this->SetSection(it->first.c_str(),it->second); - } + } } //---------------------------------------------------------------------------- -void cmDocumentation::PrependSection(const char *name, +void cmDocumentation::PrependSection(const char *name, const char *docs[][3]) { cmDocumentationSection *sec = 0; @@ -991,7 +992,7 @@ void cmDocumentation::PrependSection(const char *name, } //---------------------------------------------------------------------------- -void cmDocumentation::PrependSection(const char *name, +void cmDocumentation::PrependSection(const char *name, std::vector &docs) { cmDocumentationSection *sec = 0; @@ -1009,7 +1010,7 @@ void cmDocumentation::PrependSection(const char *name, } //---------------------------------------------------------------------------- -void cmDocumentation::AppendSection(const char *name, +void cmDocumentation::AppendSection(const char *name, const char *docs[][3]) { cmDocumentationSection *sec = 0; @@ -1027,7 +1028,7 @@ void cmDocumentation::AppendSection(const char *name, } //---------------------------------------------------------------------------- -void cmDocumentation::AppendSection(const char *name, +void cmDocumentation::AppendSection(const char *name, std::vector &docs) { cmDocumentationSection *sec = 0; @@ -1045,7 +1046,7 @@ void cmDocumentation::AppendSection(const char *name, } //---------------------------------------------------------------------------- -void cmDocumentation::AppendSection(const char *name, +void cmDocumentation::AppendSection(const char *name, cmDocumentationEntry &docs) { @@ -1055,7 +1056,7 @@ void cmDocumentation::AppendSection(const char *name, } //---------------------------------------------------------------------------- -void cmDocumentation::PrependSection(const char *name, +void cmDocumentation::PrependSection(const char *name, cmDocumentationEntry &docs) { @@ -1067,7 +1068,7 @@ void cmDocumentation::PrependSection(const char *name, //---------------------------------------------------------------------------- void cmDocumentation::SetSeeAlsoList(const char *data[][3]) { - cmDocumentationSection *sec = + cmDocumentationSection *sec = new cmDocumentationSection("See Also", "SEE ALSO"); this->AllSections["See Also"] = sec; this->SeeAlsoString = ".B "; @@ -1075,7 +1076,7 @@ void cmDocumentation::SetSeeAlsoList(const char *data[][3]) while(data[i][1]) { this->SeeAlsoString += data[i][1]; - this->SeeAlsoString += data[i+1][1]? "(1), ":"(1)"; + this->SeeAlsoString += data[i+1][1]? "(1), ":"(1)"; ++i; } sec->Append(0,this->SeeAlsoString.c_str(),0); @@ -1096,9 +1097,9 @@ bool cmDocumentation::PrintDocumentationGeneric(std::ostream& os, os << "Required argument missing.\n"; return false; } - const std::vector &entries = + const std::vector &entries = this->AllSections[section]->GetEntries(); - for(std::vector::const_iterator ei = + for(std::vector::const_iterator ei = entries.begin(); ei != entries.end(); ++ei) { @@ -1138,7 +1139,7 @@ bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os) os << "Argument --help-module needs a module name.\n"; return false; } - + std::string moduleName; // find the module std::vector dirs; @@ -1172,10 +1173,10 @@ bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os) if(!moduleName.empty()) { - cmDocumentationSection *sec = + cmDocumentationSection *sec = new cmDocumentationSection("Standard CMake Modules", "MODULES"); this->AllSections["Modules"] = sec; - if (this->CreateSingleModule(moduleName.c_str(), + if (this->CreateSingleModule(moduleName.c_str(), this->CurrentArgument.c_str(), *this->AllSections["Modules"])) { @@ -1204,7 +1205,7 @@ bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os) bool cmDocumentation::PrintDocumentationSingleProperty(std::ostream& os) { bool done = false; - for (std::vector::iterator i = + for (std::vector::iterator i = this->PropertySections.begin(); !done && i != this->PropertySections.end(); ++i) { @@ -1241,7 +1242,7 @@ bool cmDocumentation::PrintDocumentationSinglePolicy(std::ostream& os) bool cmDocumentation::PrintDocumentationSingleVariable(std::ostream& os) { bool done = false; - for (std::vector::iterator i = + for (std::vector::iterator i = this->VariableSections.begin(); !done && i != this->VariableSections.end(); ++i) { @@ -1270,9 +1271,9 @@ bool cmDocumentation::PrintDocumentationList(std::ostream& os, return false; } - const std::vector &entries = + const std::vector &entries = this->AllSections[section]->GetEntries(); - for(std::vector::const_iterator ei = + for(std::vector::const_iterator ei = entries.begin(); ei != entries.end(); ++ei) { @@ -1364,7 +1365,7 @@ bool cmDocumentation::PrintDocumentationProperties(std::ostream& os) this->ClearSections(); this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Properties)); this->AddSectionToPrint("Properties Description"); - for (std::vector::iterator i = + for (std::vector::iterator i = this->PropertySections.begin(); i != this->PropertySections.end(); ++i) { @@ -1383,7 +1384,7 @@ bool cmDocumentation::PrintDocumentationVariables(std::ostream& os) { this->ClearSections(); this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Variables)); - for (std::vector::iterator i = + for (std::vector::iterator i = this->VariableSections.begin(); i != this->VariableSections.end(); ++i) { @@ -1464,10 +1465,10 @@ void cmDocumentation::CreateFullDocumentation() this->AddSectionToPrint("Commands"); emitted.insert("Commands"); - + this->AddSectionToPrint("Properties Description"); emitted.insert("Properties Description"); - for (std::vector::iterator i = + for (std::vector::iterator i = this->PropertySections.begin(); i != this->PropertySections.end(); ++i) { @@ -1481,7 +1482,7 @@ void cmDocumentation::CreateFullDocumentation() emitted.insert("Author"); // add any sections not yet written out, or to be written out - for (std::map::iterator i = + for (std::map::iterator i = this->AllSections.begin(); i != this->AllSections.end(); ++i) { @@ -1579,6 +1580,6 @@ const char* cmDocumentation::GetDefaultDocName(Type ht) const //---------------------------------------------------------------------------- bool cmDocumentation::IsOption(const char* arg) const { - return ((arg[0] == '-') || (strcmp(arg, "/V") == 0) || + return ((arg[0] == '-') || (strcmp(arg, "/V") == 0) || (strcmp(arg, "/?") == 0)); } diff --git a/Source/cmDocumentationFormatter.h b/Source/cmDocumentationFormatter.h index f8cdc96c4..665b9b61a 100644 --- a/Source/cmDocumentationFormatter.h +++ b/Source/cmDocumentationFormatter.h @@ -16,7 +16,7 @@ /** This is just a helper class to make it build with MSVC 6.0. Actually the enums and internal classes could directly go into -cmDocumentation, but then MSVC6 complains in RequestedHelpItem that +cmDocumentation, but then MSVC6 complains in RequestedHelpItem that cmDocumentation is an undefined type and so it doesn't know the enums. Moving the enums to a class which is then already completely parsed helps against this. */ @@ -24,10 +24,10 @@ class cmDocumentationEnums { public: /** Types of help provided. */ - enum Type + enum Type { None, Usage, Single, SingleModule, SingleProperty, SingleVariable, List, ModuleList, PropertyList, VariableList, - Full, Properties, Variables, Modules, CustomModules, Commands, + Full, Properties, Variables, Modules, CustomModules, Commands, CompatCommands, Copyright, Version, Policies, SinglePolicy }; /** Forms of documentation output. */ @@ -36,7 +36,7 @@ public: class cmDocumentationSection; -/** Base class for printing the documentation in the various supported +/** Base class for printing the documentation in the various supported formats. */ class cmDocumentationFormatter { @@ -46,7 +46,7 @@ public: void PrintFormatted(std::ostream& os, const char* text); virtual cmDocumentationEnums::Form GetForm() const = 0; - + virtual void PrintHeader(const char* /*docname*/, const char* /*appname*/, std::ostream& /*os*/) {} @@ -60,7 +60,7 @@ public: std::vector&) {} - /** Compute a prefix for links into a section (#_SOMETHING). */ + /** Compute a prefix for links into a section (#\_SOMETHING). */ std::string ComputeSectionLinkPrefix(std::string const& name); }; diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 7e73e3659..32595ee4b 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -125,6 +125,8 @@ cmExportBuildFileGenerator std::string prop = "IMPORTED_IMPLIB"; prop += suffix; std::string value = target->GetFullPath(config, true); + target->GetImplibGNUtoMS(value, value, + "${CMAKE_IMPORT_LIBRARY_SUFFIX}"); properties[prop] = value; } } diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h index f33e9e26a..eb19d2ef4 100644 --- a/Source/cmExportCommand.h +++ b/Source/cmExportCommand.h @@ -13,6 +13,7 @@ #define cmExportCommand_h #include "cmCommand.h" +#include "cmDocumentLocationUndefined.h" class cmExportBuildFileGenerator; @@ -80,6 +81,7 @@ public: "should never be installed. " "See the install(EXPORT) command to export targets from an " "installation tree." + CM_LOCATION_UNDEFINED_BEHAVIOR("passing it to this command") "\n" " export(PACKAGE )\n" "Store the current build directory in the CMake user package registry " diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 9e5c91efc..c4f5dfb50 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -368,3 +368,66 @@ cmExportFileGenerator os << " )\n" << "\n"; } + + +//---------------------------------------------------------------------------- +void +cmExportFileGenerator::GenerateImportedFileCheckLoop(std::ostream& os) +{ + // Add code which verifies at cmake time that the file which is being + // imported actually exists on disk. This should in theory always be theory + // case, but still when packages are split into normal and development + // packages this might get broken (e.g. the Config.cmake could be part of + // the non-development package, something similar happened to me without + // on SUSE with a mysql pkg-config file, which claimed everything is fine, + // but the development package was not installed.). + os << "# Loop over all imported files and verify that they actually exist\n" + "FOREACH(target ${_IMPORT_CHECK_TARGETS} )\n" + " FOREACH(file ${_IMPORT_CHECK_FILES_FOR_${target}} )\n" + " IF(NOT EXISTS \"${file}\" )\n" + " MESSAGE(FATAL_ERROR \"The imported target \\\"${target}\\\"" + " references the file\n" + " \\\"${file}\\\"\n" + "but this file does not exist. Possible reasons include:\n" + "* The file was deleted, renamed, or moved to another location.\n" + "* An install or uninstall procedure did not complete successfully.\n" + "* The installation package was faulty and contained\n" + " \\\"${CMAKE_CURRENT_LIST_FILE}\\\"\n" + "but not all the files it references.\n" + "\")\n" + " ENDIF()\n" + " ENDFOREACH()\n" + " UNSET(_IMPORT_CHECK_FILES_FOR_${target})\n" + "ENDFOREACH()\n" + "UNSET(_IMPORT_CHECK_TARGETS)\n" + "\n"; +} + + +//---------------------------------------------------------------------------- +void +cmExportFileGenerator +::GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target, + ImportPropertyMap const& properties, + const std::set& importedLocations) +{ + // Construct the imported target name. + std::string targetName = this->Namespace; + targetName += target->GetName(); + + os << "LIST(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n" + "LIST(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " "; + + for(std::set::const_iterator li = importedLocations.begin(); + li != importedLocations.end(); + ++li) + { + ImportPropertyMap::const_iterator pi = properties.find(*li); + if (pi != properties.end()) + { + os << "\"" << pi->second << "\" "; + } + } + + os << ")\n\n"; +} diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 05f73a247..f271e5570 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -56,6 +56,11 @@ protected: void GenerateImportPropertyCode(std::ostream& os, const char* config, cmTarget* target, ImportPropertyMap const& properties); + void GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target, + ImportPropertyMap const& properties, + const std::set& importedLocations); + void GenerateImportedFileCheckLoop(std::ostream& os); + // Collect properties with detailed information about targets beyond // their location on disk. diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 23ff5fb12..da14dd787 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -167,16 +167,18 @@ cmExportInstallFileGenerator // Collect import properties for this target. cmTargetExport* te = *tei; ImportPropertyMap properties; + std::set importedLocations; + this->SetImportLocationProperty(config, suffix, te->ArchiveGenerator, + properties, importedLocations); + this->SetImportLocationProperty(config, suffix, te->LibraryGenerator, + properties, importedLocations); this->SetImportLocationProperty(config, suffix, - te->ArchiveGenerator, properties); - this->SetImportLocationProperty(config, suffix, - te->LibraryGenerator, properties); - this->SetImportLocationProperty(config, suffix, - te->RuntimeGenerator, properties); - this->SetImportLocationProperty(config, suffix, - te->FrameworkGenerator, properties); - this->SetImportLocationProperty(config, suffix, - te->BundleGenerator, properties); + te->RuntimeGenerator, properties, + importedLocations); + this->SetImportLocationProperty(config, suffix, te->FrameworkGenerator, + properties, importedLocations); + this->SetImportLocationProperty(config, suffix, te->BundleGenerator, + properties, importedLocations); // If any file location was set for the target add it to the // import file. @@ -194,9 +196,13 @@ cmExportInstallFileGenerator // Generate code in the export file. this->GenerateImportPropertyCode(os, config, te->Target, properties); + this->GenerateImportedFileChecksCode(os, te->Target, properties, + importedLocations); } } + this->GenerateImportedFileCheckLoop(os); + // Cleanup the import prefix variable. if(!this->ImportPrefix.empty()) { @@ -211,7 +217,9 @@ void cmExportInstallFileGenerator ::SetImportLocationProperty(const char* config, std::string const& suffix, cmInstallTargetGenerator* itgen, - ImportPropertyMap& properties) + ImportPropertyMap& properties, + std::set& importedLocations + ) { // Skip rules that do not match this configuration. if(!(itgen && itgen->InstallsForConfig(config))) @@ -249,6 +257,7 @@ cmExportInstallFileGenerator // Store the property. properties[prop] = value; + importedLocations.insert(prop); } else { @@ -291,6 +300,7 @@ cmExportInstallFileGenerator // Store the property. properties[prop] = value; + importedLocations.insert(prop); } } diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 8c8fb4445..fb678e891 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -75,7 +75,9 @@ protected: void SetImportLocationProperty(const char* config, std::string const& suffix, cmInstallTargetGenerator* itgen, - ImportPropertyMap& properties); + ImportPropertyMap& properties, + std::set& importedLocations + ); void ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen); diff --git a/Source/cmExprLexer.cxx b/Source/cmExprLexer.cxx index a642f5535..53dfca7c0 100644 --- a/Source/cmExprLexer.cxx +++ b/Source/cmExprLexer.cxx @@ -44,7 +44,7 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; #endif /* ! C99 */ @@ -165,7 +165,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE; #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) - + /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ @@ -231,7 +231,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -787,7 +787,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP #line 88 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ yylvalp->Number = atoi(yytext); return exp_NUMBER; } +{ yylvalp->Number = atoi(yytext); return exp_NUMBER; } case 2: YY_RULE_SETUP #line 90 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" @@ -795,43 +795,43 @@ YY_RULE_SETUP case 3: YY_RULE_SETUP #line 91 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_MINUS; } +{ return exp_MINUS; } case 4: YY_RULE_SETUP #line 92 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_TIMES; } +{ return exp_TIMES; } case 5: YY_RULE_SETUP #line 93 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_DIVIDE; } +{ return exp_DIVIDE; } case 6: YY_RULE_SETUP #line 94 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_MOD; } +{ return exp_MOD; } case 7: YY_RULE_SETUP #line 95 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_OR; } +{ return exp_OR; } case 8: YY_RULE_SETUP #line 96 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_AND; } +{ return exp_AND; } case 9: YY_RULE_SETUP #line 97 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_XOR; } +{ return exp_XOR; } case 10: YY_RULE_SETUP #line 98 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_NOT; } +{ return exp_NOT; } case 11: YY_RULE_SETUP #line 99 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_SHIFTLEFT; } +{ return exp_SHIFTLEFT; } case 12: YY_RULE_SETUP #line 100 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" -{ return exp_SHIFTRIGHT; } +{ return exp_SHIFTRIGHT; } case 13: YY_RULE_SETUP #line 101 "/home/andy/vtk/CMake/Source/cmExprLexer.in.l" @@ -1319,7 +1319,7 @@ static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner) YY_BUFFER_STATE cmExpr_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) cmExpr_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in cmExpr_yy_create_buffer()" ); @@ -1363,7 +1363,7 @@ static void cmExpr_yy_load_buffer_state (yyscan_t yyscanner) #ifndef __cplusplus extern int isatty (int ); #endif /* __cplusplus */ - + /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a cmExpr_yyrestart() or at EOF. @@ -1389,7 +1389,7 @@ extern int isatty (int ); } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - + errno = oerrno; } @@ -1493,9 +1493,9 @@ static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner) yyg->yy_buffer_stack = (struct yy_buffer_state**)cmExpr_yyalloc (nuto_alloc * sizeof(struct yy_buffer_state*) , yyscanner); - + memset(yyg->yy_buffer_stack, 0, nuto_alloc * sizeof(struct yy_buffer_state*)); - + yyg->yy_buffer_stack_max = nuto_alloc; yyg->yy_buffer_stack_top = 0; return; @@ -1522,12 +1522,12 @@ static void cmExpr_yyensure_buffer_stack (yyscan_t yyscanner) * @param base the character buffer * @param size the size in bytes of the character buffer * @param yyscanner The scanner object. - * @return the newly allocated buffer state object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE cmExpr_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -1554,8 +1554,7 @@ YY_BUFFER_STATE cmExpr_yy_scan_buffer (char * base, yy_size_t size , yyscan_t } /** Setup the input buffer state to scan a string. The next call to cmExpr_yylex() will - * scan from a @e copy of @a str. - * @param str a NUL-terminated string to scan + * scan from a @e copy of @a yy_str. * @param yy_str a NUL-terminated string to scan * @param yyscanner The scanner object. * @return the newly allocated buffer state object. @@ -1564,7 +1563,7 @@ YY_BUFFER_STATE cmExpr_yy_scan_buffer (char * base, yy_size_t size , yyscan_t */ YY_BUFFER_STATE cmExpr_yy_scan_string (yyconst char * yy_str , yyscan_t yyscanner) { - + return cmExpr_yy_scan_bytes(yy_str,strlen(yy_str) ,yyscanner); } @@ -1581,7 +1580,7 @@ YY_BUFFER_STATE cmExpr_yy_scan_bytes (yyconst char * bytes, int len , yyscan_t char *buf; yy_size_t n; int i; - + /* Get memory for full buffer, including space for trailing EOB's. */ n = len + 2; buf = (char *) cmExpr_yyalloc(n ,yyscanner ); @@ -1649,10 +1648,10 @@ YY_EXTRA_TYPE cmExpr_yyget_extra (yyscan_t yyscanner) int cmExpr_yyget_lineno (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yylineno; } @@ -1662,10 +1661,10 @@ int cmExpr_yyget_lineno (yyscan_t yyscanner) int cmExpr_yyget_column (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - + if (! YY_CURRENT_BUFFER) return 0; - + return yycolumn; } @@ -1726,13 +1725,13 @@ void cmExpr_yyset_lineno (int line_number , yyscan_t yyscanner) /* lineno is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "cmExpr_yyset_lineno called with no buffer" , yyscanner); - + yy_fatal_error( "cmExpr_yyset_lineno called with no buffer" , yyscanner); + yylineno = line_number; } /** Set the current column. - * @param line_number + * @param column_no * @param yyscanner The scanner object. */ void cmExpr_yyset_column (int column_no , yyscan_t yyscanner) @@ -1741,8 +1740,8 @@ void cmExpr_yyset_column (int column_no , yyscan_t yyscanner) /* column is only valid if an input buffer exists. */ if (! YY_CURRENT_BUFFER ) - yy_fatal_error( "cmExpr_yyset_column called with no buffer" , yyscanner); - + yy_fatal_error( "cmExpr_yyset_column called with no buffer" , yyscanner); + yycolumn = column_no; } diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 4f93067c9..38002ec48 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -19,6 +19,7 @@ #include "cmGeneratedFileStream.h" #include "cmTarget.h" #include "cmSystemTools.h" +#include "cmXMLSafe.h" #include @@ -266,10 +267,17 @@ void cmExtraCodeBlocksGenerator } // Convert + const char* cmakeRoot = mf->GetDefinition("CMAKE_ROOT"); for (std::vector::const_iterator jt = listFiles.begin(); jt != listFiles.end(); ++jt) { + // don't put cmake's own files into the project (#12110): + if (jt->find(cmakeRoot) == 0) + { + continue; + } + const std::string &relative = cmSystemTools::RelativePath( it->second[0]->GetMakefile()->GetHomeDirectory(), jt->c_str()); @@ -573,15 +581,70 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, "
\n" @@ -1083,20 +1287,25 @@ void cmExtraEclipseCDT4Generator ::AppendLinkedResource (cmGeneratedFileStream& fout, const std::string& name, const std::string& path, - bool isVirtualFolder) + LinkType linkType) { const char* locationTag = "location"; - if (isVirtualFolder) // ... and not a linked folder + const char* typeTag = "2"; + if (linkType == VirtualFolder) // ... and not a linked folder { locationTag = "locationURI"; } + if (linkType == LinkToFile) + { + typeTag = "1"; + } fout << "\t\t\n" "\t\t\t" << cmExtraEclipseCDT4Generator::EscapeForXML(name) << "\n" - "\t\t\t2\n" + "\t\t\t" << typeTag << "\n" "\t\t\t<" << locationTag << ">" << cmExtraEclipseCDT4Generator::EscapeForXML(path) << "\n" @@ -1145,7 +1354,7 @@ bool cmExtraEclipseCDT4Generator else { this->AppendLinkedResource(fout, name, - this->GetEclipsePath(outputPath)); + this->GetEclipsePath(outputPath), LinkToFolder); this->OutLinkedResources.push_back(name); return true; } diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h index a6837313b..ebd8c081e 100644 --- a/Source/cmExtraEclipseCDT4Generator.h +++ b/Source/cmExtraEclipseCDT4Generator.h @@ -25,6 +25,8 @@ class cmGeneratedFileStream; class cmExtraEclipseCDT4Generator : public cmExternalMakefileProjectGenerator { public: + enum LinkType {VirtualFolder, LinkToFolder, LinkToFile }; + cmExtraEclipseCDT4Generator(); static cmExternalMakefileProjectGenerator* New() { @@ -44,7 +46,7 @@ public: private: // create .project file in the source tree - void CreateSourceProjectFile() const; + void CreateSourceProjectFile(); // create .project file void CreateProjectFile(); @@ -73,7 +75,8 @@ private: const std::string& make, const std::string& makeArguments, const std::string& path, - const char* prefix = ""); + const char* prefix = "", + const char* makeTarget = NULL); static void AppendScannerProfile (cmGeneratedFileStream& fout, const std::string& profileID, bool openActionEnabled, @@ -88,7 +91,7 @@ private: static void AppendLinkedResource (cmGeneratedFileStream& fout, const std::string& name, const std::string& path, - bool isVirtualFolder = false); + LinkType linkType); bool AppendOutLinkedResource(cmGeneratedFileStream& fout, const std::string& defname, @@ -101,12 +104,17 @@ private: static void AddEnvVar(cmGeneratedFileStream& fout, const char* envVar, cmMakefile* mf); + void CreateLinksToSubprojects(cmGeneratedFileStream& fout, + const std::string& baseDir); + void CreateLinksForTargets(cmGeneratedFileStream& fout); + std::vector SrcLinkedResources; std::vector OutLinkedResources; std::string HomeDirectory; std::string HomeOutputDirectory; bool IsOutOfSourceBuild; bool GenerateSourceProject; + bool SupportsVirtualFolders; }; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 9a3de9ba9..6df5ab38f 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -13,6 +13,7 @@ #include "cmake.h" #include "cmHexFileConverter.h" #include "cmFileTimeComparison.h" +#include "cmCryptoHash.h" #if defined(CMAKE_BUILD_WITH_CMAKE) #include "cm_curl.h" @@ -22,6 +23,7 @@ #include #include +#include #include #include #include @@ -83,6 +85,15 @@ bool cmFileCommand { return this->HandleReadCommand(args); } + else if ( subCommand == "MD5" || + subCommand == "SHA1" || + subCommand == "SHA224" || + subCommand == "SHA256" || + subCommand == "SHA384" || + subCommand == "SHA512" ) + { + return this->HandleHashCommand(args); + } else if ( subCommand == "STRINGS" ) { return this->HandleStringsCommand(args); @@ -338,6 +349,41 @@ bool cmFileCommand::HandleReadCommand(std::vector const& args) return true; } +//---------------------------------------------------------------------------- +bool cmFileCommand::HandleHashCommand(std::vector const& args) +{ +#if defined(CMAKE_BUILD_WITH_CMAKE) + if(args.size() != 3) + { + cmOStringStream e; + e << args[0] << " requires a file name and output variable"; + this->SetError(e.str().c_str()); + return false; + } + + cmsys::auto_ptr hash(cmCryptoHash::New(args[0].c_str())); + if(hash.get()) + { + std::string out = hash->HashFile(args[1].c_str()); + if(!out.empty()) + { + this->Makefile->AddDefinition(args[2].c_str(), out.c_str()); + return true; + } + cmOStringStream e; + e << args[0] << " failed to read file \"" << args[1] << "\": " + << cmSystemTools::GetLastSystemError(); + this->SetError(e.str().c_str()); + } + return false; +#else + cmOStringStream e; + e << args[0] << " not available during bootstrap"; + this->SetError(e.str().c_str()); + return false; +#endif +} + //---------------------------------------------------------------------------- bool cmFileCommand::HandleStringsCommand(std::vector const& args) { @@ -2753,6 +2799,10 @@ cmFileCommand::HandleDownloadCommand(std::vector const& args) ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); check_curl_result(res, "DOWNLOAD cannot set url: "); + // enable HTTP ERROR parsing + res = ::curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); + check_curl_result(res, "DOWNLOAD cannot set http failure option: "); + res = ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, cmWriteToFileCallback); check_curl_result(res, "DOWNLOAD cannot set write function: "); @@ -2982,6 +3032,7 @@ cmFileCommand::HandleUploadCommand(std::vector const& args) std::string errStr = "UPLOAD cannot stat file '"; errStr += filename + "'."; this->SetError(errStr.c_str()); + fclose(fin); return false; } @@ -2991,6 +3042,7 @@ cmFileCommand::HandleUploadCommand(std::vector const& args) if(!curl) { this->SetError("UPLOAD error initializing curl."); + fclose(fin); return false; } diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index 162890abf..9e2ed0fbd 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -65,6 +65,7 @@ public: " file(WRITE filename \"message to write\"... )\n" " file(APPEND filename \"message to write\"... )\n" " file(READ filename variable [LIMIT numBytes] [OFFSET offset] [HEX])\n" + " file( filename variable)\n" " file(STRINGS filename variable [LIMIT_COUNT num]\n" " [LIMIT_INPUT numBytes] [LIMIT_OUTPUT numBytes]\n" " [LENGTH_MINIMUM numBytes] [LENGTH_MAXIMUM numBytes]\n" @@ -94,6 +95,8 @@ public: "variable. It will start at the given offset and read up to numBytes. " "If the argument HEX is given, the binary data will be converted to " "hexadecimal representation and this will be stored in the variable.\n" + "MD5, SHA1, SHA224, SHA256, SHA384, and SHA512 " + "will compute a cryptographic hash of the content of a file.\n" "STRINGS will parse a list of ASCII strings from a file and " "store it in a variable. Binary data in the file are ignored. Carriage " "return (CR) characters are ignored. It works also for Intel Hex and " @@ -227,6 +230,7 @@ protected: bool HandleRemove(std::vector const& args, bool recurse); bool HandleWriteCommand(std::vector const& args, bool append); bool HandleReadCommand(std::vector const& args); + bool HandleHashCommand(std::vector const& args); bool HandleStringsCommand(std::vector const& args); bool HandleGlobCommand(std::vector const& args, bool recurse); bool HandleMakeDirectoryCommand(std::vector const& args); diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index ce9deb143..183da4a79 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -299,11 +299,7 @@ bool cmFindBase::ParseArguments(std::vector const& argsIn) this->GetIgnoredPaths(ignored); this->FilterPaths(this->SearchPaths, ignored); - // Handle search root stuff. - this->RerootPaths(this->SearchPaths); - - // Add a trailing slash to all prefixes to aid the search process. - this->AddTrailingSlashes(this->SearchPaths); + this->ComputeFinalPaths(); return true; } diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index a05e33798..b44864e13 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -471,8 +471,13 @@ void cmFindCommon::AddPathInternal(std::string const& in_path, } //---------------------------------------------------------------------------- -void cmFindCommon::AddTrailingSlashes(std::vector& paths) +void cmFindCommon::ComputeFinalPaths() { + std::vector& paths = this->SearchPaths; + + // Expand list of paths inside all search roots. + this->RerootPaths(paths); + // Add a trailing slash to all paths to aid the search process. for(std::vector::iterator i = paths.begin(); i != paths.end(); ++i) diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index 875c22354..542805faf 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -47,8 +47,8 @@ protected: void FilterPaths(std::vector& paths, const std::set& ignore); - /** Add trailing slashes to all search paths. */ - void AddTrailingSlashes(std::vector& paths); + /** Compute final search path list (reroot + trailing slash). */ + void ComputeFinalPaths(); /** Compute the current default root path mode. */ void SelectDefaultRootPathMode(); diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 5f106bce0..7d3f09bda 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -191,6 +191,9 @@ void cmFindPackageCommand::GenerateDocumentation() "\"-version.cmake\" or \"Version.cmake\". " "If no such version file is available then the configuration file " "is assumed to not be compatible with any requested version. " + "A basic version file containing generic version matching code can be " + "created using the macro write_basic_config_version_file(), see its " + "documentation for more details. " "When a version file is found it is loaded to check the requested " "version number. " "The version file is loaded in a nested scope in which the following " @@ -335,6 +338,10 @@ void cmFindPackageCommand::GenerateDocumentation() this->CommandDocumentation += this->GenericDocumentationPathsOrder; this->CommandDocumentation += "\n" + "Every non-REQUIRED find_package() call can be disabled by setting the " + "variable CMAKE_DISABLE_FIND_PACKAGE_ to TRUE. See the " + "documentation for the CMAKE_DISABLE_FIND_PACKAGE_ variable for " + "more information.\n" "See the cmake_policy() command documentation for discussion of the " "NO_POLICY_SCOPE option." ; @@ -607,6 +614,24 @@ bool cmFindPackageCommand } } + std::string disableFindPackageVar = "CMAKE_DISABLE_FIND_PACKAGE_"; + disableFindPackageVar += this->Name; + if(this->Makefile->IsOn(disableFindPackageVar.c_str())) + { + if (this->Required) + { + cmOStringStream e; + e << "for module " << this->Name << " called with REQUIRED, but " + << disableFindPackageVar + << " is enabled. A REQUIRED package cannot be disabled."; + this->SetError(e.str().c_str()); + return false; + } + + return true; + } + + this->SetModuleVariables(components); // See if there is a Find.cmake module. @@ -1174,20 +1199,20 @@ void cmFindPackageCommand::AppendSuccessInformation() if ((cmSystemTools::IsOn(result)) || (cmSystemTools::IsOn(upperResult))) { this->AppendToProperty("PACKAGES_FOUND"); - if (!this->Quiet) - { - this->AppendToProperty("ENABLED_FEATURES"); - } } else { this->AppendToProperty("PACKAGES_NOT_FOUND"); - if (!this->Quiet) - { - this->AppendToProperty("DISABLED_FEATURES"); - } } + // Record whether the find was quiet or not, so this can be used + // e.g. in FeatureSummary.cmake + std::string quietInfoPropName = "_CMAKE_"; + quietInfoPropName += this->Name; + quietInfoPropName += "_QUIET"; + this->Makefile->GetCMakeInstance()->SetProperty(quietInfoPropName.c_str(), + this->Quiet ? "TRUE" : "FALSE"); + // set a global property to record the required version of this package std::string versionInfoPropName = "_CMAKE_"; versionInfoPropName += this->Name; @@ -1218,7 +1243,7 @@ void cmFindPackageCommand::ComputePrefixes() this->AddPrefixesCMakeSystemVariable(); this->AddPrefixesSystemRegistry(); this->AddPrefixesUserGuess(); - this->ComputeFinalPrefixes(); + this->ComputeFinalPaths(); } //---------------------------------------------------------------------------- @@ -1548,18 +1573,6 @@ void cmFindPackageCommand::AddPrefixesUserHints() 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. - this->AddTrailingSlashes(prefixes); -} - //---------------------------------------------------------------------------- bool cmFindPackageCommand::SearchDirectory(std::string const& dir) { diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 2b2e1dace..e73635284 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -93,7 +93,6 @@ private: void AddPrefixesCMakeSystemVariable(); void AddPrefixesUserGuess(); void AddPrefixesUserHints(); - void ComputeFinalPrefixes(); void LoadPackageRegistryDir(std::string const& dir); void LoadPackageRegistryWinUser(); void LoadPackageRegistryWinSystem(); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 6c8938e5d..124519ada 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -18,6 +18,7 @@ #include "cmExternalMakefileProjectGenerator.h" #include "cmake.h" #include "cmMakefile.h" +#include "cmQtAutomoc.h" #include "cmSourceFile.h" #include "cmVersion.h" #include "cmExportInstallFileGenerator.h" @@ -76,6 +77,79 @@ cmGlobalGenerator::~cmGlobalGenerator() this->ClearExportSets(); } +void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang, + cmMakefile *mf, + bool optional) { + std::string langComp = "CMAKE_"; + langComp += lang; + langComp += "_COMPILER"; + + if(!mf->GetDefinition(langComp.c_str())) + { + if(!optional) + { + cmSystemTools::Error(langComp.c_str(), + " not set, after EnableLanguage"); + } + return; + } + const char* name = mf->GetRequiredDefinition(langComp.c_str()); + std::string path; + if(!cmSystemTools::FileIsFullPath(name)) + { + path = cmSystemTools::FindProgram(name); + } + else + { + path = name; + } + if((path.size() == 0 || !cmSystemTools::FileExists(path.c_str())) + && (optional==false)) + { + std::string message = "your "; + message += lang; + message += " compiler: \""; + message += name; + message += "\" was not found. Please set "; + message += langComp; + message += " to a valid compiler path or name."; + cmSystemTools::Error(message.c_str()); + path = name; + } + std::string doc = lang; + doc += " compiler."; + const char* cname = this->GetCMakeInstance()-> + GetCacheManager()->GetCacheValue(langComp.c_str()); + std::string changeVars; + if(cname && (path != cname) && (optional==false)) + { + std::string cnameString = cname; + std::string pathString = path; + // get rid of potentially multiple slashes: + cmSystemTools::ConvertToUnixSlashes(cnameString); + cmSystemTools::ConvertToUnixSlashes(pathString); + if (cnameString != pathString) + { + const char* cvars = + this->GetCMakeInstance()->GetProperty( + "__CMAKE_DELETE_CACHE_CHANGE_VARS_"); + if(cvars) + { + changeVars += cvars; + changeVars += ";"; + } + changeVars += langComp; + changeVars += ";"; + changeVars += cname; + this->GetCMakeInstance()->SetProperty( + "__CMAKE_DELETE_CACHE_CHANGE_VARS_", + changeVars.c_str()); + } + } + mf->AddCacheDefinition(langComp.c_str(), path.c_str(), + doc.c_str(), cmCacheManager::FILEPATH); +} + // Find the make program for the generator, required for try compiles void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) { @@ -269,7 +343,7 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& languages, cmOStringStream windowsVersionString; windowsVersionString << osvi.dwMajorVersion << "." << osvi.dwMinorVersion; windowsVersionString.str(); - mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION", + mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION", windowsVersionString.str().c_str()); #endif // Read the DetermineSystem file @@ -618,8 +692,8 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf) if (sscanf(linkerPref, "%d", &preference)!=1) { // backward compatibility: before 2.6 LINKER_PREFERENCE - // was either "None" or "Prefered", and only the first character was - // tested. So if there is a custom language out there and it is + // was either "None" or "Prefered", and only the first character was + // tested. So if there is a custom language out there and it is // "Prefered", set its preference high if (linkerPref[0]=='P') { @@ -782,7 +856,7 @@ void cmGlobalGenerator::Configure() // so create the map from project name to vector of local generators this->FillProjectMap(); - if ( !this->CMakeInstance->GetScriptMode() ) + if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE) { const char* msg = "Configuring done"; if(cmSystemTools::GetErrorOccuredFlag()) @@ -832,6 +906,10 @@ void cmGlobalGenerator::Generate() return; } + // Iterate through all targets and set up automoc for those which have + // the AUTOMOC property set + this->CreateAutomocTargets(); + // For each existing cmLocalGenerator unsigned int i; @@ -950,6 +1028,35 @@ bool cmGlobalGenerator::CheckTargets() return true; } +//---------------------------------------------------------------------------- +void cmGlobalGenerator::CreateAutomocTargets() +{ +#ifdef CMAKE_BUILD_WITH_CMAKE + 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) + { + if(target.GetPropertyAsBool("AUTOMOC") && !target.IsImported()) + { + cmQtAutomoc automoc; + automoc.SetupAutomocTarget(&target); + } + } + } + } +#endif +} + + void cmGlobalGenerator::CheckLocalGenerators() { std::map notFoundMap; @@ -1019,9 +1126,9 @@ void cmGlobalGenerator::CheckLocalGenerators() if(notFoundMap.size()) { std::string notFoundVars; - for(std::map::const_iterator + for(std::map::const_iterator ii = notFoundMap.begin(); - ii != notFoundMap.end(); + ii != notFoundMap.end(); ++ii) { notFoundVars += ii->first; @@ -1057,7 +1164,7 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir, { this->FirstTimeProgress = 0.95f; } - this->CMakeInstance->UpdateProgress("Configuring", + this->CMakeInstance->UpdateProgress("Configuring", this->FirstTimeProgress); } @@ -1136,7 +1243,7 @@ int cmGlobalGenerator::Build( const char *config, bool clean, bool fast, double timeout, - bool verbose, + cmSystemTools::OutputOption outputflag, const char* extraOptions, std::vector const& nativeOptions) { @@ -1161,7 +1268,7 @@ int cmGlobalGenerator::Build( { outputPtr = &outputBuffer; } - + // should we do a clean first? if (clean) { @@ -1176,7 +1283,7 @@ int cmGlobalGenerator::Build( } if (!cmSystemTools::RunSingleCommand(cleanCommand.c_str(), outputPtr, - &retVal, 0, verbose, timeout)) + &retVal, 0, outputflag, timeout)) { cmSystemTools::SetRunCommandHideConsole(hideconsole); cmSystemTools::Error("Generator: execution of make clean failed."); @@ -1199,7 +1306,7 @@ int cmGlobalGenerator::Build( // now build std::string makeCommand = this->GenerateBuildCommand(makeCommandCSTR, projectName, - extraOptions, target, + extraOptions, target, config, false, fast); if(output) { @@ -1217,7 +1324,7 @@ int cmGlobalGenerator::Build( } if (!cmSystemTools::RunSingleCommand(command, outputPtr, - &retVal, 0, verbose, timeout)) + &retVal, 0, outputflag, timeout)) { cmSystemTools::SetRunCommandHideConsole(hideconsole); cmSystemTools::Error @@ -1272,8 +1379,8 @@ void cmGlobalGenerator::AddLocalGenerator(cmLocalGenerator *lg) if(this->FirstTimeProgress > 0.95f) { this->FirstTimeProgress = 0.95f; - } - this->CMakeInstance->UpdateProgress("Configuring", + } + this->CMakeInstance->UpdateProgress("Configuring", this->FirstTimeProgress); return; } @@ -1296,8 +1403,8 @@ void cmGlobalGenerator::AddInstallComponent(const char* component) } } -void cmGlobalGenerator::AddTargetToExports(const char* exportSetName, - cmTarget* target, +void cmGlobalGenerator::AddTargetToExports(const char* exportSetName, + cmTarget* target, cmInstallTargetGenerator* archive, cmInstallTargetGenerator* runTime, cmInstallTargetGenerator* library, @@ -1331,7 +1438,7 @@ void cmGlobalGenerator::ClearExportSets() const std::vector* cmGlobalGenerator::GetExportSet( const char* name) const { - std::map >::const_iterator + std::map >::const_iterator exportSetIt = this->ExportSets.find(name); if (exportSetIt != this->ExportSets.end()) { @@ -1443,7 +1550,7 @@ void cmGlobalGenerator::GetEnabledLanguages(std::vector& lang) int cmGlobalGenerator::GetLinkerPreference(const char* lang) { - std::map::const_iterator it = + std::map::const_iterator it = this->LanguageToLinkerPreference.find(lang); if (it != this->LanguageToLinkerPreference.end()) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 5268731f7..ded3345db 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -17,7 +17,7 @@ #include "cmTarget.h" // For cmTargets #include "cmTargetDepend.h" // For cmTargetDependSet - +#include "cmSystemTools.h" // for cmSystemTools::OutputOption class cmake; class cmMakefile; class cmLocalGenerator; @@ -76,6 +76,13 @@ public: virtual void EnableLanguage(std::vectorconst& languages, cmMakefile *, bool optional); + /** + * Resolve the CMAKE__COMPILER setting for the given language. + * Intended to be called from EnableLanguage. + */ + void ResolveLanguageCompiler(const std::string &lang, cmMakefile *mf, + bool optional); + /** * Try to determine system infomation, get it from another generator */ @@ -83,7 +90,7 @@ public: cmMakefile* mf); /** - * Try running cmake and building a file. This is used for dynalically + * Try running cmake and building a file. This is used for dynamically * loaded commands, not as part of the usual build process. */ virtual int TryCompile(const char *srcdir, const char *bindir, @@ -102,7 +109,8 @@ public: std::string *output, const char *makeProgram, const char *config, bool clean, bool fast, - double timeout, bool verbose=false, + double timeout, + cmSystemTools::OutputOption outputflag=cmSystemTools::OUTPUT_NONE, const char* extraOptions = 0, std::vector const& nativeOptions = std::vector()); @@ -119,6 +127,7 @@ public: ///! Get the CMake instance cmake *GetCMakeInstance() { return this->CMakeInstance; }; + const cmake *GetCMakeInstance() const { return this->CMakeInstance; }; void SetConfiguredFilesPath(cmGlobalGenerator* gen); const std::vector& GetLocalGenerators() const { @@ -161,8 +170,8 @@ public: int TryCompileTimeout; - bool GetForceUnixPaths() {return this->ForceUnixPaths;} - bool GetToolSupportsColor() { return this->ToolSupportsColor; } + bool GetForceUnixPaths() const { return this->ForceUnixPaths; } + bool GetToolSupportsColor() const { return this->ToolSupportsColor; } ///! return the language for the given extension const char* GetLanguageFromExtension(const char* ext); @@ -177,11 +186,11 @@ public: virtual const char* GetCMakeCFGInitDirectory() { return "."; } /** Get whether the generator should use a script for link commands. */ - bool GetUseLinkScript() { return this->UseLinkScript; } + bool GetUseLinkScript() const { return this->UseLinkScript; } /** Get whether the generator should produce special marks on rules producing symbolic (non-file) outputs. */ - bool GetNeedSymbolicMark() { return this->NeedSymbolicMark; } + bool GetNeedSymbolicMark() const { return this->NeedSymbolicMark; } /* * Determine what program to use for building the project. @@ -211,7 +220,8 @@ public: /** Get the manifest of all targets that will be built for each configuration. This is valid during generation only. */ - cmTargetManifest const& GetTargetManifest() { return this->TargetManifest; } + cmTargetManifest const& GetTargetManifest() const + { return this->TargetManifest; } /** Get the content of a directory. Directory listings are loaded from disk at most once and cached. During the generation step @@ -222,17 +232,17 @@ public: void AddTarget(cmTargets::value_type &v); - virtual const char* GetAllTargetName() { return "ALL_BUILD"; } - virtual const char* GetInstallTargetName() { return "INSTALL"; } - virtual const char* GetInstallLocalTargetName() { return 0; } - virtual const char* GetInstallStripTargetName() { return 0; } - virtual const char* GetPreinstallTargetName() { return 0; } - virtual const char* GetTestTargetName() { return "RUN_TESTS"; } - virtual const char* GetPackageTargetName() { return "PACKAGE"; } - virtual const char* GetPackageSourceTargetName(){ return 0; } - virtual const char* GetEditCacheTargetName() { return 0; } - virtual const char* GetRebuildCacheTargetName() { return 0; } - virtual const char* GetCleanTargetName() { return 0; } + virtual const char* GetAllTargetName() const { return "ALL_BUILD"; } + virtual const char* GetInstallTargetName() const { return "INSTALL"; } + virtual const char* GetInstallLocalTargetName() const { return 0; } + virtual const char* GetInstallStripTargetName() const { return 0; } + virtual const char* GetPreinstallTargetName() const { return 0; } + virtual const char* GetTestTargetName() const { return "RUN_TESTS"; } + virtual const char* GetPackageTargetName() const { return "PACKAGE"; } + virtual const char* GetPackageSourceTargetName() const { return 0; } + virtual const char* GetEditCacheTargetName() const { return 0; } + virtual const char* GetRebuildCacheTargetName() const { return 0; } + virtual const char* GetCleanTargetName() const { return 0; } // Class to track a set of dependencies. typedef cmTargetDependSet TargetDependSet; @@ -281,6 +291,8 @@ protected: virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS(); bool CheckTargets(); + void CreateAutomocTargets(); + // Fill the ProjectMap, this must be called after LocalGenerators // has been populated. diff --git a/Source/cmGlobalKdevelopGenerator.h b/Source/cmGlobalKdevelopGenerator.h index 63f7c1f94..a1ad39d44 100644 --- a/Source/cmGlobalKdevelopGenerator.h +++ b/Source/cmGlobalKdevelopGenerator.h @@ -23,8 +23,8 @@ class cmLocalGenerator; * cmGlobalKdevelopGenerator produces a project file for KDevelop 3 (KDevelop * > 3.1.1). The project is based on the "Custom Makefile based C/C++" * project of KDevelop. Such a project consists of Unix Makefiles in the - * build directory together with a .kdevelop project file, - * which contains the project settings and a .kdevelop.filelist + * build directory together with a \.kdevelop project file, + * which contains the project settings and a \.kdevelop.filelist * file, which lists the source files relative to the kdevelop project * directory. The kdevelop project directory is the base source directory. */ @@ -36,19 +36,19 @@ public: virtual const char* GetName() const { return cmGlobalKdevelopGenerator::GetActualName();} static const char* GetActualName() { return "KDevelop3";} - static cmExternalMakefileProjectGenerator* New() + static cmExternalMakefileProjectGenerator* New() { return new cmGlobalKdevelopGenerator; } /** Get the documentation entry for this generator. */ - virtual void GetDocumentation(cmDocumentationEntry& entry, + virtual void GetDocumentation(cmDocumentationEntry& entry, const char* fullName) const; virtual void Generate(); private: /*** Create the foo.kdevelop.filelist file, return false if it doesn't - succeed. If the file already exists the contents will be merged. + succeed. If the file already exists the contents will be merged. */ bool CreateFilelistFile(const std::vector& lgs, - const std::string& outputDir, + const std::string& outputDir, const std::string& projectDirIn, const std::string& projectname, std::string& cmakeFilePattern, @@ -62,13 +62,13 @@ private: listfiles used by this CMakeLists.txt */ void CreateProjectFile(const std::string& outputDir, const std::string& projectDir, - const std::string& projectname, - const std::string& executable, + const std::string& projectname, + const std::string& executable, const std::string& cmakeFilePattern, const std::string& fileToOpen); /*** Reads the old foo.kdevelop line by line and only replaces the - "important" lines + "important" lines */ void MergeProjectFiles(const std::string& outputDir, const std::string& projectDir, @@ -78,10 +78,10 @@ private: const std::string& fileToOpen, const std::string& sessionFilename); ///! Creates a new foo.kdevelop and a new foo.kdevses file - void CreateNewProjectFile(const std::string& outputDir, - const std::string& projectDir, + void CreateNewProjectFile(const std::string& outputDir, + const std::string& projectDir, const std::string& filename, - const std::string& executable, + const std::string& executable, const std::string& cmakeFilePattern, const std::string& fileToOpen, const std::string& sessionFilename); diff --git a/Source/cmGlobalMinGWMakefileGenerator.cxx b/Source/cmGlobalMinGWMakefileGenerator.cxx index 2f558dc2c..a9e779847 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.cxx +++ b/Source/cmGlobalMinGWMakefileGenerator.cxx @@ -66,18 +66,6 @@ cmLocalGenerator *cmGlobalMinGWMakefileGenerator::CreateLocalGenerator() lg->SetPassMakeflags(false); lg->SetUnixCD(true); lg->SetMinGWMake(true); - - // mingw32-make has trouble running code like - // - // @echo message with spaces - // - // If quotes are added - // - // @echo "message with spaces" - // - // it runs but the quotes are displayed. Instead just use cmake to - // echo. - lg->SetNativeEchoCommand("@$(CMAKE_COMMAND) -E echo ", false); return lg; } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 169d77d9d..a23c0d8d3 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -39,7 +39,6 @@ void cmGlobalUnixMakefileGenerator3 bool optional) { this->cmGlobalGenerator::EnableLanguage(languages, mf, optional); - std::string path; for(std::vector::const_iterator l = languages.begin(); l != languages.end(); ++l) { @@ -47,74 +46,7 @@ void cmGlobalUnixMakefileGenerator3 { continue; } - const char* lang = l->c_str(); - std::string langComp = "CMAKE_"; - langComp += lang; - langComp += "_COMPILER"; - - if(!mf->GetDefinition(langComp.c_str())) - { - if(!optional) - { - cmSystemTools::Error(langComp.c_str(), - " not set, after EnableLanguage"); - } - continue; - } - const char* name = mf->GetRequiredDefinition(langComp.c_str()); - if(!cmSystemTools::FileIsFullPath(name)) - { - path = cmSystemTools::FindProgram(name); - } - else - { - path = name; - } - if((path.size() == 0 || !cmSystemTools::FileExists(path.c_str())) - && (optional==false)) - { - std::string message = "your "; - message += lang; - message += " compiler: \""; - message += name; - message += "\" was not found. Please set "; - message += langComp; - message += " to a valid compiler path or name."; - cmSystemTools::Error(message.c_str()); - path = name; - } - std::string doc = lang; - doc += " compiler."; - const char* cname = this->GetCMakeInstance()-> - GetCacheManager()->GetCacheValue(langComp.c_str()); - std::string changeVars; - if(cname && (path != cname) && (optional==false)) - { - std::string cnameString = cname; - std::string pathString = path; - // get rid of potentially multiple slashes: - cmSystemTools::ConvertToUnixSlashes(cnameString); - cmSystemTools::ConvertToUnixSlashes(pathString); - if (cnameString != pathString) - { - const char* cvars = - this->GetCMakeInstance()->GetProperty( - "__CMAKE_DELETE_CACHE_CHANGE_VARS_"); - if(cvars) - { - changeVars += cvars; - changeVars += ";"; - } - changeVars += langComp; - changeVars += ";"; - changeVars += cname; - this->GetCMakeInstance()->SetProperty( - "__CMAKE_DELETE_CACHE_CHANGE_VARS_", - changeVars.c_str()); - } - } - mf->AddCacheDefinition(langComp.c_str(), path.c_str(), - doc.c_str(), cmCacheManager::FILEPATH); + this->ResolveLanguageCompiler(*l, mf, optional); } } diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index d21d5b957..9663b5592 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -36,7 +36,7 @@ class cmLocalUnixMakefileGenerator3; targets that are required to make the process work. Makefile2 in turn will recursively make targets in the correct order. Each - target has its own directory .dir and its own makefile build.make in + target has its own directory \.dir and its own makefile build.make in that directory. Also in that directory is a couple makefiles per source file used by the target. Typically these are named source.obj.build.make and source.obj.build.depend.make. The source.obj.build.make contains the rules @@ -90,7 +90,7 @@ public: void WriteHelpRule(std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3 *); - // write the top lvel target rules + // write the top level target rules void WriteConvenienceRules(std::ostream& ruleFileStream, std::set &emitted); @@ -136,18 +136,18 @@ protected: // does this generator need a requires step for any of its targets bool NeedRequiresStep(cmTarget const&); - // Setup target names - virtual const char* GetAllTargetName() { return "all"; } - virtual const char* GetInstallTargetName() { return "install"; } - virtual const char* GetInstallLocalTargetName() { return "install/local"; } - virtual const char* GetInstallStripTargetName() { return "install/strip"; } - virtual const char* GetPreinstallTargetName() { return "preinstall"; } - virtual const char* GetTestTargetName() { return "test"; } - virtual const char* GetPackageTargetName() { return "package"; } - virtual const char* GetPackageSourceTargetName(){ return "package_source"; } - virtual const char* GetEditCacheTargetName() { return "edit_cache"; } - virtual const char* GetRebuildCacheTargetName() { return "rebuild_cache"; } - virtual const char* GetCleanTargetName() { return "clean"; } + // Target name hooks for superclass. + const char* GetAllTargetName() const { return "all"; } + const char* GetInstallTargetName() const { return "install"; } + const char* GetInstallLocalTargetName() const { return "install/local"; } + const char* GetInstallStripTargetName() const { return "install/strip"; } + const char* GetPreinstallTargetName() const { return "preinstall"; } + const char* GetTestTargetName() const { return "test"; } + const char* GetPackageTargetName() const { return "package"; } + const char* GetPackageSourceTargetName() const { return "package_source"; } + const char* GetEditCacheTargetName() const { return "edit_cache"; } + const char* GetRebuildCacheTargetName() const { return "rebuild_cache"; } + const char* GetCleanTargetName() const { return "clean"; } virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() { return true; } diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 328a3da63..22ead10a5 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -43,7 +43,8 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio10Generator::CreateLocalGenerator() { - cmLocalVisualStudio10Generator* lg = new cmLocalVisualStudio10Generator; + cmLocalVisualStudio10Generator* lg = + new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS10); lg->SetPlatformName(this->GetPlatformName()); lg->SetGlobalGenerator(this); return lg; @@ -175,3 +176,39 @@ std::string cmGlobalVisualStudio10Generator } return makeCommand; } + +//---------------------------------------------------------------------------- +bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf) +{ + if(!this->PlatformToolset.empty()) + { + return true; + } + // This edition does not come with 64-bit tools. Look for them. + // + // TODO: Detect available tools? x64\v100 exists but does not work? + // KHLM\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\4.0;VCTargetsPath + // c:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/Platforms/ + // {Itanium,Win32,x64}/PlatformToolsets/{v100,v90,Windows7.1SDK} + std::string winSDK_7_1; + if(cmSystemTools::ReadRegistryValue( + "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\" + "Windows\\v7.1;InstallationFolder", winSDK_7_1)) + { + cmOStringStream m; + m << "Found Windows SDK v7.1: " << winSDK_7_1; + mf->DisplayStatus(m.str().c_str(), -1); + this->PlatformToolset = "Windows7.1SDK"; + return true; + } + else + { + cmOStringStream e; + e << "Cannot enable 64-bit tools with Visual Studio 2010 Express.\n" + << "Install the Microsoft Windows SDK v7.1 to get 64-bit tools:\n" + << " http://msdn.microsoft.com/en-us/windows/bb980924.aspx"; + mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); + cmSystemTools::SetFatalErrorOccured(); + return false; + } +} diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index bef56424c..18b483d09 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -74,11 +74,11 @@ public: virtual std::string GetUserMacrosRegKeyBase(); virtual const char* GetCMakeCFGInitDirectory() { return "$(Configuration)";} + bool Find64BitTools(cmMakefile* mf); protected: virtual const char* GetIDEVersion() { return "10.0"; } std::string PlatformToolset; -private: bool ExpressEdition; }; #endif diff --git a/Source/cmGlobalVisualStudio10IA64Generator.cxx b/Source/cmGlobalVisualStudio10IA64Generator.cxx new file mode 100644 index 000000000..5f70f6bba --- /dev/null +++ b/Source/cmGlobalVisualStudio10IA64Generator.cxx @@ -0,0 +1,51 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmGlobalVisualStudio10IA64Generator.h" +#include "cmMakefile.h" +#include "cmake.h" + +//---------------------------------------------------------------------------- +cmGlobalVisualStudio10IA64Generator::cmGlobalVisualStudio10IA64Generator() +{ +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio10IA64Generator +::GetDocumentation(cmDocumentationEntry& entry) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates Visual Studio 10 Itanium project files."; + entry.Full = ""; +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio10IA64Generator +::AddPlatformDefinitions(cmMakefile* mf) +{ + this->cmGlobalVisualStudio10Generator::AddPlatformDefinitions(mf); + mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE"); + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64"); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64"); +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio10IA64Generator +::EnableLanguage(std::vector const& languages, + cmMakefile* mf, bool optional) +{ + if(this->IsExpressEdition() && !this->Find64BitTools(mf)) + { + return; + } + this->cmGlobalVisualStudio10Generator + ::EnableLanguage(languages, mf, optional); +} diff --git a/Source/cmGlobalVisualStudio10IA64Generator.h b/Source/cmGlobalVisualStudio10IA64Generator.h new file mode 100644 index 000000000..a088272ef --- /dev/null +++ b/Source/cmGlobalVisualStudio10IA64Generator.h @@ -0,0 +1,40 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmGlobalVisualStudio10IA64Generator_h +#define cmGlobalVisualStudio10IA64Generator_h + +#include "cmGlobalVisualStudio10Generator.h" + +class cmGlobalVisualStudio10IA64Generator : + public cmGlobalVisualStudio10Generator +{ +public: + cmGlobalVisualStudio10IA64Generator(); + static cmGlobalGenerator* New() { + return new cmGlobalVisualStudio10IA64Generator; } + + ///! Get the name for the generator. + virtual const char* GetName() const { + return cmGlobalVisualStudio10IA64Generator::GetActualName();} + static const char* GetActualName() {return "Visual Studio 10 IA64";} + + virtual const char* GetPlatformName() const {return "Itanium";} + + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const; + + virtual void AddPlatformDefinitions(cmMakefile* mf); + + virtual void EnableLanguage(std::vectorconst& languages, + cmMakefile *, bool optional); +}; +#endif diff --git a/Source/cmGlobalVisualStudio10Win64Generator.cxx b/Source/cmGlobalVisualStudio10Win64Generator.cxx index 86007776d..49dc47364 100644 --- a/Source/cmGlobalVisualStudio10Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio10Win64Generator.cxx @@ -37,42 +37,6 @@ void cmGlobalVisualStudio10Win64Generator mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64"); } -//---------------------------------------------------------------------------- -bool cmGlobalVisualStudio10Win64Generator::Find64BitTools(cmMakefile* mf) -{ - if(!this->PlatformToolset.empty()) - { - return true; - } - // This edition does not come with 64-bit tools. Look for them. - // - // TODO: Detect available tools? x64\v100 exists but does not work? - // KHLM\\SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\4.0;VCTargetsPath - // c:/Program Files (x86)/MSBuild/Microsoft.Cpp/v4.0/Platforms/ - // {Itanium,Win32,x64}/PlatformToolsets/{v100,v90,Windows7.1SDK} - std::string winSDK_7_1; - if(cmSystemTools::ReadRegistryValue( - "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\" - "Windows\\v7.1;InstallationFolder", winSDK_7_1)) - { - cmOStringStream m; - m << "Found Windows SDK v7.1: " << winSDK_7_1; - mf->DisplayStatus(m.str().c_str(), -1); - this->PlatformToolset = "Windows7.1SDK"; - return true; - } - else - { - cmOStringStream e; - e << "Cannot enable 64-bit tools with Visual Studio 2010 Express.\n" - << "Install the Microsoft Windows SDK v7.1 to get 64-bit tools:\n" - << " http://msdn.microsoft.com/en-us/windows/bb980924.aspx"; - mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str()); - cmSystemTools::SetFatalErrorOccured(); - return false; - } -} - //---------------------------------------------------------------------------- void cmGlobalVisualStudio10Win64Generator ::EnableLanguage(std::vector const& languages, diff --git a/Source/cmGlobalVisualStudio10Win64Generator.h b/Source/cmGlobalVisualStudio10Win64Generator.h index e6d3dc534..8a2de4c0a 100644 --- a/Source/cmGlobalVisualStudio10Win64Generator.h +++ b/Source/cmGlobalVisualStudio10Win64Generator.h @@ -34,7 +34,6 @@ public: virtual void AddPlatformDefinitions(cmMakefile* mf); - bool Find64BitTools(cmMakefile* mf); virtual void EnableLanguage(std::vectorconst& languages, cmMakefile *, bool optional); }; diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx new file mode 100644 index 000000000..be7fd5572 --- /dev/null +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -0,0 +1,56 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmGlobalVisualStudio11Generator.h" +#include "cmLocalVisualStudio10Generator.h" +#include "cmMakefile.h" + +//---------------------------------------------------------------------------- +cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator() +{ + this->FindMakeProgramFile = "CMakeVS11FindMake.cmake"; + this->ExpressEdition = false; // TODO: VS 11 Express support + this->PlatformToolset = "v110"; +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio11Generator::AddPlatformDefinitions(cmMakefile* mf) +{ + mf->AddDefinition("MSVC11", "1"); + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86"); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86"); +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout) +{ + fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n"; + fout << "# Visual Studio 11\n"; +} + +//---------------------------------------------------------------------------- +cmLocalGenerator *cmGlobalVisualStudio11Generator::CreateLocalGenerator() +{ + cmLocalVisualStudio10Generator* lg = + new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS11); + lg->SetPlatformName(this->GetPlatformName()); + lg->SetGlobalGenerator(this); + return lg; +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio11Generator +::GetDocumentation(cmDocumentationEntry& entry) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates Visual Studio 11 project files."; + entry.Full = ""; +} diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h new file mode 100644 index 000000000..7e8f6aa4e --- /dev/null +++ b/Source/cmGlobalVisualStudio11Generator.h @@ -0,0 +1,46 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmGlobalVisualStudio11Generator_h +#define cmGlobalVisualStudio11Generator_h + +#include "cmGlobalVisualStudio10Generator.h" + + +/** \class cmGlobalVisualStudio11Generator */ +class cmGlobalVisualStudio11Generator: + public cmGlobalVisualStudio10Generator +{ +public: + cmGlobalVisualStudio11Generator(); + static cmGlobalGenerator* New() { + return new cmGlobalVisualStudio11Generator; } + + ///! Get the name for the generator. + virtual const char* GetName() const { + return cmGlobalVisualStudio11Generator::GetActualName();} + static const char* GetActualName() {return "Visual Studio 11";} + virtual void AddPlatformDefinitions(cmMakefile* mf); + + virtual void WriteSLNHeader(std::ostream& fout); + + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const; + + ///! create the correct local generator + virtual cmLocalGenerator *CreateLocalGenerator(); + + /** TODO: VS 11 user macro support. */ + virtual std::string GetUserMacrosDirectory() { return ""; } +protected: + virtual const char* GetIDEVersion() { return "11.0"; } +}; +#endif diff --git a/Source/cmGlobalVisualStudio11Win64Generator.cxx b/Source/cmGlobalVisualStudio11Win64Generator.cxx new file mode 100644 index 000000000..10c902753 --- /dev/null +++ b/Source/cmGlobalVisualStudio11Win64Generator.cxx @@ -0,0 +1,33 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmGlobalVisualStudio11Win64Generator.h" +#include "cmMakefile.h" +#include "cmake.h" + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio11Win64Generator +::GetDocumentation(cmDocumentationEntry& entry) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates Visual Studio 11 Win64 project files."; + entry.Full = ""; +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio11Win64Generator +::AddPlatformDefinitions(cmMakefile* mf) +{ + this->cmGlobalVisualStudio11Generator::AddPlatformDefinitions(mf); + mf->AddDefinition("CMAKE_FORCE_WIN64", "TRUE"); + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "x64"); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "x64"); +} diff --git a/Source/cmGlobalVisualStudio11Win64Generator.h b/Source/cmGlobalVisualStudio11Win64Generator.h new file mode 100644 index 000000000..53f19538c --- /dev/null +++ b/Source/cmGlobalVisualStudio11Win64Generator.h @@ -0,0 +1,37 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmGlobalVisualStudio11Win64Generator_h +#define cmGlobalVisualStudio11Win64Generator_h + +#include "cmGlobalVisualStudio11Generator.h" + +class cmGlobalVisualStudio11Win64Generator : + public cmGlobalVisualStudio11Generator +{ +public: + cmGlobalVisualStudio11Win64Generator() {} + static cmGlobalGenerator* New() { + return new cmGlobalVisualStudio11Win64Generator; } + + ///! Get the name for the generator. + virtual const char* GetName() const { + return cmGlobalVisualStudio11Win64Generator::GetActualName();} + static const char* GetActualName() {return "Visual Studio 11 Win64";} + + virtual const char* GetPlatformName() const {return "x64";} + + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const; + + virtual void AddPlatformDefinitions(cmMakefile* mf); +}; +#endif diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index adb5f2ff7..a5feaca60 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -26,8 +26,8 @@ cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator() ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio71Generator::CreateLocalGenerator() { - cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; - lg->SetVersion71(); + cmLocalVisualStudio7Generator *lg = + new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS71); lg->SetExtraFlagTable(this->GetExtraFlagTableVS7()); lg->SetGlobalGenerator(this); return lg; diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 51b891849..a68e6d8b6 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -133,7 +133,8 @@ std::string cmGlobalVisualStudio7Generator ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator() { - cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; + cmLocalVisualStudio7Generator *lg = + new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS7); lg->SetExtraFlagTable(this->GetExtraFlagTableVS7()); lg->SetGlobalGenerator(this); return lg; @@ -739,18 +740,6 @@ void cmGlobalVisualStudio7Generator entry.Full = ""; } -// make sure "special" targets have GUID's -void cmGlobalVisualStudio7Generator::Configure() -{ - cmGlobalGenerator::Configure(); - this->CreateGUID("ALL_BUILD"); - this->CreateGUID("INSTALL"); - this->CreateGUID("RUN_TESTS"); - this->CreateGUID("EDIT_CACHE"); - this->CreateGUID("REBUILD_CACHE"); - this->CreateGUID("PACKAGE"); -} - //---------------------------------------------------------------------------- void cmGlobalVisualStudio7Generator diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index b6c84e8ff..adfb757f1 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -26,9 +26,9 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator { public: cmGlobalVisualStudio7Generator(); - static cmGlobalGenerator* New() { + static cmGlobalGenerator* New() { return new cmGlobalVisualStudio7Generator; } - + ///! Get the name for the generator. virtual const char* GetName() const { return cmGlobalVisualStudio7Generator::GetActualName();} @@ -39,21 +39,21 @@ public: /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry) const; - + /** * Try to determine system infomation such as shared library - * extension, pthreads, byte order etc. + * extension, pthreads, byte order etc. */ - virtual void EnableLanguage(std::vectorconst& languages, + virtual void EnableLanguage(std::vectorconst& languages, cmMakefile *, bool optional); /** - * Try running cmake and building a file. This is used for dynalically + * Try running cmake and building a file. This is used for dynamically * loaded commands, not as part of the usual build process. */ virtual std::string GenerateBuildCommand(const char* makeProgram, - const char *projectName, - const char* additionalOptions, + const char *projectName, + const char* additionalOptions, const char *targetName, const char* config, bool ignoreErrors, @@ -62,7 +62,7 @@ public: /** * Generate the all required files for building this project/tree. This * basically creates a series of LocalGenerators for each directory and - * requests that they Generate. + * requests that they Generate. */ virtual void Generate(); @@ -75,14 +75,11 @@ public: * Get the list of configurations */ std::vector *GetConfigurations(); - + ///! Create a GUID or get an existing one. void CreateGUID(const char* name); std::string GetGUID(const char* name); - ///! do configure step - virtual void Configure(); - /** Append the subdirectory for the given configuration. */ virtual void AppendDirectoryForConfig(const char* prefix, const char* config, @@ -100,13 +97,13 @@ protected: virtual const char* GetIDEVersion() { return "7.0"; } static cmIDEFlagTable const* GetExtraFlagTableVS7(); - virtual void OutputSLNFile(cmLocalGenerator* root, + virtual void OutputSLNFile(cmLocalGenerator* root, std::vector& generators); virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, std::vector& generators); - virtual void WriteProject(std::ostream& fout, + virtual void WriteProject(std::ostream& fout, const char* name, const char* path, cmTarget &t); - virtual void WriteProjectDepends(std::ostream& fout, + virtual void WriteProjectDepends(std::ostream& fout, const char* name, const char* path, cmTarget &t); virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, @@ -127,11 +124,11 @@ protected: std::ostream& fout, cmLocalGenerator* root, OrderedTargetDependSet const& projectTargets); - + void GenerateConfigurations(cmMakefile* mf); - virtual void WriteExternalProject(std::ostream& fout, - const char* name, + virtual void WriteExternalProject(std::ostream& fout, + const char* name, const char* path, const std::set& dependencies); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index ef723b7dc..a72310978 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -28,8 +28,8 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator() ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator() { - cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; - lg->SetVersion8(); + cmLocalVisualStudio7Generator *lg = + new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS8); lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); diff --git a/Source/cmGlobalVisualStudio8Win64Generator.cxx b/Source/cmGlobalVisualStudio8Win64Generator.cxx index 3469b1710..60e45b840 100644 --- a/Source/cmGlobalVisualStudio8Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio8Win64Generator.cxx @@ -25,8 +25,8 @@ cmGlobalVisualStudio8Win64Generator::cmGlobalVisualStudio8Win64Generator() ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio8Win64Generator::CreateLocalGenerator() { - cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; - lg->SetVersion8(); + cmLocalVisualStudio7Generator *lg + = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS8); lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index f8ceea0b0..f082675eb 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -40,8 +40,8 @@ void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout) ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio9Generator::CreateLocalGenerator() { - cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; - lg->SetVersion9(); + cmLocalVisualStudio7Generator *lg + = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9); lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); diff --git a/Source/cmGlobalVisualStudio9IA64Generator.cxx b/Source/cmGlobalVisualStudio9IA64Generator.cxx new file mode 100644 index 000000000..993340ae8 --- /dev/null +++ b/Source/cmGlobalVisualStudio9IA64Generator.cxx @@ -0,0 +1,48 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmGlobalVisualStudio9IA64Generator.h" +#include "cmLocalVisualStudio7Generator.h" +#include "cmMakefile.h" + + +cmGlobalVisualStudio9IA64Generator::cmGlobalVisualStudio9IA64Generator() +{ + this->ArchitectureId = "Itanium"; +} + +///! Create a local generator appropriate to this Global Generator +cmLocalGenerator *cmGlobalVisualStudio9IA64Generator::CreateLocalGenerator() +{ + cmLocalVisualStudio7Generator *lg = + new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9); + lg->SetPlatformName(this->GetPlatformName()); + lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); + lg->SetGlobalGenerator(this); + return lg; +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio9IA64Generator +::GetDocumentation(cmDocumentationEntry& entry) const +{ + entry.Name = this->GetName(); + entry.Brief = "Generates Visual Studio 9 2008 Itanium project files."; + entry.Full = ""; +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio9IA64Generator +::AddPlatformDefinitions(cmMakefile* mf) +{ + cmGlobalVisualStudio9Generator::AddPlatformDefinitions(mf); + mf->AddDefinition("CMAKE_FORCE_IA64", "TRUE"); +} diff --git a/Source/cmGlobalVisualStudio9IA64Generator.h b/Source/cmGlobalVisualStudio9IA64Generator.h new file mode 100644 index 000000000..e33ee1550 --- /dev/null +++ b/Source/cmGlobalVisualStudio9IA64Generator.h @@ -0,0 +1,50 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmGlobalVisualStudio9IA64Generator_h +#define cmGlobalVisualStudio9IA64Generator_h + +#include "cmGlobalVisualStudio9Generator.h" + + +/** \class cmGlobalVisualStudio8IA64Generator + * \brief Write a Unix makefiles. + * + * cmGlobalVisualStudio8IA64Generator manages UNIX build process for a tree + */ +class cmGlobalVisualStudio9IA64Generator : + public cmGlobalVisualStudio9Generator +{ +public: + cmGlobalVisualStudio9IA64Generator(); + static cmGlobalGenerator* New() { + return new cmGlobalVisualStudio9IA64Generator; } + + ///! Get the name for the generator. + virtual const char* GetName() const { + return cmGlobalVisualStudio9IA64Generator::GetActualName();} + static const char* GetActualName() {return "Visual Studio 9 2008 IA64";} + + virtual const char* GetPlatformName() const {return "Itanium";} + + /** Get the documentation entry for this generator. */ + virtual void GetDocumentation(cmDocumentationEntry& entry) const; + + ///! create the correct local generator + virtual cmLocalGenerator *CreateLocalGenerator(); + + /** + * Try to determine system infomation such as shared library + * extension, pthreads, byte order etc. + */ + virtual void AddPlatformDefinitions(cmMakefile *); +}; +#endif diff --git a/Source/cmGlobalVisualStudio9Win64Generator.cxx b/Source/cmGlobalVisualStudio9Win64Generator.cxx index ff4fd4f5d..08f537d1a 100644 --- a/Source/cmGlobalVisualStudio9Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio9Win64Generator.cxx @@ -22,8 +22,8 @@ cmGlobalVisualStudio9Win64Generator::cmGlobalVisualStudio9Win64Generator() ///! Create a local generator appropriate to this Global Generator cmLocalGenerator *cmGlobalVisualStudio9Win64Generator::CreateLocalGenerator() { - cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; - lg->SetVersion9(); + cmLocalVisualStudio7Generator *lg = + new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9); lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 2cbd3ed62..859503f51 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -327,7 +327,9 @@ std::string cmGlobalXCodeGenerator::PostBuildMakeTarget(std::string const& tName, std::string const& configName) { - std::string out = "PostBuild." + tName; + std::string target = tName; + cmSystemTools::ReplaceString(target, " ", "_"); + std::string out = "PostBuild." + target; if(this->XcodeVersion > 20) { out += "." + configName; @@ -335,6 +337,9 @@ cmGlobalXCodeGenerator::PostBuildMakeTarget(std::string const& tName, return out; } +//---------------------------------------------------------------------------- +#define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZERO_CHECK" + //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, @@ -366,8 +371,18 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, makecommand.push_back(this->CurrentXCodeHackMakefile.c_str()); makecommand.push_back(""); // placeholder, see below - // Add Re-Run CMake rules - this->CreateReRunCMakeFile(root, gens); + // Add ZERO_CHECK + bool regenerate = !mf->IsOn("CMAKE_SUPPRESS_REGENERATION"); + if (regenerate) + { + this->CreateReRunCMakeFile(root, gens); + std::string file = this->ConvertToRelativeForMake( + this->CurrentReRunCMakeMakefile.c_str()); + cmSystemTools::ReplaceString(file, "\\ ", " "); + mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, true, no_depends, + no_working_directory, + "make", "-f", file.c_str()); + } // now make the allbuild depend on all the non-utility targets // in the project @@ -379,10 +394,17 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, { continue; } + cmTargets& tgts = lg->GetMakefile()->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { cmTarget& target = l->second; + + if (regenerate && (l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET)) + { + target.AddUtility(CMAKE_CHECK_BUILD_SYSTEM_TARGET); + } + // make all exe, shared libs and modules // run the depend check makefile as a post build rule // this will make sure that when the next target is built @@ -402,8 +424,8 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str()); - } + if(!target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) { allbuild->AddUtility(target.GetName()); @@ -436,8 +458,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile( std::vector::iterator new_end = std::unique(lfiles.begin(), lfiles.end()); lfiles.erase(new_end, lfiles.end()); - std::string dir = mf->GetHomeOutputDirectory(); - this->CurrentReRunCMakeMakefile = dir; + this->CurrentReRunCMakeMakefile = mf->GetStartOutputDirectory(); this->CurrentReRunCMakeMakefile += "/CMakeScripts"; cmSystemTools::MakeDirectory(this->CurrentReRunCMakeMakefile.c_str()); this->CurrentReRunCMakeMakefile += "/ReRunCMake.make"; @@ -469,12 +490,34 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects() delete this->XCodeObjects[i]; } this->XCodeObjects.clear(); + this->XCodeObjectIDs.clear(); this->GroupMap.clear(); this->GroupNameMap.clear(); this->TargetGroup.clear(); this->FileRefs.clear(); } +//---------------------------------------------------------------------------- +void cmGlobalXCodeGenerator::addObject(cmXCodeObject *obj) +{ + if(obj->GetType() == cmXCodeObject::OBJECT) + { + cmStdString id = obj->GetId(); + + // If this is a duplicate id, it's an error: + // + if(this->XCodeObjectIDs.count(id)) + { + cmSystemTools::Error( + "Xcode generator: duplicate object ids not allowed"); + } + + this->XCodeObjectIDs.insert(id); + } + + this->XCodeObjects.push_back(obj); +} + //---------------------------------------------------------------------------- cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype) @@ -488,7 +531,7 @@ cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype) { obj = new cmXCode21Object(ptype, cmXCodeObject::OBJECT); } - this->XCodeObjects.push_back(obj); + this->addObject(obj); return obj; } @@ -497,7 +540,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type) { cmXCodeObject* obj = new cmXCodeObject(cmXCodeObject::None, type); - this->XCodeObjects.push_back(obj); + this->addObject(obj); return obj; } @@ -540,6 +583,13 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, { lg->AppendFlags(flags, cmtarget.GetProperty("COMPILE_FLAGS")); } + const char* srcfmt = sf->GetProperty("Fortran_FORMAT"); + switch(this->CurrentLocalGenerator->GetFortranFormat(srcfmt)) + { + case cmLocalGenerator::FortranFormatFixed: flags="-fixed "+flags; break; + case cmLocalGenerator::FortranFormatFree: flags="-free "+flags; break; + default: break; + } lg->AppendFlags(flags, sf->GetProperty("COMPILE_FLAGS")); // Add per-source definitions. @@ -728,7 +778,8 @@ cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf, bool cmGlobalXCodeGenerator::SpecialTargetEmitted(std::string const& tname) { if(tname == "ALL_BUILD" || tname == "XCODE_DEPEND_HELPER" || - tname == "install" || tname == "package" || tname == "RUN_TESTS" ) + tname == "install" || tname == "package" || tname == "RUN_TESTS" || + tname == CMAKE_CHECK_BUILD_SYSTEM_TARGET ) { if(this->TargetDoneSet.find(tname) != this->TargetDoneSet.end()) { @@ -1114,11 +1165,6 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, commands.push_back(*(*i)->GetCustomCommand()); } } - std::vector reruncom; - cmXCodeObject* cmakeReRunPhase = - this->CreateBuildPhase("CMake ReRun", "cmakeReRunPhase", - cmtarget, reruncom); - buildPhases->AddObject(cmakeReRunPhase); // create prebuild phase cmXCodeObject* cmakeRulesBuildPhase = this->CreateBuildPhase("CMake Rules", @@ -1182,19 +1228,30 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } //---------------------------------------------------------------------------- +// This function removes each occurence of the flag and returns the last one +// (i.e., the dominant flag in GCC) std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag, std::string& flags) { std::string retFlag; - std::string::size_type pos = flags.find(flag); - if(pos != flags.npos && (pos ==0 || flags[pos-1]==' ')) + std::string::size_type pos = flags.rfind(flag); + bool saved = false; + while(pos != flags.npos) { - while(pos < flags.size() && flags[pos] != ' ') + if(pos == 0 || flags[pos-1]==' ') { - retFlag += flags[pos]; - flags[pos] = ' '; - pos++; + while(pos < flags.size() && flags[pos] != ' ') + { + if(!saved) + { + retFlag += flags[pos]; + } + flags[pos] = ' '; + pos++; + } } + saved = true; + pos = flags.rfind(flag); } return retFlag; } @@ -1207,20 +1264,6 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, const & commands, const char* name) { - if(strcmp(name, "cmakeReRunPhase") == 0) - { - std::string cdir = this->CurrentMakefile->GetHomeOutputDirectory(); - cdir = this->ConvertToRelativeForMake(cdir.c_str()); - std::string makecmd = "make -C "; - makecmd += cdir; - makecmd += " -f "; - makecmd += - this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile.c_str()); - cmSystemTools::ReplaceString(makecmd, "\\ ", "\\\\ "); - buildphase->AddAttribute("shellScript", - this->CreateString(makecmd.c_str())); - return; - } // collect multiple outputs of custom commands into a set // which will be used for every configuration @@ -1284,6 +1327,8 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, cmSystemTools::ReplaceString(makecmd, "\\ ", "\\\\ "); buildphase->AddAttribute("shellScript", this->CreateString(makecmd.c_str())); + buildphase->AddAttribute("showEnvVarsInLog", + this->CreateString("0")); } //---------------------------------------------------------------------------- @@ -1480,7 +1525,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, BuildObjectListOrString ppDefs(this, this->XcodeVersion >= 30); if(this->XcodeVersion > 15) { - this->AppendDefines(ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)\""); + this->AppendDefines(ppDefs, + "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\""); } if(const char* exportMacro = target.GetExportMacro()) { @@ -1597,9 +1643,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { if(this->XcodeVersion >= 21) { - std::string pncdir = target.GetDirectory(configName); - buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", - this->CreateString(pncdir.c_str())); + if(!target.UsesDefaultOutputDir(configName, false)) + { + std::string pncdir = target.GetDirectory(configName); + buildSettings->AddAttribute("CONFIGURATION_BUILD_DIR", + this->CreateString(pncdir.c_str())); + } } else { @@ -1753,7 +1802,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, default: break; } - if(this->XcodeVersion >= 22) + if(this->XcodeVersion >= 22 && this->XcodeVersion < 40) { buildSettings->AddAttribute("PREBINDING", this->CreateString("NO")); @@ -1843,7 +1892,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, flags += gflag; } const char* debugStr = "YES"; - if(gflagc.size() ==0 && gflag.size() == 0) + // We can't set the Xcode flag differently depending on the language, + // so put them back in this case. + if( (lang && strcmp(lang, "CXX") == 0) && gflag != gflagc ) + { + cflags += " "; + cflags += gflagc; + flags += " "; + flags += gflag; + debugStr = "NO"; + } + if( gflag == "-g0" || gflag.size() == 0 ) { debugStr = "NO"; } @@ -1876,6 +1935,21 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(flags.c_str())); } + // Add Fortran source format attribute if property is set. + const char* format = 0; + const char* tgtfmt = target.GetProperty("Fortran_FORMAT"); + switch(this->CurrentLocalGenerator->GetFortranFormat(tgtfmt)) + { + case cmLocalGenerator::FortranFormatFixed: format = "fixed"; break; + case cmLocalGenerator::FortranFormatFree: format = "free"; break; + default: break; + } + if(format) + { + buildSettings->AddAttribute("IFORT_LANG_SRCFMT", + this->CreateString(format)); + } + // Create the INSTALL_PATH attribute. std::string install_name_dir; if(target.GetType() == cmTarget::SHARED_LIBRARY) @@ -1992,6 +2066,9 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) shellBuildPhase->AddAttribute("shellScript", this->CreateString( "# shell script goes here\nexit 0")); + shellBuildPhase->AddAttribute("showEnvVarsInLog", + this->CreateString("0")); + cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXAggregateTarget); target->SetComment(cmtarget.GetName()); @@ -2035,6 +2112,9 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) } } + target->SetId(this->GetOrCreateId( + cmtarget.GetName(), target->GetId()).c_str()); + return target; } @@ -2183,6 +2263,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, target->AddAttribute("productType", this->CreateString(productType)); } target->SetTarget(&cmtarget); + target->SetId(this->GetOrCreateId( + cmtarget.GetName(), target->GetId()).c_str()); return target; } @@ -2205,6 +2287,26 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget* t) return 0; } +//---------------------------------------------------------------------------- +std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name, + const char* id) +{ + std::string guidStoreName = name; + guidStoreName += "_GUID_CMAKE"; + const char* storedGUID = + this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str()); + + if(storedGUID) + { + return storedGUID; + } + + this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(), + id, "Stored Xcode object GUID", cmCacheManager::INTERNAL); + + return id; +} + //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target, cmXCodeObject* dependTarget) @@ -2399,10 +2501,11 @@ void cmGlobalXCodeGenerator { if(this->XcodeVersion > 15) { - // now add the same one but append $(CONFIGURATION) to it: + // Now add the same one but append + // $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) to it: linkDirs += " "; linkDirs += this->XCodeEscapePath( - (*libDir + "/$(CONFIGURATION)").c_str()); + (*libDir + "/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)").c_str()); } linkDirs += " "; linkDirs += this->XCodeEscapePath(libDir->c_str()); @@ -2733,6 +2836,12 @@ void cmGlobalXCodeGenerator this->RootObject = this->CreateObject(cmXCodeObject::PBXProject); this->RootObject->SetComment("Project object"); + + std::string project_id = "PROJECT_"; + project_id += root->GetMakefile()->GetProjectName(); + this->RootObject->SetId(this->GetOrCreateId( + project_id.c_str(), this->RootObject->GetId()).c_str()); + group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); this->RootObject->AddAttribute("mainGroup", this->CreateObjectReference(mainGroup)); @@ -3131,6 +3240,11 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root, } this->WriteXCodePBXProj(fout, root, generators); this->ClearXCodeObjects(); + + // Since this call may have created new cache entries, save the cache: + // + root->GetMakefile()->GetCacheManager()->SaveCache( + root->GetMakefile()->GetHomeOutputDirectory()); } //---------------------------------------------------------------------------- @@ -3173,7 +3287,8 @@ cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout, //---------------------------------------------------------------------------- const char* cmGlobalXCodeGenerator::GetCMakeCFGInitDirectory() { - return this->XcodeVersion >= 21? "$(CONFIGURATION)" : "."; + return this->XcodeVersion >= 21 ? + "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" : "."; } //---------------------------------------------------------------------------- @@ -3402,7 +3517,14 @@ void cmGlobalXCodeGenerator::AppendFlag(std::string& flags, { if(*c == '\'') { - flags += "\\\\'"; + if (this->XcodeVersion >= 40) + { + flags += "'\\\\''"; + } + else + { + flags += "\\\\'"; + } } else if(*c == '\\') { diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 39a5fd722..ed54be3b9 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -123,6 +123,8 @@ private: ); cmXCodeObject* FindXCodeTarget(cmTarget*); + std::string GetOrCreateId(const char* name, const char* id); + // create cmXCodeObject from these functions so that memory can be managed // correctly. All objects created are stored in this->XCodeObjects. cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype); @@ -192,14 +194,16 @@ private: void AppendFlag(std::string& flags, std::string const& flag); protected: - virtual const char* GetInstallTargetName() { return "install"; } - virtual const char* GetPackageTargetName() { return "package"; } + virtual const char* GetInstallTargetName() const { return "install"; } + virtual const char* GetPackageTargetName() const { return "package"; } unsigned int XcodeVersion; std::string VersionString; + std::set XCodeObjectIDs; std::vector XCodeObjects; cmXCodeObject* RootObject; private: + void addObject(cmXCodeObject *obj); std::string PostBuildMakeTarget(std::string const& tName, std::string const& configName); cmXCodeObject* MainGroupChildren; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 33ffbfb3c..ac1c94944 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -101,6 +101,13 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string to1 = toDir + targetNameImport; filesFrom.push_back(from1); filesTo.push_back(to1); + std::string targetNameImportLib; + if(this->Target->GetImplibGNUtoMS(targetNameImport, + targetNameImportLib)) + { + filesFrom.push_back(fromDirConfig + targetNameImportLib); + filesTo.push_back(toDir + targetNameImportLib); + } // An import library looks like a static library. type = cmTarget::STATIC_LIBRARY; @@ -157,6 +164,13 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string to1 = toDir + targetNameImport; filesFrom.push_back(from1); filesTo.push_back(to1); + std::string targetNameImportLib; + if(this->Target->GetImplibGNUtoMS(targetNameImport, + targetNameImportLib)) + { + filesFrom.push_back(fromDirConfig + targetNameImportLib); + filesTo.push_back(toDir + targetNameImportLib); + } // An import library looks like a static library. type = cmTarget::STATIC_LIBRARY; @@ -314,7 +328,11 @@ std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target, if(nameType == NameImplib) { // Use the import library name. - fname = targetNameImport; + if(!target->GetImplibGNUtoMS(targetNameImport, fname, + "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) + { + fname = targetNameImport; + } } else if(nameType == NameReal) { @@ -339,7 +357,11 @@ std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target, if(nameType == NameImplib) { // Use the import library name. - fname = targetNameImport; + if(!target->GetImplibGNUtoMS(targetNameImport, fname, + "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) + { + fname = targetNameImport; + } } else if(nameType == NameSO) { diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h index e5ff4f0f3..aa13589a3 100644 --- a/Source/cmLinkDirectoriesCommand.h +++ b/Source/cmLinkDirectoriesCommand.h @@ -65,7 +65,12 @@ public: "For historical reasons, relative paths given to this command are " "passed to the linker unchanged " "(unlike many CMake commands which interpret them relative to the " - "current source directory)." + "current source directory).\n" + "Note that this command is rarely necessary. Library locations " + "returned by find_package() and find_library() are absolute paths. " + "Pass these absolute library file paths directly to the " + "target_link_libraries() command. CMake will ensure the linker finds " + "them." ; } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7da35eb26..ffbeb4856 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -96,14 +96,14 @@ void cmLocalGenerator::Configure() std::string filesDir = this->Makefile->GetStartOutputDirectory(); filesDir += cmake::GetCMakeFilesDirectory(); cmSystemTools::MakeDirectory(filesDir.c_str()); - + // find & read the list file this->ReadInputFile(); // at the end of the ReadListFile handle any old style subdirs // first get all the subdirectories std::vector subdirs = this->GetChildren(); - + // for each subdir recurse std::vector::iterator sdi = subdirs.begin(); for (; sdi != subdirs.end(); ++sdi) @@ -112,7 +112,7 @@ void cmLocalGenerator::Configure() { this->Makefile->ConfigureSubDirectory(*sdi); } - } + } // Check whether relative paths should be used for optionally // relative paths. @@ -212,10 +212,10 @@ void cmLocalGenerator::ReadInputFile() } void cmLocalGenerator::SetupPathConversions() -{ +{ // Setup the current output directory components for use by // Convert - std::string outdir; + std::string outdir; outdir = cmSystemTools::CollapseFullPath(this->Makefile->GetHomeDirectory()); cmSystemTools::SplitPath(outdir.c_str(), this->HomeDirectoryComponents); @@ -225,12 +225,12 @@ void cmLocalGenerator::SetupPathConversions() outdir = cmSystemTools::CollapseFullPath (this->Makefile->GetHomeOutputDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), + cmSystemTools::SplitPath(outdir.c_str(), this->HomeOutputDirectoryComponents); outdir = cmSystemTools::CollapseFullPath (this->Makefile->GetStartOutputDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), + cmSystemTools::SplitPath(outdir.c_str(), this->StartOutputDirectoryComponents); } @@ -289,17 +289,17 @@ void cmLocalGenerator::GenerateTestFiles() fout.SetCopyIfDifferent(true); fout << "# CMake generated Testfile for " << std::endl - << "# Source directory: " + << "# Source directory: " << this->Makefile->GetStartDirectory() << std::endl - << "# Build directory: " + << "# Build directory: " << this->Makefile->GetStartOutputDirectory() << std::endl << "# " << std::endl << "# This file includes the relevent testing commands " << "required for " << std::endl << "# testing this directory and lists subdirectories to " << "be tested as well." << std::endl; - - const char* testIncludeFile = + + const char* testIncludeFile = this->Makefile->GetProperty("TEST_INCLUDE_FILE"); if ( testIncludeFile ) { @@ -320,7 +320,7 @@ void cmLocalGenerator::GenerateTestFiles() for(i = 0; i < this->Children.size(); ++i) { fout << "SUBDIRS("; - std::string outP = + std::string outP = this->Children[i]->GetMakefile()->GetStartOutputDirectory(); fout << this->Convert(outP.c_str(),START_OUTPUT); fout << ")" << std::endl; @@ -472,7 +472,7 @@ void cmLocalGenerator::GenerateInstallRules() // Ask each install generator to write its code. std::vector const& installers = this->Makefile->GetInstallGenerators(); - for(std::vector::const_iterator + for(std::vector::const_iterator gi = installers.begin(); gi != installers.end(); ++gi) { @@ -553,15 +553,15 @@ void cmLocalGenerator::GenerateTargetManifest() } } -void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, - const char* lang, +void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, + const char* lang, cmSourceFile& source, cmTarget& ) -{ +{ std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname)); objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL); std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL); - std::string sourceFile = + std::string sourceFile = this->Convert(source.GetFullPath().c_str(),START_OUTPUT,SHELL,true); std::string varString = "CMAKE_"; varString += lang; @@ -655,7 +655,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) ofname += "/"; ofname += obj; objVector.push_back(ofname); - this->AddCustomCommandToCreateObject(ofname.c_str(), + this->AddCustomCommandToCreateObject(ofname.c_str(), llang, *(*i), target); objs += this->Convert(ofname.c_str(),START_OUTPUT,MAKEFILE); objs += " "; @@ -672,7 +672,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) // Shared Module: std::string linkLibs; // should be set std::string flags; // should be set - std::string linkFlags; // should be set + std::string linkFlags; // should be set this->GetTargetFlags(linkLibs, flags, linkFlags, target); cmLocalGenerator::RuleVariables vars; vars.Language = llang; @@ -682,17 +682,17 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) vars.LinkLibraries = linkLibs.c_str(); vars.Flags = flags.c_str(); vars.LinkFlags = linkFlags.c_str(); - + std::string langFlags; this->AddLanguageFlags(langFlags, llang, 0); this->AddArchitectureFlags(langFlags, &target, llang, 0); vars.LanguageCompileFlags = langFlags.c_str(); - + cmCustomCommandLines commandLines; std::vector rules; rules.push_back(this->Makefile->GetRequiredDefinition(createRule.c_str())); std::vector commands; - cmSystemTools::ExpandList(rules, commands); + cmSystemTools::ExpandList(rules, commands); for(std::vector::iterator i = commands.begin(); i != commands.end(); ++i) { @@ -728,21 +728,21 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target) (this->Makefile->GetSource(targetFullPath.c_str())); } - + void cmLocalGenerator ::CreateCustomTargetsAndCommands(std::set const& lang) -{ +{ cmTargets &tgts = this->Makefile->GetTargets(); - for(cmTargets::iterator l = tgts.begin(); + for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { cmTarget& target = l->second; switch(target.GetType()) - { + { case cmTarget::STATIC_LIBRARY: case cmTarget::SHARED_LIBRARY: case cmTarget::MODULE_LIBRARY: - case cmTarget::EXECUTABLE: + case cmTarget::EXECUTABLE: { const char* llang = target.GetLinkerLanguage(); if(!llang) @@ -759,7 +759,7 @@ void cmLocalGenerator this->AddBuildTargetRule(llang, target); } } - break; + break; default: break; } @@ -769,14 +769,14 @@ void cmLocalGenerator // List of variables that are replaced when // rules are expanced. These variables are // replaced in the form with GetSafeDefinition(var). -// ${LANG} is replaced in the variable first with all enabled +// ${LANG} is replaced in the variable first with all enabled // languages. static const char* ruleReplaceVars[] = { "CMAKE_${LANG}_COMPILER", "CMAKE_SHARED_LIBRARY_CREATE_${LANG}_FLAGS", "CMAKE_SHARED_MODULE_CREATE_${LANG}_FLAGS", - "CMAKE_SHARED_MODULE_${LANG}_FLAGS", + "CMAKE_SHARED_MODULE_${LANG}_FLAGS", "CMAKE_SHARED_LIBRARY_${LANG}_FLAGS", "CMAKE_${LANG}_LINK_FLAGS", "CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG", @@ -807,7 +807,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, return replaceValues.Flags; } } - + if(replaceValues.Source) { if(variable == "SOURCE") @@ -870,7 +870,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } if(replaceValues.Target) - { + { if(variable == "TARGET_QUOTED") { std::string targetQuoted = replaceValues.Target; @@ -996,7 +996,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } if(variable == "TARGET_TYPE") { - return cmTarget::TargetTypeNames[replaceValues.CMTarget->GetType()]; + return cmTarget::GetTargetTypeName(replaceValues.CMTarget->GetType()); } } if(replaceValues.Output) @@ -1018,13 +1018,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, int pos = 0; while(ruleReplaceVars[pos]) { - for(std::vector::iterator i = enabledLanguages.begin(); - i != enabledLanguages.end(); ++i) - { + for(std::vector::iterator i = enabledLanguages.begin(); + i != enabledLanguages.end(); ++i) + { const char* lang = i->c_str(); std::string actualReplace = ruleReplaceVars[pos]; // If this is the compiler then look for the extra variable - // _COMPILER_ARG1 which must be the first argument to the compiler + // _COMPILER_ARG1 which must be the first argument to the compiler const char* compilerArg1 = 0; if(actualReplace == "CMAKE_${LANG}_COMPILER") { @@ -1038,7 +1038,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } if(actualReplace == variable) { - std::string replace = + std::string replace = this->Makefile->GetSafeDefinition(variable.c_str()); // if the variable is not a FLAG then treat it like a path if(variable.find("_FLAG") == variable.npos) @@ -1062,7 +1062,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, } -void +void cmLocalGenerator::ExpandRuleVariables(std::string& s, const RuleVariables& replaceValues) { @@ -1184,6 +1184,13 @@ cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote, return this->ConvertToOutputForExistingCommon(remotePath, result); } +//---------------------------------------------------------------------------- +std::string +cmLocalGenerator::ConvertToIncludeReference(std::string const& path) +{ + return this->ConvertToOutputForExisting(path.c_str()); +} + //---------------------------------------------------------------------------- const char* cmLocalGenerator::GetIncludeFlags(const char* lang, bool forResponseFile) @@ -1206,7 +1213,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang, std::string flagVar = "CMAKE_INCLUDE_FLAG_"; flagVar += lang; - const char* includeFlag = + const char* includeFlag = this->Makefile->GetSafeDefinition(flagVar.c_str()); flagVar = "CMAKE_INCLUDE_FLAG_SEP_"; flagVar += lang; @@ -1216,7 +1223,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang, { quotePaths = true; } - bool repeatFlag = true; + bool repeatFlag = true; // should the include flag be repeated like ie. -IA -IB if(!sep) { @@ -1285,7 +1292,7 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang, } else { - includePath = this->ConvertToOutputForExisting(i->c_str()); + includePath = this->ConvertToIncludeReference(*i); } if(quotePaths && includePath.size() && includePath[0] != '\"') { @@ -1347,15 +1354,15 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector& dirs, this->Makefile->GetDefinition("VTK_SOURCE_DIR"); if(vtkSourceDir) { - const char* vtk_major = + const char* vtk_major = this->Makefile->GetDefinition("VTK_MAJOR_VERSION"); - const char* vtk_minor = + const char* vtk_minor = this->Makefile->GetDefinition("VTK_MINOR_VERSION"); vtk_major = vtk_major? vtk_major : "4"; vtk_minor = vtk_minor? vtk_minor : "4"; int vmajor = 0; int vminor = 0; - if(sscanf(vtk_major, "%d", &vmajor) && + if(sscanf(vtk_major, "%d", &vmajor) && sscanf(vtk_minor, "%d", &vminor) && vmajor == 4 && vminor <= 4) { includeSourceDir = true; @@ -1396,7 +1403,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector& dirs, } // Get the project-specified include directories. - std::vector& includes = + std::vector& includes = this->Makefile->GetIncludeDirectories(); // Support putting all the in-project include directories first if @@ -1439,40 +1446,51 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, std::string& linkFlags, cmTarget& target) { - std::string buildType = + std::string buildType = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - buildType = cmSystemTools::UpperCase(buildType); - const char* libraryLinkVariable = + buildType = cmSystemTools::UpperCase(buildType); + const char* libraryLinkVariable = "CMAKE_SHARED_LINKER_FLAGS"; // default to shared library - + switch(target.GetType()) { - case cmTarget::STATIC_LIBRARY: + case cmTarget::STATIC_LIBRARY: { - const char* targetLinkFlags = + const char* targetLinkFlags = target.GetProperty("STATIC_LIBRARY_FLAGS"); if(targetLinkFlags) { linkFlags += targetLinkFlags; linkFlags += " "; } + if(!buildType.empty()) + { + std::string build = "STATIC_LIBRARY_FLAGS_"; + build += buildType; + targetLinkFlags = target.GetProperty(build.c_str()); + if(targetLinkFlags) + { + linkFlags += targetLinkFlags; + linkFlags += " "; + } + } } - break; + break; case cmTarget::MODULE_LIBRARY: libraryLinkVariable = "CMAKE_MODULE_LINKER_FLAGS"; case cmTarget::SHARED_LIBRARY: - { + { linkFlags = this->Makefile->GetSafeDefinition(libraryLinkVariable); linkFlags += " "; - if(buildType.size()) + if(!buildType.empty()) { std::string build = libraryLinkVariable; build += "_"; build += buildType; linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += " "; - } - if(this->Makefile->IsOn("WIN32") && + } + if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) { const std::vector& sources = target.GetSourceFiles(); @@ -1482,28 +1500,31 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, cmSourceFile* sf = *i; if(sf->GetExtension() == "def") { - linkFlags += + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); linkFlags += this->Convert(sf->GetFullPath().c_str(), START_OUTPUT, SHELL); linkFlags += " "; } } - } + } const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); if(targetLinkFlags) { linkFlags += targetLinkFlags; linkFlags += " "; - std::string configLinkFlags = targetLinkFlags; + } + if(!buildType.empty()) + { + std::string configLinkFlags = "LINK_FLAGS_"; configLinkFlags += buildType; targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); if(targetLinkFlags) - { + { linkFlags += targetLinkFlags; linkFlags += " "; } - } + } cmOStringStream linklibsStr; this->OutputLinkLibraries(linklibsStr, target, false); linkLibs = linklibsStr.str(); @@ -1511,16 +1532,16 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, break; case cmTarget::EXECUTABLE: { - linkFlags += + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); linkFlags += " "; - if(buildType.size()) + if(!buildType.empty()) { std::string build = "CMAKE_EXE_LINKER_FLAGS_"; build += buildType; linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += " "; - } + } const char* linkLanguage = target.GetLinkerLanguage(); if(!linkLanguage) { @@ -1545,7 +1566,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, if(cmSystemTools::IsOn (this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { - std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + linkLanguage + std::string("_FLAGS"); linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str()); linkFlags += " "; @@ -1558,7 +1579,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, } else { - linkFlags += + linkFlags += this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); linkFlags += " "; } @@ -1566,18 +1587,21 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, if(targetLinkFlags) { linkFlags += targetLinkFlags; - linkFlags += " "; - std::string configLinkFlags = targetLinkFlags; + linkFlags += " "; + } + if(!buildType.empty()) + { + std::string configLinkFlags = "LINK_FLAGS_"; configLinkFlags += buildType; targetLinkFlags = target.GetProperty(configLinkFlags.c_str()); if(targetLinkFlags) - { + { linkFlags += targetLinkFlags; linkFlags += " "; } } } - break; + break; default: break; } @@ -1637,9 +1661,9 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout, const char* linkLanguage = cli.GetLinkLanguage(); - std::string libPathFlag = + std::string libPathFlag = this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); - std::string libPathTerminator = + std::string libPathTerminator = this->Makefile->GetSafeDefinition("CMAKE_LIBRARY_PATH_TERMINATOR"); // Flags to link an executable to shared libraries. @@ -1762,11 +1786,11 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags, { std::vector archs; target->GetAppleArchs(config, archs); - const char* sysroot = + const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT"); - const char* sysrootDefault = + const char* sysrootDefault = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT"); - const char* deploymentTarget = + const char* deploymentTarget = this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); std::string isysrootVar = std::string("CMAKE_") + lang + "_HAS_ISYSROOT"; bool hasIsysroot = this->Makefile->IsOn(isysrootVar.c_str()); @@ -1852,7 +1876,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, if(cmSystemTools::FileIsFullPath(inName)) { std::string tLocation; - if(target->GetType() >= cmTarget::EXECUTABLE && + if(target->GetType() >= cmTarget::EXECUTABLE && target->GetType() <= cmTarget::MODULE_LIBRARY) { tLocation = target->GetLocation(config); @@ -2880,7 +2904,7 @@ std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars, else { cmsysSystem_Shell_GetArgumentForUnix(str, &arg[0], flags); - } + } return std::string(&arg[0]); } @@ -2916,6 +2940,31 @@ std::string cmLocalGenerator::EscapeForCMake(const char* str) return result; } +//---------------------------------------------------------------------------- +cmLocalGenerator::FortranFormat +cmLocalGenerator::GetFortranFormat(const char* value) +{ + FortranFormat format = FortranFormatNone; + if(value && *value) + { + std::vector fmt; + cmSystemTools::ExpandListArgument(value, fmt); + for(std::vector::iterator fi = fmt.begin(); + fi != fmt.end(); ++fi) + { + if(*fi == "FIXED") + { + format = FortranFormatFixed; + } + if(*fi == "FREE") + { + format = FortranFormatFree; + } + } + } + return format; +} + //---------------------------------------------------------------------------- std::string cmLocalGenerator::GetTargetDirectory(cmTarget const&) const @@ -2927,9 +2976,9 @@ cmLocalGenerator::GetTargetDirectory(cmTarget const&) const //---------------------------------------------------------------------------- -void +void cmLocalGenerator::GetTargetObjectFileDirectories(cmTarget* , - std::vector& + std::vector& ) { cmSystemTools::Error("GetTargetObjectFileDirectories" diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index aebf9f39a..0c5b9d074 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -25,7 +25,7 @@ class cmCustomCommand; * \brief Create required build files for a directory. * * Subclasses of this abstract class generate makefiles, DSP, etc for various - * platforms. This class should never be constructued directly. A + * platforms. This class should never be constructed directly. A * GlobalGenerator will create it and invoke the appropriate commands on it. */ class cmLocalGenerator @@ -33,19 +33,19 @@ class cmLocalGenerator public: cmLocalGenerator(); virtual ~cmLocalGenerator(); - + /** - * Generate the makefile for this directory. + * Generate the makefile for this directory. */ virtual void Generate() {} /** * Process the CMakeLists files for this directory to fill in the - * Makefile ivar + * Makefile ivar */ virtual void Configure(); - /** + /** * Calls TraceVSDependencies() on all targets of this generator. */ virtual void TraceDependencies(); @@ -75,22 +75,24 @@ public: ///! Get the makefile for this generator cmMakefile *GetMakefile() { return this->Makefile; }; - + ///! Get the makefile for this generator, const version const cmMakefile *GetMakefile() const { return this->Makefile; }; - + ///! Get the GlobalGenerator this is associated with cmGlobalGenerator *GetGlobalGenerator() { return this->GlobalGenerator; }; + const cmGlobalGenerator *GetGlobalGenerator() const { + return this->GlobalGenerator; }; ///! Set the Global Generator, done on creation by the GlobalGenerator void SetGlobalGenerator(cmGlobalGenerator *gg); - /** - * Convert something to something else. This is a centralized coversion + /** + * Convert something to something else. This is a centralized conversion * routine used by the generators to handle relative paths and the like. - * The flags determine what is actually done. + * The flags determine what is actually done. * * relative: treat the argument as a directory and convert it to make it * relative or full or unchanged. If relative (HOME, START etc) then that @@ -115,7 +117,7 @@ public: * Get path for the specified relative root. */ const char* GetRelativeRootPath(RelativeRoot relroot); - + /** * Convert the given path to an output path that is optionally * relative based on the cache option CMAKE_USE_RELATIVE_PATHS. The @@ -124,14 +126,14 @@ public: */ std::string ConvertToOptionallyRelativeOutputPath(const char* remote); - ///! set/get the parent generator + ///! set/get the parent generator cmLocalGenerator* GetParent(){return this->Parent;} void SetParent(cmLocalGenerator* g) { this->Parent = g; g->AddChild(this); } ///! set/get the children void AddChild(cmLocalGenerator* g) { this->Children.push_back(g); } std::vector& GetChildren() { return this->Children; }; - + void AddArchitectureFlags(std::string& flags, cmTarget* target, const char *lang, const char* config); @@ -141,6 +143,7 @@ public: void AddSharedFlags(std::string& flags, const char* lang, bool shared); void AddConfigVariableFlags(std::string& flags, const char* var, const char* config); + ///! Append flags to a string. virtual void AppendFlags(std::string& flags, const char* newFlags); ///! Get the include flags for the current makefile and language const char* GetIncludeFlags(const char* lang, @@ -177,11 +180,13 @@ public: path and short path if spaces. */ std::string ConvertToOutputForExisting(RelativeRoot remote, const char* local = 0); - + + virtual std::string ConvertToIncludeReference(std::string const& path); + /** Called from command-line hook to clear dependencies. */ - virtual void ClearDependencies(cmMakefile* /* mf */, + virtual void ClearDependencies(cmMakefile* /* mf */, bool /* verbose */) {} - + /** Called from command-line hook to update dependencies. */ virtual bool UpdateDependencies(const char* /* tgtInfo */, bool /*verbose*/, @@ -244,14 +249,22 @@ public: /** Escape the given string as an argument in a CMake script. */ std::string EscapeForCMake(const char* str); + enum FortranFormat + { + FortranFormatNone, + FortranFormatFixed, + FortranFormatFree + }; + FortranFormat GetFortranFormat(const char* value); + /** Return the directories into which object files will be put. * There maybe more than one for fat binary systems like OSX. */ - virtual void + virtual void GetTargetObjectFileDirectories(cmTarget* target, - std::vector& + std::vector& dirs); - + /** * Convert the given remote path to a relative path with respect to * the given local path. The local path must be given in component @@ -307,17 +320,17 @@ public: std::string const& dir_max, bool* hasSourceExtension = 0); -protected: /** Fill out these strings for the given target. Libraries to link, * flags, and linkflags. */ - void GetTargetFlags(std::string& linkLibs, + void GetTargetFlags(std::string& linkLibs, std::string& flags, std::string& linkFlags, cmTarget&target); - + +protected: ///! put all the libraries for a target on into the given stream virtual void OutputLinkLibraries(std::ostream&, cmTarget&, bool relink); - + // Expand rule variables in CMake of the type found in language rules void ExpandRuleVariables(std::string& string, const RuleVariables& replaceValues); @@ -329,13 +342,13 @@ protected: void InsertRuleLauncher(std::string& s, cmTarget* target, const char* prop); - - /** Convert a target to a utility target for unsupported + + /** Convert a target to a utility target for unsupported * languages of a generator */ void AddBuildTargetRule(const char* llang, cmTarget& target); - ///! add a custom command to build a .o file that is part of a target - void AddCustomCommandToCreateObject(const char* ofname, - const char* lang, + ///! add a custom command to build a .o file that is part of a target + void AddCustomCommandToCreateObject(const char* ofname, + const char* lang, cmSourceFile& source, cmTarget& target); // Create Custom Targets and commands for unsupported languages @@ -359,7 +372,7 @@ protected: std::string FindRelativePathTopBinary(); void SetupPathConversions(); - std::string ConvertToLinkReference(std::string const& lib); + virtual std::string ConvertToLinkReference(std::string const& lib); /** Check whether the native build system supports the given definition. Issues a warning. */ diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 5c2cda183..6be3eb92e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -68,8 +68,6 @@ cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3() this->ColorMakefile = false; this->SkipPreprocessedSourceRules = false; this->SkipAssemblySourceRules = false; - this->NativeEchoCommand = "@echo "; - this->NativeEchoWindows = true; this->MakeCommandEscapeTargetTwice = false; this->IsMakefileGenerator = true; this->BorlandMakeCurlyHack = false; @@ -472,6 +470,8 @@ void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() << "SET(CMAKE_CXX_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH})\n"; infoFileStream << "SET(CMAKE_Fortran_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH})\n"; + infoFileStream + << "SET(CMAKE_ASM_INCLUDE_PATH ${CMAKE_C_INCLUDE_PATH})\n"; // Store the include regular expressions for this directory. infoFileStream @@ -609,6 +609,27 @@ cmLocalUnixMakefileGenerator3 } } +//---------------------------------------------------------------------------- +std::string +cmLocalUnixMakefileGenerator3 +::ConvertShellCommand(std::string const& cmd, RelativeRoot root) +{ + if(this->WatcomWMake && + cmSystemTools::FileIsFullPath(cmd.c_str()) && + cmd.find_first_of("( )") != cmd.npos) + { + // On Watcom WMake use the windows short path for the command + // name. This is needed to avoid funny quoting problems on + // lines with shell redirection operators. + std::string scmd; + if(cmSystemTools::GetShortPath(cmd.c_str(), scmd)) + { + return this->Convert(scmd.c_str(), NONE, SHELL); + } + } + return this->Convert(cmd.c_str(), root, SHELL); +} + //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3 @@ -648,13 +669,13 @@ cmLocalUnixMakefileGenerator3 makefileStream << "# The CMake executable.\n" << "CMAKE_COMMAND = " - << this->Convert(cmakecommand.c_str(), FULL, SHELL).c_str() + << this->ConvertShellCommand(cmakecommand, FULL) << "\n" << "\n"; makefileStream << "# The command to remove a file.\n" << "RM = " - << this->Convert(cmakecommand.c_str(),FULL,SHELL).c_str() + << this->ConvertShellCommand(cmakecommand, FULL) << " -E remove -f\n" << "\n"; @@ -664,7 +685,7 @@ cmLocalUnixMakefileGenerator3 makefileStream << "# The program to use to edit the cache.\n" << "CMAKE_EDIT_COMMAND = " - << this->Convert(edit_cmd,FULL,SHELL) << "\n" + << this->ConvertShellCommand(edit_cmd, FULL) << "\n" << "\n"; } @@ -699,7 +720,7 @@ cmLocalUnixMakefileGenerator3 // This should be the first target except for the default_target in // the interface Makefile. this->WriteMakeRule( - makefileStream, "Disable implicit rules so canoncical targets will work.", + makefileStream, "Disable implicit rules so canonical targets will work.", ".SUFFIXES", no_depends, no_commands, false); if(!this->NMake && !this->WatcomWMake && !this->BorlandMakeCurlyHack) @@ -1021,22 +1042,9 @@ cmLocalUnixMakefileGenerator3 // without the current directory being in the search path. cmd = "./" + cmd; } - if(this->WatcomWMake && - cmSystemTools::FileIsFullPath(cmd.c_str()) && - cmd.find(" ") != cmd.npos) - { - // On Watcom WMake use the windows short path for the command - // name. This is needed to avoid funny quoting problems on - // lines with shell redirection operators. - std::string scmd; - if(cmSystemTools::GetShortPath(cmd.c_str(), scmd)) - { - cmd = scmd; - } - } std::string launcher = this->MakeLauncher(cc, target, workingDir? NONE : START_OUTPUT); - cmd = launcher + this->Convert(cmd.c_str(),NONE,SHELL); + cmd = launcher + this->ConvertShellCommand(cmd, NONE); ccg.AppendArguments(c, cmd); if(content) @@ -1235,9 +1243,8 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector& commands, if(color_name.empty()) { // Use the native echo command. - cmd = this->NativeEchoCommand; - cmd += this->EscapeForShell(line.c_str(), false, - this->NativeEchoWindows); + cmd = "@echo "; + cmd += this->EscapeForShell(line.c_str(), false, true); } else { @@ -1279,6 +1286,7 @@ cmLocalUnixMakefileGenerator3 // and there are no "." charactors in the string, then return the // unmodified combination. if((!this->MakefileVariableSize && unmodified.find('.') == s.npos) + && (!this->MakefileVariableSize && unmodified.find('+') == s.npos) && (!this->MakefileVariableSize && unmodified.find('-') == s.npos)) { return unmodified; @@ -1300,6 +1308,7 @@ cmLocalUnixMakefileGenerator3 { cmSystemTools::ReplaceString(ret, ".", "_"); cmSystemTools::ReplaceString(ret, "-", "__"); + cmSystemTools::ReplaceString(ret, "+", "___"); int ni = 0; char buffer[5]; // make sure the _ version is not already used, if @@ -1560,7 +1569,7 @@ cmLocalUnixMakefileGenerator3 // Create the scanner for this language cmDepends *scanner = 0; - if(lang == "C" || lang == "CXX" || lang == "RC") + if(lang == "C" || lang == "CXX" || lang == "RC" || lang == "ASM") { // TODO: Handle RC (resource files) dependencies correctly. scanner = new cmDependsC(this, targetDir, lang.c_str(), &validDeps); diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index 9ff6e5e51..45ac21de3 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -38,21 +38,21 @@ public: /** * Process the CMakeLists files for this directory to fill in the - * Makefile ivar + * Makefile ivar */ virtual void Configure(); /** - * Generate the makefile for this directory. + * Generate the makefile for this directory. */ virtual void Generate(); - + // this returns the relative path between the HomeOutputDirectory and this // local generators StartOutputDirectory const std::string &GetHomeRelativeOutputPath(); - // Write out a make rule + // Write out a make rule void WriteMakeRule(std::ostream& os, const char* comment, const char* target, @@ -60,7 +60,7 @@ public: const std::vector& commands, bool symbolic, bool in_help = false); - + // write the main variables used by the makefiles void WriteMakeVariables(std::ostream& makefileStream); @@ -71,7 +71,7 @@ public: */ void SetPassMakeflags(bool s){this->PassMakeflags = s;} bool GetPassMakeflags() { return this->PassMakeflags; } - + /** * Set the flag used to keep the make program silent. */ @@ -115,7 +115,7 @@ public: void SetDefineWindowsNULL(bool v) {this->DefineWindowsNULL = v;} /** - * If set to true, cd dir && command is used to + * If set to true, cd dir && command is used to * run commands in a different directory. */ void SetUnixCD(bool v) {this->UnixCD = v;} @@ -126,14 +126,6 @@ public: */ void SetSilentNoColon(bool v) {this->SilentNoColon = v;} - /** - * Set the command to use for native make shell echo. The value - * should include all parts of the command up to the beginning of - * the message (including a whitespace separator). - */ - void SetNativeEchoCommand(const char* cmd, bool isWindows) - { this->NativeEchoCommand = cmd; this->NativeEchoWindows = isWindows; } - /** * Set the string used to include one makefile into another default * is include. @@ -169,15 +161,15 @@ public: // used in writing out Cmake files such as WriteDirectoryInformation static void WriteCMakeArgument(std::ostream& os, const char* s); - /** creates the common disclainer text at the top of each makefile */ + /** creates the common disclaimer text at the top of each makefile */ void WriteDisclaimer(std::ostream& os); // write a comment line #====... in the stream void WriteDivider(std::ostream& os); /** used to create a recursive make call */ - std::string GetRecursiveMakeCall(const char *makefile, const char* tgt); - + std::string GetRecursiveMakeCall(const char *makefile, const char* tgt); + // append flags to a string virtual void AppendFlags(std::string& flags, const char* newFlags); @@ -193,7 +185,7 @@ public: virtual std::string GetTargetDirectory(cmTarget const& target) const; // create a command that cds to the start dir then runs the commands - void CreateCDCommand(std::vector& commands, + void CreateCDCommand(std::vector& commands, const char *targetDir, cmLocalGenerator::RelativeRoot returnDir); @@ -208,7 +200,7 @@ public: /** Called from command-line hook to clear dependencies. */ virtual void ClearDependencies(cmMakefile* mf, bool verbose); - + /** write some extra rules such as make test etc */ void WriteSpecialTargetsTop(std::ostream& makefileStream); void WriteSpecialTargetsBottom(std::ostream& makefileStream); @@ -232,7 +224,7 @@ public: // write the target rules for the local Makefile into the stream void WriteLocalAllRules(std::ostream& ruleFileStream); - + struct LocalObjectEntry { cmTarget* Target; @@ -246,7 +238,7 @@ public: bool HasSourceExtension; bool HasPreprocessRule; bool HasAssembleRule; - LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false), + LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false), HasAssembleRule(false) {} }; std::map const& GetLocalObjectFiles() @@ -269,15 +261,15 @@ public: void GetTargetObjectFileDirectories(cmTarget* target, std::vector& dirs); - // Fill the vector with the target names for the object files, - // preprocessed files and assembly files. Currently only used by the + // Fill the vector with the target names for the object files, + // preprocessed files and assembly files. Currently only used by the // Eclipse generator. void GetIndividualFileTargets(std::vector& targets); - + protected: void WriteLocalMakefile(); - - + + // write the target rules for the local Makefile into the stream void WriteLocalMakefileTargets(std::ostream& ruleFileStream, std::set &emitted); @@ -286,17 +278,17 @@ protected: void WriteDirectoryInformationFile(); - // write the depend info + // write the depend info void WriteDependLanguageInfo(std::ostream& cmakefileStream, cmTarget &tgt); - + // write the local help rule void WriteHelpRule(std::ostream& ruleFileStream); - + // this converts a file name that is relative to the StartOuputDirectory // into a full path std::string ConvertToFullPath(const std::string& localPath); - + void WriteConvenienceRule(std::ostream& ruleFileStream, const char* realTarget, const char* helpTarget); @@ -312,7 +304,7 @@ protected: void WriteObjectConvenienceRule(std::ostream& ruleFileStream, const char* comment, const char* output, LocalObjectInfo const& info); - + std::string GetObjectFileName(cmTarget& target, const cmSourceFile& source, std::string* nameWithoutTargetDir = 0, @@ -348,6 +340,7 @@ protected: void CheckMultipleOutputs(bool verbose); private: + std::string ConvertShellCommand(std::string const& cmd, RelativeRoot root); std::string MakeLauncher(const cmCustomCommand& cc, cmTarget* target, RelativeRoot relative); @@ -365,8 +358,6 @@ private: std::string IncludeDirective; std::string MakeSilentFlag; std::string ConfigurationName; - std::string NativeEchoCommand; - bool NativeEchoWindows; bool DefineWindowsNULL; bool UnixCD; bool PassMakeflags; diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 1850c1688..8b22705b3 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -61,7 +61,8 @@ class cmVS10XMLParser : public cmXMLParser //---------------------------------------------------------------------------- -cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator() +cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator(VSVersion v): + cmLocalVisualStudio7Generator(v) { } @@ -93,10 +94,18 @@ void cmLocalVisualStudio10Generator::Generate() for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) { - cmVisualStudio10TargetGenerator tg( - &l->second, static_cast( - this->GetGlobalGenerator())); - tg.Generate(); + if(static_cast(this->GlobalGenerator) + ->TargetIsFortranOnly(l->second)) + { + this->CreateSingleVCProj(l->first.c_str(),l->second); + } + else + { + cmVisualStudio10TargetGenerator tg( + &l->second, static_cast( + this->GetGlobalGenerator())); + tg.Generate(); + } } this->WriteStampFiles(); } diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index 0fccdb071..699de4c00 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -25,7 +25,7 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio10Generator(); + cmLocalVisualStudio10Generator(VSVersion v); virtual ~cmLocalVisualStudio10Generator(); diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 095e1a796..1dfcbea02 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -21,7 +21,8 @@ #include -cmLocalVisualStudio6Generator::cmLocalVisualStudio6Generator() +cmLocalVisualStudio6Generator::cmLocalVisualStudio6Generator(): + cmLocalVisualStudioGenerator(VS6) { } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 7a62b9cb1..11a038763 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -45,9 +45,9 @@ private: extern cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[]; //---------------------------------------------------------------------------- -cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator() +cmLocalVisualStudio7Generator::cmLocalVisualStudio7Generator(VSVersion v): + cmLocalVisualStudioGenerator(v) { - this->Version = 7; this->PlatformName = "Win32"; this->ExtraFlagTable = 0; this->Internal = new cmLocalVisualStudio7GeneratorInternals(this); @@ -68,6 +68,27 @@ void cmLocalVisualStudio7Generator::AddHelperCommands() lang.insert("DEF"); lang.insert("Fortran"); this->CreateCustomTargetsAndCommands(lang); + + // Now create GUIDs for targets + cmTargets &tgts = this->Makefile->GetTargets(); + + cmGlobalVisualStudio7Generator* gg = + static_cast(this->GlobalGenerator); + for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) + { + const char* path = l->second.GetProperty("EXTERNAL_MSPROJECT"); + if(path) + { + this->ReadAndStoreExternalGUID( + l->second.GetName(), path); + } + else + { + gg->CreateGUID(l->first.c_str()); + } + } + + this->FixGlobalTargets(); } @@ -202,6 +223,14 @@ void cmLocalVisualStudio7Generator this->FortranProject = static_cast(this->GlobalGenerator) ->TargetIsFortranOnly(target); + + // Intel Fortran for VS10 uses VS9 format ".vfproj" files. + VSVersion realVersion = this->Version; + if(this->FortranProject && this->Version >= VS10) + { + this->Version = VS9; + } + // add to the list of projects std::string pname = lname; target.SetProperty("GENERATOR_FILE_NAME",lname); @@ -229,6 +258,8 @@ void cmLocalVisualStudio7Generator { this->GlobalGenerator->FileReplacedDuringGenerate(fname); } + + this->Version = realVersion; } //---------------------------------------------------------------------------- @@ -309,6 +340,8 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFortranFlagTable[] = { {"Preprocess", "fpp", "Run Preprocessor on files", "preprocessYes", 0}, {"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "true", 0}, + {"SourceFileFormat", "fixed", "Use Fixed Format", "fileFormatFixed", 0}, + {"SourceFileFormat", "free", "Use Free Format", "fileFormatFree", 0}, {"DebugInformationFormat", "Zi", "full debug", "debugEnabled", 0}, {"DebugInformationFormat", "debug:full", "full debug", "debugEnabled", 0}, {"DebugInformationFormat", "Z7", "c7 compat", "debugOldStyleInfo", 0}, @@ -666,6 +699,16 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, } } + if(this->FortranProject) + { + switch(this->GetFortranFormat(target.GetProperty("Fortran_FORMAT"))) + { + case FortranFormatFixed: flags += " -fixed"; break; + case FortranFormatFree: flags += " -free"; break; + default: break; + } + } + // Add the target-specific flags. if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS")) { @@ -686,7 +729,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, t = Options::FortranCompiler; table = cmLocalVisualStudio7GeneratorFortranFlagTable; } - Options targetOptions(this, this->Version, t, + Options targetOptions(this, t, table, this->ExtraFlagTable); targetOptions.FixExceptionHandlingDefault(); @@ -825,6 +868,13 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, tool = "VFMIDLTool"; } fout << "\t\t\tConvertToXMLOutputPath(i->c_str()); + fout << ipath << ";"; + } + fout << "\"\n"; fout << "\t\t\t\tMkTypLibCompatible=\"FALSE\"\n"; if( this->PlatformName == "x64" ) { @@ -848,7 +898,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, // end of Version >= 8) + if(targetBuilds && this->Version >= VS8) { // Check the filesystem type where the target will be written. if(cmLVS6G_IsFAT(target.GetDirectory(configName).c_str())) @@ -935,7 +985,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, extraLinkOptions += " "; extraLinkOptions += targetLinkFlags; } - Options linkOptions(this, this->Version, Options::Linker, + Options linkOptions(this, Options::Linker, cmLocalVisualStudio7GeneratorLinkFlagTable); linkOptions.Parse(extraLinkOptions.c_str()); if(!this->ModuleDefinitionFile.empty()) @@ -1279,7 +1329,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, fout << "\t\n"; // Write the VCProj file's footer. - this->WriteVCProjFooter(fout); + this->WriteVCProjFooter(fout, target); } struct cmLVS7GFileConfig @@ -1333,6 +1383,21 @@ cmLocalVisualStudio7GeneratorFCInfo fc.CompileFlags = cflags; needfc = true; } + if(lg->FortranProject) + { + switch(lg->GetFortranFormat(sf.GetProperty("Fortran_FORMAT"))) + { + case cmLocalGenerator::FortranFormatFixed: + fc.CompileFlags = "-fixed " + fc.CompileFlags; + needfc = true; + break; + case cmLocalGenerator::FortranFormatFree: + fc.CompileFlags = "-free " + fc.CompileFlags; + needfc = true; + break; + default: break; + } + } if(const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS")) { fc.CompileDefs = cdefs; @@ -1541,8 +1606,15 @@ void cmLocalVisualStudio7Generator !fc.CompileDefs.empty() || !fc.CompileDefsConfig.empty()) { - Options fileOptions(this, this->Version, Options::Compiler, - cmLocalVisualStudio7GeneratorFlagTable, + Options::Tool tool = Options::Compiler; + cmVS7FlagTable const* table = + cmLocalVisualStudio7GeneratorFlagTable; + if(this->FortranProject) + { + tool = Options::FortranCompiler; + table = cmLocalVisualStudio7GeneratorFortranFlagTable; + } + Options fileOptions(this, tool, table, this->ExtraFlagTable); fileOptions.Parse(fc.CompileFlags.c_str()); fileOptions.AddDefines(fc.CompileDefs.c_str()); @@ -1622,6 +1694,10 @@ WriteCustomRule(std::ostream& fout, } std::string script = this->ConstructScript(command, i->c_str()); + if(this->FortranProject) + { + cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str()); + } fout << "\t\t\t\t\t\n" << "Version == 71) + if(this->Version == VS71) { fout << "\tVersion=\"7.10\"\n"; } else { - fout << "\tVersion=\"" << this->Version << ".00\"\n"; + fout << "\tVersion=\"" << (this->Version/10) << ".00\"\n"; } const char* projLabel = target.GetProperty("PROJECT_LABEL"); if(!projLabel) @@ -1868,7 +1951,7 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, cmGlobalVisualStudio7Generator* gg = static_cast(this->GlobalGenerator); fout << "\tName=\"" << projLabel << "\"\n"; - if(this->Version >= 8) + if(this->Version >= VS8) { fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n"; } @@ -1880,10 +1963,28 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, } -void cmLocalVisualStudio7Generator::WriteVCProjFooter(std::ostream& fout) +void cmLocalVisualStudio7Generator::WriteVCProjFooter(std::ostream& fout, + cmTarget &target) { - fout << "\t\n" - << "\t\n" + fout << "\t\n"; + + cmPropertyMap const& props = target.GetProperties(); + for(cmPropertyMap::const_iterator i = props.begin(); i != props.end(); ++i) + { + if(i->first.find("VS_GLOBAL_") == 0) + { + std::string name = i->first.substr(10); + if(name != "") + { + fout << "\t\tsecond.GetValue() << "\"\n" + << "\t\t/>\n"; + } + } + } + + fout << "\t\n" << "\n"; } @@ -2003,29 +2104,6 @@ void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID( } -void cmLocalVisualStudio7Generator::ConfigureFinalPass() -{ - cmLocalGenerator::ConfigureFinalPass(); - cmTargets &tgts = this->Makefile->GetTargets(); - - cmGlobalVisualStudio7Generator* gg = - static_cast(this->GlobalGenerator); - for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) - { - const char* path = l->second.GetProperty("EXTERNAL_MSPROJECT"); - if(path) - { - this->ReadAndStoreExternalGUID( - l->second.GetName(), path); - } - else - { - gg->CreateGUID(l->first.c_str()); - } - } - -} - //---------------------------------------------------------------------------- std::string cmLocalVisualStudio7Generator ::GetTargetDirectory(cmTarget const& target) const diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 160e2d493..5b634b8c6 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -35,7 +35,7 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator { public: ///! Set cache only and recurse to false by default. - cmLocalVisualStudio7Generator(); + cmLocalVisualStudio7Generator(VSVersion v); virtual ~cmLocalVisualStudio7Generator(); @@ -53,11 +53,7 @@ public: */ void SetBuildType(BuildType,const char *name); - void SetVersion71() {this->Version = 71;} - void SetVersion8() {this->Version = 8;} - void SetVersion9() {this->Version = 9;} void SetPlatformName(const char* n) { this->PlatformName = n;} - virtual void ConfigureFinalPass(); void GetTargetObjectFileDirectories(cmTarget* target, std::vector& dirs); @@ -75,6 +71,8 @@ public: virtual void ReadAndStoreExternalGUID(const char* name, const char* path); +protected: + void CreateSingleVCProj(const char *lname, cmTarget &tgt); private: typedef cmVisualStudioGeneratorOptions Options; typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo; @@ -84,8 +82,7 @@ private: void WriteProjectFiles(); void WriteVCProjHeader(std::ostream& fout, const char *libName, cmTarget &tgt, std::vector &sgs); - void WriteVCProjFooter(std::ostream& fout); - void CreateSingleVCProj(const char *lname, cmTarget &tgt); + void WriteVCProjFooter(std::ostream& fout, cmTarget &target); void WriteVCProjFile(std::ostream& fout, const char *libName, cmTarget &tgt); void WriteConfigurations(std::ostream& fout, @@ -130,7 +127,6 @@ private: cmVS7FlagTable const* ExtraFlagTable; std::string ModuleDefinitionFile; - int Version; bool FortranProject; std::string PlatformName; // Win32 or x64 cmLocalVisualStudio7GeneratorInternals* Internal; diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 4390a08a7..de1ac30fe 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -18,10 +18,11 @@ #include "windows.h" //---------------------------------------------------------------------------- -cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator() +cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator(VSVersion v) { this->WindowsShell = true; this->WindowsVSIDE = true; + this->Version = v; } //---------------------------------------------------------------------------- @@ -249,6 +250,20 @@ cmLocalVisualStudioGenerator // Add this command line. std::string cmd = ccg.GetCommand(c); + + // Use "call " before any invocations of .bat or .cmd files + // invoked as custom commands. + // + std::string suffix; + if (cmd.size() > 4) + { + suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size()-4)); + if (suffix == ".bat" || suffix == ".cmd") + { + script += "call "; + } + } + script += this->Convert(cmd.c_str(), relativeRoot, SHELL); ccg.AppendArguments(c, script); diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index a38bc30bf..fcf1f21f0 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -29,7 +29,19 @@ class cmCustomCommand; class cmLocalVisualStudioGenerator : public cmLocalGenerator { public: - cmLocalVisualStudioGenerator(); + /** Known versions of Visual Studio. */ + enum VSVersion + { + VS6 = 60, + VS7 = 70, + VS71 = 71, + VS8 = 80, + VS9 = 90, + VS10 = 100, + VS11 = 110 + }; + + cmLocalVisualStudioGenerator(VSVersion v); virtual ~cmLocalVisualStudioGenerator(); /** Construct a script from the given list of command lines. */ @@ -41,6 +53,9 @@ public: sequence of custom commands. */ const char* GetReportErrorLabel() const; + /** Version of Visual Studio. */ + VSVersion GetVersion() const { return this->Version; } + protected: virtual const char* ReportErrorLabel() const; virtual bool CustomCommandUseLocal() const { return false; } @@ -58,6 +73,8 @@ protected: std::map& count); std::set NeedObjectName; friend class cmVisualStudio10TargetGenerator; + + VSVersion Version; }; #endif diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 63bf03bdd..7939d7322 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -384,7 +384,9 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, // Decide whether to invoke the command. if(pcmd->GetEnabled() && !cmSystemTools::GetFatalErrorOccured() && - (!this->GetCMakeInstance()->GetScriptMode() || pcmd->IsScriptable())) + (this->GetCMakeInstance()->GetWorkingMode() != cmake::SCRIPT_MODE + || pcmd->IsScriptable())) + { // if trace is one, print out invoke information if(this->GetCMakeInstance()->GetTrace()) @@ -411,7 +413,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, this->IssueMessage(cmake::FATAL_ERROR, pcmd->GetError()); } result = false; - if ( this->GetCMakeInstance()->GetScriptMode() ) + if ( this->GetCMakeInstance()->GetWorkingMode() != cmake::NORMAL_MODE) { cmSystemTools::SetFatalErrorOccured(); } @@ -422,7 +424,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, this->UsedCommands.push_back(pcmd.release()); } } - else if ( this->GetCMakeInstance()->GetScriptMode() + else if ( this->GetCMakeInstance()->GetWorkingMode() == cmake::SCRIPT_MODE && !pcmd->IsScriptable() ) { std::string error = "Command "; @@ -1377,7 +1379,7 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target, { cmOStringStream e; e << "Target \"" << lib << "\" of type " - << cmTarget::TargetTypeNames[static_cast(tgt->GetType())] + << cmTarget::GetTargetTypeName(tgt->GetType()) << " 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."; @@ -1759,6 +1761,10 @@ void cmMakefile::AddDefinition(const char* name, bool value) void cmMakefile::CheckForUnusedVariables() const { + if (!this->WarnUnused) + { + return; + } const cmDefinitions& defs = this->Internal->VarStack.top(); const std::set& locals = defs.LocalKeys(); std::set::const_iterator it = locals.begin(); @@ -1882,7 +1888,7 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target) } -void cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, +cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, const std::vector &srcs, bool excludeFromAll) { @@ -1905,6 +1911,7 @@ void cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, } target->AddSources(srcs); this->AddGlobalLinkInformation(lname, *target); + return target; } cmTarget* cmMakefile::AddExecutable(const char *exeName, @@ -3020,8 +3027,15 @@ cmCacheManager *cmMakefile::GetCacheManager() const void cmMakefile::DisplayStatus(const char* message, float s) { - this->GetLocalGenerator()->GetGlobalGenerator() - ->GetCMakeInstance()->UpdateProgress(message, s); + cmake* cm = this->GetLocalGenerator()->GetGlobalGenerator() + ->GetCMakeInstance(); + if (cm->GetWorkingMode() == cmake::FIND_PACKAGE_MODE) + { + // don't output any STATUS message in FIND_PACKAGE_MODE, since they will + // directly be fed to the compiler, which will be confused. + return; + } + cm->UpdateProgress(message, s); } std::string cmMakefile::GetModulesFile(const char* filename) @@ -3199,7 +3213,8 @@ void cmMakefile::ConfigureString(const std::string& input, } int cmMakefile::ConfigureFile(const char* infile, const char* outfile, - bool copyonly, bool atOnly, bool escapeQuotes) + bool copyonly, bool atOnly, bool escapeQuotes, + const cmNewLineStyle& newLine) { int res = 1; if ( !this->CanIWriteThisFile(outfile) ) @@ -3236,9 +3251,20 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, } else { + std::string newLineCharacters; + std::ios_base::openmode omode = std::ios_base::out | std::ios_base::trunc; + if (newLine.IsValid()) + { + newLineCharacters = newLine.GetCharacters(); + omode |= std::ios::binary; + } + else + { + newLineCharacters = "\n"; + } std::string tempOutputFile = soutfile; tempOutputFile += ".tmp"; - std::ofstream fout(tempOutputFile.c_str()); + std::ofstream fout(tempOutputFile.c_str(), omode); if(!fout) { cmSystemTools::Error( @@ -3263,7 +3289,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile, { outLine = ""; this->ConfigureString(inLine, outLine, atOnly, escapeQuotes); - fout << outLine.c_str() << "\n"; + fout << outLine.c_str() << newLineCharacters; } // close the files before attempting to copy fin.close(); @@ -3332,7 +3358,8 @@ void cmMakefile::SetProperty(const char* prop, const char* value) this->Properties.SetProperty(prop,value,cmProperty::DIRECTORY); } -void cmMakefile::AppendProperty(const char* prop, const char* value) +void cmMakefile::AppendProperty(const char* prop, const char* value, + bool asString) { if (!prop) { @@ -3365,7 +3392,7 @@ void cmMakefile::AppendProperty(const char* prop, const char* value) return; } - this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY); + this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY,asString); } const char *cmMakefile::GetPropertyOrDefinition(const char* prop) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1c1aef3c0..123678783 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -19,6 +19,7 @@ #include "cmPropertyMap.h" #include "cmSystemTools.h" #include "cmTarget.h" +#include "cmNewLineStyle.h" #include "cmake.h" #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -72,7 +73,7 @@ public: /** Return whether compatibility features needed for a version of the cache or lower should be enabled. */ bool NeedCacheCompatibility(int major, int minor); - + /** * Construct an empty makefile. */ @@ -87,8 +88,8 @@ public: /** * Read and parse a CMakeLists.txt file. */ - bool ReadListFile(const char* listfile, - const char* external= 0, + bool ReadListFile(const char* listfile, + const char* external= 0, std::string* fullPath= 0, bool noPolicyScope = true); @@ -121,21 +122,21 @@ public: * Try running cmake and building a file. This is used for dynalically * loaded commands, not as part of the usual build process. */ - int TryCompile(const char *srcdir, const char *bindir, + int TryCompile(const char *srcdir, const char *bindir, const char *projectName, const char *targetName, bool fast, const std::vector *cmakeArgs, std::string *output); - + /** * Specify the makefile generator. This is platform/compiler * dependent, although the interface is through a generic * superclass. */ void SetLocalGenerator(cmLocalGenerator*); - + ///! Get the current makefile generator. - cmLocalGenerator* GetLocalGenerator() + cmLocalGenerator* GetLocalGenerator() { return this->LocalGenerator;} /** @@ -153,15 +154,15 @@ public: /** * Perform FinalPass, Library dependency analysis etc before output of the - * makefile. + * makefile. */ void ConfigureFinalPass(); - + /** * run the final pass on all commands. */ void FinalPass(); - + /** * Print the object state to std::cout. */ @@ -205,11 +206,11 @@ public: cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type); cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name); - + /** * Add an executable to the build. */ - cmTarget* AddExecutable(const char *exename, + cmTarget* AddExecutable(const char *exename, const std::vector &srcs, bool excludeFromAll = false); @@ -237,7 +238,7 @@ public: */ void AddLinkLibrary(const char*); void AddLinkLibrary(const char*, cmTarget::LinkLibraryType type); - void AddLinkLibraryForTarget(const char *tgt, const char*, + void AddLinkLibraryForTarget(const char *tgt, const char*, cmTarget::LinkLibraryType type); void AddLinkDirectoryForTarget(const char *tgt, const char* d); @@ -265,9 +266,9 @@ public: /** * Add a subdirectory to the build. */ - void AddSubDirectory(const char*, bool excludeFromAll=false, + void AddSubDirectory(const char*, bool excludeFromAll=false, bool preorder = false); - void AddSubDirectory(const char* fullSrcDir,const char *fullBinDir, + void AddSubDirectory(const char* fullSrcDir,const char *fullBinDir, bool excludeFromAll, bool preorder, bool immediate); @@ -275,7 +276,7 @@ public: * Configure a subdirectory */ void ConfigureSubDirectory(cmLocalGenerator *); - + /** * Add an include directory to the build. */ @@ -287,13 +288,13 @@ public: */ void AddDefinition(const char* name, const char* value); ///! Add a definition to this makefile and the global cmake cache. - void AddCacheDefinition(const char* name, const char* value, + void AddCacheDefinition(const char* name, const char* value, const char* doc, cmCacheManager::CacheEntryType type, bool force = false); /** - * Add bool variable definition to the build. + * Add bool variable definition to the build. */ void AddDefinition(const char* name, bool); @@ -304,7 +305,7 @@ public: void RemoveDefinition(const char* name); ///! Remove a definition from the cache. void RemoveCacheDefinition(const char* name); - + /** * Specify the name of the project for this build. */ @@ -325,7 +326,7 @@ public: /** * Set the name of the library. */ - void AddLibrary(const char *libname, cmTarget::TargetType type, + cmTarget* AddLibrary(const char *libname, cmTarget::TargetType type, const std::vector &srcs, bool excludeFromAll = false); @@ -339,14 +340,14 @@ public: * Add a source group for consideration when adding a new source. * name is tokenized. */ - void AddSourceGroup(const std::vector& name, + void AddSourceGroup(const std::vector& name, const char* regex=0); #endif //@{ /** - * Set, Push, Pop policy values for CMake. + * Set, Push, Pop policy values for CMake. */ bool SetPolicy(cmPolicies::PolicyID id, cmPolicies::PolicyStatus status); bool SetPolicy(const char *id, cmPolicies::PolicyStatus status); @@ -374,31 +375,31 @@ public: * Get the Policies Instance */ cmPolicies *GetPolicies(); - + /** * Add an auxiliary directory to the build. */ void AddExtraDirectory(const char* dir); - + /** * Add an auxiliary directory to the build. */ void MakeStartDirectoriesCurrent() { - this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", + this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", this->cmStartDirectory.c_str()); - this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", + this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", this->StartOutputDirectory.c_str()); } - + //@{ /** * Set/Get the home directory (or output directory) in the project. The * home directory is the top directory of the project. It is where * CMakeSetup or configure was run. Remember that CMake processes * CMakeLists files by recursing up the tree starting at the StartDirectory - * and going up until it reaches the HomeDirectory. + * and going up until it reaches the HomeDirectory. */ void SetHomeDirectory(const char* dir); const char* GetHomeDirectory() const @@ -428,15 +429,15 @@ public: * is the directory of the CMakeLists.txt file that started the current * round of processing. Remember that CMake processes CMakeLists files by * recursing up the tree starting at the StartDirectory and going up until - * it reaches the HomeDirectory. + * it reaches the HomeDirectory. */ - void SetStartDirectory(const char* dir) + void SetStartDirectory(const char* dir) { this->cmStartDirectory = dir; cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory); - this->cmStartDirectory = + this->cmStartDirectory = cmSystemTools::CollapseFullPath(this->cmStartDirectory.c_str()); - this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", + this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR", this->cmStartDirectory.c_str()); } const char* GetStartDirectory() const @@ -447,10 +448,10 @@ public: { this->StartOutputDirectory = lib; cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory); - this->StartOutputDirectory = + this->StartOutputDirectory = cmSystemTools::CollapseFullPath(this->StartOutputDirectory.c_str()); cmSystemTools::MakeDirectory(this->StartOutputDirectory.c_str()); - this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", + this->AddDefinition("CMAKE_CURRENT_BINARY_DIR", this->StartOutputDirectory.c_str()); } const char* GetStartOutputDirectory() const @@ -459,7 +460,7 @@ public: } //@} - const char* GetCurrentDirectory() const + const char* GetCurrentDirectory() const { return this->cmStartDirectory.c_str(); } @@ -478,7 +479,7 @@ public: //@} - /** + /** * Set a regular expression that include files must match * in order to be considered as part of the depend information. */ @@ -487,11 +488,11 @@ public: this->IncludeFileRegularExpression = regex; } const char* GetIncludeRegularExpression() - { + { return this->IncludeFileRegularExpression.c_str(); } - /** + /** * Set a regular expression that include files that are not found * must match in order to be considered a problem. */ @@ -523,11 +524,11 @@ public: * Get a list of include directories in the build. */ std::vector& GetIncludeDirectories() - { + { return this->IncludeDirectories; } const std::vector& GetIncludeDirectories() const - { + { return this->IncludeDirectories; } void SetIncludeDirectories(const std::vector& vec) @@ -542,7 +543,7 @@ public: bool IsSystemIncludeDirectory(const char* dir); /** Expand out any arguements in the vector that have ; separated - * strings into multiple arguements. A new vector is created + * strings into multiple arguements. A new vector is created * containing the expanded versions of all arguments in argsIn. * This method differes from the one in cmSystemTools in that if * the CmakeLists file is version 1.2 or earlier it will check for @@ -558,7 +559,7 @@ public: cmSourceFile* GetSource(const char* sourceName); /** Get a cmSourceFile pointer for a given source name, if the name is - * not found, then create the source file and return it. generated + * not found, then create the source file and return it. generated * indicates if it is a generated file, this is used in determining * how to create the source file instance e.g. name */ @@ -597,8 +598,8 @@ public: * variables will be listed. */ std::vector GetDefinitions(int cacheonly=0) const; - - /** Test a boolean cache entry to see if it is true or false, + + /** Test a boolean cache entry to see if it is true or false, * returns false if no entry defined. */ bool IsOn(const char* name) const; @@ -617,13 +618,13 @@ public: * Make sure CMake can write this file */ bool CanIWriteThisFile(const char* fileName); - + /** * Get the vector of used command instances. */ const std::vector& GetUsedCommands() const {return this->UsedCommands;} - + #if defined(CMAKE_BUILD_WITH_CMAKE) /** * Get the vector source groups. @@ -663,12 +664,12 @@ public: { return this->OutputFiles; } void AddCMakeOutputFile(const char* file) { this->OutputFiles.push_back(file);} - + /** - * Expand all defined variables in the string. + * Expand all defined variables in the string. * Defined variables come from the this->Definitions map. * They are expanded with ${var} where var is the - * entry in the this->Definitions map. Also @var@ is + * entry in the this->Definitions map. Also \@var\@ is * expanded to match autoconf style expansions. */ const char *ExpandVariablesInString(std::string& source); @@ -682,15 +683,15 @@ public: /** * Remove any remaining variables in the string. Anything with ${var} or - * @var@ will be removed. + * \@var\@ will be removed. */ - void RemoveVariablesInString(std::string& source, + void RemoveVariablesInString(std::string& source, bool atOnly = false) const; /** * Expand variables in the makefiles ivars such as link directories etc */ - void ExpandVariables(); + void ExpandVariables(); /** * Replace variables and #cmakedefine lines in the given string. @@ -702,8 +703,10 @@ public: /** * Copy file but change lines acording to ConfigureString */ - int ConfigureFile(const char* infile, const char* outfile, - bool copyonly, bool atOnly, bool escapeQuotes); + int ConfigureFile(const char* infile, const char* outfile, + bool copyonly, bool atOnly, bool escapeQuotes, + const cmNewLineStyle& = cmNewLineStyle()); + #if defined(CMAKE_BUILD_WITH_CMAKE) /** @@ -717,12 +720,12 @@ public: * Execute a single CMake command. Returns true if the command * succeeded or false if it failed. */ - bool ExecuteCommand(const cmListFileFunction& lff, + bool ExecuteCommand(const cmListFileFunction& lff, cmExecutionStatus &status); /** Check if a command exists. */ bool CommandExists(const char* name) const; - + /** * Add a command to this cmake instance */ @@ -748,7 +751,7 @@ public: ///! Display progress or status message. void DisplayStatus(const char*, float); - + /** * Expand the given list file arguments into the full set after * variable replacement and list expansion. @@ -757,13 +760,13 @@ public: std::vector& outArgs); /** * Get the instance - */ + */ cmake *GetCMakeInstance() const; /** * Get all the source files this makefile knows about */ - const std::vector &GetSourceFiles() const + const std::vector &GetSourceFiles() const {return this->SourceFiles;} std::vector &GetSourceFiles() {return this->SourceFiles;} @@ -775,7 +778,7 @@ public: /** * Add a macro to the list of macros. The arguments should be name of the - * macro and a documentation signature of it + * macro and a documentation signature of it */ void AddMacro(const char* name, const char* signature); @@ -797,9 +800,9 @@ public: */ std::string GetModulesFile(const char* name); - ///! Set/Get a property of this directory + ///! Set/Get a property of this directory void SetProperty(const char *prop, const char *value); - void AppendProperty(const char *prop, const char *value); + void AppendProperty(const char *prop, const char *value,bool asString=false); const char *GetProperty(const char *prop); const char *GetPropertyOrDefinition(const char *prop); const char *GetProperty(const char *prop, cmProperty::ScopeType scope); @@ -812,7 +815,7 @@ public: ///! Initialize a makefile from its parent void InitializeFromParent(); - + ///! Set/Get the preorder flag void SetPreOrder(bool p) { this->PreOrder = p; } bool GetPreOrder() const { return this->PreOrder; } @@ -859,11 +862,11 @@ protected: void CheckForUnused(const char* reason, const char* name) const; std::string Prefix; - std::vector AuxSourceDirectories; // + std::vector AuxSourceDirectories; // - std::string cmStartDirectory; - std::string StartOutputDirectory; - std::string cmHomeDirectory; + std::string cmStartDirectory; + std::string StartOutputDirectory; + std::string cmHomeDirectory; std::string HomeOutputDirectory; std::string cmCurrentListFile; @@ -875,7 +878,7 @@ protected: // Tests std::map Tests; - + // The include and link-library paths. These may have order // dependency, so they must be vectors (not set). std::vector IncludeDirectories; @@ -887,8 +890,8 @@ protected: std::vector ListFiles; // list of command files loaded std::vector OutputFiles; // list of command files loaded - - + + cmTarget::LinkLibraryVectorType LinkLibraries; std::vector InstallGenerators; @@ -911,9 +914,9 @@ protected: std::vector UsedCommands; cmLocalGenerator* LocalGenerator; - bool IsFunctionBlocked(const cmListFileFunction& lff, + bool IsFunctionBlocked(const cmListFileFunction& lff, cmExecutionStatus &status); - + private: void Initialize(); @@ -923,10 +926,10 @@ private: void ReadSources(std::ifstream& fin, bool t); friend class cmMakeDepend; // make depend needs direct access - // to the Sources array - void PrintStringVector(const char* s, const + // to the Sources array + void PrintStringVector(const char* s, const std::vector >& v) const; - void PrintStringVector(const char* s, + void PrintStringVector(const char* s, const std::vector& v) const; void AddDefaultDefinitions(); @@ -954,7 +957,7 @@ private: bool WarnUnused; bool CheckSystemVars; - // stack of list files being read + // stack of list files being read std::deque ListFileStack; // stack of commands being invoked. diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index cd75d7977..78278cbbf 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -241,6 +241,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) exeCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); + std::string implib; + if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib)) + { + exeCleanFiles.push_back(this->Convert(implib.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); + } } // List the PDB for cleaning only when the whole target is @@ -270,8 +277,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_LINK_EXECUTABLE"; - std::string linkRule = - this->Makefile->GetRequiredDefinition(linkRuleVar.c_str()); + std::string linkRule = this->GetLinkRule(linkRuleVar.c_str()); std::vector commands1; cmSystemTools::ExpandListArgument(linkRule, real_link_commands); if(this->Target->IsExecutableWithExports()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 31f7be5cf..b4174cc36 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -512,6 +512,13 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules libCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(), cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); + std::string implib; + if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib)) + { + libCleanFiles.push_back(this->Convert(implib.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::UNCHANGED)); + } } // List the PDB for cleaning only when the whole target is @@ -772,7 +779,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules else { // Get the set of commands. - std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar); + std::string linkRule = this->GetLinkRule(linkRuleVar); cmSystemTools::ExpandListArgument(linkRule, real_link_commands); // Expand placeholders. diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d0df8f076..a3a832bc8 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -501,6 +501,35 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) ); } +//---------------------------------------------------------------------------- +void +cmMakefileTargetGenerator +::AppendFortranFormatFlags(std::string& flags, cmSourceFile& source) +{ + const char* srcfmt = source.GetProperty("Fortran_FORMAT"); + cmLocalGenerator::FortranFormat format = + this->LocalGenerator->GetFortranFormat(srcfmt); + if(format == cmLocalGenerator::FortranFormatNone) + { + const char* tgtfmt = this->Target->GetProperty("Fortran_FORMAT"); + format = this->LocalGenerator->GetFortranFormat(tgtfmt); + } + const char* var = 0; + switch (format) + { + case cmLocalGenerator::FortranFormatFixed: + var = "CMAKE_Fortran_FORMAT_FIXED_FLAG"; break; + case cmLocalGenerator::FortranFormatFree: + var = "CMAKE_Fortran_FORMAT_FREE_FLAG"; break; + default: break; + } + if(var) + { + this->LocalGenerator->AppendFlags( + flags, this->Makefile->GetDefinition(var)); + } +} + //---------------------------------------------------------------------------- void cmMakefileTargetGenerator @@ -562,6 +591,12 @@ cmMakefileTargetGenerator } } + // Add Fortran format flags. + if(strcmp(lang, "Fortran") == 0) + { + this->AppendFortranFormatFlags(flags, source); + } + // Add flags from source file properties. if (source.GetProperty("COMPILE_FLAGS")) { @@ -1598,6 +1633,23 @@ void cmMakefileTargetGenerator } } +//---------------------------------------------------------------------------- +std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar) +{ + std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar); + if(this->Target->HasImplibGNUtoMS()) + { + std::string ruleVar = "CMAKE_"; + ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); + ruleVar += "_GNUtoMS_RULE"; + if(const char* rule = this->Makefile->GetDefinition(ruleVar.c_str())) + { + linkRule += rule; + } + } + return linkRule; +} + //---------------------------------------------------------------------------- void cmMakefileTargetGenerator ::CloseFileStreams() diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index b68f8bf3b..8fba13f6e 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -112,12 +112,17 @@ protected: // Return the a string with -F flags on apple std::string GetFrameworkFlags(); + void AppendFortranFormatFlags(std::string& flags, cmSourceFile& source); + // append intertarget dependencies void AppendTargetDepends(std::vector& depends); // Append link rule dependencies (objects, etc.). void AppendLinkDepends(std::vector& depends); + // Lookup the link rule for this target. + std::string GetLinkRule(const char* linkRuleVar); + /** In order to support parallel builds for custom commands with multiple outputs the outputs are given a serial order, and only the first output actually has the build rule. Other outputs diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index f52f7ab50..a82c50349 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -34,6 +34,20 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() *this->BuildFileStream << "# Utility rule file for " << this->Target->GetName() << ".\n\n"; + if(!this->NoRuleMessages) + { + const char* root = (this->Makefile->IsOn("CMAKE_MAKE_INCLUDE_FROM_ROOT")? + "$(CMAKE_BINARY_DIR)/" : ""); + // Include the progress variables for the target. + *this->BuildFileStream + << "# Include the progress variables for this target.\n" + << this->LocalGenerator->IncludeDirective << " " << root + << this->Convert(this->ProgressFileNameFull.c_str(), + cmLocalGenerator::HOME_OUTPUT, + cmLocalGenerator::MAKEFILE) + << "\n\n"; + } + // write the custom commands for this target this->WriteTargetBuildRules(); diff --git a/Source/cmMarkAsAdvancedCommand.h b/Source/cmMarkAsAdvancedCommand.h index 0a5eb9ec7..26e0a07fd 100644 --- a/Source/cmMarkAsAdvancedCommand.h +++ b/Source/cmMarkAsAdvancedCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmMarkAsAdvancedCommand - * \brief MarkAsAdvanced a CMAKE variable + * \brief mark_as_advanced command * - * cmMarkAsAdvancedCommand sets a variable to a value with expansion. + * cmMarkAsAdvancedCommand implements the mark_as_advanced CMake command */ class cmMarkAsAdvancedCommand : public cmCommand { diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx new file mode 100644 index 000000000..6f7b6a949 --- /dev/null +++ b/Source/cmNewLineStyle.cxx @@ -0,0 +1,95 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "cmNewLineStyle.h" + + + +cmNewLineStyle::cmNewLineStyle() : NewLineStyle(Invalid) +{ +} + + +bool cmNewLineStyle::IsValid() const +{ + return NewLineStyle != Invalid; +} + + +bool cmNewLineStyle::ReadFromArguments(const std::vector& args, + std::string& errorString) +{ + NewLineStyle = Invalid; + + for (size_t i = 0; i< args.size(); i++) + { + if (args[i] == "NEWLINE_STYLE") + { + size_t const styleIndex = i + 1; + if (args.size() > styleIndex) + { + const std::string eol = args[styleIndex]; + if (eol == "LF" || eol == "UNIX") + { + NewLineStyle = LF; + return true; + } + else if (eol == "CRLF" || eol == "WIN32" || eol == "DOS") + { + NewLineStyle = CRLF; + return true; + } + else + { + errorString = "NEWLINE_STYLE sets an unknown style, only LF, " + "CRLF, UNIX, DOS, and WIN32 are supported"; + return false; + } + } + else + { + errorString = "NEWLINE_STYLE must set a style: " + "LF, CRLF, UNIX, DOS, or WIN32"; + return false; + } + } + } + return true; +} + + +const std::string cmNewLineStyle::GetCharacters() const +{ + switch (NewLineStyle) + { + case Invalid: + return ""; + case LF: + return "\n"; + case CRLF: + return "\r\n"; + default: + ; + }; + return ""; +} + + +void cmNewLineStyle::SetStyle(Style style) +{ + NewLineStyle = style; +} + + +cmNewLineStyle::Style cmNewLineStyle::GetStyle() const +{ + return NewLineStyle; +} diff --git a/Source/cmNewLineStyle.h b/Source/cmNewLineStyle.h new file mode 100644 index 000000000..cae110604 --- /dev/null +++ b/Source/cmNewLineStyle.h @@ -0,0 +1,46 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmNewLineStyle_h +#define cmNewLineStyle_h + +#include "cmStandardIncludes.h" + +class cmNewLineStyle +{ +public: + + cmNewLineStyle(); + + enum Style + { + Invalid, + // LF = '\n', 0x0A, 10 + // CR = '\r', 0x0D, 13 + LF, // Unix + CRLF // Dos + }; + + void SetStyle(Style); + Style GetStyle() const; + + bool IsValid() const; + + bool ReadFromArguments(const std::vector& args, + std::string &errorString); + + const std::string GetCharacters() const; + +private: + Style NewLineStyle; +}; + +#endif diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 1a831d92a..6e3b6afec 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -47,9 +47,13 @@ bool cmProjectCommand this->Makefile->AddDefinition("PROJECT_NAME", args[0].c_str()); // Set the CMAKE_PROJECT_NAME variable to be the highest-level - // project name in the tree. This is always the first PROJECT - // command encountered. - if(!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME")) + // project name in the tree. If there are two project commands + // in the same CMakeLists.txt file, and it is the top level + // CMakeLists.txt file, then go with the last one, so that + // CMAKE_PROJECT_NAME will match PROJECT_NAME, and cmake --build + // will work. + if(!this->Makefile->GetDefinition("CMAKE_PROJECT_NAME") + || (this->Makefile->GetLocalGenerator()->GetParent() == 0) ) { this->Makefile->AddDefinition("CMAKE_PROJECT_NAME", args[0].c_str()); this->Makefile->AddCacheDefinition diff --git a/Source/cmProperty.cxx b/Source/cmProperty.cxx index 166bd007e..3b37cf3b8 100644 --- a/Source/cmProperty.cxx +++ b/Source/cmProperty.cxx @@ -19,10 +19,10 @@ void cmProperty::Set(const char *name, const char *value) this->ValueHasBeenSet = true; } -void cmProperty::Append(const char *name, const char *value) +void cmProperty::Append(const char *name, const char *value, bool asString) { this->Name = name; - if(!this->Value.empty() && *value) + if(!this->Value.empty() && *value && !asString) { this->Value += ";"; } diff --git a/Source/cmProperty.h b/Source/cmProperty.h index 71bd1e768..e0fcd631e 100644 --- a/Source/cmProperty.h +++ b/Source/cmProperty.h @@ -24,7 +24,7 @@ public: void Set(const char *name, const char *value); // append to this property - void Append(const char *name, const char *value); + void Append(const char *name, const char *value, bool asString = false); // get the value const char *GetValue() const; diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index 052b811f9..a4d0bf3d8 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -59,7 +59,7 @@ void cmPropertyMap::SetProperty(const char *name, const char *value, } void cmPropertyMap::AppendProperty(const char* name, const char* value, - cmProperty::ScopeType scope) + cmProperty::ScopeType scope, bool asString) { // Skip if nothing to append. if(!name || !value || !*value) @@ -81,7 +81,7 @@ void cmPropertyMap::AppendProperty(const char* name, const char* value, #endif cmProperty *prop = this->GetOrCreateProperty(name); - prop->Append(name,value); + prop->Append(name,value,asString); } const char *cmPropertyMap diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index 02fb0606a..94275e2ac 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -25,7 +25,7 @@ public: cmProperty::ScopeType scope); void AppendProperty(const char* name, const char* value, - cmProperty::ScopeType scope); + cmProperty::ScopeType scope, bool asString=false); const char *GetPropertyValue(const char *name, cmProperty::ScopeType scope, diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx new file mode 100644 index 000000000..0d0d80cff --- /dev/null +++ b/Source/cmQtAutomoc.cxx @@ -0,0 +1,1073 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "cmGlobalGenerator.h" +#include "cmLocalGenerator.h" +#include "cmMakefile.h" +#include "cmSourceFile.h" +#include "cmSystemTools.h" + +#include + +#include + +#include "cmQtAutomoc.h" + + +static bool containsQ_OBJECT(const std::string& text) +{ + // this simple check is much much faster than the regexp + if (strstr(text.c_str(), "Q_OBJECT") == NULL) + { + return false; + } + + cmsys::RegularExpression qObjectRegExp("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]"); + return qObjectRegExp.find(text); +} + + +static std::string findMatchingHeader(const std::string& absPath, + const std::string& mocSubDir, + const std::string& basename, + const std::list& headerExtensions) +{ + std::string header; + for(std::list::const_iterator ext = headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + std::string sourceFilePath = absPath + basename + (*ext); + if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) + { + header = sourceFilePath; + break; + } + if (!mocSubDir.empty()) + { + sourceFilePath = mocSubDir + basename + (*ext); + if (cmsys::SystemTools::FileExists(sourceFilePath.c_str())) + { + header = sourceFilePath; + break; + } + } + } + + return header; +} + + +static std::string extractSubDir(const std::string& absPath, + const std::string& currentMoc) +{ + std::string subDir; + if (currentMoc.find_first_of('/') != std::string::npos) + { + subDir = absPath + + cmsys::SystemTools::GetFilenamePath(currentMoc) + '/'; + } + return subDir; +} + + +cmQtAutomoc::cmQtAutomoc() +:Verbose(cmsys::SystemTools::GetEnv("VERBOSE") != 0) +,ColorOutput(true) +,RunMocFailed(false) +,GenerateAll(false) +{ + + std::string colorEnv = ""; + cmsys::SystemTools::GetEnv("COLOR", colorEnv); + if(!colorEnv.empty()) + { + if(cmSystemTools::IsOn(colorEnv.c_str())) + { + this->ColorOutput = true; + } + else + { + this->ColorOutput = false; + } + } +} + + +void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) +{ + cmMakefile* makefile = target->GetMakefile(); + const char* targetName = target->GetName(); + // don't do anything if there is no Qt4 or Qt5Core (which contains moc): + std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); + if (qtMajorVersion == "") + { + qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); + } + if (qtMajorVersion != "4" && qtMajorVersion != "5") + { + return; + } + + bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); + + // create a custom target for running automoc at buildtime: + std::string automocTargetName = targetName; + automocTargetName += "_automoc"; + + std::string targetDir = makefile->GetCurrentOutputDirectory(); + targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory(); + targetDir += "/"; + targetDir += automocTargetName; + targetDir += ".dir/"; + + cmCustomCommandLine currentLine; + currentLine.push_back(makefile->GetSafeDefinition("CMAKE_COMMAND")); + currentLine.push_back("-E"); + currentLine.push_back("cmake_automoc"); + currentLine.push_back(targetDir); + + cmCustomCommandLines commandLines; + commandLines.push_back(currentLine); + + std::string workingDirectory = cmSystemTools::CollapseFullPath( + "", makefile->GetCurrentOutputDirectory()); + + std::vector depends; + std::string automocComment = "Automoc for target "; + automocComment += targetName; + + makefile->AddUtilityCommand(automocTargetName.c_str(), true, + workingDirectory.c_str(), depends, + commandLines, false, automocComment.c_str()); + target->AddUtility(automocTargetName.c_str()); + + // configure a file to get all information to automoc at buildtime: + std::string _moc_files; + std::string _moc_headers; + const char* sepFiles = ""; + const char* sepHeaders = ""; + + const std::vector& srcFiles = target->GetSourceFiles(); + + for(std::vector::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string absFile = sf->GetFullPath(); + bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); + bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")); + + if ((skip==false) && (generated == false)) + { + std::string ext = sf->GetExtension(); + cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat( + ext.c_str()); + if (fileType == cmSystemTools::CXX_FILE_FORMAT) + { + _moc_files += sepFiles; + _moc_files += absFile; + sepFiles = ";"; + } + else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) + { + _moc_headers += sepHeaders; + _moc_headers += absFile; + sepHeaders = ";"; + } + } + } + + const char* tmp = makefile->GetProperty("INCLUDE_DIRECTORIES"); + std::string _moc_incs = (tmp!=0 ? tmp : ""); + tmp = makefile->GetProperty("DEFINITIONS"); + std::string _moc_defs = (tmp!=0 ? tmp : ""); + tmp = makefile->GetProperty("COMPILE_DEFINITIONS"); + std::string _moc_compile_defs = (tmp!=0 ? tmp : ""); + tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS"); + std::string _moc_options = (tmp!=0 ? tmp : ""); + + // forget the variables added here afterwards again: + cmMakefile::ScopePushPop varScope(makefile); + static_cast(varScope); + + makefile->AddDefinition("_moc_target_name", automocTargetName.c_str()); + makefile->AddDefinition("_moc_incs", _moc_incs.c_str()); + makefile->AddDefinition("_moc_defs", _moc_defs.c_str()); + makefile->AddDefinition("_moc_compile_defs", _moc_compile_defs.c_str()); + makefile->AddDefinition("_moc_options", _moc_options.c_str()); + makefile->AddDefinition("_moc_files", _moc_files.c_str()); + makefile->AddDefinition("_moc_headers", _moc_headers.c_str()); + makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE"); + + const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT"); + std::string inputFile = cmakeRoot; + inputFile += "/Modules/AutomocInfo.cmake.in"; + std::string outputFile = targetDir; + outputFile += "/AutomocInfo.cmake"; + makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(), + false, true, false); + + std::string mocCppFile = makefile->GetCurrentOutputDirectory(); + mocCppFile += "/"; + mocCppFile += automocTargetName; + mocCppFile += ".cpp"; + cmSourceFile* mocCppSource = makefile->GetOrCreateSource(mocCppFile.c_str(), + true); + target->AddSourceFile(mocCppSource); + + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + mocCppFile.c_str(), false); +} + + +bool cmQtAutomoc::Run(const char* targetDirectory) +{ + cmake cm; + cmGlobalGenerator* gg = this->CreateGlobalGenerator(&cm, targetDirectory); + cmMakefile* makefile = gg->GetCurrentLocalGenerator()->GetMakefile(); + + this->ReadAutomocInfoFile(makefile, targetDirectory); + this->ReadOldMocDefinitionsFile(makefile, targetDirectory); + + this->Init(); + + if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") + { + this->RunAutomoc(); + } + + this->WriteOldMocDefinitionsFile(targetDirectory); + + delete gg; + gg = NULL; + makefile = NULL; + return true; +} + + +cmGlobalGenerator* cmQtAutomoc::CreateGlobalGenerator(cmake* cm, + const char* targetDirectory) +{ + cmGlobalGenerator* gg = new cmGlobalGenerator(); + gg->SetCMakeInstance(cm); + + cmLocalGenerator* lg = gg->CreateLocalGenerator(); + lg->GetMakefile()->SetHomeOutputDirectory(targetDirectory); + lg->GetMakefile()->SetStartOutputDirectory(targetDirectory); + lg->GetMakefile()->SetHomeDirectory(targetDirectory); + lg->GetMakefile()->SetStartDirectory(targetDirectory); + gg->SetCurrentLocalGenerator(lg); + + return gg; +} + + +bool cmQtAutomoc::ReadAutomocInfoFile(cmMakefile* makefile, + const char* targetDirectory) +{ + std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); + cmSystemTools::ConvertToUnixSlashes(filename); + filename += "/AutomocInfo.cmake"; + + if (!makefile->ReadListFile(0, filename.c_str())) + { + cmSystemTools::Error("Error processing file:", filename.c_str()); + return false; + } + + this->QtMajorVersion = makefile->GetSafeDefinition("AM_QT_VERSION_MAJOR"); + if (this->QtMajorVersion == "") + { + this->QtMajorVersion = makefile->GetSafeDefinition( + "AM_Qt5Core_VERSION_MAJOR"); + } + this->Sources = makefile->GetSafeDefinition("AM_SOURCES"); + this->Headers = makefile->GetSafeDefinition("AM_HEADERS"); + this->IncludeProjectDirsBefore = makefile->IsOn( + "AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"); + this->Srcdir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_SOURCE_DIR"); + this->Builddir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_BINARY_DIR"); + this->MocExecutable = makefile->GetSafeDefinition("AM_QT_MOC_EXECUTABLE"); + this->MocCompileDefinitionsStr = makefile->GetSafeDefinition( + "AM_MOC_COMPILE_DEFINITIONS"); + this->MocDefinitionsStr = makefile->GetSafeDefinition("AM_MOC_DEFINITIONS"); + this->MocIncludesStr = makefile->GetSafeDefinition("AM_MOC_INCLUDES"); + this->MocOptionsStr = makefile->GetSafeDefinition("AM_MOC_OPTIONS"); + this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR"); + this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR"); + this->TargetName = makefile->GetSafeDefinition("AM_TARGET_NAME"); + + this->RelaxedMode = makefile->IsOn("AM_RELAXED_MODE"); + + return true; +} + + +bool cmQtAutomoc::ReadOldMocDefinitionsFile(cmMakefile* makefile, + const char* targetDirectory) +{ + std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); + cmSystemTools::ConvertToUnixSlashes(filename); + filename += "/AutomocOldMocDefinitions.cmake"; + + if (makefile->ReadListFile(0, filename.c_str())) + { + this->OldMocDefinitionsStr = + makefile->GetSafeDefinition("AM_OLD_MOC_DEFINITIONS"); + } + return true; +} + + +void cmQtAutomoc::WriteOldMocDefinitionsFile(const char* targetDirectory) +{ + std::string filename(cmSystemTools::CollapseFullPath(targetDirectory)); + cmSystemTools::ConvertToUnixSlashes(filename); + filename += "/AutomocOldMocDefinitions.cmake"; + + std::fstream outfile; + outfile.open(filename.c_str(), + std::ios::out | std::ios::trunc); + outfile << "set(AM_OLD_MOC_DEFINITIONS \"" + << this->Join(this->MocDefinitions, ' ') << "\")\n"; + + outfile.close(); +} + + +void cmQtAutomoc::Init() +{ + this->OutMocCppFilename = this->Builddir; + this->OutMocCppFilename += this->TargetName; + this->OutMocCppFilename += ".cpp"; + + std::vector cdefList; + cmSystemTools::ExpandListArgument(this->MocCompileDefinitionsStr, cdefList); + if (!cdefList.empty()) + { + for(std::vector::const_iterator it = cdefList.begin(); + it != cdefList.end(); + ++it) + { + this->MocDefinitions.push_back("-D" + (*it)); + } + } + else + { + std::string tmpMocDefs = this->MocDefinitionsStr; + cmSystemTools::ReplaceString(tmpMocDefs, " ", ";"); + + std::vector defList; + cmSystemTools::ExpandListArgument(tmpMocDefs, defList); + + for(std::vector::const_iterator it = defList.begin(); + it != defList.end(); + ++it) + { + if (this->StartsWith(*it, "-D")) + { + this->MocDefinitions.push_back(*it); + } + } + } + + cmSystemTools::ExpandListArgument(this->MocOptionsStr, this->MocOptions); + + std::vector incPaths; + cmSystemTools::ExpandListArgument(this->MocIncludesStr, incPaths); + + std::set frameworkPaths; + for(std::vector::const_iterator it = incPaths.begin(); + it != incPaths.end(); + ++it) + { + const std::string &path = *it; + this->MocIncludes.push_back("-I" + path); + if (this->EndsWith(path, ".framework/Headers")) + { + // Go up twice to get to the framework root + std::vector pathComponents; + cmsys::SystemTools::SplitPath(path.c_str(), pathComponents); + std::string frameworkPath =cmsys::SystemTools::JoinPath( + pathComponents.begin(), pathComponents.end() - 2); + frameworkPaths.insert(frameworkPath); + } + } + + for (std::set::const_iterator it = frameworkPaths.begin(); + it != frameworkPaths.end(); ++it) + { + this->MocIncludes.push_back("-F"); + this->MocIncludes.push_back(*it); + } + + + if (this->IncludeProjectDirsBefore) + { + const std::string &binDir = "-I" + this->ProjectBinaryDir; + + const std::string srcDir = "-I" + this->ProjectSourceDir; + + std::list sortedMocIncludes; + std::list::iterator it = this->MocIncludes.begin(); + while (it != this->MocIncludes.end()) + { + if (this->StartsWith(*it, binDir)) + { + sortedMocIncludes.push_back(*it); + it = this->MocIncludes.erase(it); + } + else + { + ++it; + } + } + it = this->MocIncludes.begin(); + while (it != this->MocIncludes.end()) + { + if (this->StartsWith(*it, srcDir)) + { + sortedMocIncludes.push_back(*it); + it = this->MocIncludes.erase(it); + } + else + { + ++it; + } + } + sortedMocIncludes.insert(sortedMocIncludes.end(), + this->MocIncludes.begin(), this->MocIncludes.end()); + this->MocIncludes = sortedMocIncludes; + } + +} + + +bool cmQtAutomoc::RunAutomoc() +{ + if (!cmsys::SystemTools::FileExists(this->OutMocCppFilename.c_str()) + || (this->OldMocDefinitionsStr != this->Join(this->MocDefinitions, ' '))) + { + this->GenerateAll = true; + } + + // the program goes through all .cpp files to see which moc files are + // included. It is not really interesting how the moc file is named, but + // what file the moc is created from. Once a moc is included the same moc + // may not be included in the _automoc.cpp file anymore. OTOH if there's a + // header containing Q_OBJECT where no corresponding moc file is included + // anywhere a moc_.cpp file is created and included in + // the _automoc.cpp file. + + // key = moc source filepath, value = moc output filepath + std::map includedMocs; + // collect all headers which may need to be mocced + std::set headerFiles; + + std::vector sourceFiles; + cmSystemTools::ExpandListArgument(this->Sources, sourceFiles); + + std::list headerExtensions; + headerExtensions.push_back(".h"); + headerExtensions.push_back(".hpp"); + headerExtensions.push_back(".hxx"); +#if defined(_WIN32) + // not case sensitive, don't add ".H" +#elif defined(__APPLE__) + // detect case-sensitive filesystem + long caseSensitive = pathconf(this->Srcdir.c_str(), _PC_CASE_SENSITIVE); + if (caseSensitive == 1) + { + headerExtensions.push_back(".H"); + } +#else + headerExtensions.push_back(".H"); +#endif + + for (std::vector::const_iterator it = sourceFiles.begin(); + it != sourceFiles.end(); + ++it) + { + const std::string &absFilename = *it; + if (this->Verbose) + { + std::cout << "AUTOMOC: Checking " << absFilename << std::endl; + } + if (this->RelaxedMode) + { + this->ParseCppFile(absFilename, headerExtensions, includedMocs); + } + else + { + this->StrictParseCppFile(absFilename, headerExtensions, includedMocs); + } + this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles); + } + + std::vector headerFilesVec; + cmSystemTools::ExpandListArgument(this->Headers, headerFilesVec); + for (std::vector::const_iterator it = headerFilesVec.begin(); + it != headerFilesVec.end(); + ++it) + { + headerFiles.insert(*it); + } + + // key = moc source filepath, value = moc output filename + std::map notIncludedMocs; + this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs); + + // run moc on all the moc's that are #included in source files + for(std::map::const_iterator + it = includedMocs.begin(); + it != includedMocs.end(); + ++it) + { + this->GenerateMoc(it->first, it->second); + } + + std::stringstream outStream(std::stringstream::out); + outStream << "/* This file is autogenerated, do not edit*/\n"; + + bool automocCppChanged = false; + if (notIncludedMocs.empty()) + { + outStream << "enum some_compilers { need_more_than_nothing };\n"; + } + else + { + // run moc on the remaining headers and include them in + // the _automoc.cpp file + for(std::map::const_iterator + it = notIncludedMocs.begin(); + it != notIncludedMocs.end(); + ++it) + { + bool mocSuccess = this->GenerateMoc(it->first, it->second); + if (mocSuccess) + { + automocCppChanged = true; + } + outStream << "#include \"" << it->second << "\"\n"; + } + } + + if (this->RunMocFailed) + { + std::cerr << "returning failed.."<< std::endl; + return false; + } + outStream.flush(); + std::string automocSource = outStream.str(); + if (!automocCppChanged) + { + // compare contents of the _automoc.cpp file + const std::string oldContents = this->ReadAll(this->OutMocCppFilename); + if (oldContents == automocSource) + { + // nothing changed: don't touch the _automoc.cpp file + return true; + } + } + + // source file that includes all remaining moc files (_automoc.cpp file) + std::fstream outfile; + outfile.open(this->OutMocCppFilename.c_str(), + std::ios::out | std::ios::trunc); + outfile << automocSource; + outfile.close(); + + return true; +} + + +void cmQtAutomoc::ParseCppFile(const std::string& absFilename, + const std::list& headerExtensions, + std::map& includedMocs) +{ + cmsys::RegularExpression mocIncludeRegExp( + "[\n][ \t]*#[ \t]*include[ \t]+" + "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); + + const std::string contentsString = this->ReadAll(absFilename); + if (contentsString.empty()) + { + std::cerr << "AUTOMOC: warning: " << absFilename << ": file is empty\n" + << std::endl; + return; + } + const std::string absPath = cmsys::SystemTools::GetFilenamePath( + cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; + const std::string scannedFileBasename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFilename); + const bool cppContainsQ_OBJECT = containsQ_OBJECT(contentsString); + bool dotMocIncluded = false; + bool mocUnderscoreIncluded = false; + std::string ownMocUnderscoreFile; + std::string ownDotMocFile; + std::string ownMocHeaderFile; + + std::string::size_type matchOffset = 0; + // first a simply string check for "moc" is *much* faster than the regexp, + // and if the string search already fails, we don't have to try the + // expensive regexp + if ((strstr(contentsString.c_str(), "moc") != NULL) + && (mocIncludeRegExp.find(contentsString))) + { + // for every moc include in the file + do + { + const std::string currentMoc = mocIncludeRegExp.match(1); + //std::cout << "found moc include: " << currentMoc << std::endl; + + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(currentMoc); + const bool moc_style = this->StartsWith(basename, "moc_"); + + // If the moc include is of the moc_foo.cpp style we expect + // the Q_OBJECT class declaration in a header file. + // If the moc include is of the foo.moc style we need to look for + // a Q_OBJECT macro in the current source file, if it contains the + // macro we generate the moc file from the source file. + // Q_OBJECT + if (moc_style) + { + // basename should be the part of the moc filename used for + // finding the correct header, so we need to remove the moc_ part + basename = basename.substr(4); + std::string mocSubDir = extractSubDir(absPath, currentMoc); + std::string headerToMoc = findMatchingHeader( + absPath, mocSubDir, basename, headerExtensions); + + if (!headerToMoc.empty()) + { + includedMocs[headerToMoc] = currentMoc; + if (basename == scannedFileBasename) + { + mocUnderscoreIncluded = true; + ownMocUnderscoreFile = currentMoc; + ownMocHeaderFile = headerToMoc; + } + } + else + { + std::cerr << "AUTOMOC: error: " << absFilename << " The file " + << "includes the moc file \"" << currentMoc << "\", " + << "but could not find header \"" << basename + << '{' << this->Join(headerExtensions, ',') << "}\" "; + if (mocSubDir.empty()) + { + std::cerr << "in " << absPath << "\n" << std::endl; + } + else + { + std::cerr << "neither in " << absPath + << " nor in " << mocSubDir << "\n" << std::endl; + } + + ::exit(EXIT_FAILURE); + } + } + else + { + std::string fileToMoc = absFilename; + if ((basename != scannedFileBasename) || (cppContainsQ_OBJECT==false)) + { + std::string mocSubDir = extractSubDir(absPath, currentMoc); + std::string headerToMoc = findMatchingHeader( + absPath, mocSubDir, basename, headerExtensions); + if (!headerToMoc.empty()) + { + // this is for KDE4 compatibility: + fileToMoc = headerToMoc; + if ((cppContainsQ_OBJECT==false) &&(basename==scannedFileBasename)) + { + std::cerr << "AUTOMOC: warning: " << absFilename << ": The file " + "includes the moc file \"" << currentMoc << + "\", but does not contain a Q_OBJECT macro. " + "Running moc on " + << "\"" << headerToMoc << "\" ! Include \"moc_" + << basename << ".cpp\" for a compatiblity with " + "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n" + << std::endl; + } + else + { + std::cerr << "AUTOMOC: warning: " << absFilename << ": The file " + "includes the moc file \"" << currentMoc << + "\" instead of \"moc_" << basename << ".cpp\". " + "Running moc on " + << "\"" << headerToMoc << "\" ! Include \"moc_" + << basename << ".cpp\" for compatiblity with " + "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n" + << std::endl; + } + } + else + { + std::cerr <<"AUTOMOC: error: " << absFilename << ": The file " + "includes the moc file \"" << currentMoc << + "\", which seems to be the moc file from a different " + "source file. CMake also could not find a matching " + "header.\n" << std::endl; + ::exit(EXIT_FAILURE); + } + } + else + { + dotMocIncluded = true; + ownDotMocFile = currentMoc; + } + includedMocs[fileToMoc] = currentMoc; + } + matchOffset += mocIncludeRegExp.end(); + } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); + } + + // In this case, check whether the scanned file itself contains a Q_OBJECT. + // If this is the case, the moc_foo.cpp should probably be generated from + // foo.cpp instead of foo.h, because otherwise it won't build. + // But warn, since this is not how it is supposed to be used. + if ((dotMocIncluded == false) && (cppContainsQ_OBJECT == true)) + { + if (mocUnderscoreIncluded == true) + { + // this is for KDE4 compatibility: + std::cerr << "AUTOMOC: warning: " << absFilename << ": The file " + << "contains a Q_OBJECT macro, but does not include " + << "\"" << scannedFileBasename << ".moc\", but instead " + "includes " + << "\"" << ownMocUnderscoreFile << "\". Running moc on " + << "\"" << absFilename << "\" ! Better include \"" + << scannedFileBasename << ".moc\" for compatiblity with " + "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n" + << std::endl; + includedMocs[absFilename] = ownMocUnderscoreFile; + includedMocs.erase(ownMocHeaderFile); + } + else + { + // otherwise always error out since it will not compile: + std::cerr << "AUTOMOC: error: " << absFilename << ": The file " + << "contains a Q_OBJECT macro, but does not include " + << "\"" << scannedFileBasename << ".moc\" !\n" + << std::endl; + ::exit(EXIT_FAILURE); + } + } + +} + + +void cmQtAutomoc::StrictParseCppFile(const std::string& absFilename, + const std::list& headerExtensions, + std::map& includedMocs) +{ + cmsys::RegularExpression mocIncludeRegExp( + "[\n][ \t]*#[ \t]*include[ \t]+" + "[\"<](([^ \">]+/)?moc_[^ \">/]+\\.cpp|[^ \">]+\\.moc)[\">]"); + + const std::string contentsString = this->ReadAll(absFilename); + if (contentsString.empty()) + { + std::cerr << "AUTOMOC: warning: " << absFilename << ": file is empty\n" + << std::endl; + return; + } + const std::string absPath = cmsys::SystemTools::GetFilenamePath( + cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; + const std::string scannedFileBasename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFilename); + + bool dotMocIncluded = false; + + std::string::size_type matchOffset = 0; + // first a simply string check for "moc" is *much* faster than the regexp, + // and if the string search already fails, we don't have to try the + // expensive regexp + if ((strstr(contentsString.c_str(), "moc") != NULL) + && (mocIncludeRegExp.find(contentsString))) + { + // for every moc include in the file + do + { + const std::string currentMoc = mocIncludeRegExp.match(1); + + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(currentMoc); + const bool mocUnderscoreStyle = this->StartsWith(basename, "moc_"); + + // If the moc include is of the moc_foo.cpp style we expect + // the Q_OBJECT class declaration in a header file. + // If the moc include is of the foo.moc style we need to look for + // a Q_OBJECT macro in the current source file, if it contains the + // macro we generate the moc file from the source file. + if (mocUnderscoreStyle) + { + // basename should be the part of the moc filename used for + // finding the correct header, so we need to remove the moc_ part + basename = basename.substr(4); + std::string mocSubDir = extractSubDir(absPath, currentMoc); + std::string headerToMoc = findMatchingHeader( + absPath, mocSubDir, basename, headerExtensions); + + if (!headerToMoc.empty()) + { + includedMocs[headerToMoc] = currentMoc; + } + else + { + std::cerr << "AUTOMOC: error: " << absFilename << " The file " + << "includes the moc file \"" << currentMoc << "\", " + << "but could not find header \"" << basename + << '{' << this->Join(headerExtensions, ',') << "}\" "; + if (mocSubDir.empty()) + { + std::cerr << "in " << absPath << "\n" << std::endl; + } + else + { + std::cerr << "neither in " << absPath + << " nor in " << mocSubDir << "\n" << std::endl; + } + + ::exit(EXIT_FAILURE); + } + } + else + { + if (basename != scannedFileBasename) + { + std::cerr <<"AUTOMOC: error: " << absFilename << ": The file " + "includes the moc file \"" << currentMoc << + "\", which seems to be the moc file from a different " + "source file. This is not supported. " + "Include \"" << scannedFileBasename << ".moc\" to run " + "moc on this source file.\n" << std::endl; + ::exit(EXIT_FAILURE); + } + dotMocIncluded = true; + includedMocs[absFilename] = currentMoc; + } + matchOffset += mocIncludeRegExp.end(); + } while(mocIncludeRegExp.find(contentsString.c_str() + matchOffset)); + } + + // In this case, check whether the scanned file itself contains a Q_OBJECT. + // If this is the case, the moc_foo.cpp should probably be generated from + // foo.cpp instead of foo.h, because otherwise it won't build. + // But warn, since this is not how it is supposed to be used. + if ((dotMocIncluded == false) && (containsQ_OBJECT(contentsString))) + { + // otherwise always error out since it will not compile: + std::cerr << "AUTOMOC: error: " << absFilename << ": The file " + << "contains a Q_OBJECT macro, but does not include " + << "\"" << scannedFileBasename << ".moc\" !\n" + << std::endl; + ::exit(EXIT_FAILURE); + } + +} + + +void cmQtAutomoc::SearchHeadersForCppFile(const std::string& absFilename, + const std::list& headerExtensions, + std::set& absHeaders) +{ + // search for header files and private header files we may need to moc: + const std::string basename = + cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename); + const std::string absPath = cmsys::SystemTools::GetFilenamePath( + cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/'; + + for(std::list::const_iterator ext = headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string headerName = absPath + basename + (*ext); + if (cmsys::SystemTools::FileExists(headerName.c_str())) + { + absHeaders.insert(headerName); + break; + } + } + for(std::list::const_iterator ext = headerExtensions.begin(); + ext != headerExtensions.end(); + ++ext) + { + const std::string privateHeaderName = absPath+basename+"_p"+(*ext); + if (cmsys::SystemTools::FileExists(privateHeaderName.c_str())) + { + absHeaders.insert(privateHeaderName); + break; + } + } + +} + + +void cmQtAutomoc::ParseHeaders(const std::set& absHeaders, + const std::map& includedMocs, + std::map& notIncludedMocs) +{ + for(std::set::const_iterator hIt=absHeaders.begin(); + hIt!=absHeaders.end(); + ++hIt) + { + const std::string& headerName = *hIt; + + if (includedMocs.find(headerName) == includedMocs.end()) + { + if (this->Verbose) + { + std::cout << "AUTOMOC: Checking " << headerName << std::endl; + } + + const std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(headerName); + + const std::string currentMoc = "moc_" + basename + ".cpp"; + const std::string contents = this->ReadAll(headerName); + if (containsQ_OBJECT(contents)) + { + //std::cout << "header contains Q_OBJECT macro"; + notIncludedMocs[headerName] = currentMoc; + } + } + } + +} + + +bool cmQtAutomoc::GenerateMoc(const std::string& sourceFile, + const std::string& mocFileName) +{ + const std::string mocFilePath = this->Builddir + mocFileName; + int sourceNewerThanMoc = 0; + bool success = cmsys::SystemTools::FileTimeCompare(sourceFile.c_str(), + mocFilePath.c_str(), + &sourceNewerThanMoc); + if (this->GenerateAll || !success || sourceNewerThanMoc >= 0) + { + // make sure the directory for the resulting moc file exists + std::string mocDir = mocFilePath.substr(0, mocFilePath.rfind('/')); + if (!cmsys::SystemTools::FileExists(mocDir.c_str(), false)) + { + cmsys::SystemTools::MakeDirectory(mocDir.c_str()); + } + + std::string msg = "Generating "; + msg += mocFileName; + cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue + |cmsysTerminal_Color_ForegroundBold, + msg.c_str(), true, this->ColorOutput); + + std::vector command; + command.push_back(this->MocExecutable); + for (std::list::const_iterator it = this->MocIncludes.begin(); + it != this->MocIncludes.end(); + ++it) + { + command.push_back(*it); + } + for(std::list::const_iterator it=this->MocDefinitions.begin(); + it != this->MocDefinitions.end(); + ++it) + { + command.push_back(*it); + } + for(std::vector::const_iterator it=this->MocOptions.begin(); + it != this->MocOptions.end(); + ++it) + { + command.push_back(*it); + } +#ifdef _WIN32 + command.push_back("-DWIN32"); +#endif + command.push_back("-o"); + command.push_back(mocFilePath); + command.push_back(sourceFile); + + if (this->Verbose) + { + for(std::vector::const_iterator cmdIt = command.begin(); + cmdIt != command.end(); + ++cmdIt) + { + std::cout << *cmdIt << " "; + } + std::cout << std::endl; + } + + std::string output; + int retVal = 0; + bool result = cmSystemTools::RunSingleCommand(command, &output, &retVal); + if (!result || retVal) + { + std::cerr << "AUTOMOC: error: process for " << mocFilePath <<" failed:\n" + << output << std::endl; + this->RunMocFailed = true; + cmSystemTools::RemoveFile(mocFilePath.c_str()); + } + return true; + } + return false; +} + + +std::string cmQtAutomoc::Join(const std::list& lst,char separator) +{ + if (lst.empty()) + { + return ""; + } + + std::string result; + for (std::list::const_iterator it = lst.begin(); + it != lst.end(); + ++it) + { + result += (*it) + separator; + } + result.erase(result.end() - 1); + return result; +} + + +bool cmQtAutomoc::StartsWith(const std::string& str, const std::string& with) +{ + return (str.substr(0, with.length()) == with); +} + + +bool cmQtAutomoc::EndsWith(const std::string& str, const std::string& with) +{ + if (with.length() > (str.length())) + { + return false; + } + return (str.substr(str.length() - with.length(), with.length()) == with); +} + + +std::string cmQtAutomoc::ReadAll(const std::string& filename) +{ + std::ifstream file(filename.c_str()); + std::stringstream stream; + stream << file.rdbuf(); + file.close(); + return stream.str(); +} diff --git a/Source/cmQtAutomoc.h b/Source/cmQtAutomoc.h new file mode 100644 index 000000000..8cbbac19d --- /dev/null +++ b/Source/cmQtAutomoc.h @@ -0,0 +1,92 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmQtAutomoc_h +#define cmQtAutomoc_h + +class cmGlobalGenerator; +class cmMakefile; + +class cmQtAutomoc +{ +public: + cmQtAutomoc(); + bool Run(const char* targetDirectory); + + void SetupAutomocTarget(cmTarget* target); + +private: + cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, + const char* targetDirectory); + + bool ReadAutomocInfoFile(cmMakefile* makefile, + const char* targetDirectory); + bool ReadOldMocDefinitionsFile(cmMakefile* makefile, + const char* targetDirectory); + void WriteOldMocDefinitionsFile(const char* targetDirectory); + + bool RunAutomoc(); + bool GenerateMoc(const std::string& sourceFile, + const std::string& mocFileName); + void ParseCppFile(const std::string& absFilename, + const std::list& headerExtensions, + std::map& includedMocs); + void StrictParseCppFile(const std::string& absFilename, + const std::list& headerExtensions, + std::map& includedMocs); + void SearchHeadersForCppFile(const std::string& absFilename, + const std::list& headerExtensions, + std::set& absHeaders); + + void ParseHeaders(const std::set& absHeaders, + const std::map& includedMocs, + std::map& notIncludedMocs); + + void Init(); + + std::string Join(const std::list& lst, char separator); + bool EndsWith(const std::string& str, const std::string& with); + bool StartsWith(const std::string& str, const std::string& with); + std::string ReadAll(const std::string& filename); + + std::string QtMajorVersion; + std::string Sources; + std::string Headers; + bool IncludeProjectDirsBefore; + std::string Srcdir; + std::string Builddir; + std::string MocExecutable; + std::string MocCompileDefinitionsStr; + std::string MocDefinitionsStr; + std::string MocIncludesStr; + std::string MocOptionsStr; + std::string ProjectBinaryDir; + std::string ProjectSourceDir; + std::string TargetName; + + std::string OldMocDefinitionsStr; + + std::string OutMocCppFilename; + std::list MocIncludes; + std::list MocDefinitions; + std::vector MocOptions; + + bool Verbose; + bool ColorOutput; + bool RunMocFailed; + bool GenerateAll; + bool RelaxedMode; + +}; + +#endif diff --git a/Source/cmRemoveCommand.h b/Source/cmRemoveCommand.h index 87c416f52..bae2ee13f 100644 --- a/Source/cmRemoveCommand.h +++ b/Source/cmRemoveCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmRemoveCommand - * \brief Set a CMAKE variable + * \brief remove command * - * cmRemoveCommand sets a variable to a value with expansion. + * cmRemoveCommand implements the remove CMake command */ class cmRemoveCommand : public cmCommand { diff --git a/Source/cmSeparateArgumentsCommand.h b/Source/cmSeparateArgumentsCommand.h index 10b3c40b6..736f0662c 100644 --- a/Source/cmSeparateArgumentsCommand.h +++ b/Source/cmSeparateArgumentsCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmSeparateArgumentsCommand - * \brief SeparateArguments a CMAKE variable + * \brief separate_arguments command * - * cmSeparateArgumentsCommand sets a variable to a value with expansion. + * cmSeparateArgumentsCommand implements the separate_arguments CMake command */ class cmSeparateArgumentsCommand : public cmCommand { diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 3a4773ce5..cc10840fd 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -20,6 +20,7 @@ cmSetPropertyCommand::cmSetPropertyCommand() { this->AppendMode = false; + this->AppendAsString = false; this->Remove = true; } @@ -83,6 +84,13 @@ bool cmSetPropertyCommand { doing = DoingNone; this->AppendMode = true; + this->AppendAsString = false; + } + else if(*arg == "APPEND_STRING") + { + doing = DoingNone; + this->AppendMode = true; + this->AppendAsString = true; } else if(doing == DoingNames) { @@ -152,7 +160,7 @@ bool cmSetPropertyCommand::HandleGlobalMode() } if(this->AppendMode) { - cm->AppendProperty(name, value); + cm->AppendProperty(name, value, this->AppendAsString); } else { @@ -218,7 +226,7 @@ bool cmSetPropertyCommand::HandleDirectoryMode() } if(this->AppendMode) { - mf->AppendProperty(name, value); + mf->AppendProperty(name, value, this->AppendAsString); } else { @@ -266,7 +274,7 @@ bool cmSetPropertyCommand::HandleTarget(cmTarget* target) } if(this->AppendMode) { - target->AppendProperty(name, value); + target->AppendProperty(name, value, this->AppendAsString); } else { @@ -317,7 +325,7 @@ bool cmSetPropertyCommand::HandleSource(cmSourceFile* sf) if(this->AppendMode) { - sf->AppendProperty(name, value); + sf->AppendProperty(name, value, this->AppendAsString); } else { @@ -377,7 +385,7 @@ bool cmSetPropertyCommand::HandleTest(cmTest* test) } if(this->AppendMode) { - test->AppendProperty(name, value); + test->AppendProperty(name, value, this->AppendAsString); } else { @@ -464,7 +472,7 @@ bool cmSetPropertyCommand::HandleCacheEntry(cmCacheManager::CacheIterator& it) } if(this->AppendMode) { - it.AppendProperty(name, value); + it.AppendProperty(name, value, this->AppendAsString); } else { diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h index c477bb73b..3a0169ed6 100644 --- a/Source/cmSetPropertyCommand.h +++ b/Source/cmSetPropertyCommand.h @@ -56,7 +56,7 @@ public: " SOURCE [src1 [src2 ...]] |\n" " TEST [test1 [test2 ...]] |\n" " CACHE [entry1 [entry2 ...]]>\n" - " [APPEND]\n" + " [APPEND] [APPEND_STRING]\n" " PROPERTY [value1 [value2 ...]])\n" "Set one property on zero or more objects of a scope. " "The first argument determines the scope in which the property " @@ -77,6 +77,9 @@ public: "list. " "If the APPEND option is given the list is appended to any " "existing property value." + "If the APPEND_STRING option is given the string is append to any " + "existing property value as string, i.e. it results in a longer " + "string and not a list of strings." ; } @@ -93,6 +96,7 @@ private: std::string PropertyValue; bool Remove; bool AppendMode; + bool AppendAsString; // Implementation of each property type. bool HandleGlobalMode(); diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h index 9e39401f7..f001a1111 100644 --- a/Source/cmSetTargetPropertiesCommand.h +++ b/Source/cmSetTargetPropertiesCommand.h @@ -92,7 +92,7 @@ public: "If not set here then it is set to target_EXPORTS by default " "(with some substitutions if the target is not a valid C " "identifier). This is useful for headers to know whether they are " - "being included from inside their library our outside to properly " + "being included from inside their library or outside to properly " "setup dllexport/dllimport decorations. " "The COMPILE_FLAGS property sets additional compiler flags used " "to build sources within the target. It may also be used to pass " @@ -140,9 +140,14 @@ public: "the target in an IDE like visual studio. VS_KEYWORD can be set " "to change the visual studio keyword, for example QT integration " "works better if this is set to Qt4VSv1.0.\n" - "VS_SCC_PROJECTNAME, VS_SCC_LOCALPATH, VS_SCC_PROVIDER can be set " + "VS_SCC_PROJECTNAME, VS_SCC_LOCALPATH, VS_SCC_PROVIDER and " + "VS_SCC_AUXPATH can be set " "to add support for source control bindings in a Visual Studio " "project file.\n" + "VS_GLOBAL_ can be set to add a Visual Studio " + "project-specific global variable. " + "Qt integration works better if VS_GLOBAL_QtVersion is set to " + "the Qt version FindQt4.cmake found. For example, \"4.7.3\"\n" "The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the " "old way to specify CMake scripts to run before and after " "installing a target. They are used only when the old " diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx index 7b80c5c4c..04e357ca8 100644 --- a/Source/cmSiteNameCommand.cxx +++ b/Source/cmSiteNameCommand.cxx @@ -63,7 +63,7 @@ bool cmSiteNameCommand { std::string host; cmSystemTools::RunSingleCommand(hostname_cmd.c_str(), - &host, 0, 0, false); + &host, 0, 0, cmSystemTools::OUTPUT_NONE); // got the hostname if (host.length()) diff --git a/Source/cmSiteNameCommand.h b/Source/cmSiteNameCommand.h index 63575693c..ac7f426ec 100644 --- a/Source/cmSiteNameCommand.h +++ b/Source/cmSiteNameCommand.h @@ -15,9 +15,9 @@ #include "cmCommand.h" /** \class cmSiteNameCommand - * \brief SiteName a CMAKE variable + * \brief site_name command * - * cmSiteNameCommand sets a variable to a value with expansion. + * cmSiteNameCommand implements the site_name CMake command */ class cmSiteNameCommand : public cmCommand { diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 42d3f06ff..cd94753cb 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -291,13 +291,15 @@ void cmSourceFile::SetProperty(const char* prop, const char* value) } //---------------------------------------------------------------------------- -void cmSourceFile::AppendProperty(const char* prop, const char* value) +void cmSourceFile::AppendProperty(const char* prop, const char* value, + bool asString) { if (!prop) { return; } - this->Properties.AppendProperty(prop, value, cmProperty::SOURCE_FILE); + this->Properties.AppendProperty(prop, value, cmProperty::SOURCE_FILE, + asString); } //---------------------------------------------------------------------------- @@ -434,6 +436,15 @@ void cmSourceFile::DefineProperties(cmake *cm) "is really an object file and should not be compiled. " "It will still be linked into the target though."); + cm->DefineProperty + ("Fortran_FORMAT", cmProperty::SOURCE_FILE, + "Set to FIXED or FREE to indicate the Fortran source layout.", + "This property tells CMake whether a given Fortran source file " + "uses fixed-format or free-format. " + "CMake will pass the corresponding format flag to the compiler. " + "Consider using the target-wide Fortran_FORMAT property if all " + "source files in a target share the same format."); + cm->DefineProperty ("GENERATED", cmProperty::SOURCE_FILE, "Is this source file generated as part of the build process.", diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 2dc848815..55147e192 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -44,7 +44,7 @@ public: ///! Set/Get a property of this source file void SetProperty(const char *prop, const char *value); - void AppendProperty(const char* prop, const char* value); + void AppendProperty(const char* prop, const char* value,bool asString=false); const char *GetProperty(const char *prop) const; bool GetPropertyAsBool(const char *prop) const; diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index e8decbb96..ea299ca90 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -161,6 +161,11 @@ extern int putenv (char *__string) __THROW; #define for if(false) {} else for #endif +// Provide std::ios_base on ancient GCC 2.9x +#if defined(__GNUC__) && __GNUC__ < 3 +namespace std { typedef ios ios_base; } +#endif + // check for the 720 compiler on the SGI // which has some strange properties that I don't think are worth // checking for in a general way in configure diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index d239c063a..ec10d571f 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -10,6 +10,8 @@ See the License for more information. ============================================================================*/ #include "cmStringCommand.h" +#include "cmCryptoHash.h" + #include #include @@ -36,6 +38,15 @@ bool cmStringCommand { return this->HandleReplaceCommand(args); } + else if ( subCommand == "MD5" || + subCommand == "SHA1" || + subCommand == "SHA224" || + subCommand == "SHA256" || + subCommand == "SHA384" || + subCommand == "SHA512" ) + { + return this->HandleHashCommand(args); + } else if(subCommand == "TOLOWER") { return this->HandleToUpperLowerCommand(args, false); @@ -82,6 +93,34 @@ bool cmStringCommand return false; } +//---------------------------------------------------------------------------- +bool cmStringCommand::HandleHashCommand(std::vector const& args) +{ +#if defined(CMAKE_BUILD_WITH_CMAKE) + if(args.size() != 3) + { + cmOStringStream e; + e << args[0] << " requires an output variable and an input string"; + this->SetError(e.str().c_str()); + return false; + } + + cmsys::auto_ptr hash(cmCryptoHash::New(args[0].c_str())); + if(hash.get()) + { + std::string out = hash->HashString(args[2].c_str()); + this->Makefile->AddDefinition(args[1].c_str(), out.c_str()); + return true; + } + return false; +#else + cmOStringStream e; + e << args[0] << " not available during bootstrap"; + this->SetError(e.str().c_str()); + return false; +#endif +} + //---------------------------------------------------------------------------- bool cmStringCommand::HandleToUpperLowerCommand( std::vector const& args, bool toUpper) diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h index 52b83d9f3..452f4a1bd 100644 --- a/Source/cmStringCommand.h +++ b/Source/cmStringCommand.h @@ -76,6 +76,8 @@ public: " string(REPLACE \n" " \n" " [...])\n" + " string(\n" + " )\n" " string(COMPARE EQUAL )\n" " string(COMPARE NOTEQUAL )\n" " string(COMPARE LESS )\n" @@ -103,6 +105,8 @@ public: "backslash through argument parsing.\n" "REPLACE will replace all occurrences of match_string in the input with " "replace_string and store the result in the output.\n" + "MD5, SHA1, SHA224, SHA256, SHA384, and SHA512 " + "will compute a cryptographic hash of the input string.\n" "COMPARE EQUAL/NOTEQUAL/LESS/GREATER will compare the strings and " "store true or false in the output variable.\n" "ASCII will convert all numbers into corresponding ASCII characters.\n" @@ -150,6 +154,7 @@ protected: bool RegexMatch(std::vector const& args); bool RegexMatchAll(std::vector const& args); bool RegexReplace(std::vector const& args); + bool HandleHashCommand(std::vector const& args); bool HandleToUpperLowerCommand(std::vector const& args, bool toUpper); bool HandleCompareCommand(std::vector const& args); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index dbb2226be..8eec1e2af 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -12,7 +12,7 @@ #if defined(_MSC_VER) && _MSC_VER < 1300 # define _WIN32_WINNT 0x0400 /* for wincrypt.h */ #endif -#include "cmSystemTools.h" +#include "cmSystemTools.h" #include #include #include @@ -54,7 +54,7 @@ #if defined(CMAKE_BUILD_WITH_CMAKE) # include // auto_ptr # include -# include +# include "cmCryptoHash.h" #endif #if defined(CMAKE_USE_ELF_PARSER) @@ -126,7 +126,7 @@ const char* cmSystemTools::GetWindows9xComspecSubstitute() return cmSystemTools::s_Windows9xComspecSubstitute.c_str(); } -void (*cmSystemTools::s_ErrorCallback)(const char*, const char*, +void (*cmSystemTools::s_ErrorCallback)(const char*, const char*, bool&, void*); void (*cmSystemTools::s_StdoutCallback)(const char*, int len, void*); void* cmSystemTools::s_ErrorCallbackClientData = 0; @@ -144,7 +144,7 @@ void cmSystemTools::ExpandRegistryValues(std::string& source, KeyWOW64 view) // a close square-bracket. The ']' character must be the first in the // list of characters inside the [^...] block of the expression. cmsys::RegularExpression regEntry("\\[(HKEY[^]]*)\\]"); - + // check for black line or comment while (regEntry.find(source)) { @@ -237,7 +237,7 @@ void cmSystemTools::Stdout(const char* s) { if(s_StdoutCallback) { - (*s_StdoutCallback)(s, static_cast(strlen(s)), + (*s_StdoutCallback)(s, static_cast(strlen(s)), s_StdoutCallbackClientData); } else @@ -247,6 +247,12 @@ void cmSystemTools::Stdout(const char* s) } } +void cmSystemTools::Stderr(const char* s, int length) +{ + std::cerr.write(s, length); + std::cerr.flush(); +} + void cmSystemTools::Stdout(const char* s, int length) { if(s_StdoutCallback) @@ -268,7 +274,7 @@ void cmSystemTools::Message(const char* m1, const char *title) } if(s_ErrorCallback) { - (*s_ErrorCallback)(m1, title, s_DisableMessages, + (*s_ErrorCallback)(m1, title, s_DisableMessages, s_ErrorCallbackClientData); return; } @@ -276,7 +282,7 @@ void cmSystemTools::Message(const char* m1, const char *title) { std::cerr << m1 << std::endl << std::flush; } - + } @@ -311,7 +317,7 @@ bool cmSystemTools::IsOn(const char* val) return false; } std::basic_string v = val; - + for(std::basic_string::iterator c = v.begin(); c != v.end(); c++) { @@ -344,13 +350,13 @@ bool cmSystemTools::IsOff(const char* val) return true; } std::basic_string v = val; - + for(std::basic_string::iterator c = v.begin(); c != v.end(); c++) { *c = static_cast(toupper(*c)); } - return (v == "OFF" || v == "0" || v == "NO" || v == "FALSE" || + return (v == "OFF" || v == "0" || v == "NO" || v == "FALSE" || v == "N" || cmSystemTools::IsNOTFOUND(v.c_str()) || v == "IGNORE"); } @@ -569,15 +575,15 @@ std::vector cmSystemTools::ParseArguments(const char* command) args.push_back(arg); } } - + return args; } bool cmSystemTools::RunSingleCommand(std::vectorconst& command, std::string* output , - int* retVal , const char* dir , - bool verbose , + int* retVal , const char* dir , + OutputOption outputflag , double timeout ) { std::vector argv; @@ -599,46 +605,62 @@ bool cmSystemTools::RunSingleCommand(std::vectorconst& command, { cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1); } + cmsysProcess_SetTimeout(cp, timeout); cmsysProcess_Execute(cp); - + std::vector tempOutput; char* data; int length; - if ( output || verbose ) + int pipe; + if ( output || outputflag != OUTPUT_NONE ) { - while(cmsysProcess_WaitForData(cp, &data, &length, 0)) - { - if(output || verbose) + while((pipe = cmsysProcess_WaitForData(cp, &data, &length, 0)) > 0) { - // Translate NULL characters in the output into valid text. - // Visual Studio 7 puts these characters in the output of its - // build process. - for(int i=0; i < length; ++i) + if(output || outputflag != OUTPUT_NONE) { - if(data[i] == '\0') + // Translate NULL characters in the output into valid text. + // Visual Studio 7 puts these characters in the output of its + // build process. + for(int i=0; i < length; ++i) { - data[i] = ' '; + if(data[i] == '\0') + { + data[i] = ' '; + } + } + } + if ( output ) + { + tempOutput.insert(tempOutput.end(), data, data+length); + } + if(outputflag != OUTPUT_NONE) + { + if(outputflag == OUTPUT_MERGE) + { + cmSystemTools::Stdout(data, length); + } + else + { + if(pipe == cmsysProcess_Pipe_STDERR) + { + cmSystemTools::Stderr(data, length); + } + else if(pipe == cmsysProcess_Pipe_STDOUT) + { + cmSystemTools::Stdout(data, length); + } } } } - if ( output ) - { - tempOutput.insert(tempOutput.end(), data, data+length); - } - if(verbose) - { - cmSystemTools::Stdout(data, length); - } - } } - + cmsysProcess_WaitForExit(cp, 0); if ( output && tempOutput.begin() != tempOutput.end()) { output->append(&*tempOutput.begin(), tempOutput.size()); } - + bool result = true; if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exited) { @@ -657,7 +679,7 @@ bool cmSystemTools::RunSingleCommand(std::vectorconst& command, else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Exception) { const char* exception_str = cmsysProcess_GetExceptionString(cp); - if ( verbose ) + if ( outputflag != OUTPUT_NONE ) { std::cerr << exception_str << std::endl; } @@ -670,7 +692,7 @@ bool cmSystemTools::RunSingleCommand(std::vectorconst& command, else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Error) { const char* error_str = cmsysProcess_GetErrorString(cp); - if ( verbose ) + if ( outputflag != OUTPUT_NONE ) { std::cerr << error_str << std::endl; } @@ -683,7 +705,7 @@ bool cmSystemTools::RunSingleCommand(std::vectorconst& command, else if(cmsysProcess_GetState(cp) == cmsysProcess_State_Expired) { const char* error_str = "Process terminated due to timeout\n"; - if ( verbose ) + if ( outputflag != OUTPUT_NONE ) { std::cerr << error_str << std::endl; } @@ -693,22 +715,22 @@ bool cmSystemTools::RunSingleCommand(std::vectorconst& command, } result = false; } - + cmsysProcess_Delete(cp); return result; } bool cmSystemTools::RunSingleCommand( - const char* command, + const char* command, std::string* output, - int *retVal, + int *retVal, const char* dir, - bool verbose, + OutputOption outputflag, double timeout) { if(s_DisableRunCommandOutput) { - verbose = false; + outputflag = OUTPUT_NONE; } std::vector args = cmSystemTools::ParseArguments(command); @@ -717,17 +739,17 @@ bool cmSystemTools::RunSingleCommand( { return false; } - return cmSystemTools::RunSingleCommand(args, output,retVal, - dir, verbose, timeout); + return cmSystemTools::RunSingleCommand(args, output,retVal, + dir, outputflag, timeout); } -bool cmSystemTools::RunCommand(const char* command, +bool cmSystemTools::RunCommand(const char* command, std::string& output, const char* dir, bool verbose, int timeout) { int dummy; - return cmSystemTools::RunCommand(command, output, dummy, + return cmSystemTools::RunCommand(command, output, dummy, dir, verbose, timeout); } @@ -742,11 +764,11 @@ bool RunCommandViaWin32(const char* command, int timeout) { #if defined(__BORLANDC__) - return + return cmWin32ProcessExecution:: - BorlandRunCommand(command, dir, output, - retVal, - verbose, timeout, + BorlandRunCommand(command, dir, output, + retVal, + verbose, timeout, cmSystemTools::GetRunCommandHideConsole()); #else // Visual studio ::SetLastError(ERROR_SUCCESS); @@ -760,7 +782,7 @@ bool RunCommandViaWin32(const char* command, { resProc.SetHideWindows(true); } - + if ( cmSystemTools::GetWindows9xComspecSubstitute() ) { resProc.SetConsoleSpawn(cmSystemTools::GetWindows9xComspecSubstitute() ); @@ -787,7 +809,7 @@ bool RunCommandViaSystem(const char* command, std::string& output, int& retVal, bool verbose) -{ +{ std::cout << "@@ " << command << std::endl; std::string commandInDir; @@ -987,9 +1009,9 @@ bool RunCommandViaPopen(const char* command, // run a command unix uses popen (easy) // windows uses system and ShortPath -bool cmSystemTools::RunCommand(const char* command, +bool cmSystemTools::RunCommand(const char* command, std::string& output, - int &retVal, + int &retVal, const char* dir, bool verbose, int timeout) @@ -998,7 +1020,7 @@ bool cmSystemTools::RunCommand(const char* command, { verbose = false; } - + #if defined(WIN32) && !defined(__CYGWIN__) // if the command does not start with a quote, then // try to find the program, and if the program can not be @@ -1017,9 +1039,9 @@ bool cmSystemTools::RunCommand(const char* command, { break; } - } + } } - // if there are more than two double quotes use + // if there are more than two double quotes use // GetShortPathName, the cmd.exe program in windows which // is used by system fails to execute if there are more than // one set of quotes in the arguments @@ -1043,16 +1065,16 @@ bool cmSystemTools::RunCommand(const char* command, shortCmd += " "; shortCmd += args; - //return RunCommandViaSystem(shortCmd.c_str(), dir, + //return RunCommandViaSystem(shortCmd.c_str(), dir, // output, retVal, verbose); - //return WindowsRunCommand(shortCmd.c_str(), dir, + //return WindowsRunCommand(shortCmd.c_str(), dir, //output, retVal, verbose); - return RunCommandViaWin32(shortCmd.c_str(), dir, + return RunCommandViaWin32(shortCmd.c_str(), dir, output, retVal, verbose, timeout); } else { - cmSystemTools::Error("Could not parse command line with quotes ", + cmSystemTools::Error("Could not parse command line with quotes ", command); } } @@ -1116,7 +1138,7 @@ bool cmSystemTools::cmCopyFile(const char* source, const char* destination) return Superclass::CopyFileAlways(source, destination); } -bool cmSystemTools::CopyFileIfDifferent(const char* source, +bool cmSystemTools::CopyFileIfDifferent(const char* source, const char* destination) { return Superclass::CopyFileIfDifferent(source, destination); @@ -1175,48 +1197,10 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname) bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) { #if defined(CMAKE_BUILD_WITH_CMAKE) - if(!cmSystemTools::FileExists(source)) - { - return false; - } - - // Open files -#if defined(_WIN32) || defined(__CYGWIN__) - cmsys_ios::ifstream fin(source, cmsys_ios::ios::binary | cmsys_ios::ios::in); -#else - cmsys_ios::ifstream fin(source); -#endif - if(!fin) - { - return false; - } - - cmsysMD5* md5 = cmsysMD5_New(); - cmsysMD5_Initialize(md5); - - // Should be efficient enough on most system: - const int bufferSize = 4096; - char buffer[bufferSize]; - unsigned char const* buffer_uc = - reinterpret_cast(buffer); - // This copy loop is very sensitive on certain platforms with - // slightly broken stream libraries (like HPUX). Normally, it is - // incorrect to not check the error condition on the fin.read() - // before using the data, but the fin.gcount() will be zero if an - // error occurred. Therefore, the loop should be safe everywhere. - while(fin) - { - fin.read(buffer, bufferSize); - if(int gcount = static_cast(fin.gcount())) - { - cmsysMD5_Append(md5, buffer_uc, gcount); - } - } - cmsysMD5_FinalizeHex(md5, md5out); - cmsysMD5_Delete(md5); - - fin.close(); - return true; + cmCryptoHashMD5 md5; + std::string str = md5.HashFile(source); + strncpy(md5out, str.c_str(), 32); + return !str.empty(); #else (void)source; (void)md5out; @@ -1228,13 +1212,8 @@ bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) std::string cmSystemTools::ComputeStringMD5(const char* input) { #if defined(CMAKE_BUILD_WITH_CMAKE) - char md5out[32]; - cmsysMD5* md5 = cmsysMD5_New(); - cmsysMD5_Initialize(md5); - cmsysMD5_Append(md5, reinterpret_cast(input), -1); - cmsysMD5_FinalizeHex(md5, md5out); - cmsysMD5_Delete(md5); - return std::string(md5out, 32); + cmCryptoHashMD5 md5; + return md5.HashString(input); #else (void)input; cmSystemTools::Message("md5sum not supported in bootstrapping mode","Error"); @@ -1247,7 +1226,7 @@ void cmSystemTools::Glob(const char *directory, const char *regexp, { cmsys::Directory d; cmsys::RegularExpression reg(regexp); - + if (d.Load(directory)) { size_t numf; @@ -1300,7 +1279,7 @@ void cmSystemTools::GlobDirs(const char *fullPath, } -void cmSystemTools::ExpandList(std::vector const& arguments, +void cmSystemTools::ExpandList(std::vector const& arguments, std::vector& newargs) { std::vector::const_iterator i; @@ -1399,8 +1378,8 @@ void cmSystemTools::ExpandListArgument(const std::string& arg, } } -bool cmSystemTools::SimpleGlob(const cmStdString& glob, - std::vector& files, +bool cmSystemTools::SimpleGlob(const cmStdString& glob, + std::vector& files, int type /* = 0 */) { files.clear(); @@ -1440,8 +1419,8 @@ bool cmSystemTools::SimpleGlob(const cmStdString& glob, { continue; } - if ( sfname.size() >= ppath.size() && - sfname.substr(0, ppath.size()) == + if ( sfname.size() >= ppath.size() && + sfname.substr(0, ppath.size()) == ppath ) { files.push_back(fname); @@ -1461,10 +1440,10 @@ cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext) } //std::string ext = cmSystemTools::LowerCase(cext); std::string ext = cext; - if ( ext == "c" || ext == ".c" || - ext == "m" || ext == ".m" + if ( ext == "c" || ext == ".c" || + ext == "m" || ext == ".m" ) { return cmSystemTools::C_FILE_FORMAT; } - if ( + if ( ext == "C" || ext == ".C" || ext == "M" || ext == ".M" || ext == "c++" || ext == ".c++" || @@ -1473,22 +1452,22 @@ cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext) ext == "cxx" || ext == ".cxx" || ext == "mm" || ext == ".mm" ) { return cmSystemTools::CXX_FILE_FORMAT; } - if ( + if ( ext == "f" || ext == ".f" || ext == "F" || ext == ".F" || ext == "f77" || ext == ".f77" || ext == "f90" || ext == ".f90" || ext == "for" || ext == ".for" || - ext == "f95" || ext == ".f95" + ext == "f95" || ext == ".f95" ) { return cmSystemTools::FORTRAN_FILE_FORMAT; } if ( ext == "java" || ext == ".java" ) { return cmSystemTools::JAVA_FILE_FORMAT; } - if ( - ext == "H" || ext == ".H" || - ext == "h" || ext == ".h" || + if ( + ext == "H" || ext == ".H" || + ext == "h" || ext == ".h" || ext == "h++" || ext == ".h++" || - ext == "hm" || ext == ".hm" || - ext == "hpp" || ext == ".hpp" || + ext == "hm" || ext == ".hm" || + ext == "hpp" || ext == ".hpp" || ext == "hxx" || ext == ".hxx" || ext == "in" || ext == ".in" || ext == "txx" || ext == ".txx" @@ -1501,18 +1480,18 @@ cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext) ext == "a" || ext == ".a") { return cmSystemTools::STATIC_LIBRARY_FILE_FORMAT; } if ( ext == "o" || ext == ".o" || - ext == "obj" || ext == ".obj") + ext == "obj" || ext == ".obj") { return cmSystemTools::OBJECT_FILE_FORMAT; } #ifdef __APPLE__ - if ( ext == "dylib" || ext == ".dylib" ) + if ( ext == "dylib" || ext == ".dylib" ) { return cmSystemTools::SHARED_LIBRARY_FILE_FORMAT; } - if ( ext == "so" || ext == ".so" || - ext == "bundle" || ext == ".bundle" ) - { return cmSystemTools::MODULE_FILE_FORMAT; } + if ( ext == "so" || ext == ".so" || + ext == "bundle" || ext == ".bundle" ) + { return cmSystemTools::MODULE_FILE_FORMAT; } #else // __APPLE__ - if ( ext == "so" || ext == ".so" || - ext == "sl" || ext == ".sl" || - ext == "dll" || ext == ".dll" ) + if ( ext == "so" || ext == ".so" || + ext == "sl" || ext == ".sl" || + ext == "dll" || ext == ".dll" ) { return cmSystemTools::SHARED_LIBRARY_FILE_FORMAT; } #endif // __APPLE__ return cmSystemTools::UNKNOWN_FILE_FORMAT; @@ -1708,7 +1687,7 @@ bool cmSystemTools::IsPathToFramework(const char* path) return false; } -bool cmSystemTools::CreateTar(const char* outFileName, +bool cmSystemTools::CreateTar(const char* outFileName, const std::vector& files, bool gzip, bool bzip2, bool verbose) { @@ -1773,7 +1752,7 @@ namespace{ static time_t now; size_t u_width = 6; size_t gs_width = 13; - + /* * We avoid collecting the entire list in memory at once by * listing things as we see them. However, that also means we can't @@ -1788,7 +1767,7 @@ namespace{ fprintf(out, "%s %d ", archive_entry_strmode(entry), archive_entry_nlink(entry)); - + /* Use uname if it's present, else uid. */ p = archive_entry_uname(entry); if ((p == NULL) || (*p == '\0')) @@ -1809,7 +1788,7 @@ namespace{ { fprintf(out, "%s", p); w = strlen(p); - } + } else { sprintf(tmp, "%lu", @@ -1817,20 +1796,20 @@ namespace{ w = strlen(tmp); fprintf(out, "%s", tmp); } - + /* * Print device number or file size, right-aligned so as to make * total width of group and devnum/filesize fields be gs_width. * If gs_width is too small, grow it. */ if (archive_entry_filetype(entry) == AE_IFCHR - || archive_entry_filetype(entry) == AE_IFBLK) + || archive_entry_filetype(entry) == AE_IFBLK) { sprintf(tmp, "%lu,%lu", (unsigned long)archive_entry_rdevmajor(entry), (unsigned long)archive_entry_rdevminor(entry)); } - else + else { /* * Note the use of platform-dependent macros to format @@ -1851,7 +1830,7 @@ namespace{ #define HALF_YEAR (time_t)365 * 86400 / 2 #if defined(_WIN32) && !defined(__CYGWIN__) /* Windows' strftime function does not support %e format. */ -#define DAY_FMT "%d" +#define DAY_FMT "%d" #else #define DAY_FMT "%e" /* Day number without leading zeros */ #endif @@ -1881,15 +1860,15 @@ namespace{ #ifdef __BORLANDC__ # pragma warn -8066 /* unreachable code */ #endif - + long copy_data(struct archive *ar, struct archive *aw) { long r; const void *buff; size_t size; off_t offset; - - for (;;) + + for (;;) { r = archive_read_data_block(ar, &buff, &size, &offset); if (r == ARCHIVE_EOF) @@ -1901,7 +1880,7 @@ long copy_data(struct archive *ar, struct archive *aw) return (r); } r = archive_write_data_block(aw, buff, size, offset); - if (r != ARCHIVE_OK) + if (r != ARCHIVE_OK) { cmSystemTools::Message("archive_write_data_block()", archive_error_string(aw)); @@ -1911,7 +1890,7 @@ long copy_data(struct archive *ar, struct archive *aw) return r; } -bool extract_tar(const char* outFileName, bool verbose, +bool extract_tar(const char* outFileName, bool verbose, bool extract) { struct archive* a = archive_read_new(); @@ -1921,12 +1900,12 @@ bool extract_tar(const char* outFileName, bool verbose, struct archive_entry *entry; int r = archive_read_open_file(a, outFileName, 10240); if(r) - { + { cmSystemTools::Error("Problem with archive_read_open_file(): ", archive_error_string(a)); return false; } - for (;;) + for (;;) { r = archive_read_next_header(a, &entry); if (r == ARCHIVE_EOF) @@ -1969,7 +1948,7 @@ bool extract_tar(const char* outFileName, bool verbose, cmSystemTools::Error("Current file:", archive_entry_pathname(entry)); } - else + else { copy_data(a, ext); r = archive_write_finish_entry(ext); @@ -1991,9 +1970,9 @@ bool extract_tar(const char* outFileName, bool verbose, } } -#endif +#endif -bool cmSystemTools::ExtractTar(const char* outFileName, +bool cmSystemTools::ExtractTar(const char* outFileName, bool , bool verbose) { #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -2005,7 +1984,7 @@ bool cmSystemTools::ExtractTar(const char* outFileName, #endif } -bool cmSystemTools::ListTar(const char* outFileName, +bool cmSystemTools::ListTar(const char* outFileName, bool , bool verbose) { @@ -2121,8 +2100,8 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, } void cmSystemTools::DoNotInheritStdPipes() -{ -#ifdef _WIN32 +{ +#ifdef _WIN32 // Check to see if we are attached to a console // if so, then do not stop the inherited pipes // or stdout and stderr will not show up in dos diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index ce499591d..641c89fae 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -29,9 +29,9 @@ class cmSystemTools: public cmsys::SystemTools { public: typedef cmsys::SystemTools Superclass; - + /** Expand out any arguements in the vector that have ; separated - * strings into multiple arguements. A new vector is created + * strings into multiple arguements. A new vector is created * containing the expanded versions of all arguments in argsIn. */ static void ExpandList(std::vector const& argsIn, @@ -52,7 +52,7 @@ public: typedef void (*ErrorCallback)(const char*, const char*, bool&, void*); /** * Set the function used by GUI's to display error messages - * Function gets passed: message as a const char*, + * Function gets passed: message as a const char*, * title as a const char*, and a reference to bool that when * set to false, will disable furthur messages (cancel). */ @@ -75,10 +75,13 @@ public: typedef void (*StdoutCallback)(const char*, int length, void*); static void SetStdoutCallback(StdoutCallback, void* clientData=0); + ///! Send a string to stderr. Stdout callbacks will not be invoced. + static void Stderr(const char* s, int length); + ///! Return true if there was an error at any point. - static bool GetErrorOccuredFlag() + static bool GetErrorOccuredFlag() { - return cmSystemTools::s_ErrorOccured || + return cmSystemTools::s_ErrorOccured || cmSystemTools::s_FatalErrorOccured; } ///! If this is set to true, cmake stops processing commands. @@ -91,7 +94,7 @@ public: cmSystemTools::s_ErrorOccured = true; } ///! Return true if there was an error at any point. - static bool GetFatalErrorOccured() + static bool GetFatalErrorOccured() { return cmSystemTools::s_FatalErrorOccured; } @@ -102,25 +105,25 @@ public: cmSystemTools::s_FatalErrorOccured = false; cmSystemTools::s_ErrorOccured = false; } - + /** * Does a string indicates that CMake/CPack/CTest internally * forced this value. This is not the same as On, but this * may be considered as "internally switched on". */ static bool IsInternallyOn(const char* val); - /** + /** * does a string indicate a true or on value ? This is not the same - * as ifdef. - */ + * as ifdef. + */ static bool IsOn(const char* val); - - /** + + /** * does a string indicate a false or off value ? Note that this is * not the same as !IsOn(...) because there are a number of * ambiguous values such as "/usr/local/bin" a path will result in * IsON and IsOff both returning false. Note that the special path - * NOTFOUND, *-NOTFOUND or IGNORE will cause IsOff to return true. + * NOTFOUND, *-NOTFOUND or IGNORE will cause IsOff to return true. */ static bool IsOff(const char* val); @@ -128,7 +131,7 @@ public: static bool IsNOTFOUND(const char* value); ///! Return true if the path is a framework static bool IsPathToFramework(const char* value); - + static bool DoesFileExistWithExtensions( const char *name, const std::vector& sourceExts); @@ -154,13 +157,13 @@ public: * want to find. 0 means all files, -1 means directories, 1 means * files only. This method returns true if search was succesfull. */ - static bool SimpleGlob(const cmStdString& glob, - std::vector& files, + static bool SimpleGlob(const cmStdString& glob, + std::vector& files, int type = 0); - + ///! Copy a file. static bool cmCopyFile(const char* source, const char* destination); - static bool CopyFileIfDifferent(const char* source, + static bool CopyFileIfDifferent(const char* source, const char* destination); /** Rename a file or directory within a single disk volume (atomic @@ -184,45 +187,53 @@ public: * If timeout is specified, the command will be terminated after * timeout expires. */ - static bool RunCommand(const char* command, std::string& output, + static bool RunCommand(const char* command, std::string& output, const char* directory = 0, bool verbose = true, int timeout = 0); static bool RunCommand(const char* command, std::string& output, - int &retVal, const char* directory = 0, - bool verbose = true, int timeout = 0); + int &retVal, const char* directory = 0, + bool verbose = true, int timeout = 0); /** - * Run a single executable command and put the stdout and stderr - * in output. + * Run a single executable command * - * If verbose is false, no user-viewable output from the program - * being run will be generated. + * Output is controlled with outputflag. If outputflag is OUTPUT_NONE, no + * user-viewable output from the program being run will be generated. + * OUTPUT_MERGE is the legacy behaviour where stdout and stderr are merged + * into stdout. OUTPUT_NORMAL passes through the output to stdout/stderr as + * it was received. * * If timeout is specified, the command will be terminated after * timeout expires. Timeout is specified in seconds. * * Argument retVal should be a pointer to the location where the - * exit code will be stored. If the retVal is not specified and - * the program exits with a code other than 0, then the this + * exit code will be stored. If the retVal is not specified and + * the program exits with a code other than 0, then the this * function will return false. * * If the command has spaces in the path the caller MUST call * cmSystemTools::ConvertToRunCommandPath on the command before passing * it into this function or it will not work. The command must be correctly - * escaped for this to with spaces. + * escaped for this to with spaces. */ + enum OutputOption + { + OUTPUT_NONE = 0, + OUTPUT_MERGE, + OUTPUT_NORMAL + }; static bool RunSingleCommand(const char* command, std::string* output = 0, - int* retVal = 0, const char* dir = 0, - bool verbose = true, + int* retVal = 0, const char* dir = 0, + OutputOption outputflag = OUTPUT_MERGE, double timeout = 0.0); - /** + /** * In this version of RunSingleCommand, command[0] should be * the command to run, and each argument to the command should * be in comand[1]...command[command.size()] */ static bool RunSingleCommand(std::vector const& command, std::string* output = 0, - int* retVal = 0, const char* dir = 0, - bool verbose = true, + int* retVal = 0, const char* dir = 0, + OutputOption outputflag = OUTPUT_MERGE, double timeout = 0.0); /** @@ -295,7 +306,7 @@ public: static const char* GetWindows9xComspecSubstitute(); /** Windows if this is true, the CreateProcess in RunCommand will - * not show new consol windows when running programs. + * not show new consol windows when running programs. */ static void SetRunCommandHideConsole(bool v){s_RunCommandHideConsole = v;} static bool GetRunCommandHideConsole(){ return s_RunCommandHideConsole;} @@ -303,16 +314,16 @@ public: * result of strerror(errno) */ static void ReportLastSystemError(const char* m); - + /** a general output handler for cmsysProcess */ static int WaitForLine(cmsysProcess* process, std::string& line, double timeout, std::vector& out, std::vector& err); - + /** Split a string on its newlines into multiple lines. Returns false only if the last line stored had no newline. */ - static bool Split(const char* s, std::vector& l); + static bool Split(const char* s, std::vector& l); static void SetForceUnixPaths(bool v) { s_ForceUnixPaths = v; @@ -327,14 +338,14 @@ public: static void ConvertToOutputSlashes(std::string& path); // ConvertToRunCommandPath does not use s_ForceUnixPaths and should - // be used when RunCommand is called from cmake, because the + // be used when RunCommand is called from cmake, because the // running cmake needs paths to be in its format static std::string ConvertToRunCommandPath(const char* path); //! Check if the first string ends with the second one. static bool StringEndsWith(const char* str1, const char* str2); - - /** compute the relative path from local to remote. local must - be a directory. remote can be a file or a directory. + + /** compute the relative path from local to remote. local must + be a directory. remote can be a file or a directory. Both remote and local must be full paths. Basically, if you are in directory local and you want to access the file in remote what is the relative path to do that. For example: @@ -385,7 +396,7 @@ public: static bool CreateTar(const char* outFileName, const std::vector& files, bool gzip, bool bzip2, bool verbose); - static bool ExtractTar(const char* inFileName, bool gzip, + static bool ExtractTar(const char* inFileName, bool gzip, bool verbose); // This should be called first thing in main // it will keep child processes from inheriting the diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 52b907217..6a937b8d3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -17,6 +17,7 @@ #include "cmGlobalGenerator.h" #include "cmComputeLinkInformation.h" #include "cmDocumentCompileDefinitions.h" +#include "cmDocumentLocationUndefined.h" #include "cmListFileCache.h" #include "cmGeneratorExpression.h" #include @@ -25,12 +26,35 @@ #include #include // required for atof #include -const char* cmTarget::TargetTypeNames[] = { - "EXECUTABLE", "STATIC_LIBRARY", - "SHARED_LIBRARY", "MODULE_LIBRARY", "UTILITY", "GLOBAL_TARGET", - "INSTALL_FILES", "INSTALL_PROGRAMS", "INSTALL_DIRECTORY", - "UNKNOWN_LIBRARY" -}; + +const char* cmTarget::GetTargetTypeName(TargetType targetType) +{ + switch( targetType ) + { + case cmTarget::STATIC_LIBRARY: + return "STATIC_LIBRARY"; + case cmTarget::MODULE_LIBRARY: + return "MODULE_LIBRARY"; + case cmTarget::SHARED_LIBRARY: + return "SHARED_LIBRARY"; + case cmTarget::EXECUTABLE: + return "EXECUTABLE"; + case cmTarget::UTILITY: + return "UTILITY"; + case cmTarget::GLOBAL_TARGET: + return "GLOBAL_TARGET"; + case cmTarget::INSTALL_FILES: + return "INSTALL_FILES"; + case cmTarget::INSTALL_PROGRAMS: + return "INSTALL_PROGRAMS"; + case cmTarget::INSTALL_DIRECTORY: + return "INSTALL_DIRECTORY"; + case cmTarget::UNKNOWN_LIBRARY: + return "UNKNOWN_LIBRARY"; + } + assert(0 && "Unexpected target type"); + return 0; +} //---------------------------------------------------------------------------- struct cmTarget::OutputInfo @@ -108,12 +132,50 @@ cmTarget::cmTarget() this->LinkLibrariesAnalyzed = false; this->HaveInstallRule = false; this->DLLPlatform = false; + this->IsApple = false; this->IsImportedTarget = false; } //---------------------------------------------------------------------------- void cmTarget::DefineProperties(cmake *cm) { + cm->DefineProperty + ("AUTOMOC", cmProperty::TARGET, + "Should the target be processed with automoc (for Qt projects).", + "AUTOMOC is a boolean specifying whether CMake will handle " + "the Qt moc preprocessor automatically, i.e. without having to use " + "the QT4_WRAP_CPP() macro. Currently Qt4 is supported. " + "When this property is set to TRUE, CMake will scan the source files " + "at build time and invoke moc accordingly. " + "If an #include statement like #include \"moc_foo.cpp\" is found, " + "the Q_OBJECT class declaration is expected in the header, and moc is " + "run on the header file. " + "If an #include statement like #include \"foo.moc\" is found, " + "then a Q_OBJECT is expected in the current source file and moc " + "is run on the file itself. " + "Additionally, all header files are parsed for Q_OBJECT macros, " + "and if found, moc is also executed on those files. The resulting " + "moc files, which are not included as shown above in any of the source " + "files are included in a generated _automoc.cpp file, " + "which is compiled as part of the target." + "This property is initialized by the value of the variable " + "CMAKE_AUTOMOC if it is set when a target is created.\n" + "Additional command line options for moc can be set via the " + "AUTOMOC_MOC_OPTIONS property.\n" + "By setting the CMAKE_AUTOMOC_RELAXED_MODE variable to TRUE the rules " + "for searching the files which will be processed by moc can be relaxed. " + "See the documentation for this variable for more details."); + + cm->DefineProperty + ("AUTOMOC_MOC_OPTIONS", cmProperty::TARGET, + "Additional options for moc when using automoc (see the AUTOMOC property)", + "This property is only used if the AUTOMOC property is set to TRUE for " + "this target. In this case, it holds additional command line options " + "which will be used when moc is executed during the build, i.e. it is " + "equivalent to the optional OPTIONS argument of the qt4_wrap_cpp() " + "macro.\n" + "By default it is empty."); + cm->DefineProperty ("BUILD_WITH_INSTALL_RPATH", cmProperty::TARGET, "Should build tree targets have install tree rpaths.", @@ -526,15 +588,6 @@ void cmTarget::DefineProperties(cmake *cm) "value is the default. " "See documentation of CMAKE__LINKER_PREFERENCE variables."); -#define CM_LOCATION_UNDEFINED_BEHAVIOR \ - "\n" \ - "Do not set properties that affect the location of the target after " \ - "reading this property. These include properties whose names match " \ - "\"(RUNTIME|LIBRARY|ARCHIVE)_OUTPUT_(NAME|DIRECTORY)(_)?\" " \ - "or \"(IMPLIB_)?(PREFIX|SUFFIX)\". " \ - "Failure to follow this rule is not diagnosed and leaves the location " \ - "of the target undefined." - cm->DefineProperty ("LOCATION", cmProperty::TARGET, "Read-only location of a target on disk.", @@ -554,7 +607,7 @@ void cmTarget::DefineProperties(cmake *cm) "In CMake 2.8.4 and above add_custom_command recognizes generator " "expressions to refer to target locations anywhere in the command. " "Therefore this property is not needed for creating custom commands." - CM_LOCATION_UNDEFINED_BEHAVIOR); + CM_LOCATION_UNDEFINED_BEHAVIOR("reading this property")); cm->DefineProperty ("LOCATION_", cmProperty::TARGET, @@ -568,7 +621,7 @@ void cmTarget::DefineProperties(cmake *cm) "arbitrary available configuration. " "Use the MAP_IMPORTED_CONFIG_ property to map imported " "configurations explicitly." - CM_LOCATION_UNDEFINED_BEHAVIOR); + CM_LOCATION_UNDEFINED_BEHAVIOR("reading this property")); cm->DefineProperty ("LINK_DEPENDS", cmProperty::TARGET, @@ -597,6 +650,9 @@ void cmTarget::DefineProperties(cmake *cm) "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. " + "This property is initialized by the value of the variable " + "CMAKE_LINK_INTERFACE_LIBRARIES if it is set when a target is " + "created. " "This property is ignored for STATIC libraries."); cm->DefineProperty @@ -896,6 +952,17 @@ void cmTarget::DefineProperties(cmake *cm) "module is loaded. " ); + cm->DefineProperty + ("Fortran_FORMAT", cmProperty::TARGET, + "Set to FIXED or FREE to indicate the Fortran source layout.", + "This property tells CMake whether the Fortran source files " + "in a target use fixed-format or free-format. " + "CMake will pass the corresponding format flag to the compiler. " + "Use the source-specific Fortran_FORMAT property to change the " + "format of a specific source file. " + "If the variable CMAKE_Fortran_FORMAT is set when a target " + "is created its value is used to initialize this property."); + cm->DefineProperty ("Fortran_MODULE_DIRECTORY", cmProperty::TARGET, "Specify output directory for Fortran modules provided by the target.", @@ -907,6 +974,23 @@ void cmTarget::DefineProperties(cmake *cm) "If the variable CMAKE_Fortran_MODULE_DIRECTORY is set when a target " "is created its value is used to initialize this property."); + cm->DefineProperty + ("GNUtoMS", cmProperty::TARGET, + "Convert GNU import library (.dll.a) to MS format (.lib).", + "When linking a shared library or executable that exports symbols " + "using GNU tools on Windows (MinGW/MSYS) with Visual Studio installed " + "convert the import library (.dll.a) from GNU to MS format (.lib). " + "Both import libraries will be installed by install(TARGETS) and " + "exported by install(EXPORT) and export() to be linked by applications " + "with either GNU- or MS-compatible tools." + "\n" + "If the variable CMAKE_GNUtoMS is set when a target " + "is created its value is used to initialize this property. " + "The variable must be set prior to the first command that enables " + "a language such as project() or enable_language(). " + "CMake provides the variable as an option to the user automatically " + "when configuring on Windows with GNU tools."); + cm->DefineProperty ("XCODE_ATTRIBUTE_", cmProperty::TARGET, "Set Xcode target attributes directly.", @@ -952,7 +1036,7 @@ void cmTarget::DefineProperties(cmake *cm) "provider property."); cm->DefineProperty ("VS_SCC_LOCALPATH", cmProperty::TARGET, - "Visual Studio Source Code Control Provider.", + "Visual Studio Source Code Control Local Path.", "Can be set to change the visual studio source code control " "local path property."); cm->DefineProperty @@ -960,6 +1044,42 @@ void cmTarget::DefineProperties(cmake *cm) "Visual Studio Source Code Control Project.", "Can be set to change the visual studio source code control " "project name property."); + cm->DefineProperty + ("VS_SCC_AUXPATH", cmProperty::TARGET, + "Visual Studio Source Code Control Aux Path.", + "Can be set to change the visual studio source code control " + "auxpath property."); + cm->DefineProperty + ("VS_GLOBAL_PROJECT_TYPES", cmProperty::TARGET, + "Visual Studio project type(s).", + "Can be set to one or more UUIDs recognized by Visual Studio " + "to indicate the type of project. This value is copied " + "verbatim into the generated project file. Example for a " + "managed C++ unit testing project: \"" + "{3AC096D0-A1C2-E12C-1390-A8335801FDAB};" + "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\". UUIDs are " + "semicolon-delimited."); + cm->DefineProperty + ("VS_GLOBAL_KEYWORD", cmProperty::TARGET, + "Visual Studio project keyword.", + "Sets the \"keyword\" attribute for a generated Visual Studio " + "project. Defaults to \"Win32Proj\". You may wish to override " + "this value with \"ManagedCProj\", for example, in a Visual " + "Studio managed C++ unit test project."); + cm->DefineProperty + ("VS_DOTNET_REFERENCES", cmProperty::TARGET, + "Visual Studio managed project .NET references", + "Adds one or more semicolon-delimited .NET references to a " + "generated Visual Studio project. For example, \"System;" + "System.Windows.Forms\"."); + cm->DefineProperty + ("VS_GLOBAL_", cmProperty::TARGET, + "Visual Studio project-specific global variable.", + "Tell the Visual Studio generator to set the global variable " + "'' to a given value in the generated Visual Studio " + "project. Ignored on other generators. Qt integration works " + "better if VS_GLOBAL_QtVersion is set to the version " + "FindQt4.cmake found. For example, \"4.7.3\""); #if 0 cm->DefineProperty @@ -1099,6 +1219,9 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")); + // Check whether we are targeting an Apple platform. + this->IsApple = this->Makefile->IsOn("APPLE"); + // Setup default property values. this->SetPropertyDefault("INSTALL_NAME_DIR", ""); this->SetPropertyDefault("INSTALL_RPATH", ""); @@ -1108,8 +1231,13 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("ARCHIVE_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0); this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0); + this->SetPropertyDefault("Fortran_FORMAT", 0); this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0); + this->SetPropertyDefault("GNUtoMS", 0); this->SetPropertyDefault("OSX_ARCHITECTURES", 0); + this->SetPropertyDefault("AUTOMOC", 0); + this->SetPropertyDefault("AUTOMOC_MOC_OPTIONS", 0); + this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0); // Collect the set of configuration types. std::vector configNames; @@ -1412,7 +1540,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) // the fact that the name matched a target was just a coincidence. if(cmSystemTools::FileIsFullPath(dep.c_str())) { - if(t->GetType() >= cmTarget::EXECUTABLE && + if(t->GetType() >= cmTarget::EXECUTABLE && t->GetType() <= cmTarget::MODULE_LIBRARY) { // This is really only for compatibility so we do not need to @@ -2191,13 +2319,14 @@ void cmTarget::SetProperty(const char* prop, const char* value) } //---------------------------------------------------------------------------- -void cmTarget::AppendProperty(const char* prop, const char* value) +void cmTarget::AppendProperty(const char* prop, const char* value, + bool asString) { if (!prop) { return; } - this->Properties.AppendProperty(prop, value, cmProperty::TARGET); + this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString); this->MaybeInvalidatePropertyCache(prop); } @@ -2302,7 +2431,7 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) std::string msg = "cmTarget::GetOutputInfo called for "; msg += this->GetName(); msg += " which has type "; - msg += cmTarget::TargetTypeNames[this->GetType()]; + msg += cmTarget::GetTargetTypeName(this->GetType()); this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); abort(); return 0; @@ -2601,40 +2730,7 @@ const char *cmTarget::GetProperty(const char* prop, // the type property returns what type the target is if (!strcmp(prop,"TYPE")) { - switch( this->GetType() ) - { - case cmTarget::STATIC_LIBRARY: - return "STATIC_LIBRARY"; - // break; /* unreachable */ - case cmTarget::MODULE_LIBRARY: - return "MODULE_LIBRARY"; - // break; /* unreachable */ - case cmTarget::SHARED_LIBRARY: - return "SHARED_LIBRARY"; - // break; /* unreachable */ - case cmTarget::EXECUTABLE: - return "EXECUTABLE"; - // break; /* unreachable */ - case cmTarget::UTILITY: - return "UTILITY"; - // break; /* unreachable */ - case cmTarget::GLOBAL_TARGET: - return "GLOBAL_TARGET"; - // break; /* unreachable */ - case cmTarget::INSTALL_FILES: - return "INSTALL_FILES"; - // break; /* unreachable */ - case cmTarget::INSTALL_PROGRAMS: - return "INSTALL_PROGRAMS"; - // break; /* unreachable */ - case cmTarget::INSTALL_DIRECTORY: - return "INSTALL_DIRECTORY"; - // break; /* unreachable */ - case cmTarget::UNKNOWN_LIBRARY: - return "UNKNOWN_LIBRARY"; - // break; /* unreachable */ - } - return 0; + return cmTarget::GetTargetTypeName(this->GetType()); } bool chain = false; const char *retVal = @@ -3268,7 +3364,11 @@ void cmTarget::GetLibraryNames(std::string& name, // the library version as the soversion. soversion = version; } - bool isApple = this->Makefile->IsOn("APPLE"); + if(!version && soversion) + { + // Use the soversion as the library version. + version = soversion; + } // Get the components of the library name. std::string prefix; @@ -3280,47 +3380,12 @@ void cmTarget::GetLibraryNames(std::string& name, name = prefix+base+suffix; // The library's soname. - if(isApple) - { - soName = prefix+base; - } - else - { - soName = name; - } - if(soversion) - { - soName += "."; - soName += soversion; - } - if(isApple) - { - soName += suffix; - } + this->ComputeVersionedName(soName, prefix, base, suffix, + name, soversion); // The library's real name on disk. - if(isApple) - { - realName = prefix+base; - } - else - { - realName = name; - } - if(version) - { - realName += "."; - realName += version; - } - else if(soversion) - { - realName += "."; - realName += soversion; - } - if(isApple) - { - realName += suffix; - } + this->ComputeVersionedName(realName, prefix, base, suffix, + name, version); // The import library name. if(this->GetType() == cmTarget::SHARED_LIBRARY || @@ -3337,6 +3402,23 @@ void cmTarget::GetLibraryNames(std::string& name, pdbName = prefix+base+".pdb"; } +//---------------------------------------------------------------------------- +void cmTarget::ComputeVersionedName(std::string& vName, + std::string const& prefix, + std::string const& base, + std::string const& suffix, + std::string const& name, + const char* version) +{ + vName = this->IsApple? (prefix+base) : name; + if(version) + { + vName += "."; + vName += version; + } + vName += this->IsApple? suffix : std::string(); +} + //---------------------------------------------------------------------------- void cmTarget::GetExecutableNames(std::string& name, std::string& realName, @@ -3399,6 +3481,26 @@ void cmTarget::GetExecutableNames(std::string& name, pdbName = prefix+base+".pdb"; } +//---------------------------------------------------------------------------- +bool cmTarget::HasImplibGNUtoMS() +{ + return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); +} + +//---------------------------------------------------------------------------- +bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName, + std::string& out, const char* newExt) +{ + if(this->HasImplibGNUtoMS() && + gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a") + { + out = gnuName.substr(0, gnuName.size()-6); + out += newExt? newExt : ".lib"; + return true; + } + return false; +} + //---------------------------------------------------------------------------- void cmTarget::GenerateTargetManifest(const char* config) { @@ -3688,9 +3790,11 @@ const char* cmTarget::GetOutputTargetType(bool implib) } //---------------------------------------------------------------------------- -void cmTarget::ComputeOutputDir(const char* config, +bool cmTarget::ComputeOutputDir(const char* config, bool implib, std::string& out) { + bool usesDefaultOutputDir = false; + // Look for a target property defining the target output directory // based on the target type. std::string targetTypeName = this->GetOutputTargetType(implib); @@ -3742,6 +3846,7 @@ void cmTarget::ComputeOutputDir(const char* config, if(out.empty()) { // Default to the current output directory. + usesDefaultOutputDir = true; out = "."; } @@ -3754,9 +3859,22 @@ void cmTarget::ComputeOutputDir(const char* config, // The generator may add the configuration's subdirectory. if(config && *config) { + const char *platforms = this->Makefile->GetDefinition( + "CMAKE_XCODE_EFFECTIVE_PLATFORMS"); + std::string suffix = + usesDefaultOutputDir && platforms ? "$(EFFECTIVE_PLATFORM_NAME)" : ""; this->Makefile->GetLocalGenerator()->GetGlobalGenerator()-> - AppendDirectoryForConfig("/", config, "", out); + AppendDirectoryForConfig("/", config, suffix.c_str(), out); } + + return usesDefaultOutputDir; +} + +//---------------------------------------------------------------------------- +bool cmTarget::UsesDefaultOutputDir(const char* config, bool implib) +{ + std::string dir; + return this->ComputeOutputDir(config, implib, dir); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 3b1f016a6..59f018483 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -62,7 +62,7 @@ public: SHARED_LIBRARY, MODULE_LIBRARY, UTILITY, GLOBAL_TARGET, INSTALL_FILES, INSTALL_PROGRAMS, INSTALL_DIRECTORY, UNKNOWN_LIBRARY}; - static const char* TargetTypeNames[]; + static const char* GetTargetTypeName(TargetType targetType); enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD }; /** @@ -224,7 +224,7 @@ public: ///! Set/Get a property of this target file void SetProperty(const char *prop, const char *value); - void AppendProperty(const char* prop, const char* value); + void AppendProperty(const char* prop, const char* value,bool asString=false); const char *GetProperty(const char *prop); const char *GetProperty(const char *prop, cmProperty::ScopeType scope); bool GetPropertyAsBool(const char *prop); @@ -369,6 +369,14 @@ public: std::string& impName, std::string& pdbName, const char* config); + /** Does this target have a GNU implib to convert to MS format? */ + bool HasImplibGNUtoMS(); + + /** Convert the given GNU import library name (.dll.a) to a name with a new + extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */ + bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, + const char* newExt = 0); + /** Add the target output files to the global generator manifest. */ void GenerateTargetManifest(const char* config); @@ -446,6 +454,10 @@ public: /** Get a build-tree directory in which to place target support files. */ std::string GetSupportDirectory() const; + /** Return whether this target uses the default value for its output + directory. */ + bool UsesDefaultOutputDir(const char* config, bool implib); + private: /** * A list of direct dependencies. Use in conjunction with DependencyMap. @@ -553,12 +565,13 @@ private: cmPropertyMap Properties; LinkLibraryVectorType OriginalLinkLibraries; bool DLLPlatform; + bool IsApple; bool IsImportedTarget; // Cache target output paths for each configuration. struct OutputInfo; OutputInfo const* GetOutputInfo(const char* config); - void ComputeOutputDir(const char* config, bool implib, std::string& out); + bool ComputeOutputDir(const char* config, bool implib, std::string& out); // Cache import information from properties for each configuration. struct ImportInfo; @@ -591,6 +604,12 @@ private: cmTargetInternalPointer Internal; void ConstructSourceFileFlags(); + void ComputeVersionedName(std::string& vName, + std::string const& prefix, + std::string const& base, + std::string const& suffix, + std::string const& name, + const char* version); }; typedef std::map cmTargets; diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 805959def..36c4ca8bd 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -95,8 +95,8 @@ bool cmTargetLinkLibrariesCommand bool haveLLT = false; // Start with primary linking and switch to link interface - // specification when the keyword is encountered. - this->DoingInterface = false; + // specification if the keyword is encountered as the first argument. + this->CurrentProcessingState = ProcessingLinkLibraries; // add libraries, nothe that there is an optional prefix // of debug and optimized than can be used @@ -104,7 +104,7 @@ bool cmTargetLinkLibrariesCommand { if(args[i] == "LINK_INTERFACE_LIBRARIES") { - this->DoingInterface = true; + this->CurrentProcessingState = ProcessingLinkInterface; if(i != 1) { this->Makefile->IssueMessage( @@ -115,6 +115,32 @@ bool cmTargetLinkLibrariesCommand return true; } } + else if(args[i] == "LINK_PUBLIC") + { + if(i != 1 && this->CurrentProcessingState != ProcessingPrivateInterface) + { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + "The LINK_PUBLIC or LINK_PRIVATE option must appear as the second " + "argument, just after the target name." + ); + return true; + } + this->CurrentProcessingState = ProcessingPublicInterface; + } + else if(args[i] == "LINK_PRIVATE") + { + if(i != 1 && this->CurrentProcessingState != ProcessingPublicInterface) + { + this->Makefile->IssueMessage( + cmake::FATAL_ERROR, + "The LINK_PUBLIC or LINK_PRIVATE option must appear as the second " + "argument, just after the target name." + ); + return true; + } + this->CurrentProcessingState = ProcessingPrivateInterface; + } else if(args[i] == "debug") { if(haveLLT) @@ -186,10 +212,12 @@ bool cmTargetLinkLibrariesCommand 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 && + // If any of the LINK_ options were given, make sure the + // LINK_INTERFACE_LIBRARIES target property exists. + // Use of any of the new keywords implies awareness of + // this property. And if no libraries are named, it should + // result in an empty link interface. + if(this->CurrentProcessingState != ProcessingLinkLibraries && !this->Target->GetProperty("LINK_INTERFACE_LIBRARIES")) { this->Target->SetProperty("LINK_INTERFACE_LIBRARIES", ""); @@ -217,11 +245,15 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt) { // Handle normal case first. - if(!this->DoingInterface) + if(this->CurrentProcessingState != ProcessingLinkInterface) { this->Makefile ->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt); - return; + if (this->CurrentProcessingState != ProcessingPublicInterface) + { + // Not LINK_INTERFACE_LIBRARIES or LINK_PUBLIC, do not add to interface. + return; + } } // Get the list of configurations considered to be DEBUG. diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index ce57df7f2..8df4ac0e8 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -19,7 +19,7 @@ * * cmTargetLinkLibrariesCommand is used to specify a list of libraries to link * into executable(s) or shared objects. The names of the libraries - * should be those defined by the LIBRARY(library) command(s). + * should be those defined by the LIBRARY(library) command(s). */ class cmTargetLinkLibrariesCommand : public cmCommand { @@ -27,7 +27,7 @@ public: /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { return new cmTargetLinkLibrariesCommand; } @@ -47,12 +47,12 @@ public: /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { - return + return "Link a target to given libraries."; } - + /** * More documentation. */ @@ -107,6 +107,18 @@ public: "Libraries specified as \"general\" (or without any keyword) are " "treated as if specified for both \"debug\" and \"optimized\"." "\n" + " target_link_libraries(\n" + " \n" + " [[debug|optimized|general] ] ...\n" + " [\n" + " [[debug|optimized|general] ] ...])\n" + "The LINK_PUBLIC and LINK_PRIVATE modes can be used to specify both " + "the link dependencies and the link interface in one command. " + "Libraries and targets following LINK_PUBLIC are linked to, and are " + "made part of the LINK_INTERFACE_LIBRARIES. Libraries and targets " + "following LINK_PRIVATE are linked to, but are not made part of the " + "LINK_INTERFACE_LIBRARIES. " + "\n" "The library dependency graph is normally acyclic (a DAG), but in the " "case of mutually-dependent STATIC libraries CMake allows the graph " "to contain cycles (strongly connected components). " @@ -130,14 +142,21 @@ public: ")" ; } - + cmTypeMacro(cmTargetLinkLibrariesCommand, cmCommand); private: void LinkLibraryTypeSpecifierWarning(int left, int right); static const char* LinkLibraryTypeNames[3]; cmTarget* Target; - bool DoingInterface; + enum ProcessingState { + ProcessingLinkLibraries, + ProcessingLinkInterface, + ProcessingPublicInterface, + ProcessingPrivateInterface + }; + + ProcessingState CurrentProcessingState; void HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt); }; diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index c25a8b6bf..502c1740d 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -84,13 +84,13 @@ void cmTest::SetProperty(const char* prop, const char* value) } //---------------------------------------------------------------------------- -void cmTest::AppendProperty(const char* prop, const char* value) +void cmTest::AppendProperty(const char* prop, const char* value, bool asString) { if (!prop) { return; } - this->Properties.AppendProperty(prop, value, cmProperty::TEST); + this->Properties.AppendProperty(prop, value, cmProperty::TEST, asString); } //---------------------------------------------------------------------------- diff --git a/Source/cmTest.h b/Source/cmTest.h index e27a24eaf..6223a01ea 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -47,7 +47,7 @@ public: ///! Set/Get a property of this source file void SetProperty(const char *prop, const char *value); - void AppendProperty(const char* prop, const char* value); + void AppendProperty(const char* prop, const char* value,bool asString=false); const char *GetProperty(const char *prop) const; bool GetPropertyAsBool(const char *prop) const; cmPropertyMap &GetProperties() { return this->Properties; }; diff --git a/Source/cmTryCompileCommand.cxx b/Source/cmTryCompileCommand.cxx index 4d39d5456..12ce015d2 100644 --- a/Source/cmTryCompileCommand.cxx +++ b/Source/cmTryCompileCommand.cxx @@ -20,6 +20,14 @@ bool cmTryCompileCommand return false; } + if(this->Makefile->GetCMakeInstance()->GetWorkingMode() == + cmake::FIND_PACKAGE_MODE) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "The TRY_COMPILE() command is not supported in --find-package mode."); + return false; + } + this->TryCompileCode(argv); // if They specified clean then we clean up what we can @@ -32,4 +40,3 @@ bool cmTryCompileCommand } return true; } - diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index 9923d03b7..0d57633f7 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -25,7 +25,7 @@ public: /** * This is a virtual constructor for the command. */ - virtual cmCommand* Clone() + virtual cmCommand* Clone() { return new cmTryCompileCommand; } @@ -45,7 +45,7 @@ public: /** * Succinct documentation. */ - virtual const char* GetTerseDocumentation() + virtual const char* GetTerseDocumentation() { return "Try building some code."; } @@ -102,14 +102,15 @@ public: "In both versions of the command, " "if OUTPUT_VARIABLE is specified, then the " "output from the build process is stored in the given variable. " - "Return the success or failure in " + "The success or failure of the try_compile, i.e. TRUE or FALSE " + "respectively, is returned in " "RESULT_VAR. CMAKE_FLAGS can be used to pass -DVAR:TYPE=VALUE flags " "to the cmake that is run during the build. " "Set variable CMAKE_TRY_COMPILE_CONFIGURATION to choose a build " "configuration." ; } - + cmTypeMacro(cmTryCompileCommand, cmCoreTryCompile); }; diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 4d31a1499..4fc0b13c0 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -22,6 +22,14 @@ bool cmTryRunCommand return false; } + if(this->Makefile->GetCMakeInstance()->GetWorkingMode() == + cmake::FIND_PACKAGE_MODE) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "The TRY_RUN() command is not supported in --find-package mode."); + return false; + } + // build an arg list for TryCompile and extract the runArgs, std::vector tryCompile; @@ -49,8 +57,8 @@ bool cmTryRunCommand { tryCompile.push_back(argv[i]); } - } - else + } + else { if (argv[i] == "OUTPUT_VARIABLE") { @@ -94,8 +102,8 @@ bool cmTryRunCommand // although they could be used together, don't allow it, because // using OUTPUT_VARIABLE makes crosscompiling harder - if (this->OutputVariable.size() - && ((this->RunOutputVariable.size()) + if (this->OutputVariable.size() + && ((this->RunOutputVariable.size()) || (this->CompileOutputVariable.size()))) { cmSystemTools::Error( @@ -141,8 +149,8 @@ bool cmTryRunCommand std::string runOutputContents; if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING")) { - this->DoNotRunExecutable(runArgs, - argv[3], + this->DoNotRunExecutable(runArgs, + argv[3], captureRunOutput ? &runOutputContents : 0); } else @@ -153,7 +161,7 @@ bool cmTryRunCommand // now put the output into the variables if(this->RunOutputVariable.size()) { - this->Makefile->AddDefinition(this->RunOutputVariable.c_str(), + this->Makefile->AddDefinition(this->RunOutputVariable.c_str(), runOutputContents.c_str()); } @@ -167,7 +175,7 @@ bool cmTryRunCommand { runOutputContents = std::string(compileOutput) + runOutputContents; } - this->Makefile->AddDefinition(this->OutputVariable.c_str(), + this->Makefile->AddDefinition(this->OutputVariable.c_str(), runOutputContents.c_str()); } } @@ -194,7 +202,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, int timeout = 0; bool worked = cmSystemTools::RunSingleCommand(finalCommand.c_str(), out, &retVal, - 0, false, timeout); + 0, cmSystemTools::OUTPUT_NONE, timeout); // set the run var char retChar[1000]; if (worked) @@ -212,9 +220,9 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, /* This is only used when cross compiling. Instead of running the executable, two cache variables are created which will hold the results - the executable would have produced. + the executable would have produced. */ -void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, +void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, const std::string& srcFile, std::string* out ) @@ -249,7 +257,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, comment += "Run result of TRY_RUN(), indicates whether the executable " "would have been able to run on its target platform.\n"; comment += detailsString; - this->Makefile->AddCacheDefinition(this->RunResultVariable.c_str(), + this->Makefile->AddCacheDefinition(this->RunResultVariable.c_str(), "PLEASE_FILL_OUT-FAILED_TO_RUN", comment.c_str(), cmCacheManager::STRING); @@ -276,7 +284,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, "would have printed on stdout and stderr on its target platform.\n"; comment += detailsString; - this->Makefile->AddCacheDefinition(internalRunOutputName.c_str(), + this->Makefile->AddCacheDefinition(internalRunOutputName.c_str(), "PLEASE_FILL_OUT-NOTFOUND", comment.c_str(), cmCacheManager::STRING); @@ -294,7 +302,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, if (error) { static bool firstTryRun = true; - std::ofstream file(resultFileName.c_str(), + std::ofstream file(resultFileName.c_str(), firstTryRun ? std::ios::out : std::ios::app); if ( file ) { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index d710405e4..a219ae923 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -178,9 +178,53 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("", 2); (*this->BuildFileStream) << "{" << this->GUID << "}\n"; - this->WriteString("\n", 2); - this->WriteString("\n", 2); - this->WriteString("Win32Proj\n", 2); + const char* vsProjectTypes = + this->Target->GetProperty("VS_GLOBAL_PROJECT_TYPES"); + if(vsProjectTypes) + { + this->WriteString("", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectTypes) << + "\n"; + } + + const char* vsProjectName = this->Target->GetProperty("VS_SCC_PROJECTNAME"); + const char* vsLocalPath = this->Target->GetProperty("VS_SCC_LOCALPATH"); + const char* vsProvider = this->Target->GetProperty("VS_SCC_PROVIDER"); + + if( vsProjectName && vsLocalPath && vsProvider ) + { + this->WriteString("", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectName) << + "\n"; + this->WriteString("", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(vsLocalPath) << + "\n"; + this->WriteString("", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(vsProvider) << + "\n"; + + const char* vsAuxPath = this->Target->GetProperty("VS_SCC_AUXPATH"); + if( vsAuxPath ) + { + this->WriteString("", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(vsAuxPath) << + "\n"; + } + } + + const char* vsGlobalKeyword = + this->Target->GetProperty("VS_GLOBAL_KEYWORD"); + if(!vsGlobalKeyword) + { + this->WriteString("Win32Proj\n", 2); + } + else + { + this->WriteString("", 2); + (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalKeyword) << + "\n"; + } + this->WriteString("", 2); (*this->BuildFileStream) << this->Platform << "\n"; const char* projLabel = this->Target->GetProperty("PROJECT_LABEL"); @@ -210,6 +254,7 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteCustomCommands(); this->WriteObjSources(); this->WriteCLSources(); + this->WriteDotNetReferences(); this->WriteProjectReferences(); this->WriteString( "WriteGroups(); } +void cmVisualStudio10TargetGenerator::WriteDotNetReferences() +{ + const char* vsDotNetReferences + = this->Target->GetProperty("VS_DOTNET_REFERENCES"); + if(vsDotNetReferences) + { + std::string references(vsDotNetReferences); + std::string::size_type position = 0; + + this->WriteString("\n", 1); + while(references.length() > 0) + { + if((position = references.find(";")) == std::string::npos) + { + position = references.length() + 1; + } + + this->WriteString("BuildFileStream) << + cmVS10EscapeXML(references.substr(0, position)) << "\">\n"; + this->WriteString("true" + "\n", 3); + this->WriteString("true" + "\n", 3); + this->WriteString("\n", 2); + + references.erase(0, position + 1); + } + + this->WriteString("\n", 1); + } +} + // ConfigurationType Application, Utility StaticLibrary DynamicLibrary void cmVisualStudio10TargetGenerator::WriteProjectConfigurations() @@ -275,16 +353,24 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() } configType += "\n"; this->WriteString(configType.c_str(), 2); + const char* mfcFlag = this->Target->GetMakefile()->GetDefinition("CMAKE_MFC_FLAG"); - if(mfcFlag) + std::string mfcFlagValue = mfcFlag ? mfcFlag : "0"; + + std::string useOfMfcValue = "false"; + if(mfcFlagValue == "1") { - this->WriteString("true\n", 2); + useOfMfcValue = "Static"; } - else + else if(mfcFlagValue == "2") { - this->WriteString("false\n", 2); + useOfMfcValue = "Dynamic"; } + std::string mfcLine = ""; + mfcLine += useOfMfcValue + "\n"; + this->WriteString(mfcLine.c_str(), 2); + if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY && this->ClOptions[*i]->UsingUnicode()) { @@ -422,7 +508,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, (*this->BuildFileStream ) << sep << out; sep = ";"; } - (*this->BuildFileStream ) << ";%(Outputs)\n"; + (*this->BuildFileStream ) << "\n"; } this->WriteString("\n", 2); } @@ -882,7 +968,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( hasFlags = true; cmVisualStudioGeneratorOptions clOptions(this->LocalGenerator, - 10, cmVisualStudioGeneratorOptions::Compiler, + cmVisualStudioGeneratorOptions::Compiler, cmVS10CLFlagTable, 0, this); clOptions.Parse(flags.c_str()); clOptions.AddDefines(configDefines.c_str()); @@ -1067,7 +1153,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( // TODO: Integrate code below with cmLocalVisualStudio7Generator. cmsys::auto_ptr pOptions( - new Options(this->LocalGenerator, 10, Options::Compiler, + new Options(this->LocalGenerator, Options::Compiler, cmVS10CLFlagTable)); Options& clOptions = *pOptions; @@ -1222,7 +1308,7 @@ cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config) { this->WriteString("\n", 2); cmVisualStudioGeneratorOptions - libOptions(this->LocalGenerator, 10, + libOptions(this->LocalGenerator, cmVisualStudioGeneratorOptions::Linker, cmVS10LibFlagTable, 0, this); libOptions.Parse(libflags?libflags:""); @@ -1302,7 +1388,7 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& flags += flagsConfig; } cmVisualStudioGeneratorOptions - linkOptions(this->LocalGenerator, 10, + linkOptions(this->LocalGenerator, cmVisualStudioGeneratorOptions::Linker, cmVS10LinkFlagTable, 0, this); if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") ) @@ -1563,6 +1649,13 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences() i != depends.end(); ++i) { cmTarget* dt = *i; + // skip fortran targets as they can not be processed by MSBuild + // the only reference will be in the .sln file + if(static_cast(this->GlobalGenerator) + ->TargetIsFortranOnly(*dt)) + { + continue; + } this->WriteString("GetMakefile(); std::string name = dt->GetName(); diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index c3c27f4ce..67025091d 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -47,6 +47,7 @@ private: void WriteProjectConfigurations(); void WriteProjectConfigurationValues(); void WriteCLSources(); + void WriteDotNetReferences(); void WriteObjSources(); void WritePathAndIncrementalLinkOptions(); void WriteItemDefinitionGroups(); diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index ae496ad12..41230e71c 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -25,14 +25,13 @@ inline std::string cmVisualStudioGeneratorOptionsEscapeForXML(const char* s) //---------------------------------------------------------------------------- cmVisualStudioGeneratorOptions -::cmVisualStudioGeneratorOptions(cmLocalGenerator* lg, - int version, +::cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool, cmVS7FlagTable const* table, cmVS7FlagTable const* extraTable, cmVisualStudio10TargetGenerator* g): cmIDEOptions(), - LocalGenerator(lg), Version(version), CurrentTool(tool), + LocalGenerator(lg), Version(lg->GetVersion()), CurrentTool(tool), TargetGenerator(g) { // Store the given flag tables. @@ -61,11 +60,12 @@ void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault() // remove the flag we need to override the IDE default of on. switch (this->Version) { - case 7: - case 71: + case cmLocalVisualStudioGenerator::VS7: + case cmLocalVisualStudioGenerator::VS71: this->FlagMap["ExceptionHandling"] = "FALSE"; break; - case 10: + case cmLocalVisualStudioGenerator::VS10: + case cmLocalVisualStudioGenerator::VS11: // by default VS puts empty // for a project, to make our projects look the same put a new line // and space over for the closing as the default @@ -86,14 +86,15 @@ void cmVisualStudioGeneratorOptions::SetVerboseMakefile(bool verbose) // to the generated project to disable logo suppression. Otherwise // the GUI default is to enable suppression. // - // Avoid this on Visual Studio 10 (and later!) because it results in: + // On Visual Studio 10 (and later!), the value of this attribute should be + // an empty string, instead of "FALSE", in order to avoid a warning: // "cl ... warning D9035: option 'nologo-' has been deprecated" // if(verbose && - this->Version != 10 && this->FlagMap.find("SuppressStartupBanner") == this->FlagMap.end()) { - this->FlagMap["SuppressStartupBanner"] = "FALSE"; + this->FlagMap["SuppressStartupBanner"] = + this->Version < cmLocalVisualStudioGenerator::VS10 ? "FALSE" : ""; } } @@ -211,7 +212,7 @@ cmVisualStudioGeneratorOptions { return; } - if(this->Version == 10) + if(this->Version >= cmLocalVisualStudioGenerator::VS10) { // if there are configuration specifc flags, then // use the configuration specific tag for PreprocessorDefinitions @@ -239,7 +240,7 @@ cmVisualStudioGeneratorOptions { // Escape the definition for the compiler. std::string define; - if(this->Version != 10) + if(this->Version < cmLocalVisualStudioGenerator::VS10) { define = this->LocalGenerator->EscapeForShell(di->c_str(), true); @@ -249,7 +250,7 @@ cmVisualStudioGeneratorOptions define = *di; } // Escape this flag for the IDE. - if(this->Version == 10) + if(this->Version >= cmLocalVisualStudioGenerator::VS10) { define = cmVisualStudio10GeneratorOptionsEscapeForXML(define.c_str()); @@ -266,7 +267,7 @@ cmVisualStudioGeneratorOptions fout << sep << define; sep = ";"; } - if(this->Version == 10) + if(this->Version >= cmLocalVisualStudioGenerator::VS10) { fout << ";%(PreprocessorDefinitions)" << suffix; } @@ -281,7 +282,7 @@ void cmVisualStudioGeneratorOptions ::OutputFlagMap(std::ostream& fout, const char* indent) { - if(this->Version == 10) + if(this->Version >= cmLocalVisualStudioGenerator::VS10) { for(std::map::iterator m = this->FlagMap.begin(); m != this->FlagMap.end(); ++m) @@ -326,7 +327,7 @@ cmVisualStudioGeneratorOptions { if(!this->FlagString.empty()) { - if(this->Version == 10) + if(this->Version >= cmLocalVisualStudioGenerator::VS10) { fout << prefix; if(this->Configuration.size()) diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h index fadc4b5e1..51a13629f 100644 --- a/Source/cmVisualStudioGeneratorOptions.h +++ b/Source/cmVisualStudioGeneratorOptions.h @@ -12,7 +12,7 @@ #ifndef cmVisualStudioGeneratorOptions_h #define cmVisualStudioGeneratorOptions_h -#include "cmLocalGenerator.h" +#include "cmLocalVisualStudioGenerator.h" #include "cmIDEOptions.h" typedef cmIDEFlagTable cmVS7FlagTable; @@ -30,8 +30,7 @@ public: Linker, FortranCompiler }; - cmVisualStudioGeneratorOptions(cmLocalGenerator* lg, - int version, + cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool, cmVS7FlagTable const* table, cmVS7FlagTable const* extraTable = 0, @@ -62,8 +61,8 @@ public: const char* suffix); void SetConfiguration(const char* config); private: - cmLocalGenerator* LocalGenerator; - int Version; + cmLocalVisualStudioGenerator* LocalGenerator; + cmLocalVisualStudioGenerator::VSVersion Version; std::string Configuration; Tool CurrentTool; diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 71c7c2557..30ade9637 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -12,6 +12,8 @@ #include "cmXCodeObject.h" #include "cmSystemTools.h" +#include // CFUUIDCreate + //---------------------------------------------------------------------------- const char* cmXCodeObject::PBXTypeNames[] = { "PBXGroup", "PBXBuildStyle", "PBXProject", "PBXHeadersBuildPhase", @@ -39,35 +41,35 @@ cmXCodeObject::cmXCodeObject(PBXType ptype, Type type) this->PBXTargetDependencyValue = 0; this->Target = 0; this->Object =0; - + this->IsA = ptype; + if(type == OBJECT) { - cmOStringStream str; - str << (void*)this; - str << (void*)this; - str << (void*)this; - this->Id = str.str(); + // Set the Id of an Xcode object to a unique string for each instance. + // However the Xcode user file references certain Ids: for those cases, + // override the generated Id using SetId(). + // + char cUuid[40] = {0}; + CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault); + CFStringRef s = CFUUIDCreateString(kCFAllocatorDefault, uuid); + CFStringGetCString(s, cUuid, sizeof(cUuid), kCFStringEncodingUTF8); + this->Id = cUuid; + CFRelease(s); + CFRelease(uuid); } else { - this->Id = - "Temporary cmake object, should not be refered to in xcode file"; - } - cmSystemTools::ReplaceString(this->Id, "0x", ""); - this->Id = cmSystemTools::UpperCase(this->Id); - if(this->Id.size() < 24) - { - int diff = 24 - this->Id.size(); - for(int i =0; i < diff; ++i) - { - this->Id += "0"; - } + this->Id = + "Temporary cmake object, should not be referred to in Xcode file"; } + + cmSystemTools::ReplaceString(this->Id, "-", ""); if(this->Id.size() > 24) { - this->Id = this->Id.substr(0,24); + this->Id = this->Id.substr(0, 24); } + this->TypeValue = type; if(this->TypeValue == OBJECT) { @@ -241,7 +243,7 @@ void cmXCodeObject::PrintString(std::ostream& os,cmStdString String) // considered special by the Xcode project file parser. bool needQuote = (String.empty() || - String.find_first_of(" <>.+-=@$[]") != String.npos); + String.find_first_of(" <>.+-=@$[],") != String.npos); const char* quote = needQuote? "\"" : ""; // Print the string, quoted and escaped as necessary. diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index 369fe669d..2fb96f30e 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -83,6 +83,10 @@ public: { return this->Id.c_str(); } + void SetId(const char* id) + { + this->Id = id; + } cmTarget* GetTarget() { return this->Target; diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c new file mode 100644 index 000000000..12c39ed63 --- /dev/null +++ b/Source/cm_sha2.c @@ -0,0 +1,1613 @@ +/* + * FILE: sha2.c + * AUTHOR: Aaron D. Gifford + * http://www.aarongifford.com/computers/sha.html + * + * Copyright (c) 2000-2003, Aaron D. Gifford + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (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: sha2.c,v 1.4 2004/01/07 22:58:18 adg Exp $ + */ + +#include /* memcpy()/memset() or bcopy()/bzero() */ +#include /* assert() */ +#include "cm_sha2.h" /* "sha2.h" -> "cm_sha2.h" renamed for CMake */ + +/* + * ASSERT NOTE: + * Some sanity checking code is included using assert(). On my FreeBSD + * system, this additional code can be removed by compiling with NDEBUG + * defined. Check your own systems manpage on assert() to see how to + * compile WITHOUT the sanity checking code on your system. + * + * UNROLLED TRANSFORM LOOP NOTE: + * You can define SHA2_UNROLL_TRANSFORM to use the unrolled transform + * loop version for the hash transform rounds (defined using macros + * later in this file). Either define on the command line, for example: + * + * cc -DSHA2_UNROLL_TRANSFORM -o sha2 sha2.c sha2prog.c + * + * or define below: + * + * #define SHA2_UNROLL_TRANSFORM + * + */ + + +/*** SHA-224/256/384/512 Machine Architecture Definitions *************/ +/* + * BYTE_ORDER NOTE: + * + * Please make sure that your system defines BYTE_ORDER. If your + * architecture is little-endian, make sure it also defines + * LITTLE_ENDIAN and that the two (BYTE_ORDER and LITTLE_ENDIAN) are + * equivilent. + * + * If your system does not define the above, then you can do so by + * hand like this: + * + * #define LITTLE_ENDIAN 1234 + * #define BIG_ENDIAN 4321 + * + * And for little-endian machines, add: + * + * #define BYTE_ORDER LITTLE_ENDIAN + * + * Or for big-endian machines: + * + * #define BYTE_ORDER BIG_ENDIAN + * + * The FreeBSD machine this was written on defines BYTE_ORDER + * appropriately by including (which in turn includes + * where the appropriate definitions are actually + * made). + */ +#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) +/* CMake modification: use byte order from cmIML. */ +# include "cmIML/ABI.h" +# undef BYTE_ORDER +# undef BIG_ENDIAN +# undef LITTLE_ENDIAN +# define BYTE_ORDER cmIML_ABI_ENDIAN_ID +# define BIG_ENDIAN cmIML_ABI_ENDIAN_ID_BIG +# define LITTLE_ENDIAN cmIML_ABI_ENDIAN_ID_LITTLE +#endif + +/* CMake modification: use types computed in header. */ +typedef cm_sha2_uint8_t sha_byte; /* Exactly 1 byte */ +typedef cm_sha2_uint32_t sha_word32; /* Exactly 4 bytes */ +typedef cm_sha2_uint64_t sha_word64; /* Exactly 8 bytes */ +#define SHA_UINT32_C(x) cmIML_INT_UINT32_C(x) +#define SHA_UINT64_C(x) cmIML_INT_UINT64_C(x) +#if defined(__BORLANDC__) +# pragma warn -8004 /* variable assigned value that is never used */ +#endif +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wcast-align" +#endif + +/*** ENDIAN REVERSAL MACROS *******************************************/ +#if BYTE_ORDER == LITTLE_ENDIAN +#define REVERSE32(w,x) { \ + sha_word32 tmp = (w); \ + tmp = (tmp >> 16) | (tmp << 16); \ + (x) = ((tmp & SHA_UINT32_C(0xff00ff00)) >> 8) | \ + ((tmp & SHA_UINT32_C(0x00ff00ff)) << 8); \ +} +#define REVERSE64(w,x) { \ + sha_word64 tmp = (w); \ + tmp = (tmp >> 32) | (tmp << 32); \ + tmp = ((tmp & SHA_UINT64_C(0xff00ff00ff00ff00)) >> 8) | \ + ((tmp & SHA_UINT64_C(0x00ff00ff00ff00ff)) << 8); \ + (x) = ((tmp & SHA_UINT64_C(0xffff0000ffff0000)) >> 16) | \ + ((tmp & SHA_UINT64_C(0x0000ffff0000ffff)) << 16); \ +} +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + +/* + * Macro for incrementally adding the unsigned 64-bit integer n to the + * unsigned 128-bit integer (represented using a two-element array of + * 64-bit words): + */ +#define ADDINC128(w,n) { \ + (w)[0] += (sha_word64)(n); \ + if ((w)[0] < (n)) { \ + (w)[1]++; \ + } \ +} + +/* + * Macros for copying blocks of memory and for zeroing out ranges + * of memory. Using these macros makes it easy to switch from + * using memset()/memcpy() and using bzero()/bcopy(). + * + * Please define either SHA2_USE_MEMSET_MEMCPY or define + * SHA2_USE_BZERO_BCOPY depending on which function set you + * choose to use: + */ +#if !defined(SHA2_USE_MEMSET_MEMCPY) && !defined(SHA2_USE_BZERO_BCOPY) +/* Default to memset()/memcpy() if no option is specified */ +#define SHA2_USE_MEMSET_MEMCPY 1 +#endif +#if defined(SHA2_USE_MEMSET_MEMCPY) && defined(SHA2_USE_BZERO_BCOPY) +/* Abort with an error if BOTH options are defined */ +#error Define either SHA2_USE_MEMSET_MEMCPY or SHA2_USE_BZERO_BCOPY, not both! +#endif + +#ifdef SHA2_USE_MEMSET_MEMCPY +#define MEMSET_BZERO(p,l) memset((p), 0, (l)) +#define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l)) +#endif +#ifdef SHA2_USE_BZERO_BCOPY +#define MEMSET_BZERO(p,l) bzero((p), (l)) +#define MEMCPY_BCOPY(d,s,l) bcopy((s), (d), (l)) +#endif + + +/*** THE SIX LOGICAL FUNCTIONS ****************************************/ +/* + * Bit shifting and rotation (used by the six SHA-XYZ logical functions: + * + * NOTE: In the original SHA-256/384/512 document, the shift-right + * function was named R and the rotate-right function was called S. + * (See: http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf on the + * web.) + * + * The newer NIST FIPS 180-2 document uses a much clearer naming + * scheme, SHR for shift-right, ROTR for rotate-right, and ROTL for + * rotate-left. (See: + * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf + * on the web.) + * + * WARNING: These macros must be used cautiously, since they reference + * supplied parameters sometimes more than once, and thus could have + * unexpected side-effects if used without taking this into account. + */ +/* Shift-right (used in SHA-256, SHA-384, and SHA-512): */ +#define SHR(b,x) ((x) >> (b)) +/* 32-bit Rotate-right (used in SHA-256): */ +#define ROTR32(b,x) (((x) >> (b)) | ((x) << (32 - (b)))) +/* 64-bit Rotate-right (used in SHA-384 and SHA-512): */ +#define ROTR64(b,x) (((x) >> (b)) | ((x) << (64 - (b)))) +/* 32-bit Rotate-left (used in SHA-1): */ +#define ROTL32(b,x) (((x) << (b)) | ((x) >> (32 - (b)))) + +/* Two logical functions used in SHA-1, SHA-254, SHA-256, SHA-384, and SHA-512: */ +#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) +#define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) + +/* Function used in SHA-1: */ +#define Parity(x,y,z) ((x) ^ (y) ^ (z)) + +/* Four logical functions used in SHA-256: */ +#define Sigma0_256(x) (ROTR32(2, (x)) ^ ROTR32(13, (x)) ^ ROTR32(22, (x))) +#define Sigma1_256(x) (ROTR32(6, (x)) ^ ROTR32(11, (x)) ^ ROTR32(25, (x))) +#define sigma0_256(x) (ROTR32(7, (x)) ^ ROTR32(18, (x)) ^ SHR( 3 , (x))) +#define sigma1_256(x) (ROTR32(17, (x)) ^ ROTR32(19, (x)) ^ SHR( 10, (x))) + +/* Four of six logical functions used in SHA-384 and SHA-512: */ +#define Sigma0_512(x) (ROTR64(28, (x)) ^ ROTR64(34, (x)) ^ ROTR64(39, (x))) +#define Sigma1_512(x) (ROTR64(14, (x)) ^ ROTR64(18, (x)) ^ ROTR64(41, (x))) +#define sigma0_512(x) (ROTR64( 1, (x)) ^ ROTR64( 8, (x)) ^ SHR( 7, (x))) +#define sigma1_512(x) (ROTR64(19, (x)) ^ ROTR64(61, (x)) ^ SHR( 6, (x))) + +/*** INTERNAL FUNCTION PROTOTYPES *************************************/ + +/* SHA-224 and SHA-256: */ +void SHA256_Internal_Init(SHA_CTX*, const sha_word32*); +void SHA256_Internal_Last(SHA_CTX*); +void SHA256_Internal_Transform(SHA_CTX*, const sha_word32*); + +/* SHA-384 and SHA-512: */ +void SHA512_Internal_Init(SHA_CTX*, const sha_word64*); +void SHA512_Internal_Last(SHA_CTX*); +void SHA512_Internal_Transform(SHA_CTX*, const sha_word64*); + + +/*** SHA2 INITIAL HASH VALUES AND CONSTANTS ***************************/ + +/* Hash constant words K for SHA-1: */ +#define K1_0_TO_19 SHA_UINT32_C(0x5a827999) +#define K1_20_TO_39 SHA_UINT32_C(0x6ed9eba1) +#define K1_40_TO_59 SHA_UINT32_C(0x8f1bbcdc) +#define K1_60_TO_79 SHA_UINT32_C(0xca62c1d6) + +/* Initial hash value H for SHA-1: */ +static const sha_word32 sha1_initial_hash_value[5] = { + SHA_UINT32_C(0x67452301), + SHA_UINT32_C(0xefcdab89), + SHA_UINT32_C(0x98badcfe), + SHA_UINT32_C(0x10325476), + SHA_UINT32_C(0xc3d2e1f0) +}; + +/* Hash constant words K for SHA-224 and SHA-256: */ +static const sha_word32 K256[64] = { + SHA_UINT32_C(0x428a2f98), SHA_UINT32_C(0x71374491), + SHA_UINT32_C(0xb5c0fbcf), SHA_UINT32_C(0xe9b5dba5), + SHA_UINT32_C(0x3956c25b), SHA_UINT32_C(0x59f111f1), + SHA_UINT32_C(0x923f82a4), SHA_UINT32_C(0xab1c5ed5), + SHA_UINT32_C(0xd807aa98), SHA_UINT32_C(0x12835b01), + SHA_UINT32_C(0x243185be), SHA_UINT32_C(0x550c7dc3), + SHA_UINT32_C(0x72be5d74), SHA_UINT32_C(0x80deb1fe), + SHA_UINT32_C(0x9bdc06a7), SHA_UINT32_C(0xc19bf174), + SHA_UINT32_C(0xe49b69c1), SHA_UINT32_C(0xefbe4786), + SHA_UINT32_C(0x0fc19dc6), SHA_UINT32_C(0x240ca1cc), + SHA_UINT32_C(0x2de92c6f), SHA_UINT32_C(0x4a7484aa), + SHA_UINT32_C(0x5cb0a9dc), SHA_UINT32_C(0x76f988da), + SHA_UINT32_C(0x983e5152), SHA_UINT32_C(0xa831c66d), + SHA_UINT32_C(0xb00327c8), SHA_UINT32_C(0xbf597fc7), + SHA_UINT32_C(0xc6e00bf3), SHA_UINT32_C(0xd5a79147), + SHA_UINT32_C(0x06ca6351), SHA_UINT32_C(0x14292967), + SHA_UINT32_C(0x27b70a85), SHA_UINT32_C(0x2e1b2138), + SHA_UINT32_C(0x4d2c6dfc), SHA_UINT32_C(0x53380d13), + SHA_UINT32_C(0x650a7354), SHA_UINT32_C(0x766a0abb), + SHA_UINT32_C(0x81c2c92e), SHA_UINT32_C(0x92722c85), + SHA_UINT32_C(0xa2bfe8a1), SHA_UINT32_C(0xa81a664b), + SHA_UINT32_C(0xc24b8b70), SHA_UINT32_C(0xc76c51a3), + SHA_UINT32_C(0xd192e819), SHA_UINT32_C(0xd6990624), + SHA_UINT32_C(0xf40e3585), SHA_UINT32_C(0x106aa070), + SHA_UINT32_C(0x19a4c116), SHA_UINT32_C(0x1e376c08), + SHA_UINT32_C(0x2748774c), SHA_UINT32_C(0x34b0bcb5), + SHA_UINT32_C(0x391c0cb3), SHA_UINT32_C(0x4ed8aa4a), + SHA_UINT32_C(0x5b9cca4f), SHA_UINT32_C(0x682e6ff3), + SHA_UINT32_C(0x748f82ee), SHA_UINT32_C(0x78a5636f), + SHA_UINT32_C(0x84c87814), SHA_UINT32_C(0x8cc70208), + SHA_UINT32_C(0x90befffa), SHA_UINT32_C(0xa4506ceb), + SHA_UINT32_C(0xbef9a3f7), SHA_UINT32_C(0xc67178f2) +}; + +/* Initial hash value H for SHA-224: */ +static const sha_word32 sha224_initial_hash_value[8] = { + SHA_UINT32_C(0xc1059ed8), + SHA_UINT32_C(0x367cd507), + SHA_UINT32_C(0x3070dd17), + SHA_UINT32_C(0xf70e5939), + SHA_UINT32_C(0xffc00b31), + SHA_UINT32_C(0x68581511), + SHA_UINT32_C(0x64f98fa7), + SHA_UINT32_C(0xbefa4fa4) +}; + +/* Initial hash value H for SHA-256: */ +static const sha_word32 sha256_initial_hash_value[8] = { + SHA_UINT32_C(0x6a09e667), + SHA_UINT32_C(0xbb67ae85), + SHA_UINT32_C(0x3c6ef372), + SHA_UINT32_C(0xa54ff53a), + SHA_UINT32_C(0x510e527f), + SHA_UINT32_C(0x9b05688c), + SHA_UINT32_C(0x1f83d9ab), + SHA_UINT32_C(0x5be0cd19) +}; + +/* Hash constant words K for SHA-384 and SHA-512: */ +static const sha_word64 K512[80] = { + SHA_UINT64_C(0x428a2f98d728ae22), SHA_UINT64_C(0x7137449123ef65cd), + SHA_UINT64_C(0xb5c0fbcfec4d3b2f), SHA_UINT64_C(0xe9b5dba58189dbbc), + SHA_UINT64_C(0x3956c25bf348b538), SHA_UINT64_C(0x59f111f1b605d019), + SHA_UINT64_C(0x923f82a4af194f9b), SHA_UINT64_C(0xab1c5ed5da6d8118), + SHA_UINT64_C(0xd807aa98a3030242), SHA_UINT64_C(0x12835b0145706fbe), + SHA_UINT64_C(0x243185be4ee4b28c), SHA_UINT64_C(0x550c7dc3d5ffb4e2), + SHA_UINT64_C(0x72be5d74f27b896f), SHA_UINT64_C(0x80deb1fe3b1696b1), + SHA_UINT64_C(0x9bdc06a725c71235), SHA_UINT64_C(0xc19bf174cf692694), + SHA_UINT64_C(0xe49b69c19ef14ad2), SHA_UINT64_C(0xefbe4786384f25e3), + SHA_UINT64_C(0x0fc19dc68b8cd5b5), SHA_UINT64_C(0x240ca1cc77ac9c65), + SHA_UINT64_C(0x2de92c6f592b0275), SHA_UINT64_C(0x4a7484aa6ea6e483), + SHA_UINT64_C(0x5cb0a9dcbd41fbd4), SHA_UINT64_C(0x76f988da831153b5), + SHA_UINT64_C(0x983e5152ee66dfab), SHA_UINT64_C(0xa831c66d2db43210), + SHA_UINT64_C(0xb00327c898fb213f), SHA_UINT64_C(0xbf597fc7beef0ee4), + SHA_UINT64_C(0xc6e00bf33da88fc2), SHA_UINT64_C(0xd5a79147930aa725), + SHA_UINT64_C(0x06ca6351e003826f), SHA_UINT64_C(0x142929670a0e6e70), + SHA_UINT64_C(0x27b70a8546d22ffc), SHA_UINT64_C(0x2e1b21385c26c926), + SHA_UINT64_C(0x4d2c6dfc5ac42aed), SHA_UINT64_C(0x53380d139d95b3df), + SHA_UINT64_C(0x650a73548baf63de), SHA_UINT64_C(0x766a0abb3c77b2a8), + SHA_UINT64_C(0x81c2c92e47edaee6), SHA_UINT64_C(0x92722c851482353b), + SHA_UINT64_C(0xa2bfe8a14cf10364), SHA_UINT64_C(0xa81a664bbc423001), + SHA_UINT64_C(0xc24b8b70d0f89791), SHA_UINT64_C(0xc76c51a30654be30), + SHA_UINT64_C(0xd192e819d6ef5218), SHA_UINT64_C(0xd69906245565a910), + SHA_UINT64_C(0xf40e35855771202a), SHA_UINT64_C(0x106aa07032bbd1b8), + SHA_UINT64_C(0x19a4c116b8d2d0c8), SHA_UINT64_C(0x1e376c085141ab53), + SHA_UINT64_C(0x2748774cdf8eeb99), SHA_UINT64_C(0x34b0bcb5e19b48a8), + SHA_UINT64_C(0x391c0cb3c5c95a63), SHA_UINT64_C(0x4ed8aa4ae3418acb), + SHA_UINT64_C(0x5b9cca4f7763e373), SHA_UINT64_C(0x682e6ff3d6b2b8a3), + SHA_UINT64_C(0x748f82ee5defb2fc), SHA_UINT64_C(0x78a5636f43172f60), + SHA_UINT64_C(0x84c87814a1f0ab72), SHA_UINT64_C(0x8cc702081a6439ec), + SHA_UINT64_C(0x90befffa23631e28), SHA_UINT64_C(0xa4506cebde82bde9), + SHA_UINT64_C(0xbef9a3f7b2c67915), SHA_UINT64_C(0xc67178f2e372532b), + SHA_UINT64_C(0xca273eceea26619c), SHA_UINT64_C(0xd186b8c721c0c207), + SHA_UINT64_C(0xeada7dd6cde0eb1e), SHA_UINT64_C(0xf57d4f7fee6ed178), + SHA_UINT64_C(0x06f067aa72176fba), SHA_UINT64_C(0x0a637dc5a2c898a6), + SHA_UINT64_C(0x113f9804bef90dae), SHA_UINT64_C(0x1b710b35131c471b), + SHA_UINT64_C(0x28db77f523047d84), SHA_UINT64_C(0x32caab7b40c72493), + SHA_UINT64_C(0x3c9ebe0a15c9bebc), SHA_UINT64_C(0x431d67c49c100d4c), + SHA_UINT64_C(0x4cc5d4becb3e42b6), SHA_UINT64_C(0x597f299cfc657e2a), + SHA_UINT64_C(0x5fcb6fab3ad6faec), SHA_UINT64_C(0x6c44198c4a475817) +}; + +/* Initial hash value H for SHA-384 */ +static const sha_word64 sha384_initial_hash_value[8] = { + SHA_UINT64_C(0xcbbb9d5dc1059ed8), + SHA_UINT64_C(0x629a292a367cd507), + SHA_UINT64_C(0x9159015a3070dd17), + SHA_UINT64_C(0x152fecd8f70e5939), + SHA_UINT64_C(0x67332667ffc00b31), + SHA_UINT64_C(0x8eb44a8768581511), + SHA_UINT64_C(0xdb0c2e0d64f98fa7), + SHA_UINT64_C(0x47b5481dbefa4fa4) +}; + +/* Initial hash value H for SHA-512 */ +static const sha_word64 sha512_initial_hash_value[8] = { + SHA_UINT64_C(0x6a09e667f3bcc908), + SHA_UINT64_C(0xbb67ae8584caa73b), + SHA_UINT64_C(0x3c6ef372fe94f82b), + SHA_UINT64_C(0xa54ff53a5f1d36f1), + SHA_UINT64_C(0x510e527fade682d1), + SHA_UINT64_C(0x9b05688c2b3e6c1f), + SHA_UINT64_C(0x1f83d9abfb41bd6b), + SHA_UINT64_C(0x5be0cd19137e2179) +}; + +/* + * Constant used by SHA224/256/384/512_End() functions for converting the + * digest to a readable hexadecimal character string: + */ +static const char *sha_hex_digits = "0123456789abcdef"; + + +/*** SHA-1: ***********************************************************/ +void SHA1_Init(SHA_CTX* context) { + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + MEMCPY_BCOPY(context->s1.state, sha1_initial_hash_value, sizeof(sha_word32) * 5); + MEMSET_BZERO(context->s1.buffer, 64); + context->s1.bitcount = 0; +} + +#ifdef SHA2_UNROLL_TRANSFORM + +/* Unrolled SHA-1 round macros: */ + +#if BYTE_ORDER == LITTLE_ENDIAN + +#define ROUND1_0_TO_15(a,b,c,d,e) \ + REVERSE32(*data++, W1[j]); \ + (e) = ROTL32(5, (a)) + Ch((b), (c), (d)) + (e) + \ + K1_0_TO_19 + W1[j]; \ + (b) = ROTL32(30, (b)); \ + j++; + +#else /* BYTE_ORDER == LITTLE_ENDIAN */ + +#define ROUND1_0_TO_15(a,b,c,d,e) \ + (e) = ROTL32(5, (a)) + Ch((b), (c), (d)) + (e) + \ + K1_0_TO_19 + ( W1[j] = *data++ ); \ + (b) = ROTL32(30, (b)); \ + j++; + +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + +#define ROUND1_16_TO_19(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Ch(b,c,d) + e + K1_0_TO_19 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +#define ROUND1_20_TO_39(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Parity(b,c,d) + e + K1_20_TO_39 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +#define ROUND1_40_TO_59(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Maj(b,c,d) + e + K1_40_TO_59 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +#define ROUND1_60_TO_79(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Parity(b,c,d) + e + K1_60_TO_79 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +void SHA1_Internal_Transform(SHA_CTX* context, const sha_word32* data) { + sha_word32 a, b, c, d, e; + sha_word32 T1, *W1; + int j; + + W1 = (sha_word32*)context->s1.buffer; + + /* Initialize registers with the prev. intermediate value */ + a = context->s1.state[0]; + b = context->s1.state[1]; + c = context->s1.state[2]; + d = context->s1.state[3]; + e = context->s1.state[4]; + + j = 0; + + /* Rounds 0 to 15 unrolled: */ + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); + + /* Rounds 16 to 19 unrolled: */ + ROUND1_16_TO_19(e,a,b,c,d); + ROUND1_16_TO_19(d,e,a,b,c); + ROUND1_16_TO_19(c,d,e,a,b); + ROUND1_16_TO_19(b,c,d,e,a); + + /* Rounds 20 to 39 unrolled: */ + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + + /* Rounds 40 to 59 unrolled: */ + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + + /* Rounds 60 to 79 unrolled: */ + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + + /* Compute the current intermediate hash value */ + context->s1.state[0] += a; + context->s1.state[1] += b; + context->s1.state[2] += c; + context->s1.state[3] += d; + context->s1.state[4] += e; + + /* Clean up */ + a = b = c = d = e = T1 = 0; +} + +#else /* SHA2_UNROLL_TRANSFORM */ + +void SHA1_Internal_Transform(SHA_CTX* context, const sha_word32* data) { + sha_word32 a, b, c, d, e; + sha_word32 T1, *W1; + int j; + + W1 = (sha_word32*)context->s1.buffer; + + /* Initialize registers with the prev. intermediate value */ + a = context->s1.state[0]; + b = context->s1.state[1]; + c = context->s1.state[2]; + d = context->s1.state[3]; + e = context->s1.state[4]; + j = 0; + do { +#if BYTE_ORDER == LITTLE_ENDIAN + T1 = data[j]; + /* Copy data while converting to host byte order */ + REVERSE32(*data++, W1[j]); + T1 = ROTL32(5, a) + Ch(b, c, d) + e + K1_0_TO_19 + W1[j]; +#else /* BYTE_ORDER == LITTLE_ENDIAN */ + T1 = ROTL32(5, a) + Ch(b, c, d) + e + K1_0_TO_19 + (W1[j] = *data++); +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 16); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Ch(b,c,d) + e + K1_0_TO_19 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 20); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Parity(b,c,d) + e + K1_20_TO_39 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 40); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Maj(b,c,d) + e + K1_40_TO_59 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 60); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Parity(b,c,d) + e + K1_60_TO_79 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 80); + + + /* Compute the current intermediate hash value */ + context->s1.state[0] += a; + context->s1.state[1] += b; + context->s1.state[2] += c; + context->s1.state[3] += d; + context->s1.state[4] += e; + + /* Clean up */ + a = b = c = d = e = T1 = 0; +} + +#endif /* SHA2_UNROLL_TRANSFORM */ + +void SHA1_Update(SHA_CTX* context, const sha_byte *data, size_t len) { + unsigned int freespace, usedspace; + if (len == 0) { + /* Calling with no data is valid - we do nothing */ + return; + } + + /* Sanity check: */ + assert(context != (SHA_CTX*)0 && data != (sha_byte*)0); + + usedspace = (unsigned int)((context->s1.bitcount >> 3) % 64); + if (usedspace > 0) { + /* Calculate how much free space is available in the buffer */ + freespace = 64 - usedspace; + + if (len >= freespace) { + /* Fill the buffer completely and process it */ + MEMCPY_BCOPY(&context->s1.buffer[usedspace], data, freespace); + context->s1.bitcount += freespace << 3; + len -= freespace; + data += freespace; + SHA1_Internal_Transform(context, (sha_word32*)context->s1.buffer); + } else { + /* The buffer is not yet full */ + MEMCPY_BCOPY(&context->s1.buffer[usedspace], data, len); + context->s1.bitcount += len << 3; + /* Clean up: */ + usedspace = freespace = 0; + return; + } + } + while (len >= 64) { + /* Process as many complete blocks as we can */ + SHA1_Internal_Transform(context, (sha_word32*)data); + context->s1.bitcount += 512; + len -= 64; + data += 64; + } + if (len > 0) { + /* There's left-overs, so save 'em */ + MEMCPY_BCOPY(context->s1.buffer, data, len); + context->s1.bitcount += len << 3; + } + /* Clean up: */ + usedspace = freespace = 0; +} + +void SHA1_Final(sha_byte digest[], SHA_CTX* context) { + sha_word32 *d = (sha_word32*)digest; + unsigned int usedspace; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + if (digest == (sha_byte*)0) { + /* + * No digest buffer, so we can do nothing + * except clean up and go home + */ + MEMSET_BZERO(context, sizeof(*context)); + return; + } + + usedspace = (unsigned int)((context->s1.bitcount >> 3) % 64); + if (usedspace == 0) { + /* Set-up for the last transform: */ + MEMSET_BZERO(context->s1.buffer, 56); + + /* Begin padding with a 1 bit: */ + *context->s1.buffer = 0x80; + } else { + /* Begin padding with a 1 bit: */ + context->s1.buffer[usedspace++] = 0x80; + + if (usedspace <= 56) { + /* Set-up for the last transform: */ + MEMSET_BZERO(&context->s1.buffer[usedspace], 56 - usedspace); + } else { + if (usedspace < 64) { + MEMSET_BZERO(&context->s1.buffer[usedspace], 64 - usedspace); + } + /* Do second-to-last transform: */ + SHA1_Internal_Transform(context, (sha_word32*)context->s1.buffer); + + /* And set-up for the last transform: */ + MEMSET_BZERO(context->s1.buffer, 56); + } + /* Clean up: */ + usedspace = 0; + } + /* Set the bit count: */ +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert FROM host byte order */ + REVERSE64(context->s1.bitcount,context->s1.bitcount); +#endif + *(sha_word64*)&context->s1.buffer[56] = context->s1.bitcount; + + /* Final transform: */ + SHA1_Internal_Transform(context, (sha_word32*)context->s1.buffer); + + /* Save the hash data for output: */ +#if BYTE_ORDER == LITTLE_ENDIAN + { + /* Convert TO host byte order */ + int j; + for (j = 0; j < (SHA1_DIGEST_LENGTH >> 2); j++) { + REVERSE32(context->s1.state[j],context->s1.state[j]); + *d++ = context->s1.state[j]; + } + } +#else + MEMCPY_BCOPY(d, context->s1.state, SHA1_DIGEST_LENGTH); +#endif + + /* Clean up: */ + MEMSET_BZERO(context, sizeof(*context)); +} + +char *SHA1_End(SHA_CTX* context, char buffer[]) { + sha_byte digest[SHA1_DIGEST_LENGTH], *d = digest; + int i; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + if (buffer != (char*)0) { + SHA1_Final(digest, context); + + for (i = 0; i < SHA1_DIGEST_LENGTH; i++) { + *buffer++ = sha_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + MEMSET_BZERO(context, sizeof(*context)); + } + MEMSET_BZERO(digest, SHA1_DIGEST_LENGTH); + return buffer; +} + +char* SHA1_Data(const sha_byte* data, size_t len, char digest[SHA1_DIGEST_STRING_LENGTH]) { + SHA_CTX context; + + SHA1_Init(&context); + SHA1_Update(&context, data, len); + return SHA1_End(&context, digest); +} + + +/*** SHA-256: *********************************************************/ +void SHA256_Internal_Init(SHA_CTX* context, const sha_word32* ihv) { + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + MEMCPY_BCOPY(context->s256.state, ihv, sizeof(sha_word32) * 8); + MEMSET_BZERO(context->s256.buffer, 64); + context->s256.bitcount = 0; +} + +void SHA256_Init(SHA_CTX* context) { + SHA256_Internal_Init(context, sha256_initial_hash_value); +} + +#ifdef SHA2_UNROLL_TRANSFORM + +/* Unrolled SHA-256 round macros: */ + +#if BYTE_ORDER == LITTLE_ENDIAN + +#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \ + REVERSE32(*data++, W256[j]); \ + T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \ + K256[j] + W256[j]; \ + (d) += T1; \ + (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ + j++ + + +#else /* BYTE_ORDER == LITTLE_ENDIAN */ + +#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \ + T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \ + K256[j] + (W256[j] = *data++); \ + (d) += T1; \ + (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ + j++ + +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + +#define ROUND256(a,b,c,d,e,f,g,h) \ + s0 = W256[(j+1)&0x0f]; \ + s0 = sigma0_256(s0); \ + s1 = W256[(j+14)&0x0f]; \ + s1 = sigma1_256(s1); \ + T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + \ + (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \ + (d) += T1; \ + (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ + j++ + +void SHA256_Internal_Transform(SHA_CTX* context, const sha_word32* data) { + sha_word32 a, b, c, d, e, f, g, h, s0, s1; + sha_word32 T1, *W256; + int j; + + W256 = (sha_word32*)context->s256.buffer; + + /* Initialize registers with the prev. intermediate value */ + a = context->s256.state[0]; + b = context->s256.state[1]; + c = context->s256.state[2]; + d = context->s256.state[3]; + e = context->s256.state[4]; + f = context->s256.state[5]; + g = context->s256.state[6]; + h = context->s256.state[7]; + + j = 0; + do { + /* Rounds 0 to 15 (unrolled): */ + ROUND256_0_TO_15(a,b,c,d,e,f,g,h); + ROUND256_0_TO_15(h,a,b,c,d,e,f,g); + ROUND256_0_TO_15(g,h,a,b,c,d,e,f); + ROUND256_0_TO_15(f,g,h,a,b,c,d,e); + ROUND256_0_TO_15(e,f,g,h,a,b,c,d); + ROUND256_0_TO_15(d,e,f,g,h,a,b,c); + ROUND256_0_TO_15(c,d,e,f,g,h,a,b); + ROUND256_0_TO_15(b,c,d,e,f,g,h,a); + } while (j < 16); + + /* Now for the remaining rounds to 64: */ + do { + ROUND256(a,b,c,d,e,f,g,h); + ROUND256(h,a,b,c,d,e,f,g); + ROUND256(g,h,a,b,c,d,e,f); + ROUND256(f,g,h,a,b,c,d,e); + ROUND256(e,f,g,h,a,b,c,d); + ROUND256(d,e,f,g,h,a,b,c); + ROUND256(c,d,e,f,g,h,a,b); + ROUND256(b,c,d,e,f,g,h,a); + } while (j < 64); + + /* Compute the current intermediate hash value */ + context->s256.state[0] += a; + context->s256.state[1] += b; + context->s256.state[2] += c; + context->s256.state[3] += d; + context->s256.state[4] += e; + context->s256.state[5] += f; + context->s256.state[6] += g; + context->s256.state[7] += h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = 0; +} + +#else /* SHA2_UNROLL_TRANSFORM */ + +void SHA256_Internal_Transform(SHA_CTX* context, const sha_word32* data) { + sha_word32 a, b, c, d, e, f, g, h, s0, s1; + sha_word32 T1, T2, *W256; + int j; + + W256 = (sha_word32*)context->s256.buffer; + + /* Initialize registers with the prev. intermediate value */ + a = context->s256.state[0]; + b = context->s256.state[1]; + c = context->s256.state[2]; + d = context->s256.state[3]; + e = context->s256.state[4]; + f = context->s256.state[5]; + g = context->s256.state[6]; + h = context->s256.state[7]; + + j = 0; + do { +#if BYTE_ORDER == LITTLE_ENDIAN + /* Copy data while converting to host byte order */ + REVERSE32(*data++,W256[j]); + /* Apply the SHA-256 compression function to update a..h */ + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + W256[j]; +#else /* BYTE_ORDER == LITTLE_ENDIAN */ + /* Apply the SHA-256 compression function to update a..h with copy */ + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j] = *data++); +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + T2 = Sigma0_256(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 16); + + do { + /* Part of the message block expansion: */ + s0 = W256[(j+1)&0x0f]; + s0 = sigma0_256(s0); + s1 = W256[(j+14)&0x0f]; + s1 = sigma1_256(s1); + + /* Apply the SHA-256 compression function to update a..h */ + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + + (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); + T2 = Sigma0_256(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 64); + + /* Compute the current intermediate hash value */ + context->s256.state[0] += a; + context->s256.state[1] += b; + context->s256.state[2] += c; + context->s256.state[3] += d; + context->s256.state[4] += e; + context->s256.state[5] += f; + context->s256.state[6] += g; + context->s256.state[7] += h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = T2 = 0; +} + +#endif /* SHA2_UNROLL_TRANSFORM */ + +void SHA256_Update(SHA_CTX* context, const sha_byte *data, size_t len) { + unsigned int freespace, usedspace; + + if (len == 0) { + /* Calling with no data is valid - we do nothing */ + return; + } + + /* Sanity check: */ + assert(context != (SHA_CTX*)0 && data != (sha_byte*)0); + + usedspace = (unsigned int)((context->s256.bitcount >> 3) % 64); + if (usedspace > 0) { + /* Calculate how much free space is available in the buffer */ + freespace = 64 - usedspace; + + if (len >= freespace) { + /* Fill the buffer completely and process it */ + MEMCPY_BCOPY(&context->s256.buffer[usedspace], data, freespace); + context->s256.bitcount += freespace << 3; + len -= freespace; + data += freespace; + SHA256_Internal_Transform(context, (sha_word32*)context->s256.buffer); + } else { + /* The buffer is not yet full */ + MEMCPY_BCOPY(&context->s256.buffer[usedspace], data, len); + context->s256.bitcount += len << 3; + /* Clean up: */ + usedspace = freespace = 0; + return; + } + } + while (len >= 64) { + /* Process as many complete blocks as we can */ + SHA256_Internal_Transform(context, (sha_word32*)data); + context->s256.bitcount += 512; + len -= 64; + data += 64; + } + if (len > 0) { + /* There's left-overs, so save 'em */ + MEMCPY_BCOPY(context->s256.buffer, data, len); + context->s256.bitcount += len << 3; + } + /* Clean up: */ + usedspace = freespace = 0; +} + +void SHA256_Internal_Last(SHA_CTX* context) { + unsigned int usedspace; + + usedspace = (unsigned int)((context->s256.bitcount >> 3) % 64); +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert FROM host byte order */ + REVERSE64(context->s256.bitcount,context->s256.bitcount); +#endif + if (usedspace > 0) { + /* Begin padding with a 1 bit: */ + context->s256.buffer[usedspace++] = 0x80; + + if (usedspace <= 56) { + /* Set-up for the last transform: */ + MEMSET_BZERO(&context->s256.buffer[usedspace], 56 - usedspace); + } else { + if (usedspace < 64) { + MEMSET_BZERO(&context->s256.buffer[usedspace], 64 - usedspace); + } + /* Do second-to-last transform: */ + SHA256_Internal_Transform(context, (sha_word32*)context->s256.buffer); + + /* And set-up for the last transform: */ + MEMSET_BZERO(context->s256.buffer, 56); + } + /* Clean up: */ + usedspace = 0; + } else { + /* Set-up for the last transform: */ + MEMSET_BZERO(context->s256.buffer, 56); + + /* Begin padding with a 1 bit: */ + *context->s256.buffer = 0x80; + } + /* Set the bit count: */ + *(sha_word64*)&context->s256.buffer[56] = context->s256.bitcount; + + /* Final transform: */ + SHA256_Internal_Transform(context, (sha_word32*)context->s256.buffer); +} + +void SHA256_Final(sha_byte digest[], SHA_CTX* context) { + sha_word32 *d = (sha_word32*)digest; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha_byte*)0) { + SHA256_Internal_Last(context); + + /* Save the hash data for output: */ +#if BYTE_ORDER == LITTLE_ENDIAN + { + /* Convert TO host byte order */ + int j; + for (j = 0; j < (SHA256_DIGEST_LENGTH >> 2); j++) { + REVERSE32(context->s256.state[j],context->s256.state[j]); + *d++ = context->s256.state[j]; + } + } +#else + MEMCPY_BCOPY(d, context->s256.state, SHA256_DIGEST_LENGTH); +#endif + } + + /* Clean up state data: */ + MEMSET_BZERO(context, sizeof(*context)); +} + +char *SHA256_End(SHA_CTX* context, char buffer[]) { + sha_byte digest[SHA256_DIGEST_LENGTH], *d = digest; + int i; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + if (buffer != (char*)0) { + SHA256_Final(digest, context); + + for (i = 0; i < SHA256_DIGEST_LENGTH; i++) { + *buffer++ = sha_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + MEMSET_BZERO(context, sizeof(*context)); + } + MEMSET_BZERO(digest, SHA256_DIGEST_LENGTH); + return buffer; +} + +char* SHA256_Data(const sha_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) { + SHA_CTX context; + + SHA256_Init(&context); + SHA256_Update(&context, data, len); + return SHA256_End(&context, digest); +} + + +/*** SHA-224: *********************************************************/ +void SHA224_Init(SHA_CTX* context) { + SHA256_Internal_Init(context, sha224_initial_hash_value); +} + +void SHA224_Internal_Transform(SHA_CTX* context, const sha_word32* data) { + SHA256_Internal_Transform(context, data); +} + +void SHA224_Update(SHA_CTX* context, const sha_byte *data, size_t len) { + SHA256_Update(context, data, len); +} + +void SHA224_Final(sha_byte digest[], SHA_CTX* context) { + sha_word32 *d = (sha_word32*)digest; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha_byte*)0) { + SHA256_Internal_Last(context); + + /* Save the hash data for output: */ +#if BYTE_ORDER == LITTLE_ENDIAN + { + /* Convert TO host byte order */ + int j; + for (j = 0; j < (SHA224_DIGEST_LENGTH >> 2); j++) { + REVERSE32(context->s256.state[j],context->s256.state[j]); + *d++ = context->s256.state[j]; + } + } +#else + MEMCPY_BCOPY(d, context->s256.state, SHA224_DIGEST_LENGTH); +#endif + } + + /* Clean up state data: */ + MEMSET_BZERO(context, sizeof(*context)); +} + +char *SHA224_End(SHA_CTX* context, char buffer[]) { + sha_byte digest[SHA224_DIGEST_LENGTH], *d = digest; + int i; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + if (buffer != (char*)0) { + SHA224_Final(digest, context); + + for (i = 0; i < SHA224_DIGEST_LENGTH; i++) { + *buffer++ = sha_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + MEMSET_BZERO(context, sizeof(*context)); + } + MEMSET_BZERO(digest, SHA224_DIGEST_LENGTH); + return buffer; +} + +char* SHA224_Data(const sha_byte* data, size_t len, char digest[SHA224_DIGEST_STRING_LENGTH]) { + SHA_CTX context; + + SHA224_Init(&context); + SHA224_Update(&context, data, len); + return SHA224_End(&context, digest); +} + + +/*** SHA-512: *********************************************************/ +void SHA512_Internal_Init(SHA_CTX* context, const sha_word64* ihv) { + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + MEMCPY_BCOPY(context->s512.state, ihv, sizeof(sha_word64) * 8); + MEMSET_BZERO(context->s512.buffer, 128); + context->s512.bitcount[0] = context->s512.bitcount[1] = 0; +} + +void SHA512_Init(SHA_CTX* context) { + SHA512_Internal_Init(context, sha512_initial_hash_value); +} + +#ifdef SHA2_UNROLL_TRANSFORM + +/* Unrolled SHA-512 round macros: */ +#if BYTE_ORDER == LITTLE_ENDIAN + +#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \ + REVERSE64(*data++, W512[j]); \ + T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \ + K512[j] + W512[j]; \ + (d) += T1, \ + (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)), \ + j++ + + +#else /* BYTE_ORDER == LITTLE_ENDIAN */ + +#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \ + T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \ + K512[j] + (W512[j] = *data++); \ + (d) += T1; \ + (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ + j++ + +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + +#define ROUND512(a,b,c,d,e,f,g,h) \ + s0 = W512[(j+1)&0x0f]; \ + s0 = sigma0_512(s0); \ + s1 = W512[(j+14)&0x0f]; \ + s1 = sigma1_512(s1); \ + T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \ + (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \ + (d) += T1; \ + (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ + j++ + +void SHA512_Internal_Transform(SHA_CTX* context, const sha_word64* data) { + sha_word64 a, b, c, d, e, f, g, h, s0, s1; + sha_word64 T1, *W512 = (sha_word64*)context->s512.buffer; + int j; + + /* Initialize registers with the prev. intermediate value */ + a = context->s512.state[0]; + b = context->s512.state[1]; + c = context->s512.state[2]; + d = context->s512.state[3]; + e = context->s512.state[4]; + f = context->s512.state[5]; + g = context->s512.state[6]; + h = context->s512.state[7]; + + j = 0; + do { + ROUND512_0_TO_15(a,b,c,d,e,f,g,h); + ROUND512_0_TO_15(h,a,b,c,d,e,f,g); + ROUND512_0_TO_15(g,h,a,b,c,d,e,f); + ROUND512_0_TO_15(f,g,h,a,b,c,d,e); + ROUND512_0_TO_15(e,f,g,h,a,b,c,d); + ROUND512_0_TO_15(d,e,f,g,h,a,b,c); + ROUND512_0_TO_15(c,d,e,f,g,h,a,b); + ROUND512_0_TO_15(b,c,d,e,f,g,h,a); + } while (j < 16); + + /* Now for the remaining rounds up to 79: */ + do { + ROUND512(a,b,c,d,e,f,g,h); + ROUND512(h,a,b,c,d,e,f,g); + ROUND512(g,h,a,b,c,d,e,f); + ROUND512(f,g,h,a,b,c,d,e); + ROUND512(e,f,g,h,a,b,c,d); + ROUND512(d,e,f,g,h,a,b,c); + ROUND512(c,d,e,f,g,h,a,b); + ROUND512(b,c,d,e,f,g,h,a); + } while (j < 80); + + /* Compute the current intermediate hash value */ + context->s512.state[0] += a; + context->s512.state[1] += b; + context->s512.state[2] += c; + context->s512.state[3] += d; + context->s512.state[4] += e; + context->s512.state[5] += f; + context->s512.state[6] += g; + context->s512.state[7] += h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = 0; +} + +#else /* SHA2_UNROLL_TRANSFORM */ + +void SHA512_Internal_Transform(SHA_CTX* context, const sha_word64* data) { + sha_word64 a, b, c, d, e, f, g, h, s0, s1; + sha_word64 T1, T2, *W512 = (sha_word64*)context->s512.buffer; + int j; + + /* Initialize registers with the prev. intermediate value */ + a = context->s512.state[0]; + b = context->s512.state[1]; + c = context->s512.state[2]; + d = context->s512.state[3]; + e = context->s512.state[4]; + f = context->s512.state[5]; + g = context->s512.state[6]; + h = context->s512.state[7]; + + j = 0; + do { +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + REVERSE64(*data++, W512[j]); + /* Apply the SHA-512 compression function to update a..h */ + T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + W512[j]; +#else /* BYTE_ORDER == LITTLE_ENDIAN */ + /* Apply the SHA-512 compression function to update a..h with copy */ + T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++); +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + T2 = Sigma0_512(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 16); + + do { + /* Part of the message block expansion: */ + s0 = W512[(j+1)&0x0f]; + s0 = sigma0_512(s0); + s1 = W512[(j+14)&0x0f]; + s1 = sigma1_512(s1); + + /* Apply the SHA-512 compression function to update a..h */ + T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + + (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); + T2 = Sigma0_512(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 80); + + /* Compute the current intermediate hash value */ + context->s512.state[0] += a; + context->s512.state[1] += b; + context->s512.state[2] += c; + context->s512.state[3] += d; + context->s512.state[4] += e; + context->s512.state[5] += f; + context->s512.state[6] += g; + context->s512.state[7] += h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = T2 = 0; +} + +#endif /* SHA2_UNROLL_TRANSFORM */ + +void SHA512_Update(SHA_CTX* context, const sha_byte *data, size_t len) { + unsigned int freespace, usedspace; + + if (len == 0) { + /* Calling with no data is valid - we do nothing */ + return; + } + + /* Sanity check: */ + assert(context != (SHA_CTX*)0 && data != (sha_byte*)0); + + usedspace = (unsigned int)((context->s512.bitcount[0] >> 3) % 128); + if (usedspace > 0) { + /* Calculate how much free space is available in the buffer */ + freespace = 128 - usedspace; + + if (len >= freespace) { + /* Fill the buffer completely and process it */ + MEMCPY_BCOPY(&context->s512.buffer[usedspace], data, freespace); + ADDINC128(context->s512.bitcount, freespace << 3); + len -= freespace; + data += freespace; + SHA512_Internal_Transform(context, (sha_word64*)context->s512.buffer); + } else { + /* The buffer is not yet full */ + MEMCPY_BCOPY(&context->s512.buffer[usedspace], data, len); + ADDINC128(context->s512.bitcount, len << 3); + /* Clean up: */ + usedspace = freespace = 0; + return; + } + } + while (len >= 128) { + /* Process as many complete blocks as we can */ + SHA512_Internal_Transform(context, (sha_word64*)data); + ADDINC128(context->s512.bitcount, 1024); + len -= 128; + data += 128; + } + if (len > 0) { + /* There's left-overs, so save 'em */ + MEMCPY_BCOPY(context->s512.buffer, data, len); + ADDINC128(context->s512.bitcount, len << 3); + } + /* Clean up: */ + usedspace = freespace = 0; +} + +void SHA512_Internal_Last(SHA_CTX* context) { + unsigned int usedspace; + + usedspace = (unsigned int)((context->s512.bitcount[0] >> 3) % 128); +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert FROM host byte order */ + REVERSE64(context->s512.bitcount[0],context->s512.bitcount[0]); + REVERSE64(context->s512.bitcount[1],context->s512.bitcount[1]); +#endif + if (usedspace > 0) { + /* Begin padding with a 1 bit: */ + context->s512.buffer[usedspace++] = 0x80; + + if (usedspace <= 112) { + /* Set-up for the last transform: */ + MEMSET_BZERO(&context->s512.buffer[usedspace], 112 - usedspace); + } else { + if (usedspace < 128) { + MEMSET_BZERO(&context->s512.buffer[usedspace], 128 - usedspace); + } + /* Do second-to-last transform: */ + SHA512_Internal_Transform(context, (sha_word64*)context->s512.buffer); + + /* And set-up for the last transform: */ + MEMSET_BZERO(context->s512.buffer, 112); + } + /* Clean up: */ + usedspace = 0; + } else { + /* Prepare for final transform: */ + MEMSET_BZERO(context->s512.buffer, 112); + + /* Begin padding with a 1 bit: */ + *context->s512.buffer = 0x80; + } + /* Store the length of input data (in bits): */ + *(sha_word64*)&context->s512.buffer[112] = context->s512.bitcount[1]; + *(sha_word64*)&context->s512.buffer[120] = context->s512.bitcount[0]; + + /* Final transform: */ + SHA512_Internal_Transform(context, (sha_word64*)context->s512.buffer); +} + +void SHA512_Final(sha_byte digest[], SHA_CTX* context) { + sha_word64 *d = (sha_word64*)digest; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha_byte*)0) { + SHA512_Internal_Last(context); + + /* Save the hash data for output: */ +#if BYTE_ORDER == LITTLE_ENDIAN + { + /* Convert TO host byte order */ + int j; + for (j = 0; j < (SHA512_DIGEST_LENGTH >> 3); j++) { + REVERSE64(context->s512.state[j],context->s512.state[j]); + *d++ = context->s512.state[j]; + } + } +#else + MEMCPY_BCOPY(d, context->s512.state, SHA512_DIGEST_LENGTH); +#endif + } + + /* Zero out state data */ + MEMSET_BZERO(context, sizeof(*context)); +} + +char *SHA512_End(SHA_CTX* context, char buffer[]) { + sha_byte digest[SHA512_DIGEST_LENGTH], *d = digest; + int i; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + if (buffer != (char*)0) { + SHA512_Final(digest, context); + + for (i = 0; i < SHA512_DIGEST_LENGTH; i++) { + *buffer++ = sha_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + MEMSET_BZERO(context, sizeof(*context)); + } + MEMSET_BZERO(digest, SHA512_DIGEST_LENGTH); + return buffer; +} + +char* SHA512_Data(const sha_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) { + SHA_CTX context; + + SHA512_Init(&context); + SHA512_Update(&context, data, len); + return SHA512_End(&context, digest); +} + + +/*** SHA-384: *********************************************************/ +void SHA384_Init(SHA_CTX* context) { + SHA512_Internal_Init(context, sha384_initial_hash_value); +} + +void SHA384_Update(SHA_CTX* context, const sha_byte* data, size_t len) { + SHA512_Update(context, data, len); +} + +void SHA384_Final(sha_byte digest[], SHA_CTX* context) { + sha_word64 *d = (sha_word64*)digest; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha_byte*)0) { + SHA512_Internal_Last(context); + + /* Save the hash data for output: */ +#if BYTE_ORDER == LITTLE_ENDIAN + { + /* Convert TO host byte order */ + int j; + for (j = 0; j < (SHA384_DIGEST_LENGTH >> 3); j++) { + REVERSE64(context->s512.state[j],context->s512.state[j]); + *d++ = context->s512.state[j]; + } + } +#else + MEMCPY_BCOPY(d, context->s512.state, SHA384_DIGEST_LENGTH); +#endif + } + + /* Zero out state data */ + MEMSET_BZERO(context, sizeof(*context)); +} + +char *SHA384_End(SHA_CTX* context, char buffer[]) { + sha_byte digest[SHA384_DIGEST_LENGTH], *d = digest; + int i; + + /* Sanity check: */ + assert(context != (SHA_CTX*)0); + + if (buffer != (char*)0) { + SHA384_Final(digest, context); + + for (i = 0; i < SHA384_DIGEST_LENGTH; i++) { + *buffer++ = sha_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + MEMSET_BZERO(context, sizeof(*context)); + } + MEMSET_BZERO(digest, SHA384_DIGEST_LENGTH); + return buffer; +} + +char* SHA384_Data(const sha_byte* data, size_t len, char digest[SHA384_DIGEST_STRING_LENGTH]) { + SHA_CTX context; + + SHA384_Init(&context); + SHA384_Update(&context, data, len); + return SHA384_End(&context, digest); +} diff --git a/Source/cm_sha2.h b/Source/cm_sha2.h new file mode 100644 index 000000000..71395f06b --- /dev/null +++ b/Source/cm_sha2.h @@ -0,0 +1,140 @@ +/* + * FILE: sha2.h + * AUTHOR: Aaron D. Gifford + * http://www.aarongifford.com/computers/sha.html + * + * Copyright (c) 2000-2003, Aaron D. Gifford + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (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: sha2.h,v 1.4 2004/01/07 19:06:18 adg Exp $ + */ + +#ifndef __SHA2_H__ +#define __SHA2_H__ + +#include "cm_sha2_mangle.h" + +/* CMake modification: use integer types from cmIML. */ +#include "cmIML/INT.h" +typedef cmIML_INT_uint8_t cm_sha2_uint8_t; +typedef cmIML_INT_uint32_t cm_sha2_uint32_t; +typedef cmIML_INT_uint64_t cm_sha2_uint64_t; + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Import u_intXX_t size_t type definitions from system headers. You + * may need to change this, or define these things yourself in this + * file. + */ +#include + +/*** SHA-224/256/384/512 Various Length Definitions *******************/ + +/* Digest lengths for SHA-1/224/256/384/512 */ +#define SHA1_DIGEST_LENGTH 20 +#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1) +#define SHA224_DIGEST_LENGTH 28 +#define SHA224_DIGEST_STRING_LENGTH (SHA224_DIGEST_LENGTH * 2 + 1) +#define SHA256_DIGEST_LENGTH 32 +#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) +#define SHA384_DIGEST_LENGTH 48 +#define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) +#define SHA512_DIGEST_LENGTH 64 +#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) + + +/*** SHA-224/256/384/512 Context Structures ***************************/ + +typedef union _SHA_CTX { + /* SHA-1 uses this part of the union: */ + struct { + cm_sha2_uint32_t state[5]; + cm_sha2_uint64_t bitcount; + cm_sha2_uint8_t buffer[64]; + } s1; + + /* SHA-224 and SHA-256 use this part of the union: */ + struct { + cm_sha2_uint32_t state[8]; + cm_sha2_uint64_t bitcount; + cm_sha2_uint8_t buffer[64]; + } s256; + + /* SHA-384 and SHA-512 use this part of the union: */ + struct { + cm_sha2_uint64_t state[8]; + cm_sha2_uint64_t bitcount[2]; + cm_sha2_uint8_t buffer[128]; + } s512; +} SHA_CTX; + +/*** SHA-256/384/512 Function Prototypes ******************************/ + +void SHA1_Init(SHA_CTX*); +void SHA1_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); +void SHA1_Final(cm_sha2_uint8_t[SHA1_DIGEST_LENGTH], SHA_CTX*); +char* SHA1_End(SHA_CTX*, char[SHA1_DIGEST_STRING_LENGTH]); +char* SHA1_Data(const cm_sha2_uint8_t*, size_t, + char[SHA1_DIGEST_STRING_LENGTH]); + +void SHA224_Init(SHA_CTX*); +void SHA224_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); +void SHA224_Final(cm_sha2_uint8_t[SHA224_DIGEST_LENGTH], SHA_CTX*); +char* SHA224_End(SHA_CTX*, char[SHA224_DIGEST_STRING_LENGTH]); +char* SHA224_Data(const cm_sha2_uint8_t*, size_t, + char[SHA224_DIGEST_STRING_LENGTH]); + +void SHA256_Init(SHA_CTX*); +void SHA256_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); +void SHA256_Final(cm_sha2_uint8_t[SHA256_DIGEST_LENGTH], SHA_CTX*); +char* SHA256_End(SHA_CTX*, char[SHA256_DIGEST_STRING_LENGTH]); +char* SHA256_Data(const cm_sha2_uint8_t*, size_t, + char[SHA256_DIGEST_STRING_LENGTH]); + +void SHA384_Init(SHA_CTX*); +void SHA384_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); +void SHA384_Final(cm_sha2_uint8_t[SHA384_DIGEST_LENGTH], SHA_CTX*); +char* SHA384_End(SHA_CTX*, char[SHA384_DIGEST_STRING_LENGTH]); +char* SHA384_Data(const cm_sha2_uint8_t*, size_t, + char[SHA384_DIGEST_STRING_LENGTH]); + +void SHA512_Init(SHA_CTX*); +void SHA512_Update(SHA_CTX*, const cm_sha2_uint8_t*, size_t); +void SHA512_Final(cm_sha2_uint8_t[SHA512_DIGEST_LENGTH], SHA_CTX*); +char* SHA512_End(SHA_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); +char* SHA512_Data(const cm_sha2_uint8_t*, size_t, + char[SHA512_DIGEST_STRING_LENGTH]); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __SHA2_H__ */ diff --git a/Source/cm_sha2_mangle.h b/Source/cm_sha2_mangle.h new file mode 100644 index 000000000..e73d13141 --- /dev/null +++ b/Source/cm_sha2_mangle.h @@ -0,0 +1,51 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2011 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cm_sha2_mangle_h +#define cm_sha2_mangle_h + +/* Mangle sha2 symbol names to avoid possible conflict with + implementations in other libraries to which CMake links. */ +#define SHA1_Data cmSHA1_Data +#define SHA1_End cmSHA1_End +#define SHA1_Final cmSHA1_Final +#define SHA1_Init cmSHA1_Init +#define SHA1_Internal_Transform cmSHA1_Internal_Transform +#define SHA1_Update cmSHA1_Update +#define SHA224_Data cmSHA224_Data +#define SHA224_End cmSHA224_End +#define SHA224_Final cmSHA224_Final +#define SHA224_Init cmSHA224_Init +#define SHA224_Internal_Transform cmSHA224_Internal_Transform +#define SHA224_Update cmSHA224_Update +#define SHA256_Data cmSHA256_Data +#define SHA256_End cmSHA256_End +#define SHA256_Final cmSHA256_Final +#define SHA256_Init cmSHA256_Init +#define SHA256_Internal_Init cmSHA256_Internal_Init +#define SHA256_Internal_Last cmSHA256_Internal_Last +#define SHA256_Internal_Transform cmSHA256_Internal_Transform +#define SHA256_Update cmSHA256_Update +#define SHA384_Data cmSHA384_Data +#define SHA384_End cmSHA384_End +#define SHA384_Final cmSHA384_Final +#define SHA384_Init cmSHA384_Init +#define SHA384_Update cmSHA384_Update +#define SHA512_Data cmSHA512_Data +#define SHA512_End cmSHA512_End +#define SHA512_Final cmSHA512_Final +#define SHA512_Init cmSHA512_Init +#define SHA512_Internal_Init cmSHA512_Internal_Init +#define SHA512_Internal_Last cmSHA512_Internal_Last +#define SHA512_Internal_Transform cmSHA512_Internal_Transform +#define SHA512_Update cmSHA512_Update + +#endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 45927cb04..d691f46dc 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -20,6 +20,7 @@ #include "cmCommand.h" #include "cmFileTimeComparison.h" #include "cmGeneratedFileStream.h" +#include "cmQtAutomoc.h" #include "cmSourceFile.h" #include "cmVersion.h" #include "cmTest.h" @@ -62,9 +63,13 @@ # include "cmGlobalVisualStudio71Generator.h" # include "cmGlobalVisualStudio8Generator.h" # include "cmGlobalVisualStudio9Generator.h" +# include "cmGlobalVisualStudio9IA64Generator.h" # include "cmGlobalVisualStudio9Win64Generator.h" # include "cmGlobalVisualStudio10Generator.h" +# include "cmGlobalVisualStudio10IA64Generator.h" # include "cmGlobalVisualStudio10Win64Generator.h" +# include "cmGlobalVisualStudio11Generator.h" +# include "cmGlobalVisualStudio11Win64Generator.h" # include "cmGlobalVisualStudio8Win64Generator.h" # include "cmGlobalBorlandMakefileGenerator.h" # include "cmGlobalNMakeMakefileGenerator.h" @@ -180,7 +185,7 @@ cmake::cmake() this->GlobalGenerator = 0; this->ProgressCallback = 0; this->ProgressCallbackClientData = 0; - this->ScriptMode = false; + this->CurrentWorkingMode = NORMAL_MODE; #ifdef CMAKE_BUILD_WITH_CMAKE this->VariableWatch = new cmVariableWatch; @@ -353,6 +358,7 @@ void cmake::RemoveUnscriptableCommands() // Parse the args bool cmake::SetCacheArgs(const std::vector& args) { + bool findPackageMode = false; for(unsigned int i=1; i < args.size(); ++i) { std::string arg = args[i]; @@ -480,7 +486,17 @@ bool cmake::SetCacheArgs(const std::vector& args) } this->ReadListFile(args, path.c_str()); } + else if (arg.find("--find-package",0) == 0) + { + findPackageMode = true; + } + } + + if (findPackageMode) + { + return this->FindPackage(args); } + return true; } @@ -511,7 +527,7 @@ void cmake::ReadListFile(const std::vector& args, (cmSystemTools::GetCurrentWorkingDirectory().c_str()); lg->GetMakefile()->SetStartDirectory (cmSystemTools::GetCurrentWorkingDirectory().c_str()); - if (this->GetScriptMode()) + if (this->GetWorkingMode() != NORMAL_MODE) { std::string file(cmSystemTools::CollapseFullPath(path)); cmSystemTools::ConvertToUnixSlashes(file); @@ -532,6 +548,111 @@ void cmake::ReadListFile(const std::vector& args, } } + +bool cmake::FindPackage(const std::vector& args) +{ + // if a generator was not yet created, temporarily create one + cmGlobalGenerator *gg = new cmGlobalGenerator; + gg->SetCMakeInstance(this); + this->SetGlobalGenerator(gg); + + // read in the list file to fill the cache + std::auto_ptr lg(gg->CreateLocalGenerator()); + cmMakefile* mf = lg->GetMakefile(); + mf->SetHomeOutputDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + mf->SetStartOutputDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + mf->SetHomeDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + mf->SetStartDirectory + (cmSystemTools::GetCurrentWorkingDirectory().c_str()); + + mf->SetArgcArgv(args); + + std::string systemFile = mf->GetModulesFile("CMakeFindPackageMode.cmake"); + mf->ReadListFile(0, systemFile.c_str()); + + std::string language = mf->GetSafeDefinition("LANGUAGE"); + std::string mode = mf->GetSafeDefinition("MODE"); + std::string packageName = mf->GetSafeDefinition("NAME"); + bool packageFound = mf->IsOn("PACKAGE_FOUND"); + bool quiet = mf->IsOn("PACKAGE_QUIET"); + + if (!packageFound) + { + if (!quiet) + { + printf("%s not found.\n", packageName.c_str()); + } + } + else if (mode == "EXIST") + { + if (!quiet) + { + printf("%s found.\n", packageName.c_str()); + } + } + else if (mode == "COMPILE") + { + std::string includes = mf->GetSafeDefinition("PACKAGE_INCLUDE_DIRS"); + std::vector includeDirs; + cmSystemTools::ExpandListArgument(includes, includeDirs); + for(std::vector::const_iterator dirIt=includeDirs.begin(); + dirIt != includeDirs.end(); + ++dirIt) + { + mf->AddIncludeDirectory(dirIt->c_str(), false); + } + + std::string includeFlags = lg->GetIncludeFlags(language.c_str(), false); + std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS"); + printf("%s %s\n", includeFlags.c_str(), definitions.c_str()); + } + else if (mode == "LINK") + { + const char* targetName = "dummy"; + std::vector srcs; + cmTarget* tgt = mf->AddExecutable(targetName, srcs, true); + tgt->SetProperty("LINKER_LANGUAGE", language.c_str()); + + std::string libs = mf->GetSafeDefinition("PACKAGE_LIBRARIES"); + std::vector libList; + cmSystemTools::ExpandListArgument(libs, libList); + for(std::vector::const_iterator libIt=libList.begin(); + libIt != libList.end(); + ++libIt) + { + mf->AddLinkLibraryForTarget(targetName, libIt->c_str(), + cmTarget::GENERAL); + } + + + std::string linkLibs; + std::string flags; + std::string linkFlags; + lg->GetTargetFlags(linkLibs, flags, linkFlags, *tgt); + + printf("%s\n", linkLibs.c_str() ); + +/* if ( use_win32 ) + { + tgt->SetProperty("WIN32_EXECUTABLE", "ON"); + } + if ( use_macbundle) + { + tgt->SetProperty("MACOSX_BUNDLE", "ON"); + }*/ + } + + // free generic one if generated +// this->SetGlobalGenerator(0); // setting 0-pointer is not possible +// delete gg; // this crashes inside the cmake instance + + return packageFound; +} + + // Parse the args void cmake::SetArgs(const std::vector& args, bool directoriesSetBefore) @@ -604,6 +725,11 @@ void cmake::SetArgs(const std::vector& args, // skip for now i++; } + else if(arg.find("--find-package",0) == 0) + { + // skip for now + i++; + } else if(arg.find("-Wno-dev",0) == 0) { // skip for now @@ -988,7 +1114,6 @@ void CMakeCommandUsage(const char* program) errorStream << "Usage: " << program << " -E [command] [arguments ...]\n" << "Available commands: \n" - << " build build_dir - build the project in build_dir.\n" << " chdir dir cmd [args]... - run command in a given directory\n" << " compare_files file1 file2 - check if file1 is same as file2\n" << " copy file destination - copy file to destination (either file " @@ -1297,7 +1422,7 @@ int cmake::ExecuteCMakeCommand(std::vector& args) int retval = 0; int timeout = 0; if ( cmSystemTools::RunSingleCommand(command.c_str(), 0, &retval, - directory.c_str(), true, timeout) ) + directory.c_str(), cmSystemTools::OUTPUT_MERGE, timeout) ) { return retval; } @@ -1570,6 +1695,12 @@ int cmake::ExecuteCMakeCommand(std::vector& args) { return cmake::ExecuteEchoColor(args); } + else if (args[1] == "cmake_automoc") + { + cmQtAutomoc automoc; + automoc.Run(args[2].c_str()); + return 0; + } #endif // Tar files @@ -2026,7 +2157,7 @@ int cmake::ActualConfigure() this->CleanupCommandsAndMacros(); int res = 0; - if ( !this->ScriptMode ) + if ( this->GetWorkingMode() == NORMAL_MODE ) { res = this->DoPreConfigureChecks(); } @@ -2214,7 +2345,7 @@ int cmake::ActualConfigure() this->CacheManager->RemoveCacheEntry("CMAKE_EXTRA_GENERATOR"); } // only save the cache if there were no fatal errors - if ( !this->ScriptMode ) + if ( this->GetWorkingMode() == NORMAL_MODE ) { this->CacheManager->SaveCache(this->GetHomeOutputDirectory()); } @@ -2280,7 +2411,7 @@ int cmake::Run(const std::vector& args, bool noconfigure) // set the cmake command this->CMakeCommand = args[0]; - if ( !this->ScriptMode ) + if ( this->GetWorkingMode() == NORMAL_MODE ) { // load the cache if(this->LoadCache() < 0) @@ -2301,7 +2432,7 @@ int cmake::Run(const std::vector& args, bool noconfigure) } // In script mode we terminate after running the script. - if(this->ScriptMode) + if(this->GetWorkingMode() != NORMAL_MODE) { if(cmSystemTools::GetErrorOccuredFlag()) { @@ -2347,7 +2478,7 @@ int cmake::Run(const std::vector& args, bool noconfigure) this->SetStartDirectory(this->GetHomeDirectory()); this->SetStartOutputDirectory(this->GetHomeOutputDirectory()); int ret = this->Configure(); - if (ret || this->ScriptMode) + if (ret || this->GetWorkingMode() != NORMAL_MODE) { #if defined(CMAKE_HAVE_VS_GENERATORS) if(!this->VSSolutionFile.empty() && this->GlobalGenerator) @@ -2401,6 +2532,13 @@ int cmake::Generate() this->ReportUndefinedPropertyAccesses (this->GetProperty("REPORT_UNDEFINED_PROPERTIES")); } + // Save the cache again after a successful Generate so that any internal + // variables created during Generate are saved. (Specifically target GUIDs + // for the Visual Studio and Xcode generators.) + if ( this->GetWorkingMode() == NORMAL_MODE ) + { + this->CacheManager->SaveCache(this->GetHomeOutputDirectory()); + } return 0; } @@ -2440,14 +2578,22 @@ void cmake::AddDefaultGenerators() &cmGlobalVisualStudio7Generator::New; this->Generators[cmGlobalVisualStudio10Generator::GetActualName()] = &cmGlobalVisualStudio10Generator::New; + this->Generators[cmGlobalVisualStudio10IA64Generator::GetActualName()] = + &cmGlobalVisualStudio10IA64Generator::New; this->Generators[cmGlobalVisualStudio10Win64Generator::GetActualName()] = &cmGlobalVisualStudio10Win64Generator::New; + this->Generators[cmGlobalVisualStudio11Generator::GetActualName()] = + &cmGlobalVisualStudio11Generator::New; + this->Generators[cmGlobalVisualStudio11Win64Generator::GetActualName()] = + &cmGlobalVisualStudio11Win64Generator::New; this->Generators[cmGlobalVisualStudio71Generator::GetActualName()] = &cmGlobalVisualStudio71Generator::New; this->Generators[cmGlobalVisualStudio8Generator::GetActualName()] = &cmGlobalVisualStudio8Generator::New; this->Generators[cmGlobalVisualStudio9Generator::GetActualName()] = &cmGlobalVisualStudio9Generator::New; + this->Generators[cmGlobalVisualStudio9IA64Generator::GetActualName()] = + &cmGlobalVisualStudio9IA64Generator::New; this->Generators[cmGlobalVisualStudio9Win64Generator::GetActualName()] = &cmGlobalVisualStudio9Win64Generator::New; this->Generators[cmGlobalVisualStudio8Win64Generator::GetActualName()] = @@ -2735,7 +2881,7 @@ int cmake::CheckBuildSystem() return 1; } - // Find find the newest dependency. + // Find the newest dependency. std::vector::iterator dep = depends.begin(); std::string dep_newest = *dep++; for(;dep != depends.end(); ++dep) @@ -2761,7 +2907,7 @@ int cmake::CheckBuildSystem() } } - // Find find the oldest output. + // Find the oldest output. std::vector::iterator out = outputs.begin(); std::string out_oldest = *out++; for(;out != outputs.end(); ++out) @@ -2913,6 +3059,13 @@ const char* cmake::GetCPackCommand() return this->CPackCommand.c_str(); } + +const char* cmake::GetCMakeCommand() +{ + return this->CMakeCommand.c_str(); +} + + void cmake::MarkCliAsUsed(const std::string& variable) { this->UsedCliVariables[variable] = true; @@ -3536,7 +3689,7 @@ void cmake::SetProperty(const char* prop, const char* value) this->Properties.SetProperty(prop, value, cmProperty::GLOBAL); } -void cmake::AppendProperty(const char* prop, const char* value) +void cmake::AppendProperty(const char* prop, const char* value, bool asString) { if (!prop) { @@ -3549,7 +3702,7 @@ void cmake::AppendProperty(const char* prop, const char* value) this->DebugConfigs.clear(); } - this->Properties.AppendProperty(prop, value, cmProperty::GLOBAL); + this->Properties.AppendProperty(prop, value, cmProperty::GLOBAL, asString); } const char *cmake::GetProperty(const char* prop) @@ -3978,7 +4131,7 @@ bool cmake::RunCommand(const char* comment, // use rc command to create .res file cmSystemTools::RunSingleCommand(command, &output, - &retCode, 0, false); + &retCode, 0, cmSystemTools::OUTPUT_NONE); // always print the output of the command, unless // it is the dumb rc command banner, but if the command // returned an error code then print the output anyway as @@ -4296,7 +4449,8 @@ int cmake::Build(const std::string& dir, const std::string& target, const std::string& config, const std::vector& nativeOptions, - bool clean) + bool clean, + cmSystemTools::OutputOption outputflag) { if(!cmSystemTools::FileIsDirectory(dir.c_str())) { @@ -4338,7 +4492,7 @@ int cmake::Build(const std::string& dir, projName.c_str(), target.c_str(), &output, makeProgram.c_str(), - config.c_str(), clean, false, 0, true, + config.c_str(), clean, false, 0, outputflag, 0, nativeOptions); } diff --git a/Source/cmake.h b/Source/cmake.h index fac86c18e..ae56e8590 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -64,6 +64,25 @@ class cmake WARNING, LOG }; + + + /** Describes the working modes of cmake. + * NORMAL_MODE: cmake runs to create project files + * SCRIPT_MODE: in script mode there is no generator and no cache. Also, + * language are not enabled, so add_executable and things do + * not do anything. Started by using -P + * FIND_PACKAGE_MODE: cmake runs in pkg-config like mode, i.e. it just + * searches for a package and prints the results to stdout. + * This is similar to SCRIPT_MODE, but commands like + * add_library() work too, since they may be used e.g. in + * exported target files. Started via --find-package + */ + enum WorkingMode + { + NORMAL_MODE, + SCRIPT_MODE, + FIND_PACKAGE_MODE + }; typedef std::map RegisteredCommandsMap; ///! construct an instance of cmake @@ -263,7 +282,7 @@ class cmake ///! Set/Get a property of this target file void SetProperty(const char *prop, const char *value); - void AppendProperty(const char *prop, const char *value); + void AppendProperty(const char *prop, const char *value,bool asString=false); const char *GetProperty(const char *prop); const char *GetProperty(const char *prop, cmProperty::ScopeType scope); bool GetPropertyAsBool(const char *prop); @@ -274,13 +293,8 @@ class cmake ///! Do all the checks before running configure int DoPreConfigureChecks(); - /** - * Set and get the script mode option. In script mode there is no - * generator and no cache. Also, language are not enabled, so - * add_executable and things do not do anything. - */ - void SetScriptMode(bool mode) { this->ScriptMode = mode; } - bool GetScriptMode() { return this->ScriptMode; } + void SetWorkingMode(WorkingMode mode) { this->CurrentWorkingMode = mode; } + WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; } ///! Debug the try compile stuff by not delelting the files bool GetDebugTryCompile(){return this->DebugTryCompile;} @@ -301,6 +315,7 @@ class cmake */ const char* GetCTestCommand(); const char* GetCPackCommand(); + const char* GetCMakeCommand(); // Do we want debug output during the cmake run. bool GetDebugOutput() { return this->DebugOutput; } @@ -364,7 +379,8 @@ class cmake const std::string& target, const std::string& config, const std::vector& nativeOptions, - bool clean); + bool clean, + cmSystemTools::OutputOption outputflag); void UnwatchUnusedCli(const char* var); void WatchUnusedCli(const char* var); @@ -407,6 +423,7 @@ protected: ///! read in a cmake list file to initialize the cache void ReadListFile(const std::vector& args, const char *path); + bool FindPackage(const std::vector& args); ///! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file. /// If it is set, truncate it to 50kb @@ -460,7 +477,7 @@ private: void* ProgressCallbackClientData; bool Verbose; bool InTryCompile; - bool ScriptMode; + WorkingMode CurrentWorkingMode; bool DebugOutput; bool Trace; bool WarnUninitialized; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 663ce8f07..436236db1 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -62,6 +62,7 @@ static const char * cmDocumentationDescription[][3] = " --config = For multi-configuration tools, choose .\n" \ " --clean-first = Build target 'clean' first, then build.\n" \ " (To clean only, use --target 'clean'.)\n" \ + " --use-stderr = Don't merge stdout/stderr.\n" \ " -- = Pass remaining options to the native tool.\n" //---------------------------------------------------------------------------- @@ -71,7 +72,7 @@ static const char * cmDocumentationOptions[][3] = {"-E", "CMake command mode.", "For true platform independence, CMake provides a list of commands " "that can be used on all systems. Run with -E help for the usage " - "information. Commands available are: build, chdir, compare_files, copy, " + "information. Commands available are: chdir, compare_files, copy, " "copy_directory, copy_if_different, echo, echo_append, environment, " "make_directory, md5sum, remove, remove_directory, rename, tar, time, " "touch, touch_nocreate. In addition, some platform specific commands " @@ -102,6 +103,11 @@ static const char * cmDocumentationOptions[][3] = "No configure or generate step is performed and the cache is not" " modified. If variables are defined using -D, this must be done " "before the -P argument."}, + {"--find-package", "Run in pkg-config like mode.", + "Search a package using find_package() and print the resulting flags " + "to stdout. This can be used to use cmake instead of pkg-config to find " + "installed libraries in plain Makefile-based projects or in " + "autoconf-based projects (via share/aclocal/cmake.m4)."}, {"--graphviz=[file]", "Generate graphviz of dependencies.", "Generate a graphviz input file that will contain all the library and " "executable dependencies in the project."}, @@ -433,7 +439,7 @@ int do_cmake(int ac, char** av) bool list_all_cached = false; bool list_help = false; bool view_only = false; - bool script_mode = false; + cmake::WorkingMode workingMode = cmake::NORMAL_MODE; std::vector args; for(int i =0; i < ac; ++i) { @@ -481,12 +487,18 @@ int do_cmake(int ac, char** av) } else { - script_mode = true; + workingMode = cmake::SCRIPT_MODE; args.push_back(av[i]); i++; args.push_back(av[i]); } } + else if (!command && strncmp(av[i], "--find-package", + strlen("--find-package")) == 0) + { + workingMode = cmake::FIND_PACKAGE_MODE; + args.push_back(av[i]); + } else { args.push_back(av[i]); @@ -511,7 +523,7 @@ int do_cmake(int ac, char** av) cmake cm; cmSystemTools::SetErrorCallback(cmakemainErrorCallback, (void *)&cm); cm.SetProgressCallback(cmakemainProgressCallback, (void *)&cm); - cm.SetScriptMode(script_mode); + cm.SetWorkingMode(workingMode); int res = cm.Run(args, view_only); if ( list_cached || list_all_cached ) @@ -568,6 +580,7 @@ static int do_build(int ac, char** av) std::string dir; std::vector nativeOptions; bool clean = false; + cmSystemTools::OutputOption outputflag = cmSystemTools::OUTPUT_MERGE; enum Doing { DoingNone, DoingDir, DoingTarget, DoingConfig, DoingNative}; Doing doing = DoingDir; @@ -590,6 +603,10 @@ static int do_build(int ac, char** av) clean = true; doing = DoingNone; } + else if(strcmp(av[i], "--use-stderr") == 0) + { + outputflag = cmSystemTools::OUTPUT_NORMAL; + } else if(strcmp(av[i], "--") == 0) { doing = DoingNative; @@ -635,6 +652,6 @@ static int do_build(int ac, char** av) } cmake cm; - return cm.Build(dir, target, config, nativeOptions, clean); + return cm.Build(dir, target, config, nativeOptions, clean, outputflag); #endif } diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 3937d8d17..85cecea89 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -68,6 +68,10 @@ static const char * cmDocumentationOptions[][3] = {"-F", "Enable failover.", "This option allows ctest to resume a test " "set execution that was previously interrupted. If no interruption " "occurred, the -F option will have no effect."}, + {"-j , --parallel ", "Run the tests in parallel using the" + "given number of jobs.", + "This option tells ctest to run the tests in parallel using given " + "number of jobs."}, {"-Q,--quiet", "Make ctest quiet.", "This option will suppress all the output. The output log file will " "still be generated if the --output-log is specified. Options such " @@ -180,8 +184,8 @@ static const char * cmDocumentationOptions[][3] = {"--build-project", "Specify the name of the project to build.", "" }, {"--build-makeprogram", "Specify the make program to use.", "" }, {"--build-noclean", "Skip the make clean step.", "" }, - {"--build-config-sample", - "A sample executable to use to determine the configuration", + {"--build-config-sample", + "A sample executable to use to determine the configuration", "A sample executable to use to determine the configuration that " "should be used. e.g. Debug/Release/etc" }, {"--build-options", "Add extra options to the build step.", @@ -276,7 +280,7 @@ int main (int argc, char *argv[]) // If there is a testing input file, check for documentation options // only if there are actually arguments. We want running without // arguments to run tests. - if(argc > 1 || !(cmSystemTools::FileExists("CTestTestfile.cmake") || + if(argc > 1 || !(cmSystemTools::FileExists("CTestTestfile.cmake") || cmSystemTools::FileExists("DartTestfile.txt"))) { if(argc == 1) @@ -301,7 +305,7 @@ int main (int argc, char *argv[]) doc.SetSection("Name",cmDocumentationName); doc.SetSection("Usage",cmDocumentationUsage); doc.SetSection("Description",cmDocumentationDescription); - doc.SetSection("Options",cmDocumentationOptions); + doc.PrependSection("Options",cmDocumentationOptions); doc.SetSection("Commands",commands); doc.SetSeeAlsoList(cmDocumentationSeeAlso); #ifdef cout diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx index 9f43a47c8..ece88ae89 100644 --- a/Source/kwsys/CommandLineArguments.cxx +++ b/Source/kwsys/CommandLineArguments.cxx @@ -592,7 +592,7 @@ void CommandLineArguments::GenerateHelp() // Create format for that string char format[80]; - sprintf(format, " %%-%ds ", static_cast(maxlen)); + sprintf(format, " %%-%us ", static_cast(maxlen)); maxlen += 4; // For the space before and after the option diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx index c1f510099..513eb6408 100644 --- a/Source/kwsys/Glob.cxx +++ b/Source/kwsys/Glob.cxx @@ -215,7 +215,7 @@ kwsys_stl::string Glob::PatternToRegex(const kwsys_stl::string& pattern, //---------------------------------------------------------------------------- void Glob::RecurseDirectory(kwsys_stl::string::size_type start, - const kwsys_stl::string& dir, bool dir_only) + const kwsys_stl::string& dir) { kwsys::Directory d; if ( !d.Load(dir.c_str()) ) @@ -258,25 +258,24 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start, fullname = dir + "/" + fname; } - if ( !dir_only || !kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) + bool isDir = kwsys::SystemTools::FileIsDirectory(realname.c_str()); + bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str()); + + if ( isDir && (!isSymLink || this->RecurseThroughSymlinks) ) { - if ( (this->Internals->Expressions.size() > 0) && - this->Internals->Expressions[ - this->Internals->Expressions.size()-1].find(fname.c_str()) ) + if (isSymLink) { - this->AddFile(this->Internals->Files, realname.c_str()); + ++this->FollowedSymlinkCount; } + this->RecurseDirectory(start+1, realname); } - if ( kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) + else { - bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str()); - if (!isSymLink || this->RecurseThroughSymlinks) + if ( (this->Internals->Expressions.size() > 0) && + this->Internals->Expressions[ + this->Internals->Expressions.size()-1].find(fname.c_str()) ) { - if (isSymLink) - { - ++this->FollowedSymlinkCount; - } - this->RecurseDirectory(start+1, realname, dir_only); + this->AddFile(this->Internals->Files, realname.c_str()); } } } @@ -284,13 +283,13 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start, //---------------------------------------------------------------------------- void Glob::ProcessDirectory(kwsys_stl::string::size_type start, - const kwsys_stl::string& dir, bool dir_only) + const kwsys_stl::string& dir) { //kwsys_ios::cout << "ProcessDirectory: " << dir << kwsys_ios::endl; bool last = ( start == this->Internals->Expressions.size()-1 ); if ( last && this->Recurse ) { - this->RecurseDirectory(start, dir, dir_only); + this->RecurseDirectory(start, dir); return; } @@ -345,7 +344,7 @@ void Glob::ProcessDirectory(kwsys_stl::string::size_type start, // << this->Internals->TextExpressions[start].c_str() << kwsys_ios::endl; //kwsys_ios::cout << "Full name: " << fullname << kwsys_ios::endl; - if ( (!dir_only || !last) && + if ( !last && !kwsys::SystemTools::FileIsDirectory(realname.c_str()) ) { continue; @@ -359,7 +358,7 @@ void Glob::ProcessDirectory(kwsys_stl::string::size_type start, } else { - this->ProcessDirectory(start+1, realname + "/", dir_only); + this->ProcessDirectory(start+1, realname + "/"); } } } @@ -462,12 +461,11 @@ bool Glob::FindFiles(const kwsys_stl::string& inexpr) // Handle network paths if ( skip > 0 ) { - this->ProcessDirectory(0, fexpr.substr(0, skip) + "/", - true); + this->ProcessDirectory(0, fexpr.substr(0, skip) + "/"); } else { - this->ProcessDirectory(0, "/", true); + this->ProcessDirectory(0, "/"); } return true; } diff --git a/Source/kwsys/Glob.hxx.in b/Source/kwsys/Glob.hxx.in index cb050ee28..88c343ce0 100644 --- a/Source/kwsys/Glob.hxx.in +++ b/Source/kwsys/Glob.hxx.in @@ -83,12 +83,12 @@ public: protected: //! Process directory void ProcessDirectory(kwsys_stl::string::size_type start, - const kwsys_stl::string& dir, bool dir_only); + const kwsys_stl::string& dir); //! Process last directory, but only when recurse flags is on. That is // effectively like saying: /path/to/file/**/file void RecurseDirectory(kwsys_stl::string::size_type start, - const kwsys_stl::string& dir, bool dir_only); + const kwsys_stl::string& dir); //! Add regular expression void AddExpression(const char* expr); diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index 9bc659e22..d49c0d73c 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -72,7 +72,7 @@ # include // int isdigit(int c); # include // extern int errno; # include -#elif __hpux +#elif defined( __hpux ) # include # include #endif @@ -1454,7 +1454,7 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed() { bool retrieved = false; -#if _WIN32 +#if defined(_WIN32) // First of all we check to see if the RDTSC (0x0F, 0x31) instruction is // supported. If not, we fallback to trying to read this value from the // registry: @@ -2389,7 +2389,7 @@ int SystemInformationImplementation::QueryMemory() this->AvailablePhysicalMemory = 0; #ifdef __CYGWIN__ return 0; -#elif _WIN32 +#elif defined(_WIN32) #if _MSC_VER < 1300 MEMORYSTATUS ms; unsigned long tv, tp, av, ap; @@ -2415,7 +2415,7 @@ int SystemInformationImplementation::QueryMemory() this->AvailableVirtualMemory = av>>10>>10; this->AvailablePhysicalMemory = ap>>10>>10; return 1; -#elif __linux +#elif defined(__linux) unsigned long tv=0; unsigned long tp=0; unsigned long av=0; @@ -2532,7 +2532,7 @@ int SystemInformationImplementation::QueryMemory() } fclose( fd ); return 1; -#elif __hpux +#elif defined(__hpux) unsigned long tv=0; unsigned long tp=0; unsigned long av=0; @@ -2639,7 +2639,7 @@ LongLong SystemInformationImplementation::GetCyclesDifference (DELAY_FUNC DelayF /** Compute the delay overhead */ void SystemInformationImplementation::DelayOverhead(unsigned int uiMS) { -#if _WIN32 +#if defined(_WIN32) LARGE_INTEGER Frequency, StartCounter, EndCounter; __int64 x; @@ -2664,10 +2664,19 @@ void SystemInformationImplementation::DelayOverhead(unsigned int uiMS) /** Return the number of logical CPU per physical CPUs Works only for windows */ unsigned char SystemInformationImplementation::LogicalCPUPerPhysicalCPU(void) { +#ifdef __APPLE__ + size_t len = 4; + int cores_per_package = 0; + int err = sysctlbyname("machdep.cpu.cores_per_package", &cores_per_package, &len, NULL, 0); + if (err != 0) + { + return 1; // That name was not found, default to 1 + } + return static_cast(cores_per_package); +#else unsigned int Regebx = 0; - #if USE_ASM_INSTRUCTIONS - if (!this->IsHyperThreadingSupported()) + if (!this->IsHyperThreadingSupported()) { return static_cast(1); // HT not supported } @@ -2678,22 +2687,8 @@ unsigned char SystemInformationImplementation::LogicalCPUPerPhysicalCPU(void) mov Regebx, ebx } #endif - -#ifdef __APPLE__ - size_t len = 4; - int cores_per_package = 0; - int err = sysctlbyname("machdep.cpu.cores_per_package", &cores_per_package, &len, NULL, 0); - if (err != 0) - { - return 1; // That name was not found, default to 1 - } - else - { - return static_cast(cores_per_package); - } -#endif - return static_cast ((Regebx & NUM_LOGICAL_BITS) >> 16); +#endif } @@ -2769,7 +2764,7 @@ unsigned char SystemInformationImplementation::GetAPICId() /** Count the number of CPUs. Works only on windows. */ int SystemInformationImplementation::CPUCount() { -#if _WIN32 +#if defined(_WIN32) unsigned char StatusFlag = 0; SYSTEM_INFO info; @@ -3359,7 +3354,7 @@ bool SystemInformationImplementation::QueryQNXProcessor() /** Query the operating system information */ bool SystemInformationImplementation::QueryOSInformation() { -#if _WIN32 +#if defined(_WIN32) this->OSName = "Windows"; diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index eefa7f587..4d83293d9 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -56,6 +56,7 @@ // support for realpath call #ifndef _WIN32 +#include #include #include #include @@ -127,7 +128,7 @@ public: #include #include #define _unlink unlink -#endif +#endif /* The maximum length of a file name. */ #if defined(PATH_MAX) @@ -167,9 +168,9 @@ static inline char *realpath(const char *path, char *resolved_path) snprintf(resolved_path, maxlen, "%s", path); BPath normalized(resolved_path, NULL, true); const char *resolved = normalized.Path(); - if (resolved != NULL) // NULL == No such file. + if (resolved != NULL) // NULL == No such file. { - if (snprintf(resolved_path, maxlen, "%s", resolved) < maxlen) + if (snprintf(resolved_path, maxlen, "%s", resolved) < maxlen) { return resolved_path; } @@ -178,7 +179,7 @@ static inline char *realpath(const char *path, char *resolved_path) } #endif -#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) +#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__)) inline int Mkdir(const char* dir) { return _mkdir(dir); @@ -281,71 +282,29 @@ extern int putenv (char *__string) __THROW; } #endif -/* Implement floattime() for various platforms */ -// Taken from Python 2.1.3 - -#if defined( _WIN32 ) && !defined( __CYGWIN__ ) -# include -# define HAVE_FTIME -# if defined( __BORLANDC__) -# define FTIME ftime -# define TIMEB timeb -# else // Visual studio? -# define FTIME _ftime -# define TIMEB _timeb -# endif -#elif defined( __CYGWIN__ ) || defined( __linux__ ) || defined(__APPLE__) -# include -# include -# define HAVE_GETTIMEOFDAY -#endif - namespace KWSYS_NAMESPACE { -class SystemToolsTranslationMap : - public kwsys_stl::map +double SystemTools::GetTime(void) { -}; - - -double -SystemTools::GetTime(void) -{ - /* There are three ways to get the time: - (1) gettimeofday() -- resolution in microseconds - (2) ftime() -- resolution in milliseconds - (3) time() -- resolution in seconds - In all cases the return value is a float in seconds. - Since on some systems (e.g. SCO ODT 3.0) gettimeofday() may - fail, so we fall back on ftime() or time(). - Note: clock resolution does not imply clock accuracy! */ -#ifdef HAVE_GETTIMEOFDAY - { +#if defined(_WIN32) && !defined(__CYGWIN__) + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + return (429.4967296*ft.dwHighDateTime + + 0.0000001*ft.dwLowDateTime + - 11644473600.0); +#else struct timeval t; -#ifdef GETTIMEOFDAY_NO_TZ - if (gettimeofday(&t) == 0) -#else /* !GETTIMEOFDAY_NO_TZ */ - if (gettimeofday(&t, static_cast(NULL)) == 0) -#endif /* !GETTIMEOFDAY_NO_TZ */ - return static_cast(t.tv_sec) + - static_cast(t.tv_usec)*0.000001; - } -#endif /* !HAVE_GETTIMEOFDAY */ - { -#if defined(HAVE_FTIME) - struct TIMEB t; - ::FTIME(&t); - return static_cast(t.time) + - static_cast(t.millitm) * static_cast(0.001); -#else /* !HAVE_FTIME */ - time_t secs; - time(&secs); - return static_cast(secs); -#endif /* !HAVE_FTIME */ - } + gettimeofday(&t, 0); + return 1.0*double(t.tv_sec) + 0.000001*double(t.tv_usec); +#endif } +class SystemToolsTranslationMap : + public kwsys_stl::map +{ +}; + // adds the elements of the env variable path to the arg passed in void SystemTools::GetPath(kwsys_stl::vector& path, const char* env) { @@ -367,7 +326,7 @@ void SystemTools::GetPath(kwsys_stl::vector& path, const char kwsys_stl::string pathEnv = cpathEnv; // A hack to make the below algorithm work. - if(pathEnv[pathEnv.length()-1] != ':') + if(!pathEnv.empty() && pathEnv[pathEnv.length()-1] != pathSep[0]) { pathEnv += pathSep; } @@ -412,6 +371,10 @@ bool SystemTools::GetEnv(const char* key, kwsys_stl::string& result) } } +#ifdef __INTEL_COMPILER +#pragma warning disable 444 +#endif + class kwsysDeletingCharVector : public kwsys_stl::vector { public: @@ -429,7 +392,7 @@ kwsysDeletingCharVector::~kwsysDeletingCharVector() #endif } bool SystemTools::PutEnv(const char* value) -{ +{ static kwsysDeletingCharVector localEnvironment; char* envVar = new char[strlen(value)+1]; strcpy(envVar, value); @@ -440,14 +403,13 @@ bool SystemTools::PutEnv(const char* value) return ret == 0; } - const char* SystemTools::GetExecutableExtension() { #if defined(_WIN32) || defined(__CYGWIN__) || defined(__VMS) return ".exe"; #else return ""; -#endif +#endif } @@ -515,7 +477,7 @@ void SystemTools::ReplaceString(kwsys_stl::string& source, { const char *src = source.c_str(); char *searchPos = const_cast(strstr(src,replace)); - + // get out quick if string is not found if (!searchPos) { @@ -532,7 +494,7 @@ void SystemTools::ReplaceString(kwsys_stl::string& source, char *orig = strdup(src); char *currentPos = orig; searchPos = searchPos - src + orig; - + // initialize the result source.erase(source.begin(),source.end()); do @@ -584,7 +546,7 @@ static DWORD SystemToolsMakeRegistryMode(DWORD mode, #endif // Read a registry value. -// Example : +// Example : // HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath // => will return the data of the "default" value of the key // HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4;Root @@ -613,7 +575,7 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, second = primary.substr(start+1, valuenamepos-start-1); primary = primary.substr(0, start); - + HKEY primaryKey = HKEY_CURRENT_USER; if (primary == "HKEY_CURRENT_USER") { @@ -635,11 +597,11 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, { primaryKey = HKEY_USERS; } - + HKEY hKey; - if(RegOpenKeyEx(primaryKey, - second.c_str(), - 0, + if(RegOpenKeyEx(primaryKey, + second.c_str(), + 0, SystemToolsMakeRegistryMode(KEY_READ, view), &hKey) != ERROR_SUCCESS) { @@ -650,11 +612,11 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value, DWORD dwType, dwSize; dwSize = 1023; char data[1024]; - if(RegQueryValueEx(hKey, - (LPTSTR)valuename.c_str(), - NULL, - &dwType, - (BYTE *)data, + if(RegQueryValueEx(hKey, + (LPTSTR)valuename.c_str(), + NULL, + &dwType, + (BYTE *)data, &dwSize) == ERROR_SUCCESS) { if (dwType == REG_SZ) @@ -689,7 +651,7 @@ bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &, // Write a registry value. -// Example : +// Example : // HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath // => will set the data of the "default" value of the key // HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4;Root @@ -702,7 +664,7 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value, kwsys_stl::string primary = key; kwsys_stl::string second; kwsys_stl::string valuename; - + size_t start = primary.find("\\"); if (start == kwsys_stl::string::npos) { @@ -717,7 +679,7 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value, second = primary.substr(start+1, valuenamepos-start-1); primary = primary.substr(0, start); - + HKEY primaryKey = HKEY_CURRENT_USER; if (primary == "HKEY_CURRENT_USER") { @@ -739,13 +701,13 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value, { primaryKey = HKEY_USERS; } - + HKEY hKey; DWORD dwDummy; char lpClass[] = ""; - if(RegCreateKeyEx(primaryKey, - second.c_str(), - 0, + if(RegCreateKeyEx(primaryKey, + second.c_str(), + 0, lpClass, REG_OPTION_NON_VOLATILE, SystemToolsMakeRegistryMode(KEY_WRITE, view), @@ -756,11 +718,11 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value, return false; } - if(RegSetValueEx(hKey, - (LPTSTR)valuename.c_str(), - 0, - REG_SZ, - (CONST BYTE *)value, + if(RegSetValueEx(hKey, + (LPTSTR)valuename.c_str(), + 0, + REG_SZ, + (CONST BYTE *)value, (DWORD)(strlen(value) + 1)) == ERROR_SUCCESS) { return true; @@ -775,7 +737,7 @@ bool SystemTools::WriteRegistryValue(const char *, const char *, KeyWOW64) #endif // Delete a registry value. -// Example : +// Example : // HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.1\InstallPath // => will delete the data of the "default" value of the key // HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.4;Root @@ -787,7 +749,7 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) kwsys_stl::string primary = key; kwsys_stl::string second; kwsys_stl::string valuename; - + size_t start = primary.find("\\"); if (start == kwsys_stl::string::npos) { @@ -802,7 +764,7 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) second = primary.substr(start+1, valuenamepos-start-1); primary = primary.substr(0, start); - + HKEY primaryKey = HKEY_CURRENT_USER; if (primary == "HKEY_CURRENT_USER") { @@ -824,11 +786,11 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) { primaryKey = HKEY_USERS; } - + HKEY hKey; - if(RegOpenKeyEx(primaryKey, - second.c_str(), - 0, + if(RegOpenKeyEx(primaryKey, + second.c_str(), + 0, SystemToolsMakeRegistryMode(KEY_WRITE, view), &hKey) != ERROR_SUCCESS) { @@ -836,7 +798,7 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view) } else { - if(RegDeleteValue(hKey, + if(RegDeleteValue(hKey, (LPTSTR)valuename.c_str()) == ERROR_SUCCESS) { RegCloseKey(hKey); @@ -857,17 +819,17 @@ bool SystemTools::SameFile(const char* file1, const char* file2) #ifdef _WIN32 HANDLE hFile1, hFile2; - hFile1 = CreateFile( file1, - GENERIC_READ, + hFile1 = CreateFile( file1, + GENERIC_READ, FILE_SHARE_READ , NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL ); - hFile2 = CreateFile( file2, - GENERIC_READ, - FILE_SHARE_READ, + hFile2 = CreateFile( file2, + GENERIC_READ, + FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, @@ -901,10 +863,10 @@ bool SystemTools::SameFile(const char* file1, const char* file2) { // see if the files are the same file // check the device inode and size - if(memcmp(&fileStat2.st_dev, &fileStat1.st_dev, sizeof(fileStat1.st_dev)) == 0 && + if(memcmp(&fileStat2.st_dev, &fileStat1.st_dev, sizeof(fileStat1.st_dev)) == 0 && memcmp(&fileStat2.st_ino, &fileStat1.st_ino, sizeof(fileStat1.st_ino)) == 0 && - fileStat2.st_size == fileStat1.st_size - ) + fileStat2.st_size == fileStat1.st_size + ) { return true; } @@ -1101,11 +1063,11 @@ kwsys_stl::string SystemTools::CapitalizedWords(const kwsys_stl::string& s) #if defined(_MSC_VER) && defined (_MT) && defined (_DEBUG) // MS has an assert that will fail if s[i] < 0; setting // LC_CTYPE using setlocale() does *not* help. Painful. - if ((int)s[i] >= 0 && isalpha(s[i]) && + if ((int)s[i] >= 0 && isalpha(s[i]) && (i == 0 || ((int)s[i - 1] >= 0 && isspace(s[i - 1])))) #else if (isalpha(s[i]) && (i == 0 || isspace(s[i - 1]))) -#endif +#endif { n[i] = static_cast(toupper(s[i])); } @@ -1122,11 +1084,11 @@ kwsys_stl::string SystemTools::UnCapitalizedWords(const kwsys_stl::string& s) #if defined(_MSC_VER) && defined (_MT) && defined (_DEBUG) // MS has an assert that will fail if s[i] < 0; setting // LC_CTYPE using setlocale() does *not* help. Painful. - if ((int)s[i] >= 0 && isalpha(s[i]) && + if ((int)s[i] >= 0 && isalpha(s[i]) && (i == 0 || ((int)s[i - 1] >= 0 && isspace(s[i - 1])))) #else if (isalpha(s[i]) && (i == 0 || isspace(s[i - 1]))) -#endif +#endif { n[i] = static_cast(tolower(s[i])); } @@ -1204,7 +1166,7 @@ char* SystemTools::AppendStrings( return newstr; } -// Return a lower case string +// Return a lower case string kwsys_stl::string SystemTools::LowerCase(const kwsys_stl::string& s) { kwsys_stl::string n; @@ -1216,7 +1178,7 @@ kwsys_stl::string SystemTools::LowerCase(const kwsys_stl::string& s) return n; } -// Return a lower case string +// Return a lower case string kwsys_stl::string SystemTools::UpperCase(const kwsys_stl::string& s) { kwsys_stl::string n; @@ -1346,7 +1308,7 @@ const char* SystemTools::FindLastString(const char* str1, const char* str2) { return NULL; } - + size_t len1 = strlen(str1), len2 = strlen(str2); if (len1 >= len2) { @@ -1374,8 +1336,8 @@ char* SystemTools::DuplicateString(const char* str) return NULL; } -// Return a cropped string -kwsys_stl::string SystemTools::CropString(const kwsys_stl::string& s, +// Return a cropped string +kwsys_stl::string SystemTools::CropString(const kwsys_stl::string& s, size_t max_len) { if (!s.size() || max_len == 0 || max_len >= s.size()) @@ -1419,7 +1381,7 @@ kwsys_stl::vector SystemTools::SplitString(const char* p, char se if(isPath && path[0] == '/') { path.erase(path.begin()); - paths.push_back("/"); + paths.push_back("/"); } kwsys_stl::string::size_type pos1 = 0; kwsys_stl::string::size_type pos2 = path.find(sep, pos1+1); @@ -1428,9 +1390,9 @@ kwsys_stl::vector SystemTools::SplitString(const char* p, char se paths.push_back(path.substr(pos1, pos2-pos1)); pos1 = pos2+1; pos2 = path.find(sep, pos1+1); - } + } paths.push_back(path.substr(pos1, pos2-pos1)); - + return paths; } @@ -1444,11 +1406,11 @@ int SystemTools::EstimateFormatLength(const char *format, va_list ap) // Quick-hack attempt at estimating the length of the string. // Should never under-estimate. - + // Start with the length of the format string itself. size_t length = strlen(format); - + // Increase the length for every argument in the format. const char* cur = format; @@ -1480,7 +1442,7 @@ int SystemTools::EstimateFormatLength(const char *format, va_list ap) { // Assume the argument contributes no more than 64 characters. length += 64; - + // Eat the argument. static_cast(va_arg(ap, double)); } break; @@ -1488,24 +1450,24 @@ int SystemTools::EstimateFormatLength(const char *format, va_list ap) { // Assume the argument contributes no more than 64 characters. length += 64; - + // Eat the argument. static_cast(va_arg(ap, int)); } break; } } - + // Move past the characters just tested. ++cur; } } - + return static_cast(length); } kwsys_stl::string SystemTools::EscapeChars( - const char *str, - const char *chars_to_escape, + const char *str, + const char *chars_to_escape, char escape_char) { kwsys_stl::string n; @@ -1562,7 +1524,7 @@ static void ConvertVMSToUnix(kwsys_stl::string& path) } #endif -// convert windows slashes to unix slashes +// convert windows slashes to unix slashes void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path) { const char* pathCString = path.c_str(); @@ -1629,7 +1591,7 @@ void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path) } } #endif - // remove trailing slash if the path is more than + // remove trailing slash if the path is more than // a single / pathCString = path.c_str(); if(path.size() > 1 && *(pathCString+(path.size()-1)) == '/') @@ -1647,7 +1609,7 @@ void SystemTools::ConvertToUnixSlashes(kwsys_stl::string& path) kwsys_stl::string SystemTools::ConvertToUnixOutputPath(const char* path) { kwsys_stl::string ret = path; - + // remove // except at the beginning might be a cygwin drive kwsys_stl::string::size_type pos=1; while((pos = ret.find("//", pos)) != kwsys_stl::string::npos) @@ -1685,7 +1647,7 @@ kwsys_stl::string SystemTools::ConvertToOutputPath(const char* path) // remove double slashes not at the start kwsys_stl::string SystemTools::ConvertToWindowsOutputPath(const char* path) -{ +{ kwsys_stl::string ret; // make it big enough for all of path and double quotes ret.reserve(strlen(path)+3); @@ -1771,13 +1733,13 @@ bool SystemTools::FilesDiffer(const char* source, const char* destination) { struct stat statSource; - if (stat(source, &statSource) != 0) + if (stat(source, &statSource) != 0) { return true; } struct stat statDestination; - if (stat(destination, &statDestination) != 0) + if (stat(destination, &statDestination) != 0) { return true; } @@ -1823,7 +1785,7 @@ bool SystemTools::FilesDiffer(const char* source, { return true; } - + // If this block differs the file differs. if(memcmp(static_cast(source_buf), static_cast(dest_buf), @@ -1882,7 +1844,7 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) // Open files #if defined(_WIN32) || defined(__CYGWIN__) - kwsys_ios::ifstream fin(source, + kwsys_ios::ifstream fin(source, kwsys_ios::ios::binary | kwsys_ios::ios::in); #else kwsys_ios::ifstream fin(source); @@ -1891,7 +1853,7 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) { return false; } - + // try and remove the destination file so that read only destination files // can be written to. // If the remove fails continue so that files in read only directories @@ -1899,17 +1861,17 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) SystemTools::RemoveFile(destination); #if defined(_WIN32) || defined(__CYGWIN__) - kwsys_ios::ofstream fout(destination, + kwsys_ios::ofstream fout(destination, kwsys_ios::ios::binary | kwsys_ios::ios::out | kwsys_ios::ios::trunc); #else - kwsys_ios::ofstream fout(destination, + kwsys_ios::ofstream fout(destination, kwsys_ios::ios::out | kwsys_ios::ios::trunc); #endif if(!fout) { return false; } - + // This copy loop is very sensitive on certain platforms with // slightly broken stream libraries (like HPUX). Normally, it is // incorrect to not check the error condition on the fin.read() @@ -1923,12 +1885,12 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination) fout.write(buffer, fin.gcount()); } } - + // Make sure the operating system has finished writing the file // before closing it. This will ensure the file is finished before // the check below. fout.flush(); - + fin.close(); fout.close(); @@ -2012,7 +1974,7 @@ bool SystemTools::CopyADirectory(const char* source, const char* destination, unsigned long SystemTools::FileLength(const char* filename) { struct stat fs; - if (stat(filename, &fs) != 0) + if (stat(filename, &fs) != 0) { return 0; } @@ -2258,7 +2220,7 @@ kwsys_stl::string SystemTools { // Add the system search path to our path first kwsys_stl::vector path; - if (!no_system_path) + if (!no_system_path) { SystemTools::GetPath(path, "CMAKE_FILE_PATH"); SystemTools::GetPath(path); @@ -2373,7 +2335,7 @@ kwsys_stl::string SystemTools::FindProgram( // first try with extensions if the os supports them if(extensions.size()) { - for(kwsys_stl::vector::iterator i = + for(kwsys_stl::vector::iterator i = extensions.begin(); i != extensions.end(); ++i) { tryPath = name; @@ -2401,7 +2363,7 @@ kwsys_stl::string SystemTools::FindProgram( } // now add the additional paths { - for(kwsys_stl::vector::const_iterator i = + for(kwsys_stl::vector::const_iterator i = userPaths.begin(); i != userPaths.end(); ++i) { path.push_back(*i); @@ -2430,7 +2392,7 @@ kwsys_stl::string SystemTools::FindProgram( // first try with extensions if(extensions.size()) { - for(kwsys_stl::vector::iterator ext + for(kwsys_stl::vector::iterator ext = extensions.begin(); ext != extensions.end(); ++ext) { tryPath = *p; @@ -2995,7 +2957,7 @@ kwsys_stl::string SystemTools::RelativePath(const char* local, const char* remot } // split up both paths into arrays of strings using / as a separator - kwsys_stl::vector localSplit = SystemTools::SplitString(local, '/', true); + kwsys_stl::vector localSplit = SystemTools::SplitString(local, '/', true); kwsys_stl::vector remoteSplit = SystemTools::SplitString(remote, '/', true); kwsys_stl::vector commonPath; // store shared parts of path in this array kwsys_stl::vector finalPath; // store the final relative path here @@ -3052,7 +3014,7 @@ kwsys_stl::string SystemTools::RelativePath(const char* local, const char* remot } } kwsys_stl::string relativePath; // result string - // now turn the array of directories into a unix path by puttint / + // now turn the array of directories into a unix path by puttint / // between each entry that does not already have one for(kwsys_stl::vector::iterator vit1 = finalPath.begin(); vit1 != finalPath.end(); ++vit1) @@ -3429,7 +3391,7 @@ kwsys_stl::string SystemTools::GetFilenamePath(const kwsys_stl::string& filename { kwsys_stl::string fn = filename; SystemTools::ConvertToUnixSlashes(fn); - + kwsys_stl::string::size_type slash_pos = fn.rfind("/"); if(slash_pos != kwsys_stl::string::npos) { @@ -3548,7 +3510,7 @@ SystemTools::GetFilenameWithoutLastExtension(const kwsys_stl::string& filename) } bool SystemTools::FileHasSignature(const char *filename, - const char *signature, + const char *signature, long offset) { if (!filename || !signature) @@ -3580,9 +3542,9 @@ bool SystemTools::FileHasSignature(const char *filename, return res; } -SystemTools::FileTypeEnum +SystemTools::FileTypeEnum SystemTools::DetectFileType(const char *filename, - unsigned long length, + unsigned long length, double percent_bin) { if (!filename || percent_bin < 0) @@ -3610,13 +3572,13 @@ SystemTools::DetectFileType(const char *filename, // Loop over contents and count size_t text_count = 0; - + const unsigned char *ptr = buffer; const unsigned char *buffer_end = buffer + read_length; while (ptr != buffer_end) { - if ((*ptr >= 0x20 && *ptr <= 0x7F) || + if ((*ptr >= 0x20 && *ptr <= 0x7F) || *ptr == '\n' || *ptr == '\r' || *ptr == '\t') @@ -3628,7 +3590,7 @@ SystemTools::DetectFileType(const char *filename, delete [] buffer; - double current_percent_bin = + double current_percent_bin = (static_cast(read_length - text_count) / static_cast(read_length)); @@ -3640,8 +3602,8 @@ SystemTools::DetectFileType(const char *filename, return SystemTools::FileTypeText; } -bool SystemTools::LocateFileInDir(const char *filename, - const char *dir, +bool SystemTools::LocateFileInDir(const char *filename, + const char *dir, kwsys_stl::string& filename_found, int try_filename_dirs) { @@ -3654,7 +3616,7 @@ bool SystemTools::LocateFileInDir(const char *filename, kwsys_stl::string filename_base = SystemTools::GetFilenameName(filename); - // Check if 'dir' is really a directory + // Check if 'dir' is really a directory // If win32 and matches something like C:, accept it as a dir kwsys_stl::string real_dir; @@ -3678,7 +3640,7 @@ bool SystemTools::LocateFileInDir(const char *filename, if (filename_base.size() && dir) { size_t dir_len = strlen(dir); - int need_slash = + int need_slash = (dir_len && dir[dir_len - 1] != '/' && dir[dir_len - 1] != '\\'); kwsys_stl::string temp = dir; @@ -3709,7 +3671,7 @@ bool SystemTools::LocateFileInDir(const char *filename, filename_dir = SystemTools::GetFilenamePath(filename_dir); filename_dir_base = SystemTools::GetFilenameName(filename_dir); #if defined( _WIN32 ) - if (!filename_dir_base.size() || + if (!filename_dir_base.size() || filename_dir_base[filename_dir_base.size() - 1] == ':') #else if (!filename_dir_base.size()) @@ -3733,7 +3695,7 @@ bool SystemTools::LocateFileInDir(const char *filename, } while (!res && filename_dir_base.size()); } } - + return res; } @@ -3779,12 +3741,12 @@ bool SystemTools::FileIsFullPath(const char* in_name) bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath) { -#if defined(WIN32) && !defined(__CYGWIN__) +#if defined(WIN32) && !defined(__CYGWIN__) const int size = int(strlen(path)) +1; // size of return char *buffer = new char[size]; // create a buffer char *tempPath = new char[size]; // create a buffer int ret; - + // if the path passed in has quotes around it, first remove the quotes if (path[0] == '"' && path[strlen(path)-1] == '"') { @@ -3795,7 +3757,7 @@ bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath) { strcpy(tempPath,path); } - + buffer[0] = 0; ret = GetShortPathName(tempPath, buffer, size); @@ -3818,7 +3780,7 @@ bool SystemTools::GetShortPath(const char* path, kwsys_stl::string& shortPath) #endif } -void SystemTools::SplitProgramFromArgs(const char* path, +void SystemTools::SplitProgramFromArgs(const char* path, kwsys_stl::string& program, kwsys_stl::string& args) { // see if this is a full path to a program @@ -3830,7 +3792,7 @@ void SystemTools::SplitProgramFromArgs(const char* path, return; } // Try to find the program in the path, note the program - // may have spaces in its name so we have to look for it + // may have spaces in its name so we have to look for it kwsys_stl::vector e; kwsys_stl::string findProg = SystemTools::FindProgram(path, e); if(findProg.size()) @@ -3861,7 +3823,7 @@ void SystemTools::SplitProgramFromArgs(const char* path, args = dir.substr(spacePos, dir.size()-spacePos); return; } - // Now try and find the the program in the path + // Now try and find the the program in the path findProg = SystemTools::FindProgram(tryProg.c_str(), e); if(findProg.size()) { @@ -4236,23 +4198,23 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() if (!bOsVersionInfoEx) { osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (!GetVersionEx((OSVERSIONINFO *)&osvi)) + if (!GetVersionEx((OSVERSIONINFO *)&osvi)) { return 0; } } - + switch (osvi.dwPlatformId) { // Test for the Windows NT product family. case VER_PLATFORM_WIN32_NT: - + // Test for the specific product family. if (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0) { -#if (_MSC_VER >= 1300) +#if (_MSC_VER >= 1300) if (osvi.wProductType == VER_NT_WORKSTATION) { res += "Microsoft Windows Vista"; @@ -4292,7 +4254,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() { // Test for the workstation type. -#if (_MSC_VER >= 1300) +#if (_MSC_VER >= 1300) if (osvi.wProductType == VER_NT_WORKSTATION) { if (osvi.dwMajorVersion == 4) @@ -4311,7 +4273,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() } } } - + // Test for the server type. else if (osvi.wProductType == VER_NT_SERVER) @@ -4335,7 +4297,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() res += " Standard Edition"; } } - + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) { if (osvi.wSuiteMask & VER_SUITE_DATACENTER) @@ -4352,7 +4314,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() } } - else if (osvi.dwMajorVersion <= 4) // Windows NT 4.0 + else if (osvi.dwMajorVersion <= 4) // Windows NT 4.0 { if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE) { @@ -4369,7 +4331,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() // Test for specific product on Windows NT 4.0 SP5 and earlier - else + else { HKEY hKey; #define BUFSIZE 80 @@ -4419,7 +4381,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() // Display service pack (if any) and build number. - if (osvi.dwMajorVersion == 4 && + if (osvi.dwMajorVersion == 4 && lstrcmpi(osvi.szCSDVersion, "Service Pack 6") == 0) { HKEY hKey; @@ -4448,7 +4410,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() res += buffer; res += ")"; } - + RegCloseKey(hKey); } else // Windows NT 3.51 and earlier or Windows 2000 and later @@ -4488,11 +4450,11 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90) { res += "Microsoft Windows Millennium Edition"; - } + } break; case VER_PLATFORM_WIN32s: - + res += "Microsoft Win32s"; break; } @@ -4502,7 +4464,7 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion() } // ---------------------------------------------------------------------- -bool SystemTools::ParseURLProtocol( const kwsys_stl::string& URL, +bool SystemTools::ParseURLProtocol( const kwsys_stl::string& URL, kwsys_stl::string& protocol, kwsys_stl::string& dataglom ) { @@ -4520,12 +4482,12 @@ bool SystemTools::ParseURLProtocol( const kwsys_stl::string& URL, } // ---------------------------------------------------------------------- -bool SystemTools::ParseURL( const kwsys_stl::string& URL, +bool SystemTools::ParseURL( const kwsys_stl::string& URL, kwsys_stl::string& protocol, - kwsys_stl::string& username, - kwsys_stl::string& password, - kwsys_stl::string& hostname, - kwsys_stl::string& dataport, + kwsys_stl::string& username, + kwsys_stl::string& password, + kwsys_stl::string& hostname, + kwsys_stl::string& dataport, kwsys_stl::string& database ) { kwsys::RegularExpression urlRe( VTK_URL_REGEX ); @@ -4548,7 +4510,7 @@ bool SystemTools::ParseURL( const kwsys_stl::string& URL, hostname = urlRe.match( 6 ); dataport = urlRe.match( 8 ); database = urlRe.match( 9 ); - + return true; } @@ -4614,8 +4576,6 @@ void SystemTools::ClassInitialize() // for windows because drive letters need to be maintained. Also, // there are not sym-links and mount points on windows anyway. #if !defined(_WIN32) || defined(__CYGWIN__) - // Work-around an SGI problem by always adding this mapping: - SystemTools::AddTranslationPath("/tmp_mnt/", "/"); // The tmp path is frequently a logical path so always keep it: SystemTools::AddKeepPath("/tmp/"); diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index cf4792304..04f197842 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -612,7 +612,7 @@ public: * Up to 'length' bytes are read from the file, if more than 'percent_bin' % * of the bytes are non-textual elements, the file is considered binary, * otherwise textual. Textual elements are bytes in the ASCII [0x20, 0x7E] - * range, but also \n, \r, \t. + * range, but also \\n, \\r, \\t. * The algorithm is simplistic, and should probably check for usual file * extensions, 'magic' signature, unicode, etc. */ @@ -690,13 +690,7 @@ public: * ----------------------------------------------------------------- */ - /** - * Get current time as a double. On certain platforms this will - * return higher resolution than seconds: - * (1) gettimeofday() -- resolution in microseconds - * (2) ftime() -- resolution in milliseconds - * (3) time() -- resolution in seconds - */ + /** Get current time in seconds since Posix Epoch (Jan 1, 1970). */ static double GetTime(); /** @@ -818,7 +812,7 @@ public: * Convert windows-style arguments given as a command-line string * into more traditional argc/argv arguments. * Note that argv[0] will be assigned the executable name using - * the ::GetModuleFileName function. + * the GetModuleFileName() function. */ static void ConvertWindowsCommandLineToUnixArguments( const char *cmd_line, int *argc, char ***argv); diff --git a/Source/kwsys/hash_fun.hxx.in b/Source/kwsys/hash_fun.hxx.in index f21efc54f..8c5eb6ae3 100644 --- a/Source/kwsys/hash_fun.hxx.in +++ b/Source/kwsys/hash_fun.hxx.in @@ -38,8 +38,9 @@ #define @KWSYS_NAMESPACE@_hash_fun_hxx #include <@KWSYS_NAMESPACE@/Configure.hxx> - +#include <@KWSYS_NAMESPACE@/FundamentalType.h> #include <@KWSYS_NAMESPACE@/cstddef> // size_t +#include <@KWSYS_NAMESPACE@/stl/string> // string namespace @KWSYS_NAMESPACE@ { @@ -65,6 +66,18 @@ struct hash { size_t operator()(const char* __s) const { return _stl_hash_string(__s); } }; +@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION + struct hash<@KWSYS_NAMESPACE@_stl::string> { + size_t operator()(const @KWSYS_NAMESPACE@_stl::string & __s) const { return _stl_hash_string(__s.c_str()); } +}; + +#if !defined(__BORLANDC__) +@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION + struct hash { + size_t operator()(const @KWSYS_NAMESPACE@_stl::string & __s) const { return _stl_hash_string(__s.c_str()); } +}; +#endif + @KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION struct hash { size_t operator()(char __x) const { return __x; } @@ -110,6 +123,28 @@ struct hash { size_t operator()(unsigned long __x) const { return __x; } }; +// use long long or __int64 +#if @KWSYS_NAMESPACE@_USE_LONG_LONG +@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION +struct hash { + size_t operator()(long long __x) const { return __x; } +}; + +@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION +struct hash { + size_t operator()(unsigned long long __x) const { return __x; } +}; +#elif @KWSYS_NAMESPACE@_USE___INT64 +@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION +struct hash<__int64> { + size_t operator()(__int64 __x) const { return __x; } +}; +@KWSYS_NAMESPACE@_CXX_DEFINE_SPECIALIZATION +struct hash { + size_t operator()(unsigned __int64 __x) const { return __x; } +}; +#endif // use long long or __int64 + } // namespace @KWSYS_NAMESPACE@ #endif diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 89a2f2094..2f009e086 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -15,7 +15,7 @@ SET(KWSYS_DATE_STAMP_YEAR 2011) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 07) +SET(KWSYS_DATE_STAMP_MONTH 12) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 08) +SET(KWSYS_DATE_STAMP_DAY 30) diff --git a/Templates/CPackConfig.cmake.in b/Templates/CPackConfig.cmake.in index 0406392a5..7150feb72 100644 --- a/Templates/CPackConfig.cmake.in +++ b/Templates/CPackConfig.cmake.in @@ -5,7 +5,7 @@ # CPACK_INSTALL_CMAKE_PROJECTS - For each project (path, name, component) # CPACK_CMAKE_GENERATOR - CMake Generator used for the projects # CPACK_INSTALL_COMMANDS - Extra commands to install components -# CPACK_INSTALL_DIRECTORIES - Extra directories to install +# CPACK_INSTALLED_DIRECTORIES - Extra directories to install # CPACK_PACKAGE_DESCRIPTION_FILE - Description file for the package # CPACK_PACKAGE_DESCRIPTION_SUMMARY - Summary of the package # CPACK_PACKAGE_EXECUTABLES - List of pairs of executables and labels diff --git a/Tests/Architecture/CMakeLists.txt b/Tests/Architecture/CMakeLists.txt index bc767fe3d..927ce3fed 100644 --- a/Tests/Architecture/CMakeLists.txt +++ b/Tests/Architecture/CMakeLists.txt @@ -1,6 +1,32 @@ cmake_minimum_required(VERSION 2.8) project(Architecture C) +function(test_for_xcode4 result_var) + set(${result_var} 0 PARENT_SCOPE) + if(APPLE) + execute_process(COMMAND xcodebuild -version + OUTPUT_VARIABLE ov RESULT_VARIABLE rv + ) + if("${rv}" STREQUAL "0") + if(ov MATCHES "^Xcode 4.[0-9].*$") + set(${result_var} 1 PARENT_SCOPE) + endif() + endif() + endif() +endfunction() + +test_for_xcode4(is_xcode4) + +set(arch0 i386) +set(arch1 ppc) + +if(is_xcode4) + # Xcode 4, use modern architectures as defaults + # Arch 'ppc' no longer works: tools no longer available starting with Xcode 4 + set(arch0 i386) + set(arch1 x86_64) +endif() + add_library(foo foo.c) if(CMAKE_OSX_ARCHITECTURES) get_property(archs TARGET foo PROPERTY OSX_ARCHITECTURES) @@ -10,12 +36,24 @@ if(CMAKE_OSX_ARCHITECTURES) "Expected [${CMAKE_OSX_ARCHITECTURES}], got [${archs}]." ) endif() + list(LENGTH archs archs_len) + if(archs_len GREATER 1) + list(GET archs 0 arch0) + list(GET archs 1 arch1) + endif() endif() -set_property(TARGET foo PROPERTY OSX_ARCHITECTURES i386) -set_property(TARGET foo PROPERTY OSX_ARCHITECTURES_DEBUG ppc) + +message("is_xcode4='${is_xcode4}'") +message("archs='${archs}'") +message("arch0='${arch0}'") +message("arch1='${arch1}'") + +set_property(TARGET foo PROPERTY OSX_ARCHITECTURES ${arch0}) +set_property(TARGET foo PROPERTY OSX_ARCHITECTURES_DEBUG ${arch1}) add_executable(bar bar.c) target_link_libraries(bar foo) + set_property(TARGET bar PROPERTY OUTPUT_NAME Architecture) -set_property(TARGET bar PROPERTY OSX_ARCHITECTURES ppc) -set_property(TARGET bar PROPERTY OSX_ARCHITECTURES_DEBUG i386) +set_property(TARGET bar PROPERTY OSX_ARCHITECTURES ${arch1}) +set_property(TARGET bar PROPERTY OSX_ARCHITECTURES_DEBUG ${arch0}) diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt index 70a2f3701..a977884c9 100644 --- a/Tests/BuildDepends/Project/CMakeLists.txt +++ b/Tests/BuildDepends/Project/CMakeLists.txt @@ -1,9 +1,30 @@ cmake_minimum_required(VERSION 2.6) project(testRebuild) + +function(test_for_xcode4 result_var) + set(${result_var} 0 PARENT_SCOPE) + if(APPLE) + execute_process(COMMAND xcodebuild -version + OUTPUT_VARIABLE ov RESULT_VARIABLE rv + ) + if("${rv}" STREQUAL "0") + if(ov MATCHES "^Xcode 4.[0-9].*$") + set(${result_var} 1 PARENT_SCOPE) + endif() + endif() + endif() +endfunction() + if(APPLE) # only use multi-arch if the sysroot exists on this machine if(EXISTS "${CMAKE_OSX_SYSROOT}") set(CMAKE_OSX_ARCHITECTURES "ppc;i386") + test_for_xcode4(is_xcode4) + if(is_xcode4) + # Xcode 4, use modern architectures as defaults + # Arch 'ppc' no longer works: tools no longer available starting with Xcode 4 + set(CMAKE_OSX_ARCHITECTURES i386 x86_64) + endif() endif(EXISTS "${CMAKE_OSX_SYSROOT}") endif(APPLE) diff --git a/Tests/CMakeBuildTest.cmake.in b/Tests/CMakeBuildTest.cmake.in index 9c3002bc9..a8bb75090 100644 --- a/Tests/CMakeBuildTest.cmake.in +++ b/Tests/CMakeBuildTest.cmake.in @@ -32,21 +32,21 @@ set(CMAKE_CONFIGURATION_TYPES @CMAKE_CONFIGURATION_TYPES@) # run the executable out of the Debug directory if there # are configuration types if(CMAKE_CONFIGURATION_TYPES) - set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/Debug/COnly") + set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/Debug/@CMAKE_BUILD_TEST_EXE@") else(CMAKE_CONFIGURATION_TYPES) - set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/COnly") + set(RUN_TEST "@CMAKE_BUILD_TEST_BINARY_DIR@/@CMAKE_BUILD_TEST_EXE@") endif(CMAKE_CONFIGURATION_TYPES) # run the test results message("running [${RUN_TEST}]") execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT) if(RESULT) - message(FATAL_ERROR "Error running test COnly") + message(FATAL_ERROR "Error running test @CMAKE_BUILD_TEST_EXE@") endif(RESULT) -# build it again with clean and only COnly target +# build it again with clean and only @CMAKE_BUILD_TEST_EXE@ target execute_process(COMMAND "${CMAKE_COMMAND}" --build "@CMAKE_BUILD_TEST_BINARY_DIR@" --config Debug - --clean-first --target COnly + --clean-first --target @CMAKE_BUILD_TEST_EXE@ RESULT_VARIABLE RESULT) if(RESULT) message(FATAL_ERROR "Error running cmake --build") @@ -55,5 +55,5 @@ endif(RESULT) # run it again after clean execute_process(COMMAND "${RUN_TEST}" RESULT_VARIABLE RESULT) if(RESULT) - message(FATAL_ERROR "Error running test COnly after clean ") + message(FATAL_ERROR "Error running test @CMAKE_BUILD_TEST_EXE@ after clean ") endif(RESULT) diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt new file mode 100644 index 000000000..1faa88848 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt @@ -0,0 +1,58 @@ +cmake_minimum_required(VERSION 2.8) + +project(target_link_libraries) + +file(WRITE + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + "int main() { return 0; } +" +) + +add_executable( + target_link_libraries + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" +) + +macro(ASSERT_PROPERTY _target _property _value) + get_target_property(_out ${_target} ${_property}) + if (NOT _out) + set(_out "") + endif() + if (NOT "${_out}" STREQUAL "${_value}") + message(SEND_ERROR "Target ${_target} does not have property ${_property} with value ${_value}. Actual value: ${_out}") + endif() +endmacro() + +include(GenerateExportHeader) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_library(depA SHARED depA.cpp) +generate_export_header(depA) + +add_library(depB SHARED depB.cpp) +generate_export_header(depB) + +target_link_libraries(depB LINK_PRIVATE depA) + +add_library(depC SHARED depC.cpp) +generate_export_header(depC) + +target_link_libraries(depC LINK_PUBLIC depA) + +assert_property(depA LINK_INTERFACE_LIBRARIES "") +assert_property(depB LINK_INTERFACE_LIBRARIES "") +assert_property(depC LINK_INTERFACE_LIBRARIES "depA") + +add_executable(targetA targetA.cpp) + +target_link_libraries(targetA LINK_INTERFACE_LIBRARIES depA depB) + +assert_property(targetA LINK_INTERFACE_LIBRARIES "depA;depB") + +set_target_properties(targetA PROPERTIES LINK_INTERFACE_LIBRARIES "") + +assert_property(targetA LINK_INTERFACE_LIBRARIES "") + +target_link_libraries(targetA depB depC) + +assert_property(targetA LINK_INTERFACE_LIBRARIES "") diff --git a/Tests/CMakeCommands/target_link_libraries/depA.cpp b/Tests/CMakeCommands/target_link_libraries/depA.cpp new file mode 100644 index 000000000..c2e8e7b9a --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depA.cpp @@ -0,0 +1,7 @@ + +#include "depA.h" + +int DepA::foo() +{ + return 0; +} diff --git a/Tests/CMakeCommands/target_link_libraries/depA.h b/Tests/CMakeCommands/target_link_libraries/depA.h new file mode 100644 index 000000000..7a859488b --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depA.h @@ -0,0 +1,7 @@ + +#include "depa_export.h" + +struct DEPA_EXPORT DepA +{ + int foo(); +}; diff --git a/Tests/CMakeCommands/target_link_libraries/depB.cpp b/Tests/CMakeCommands/target_link_libraries/depB.cpp new file mode 100644 index 000000000..97e5be274 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depB.cpp @@ -0,0 +1,11 @@ + +#include "depB.h" + +#include "depA.h" + +int DepB::foo() +{ + DepA a; + + return 0; +} diff --git a/Tests/CMakeCommands/target_link_libraries/depB.h b/Tests/CMakeCommands/target_link_libraries/depB.h new file mode 100644 index 000000000..e617813ba --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depB.h @@ -0,0 +1,7 @@ + +#include "depb_export.h" + +struct DEPB_EXPORT DepB +{ + int foo(); +}; diff --git a/Tests/CMakeCommands/target_link_libraries/depC.cpp b/Tests/CMakeCommands/target_link_libraries/depC.cpp new file mode 100644 index 000000000..93410a8f2 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depC.cpp @@ -0,0 +1,13 @@ + +#include "depC.h" + +int DepC::foo() +{ + return 0; +} + +DepA DepC::getA() +{ + DepA a; + return a; +} \ No newline at end of file diff --git a/Tests/CMakeCommands/target_link_libraries/depC.h b/Tests/CMakeCommands/target_link_libraries/depC.h new file mode 100644 index 000000000..4d65c9eb3 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/depC.h @@ -0,0 +1,12 @@ + +#include "depc_export.h" + +#include "depA.h" + +struct DEPC_EXPORT DepC +{ + int foo(); + + DepA getA(); + +}; diff --git a/Tests/CMakeCommands/target_link_libraries/targetA.cpp b/Tests/CMakeCommands/target_link_libraries/targetA.cpp new file mode 100644 index 000000000..3c6472e9a --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/targetA.cpp @@ -0,0 +1,12 @@ + +#include "depB.h" +#include "depC.h" + +int main(int argc, char **argv) +{ + DepA a; + DepB b; + DepC c; + + return a.foo() + b.foo() + c.foo(); +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2ad9a7759..42b3ef79b 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -16,6 +16,8 @@ MACRO(ADD_TEST_MACRO NAME COMMAND) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${dir}") ENDMACRO(ADD_TEST_MACRO) +INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake) + # Fake a user home directory to avoid polluting the real one. IF(DEFINED ENV{HOME} AND NOT CTEST_NO_TEST_HOME) SET(TEST_HOME "${CMake_BINARY_DIR}/Tests/CMakeFiles/TestHome") @@ -46,6 +48,8 @@ IF(BUILD_TESTING) ADD_SUBDIRECTORY(CMakeLib) + ADD_SUBDIRECTORY(FindPackageModeMakefileTest) + # Collect a list of all test build directories. SET(TEST_BUILD_DIRS) @@ -155,6 +159,9 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(MissingSourceFile MissingSourceFile) SET_TESTS_PROPERTIES(MissingSourceFile PROPERTIES PASS_REGULAR_EXPRESSION "CMake Error at CMakeLists.txt:3 \\(add_executable\\):[ \r\n]*Cannot find source file:[ \r\n]*DoesNotExist/MissingSourceFile.c") + IF(CMAKE_Fortran_COMPILER) + ADD_TEST_MACRO(FortranOnly FortranOnly) + ENDIF() ADD_TEST_MACRO(COnly COnly) ADD_TEST_MACRO(CxxOnly CxxOnly) ADD_TEST_MACRO(IPO COnly/COnly) @@ -213,14 +220,28 @@ IF(BUILD_TESTING) SET(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/COnly") SET(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/CMakeBuildCOnly") + SET(CMAKE_BUILD_TEST_EXE COnly) CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CMakeBuildTest.cmake.in" "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake" @ONLY) ADD_TEST(CMakeBuildTest ${CMAKE_CMAKE_COMMAND} -P "${CMake_BINARY_DIR}/Tests/CMakeBuildTest.cmake") LIST(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR}) + # now do it again for a project that has two project commands + SET(CMAKE_BUILD_TEST_SOURCE_DIR "${CMake_SOURCE_DIR}/Tests/DoubleProject") + SET(CMAKE_BUILD_TEST_BINARY_DIR "${CMake_BINARY_DIR}/Tests/DoubleProject") + SET(CMAKE_BUILD_TEST_EXE just_silly) + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CMakeBuildTest.cmake.in" + "${CMake_BINARY_DIR}/Tests/CMakeBuildDoubleProjectTest.cmake" @ONLY) + ADD_TEST(CMakeDoubleProject ${CMAKE_CMAKE_COMMAND} -P + "${CMake_BINARY_DIR}/Tests/CMakeBuildDoubleProjectTest.cmake") + LIST(APPEND TEST_BUILD_DIRS ${CMAKE_BUILD_TEST_BINARY_DIR}) ADD_TEST_MACRO(Module.CheckTypeSize CheckTypeSize) + ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader) + + ADD_TEST_MACRO(Module.CheckCXXCompilerFlag CheckCXXCompilerFlag) + ADD_TEST(LinkFlags-prepare ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} --build-and-test @@ -357,6 +378,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ dash2win64_release.cmake) ADD_NIGHTLY_BUILD_TEST(CMakeNightlyMac dashmacmini2_release.cmake) + ADD_NIGHTLY_BUILD_TEST(CMakeNightlyMac64 + dashmacmini5_release.cmake) ADD_NIGHTLY_BUILD_TEST(CMakeNightlyLinux magrathea_release.cmake) ENDIF(CMAKE_BUILD_NIGHTLY_RELEASES) @@ -840,6 +863,45 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Environment") + IF(NOT QT4_FOUND) + FIND_PACKAGE(Qt4) + ENDIF(NOT QT4_FOUND) + + IF(QT4_FOUND) + # test whether the Qt4 which has been found works, on some machines + # which run nightly builds there were errors like "wrong file format" + # for libQtCore.so. So first check it works, and only if it does add + # the automoc test. + INCLUDE(CheckCXXSourceCompiles) + SET(_save_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") + SET(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + + SET(CMAKE_REQUIRED_INCLUDES ${QT_INCLUDES}) + SET(CMAKE_REQUIRED_LIBRARIES ${QT_QTCORE_LIBRARIES}) + + CHECK_CXX_SOURCE_COMPILES("#include \n int main() {return (qApp == 0 ? 0 : 1); }\n" + QT4_WORKS_FOR_AUTOMOC_TEST) + + SET(CMAKE_REQUIRED_INCLUDES "${_save_CMAKE_REQUIRED_INCLUDES}") + SET(CMAKE_REQUIRED_LIBRARIES "${_save_CMAKE_REQUIRED_LIBRARIES}") + + IF(QT4_WORKS_FOR_AUTOMOC_TEST) + ADD_TEST(QtAutomoc ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/QtAutomoc" + "${CMake_BINARY_DIR}/Tests/QtAutomoc" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project QtAutomoc + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-exe-dir "${CMake_BINARY_DIR}/Tests/QtAutomoc" + --force-new-ctest-process + --build-options -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE} + --test-command ${CMAKE_CTEST_COMMAND} -V + ) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomoc") + ENDIF() + ENDIF() + ADD_TEST(ExternalProject ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Tests/ExternalProject" @@ -1154,6 +1216,111 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MakeClean") ENDIF("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile") + if(NOT DEFINED CTEST_RUN_MFC) + set(CTEST_RUN_MFC OFF) + + if(MSVC) + set(CTEST_RUN_MFC ON) + + # Look for evidence that this is a VCExpress build. If so, avoid + # the MFC test by default. + string(TOLOWER "${CMAKE_TEST_MAKEPROGRAM}" mkprog) + if(mkprog MATCHES "vcexpress") + message(STATUS + "CMAKE_TEST_MAKEPROGRAM indicates vcexpress, avoiding MFC test") + set(CTEST_RUN_MFC OFF) + endif() + + # Since MSBuild might also be the "makeprogram" for a VCExpress + # build tree, use one more heuristic, too. The string representing + # the .vcproj file type contains "VCExpress" on machines where an + # express edition of VS was installed last: + if(CTEST_RUN_MFC) + execute_process(COMMAND cmd /c assoc .vcproj + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE ov) + if(ov MATCHES "VCExpress") + message(STATUS + ".vcproj file association indicates VCExpress, avoiding MFC test") + set(CTEST_RUN_MFC OFF) + endif() + endif() + + # For the Watcom WMake generator, avoid the MFC test by default. + if(CTEST_RUN_MFC) + if("${CMAKE_TEST_GENERATOR}" MATCHES "WMake") + message(STATUS + "using the Watcom WMake generator, avoiding MFC test") + set(CTEST_RUN_MFC OFF) + endif() + endif() + + # Last resort, after quick checks are done. Do a try_compile, and avoid + # the MFC test if the simplest possible MFC app cannot be compiled. + if(CTEST_RUN_MFC AND NOT DEFINED HAVE_MFC) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/MFC/try_compile/CMakeLists.txt + ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/CMakeLists.txt + COPYONLY + ) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.cpp + ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.cpp + COPYONLY + ) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/MFC/mfc1/stdafx.h + ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/stdafx.h + COPYONLY + ) + + message(STATUS "Looking for MFC") + + try_compile(HAVE_MFC + ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile/build + ${CMAKE_CURRENT_BINARY_DIR}/MFC/try_compile + try_compile_mfc + OUTPUT_VARIABLE HAVE_MFC_OUTPUT) + + if(HAVE_MFC) + message(STATUS "Looking for MFC - found") + set(HAVE_MFC 1 CACHE INTERNAL "Have MFC") + file(APPEND + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if MFC exists passed with the following output:\n" + "${HAVE_MFC_OUTPUT}\n\n") + else() + message(STATUS "Looking for MFC - not found") + set(HAVE_MFC "" CACHE INTERNAL "Have MFC") + file(APPEND + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if MFC exists failed with the following output:\n" + "${HAVE_MFC_OUTPUT}\n\n") + endif() + endif() + + if(CTEST_RUN_MFC AND NOT HAVE_MFC) + message(STATUS + "cannot compile simplest ever MFC app, avoiding MFC test") + set(CTEST_RUN_MFC OFF) + endif() + endif() + endif() + + if(CTEST_RUN_MFC) + add_test(MFC ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/MFC" + "${CMake_BINARY_DIR}/Tests/MFC" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project mfc_driver + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --test-command ${CMAKE_CTEST_COMMAND} + -C \${CTEST_CONFIGURATION_TYPE} -VV) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MFC") + endif() + IF(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio") ADD_TEST(VSExternalInclude ${CMAKE_CTEST_COMMAND} --build-and-test @@ -1479,6 +1646,35 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ SET_TESTS_PROPERTIES(CTestTestUpload PROPERTIES PASS_REGULAR_EXPRESSION "Upload\\.xml") + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestConfigFileInBuildDir1 ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/test1.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir1/testOut1.log" + ) + SET_TESTS_PROPERTIES(CTestTestConfigFileInBuildDir1 PROPERTIES DEPENDS CTestTestNoBuild + PASS_REGULAR_EXPRESSION + "Reading ctest configuration file: ${CMake_SOURCE_DIR}.Tests.CTestTestConfigFileInBuildDir.CTestConfig.cmake") + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/test2.cmake" + @ONLY ESCAPE_QUOTES) + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake" + "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/CTestConfig.cmake" + @ONLY ESCAPE_QUOTES COPYONLY) + ADD_TEST(CTestTestConfigFileInBuildDir2 ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/test2.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/testOut2.log" + ) + SET_TESTS_PROPERTIES(CTestTestConfigFileInBuildDir2 PROPERTIES DEPENDS CTestTestNoBuild + REQUIRED_FILES ${CMake_BINARY_DIR}/Tests/CTestTestConfigFileInBuildDir2/CTestConfig.cmake + PASS_REGULAR_EXPRESSION + "Reading ctest configuration file: ${CMake_BINARY_DIR}.Tests.CTestTestConfigFileInBuildDir2.CTestConfig.cmake") + # Use macro, not function so that build can still be driven by CMake 2.4. # After 2.6 is required, this could be a function without the extra 'set' # calls. @@ -1522,6 +1718,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ -P "${CMake_SOURCE_DIR}/Tests/CMakeCommands/build_command/RunCMake.cmake" ) + ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries) + CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestCrash/test.cmake" @@ -1536,7 +1734,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ PASS_REGULAR_EXPRESSION "Failed") ELSE(CMAKE_TEST_GENERATOR MATCHES "Watcom WMake") SET_TESTS_PROPERTIES(CTestTestCrash PROPERTIES - PASS_REGULAR_EXPRESSION "SegFault") + PASS_REGULAR_EXPRESSION "(Illegal|SegFault)") ENDIF(CMAKE_TEST_GENERATOR MATCHES "Watcom WMake") CONFIGURE_FILE( @@ -1876,35 +2074,41 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ENDIF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) ENDIF() - # fortran does not work for IDE builds because - # CMAKE_STANDARD_LIBRARIES needs to be per language - IF(CMAKE_TEST_GENERATOR MATCHES "Make|KDevelop") - INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CheckFortran.cmake) - IF(CMAKE_Fortran_COMPILER) - ADD_TEST(Fortran ${CMAKE_CTEST_COMMAND} + IF(CMAKE_Fortran_COMPILER) + ADD_TEST(Fortran ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Fortran" + "${CMake_BINARY_DIR}/Tests/Fortran" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project testf + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + --test-command testf) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") + + # FortranCInterface tests. + IF(UNIX) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake @ONLY) + ADD_TEST(FortranC.Flags ${CMAKE_CMAKE_COMMAND} -P + ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC/Flags") + ELSE() + ADD_TEST(FortranC ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/Fortran" - "${CMake_BINARY_DIR}/Tests/Fortran" + "${CMake_SOURCE_DIR}/Tests/FortranC" + "${CMake_BINARY_DIR}/Tests/FortranC" --build-generator ${CMAKE_TEST_GENERATOR} - --build-project testf + --build-project FortranC --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config - --test-command testf) - LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") - - # FortranCInterface tests. - IF(UNIX) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake @ONLY) - ADD_TEST(FortranC.Flags ${CMAKE_CMAKE_COMMAND} -P - ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake) - LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC/Flags") - ENDIF() + --test-command CMakeFiles/FortranCInterface/FortranCInterface) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC") ENDIF() ENDIF() - find_package(Java QUIET) - IF(JAVA_COMPILE AND JAVA_RUNTIME AND JAVA_ARCHIVE AND NOT MINGW + find_package(Java COMPONENTS Development QUIET) + IF(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE AND Java_JAR_EXECUTABLE AND NOT MINGW AND NOT "${CMAKE_TEST_GENERATOR}" MATCHES "Xcode") GET_FILENAME_COMPONENT(JNIPATH ${JAVA_COMPILE} PATH) FIND_FILE(JNI_H jni.h @@ -2073,6 +2277,19 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --test-command IncludeDirectories) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories") + IF(CMAKE_USE_KWSTYLE AND KWSTYLE_EXECUTABLE) + # The "make StyleCheck" command line as a test. If the test fails, look + # for lines like "Error #0 (624) Line length exceed 88 (max=79)" in the + # output to find where the style errors are... + ADD_TEST(KWStyle ${KWSTYLE_EXECUTABLE} + -xml ${CMake_BINARY_DIR}/CMake.kws.xml + -o ${CMake_SOURCE_DIR}/Utilities/KWStyle/CMakeOverwrite.txt + -v + -D ${CMake_BINARY_DIR}/CMakeKWSFiles.txt + ) + SET_TESTS_PROPERTIES(KWStyle PROPERTIES + WORKING_DIRECTORY ${CMake_BINARY_DIR}/Utilities/KWStyle) + ENDIF() ENDIF(BUILD_TESTING) SUBDIRS(CMakeTests) diff --git a/Tests/CMakeTestAllGenerators/RunCMake.cmake b/Tests/CMakeTestAllGenerators/RunCMake.cmake index dcf4a23c6..6d27d3be1 100644 --- a/Tests/CMakeTestAllGenerators/RunCMake.cmake +++ b/Tests/CMakeTestAllGenerators/RunCMake.cmake @@ -60,6 +60,28 @@ message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") message(STATUS "CMake generators='${generators}'") +# If we'll be testing any of the MinGW Makefiles generators, adjust the +# ENV{PATH} to make sure libgmp-10.dll can be loaded as needed. But only if +# the testing machine has a default MinGW install... (If you have a +# non-default install, append to the PATH before running the test...) +# +if(generators MATCHES "MinGW Makefiles") + if(EXISTS "C:/MinGW/bin/libgmp-10.dll") + string(TOLOWER "$ENV{PATH}" path) + if(NOT path MATCHES "/mingw/bin") + if(UNIX) + set(sep ":") + set(mingw_bin "/mingw/bin") + else() + set(sep ";") + set(mingw_bin "C:/MinGW/bin") + endif() + set(ENV{PATH} "$ENV{PATH}${sep}${mingw_bin}") + message(STATUS "info: appending '${sep}${mingw_bin}' to the PATH") + endif() + endif() +endif() + # First setup a source tree to run CMake on. # execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory diff --git a/Tests/CMakeTests/.gitattributes b/Tests/CMakeTests/.gitattributes new file mode 100644 index 000000000..c34e350e5 --- /dev/null +++ b/Tests/CMakeTests/.gitattributes @@ -0,0 +1 @@ +File-HASH-Input.txt crlf=input diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index 5cb50c93a..fc1426e8e 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -28,6 +28,7 @@ AddCMakeTest(Math "") AddCMakeTest(CMakeMinimumRequired "") AddCMakeTest(CompilerIdVendor "") AddCMakeTest(ProcessorCount "") +AddCMakeTest(PushCheckState "") AddCMakeTest(FileDownload "") set_property(TEST CMake.FileDownload PROPERTY diff --git a/Tests/CMakeTests/CheckCMakeTest.cmake b/Tests/CMakeTests/CheckCMakeTest.cmake index 2e4feddd3..db9290522 100644 --- a/Tests/CMakeTests/CheckCMakeTest.cmake +++ b/Tests/CMakeTests/CheckCMakeTest.cmake @@ -12,7 +12,7 @@ function(check_cmake_test prefix) ) string(REGEX REPLACE "\n" "\n out> " out " out> ${stdout}") string(REGEX REPLACE "\n" "\n err> " err " err> ${stderr}") - if(NOT "${result}" STREQUAL ${${test}-RESULT}) + if(NOT "${result}" STREQUAL "${${test}-RESULT}") message(FATAL_ERROR "Test ${test} result is [${result}], not [${${test}-RESULT}].\n" "Test ${test} output:\n" diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake new file mode 100644 index 000000000..3b09eb0c3 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-COPYONLY.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out COPYONLY NEWLINE_STYLE DOS) diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake new file mode 100644 index 000000000..133a67a8a --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-NoArg.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out NEWLINE_STYLE) diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake new file mode 100644 index 000000000..b7e619ca2 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-ValidArg.cmake @@ -0,0 +1,17 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) + +function(test_eol style in out) + file(WRITE ${file_name} "${in}") + configure_file(${file_name} ${file_name}.out NEWLINE_STYLE ${style}) + file(READ ${file_name}.out new HEX) + if(NOT "${new}" STREQUAL "${out}") + message(FATAL_ERROR "No ${style} line endings") + endif() +endfunction() + +test_eol(DOS "a\n" "610d0a") +test_eol(WIN32 "b\n" "620d0a") +test_eol(CRLF "c\n" "630d0a") + +test_eol(UNIX "d\n" "640a") +test_eol(LF "e\n" "650a") diff --git a/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake b/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake new file mode 100644 index 000000000..e8887c127 --- /dev/null +++ b/Tests/CMakeTests/ConfigureFile-NewLineStyle-WrongArg.cmake @@ -0,0 +1,3 @@ +set(file_name ${CMAKE_CURRENT_SOURCE_DIR}/ConfigureFile-NewLineStyle.txt) +file(WRITE ${file_name} "Data\n") +configure_file(${file_name} ${file_name}.out NEWLINE_STYLE FOO) diff --git a/Tests/CMakeTests/ConfigureFileTest.cmake.in b/Tests/CMakeTests/ConfigureFileTest.cmake.in index c78a4705b..6cc61d90c 100644 --- a/Tests/CMakeTests/ConfigureFileTest.cmake.in +++ b/Tests/CMakeTests/ConfigureFileTest.cmake.in @@ -6,6 +6,14 @@ set(Relative-RESULT 0) set(Relative-STDERR "Relative test file") set(BadArg-RESULT 1) set(BadArg-STDERR "called with incorrect number of arguments") +set(NewLineStyle-NoArg-RESULT 1) +set(NewLineStyle-NoArg-STDERR "NEWLINE_STYLE must set a style:") +set(NewLineStyle-WrongArg-RESULT 1) +set(NewLineStyle-WrongArg-STDERR "NEWLINE_STYLE sets an unknown style") +set(NewLineStyle-ValidArg-RESULT 0) +set(NewLineStyle-ValidArg-STDERR ) +set(NewLineStyle-COPYONLY-RESULT 1) +set(NewLineStyle-COPYONLY-STDERR "COPYONLY could not be used in combination") include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") check_cmake_test(ConfigureFile @@ -13,4 +21,8 @@ check_cmake_test(ConfigureFile DirOutput Relative BadArg + NewLineStyle-NoArg + NewLineStyle-WrongArg + NewLineStyle-ValidArg + NewLineStyle-COPYONLY ) diff --git a/Tests/CMakeTests/File-HASH-Input.txt b/Tests/CMakeTests/File-HASH-Input.txt new file mode 100644 index 000000000..a1d315b2d --- /dev/null +++ b/Tests/CMakeTests/File-HASH-Input.txt @@ -0,0 +1 @@ +sample input string diff --git a/Tests/CMakeTests/File-MD5-BadArg1.cmake b/Tests/CMakeTests/File-MD5-BadArg1.cmake new file mode 100644 index 000000000..ac5f67ae2 --- /dev/null +++ b/Tests/CMakeTests/File-MD5-BadArg1.cmake @@ -0,0 +1 @@ +file(MD5) diff --git a/Tests/CMakeTests/File-MD5-BadArg2.cmake b/Tests/CMakeTests/File-MD5-BadArg2.cmake new file mode 100644 index 000000000..2acc0757e --- /dev/null +++ b/Tests/CMakeTests/File-MD5-BadArg2.cmake @@ -0,0 +1 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt) diff --git a/Tests/CMakeTests/File-MD5-BadArg4.cmake b/Tests/CMakeTests/File-MD5-BadArg4.cmake new file mode 100644 index 000000000..79b27558d --- /dev/null +++ b/Tests/CMakeTests/File-MD5-BadArg4.cmake @@ -0,0 +1 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt md5 extra_arg) diff --git a/Tests/CMakeTests/File-MD5-NoFile.cmake b/Tests/CMakeTests/File-MD5-NoFile.cmake new file mode 100644 index 000000000..1b91bc8d8 --- /dev/null +++ b/Tests/CMakeTests/File-MD5-NoFile.cmake @@ -0,0 +1 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/DoesNotExist.cmake md5) diff --git a/Tests/CMakeTests/File-MD5-Works.cmake b/Tests/CMakeTests/File-MD5-Works.cmake new file mode 100644 index 000000000..0fabe54a4 --- /dev/null +++ b/Tests/CMakeTests/File-MD5-Works.cmake @@ -0,0 +1,2 @@ +file(MD5 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt md5) +message("${md5}") diff --git a/Tests/CMakeTests/File-SHA1-Works.cmake b/Tests/CMakeTests/File-SHA1-Works.cmake new file mode 100644 index 000000000..f2ab5d747 --- /dev/null +++ b/Tests/CMakeTests/File-SHA1-Works.cmake @@ -0,0 +1,2 @@ +file(SHA1 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha1) +message("${sha1}") diff --git a/Tests/CMakeTests/File-SHA224-Works.cmake b/Tests/CMakeTests/File-SHA224-Works.cmake new file mode 100644 index 000000000..3e86b172f --- /dev/null +++ b/Tests/CMakeTests/File-SHA224-Works.cmake @@ -0,0 +1,2 @@ +file(SHA224 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha224) +message("${sha224}") diff --git a/Tests/CMakeTests/File-SHA256-Works.cmake b/Tests/CMakeTests/File-SHA256-Works.cmake new file mode 100644 index 000000000..b72d89e95 --- /dev/null +++ b/Tests/CMakeTests/File-SHA256-Works.cmake @@ -0,0 +1,2 @@ +file(SHA256 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha256) +message("${sha256}") diff --git a/Tests/CMakeTests/File-SHA384-Works.cmake b/Tests/CMakeTests/File-SHA384-Works.cmake new file mode 100644 index 000000000..0eeca33cb --- /dev/null +++ b/Tests/CMakeTests/File-SHA384-Works.cmake @@ -0,0 +1,2 @@ +file(SHA384 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha384) +message("${sha384}") diff --git a/Tests/CMakeTests/File-SHA512-Works.cmake b/Tests/CMakeTests/File-SHA512-Works.cmake new file mode 100644 index 000000000..d74ee4429 --- /dev/null +++ b/Tests/CMakeTests/File-SHA512-Works.cmake @@ -0,0 +1,2 @@ +file(SHA512 ${CMAKE_CURRENT_LIST_DIR}/File-HASH-Input.txt sha512) +message("${sha512}") diff --git a/Tests/CMakeTests/FileTest.cmake.in b/Tests/CMakeTests/FileTest.cmake.in index b6dcaa6d1..3c3d85ddc 100644 --- a/Tests/CMakeTests/FileTest.cmake.in +++ b/Tests/CMakeTests/FileTest.cmake.in @@ -12,6 +12,26 @@ set(Copy-NoDest-RESULT 1) set(Copy-NoDest-STDERR "given no DESTINATION") set(Copy-NoFile-RESULT 1) set(Copy-NoFile-STDERR "COPY cannot find.*/does_not_exist\\.txt") +set(MD5-NoFile-RESULT 1) +set(MD5-NoFile-STDERR "file MD5 failed to read file") +set(MD5-BadArg1-RESULT 1) +set(MD5-BadArg1-STDERR "file must be called with at least two arguments") +set(MD5-BadArg2-RESULT 1) +set(MD5-BadArg2-STDERR "file MD5 requires a file name and output variable") +set(MD5-BadArg4-RESULT 1) +set(MD5-BadArg4-STDERR "file MD5 requires a file name and output variable") +set(MD5-Works-RESULT 0) +set(MD5-Works-STDERR "10d20ddb981a6202b84aa1ce1cb7fce3") +set(SHA1-Works-RESULT 0) +set(SHA1-Works-STDERR "83f093e04289b21a9415f408ad50be8b57ad2f34") +set(SHA224-Works-RESULT 0) +set(SHA224-Works-STDERR "e995a7789922c4ef9279d94e763c8375934180a51baa7147bc48edf7") +set(SHA256-Works-RESULT 0) +set(SHA256-Works-STDERR "d1c5915d8b71150726a1eef75a29ec6bea8fd1bef6b7299ef8048760b0402025") +set(SHA384-Works-RESULT 0) +set(SHA384-Works-STDERR "1de9560b4e030e02051ea408200ffc55d70c97ac64ebf822461a5c786f495c36df43259b14483bc8d364f0106f4971ee") +set(SHA512-Works-RESULT 0) +set(SHA512-Works-STDERR "3982a1b4e651768bec70ab1fb97045cb7a659f4ba7203d501c52ab2e803071f9d5fd272022df15f27727fc67f8cd022e710e29010b2a9c0b467c111e2f6abf51") include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") check_cmake_test(File @@ -22,6 +42,16 @@ check_cmake_test(File Copy-LateArg Copy-NoDest Copy-NoFile + MD5-NoFile + MD5-BadArg1 + MD5-BadArg2 + MD5-BadArg4 + MD5-Works + SHA1-Works + SHA224-Works + SHA256-Works + SHA384-Works + SHA512-Works ) # Also execute each test listed in FileTestScript.cmake: diff --git a/Tests/CMakeTests/PushCheckStateTest.cmake.in b/Tests/CMakeTests/PushCheckStateTest.cmake.in new file mode 100644 index 000000000..e707b9a92 --- /dev/null +++ b/Tests/CMakeTests/PushCheckStateTest.cmake.in @@ -0,0 +1,30 @@ +include(CMakePushCheckState) + +set(CMAKE_REQUIRED_DEFINITIONS defs1 ) + +cmake_push_check_state() + +set(CMAKE_REQUIRED_DEFINITIONS defs2) + +cmake_push_check_state() + +set(CMAKE_REQUIRED_DEFINITIONS defs3) + +cmake_pop_check_state() + +if (NOT "${CMAKE_REQUIRED_DEFINITIONS}" STREQUAL "defs2") + set(fatal TRUE) + message("ERROR: "CMAKE_REQUIRED_DEFINITIONS is \"${CMAKE_REQUIRED_DEFINITIONS}\" (expected \"defs2\")" ) +endif() + +cmake_pop_check_state() + +if (NOT "${CMAKE_REQUIRED_DEFINITIONS}" STREQUAL "defs1") + set(fatal TRUE) + message("ERROR: "CMAKE_REQUIRED_DEFINITIONS is \"${CMAKE_REQUIRED_DEFINITIONS}\" (expected \"defs1\")" ) +endif() + + +if(fatal) + message(FATAL_ERROR "cmake_push_check_state() test failed") +endif() diff --git a/Tests/CMakeTests/String-MD5-BadArg1.cmake b/Tests/CMakeTests/String-MD5-BadArg1.cmake new file mode 100644 index 000000000..89464769b --- /dev/null +++ b/Tests/CMakeTests/String-MD5-BadArg1.cmake @@ -0,0 +1 @@ +string(MD5) diff --git a/Tests/CMakeTests/String-MD5-BadArg2.cmake b/Tests/CMakeTests/String-MD5-BadArg2.cmake new file mode 100644 index 000000000..abbbf879a --- /dev/null +++ b/Tests/CMakeTests/String-MD5-BadArg2.cmake @@ -0,0 +1 @@ +string(MD5 md5) diff --git a/Tests/CMakeTests/String-MD5-BadArg4.cmake b/Tests/CMakeTests/String-MD5-BadArg4.cmake new file mode 100644 index 000000000..edd442762 --- /dev/null +++ b/Tests/CMakeTests/String-MD5-BadArg4.cmake @@ -0,0 +1 @@ +string(MD5 md5 input extra_arg) diff --git a/Tests/CMakeTests/String-MD5-Works.cmake b/Tests/CMakeTests/String-MD5-Works.cmake new file mode 100644 index 000000000..4ef7a0754 --- /dev/null +++ b/Tests/CMakeTests/String-MD5-Works.cmake @@ -0,0 +1,2 @@ +string(MD5 md5 "sample input string\n") +message("${md5}") diff --git a/Tests/CMakeTests/String-SHA1-Works.cmake b/Tests/CMakeTests/String-SHA1-Works.cmake new file mode 100644 index 000000000..2f3b51b61 --- /dev/null +++ b/Tests/CMakeTests/String-SHA1-Works.cmake @@ -0,0 +1,2 @@ +string(SHA1 sha1 "sample input string\n") +message("${sha1}") diff --git a/Tests/CMakeTests/String-SHA224-Works.cmake b/Tests/CMakeTests/String-SHA224-Works.cmake new file mode 100644 index 000000000..5b7f880ee --- /dev/null +++ b/Tests/CMakeTests/String-SHA224-Works.cmake @@ -0,0 +1,2 @@ +string(SHA224 sha224 "sample input string\n") +message("${sha224}") diff --git a/Tests/CMakeTests/String-SHA256-Works.cmake b/Tests/CMakeTests/String-SHA256-Works.cmake new file mode 100644 index 000000000..e3e89ae5d --- /dev/null +++ b/Tests/CMakeTests/String-SHA256-Works.cmake @@ -0,0 +1,2 @@ +string(SHA256 sha256 "sample input string\n") +message("${sha256}") diff --git a/Tests/CMakeTests/String-SHA384-Works.cmake b/Tests/CMakeTests/String-SHA384-Works.cmake new file mode 100644 index 000000000..828a19031 --- /dev/null +++ b/Tests/CMakeTests/String-SHA384-Works.cmake @@ -0,0 +1,2 @@ +string(SHA384 sha384 "sample input string\n") +message("${sha384}") diff --git a/Tests/CMakeTests/String-SHA512-Works.cmake b/Tests/CMakeTests/String-SHA512-Works.cmake new file mode 100644 index 000000000..e17db5c6e --- /dev/null +++ b/Tests/CMakeTests/String-SHA512-Works.cmake @@ -0,0 +1,2 @@ +string(SHA512 sha512 "sample input string\n") +message("${sha512}") diff --git a/Tests/CMakeTests/StringTest.cmake.in b/Tests/CMakeTests/StringTest.cmake.in index 6bb60f4fe..49e7dc90c 100644 --- a/Tests/CMakeTests/StringTest.cmake.in +++ b/Tests/CMakeTests/StringTest.cmake.in @@ -1,3 +1,35 @@ +set(MD5-BadArg1-RESULT 1) +set(MD5-BadArg1-STDERR "string MD5 requires an output variable") +set(MD5-BadArg2-RESULT 1) +set(MD5-BadArg2-STDERR "string MD5 requires an output variable and an input string") +set(MD5-BadArg4-RESULT 1) +set(MD5-BadArg4-STDERR "string MD5 requires an output variable and an input string") +set(MD5-Works-RESULT 0) +set(MD5-Works-STDERR "10d20ddb981a6202b84aa1ce1cb7fce3") +set(SHA1-Works-RESULT 0) +set(SHA1-Works-STDERR "83f093e04289b21a9415f408ad50be8b57ad2f34") +set(SHA224-Works-RESULT 0) +set(SHA224-Works-STDERR "e995a7789922c4ef9279d94e763c8375934180a51baa7147bc48edf7") +set(SHA256-Works-RESULT 0) +set(SHA256-Works-STDERR "d1c5915d8b71150726a1eef75a29ec6bea8fd1bef6b7299ef8048760b0402025") +set(SHA384-Works-RESULT 0) +set(SHA384-Works-STDERR "1de9560b4e030e02051ea408200ffc55d70c97ac64ebf822461a5c786f495c36df43259b14483bc8d364f0106f4971ee") +set(SHA512-Works-RESULT 0) +set(SHA512-Works-STDERR "3982a1b4e651768bec70ab1fb97045cb7a659f4ba7203d501c52ab2e803071f9d5fd272022df15f27727fc67f8cd022e710e29010b2a9c0b467c111e2f6abf51") + +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") +check_cmake_test(String + MD5-BadArg1 + MD5-BadArg2 + MD5-BadArg4 + MD5-Works + SHA1-Works + SHA224-Works + SHA256-Works + SHA384-Works + SHA512-Works + ) + # Execute each test listed in StringTestScript.cmake: # set(scriptname "@CMAKE_CURRENT_SOURCE_DIR@/StringTestScript.cmake") diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in index d82943f83..9444a1473 100644 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-IgnoreGroup.cmake.in @@ -7,6 +7,7 @@ endif(CPACK_GENERATOR MATCHES "ZIP") if(CPACK_GENERATOR MATCHES "RPM") set(CPACK_RPM_COMPONENT_INSTALL "ON") + set(CPACK_RPM_applications_PACKAGE_REQUIRES "mylib-libraries") endif(CPACK_GENERATOR MATCHES "RPM") if(CPACK_GENERATOR MATCHES "DEB") diff --git a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in index 1e1a410ab..2d251b363 100644 --- a/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in +++ b/Tests/CPackComponentsForAll/MyLibCPackConfig-OnePackPerGroup.cmake.in @@ -7,6 +7,7 @@ endif(CPACK_GENERATOR MATCHES "ZIP") if(CPACK_GENERATOR MATCHES "RPM") set(CPACK_RPM_COMPONENT_INSTALL "ON") + set(CPACK_RPM_Development_PACKAGE_REQUIRES "mylib-Runtime") endif(CPACK_GENERATOR MATCHES "RPM") if(CPACK_GENERATOR MATCHES "DEB") diff --git a/Tests/CTestTestConfigFileInBuildDir/CMakeLists.txt b/Tests/CTestTestConfigFileInBuildDir/CMakeLists.txt new file mode 100644 index 000000000..3c53e6623 --- /dev/null +++ b/Tests/CTestTestConfigFileInBuildDir/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(CTestTestConfigFileInBuildDir) +include(CTest) diff --git a/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake b/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake new file mode 100644 index 000000000..d2c28f98c --- /dev/null +++ b/Tests/CTestTestConfigFileInBuildDir/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "CTestTestConfigFileInBuildDir") +set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") +set(CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in b/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in new file mode 100644 index 000000000..498cab280 --- /dev/null +++ b/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in @@ -0,0 +1,17 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ConfigFileInBuildDir1") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestConfigFileInBuildDir") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestConfigFileInBuildDir1") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in b/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in new file mode 100644 index 000000000..d359f2d36 --- /dev/null +++ b/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in @@ -0,0 +1,17 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ConfigFileInBuildDir2") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestConfigFileInBuildDir") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestConfigFileInBuildDir2") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake index a52cb148d..335d09e7e 100644 --- a/Tests/CTestUpdateCommon.cmake +++ b/Tests/CTestUpdateCommon.cmake @@ -29,11 +29,13 @@ function(check_updates build) endif(NOT UPDATE_XML_FILE) message(" found ${UPDATE_XML_FILE}") + set(max_update_xml_size 16384) + # Read entries from the Update.xml file set(types "Updated|Modified|Conflicting") file(STRINGS ${TOP}/${UPDATE_XML_FILE} UPDATE_XML_ENTRIES REGEX "<(${types}|FullName)>" - LIMIT_INPUT 4096 + LIMIT_INPUT ${max_update_xml_size} ) string(REGEX REPLACE "[ \t]*<(${types})>[ \t]*;[ \t]*([^<]*)" @@ -51,7 +53,7 @@ function(check_updates build) set(rev_regex "^\t<(${rev_regex})>[^<\n]+$") file(STRINGS ${TOP}/${UPDATE_XML_FILE} UPDATE_XML_REVISIONS REGEX "${rev_regex}" - LIMIT_INPUT 4096 + LIMIT_INPUT ${max_update_xml_size} ) foreach(r IN LISTS UPDATE_XML_REVISIONS) string(REGEX REPLACE "${rev_regex}" "\\1" element "${r}") @@ -94,7 +96,7 @@ function(check_updates build) file(GLOB UPDATE_LOG_FILE ${TOP}/${build}/Testing/Temporary/LastUpdate*.log) if(UPDATE_LOG_FILE) - file(READ ${UPDATE_LOG_FILE} UPDATE_LOG LIMIT 4096) + file(READ ${UPDATE_LOG_FILE} UPDATE_LOG LIMIT ${max_update_xml_size}) string(REGEX REPLACE "\n" "\n " UPDATE_LOG "${UPDATE_LOG}") set(MSG "${MSG}Update log:\n ${UPDATE_LOG}") else(UPDATE_LOG_FILE) diff --git a/Tests/CTestUpdateSVN.cmake.in b/Tests/CTestUpdateSVN.cmake.in index 97b2a07fe..edafb4ef2 100644 --- a/Tests/CTestUpdateSVN.cmake.in +++ b/Tests/CTestUpdateSVN.cmake.in @@ -23,6 +23,16 @@ file(MAKE_DIRECTORY ${TOP}/config) set(SVNCMD ${SVN} --config-dir ${TOP}/config) set(SVNUSER --username "test author" --non-interactive) +# Configure for this svn version. +execute_process( + COMMAND ${SVN} help add OUTPUT_VARIABLE help_add ERROR_VARIABLE help_add + ) +if("${help_add}" MATCHES "--depth") + set(depth_empty "--depth=empty") +else() + set(depth_empty "") +endif() + #----------------------------------------------------------------------------- # Initialize the testing directory. message("Creating test directory...") @@ -63,7 +73,7 @@ update_content(user-source files_added files_removed dirs_added) if(dirs_added) run_child( WORKING_DIRECTORY ${TOP}/user-source - COMMAND ${SVNCMD} add ${dirs_added} + COMMAND ${SVNCMD} add ${depth_empty} ${dirs_added} ) endif(dirs_added) run_child( diff --git a/Tests/CheckCompilerRelatedVariables/CMakeLists.txt b/Tests/CheckCompilerRelatedVariables/CMakeLists.txt index 8095a1cf1..8b279a5c4 100644 --- a/Tests/CheckCompilerRelatedVariables/CMakeLists.txt +++ b/Tests/CheckCompilerRelatedVariables/CMakeLists.txt @@ -34,6 +34,9 @@ endif() if(DEFINED MSVC10) math(EXPR msvc_total "${msvc_total} + 1") endif() +if(DEFINED MSVC11) + math(EXPR msvc_total "${msvc_total} + 1") +endif() echo_var(MSVC) echo_var(MSVC60) @@ -42,6 +45,7 @@ echo_var(MSVC71) echo_var(MSVC80) echo_var(MSVC90) echo_var(MSVC10) +echo_var(MSVC11) if(MSVC) # diff --git a/Tests/DoubleProject/CMakeLists.txt b/Tests/DoubleProject/CMakeLists.txt new file mode 100644 index 000000000..02a627597 --- /dev/null +++ b/Tests/DoubleProject/CMakeLists.txt @@ -0,0 +1,3 @@ +project(dumb) +project(dumber) +add_executable(just_silly silly.c) diff --git a/Tests/DoubleProject/silly.c b/Tests/DoubleProject/silly.c new file mode 100644 index 000000000..f8b643afb --- /dev/null +++ b/Tests/DoubleProject/silly.c @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt index 2e01c5067..ccfb8940c 100644 --- a/Tests/ExportImport/CMakeLists.txt +++ b/Tests/ExportImport/CMakeLists.txt @@ -22,6 +22,11 @@ else(CMAKE_CONFIGURATION_TYPES) endif(CMAKE_BUILD_TYPE) endif(CMAKE_CONFIGURATION_TYPES) +if(MINGW OR MSYS) + # Test CMAKE_GNUtoMS whether we have VS or not. + set(ExportImport_GNUtoMS 1) +endif() + configure_file(${ExportImport_SOURCE_DIR}/InitialCache.cmake.in ${ExportImport_BINARY_DIR}/InitialCache.cmake @ONLY) diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 235a1d215..f06a4659f 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -23,8 +23,13 @@ add_library(testLib1 STATIC testLib1.c) add_library(testLib2 STATIC testLib2.c) target_link_libraries(testLib2 testLib1) +# Test library with empty link interface. Link it to an implementation +# dependency that itself links to dependencies publicly. +add_library(testLib3ImpDep SHARED testLib3ImpDep.c) +set_property(TARGET testLib3ImpDep PROPERTY LIBRARY_OUTPUT_DIRECTORY impl/dep) add_library(testLib3Imp SHARED testLib3Imp.c) set_property(TARGET testLib3Imp PROPERTY LIBRARY_OUTPUT_DIRECTORY impl) +target_link_libraries(testLib3Imp testLib3ImpDep) add_library(testLib3 SHARED testLib3.c) target_link_libraries(testLib3 testLib3Imp) set_property(TARGET testLib3 PROPERTY LINK_INTERFACE_LIBRARIES "") @@ -104,6 +109,14 @@ install( LIBRARY DESTINATION lib/impl ARCHIVE DESTINATION lib/impl ) +install( + TARGETS + testLib3ImpDep + EXPORT exp + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib/impl/dep + ARCHIVE DESTINATION lib/impl/dep + ) install( TARGETS testLib5 EXPORT exp @@ -120,7 +133,7 @@ endif(WIN32) # Export from build tree. export(TARGETS testExe1 testLib1 testLib2 testLib3 - testExe2libImp testLib3Imp + testExe2libImp testLib3Imp testLib3ImpDep NAMESPACE bld_ FILE ExportBuildTree.cmake ) diff --git a/Tests/ExportImport/Export/testLib3Imp.c b/Tests/ExportImport/Export/testLib3Imp.c index fb4c13faa..c27bccd40 100644 --- a/Tests/ExportImport/Export/testLib3Imp.c +++ b/Tests/ExportImport/Export/testLib3Imp.c @@ -1,7 +1,10 @@ #if defined(_WIN32) || defined(__CYGWIN__) # define testLib3Imp_EXPORT __declspec(dllexport) +# define testLib3ImpDep_IMPORT __declspec(dllimport) #else # define testLib3Imp_EXPORT +# define testLib3ImpDep_IMPORT #endif -testLib3Imp_EXPORT int testLib3Imp(void) { return 0; } +testLib3ImpDep_IMPORT int testLib3ImpDep(void); +testLib3Imp_EXPORT int testLib3Imp(void) { return testLib3ImpDep(); } diff --git a/Tests/ExportImport/Export/testLib3ImpDep.c b/Tests/ExportImport/Export/testLib3ImpDep.c new file mode 100644 index 000000000..578ac30ef --- /dev/null +++ b/Tests/ExportImport/Export/testLib3ImpDep.c @@ -0,0 +1,7 @@ +#if defined(_WIN32) || defined(__CYGWIN__) +# define testLib3ImpDep_EXPORT __declspec(dllexport) +#else +# define testLib3ImpDep_EXPORT +#endif + +testLib3ImpDep_EXPORT int testLib3ImpDep(void) { return 0; } diff --git a/Tests/ExportImport/InitialCache.cmake.in b/Tests/ExportImport/InitialCache.cmake.in index f920b1f94..4893f7020 100644 --- a/Tests/ExportImport/InitialCache.cmake.in +++ b/Tests/ExportImport/InitialCache.cmake.in @@ -12,3 +12,4 @@ SET(CMAKE_CXX_FLAGS_MINSIZEREL "@CMAKE_CXX_FLAGS_MINSIZEREL@" CACHE STRING "C++ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@" CACHE STRING "C++ Flags") SET(CMAKE_INSTALL_PREFIX "@ExportImport_BINARY_DIR@/Root" CACHE STRING "Installation Prefix") SET(CMAKE_SKIP_RPATH ON CACHE BOOL "No RPATH") +SET(CMAKE_GNUtoMS "@ExportImport_GNUtoMS@" CACHE BOOL "CMAKE_GNUtoMS") diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index 4a542d722..ac701298f 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -343,13 +343,6 @@ endif() # Only do svn tests with svn >= version 1.2 # if(do_svn_tests) - execute_process(COMMAND ${Subversion_SVN_EXECUTABLE} --version - OUTPUT_VARIABLE Subversion_VERSION_SVN - OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX REPLACE "^(.*\n)?svn, version ([.0-9]+).*" - "\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}") - message(STATUS "Subversion_VERSION_SVN='${Subversion_VERSION_SVN}'") - if(Subversion_VERSION_SVN VERSION_LESS 1.2) message(STATUS "No ExternalProject svn tests with svn client less than version 1.2") set(do_svn_tests 0) diff --git a/Tests/ExternalProject/Example/CMakeLists.txt b/Tests/ExternalProject/Example/CMakeLists.txt index 2cadd7d22..69ebaaf51 100644 --- a/Tests/ExternalProject/Example/CMakeLists.txt +++ b/Tests/ExternalProject/Example/CMakeLists.txt @@ -6,6 +6,6 @@ include(ExternalProject) ExternalProject_Add( cmake281 URL http://www.cmake.org/files/v2.8/cmake-2.8.1.tar.gz - CMAKE_ARGS -D CMAKE_INSTALL_PREFIX= + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= BUILD_COMMAND "" ) diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt new file mode 100644 index 000000000..3674f0efe --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -0,0 +1,31 @@ + + +if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile") + + # Test whether the make is GNU make, and only add the test in this case, + # since the configured makefile in this test uses $(shell ...), which + # is AFAIK a GNU make extension. Alex + execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} -v + OUTPUT_VARIABLE makeVersionOutput + ERROR_QUIET + TIMEOUT 10) + string(TOUPPER "${makeVersionOutput}" MAKE_VERSION_OUTPUT) + if("${MAKE_VERSION_OUTPUT}" MATCHES ".*GNU MAKE.*") + + # build a library which we can search during the test + add_library(foo STATIC foo.cpp) + + # configure a FindFoo.cmake so it knows where the library can be found + configure_file(FindFoo.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FindFoo.cmake @ONLY) + + # now set up the test: + get_target_property(cmakeExecutable cmake LOCATION) + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) + + add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile ) + + endif() + +endif() diff --git a/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in b/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in new file mode 100644 index 000000000..dc62bac41 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/FindFoo.cmake.in @@ -0,0 +1,9 @@ + +find_library(FOO_LIBRARY NAMES foo HINTS "@CMAKE_CURRENT_BINARY_DIR@" ) +find_path(FOO_INCLUDE_DIR NAMES foo.h HINTS "@CMAKE_CURRENT_SOURCE_DIR@" ) + +set(FOO_LIBRARIES ${FOO_LIBRARY}) +set(FOO_INCLUDE_DIRS "${FOO_INCLUDE_DIR}" "/some/path/with a space/include" ) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Foo DEFAULT_MSG FOO_LIBRARY FOO_INCLUDE_DIR ) diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in new file mode 100644 index 000000000..073d82ec7 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -0,0 +1,10 @@ +all: clean pngtest + +main.o: main.cpp + "@CMAKE_CXX_COMPILER@" $(CXXFLAGS) -c $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE) main.cpp + +pngtest: main.o + "@CMAKE_CXX_COMPILER@" $(LDFLAGS) -o pngtest main.o $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK) + +clean: + rm -f *.o pngtest diff --git a/Tests/FindPackageModeMakefileTest/foo.cpp b/Tests/FindPackageModeMakefileTest/foo.cpp new file mode 100644 index 000000000..6aea22629 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/foo.cpp @@ -0,0 +1,4 @@ +int foo() +{ + return 1477; +} diff --git a/Tests/FindPackageModeMakefileTest/foo.h b/Tests/FindPackageModeMakefileTest/foo.h new file mode 100644 index 000000000..4ec598ad5 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/foo.h @@ -0,0 +1,6 @@ +#ifndef FOO_H +#define FOO_H + +int foo(); + +#endif diff --git a/Tests/FindPackageModeMakefileTest/main.cpp b/Tests/FindPackageModeMakefileTest/main.cpp new file mode 100644 index 000000000..e5f9134ce --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/main.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + printf("foo is: %d\n", foo()); + return 0; +} diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 87fe84eb1..9a4bdfeb5 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -75,7 +75,7 @@ ENDIF() # For purposes of the test wipe out previous find results. SET(PACKAGES - foo Foo Bar TFramework Tframework TApp Tapp Special + foo Foo Bar Blub TFramework Tframework TApp Tapp Special VersionedA VersionedB VersionedC VersionedD VersionedE WrongA WrongB WrongC WrongD wibbleA wibbleB @@ -104,6 +104,8 @@ set(CMAKE_IGNORE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/cmake/zot-3.1) FIND_PACKAGE(foo NO_MODULE) FIND_PACKAGE(Foo CONFIGS FooConfig.cmake) FIND_PACKAGE(Bar) +SET(CMAKE_DISABLE_FIND_PACKAGE_Blub TRUE) +FIND_PACKAGE(Blub NO_MODULE) FIND_PACKAGE(TFramework CONFIGS TFrameworkConfig.cmake) FIND_PACKAGE(Tframework) FIND_PACKAGE(TApp) @@ -169,6 +171,7 @@ ENDIF() SET(foo_EXPECTED "lib/foo-1.2/foo-config.cmake") SET(Foo_EXPECTED "lib/foo-1.2/CMake/FooConfig.cmake") SET(Bar_EXPECTED "lib/Bar/BarConfig.cmake") +SET(Blub_MISSING "") SET(Special_EXPECTED "lib/suffix/test/SuffixTestConfig.cmake") SET(TFramework_EXPECTED "TFramework.framework/Versions/A/Resources/CMake/TFrameworkConfig.cmake") @@ -300,3 +303,94 @@ SET(CMakeTestExportPackage_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) STRING(REGEX REPLACE "-.*$" "" version ${CMAKE_VERSION}) FIND_PACKAGE(CMakeTestExportPackage 1.${version} EXACT REQUIRED) + +#----------------------------------------------------------------------------- +# Test write_basic_config_version_file(). + +include(WriteBasicConfigVersionFile) + +write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake + VERSION 1.2.3 + COMPATIBILITY AnyNewerVersion) + +set(PACKAGE_FIND_VERSION 2.3.4) +include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Foo123 with version 1.2.3, but 2.3.4 was requested !") +endif() + +set(PACKAGE_FIND_VERSION 0.0.1) +include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (0.0.1 was requested) !") +endif() + +set(PACKAGE_FIND_VERSION 1.0.0) +include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.0.0 was requested) !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + +set(PACKAGE_FIND_VERSION 1.2.3) +include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.2.3 was requested) !") +endif() +if(NOT PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !") +endif() + + +####################### + +write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake + VERSION 1.2.3 + COMPATIBILITY SameMajorVersion) + +set(PACKAGE_VERSION_EXACT FALSE) +set(PACKAGE_FIND_VERSION 2.3.4) +set(PACKAGE_FIND_VERSION_MAJOR 2) +include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Boo123 with version 1.2.3, but 2.3.4 was requested !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + +set(PACKAGE_FIND_VERSION 0.0.1) +set(PACKAGE_FIND_VERSION_MAJOR 0) +include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Boo123 with version 1.2.3, but 0.0.1 was requested !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + +set(PACKAGE_FIND_VERSION 1.0.0) +set(PACKAGE_FIND_VERSION_MAJOR 1) +include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.0.0 was requested) !") +endif() +if(PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !") +endif() + +set(PACKAGE_FIND_VERSION 1.2.3) +set(PACKAGE_FIND_VERSION_MAJOR 1) +include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.2.3 was requested) !") +endif() +if(NOT PACKAGE_VERSION_EXACT) + message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !") +endif() + +if(PACKAGE_VERSION_UNSUITABLE) + message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !") +endif() diff --git a/Tests/FindPackageTest/lib/Blub/BlubConfig.cmake b/Tests/FindPackageTest/lib/Blub/BlubConfig.cmake new file mode 100644 index 000000000..deffa5729 --- /dev/null +++ b/Tests/FindPackageTest/lib/Blub/BlubConfig.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index c216529f4..a995f68dd 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -113,16 +113,8 @@ endfunction() # if the id's match or the compilers are compatible, then # call the test_fortran_c_interface_module function -if(("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel") - AND - ("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC") - ) - set(COMPATABLE_COMPILERS TRUE) -endif() -if("${CMAKE_Fortran_COMPILER_ID}:${CMAKE_C_COMPILER_ID}" MATCHES "Absoft:GNU") - set(COMPATABLE_COMPILERS TRUE) -endif() -if(COMPATABLE_COMPILERS +if("${CMAKE_Fortran_COMPILER_ID}:${CMAKE_C_COMPILER_ID}" MATCHES + "(Intel:MSVC|Absoft:GNU)" OR ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "${CMAKE_C_COMPILER_ID}" )) test_fortran_c_interface_module() else() @@ -161,8 +153,10 @@ if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) add_executable(test_use_in_comment_fixedform test_use_in_comment_fixedform.f) + set_property(SOURCE test_use_in_comment_fixedform.f PROPERTY Fortran_FORMAT FIXED) add_executable(test_use_in_comment_freeform test_use_in_comment_freeform.f90) + set_property(SOURCE test_use_in_comment_freeform.f90 PROPERTY Fortran_FORMAT FREE) add_executable(test_in_interface in_interface/main.f90 diff --git a/Tests/FortranOnly/CMakeLists.txt b/Tests/FortranOnly/CMakeLists.txt new file mode 100644 index 000000000..d57a8b295 --- /dev/null +++ b/Tests/FortranOnly/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required (VERSION 2.8) +project(FortranOnly Fortran) +message("CTEST_FULL_OUTPUT ") + +# create a library with hello and world functions +add_library(FortranOnlylib hello.f world.f) +set_property(TARGET FortranOnlylib PROPERTY Fortran_FORMAT FIXED) +set_property(SOURCE world.f PROPERTY Fortran_FORMAT FREE) + +# create an executable that calls hello and world +add_executable(FortranOnly testf.f) +target_link_libraries(FortranOnly FortranOnlylib) + +# create a custom command that runs FortranOnly and puts +# the output into the file testfhello.txt +add_custom_command(OUTPUT ${FortranOnly_BINARY_DIR}/testfhello.txt + COMMAND ${FortranOnly_BINARY_DIR}/${CMAKE_CFG_INTDIR}/FortranOnly + > testfhello.txt) +# create a second executable FortranOnly2 that has +# testfhello.txt has an source file so that it will +# run the above custom command. +add_executable(FortranOnly2 testfhello.txt testf.f) +target_link_libraries(FortranOnly2 FortranOnlylib) +# create a custom target to check the content of testfhello.txt +# by running the cmake script checktestf2.cmake +add_custom_target(checktestf2 ALL + COMMAND ${CMAKE_COMMAND} + -P ${FortranOnly_SOURCE_DIR}/checktestf2.cmake) + +# create a custom target that runs FortranOnly exectuable and creates +# a file out.txt that should have hello world in it. +add_custom_target(sayhello ALL + COMMAND ${FortranOnly_BINARY_DIR}/${CMAKE_CFG_INTDIR}/FortranOnly > out.txt +) +# make sure stuff is built in the right order +add_dependencies(checktestf2 FortranOnly2) +add_dependencies(sayhello FortranOnly) +add_dependencies(FortranOnly2 FortranOnly) + +# add a custom target that checkes that out.txt has the correct +# content +add_custom_target(checksayhello ALL + COMMAND ${CMAKE_COMMAND} -P ${FortranOnly_SOURCE_DIR}/checksayhello.cmake + ) +add_dependencies(checksayhello sayhello) diff --git a/Tests/FortranOnly/checksayhello.cmake b/Tests/FortranOnly/checksayhello.cmake new file mode 100644 index 000000000..5352290ab --- /dev/null +++ b/Tests/FortranOnly/checksayhello.cmake @@ -0,0 +1,7 @@ +file(READ out.txt IN) +message("${IN}") +if(IN MATCHES Hello AND IN MATCHES World) + message("Passed") +else() + message(FATAL_ERROR "Hello world not found") +endif() diff --git a/Tests/FortranOnly/checktestf2.cmake b/Tests/FortranOnly/checktestf2.cmake new file mode 100644 index 000000000..f0e6be329 --- /dev/null +++ b/Tests/FortranOnly/checktestf2.cmake @@ -0,0 +1,8 @@ +file(READ testfhello.txt IN) +message("${IN}") +if(IN MATCHES Hello AND IN MATCHES World) + message("Passed") +else() + message(FATAL_ERROR "Hello world not found") +endif() +file(WRITE testfhello2.txt ${IN}) diff --git a/Tests/FortranOnly/hello.f b/Tests/FortranOnly/hello.f new file mode 100644 index 000000000..63e64080d --- /dev/null +++ b/Tests/FortranOnly/hello.f @@ -0,0 +1,5 @@ + SUBROUTINE HELLO + + PRINT *, 'Hello' + + END diff --git a/Tests/FortranOnly/testf.f b/Tests/FortranOnly/testf.f new file mode 100644 index 000000000..490918108 --- /dev/null +++ b/Tests/FortranOnly/testf.f @@ -0,0 +1,6 @@ + PROGRAM TESTF + + CALL HELLO() + CALL WORLD() + + END diff --git a/Tests/FortranOnly/world.f b/Tests/FortranOnly/world.f new file mode 100644 index 000000000..342b24431 --- /dev/null +++ b/Tests/FortranOnly/world.f @@ -0,0 +1,4 @@ +! Free-format ".f" file to test Fortran_FORMAT property +SUBROUTINE WORLD + PRINT *, 'World!' +END diff --git a/Tests/Java/CMakeLists.txt b/Tests/Java/CMakeLists.txt index b0dfaa5e6..6a69a2464 100644 --- a/Tests/Java/CMakeLists.txt +++ b/Tests/Java/CMakeLists.txt @@ -1,42 +1,9 @@ -cmake_minimum_required (VERSION 2.6) -PROJECT(hello Java) -SET(CMAKE_VERBOSE_MAKEFILE 1) - -IF("${hello_SOURCE_DIR}" STREQUAL "${hello_BINARY_DIR}") - MESSAGE("In Source, building Java using ADD_CUSTOM_COMMAND()") - SET(OLD_CUSTOM_COMMAND_WAY 1) -ELSE("${hello_SOURCE_DIR}" STREQUAL "${hello_BINARY_DIR}") - MESSAGE("Out of source, using built-in Java support") - SET(OLD_CUSTOM_COMMAND_WAY ) -ENDIF("${hello_SOURCE_DIR}" STREQUAL "${hello_BINARY_DIR}") - -IF(NOT OLD_CUSTOM_COMMAND_WAY) - - INCLUDE_DIRECTORIES(${hello_SOURCE_DIR} - ${hello_BINARY_DIR} ) - ADD_LIBRARY(hello A.java HelloWorld.java) +project(hello Java) -ELSE(NOT OLD_CUSTOM_COMMAND_WAY) - - ADD_CUSTOM_COMMAND( - OUTPUT ${hello_BINARY_DIR}/A.class - MAIN_DEPENDENCY ${hello_SOURCE_DIR}/A.java - COMMAND ${CMAKE_Java_COMPILER} ARGS -classpath . -d ${hello_BINARY_DIR} ${hello_SOURCE_DIR}/A.java) - ADD_CUSTOM_COMMAND( - OUTPUT ${hello_BINARY_DIR}/HelloWorld.class - MAIN_DEPENDENCY ${hello_SOURCE_DIR}/HelloWorld.java - DEPENDS ${hello_BINARY_DIR}/A.class - COMMAND ${CMAKE_Java_COMPILER} ARGS -classpath . -d ${hello_BINARY_DIR} ${hello_SOURCE_DIR}/HelloWorld.java) - ADD_CUSTOM_COMMAND( - OUTPUT ${hello_BINARY_DIR}/hello.jar - DEPENDS ${hello_BINARY_DIR}/A.class ${hello_BINARY_DIR}/HelloWorld.class - COMMAND ${CMAKE_COMMAND} - ARGS -E chdir ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_Java_ARCHIVE} - -cvf hello.jar *.class) - - ADD_CUSTOM_TARGET(hello_jar ALL - DEPENDS ${hello_BINARY_DIR}/hello.jar) +cmake_minimum_required (VERSION 2.6) +set(CMAKE_VERBOSE_MAKEFILE 1) -ENDIF(NOT OLD_CUSTOM_COMMAND_WAY) +find_package(Java COMPONENTS Development) +include (UseJava) +add_jar(hello A.java HelloWorld.java) diff --git a/Tests/MFC/CMakeLists.txt b/Tests/MFC/CMakeLists.txt new file mode 100644 index 000000000..62ff749fe --- /dev/null +++ b/Tests/MFC/CMakeLists.txt @@ -0,0 +1,61 @@ +cmake_minimum_required(VERSION 2.8) +project(mfc_driver) + +include(CTest) +include(ExternalProject) + + +set(CMAKE_MFC_FLAG_VALUE "2") +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.SharedMfcDll.txt + @ONLY + ) + +ExternalProject_Add(mfcShared + URL ${CMAKE_CURRENT_SOURCE_DIR}/mfc1 + PATCH_COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.SharedMfcDll.txt + /CMakeLists.txt + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= + ) + + +set(CMAKE_MFC_FLAG_VALUE "1") +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.StaticMfcLib.txt + @ONLY + ) + +ExternalProject_Add(mfcStatic + URL ${CMAKE_CURRENT_SOURCE_DIR}/mfc1 + PATCH_COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.StaticMfcLib.txt + /CMakeLists.txt + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= + ) + + +set(binary_dir "${CMAKE_CURRENT_BINARY_DIR}") +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/ValidateBuild.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/ValidateBuild.cmake + @ONLY + ) +add_test( + NAME validate + COMMAND ${CMAKE_COMMAND} + -P "${CMAKE_CURRENT_BINARY_DIR}/ValidateBuild.cmake" + ) + + +add_test( + NAME environment + COMMAND ${CMAKE_COMMAND} -E environment + ) + + +message(STATUS "===== environment =====") +execute_process(COMMAND ${CMAKE_COMMAND} -E environment) +message(STATUS "===== /environment =====") diff --git a/Tests/MFC/CMakeLists.txt.in b/Tests/MFC/CMakeLists.txt.in new file mode 100644 index 000000000..e6bfabd33 --- /dev/null +++ b/Tests/MFC/CMakeLists.txt.in @@ -0,0 +1,62 @@ +cmake_minimum_required(VERSION 2.8) +project(mfc1) + +macro(replace_flags var these those) + if("${${var}}" MATCHES "${these}") + string(REGEX REPLACE "${these}" "${those}" ${var} "${${var}}") + #message(STATUS "info: ${var} changed to '${${var}}'") + endif() + message(STATUS "info: ${var}='${${var}}'") +endmacro() + +macro(msvc_link_to_static_crt) + if(MSVC) + set(has_correct_flag 0) + foreach(lang C CXX) + foreach(suffix "" _DEBUG _MINSIZEREL _RELEASE _RELWITHDEBINFO) + replace_flags("CMAKE_${lang}_FLAGS${suffix}" "/MD" "/MT") + if(CMAKE_${lang}_FLAGS${suffix} MATCHES "/MT") + set(has_correct_flag 1) + endif() + endforeach() + endforeach() + if(NOT has_correct_flag) + message(FATAL_ERROR "no CMAKE_*_FLAGS var contains /MT") + endif() + endif() +endmacro() + +set(files + ChildFrm.cpp + ChildFrm.h + MainFrm.cpp + MainFrm.h + mfc1.cpp + mfc1.h + mfc1.rc + mfc1Doc.cpp + mfc1Doc.h + mfc1View.cpp + mfc1View.h + Resource.h + stdafx.cpp + stdafx.h +) + +set(CMAKE_MFC_FLAG "@CMAKE_MFC_FLAG_VALUE@") + +if("${CMAKE_MFC_FLAG}" STREQUAL "1") + msvc_link_to_static_crt() +else() + # VS generators add this automatically based on the CMAKE_MFC_FLAG value, + # but generators matching "Make" require: + add_definitions(-D_AFXDLL) +endif() + +add_executable(mfc1 WIN32 ${files}) +install(TARGETS mfc1 DESTINATION bin) + +if("${CMAKE_MFC_FLAG}" STREQUAL "2") + set(CMAKE_INSTALL_MFC_LIBRARIES ON) + include(InstallRequiredSystemLibraries) +endif() diff --git a/Tests/MFC/ValidateBuild.cmake.in b/Tests/MFC/ValidateBuild.cmake.in new file mode 100644 index 000000000..ed923f5e7 --- /dev/null +++ b/Tests/MFC/ValidateBuild.cmake.in @@ -0,0 +1,68 @@ +# +# This code validates that the install trees of the shared and static builds +# of "mfc1" have the expected contents: +# +set(binary_dir "@binary_dir@") +message("binary_dir='${binary_dir}'") + +# There should be exactly one file in the static install tree "bin" directory +# and it should be named "mfc1.exe" +# +message(STATUS "===== mfcStatic install tree =====") +file(GLOB_RECURSE files "${binary_dir}/mfcStatic-prefix/bin/*.*") +message(STATUS "mfcStatic files='${files}'") +list(LENGTH files len) +if(NOT len EQUAL 1) + message(FATAL_ERROR + "len='${len}' is not '1' (count of static 'bin' files)") +endif() +get_filename_component(name "${files}" NAME) +string(TOLOWER "${name}" name) +if(NOT "${name}" STREQUAL "mfc1.exe") + message(FATAL_ERROR "unexpected mfcStatic file name '${name}'") +endif() + +# There should be at least 3 files in the shared install tree "bin" +# directory: mfc1.exe, the main MFC dll and the C runtime dll. With more +# recent versions of VS, there will also be an MFC language dll and a +# manifest file. +# +message(STATUS "===== mfcShared install tree =====") +file(GLOB_RECURSE files "${binary_dir}/mfcShared-prefix/bin/*.*") +message(STATUS "mfcShared files='${files}'") +list(LENGTH files len) + +set(msvc6 "@MSVC60@") +if("${msvc6}" STREQUAL "1") + set(expected_minimum_file_count 1) +else() + set(expected_minimum_file_count 3) +endif() + +if(len LESS ${expected_minimum_file_count}) + message(FATAL_ERROR + "len='${len}' is less than '${expected_minimum_file_count}' (count of shared 'bin' files)") +endif() +foreach(f ${files}) + message(STATUS "file '${f}'") + get_filename_component(ext "${f}" EXT) + string(TOLOWER "${ext}" ext) + + if("${ext}" MATCHES "\\.exe$") + message(STATUS " exe file") + get_filename_component(name "${f}" NAME) + string(TOLOWER "${name}" name) + if(NOT "${name}" STREQUAL "mfc1.exe") + message(FATAL_ERROR "unexpected mfcShared .exe file name '${name}'") + endif() + elseif("${ext}" MATCHES "\\.dll$") + message(STATUS " dll file") + elseif("${ext}" MATCHES "\\.manifest$") + message(STATUS " manifest file") + else() + message(STATUS " unknown file") + message(FATAL_ERROR "unexpected mfcShared ${ext} file name '${f}'") + endif() +endforeach() + +message(STATUS "All mfc1 build validation tests pass.") diff --git a/Tests/MFC/mfc1/.gitattributes b/Tests/MFC/mfc1/.gitattributes new file mode 100644 index 000000000..59be5dcfb --- /dev/null +++ b/Tests/MFC/mfc1/.gitattributes @@ -0,0 +1,6 @@ +.gitattributes export-ignore + +*.sln -crlf +*.vcproj -crlf + +* -whitespace diff --git a/Tests/MFC/mfc1/ChildFrm.cpp b/Tests/MFC/mfc1/ChildFrm.cpp new file mode 100644 index 000000000..b04c4f231 --- /dev/null +++ b/Tests/MFC/mfc1/ChildFrm.cpp @@ -0,0 +1,59 @@ +// ChildFrm.cpp : implementation of the CChildFrame class +// +#include "stdafx.h" +#include "mfc1.h" + +#include "ChildFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CChildFrame + +IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd) + +BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd) +END_MESSAGE_MAP() + + +// CChildFrame construction/destruction + +CChildFrame::CChildFrame() +{ + // TODO: add member initialization code here +} + +CChildFrame::~CChildFrame() +{ +} + + +BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: Modify the Window class or styles here by modifying the CREATESTRUCT cs + if( !CMDIChildWnd::PreCreateWindow(cs) ) + return FALSE; + + return TRUE; +} + + +// CChildFrame diagnostics + +#ifdef _DEBUG +void CChildFrame::AssertValid() const +{ + CMDIChildWnd::AssertValid(); +} + +void CChildFrame::Dump(CDumpContext& dc) const +{ + CMDIChildWnd::Dump(dc); +} + +#endif //_DEBUG + + +// CChildFrame message handlers diff --git a/Tests/MFC/mfc1/ChildFrm.h b/Tests/MFC/mfc1/ChildFrm.h new file mode 100644 index 000000000..34b80f126 --- /dev/null +++ b/Tests/MFC/mfc1/ChildFrm.h @@ -0,0 +1,34 @@ +// ChildFrm.h : interface of the CChildFrame class +// + + +#pragma once + + +class CChildFrame : public CMDIChildWnd +{ + DECLARE_DYNCREATE(CChildFrame) +public: + CChildFrame(); + +// Attributes +public: + +// Operations +public: + +// Overrides + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + +// Implementation +public: + virtual ~CChildFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +// Generated message map functions +protected: + DECLARE_MESSAGE_MAP() +}; diff --git a/Tests/MFC/mfc1/MainFrm.cpp b/Tests/MFC/mfc1/MainFrm.cpp new file mode 100644 index 000000000..44554bf4c --- /dev/null +++ b/Tests/MFC/mfc1/MainFrm.cpp @@ -0,0 +1,98 @@ +// MainFrm.cpp : implementation of the CMainFrame class +// + +#include "stdafx.h" +#include "mfc1.h" + +#include "MainFrm.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// CMainFrame + +IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) + +BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) + ON_WM_CREATE() +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // status line indicator + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + + +// CMainFrame construction/destruction + +CMainFrame::CMainFrame() +{ + // TODO: add member initialization code here +} + +CMainFrame::~CMainFrame() +{ +} + + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP + | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || + !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) + { + TRACE0("Failed to create toolbar\n"); + return -1; // fail to create + } + + if (!m_wndStatusBar.Create(this) || + !m_wndStatusBar.SetIndicators(indicators, + sizeof(indicators)/sizeof(UINT))) + { + TRACE0("Failed to create status bar\n"); + return -1; // fail to create + } + // TODO: Delete these three lines if you don't want the toolbar to be dockable + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockControlBar(&m_wndToolBar); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CMDIFrameWnd::PreCreateWindow(cs) ) + return FALSE; + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + return TRUE; +} + + +// CMainFrame diagnostics + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CMDIFrameWnd::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CMDIFrameWnd::Dump(dc); +} + +#endif //_DEBUG + + +// CMainFrame message handlers diff --git a/Tests/MFC/mfc1/MainFrm.h b/Tests/MFC/mfc1/MainFrm.h new file mode 100644 index 000000000..1039ac5ee --- /dev/null +++ b/Tests/MFC/mfc1/MainFrm.h @@ -0,0 +1,38 @@ +// MainFrm.h : interface of the CMainFrame class +// + + +#pragma once +class CMainFrame : public CMDIFrameWnd +{ + DECLARE_DYNAMIC(CMainFrame) +public: + CMainFrame(); + +// Attributes +public: + +// Operations +public: + +// Overrides +public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + +// Implementation +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: // control bar embedded members + CStatusBar m_wndStatusBar; + CToolBar m_wndToolBar; + +// Generated message map functions +protected: + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + DECLARE_MESSAGE_MAP() +}; diff --git a/Tests/MFC/mfc1/ReadMe.txt b/Tests/MFC/mfc1/ReadMe.txt new file mode 100644 index 000000000..d84608e71 --- /dev/null +++ b/Tests/MFC/mfc1/ReadMe.txt @@ -0,0 +1,135 @@ +================================================================================ + MICROSOFT FOUNDATION CLASS LIBRARY : mfc1 Project Overview +=============================================================================== + +The application wizard has created this mfc1 application for +you. This application not only demonstrates the basics of using the Microsoft +Foundation Classes but is also a starting point for writing your application. + +This file contains a summary of what you will find in each of the files that +make up your mfc1 application. + +mfc1.vcproj + This is the main project file for VC++ projects generated using an application wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + application wizard. + +mfc1.h + This is the main header file for the application. It includes other + project specific headers (including Resource.h) and declares the + Cmfc1App application class. + +mfc1.cpp + This is the main application source file that contains the application + class Cmfc1App. + +mfc1.rc + This is a listing of all of the Microsoft Windows resources that the + program uses. It includes the icons, bitmaps, and cursors that are stored + in the RES subdirectory. This file can be directly edited in Microsoft + Visual C++. Your project resources are in 1033. + +res\mfc1.ico + This is an icon file, which is used as the application's icon. This + icon is included by the main resource file mfc1.rc. + +res\mfc1.rc2 + This file contains resources that are not edited by Microsoft + Visual C++. You should place all resources not editable by + the resource editor in this file. +mfc1.reg + This is an example .reg file that shows you the kind of registration + settings the framework will set for you. You can use this as a .reg + file to go along with your application or just delete it and rely + on the default RegisterShellFileTypes registration. +///////////////////////////////////////////////////////////////////////////// + +For the main frame window: + The project includes a standard MFC interface. +MainFrm.h, MainFrm.cpp + These files contain the frame class CMainFrame, which is derived from + CMDIFrameWnd and controls all MDI frame features. +res\Toolbar.bmp + This bitmap file is used to create tiled images for the toolbar. + The initial toolbar and status bar are constructed in the CMainFrame + class. Edit this toolbar bitmap using the resource editor, and + update the IDR_MAINFRAME TOOLBAR array in mfc1.rc to add + toolbar buttons. +///////////////////////////////////////////////////////////////////////////// + +For the child frame window: + +ChildFrm.h, ChildFrm.cpp + These files define and implement the CChildFrame class, which + supports the child windows in an MDI application. + +///////////////////////////////////////////////////////////////////////////// + +The application wizard creates one document type and one view: + +mfc1Doc.h, mfc1Doc.cpp - the document + These files contain your Cmfc1Doc class. Edit these files to + add your special document data and to implement file saving and loading + (via Cmfc1Doc::Serialize). + The Document will have the following strings: + File extension: mf1 + File type ID: mfc1.Document + Main frame caption: mfc1 + Doc type name: mfc1 + Filter name: mfc1 Files (*.mf1) + File new short name: mfc1 + File type long name: mfc1.Document +mfc1View.h, mfc1View.cpp - the view of the document + These files contain your Cmfc1View class. + Cmfc1View objects are used to view Cmfc1Doc objects. +res\mfc1Doc.ico + This is an icon file, which is used as the icon for MDI child windows + for the Cmfc1Doc class. This icon is included by the main + resource file mfc1.rc. +///////////////////////////////////////////////////////////////////////////// + +Other Features: + +ActiveX Controls + The application includes support to use ActiveX controls. + +Printing and Print Preview support + The application wizard has generated code to handle the print, print setup, and print preview + commands by calling member functions in the CView class from the MFC library. +///////////////////////////////////////////////////////////////////////////// + +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named mfc1.pch and a precompiled types file named StdAfx.obj. + +Resource.h + This is the standard header file, which defines new resource IDs. + Microsoft Visual C++ reads and updates this file. + +mfc1.manifest + Application manifest files are used by Windows XP to describe an applications + dependency on specific versions of Side-by-Side assemblies. The loader uses this + information to load the appropriate assembly from the assembly cache or private + from the application. The Application manifest maybe included for redistribution + as an external .manifest file that is installed in the same folder as the application + executable or it may be included in the executable in the form of a resource. +///////////////////////////////////////////////////////////////////////////// + +Other notes: + +The application wizard uses "TODO:" to indicate parts of the source code you +should add to or customize. + +If your application uses MFC in a shared DLL, and your application is in a +language other than the operating system's current language, you will need +to copy the corresponding localized resources MFC70XXX.DLL from the Microsoft +Visual C++ CD-ROM under the Win\System directory to your computer's system or +system32 directory, and rename it to be MFCLOC.DLL. ("XXX" stands for the +language abbreviation. For example, MFC70DEU.DLL contains resources +translated to German.) If you don't do this, some of the UI elements of +your application will remain in the language of the operating system. + +///////////////////////////////////////////////////////////////////////////// diff --git a/Tests/MFC/mfc1/Resource.h b/Tests/MFC/mfc1/Resource.h new file mode 100644 index 000000000..0a9c13f57 --- /dev/null +++ b/Tests/MFC/mfc1/Resource.h @@ -0,0 +1,20 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by mfc1.rc +// +#define IDD_ABOUTBOX 100 +#define IDP_OLE_INIT_FAILED 100 +#define IDR_MAINFRAME 128 +#define IDR_mfc1TYPE 129 +#define IDR_MANIFEST CREATEPROCESS_MANIFEST_RESOURCE_ID + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 130 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 32771 +#endif +#endif diff --git a/Tests/MFC/mfc1/mfc1.cpp b/Tests/MFC/mfc1/mfc1.cpp new file mode 100644 index 000000000..9530cd2b9 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.cpp @@ -0,0 +1,144 @@ +// mfc1.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "mfc1.h" +#include "MainFrm.h" + +#include "ChildFrm.h" +#include "mfc1Doc.h" +#include "mfc1View.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Cmfc1App + +BEGIN_MESSAGE_MAP(Cmfc1App, CWinApp) + ON_COMMAND(ID_APP_ABOUT, OnAppAbout) + // Standard file based document commands + ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) + // Standard print setup command + ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) +END_MESSAGE_MAP() + + +// Cmfc1App construction + +Cmfc1App::Cmfc1App() +{ + // TODO: add construction code here, + // Place all significant initialization in InitInstance +} + + +// The one and only Cmfc1App object + +Cmfc1App theApp; + +// Cmfc1App initialization + +BOOL Cmfc1App::InitInstance() +{ + // InitCommonControls() is required on Windows XP if an application + // manifest specifies use of ComCtl32.dll version 6 or later to enable + // visual styles. Otherwise, any window creation will fail. + InitCommonControls(); + + CWinApp::InitInstance(); + + // Initialize OLE libraries + if (!AfxOleInit()) + { + AfxMessageBox(IDP_OLE_INIT_FAILED); + return FALSE; + } + AfxEnableControlContainer(); + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need + // Change the registry key under which our settings are stored + // TODO: You should modify this string to be something appropriate + // such as the name of your company or organization + SetRegistryKey(_T("Local AppWizard-Generated Applications")); + LoadStdProfileSettings(4); // Load standard INI file options (including MRU) + // Register the application's document templates. Document templates + // serve as the connection between documents, frame windows and views + CMultiDocTemplate* pDocTemplate; + pDocTemplate = new CMultiDocTemplate(IDR_mfc1TYPE, + RUNTIME_CLASS(Cmfc1Doc), + RUNTIME_CLASS(CChildFrame), // custom MDI child frame + RUNTIME_CLASS(Cmfc1View)); + if (!pDocTemplate) + return FALSE; + AddDocTemplate(pDocTemplate); + // create main MDI Frame window + CMainFrame* pMainFrame = new CMainFrame; + if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME)) + return FALSE; + m_pMainWnd = pMainFrame; + // call DragAcceptFiles only if there's a suffix + // In an MDI app, this should occur immediately after setting m_pMainWnd + // Enable drag/drop open + m_pMainWnd->DragAcceptFiles(); + // Enable DDE Execute open + EnableShellOpen(); + RegisterShellFileTypes(TRUE); + // Parse command line for standard shell commands, DDE, file open + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + // Dispatch commands specified on the command line. Will return FALSE if + // app was launched with /RegServer, /Register, /Unregserver or /Unregister. + if (!ProcessShellCommand(cmdInfo)) + return FALSE; + // The main window has been initialized, so show and update it + pMainFrame->ShowWindow(m_nCmdShow); + pMainFrame->UpdateWindow(); + return TRUE; +} + + + +// CAboutDlg dialog used for App About + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + +// Dialog Data + enum { IDD = IDD_ABOUTBOX }; + +protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + +// Implementation +protected: + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) +END_MESSAGE_MAP() + +// App command to run the dialog +void Cmfc1App::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + + +// Cmfc1App message handlers diff --git a/Tests/MFC/mfc1/mfc1.h b/Tests/MFC/mfc1/mfc1.h new file mode 100644 index 000000000..c273601f8 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.h @@ -0,0 +1,31 @@ +// mfc1.h : main header file for the mfc1 application +// +#pragma once + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + + +// Cmfc1App: +// See mfc1.cpp for the implementation of this class +// + +class Cmfc1App : public CWinApp +{ +public: + Cmfc1App(); + + +// Overrides +public: + virtual BOOL InitInstance(); + +// Implementation + afx_msg void OnAppAbout(); + DECLARE_MESSAGE_MAP() +}; + +extern Cmfc1App theApp; diff --git a/Tests/MFC/mfc1/mfc1.rc b/Tests/MFC/mfc1/mfc1.rc new file mode 100644 index 000000000..346c5fb77 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.rc @@ -0,0 +1,393 @@ +//Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// + +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +#ifdef APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "#define _AFX_NO_SPLITTER_RESOURCES\r\n" + "#define _AFX_NO_OLE_RESOURCES\r\n" + "#define _AFX_NO_TRACKER_RESOURCES\r\n" + "#define _AFX_NO_PROPERTY_RESOURCES\r\n" + "\r\n" + "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" + "LANGUAGE 9, 1\r\n" + "#pragma code_page(1252)\r\n" + "#include ""res\\mfc1.rc2"" // non-Microsoft Visual C++ edited resources\r\n" + "#include ""afxres.rc"" // Standard components\r\n" + "#include ""afxprint.rc"" // printing/print preview resources\r\n" + "#endif\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 +#pragma code_page(1252) +IDR_MAINFRAME ICON "res\\mfc1.ico" +IDR_mfc1TYPE ICON "res\\mfc1Doc.ico" +#endif +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +IDR_MAINFRAME BITMAP "res\\Toolbar.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// Toolbar +// + +IDR_MAINFRAME TOOLBAR 16, 15 +BEGIN + BUTTON ID_FILE_NEW + BUTTON ID_FILE_OPEN + BUTTON ID_FILE_SAVE + SEPARATOR + BUTTON ID_EDIT_CUT + BUTTON ID_EDIT_COPY + BUTTON ID_EDIT_PASTE + SEPARATOR + BUTTON ID_FILE_PRINT + BUTTON ID_APP_ABOUT +END + + + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 +#pragma code_page(1252) +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_MAINFRAME MENU +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New\tCtrl+N", ID_FILE_NEW + MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN + MENUITEM SEPARATOR + MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP + MENUITEM SEPARATOR + MENUITEM "Recent File", ID_FILE_MRU_FILE1,GRAYED + MENUITEM SEPARATOR + MENUITEM "&Close", ID_FILE_CLOSE + MENUITEM "E&xit", ID_APP_EXIT + END + POPUP "&View" + BEGIN + MENUITEM "&Toolbar", ID_VIEW_TOOLBAR + MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR + END + POPUP "&Help" + BEGIN + MENUITEM "&About mfc1...", ID_APP_ABOUT + END +END +IDR_mfc1TYPE MENU +BEGIN + POPUP "&File" + BEGIN + MENUITEM "&New\tCtrl+N", ID_FILE_NEW + MENUITEM "&Open...\tCtrl+O", ID_FILE_OPEN + MENUITEM "&Close", ID_FILE_CLOSE + MENUITEM "&Save\tCtrl+S", ID_FILE_SAVE + MENUITEM "Save &As...", ID_FILE_SAVE_AS + MENUITEM SEPARATOR + MENUITEM "&Print...\tCtrl+P", ID_FILE_PRINT + MENUITEM "Print Pre&view", ID_FILE_PRINT_PREVIEW + MENUITEM "P&rint Setup...", ID_FILE_PRINT_SETUP + MENUITEM SEPARATOR + MENUITEM "Recent File", ID_FILE_MRU_FILE1,GRAYED + MENUITEM SEPARATOR + MENUITEM "E&xit", ID_APP_EXIT + END + POPUP "&Edit" + BEGIN + MENUITEM "&Undo\tCtrl+Z", ID_EDIT_UNDO + MENUITEM SEPARATOR + MENUITEM "Cu&t\tCtrl+X", ID_EDIT_CUT + MENUITEM "&Copy\tCtrl+C", ID_EDIT_COPY + MENUITEM "&Paste\tCtrl+V", ID_EDIT_PASTE + END + POPUP "&View" + BEGIN + MENUITEM "&Toolbar", ID_VIEW_TOOLBAR + MENUITEM "&Status Bar", ID_VIEW_STATUS_BAR + END + POPUP "&Window" + BEGIN + MENUITEM "&New Window", ID_WINDOW_NEW + MENUITEM "&Cascade", ID_WINDOW_CASCADE + MENUITEM "&Tile", ID_WINDOW_TILE_HORZ + MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE + END + POPUP "&Help" + BEGIN + MENUITEM "&About mfc1...", ID_APP_ABOUT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDR_MAINFRAME ACCELERATORS +BEGIN + "N", ID_FILE_NEW, VIRTKEY,CONTROL + "O", ID_FILE_OPEN, VIRTKEY,CONTROL + "S", ID_FILE_SAVE, VIRTKEY,CONTROL + "P", ID_FILE_PRINT, VIRTKEY,CONTROL + "Z", ID_EDIT_UNDO, VIRTKEY,CONTROL + "X", ID_EDIT_CUT, VIRTKEY,CONTROL + "C", ID_EDIT_COPY, VIRTKEY,CONTROL + "V", ID_EDIT_PASTE, VIRTKEY,CONTROL + VK_BACK, ID_EDIT_UNDO, VIRTKEY,ALT + VK_DELETE, ID_EDIT_CUT, VIRTKEY,SHIFT + VK_INSERT, ID_EDIT_COPY, VIRTKEY,CONTROL + VK_INSERT, ID_EDIT_PASTE, VIRTKEY,SHIFT + VK_F6, ID_NEXT_PANE, VIRTKEY + VK_F6, ID_PREV_PANE, VIRTKEY,SHIFT +END + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +#if _MSC_VER < 1300 +#define DS_SHELLFONT_FLAG 0 +#else +#define DS_SHELLFONT_FLAG DS_SHELLFONT +#endif + +IDD_ABOUTBOX DIALOGEX 0, 0, 235, 55 +CAPTION "About mfc1" +STYLE DS_MODALFRAME | DS_SHELLFONT_FLAG | WS_POPUP | WS_CAPTION | WS_SYSMENU +FONT 8, "MS Shell Dlg" +BEGIN + ICON IDR_MAINFRAME,IDC_STATIC,11,17,20,20 + LTEXT "mfc1 Version 1.0",IDC_STATIC,40,10,119,8, + SS_NOPREFIX + LTEXT "Copyright (C) 2011",IDC_STATIC,40,25,119,8 + DEFPUSHBUTTON "OK",IDOK,178,7,50,16,WS_GROUP +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "TODO: " + VALUE "FileDescription", "TODO: " + VALUE "FileVersion", "1.0.0.1" + VALUE "InternalName", "mfc1.exe" + VALUE "LegalCopyright", "TODO: (c) . All rights reserved." + VALUE "OriginalFilename","mfc1.exe" + VALUE "ProductName", "TODO: " + VALUE "ProductVersion", "1.0.0.1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 228 + TOPMARGIN, 7 + BOTTOMMARGIN, 48 + END +END +#endif // APSTUDIO_INVOKED + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN +// Non-mac-targeting apps remove the two extra substrings + IDR_MAINFRAME "mfc1" + // has a file suffix - shell file type too + IDR_mfc1TYPE "\nmfc1\nmfc1\nmfc1 Files (*.mf1)\n.mf1\nmfc1.Document\nmfc1.Document" +END +STRINGTABLE +BEGIN + AFX_IDS_APP_TITLE "mfc1" + AFX_IDS_IDLEMESSAGE "Ready" +END +STRINGTABLE +BEGIN + ID_INDICATOR_EXT "EXT" + ID_INDICATOR_CAPS "CAP" + ID_INDICATOR_NUM "NUM" + ID_INDICATOR_SCRL "SCRL" + ID_INDICATOR_OVR "OVR" + ID_INDICATOR_REC "REC" +END +STRINGTABLE +BEGIN + ID_FILE_NEW "Create a new document\nNew" + ID_FILE_OPEN "Open an existing document\nOpen" + ID_FILE_CLOSE "Close the active document\nClose" + ID_FILE_SAVE "Save the active document\nSave" + ID_FILE_SAVE_AS "Save the active document with a new name\nSave As" + ID_FILE_PAGE_SETUP "Change the printing options\nPage Setup" + ID_FILE_PRINT_SETUP "Change the printer and printing options\nPrint Setup" + ID_FILE_PRINT "Print the active document\nPrint" + ID_FILE_PRINT_PREVIEW "Display full pages\nPrint Preview" + ID_APP_ABOUT "Display program information, version number and copyright\nAbout" + ID_APP_EXIT "Quit the application; prompts to save documents\nExit" + ID_FILE_MRU_FILE1 "Open this document" + ID_FILE_MRU_FILE2 "Open this document" + ID_FILE_MRU_FILE3 "Open this document" + ID_FILE_MRU_FILE4 "Open this document" + ID_FILE_MRU_FILE5 "Open this document" + ID_FILE_MRU_FILE6 "Open this document" + ID_FILE_MRU_FILE7 "Open this document" + ID_FILE_MRU_FILE8 "Open this document" + ID_FILE_MRU_FILE9 "Open this document" + ID_FILE_MRU_FILE10 "Open this document" + ID_FILE_MRU_FILE11 "Open this document" + ID_FILE_MRU_FILE12 "Open this document" + ID_FILE_MRU_FILE13 "Open this document" + ID_FILE_MRU_FILE14 "Open this document" + ID_FILE_MRU_FILE15 "Open this document" + ID_FILE_MRU_FILE16 "Open this document" + ID_NEXT_PANE "Switch to the next window pane\nNext Pane" + ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" + ID_WINDOW_NEW "Open another window for the active document\nNew Window" + ID_WINDOW_ARRANGE "Arrange icons at the bottom of the window\nArrange Icons" + ID_WINDOW_CASCADE "Arrange windows so they overlap\nCascade Windows" + ID_WINDOW_TILE_HORZ "Arrange windows as non-overlapping tiles\nTile Windows" + ID_WINDOW_TILE_VERT "Arrange windows as non-overlapping tiles\nTile Windows" + ID_WINDOW_SPLIT "Split the active window into panes\nSplit" + ID_EDIT_CLEAR "Erase the selection\nErase" + ID_EDIT_CLEAR_ALL "Erase everything\nErase All" + ID_EDIT_COPY "Copy the selection and put it on the Clipboard\nCopy" + ID_EDIT_CUT "Cut the selection and put it on the Clipboard\nCut" + ID_EDIT_FIND "Find the specified text\nFind" + ID_EDIT_PASTE "Insert Clipboard contents\nPaste" + ID_EDIT_REPEAT "Repeat the last action\nRepeat" + ID_EDIT_REPLACE "Replace specific text with different text\nReplace" + ID_EDIT_SELECT_ALL "Select the entire document\nSelect All" + ID_EDIT_UNDO "Undo the last action\nUndo" + ID_EDIT_REDO "Redo the previously undone action\nRedo" + ID_VIEW_TOOLBAR "Show or hide the toolbar\nToggle ToolBar" + ID_VIEW_STATUS_BAR "Show or hide the status bar\nToggle StatusBar" +END + +STRINGTABLE +BEGIN + AFX_IDS_SCSIZE "Change the window size" + AFX_IDS_SCMOVE "Change the window position" + AFX_IDS_SCMINIMIZE "Reduce the window to an icon" + AFX_IDS_SCMAXIMIZE "Enlarge the window to full size" + AFX_IDS_SCNEXTWINDOW "Switch to the next document window" + AFX_IDS_SCPREVWINDOW "Switch to the previous document window" + AFX_IDS_SCCLOSE "Close the active window and prompts to save the documents" + AFX_IDS_SCRESTORE "Restore the window to normal size" + AFX_IDS_SCTASKLIST "Activate Task List" + AFX_IDS_MDICHILD "Activate this window" + AFX_IDS_PREVIEW_CLOSE "Close print preview mode\nCancel Preview" +END + +#endif + +#ifdef _UNICODE +IDR_MANIFEST RT_MANIFEST "res\\mfc1.manifest" +#endif + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + +#define _AFX_NO_SPLITTER_RESOURCES +#define _AFX_NO_OLE_RESOURCES +#define _AFX_NO_TRACKER_RESOURCES +#define _AFX_NO_PROPERTY_RESOURCES + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 +#pragma code_page(1252) +#include "res\\mfc1.rc2" // non-Microsoft Visual C++ edited resources +#include "afxres.rc" // Standard components +#include "afxprint.rc" // printing/print preview resources +#endif +#endif // not APSTUDIO_INVOKED diff --git a/Tests/MFC/mfc1/mfc1.reg b/Tests/MFC/mfc1/mfc1.reg new file mode 100644 index 000000000..9f3a86ffb --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.reg @@ -0,0 +1,13 @@ +REGEDIT +; This .REG file may be used by your SETUP program. +; If a SETUP program is not available, the entries below will be +; registered in your InitInstance automatically with a call to +; CWinApp::RegisterShellFileTypes and COleObjectFactory::UpdateRegistryAll. + +HKEY_CLASSES_ROOT\.mf1 = mfc1.Document +HKEY_CLASSES_ROOT\mfc1.Document\shell\open\command = mfc1.EXE %1 +HKEY_CLASSES_ROOT\mfc1.Document\shell\open\ddeexec = [open("%1")] +HKEY_CLASSES_ROOT\mfc1.Document\shell\open\ddeexec\application = mfc1 + ; note: the application is optional + ; (it defaults to the app name in "command") +HKEY_CLASSES_ROOT\mfc1.Document = mfc1.Document diff --git a/Tests/MFC/mfc1/mfc1.sln b/Tests/MFC/mfc1/mfc1.sln new file mode 100644 index 000000000..78bbe56f2 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mfc1", "mfc1.vcproj", "{06C08100-1145-4104-AEC3-6BC8C608B819}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {06C08100-1145-4104-AEC3-6BC8C608B819}.Debug.ActiveCfg = Debug|Win32 + {06C08100-1145-4104-AEC3-6BC8C608B819}.Debug.Build.0 = Debug|Win32 + {06C08100-1145-4104-AEC3-6BC8C608B819}.Release.ActiveCfg = Release|Win32 + {06C08100-1145-4104-AEC3-6BC8C608B819}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Tests/MFC/mfc1/mfc1.vcproj b/Tests/MFC/mfc1/mfc1.vcproj new file mode 100644 index 000000000..6df86e564 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1.vcproj @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/MFC/mfc1/mfc1Doc.cpp b/Tests/MFC/mfc1/mfc1Doc.cpp new file mode 100644 index 000000000..8767052ed --- /dev/null +++ b/Tests/MFC/mfc1/mfc1Doc.cpp @@ -0,0 +1,78 @@ +// mfc1Doc.cpp : implementation of the Cmfc1Doc class +// + +#include "stdafx.h" +#include "mfc1.h" + +#include "mfc1Doc.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Cmfc1Doc + +IMPLEMENT_DYNCREATE(Cmfc1Doc, CDocument) + +BEGIN_MESSAGE_MAP(Cmfc1Doc, CDocument) +END_MESSAGE_MAP() + + +// Cmfc1Doc construction/destruction + +Cmfc1Doc::Cmfc1Doc() +{ + // TODO: add one-time construction code here + +} + +Cmfc1Doc::~Cmfc1Doc() +{ +} + +BOOL Cmfc1Doc::OnNewDocument() +{ + if (!CDocument::OnNewDocument()) + return FALSE; + + // TODO: add reinitialization code here + // (SDI documents will reuse this document) + + return TRUE; +} + + + + +// Cmfc1Doc serialization + +void Cmfc1Doc::Serialize(CArchive& ar) +{ + if (ar.IsStoring()) + { + // TODO: add storing code here + } + else + { + // TODO: add loading code here + } +} + + +// Cmfc1Doc diagnostics + +#ifdef _DEBUG +void Cmfc1Doc::AssertValid() const +{ + CDocument::AssertValid(); +} + +void Cmfc1Doc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + + +// Cmfc1Doc commands diff --git a/Tests/MFC/mfc1/mfc1Doc.h b/Tests/MFC/mfc1/mfc1Doc.h new file mode 100644 index 000000000..92d8e3541 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1Doc.h @@ -0,0 +1,37 @@ +// mfc1Doc.h : interface of the Cmfc1Doc class +// + + +#pragma once + +class Cmfc1Doc : public CDocument +{ +protected: // create from serialization only + Cmfc1Doc(); + DECLARE_DYNCREATE(Cmfc1Doc) + +// Attributes +public: + +// Operations +public: + +// Overrides + public: + virtual BOOL OnNewDocument(); + virtual void Serialize(CArchive& ar); + +// Implementation +public: + virtual ~Cmfc1Doc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generated message map functions +protected: + DECLARE_MESSAGE_MAP() +}; diff --git a/Tests/MFC/mfc1/mfc1View.cpp b/Tests/MFC/mfc1/mfc1View.cpp new file mode 100644 index 000000000..06c765230 --- /dev/null +++ b/Tests/MFC/mfc1/mfc1View.cpp @@ -0,0 +1,99 @@ +// mfc1View.cpp : implementation of the Cmfc1View class +// + +#include "stdafx.h" +#include "mfc1.h" + +#include "mfc1Doc.h" +#include "mfc1View.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#endif + + +// Cmfc1View + +IMPLEMENT_DYNCREATE(Cmfc1View, CView) + +BEGIN_MESSAGE_MAP(Cmfc1View, CView) + // Standard printing commands + ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) + ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) +END_MESSAGE_MAP() + +// Cmfc1View construction/destruction + +Cmfc1View::Cmfc1View() +{ + // TODO: add construction code here + +} + +Cmfc1View::~Cmfc1View() +{ +} + +BOOL Cmfc1View::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + return CView::PreCreateWindow(cs); +} + +// Cmfc1View drawing + +void Cmfc1View::OnDraw(CDC* /*pDC*/) +{ + Cmfc1Doc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + if (!pDoc) + return; + + // TODO: add draw code for native data here +} + + +// Cmfc1View printing + +BOOL Cmfc1View::OnPreparePrinting(CPrintInfo* pInfo) +{ + // default preparation + return DoPreparePrinting(pInfo); +} + +void Cmfc1View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: add extra initialization before printing +} + +void Cmfc1View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) +{ + // TODO: add cleanup after printing +} + + +// Cmfc1View diagnostics + +#ifdef _DEBUG +void Cmfc1View::AssertValid() const +{ + CView::AssertValid(); +} + +void Cmfc1View::Dump(CDumpContext& dc) const +{ + CView::Dump(dc); +} + +Cmfc1Doc* Cmfc1View::GetDocument() const // non-debug version is inline +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(Cmfc1Doc))); + return (Cmfc1Doc*)m_pDocument; +} +#endif //_DEBUG + + +// Cmfc1View message handlers diff --git a/Tests/MFC/mfc1/mfc1View.h b/Tests/MFC/mfc1/mfc1View.h new file mode 100644 index 000000000..42446536b --- /dev/null +++ b/Tests/MFC/mfc1/mfc1View.h @@ -0,0 +1,48 @@ +// mfc1View.h : interface of the Cmfc1View class +// + + +#pragma once + + +class Cmfc1View : public CView +{ +protected: // create from serialization only + Cmfc1View(); + DECLARE_DYNCREATE(Cmfc1View) + +// Attributes +public: + Cmfc1Doc* GetDocument() const; + +// Operations +public: + +// Overrides + public: + virtual void OnDraw(CDC* pDC); // overridden to draw this view +virtual BOOL PreCreateWindow(CREATESTRUCT& cs); +protected: + virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); + virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); + virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); + +// Implementation +public: + virtual ~Cmfc1View(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generated message map functions +protected: + DECLARE_MESSAGE_MAP() +}; + +#ifndef _DEBUG // debug version in mfc1View.cpp +inline Cmfc1Doc* Cmfc1View::GetDocument() const + { return reinterpret_cast(m_pDocument); } +#endif diff --git a/Tests/MFC/mfc1/res/Toolbar.bmp b/Tests/MFC/mfc1/res/Toolbar.bmp new file mode 100644 index 000000000..d501723c1 Binary files /dev/null and b/Tests/MFC/mfc1/res/Toolbar.bmp differ diff --git a/Tests/MFC/mfc1/res/mfc1.ico b/Tests/MFC/mfc1/res/mfc1.ico new file mode 100644 index 000000000..8a84ca3d3 Binary files /dev/null and b/Tests/MFC/mfc1/res/mfc1.ico differ diff --git a/Tests/MFC/mfc1/res/mfc1.manifest b/Tests/MFC/mfc1/res/mfc1.manifest new file mode 100644 index 000000000..b15d2f2f2 --- /dev/null +++ b/Tests/MFC/mfc1/res/mfc1.manifest @@ -0,0 +1,22 @@ + + + +Your app description here + + + + + + diff --git a/Tests/MFC/mfc1/res/mfc1.rc2 b/Tests/MFC/mfc1/res/mfc1.rc2 new file mode 100644 index 000000000..62a3ab0d6 --- /dev/null +++ b/Tests/MFC/mfc1/res/mfc1.rc2 @@ -0,0 +1,13 @@ +// +// mfc1.RC2 - resources Microsoft Visual C++ does not edit directly +// + +#ifdef APSTUDIO_INVOKED +#error this file is not editable by Microsoft Visual C++ +#endif //APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// Add manually edited resources here... + +///////////////////////////////////////////////////////////////////////////// diff --git a/Tests/MFC/mfc1/res/mfc1Doc.ico b/Tests/MFC/mfc1/res/mfc1Doc.ico new file mode 100644 index 000000000..2a1f1ae6e Binary files /dev/null and b/Tests/MFC/mfc1/res/mfc1Doc.ico differ diff --git a/Tests/MFC/mfc1/stdafx.cpp b/Tests/MFC/mfc1/stdafx.cpp new file mode 100644 index 000000000..67fd1b539 --- /dev/null +++ b/Tests/MFC/mfc1/stdafx.cpp @@ -0,0 +1,5 @@ +// stdafx.cpp : source file that includes just the standard includes +// mfc1.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" diff --git a/Tests/MFC/mfc1/stdafx.h b/Tests/MFC/mfc1/stdafx.h new file mode 100644 index 000000000..35a678dcd --- /dev/null +++ b/Tests/MFC/mfc1/stdafx.h @@ -0,0 +1,56 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently + +#pragma once + +#ifndef VC_EXTRALEAN +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#endif + +// See http://msdn.microsoft.com/en-us/library/6sehtctf.aspx for more info +// on WINVER and _WIN32_WINNT + +// Modify the following defines if you have to target a platform prior to the ones specified below. +// Refer to MSDN for the latest info on corresponding values for different platforms. +#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later. +#if _MSC_VER < 1600 +#define WINVER 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. +#else +#define WINVER 0x0501 // Target Windows XP and later with VS 10 and later +#endif +#endif + +#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later. +#if _MSC_VER < 1600 +#define _WIN32_WINNT 0x0400 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later. +#else +#define _WIN32_WINNT 0x0501 // Target Windows XP and later with VS 10 and later +#endif +#endif + +#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. +#if _MSC_VER < 1600 +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#endif +#endif + +#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. +#if _MSC_VER < 1600 +#define _WIN32_IE 0x0400 // Change this to the appropriate value to target IE 5.0 or later. +#endif +#endif + +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit + +// turns off MFC's hiding of some common and often safely ignored warning messages +#define _AFX_ALL_WARNINGS + +#include // MFC core and standard components +#include // MFC extensions +#include // MFC Automation classes + +#include // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT diff --git a/Tests/MFC/try_compile/CMakeLists.txt b/Tests/MFC/try_compile/CMakeLists.txt new file mode 100644 index 000000000..8e5d746f6 --- /dev/null +++ b/Tests/MFC/try_compile/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.8) +project(try_compile_mfc) + +set(files + stdafx.cpp + stdafx.h +) + +set(CMAKE_MFC_FLAG "2") + +# VS generators add this automatically based on the CMAKE_MFC_FLAG value, +# but generators matching "Make" require: +add_definitions(-D_AFXDLL) + +add_executable(simplest_possible_mfc_exe WIN32 ${files}) diff --git a/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt new file mode 100644 index 000000000..77f50060f --- /dev/null +++ b/Tests/Module/CheckCXXCompilerFlag/CMakeLists.txt @@ -0,0 +1,74 @@ +cmake_minimum_required(VERSION 2.8) +project(CheckCXXCompilerFlag) + +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +set(CMAKE_VERBOSE_MAKEFILE 1) + +macro(TEST_FAIL value msg) + if (${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +macro(TEST_PASS value msg) + if (NOT ${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +if(CMAKE_COMPILER_IS_GNUCXX) + exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE _gcc_version_info) + string (REGEX MATCH "[345]\\.[0-9]\\.[0-9]" _gcc_version "${_gcc_version_info}") + # gcc on mac just reports: "gcc (GCC) 3.3 20030304 ..." without the + # patch level, handle this here: + if(NOT _gcc_version) + string (REGEX REPLACE ".*\\(GCC\\).* ([34]\\.[0-9]) .*" "\\1.0" _gcc_version "${_gcc_version_info}") + endif() +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES Clang) + exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE _clang_version_info) + string (REGEX REPLACE ".*version ([0-9]\\.[0-9]).*" "\\1" _clang_version "${_clang_version_info}") +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES Intel) + exec_program(${CMAKE_CXX_COMPILER} ARGS -V OUTPUT_VARIABLE _intel_version_info) + string (REGEX REPLACE ".*Version ([0-9]+(\\.[0-9]+)+).*" "\\1" _intel_version "${_intel_version_info}") +endif() + +message("Platform:\n WIN32: ${WIN32}\n UNIX: ${UNIX}\n APPLE: ${APPLE}\n MINGW: ${MINGW}\n CYGWIN: ${CYGWIN}\n" + " MSVC: ${MSVC}\n MSVC60: ${MSVC60}\n MSVC70: ${MSVC70}\n MSVC71: ${MSVC71}\n MSVC80: ${MSVC80}\n MSVC90: ${MSVC90}\n MSVC10: ${MSVC10}\n" + " GCC: ${_gcc_version}\n" + " Clang: ${_clang_version}\n" + " Intel: ${_intel_version}\n" +) + +include(CheckCXXCompilerFlag) + +check_cxx_compiler_flag(-fvisibility=hidden HAS_HIDDEN_VISIBILITY) + +message("HAS_HIDDEN_VISIBILITY: ${HAS_HIDDEN_VISIBILITY}\n\nCOMPILE OUTPUT:\n${OUTPUT}") + +if(CMAKE_COMPILER_IS_GNUCXX) + if(NOT WIN32) +# test_pass(HAS_HIDDEN_VISIBILITY "GCC should support hidden visibility, but does not.") + endif() +else() + message("Unhandled Platform") +endif() + +# +# This is a no-op executable... If this test is going to fail, it fails during +# the configure step while cmake is configuring this CMakeLists.txt file... +# + +file(WRITE + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + "int main() { return 0; } +" +) + +add_executable( + CheckCXXCompilerFlag + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" +) diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt new file mode 100644 index 000000000..4a5b1cb5a --- /dev/null +++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt @@ -0,0 +1,184 @@ +cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR) + +project(GenerateExportHeader) + +# Prevent timeout on Watcom by not running the tests. +if ("${CMAKE_CXX_COMPILER_ID}" MATCHES Watcom) + file(WRITE + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + "int main() { return 0; } + " + ) + + add_executable( + GenerateExportHeader + "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" + ) + return() +endif() + +include(CheckCXXCompilerFlag) + +set( CMAKE_INCLUDE_CURRENT_DIR ON ) + +macro(TEST_FAIL value msg) + if (${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +macro(TEST_PASS value msg) + if (NOT ${value}) + message (SEND_ERROR "Test fail:" ${msg} ${Out} ) + endif () +endmacro() + +check_cxx_compiler_flag(-Werror HAS_WERROR_FLAG) + +if(HAS_WERROR_FLAG) + set(ERROR_FLAG "-Werror") +else() + # MSVC + # And intel on windows? + # http://software.intel.com/en-us/articles/how-to-handle-warnings-message-in-compiler/?wapkw=%28compiler+warning+message%29 + check_cxx_compiler_flag("/WX" HAS_WX_FLAG) + if(HAS_WX_FLAG) + set(ERROR_FLAG "/WX") + else() + # Sun CC + # http://www.acsu.buffalo.edu/~charngda/sunstudio.html + check_cxx_compiler_flag("-errwarn=%all" HAS_ERRWARN_ALL) + if (HAS_ERRWARN_ALL) + set(ERROR_FLAG "-errwarn=%all") + else() + endif() + endif() +endif() + +set(DEPS + libshared + libstatic + lib_shared_and_static +) + +foreach(DEP ${DEPS}) + try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/${DEP}_build + ${CMAKE_CURRENT_SOURCE_DIR}/${DEP} + ${DEP} + OUTPUT_VARIABLE Out + ) + if (NOT Result) + message("OUTPUT: ${Out}") + endif() +endforeach() + +# The _do_build macro is called from a child scope, where +# the current source and binary dir are different. Save them here +# for use in the macro. +set(TEST_TOP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(TEST_TOP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) + + +# We seem to get race conditions is writing this stuff to the same file at least on MinGW +# So to write to separate source and build directories, we use a count to differentiate. +set (COUNT 0) +macro(_do_build Include Library LibrarySource Source) + + math(EXPR COUNT "${COUNT} + 1" ) + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/src.cpp" "#include \"${Include}\"\n" + "int main() { ${Source}; }\n" + ) + + if ("${Library}" STREQUAL "static_variant") + set(CONDITIONAL_STATIC_DEFINE "add_definitions(-DLIBSHARED_AND_STATIC_STATIC_DEFINE)\n") + endif() + + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test${COUNT}/CMakeLists.txt" + "cmake_minimum_required(VERSION 2.8)\n" + + "project(compiletest)\n" + + "set(CMAKE_INCLUDE_CURRENT_DIR ON)\n" + + "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"\${CMAKE_CURRENT_BINARY_DIR}\")\n" + + "include(GenerateExportHeader)\n" + + "add_compiler_export_flags()\n" + + "if(NOT \"${ERROR_FLAG}\" STREQUAL \"\")\n" + " add_definitions(${ERROR_FLAG})\n" + "endif()\n" + + "include(\"${TEST_TOP_BINARY_DIR}/${LibrarySource}_build/Targets.cmake\")\n" + + "include_directories(\"${TEST_TOP_SOURCE_DIR}/${LibrarySource}\"\n" + " \"${TEST_TOP_BINARY_DIR}/${LibrarySource}_build\")\n" + + "${CONDITIONAL_STATIC_DEFINE}" + + "add_executable(compiletest src.cpp)\n" + "target_link_libraries(compiletest ${Library})\n" + ) + + try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/fail${COUNT} + ${CMAKE_CURRENT_BINARY_DIR}/test${COUNT} + compiletest + OUTPUT_VARIABLE Out + ) +endmacro() + +macro(build_fail Include Library LibrarySource Source Message) + _do_build(${Include} ${Library} ${LibrarySource} "${Source}") + test_fail(Result ${Message}) +endmacro() + +macro(build_pass Include Library LibrarySource Source Message) + _do_build(${Include} ${Library} ${LibrarySource} "${Source}") + test_pass(Result ${Message}) +endmacro() + +include(GenerateExportHeader) + +add_compiler_export_flags() + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + +message("#### COMPILER_HAS_DEPRECATED: " ${COMPILER_HAS_DEPRECATED}) +message("#### COMPILER_HAS_HIDDEN_VISIBILITY: " ${COMPILER_HAS_HIDDEN_VISIBILITY}) +message("#### WIN32: " ${WIN32}) +message("#### HAS_WERROR_FLAG: " ${HAS_WERROR_FLAG}) + +set(link_libraries) +macro(macro_add_test_library name) + add_subdirectory(${name}) + include_directories(${name} + ${${name}_BINARY_DIR} # For the export header. + ) + list(APPEND link_libraries ${name}) + add_subdirectory(${name}test) +endmacro() + +macro_add_test_library(libshared) +macro_add_test_library(libstatic) +add_subdirectory(lib_shared_and_static) +add_subdirectory(lib_shared_and_statictest) + +add_subdirectory(override_symbol) +add_subdirectory(nodeprecated) +add_subdirectory(prefix) + +if (CMAKE_COMPILER_IS_GNUCXX OR (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)) + # We deliberately call deprecated methods, and test for that elsewhere. + # No need to clutter the test output with warnings. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") +endif() + +if(MSVC AND COMPILER_HAS_DEPRECATED) + add_definitions(/wd4996) +endif() + +add_executable(GenerateExportHeader exportheader_test.cpp) + +target_link_libraries(GenerateExportHeader ${link_libraries}) diff --git a/Tests/Module/GenerateExportHeader/exportheader_test.cpp b/Tests/Module/GenerateExportHeader/exportheader_test.cpp new file mode 100644 index 000000000..55c3c1ad6 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/exportheader_test.cpp @@ -0,0 +1,82 @@ + +#include "libshared.h" + +#include "libstatic.h" + +// #define BUILD_FAIL + +#ifndef BUILD_FAIL +#define DOES_NOT_BUILD(function) +#else +#define DOES_NOT_BUILD(function) function +#endif + +int main() +{ + { + Libshared l; + l.libshared(); + l.libshared_exported(); + l.libshared_deprecated(); + l.libshared_not_exported(); + + DOES_NOT_BUILD(l.libshared_excluded();) + } + + { + LibsharedNotExported l; + DOES_NOT_BUILD(l.libshared();) + l.libshared_exported(); + l.libshared_deprecated(); + DOES_NOT_BUILD(l.libshared_not_exported();) + DOES_NOT_BUILD(l.libshared_excluded();) + } + + { + LibsharedExcluded l; + DOES_NOT_BUILD(l.libshared();) + l.libshared_exported(); + l.libshared_deprecated(); + DOES_NOT_BUILD(l.libshared_not_exported();) + DOES_NOT_BUILD(l.libshared_excluded();) + } + + libshared_exported(); + libshared_deprecated(); + DOES_NOT_BUILD(libshared_not_exported();) + DOES_NOT_BUILD(libshared_excluded();) + + { + Libstatic l; + l.libstatic(); + l.libstatic_exported(); + l.libstatic_deprecated(); + l.libstatic_not_exported(); + l.libstatic_excluded(); + } + + { + LibstaticNotExported l; + l.libstatic(); + l.libstatic_exported(); + l.libstatic_deprecated(); + l.libstatic_not_exported(); + l.libstatic_excluded(); + } + + { + LibstaticExcluded l; + l.libstatic(); + l.libstatic_exported(); + l.libstatic_deprecated(); + l.libstatic_not_exported(); + l.libstatic_excluded(); + } + + libstatic_exported(); + libstatic_deprecated(); + libstatic_not_exported(); + libstatic_excluded(); + + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt new file mode 100644 index 000000000..be0387fd5 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/CMakeLists.txt @@ -0,0 +1,23 @@ + +cmake_minimum_required(VERSION 2.8) + +project(lib_shared_and_static) + +include(GenerateExportHeader) + +add_compiler_export_flags() + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(lib_SRCS + libshared_and_static.cpp +) + +add_library(shared_variant SHARED ${lib_SRCS}) +add_library(static_variant ${lib_SRCS}) + +generate_export_header(shared_variant BASE_NAME libshared_and_static) + +set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE) + +export(TARGETS shared_variant static_variant FILE Targets.cmake) diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp new file mode 100644 index 000000000..1e0727362 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.cpp @@ -0,0 +1,91 @@ + +#include "libshared_and_static.h" + +int LibsharedAndStatic::libshared_and_static() const +{ + return 0; +} + +int LibsharedAndStatic::libshared_and_static_exported() const +{ + return 0; +} + +int LibsharedAndStatic::libshared_and_static_deprecated() const +{ + return 0; +} + +int LibsharedAndStatic::libshared_and_static_not_exported() const { + return 0; +} + +int LibsharedAndStatic::libshared_and_static_excluded() const { + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static() const +{ + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_exported() const +{ + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_deprecated() const +{ + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_not_exported() const { + return 0; +} + +int LibsharedAndStaticNotExported::libshared_and_static_excluded() const { + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static() const +{ + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_exported() const +{ + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_deprecated() const +{ + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_not_exported() const { + return 0; +} + +int LibsharedAndStaticExcluded::libshared_and_static_excluded() const { + return 0; +} + +int libshared_and_static() { + return 0; +} + +int libshared_and_static_exported() { + return 0; +} + +int libshared_and_static_deprecated() { + return 0; +} + +int libshared_and_static_not_exported() { + return 0; +} + +int libshared_and_static_excluded() { + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h new file mode 100644 index 000000000..049bfe9c4 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_static/libshared_and_static.h @@ -0,0 +1,54 @@ + +#ifndef SHARED_AND_STATIC_H +#define SHARED_AND_STATIC_H + +#include "libshared_and_static_export.h" + +class LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic { +public: + int libshared_and_static() const; + + int libshared_and_static_exported() const; + + int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + + int libshared_and_static_not_exported() const; + + int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; +}; + +class LibsharedAndStaticNotExported { +public: + int libshared_and_static() const; + + int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; + + int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + + int libshared_and_static_not_exported() const; + + int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; +}; + +class LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded { +public: + int libshared_and_static() const; + + int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const; + + int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const; + + int libshared_and_static_not_exported() const; + + int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const; +}; + +LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported(); + +LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int libshared_and_static_deprecated(); + +int libshared_and_static_not_exported(); + +int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded(); + +#endif diff --git a/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt new file mode 100644 index 000000000..207534d6e --- /dev/null +++ b/Tests/Module/GenerateExportHeader/lib_shared_and_statictest/CMakeLists.txt @@ -0,0 +1,33 @@ + +macro(shared_variant_build_pass Source Message) + build_pass("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +macro(shared_variant_build_fail Source Message) + build_fail("libshared_and_static.h" "shared_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +macro(static_variant_build_pass Source Message) + build_pass("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +macro(static_variant_build_fail Source Message) + build_fail("libshared_and_static.h" "static_variant" "lib_shared_and_static" "${Source}" ${Message}) +endmacro() + +static_variant_build_pass("return libshared_and_static_exported();" "Failed to build static variant") +shared_variant_build_pass("return libshared_and_static_exported();" "Failed to build shared variant") +# if (COMPILER_HAS_DEPRECATED) +# shared_variant_build_fail("return libshared_and_static_deprecated();" "Built shared deprecated variant") +# static_variant_build_fail("return libshared_and_static_deprecated();" "Built static deprecated variant") +# else() +# shared_variant_build_pass("return libshared_and_static_deprecated();" "Built shared deprecated variant") +# static_variant_build_pass("return libshared_and_static_deprecated();" "Built static deprecated variant") +# endif() +static_variant_build_pass("return libshared_and_static_not_exported();" "Failed to build static not exported variant") + +if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY) + shared_variant_build_fail("return libshared_and_static_not_exported();" "Built shared not exported variant") +else() + shared_variant_build_pass("return libshared_and_static_not_exported();" "Built shared not exported variant") +endif() diff --git a/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt new file mode 100644 index 000000000..e20adb1a7 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libshared/CMakeLists.txt @@ -0,0 +1,16 @@ + +cmake_minimum_required(VERSION 2.8) + +project(libshared) + +include(GenerateExportHeader) + +add_compiler_export_flags() + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_library(libshared SHARED libshared.cpp) + +generate_export_header(libshared) + +export(TARGETS libshared FILE Targets.cmake) diff --git a/Tests/Module/GenerateExportHeader/libshared/libshared.cpp b/Tests/Module/GenerateExportHeader/libshared/libshared.cpp new file mode 100644 index 000000000..d4041b36d --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libshared/libshared.cpp @@ -0,0 +1,91 @@ + +#include "libshared.h" + +int Libshared::libshared() const +{ + return 0; +} + +int Libshared::libshared_exported() const +{ + return 0; +} + +int Libshared::libshared_deprecated() const +{ + return 0; +} + +int Libshared::libshared_not_exported() const { + return 0; +} + +int Libshared::libshared_excluded() const { + return 0; +} + +int LibsharedNotExported::libshared() const +{ + return 0; +} + +int LibsharedNotExported::libshared_exported() const +{ + return 0; +} + +int LibsharedNotExported::libshared_deprecated() const +{ + return 0; +} + +int LibsharedNotExported::libshared_not_exported() const { + return 0; +} + +int LibsharedNotExported::libshared_excluded() const { + return 0; +} + +int LibsharedExcluded::libshared() const +{ + return 0; +} + +int LibsharedExcluded::libshared_exported() const +{ + return 0; +} + +int LibsharedExcluded::libshared_deprecated() const +{ + return 0; +} + +int LibsharedExcluded::libshared_not_exported() const { + return 0; +} + +int LibsharedExcluded::libshared_excluded() const { + return 0; +} + +int libshared() { + return 0; +} + +int libshared_exported() { + return 0; +} + +int libshared_deprecated() { + return 0; +} + +int libshared_not_exported() { + return 0; +} + +int libshared_excluded() { + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/libshared/libshared.h b/Tests/Module/GenerateExportHeader/libshared/libshared.h new file mode 100644 index 000000000..3d9bbff4f --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libshared/libshared.h @@ -0,0 +1,54 @@ + +#ifndef LIBSHARED_H +#define LIBSHARED_H + +#include "libshared_export.h" + +class LIBSHARED_EXPORT Libshared { +public: + int libshared() const; + + int libshared_exported() const; + + int LIBSHARED_DEPRECATED libshared_deprecated() const; + + int libshared_not_exported() const; + + int LIBSHARED_NO_EXPORT libshared_excluded() const; +}; + +class LibsharedNotExported { +public: + int libshared() const; + + int LIBSHARED_EXPORT libshared_exported() const; + + int LIBSHARED_DEPRECATED_EXPORT libshared_deprecated() const; + + int libshared_not_exported() const; + + int LIBSHARED_NO_EXPORT libshared_excluded() const; +}; + +class LIBSHARED_NO_EXPORT LibsharedExcluded { +public: + int libshared() const; + + int LIBSHARED_EXPORT libshared_exported() const; + + int LIBSHARED_DEPRECATED_EXPORT libshared_deprecated() const; + + int libshared_not_exported() const; + + int LIBSHARED_NO_EXPORT libshared_excluded() const; +}; + +LIBSHARED_EXPORT int libshared_exported(); + +LIBSHARED_DEPRECATED_EXPORT int libshared_deprecated(); + +int libshared_not_exported(); + +int LIBSHARED_NO_EXPORT libshared_excluded(); + +#endif diff --git a/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt new file mode 100644 index 000000000..a5804fcfb --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libsharedtest/CMakeLists.txt @@ -0,0 +1,44 @@ + +macro(shared_build_pass Source Message) + build_pass("libshared.h" "libshared" "libshared" "${Source}" ${Message}) +endmacro() + +macro(shared_build_fail Source Message) + build_fail("libshared.h" "libshared" "libshared" "${Source}" ${Message}) +endmacro() + +shared_build_pass("Libshared l; return l.libshared_exported();" "Failed to build exported") + +# if (COMPILER_HAS_DEPRECATED) +# shared_build_fail("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") +# else() +# shared_build_pass("Libshared l; return l.libshared_deprecated();" "Built use of deprecated class method. This should not be possible.") +# endif() +if (COMPILER_HAS_HIDDEN_VISIBILITY) + shared_build_fail("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") +else() + # There is no MSVC equivalent to hiding symbols. + shared_build_pass("Libshared l; return l.libshared_excluded();" "Built use of excluded class method. This is possible on MSVC.") +endif() + +if (WIN32 OR COMPILER_HAS_HIDDEN_VISIBILITY) + shared_build_fail("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method. This should not be possible.") + shared_build_fail("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method. This should not be possible.") + shared_build_fail("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method. This should not be possible.") + shared_build_fail("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method. This should not be possible.") + shared_build_fail("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method. This should not be possible.") + shared_build_fail("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method. This should not be possible.") + + shared_build_fail("return libshared_excluded();" "Built use of excluded function. This should not be possible.") + shared_build_fail("return libshared_not_exported();" "Built use of not-exported function. This should not be possible.") +else() + shared_build_pass("LibsharedNotExported l; return l.libshared();" "Built use of not-exported class method.") + shared_build_pass("LibsharedNotExported l; return l.libshared_not_exported();" "Built use of not-exported class method.") + shared_build_pass("LibsharedNotExported l; return l.libshared_excluded();" "Built use of not-exported class method.") + shared_build_pass("LibsharedExcluded l; return l.libshared();" "Built use of excluded class method.") + shared_build_pass("LibsharedExcluded l; return l.libshared_not_exported();" "Built use of excluded class method.") + shared_build_pass("LibsharedExcluded l; return l.libshared_excluded();" "Built use of excluded class method.") + + shared_build_pass("return libshared_excluded();" "Built use of excluded function.") + shared_build_pass("return libshared_not_exported();" "Built use of not-exported function.") +endif() diff --git a/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt new file mode 100644 index 000000000..b2db3ea74 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatic/CMakeLists.txt @@ -0,0 +1,18 @@ + +cmake_minimum_required(VERSION 2.8) + +project(libstatic) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +include(GenerateExportHeader) + +add_compiler_export_flags() + +# Show that the export header has no effect on a static library. + +add_library(libstatic STATIC libstatic.cpp) + +generate_export_header(libstatic) + +export(TARGETS libstatic FILE Targets.cmake) diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp b/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp new file mode 100644 index 000000000..0710c3e9e --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.cpp @@ -0,0 +1,87 @@ + +#include "libstatic.h" + +int Libstatic::libstatic() const +{ + return 0; +} + +int Libstatic::libstatic_exported() const +{ + return 0; +} + +int Libstatic::libstatic_deprecated() const +{ + return 0; +} + +int Libstatic::libstatic_not_exported() const { + return 0; +} + +int Libstatic::libstatic_excluded() const { + return 0; +} + +int LibstaticNotExported::libstatic() const +{ + return 0; +} + +int LibstaticNotExported::libstatic_exported() const +{ + return 0; +} + +int LibstaticNotExported::libstatic_deprecated() const +{ + return 0; +} + +int LibstaticNotExported::libstatic_not_exported() const { + return 0; +} + +int LibstaticNotExported::libstatic_excluded() const { + return 0; +} + +int LibstaticExcluded::libstatic() const +{ + return 0; +} + +int LibstaticExcluded::libstatic_exported() const +{ + return 0; +} + +int LibstaticExcluded::libstatic_deprecated() const +{ + return 0; +} + +int LibstaticExcluded::libstatic_not_exported() const { + return 0; +} + +int LibstaticExcluded::libstatic_excluded() const { + return 0; +} + +int libstatic_exported() { + return 0; +} + +int libstatic_deprecated() { + return 0; +} + +int libstatic_not_exported() { + return 0; +} + +int libstatic_excluded() { + return 0; +} diff --git a/Tests/Module/GenerateExportHeader/libstatic/libstatic.h b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h new file mode 100644 index 000000000..cc7a35b4e --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatic/libstatic.h @@ -0,0 +1,54 @@ + +#ifndef LIBSTATIC_H +#define LIBSTATIC_H + +#include "libstatic_export.h" + +class LIBSTATIC_EXPORT Libstatic { +public: + int libstatic() const; + + int libstatic_exported() const; + + int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + + int libstatic_not_exported() const; + + int LIBSTATIC_NO_EXPORT libstatic_excluded() const; +}; + +class LibstaticNotExported { +public: + int libstatic() const; + + int LIBSTATIC_EXPORT libstatic_exported() const; + + int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + + int libstatic_not_exported() const; + + int LIBSTATIC_NO_EXPORT libstatic_excluded() const; +}; + +class LIBSTATIC_NO_EXPORT LibstaticExcluded { +public: + int libstatic() const; + + int LIBSTATIC_EXPORT libstatic_exported() const; + + int LIBSTATIC_DEPRECATED libstatic_deprecated() const; + + int libstatic_not_exported() const; + + int LIBSTATIC_NO_EXPORT libstatic_excluded() const; +}; + +LIBSTATIC_EXPORT int libstatic_exported(); + +LIBSTATIC_DEPRECATED_EXPORT int libstatic_deprecated(); + +int libstatic_not_exported(); + +int LIBSTATIC_NO_EXPORT libstatic_excluded(); + +#endif diff --git a/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt new file mode 100644 index 000000000..eb6bb874c --- /dev/null +++ b/Tests/Module/GenerateExportHeader/libstatictest/CMakeLists.txt @@ -0,0 +1,18 @@ + +macro(static_build_pass Source Message) + build_pass("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message}) +endmacro() + +macro(static_build_fail Source Message) + build_fail("libstatic.h" "libstatic" "libstatic" "${Source}" ${Message}) +endmacro() + +static_build_pass("Libstatic l; return l.libstatic_exported();" "Failed to build exported.") + +# if (COMPILER_HAS_DEPRECATED) +# static_build_fail("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") +# static_build_fail("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") +# else() +# static_build_pass("Libstatic l; return l.libstatic_deprecated();" "Built use of deprecated class method. This should not be possible.") +# static_build_pass("libstatic_deprecated();" "Built use of deprecated function. This should not be possible.") +# endif() diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt new file mode 100644 index 000000000..aeeb13a85 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt @@ -0,0 +1,26 @@ +cmake_minimum_required(VERSION 2.8) + +project(nodeprecated) + +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined) + +configure_file(CMakeLists.txt.in ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined/CMakeLists.txt) +set(DEFINE_NO_DEPRECATED DEFINE_NO_DEPRECATED) +configure_file(CMakeLists.txt.in ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined/CMakeLists.txt) + +try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined_build + ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_not_defined + nodeprecated_test + OUTPUT_VARIABLE Out +) + +test_pass(Result "Failed to build without no-deprecated define") + +try_compile(Result ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined_build + ${CMAKE_CURRENT_BINARY_DIR}/nodeprecated_defined + nodeprecated_test + OUTPUT_VARIABLE Out +) + +test_fail(Result "Built even with no-deprecated define") \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt.in b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt.in new file mode 100644 index 000000000..d8dc482f3 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/CMakeLists.txt.in @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.8) + +project(nodeprecated_test) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +include(GenerateExportHeader) + +add_library(nodeprecatedlib SHARED someclass.cpp) + +generate_export_header(nodeprecatedlib @DEFINE_NO_DEPRECATED@) + +add_executable(nodeprecatedconsumer main.cpp) + +target_link_libraries(nodeprecatedconsumer nodeprecatedlib) diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp b/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp new file mode 100644 index 000000000..445a65204 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/src/main.cpp @@ -0,0 +1,9 @@ + +#include "someclass.h" + +int main(int, char**) +{ + SomeClass sc; + sc.someMethod(); + return 0; +} \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp new file mode 100644 index 000000000..a3f41111c --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.cpp @@ -0,0 +1,9 @@ + +#include "someclass.h" + +#ifndef NODEPRECATEDLIB_NO_DEPRECATED +void SomeClass::someMethod() const +{ + +} +#endif diff --git a/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.h b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.h new file mode 100644 index 000000000..312a177f1 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/nodeprecated/src/someclass.h @@ -0,0 +1,10 @@ + +#include "nodeprecatedlib_export.h" + +class NODEPRECATEDLIB_EXPORT SomeClass +{ +public: +#ifndef NODEPRECATEDLIB_NO_DEPRECATED + void someMethod() const; +#endif +}; diff --git a/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt new file mode 100644 index 000000000..aeeef20ee --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/CMakeLists.txt @@ -0,0 +1,11 @@ +project(override_symbol) + +add_library(somelib SHARED someclass.cpp) + +set_target_properties(somelib PROPERTIES DEFINE_SYMBOL SOMELIB_MAKEDLL) + +generate_export_header(somelib) + +add_executable(consumer main.cpp) + +target_link_libraries(consumer somelib) diff --git a/Tests/Module/GenerateExportHeader/override_symbol/main.cpp b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp new file mode 100644 index 000000000..445a65204 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/main.cpp @@ -0,0 +1,9 @@ + +#include "someclass.h" + +int main(int, char**) +{ + SomeClass sc; + sc.someMethod(); + return 0; +} \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp new file mode 100644 index 000000000..7326b780a --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/someclass.cpp @@ -0,0 +1,7 @@ + +#include "someclass.h" + +void SomeClass::someMethod() const +{ + +} \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/override_symbol/someclass.h b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h new file mode 100644 index 000000000..ae5e84454 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/override_symbol/someclass.h @@ -0,0 +1,8 @@ + +#include "somelib_export.h" + +class SOMELIB_EXPORT SomeClass +{ +public: + void someMethod() const; +}; diff --git a/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt b/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt new file mode 100644 index 000000000..bd64df283 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/prefix/CMakeLists.txt @@ -0,0 +1,15 @@ +project(use_prefix) + +set(use_prefix_lib_SRCS + useprefixclass.cpp +) + +add_library(use_prefix_lib SHARED useprefixclass.cpp) + +generate_export_header(use_prefix_lib + PREFIX_NAME MYPREFIX_ +) + +add_executable(use_prefix main.cpp) + +target_link_libraries(use_prefix use_prefix_lib) \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/prefix/main.cpp b/Tests/Module/GenerateExportHeader/prefix/main.cpp new file mode 100644 index 000000000..d04ae3c9c --- /dev/null +++ b/Tests/Module/GenerateExportHeader/prefix/main.cpp @@ -0,0 +1,8 @@ + +#include "useprefixclass.h" + +int main(int argc, char **argv) +{ + UsePrefixClass upc; + return upc.someMethod(); +} \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp new file mode 100644 index 000000000..8337ab845 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.cpp @@ -0,0 +1,7 @@ + +#include "useprefixclass.h" + +int UsePrefixClass::someMethod() const +{ + return 0; +} \ No newline at end of file diff --git a/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h new file mode 100644 index 000000000..f5e31b507 --- /dev/null +++ b/Tests/Module/GenerateExportHeader/prefix/useprefixclass.h @@ -0,0 +1,13 @@ + +#ifndef USEPREFIXCLASS_H +#define USEPREFIXCLASS_H + +#include "use_prefix_lib_export.h" + +class MYPREFIX_USE_PREFIX_LIB_EXPORT UsePrefixClass +{ +public: + int someMethod() const; +}; + +#endif diff --git a/Tests/Preprocess/CMakeLists.txt b/Tests/Preprocess/CMakeLists.txt index b4ec17c6b..1ed7b83ac 100644 --- a/Tests/Preprocess/CMakeLists.txt +++ b/Tests/Preprocess/CMakeLists.txt @@ -37,6 +37,9 @@ endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio") if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 10") set(PP_VS100 1) endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio 10") +if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 11") + set(PP_VS110 1) +endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio 11") # Some tests below check the PP_* variables set above. They are meant # to test the case that the build tool is at fault. Other tests below @@ -52,7 +55,7 @@ endif("${CMAKE_GENERATOR}" MATCHES "Visual Studio 10") # must not have it escaped inside the configured header. set(STRING_EXTRA "") -if(NOT BORLAND AND NOT PP_VS70 AND NOT PP_VS100) +if(NOT BORLAND AND NOT PP_VS70 AND NOT PP_VS100 AND NOT PP_VS110) # Borland, VS70 IDE: ; # The Borland compiler will simply not accept a non-escaped semicolon # on the command line. If it is escaped \; then the escape character diff --git a/Tests/Properties/CMakeLists.txt b/Tests/Properties/CMakeLists.txt index e0c752297..c1bc3b9e3 100644 --- a/Tests/Properties/CMakeLists.txt +++ b/Tests/Properties/CMakeLists.txt @@ -71,6 +71,24 @@ if (NOT TARGETRESULT) "Error: target result is TARGETRESULT=${TARGETRESULT}") endif (NOT TARGETRESULT) +# test APPEND and APPEND_STRING set_property() +set_property(TARGET Properties PROPERTY FOO foo) +set_property(TARGET Properties PROPERTY BAR bar) +set_property(TARGET Properties APPEND PROPERTY FOO 123) +set_property(TARGET Properties APPEND_STRING PROPERTY BAR 456) + +get_property(APPEND_RESULT TARGET Properties PROPERTY FOO) +if (NOT "${APPEND_RESULT}" STREQUAL "foo;123") + message(SEND_ERROR + "Error: target result is APPEND_RESULT=${APPEND_RESULT}") +endif () + +get_property(APPEND_STRING_RESULT TARGET Properties PROPERTY BAR) +if (NOT "${APPEND_STRING_RESULT}" STREQUAL "bar456") + message(SEND_ERROR + "Error: target result is APPEND_STRING_RESULT=${APPEND_STRING_RESULT}") +endif () + # test get_property SET get_property(TARGETRESULT TARGET Properties PROPERTY TARGETTEST SET) if (NOT TARGETRESULT) diff --git a/Tests/QtAutomoc/CMakeLists.txt b/Tests/QtAutomoc/CMakeLists.txt new file mode 100644 index 000000000..d255a5a7d --- /dev/null +++ b/Tests/QtAutomoc/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 2.8) + +project(QtAutomoc) + +find_package(Qt4 REQUIRED) + +include(UseQt4) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +add_definitions(-DFOO) + +# enable relaxed mode so automoc can handle all the special cases: +set(CMAKE_AUTOMOC_RELAXED_MODE TRUE) + +# create an executable and a library target, both requiring automoc: +add_library(codeeditorLib STATIC codeeditor.cpp) + +add_executable(foo main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp xyz.cpp yaf.cpp private_slot.cpp) + +set_target_properties(foo codeeditorLib PROPERTIES AUTOMOC TRUE) + +target_link_libraries(foo codeeditorLib ${QT_LIBRARIES} ) diff --git a/Tests/QtAutomoc/abc.cpp b/Tests/QtAutomoc/abc.cpp new file mode 100644 index 000000000..4bbc76905 --- /dev/null +++ b/Tests/QtAutomoc/abc.cpp @@ -0,0 +1,49 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + + +#include "abc.h" +#include "abc_p.h" + +#include + +class PrintAbc : public QObject +{ + Q_OBJECT + public: + PrintAbc():QObject() {} + public slots: + void print() const { printf("abc\n"); } +}; + +Abc::Abc() +:QObject() +{ +} + + +void Abc::doAbc() +{ + PrintAbc pa; + pa.print(); + AbcP abcP; + abcP.doAbcP(); +} + +// check that including the moc file for the cpp file and the header works: +#include "abc.moc" +#include "moc_abc.cpp" +#include "moc_abc_p.cpp" + +// check that including a moc file from another header works: +#include "moc_xyz.cpp" diff --git a/Tests/QtAutomoc/abc.h b/Tests/QtAutomoc/abc.h new file mode 100644 index 000000000..d1924b0da --- /dev/null +++ b/Tests/QtAutomoc/abc.h @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef ABC_H +#define ABC_H + +#include + +class Abc : public QObject +{ + Q_OBJECT + public: + Abc(); + public slots: + void doAbc(); +}; + +#endif diff --git a/Tests/QtAutomoc/abc_p.h b/Tests/QtAutomoc/abc_p.h new file mode 100644 index 000000000..952fff315 --- /dev/null +++ b/Tests/QtAutomoc/abc_p.h @@ -0,0 +1,30 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef ABC_P_H +#define ABC_P_H + +#include + +#include + +class AbcP : public QObject +{ + Q_OBJECT + public: + AbcP() {} + public slots: + void doAbcP() { printf("I am private abc !\n"); } +}; + +#endif diff --git a/Tests/QtAutomoc/bar.cpp b/Tests/QtAutomoc/bar.cpp new file mode 100644 index 000000000..8be48159d --- /dev/null +++ b/Tests/QtAutomoc/bar.cpp @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "sub/bar.h" + +#include + +Bar::Bar() +:QObject() +{ +} + +void Bar::doBar() +{ + printf("Hello bar !\n"); +} + +#include "sub/moc_bar.cpp" diff --git a/Tests/QtAutomoc/blub.cpp b/Tests/QtAutomoc/blub.cpp new file mode 100644 index 000000000..bd53972ac --- /dev/null +++ b/Tests/QtAutomoc/blub.cpp @@ -0,0 +1,40 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "blub.h" + +#include + +class BlubBlub : public QObject +{ + Q_OBJECT + public: + BlubBlub():QObject() {} + public slots: + int getValue() const { return 13; } +}; + +Blub::Blub() +{ +} + + +void Blub::blubber() +{ + BlubBlub bb; + printf("Blub blub %d ! \n", bb.getValue()); +} + +// test the case that the wrong moc-file is included, it should +// actually be "blub.moc" +#include "moc_blub.cpp" diff --git a/Tests/QtAutomoc/blub.h b/Tests/QtAutomoc/blub.h new file mode 100644 index 000000000..1967bc1ea --- /dev/null +++ b/Tests/QtAutomoc/blub.h @@ -0,0 +1,26 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef BLUB_H +#define BLUB_H + +#include + +class Blub +{ + public: + Blub(); + void blubber(); +}; + +#endif diff --git a/Tests/QtAutomoc/calwidget.cpp b/Tests/QtAutomoc/calwidget.cpp new file mode 100644 index 000000000..24f3b4efe --- /dev/null +++ b/Tests/QtAutomoc/calwidget.cpp @@ -0,0 +1,424 @@ +/**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + + #include + + #include "calwidget.h" + + Window::Window() + { + createPreviewGroupBox(); + createGeneralOptionsGroupBox(); + createDatesGroupBox(); + createTextFormatsGroupBox(); + + QGridLayout *layout = new QGridLayout; + layout->addWidget(previewGroupBox, 0, 0); + layout->addWidget(generalOptionsGroupBox, 0, 1); + layout->addWidget(datesGroupBox, 1, 0); + layout->addWidget(textFormatsGroupBox, 1, 1); + layout->setSizeConstraint(QLayout::SetFixedSize); + setLayout(layout); + + previewLayout->setRowMinimumHeight(0, calendar->sizeHint().height()); + previewLayout->setColumnMinimumWidth(0, calendar->sizeHint().width()); + + setWindowTitle(tr("Calendar Widget")); + } + + void Window::localeChanged(int index) + { + calendar->setLocale(localeCombo->itemData(index).toLocale()); + } + + void Window::firstDayChanged(int index) + { + calendar->setFirstDayOfWeek(Qt::DayOfWeek( + firstDayCombo->itemData(index).toInt())); + } + + void Window::selectionModeChanged(int index) + { + calendar->setSelectionMode(QCalendarWidget::SelectionMode( + selectionModeCombo->itemData(index).toInt())); + } + + void Window::horizontalHeaderChanged(int index) + { + calendar->setHorizontalHeaderFormat(QCalendarWidget::HorizontalHeaderFormat( + horizontalHeaderCombo->itemData(index).toInt())); + } + + void Window::verticalHeaderChanged(int index) + { + calendar->setVerticalHeaderFormat(QCalendarWidget::VerticalHeaderFormat( + verticalHeaderCombo->itemData(index).toInt())); + } + + void Window::selectedDateChanged() + { + currentDateEdit->setDate(calendar->selectedDate()); + } + + void Window::minimumDateChanged(const QDate &date) + { + calendar->setMinimumDate(date); + maximumDateEdit->setDate(calendar->maximumDate()); + } + + void Window::maximumDateChanged(const QDate &date) + { + calendar->setMaximumDate(date); + minimumDateEdit->setDate(calendar->minimumDate()); + } + + void Window::weekdayFormatChanged() + { + QTextCharFormat format; + + format.setForeground(qvariant_cast( + weekdayColorCombo->itemData(weekdayColorCombo->currentIndex()))); + calendar->setWeekdayTextFormat(Qt::Monday, format); + calendar->setWeekdayTextFormat(Qt::Tuesday, format); + calendar->setWeekdayTextFormat(Qt::Wednesday, format); + calendar->setWeekdayTextFormat(Qt::Thursday, format); + calendar->setWeekdayTextFormat(Qt::Friday, format); + } + + void Window::weekendFormatChanged() + { + QTextCharFormat format; + + format.setForeground(qvariant_cast( + weekendColorCombo->itemData(weekendColorCombo->currentIndex()))); + calendar->setWeekdayTextFormat(Qt::Saturday, format); + calendar->setWeekdayTextFormat(Qt::Sunday, format); + } + + void Window::reformatHeaders() + { + QString text = headerTextFormatCombo->currentText(); + QTextCharFormat format; + + if (text == tr("Bold")) { + format.setFontWeight(QFont::Bold); + } else if (text == tr("Italic")) { + format.setFontItalic(true); + } else if (text == tr("Green")) { + format.setForeground(Qt::green); + } + calendar->setHeaderTextFormat(format); + } + + void Window::reformatCalendarPage() + { + if (firstFridayCheckBox->isChecked()) { + QDate firstFriday(calendar->yearShown(), calendar->monthShown(), 1); + while (firstFriday.dayOfWeek() != Qt::Friday) + firstFriday = firstFriday.addDays(1); + QTextCharFormat firstFridayFormat; + firstFridayFormat.setForeground(Qt::blue); + calendar->setDateTextFormat(firstFriday, firstFridayFormat); + } + + //May First in Red takes precedence + if (mayFirstCheckBox->isChecked()) { + const QDate mayFirst(calendar->yearShown(), 5, 1); + QTextCharFormat mayFirstFormat; + mayFirstFormat.setForeground(Qt::red); + calendar->setDateTextFormat(mayFirst, mayFirstFormat); + } + } + + void Window::createPreviewGroupBox() + { + previewGroupBox = new QGroupBox(tr("Preview")); + + calendar = new QCalendarWidget; + calendar->setMinimumDate(QDate(1900, 1, 1)); + calendar->setMaximumDate(QDate(3000, 1, 1)); + calendar->setGridVisible(true); + + connect(calendar, SIGNAL(currentPageChanged(int,int)), + this, SLOT(reformatCalendarPage())); + + previewLayout = new QGridLayout; + previewLayout->addWidget(calendar, 0, 0, Qt::AlignCenter); + previewGroupBox->setLayout(previewLayout); + } + + void Window::createGeneralOptionsGroupBox() + { + generalOptionsGroupBox = new QGroupBox(tr("General Options")); + + localeCombo = new QComboBox; + int curLocaleIndex = -1; + int index = 0; + for (int _lang = QLocale::C; _lang <= QLocale::LastLanguage; ++_lang) { + QLocale::Language lang = static_cast(_lang); + QList countries = QLocale::countriesForLanguage(lang); + for (int i = 0; i < countries.count(); ++i) { + QLocale::Country country = countries.at(i); + QString label = QLocale::languageToString(lang); + label += QLatin1Char('/'); + label += QLocale::countryToString(country); + QLocale locale(lang, country); + if (this->locale().language() == lang && this->locale().country() == country) + curLocaleIndex = index; + localeCombo->addItem(label, locale); + ++index; + } + } + if (curLocaleIndex != -1) + localeCombo->setCurrentIndex(curLocaleIndex); + localeLabel = new QLabel(tr("&Locale")); + localeLabel->setBuddy(localeCombo); + + firstDayCombo = new QComboBox; + firstDayCombo->addItem(tr("Sunday"), Qt::Sunday); + firstDayCombo->addItem(tr("Monday"), Qt::Monday); + firstDayCombo->addItem(tr("Tuesday"), Qt::Tuesday); + firstDayCombo->addItem(tr("Wednesday"), Qt::Wednesday); + firstDayCombo->addItem(tr("Thursday"), Qt::Thursday); + firstDayCombo->addItem(tr("Friday"), Qt::Friday); + firstDayCombo->addItem(tr("Saturday"), Qt::Saturday); + + firstDayLabel = new QLabel(tr("Wee&k starts on:")); + firstDayLabel->setBuddy(firstDayCombo); + + selectionModeCombo = new QComboBox; + selectionModeCombo->addItem(tr("Single selection"), + QCalendarWidget::SingleSelection); + selectionModeCombo->addItem(tr("None"), QCalendarWidget::NoSelection); + + selectionModeLabel = new QLabel(tr("&Selection mode:")); + selectionModeLabel->setBuddy(selectionModeCombo); + + gridCheckBox = new QCheckBox(tr("&Grid")); + gridCheckBox->setChecked(calendar->isGridVisible()); + + navigationCheckBox = new QCheckBox(tr("&Navigation bar")); + navigationCheckBox->setChecked(true); + + horizontalHeaderCombo = new QComboBox; + horizontalHeaderCombo->addItem(tr("Single letter day names"), + QCalendarWidget::SingleLetterDayNames); + horizontalHeaderCombo->addItem(tr("Short day names"), + QCalendarWidget::ShortDayNames); + horizontalHeaderCombo->addItem(tr("None"), + QCalendarWidget::NoHorizontalHeader); + horizontalHeaderCombo->setCurrentIndex(1); + + horizontalHeaderLabel = new QLabel(tr("&Horizontal header:")); + horizontalHeaderLabel->setBuddy(horizontalHeaderCombo); + + verticalHeaderCombo = new QComboBox; + verticalHeaderCombo->addItem(tr("ISO week numbers"), + QCalendarWidget::ISOWeekNumbers); + verticalHeaderCombo->addItem(tr("None"), QCalendarWidget::NoVerticalHeader); + + verticalHeaderLabel = new QLabel(tr("&Vertical header:")); + verticalHeaderLabel->setBuddy(verticalHeaderCombo); + + connect(localeCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(localeChanged(int))); + connect(firstDayCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(firstDayChanged(int))); + connect(selectionModeCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(selectionModeChanged(int))); + connect(gridCheckBox, SIGNAL(toggled(bool)), + calendar, SLOT(setGridVisible(bool))); + connect(navigationCheckBox, SIGNAL(toggled(bool)), + calendar, SLOT(setNavigationBarVisible(bool))); + connect(horizontalHeaderCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(horizontalHeaderChanged(int))); + connect(verticalHeaderCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(verticalHeaderChanged(int))); + + QHBoxLayout *checkBoxLayout = new QHBoxLayout; + checkBoxLayout->addWidget(gridCheckBox); + checkBoxLayout->addStretch(); + checkBoxLayout->addWidget(navigationCheckBox); + + QGridLayout *outerLayout = new QGridLayout; + outerLayout->addWidget(localeLabel, 0, 0); + outerLayout->addWidget(localeCombo, 0, 1); + outerLayout->addWidget(firstDayLabel, 1, 0); + outerLayout->addWidget(firstDayCombo, 1, 1); + outerLayout->addWidget(selectionModeLabel, 2, 0); + outerLayout->addWidget(selectionModeCombo, 2, 1); + outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2); + outerLayout->addWidget(horizontalHeaderLabel, 4, 0); + outerLayout->addWidget(horizontalHeaderCombo, 4, 1); + outerLayout->addWidget(verticalHeaderLabel, 5, 0); + outerLayout->addWidget(verticalHeaderCombo, 5, 1); + generalOptionsGroupBox->setLayout(outerLayout); + + firstDayChanged(firstDayCombo->currentIndex()); + selectionModeChanged(selectionModeCombo->currentIndex()); + horizontalHeaderChanged(horizontalHeaderCombo->currentIndex()); + verticalHeaderChanged(verticalHeaderCombo->currentIndex()); + } + + void Window::createDatesGroupBox() + { + datesGroupBox = new QGroupBox(tr("Dates")); + + minimumDateEdit = new QDateEdit; + minimumDateEdit->setDisplayFormat("MMM d yyyy"); + minimumDateEdit->setDateRange(calendar->minimumDate(), + calendar->maximumDate()); + minimumDateEdit->setDate(calendar->minimumDate()); + + minimumDateLabel = new QLabel(tr("&Minimum Date:")); + minimumDateLabel->setBuddy(minimumDateEdit); + + currentDateEdit = new QDateEdit; + currentDateEdit->setDisplayFormat("MMM d yyyy"); + currentDateEdit->setDate(calendar->selectedDate()); + currentDateEdit->setDateRange(calendar->minimumDate(), + calendar->maximumDate()); + + currentDateLabel = new QLabel(tr("&Current Date:")); + currentDateLabel->setBuddy(currentDateEdit); + + maximumDateEdit = new QDateEdit; + maximumDateEdit->setDisplayFormat("MMM d yyyy"); + maximumDateEdit->setDateRange(calendar->minimumDate(), + calendar->maximumDate()); + maximumDateEdit->setDate(calendar->maximumDate()); + + maximumDateLabel = new QLabel(tr("Ma&ximum Date:")); + maximumDateLabel->setBuddy(maximumDateEdit); + + connect(currentDateEdit, SIGNAL(dateChanged(QDate)), + calendar, SLOT(setSelectedDate(QDate))); + connect(calendar, SIGNAL(selectionChanged()), + this, SLOT(selectedDateChanged())); + connect(minimumDateEdit, SIGNAL(dateChanged(QDate)), + this, SLOT(minimumDateChanged(QDate))); + connect(maximumDateEdit, SIGNAL(dateChanged(QDate)), + this, SLOT(maximumDateChanged(QDate))); + + QGridLayout *dateBoxLayout = new QGridLayout; + dateBoxLayout->addWidget(currentDateLabel, 1, 0); + dateBoxLayout->addWidget(currentDateEdit, 1, 1); + dateBoxLayout->addWidget(minimumDateLabel, 0, 0); + dateBoxLayout->addWidget(minimumDateEdit, 0, 1); + dateBoxLayout->addWidget(maximumDateLabel, 2, 0); + dateBoxLayout->addWidget(maximumDateEdit, 2, 1); + dateBoxLayout->setRowStretch(3, 1); + + datesGroupBox->setLayout(dateBoxLayout); + } + + void Window::createTextFormatsGroupBox() + { + textFormatsGroupBox = new QGroupBox(tr("Text Formats")); + + weekdayColorCombo = createColorComboBox(); + weekdayColorCombo->setCurrentIndex( + weekdayColorCombo->findText(tr("Black"))); + + weekdayColorLabel = new QLabel(tr("&Weekday color:")); + weekdayColorLabel->setBuddy(weekdayColorCombo); + + weekendColorCombo = createColorComboBox(); + weekendColorCombo->setCurrentIndex( + weekendColorCombo->findText(tr("Red"))); + + weekendColorLabel = new QLabel(tr("Week&end color:")); + weekendColorLabel->setBuddy(weekendColorCombo); + + headerTextFormatCombo = new QComboBox; + headerTextFormatCombo->addItem(tr("Bold")); + headerTextFormatCombo->addItem(tr("Italic")); + headerTextFormatCombo->addItem(tr("Plain")); + + headerTextFormatLabel = new QLabel(tr("&Header text:")); + headerTextFormatLabel->setBuddy(headerTextFormatCombo); + + firstFridayCheckBox = new QCheckBox(tr("&First Friday in blue")); + + mayFirstCheckBox = new QCheckBox(tr("May &1 in red")); + + connect(weekdayColorCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(weekdayFormatChanged())); + connect(weekendColorCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(weekendFormatChanged())); + connect(headerTextFormatCombo, SIGNAL(currentIndexChanged(QString)), + this, SLOT(reformatHeaders())); + connect(firstFridayCheckBox, SIGNAL(toggled(bool)), + this, SLOT(reformatCalendarPage())); + connect(mayFirstCheckBox, SIGNAL(toggled(bool)), + this, SLOT(reformatCalendarPage())); + + QHBoxLayout *checkBoxLayout = new QHBoxLayout; + checkBoxLayout->addWidget(firstFridayCheckBox); + checkBoxLayout->addStretch(); + checkBoxLayout->addWidget(mayFirstCheckBox); + + QGridLayout *outerLayout = new QGridLayout; + outerLayout->addWidget(weekdayColorLabel, 0, 0); + outerLayout->addWidget(weekdayColorCombo, 0, 1); + outerLayout->addWidget(weekendColorLabel, 1, 0); + outerLayout->addWidget(weekendColorCombo, 1, 1); + outerLayout->addWidget(headerTextFormatLabel, 2, 0); + outerLayout->addWidget(headerTextFormatCombo, 2, 1); + outerLayout->addLayout(checkBoxLayout, 3, 0, 1, 2); + textFormatsGroupBox->setLayout(outerLayout); + + weekdayFormatChanged(); + weekendFormatChanged(); + reformatHeaders(); + reformatCalendarPage(); + } + +QComboBox *Window::createColorComboBox() + { + QComboBox *comboBox = new QComboBox; + comboBox->addItem(tr("Red"), Qt::red); + comboBox->addItem(tr("Blue"), Qt::blue); + comboBox->addItem(tr("Black"), Qt::black); + comboBox->addItem(tr("Magenta"), Qt::magenta); + return comboBox; + } + +//#include "moc_calwidget.cpp" diff --git a/Tests/QtAutomoc/calwidget.h b/Tests/QtAutomoc/calwidget.h new file mode 100644 index 000000000..844738937 --- /dev/null +++ b/Tests/QtAutomoc/calwidget.h @@ -0,0 +1,121 @@ + /**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + +#ifndef WINDOW_H +#define WINDOW_H + +#include + + class QCalendarWidget; + class QCheckBox; + class QComboBox; + class QDate; + class QDateEdit; + class QGridLayout; + class QGroupBox; + class QLabel; + + class Window : public QWidget + { + Q_OBJECT + + public: + Window(); + + private slots: + void localeChanged(int index); + void firstDayChanged(int index); + void selectionModeChanged(int index); + void horizontalHeaderChanged(int index); + void verticalHeaderChanged(int index); + void selectedDateChanged(); + void minimumDateChanged(const QDate &date); + void maximumDateChanged(const QDate &date); + void weekdayFormatChanged(); + void weekendFormatChanged(); + void reformatHeaders(); + void reformatCalendarPage(); + + private: + void createPreviewGroupBox(); + void createGeneralOptionsGroupBox(); + void createDatesGroupBox(); + void createTextFormatsGroupBox(); + QComboBox *createColorComboBox(); + + QGroupBox *previewGroupBox; + QGridLayout *previewLayout; + QCalendarWidget *calendar; + + QGroupBox *generalOptionsGroupBox; + QLabel *localeLabel; + QLabel *firstDayLabel; + QLabel *selectionModeLabel; + QLabel *horizontalHeaderLabel; + QLabel *verticalHeaderLabel; + QComboBox *localeCombo; + QComboBox *firstDayCombo; + QComboBox *selectionModeCombo; + QCheckBox *gridCheckBox; + QCheckBox *navigationCheckBox; + QComboBox *horizontalHeaderCombo; + QComboBox *verticalHeaderCombo; + + QGroupBox *datesGroupBox; + QLabel *currentDateLabel; + QLabel *minimumDateLabel; + QLabel *maximumDateLabel; + QDateEdit *currentDateEdit; + QDateEdit *minimumDateEdit; + QDateEdit *maximumDateEdit; + + QGroupBox *textFormatsGroupBox; + QLabel *weekdayColorLabel; + QLabel *weekendColorLabel; + QLabel *headerTextFormatLabel; + QComboBox *weekdayColorCombo; + QComboBox *weekendColorCombo; + QComboBox *headerTextFormatCombo; + + QCheckBox *firstFridayCheckBox; + QCheckBox *mayFirstCheckBox; + }; + + #endif diff --git a/Tests/QtAutomoc/codeeditor.cpp b/Tests/QtAutomoc/codeeditor.cpp new file mode 100644 index 000000000..01da06276 --- /dev/null +++ b/Tests/QtAutomoc/codeeditor.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + + #include + + #include "codeeditor.h" + + + CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent) + { + lineNumberArea = new LineNumberArea(this); + + connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); + connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); + connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); + + updateLineNumberAreaWidth(0); + highlightCurrentLine(); + } + + + + int CodeEditor::lineNumberAreaWidth() + { + int digits = 1; + int max = qMax(1, blockCount()); + while (max >= 10) { + max /= 10; + ++digits; + } + + int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits; + + return space; + } + + + + void CodeEditor::updateLineNumberAreaWidth(int /* newBlockCount */) + { + setViewportMargins(lineNumberAreaWidth(), 0, 0, 0); + } + + + + void CodeEditor::updateLineNumberArea(const QRect &rect, int dy) + { + if (dy) + lineNumberArea->scroll(0, dy); + else + lineNumberArea->update(0, rect.y(), lineNumberArea->width(), rect.height()); + + if (rect.contains(viewport()->rect())) + updateLineNumberAreaWidth(0); + } + + + + void CodeEditor::resizeEvent(QResizeEvent *e) + { + QPlainTextEdit::resizeEvent(e); + + QRect cr = contentsRect(); + lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height())); + } + + + + void CodeEditor::highlightCurrentLine() + { + QList extraSelections; + + if (!isReadOnly()) { + QTextEdit::ExtraSelection selection; + + QColor lineColor = QColor(Qt::yellow).lighter(160); + + selection.format.setBackground(lineColor); + selection.format.setProperty(QTextFormat::FullWidthSelection, true); + selection.cursor = textCursor(); + selection.cursor.clearSelection(); + extraSelections.append(selection); + } + + setExtraSelections(extraSelections); + } + + + + void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) + { + QPainter painter(lineNumberArea); + painter.fillRect(event->rect(), Qt::lightGray); + + + QTextBlock block = firstVisibleBlock(); + int blockNumber = block.blockNumber(); + int top = (int) blockBoundingGeometry(block).translated(contentOffset()).top(); + int bottom = top + (int) blockBoundingRect(block).height(); + + while (block.isValid() && top <= event->rect().bottom()) { + if (block.isVisible() && bottom >= event->rect().top()) { + QString number = QString::number(blockNumber + 1); + painter.setPen(Qt::black); + painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(), + Qt::AlignRight, number); + } + + block = block.next(); + top = bottom; + bottom = top + (int) blockBoundingRect(block).height(); + ++blockNumber; + } + } + +#include "codeeditor.moc" diff --git a/Tests/QtAutomoc/codeeditor.h b/Tests/QtAutomoc/codeeditor.h new file mode 100644 index 000000000..56e9e7923 --- /dev/null +++ b/Tests/QtAutomoc/codeeditor.h @@ -0,0 +1,99 @@ + /**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + + #ifndef CODEEDITOR_H + #define CODEEDITOR_H + + #include + #include + + class QPaintEvent; + class QResizeEvent; + class QSize; + class QWidget; + + class LineNumberArea; + + + class CodeEditor : public QPlainTextEdit + { + Q_OBJECT + + public: + CodeEditor(QWidget *parent = 0); + + void lineNumberAreaPaintEvent(QPaintEvent *event); + int lineNumberAreaWidth(); + + protected: + void resizeEvent(QResizeEvent *event); + + private slots: + void updateLineNumberAreaWidth(int newBlockCount); + void highlightCurrentLine(); + void updateLineNumberArea(const QRect &, int); + + private: + QWidget *lineNumberArea; + }; + + + class LineNumberArea : public QWidget + { + public: + LineNumberArea(CodeEditor *editor) : QWidget(editor) { + codeEditor = editor; + } + + QSize sizeHint() const { + return QSize(codeEditor->lineNumberAreaWidth(), 0); + } + + protected: + void paintEvent(QPaintEvent *event) { + codeEditor->lineNumberAreaPaintEvent(event); + } + + private: + CodeEditor *codeEditor; + }; + + + #endif diff --git a/Tests/QtAutomoc/foo.cpp b/Tests/QtAutomoc/foo.cpp new file mode 100644 index 000000000..699ba094b --- /dev/null +++ b/Tests/QtAutomoc/foo.cpp @@ -0,0 +1,39 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#include "foo.h" + +#include + +class FooFoo : public QObject +{ + Q_OBJECT + public: + FooFoo():QObject() {} + public slots: + int getValue() const { return 12; } +}; + +Foo::Foo() +:QObject() +{ +} + + +void Foo::doFoo() +{ + FooFoo ff; + printf("Hello automoc: %d\n", ff.getValue()); +} + +#include "foo.moc" diff --git a/Tests/QtAutomoc/foo.h b/Tests/QtAutomoc/foo.h new file mode 100644 index 000000000..32d4c8d8f --- /dev/null +++ b/Tests/QtAutomoc/foo.h @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef FOO_H +#define FOO_H + +#include + +class Foo : public QObject +{ + Q_OBJECT + public: + Foo(); + public slots: + void doFoo(); +}; + +#endif diff --git a/Tests/QtAutomoc/main.cpp b/Tests/QtAutomoc/main.cpp new file mode 100644 index 000000000..738f67720 --- /dev/null +++ b/Tests/QtAutomoc/main.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** + ** + ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + ** All rights reserved. + ** Contact: Nokia Corporation (qt-info@nokia.com) + ** + ** This file is part of the examples of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:BSD$ + ** You may use this file under the terms of the BSD license as follows: + ** + ** "Redistribution and use in source and binary forms, with or without + ** modification, are permitted provided that the following conditions are + ** met: + ** * Redistributions of source code must retain the above copyright + ** notice, this list of conditions and the following disclaimer. + ** * Redistributions in binary form must reproduce the above copyright + ** notice, this list of conditions and the following disclaimer in + ** the documentation and/or other materials provided with the + ** distribution. + ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor + ** the names of its contributors may be used to endorse or promote + ** products derived from this software without specific prior written + ** permission. + ** + ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + +#include + +#include "codeeditor.h" +#include "calwidget.h" +#include "foo.h" +#include "blub.h" +#include "sub/bar.h" +#include "abc.h" +#include "xyz.h" +#include "yaf.h" + +int main(int argv, char **args) +{ + QApplication app(argv, args); + + CodeEditor editor; + editor.setWindowTitle(QObject::tr("Code Editor Example")); + editor.show(); + + Window w; + w.show(); + + Foo foo; + foo.doFoo(); + + Blub b; + b.blubber(); + + Bar bar; + bar.doBar(); + + Abc abc; + abc.doAbc(); + + Xyz xyz; + xyz.doXyz(); + + Yaf yaf; + yaf.doYaf(); + + return app.exec(); +} diff --git a/Tests/QtAutomoc/private_slot.cpp b/Tests/QtAutomoc/private_slot.cpp new file mode 100644 index 000000000..1387a70cf --- /dev/null +++ b/Tests/QtAutomoc/private_slot.cpp @@ -0,0 +1,21 @@ + +#include "private_slot.h" + +class PrivateSlotPrivate +{ +public: + + void privateSlot() + { + + } +}; + +PrivateSlot::PrivateSlot(QObject *parent) + : QObject(parent), + d(new PrivateSlotPrivate) +{ + +} + +#include "private_slot.moc" diff --git a/Tests/QtAutomoc/private_slot.h b/Tests/QtAutomoc/private_slot.h new file mode 100644 index 000000000..28e54482a --- /dev/null +++ b/Tests/QtAutomoc/private_slot.h @@ -0,0 +1,20 @@ + +#ifndef PRIVATE_SLOT_H +#define PRIVATE_SLOT_H + +#include + +class PrivateSlotPrivate; + +class PrivateSlot : public QObject +{ + Q_OBJECT +public: + PrivateSlot(QObject *parent = 0); + +private: + PrivateSlotPrivate * const d; + Q_PRIVATE_SLOT(d, void privateSlot()) +}; + +#endif diff --git a/Tests/QtAutomoc/sub/bar.h b/Tests/QtAutomoc/sub/bar.h new file mode 100644 index 000000000..db56b8ed5 --- /dev/null +++ b/Tests/QtAutomoc/sub/bar.h @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef BAR_H +#define BAR_H + +#include + +class Bar : public QObject +{ + Q_OBJECT + public: + Bar(); + public slots: + void doBar(); +}; + +#endif diff --git a/Tests/QtAutomoc/xyz.cpp b/Tests/QtAutomoc/xyz.cpp new file mode 100644 index 000000000..a3562a337 --- /dev/null +++ b/Tests/QtAutomoc/xyz.cpp @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + + +#include "xyz.h" + +#include + +Xyz::Xyz() +:QObject() +{ +} + + +void Xyz::doXyz() +{ + printf("This is xyz !\n"); +} diff --git a/Tests/QtAutomoc/xyz.h b/Tests/QtAutomoc/xyz.h new file mode 100644 index 000000000..8175d3792 --- /dev/null +++ b/Tests/QtAutomoc/xyz.h @@ -0,0 +1,28 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef XYZ_H +#define XYZ_H + +#include + +class Xyz : public QObject +{ + Q_OBJECT + public: + Xyz(); + public slots: + void doXyz(); +}; + +#endif diff --git a/Tests/QtAutomoc/yaf.cpp b/Tests/QtAutomoc/yaf.cpp new file mode 100644 index 000000000..d278ab422 --- /dev/null +++ b/Tests/QtAutomoc/yaf.cpp @@ -0,0 +1,32 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + + +#include "yaf.h" +#include "yaf_p.h" + +#include + +Yaf::Yaf() +{ +} + + +void Yaf::doYaf() +{ + YafP yafP; + yafP.doYafP(); +} + +// check that including a moc file from a private header the wrong way works: +#include "yaf_p.moc" diff --git a/Tests/QtAutomoc/yaf.h b/Tests/QtAutomoc/yaf.h new file mode 100644 index 000000000..8689f8308 --- /dev/null +++ b/Tests/QtAutomoc/yaf.h @@ -0,0 +1,25 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef YAF_H +#define YAF_H + +class Yaf +{ + public: + Yaf(); + public: + void doYaf(); +}; + +#endif diff --git a/Tests/QtAutomoc/yaf_p.h b/Tests/QtAutomoc/yaf_p.h new file mode 100644 index 000000000..f0368ade1 --- /dev/null +++ b/Tests/QtAutomoc/yaf_p.h @@ -0,0 +1,30 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2011 Kitware, Inc. + Copyright 2011 Alexander Neundorf (neundorf@kde.org) + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef YAF_P_H +#define YAF_P_H + +#include + +#include + +class YafP : public QObject +{ + Q_OBJECT + public: + YafP() {} + public slots: + void doYafP() { printf("I am yet another file !\n"); } +}; + +#endif diff --git a/Tests/SimpleInstall/CMakeLists.txt b/Tests/SimpleInstall/CMakeLists.txt index 564db9ff1..378b5292b 100644 --- a/Tests/SimpleInstall/CMakeLists.txt +++ b/Tests/SimpleInstall/CMakeLists.txt @@ -173,6 +173,12 @@ ELSE(STAGE2) TARGET_LINK_LIBRARIES(SimpleInstall test1 test2 test4) SET(install_target SimpleInstall) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) + # Disable VERSION test until it is implemented in the Xcode generator. + IF(NOT XCODE) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) + ENDIF(NOT XCODE) + # Make sure the test executable can run from the install tree. SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) @@ -293,11 +299,6 @@ ELSE(STAGE2) ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_INSTALL_PREFIX}/InstallScriptOut.cmake;${CMAKE_INSTALL_PREFIX}/InstallScript4Out.cmake") - SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) - # Disable VERSION test until it is implemented in the Xcode generator. - IF(NOT XCODE) - SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) - ENDIF(NOT XCODE) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT diff --git a/Tests/SimpleInstallS2/CMakeLists.txt b/Tests/SimpleInstallS2/CMakeLists.txt index 564db9ff1..378b5292b 100644 --- a/Tests/SimpleInstallS2/CMakeLists.txt +++ b/Tests/SimpleInstallS2/CMakeLists.txt @@ -173,6 +173,12 @@ ELSE(STAGE2) TARGET_LINK_LIBRARIES(SimpleInstall test1 test2 test4) SET(install_target SimpleInstall) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) + # Disable VERSION test until it is implemented in the Xcode generator. + IF(NOT XCODE) + SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) + ENDIF(NOT XCODE) + # Make sure the test executable can run from the install tree. SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib) @@ -293,11 +299,6 @@ ELSE(STAGE2) ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_INSTALL_PREFIX}/InstallScriptOut.cmake;${CMAKE_INSTALL_PREFIX}/InstallScript4Out.cmake") - SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES OUTPUT_NAME SimpleInstExe) - # Disable VERSION test until it is implemented in the Xcode generator. - IF(NOT XCODE) - SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES VERSION 1.2) - ENDIF(NOT XCODE) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake) SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT diff --git a/Tests/VSExternalInclude/CMakeLists.txt b/Tests/VSExternalInclude/CMakeLists.txt index 1e6896801..a2fd61973 100644 --- a/Tests/VSExternalInclude/CMakeLists.txt +++ b/Tests/VSExternalInclude/CMakeLists.txt @@ -6,7 +6,7 @@ IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6") ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio 6") SET(PROJECT_EXT vcproj) ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6") -IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 10") +IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[01]") SET(PROJECT_EXT vcxproj) ENDIF() @@ -46,7 +46,7 @@ ADD_DEPENDENCIES(VSExternalInclude lib2) # and the sln file can no longer be the only source # of that depend. So, for VS 10 make the executable # depend on lib1 and lib2 -IF(MSVC10) +IF(MSVC10 OR MSVC11) ADD_DEPENDENCIES(VSExternalInclude lib1) ENDIF() diff --git a/Tests/VSResource/CMakeLists.txt b/Tests/VSResource/CMakeLists.txt index 5d7d14e5e..c5cb336ae 100644 --- a/Tests/VSResource/CMakeLists.txt +++ b/Tests/VSResource/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.3.20110118) +cmake_minimum_required(VERSION 2.8.4) project(VSResource) string(REPLACE "/INCREMENTAL:YES" "" @@ -35,3 +35,6 @@ else() endif() add_executable(VSResource main.cpp test.rc) + +set_property(TARGET VSResource + PROPERTY VS_GLOBAL_CMakeTestVsGlobalVariable "test val") diff --git a/Tests/iOSNavApp/CMakeLists.txt b/Tests/iOSNavApp/CMakeLists.txt new file mode 100644 index 000000000..12c3ada35 --- /dev/null +++ b/Tests/iOSNavApp/CMakeLists.txt @@ -0,0 +1,38 @@ +cmake_minimum_required(VERSION 2.8.5) +project(NavApp3) + +set(CMAKE_OSX_SYSROOT iphoneos4.3) +set(CMAKE_OSX_ARCHITECTURES "armv6;armv7;i386") +set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator") + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/Classes + ) + +add_library(Functions STATIC TotalFunction.c TotalFunction.h) + +set(M_SRCS main.m Classes/NavApp3AppDelegate.m Classes/RootViewController.m) +set(HEADERS Classes/NavApp3AppDelegate.h Classes/RootViewController.h) +set(RESOURCES MainWindow.xib RootViewController.xib) + +add_executable(NavApp3 MACOSX_BUNDLE ${M_SRCS} ${HEADERS} ${RESOURCES}) + +target_link_libraries(NavApp3 + Functions + "-framework CoreGraphics" + "-framework Foundation" + "-framework UIKit" + ) + +set_target_properties(NavApp3 PROPERTIES + MACOSX_BUNDLE_GUI_IDENTIFIER "com.yourcompany.NavApp3" + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in + RESOURCE "${RESOURCES}" + XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "iPhone Developer" + XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym" + XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER YES + XCODE_ATTRIBUTE_GCC_PREFIX_HEADER ${CMAKE_CURRENT_LIST_DIR}/NavApp3_Prefix.pch + XCODE_ATTRIBUTE_INFOPLIST_PREPROCESS YES + XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 3.0 + ) diff --git a/Tests/iOSNavApp/Classes/NavApp3AppDelegate.h b/Tests/iOSNavApp/Classes/NavApp3AppDelegate.h new file mode 100644 index 000000000..f1234fe8b --- /dev/null +++ b/Tests/iOSNavApp/Classes/NavApp3AppDelegate.h @@ -0,0 +1,20 @@ +// +// NavApp3AppDelegate.h +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import + +@interface NavApp3AppDelegate : NSObject { + + UIWindow *window; + UINavigationController *navigationController; +} + +@property (nonatomic, retain) IBOutlet UIWindow *window; +@property (nonatomic, retain) IBOutlet UINavigationController *navigationController; + +@end diff --git a/Tests/iOSNavApp/Classes/NavApp3AppDelegate.m b/Tests/iOSNavApp/Classes/NavApp3AppDelegate.m new file mode 100644 index 000000000..c82204c11 --- /dev/null +++ b/Tests/iOSNavApp/Classes/NavApp3AppDelegate.m @@ -0,0 +1,88 @@ +// +// NavApp3AppDelegate.m +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import "NavApp3AppDelegate.h" +#import "RootViewController.h" + + +@implementation NavApp3AppDelegate + +@synthesize window; +@synthesize navigationController; + + +#pragma mark - +#pragma mark Application lifecycle + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + + // Override point for customization after application launch. + // Add the navigation controller's view to the window and display. + [self.window addSubview:navigationController.view]; + [self.window makeKeyAndVisible]; + + return YES; +} + + +- (void)applicationWillResignActive:(UIApplication *)application { + /* + Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + */ +} + + +- (void)applicationDidEnterBackground:(UIApplication *)application { + /* + Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + If your application supports background execution, called instead of applicationWillTerminate: when the user quits. + */ +} + + +- (void)applicationWillEnterForeground:(UIApplication *)application { + /* + Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background. + */ +} + + +- (void)applicationDidBecomeActive:(UIApplication *)application { + /* + Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + */ +} + + +- (void)applicationWillTerminate:(UIApplication *)application { + /* + Called when the application is about to terminate. + See also applicationDidEnterBackground:. + */ +} + + +#pragma mark - +#pragma mark Memory management + +- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { + /* + Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. + */ +} + + +- (void)dealloc { + [navigationController release]; + [window release]; + [super dealloc]; +} + + +@end diff --git a/Tests/iOSNavApp/Classes/RootViewController.h b/Tests/iOSNavApp/Classes/RootViewController.h new file mode 100644 index 000000000..c5e9c1148 --- /dev/null +++ b/Tests/iOSNavApp/Classes/RootViewController.h @@ -0,0 +1,14 @@ +// +// RootViewController.h +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import + +@interface RootViewController : UITableViewController { +} + +@end diff --git a/Tests/iOSNavApp/Classes/RootViewController.m b/Tests/iOSNavApp/Classes/RootViewController.m new file mode 100644 index 000000000..8a20d89db --- /dev/null +++ b/Tests/iOSNavApp/Classes/RootViewController.m @@ -0,0 +1,168 @@ +// +// RootViewController.m +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import "RootViewController.h" + +#include "TotalFunction.h" + + +@implementation RootViewController + + +#pragma mark - +#pragma mark View lifecycle + +/* +- (void)viewDidLoad { + [super viewDidLoad]; + + // Uncomment the following line to display an Edit button in the navigation bar for this view controller. + // self.navigationItem.rightBarButtonItem = self.editButtonItem; +} +*/ + +/* +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; +} +*/ +/* +- (void)viewDidAppear:(BOOL)animated { + [super viewDidAppear:animated]; +} +*/ +/* +- (void)viewWillDisappear:(BOOL)animated { + [super viewWillDisappear:animated]; +} +*/ +/* +- (void)viewDidDisappear:(BOOL)animated { + [super viewDidDisappear:animated]; +} +*/ + +/* + // Override to allow orientations other than the default portrait orientation. +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { + // Return YES for supported orientations. + return (interfaceOrientation == UIInterfaceOrientationPortrait); +} + */ + + +#pragma mark - +#pragma mark Table view data source + +// Customize the number of sections in the table view. +- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { + return 1; +} + + +// Customize the number of rows in the table view. +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + int n = Total("numberOfRows"); + return n; +} + + +// Customize the appearance of table view cells. +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + + static NSString *CellIdentifier = @"Cell"; + + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + if (cell == nil) { + cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; + } + + // Configure the cell. + cell.textLabel.text = [NSString stringWithFormat:@"%d", [indexPath row]]; + + return cell; +} + + +/* +// Override to support conditional editing of the table view. +- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the specified item to be editable. + return YES; +} +*/ + + +/* +// Override to support editing the table view. +- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { + + if (editingStyle == UITableViewCellEditingStyleDelete) { + // Delete the row from the data source. + [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; + } + else if (editingStyle == UITableViewCellEditingStyleInsert) { + // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. + } +} +*/ + + +/* +// Override to support rearranging the table view. +- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { +} +*/ + + +/* +// Override to support conditional rearranging of the table view. +- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { + // Return NO if you do not want the item to be re-orderable. + return YES; +} +*/ + + +#pragma mark - +#pragma mark Table view delegate + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + + /* + <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; + // ... + // Pass the selected object to the new view controller. + [self.navigationController pushViewController:detailViewController animated:YES]; + [detailViewController release]; + */ +} + + +#pragma mark - +#pragma mark Memory management + +- (void)didReceiveMemoryWarning { + // Releases the view if it doesn't have a superview. + [super didReceiveMemoryWarning]; + + // Relinquish ownership any cached data, images, etc that aren't in use. +} + +- (void)viewDidUnload { + // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand. + // For example: self.myOutlet = nil; +} + + +- (void)dealloc { + [super dealloc]; +} + + +@end diff --git a/Tests/iOSNavApp/Info.plist.in b/Tests/iOSNavApp/Info.plist.in new file mode 100644 index 000000000..6ea0f00ee --- /dev/null +++ b/Tests/iOSNavApp/Info.plist.in @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleDisplayName + NavApp3 + CFBundleExecutable + NavApp3 + CFBundleIconFile + + CFBundleIdentifier + com.yourcompany.NavApp3 + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + NavApp3 + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + LSRequiresIPhoneOS + + NSMainNibFile + MainWindow + UISupportedInterfaceOrientations + + + diff --git a/Tests/iOSNavApp/MainWindow.xib b/Tests/iOSNavApp/MainWindow.xib new file mode 100644 index 000000000..1ff5f67fc --- /dev/null +++ b/Tests/iOSNavApp/MainWindow.xib @@ -0,0 +1,542 @@ + + + + 1024 + 10D571 + 786 + 1038.29 + 460.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 112 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + IBCocoaTouchFramework + + + + 1316 + + {320, 480} + + 1 + MSAxIDEAA + + NO + NO + + IBCocoaTouchFramework + YES + + + + + 1 + + IBCocoaTouchFramework + NO + + + 256 + {0, 0} + NO + YES + YES + IBCocoaTouchFramework + + + YES + + + + IBCocoaTouchFramework + + + RootViewController + + + 1 + + IBCocoaTouchFramework + NO + + + + + + + YES + + + delegate + + + + 4 + + + + window + + + + 5 + + + + navigationController + + + + 15 + + + + + YES + + 0 + + + + + + 2 + + + YES + + + + + -1 + + + File's Owner + + + 3 + + + + + -2 + + + + + 9 + + + YES + + + + + + + 11 + + + + + 13 + + + YES + + + + + + 14 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 11.IBPluginDependency + 13.CustomClassName + 13.IBPluginDependency + 2.IBAttributePlaceholdersKey + 2.IBEditorWindowLastContentRect + 2.IBPluginDependency + 3.CustomClassName + 3.IBPluginDependency + 9.IBEditorWindowLastContentRect + 9.IBPluginDependency + + + YES + UIApplication + UIResponder + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + RootViewController + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + YES + + + YES + + + {{673, 376}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + NavApp3AppDelegate + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + {{186, 376}, {320, 480}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 16 + + + + YES + + RootViewController + UITableViewController + + IBProjectSource + Classes/RootViewController.h + + + + UIWindow + UIView + + IBUserSource + + + + + NavApp3AppDelegate + NSObject + + YES + + YES + navigationController + window + + + YES + UINavigationController + UIWindow + + + + YES + + YES + navigationController + window + + + YES + + navigationController + UINavigationController + + + window + UIWindow + + + + + IBProjectSource + Classes/NavApp3AppDelegate.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIApplication + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIApplication.h + + + + UIBarButtonItem + UIBarItem + + IBFrameworkSource + UIKit.framework/Headers/UIBarButtonItem.h + + + + UIBarItem + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIBarItem.h + + + + UINavigationBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UINavigationBar.h + + + + UINavigationController + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UINavigationItem + NSObject + + + + UIResponder + NSObject + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UITableViewController + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITableViewController.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UIPopoverController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UISplitViewController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + UIWindow + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIWindow.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + NavApp3.xcodeproj + 3 + 112 + + diff --git a/Tests/iOSNavApp/NavApp3_Prefix.pch b/Tests/iOSNavApp/NavApp3_Prefix.pch new file mode 100644 index 000000000..9919f3076 --- /dev/null +++ b/Tests/iOSNavApp/NavApp3_Prefix.pch @@ -0,0 +1,14 @@ +// +// Prefix header for all source files of the 'NavApp3' target in the 'NavApp3' project +// +#import + +#ifndef __IPHONE_3_0 +#warning "This project uses features only available in iPhone SDK 3.0 and later." +#endif + + +#ifdef __OBJC__ + #import + #import +#endif diff --git a/Tests/iOSNavApp/RootViewController.xib b/Tests/iOSNavApp/RootViewController.xib new file mode 100644 index 000000000..12a4831f2 --- /dev/null +++ b/Tests/iOSNavApp/RootViewController.xib @@ -0,0 +1,384 @@ + + + + 784 + 10D541 + 760 + 1038.29 + 460.00 + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + 81 + + + YES + + + + YES + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + YES + + YES + + + YES + + + + YES + + IBFilesOwner + IBCocoaTouchFramework + + + IBFirstResponder + IBCocoaTouchFramework + + + + 274 + {320, 247} + + + 3 + MQA + + NO + YES + NO + IBCocoaTouchFramework + NO + 1 + 0 + YES + 44 + 22 + 22 + + + + + YES + + + view + + + + 3 + + + + dataSource + + + + 4 + + + + delegate + + + + 5 + + + + + YES + + 0 + + + + + + -1 + + + File's Owner + + + -2 + + + + + 2 + + + + + + + YES + + YES + -1.CustomClassName + -2.CustomClassName + 2.IBEditorWindowLastContentRect + 2.IBPluginDependency + + + YES + RootViewController + UIResponder + {{144, 609}, {320, 247}} + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + YES + + + YES + + + + + YES + + + YES + + + + 5 + + + + YES + + RootViewController + UITableViewController + + IBProjectSource + Classes/RootViewController.h + + + + + YES + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSError.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSFileManager.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueCoding.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyValueObserving.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSKeyedArchiver.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSNetServices.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSObject.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSPort.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSRunLoop.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSStream.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSThread.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURL.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSURLConnection.h + + + + NSObject + + IBFrameworkSource + Foundation.framework/Headers/NSXMLParser.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIAccessibility.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UINibLoading.h + + + + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UIResponder.h + + + + UIResponder + NSObject + + + + UIScrollView + UIView + + IBFrameworkSource + UIKit.framework/Headers/UIScrollView.h + + + + UISearchBar + UIView + + IBFrameworkSource + UIKit.framework/Headers/UISearchBar.h + + + + UISearchDisplayController + NSObject + + IBFrameworkSource + UIKit.framework/Headers/UISearchDisplayController.h + + + + UITableView + UIScrollView + + IBFrameworkSource + UIKit.framework/Headers/UITableView.h + + + + UITableViewController + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITableViewController.h + + + + UIView + + IBFrameworkSource + UIKit.framework/Headers/UITextField.h + + + + UIView + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIView.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UINavigationController.h + + + + UIViewController + + IBFrameworkSource + UIKit.framework/Headers/UITabBarController.h + + + + UIViewController + UIResponder + + IBFrameworkSource + UIKit.framework/Headers/UIViewController.h + + + + + 0 + IBCocoaTouchFramework + + com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS + + + + com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 + + + YES + NavApp3.xcodeproj + 3 + 81 + + diff --git a/Tests/iOSNavApp/TotalFunction.c b/Tests/iOSNavApp/TotalFunction.c new file mode 100644 index 000000000..0965a88ac --- /dev/null +++ b/Tests/iOSNavApp/TotalFunction.c @@ -0,0 +1,14 @@ +// +// TotalFunction.c +// NavApp3 +// +// Created by David Cole on 8/10/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#include "TotalFunction.h" + +int Total(const char *context) +{ + return 22; +} diff --git a/Tests/iOSNavApp/TotalFunction.h b/Tests/iOSNavApp/TotalFunction.h new file mode 100644 index 000000000..1301c3d64 --- /dev/null +++ b/Tests/iOSNavApp/TotalFunction.h @@ -0,0 +1,14 @@ +// +// TotalFunction.h +// NavApp3 +// +// Created by David Cole on 8/10/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#ifndef NavApp3_TotalFunction_h +#define NavApp3_TotalFunction_h + +int Total(const char *context); + +#endif diff --git a/Tests/iOSNavApp/main.m b/Tests/iOSNavApp/main.m new file mode 100644 index 000000000..8070c4727 --- /dev/null +++ b/Tests/iOSNavApp/main.m @@ -0,0 +1,17 @@ +// +// main.m +// NavApp3 +// +// Created by David Cole on 6/23/11. +// Copyright 2011 Kitware, Inc. All rights reserved. +// + +#import + +int main(int argc, char *argv[]) { + + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + int retVal = UIApplicationMain(argc, argv, nil, nil); + [pool release]; + return retVal; +} diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 8b3e7f658..798c16397 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -126,6 +126,7 @@ ADD_CUSTOM_COMMAND( INSTALL_FILES(${CMAKE_MAN_DIR}/man1 FILES ${MAN_FILES}) INSTALL_FILES(${CMAKE_DOC_DIR} FILES ${HTML_FILES} ${TEXT_FILES}) +INSTALL(FILES cmake.m4 DESTINATION share/aclocal) # Drive documentation generation. ADD_CUSTOM_TARGET(documentation ALL DEPENDS ${DOC_FILES} ${CMake_BINARY_DIR}/Docs/cmake.txt ) diff --git a/Utilities/Doxygen/CMakeLists.txt b/Utilities/Doxygen/CMakeLists.txt index 5d076e041..2430391fd 100644 --- a/Utilities/Doxygen/CMakeLists.txt +++ b/Utilities/Doxygen/CMakeLists.txt @@ -17,8 +17,6 @@ INCLUDE (${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL) IF (BUILD_DOCUMENTATION) - INCLUDE (${CMAKE_ROOT}/Modules/FindVTK.cmake) - # # Configure the script and the doxyfile, then add target # diff --git a/Utilities/Doxygen/doxyfile.in b/Utilities/Doxygen/doxyfile.in index c3d3a3869..9743af721 100644 --- a/Utilities/Doxygen/doxyfile.in +++ b/Utilities/Doxygen/doxyfile.in @@ -28,6 +28,8 @@ INCLUDED_BY_GRAPH = YES CLASS_DIAGRAMS = YES GENERATE_LEGEND = YES GRAPHICAL_HIERARCHY = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES ALLEXTERNALS = NO @@ -61,7 +63,7 @@ SORT_MEMBER_DOCS = NO DISTRIBUTE_GROUP_DOC = YES TAB_SIZE = 3 -FILE_PATTERNS = *.h *.hxx +FILE_PATTERNS = *.h *.hxx *.cxx RECURSIVE = NO EXCLUDE_PATTERNS = diff --git a/Utilities/Git/commit-msg b/Utilities/Git/commit-msg new file mode 100755 index 000000000..9a5d1c1b3 --- /dev/null +++ b/Utilities/Git/commit-msg @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +#============================================================================= +# CMake - Cross Platform Makefile Generator +# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +die() { + echo 'commit-msg hook failure' 1>&2 + echo '-----------------------' 1>&2 + echo '' 1>&2 + echo "$@" 1>&2 + exit 1 +} + +# This is a placeholder for future commit-msg checks. +exit 0 diff --git a/Utilities/Git/pre-commit b/Utilities/Git/pre-commit new file mode 100755 index 000000000..110e9ee35 --- /dev/null +++ b/Utilities/Git/pre-commit @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +#============================================================================= +# CMake - Cross Platform Makefile Generator +# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +die() { + echo 'pre-commit hook failure' 1>&2 + echo '-----------------------' 1>&2 + echo '' 1>&2 + echo "$@" 1>&2 + exit 1 +} + +if test -z "$HOOKS_ALLOW_KWSYS"; then + # Disallow changes to KWSys + files=$(git diff-index --name-only --cached HEAD -- Source/kwsys) && + if test -n "$files"; then + die 'Changes to KWSys files + +'"$(echo "$files" | sed 's/^/ /')"' + +cannot be committed through Git. KWSys is kept in a CVS repository +shared by several projects. A robot replays changes committed there +into the Source/kwsys directory in CMake. Please send changes to +this directory separately. Run + + git reset HEAD -- Source/kwsys + +to unstage these changes and then + + git diff -- Source/kwsys > kwsys.patch + +to construct the patch. Alternatively, set environment variable + + HOOKS_ALLOW_KWSYS=1 + +to disable this check and commit the changes locally.' + fi +fi diff --git a/Utilities/Git/prepare-commit-msg b/Utilities/Git/prepare-commit-msg new file mode 100755 index 000000000..1517bb2db --- /dev/null +++ b/Utilities/Git/prepare-commit-msg @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +#============================================================================= +# CMake - Cross Platform Makefile Generator +# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +# This is a placeholder for future prepare-commit-msg hooks. +exit 0 diff --git a/Utilities/KWIML/ABI.h.in b/Utilities/KWIML/ABI.h.in new file mode 100644 index 000000000..e95a4ffe6 --- /dev/null +++ b/Utilities/KWIML/ABI.h.in @@ -0,0 +1,466 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of Kitware, Inc. nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +============================================================================*/ +#ifndef @KWIML@_ABI_H +#define @KWIML@_ABI_H +/* +This header defines macros with information about the C ABI. +Only information that can be determined using the preprocessor at +compilation time is available. No try-compile results may be added +here. Instead we memorize results on platforms of interest. + +An includer may optionally define the following macros to suppress errors: + + @KWIML@_ABI_NO_VERIFY = skip verification declarations + @KWIML@_ABI_NO_ERROR_CHAR_SIGN = signedness of 'char' may be unknown + @KWIML@_ABI_NO_ERROR_LONG_LONG = existence of 'long long' may be unknown + @KWIML@_ABI_NO_ERROR_ENDIAN = byte order of CPU may be unknown + +An includer may test the following macros after inclusion: + + @KWIML@_ABI_SIZEOF_DATA_PTR = sizeof(void*) + @KWIML@_ABI_SIZEOF_CODE_PTR = sizeof(void(*)(void)) + @KWIML@_ABI_SIZEOF_FLOAT = sizeof(float) + @KWIML@_ABI_SIZEOF_DOUBLE = sizeof(double) + @KWIML@_ABI_SIZEOF_CHAR = sizeof(char) + @KWIML@_ABI_SIZEOF_SHORT = sizeof(short) + @KWIML@_ABI_SIZEOF_INT = sizeof(int) + @KWIML@_ABI_SIZEOF_LONG = sizeof(long) + + @KWIML@_ABI_SIZEOF_LONG_LONG = sizeof(long long) or 0 if not a type + Undefined if existence is unknown and error suppression macro + @KWIML@_ABI_NO_ERROR_LONG_LONG was defined. + + @KWIML@_ABI_SIZEOF___INT64 = 8 if '__int64' exists or 0 if not + Undefined if existence is unknown. + + @KWIML@_ABI___INT64_IS_LONG = 1 if '__int64' is 'long' (same type) + Undefined otherwise. + @KWIML@_ABI___INT64_IS_LONG_LONG = 1 if '__int64' is 'long long' (same type) + Undefined otherwise. + @KWIML@_ABI___INT64_IS_UNIQUE = 1 if '__int64' is a distinct type + Undefined otherwise. + + @KWIML@_ABI_CHAR_IS_UNSIGNED = 1 if 'char' is unsigned, else undefined + @KWIML@_ABI_CHAR_IS_SIGNED = 1 if 'char' is signed, else undefined + One of these is defined unless signedness of 'char' is unknown and + error suppression macro @KWIML@_ABI_NO_ERROR_CHAR_SIGN was defined. + + @KWIML@_ABI_ENDIAN_ID_BIG = id for big-endian (always defined) + @KWIML@_ABI_ENDIAN_ID_LITTLE = id for little-endian (always defined) + @KWIML@_ABI_ENDIAN_ID = id of byte order of target CPU + Defined to @KWIML@_ABI_ENDIAN_ID_BIG or @KWIML@_ABI_ENDIAN_ID_LITTLE + unless byte order is unknown and error suppression macro + @KWIML@_ABI_NO_ERROR_ENDIAN was defined. + +We verify most results using dummy "extern" declarations that are +invalid if the macros are wrong. Verification is disabled if +suppression macro @KWIML@_ABI_NO_VERIFY was defined. +*/ + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_DATA_PTR) +# if defined(__SIZEOF_POINTER__) +# define @KWIML@_ABI_SIZEOF_DATA_PTR __SIZEOF_POINTER__ +# elif defined(_SIZE_PTR) +# define @KWIML@_ABI_SIZEOF_DATA_PTR (_SIZE_PTR >> 3) +# elif defined(_LP64) || defined(__LP64__) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 8 +# elif defined(_ILP32) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 4 +# elif defined(__64BIT__) /* IBM XL */ +# define @KWIML@_ABI_SIZEOF_DATA_PTR 8 +# elif defined(_M_X64) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 8 +# elif defined(__ia64) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 8 +# elif defined(__sparcv9) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 8 +# elif defined(__x86_64) || defined(__x86_64__) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 8 +# elif defined(__amd64) || defined(__amd64__) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 8 +# elif defined(__i386) || defined(__i386__) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 4 +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_DATA_PTR) +# define @KWIML@_ABI_SIZEOF_DATA_PTR 4 +#endif +#if !defined(@KWIML@_ABI_SIZEOF_CODE_PTR) +# define @KWIML@_ABI_SIZEOF_CODE_PTR @KWIML@_ABI_SIZEOF_DATA_PTR +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_CHAR) +# define @KWIML@_ABI_SIZEOF_CHAR 1 +#endif + +#if !defined(@KWIML@_ABI_CHAR_IS_UNSIGNED) && !defined(@KWIML@_ABI_CHAR_IS_SIGNED) +# if defined(__CHAR_UNSIGNED__) /* GNU, some IBM XL, others? */ +# define @KWIML@_ABI_CHAR_IS_UNSIGNED 1 +# elif defined(_CHAR_UNSIGNED) /* Intel, IBM XL, MSVC, Borland, others? */ +# define @KWIML@_ABI_CHAR_IS_UNSIGNED 1 +# elif defined(_CHAR_SIGNED) /* IBM XL, others? */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(__CHAR_SIGNED__) /* IBM XL, Watcom, others? */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(__SIGNED_CHARS__) /* EDG, Intel, SGI MIPSpro */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(_CHAR_IS_SIGNED) /* Some SunPro, others? */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(_CHAR_IS_UNSIGNED) /* SunPro, others? */ +# define @KWIML@_ABI_CHAR_IS_UNSIGNED 1 +# elif defined(__GNUC__) /* GNU default */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* SunPro default */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(__HP_cc) || defined(__HP_aCC) /* HP default (unless +uc) */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(_SGI_COMPILER_VERSION) /* SGI MIPSpro default */ +# define @KWIML@_ABI_CHAR_IS_UNSIGNED 1 +# elif defined(__PGIC__) /* PGI default */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(_MSC_VER) /* MSVC default */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# elif defined(__WATCOMC__) /* Watcom default */ +# define @KWIML@_ABI_CHAR_IS_UNSIGNED 1 +# elif defined(__BORLANDC__) /* Borland default */ +# define @KWIML@_ABI_CHAR_IS_SIGNED 1 +# endif +#endif +#if !defined(@KWIML@_ABI_CHAR_IS_UNSIGNED) && !defined(@KWIML@_ABI_CHAR_IS_SIGNED) \ + && !defined(@KWIML@_ABI_NO_ERROR_CHAR_SIGN) +# error "Signedness of 'char' unknown." +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_SHORT) +# if defined(__SIZEOF_SHORT__) +# define @KWIML@_ABI_SIZEOF_SHORT __SIZEOF_SHORT__ +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_SHORT) +# define @KWIML@_ABI_SIZEOF_SHORT 2 +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_INT) +# if defined(__SIZEOF_INT__) +# define @KWIML@_ABI_SIZEOF_INT __SIZEOF_INT__ +# elif defined(_SIZE_INT) +# define @KWIML@_ABI_SIZEOF_INT (_SIZE_INT >> 3) +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_INT) +# define @KWIML@_ABI_SIZEOF_INT 4 +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_LONG) +# if defined(__SIZEOF_LONG__) +# define @KWIML@_ABI_SIZEOF_LONG __SIZEOF_LONG__ +# elif defined(_SIZE_LONG) +# define @KWIML@_ABI_SIZEOF_LONG (_SIZE_LONG >> 3) +# elif defined(__LONG_MAX__) +# if __LONG_MAX__ == 0x7fffffff +# define @KWIML@_ABI_SIZEOF_LONG 4 +# elif __LONG_MAX__>>32 == 0x7fffffff +# define @KWIML@_ABI_SIZEOF_LONG 8 +# endif +# elif defined(_MSC_VER) /* MSVC and Intel on Windows */ +# define @KWIML@_ABI_SIZEOF_LONG 4 +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_LONG) +# define @KWIML@_ABI_SIZEOF_LONG @KWIML@_ABI_SIZEOF_DATA_PTR +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_LONG_LONG) +# if defined(__SIZEOF_LONG_LONG__) +# define @KWIML@_ABI_SIZEOF_LONG_LONG __SIZEOF_LONG_LONG__ +# elif defined(__LONG_LONG_MAX__) +# if __LONG_LONG_MAX__ == 0x7fffffff +# define @KWIML@_ABI_SIZEOF_LONG_LONG 4 +# elif __LONG_LONG_MAX__>>32 == 0x7fffffff +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# endif +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_LONG_LONG) +# if defined(_LONGLONG) /* SGI, some GNU, perhaps others. */ \ + && !defined(_MSC_VER) +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(_LONG_LONG) /* IBM XL, perhaps others. */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__NO_LONG_LONG) /* EDG */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 0 +# elif defined(__cplusplus) && __cplusplus > 199711L /* C++0x */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* SunPro */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__HP_cc) || defined(__HP_aCC) /* HP */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__PGIC__) /* PGI */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__WATCOMC__) /* Watcom */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__INTEL_COMPILER) /* Intel */ +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# elif defined(__BORLANDC__) /* Borland */ +# if __BORLANDC__ >= 0x0560 +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# else +# define @KWIML@_ABI_SIZEOF_LONG_LONG 0 +# endif +# elif defined(_MSC_VER) /* Microsoft */ +# if _MSC_VER >= 1310 +# define @KWIML@_ABI_SIZEOF_LONG_LONG 8 +# else +# define @KWIML@_ABI_SIZEOF_LONG_LONG 0 +# endif +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && !defined(@KWIML@_ABI_NO_ERROR_LONG_LONG) +# error "Existence of 'long long' unknown." +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF___INT64) +# if defined(__INTEL_COMPILER) +# define @KWIML@_ABI_SIZEOF___INT64 8 +# elif defined(_MSC_VER) +# define @KWIML@_ABI_SIZEOF___INT64 8 +# elif defined(__BORLANDC__) +# define @KWIML@_ABI_SIZEOF___INT64 8 +# else +# define @KWIML@_ABI_SIZEOF___INT64 0 +# endif +#endif + +#if defined(@KWIML@_ABI_SIZEOF___INT64) && @KWIML@_ABI_SIZEOF___INT64 > 0 +# if @KWIML@_ABI_SIZEOF_LONG == 8 +# define @KWIML@_ABI___INT64_IS_LONG 1 +# elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8 +# define @KWIML@_ABI___INT64_IS_LONG_LONG 1 +# else +# define @KWIML@_ABI___INT64_IS_UNIQUE 1 +# endif +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_FLOAT) +# if defined(__SIZEOF_FLOAT__) +# define @KWIML@_ABI_SIZEOF_FLOAT __SIZEOF_FLOAT__ +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_FLOAT) +# define @KWIML@_ABI_SIZEOF_FLOAT 4 +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_SIZEOF_DOUBLE) +# if defined(__SIZEOF_DOUBLE__) +# define @KWIML@_ABI_SIZEOF_DOUBLE __SIZEOF_DOUBLE__ +# endif +#endif +#if !defined(@KWIML@_ABI_SIZEOF_DOUBLE) +# define @KWIML@_ABI_SIZEOF_DOUBLE 8 +#endif + +/*--------------------------------------------------------------------------*/ +/* Identify possible endian cases. The macro @KWIML@_ABI_ENDIAN_ID will be + defined to one of these, or undefined if unknown. */ +#if !defined(@KWIML@_ABI_ENDIAN_ID_BIG) +# define @KWIML@_ABI_ENDIAN_ID_BIG 4321 +#endif +#if !defined(@KWIML@_ABI_ENDIAN_ID_LITTLE) +# define @KWIML@_ABI_ENDIAN_ID_LITTLE 1234 +#endif +#if @KWIML@_ABI_ENDIAN_ID_BIG == @KWIML@_ABI_ENDIAN_ID_LITTLE +# error "@KWIML@_ABI_ENDIAN_ID_BIG == @KWIML@_ABI_ENDIAN_ID_LITTLE" +#endif + +#if defined(@KWIML@_ABI_ENDIAN_ID) /* Skip #elif cases if already defined. */ + +/* Use dedicated symbols if the compiler defines them. Do this first + because some architectures allow runtime byte order selection by + the operating system (values for such architectures below are + guesses for compilers that do not define a dedicated symbol). + Ensure that only one is defined in case the platform or a header + defines both as possible values for some third symbol. */ +#elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG +#elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE +#elif defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG +#elif defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE + +/* Alpha */ +#elif defined(__alpha) || defined(__alpha__) || defined(_M_ALPHA) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE + +/* Arm */ +#elif defined(__arm__) +# if !defined(__ARMEB__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE +# else +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG +# endif + +/* Intel x86 */ +#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE +#elif defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE +#elif defined(__MWERKS__) && defined(__INTEL__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE + +/* Intel x86-64 */ +#elif defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE +#elif defined(__amd64) || defined(__amd64__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE + +/* Intel Architecture-64 (Itanium) */ +#elif defined(__ia64) || defined(__ia64__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE +#elif defined(_IA64) || defined(__IA64__) || defined(_M_IA64) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_LITTLE + +/* PowerPC */ +#elif defined(__powerpc) || defined(__powerpc__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG +#elif defined(__ppc) || defined(__ppc__) || defined(__POWERPC__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* SPARC */ +#elif defined(__sparc) || defined(__sparc__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* HP/PA RISC */ +#elif defined(__hppa) || defined(__hppa__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* Motorola 68k */ +#elif defined(__m68k__) || defined(M68000) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* MIPS */ +#elif defined(__mips) || defined(__mips__) || defined(__MIPS__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* RS/6000 */ +#elif defined(__THW_RS600) || defined(_IBMR2) || defined(_POWER) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG +#elif defined(_ARCH_PWR) || defined(_ARCH_PWR2) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* System/370 */ +#elif defined(__370__) || defined(__THW_370__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* System/390 */ +#elif defined(__s390__) || defined(__s390x__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* z/Architecture */ +#elif defined(__SYSC_ZARCH__) +# define @KWIML@_ABI_ENDIAN_ID @KWIML@_ABI_ENDIAN_ID_BIG + +/* Unknown CPU */ +#elif !defined(@KWIML@_ABI_NO_ERROR_ENDIAN) +# error "Byte order of target CPU unknown." +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_ABI_NO_VERIFY) +#define @KWIML@_ABI__VERIFY(n, x, y) extern int (*n)[x]; extern int (*n)[y] +#define @KWIML@_ABI__VERIFY2(n, x, y) extern int (*n)(x*); extern int (*n)(y*) +#if defined(__cplusplus) +# define @KWIML@_ABI__VERIFY3(n, x, y) extern int* n(x*); extern char* n(y*) +#else +# define @KWIML@_ABI__VERIFY3(n, x, y) extern int* n(x*) /* TODO: possible? */ +#endif +#define @KWIML@_ABI__VERIFY_BOOL(m, b) @KWIML@_ABI__VERIFY(m##__VERIFY__, 2, (b)?2:3) +#define @KWIML@_ABI__VERIFY_SIZE(m, t) @KWIML@_ABI__VERIFY(m##__VERIFY__, m, sizeof(t)) +#define @KWIML@_ABI__VERIFY_SAME(m, x, y) @KWIML@_ABI__VERIFY2(m##__VERIFY__, x, y) +#define @KWIML@_ABI__VERIFY_DIFF(m, x, y) @KWIML@_ABI__VERIFY3(m##__VERIFY__, x, y) + +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_DATA_PTR, int*); +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_CODE_PTR, int(*)(int)); +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_CHAR, char); +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_SHORT, short); +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_INT, int); +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_LONG, long); +#if defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG > 0 +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_LONG_LONG, long long); +#endif +#if defined(@KWIML@_ABI_SIZEOF___INT64) && @KWIML@_ABI_SIZEOF___INT64 > 0 +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF___INT64, __int64); +#endif +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_FLOAT, float); +@KWIML@_ABI__VERIFY_SIZE(@KWIML@_ABI_SIZEOF_DOUBLE, double); + +#if defined(@KWIML@_ABI___INT64_IS_LONG) +@KWIML@_ABI__VERIFY_SAME(@KWIML@_ABI___INT64_IS_LONG, __int64, long); +#elif defined(@KWIML@_ABI___INT64_IS_LONG_LONG) +@KWIML@_ABI__VERIFY_SAME(@KWIML@_ABI___INT64_IS_LONG_LONG, __int64, long long); +#elif defined(@KWIML@_ABI_SIZEOF___INT64) && @KWIML@_ABI_SIZEOF___INT64 > 0 +@KWIML@_ABI__VERIFY_DIFF(@KWIML@_ABI___INT64_NOT_LONG, __int64, long); +# if defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG > 0 +@KWIML@_ABI__VERIFY_DIFF(@KWIML@_ABI___INT64_NOT_LONG_LONG, __int64, long long); +# endif +#endif + +#if defined(@KWIML@_ABI_CHAR_IS_UNSIGNED) +@KWIML@_ABI__VERIFY_BOOL(@KWIML@_ABI_CHAR_IS_UNSIGNED, (char)0x80 > 0); +#elif defined(@KWIML@_ABI_CHAR_IS_SIGNED) +@KWIML@_ABI__VERIFY_BOOL(@KWIML@_ABI_CHAR_IS_SIGNED, (char)0x80 < 0); +#endif + +#undef @KWIML@_ABI__VERIFY_DIFF +#undef @KWIML@_ABI__VERIFY_SAME +#undef @KWIML@_ABI__VERIFY_SIZE +#undef @KWIML@_ABI__VERIFY_BOOL +#undef @KWIML@_ABI__VERIFY3 +#undef @KWIML@_ABI__VERIFY2 +#undef @KWIML@_ABI__VERIFY + +#endif + +#endif diff --git a/Utilities/KWIML/CMakeLists.txt b/Utilities/KWIML/CMakeLists.txt new file mode 100644 index 000000000..6a8641adc --- /dev/null +++ b/Utilities/KWIML/CMakeLists.txt @@ -0,0 +1,79 @@ +#============================================================================= +# Kitware Information Macro Library +# Copyright 2010-2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +# Import the KWIML directory tree into a subdirectory under a parent +# project and configure the library as follows: +# +# SET(KWIML myIML) +# SUBDIRS(KWIML) +# +# Optional settings are as follows: +# +# KWIML_HEADER_ROOT = build tree directory to hold KWIML headers. +# Headers will go in a directory called "${KWIML}" under this root. +# For example: +# +# SET(KWIML_HEADER_ROOT ${PROJECT_BINARY_DIR}) +# INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}) +# +# KWIML_INSTALL_INCLUDE_DIR = install KWIML with "make install" +# Specify a value relative to the install prefix and do NOT start with '/'. +# KWIML_INSTALL_INCLUDE_OPTIONS = extra header installation options +# Specify options for the install(FILES) command. +# +# KWIML_LABELS_TEST = list of labels for KWIML tests + +cmake_minimum_required(VERSION 2.6.3 FATAL_ERROR) + +#----------------------------------------------------------------------------- +if(NOT DEFINED KWIML) + if(NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}") + message(FATAL_ERROR "Set KWIML namespace in parent directory!") + endif() + set(KWIML KWIML) + set(KWIML_STANDALONE 1) + project(KWIML) + include(CTest) + mark_as_advanced(BUILD_TESTING) +endif() + +#----------------------------------------------------------------------------- +get_property(KWIML_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) +foreach(lang ${KWIML_LANGUAGES}) + set(KWIML_LANGUAGE_${lang} 1) +endforeach() +if(NOT KWIML_LANGUAGE_C AND NOT KWIML_LANGUAGE_CXX) + set(BUILD_TESTING OFF) +endif() + +#----------------------------------------------------------------------------- +if(NOT KWIML_HEADER_ROOT) + set(KWIML_HEADER_ROOT "${PROJECT_BINARY_DIR}") +endif() +set(KWIML_HEADER_DIR "${KWIML_HEADER_ROOT}/${KWIML}") +include_directories(${KWIML_HEADER_ROOT}) + +#----------------------------------------------------------------------------- +foreach(h ABI INT) + set(header ${KWIML_HEADER_DIR}/${h}.h) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${h}.h.in ${header} @ONLY) + if(KWIML_INSTALL_INCLUDE_DIR) + install(FILES ${header} + DESTINATION ${KWIML_INSTALL_INCLUDE_DIR}/${KWIML} + ${KWIML_INSTALL_INCLUDE_OPTIONS}) + endif() +endforeach() + +#----------------------------------------------------------------------------- +if(BUILD_TESTING) + add_subdirectory(test) +endif() diff --git a/Utilities/KWIML/Copyright.txt b/Utilities/KWIML/Copyright.txt new file mode 100644 index 000000000..c1e5ebc3f --- /dev/null +++ b/Utilities/KWIML/Copyright.txt @@ -0,0 +1,30 @@ +Kitware Information Macro Library +Copyright 2010-2011 Kitware, Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +* Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +* Neither the name of Kitware, Inc. nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Utilities/KWIML/INT.h.in b/Utilities/KWIML/INT.h.in new file mode 100644 index 000000000..3c1f05dc4 --- /dev/null +++ b/Utilities/KWIML/INT.h.in @@ -0,0 +1,736 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + * Neither the name of Kitware, Inc. nor the names of its contributors + may be used to endorse or promote products derived from this + software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +============================================================================*/ +#ifndef @KWIML@_INT_H +#define @KWIML@_INT_H +/* +This header defines macros with information about sized integer types. +Only information that can be determined using the preprocessor at +compilation time is available. No try-compile results may be added +here. Instead we memorize results on platforms of interest. + +An includer may optionally define the following macros to suppress errors: + +Input: + @KWIML@_INT_NO_VERIFY = skip verification declarations + @KWIML@_INT_NO_ERROR_INT64_T = type '@KWIML@_INT_int64_t' is optional (*) + @KWIML@_INT_NO_ERROR_UINT64_T = type '@KWIML@_INT_uint64_t' is optional (*) + @KWIML@_INT_NO_ERROR_INTPTR_T = type '@KWIML@_INT_intptr_t' is optional (*) + @KWIML@_INT_NO_ERROR_UINTPTR_T = type '@KWIML@_INT_uintptr_t' is optional (*) + +An includer may optionally define the following macros to override defaults. +Either way, an includer may test these macros after inclusion: + + @KWIML@_INT_HAVE_STDINT_H = include + @KWIML@_INT_NO_STDINT_H = do not include + @KWIML@_INT_HAVE_INTTYPES_H = include + @KWIML@_INT_NO_INTTYPES_H = do not include + +An includer may test the following macros after inclusion: + + @KWIML@_INT_HAVE_INT#_T = type 'int#_t' is available + @KWIML@_INT_HAVE_UINT#_T = type 'uint#_t' is available + # = 8, 16, 32, 64, PTR + + @KWIML@_INT_int#_t = signed integer type exactly # bits wide + @KWIML@_INT_uint#_t = unsigned integer type exactly # bits wide + # = 8, 16, 32, 64 (*), ptr (*) + + @KWIML@_INT_NO_INT64_T = type '@KWIML@_INT_int64_t' not available + @KWIML@_INT_NO_UINT64_T = type '@KWIML@_INT_uint64_t' not available + @KWIML@_INT_NO_INTPTR_T = type '@KWIML@_INT_intptr_t' not available + @KWIML@_INT_NO_UINTPTR_T = type '@KWIML@_INT_uintptr_t' not available + + @KWIML@_INT_INT#_C(c) = signed integer constant at least # bits wide + @KWIML@_INT_UINT#_C(c) = unsigned integer constant at least # bits wide + # = 8, 16, 32, 64 (*) + + @KWIML@_INT_# = print or scan format, in table below + # = 8, 16, 32, 64, PTR (*) + + signed unsigned + ----------- ------------------------------ + | decimal | decimal octal hexadecimal | + print | PRId PRIi | PRIu PRIo PRIx PRIX | + scan | SCNd SCNi | SCNu SCNo SCNx | + ----------- ------------------------------ + + The SCN*8 and SCN*64 format macros will not be defined on systems + with scanf implementations known not to support them. + + @KWIML@_INT_BROKEN_INT64_C = macro INT64_C is incorrect if defined + @KWIML@_INT_BROKEN_UINT64_C = macro UINT64_C is incorrect if defined + Some compilers define integer constant macros incorrectly and + cannot handle literals as large as the integer type. + + @KWIML@_INT_BROKEN_INT8_T = type 'int8_t' is available but incorrect + Some compilers have a flag to make 'char' (un)signed but do not account + for it while defining int8_t in the non-default case. + + The broken cases do not affect correctness of the macros documented above. +*/ + +#include "ABI.h" + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_STDINT_H) /* Already defined. */ +#elif defined(@KWIML@_INT_NO_STDINT_H) /* Already defined. */ +#elif defined(HAVE_STDINT_H) /* Optionally provided by includer. */ +# define @KWIML@_INT_HAVE_STDINT_H 1 +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ +# define @KWIML@_INT_HAVE_STDINT_H 1 +#elif defined(_MSC_VER) /* MSVC */ +# if _MSC_VER >= 1600 +# define @KWIML@_INT_HAVE_STDINT_H 1 +# else +# define @KWIML@_INT_NO_STDINT_H 1 +# endif +#elif defined(__BORLANDC__) /* Borland */ +# if __BORLANDC__ >= 0x560 +# define @KWIML@_INT_HAVE_STDINT_H 1 +# else +# define @KWIML@_INT_NO_STDINT_H 1 +# endif +#elif defined(__WATCOMC__) /* Watcom */ +# define @KWIML@_INT_NO_STDINT_H 1 +#endif + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_INTTYPES_H) /* Already defined. */ +#elif defined(@KWIML@_INT_NO_INTTYPES_H) /* Already defined. */ +#elif defined(HAVE_INTTYPES_H) /* Optionally provided by includer. */ +# define @KWIML@_INT_HAVE_INTTYPES_H 1 +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L /* C99 */ +# define @KWIML@_INT_HAVE_INTTYPES_H 1 +#elif defined(_MSC_VER) /* MSVC */ +# define @KWIML@_INT_NO_INTTYPES_H 1 +#elif defined(__BORLANDC__) /* Borland */ +# define @KWIML@_INT_NO_INTTYPES_H 1 +#elif defined(__WATCOMC__) /* Watcom */ +# define @KWIML@_INT_NO_INTTYPES_H 1 +#else /* Assume it exists. */ +# define @KWIML@_INT_HAVE_INTTYPES_H 1 +#endif + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_STDINT_H) && defined(@KWIML@_INT_NO_STDINT_H) +# error "Both @KWIML@_INT_HAVE_STDINT_H and @KWIML@_INT_NO_STDINT_H defined!" +#endif +#if defined(@KWIML@_INT_HAVE_INTTYPES_H) && defined(@KWIML@_INT_NO_INTTYPES_H) +# error "Both @KWIML@_INT_HAVE_INTTYPES_H and @KWIML@_INT_NO_INTTYPES_H defined!" +#endif + +#if defined(@KWIML@_INT_HAVE_STDINT_H) +# include +#endif +#if defined(@KWIML@_INT_HAVE_INTTYPES_H) +# if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) +# define __STDC_FORMAT_MACROS +# endif +# include +#endif + +#if defined(@KWIML@_INT_HAVE_STDINT_H) || defined(@KWIML@_INT_HAVE_INTTYPES_H) +#define @KWIML@_INT_HAVE_INT8_T 1 +#define @KWIML@_INT_HAVE_UINT8_T 1 +#define @KWIML@_INT_HAVE_INT16_T 1 +#define @KWIML@_INT_HAVE_UINT16_T 1 +#define @KWIML@_INT_HAVE_INT32_T 1 +#define @KWIML@_INT_HAVE_UINT32_T 1 +#define @KWIML@_INT_HAVE_INT64_T 1 +#define @KWIML@_INT_HAVE_UINT64_T 1 +#define @KWIML@_INT_HAVE_INTPTR_T 1 +#define @KWIML@_INT_HAVE_UINTPTR_T 1 +#endif + +#if (defined(__SUNPRO_C)||defined(__SUNPRO_CC)) && defined(_CHAR_IS_UNSIGNED) +# define @KWIML@_INT_BROKEN_INT8_T /* system type defined incorrectly */ +#elif defined(__BORLANDC__) && defined(_CHAR_UNSIGNED) +# define @KWIML@_INT_BROKEN_INT8_T /* system type defined incorrectly */ +#endif + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_INT8_T) && !defined(@KWIML@_INT_BROKEN_INT8_T) +# define @KWIML@_INT_int8_t int8_t +#else +# define @KWIML@_INT_int8_t signed char +#endif +#if defined(@KWIML@_INT_HAVE_UINT8_T) +# define @KWIML@_INT_uint8_t uint8_t +#else +# define @KWIML@_INT_uint8_t unsigned char +#endif + +#if defined(__INTEL_COMPILER) +# if defined(_WIN32) +# define @KWIML@_INT__NO_SCN8 +# endif +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) +# define @KWIML@_INT__NO_SCN8 +#elif defined(__HP_cc) || defined(__HP_aCC) +# define @KWIML@_INT__NO_SCN8 +#elif defined(__BORLANDC__) +# define @KWIML@_INT__NO_SCN8 +# define @KWIML@_INT__NO_SCN64 +#elif defined(_MSC_VER) +# define @KWIML@_INT__NO_SCN8 +#elif defined(__WATCOMC__) +# define @KWIML@_INT__NO_SCN8 +#endif + +/* 8-bit d, i */ +#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(PRId8) +# define @KWIML@_INT_PRId8 PRId8 +#else +# define @KWIML@_INT_PRId8 "d" +#endif +#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(SCNd8) +# define @KWIML@_INT_SCNd8 SCNd8 +#elif !defined(@KWIML@_INT__NO_SCN8) +# define @KWIML@_INT_SCNd8 "hhd" +#endif +#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(PRIi8) +# define @KWIML@_INT_PRIi8 PRIi8 +#else +# define @KWIML@_INT_PRIi8 "i" +#endif +#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(SCNi8) +# define @KWIML@_INT_SCNi8 SCNi8 +#elif !defined(@KWIML@_INT__NO_SCN8) +# define @KWIML@_INT_SCNi8 "hhi" +#endif + +/* 8-bit o, u, x, X */ +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIo8) +# define @KWIML@_INT_PRIo8 PRIo8 +#else +# define @KWIML@_INT_PRIo8 "o" +#endif +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNo8) +# define @KWIML@_INT_SCNo8 SCNo8 +#elif !defined(@KWIML@_INT__NO_SCN8) +# define @KWIML@_INT_SCNo8 "hho" +#endif +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIu8) +# define @KWIML@_INT_PRIu8 PRIu8 +#else +# define @KWIML@_INT_PRIu8 "u" +#endif +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNu8) +# define @KWIML@_INT_SCNu8 SCNu8 +#elif !defined(@KWIML@_INT__NO_SCN8) +# define @KWIML@_INT_SCNu8 "hhu" +#endif +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIx8) +# define @KWIML@_INT_PRIx8 PRIx8 +#else +# define @KWIML@_INT_PRIx8 "x" +#endif +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNx8) +# define @KWIML@_INT_SCNx8 SCNx8 +#elif !defined(@KWIML@_INT__NO_SCN8) +# define @KWIML@_INT_SCNx8 "hhx" +#endif +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIX8) +# define @KWIML@_INT_PRIX8 PRIX8 +#else +# define @KWIML@_INT_PRIX8 "X" +#endif + +/* 8-bit constants */ +#if defined(INT8_C) +# define @KWIML@_INT_INT8_C(c) INT8_C(c) +#else +# define @KWIML@_INT_INT8_C(c) c +#endif +#if defined(UINT8_C) +# define @KWIML@_INT_UINT8_C(c) UINT8_C(c) +#else +# define @KWIML@_INT_UINT8_C(c) c ## u +#endif + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_INT16_T) +# define @KWIML@_INT_int16_t int16_t +#else +# define @KWIML@_INT_int16_t signed short +#endif +#if defined(@KWIML@_INT_HAVE_UINT16_T) +# define @KWIML@_INT_uint16_t uint16_t +#else +# define @KWIML@_INT_uint16_t unsigned short +#endif + +/* 16-bit d, i */ +#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(PRId16) +# define @KWIML@_INT_PRId16 PRId16 +#else +# define @KWIML@_INT_PRId16 "d" +#endif +#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(SCNd16) +# define @KWIML@_INT_SCNd16 SCNd16 +#else +# define @KWIML@_INT_SCNd16 "hd" +#endif +#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(PRIi16) +# define @KWIML@_INT_PRIi16 PRIi16 +#else +# define @KWIML@_INT_PRIi16 "i" +#endif +#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(SCNi16) +# define @KWIML@_INT_SCNi16 SCNi16 +#else +# define @KWIML@_INT_SCNi16 "hi" +#endif + +/* 16-bit o, u, x, X */ +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIo16) +# define @KWIML@_INT_PRIo16 PRIo16 +#else +# define @KWIML@_INT_PRIo16 "o" +#endif +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNo16) +# define @KWIML@_INT_SCNo16 SCNo16 +#else +# define @KWIML@_INT_SCNo16 "ho" +#endif +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIu16) +# define @KWIML@_INT_PRIu16 PRIu16 +#else +# define @KWIML@_INT_PRIu16 "u" +#endif +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNu16) +# define @KWIML@_INT_SCNu16 SCNu16 +#else +# define @KWIML@_INT_SCNu16 "hu" +#endif +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIx16) +# define @KWIML@_INT_PRIx16 PRIx16 +#else +# define @KWIML@_INT_PRIx16 "x" +#endif +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNx16) +# define @KWIML@_INT_SCNx16 SCNx16 +#else +# define @KWIML@_INT_SCNx16 "hx" +#endif +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIX16) +# define @KWIML@_INT_PRIX16 PRIX16 +#else +# define @KWIML@_INT_PRIX16 "X" +#endif + +/* 16-bit constants */ +#if defined(INT16_C) +# define @KWIML@_INT_INT16_C(c) INT16_C(c) +#else +# define @KWIML@_INT_INT16_C(c) c +#endif +#if defined(UINT16_C) +# define @KWIML@_INT_UINT16_C(c) UINT16_C(c) +#else +# define @KWIML@_INT_UINT16_C(c) c ## u +#endif + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_INT32_T) +# define @KWIML@_INT_int32_t int32_t +#else +# define @KWIML@_INT_int32_t signed int +#endif +#if defined(@KWIML@_INT_HAVE_UINT32_T) +# define @KWIML@_INT_uint32_t uint32_t +#else +# define @KWIML@_INT_uint32_t unsigned int +#endif + +/* 32-bit d, i */ +#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(PRId32) +# define @KWIML@_INT_PRId32 PRId32 +#else +# define @KWIML@_INT_PRId32 "d" +#endif +#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(SCNd32) +# define @KWIML@_INT_SCNd32 SCNd32 +#else +# define @KWIML@_INT_SCNd32 "d" +#endif +#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(PRIi32) +# define @KWIML@_INT_PRIi32 PRIi32 +#else +# define @KWIML@_INT_PRIi32 "i" +#endif +#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(SCNi32) +# define @KWIML@_INT_SCNi32 SCNi32 +#else +# define @KWIML@_INT_SCNi32 "i" +#endif + +/* 32-bit o, u, x, X */ +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIo32) +# define @KWIML@_INT_PRIo32 PRIo32 +#else +# define @KWIML@_INT_PRIo32 "o" +#endif +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNo32) +# define @KWIML@_INT_SCNo32 SCNo32 +#else +# define @KWIML@_INT_SCNo32 "o" +#endif +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIu32) +# define @KWIML@_INT_PRIu32 PRIu32 +#else +# define @KWIML@_INT_PRIu32 "u" +#endif +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNu32) +# define @KWIML@_INT_SCNu32 SCNu32 +#else +# define @KWIML@_INT_SCNu32 "u" +#endif +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIx32) +# define @KWIML@_INT_PRIx32 PRIx32 +#else +# define @KWIML@_INT_PRIx32 "x" +#endif +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNx32) +# define @KWIML@_INT_SCNx32 SCNx32 +#else +# define @KWIML@_INT_SCNx32 "x" +#endif +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIX32) +# define @KWIML@_INT_PRIX32 PRIX32 +#else +# define @KWIML@_INT_PRIX32 "X" +#endif + +/* 32-bit constants */ +#if defined(INT32_C) +# define @KWIML@_INT_INT32_C(c) INT32_C(c) +#else +# define @KWIML@_INT_INT32_C(c) c +#endif +#if defined(UINT32_C) +# define @KWIML@_INT_UINT32_C(c) UINT32_C(c) +#else +# define @KWIML@_INT_UINT32_C(c) c ## u +#endif + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_INT64_T) +# define @KWIML@_INT_int64_t int64_t +#elif @KWIML@_ABI_SIZEOF_LONG == 8 +# define @KWIML@_INT_int64_t signed long +#elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8 +# define @KWIML@_INT_int64_t signed long long +#elif defined(@KWIML@_ABI_SIZEOF___INT64) +# define @KWIML@_INT_int64_t signed __int64 +#elif defined(@KWIML@_INT_NO_ERROR_INT64_T) +# define @KWIML@_INT_NO_INT64_T +#else +# error "No type known for 'int64_t'." +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) +# define @KWIML@_INT_uint64_t uint64_t +#elif @KWIML@_ABI_SIZEOF_LONG == 8 +# define @KWIML@_INT_uint64_t unsigned long +#elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8 +# define @KWIML@_INT_uint64_t unsigned long long +#elif defined(@KWIML@_ABI_SIZEOF___INT64) +# define @KWIML@_INT_uint64_t unsigned __int64 +#elif defined(@KWIML@_INT_NO_ERROR_UINT64_T) +# define @KWIML@_INT_NO_UINT64_T +#else +# error "No type known for 'uint64_t'." +#endif + +#if defined(__INTEL_COMPILER) +#elif defined(__BORLANDC__) +# define @KWIML@_INT__NO_FMTLL /* type 'long long' but not 'll' format */ +# define @KWIML@_INT_BROKEN_INT64_C /* system macro defined incorrectly */ +# define @KWIML@_INT_BROKEN_UINT64_C /* system macro defined incorrectly */ +#elif defined(_MSC_VER) && _MSC_VER < 1400 +# define @KWIML@_INT__NO_FMTLL /* type 'long long' but not 'll' format */ +#endif + +#if @KWIML@_ABI_SIZEOF_LONG == 8 +# define @KWIML@_INT__FMT64 "l" +#elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8 +# if !defined(@KWIML@_INT__NO_FMTLL) +# define @KWIML@_INT__FMT64 "ll" +# else +# define @KWIML@_INT__FMT64 "I64" +# endif +#elif defined(@KWIML@_ABI_SIZEOF___INT64) +# if defined(__BORLANDC__) +# define @KWIML@_INT__FMT64 "L" +# else +# define @KWIML@_INT__FMT64 "I64" +# endif +#endif + +/* 64-bit d, i */ +#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(PRId64) +# define @KWIML@_INT_PRId64 PRId64 +#elif defined(@KWIML@_INT__FMT64) +# define @KWIML@_INT_PRId64 @KWIML@_INT__FMT64 "d" +#endif +#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(SCNd64) +# define @KWIML@_INT_SCNd64 SCNd64 +#elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) +# define @KWIML@_INT_SCNd64 @KWIML@_INT__FMT64 "d" +#endif +#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(PRIi64) +# define @KWIML@_INT_PRIi64 PRIi64 +#elif defined(@KWIML@_INT__FMT64) +# define @KWIML@_INT_PRIi64 @KWIML@_INT__FMT64 "d" +#endif +#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(SCNi64) +# define @KWIML@_INT_SCNi64 SCNi64 +#elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) +# define @KWIML@_INT_SCNi64 @KWIML@_INT__FMT64 "d" +#endif + +/* 64-bit o, u, x, X */ +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIo64) +# define @KWIML@_INT_PRIo64 PRIo64 +#elif defined(@KWIML@_INT__FMT64) +# define @KWIML@_INT_PRIo64 @KWIML@_INT__FMT64 "o" +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNo64) +# define @KWIML@_INT_SCNo64 SCNo64 +#elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) +# define @KWIML@_INT_SCNo64 @KWIML@_INT__FMT64 "o" +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIu64) +# define @KWIML@_INT_PRIu64 PRIu64 +#elif defined(@KWIML@_INT__FMT64) +# define @KWIML@_INT_PRIu64 @KWIML@_INT__FMT64 "u" +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNu64) +# define @KWIML@_INT_SCNu64 SCNu64 +#elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) +# define @KWIML@_INT_SCNu64 @KWIML@_INT__FMT64 "u" +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIx64) +# define @KWIML@_INT_PRIx64 PRIx64 +#elif defined(@KWIML@_INT__FMT64) +# define @KWIML@_INT_PRIx64 @KWIML@_INT__FMT64 "x" +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNx64) +# define @KWIML@_INT_SCNx64 SCNx64 +#elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) +# define @KWIML@_INT_SCNx64 @KWIML@_INT__FMT64 "x" +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIX64) +# define @KWIML@_INT_PRIX64 PRIX64 +#elif defined(@KWIML@_INT__FMT64) +# define @KWIML@_INT_PRIX64 @KWIML@_INT__FMT64 "X" +#endif + +/* 64-bit constants */ +#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(INT64_C) \ + && !defined(@KWIML@_INT_BROKEN_INT64_C) +# define @KWIML@_INT_INT64_C(c) INT64_C(c) +#elif @KWIML@_ABI_SIZEOF_LONG == 8 +# define @KWIML@_INT_INT64_C(c) c ## l +#elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8 +# define @KWIML@_INT_INT64_C(c) c ## ll +#elif defined(@KWIML@_ABI_SIZEOF___INT64) +# define @KWIML@_INT_INT64_C(c) c ## i64 +#endif +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(UINT64_C) \ + && !defined(@KWIML@_INT_BROKEN_UINT64_C) +# define @KWIML@_INT_UINT64_C(c) UINT64_C(c) +#elif @KWIML@_ABI_SIZEOF_LONG == 8 +# define @KWIML@_INT_UINT64_C(c) c ## ul +#elif defined(@KWIML@_ABI_SIZEOF_LONG_LONG) && @KWIML@_ABI_SIZEOF_LONG_LONG == 8 +# define @KWIML@_INT_UINT64_C(c) c ## ull +#elif defined(@KWIML@_ABI_SIZEOF___INT64) +# define @KWIML@_INT_UINT64_C(c) c ## ui64 +#endif + +/*--------------------------------------------------------------------------*/ +#if defined(@KWIML@_INT_HAVE_INTPTR_T) +# define @KWIML@_INT_intptr_t intptr_t +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_intptr_t @KWIML@_INT_int32_t +#elif !defined(@KWIML@_INT_NO_INT64_T) +# define @KWIML@_INT_intptr_t @KWIML@_INT_int64_t +#elif defined(@KWIML@_INT_NO_ERROR_INTPTR_T) +# define @KWIML@_INT_NO_INTPTR_T +#else +# error "No type known for 'intptr_t'." +#endif +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) +# define @KWIML@_INT_uintptr_t uintptr_t +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_uintptr_t @KWIML@_INT_uint32_t +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_uintptr_t @KWIML@_INT_uint64_t +#elif defined(@KWIML@_INT_NO_ERROR_UINTPTR_T) +# define @KWIML@_INT_NO_UINTPTR_T +#else +# error "No type known for 'uintptr_t'." +#endif + +#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(PRIdPTR) +# define @KWIML@_INT_PRIdPTR PRIdPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_PRIdPTR @KWIML@_INT_PRId32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_PRIdPTR @KWIML@_INT_PRId64 +#endif +#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(SCNdPTR) +# define @KWIML@_INT_SCNdPTR SCNdPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_SCNdPTR @KWIML@_INT_SCNd32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_SCNdPTR @KWIML@_INT_SCNd64 +#endif +#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(PRIiPTR) +# define @KWIML@_INT_PRIiPTR PRIiPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_PRIiPTR @KWIML@_INT_PRIi32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_PRIiPTR @KWIML@_INT_PRIi64 +#endif +#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(SCNiPTR) +# define @KWIML@_INT_SCNiPTR SCNiPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_SCNiPTR @KWIML@_INT_SCNi32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_SCNiPTR @KWIML@_INT_SCNi64 +#endif + +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIoPTR) +# define @KWIML@_INT_PRIoPTR PRIoPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_PRIoPTR @KWIML@_INT_PRIo32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_PRIoPTR @KWIML@_INT_PRIo64 +#endif +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNoPTR) +# define @KWIML@_INT_SCNoPTR SCNoPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_SCNoPTR @KWIML@_INT_SCNo32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_SCNoPTR @KWIML@_INT_SCNo64 +#endif +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIuPTR) +# define @KWIML@_INT_PRIuPTR PRIuPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_PRIuPTR @KWIML@_INT_PRIu32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_PRIuPTR @KWIML@_INT_PRIu64 +#endif +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNuPTR) +# define @KWIML@_INT_SCNuPTR SCNuPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_SCNuPTR @KWIML@_INT_SCNu32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_SCNuPTR @KWIML@_INT_SCNu64 +#endif +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIxPTR) +# define @KWIML@_INT_PRIxPTR PRIxPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_PRIxPTR @KWIML@_INT_PRIx32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_PRIxPTR @KWIML@_INT_PRIx64 +#endif +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNxPTR) +# define @KWIML@_INT_SCNxPTR SCNxPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_SCNxPTR @KWIML@_INT_SCNx32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_SCNxPTR @KWIML@_INT_SCNx64 +#endif +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIXPTR) +# define @KWIML@_INT_PRIXPTR PRIXPTR +#elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 +# define @KWIML@_INT_PRIXPTR @KWIML@_INT_PRIX32 +#elif !defined(@KWIML@_INT_NO_UINT64_T) +# define @KWIML@_INT_PRIXPTR @KWIML@_INT_PRIX64 +#endif + +/*--------------------------------------------------------------------------*/ +#if !defined(@KWIML@_INT_NO_VERIFY) +#define @KWIML@_INT__VERIFY(n, x, y) extern int (*n)[x]; extern int (*n)[y] +#define @KWIML@_INT__VERIFY_BOOL(m, b) @KWIML@_INT__VERIFY(m##__VERIFY__, 2, (b)?2:3) +#define @KWIML@_INT__VERIFY_TYPE(t, s) @KWIML@_INT__VERIFY(t##__VERIFY__, s, sizeof(t)) +#define @KWIML@_INT__VERIFY_SIGN(t, u, o) @KWIML@_INT__VERIFY_BOOL(t##__SIGN, (t)((u)1 << ((sizeof(t)<<3)-1)) o 0) + +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_int8_t, 1); +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uint8_t, 1); +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_int16_t, 2); +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uint16_t, 2); +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_int32_t, 4); +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uint32_t, 4); +#if !defined(@KWIML@_INT_NO_INT64_T) +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_int64_t, 8); +#endif +#if !defined(@KWIML@_INT_NO_UINT64_T) +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uint64_t, 8); +#endif +#if !defined(@KWIML@_INT_NO_INTPTR_T) +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_intptr_t, sizeof(void*)); +#endif +#if !defined(@KWIML@_INT_NO_UINTPTR_T) +@KWIML@_INT__VERIFY_TYPE(@KWIML@_INT_uintptr_t, sizeof(void*)); +#endif + +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_int8_t, @KWIML@_INT_uint8_t, <); +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uint8_t, @KWIML@_INT_uint8_t, >); +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_int16_t, @KWIML@_INT_uint16_t, <); +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uint16_t, @KWIML@_INT_uint16_t, >); +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_int32_t, @KWIML@_INT_uint32_t, <); +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uint32_t, @KWIML@_INT_uint32_t, >); +#if !defined(@KWIML@_INT_NO_INT64_T) +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_int64_t, @KWIML@_INT_uint64_t, <); +#endif +#if !defined(@KWIML@_INT_NO_UINT64_T) +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uint64_t, @KWIML@_INT_uint64_t, >); +#endif +#if !defined(@KWIML@_INT_NO_INTPTR_T) +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_intptr_t, @KWIML@_INT_uintptr_t, <); +#endif +#if !defined(@KWIML@_INT_NO_UINTPTR_T) +@KWIML@_INT__VERIFY_SIGN(@KWIML@_INT_uintptr_t, @KWIML@_INT_uintptr_t, >); +#endif + +#undef @KWIML@_INT__VERIFY_SIGN +#undef @KWIML@_INT__VERIFY_TYPE +#undef @KWIML@_INT__VERIFY_BOOL +#undef @KWIML@_INT__VERIFY + +#endif + +#endif diff --git a/Utilities/KWIML/README.txt b/Utilities/KWIML/README.txt new file mode 100644 index 000000000..6bdf859d9 --- /dev/null +++ b/Utilities/KWIML/README.txt @@ -0,0 +1,29 @@ +KWIML - The Kitware Information Macro Library + +KWIML provides header files that use preprocessor tests to detect and +provide information about the compiler and its target architecture. The +headers contain no configuration-time test results and thus may be +installed into an architecture-independent include directory. This +makes them suitable for use in the public interface of any package. + +This source tree is intended for distribution inside the source trees of +other packages. In order to avoid name collisions among multiple +packages the KWIML headers are configured with a per-package prefix on +both the header locations and the macros they define. See comments in +CMakeLists.txt for instructions to include KWIML inside another project. + +The entire KWIML source tree is distributed under the OSI-approved +3-clause BSD License. Files used only for build and test purposes +contain a copyright notice and reference Copyright.txt for details. +Headers meant for installation and distribution outside the source tree +come with full inlined copies of the copyright notice and license text. +This makes them suitable for distribution with any package under +compatible license terms. + +The following components are provided. See header comments for details: + + ABI.h = Fundamental type size and representation + INT.h = Fixed-size integer types and format specifiers + +The "test" subdirectory builds tests that verify correctness of the +information provided by each header. diff --git a/Utilities/KWIML/test/CMakeLists.txt b/Utilities/KWIML/test/CMakeLists.txt new file mode 100644 index 000000000..a2359cce1 --- /dev/null +++ b/Utilities/KWIML/test/CMakeLists.txt @@ -0,0 +1,70 @@ +#============================================================================= +# Kitware Information Macro Library +# Copyright 2010-2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= + +set(test_defs KWIML_NAMESPACE=${KWIML}) + +# Tell CMake how to follow dependencies of sources in this directory. +set_property(DIRECTORY + PROPERTY IMPLICIT_DEPENDS_INCLUDE_TRANSFORM + "KWIML_HEADER(%)=<${KWIML}/%>" + ) + +# Suppress printf/scanf format warnings; we test if the sizes match. +foreach(lang C CXX) + if(KWIML_LANGUAGE_${lang} AND "${CMAKE_${lang}_COMPILER_ID}" STREQUAL GNU) + set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -Wno-format") + endif() +endforeach() + +if(KWIML_LANGUAGE_C) + set(test_srcs test.c) +else() + set(test_srcs test.cxx) +endif() +if(KWIML_LANGUAGE_C) + list(APPEND test_defs KWIML_LANGUAGE_C) + list(APPEND test_srcs + test_ABI_C.c + test_INT_C.c + test_include_C.c + ) +endif() +if(KWIML_LANGUAGE_CXX) + list(APPEND test_defs KWIML_LANGUAGE_CXX) + list(APPEND test_srcs + test_ABI_CXX.cxx + test_INT_CXX.cxx + test_include_CXX.cxx + ) +endif() + +foreach(th test_ABI_endian test_INT_format) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${th}.h.in + ${CMAKE_CURRENT_BINARY_DIR}/${th}.h @ONLY) +endforeach() +include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) +add_executable(${KWIML}_test ${test_srcs}) +set_property(TARGET ${KWIML}_test PROPERTY COMPILE_DEFINITIONS ${test_defs}) +set_property(TARGET ${KWIML}_test PROPERTY + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) +add_test(${KWIML}.test ${CMAKE_CURRENT_BINARY_DIR}/${KWIML}_test) +set_property(TEST ${KWIML}.test PROPERTY LABELS ${KWIML_LABELS_TEST}) + +# Xcode 2.x forgets to create the output directory before linking +# the individual architectures. +if(CMAKE_OSX_ARCHITECTURES AND XCODE + AND NOT "${XCODE_VERSION}" MATCHES "^[^12]") + add_custom_command( + TARGET ${KWIML}_test + PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}" + ) +endif() diff --git a/Utilities/KWIML/test/test.c b/Utilities/KWIML/test/test.c new file mode 100644 index 000000000..131c81f92 --- /dev/null +++ b/Utilities/KWIML/test/test.c @@ -0,0 +1,39 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifdef __cplusplus +extern "C" { +#endif +extern int test_ABI_C(void); +extern int test_INT_C(void); +extern int test_ABI_CXX(void); +extern int test_INT_CXX(void); +extern int test_include_C(void); +extern int test_include_CXX(void); +#ifdef __cplusplus +} // extern "C" +#endif + +int main(void) +{ + int result = 1; +#ifdef KWIML_LANGUAGE_C + result = test_ABI_C() && result; + result = test_INT_C() && result; + result = test_include_C() && result; +#endif +#ifdef KWIML_LANGUAGE_CXX + result = test_ABI_CXX() && result; + result = test_INT_CXX() && result; + result = test_include_CXX() && result; +#endif + return result? 0 : 1; +} diff --git a/Utilities/KWIML/test/test.cxx b/Utilities/KWIML/test/test.cxx new file mode 100644 index 000000000..bf614218a --- /dev/null +++ b/Utilities/KWIML/test/test.cxx @@ -0,0 +1,12 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "test.c" diff --git a/Utilities/KWIML/test/test.h b/Utilities/KWIML/test/test.h new file mode 100644 index 000000000..b87a0e7e9 --- /dev/null +++ b/Utilities/KWIML/test/test.h @@ -0,0 +1,37 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef KWIML_NAMESPACE +# error "Do not include test.h outside of KWIML test files." +#endif + +#ifndef KWIML_TEST_H +#define KWIML_TEST_H + +/* + Define KWIML_HEADER macro to help the test files include kwiml + headers from the configured namespace directory. The macro can be + used like this: + + #include KWIML_HEADER(ABI.h) +*/ +#define KWIML_HEADER(x) KWIML_HEADER0(KWIML_NAMESPACE/x) +#define KWIML_HEADER0(x) KWIML_HEADER1(x) +#define KWIML_HEADER1(x) + +/* Quiet MS standard library deprecation warnings. */ +#ifndef _CRT_SECURE_NO_DEPRECATE +# define _CRT_SECURE_NO_DEPRECATE +#endif + +#else +# error "test.h included multiple times." +#endif diff --git a/Utilities/KWIML/test/test_ABI_C.c b/Utilities/KWIML/test/test_ABI_C.c new file mode 100644 index 000000000..3ca4ad390 --- /dev/null +++ b/Utilities/KWIML/test/test_ABI_C.c @@ -0,0 +1,22 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "test.h" +#include KWIML_HEADER(ABI.h) +#include "test_ABI_endian.h" +int test_ABI_C(void) +{ + if(!test_ABI_endian()) + { + return 0; + } + return 1; +} diff --git a/Utilities/KWIML/test/test_ABI_CXX.cxx b/Utilities/KWIML/test/test_ABI_CXX.cxx new file mode 100644 index 000000000..7ede20e09 --- /dev/null +++ b/Utilities/KWIML/test/test_ABI_CXX.cxx @@ -0,0 +1,22 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "test.h" +#include KWIML_HEADER(ABI.h) +#include "test_ABI_endian.h" +extern "C" int test_ABI_CXX(void) +{ + if(!test_ABI_endian()) + { + return 0; + } + return 1; +} diff --git a/Utilities/KWIML/test/test_ABI_endian.h.in b/Utilities/KWIML/test/test_ABI_endian.h.in new file mode 100644 index 000000000..992baeaeb --- /dev/null +++ b/Utilities/KWIML/test/test_ABI_endian.h.in @@ -0,0 +1,47 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include + +#ifdef __cplusplus +# define LANG "C++ " +#else +# define LANG "C " +#endif + +static int test_ABI_endian(void) +{ + int result = 1; + { +#if defined(@KWIML@_ABI_ENDIAN_ID) + int expect; + union { short s; unsigned char c[sizeof(short)]; } x; + x.s = 1; + expect = (x.c[0] == 1 ? + @KWIML@_ABI_ENDIAN_ID_LITTLE : @KWIML@_ABI_ENDIAN_ID_BIG); + printf(LANG "@KWIML@_ABI_ENDIAN_ID: expected [%d], got [%d]", + expect, @KWIML@_ABI_ENDIAN_ID); + if(@KWIML@_ABI_ENDIAN_ID == expect) + { + printf(", PASSED\n"); + } + else + { + printf(", FAILED\n"); + result = 0; + } +#else + printf(LANG "@KWIML@_ABI_ENDIAN_ID: unknown, FAILED\n"); + result = 0; +#endif + } + return result; +} diff --git a/Utilities/KWIML/test/test_INT_C.c b/Utilities/KWIML/test/test_INT_C.c new file mode 100644 index 000000000..5513a0bd8 --- /dev/null +++ b/Utilities/KWIML/test/test_INT_C.c @@ -0,0 +1,22 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "test.h" +#include KWIML_HEADER(INT.h) +#include "test_INT_format.h" +int test_INT_C(void) +{ + if(!test_INT_format()) + { + return 0; + } + return 1; +} diff --git a/Utilities/KWIML/test/test_INT_CXX.cxx b/Utilities/KWIML/test/test_INT_CXX.cxx new file mode 100644 index 000000000..9f74e9680 --- /dev/null +++ b/Utilities/KWIML/test/test_INT_CXX.cxx @@ -0,0 +1,22 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include "test.h" +#include KWIML_HEADER(INT.h) +#include "test_INT_format.h" +extern "C" int test_INT_CXX(void) +{ + if(!test_INT_format()) + { + return 0; + } + return 1; +} diff --git a/Utilities/KWIML/test/test_INT_format.h.in b/Utilities/KWIML/test/test_INT_format.h.in new file mode 100644 index 000000000..72a62f259 --- /dev/null +++ b/Utilities/KWIML/test/test_INT_format.h.in @@ -0,0 +1,188 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include +#include + +#ifdef __cplusplus +# define LANG "C++ " +#else +# define LANG "C " +#endif + +#define VALUE(T, U) \ + (@KWIML@_INT_##T)((@KWIML@_INT_##U)0xab << \ + ((sizeof(@KWIML@_INT_##T)-1)<<3)) \ + +#define TEST_C(C, V, PRI, T, U) \ + { \ + @KWIML@_INT_##T const x = VALUE(T, U); \ + @KWIML@_INT_##T y = @KWIML@_INT_##C(V); \ + printf(LANG "@KWIML@_INT_" #C ":" \ + " expression [%"@KWIML@_INT_PRI##PRI"]," \ + " literal [%"@KWIML@_INT_PRI##PRI"]", x, y); \ + if(x == y) \ + { \ + printf(", PASSED\n"); \ + } \ + else \ + { \ + printf(", FAILED\n"); \ + result = 0; \ + } \ + } + +#define TEST_PRI(PRI, T, U, STR) \ + { \ + @KWIML@_INT_##T const x = VALUE(T, U); \ + char const* str = STR; \ + sprintf(buf, "%"@KWIML@_INT_PRI##PRI, x); \ + printf(LANG "@KWIML@_INT_PRI" #PRI ":" \ + " expected [%s], got [%s]", str, buf); \ + if(strcmp(str, buf) == 0) \ + { \ + printf(", PASSED\n"); \ + } \ + else \ + { \ + printf(", FAILED\n"); \ + result = 0; \ + } \ + } + +#define TEST_SCN(SCN, T, U, STR) TEST_SCN2(SCN, SCN, T, U, STR) +#define TEST_SCN2(PRI, SCN, T, U, STR) \ + { \ + @KWIML@_INT_##T const x = VALUE(T, U); \ + @KWIML@_INT_##T y; \ + char const* str = STR; \ + if(sscanf(str, "%"@KWIML@_INT_SCN##SCN, &y) != 1) \ + { \ + y = 0; \ + } \ + printf(LANG "@KWIML@_INT_SCN" #SCN ":" \ + " expected [%"@KWIML@_INT_PRI##PRI"]," \ + " got [%"@KWIML@_INT_PRI##PRI"]", x, y); \ + if(x == y) \ + { \ + printf(", PASSED\n"); \ + } \ + else \ + { \ + printf(", FAILED\n"); \ + result = 0; \ + } \ + } + +#define TEST(FMT, T, U, STR) TEST2(FMT, FMT, T, U, STR) +#define TEST2(PRI, SCN, T, U, STR) \ + TEST_PRI(PRI, T, U, STR) \ + TEST_SCN2(PRI, SCN, T, U, STR) + +static int test_INT_format(void) +{ + int result = 1; + char buf[256]; + TEST_PRI(i8, int8_t, uint8_t, "-85") +#if defined(@KWIML@_INT_SCNi8) + TEST_SCN(i8, int8_t, uint8_t, "-85") +#endif + TEST_PRI(d8, int8_t, uint8_t, "-85") +#if defined(@KWIML@_INT_SCNd8) + TEST_SCN(d8, int8_t, uint8_t, "-85") +#endif + TEST_PRI(o8, uint8_t, uint8_t, "253") +#if defined(@KWIML@_INT_SCNo8) + TEST_SCN(o8, uint8_t, uint8_t, "253") +#endif + TEST_PRI(u8, uint8_t, uint8_t, "171") +#if defined(@KWIML@_INT_SCNu8) + TEST_SCN(u8, uint8_t, uint8_t, "171") +#endif + TEST_PRI(x8, uint8_t, uint8_t, "ab") + TEST_PRI(X8, uint8_t, uint8_t, "AB") +#if defined(@KWIML@_INT_SCNx8) + TEST_SCN(x8, uint8_t, uint8_t, "ab") + TEST_SCN2(X8, x8, uint8_t, uint8_t, "AB") +#endif + + TEST(i16, int16_t, uint16_t, "-21760") + TEST(d16, int16_t, uint16_t, "-21760") + TEST(o16, uint16_t, uint16_t, "125400") + TEST(u16, uint16_t, uint16_t, "43776") + TEST(x16, uint16_t, uint16_t, "ab00") + TEST2(X16, x16, uint16_t, uint16_t, "AB00") + + TEST(i32, int32_t, uint32_t, "-1426063360") + TEST(d32, int32_t, uint32_t, "-1426063360") + TEST(o32, uint32_t, uint32_t, "25300000000") + TEST(u32, uint32_t, uint32_t, "2868903936") + TEST(x32, uint32_t, uint32_t, "ab000000") + TEST2(X32, x32, uint32_t, uint32_t, "AB000000") + + TEST_PRI(i64, int64_t, uint64_t, "-6124895493223874560") +#if defined(@KWIML@_INT_SCNi64) + TEST_SCN(i64, int64_t, uint64_t, "-6124895493223874560") +#endif + TEST_PRI(d64, int64_t, uint64_t, "-6124895493223874560") +#if defined(@KWIML@_INT_SCNd64) + TEST_SCN(d64, int64_t, uint64_t, "-6124895493223874560") +#endif + TEST_PRI(o64, uint64_t, uint64_t, "1254000000000000000000") +#if defined(@KWIML@_INT_SCNo64) + TEST_SCN(o64, uint64_t, uint64_t, "1254000000000000000000") +#endif + TEST_PRI(u64, uint64_t, uint64_t, "12321848580485677056") +#if defined(@KWIML@_INT_SCNu64) + TEST_SCN(u64, uint64_t, uint64_t, "12321848580485677056") +#endif + TEST_PRI(x64, uint64_t, uint64_t, "ab00000000000000") + TEST_PRI(X64, uint64_t, uint64_t, "AB00000000000000") +#if defined(@KWIML@_INT_SCNx64) + TEST_SCN(x64, uint64_t, uint64_t, "ab00000000000000") + TEST_SCN2(X64, x64, uint64_t, uint64_t, "AB00000000000000") +#endif + +#if !defined(@KWIML@_INT_NO_INTPTR_T) +# if @KWIML@_ABI_SIZEOF_DATA_PTR == 4 + TEST(iPTR, intptr_t, uint32_t, "-1426063360") + TEST(dPTR, intptr_t, uint32_t, "-1426063360") +# else + TEST(iPTR, intptr_t, uint64_t, "-6124895493223874560") + TEST(dPTR, intptr_t, uint64_t, "-6124895493223874560") +# endif +#endif + +#if !defined(@KWIML@_INT_NO_UINTPTR_T) +# if @KWIML@_ABI_SIZEOF_DATA_PTR == 4 + TEST(oPTR, uintptr_t, uintptr_t, "25300000000") + TEST(uPTR, uintptr_t, uintptr_t, "2868903936") + TEST(xPTR, uintptr_t, uintptr_t, "ab000000") + TEST2(XPTR, xPTR, uintptr_t, uintptr_t, "AB000000") +# else + TEST(oPTR, uintptr_t, uintptr_t, "1254000000000000000000") + TEST(uPTR, uintptr_t, uintptr_t, "12321848580485677056") + TEST(xPTR, uintptr_t, uintptr_t, "ab00000000000000") + TEST2(XPTR, xPTR, uintptr_t, uintptr_t, "AB00000000000000") +# endif +#endif + + TEST_C(INT8_C, -0x55, i8, int8_t, uint8_t) + TEST_C(UINT8_C, 0xAB, u8, uint8_t, uint8_t) + TEST_C(INT16_C, -0x5500, i16, int16_t, uint16_t) + TEST_C(UINT16_C, 0xAB00, u16, uint16_t, uint16_t) + TEST_C(INT32_C, -0x55000000, i32, int32_t, uint32_t) + TEST_C(UINT32_C, 0xAB000000, u32, uint32_t, uint32_t) + TEST_C(INT64_C, -0x5500000000000000, i64, int64_t, uint64_t) + TEST_C(UINT64_C, 0xAB00000000000000, u64, uint64_t, uint64_t) + + return result; +} diff --git a/Utilities/KWIML/test/test_include_C.c b/Utilities/KWIML/test/test_include_C.c new file mode 100644 index 000000000..fb3e4cf7f --- /dev/null +++ b/Utilities/KWIML/test/test_include_C.c @@ -0,0 +1,22 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include + +/* Test KWIML header inclusion after above system headers. */ +#include "test.h" +#include KWIML_HEADER(ABI.h) +#include KWIML_HEADER(INT.h) + +int test_include_C(void) +{ + return 1; +} diff --git a/Utilities/KWIML/test/test_include_CXX.cxx b/Utilities/KWIML/test/test_include_CXX.cxx new file mode 100644 index 000000000..111311a84 --- /dev/null +++ b/Utilities/KWIML/test/test_include_CXX.cxx @@ -0,0 +1,28 @@ +/*============================================================================ + Kitware Information Macro Library + Copyright 2010-2011 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#include + +#if defined(_MSC_VER) && defined(NDEBUG) +// Use C++ runtime to avoid linker warning: +// warning LNK4089: all references to 'MSVCP71.dll' discarded by /OPT:REF +std::string test_include_CXX_use_stl_string; +#endif + +/* Test KWIML header inclusion after above system headers. */ +#include "test.h" +#include KWIML_HEADER(ABI.h) +#include KWIML_HEADER(INT.h) + +extern "C" int test_include_CXX(void) +{ + return 1; +} diff --git a/Utilities/KWStyle/CMakeLists.txt b/Utilities/KWStyle/CMakeLists.txt index 4803ffa98..5b0c84e8b 100644 --- a/Utilities/KWStyle/CMakeLists.txt +++ b/Utilities/KWStyle/CMakeLists.txt @@ -12,17 +12,34 @@ #----------------------------------------------------------------------------- # CMake uses KWStyle for checking the coding style -OPTION(CMAKE_USE_KWSTYLE "Run KWStyle in order to check for violations of the coding standard." OFF) -MARK_AS_ADVANCED(CMAKE_USE_KWSTYLE) -IF(CMAKE_USE_KWSTYLE) - FIND_PROGRAM(KWSTYLE_EXECUTABLE +# Search for a built-from-source KWStyle under Dashboards/Support on a typical +# dashboard machines: +# +SET(home "$ENV{HOME}") +IF(NOT home) + STRING(REPLACE "\\" "/" home "$ENV{USERPROFILE}") +ENDIF() + +FIND_PROGRAM(KWSTYLE_EXECUTABLE NAMES KWStyle PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Kitware Inc.\\KWStyle 1.0.0]/bin" + "${home}/Dashboards/Support/KWStyle/bin" ) - MARK_AS_ADVANCED(KWSTYLE_EXECUTABLE) +MARK_AS_ADVANCED(KWSTYLE_EXECUTABLE) + +SET(CMAKE_USE_KWSTYLE_DEFAULT OFF) +IF(KWSTYLE_EXECUTABLE) + SET(CMAKE_USE_KWSTYLE_DEFAULT ON) +ENDIF() +OPTION(CMAKE_USE_KWSTYLE + "Add StyleCheck target and KWStyle test: run KWStyle to check for coding standard violations." + ${CMAKE_USE_KWSTYLE_DEFAULT}) +MARK_AS_ADVANCED(CMAKE_USE_KWSTYLE) + +IF(CMAKE_USE_KWSTYLE) OPTION(KWSTYLE_USE_VIM_FORMAT "Set KWStyle to generate errors with a VIM-compatible format." OFF) OPTION(KWSTYLE_USE_MSVC_FORMAT "Set KWStyle to generate errors with a VisualStudio-compatible format." OFF) MARK_AS_ADVANCED(KWSTYLE_USE_VIM_FORMAT) @@ -59,4 +76,3 @@ IF(CMAKE_USE_KWSTYLE) ADD_CUSTOM_TARGET(StyleCheck DEPENDS ${CMake_BINARY_DIR}/KWStyleReport.txt) ENDIF(CMAKE_USE_KWSTYLE) - diff --git a/Utilities/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake index 75b00616a..c304e6777 100644 --- a/Utilities/Release/create-cmake-release.cmake +++ b/Utilities/Release/create-cmake-release.cmake @@ -7,9 +7,9 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/logs) set(RELEASE_SCRIPTS_BATCH_1 dash2win64_release.cmake # Windows - dashmacmini2_release.cmake # Mac Darwin universal + dashmacmini2_release.cmake # Mac Darwin universal ppc;i386 + dashmacmini5_release.cmake # Mac Darwin64 universal x86_64;i386 magrathea_release.cmake # Linux - dashsun1_release.cmake # SunOS v20n250_aix_release.cmake # AIX 5.3 ferrari_sgi64_release.cmake # IRIX 64 ferrari_sgi_release.cmake # IRIX diff --git a/Utilities/Release/dash2win64_cygwin.cmake b/Utilities/Release/dash2win64_cygwin.cmake index da6600292..74d501243 100644 --- a/Utilities/Release/dash2win64_cygwin.cmake +++ b/Utilities/Release/dash2win64_cygwin.cmake @@ -8,6 +8,7 @@ set(CPACK_SOURCE_GENERATORS "CygwinSource") set(MAKE_PROGRAM "make") set(INITIAL_CACHE "CMAKE_BUILD_TYPE:STRING=Release CMAKE_Fortran_COMPILER_FULLPATH:FILEPATH=FALSE +DART_TESTING_TIMEOUT:STRING=7200 ") set(CXX g++) set(CC gcc) diff --git a/Utilities/Release/dashmacmini2_release.cmake b/Utilities/Release/dashmacmini2_release.cmake index d117014f9..115181de2 100644 --- a/Utilities/Release/dashmacmini2_release.cmake +++ b/Utilities/Release/dashmacmini2_release.cmake @@ -6,13 +6,12 @@ set(HOST dashmacmini2) set(MAKE_PROGRAM "make") set(MAKE "${MAKE_PROGRAM} -j2") set(CPACK_BINARY_GENERATORS "PackageMaker TGZ TZ") -set(CPACK_SOURCE_GENERATORS "TGZ TZ") set(INITIAL_CACHE " CMAKE_BUILD_TYPE:STRING=Release CMAKE_OSX_ARCHITECTURES:STRING=ppc;i386 CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE CPACK_SYSTEM_NAME:STRING=Darwin-universal -BUILD_QtDialog:BOOL:=TRUE +BUILD_QtDialog:BOOL=TRUE QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Software/QtBinUniversal/bin/qmake ") get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) diff --git a/Utilities/Release/dashmacmini5_release.cmake b/Utilities/Release/dashmacmini5_release.cmake new file mode 100644 index 000000000..9bb3a98a0 --- /dev/null +++ b/Utilities/Release/dashmacmini5_release.cmake @@ -0,0 +1,20 @@ +set(PROCESSORS 4) +set(CMAKE_RELEASE_DIRECTORY /Users/kitware/CMakeReleaseDirectory) +# set(USER_OVERRIDE "set(CMAKE_CXX_LINK_EXECUTABLE \\\"gcc -o -shared-libgcc -lstdc++-static\\\")") +set(INSTALL_PREFIX /) +set(HOST dashmacmini5) +set(MAKE_PROGRAM "make") +set(MAKE "${MAKE_PROGRAM} -j5") +set(CPACK_BINARY_GENERATORS "PackageMaker TGZ TZ") +set(CPACK_SOURCE_GENERATORS "TGZ TZ") +set(INITIAL_CACHE " +CMAKE_BUILD_TYPE:STRING=Release +CMAKE_OSX_ARCHITECTURES:STRING=x86_64;i386 +CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.5 +CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE +CPACK_SYSTEM_NAME:STRING=Darwin64-universal +BUILD_QtDialog:BOOL=TRUE +QT_QMAKE_EXECUTABLE:FILEPATH=/Users/kitware/Support/qt-4.7.4/install/bin/qmake +") +get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) +include(${path}/release_cmake.cmake) diff --git a/Utilities/Release/dashsun1_release.cmake b/Utilities/Release/dashsun1_release.cmake deleted file mode 100644 index f98795d9d..000000000 --- a/Utilities/Release/dashsun1_release.cmake +++ /dev/null @@ -1,18 +0,0 @@ -set(PROCESSORS 1) -set(HOST dashsun1) -set(CMAKE_RELEASE_DIRECTORY "/home/kitware/CMakeReleaseDirectory" ) -set(MAKE_PROGRAM "make") -set(USER_MAKE_RULE_FILE - "/home/kitware/CMakeReleaseDirectory/UserMakeRules.cmake") -set(INITIAL_CACHE " -CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE -CMAKE_BUILD_TYPE:STRING=Release -HAVE_LIBDL:INTERNAL=FALSE -CMAKE_EXE_LINKER_FLAGS:STRING=-Bdynamic -ldl -Bstatic -CMAKE_USER_MAKE_RULES_OVERRIDE:STRING=${USER_MAKE_RULE_FILE} -CURSES_LIBRARY:FILEPATH=/usr/lib/libcurses.a -FORM_LIBRARY:FILEPATH=/usr/lib/libform.a") -set(USER_MAKE_RULE_FILE_CONTENTS - "SET(CMAKE_DL_LIBS \\\"-Bdynamic -ldl -Bstatic\\\")") -get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH) -include(${path}/release_cmake.cmake) diff --git a/Utilities/cmake.m4 b/Utilities/cmake.m4 new file mode 100644 index 000000000..a374a3bfb --- /dev/null +++ b/Utilities/cmake.m4 @@ -0,0 +1,53 @@ +dnl ============================================================================ +dnl CMake - Cross Platform Makefile Generator +dnl Copyright 2011 Matthias Kretz, kretz@kde.org +dnl +dnl Distributed under the OSI-approved BSD License (the "License"); +dnl see accompanying file Copyright.txt for details. +dnl +dnl This software is distributed WITHOUT ANY WARRANTY; without even the +dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +dnl See the License for more information. +dnl ============================================================================ + +AC_DEFUN([CMAKE_FIND_BINARY], +[AC_ARG_VAR([CMAKE_BINARY], [path to the cmake binary])dnl + +if test "x$ac_cv_env_CMAKE_BINARY_set" != "xset"; then + AC_PATH_TOOL([CMAKE_BINARY], [cmake])dnl +fi +])dnl + +# $1: package name +# $2: language (e.g. C/CXX/Fortran) +# $3: The compiler ID, defaults to GNU. +# Possible values are: GNU, Intel, Clang, SunPro, HP, XL, VisualAge, PGI, +# PathScale, Cray, SCO, MIPSpro, MSVC +# $4: optional extra arguments to cmake, e.g. "-DCMAKE_SIZEOF_VOID_P=8" +# $5: optional path to cmake binary +AC_DEFUN([CMAKE_FIND_PACKAGE], [ +AC_REQUIRE([CMAKE_FIND_BINARY])dnl + +AC_ARG_VAR([$1][_][$2][FLAGS], [$2 compiler flags for $1. This overrides the cmake output])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1. This overrides the cmake output])dnl + +failed=false +AC_MSG_CHECKING([for $1]) +if test -n "$1[]_$2[]FLAGS"; then + $1[]_$2[]FLAGS=`$CMAKE_BINARY --find-package "-DNAME=$1" "-DCOMPILER_ID=m4_default([$3], [GNU])" "-DLANGUAGE=$2" -DMODE=COMPILE $4` || failed=true +fi +if test -n "$1[]_LIBS"; then + $1[]_LIBS=`$CMAKE_BINARY --find-package "-DNAME=$1" "-DCOMPILER_ID=m4_default([$3], [GNU])" "-DLANGUAGE=$2" -DMODE=LINK $4` || failed=true +fi + +if $failed; then + unset $1[]_$2[]FLAGS + unset $1[]_LIBS + + AC_MSG_RESULT([no]) + $6 +else + AC_MSG_RESULT([yes]) + $5 +fi[]dnl +]) diff --git a/Utilities/cmlibarchive/build/cmake/CheckFileOffsetBits.cmake b/Utilities/cmlibarchive/build/cmake/CheckFileOffsetBits.cmake index 5f4e053d0..472b80d0d 100644 --- a/Utilities/cmlibarchive/build/cmake/CheckFileOffsetBits.cmake +++ b/Utilities/cmlibarchive/build/cmake/CheckFileOffsetBits.cmake @@ -18,7 +18,7 @@ MACRO (CHECK_FILE_OFFSET_BITS) IF(NOT DEFINED _FILE_OFFSET_BITS) - MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files") + MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files") TRY_COMPILE(__WITHOUT_FILE_OFFSET_BITS_64 ${CMAKE_BINARY_DIR} ${libarchive_SOURCE_DIR}/build/cmake/CheckFileOffsetBits.c @@ -32,10 +32,10 @@ MACRO (CHECK_FILE_OFFSET_BITS) IF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) SET(_FILE_OFFSET_BITS 64 CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files") - MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files - needed") + MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - needed") ELSE(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) SET(_FILE_OFFSET_BITS "" CACHE INTERNAL "_FILE_OFFSET_BITS macro needed for large files") - MESSAGE(STATUS "Cheking _FILE_OFFSET_BITS for large files - not needed") + MESSAGE(STATUS "Checking _FILE_OFFSET_BITS for large files - not needed") ENDIF(NOT __WITHOUT_FILE_OFFSET_BITS_64 AND __WITH_FILE_OFFSET_BITS_64) ENDIF(NOT DEFINED _FILE_OFFSET_BITS) diff --git a/Utilities/cmlibarchive/libarchive/archive.h b/Utilities/cmlibarchive/libarchive/archive.h index 9b918a82b..8bc612f4b 100644 --- a/Utilities/cmlibarchive/libarchive/archive.h +++ b/Utilities/cmlibarchive/libarchive/archive.h @@ -52,7 +52,7 @@ /* These should match the types used in 'struct stat' */ #if defined(_WIN32) && !defined(__CYGWIN__) #define __LA_INT64_T __int64 -# if defined(_SSIZE_T_DEFINED) +# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_) # define __LA_SSIZE_T ssize_t # elif defined(_WIN64) # define __LA_SSIZE_T __int64 diff --git a/bootstrap b/bootstrap index c9998882e..3daac2a37 100755 --- a/bootstrap +++ b/bootstrap @@ -215,6 +215,7 @@ CMAKE_CXX_SOURCES="\ cmMakefileLibraryTargetGenerator \ cmMakefileTargetGenerator \ cmMakefileUtilityTargetGenerator \ + cmNewLineStyle \ cmBootstrapCommands \ cmCommands \ cmTarget \