diff --git a/.gitattributes b/.gitattributes index 878221f9b..43676a97f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12,3 +12,9 @@ configure crlf=input *.dsw -crlf *.sln -crlf *.vcproj -crlf + +*.c whitespace=tab-in-indent +*.h whitespace=tab-in-indent +*.cxx whitespace=tab-in-indent +*.txt whitespace=tab-in-indent +*.cmake whitespace=tab-in-indent diff --git a/CMakeLists.txt b/CMakeLists.txt index 23dd2a522..be5a67f72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,18 +69,25 @@ MACRO(CMAKE_HANDLE_SYSTEM_LIBRARIES) CACHE BOOL "Use system-installed expat" FORCE) SET(CMAKE_USE_SYSTEM_ZLIB "${CMAKE_USE_SYSTEM_LIBRARIES}" CACHE BOOL "Use system-installed zlib" FORCE) + SET(CMAKE_USE_SYSTEM_BZIP2 "${CMAKE_USE_SYSTEM_LIBRARIES}" + CACHE BOOL "Use system-installed bzip2" FORCE) + SET(CMAKE_USE_SYSTEM_LIBARCHIVE "${CMAKE_USE_SYSTEM_LIBRARIES}" + CACHE BOOL "Use system-installed libarchive" FORCE) ENDIF(CMAKE_USE_SYSTEM_LIBRARIES_USER) # Optionally use system utility libraries. + OPTION(CMAKE_USE_SYSTEM_LIBARCHIVE "Use system-installed libarchive" ${CMAKE_USE_SYSTEM_LIBRARIES}) CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_CURL "Use system-installed curl" ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CTEST_USE_XMLRPC" ON) CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_EXPAT "Use system-installed expat" ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CTEST_USE_XMLRPC" ON) CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_ZLIB "Use system-installed zlib" - ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CMAKE_USE_SYSTEM_CURL" ON) + ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CMAKE_USE_SYSTEM_LIBARCHIVE;NOT CMAKE_USE_SYSTEM_CURL" ON) + CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_BZIP2 "Use system-installed bzip2" + ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON) # Mention to the user what system libraries are being used. - FOREACH(util CURL EXPAT XMLRPC ZLIB) + FOREACH(util BZIP2 CURL EXPAT LIBARCHIVE ZLIB) IF(CMAKE_USE_SYSTEM_${util}) MESSAGE(STATUS "Using system-installed ${util}") ENDIF(CMAKE_USE_SYSTEM_${util}) @@ -173,6 +180,36 @@ MACRO(CMAKE_SETUP_TESTING) ENDMACRO(CMAKE_SETUP_TESTING) +# Provide a way for Visual Studio Express users to turn OFF the new FOLDER +# organization feature. Default to ON for non-Express users. Express users must +# explicitly turn off this option to build CMake in the Express IDE... +# +OPTION(CMAKE_USE_FOLDERS "Enable folder grouping of projects in IDEs." ON) +MARK_AS_ADVANCED(CMAKE_USE_FOLDERS) + + +#----------------------------------------------------------------------- +# a macro that only sets the FOLDER target property if it's +# "appropriate" +#----------------------------------------------------------------------- +MACRO(CMAKE_SET_TARGET_FOLDER tgt folder) + IF(CMAKE_USE_FOLDERS) + SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON) + + # Really, I just want this to be an "if(TARGET ${tgt})" ... + # but I'm not sure that our min req'd., CMake 2.4.5 can handle + # that... so I'm just activating this for now, with a version + # compare, and only for MSVC builds. + IF(MSVC) + IF(NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} LESS 2.8) + SET_PROPERTY(TARGET "${tgt}" PROPERTY FOLDER "${folder}") + ENDIF() + ENDIF() + ELSE() + SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS OFF) + ENDIF() +ENDMACRO(CMAKE_SET_TARGET_FOLDER) + #----------------------------------------------------------------------- # a macro to build the utilities used by CMake @@ -192,7 +229,17 @@ MACRO (CMAKE_BUILD_UTILITIES) SET(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source) SET(KWSYS_INSTALL_DOC_DIR "${CMake_DOC_DEST}") ADD_SUBDIRECTORY(Source/kwsys) - + SET(kwsys_folder "Utilities/KWSys") + CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE} "${kwsys_folder}") + 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}") + #--------------------------------------------------------------------- # Setup third-party libraries. # Everything in the tree should be able to include files from the @@ -221,6 +268,7 @@ MACRO (CMAKE_BUILD_UTILITIES) SET(CMAKE_ZLIB_INCLUDES) SET(CMAKE_ZLIB_LIBRARIES cmzlib) ADD_SUBDIRECTORY(Utilities/cmzlib) + CMAKE_SET_TARGET_FOLDER(cmzlib "Utilities/3rdParty") ENDIF(CMAKE_USE_SYSTEM_ZLIB) #--------------------------------------------------------------------- @@ -247,6 +295,8 @@ MACRO (CMAKE_BUILD_UTILITIES) SET(CMAKE_CURL_TEST_URL "${CMAKE_TESTS_CDASH_SERVER}/user.php") ENDIF(CMAKE_TESTS_CDASH_SERVER) ADD_SUBDIRECTORY(Utilities/cmcurl) + CMAKE_SET_TARGET_FOLDER(cmcurl "Utilities/3rdParty") + CMAKE_SET_TARGET_FOLDER(LIBCURL "Utilities/3rdParty") ENDIF(CMAKE_USE_SYSTEM_CURL) #--------------------------------------------------------------------- @@ -255,6 +305,7 @@ MACRO (CMAKE_BUILD_UTILITIES) "${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmcompress") SET(CMAKE_COMPRESS_LIBRARIES "cmcompress") ADD_SUBDIRECTORY(Utilities/cmcompress) + CMAKE_SET_TARGET_FOLDER(cmcompress "Utilities/3rdParty") IF(CMAKE_USE_SYSTEM_BZIP2) FIND_PACKAGE(BZip2) ELSE() @@ -262,10 +313,22 @@ MACRO (CMAKE_BUILD_UTILITIES) "${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmbzip2") SET(BZIP2_LIBRARIES cmbzip2) ADD_SUBDIRECTORY(Utilities/cmbzip2) + CMAKE_SET_TARGET_FOLDER(cmbzip2 "Utilities/3rdParty") ENDIF() + + #--------------------------------------------------------------------- + # Build or use system libarchive for CMake and CTest. IF(CMAKE_USE_SYSTEM_LIBARCHIVE) - FIND_PACKAGE(libarchive) - SET(CMAKE_TAR_LIBRARIES libarchive) + IF(EXISTS ${CMAKE_ROOT}/Modules/FindLibArchive.cmake) + FIND_PACKAGE(LibArchive) + ELSE() + CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR) + INCLUDE(${CMake_SOURCE_DIR}/Modules/FindLibArchive.cmake) + ENDIF() + IF(NOT LibArchive_FOUND) + MESSAGE(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBARCHIVE is ON but LibArchive is not found!") + ENDIF() + SET(CMAKE_TAR_LIBRARIES ${LibArchive_LIBRARIES}) ELSE(CMAKE_USE_SYSTEM_LIBARCHIVE) SET(HAVE_LIBZ 1) SET(HAVE_ZLIB_H 1) @@ -275,6 +338,7 @@ MACRO (CMAKE_BUILD_UTILITIES) SET(BUILD_ARCHIVE_WITHIN_CMAKE TRUE) ADD_DEFINITIONS(-DLIBARCHIVE_STATIC) ADD_SUBDIRECTORY(Utilities/cmlibarchive) + CMAKE_SET_TARGET_FOLDER(cmlibarchive "Utilities/3rdParty") SET(CMAKE_TAR_LIBRARIES cmlibarchive ${BZIP2_LIBRARIES}) ENDIF(CMAKE_USE_SYSTEM_LIBARCHIVE) @@ -292,6 +356,7 @@ MACRO (CMAKE_BUILD_UTILITIES) SET(CMAKE_EXPAT_INCLUDES) SET(CMAKE_EXPAT_LIBRARIES cmexpat) ADD_SUBDIRECTORY(Utilities/cmexpat) + CMAKE_SET_TARGET_FOLDER(cmexpat "Utilities/3rdParty") ENDIF(CMAKE_USE_SYSTEM_EXPAT) #--------------------------------------------------------------------- @@ -330,7 +395,21 @@ MACRO (CMAKE_BUILD_UTILITIES) ENDIF(BUILD_CursesDialog) ENDMACRO (CMAKE_BUILD_UTILITIES) - +#----------------------------------------------------------------------- +IF(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD") + EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} + ${CMAKE_CXX_COMPILER_ARG1} -dumpversion + OUTPUT_VARIABLE _GXX_VERSION + ) + STRING(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2" + _GXX_VERSION_SHORT ${_GXX_VERSION}) + IF(_GXX_VERSION_SHORT EQUAL 33) + MESSAGE(FATAL_ERROR + "GXX 3.3 on OpenBSD is known to cause CPack to Crash.\n" + "Please use GXX 4.2 or greater to build CMake on OpenBSD\n" + "${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}") + ENDIF() +ENDIF() #----------------------------------------------------------------------- # The main section of the CMakeLists file @@ -339,7 +418,7 @@ ENDMACRO (CMAKE_BUILD_UTILITIES) # The CMake version number. SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 8) -SET(CMake_VERSION_PATCH 2) +SET(CMake_VERSION_PATCH 3) SET(CMake_VERSION_TWEAK 0) #SET(CMake_VERSION_RC 4) @@ -521,6 +600,10 @@ ADD_SUBDIRECTORY(Source) ADD_SUBDIRECTORY(Utilities) ADD_SUBDIRECTORY(Tests) +CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests") +CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat") +CMAKE_SET_TARGET_FOLDER(documentation "Documentation") + # add a test ADD_TEST(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" --system-information -G "${CMAKE_TEST_GENERATOR}" ) diff --git a/ChangeLog.manual b/ChangeLog.manual index 7b0a90135..c2e2cdf29 100644 --- a/ChangeLog.manual +++ b/ChangeLog.manual @@ -1,3 +1,413 @@ +No changes in CMake 2.8.3 since 2.8.3-rc4. + +Changes in CMake 2.8.3-rc4 (since 2.8.3-rc3) +-------------------------------------------- +Bill Hoffman (1): + When processing DartMeasurements use the tests working directory. + +David Cole (2): + ExternalProject: No svn --username if empty (#11173) + Avoid problem reading jni.h on Macs. + +David Partyka (5): + Fixed appending PATH to dumpbin tool from growing without bounds. + Switch to CMAKE_PATH when doing PATH comparisons on Windows. + Remove unecessary TO_CMAKE_PATH for gp_cmd_dir. + Append the gp_tool path to the system PATH using native slashes. + Fixes to GetPrerequisites for cygwin + +Eric NOULARD (1): + CPackDeb Added several optional debian binary package fields + +Marcus D. Hanwell (2): + ENH: Added case for Python 2.7. + Fixed parallel build for generators with EXTRA. + +Changes in CMake 2.8.3-rc3 (since 2.8.3-rc2) +-------------------------------------------- +Alex Neundorf (4): + Remove trailing whitespace + Add automatic variable CMAKE_CURRENT_LIST_DIR(dir of CMAKE_CURRENT_LIST_FILE) + Use absolute path to FindPackageHandleStandardArgs.cmake everywhere + CodeBlocks Generator: Do not omit files in the project file listing. + +Brad King (4): + VS10: Order .vcxproj dependencies deterministically (#10502) + Document ENABLE_EXPORTS behavior on Mac (#11295) + FindHDF5: Fix typo in parallel-IO support check (#11291) + Xcode: Recognize .hh as C++ (#11307) + +Clinton Stimpson (1): + Find imports dir in Qt 4.7 + +David Partyka (1): + Update module to locate newely released MS MPI HPC Pack R2. + +Philip Lowman (1): + Remove superfluous variable Boost_COMPAT_STATIC_RUNTIME. + +Rolf Eike Beer (2): + FindSubversion: Fix for German localized client (#11273) + FindSubversion: Use C locale to detect version (#11273) + +Changes in CMake 2.8.3-rc2 (since 2.8.3-rc1) +-------------------------------------------- +Alex Neundorf (5): + APPEND and not-APPEND mode of feature_summary() were swapped + Set a default DESCRIPTION if none is given for ALL mode of feature_summary() + Close ENDFUNCTION() properly with the same name as FUNCTION() + Make cmake-gui remember whether the "Advanced" checkbox was checked or not + Also store the required version number in the details message. + +Ben Boeckel (3): + Add test that CMake errors with empty libs + Fix which string is checked for in the test + XCode generation should fail if lang isn't known + +Bill Hoffman (5): + Fix the name of the variable being tested. + Fix KWStyle line length issues. + Add a delay after untar on windows to make external project work on windows 7 + Add a new line to the end of the generated main.cxx for the hpux compiler. + Fix for bug #11274, VS10 custom commands that create files in INTDIR fix. + +Brad King (12): + Evaluate rule variable for executables + ccmake: Fix search with '/' + MinGW: Support long object file lists + Document IMPORTED_NO_SONAME target property + FindMPI: Recoginze -f flags from mpicc (#10771) + Add module-dir flag for Compaq Visual Fortran (#11248) + FindPythonInterp: Look for python2.7 interpreter + VS10: Use $(IntDir) for per-source output directory (#11270) + Reset platform/compiler info status for each language + Remove trailing whitespace from Xcode generator source + VS10: Skip targets with no linker language (#11230) + VS10: Encode custom command comments for echo (#11283) + +Clinton Stimpson (1): + Fix regression in cross-compile patches with finding Qt libs. + +David Cole (7): + Enable calling commands with : in argv[1] (#9963) + No extra spaces in CustomCommand test (#9963) + Avoid CustomCommand test failure on VS71 (#9963) + Update release scripts. + Avoid CustomCommand test failure on VS71 (#9963) + Honor MAKECOMMAND value saved in cache (#11026) + New USE_FOLDERS property OFF by default. (#3796) + +David Gobbi (1): + Set the module prefix, updated Windows suffix. + +Eric NOULARD (2): + InstallGen/CPack fix handling absolute installed file regression + CPackRPM Handle parenthesis in CPACK_SYSTEM_NAME (fix bug 10737) + +James Bigler (2): + Fix for bug 0011263. + Allow -g3 for CUDA v3.0+. + +Mikkel Krautz (2): + Xcode: Avoid trailing space in ARCHS list (#11244) + Xcode: Quote string values containing '$' (#11244) + +Philip Lowman (12): + FindBoost.cmake fixes for issues 11204 & 8529 + FindBoost.cmake: Miscellaneous changes and refactoring + FindBoost.cmake: Add Boost_NO_SYSTEM_PATHS option + FindBoost.cmake: Fix compiling against a boost source tree + FindBoost.cmake: Fixes 11246 + FindBoost.cmake: Fixes 11121 + FindBoost.cmake: Fixes 10436 + FindBoost.cmake: Implements 11160 + Fix 11136: [patch] FindThreads.cmake documents the wrong variable + FindBoost.cmake: Fix library search path glitch introduced in earlier commit + FindFLEX.cmake: Fix issue 11249 + Fixes issue 11279: CMakeDetermineVSServicePack support for VS10 + +Yaakov Selkowitz (2): + FindFLTK*: Use Cygwin fltk on Cygwin (#11290) + Use 'uname -m' for processor on Cygwin (#10774) + +Changes in CMake 2.8.3-rc1 (since 2.8.2) +---------------------------------------- +Alex Neundorf (39): + fix build on SUSE 11.2 in cmcurl due to ssize_t + -add an additional name for finding libtiff on Windows + -fix typo in docs of deprecated MacroAddFileDependencies.cmake + add 2nd, more powerful mode to find_package_handle_standard_args() + -fix indentation of the documentation + Add version checking support to FindFlex and FindPerlLibs + FindSquish doesn't detect the version, remove that from the documentation + Improved version checking for FindRuby using the new mode of FPHSA() + Improved version checking for FindJava using the new FPHSA() mode + Fix DETAILS string with version number in FHPSA() + Improved version checking for FindSubversion using the new mode of FPHSA() + Improved version checking for FindCUDA using the new mode of FPHSA + Use FPHSA() in FindSWIG, including version checking. + Change documentation of Subversion_FOUND and SUBVERSION_FOUND. + Add macro CMakeParseArguments() and use it in FPHSA() + Fix ZLIB version parsing if no TWEAK version exists + Fix EclipseCDT include path parsing with spaces (#10868) + Fix EclipseCDT parsing of builtin macros with spaces (#10868) + Remove trailing spaces + Detect a COMPILER_ID also for ASM. + Add timeout to execute_process() in CMAKE_DETERMINE_COMPILER_ID(). + Fix parsing of builtin macros so Eclipse handles them properly (#10868) + Log the required package version and major improvement to FeatureSummary + Improve documentation. + Improve wording of the documentation. + Add macro ADD_FEATURE_INFO() and improve docs. + Remove trailing whitespace + Make target_link_libraries() complain if bad target name is used + Just warn in case of a bad target as only argument for t_l_l() + Remove trailing whitespace + New CMP0016 for deciding whether an unknown target in TLL() is an error. + Record all considered Config files and their versions. + Improve error message in Config-mode when no appropriate version was found + Replace the two vector with one vector + Small cleanup of FindPackageHandleStandardArgs.cmake + Don't create an empty element at the end of Foo_CONSIDERED_CONFIGS/VERSIONS + Add option CONFIG_MODE to FPHSA() + Improve version notice in the generated message + Improve wording of the error message of find_package() in config-mode + +Andrew Maclean (3): + Adding a FindPostgreSQL.cmake module + Forgot the copyright notice. + Changed ADDITIONAL_SEARCH_PATHS to PostgreSQL_ADDITIONAL_SEARCH_PATHS. + +Arjen Verweij (1): + Pass objects to Intel linker using a response file + +Bill Hoffman (9): + Disable gcc 33 on OpenBSD because it crashes CPack by default. + Fix for bug#10483, INCLUDE_EXTERNAL_MSPROJECT: ProjectGUID now ProjectGuid + Remove the ctest submit larget output test. + Let CMake recognize .CPP .CXX and .C++ as c++ files. + Fix for bug 10388, fix various default flags. + Only use .CPP .CXX and .C++ do not work by default with g+++. + Fix targets with . in the name for VS 10 IDE. + Only test for .CPP on Microsoft compilers which will handle .CPP as c++. + Allow testing of .CPP on WIN32 as it is a case insensitive OS and should work. + +Brad King (69): + ExternalProject: Add LOG_* options to hide step output + FindMPI: Do not parse -l in middle of library name + FindMPI: Parse mpicc flags more carefully (#9093) + Fix or cast integer conversions in cmake + Begin post-2.8.2 development + FindMPI: Failure is not an error if not REQUIRED + FindMPI: Trust mpicc -showme on BlueGene/L + VS: Always separate preprocessor defs by semicolon (#10902) + KWSys: Cleanup putenv leak option implementation + KWSys: Pass ptrdiff_t check result to System.c + Fix or cast more integer conversions in cmake + Use same type in both cases of '?:' operator + FindMPI: Fix parsing of mpicc -Wl,-L link flags (#9093) + Fix signed/unsigned comparison warnings in ccmake + Fix integer conversions in cpack + bootstrap: Detect known C/C++ compiler toolchains + KWSys: Use short fallback timeout for Process tests + KWSys: Optionally suppress consistent test failures + KWSys: Avoid Clang optimizer bug in testProcess-[45] + Poison GCC 3.3 on OpenBSD a bit later + KWSys: Avoid undefined behavior in Process crash tests + Optionally use system bzip2 library (#10932) + ctest_update: Abort if Git FETCH_HEAD has no candidates + ctest_update: Support ".git file" work trees + ctest_update: Run 'git submodule' at top level + FindBoost: Search for Boost 1.42 + Add FindLibArchive module (#10923) + Add option CMAKE_USE_SYSTEM_LIBARCHIVE (#10923) + Refer to self with CMake_(SOURCE|BINARY)_DIR (#10046) + ExternalProject: Fix $(MAKE) with cygpath on Windows + FindBoost: Search for Boost 1.43 and 1.44 + Include headers from chosen libarchive (#10923) + No response files with GNU ld <= 2.16 (#10913) + Create class cmArchiveWrite to wrap libarchive (#11020) + Include entries for directories in tarballs (#11020) + cmArchiveWrite: Fix signed/unsigned compare/convert + cmArchiveWrite: Fix signed/unsigned again + CPack: Avoid member shadowing after API refactor + KWSys: Fix SplitPath for leading '\' on Windows + KWSys: Fix GetActualCaseForPath for UNC paths + ModuleNoticesTest: Do not require "Kitware" copyright + Modules: Fix CMakeParseArguments copyright notice + FortranCInterface: Fix doc typo FC.h -> FCMangle.h + CTest: Avoid use of old EscapeSpaces method + Remove cmSystemTools::EscapeSpaces method + Clarify install(TARGETS) docs for EXPORT option + Factor out global generator ComputeTargetDepends method + Factor out duplicate VS target dependency code + Refactor VS <= 7.1 utility-depends workaround + Restore GetTargetDirectDepends const return + Split notion of node lists and edge lists + Distinguish "strong" and "weak" target dependency edges + Honor strong intra-component target dependencies + libarchive: Remove SCHILY dev,ino,nlink attributes (#11176) + Fix unused parameter warning in VS 7.1 generator + KWSys: Avoid empty string dereference in SplitString + KWSys: Improve SplitPath method documentation + KWSys: Use SplitPath in GetActualCaseForPath + Add whitespace=tab-in-indent attribute for sources + Search MacPorts /opt/local prefix on Mac + HP-UX: Always add /usr/lib to rpath (#10571) + No CMAKE_CONFIGURATION_TYPES in single-config generators (#10202) + KWSys: Suppress -Wcast-align warning in MD5.c + Suppress -Wcast-align in curl and bzip2 + libarchive: Fix purposeful crash + bootstrap: Honor CFLAGS during "make" test (#10545) + file(DOWNLOAD): Fix error message formatting + Fix line-too-long style errors + Report missing source files with context of target + +Clinton Stimpson (10): + Fix performance issue with getting version from zlib.h + Fix bug 10418 - GetPrerequisites returning "not" as a dependency. + Fix regression in 5e6634fd77969433a87c150a2fb3f2079131484f for Windows. + Change Qt4ConfigDependentSettings to use more standard find modules. + Add cross-compiling support to FindQt4.cmake + Tweak for cygwin, don't convert : to ; + Fix some issues with refinding when qmake executable is changed. + Find correct Qt plugins for cross-compiling. + Fix mingw/VS warning message with cross compile re-org. + Make sure moc parameters file goes in binary directory. + +David Cole (20): + CheckSourceTree test: read UpdateCommand from Update.xml. + Eliminate -Wconversion warnings. + Detect CMake warnings and errors in build output. + Activate retry code on any curl submit failure. + Add another expected output for the failed submit tests. + ExternalProject: Use $(MAKE) whenever possible. + Copy Resources in Frameworks during fixup_bundle (#10020) + Update path to git. dashmacmini2 was "upgraded." + ExternalProject: Remove 'unknown keyword' warning (#11034) + Add documentation for CPACK_PROJECT_CONFIG_FILE. + Add STEP_TARGETS to ExternalProject module. + Refine formatting for cmake --help-module output. + Improve documentation of OPTION command. + Add FOLDER target property, for IDEs (#3796) + Avoid adding self as prerequisite. (#10417) + Correct CMAKE_INSTALL_PREFIX value for Win64 apps (#9992) + Preserve timestamps on files on tar extract. + Use QUIET to avoid Java status messages. + VS2010: Honor PROJECT_LABEL target property (#10611) + VS2010: Set IntDir for utility and global targets. + +David Genest (1): + Honor CMAKE_USER_MAKE_RULES_OVERRIDE in try_compile (#10902) + +Eric NOULARD (20): + CPackRPM:: Replace - with _ in RPM Version (fix bug 0010934) + Provides default changelog if no file is provided + CPackRPM:: Quote every filenames in %file section (see bugs 10701,10871,10345) + CPackRPM:: [partially] support relocatable package + CPackDEB: merge wrong installed size patch. see bugs 10296 (and 10292) + CPackDeb optionally generates auto-dependency list part fix of bug 10292 + Proposal for bash-completion support file + CPack: Refactor API in order to handle multi-file packages + CPack: Avoid member shadowing after API refactor (part2) + Improve cmake-completion (install doc, ctest -R completion) + Add ZIP archive format and LZMA compress support to libarchive-wrapper + Add XZ compress support to libarchive-wrapper + Add Compress compress support to libarchive-wrapper + CPack Backward-compatibly enforce DESTDIR for DEB and RPM + CPack Enable better handling of absolute installed files + CPackArchiveGenerator use cmArchiveWrite wrapper + CPackArchiveGenerator add component supports + CPackArchiveGenerator improve usability and robustness + CPack fix broken compilation for CygwinSource generator + CPack handle symlinks in CPACK_INSTALLED_DIRECTORIES fix for bug5430 + +James Bigler (1): + Added CUDA 3.2 directory changes. Disable emulation mode for CUDA 3.1+. + +Kai Wasserbäch (1): + Fix spelling errors reported by Lintian. + +Kovarththanan Rajaratnam (4): + FindZLIB: optimize zlib.h version parsing + FindCygwin: add new registry entry for Cygwin 1.7 (#10951) + FindZLIB: use the FPHSA version mode + FindSubversion: set compatibility variables based on FPHSA() + +Marcel Loose (1): + Issue 10199: Fixed code documentation and now set _WC_ROOT + +Marcus D. Hanwell (1): + Bug with default library type of Python modules. + +Mathieu Malaterre (3): + Add missing PATHS to find_path commands to fix openssl searching + BUG: 0009611 Fix Arch independent FindJNI.cmake on Linux + Fix 11035 : debug/release library configuration mistake + +Michael Wild (2): + Improve documentation of BundleUtilities.cmake + Improve documentation of GetPrerequisites.cmake + +Miguel A. Figueroa-Villanueva (7): + ENH: #9775 Added support for new wxWidgets 2.9 libraries. + BUG: #9775 Fixed patch FindwxWidgets-fixed-bug-9775. + BUG #10658: FindwxWidgets USE_FILE should not include .cmake extension. + STYLE: Clarified/Fixed documentation of UsewxWidgets. + BUG #11123: Generic include dir should come after config specific one. + BUG #8184: Fixed FindwxWidgets wrong order of default libs for MinGW. + ENH #8993: FindwxWidgets add support for wx-config custom options. + +Mike McQuaid (1): + Make bundle items writable before fixup (#9284) + +Modestas Vainius (1): + CTestTestFailedSubmit-xmlrpc: Pass with "Submission problem" + +Patrick Gansterer (4): + VS: Convert PlatformName member to a virtual method + VS: Add more TargetMachine option values + VS: Map /ENTRY linker option to EntryPointSymbol + VS: Add ArchitectureId to VS 8 and 9 generators + +Philip Lowman (7): + Fixes problem finding libraries under Boost (#9510) + Add detection for new pangommconfig.h header file + Several fixes needed to improve Windows support + 11041: Improve FindCxxTest to use Python or Perl automatically; custom flags + 10241: FindBISON.cmake clears wrong variable + 10688: FindGTK2.cmake doesn't auto-detect macports + Merge patch for detecting gdk-pixbuf library + +Pino Toscano (1): + GNU/Hurd platform support fixes (#9873) + +Robert Goulet (1): + VS2010: Disable PDBs when there is no debug info + +Rolf Eike Beer (2): + clean up some stuff in CPack RPM script + Set MSVC_VERSION for MSVC 6, 7, 7.1 (#7944) + +Todd Gamblin (3): + Modules: Fix spelling 'To distributed' -> 'To distribute' + Teach find_* commands to ignore some paths + Add platform files for BlueGene/P systems + +Zach Mullen (12): + Checksums on CTest submit files, and retry timed out submissions. + Cross-platform fixes for checksum/retry code + Fix subscript out of range crash + CTest should resubmit in the checksum failed case + Testing for CTest checksum + Mock checksum failure output for old CDash versions + Checksum test should use CMAKE_TESTS_CDASH_SERVER + Fix cycle detection for test dependencies + More robust cost-based scheduling impl + Fix hard-coded CDash URI in version query + Added CTest command --print-labels + We shouldn't ask CDash for its version info until/unless we actually need it. + No changes in CMake 2.8.2 since 2.8.2-rc4. Changes in CMake 2.8.2-rc4 (since 2.8.2-rc3) diff --git a/Docs/cmake-completion b/Docs/cmake-completion new file mode 100644 index 000000000..011f3fa93 --- /dev/null +++ b/Docs/cmake-completion @@ -0,0 +1,190 @@ +# +# bash-completion file for CMake +# Provided by Eric NOULARD - eric.noulard@gmail.com +# +# see http://bash-completion.alioth.debian.org/ +# and http://www.cmake.org +# +# We will try to complete cmake commands options +# at 2 (or may be 3 levels) +# [cmake|cpack|ctest] +# +# level0 is top level cmake/cpack/ctest options +# level1 is the first argument of level0 option +# level2 is the seconf argument of level1 argument +# FIXME: I don't know how to handle level2 +# +# The file has been proposed for inclusion in the bash-completion package +# https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=312632&group_id=100114 +# In the meantime, +# 1) If you want to test bash completion for cmake/cpack/ctest +# just source the current file at bash prompt +# . ./cmake-completion +# +# 2) If you want to install it for good copy this file to +# cp cmake-completion /etc/bash_completion.d/cmake +# + +# +# cmake command +# +# have cmake && +_cmake() +{ + local cur prev opts words cword + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + # seems to be only available on bash-completion 1.2 + #_get_comp_words_by_ref cur prev + + # cmake command line option we want to complete + opts=`cmake --help | grep "^ \-.*=\ .*" | cut -d" " -f 3 | cut -d= -f 1 | cut -d[ -f 1` + + # + # Complete the arguments to some of + # the most commonly used commands (Level 1). + # + case "${prev}" in + -E) + local running=$(for x in `cmake -E |& grep "^ " | cut -d" " -f 3`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + --help-command) + local running=$(for x in `cmake --help-command-list`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + --help-module) + local running=$(for x in `cmake --help-module-list`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + --help-policy) + local running=$(for x in `cmake --help-policies | grep "^ CMP"`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + --help-property) + local running=$(for x in `cmake --help-property-list`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + --help-variable) + local running=$(for x in `cmake --help-variable-list`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + *) + ;; + esac + + # + # Complete the arguments to some of + # the most commonly used commands (Level 2). + # ?? How to do that .. + + # + # Complete the option (Level 0 - right after cmake) + # + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) +} && +complete -F _cmake -o default cmake + +# +# cpack command +# +#have cpack && +_cpack() +{ + local cur prev opts words cword + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + # seems to be only available on bash-completion 1.2 + #_get_comp_words_by_ref cur prev + + # cpack command line option we want to complete + opts=`cpack --help | grep "^ \-.*=\ .*" | cut -d" " -f 3 | cut -d= -f 1` + opts="${opts} --help -V" + + # + # Complete the arguments to some of + # the most commonly used commands (Level 1). + # + case "${prev}" in + -G) + local running=$(for x in `cpack --help | grep "^ .*=\ .*" | grep -v "^ -" | cut -d" " -f 3`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + --config) + COMPREPLY=( $(compgen -f ${cur}) ) + return 0 + ;; + *) + ;; + esac + + # + # Complete the option (Level 0 - right after cmake) + # + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) +} && +complete -F _cpack -o default cpack + +# +# cmake command +# +# have ctest && +_ctest() +{ + local cur prev opts words cword + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + # seems to be only available on bash-completion 1.2 + #_get_comp_words_by_ref cur prev + + # cmake command line option we want to complete + opts=`ctest --help | grep "\-\-.*" | cut -d" " -f 3 | sed s/,/\\\n/g` + + # + # Complete the arguments to some of + # the most commonly used commands (Level 1). + # + case "${prev}" in + --help-command) + local running=$(for x in `ctest --help-command-list`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + -R) + local running=$(for x in `ctest -N 2> /dev/null | grep "^ Test" | cut -d: -f 2`; do echo ${x} ; done ) + COMPREPLY=( $(compgen -W "${running}" -- ${cur}) ) + return 0 + ;; + *) + ;; + esac + + # + # Complete the arguments to some of + # the most commonly used commands (Level 2). + # ?? How to do that .. + + # + # Complete the option (Level 0 - right after cmake) + # + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) +} && +complete -F _ctest -o default ctest + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh \ No newline at end of file diff --git a/Modules/AddFileDependencies.cmake b/Modules/AddFileDependencies.cmake index ae2e803ab..f971e37f5 100644 --- a/Modules/AddFileDependencies.cmake +++ b/Modules/AddFileDependencies.cmake @@ -12,7 +12,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(ADD_FILE_DEPENDENCIES _file) diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake index d9c41f48a..c7ead5bd0 100644 --- a/Modules/BundleUtilities.cmake +++ b/Modules/BundleUtilities.cmake @@ -1,9 +1,11 @@ -# BundleUtilities.cmake +# - Functions to help assemble a standalone bundle application. +# A collection of CMake utility functions useful for dealing with .app +# bundles on the Mac and bundle-like directories on any OS. # -# A collection of CMake utility functions useful for dealing with .app bundles -# on the Mac and bundle-like directories on any OS. -# -# The following functions are provided by this script: +# The following functions are provided by this module: +# fixup_bundle +# copy_and_fixup_bundle +# verify_app # get_bundle_main_executable # get_dotapp_dir # get_bundle_and_executable @@ -13,15 +15,121 @@ # set_bundle_key_values # get_bundle_keys # copy_resolved_item_into_bundle +# copy_resolved_framework_into_bundle # fixup_bundle_item -# fixup_bundle -# copy_and_fixup_bundle # verify_bundle_prerequisites # verify_bundle_symlinks -# verify_app -# # Requires CMake 2.6 or greater because it uses function, break and # PARENT_SCOPE. Also depends on GetPrerequisites.cmake. +# +# FIXUP_BUNDLE( ) +# Fix up a bundle in-place and make it standalone, such that it can be +# drag-n-drop copied to another machine and run on that machine as long as all +# of the system libraries are compatible. +# +# Gather all the keys for all the executables and libraries in a bundle, and +# then, for each key, copy each prerequisite into the bundle. Then fix each one +# up according to its own list of prerequisites. +# +# Then clear all the keys and call verify_app on the final bundle to ensure +# that it is truly standalone. +# +# COPY_AND_FIXUP_BUNDLE( ) +# Makes a copy of the bundle at location and then fixes up the +# new copied bundle in-place at ... +# +# VERIFY_APP() +# Verifies that an application appears valid based on running analysis +# tools on it. Calls "message(FATAL_ERROR" if the application is not verified. +# +# GET_BUNDLE_MAIN_EXECUTABLE( ) +# The result will be the full path name of the bundle's main executable file +# or an "error:" prefixed string if it could not be determined. +# +# GET_DOTAPP_DIR( ) +# Returns the nearest parent dir whose name ends with ".app" given the full +# path to an executable. If there is no such parent dir, then return a dir at +# the same level as the executable, named with the executable's base name and +# ending with ".app" +# +# The returned directory may or may not exist. +# +# GET_BUNDLE_AND_EXECUTABLE( ) +# Takes either a ".app" directory name or the name of an executable +# nested inside a ".app" directory and returns the path to the ".app" +# directory in and the path to its main executable in +# +# +# GET_BUNDLE_ALL_EXECUTABLES( ) +# Scans the given bundle recursively for all executable files and accumulates +# them into a variable. +# +# GET_ITEM_KEY( ) +# Given a file (item) name, generate a key that should be unique considering +# the set of libraries that need copying or fixing up to make a bundle +# standalone. This is essentially the file name including extension with "." +# replaced by "_" +# +# This key is used as a prefix for CMake variables so that we can associate a +# set of variables with a given item based on its key. +# +# CLEAR_BUNDLE_KEYS() +# Loop over the list of keys, clearing all the variables associated with each +# key. After the loop, clear the list of keys itself. +# +# Caller of get_bundle_keys should call clear_bundle_keys when done with list +# of keys. +# +# SET_BUNDLE_KEY_VALUES( +# ) +# Add a key to the list (if necessary) for the given item. If added, +# also set all the variables associated with that key. +# +# GET_BUNDLE_KEYS( ) +# Loop over all the executable and library files within the bundle (and given +# as extra ) and accumulate a list of keys representing them. Set +# values associated with each key such that we can loop over all of them and +# copy prerequisite libs into the bundle and then do appropriate +# install_name_tool fixups. +# +# COPY_RESOLVED_ITEM_INTO_BUNDLE( ) +# Copy a resolved item into the bundle if necessary. Copy is not necessary if +# the resolved_item is "the same as" the resolved_embedded_item. +# +# COPY_RESOLVED_FRAMEWORK_INTO_BUNDLE( ) +# Copy a resolved framework into the bundle if necessary. Copy is not necessary +# if the resolved_item is "the same as" the resolved_embedded_item. +# +# By default, BU_COPY_FULL_FRAMEWORK_CONTENTS is not set. If you want full +# frameworks embedded in your bundles, set BU_COPY_FULL_FRAMEWORK_CONTENTS to +# ON before calling fixup_bundle. By default, +# COPY_RESOLVED_FRAMEWORK_INTO_BUNDLE copies the framework dylib itself plus +# the framework Resources directory. +# +# FIXUP_BUNDLE_ITEM( ) +# Get the direct/non-system prerequisites of the resolved embedded item. For +# each prerequisite, change the way it is referenced to the value of the +# _EMBEDDED_ITEM keyed variable for that prerequisite. (Most likely changing to +# an "@executable_path" style reference.) +# +# Also, change the id of the item being fixed up to its own _EMBEDDED_ITEM +# value. +# +# Accumulate changes in a local variable and make *one* call to +# install_name_tool at the end of the function with all the changes at once. +# +# If the BU_CHMOD_BUNDLE_ITEMS variable is set then bundle items will be +# marked writable before install_name_tool tries to change them. +# +# VERIFY_BUNDLE_PREREQUISITES( ) +# Verifies that the sum of all prerequisites of all files inside the bundle +# are contained within the bundle or are "system" libraries, presumed to exist +# everywhere. +# +# VERIFY_BUNDLE_SYMLINKS( ) +# Verifies that any symlinks found in the bundle point to other files that are +# already also in the bundle... Anything that points to an external file causes +# this function to fail the verification. #============================================================================= # Copyright 2008-2009 Kitware, Inc. @@ -33,7 +141,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (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 get_prerequisites function @@ -43,11 +151,6 @@ get_filename_component(BundleUtilities_cmake_dir "${CMAKE_CURRENT_LIST_FILE}" PA include("${BundleUtilities_cmake_dir}/GetPrerequisites.cmake") -# get_bundle_main_executable -# -# The result will be the full path name of the bundle's main executable file -# or an "error:" prefixed string if it could not be determined. -# function(get_bundle_main_executable bundle result_var) set(result "error: '${bundle}/Contents/Info.plist' file does not exist") @@ -109,15 +212,6 @@ function(get_bundle_main_executable bundle result_var) endfunction(get_bundle_main_executable) -# get_dotapp_dir -# -# Returns the nearest parent dir whose name ends with ".app" given the full path -# to an executable. If there is no such parent dir, then return a dir at the same -# level as the executable, named with the executable's base name and ending with -# ".app" -# -# The returned directory may or may not exist. -# function(get_dotapp_dir exe dotapp_dir_var) set(s "${exe}") @@ -155,13 +249,6 @@ function(get_dotapp_dir exe dotapp_dir_var) endfunction(get_dotapp_dir) -# get_bundle_and_executable -# -# Takes either a ".app" directory name or the name of an executable -# nested inside a ".app" directory and returns the path to the ".app" -# directory in ${bundle_var} and the path to its main executable in -# ${executable_var} -# function(get_bundle_and_executable app bundle_var executable_var valid_var) set(valid 0) @@ -215,11 +302,6 @@ function(get_bundle_and_executable app bundle_var executable_var valid_var) endfunction(get_bundle_and_executable) -# get_bundle_all_executables -# -# Scans the given bundle recursively for all executable files and accumulates -# them into a variable. -# function(get_bundle_all_executables bundle exes_var) set(exes "") @@ -235,15 +317,6 @@ function(get_bundle_all_executables bundle exes_var) endfunction(get_bundle_all_executables) -# get_item_key -# -# Given a file (item) name, generate a key that should be unique considering the set of -# libraries that need copying or fixing up to make a bundle standalone. This is -# essentially the file name including extension with "." replaced by "_" -# -# This key is used as a prefix for CMake variables so that we can associate a set -# of variables with a given item based on its key. -# function(get_item_key item key_var) get_filename_component(item_name "${item}" NAME) if(WIN32) @@ -254,14 +327,6 @@ function(get_item_key item key_var) endfunction(get_item_key) -# clear_bundle_keys -# -# Loop over the list of keys, clearing all the variables associated with each -# key. After the loop, clear the list of keys itself. -# -# Caller of get_bundle_keys should call clear_bundle_keys when done with list -# of keys. -# function(clear_bundle_keys keys_var) foreach(key ${${keys_var}}) set(${key}_ITEM PARENT_SCOPE) @@ -275,11 +340,6 @@ function(clear_bundle_keys keys_var) endfunction(clear_bundle_keys) -# set_bundle_key_values -# -# Add a key to the list (if necessary) for the given item. If added, -# also set all the variables associated with that key. -# function(set_bundle_key_values keys_var context item exepath dirs copyflag) get_filename_component(item_name "${item}" NAME) @@ -335,14 +395,6 @@ function(set_bundle_key_values keys_var context item exepath dirs copyflag) endfunction(set_bundle_key_values) -# get_bundle_keys -# -# Loop over all the executable and library files within the bundle (and given as -# extra "${libs}") and accumulate a list of keys representing them. Set values -# associated with each key such that we can loop over all of them and copy -# prerequisite libs into the bundle and then do appropriate install_name_tool -# fixups. -# function(get_bundle_keys app libs dirs keys_var) set(${keys_var} PARENT_SCOPE) @@ -363,7 +415,7 @@ function(get_bundle_keys app libs dirs keys_var) # but that do not show up in otool -L output...) # foreach(lib ${libs}) - set_bundle_key_values(${keys_var} "${lib}" "${lib}" "${exepath}" "${dirs}" 1) + set_bundle_key_values(${keys_var} "${lib}" "${lib}" "${exepath}" "${dirs}" 0) set(prereqs "") get_prerequisites("${lib}" prereqs 1 1 "${exepath}" "${dirs}") @@ -405,11 +457,6 @@ function(get_bundle_keys app libs dirs keys_var) endfunction(get_bundle_keys) -# copy_resolved_item_into_bundle -# -# Copy a resolved item into the bundle if necessary. Copy is not necessary if -# the resolved_item is "the same as" the resolved_embedded_item. -# function(copy_resolved_item_into_bundle resolved_item resolved_embedded_item) if(WIN32) # ignore case on Windows @@ -433,18 +480,48 @@ function(copy_resolved_item_into_bundle resolved_item resolved_embedded_item) endfunction(copy_resolved_item_into_bundle) -# fixup_bundle_item -# -# Get the direct/non-system prerequisites of the resolved embedded item. For each -# prerequisite, change the way it is referenced to the value of the _EMBEDDED_ITEM -# keyed variable for that prerequisite. (Most likely changing to an "@executable_path" -# style reference.) -# -# Also, change the id of the item being fixed up to its own _EMBEDDED_ITEM value. -# -# Accumulate changes in a local variable and make *one* call to install_name_tool -# at the end of the function with all the changes at once. -# +function(copy_resolved_framework_into_bundle resolved_item resolved_embedded_item) + if(WIN32) + # ignore case on Windows + string(TOLOWER "${resolved_item}" resolved_item_compare) + string(TOLOWER "${resolved_embedded_item}" resolved_embedded_item_compare) + else() + set(resolved_item_compare "${resolved_item}") + set(resolved_embedded_item_compare "${resolved_embedded_item}") + endif() + + if("${resolved_item_compare}" STREQUAL "${resolved_embedded_item_compare}") + message(STATUS "warning: resolved_item == resolved_embedded_item - not copying...") + else() + if(BU_COPY_FULL_FRAMEWORK_CONTENTS) + # Full Framework (everything): + get_filename_component(resolved_dir "${resolved_item}" PATH) + get_filename_component(resolved_dir "${resolved_dir}/../.." ABSOLUTE) + get_filename_component(resolved_embedded_dir "${resolved_embedded_item}" PATH) + get_filename_component(resolved_embedded_dir "${resolved_embedded_dir}/../.." ABSOLUTE) + #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy_directory '${resolved_dir}' '${resolved_embedded_dir}'") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${resolved_dir}" "${resolved_embedded_dir}") + else() + # Framework lib itself: + #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy ${resolved_item} ${resolved_embedded_item}") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy "${resolved_item}" "${resolved_embedded_item}") + + # Plus Resources, if they exist: + string(REGEX REPLACE "^(.*)/[^/]+/[^/]+/[^/]+$" "\\1/Resources" resolved_resources "${resolved_item}") + string(REGEX REPLACE "^(.*)/[^/]+/[^/]+/[^/]+$" "\\1/Resources" resolved_embedded_resources "${resolved_embedded_item}") + if(EXISTS "${resolved_resources}") + #message(STATUS "copying COMMAND ${CMAKE_COMMAND} -E copy_directory '${resolved_resources}' '${resolved_embedded_resources}'") + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${resolved_resources}" "${resolved_embedded_resources}") + endif() + endif() + endif() + + if(UNIX AND NOT APPLE) + file(RPATH_REMOVE FILE "${resolved_embedded_item}") + endif(UNIX AND NOT APPLE) +endfunction(copy_resolved_framework_into_bundle) + + function(fixup_bundle_item resolved_embedded_item exepath dirs) # This item's key is "ikey": # @@ -467,6 +544,10 @@ function(fixup_bundle_item resolved_embedded_item exepath dirs) endif(NOT "${${rkey}_EMBEDDED_ITEM}" STREQUAL "") endforeach(pr) + if(BU_CHMOD_BUNDLE_ITEMS) + execute_process(COMMAND chmod u+w "${resolved_embedded_item}") + endif() + # Change this item's id and all of its references in one call # to install_name_tool: # @@ -476,19 +557,6 @@ function(fixup_bundle_item resolved_embedded_item exepath dirs) endfunction(fixup_bundle_item) -# fixup_bundle -# -# Fix up a bundle in-place and make it standalone, such that it can be drag-n-drop -# copied to another machine and run on that machine as long as all of the system -# libraries are compatible. -# -# Gather all the keys for all the executables and libraries in a bundle, and then, -# for each key, copy each prerequisite into the bundle. Then fix each one up according -# to its own list of prerequisites. -# -# Then clear all the keys and call verify_app on the final bundle to ensure that -# it is truly standalone. -# function(fixup_bundle app libs dirs) message(STATUS "fixup_bundle") message(STATUS " app='${app}'") @@ -528,8 +596,14 @@ function(fixup_bundle app libs dirs) endif(show_status) if(${${key}_COPYFLAG}) - copy_resolved_item_into_bundle("${${key}_RESOLVED_ITEM}" - "${${key}_RESOLVED_EMBEDDED_ITEM}") + set(item "${${key}_ITEM}") + if(item MATCHES "[^/]+\\.framework/") + copy_resolved_framework_into_bundle("${${key}_RESOLVED_ITEM}" + "${${key}_RESOLVED_EMBEDDED_ITEM}") + else() + copy_resolved_item_into_bundle("${${key}_RESOLVED_ITEM}" + "${${key}_RESOLVED_EMBEDDED_ITEM}") + endif() endif(${${key}_COPYFLAG}) endforeach(key) @@ -557,23 +631,12 @@ function(fixup_bundle app libs dirs) endfunction(fixup_bundle) -# copy_and_fixup_bundle -# -# Makes a copy of the bundle "src" at location "dst" and then fixes up the -# new copied bundle in-place at "dst"... -# function(copy_and_fixup_bundle src dst libs dirs) execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${src}" "${dst}") fixup_bundle("${dst}" "${libs}" "${dirs}") endfunction(copy_and_fixup_bundle) -# verify_bundle_prerequisites -# -# Verifies that the sum of all prerequisites of all files inside the bundle -# are contained within the bundle or are "system" libraries, presumed to exist -# everywhere. -# function(verify_bundle_prerequisites bundle result_var info_var) set(result 1) set(info "") @@ -635,12 +698,6 @@ function(verify_bundle_prerequisites bundle result_var info_var) endfunction(verify_bundle_prerequisites) -# verify_bundle_symlinks -# -# Verifies that any symlinks found in the bundle point to other files that are -# already also in the bundle... Anything that points to an external file causes -# this function to fail the verification. -# function(verify_bundle_symlinks bundle result_var info_var) set(result 1) set(info "") @@ -654,11 +711,6 @@ function(verify_bundle_symlinks bundle result_var info_var) endfunction(verify_bundle_symlinks) -# verify_app -# -# Verifies that an application appears valid based on running analysis tools on it. -# Calls message/FATAL_ERROR if the application is not verified. -# function(verify_app app) set(verified 0) set(info "") diff --git a/Modules/CMake.cmake b/Modules/CMake.cmake index cbdaa350c..53a0ddf99 100644 --- a/Modules/CMake.cmake +++ b/Modules/CMake.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This file is used by cmake.cxx to compute the CMAKE_ROOT location. diff --git a/Modules/CMakeASM-ATTInformation.cmake b/Modules/CMakeASM-ATTInformation.cmake index 51c445b6b..abf560bb0 100644 --- a/Modules/CMakeASM-ATTInformation.cmake +++ b/Modules/CMakeASM-ATTInformation.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # support for AT&T syntax assemblers, e.g. GNU as diff --git a/Modules/CMakeASMInformation.cmake b/Modules/CMakeASMInformation.cmake index 0fad25df7..b94303e8e 100644 --- a/Modules/CMakeASMInformation.cmake +++ b/Modules/CMakeASMInformation.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MESSAGE(STATUS "Loaded CMakeASM${ASM_DIALECT}Information - ASM${ASM_DIALECT} support is still experimental, please report issues") @@ -28,18 +28,25 @@ IF("${CMAKE_BASE_NAME}" STREQUAL "as") SET(CMAKE_BASE_NAME gas) ENDIF("${CMAKE_BASE_NAME}" STREQUAL "as") -INCLUDE(Platform/${CMAKE_BASE_NAME} OPTIONAL) +# Load compiler-specific information. +SET(_INCLUDED_FILE "") +IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + INCLUDE(Compiler/${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) +ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) +IF(NOT _INCLUDED_FILE) + INCLUDE(Platform/${CMAKE_BASE_NAME} OPTIONAL) +ENDIF(NOT _INCLUDED_FILE) IF(CMAKE_SYSTEM_PROCESSOR) - INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) + INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) + IF(NOT _INCLUDED_FILE) + INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL) + ENDIF(NOT _INCLUDED_FILE) ENDIF(CMAKE_SYSTEM_PROCESSOR) -IF(NOT _INCLUDED_FILE) - INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-ASM-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL) -ENDIF(NOT _INCLUDED_FILE) -INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) +INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}-ASM${ASM_DIALECT} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) IF(NOT _INCLUDED_FILE) - INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_C_COMPILER_ID}-ASM OPTIONAL) + INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL) ENDIF(NOT _INCLUDED_FILE) # Set default assembler file extensions: diff --git a/Modules/CMakeASM_MASMInformation.cmake b/Modules/CMakeASM_MASMInformation.cmake index 2f27d2a8f..4e1386fab 100644 --- a/Modules/CMakeASM_MASMInformation.cmake +++ b/Modules/CMakeASM_MASMInformation.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # support for the MS assembler, masm and masm64 diff --git a/Modules/CMakeBackwardCompatibilityC.cmake b/Modules/CMakeBackwardCompatibilityC.cmake index c6537cf3b..00e568830 100644 --- a/Modules/CMakeBackwardCompatibilityC.cmake +++ b/Modules/CMakeBackwardCompatibilityC.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Nothing here yet diff --git a/Modules/CMakeBackwardCompatibilityCXX.cmake b/Modules/CMakeBackwardCompatibilityCXX.cmake index a4175e881..707bbde50 100644 --- a/Modules/CMakeBackwardCompatibilityCXX.cmake +++ b/Modules/CMakeBackwardCompatibilityCXX.cmake @@ -16,7 +16,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF(NOT CMAKE_SKIP_COMPATIBILITY_TESTS) diff --git a/Modules/CMakeBorlandFindMake.cmake b/Modules/CMakeBorlandFindMake.cmake index d9081688d..1ef28df83 100644 --- a/Modules/CMakeBorlandFindMake.cmake +++ b/Modules/CMakeBorlandFindMake.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) SET (CMAKE_MAKE_PROGRAM "make" CACHE STRING diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake index fb4f0e8a3..86a824a76 100644 --- a/Modules/CMakeCInformation.cmake +++ b/Modules/CMakeCInformation.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This file sets the basic flags for the C language in CMake. @@ -26,6 +26,8 @@ ELSE(UNIX) SET(CMAKE_C_OUTPUT_EXTENSION .obj) ENDIF(UNIX) +SET(_INCLUDED_FILE 0) + # Load compiler-specific information. IF(CMAKE_C_COMPILER_ID) INCLUDE(Compiler/${CMAKE_C_COMPILER_ID}-C OPTIONAL) diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index b264da1c9..d7ae8d994 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -21,8 +21,8 @@ IF(CMAKE_COMPILER_IS_MINGW) SET(MINGW 1) ENDIF(CMAKE_COMPILER_IS_MINGW) SET(CMAKE_CXX_COMPILER_ID_RUN 1) -SET(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;H;o;O;obj;OBJ;def;DEF;rc;RC) -SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm) +SET(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) +SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;CPP) SET(CMAKE_CXX_LINKER_PREFERENCE 30) SET(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1) diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 0a7e9903e..680f8fdbd 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This file sets the basic flags for the C++ language in CMake. @@ -26,6 +26,8 @@ ELSE(UNIX) SET(CMAKE_CXX_OUTPUT_EXTENSION .obj) ENDIF(UNIX) +SET(_INCLUDED_FILE 0) + # Load compiler-specific information. IF(CMAKE_CXX_COMPILER_ID) INCLUDE(Compiler/${CMAKE_CXX_COMPILER_ID}-CXX OPTIONAL) diff --git a/Modules/CMakeCommonLanguageInclude.cmake b/Modules/CMakeCommonLanguageInclude.cmake index 80d5678d9..237f8ddec 100644 --- a/Modules/CMakeCommonLanguageInclude.cmake +++ b/Modules/CMakeCommonLanguageInclude.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # this file has flags that are shared across languages and sets diff --git a/Modules/CMakeDependentOption.cmake b/Modules/CMakeDependentOption.cmake index 4d978c487..8b8dc07fb 100644 --- a/Modules/CMakeDependentOption.cmake +++ b/Modules/CMakeDependentOption.cmake @@ -22,7 +22,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(CMAKE_DEPENDENT_OPTION option doc default depends force) diff --git a/Modules/CMakeDetermineASM-ATTCompiler.cmake b/Modules/CMakeDetermineASM-ATTCompiler.cmake index 99c591bed..9dd2f11de 100644 --- a/Modules/CMakeDetermineASM-ATTCompiler.cmake +++ b/Modules/CMakeDetermineASM-ATTCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # determine the compiler to use for ASM using AT&T syntax, e.g. GNU as diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index adf140888..06dd6b86f 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # determine the compiler to use for ASM programs @@ -38,9 +38,9 @@ ELSE(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER) # we only get here if CMAKE_ASM${ASM_DIALECT}_COMPILER was specified using -D or a pre-made CMakeCache.txt # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE # - # if a compiler was specified by the user but without path, + # if a compiler was specified by the user but without path, # now try to find it with the full path - # if it is found, force it into the cache, + # if it is found, force it into the cache, # if not, don't overwrite the setting (which was given by the user) with "NOTFOUND" GET_FILENAME_COMPONENT(_CMAKE_USER_ASM${ASM_DIALECT}_COMPILER_PATH "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" PATH) IF(NOT _CMAKE_USER_ASM${ASM_DIALECT}_COMPILER_PATH) @@ -57,11 +57,30 @@ IF (NOT _CMAKE_TOOLCHAIN_LOCATION) GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" PATH) ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION) -# If we have a gas/as cross compiler, they have usually some prefix, like + +IF(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + + # Table of per-vendor compiler id flags with expected output. + LIST(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS GNU ) + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_GNU "--version") + SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_GNU "GNU assembler") + + CMAKE_DETERMINE_COMPILER_ID_VENDOR(ASM${ASM_DIALECT}) + + IF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + MESSAGE(STATUS "The ASM${ASM_DIALECT} compiler identification is ${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID}") + ELSE(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + MESSAGE(STATUS "The ASM${ASM_DIALECT} compiler identification is unknown") + ENDIF(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) + +ENDIF() + + +# If we have a gas/as cross compiler, they have usually some prefix, like # e.g. powerpc-linux-gas, arm-elf-gas or i586-mingw32msvc-gas . # The other tools of the toolchain usually have the same prefix # NAME_WE cannot be used since then this test will fail for names lile -# "arm-unknown-nto-qnx6.3.0-gas.exe", where BASENAME would be +# "arm-unknown-nto-qnx6.3.0-gas.exe", where BASENAME would be # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" IF (NOT _CMAKE_TOOLCHAIN_PREFIX) GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" NAME) @@ -86,7 +105,7 @@ SET(_CMAKE_ASM_COMPILER_ARG1 "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARG1}") SET(_CMAKE_ASM_COMPILER_ENV_VAR "${CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR}") # configure variables set in this file for fast reload later on -CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in +CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeASMCompiler.cmake.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeASM${ASM_DIALECT}Compiler.cmake IMMEDIATE @ONLY) SET(_CMAKE_ASM_COMPILER) diff --git a/Modules/CMakeDetermineASM_MASMCompiler.cmake b/Modules/CMakeDetermineASM_MASMCompiler.cmake index 8223ea0ec..e23f7db4c 100644 --- a/Modules/CMakeDetermineASM_MASMCompiler.cmake +++ b/Modules/CMakeDetermineASM_MASMCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Find the MS assembler (masm or masm64) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 17fa05faf..639b4265c 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # determine the compiler to use for C programs diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 117010624..555d20e43 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # determine the compiler to use for C++ programs diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index aa4733b32..d6df30590 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Function to compile a source file to identify the compiler ABI. diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 4a800a8ea..bf78a5ba3 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Function to compile a source file to identify the compiler. This is @@ -63,7 +63,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) SET(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE) SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) - SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" + SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" PARENT_SCOPE) ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID) @@ -247,7 +247,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) # Return the information extracted. SET(CMAKE_${lang}_COMPILER_ID "${CMAKE_${lang}_COMPILER_ID}" PARENT_SCOPE) SET(CMAKE_${lang}_PLATFORM_ID "${CMAKE_${lang}_PLATFORM_ID}" PARENT_SCOPE) - SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" + SET(MSVC_${lang}_ARCHITECTURE_ID "${MSVC_${lang}_ARCHITECTURE_ID}" PARENT_SCOPE) SET(CMAKE_EXECUTABLE_FORMAT "${CMAKE_EXECUTABLE_FORMAT}" PARENT_SCOPE) ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang) @@ -261,6 +261,17 @@ ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_CHECK lang) # We try running the compiler with the flag for each vendor and # matching its regular expression in the output. FUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang) + + IF(NOT CMAKE_${lang}_COMPILER_ID_DIR) + # We get here when this function is called not from within CMAKE_DETERMINE_COMPILER_ID() + # This is done e.g. for detecting the compiler ID for assemblers. + # Compute the directory in which to run the test and Create a clean working directory. + SET(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CompilerId${lang}) + FILE(REMOVE_RECURSE ${CMAKE_${lang}_COMPILER_ID_DIR}) + FILE(MAKE_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}) + ENDIF(NOT CMAKE_${lang}_COMPILER_ID_DIR) + + FOREACH(vendor ${CMAKE_${lang}_COMPILER_ID_VENDORS}) SET(flags ${CMAKE_${lang}_COMPILER_ID_VENDOR_FLAGS_${vendor}}) SET(regex ${CMAKE_${lang}_COMPILER_ID_VENDOR_REGEX_${vendor}}) @@ -272,6 +283,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang) WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR} OUTPUT_VARIABLE output ERROR_VARIABLE output RESULT_VARIABLE result + TIMEOUT 10 ) IF("${output}" MATCHES "${regex}") FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log @@ -280,9 +292,15 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang) SET(CMAKE_${lang}_COMPILER_ID "${vendor}" PARENT_SCOPE) BREAK() ELSE() - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" " - "did not match \"${regex}\":\n${output}") + IF("${result}" MATCHES "timeout") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" " + "terminated after 10 s due to timeout.") + ELSE() + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" " + "did not match \"${regex}\":\n${output}") + ENDIF() ENDIF() ENDFOREACH() ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR) diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 34477a147..03ddd78eb 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # determine the compiler to use for Fortran programs diff --git a/Modules/CMakeDetermineJavaCompiler.cmake b/Modules/CMakeDetermineJavaCompiler.cmake index 483db6b3d..aefcaba36 100644 --- a/Modules/CMakeDetermineJavaCompiler.cmake +++ b/Modules/CMakeDetermineJavaCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # determine the compiler to use for Java programs diff --git a/Modules/CMakeDetermineRCCompiler.cmake b/Modules/CMakeDetermineRCCompiler.cmake index e1b6df27a..094b8937b 100644 --- a/Modules/CMakeDetermineRCCompiler.cmake +++ b/Modules/CMakeDetermineRCCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # determine the compiler to use for C programs diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index 623caf9a8..0e65bceae 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is used by the Makefile generator to determin the following variables: @@ -47,17 +47,17 @@ IF(CMAKE_HOST_UNIX) IF(CMAKE_UNAME) EXEC_PROGRAM(uname ARGS -s OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_NAME) EXEC_PROGRAM(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) - IF(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux") + IF(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*") EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) - ELSE(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux") + ELSE(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*") EXEC_PROGRAM(uname ARGS -p OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) IF("${val}" GREATER 0) EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) ENDIF("${val}" GREATER 0) - ENDIF(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux") + ENDIF(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*") # check the return of the last uname -m or -p IF("${val}" GREATER 0) SET(CMAKE_HOST_SYSTEM_PROCESSOR "unknown") diff --git a/Modules/CMakeDetermineVSServicePack.cmake b/Modules/CMakeDetermineVSServicePack.cmake index a5bb528ee..a877e6ef7 100644 --- a/Modules/CMakeDetermineVSServicePack.cmake +++ b/Modules/CMakeDetermineVSServicePack.cmake @@ -23,8 +23,8 @@ # =========================== #============================================================================= -# Copyright 2009 Kitware, Inc. -# Copyright 2009 Philip Lowman +# Copyright 2009-2010 Kitware, Inc. +# Copyright 2009-2010 Philip Lowman # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -33,7 +33,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # [INTERNAL] @@ -47,6 +47,8 @@ function(_DetermineVSServicePackFromCompiler _OUT_VAR _cl_version) set(_version "vc90") elseif(${_cl_version} VERSION_EQUAL "15.00.30729.01") set(_version "vc90sp1") + elseif(${_cl_version} VERSION_EQUAL "16.00.30319.01") + set(_version "vc100") else() set(_version "") endif() diff --git a/Modules/CMakeExportBuildSettings.cmake b/Modules/CMakeExportBuildSettings.cmake index f7d7de183..8d316b941 100644 --- a/Modules/CMakeExportBuildSettings.cmake +++ b/Modules/CMakeExportBuildSettings.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is purposely no longer documented. It does nothing useful. diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index d27c978a5..64ec403ad 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -26,7 +26,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # if it's the MS C/CXX compiler, search for link diff --git a/Modules/CMakeFindCodeBlocks.cmake b/Modules/CMakeFindCodeBlocks.cmake index 0dbe20f14..c72c8f7b8 100644 --- a/Modules/CMakeFindCodeBlocks.cmake +++ b/Modules/CMakeFindCodeBlocks.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This file is included in CMakeSystemSpecificInformation.cmake if diff --git a/Modules/CMakeFindEclipseCDT4.cmake b/Modules/CMakeFindEclipseCDT4.cmake index f479285f1..836e4c9bf 100644 --- a/Modules/CMakeFindEclipseCDT4.cmake +++ b/Modules/CMakeFindEclipseCDT4.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This file is included in CMakeSystemSpecificInformation.cmake if @@ -22,8 +22,8 @@ FIND_PROGRAM(CMAKE_ECLIPSE_EXECUTABLE NAMES eclipse DOC "The Eclipse executable" # 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 _result _resultDefines) - SET(${_result}) +MACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _resultIncludeDirs _resultDefines) + SET(${_resultIncludeDirs}) SET(_gccOutput) FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/dummy" "\n" ) EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} -v -E -x ${_lang} -dD dummy @@ -32,24 +32,43 @@ MACRO(_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS _lang _result _resultDefines) 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" ) - SET(${_result} ${CMAKE_MATCH_1}) - STRING(REPLACE "\n" " " ${_result} "${${_result}}") - SEPARATE_ARGUMENTS(${_result}) + + # 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" ) - - IF( "${_gccStdout}" MATCHES "built-in>\"\n(.+)# 1 +\"dummy\"" ) - SET(_builtinDefines ${CMAKE_MATCH_1}) - # Remove the '# 1 ""' lines - STRING(REGEX REPLACE "# 1[^\n]+\n" "" _filteredOutput "${_builtinDefines}") - # Remove the "#define " parts from the output: - STRING(REGEX REPLACE "#define " "" _defineRemoved "${_filteredOutput}") - # Replace the line breaks with spaces, so we can use separate arguments afterwards - STRING(REGEX REPLACE "\n" " " _defineRemoved "${_defineRemoved}") - # Remove space at the end, this would produce empty list items - STRING(REGEX REPLACE " +$" "" ${_resultDefines} "${_defineRemoved}") - SEPARATE_ARGUMENTS(${_resultDefines}) - ENDIF( "${_gccStdout}" MATCHES "built-in>\"\n(.+)# 1 +\"dummy\"" ) + + + # 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 diff --git a/Modules/CMakeFindFrameworks.cmake b/Modules/CMakeFindFrameworks.cmake index 1bc893544..001da20f3 100644 --- a/Modules/CMakeFindFrameworks.cmake +++ b/Modules/CMakeFindFrameworks.cmake @@ -10,7 +10,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED) diff --git a/Modules/CMakeFindKDevelop3.cmake b/Modules/CMakeFindKDevelop3.cmake index 1c77365ab..331dc6ef9 100644 --- a/Modules/CMakeFindKDevelop3.cmake +++ b/Modules/CMakeFindKDevelop3.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This file is included in CMakeSystemSpecificInformation.cmake if diff --git a/Modules/CMakeFindWMake.cmake b/Modules/CMakeFindWMake.cmake index e4bbb3dae..6972c4c40 100644 --- a/Modules/CMakeFindWMake.cmake +++ b/Modules/CMakeFindWMake.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) SET (CMAKE_MAKE_PROGRAM "wmake" CACHE STRING diff --git a/Modules/CMakeFindXCode.cmake b/Modules/CMakeFindXCode.cmake index 240f936bb..53967b52a 100644 --- a/Modules/CMakeFindXCode.cmake +++ b/Modules/CMakeFindXCode.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PROGRAM(CMAKE_MAKE_PROGRAM diff --git a/Modules/CMakeForceCompiler.cmake b/Modules/CMakeForceCompiler.cmake index b7a681acd..2a839fd93 100644 --- a/Modules/CMakeForceCompiler.cmake +++ b/Modules/CMakeForceCompiler.cmake @@ -39,7 +39,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(CMAKE_FORCE_C_COMPILER compiler id) diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index 97a5e7e91..f6a52c6eb 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -9,13 +9,15 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This file sets the basic flags for the Fortran language in CMake. # It also loads the available platform file for the system-compiler # if it exists. +SET(_INCLUDED_FILE 0) + # Load compiler-specific information. IF(CMAKE_Fortran_COMPILER_ID) INCLUDE(Compiler/${CMAKE_Fortran_COMPILER_ID}-Fortran OPTIONAL) diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake index c0f3aa6aa..b5d30724a 100644 --- a/Modules/CMakeGenericSystem.cmake +++ b/Modules/CMakeGenericSystem.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) SET(CMAKE_SHARED_LIBRARY_C_FLAGS "") # -pic @@ -52,6 +52,94 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles") ENDIF(DEFINED CMAKE_RULE_MESSAGES) ENDIF(CMAKE_GENERATOR MATCHES "Makefiles") + +# GetDefaultWindowsPrefixBase +# +# Compute the base directory for CMAKE_INSTALL_PREFIX based on: +# - is this 32-bit or 64-bit Windows +# - is this 32-bit or 64-bit CMake running +# - what architecture targets will be built +# +function(GetDefaultWindowsPrefixBase var) + + # Try to guess what architecture targets will end up being built as, + # even if CMAKE_SIZEOF_VOID_P is not computed yet... We need to know + # the architecture of the targets being built to choose the right + # default value for CMAKE_INSTALL_PREFIX. + # + if("${CMAKE_GENERATOR}" MATCHES "Win64") + set(arch_hint "x64") + elseif("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8") + set(arch_hint "x64") + elseif("$ENV{LIB}" MATCHES "(amd64|ia64)") + set(arch_hint "x64") + endif() + + if(NOT arch_hint) + set(arch_hint "x86") + endif() + + # default env in a 64-bit app on Win64: + # ProgramFiles=C:\Program Files + # ProgramFiles(x86)=C:\Program Files (x86) + # ProgramW6432=C:\Program Files + # + # default env in a 32-bit app on Win64: + # ProgramFiles=C:\Program Files (x86) + # ProgramFiles(x86)=C:\Program Files (x86) + # ProgramW6432=C:\Program Files + # + # default env in a 32-bit app on Win32: + # ProgramFiles=C:\Program Files + # ProgramFiles(x86) NOT DEFINED + # ProgramW6432 NOT DEFINED + + # By default, use the ProgramFiles env var as the base value of + # CMAKE_INSTALL_PREFIX: + # + set(_PREFIX_ENV_VAR "ProgramFiles") + + if ("$ENV{ProgramW6432}" STREQUAL "") + # running on 32-bit Windows + # must be a 32-bit CMake, too... + #message("guess: this is a 32-bit CMake running on 32-bit Windows") + else() + # running on 64-bit Windows + if ("$ENV{ProgramW6432}" STREQUAL "$ENV{ProgramFiles}") + # 64-bit CMake + #message("guess: this is a 64-bit CMake running on 64-bit Windows") + if(NOT "${arch_hint}" STREQUAL "x64") + # building 32-bit targets + set(_PREFIX_ENV_VAR "ProgramFiles(x86)") + endif() + else() + # 32-bit CMake + #message("guess: this is a 32-bit CMake running on 64-bit Windows") + if("${arch_hint}" STREQUAL "x64") + # building 64-bit targets + set(_PREFIX_ENV_VAR "ProgramW6432") + endif() + endif() + endif() + + #if("${arch_hint}" STREQUAL "x64") + # message("guess: you are building a 64-bit app") + #else() + # message("guess: you are building a 32-bit app") + #endif() + + if(NOT "$ENV{${_PREFIX_ENV_VAR}}" STREQUAL "") + file(TO_CMAKE_PATH "$ENV{${_PREFIX_ENV_VAR}}" _base) + elseif(NOT "$ENV{SystemDrive}" STREQUAL "") + set(_base "$ENV{SystemDrive}/Program Files") + else() + set(_base "C:/Program Files") + endif() + + set(${var} "${_base}" PARENT_SCOPE) +endfunction() + + # Set a variable to indicate whether the value of CMAKE_INSTALL_PREFIX # was initialized by the block below. This is useful for user # projects to change the default prefix while still allowing the @@ -65,23 +153,11 @@ IF(CMAKE_HOST_UNIX) SET(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Install path prefix, prepended onto install directories.") ELSE(CMAKE_HOST_UNIX) - IF("$ENV{ProgramFiles}" MATCHES "^$") - IF("$ENV{SystemDrive}" MATCHES "^$") - SET(CMAKE_GENERIC_PROGRAM_FILES "C:/Program Files") - ELSE("$ENV{SystemDrive}" MATCHES "^$") - SET(CMAKE_GENERIC_PROGRAM_FILES "$ENV{SystemDrive}/Program Files") - ENDIF("$ENV{SystemDrive}" MATCHES "^$") - ELSE("$ENV{ProgramFiles}" MATCHES "^$") - SET(CMAKE_GENERIC_PROGRAM_FILES "$ENV{ProgramFiles}") - ENDIF("$ENV{ProgramFiles}" MATCHES "^$") + GetDefaultWindowsPrefixBase(CMAKE_GENERIC_PROGRAM_FILES) SET(CMAKE_INSTALL_PREFIX "${CMAKE_GENERIC_PROGRAM_FILES}/${PROJECT_NAME}" CACHE PATH "Install path prefix, prepended onto install directories.") SET(CMAKE_GENERIC_PROGRAM_FILES) - - # Make sure the prefix uses forward slashes. - STRING(REGEX REPLACE "\\\\" "/" - CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") ENDIF(CMAKE_HOST_UNIX) MARK_AS_ADVANCED( diff --git a/Modules/CMakeImportBuildSettings.cmake b/Modules/CMakeImportBuildSettings.cmake index 968bc793b..848d89445 100644 --- a/Modules/CMakeImportBuildSettings.cmake +++ b/Modules/CMakeImportBuildSettings.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is purposely no longer documented. It does nothing useful. diff --git a/Modules/CMakeJOMFindMake.cmake b/Modules/CMakeJOMFindMake.cmake index a72420ab6..617f3bb90 100644 --- a/Modules/CMakeJOMFindMake.cmake +++ b/Modules/CMakeJOMFindMake.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) diff --git a/Modules/CMakeJavaInformation.cmake b/Modules/CMakeJavaInformation.cmake index f537da53d..e9bc9be23 100644 --- a/Modules/CMakeJavaInformation.cmake +++ b/Modules/CMakeJavaInformation.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This should be included before the _INIT variables are diff --git a/Modules/CMakeMSYSFindMake.cmake b/Modules/CMakeMSYSFindMake.cmake index e95f74fd3..95492a0b0 100644 --- a/Modules/CMakeMSYSFindMake.cmake +++ b/Modules/CMakeMSYSFindMake.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PROGRAM(CMAKE_MAKE_PROGRAM make diff --git a/Modules/CMakeMinGWFindMake.cmake b/Modules/CMakeMinGWFindMake.cmake index 68e8442fa..f760d74d4 100644 --- a/Modules/CMakeMinGWFindMake.cmake +++ b/Modules/CMakeMinGWFindMake.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PROGRAM(CMAKE_MAKE_PROGRAM mingw32-make.exe PATHS diff --git a/Modules/CMakeNMakeFindMake.cmake b/Modules/CMakeNMakeFindMake.cmake index 84ea56da6..f6472170c 100644 --- a/Modules/CMakeNMakeFindMake.cmake +++ b/Modules/CMakeNMakeFindMake.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) diff --git a/Modules/CMakeParseArguments.cmake b/Modules/CMakeParseArguments.cmake new file mode 100644 index 000000000..7ce4c49ae --- /dev/null +++ b/Modules/CMakeParseArguments.cmake @@ -0,0 +1,138 @@ +# CMAKE_PARSE_ARGUMENTS( args...) +# +# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for +# parsing the arguments given to that macro or function. +# It processes the arguments and defines a set of variables which hold the +# values of the respective options. +# +# The argument contains all options for the respective macro, +# i.e. keywords which can be used when calling the macro without any value +# following, like e.g. the OPTIONAL keyword of the install() command. +# +# The argument contains all keywords for this macro +# which are followed by one value, like e.g. DESTINATION keyword of the +# install() command. +# +# The argument contains all keywords for this macro +# which can be followed by more than one value, like e.g. the TARGETS or +# FILES keywords of the install() command. +# +# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the +# keywords listed in , and +# a variable composed of the given +# followed by "_" and the name of the respective keyword. +# These variables will then hold the respective value from the argument list. +# For the keywords this will be TRUE or FALSE. +# +# All remaining arguments are collected in a variable +# _UNPARSED_ARGUMENTS, this can be checked afterwards to see whether +# your macro was called with unrecognized parameters. +# +# As an example here a my_install() macro, which takes similar arguments as the +# real install() command: +# +# function(MY_INSTALL) +# set(options OPTIONAL FAST) +# set(oneValueArgs DESTINATION RENAME) +# set(multiValueArgs TARGETS CONFIGURATIONS) +# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) +# ... +# +# Assume my_install() has been called like this: +# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) +# +# After the cmake_parse_arguments() call the macro will have set the following +# variables: +# MY_INSTALL_OPTIONAL = TRUE +# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() +# MY_INSTALL_DESTINATION = "bin" +# MY_INSTALL_RENAME = "" (was not used) +# MY_INSTALL_TARGETS = "foo;bar" +# MY_INSTALL_CONFIGURATIONS = "" (was not used) +# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" +# +# You can the continue and process these variables. +# +# Keywords terminate lists of values, e.g. if directly after a one_value_keyword +# another recognized keyword follows, this is interpreted as the beginning of +# the new option. +# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in +# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would +# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. + +#============================================================================= +# Copyright 2010 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(__CMAKE_PARSE_ARGUMENTS_INCLUDED) + return() +endif() +set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) + + +function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) + # first set all result variables to empty/FALSE + foreach(arg_name ${_singleArgNames} ${_multiArgNames}) + set(${prefix}_${arg_name}) + endforeach(arg_name) + + foreach(option ${_optionNames}) + set(${prefix}_${option} FALSE) + endforeach(option) + + set(${prefix}_UNPARSED_ARGUMENTS) + + set(insideValues FALSE) + set(currentArgName) + + # now iterate over all arguments and fill the result variables + foreach(currentArg ${ARGN}) + list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword + list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword + list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword + + if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) + if(insideValues) + if("${insideValues}" STREQUAL "SINGLE") + set(${prefix}_${currentArgName} ${currentArg}) + set(insideValues FALSE) + elseif("${insideValues}" STREQUAL "MULTI") + list(APPEND ${prefix}_${currentArgName} ${currentArg}) + endif() + else(insideValues) + list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) + endif(insideValues) + else() + if(NOT ${optionIndex} EQUAL -1) + set(${prefix}_${currentArg} TRUE) + set(insideValues FALSE) + elseif(NOT ${singleArgIndex} EQUAL -1) + set(currentArgName ${currentArg}) + set(${prefix}_${currentArgName}) + set(insideValues "SINGLE") + elseif(NOT ${multiArgIndex} EQUAL -1) + set(currentArgName ${currentArg}) + set(${prefix}_${currentArgName}) + set(insideValues "MULTI") + endif() + endif() + + endforeach(currentArg) + + # propagate the result variables to the caller: + foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) + set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) + endforeach(arg_name) + set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) + +endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs) diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake index 1761d2806..defdb472d 100644 --- a/Modules/CMakeParseImplicitLinkInfo.cmake +++ b/Modules/CMakeParseImplicitLinkInfo.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Function parse implicit linker options. diff --git a/Modules/CMakePrintSystemInformation.cmake b/Modules/CMakePrintSystemInformation.cmake index 3f33ce8fa..2c5d0f2ae 100644 --- a/Modules/CMakePrintSystemInformation.cmake +++ b/Modules/CMakePrintSystemInformation.cmake @@ -13,7 +13,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MESSAGE("CMAKE_SYSTEM is ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}") diff --git a/Modules/CMakeRCInformation.cmake b/Modules/CMakeRCInformation.cmake index f6509fbb4..fcd00999a 100644 --- a/Modules/CMakeRCInformation.cmake +++ b/Modules/CMakeRCInformation.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) diff --git a/Modules/CMakeSystemSpecificInformation.cmake b/Modules/CMakeSystemSpecificInformation.cmake index 75d737f9a..faa9e3625 100644 --- a/Modules/CMakeSystemSpecificInformation.cmake +++ b/Modules/CMakeSystemSpecificInformation.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This file is included by cmGlobalGenerator::EnableLanguage. diff --git a/Modules/CMakeTestASM-ATTCompiler.cmake b/Modules/CMakeTestASM-ATTCompiler.cmake index 9ba306afd..3b7a74f18 100644 --- a/Modules/CMakeTestASM-ATTCompiler.cmake +++ b/Modules/CMakeTestASM-ATTCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This file is used by EnableLanguage in cmGlobalGenerator to diff --git a/Modules/CMakeTestASMCompiler.cmake b/Modules/CMakeTestASMCompiler.cmake index d62a79ada..54def8136 100644 --- a/Modules/CMakeTestASMCompiler.cmake +++ b/Modules/CMakeTestASMCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This file is used by EnableLanguage in cmGlobalGenerator to diff --git a/Modules/CMakeTestASM_MASMCompiler.cmake b/Modules/CMakeTestASM_MASMCompiler.cmake index 63207e3ba..84ca98f43 100644 --- a/Modules/CMakeTestASM_MASMCompiler.cmake +++ b/Modules/CMakeTestASM_MASMCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This file is used by EnableLanguage in cmGlobalGenerator to diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index bac993260..038c2fd47 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(CMakeTestCompilerCommon) diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index 06ef30136..c1a3b3a10 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(CMakeTestCompilerCommon) diff --git a/Modules/CMakeTestCompilerCommon.cmake b/Modules/CMakeTestCompilerCommon.cmake index 4307627d9..fd8a105b2 100644 --- a/Modules/CMakeTestCompilerCommon.cmake +++ b/Modules/CMakeTestCompilerCommon.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) function(PrintTestCompilerStatus LANG MSG) diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index 61d6336a5..33f62eb50 100644 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(CMakeTestCompilerCommon) diff --git a/Modules/CMakeTestJavaCompiler.cmake b/Modules/CMakeTestJavaCompiler.cmake index 546d9b9ca..cfd3e24b6 100644 --- a/Modules/CMakeTestJavaCompiler.cmake +++ b/Modules/CMakeTestJavaCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This file is used by EnableLanguage in cmGlobalGenerator to diff --git a/Modules/CMakeTestRCCompiler.cmake b/Modules/CMakeTestRCCompiler.cmake index 194f86068..a5c8d1149 100644 --- a/Modules/CMakeTestRCCompiler.cmake +++ b/Modules/CMakeTestRCCompiler.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This file is used by EnableLanguage in cmGlobalGenerator to diff --git a/Modules/CMakeUnixFindMake.cmake b/Modules/CMakeUnixFindMake.cmake index 8c9e03114..39962c0d3 100644 --- a/Modules/CMakeUnixFindMake.cmake +++ b/Modules/CMakeUnixFindMake.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PROGRAM(CMAKE_MAKE_PROGRAM NAMES gmake make smake) diff --git a/Modules/CMakeVS10FindMake.cmake b/Modules/CMakeVS10FindMake.cmake index 460de25e5..af5f3a7d5 100644 --- a/Modules/CMakeVS10FindMake.cmake +++ b/Modules/CMakeVS10FindMake.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # We use MSBuild as the build tool for VS 10 diff --git a/Modules/CMakeVS6BackwardCompatibility.cmake b/Modules/CMakeVS6BackwardCompatibility.cmake index 83708962f..438f64f6c 100644 --- a/Modules/CMakeVS6BackwardCompatibility.cmake +++ b/Modules/CMakeVS6BackwardCompatibility.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # hard code these for fast backwards compatibility tests diff --git a/Modules/CMakeVS6FindMake.cmake b/Modules/CMakeVS6FindMake.cmake index 0dd21a8da..dccf8c462 100644 --- a/Modules/CMakeVS6FindMake.cmake +++ b/Modules/CMakeVS6FindMake.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PROGRAM(CMAKE_MAKE_PROGRAM @@ -22,3 +22,4 @@ FIND_PROGRAM(CMAKE_MAKE_PROGRAM ) MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) SET(MSVC60 1) +SET(MSVC_VERSION 1200) diff --git a/Modules/CMakeVS71FindMake.cmake b/Modules/CMakeVS71FindMake.cmake index 8fd332c75..2381adb55 100644 --- a/Modules/CMakeVS71FindMake.cmake +++ b/Modules/CMakeVS71FindMake.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PROGRAM(CMAKE_MAKE_PROGRAM @@ -23,3 +23,4 @@ FIND_PROGRAM(CMAKE_MAKE_PROGRAM ) MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) SET(MSVC71 1) +SET(MSVC_VERSION 1310) diff --git a/Modules/CMakeVS7BackwardCompatibility.cmake b/Modules/CMakeVS7BackwardCompatibility.cmake index 3c7895323..df0b3bb97 100644 --- a/Modules/CMakeVS7BackwardCompatibility.cmake +++ b/Modules/CMakeVS7BackwardCompatibility.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # hard code these for fast backwards compatibility tests diff --git a/Modules/CMakeVS7FindMake.cmake b/Modules/CMakeVS7FindMake.cmake index 7f65a28a4..665158c88 100644 --- a/Modules/CMakeVS7FindMake.cmake +++ b/Modules/CMakeVS7FindMake.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PROGRAM(CMAKE_MAKE_PROGRAM @@ -22,3 +22,4 @@ FIND_PROGRAM(CMAKE_MAKE_PROGRAM ) MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) SET(MSVC70 1) +SET(MSVC_VERSION 1300) diff --git a/Modules/CMakeVS8FindMake.cmake b/Modules/CMakeVS8FindMake.cmake index 2f03e60de..bb0818014 100644 --- a/Modules/CMakeVS8FindMake.cmake +++ b/Modules/CMakeVS8FindMake.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (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 diff --git a/Modules/CMakeVS9FindMake.cmake b/Modules/CMakeVS9FindMake.cmake index 4704bcc21..9e3c39ef3 100644 --- a/Modules/CMakeVS9FindMake.cmake +++ b/Modules/CMakeVS9FindMake.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (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 diff --git a/Modules/CMakeVerifyManifest.cmake b/Modules/CMakeVerifyManifest.cmake index dbba46418..75783691f 100644 --- a/Modules/CMakeVerifyManifest.cmake +++ b/Modules/CMakeVerifyManifest.cmake @@ -26,7 +26,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 2991ada2f..7033e314a 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -19,9 +19,41 @@ # described below, for more information about component-specific # installations. # -# Before including the CPack module, there are a variety of variables -# that can be set to customize the resulting installers. The most -# commonly-used variables are: +# The CPACK_GENERATOR variable has different meanings in different +# contexts. In your CMakeLists.txt file, CPACK_GENERATOR is a +# *list of generators*: when run with no other arguments, CPack +# will iterate over that list and produce one package for each +# generator. In a CPACK_PROJECT_CONFIG_FILE, though, CPACK_GENERATOR +# is a *string naming a single generator*. If you need per-cpack- +# generator logic to control *other* cpack settings, then you need +# a CPACK_PROJECT_CONFIG_FILE. +# +# The CMake source tree itself contains a CPACK_PROJECT_CONFIG_FILE. +# See the top level file CMakeCPackOptions.cmake.in for an example. +# +# If set, the CPACK_PROJECT_CONFIG_FILE is included automatically +# on a per-generator basis. It only need contain overrides. +# +# Here's how it works: +# - cpack runs +# - it includes CPackConfig.cmake +# - it iterates over the generators listed in that file's +# CPACK_GENERATOR list variable (unless told to use just a +# specific one via -G on the command line...) +# +# - foreach generator, it then +# - sets CPACK_GENERATOR to the one currently being iterated +# - includes the CPACK_PROJECT_CONFIG_FILE +# - produces the package for that generator +# +# This is the key: For each generator listed in CPACK_GENERATOR +# in CPackConfig.cmake, cpack will *reset* CPACK_GENERATOR +# internally to *the one currently being used* and then include +# the CPACK_PROJECT_CONFIG_FILE. +# +# Before including this CPack module in your CMakeLists.txt file, +# there are a variety of variables that can be set to customize +# the resulting installers. The most commonly-used variables are: # # CPACK_PACKAGE_NAME - The name of the package (or application). If # not specified, defaults to the project name. @@ -48,6 +80,11 @@ # CPACK_PACKAGE_INSTALL_DIRECTORY - Installation directory on the # target system, e.g., "CMake 2.5". # +# CPACK_PROJECT_CONFIG_FILE - File included at cpack time, once per +# generator after setting CPACK_GENERATOR to the actual generator +# being used. Allows per-generator setting of CPACK_* variables at +# cpack time. +# # CPACK_RESOURCE_FILE_LICENSE - License file for the project, which # will typically be displayed to the user (often with an explicit # "Accept" button, for graphical installers) prior to installation. @@ -459,7 +496,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Pick a configuration file diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index f5ca592ba..98d40d65e 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -1,15 +1,18 @@ # - The builtin (binary) CPack Deb generator (Unix only) # CPackDeb may be used to create Deb package using CPack. # CPackDeb is a CPack generator thus it uses the CPACK_XXX variables -# used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration +# used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration. +# CPackDeb generator should work on any linux host but it will +# produce better deb package when Debian specific tools 'dpkg-xxx' +# are usable on the build system. # -# However CPackRPM has specific features which are controlled by -# the specifics CPACK_RPM_XXX variables.You'll find a detailed usage on -# the wiki: +# CPackDeb has specific features which are controlled by +# the specifics CPACK_DEBIAN_XXX variables.You'll find a detailed usage on +# the wiki: # http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29 # However as a handy reminder here comes the list of specific variables: # -# CPACK_DEBIAN_PACKAGE_NAME +# CPACK_DEBIAN_PACKAGE_NAME # Mandatory : YES # Default : CPACK_PACKAGE_NAME (lower case) # The debian package summary @@ -19,12 +22,12 @@ # The debian package version # CPACK_DEBIAN_PACKAGE_ARCHITECTURE) # Mandatory : YES -# Default : Output of dpkg --print-architecture or i386 +# Default : Output of dpkg --print-architecture (or i386 if dpkg is not found) # The debian package architecture # CPACK_DEBIAN_PACKAGE_DEPENDS # Mandatory : NO # Default : - -# May be used to set deb dependencies. +# May be used to set deb dependencies. # CPACK_DEBIAN_PACKAGE_MAINTAINER # Mandatory : YES # Default : CPACK_PACKAGE_CONTACT @@ -41,6 +44,61 @@ # Mandatory : YES # Default : 'optional' # The debian package priority +# CPACK_DEBIAN_PACKAGE_HOMEPAGE +# Mandatory : NO +# Default : - +# The URL of the web site for this package +# CPACK_DEBIAN_PACKAGE_SHLIBDEPS +# Mandatory : NO +# Default : OFF +# May be set to ON in order to use dpkg-shlibdeps to generate +# better package dependency list. +# You may need set CMAKE_INSTALL_RPATH toi appropriate value +# if you use this feature, because if you don't dpkg-shlibdeps +# may fail to find your own shared libs. +# See http://www.cmake.org/Wiki/CMake_RPATH_handling. +# CPACK_DEBIAN_PACKAGE_DEBUG +# Mandatory : NO +# Default : - +# May be set when invoking cpack in order to trace debug informations +# during CPackDeb run. +# CPACK_DEBIAN_PACKAGE_PREDEPENDS +# Mandatory : NO +# Default : - +# see http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps +# This field is like Depends, except that it also forces dpkg to complete installation of +# the packages named before even starting the installation of the package which declares +# the pre-dependency. +# CPACK_DEBIAN_PACKAGE_ENHANCES +# Mandatory : NO +# Default : - +# see http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps +# This field is similar to Suggests but works in the opposite direction. +# It is used to declare that a package can enhance the functionality of another package. +# CPACK_DEBIAN_PACKAGE_BREAKS +# Mandatory : NO +# Default : - +# see http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps +# When one binary package declares that it breaks another, dpkg will refuse to allow the +# package which declares Breaks be installed unless the broken package is deconfigured first, +# and it will refuse to allow the broken package to be reconfigured. +# CPACK_DEBIAN_PACKAGE_CONFLICTS +# Mandatory : NO +# Default : - +# see http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps +# When one binary package declares a conflict with another using a Conflicts field, +# dpkg will refuse to allow them to be installed on the system at the same time. +# CPACK_DEBIAN_PACKAGE_PROVIDES +# Mandatory : NO +# Default : - +# see http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps +# A virtual package is one which appears in the Provides control field of another package. +# CPACK_DEBIAN_PACKAGE_REPLACES +# Mandatory : NO +# Default : - +# see http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps +# Packages can declare in their control file that they should overwrite +# files in certain other packages, or completely replace other packages. #============================================================================= # Copyright 2007-2009 Kitware, Inc. @@ -53,7 +111,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # CPack script for creating Debian package @@ -69,6 +127,103 @@ IF(NOT UNIX) MESSAGE(FATAL_ERROR "CPackDeb.cmake may only be used under UNIX.") ENDIF(NOT UNIX) +# CPACK_DEBIAN_PACKAGE_SHLIBDEPS +# If specify OFF, only user depends are used +IF(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS) + SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) +ENDIF(NOT DEFINED CPACK_DEBIAN_PACKAGE_SHLIBDEPS) + +IF(CPACK_DEBIAN_PACKAGE_SHLIBDEPS) + # dpkg-shlibdeps is a Debian utility for generating dependency list + FIND_PROGRAM(SHLIBDEPS_EXECUTABLE dpkg-shlibdeps) + + # Check version of the dpkg-shlibdeps tool using CPackRPM method + IF(SHLIBDEPS_EXECUTABLE) + EXECUTE_PROCESS(COMMAND ${SHLIBDEPS_EXECUTABLE} --version + OUTPUT_VARIABLE _TMP_VERSION + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + STRING(REGEX MATCH "dpkg-shlibdeps version ([0-9]+\\.[0-9]+\\.[0-9]+)" + SHLIBDEPS_EXECUTABLE_VERSION + ${_TMP_VERSION}) + SET(SHLIBDEPS_EXECUTABLE_VERSION "${CMAKE_MATCH_1}") + IF(CPACK_DEBIAN_PACKAGE_DEBUG) + MESSAGE( "CPackDeb Debug: dpkg-shlibdeps version is <${SHLIBDEPS_EXECUTABLE_VERSION}>") + ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG) + + # Generating binary list - Get type of all install files + EXECUTE_PROCESS(COMMAND find -type f + COMMAND xargs file + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE CPACK_DEB_INSTALL_FILES) + + # Convert to CMake list + STRING(REGEX REPLACE "\n" ";" CPACK_DEB_INSTALL_FILES ${CPACK_DEB_INSTALL_FILES}) + + # Only dynamically linked ELF files are included + # Extract only file name infront of ":" + FOREACH ( _FILE ${CPACK_DEB_INSTALL_FILES}) + IF ( ${_FILE} MATCHES "ELF.*dynamically linked") + STRING(REGEX MATCH "(^.*):" _FILE_NAME ${_FILE}) + LIST(APPEND CPACK_DEB_BINARY_FILES ${CMAKE_MATCH_1}) + ENDIF() + ENDFOREACH() + + MESSAGE( "CPackDeb: - Generating dependency list") + + # Create blank control file for running dpkg-shlibdeps + # There might be some other way to invoke dpkg-shlibdeps without creating this file + # but standard debian package should not have anything that can collide with this file or directory + FILE(MAKE_DIRECTORY ${CPACK_TEMPORARY_DIRECTORY}/debian) + FILE(WRITE ${CPACK_TEMPORARY_DIRECTORY}/debian/control "") + + # Execute dpkg-shlibdeps + # --ignore-missing-info : allow dpkg-shlibdeps to run even if some libs do not belong to a package + # -O : print to STDOUT + EXECUTE_PROCESS(COMMAND ${SHLIBDEPS_EXECUTABLE} --ignore-missing-info -O ${CPACK_DEB_BINARY_FILES} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE SHLIBDEPS_OUTPUT + RESULT_VARIABLE SHLIBDEPS_RESULT + ERROR_VARIABLE SHLIBDEPS_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE ) + IF(CPACK_DEBIAN_PACKAGE_DEBUG) + # dpkg-shlibdeps will throw some warnings if some input files are not binary + MESSAGE( "CPackDeb Debug: dpkg-shlibdeps warnings \n${SHLIBDEPS_ERROR}") + ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG) + IF (NOT SHLIBDEPS_RESULT EQUAL 0) + MESSAGE (FATAL_ERROR "CPackDeb: dpkg-shlibdeps: ${SHLIBDEPS_ERROR}") + ENDIF (NOT SHLIBDEPS_RESULT EQUAL 0) + + #Get rid of prefix generated by dpkg-shlibdeps + string (REGEX REPLACE "^.*Depends=" "" CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS ${SHLIBDEPS_OUTPUT}) + + IF(CPACK_DEBIAN_PACKAGE_DEBUG) + MESSAGE( "CPackDeb Debug: Found dependency: ${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}") + ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG) + + # Remove blank control file + # Might not be safe if package actual contain file or directory named debian + FILE(REMOVE_RECURSE "${CPACK_TEMPORARY_DIRECTORY}/debian") + + # Append user depend if set + IF (CPACK_DEBIAN_PACKAGE_DEPENDS) + SET (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}, ${CPACK_DEBIAN_PACKAGE_DEPENDS}") + ELSE (CPACK_DEBIAN_PACKAGE_DEPENDS) + SET (CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_AUTO_DEPENDS}") + ENDIF (CPACK_DEBIAN_PACKAGE_DEPENDS) + + ELSE (SHLIBDEPS_EXECUTABLE) + IF(CPACK_DEBIAN_PACKAGE_DEBUG) + MESSAGE( "CPackDeb Debug: Using only user-provided depends because dpkg-shlibdeps is not found.") + ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG) + ENDIF(SHLIBDEPS_EXECUTABLE) + +ELSE (CPACK_DEBIAN_PACKAGE_SHLIBDEPS) + IF(CPACK_DEBIAN_PACKAGE_DEBUG) + MESSAGE( "CPackDeb Debug: Using only user-provided depends") + ENDIF(CPACK_DEBIAN_PACKAGE_DEBUG) +ENDIF(CPACK_DEBIAN_PACKAGE_SHLIBDEPS) + # Let's define the control file found in debian package: # Binary package: @@ -84,7 +239,7 @@ ENDIF(NOT CPACK_DEBIAN_PACKAGE_NAME) # Version: (mandatory) IF(NOT CPACK_DEBIAN_PACKAGE_VERSION) IF(NOT CPACK_PACKAGE_VERSION) - MESSAGE(FATAL_ERROR "Debian package requires a package version") + MESSAGE(FATAL_ERROR "CPackDeb: Debian package requires a package version") ENDIF(NOT CPACK_PACKAGE_VERSION) SET(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) ENDIF(NOT CPACK_DEBIAN_PACKAGE_VERSION) @@ -95,7 +250,7 @@ IF(NOT CPACK_DEBIAN_PACKAGE_ARCHITECTURE) # $ dpkg --print-architecture FIND_PROGRAM(DPKG_CMD dpkg) IF(NOT DPKG_CMD) - MESSAGE(STATUS "Can not find dpkg in your path, default to i386.") + MESSAGE(STATUS "CPackDeb: Can not find dpkg in your path, default to i386.") SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386) ENDIF(NOT DPKG_CMD) EXECUTE_PROCESS(COMMAND "${DPKG_CMD}" --print-architecture @@ -116,7 +271,7 @@ ENDIF(NOT CPACK_DEBIAN_PACKAGE_DEPENDS) # Maintainer: (mandatory) IF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER) IF(NOT CPACK_PACKAGE_CONTACT) - MESSAGE(FATAL_ERROR "Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER") + MESSAGE(FATAL_ERROR "CPackDeb: Debian package requires a maintainer for a package, set CPACK_PACKAGE_CONTACT or CPACK_DEBIAN_PACKAGE_MAINTAINER") ENDIF(NOT CPACK_PACKAGE_CONTACT) SET(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT}) ENDIF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER) @@ -124,7 +279,7 @@ ENDIF(NOT CPACK_DEBIAN_PACKAGE_MAINTAINER) # Description: (mandatory) IF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) - MESSAGE(FATAL_ERROR "Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION") + MESSAGE(FATAL_ERROR "CPackDeb: Debian package requires a summary for a package, set CPACK_PACKAGE_DESCRIPTION_SUMMARY or CPACK_DEBIAN_PACKAGE_DESCRIPTION") ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) ENDIF(NOT CPACK_DEBIAN_PACKAGE_DESCRIPTION) @@ -147,13 +302,13 @@ ENDIF(NOT CPACK_DEBIAN_PACKAGE_PRIORITY ) # CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA # This variable allow advanced user to add custom script to the control.tar.gz (inside the .deb archive) -# Typical examples are: +# Typical examples are: # - conffiles # - postinst # - postrm # - prerm" # Usage: -# SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA +# SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA # "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm") diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 3bf8e0e10..e2d788029 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -4,14 +4,14 @@ # used by CPack : http://www.cmake.org/Wiki/CMake:CPackConfiguration # # However CPackRPM has specific features which are controlled by -# the specifics CPACK_RPM_XXX variables. You'll find a detailed usage on -# the wiki: +# the specifics CPACK_RPM_XXX variables. You'll find a detailed usage on +# the wiki: # http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#RPM_.28Unix_Only.29 # However as a handy reminder here comes the list of specific variables: # -# CPACK_RPM_PACKAGE_SUMMARY +# CPACK_RPM_PACKAGE_SUMMARY # Mandatory : YES -# Default : CPACK_PACKAGE_DESCRIPTION +# Default : CPACK_PACKAGE_DESCRIPTION_SUMMARY # The RPM package summary # CPACK_RPM_PACKAGE_NAME # Mandatory : YES @@ -24,14 +24,14 @@ # CPACK_RPM_PACKAGE_ARCHITECTURE # Mandatory : NO # Default : - -# The RPM package architecture. This may be set to "noarch" if you +# The RPM package architecture. This may be set to "noarch" if you # know you are building a noarch package. # CPACK_RPM_PACKAGE_RELEASE # Mandatory : YES # Default : 1 -# The RPM package release. This is the numbering of the RPM package -# itself, i.e. the version of the packaging and not the version of the -# content (see CPACK_RPM_PACKAGE_VERSION). One may change the default +# The RPM package release. This is the numbering of the RPM package +# itself, i.e. the version of the packaging and not the version of the +# content (see CPACK_RPM_PACKAGE_VERSION). One may change the default # value if the previous packaging was buggy and/or you want to put here # a fancy Linux distro specific numbering. # CPACK_RPM_PACKAGE_LICENSE @@ -42,10 +42,14 @@ # Mandatory : YES # Default : "unknown" # The RPM package group. -# CPACK_RPM_PACKAGE_VENDOR +# CPACK_RPM_PACKAGE_VENDOR # Mandatory : YES # Default : CPACK_PACKAGE_VENDOR if set or "unknown" -# The RPM package group. +# The RPM package vendor. +# CPACK_RPM_PACKAGE_URL +# Mandatory : NO +# Default : - +# The projects URL. # CPACK_RPM_PACKAGE_DESCRIPTION # Mandatory : YES # Default : CPACK_PACKAGE_DESCRIPTION_FILE if set or "no package description available" @@ -61,18 +65,38 @@ # Mandatory : NO # Default : - # May be used to set RPM dependencies (requires). -# Note that you must enclose the complete requires string between quotes, +# Note that you must enclose the complete requires string between quotes, # for example: # set(CPACK_RPM_PACKAGE_REQUIRES "python >= 2.5.0, cmake >= 2.8") -# CPACK_RPM_PACKAGES_PROVIDES +# CPACK_RPM_PACKAGE_SUGGESTS +# Mandatory : NO +# Default : - +# May be used to set weak RPM dependencies (suggests). +# Note that you must enclose the complete requires string between quotes. +# CPACK_RPM_PACKAGE_PROVIDES # Mandatory : NO # Default : - # May be used to set RPM dependencies (provides). +# CPACK_RPM_PACKAGE_OBSOLETES +# Mandatory : NO +# Default : - +# May be used to set RPM packages that are obsoleted by this one. +# CPACK_RPM_PACKAGE_RELOCATABLE +# Mandatory : NO +# Default : CPACK_PACKAGE_RELOCATABLE +# If this variable is set to TRUE or ON CPackRPM will try +# to build a relocatable RPM package. A relocatable RPM may +# be installed using rpm --prefix or --relocate in order to +# install it at an alternate place see rpm(8). +# Note that currently this may fail if CPACK_SET_DESTDIR is set to ON. +# 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 # Mandatory : NO # Default : - -# 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 +# 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. # CPACK_RPM_SPEC_MORE_DEFINE # Mandatory : NO @@ -81,19 +105,19 @@ # CPACK_RPM_PACKAGE_DEBUG # Mandatory : NO # Default : - -# May be set when invoking cpack in order to trace debug informations -# during CPack RPM run. For example you may launch CPack like this +# May be set when invoking cpack in order to trace debug information +# during CPack RPM run. For example you may launch CPack like this # cpack -D CPACK_RPM_PACKAGE_DEBUG=1 -G RPM # CPACK_RPM_USER_BINARY_SPECFILE # Mandatory : NO -# Default : - +# Default : - # May be set by the user in order to specify a USER binary spec file # to be used by CPackRPM instead of generating the file. # The specified file will be processed by CONFIGURE_FILE( @ONLY). # CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE # Mandatory : NO # Default : - -# If set CPack will generate a template for USER specified binary +# If set CPack will generate a template for USER specified binary # spec file and stop with an error. For example launch CPack like this # cpack -D CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE=1 -G RPM # The user may then use this file in order to hand-craft is own @@ -116,6 +140,12 @@ # put after the %post or %postun section # One may verify which scriptlet has been included with # rpm -qp --scripts package.rpm +# 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 +# section. #============================================================================= # Copyright 2007-2009 Kitware, Inc. @@ -127,7 +157,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Author: Eric Noulard with the help of Alexander Neundorf. @@ -141,23 +171,23 @@ IF(NOT UNIX) ENDIF(NOT UNIX) # rpmbuild is the basic command for building RPM package -# it may be a simple (symbolic) link to rpmb command. +# it may be a simple (symbolic) link to rpm command. FIND_PROGRAM(RPMBUILD_EXECUTABLE rpmbuild) -# Check version of the rpmbuild tool this would be easier to +# Check version of the rpmbuild tool this would be easier to # track bugs with users and CPackRPM debug mode. -# We may use RPM version in order to check for available version dependent features +# We may use RPM version in order to check for available version dependent features IF(RPMBUILD_EXECUTABLE) execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --version OUTPUT_VARIABLE _TMP_VERSION ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) - string(REGEX REPLACE "^.*\ " "" + string(REGEX REPLACE "^.*\ " "" RPMBUILD_EXECUTABLE_VERSION - ${_TMP_VERSION}) + ${_TMP_VERSION}) IF(CPACK_RPM_PACKAGE_DEBUG) MESSAGE("CPackRPM:Debug: rpmbuild version is <${RPMBUILD_EXECUTABLE_VERSION}>") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) + ENDIF(CPACK_RPM_PACKAGE_DEBUG) ENDIF(RPMBUILD_EXECUTABLE) IF(NOT RPMBUILD_EXECUTABLE) @@ -165,14 +195,14 @@ IF(NOT RPMBUILD_EXECUTABLE) ENDIF(NOT RPMBUILD_EXECUTABLE) # We may use RPM version in the future in order -# to shut down warning about space in buildtree +# to shut down warning about space in buildtree # some recent RPM version should support space in different places. # not checked [yet]. IF(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*") MESSAGE(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.") ENDIF(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*") -# If rpmbuild is found +# If rpmbuild is found # we try to discover alien since we may be on non RPM distro like Debian. # In this case we may try to to use more advanced features # like generating RPM directly from DEB using alien. @@ -182,7 +212,7 @@ IF(ALIEN_EXECUTABLE) MESSAGE(STATUS "alien found, we may be on a Debian based distro.") ENDIF(ALIEN_EXECUTABLE) -# +# # Use user-defined RPM specific variables value # or generate reasonable default value from # CPACK_xxx generic values. @@ -197,10 +227,10 @@ IF(NOT CPACK_RPM_PACKAGE_SUMMARY) IF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_SUMMARY) ELSE(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) - SET(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) + SET(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY}) ENDIF(NOT CPACK_PACKAGE_DESCRIPTION_SUMMARY) ENDIF(NOT CPACK_RPM_PACKAGE_SUMMARY) - + # CPACK_RPM_PACKAGE_NAME (mandatory) IF(NOT CPACK_RPM_PACKAGE_NAME) STRING(TOLOWER "${CPACK_PACKAGE_NAME}" CPACK_RPM_PACKAGE_NAME) @@ -213,6 +243,11 @@ IF(NOT CPACK_RPM_PACKAGE_VERSION) ENDIF(NOT CPACK_PACKAGE_VERSION) SET(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) ENDIF(NOT CPACK_RPM_PACKAGE_VERSION) +# Replace '-' in version with '_' +# '-' character is an Illegal RPM version character +# it is illegal because it is used to separate +# RPM "Version" from RPM "Release" +STRING(REPLACE "-" "_" CPACK_RPM_PACKAGE_VERSION ${CPACK_RPM_PACKAGE_VERSION}) # CPACK_RPM_PACKAGE_ARCHITECTURE (optional) IF(CPACK_RPM_PACKAGE_ARCHITECTURE) @@ -260,7 +295,7 @@ ENDIF(NOT CPACK_RPM_PACKAGE_VENDOR) # CPACK_RPM_PACKAGE_DESCRIPTION # The variable content may be either -# - explicitely given by tthe user or +# - explicitly given by the user or # - filled with the content of CPACK_PACKAGE_DESCRIPTION_FILE # if it is defined # - set to a default value @@ -294,25 +329,36 @@ IF (CPACK_RPM_COMPRESSION_TYPE) ELSE(CPACK_RPM_COMPRESSION_TYPE) SET(CPACK_RPM_COMPRESSION_TYPE_TMP "") ENDIF(CPACK_RPM_COMPRESSION_TYPE) -# CPACK_RPM_PACKAGE_REQUIRES -# Placeholder used to specify binary RPM dependencies (if any) -# see http://www.rpm.org/max-rpm/s1-rpm-depend-manual-dependencies.html -IF(CPACK_RPM_PACKAGE_REQUIRES) - IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:Debug: User defined Requires:\n ${CPACK_RPM_PACKAGE_REQUIRES}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) - SET(TMP_RPM_REQUIRES "Requires: ${CPACK_RPM_PACKAGE_REQUIRES}") -ENDIF(CPACK_RPM_PACKAGE_REQUIRES) -# CPACK_RPM_PACKAGE_PROVIDES -# Placeholder used to specify binary RPM dependencies (if any) -# see http://www.rpm.org/max-rpm/s1-rpm-depend-manual-dependencies.html -IF(CPACK_RPM_PACKAGE_PROVIDES) - IF(CPACK_RPM_PACKAGE_DEBUG) - MESSAGE("CPackRPM:Debug: User defined Provides:\n ${CPACK_RPM_PACKAGE_PROVIDES}") - ENDIF(CPACK_RPM_PACKAGE_DEBUG) - SET(TMP_RPM_PROVIDES "Provides: ${CPACK_RPM_PACKAGE_PROVIDES}") -ENDIF(CPACK_RPM_PACKAGE_PROVIDES) +if(CPACK_PACKAGE_RELOCATABLE) + set(CPACK_RPM_PACKAGE_RELOCATABLE TRUE) +endif(CPACK_PACKAGE_RELOCATABLE) +if(CPACK_RPM_PACKAGE_RELOCATABLE) + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Trying to build a relocatable package") + endif(CPACK_RPM_PACKAGE_DEBUG) + if(CPACK_SET_DESTDIR AND (NOT CPACK_SET_DESTDIR STREQUAL "I_ON")) + message("CPackRPM:Warning: CPACK_SET_DESTDIR is set (=${CPACK_SET_DESTDIR}) while requesting a relocatable package (CPACK_RPM_PACKAGE_RELOCATABLE is set): this is not supported, the package won't be relocatable.") + else(CPACK_SET_DESTDIR AND (NOT CPACK_SET_DESTDIR STREQUAL "I_ON")) + set(CPACK_RPM_PACKAGE_PREFIX ${CPACK_PACKAGING_INSTALL_PREFIX}) + 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 +FOREACH(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX) + IF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}) + 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) + STRING(TOLOWER "${_PACKAGE_HEADER_TAIL}" _PACKAGE_HEADER_TAIL) + 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}}") + 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}) +ENDFOREACH(_RPM_SPEC_HEADER) # CPACK_RPM_SPEC_INSTALL_POST # May be used to define a RPM post intallation script @@ -348,7 +394,7 @@ endif(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE) # CPACK_RPM_PRE_INSTALL_SCRIPT_FILE # CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE -# 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_PRE_INSTALL_SCRIPT_FILE) @@ -367,6 +413,19 @@ if(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE) endif(EXISTS ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE}) endif(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE) +# CPACK_RPM_CHANGELOG_FILE +# May be used to embed a changelog in the spec file. +# The refered file will be read and directly put after the %changelog section +if(CPACK_RPM_CHANGELOG_FILE) + if(EXISTS ${CPACK_RPM_CHANGELOG_FILE}) + file(READ ${CPACK_RPM_CHANGELOG_FILE} CPACK_RPM_SPEC_CHANGELOG) + else(EXISTS ${CPACK_RPM_CHANGELOG_FILE}) + message(SEND_ERROR "CPackRPM:Warning: CPACK_RPM_CHANGELOG_FILE <${CPACK_RPM_CHANGELOG_FILE}> does not exists - ignoring") + endif(EXISTS ${CPACK_RPM_CHANGELOG_FILE}) +else(CPACK_RPM_CHANGELOG_FILE) + set(CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Erk \n Generated by CPack RPM (no Changelog file were provided)") +endif(CPACK_RPM_CHANGELOG_FILE) + # CPACK_RPM_SPEC_MORE_DEFINE # This is a generated spec rpm file spaceholder IF(CPACK_RPM_SPEC_MORE_DEFINE) @@ -396,18 +455,47 @@ SET(CPACK_RPM_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}") # Use files tree to construct files command (spec file) # We should not forget to include symlinks (thus -o -type l) -# We must remove the './' due to the local search (thus the sed) +# 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 - COMMAND sed {s/\\.//} - COMMAND sed {s/.*man.*\\/.*/&*/} + COMMAND sed {s:.*/man.*/.*:&*:} + COMMAND sed {s/\\.\\\(.*\\\)/\"\\1\"/} WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" OUTPUT_VARIABLE CPACK_RPM_INSTALL_FILES) +if (CPACK_ABSOLUTE_DESTINATION_FILES) + IF(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: Handling Absolute Destination Files: ${CPACK_ABSOLUTE_DESTINATION_FILES}") + ENDIF(CPACK_RPM_PACKAGE_DEBUG) + # Remove trailing space + string(STRIP "${CPACK_RPM_INSTALL_FILES}" CPACK_RPM_INSTALL_FILES_LIST) + # Transform endline separated - string into CMake List + string(REPLACE "\n" ";" CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES_LIST}") + # 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}) + # Rebuild 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) + # Build ABSOLUTE_INSTALL_FILES + set(CPACK_RPM_ABSOLUTE_INSTALL_FILES "") + foreach(F IN LISTS CPACK_ABSOLUTE_DESTINATION_FILES) + 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) + # 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}.spec") - + # Print out some debug information if we were asked for that IF(CPACK_RPM_PACKAGE_DEBUG) MESSAGE("CPackRPM:Debug: CPACK_TOPLEVEL_DIRECTORY = ${CPACK_TOPLEVEL_DIRECTORY}") @@ -420,7 +508,7 @@ IF(CPACK_RPM_PACKAGE_DEBUG) MESSAGE("CPackRPM:Debug: CPACK_PACKAGE_INSTALL_DIRECTORY = ${CPACK_PACKAGE_INSTALL_DIRECTORY}") MESSAGE("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") ENDIF(CPACK_RPM_PACKAGE_DEBUG) - + # USER generated spec file handling. # We should generate a spec file template: # - either because the user asked for it : CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE @@ -429,7 +517,7 @@ ENDIF(CPACK_RPM_PACKAGE_DEBUG) IF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) FILE(WRITE ${CPACK_RPM_BINARY_SPECFILE}.in "# -*- rpm-spec -*- -Buildroot: \@CPACK_RPM_DIRECTORY\@/\@CPACK_PACKAGE_FILE_NAME\@ +BuildRoot: \@CPACK_RPM_DIRECTORY\@/\@CPACK_PACKAGE_FILE_NAME\@ Summary: \@CPACK_RPM_PACKAGE_SUMMARY\@ Name: \@CPACK_RPM_PACKAGE_NAME\@ Version: \@CPACK_RPM_PACKAGE_VERSION\@ @@ -437,11 +525,13 @@ Release: \@CPACK_RPM_PACKAGE_RELEASE\@ License: \@CPACK_RPM_PACKAGE_LICENSE\@ Group: \@CPACK_RPM_PACKAGE_GROUP\@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ +\@TMP_RPM_URL\@ \@TMP_RPM_REQUIRES\@ \@TMP_RPM_PROVIDES\@ +\@TMP_RPM_OBSOLETES\@ \@TMP_RPM_BUILDARCH\@ - -#p define prefix \@CMAKE_INSTALL_PREFIX\@ +\@TMP_RPM_PREFIX\@ + %define _rpmdir \@CPACK_RPM_DIRECTORY\@ %define _rpmfilename \@CPACK_RPM_FILE_NAME\@ %define _unpackaged_files_terminate_build 0 @@ -449,7 +539,7 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ \@TMP_RPM_SPEC_INSTALL_POST\@ \@CPACK_RPM_SPEC_MORE_DEFINE\@ \@CPACK_RPM_COMPRESSION_TYPE_TMP\@ - + %description \@CPACK_RPM_PACKAGE_DESCRIPTION\@ @@ -458,17 +548,17 @@ Vendor: \@CPACK_RPM_PACKAGE_VENDOR\@ # We do only save CPack installed tree in _prepr # and then restore it in build. %prep -mv $RPM_BUILD_ROOT \@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot +mv $RPM_BUILD_ROOT \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" #p build - + %install if [ -e $RPM_BUILD_ROOT ]; then - mv \@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot/* $RPM_BUILD_ROOT + mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot/*\" $RPM_BUILD_ROOT else - mv \@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot $RPM_BUILD_ROOT -fi + mv \"\@CPACK_TOPLEVEL_DIRECTORY\@/tmpBBroot\" $RPM_BUILD_ROOT +fi %clean @@ -487,63 +577,42 @@ fi %files %defattr(-,root,root,-) ${CPACK_RPM_INSTALL_FILES} +${CPACK_RPM_ABSOLUTE_INSTALL_FILES} %changelog -* Sun Apr 4 2010 Erk - Add support for specifying RPM compression type -* Sat Nov 28 2009 Erk - Refix backup/restore install tree for OpenSuSE 11.2 -* Sun Nov 22 2009 Erk - Include symlinks in the file list. -* Sat Nov 14 2009 Erk - Replace prep and build step with backup and restore - of the previously CPack installed tree. This should - mimic what is expected in rpmbuild usual steps -* Wed Nov 11 2009 Erk - Add support for USER defined pre/post[un]install scripts -* Wed Oct 07 2009 Erk - Add user custom spec file support -* Sat Oct 03 2009 Kami - Update to handle more precisely the files section -* Mon Oct 03 2008 Erk - Update generator to handle optional dependencies using Requires - Update DEBUG output typos. -* Mon Aug 25 2008 Erk - Update generator to handle optional post-install -* Tue Aug 16 2007 Erk - Generated by CPack RPM Generator and associated macros +\@CPACK_RPM_SPEC_CHANGELOG\@ ") # Stop here if we were asked to only generate a template USER spec file # The generated file may then be used as a template by user who wants - # to customize their own spec file. + # to customize their own spec file. IF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE) MESSAGE(FATAL_ERROR "CPackRPM: STOP here Generated USER binary spec file templare is: ${CPACK_RPM_BINARY_SPECFILE}.in") ENDIF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE) ENDIF(CPACK_RPM_GENERATE_USER_BINARY_SPECFILE_TEMPLATE OR NOT CPACK_RPM_USER_BINARY_SPECFILE) # After that we may either use a user provided spec file -# or generate one using appropriate variables value. +# or generate one using appropriate variables value. IF(CPACK_RPM_USER_BINARY_SPECFILE) # User may have specified SPECFILE just use it MESSAGE("CPackRPM: Will use USER specified spec file: ${CPACK_RPM_USER_BINARY_SPECFILE}") # The user provided file is processed for @var replacement CONFIGURE_FILE(${CPACK_RPM_USER_BINARY_SPECFILE} ${CPACK_RPM_BINARY_SPECFILE} @ONLY) ELSE(CPACK_RPM_USER_BINARY_SPECFILE) - # No User specified spec file, will use the generated spec file - MESSAGE("CPackRPM: Will use GENERATED spec file: ${CPACK_RPM_BINARY_SPECFILE}") - # Note the just created file is processed for @var replacement + # No User specified spec file, will use the generated spec file + MESSAGE("CPackRPM: Will use GENERATED spec file: ${CPACK_RPM_BINARY_SPECFILE}") + # Note the just created file is processed for @var replacement CONFIGURE_FILE(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY) ENDIF(CPACK_RPM_USER_BINARY_SPECFILE) IF(RPMBUILD_EXECUTABLE) # Now call rpmbuild using the SPECFILE EXECUTE_PROCESS( - COMMAND "${RPMBUILD_EXECUTABLE}" -bb - --buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" + COMMAND "${RPMBUILD_EXECUTABLE}" -bb + --buildroot "${CPACK_RPM_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" "${CPACK_RPM_BINARY_SPECFILE}" WORKING_DIRECTORY "${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}" ERROR_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.err" - OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.out") + OUTPUT_FILE "${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.out") IF(CPACK_RPM_PACKAGE_DEBUG) MESSAGE("CPackRPM:Debug: You may consult rpmbuild logs in: ") MESSAGE("CPackRPM:Debug: - ${CPACK_TOPLEVEL_DIRECTORY}/rpmbuild.err") diff --git a/Modules/CPackZIP.cmake b/Modules/CPackZIP.cmake index b73bdf100..99963cf91 100644 --- a/Modules/CPackZIP.cmake +++ b/Modules/CPackZIP.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF(CMAKE_BINARY_DIR) diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake index 2d0702e96..bb76ddd25 100644 --- a/Modules/CTest.cmake +++ b/Modules/CTest.cmake @@ -55,7 +55,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) OPTION(BUILD_TESTING "Build the testing tree." ON) @@ -163,6 +163,11 @@ IF(BUILD_TESTING) SET(DART_TESTING_TIMEOUT 1500 CACHE STRING "Maximum time allowed before CTest will kill the test.") + SET(CTEST_SUBMIT_RETRY_DELAY 5 CACHE STRING + "How long to wait between timed-out CTest submissions.") + SET(CTEST_SUBMIT_RETRY_COUNT 3 CACHE STRING + "How many times to retry timed-out CTest submissions.") + FIND_PROGRAM(MEMORYCHECK_COMMAND NAMES purify valgrind boundscheck PATHS @@ -223,8 +228,10 @@ IF(BUILD_TESTING) ENDIF(NOT BUILDNAME) # the build command - BUILD_COMMAND(MAKECOMMAND CONFIGURATION "\${CTEST_CONFIGURATION_TYPE}") - SET(MAKECOMMAND ${MAKECOMMAND} CACHE STRING "Command to build the project") + BUILD_COMMAND(MAKECOMMAND_DEFAULT_VALUE + CONFIGURATION "\${CTEST_CONFIGURATION_TYPE}") + SET(MAKECOMMAND ${MAKECOMMAND_DEFAULT_VALUE} + CACHE STRING "Command to build the project") # the default build configuration the ctest build handler will use # if there is no -C arg given to ctest: @@ -262,7 +269,9 @@ IF(BUILD_TESTING) SCPCOMMAND SLURM_SBATCH_COMMAND SLURM_SRUN_COMMAND - SITE + SITE + CTEST_SUBMIT_RETRY_DELAY + CTEST_SUBMIT_RETRY_COUNT ) # BUILDNAME IF(NOT RUN_FROM_DART) diff --git a/Modules/CTestScriptMode.cmake b/Modules/CTestScriptMode.cmake index 4a93d2354..e459c1d59 100644 --- a/Modules/CTestScriptMode.cmake +++ b/Modules/CTestScriptMode.cmake @@ -11,7 +11,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Determine the current system, so this information can be used diff --git a/Modules/CTestTargets.cmake b/Modules/CTestTargets.cmake index fc47ff8a0..e3ef86cbe 100644 --- a/Modules/CTestTargets.cmake +++ b/Modules/CTestTargets.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF(NOT RUN_FROM_CTEST_OR_DART) @@ -65,6 +65,7 @@ IF(NOT _CTEST_TARGETS_ADDED) ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode} ) SET_PROPERTY(TARGET ${mode} PROPERTY RULE_LAUNCH_CUSTOM "") + SET_PROPERTY(TARGET ${mode} PROPERTY FOLDER "CTestDashboardTargets") ENDFOREACH(mode) # For Makefile generators add more granular targets. @@ -79,6 +80,7 @@ IF(NOT _CTEST_TARGETS_ADDED) ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}${testtype} ) SET_PROPERTY(TARGET ${mode}${testtype} PROPERTY RULE_LAUNCH_CUSTOM "") + SET_PROPERTY(TARGET ${mode}${testtype} PROPERTY FOLDER "CTestDashboardTargets") ENDFOREACH(testtype) ENDFOREACH(mode) ENDIF("${CMAKE_GENERATOR}" MATCHES Make) diff --git a/Modules/CheckCCompilerFlag.cmake b/Modules/CheckCCompilerFlag.cmake index d5d8db938..0068617bb 100644 --- a/Modules/CheckCCompilerFlag.cmake +++ b/Modules/CheckCCompilerFlag.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(CheckCSourceCompiles) diff --git a/Modules/CheckCSourceCompiles.cmake b/Modules/CheckCSourceCompiles.cmake index b2768c20c..e8bfc0c96 100644 --- a/Modules/CheckCSourceCompiles.cmake +++ b/Modules/CheckCSourceCompiles.cmake @@ -21,7 +21,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(CHECK_C_SOURCE_COMPILES SOURCE VAR) diff --git a/Modules/CheckCSourceRuns.cmake b/Modules/CheckCSourceRuns.cmake index 50cd02818..764c756d4 100644 --- a/Modules/CheckCSourceRuns.cmake +++ b/Modules/CheckCSourceRuns.cmake @@ -21,7 +21,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(CHECK_C_SOURCE_RUNS SOURCE VAR) diff --git a/Modules/CheckCXXCompilerFlag.cmake b/Modules/CheckCXXCompilerFlag.cmake index 5d22ee539..d8e471548 100644 --- a/Modules/CheckCXXCompilerFlag.cmake +++ b/Modules/CheckCXXCompilerFlag.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(CheckCXXSourceCompiles) diff --git a/Modules/CheckCXXSourceCompiles.cmake b/Modules/CheckCXXSourceCompiles.cmake index 5f1660777..4502c6b4e 100644 --- a/Modules/CheckCXXSourceCompiles.cmake +++ b/Modules/CheckCXXSourceCompiles.cmake @@ -21,7 +21,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(CHECK_CXX_SOURCE_COMPILES SOURCE VAR) diff --git a/Modules/CheckCXXSourceRuns.cmake b/Modules/CheckCXXSourceRuns.cmake index 3a3dafaae..ace60d1a7 100644 --- a/Modules/CheckCXXSourceRuns.cmake +++ b/Modules/CheckCXXSourceRuns.cmake @@ -21,7 +21,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(CHECK_CXX_SOURCE_RUNS SOURCE VAR) diff --git a/Modules/CheckFortranFunctionExists.cmake b/Modules/CheckFortranFunctionExists.cmake index 0e0f21748..6e932d09d 100644 --- a/Modules/CheckFortranFunctionExists.cmake +++ b/Modules/CheckFortranFunctionExists.cmake @@ -19,7 +19,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE) diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake index e8fd85d4a..e1a177722 100644 --- a/Modules/CheckFunctionExists.cmake +++ b/Modules/CheckFunctionExists.cmake @@ -22,7 +22,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake index d1ea76a61..eb732d28b 100644 --- a/Modules/CheckIncludeFile.cmake +++ b/Modules/CheckIncludeFile.cmake @@ -25,7 +25,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(CHECK_INCLUDE_FILE INCLUDE VARIABLE) diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake index b1ac62ada..c5d8f9aa2 100644 --- a/Modules/CheckIncludeFileCXX.cmake +++ b/Modules/CheckIncludeFileCXX.cmake @@ -25,7 +25,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake index 21e97dc5f..75b5ca168 100644 --- a/Modules/CheckIncludeFiles.cmake +++ b/Modules/CheckIncludeFiles.cmake @@ -22,7 +22,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(CHECK_INCLUDE_FILES INCLUDE VARIABLE) diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake index 64f6455e9..caf4f4c93 100644 --- a/Modules/CheckLibraryExists.cmake +++ b/Modules/CheckLibraryExists.cmake @@ -23,7 +23,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) diff --git a/Modules/CheckSizeOf.cmake b/Modules/CheckSizeOf.cmake index 0663ce4ba..f6d6636e5 100644 --- a/Modules/CheckSizeOf.cmake +++ b/Modules/CheckSizeOf.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MESSAGE(SEND_ERROR diff --git a/Modules/CheckStructHasMember.cmake b/Modules/CheckStructHasMember.cmake index 32abe73b6..18e80e3c0 100644 --- a/Modules/CheckStructHasMember.cmake +++ b/Modules/CheckStructHasMember.cmake @@ -25,7 +25,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(CheckCSourceCompiles) diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index d48b65f14..40910f25c 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -23,7 +23,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE) diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index 6f4b43760..5d5c931b9 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -43,7 +43,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) include(CheckIncludeFile) diff --git a/Modules/CheckVariableExists.cmake b/Modules/CheckVariableExists.cmake index 13104e51c..98328912c 100644 --- a/Modules/CheckVariableExists.cmake +++ b/Modules/CheckVariableExists.cmake @@ -23,7 +23,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(CHECK_VARIABLE_EXISTS VAR VARIABLE) diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index 63652b655..0bb31f9e5 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is shared by multiple languages; use include blocker. diff --git a/Modules/Compiler/PGI.cmake b/Modules/Compiler/PGI.cmake index c6960fcac..162e3c9b8 100644 --- a/Modules/Compiler/PGI.cmake +++ b/Modules/Compiler/PGI.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is shared by multiple languages; use include blocker. diff --git a/Modules/Compiler/PathScale.cmake b/Modules/Compiler/PathScale.cmake index a53112b86..107f779a9 100644 --- a/Modules/Compiler/PathScale.cmake +++ b/Modules/Compiler/PathScale.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is shared by multiple languages; use include blocker. diff --git a/Modules/Dart.cmake b/Modules/Dart.cmake index f125ceb9e..870545471 100644 --- a/Modules/Dart.cmake +++ b/Modules/Dart.cmake @@ -29,7 +29,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) OPTION(BUILD_TESTING "Build the testing tree." ON) diff --git a/Modules/DartConfiguration.tcl.in b/Modules/DartConfiguration.tcl.in index 51f514fde..caf0afe23 100644 --- a/Modules/DartConfiguration.tcl.in +++ b/Modules/DartConfiguration.tcl.in @@ -84,3 +84,7 @@ CurlOptions: @CTEST_CURL_OPTIONS@ # warning, if you add new options here that have to do with submit, # you have to update cmCTestSubmitCommand.cxx +# For CTest submissions that timeout, these options +# specify behavior for retrying the submission +CTestSubmitRetryDelay: @CTEST_SUBMIT_RETRY_DELAY@ +CTestSubmitRetryCount: @CTEST_SUBMIT_RETRY_COUNT@ diff --git a/Modules/Documentation.cmake b/Modules/Documentation.cmake index ddb19ca1f..ffeb371cc 100644 --- a/Modules/Documentation.cmake +++ b/Modules/Documentation.cmake @@ -12,7 +12,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 8c249dc7f..997164a8e 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -39,10 +39,19 @@ # #--Install step--------------- # [INSTALL_DIR dir] # Installation prefix # [INSTALL_COMMAND cmd...] # Command to drive install after build -# #--Test step--------------- +# #--Test step------------------ # [TEST_BEFORE_INSTALL 1] # Add test step executed before install step # [TEST_AFTER_INSTALL 1] # Add test step executed after install step # [TEST_COMMAND cmd...] # Command to drive test +# #--Output logging------------- +# [LOG_DOWNLOAD 1] # Wrap download in script to log output +# [LOG_UPDATE 1] # Wrap update in script to log output +# [LOG_CONFIGURE 1] # Wrap configure in script to log output +# [LOG_BUILD 1] # Wrap build in script to log output +# [LOG_TEST 1] # Wrap test in script to log output +# [LOG_INSTALL 1] # Wrap install in script to log output +# #--Custom targets------------- +# [STEP_TARGETS st1 st2 ...] # Generate custom targets for these steps # ) # The *_DIR options specify directories for the project, with default # directories computed as follows. @@ -86,6 +95,7 @@ # [DEPENDS files...] # Files on which this step depends # [ALWAYS 1] # No stamp file, step always runs # [WORKING_DIRECTORY dir] # Working directory for command +# [LOG 1] # Wrap step in script to log output # ) # The command line, comment, and working directory of every standard # and custom step is processed to replace tokens @@ -101,6 +111,35 @@ # It stores property values in variables of the same name. # Property names correspond to the keyword argument names of # 'ExternalProject_Add'. +# +# The 'ExternalProject_Add_StepTargets' function generates custom targets for +# the steps listed: +# ExternalProject_Add_StepTargets( [step1 [step2 [...]]]) +# +# If STEP_TARGETS is set then ExternalProject_Add_StepTargets is automatically +# called at the end of matching calls to ExternalProject_Add_Step. Pass +# STEP_TARGETS explicitly to individual ExternalProject_Add calls, or +# implicitly to all ExternalProject_Add calls by setting the directory property +# EP_STEP_TARGETS. +# +# If STEP_TARGETS is not set, clients may still manually call +# ExternalProject_Add_StepTargets after calling ExternalProject_Add or +# ExternalProject_Add_Step. +# +# This functionality is provided to make it easy to drive the steps +# independently of each other by specifying targets on build command lines. +# For example, you may be submitting to a sub-project based dashboard, where +# you want to drive the configure portion of the build, then submit to the +# dashboard, followed by the build portion, followed by tests. If you invoke +# a custom target that depends on a step halfway through the step dependency +# chain, then all the previous steps will also run to ensure everything is +# up to date. +# +# For example, to drive configure, build and test steps independently for each +# ExternalProject_Add call in your project, write the following line prior to +# any ExternalProject_Add calls in your CMakeLists file: +# +# set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) #============================================================================= # Copyright 2008-2009 Kitware, Inc. @@ -112,11 +151,13 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Pre-compute a regex to match documented keywords for each command. -file(STRINGS "${CMAKE_CURRENT_LIST_FILE}" lines LIMIT_COUNT 103 +math(EXPR _ep_documentation_line_count "${CMAKE_CURRENT_LIST_LINE} - 16") +file(STRINGS "${CMAKE_CURRENT_LIST_FILE}" lines + LIMIT_COUNT ${_ep_documentation_line_count} REGEX "^# ( \\[[A-Z0-9_]+ [^]]*\\] +#.*$|[A-Za-z0-9_]+\\()") foreach(line IN LISTS lines) if("${line}" MATCHES "^# [A-Za-z0-9_]+\\(") @@ -146,8 +187,8 @@ function(_ep_parse_arguments f name ns args) # correctly based on target properties. # # We loop through ARGN and consider the namespace starting with an - # upper-case letter followed by at least two more upper-case letters - # or underscores to be keywords. + # upper-case letter followed by at least two more upper-case letters, + # numbers or underscores to be keywords. set(key) foreach(arg IN LISTS args) @@ -158,14 +199,6 @@ function(_ep_parse_arguments f name ns args) NOT arg MATCHES "^(TRUE|FALSE)$") if(_ep_keywords_${f} AND arg MATCHES "${_ep_keywords_${f}}") set(is_value 0) - else() - if(NOT (key STREQUAL "COMMAND") - AND NOT (key STREQUAL "CVS_MODULE") - AND NOT (key STREQUAL "DEPENDS") - AND NOT (key STREQUAL "DOWNLOAD_COMMAND") - ) - message(AUTHOR_WARNING "unknown ${f} keyword: ${arg}") - endif() endif() endif() @@ -208,6 +241,14 @@ define_property(DIRECTORY PROPERTY "EP_PREFIX" INHERITED "ExternalProject module." ) +define_property(DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED + BRIEF_DOCS + "List of ExternalProject steps that automatically get corresponding targets" + FULL_DOCS + "See documentation of the ExternalProject_Add_StepTargets() function in the " + "ExternalProject module." + ) + function(_ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag src_name work_dir) file(WRITE ${script_filename} @@ -555,8 +596,8 @@ function(_ep_get_build_command name step cmd_var) if(cfg_cmd_id STREQUAL "cmake") # CMake project. Select build command based on generator. get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR) - if("${cmake_generator}" MATCHES "Make" AND - "${cmake_generator}" STREQUAL "${CMAKE_GENERATOR}") + if("${CMAKE_GENERATOR}" MATCHES "Make" AND + ("${cmake_generator}" MATCHES "Make" OR NOT cmake_generator)) # The project uses the same Makefile generator. Use recursive make. set(cmd "$(MAKE)") if(step STREQUAL "INSTALL") @@ -585,7 +626,8 @@ function(_ep_get_build_command name step cmd_var) endif() else() # if(cfg_cmd_id STREQUAL "configure") # Non-CMake project. Guess "make" and "make install" and "make test". - set(cmd "make") + # But use "$(MAKE)" to get recursive parallel make. + set(cmd "$(MAKE)") if(step STREQUAL "INSTALL") set(args install) endif() @@ -606,6 +648,101 @@ function(_ep_get_build_command name step cmd_var) set(${cmd_var} "${cmd}" PARENT_SCOPE) endfunction(_ep_get_build_command) +function(_ep_write_log_script name step cmd_var) + ExternalProject_Get_Property(${name} stamp_dir) + set(command "${${cmd_var}}") + + set(make "") + set(code_cygpath_make "") + if("${command}" MATCHES "^\\$\\(MAKE\\)") + # GNU make recognizes the string "$(MAKE)" as recursive make, so + # ensure that it appears directly in the makefile. + string(REGEX REPLACE "^\\$\\(MAKE\\)" "\${make}" command "${command}") + set(make "-Dmake=$(MAKE)") + + if(WIN32 AND NOT CYGWIN) + set(code_cygpath_make " +if(\${make} MATCHES \"^/\") + execute_process( + COMMAND cygpath -w \${make} + OUTPUT_VARIABLE cygpath_make + ERROR_VARIABLE cygpath_make + RESULT_VARIABLE cygpath_error + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(NOT cygpath_error) + set(make \${cygpath_make}) + endif() +endif() +") + endif() + endif() + + set(config "") + if("${CMAKE_CFG_INTDIR}" MATCHES "^\\$") + string(REPLACE "${CMAKE_CFG_INTDIR}" "\${config}" command "${command}") + set(config "-Dconfig=${CMAKE_CFG_INTDIR}") + endif() + + # Wrap multiple 'COMMAND' lines up into a second-level wrapper + # script so all output can be sent to one log file. + if("${command}" MATCHES ";COMMAND;") + set(code_execute_process " +${code_cygpath_make} +execute_process(COMMAND \${command} RESULT_VARIABLE result) +if(result) + set(msg \"Command failed (\${result}):\\n\") + foreach(arg IN LISTS command) + set(msg \"\${msg} '\${arg}'\") + endforeach(arg) + message(FATAL_ERROR \"\${msg}\") +endif() +") + set(code "") + set(cmd "") + set(sep "") + foreach(arg IN LISTS command) + if("x${arg}" STREQUAL "xCOMMAND") + set(code "${code}set(command \"${cmd}\")${code_execute_process}") + set(cmd "") + set(sep "") + else() + set(cmd "${cmd}${sep}${arg}") + set(sep ";") + endif() + endforeach() + set(code "${code}set(command \"${cmd}\")${code_execute_process}") + file(WRITE ${stamp_dir}/${name}-${step}-impl.cmake "${code}") + set(command ${CMAKE_COMMAND} "-Dmake=\${make}" "-Dconfig=\${config}" -P ${stamp_dir}/${name}-${step}-impl.cmake) + endif() + + # Wrap the command in a script to log output to files. + set(script ${stamp_dir}/${name}-${step}.cmake) + set(logbase ${stamp_dir}/${name}-${step}) + file(WRITE ${script} " +${code_cygpath_make} +set(command \"${command}\") +execute_process( + COMMAND \${command} + RESULT_VARIABLE result + OUTPUT_FILE \"${logbase}-out.log\" + ERROR_FILE \"${logbase}-err.log\" + ) +if(result) + set(msg \"Command failed: \${result}\\n\") + foreach(arg IN LISTS command) + set(msg \"\${msg} '\${arg}'\") + endforeach(arg) + set(msg \"\${msg}\\nSee also\\n ${logbase}-*.log\\n\") + message(FATAL_ERROR \"\${msg}\") +else() + set(msg \"${name} ${step} command succeeded. See also ${logbase}-*.log\\n\") + message(STATUS \"\${msg}\") +endif() +") + set(command ${CMAKE_COMMAND} ${make} ${config} -P ${script}) + set(${cmd_var} "${command}" PARENT_SCOPE) +endfunction(_ep_write_log_script) # This module used to use "/${CMAKE_CFG_INTDIR}" directly and produced # makefiles with "/./" in paths for custom command dependencies. Which @@ -624,6 +761,19 @@ function(_ep_get_configuration_subdir_suffix suffix_var) endfunction(_ep_get_configuration_subdir_suffix) +function(ExternalProject_Add_StepTargets name) + set(steps ${ARGN}) + + _ep_get_configuration_subdir_suffix(cfgdir) + ExternalProject_Get_Property(${name} stamp_dir) + + foreach(step ${steps}) + add_custom_target(${name}-${step} + DEPENDS ${stamp_dir}${cfgdir}/${name}-${step}) + endforeach() +endfunction(ExternalProject_Add_StepTargets) + + function(ExternalProject_Add_Step name step) set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles) ExternalProject_Get_Property(${name} stamp_dir) @@ -695,6 +845,12 @@ function(ExternalProject_Add_Step name step) set(touch ${CMAKE_COMMAND} -E touch ${stamp_dir}${cfgdir}/${name}-${step}) endif() + # Wrap with log script? + get_property(log TARGET ${name} PROPERTY _EP_${step}_LOG) + if(command AND log) + _ep_write_log_script(${name} ${step} command) + endif() + add_custom_command( OUTPUT ${stamp_dir}${cfgdir}/${name}-${step} COMMENT ${comment} @@ -704,6 +860,18 @@ function(ExternalProject_Add_Step name step) WORKING_DIRECTORY ${work_dir} VERBATIM ) + + # Add custom "step target"? + get_property(step_targets TARGET ${name} PROPERTY _EP_STEP_TARGETS) + if(NOT step_targets) + get_property(step_targets DIRECTORY PROPERTY EP_STEP_TARGETS) + endif() + foreach(st ${step_targets}) + if("${st}" STREQUAL "${step}") + ExternalProject_Add_StepTargets(${name} ${step}) + break() + endif() + endforeach() endfunction(ExternalProject_Add_Step) @@ -816,8 +984,15 @@ function(_ep_add_download_command name) get_filename_component(src_name "${source_dir}" NAME) get_filename_component(work_dir "${source_dir}" PATH) set(comment "Performing download step (SVN checkout) for '${name}'") + set(svn_user_pw_args "") + if(svn_username) + set(svn_user_pw_args ${svn_user_pw_args} "--username=${svn_username}") + endif() + if(svn_password) + set(svn_user_pw_args ${svn_user_pw_args} "--password=${svn_password}") + endif() set(cmd ${Subversion_SVN_EXECUTABLE} co ${svn_repository} ${svn_revision} - --username=${svn_username} --password=${svn_password} ${src_name}) + ${svn_user_pw_args} ${src_name}) list(APPEND depends ${stamp_dir}/${name}-svninfo.txt) elseif(git_repository) find_package(Git) @@ -905,12 +1080,20 @@ function(_ep_add_download_command name) endif() endif() + get_property(log TARGET ${name} PROPERTY _EP_LOG_DOWNLOAD) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} download COMMENT ${comment} COMMAND ${cmd} WORKING_DIRECTORY ${work_dir} DEPENDS ${depends} DEPENDEES mkdir + ${log} ) endfunction(_ep_add_download_command) @@ -948,8 +1131,15 @@ function(_ep_add_update_command name) get_property(svn_revision TARGET ${name} PROPERTY _EP_SVN_REVISION) get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME) get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD) + set(svn_user_pw_args "") + if(svn_username) + set(svn_user_pw_args ${svn_user_pw_args} "--username=${svn_username}") + endif() + if(svn_password) + set(svn_user_pw_args ${svn_user_pw_args} "--password=${svn_password}") + endif() set(cmd ${Subversion_SVN_EXECUTABLE} up ${svn_revision} - --username=${svn_username} --password=${svn_password}) + ${svn_user_pw_args}) set(always 1) elseif(git_repository) if(NOT GIT_EXECUTABLE) @@ -968,12 +1158,20 @@ function(_ep_add_update_command name) set(always 1) endif() + get_property(log TARGET ${name} PROPERTY _EP_LOG_UPDATE) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} update COMMENT ${comment} COMMAND ${cmd} ALWAYS ${always} WORKING_DIRECTORY ${work_dir} DEPENDEES download + ${log} ) endfunction(_ep_add_update_command) @@ -1044,11 +1242,19 @@ function(_ep_add_configure_command name) configure_file(${tmp_dir}/${name}-cfgcmd.txt.in ${tmp_dir}/${name}-cfgcmd.txt) list(APPEND file_deps ${tmp_dir}/${name}-cfgcmd.txt) + get_property(log TARGET ${name} PROPERTY _EP_LOG_CONFIGURE) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} configure COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} DEPENDEES update patch DEPENDS ${file_deps} + ${log} ) endfunction(_ep_add_configure_command) @@ -1063,10 +1269,18 @@ function(_ep_add_build_command name) _ep_get_build_command(${name} BUILD cmd) endif() + get_property(log TARGET ${name} PROPERTY _EP_LOG_BUILD) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} build COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} DEPENDEES configure + ${log} ) endfunction(_ep_add_build_command) @@ -1081,10 +1295,18 @@ function(_ep_add_install_command name) _ep_get_build_command(${name} INSTALL cmd) endif() + get_property(log TARGET ${name} PROPERTY _EP_LOG_INSTALL) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} install COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} DEPENDEES build + ${log} ) endfunction(_ep_add_install_command) @@ -1112,10 +1334,18 @@ function(_ep_add_test_command name) set(dep_args DEPENDEES install) endif() + get_property(log TARGET ${name} PROPERTY _EP_LOG_TEST) + if(log) + set(log LOG 1) + else() + set(log "") + endif() + ExternalProject_Add_Step(${name} test COMMAND ${cmd} WORKING_DIRECTORY ${binary_dir} ${dep_args} + ${log} ) endif() endfunction(_ep_add_test_command) diff --git a/Modules/FLTKCompatibility.cmake b/Modules/FLTKCompatibility.cmake index 77ca47b2a..6b6f9607b 100644 --- a/Modules/FLTKCompatibility.cmake +++ b/Modules/FLTKCompatibility.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(CheckIncludeFile) diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake index d1d31bceb..f7bfe27e7 100644 --- a/Modules/FeatureSummary.cmake +++ b/Modules/FeatureSummary.cmake @@ -1,23 +1,100 @@ # - Macros for generating a summary of enabled/disabled features # -# PRINT_ENABLED_FEATURES() -# Print a summary of all enabled features. By default all successfull -# FIND_PACKAGE() calls will appear here, except the ones which used the -# QUIET keyword. Additional features can be added by appending an entry -# to the global ENABLED_FEATURES property. If SET_FEATURE_INFO() is -# used for that feature, the output will be much more informative. +# This module provides the macros feature_summary(), set_package_info() and +# add_feature_info(). +# For compatiblity it also still provides set_feature_info(), +# print_enabled_features() and print_disabled_features. # -# PRINT_DISABLED_FEATURES() -# Same as PRINT_ENABLED_FEATURES(), but for disabled features. It can -# be extended the same way by adding to the global property -# DISABLED_FEATURES. +# These macros can be used to generate a summary of enabled and disabled +# packages and/or feature for a build tree: # -# SET_FEATURE_INFO(NAME DESCRIPTION [URL [COMMENT] ] ) -# Use this macro to set up information about the named feature, which will -# then be displayed by PRINT_ENABLED/DISABLED_FEATURES(). -# Example: SET_FEATURE_INFO(LibXml2 "XML processing library." -# "http://xmlsoft.org/") +# -- Enabled features: +# LibXml2 (required version >= 2.4) , XML processing library. , +# PNG , A PNG image library. , +# -- Disabled features: +# Lua51 , The Lua scripting language. , +# Foo , Foo provides cool stuff. # +# +# FEATURE_SUMMARY( [FILENAME ] +# [APPEND] +# [VAR ] +# [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. +# 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. +# +# 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 +# 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 +# +# 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 +# it already existed. +# If the VAR option is used, the information is "printed" into the specified +# variable. +# 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. +# +# 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: +# feature_summary(WHAT ENABLED_FEATURES +# DESCRIPTION "Enabled Features:" +# VAR enabledFeaturesText) +# message(STATUS "${enabledFeaturesText}") +# +# +# 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. +# +# Example for setting the info for a package: +# find_package(LibXml2) +# set_package_info(LibXml2 "XML processing library." "http://xmlsoft.org/") +# +# +# 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. +# The information can be displayed using feature_summary() for ENABLED_FEATURES +# and DISABLED_FEATURES respectively. +# +# Example for setting the info for a feature: +# option(WITH_FOO "Help for foo" ON) +# add_feature_info(Foo WITH_FOO "The Foo feature provides very cool stuff.") +# +# +# The following macros are provided for compatibility with previous CMake versions: +# +# 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( ) #============================================================================= # Copyright 2007-2009 Kitware, Inc. @@ -29,50 +106,128 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -FUNCTION(SET_FEATURE_INFO _name _desc) +INCLUDE(CMakeParseArguments) + + +FUNCTION(ADD_FEATURE_INFO _name _enabled _desc) + IF (${_enabled}) + SET_PROPERTY(GLOBAL APPEND PROPERTY ENABLED_FEATURES "${_name}") + ELSE () + SET_PROPERTY(GLOBAL APPEND PROPERTY DISABLED_FEATURES "${_name}") + ENDIF () + + SET_PROPERTY(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_desc}" ) +ENDFUNCTION(ADD_FEATURE_INFO) + + +FUNCTION(SET_FEATURE_INFO) + SET_PACKAGE_INFO(${ARGN}) +ENDFUNCTION(SET_FEATURE_INFO) + + +FUNCTION(SET_PACKAGE_INFO _name _desc) SET(_url "${ARGV2}") SET(_comment "${ARGV3}") - SET_PROPERTY(GLOBAL PROPERTY ${_name}_DESCRIPTION "${_desc}" ) + SET_PROPERTY(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_desc}" ) IF(_url MATCHES ".+") - SET_PROPERTY(GLOBAL PROPERTY ${_name}_URL "${_url}" ) + SET_PROPERTY(GLOBAL PROPERTY _CMAKE_${_name}_URL "${_url}" ) ENDIF(_url MATCHES ".+") IF(_comment MATCHES ".+") - SET_PROPERTY(GLOBAL PROPERTY ${_name}_COMMENT "${_comment}" ) + SET_PROPERTY(GLOBAL PROPERTY _CMAKE_${_name}_COMMENT "${_comment}" ) ENDIF(_comment MATCHES ".+") -ENDFUNCTION(SET_FEATURE_INFO) +ENDFUNCTION(SET_PACKAGE_INFO) -FUNCTION(_PRINT_FEATURES _property _text) - SET(_currentFeatureText "${_text}") +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 ${_currentFeature}_DESCRIPTION) + 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 ${_currentFeature}_URL) + GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_URL) IF(_info) SET(_currentFeatureText "${_currentFeatureText} , <${_info}>") ENDIF(_info) - GET_PROPERTY(_info GLOBAL PROPERTY ${_currentFeature}_COMMENT) + GET_PROPERTY(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_COMMENT) IF(_info) SET(_currentFeatureText "${_currentFeatureText} , ${_info}") ENDIF(_info) ENDFOREACH(_currentFeature) - MESSAGE(STATUS "${_currentFeatureText}\n") -ENDFUNCTION(_PRINT_FEATURES) + SET(${_var} "${_currentFeatureText}" PARENT_SCOPE) +ENDFUNCTION(_FS_GET_FEATURE_SUMMARY) FUNCTION(PRINT_ENABLED_FEATURES) - _PRINT_FEATURES( ENABLED_FEATURES "Enabled features:") + FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:") ENDFUNCTION(PRINT_ENABLED_FEATURES) FUNCTION(PRINT_DISABLED_FEATURES) - _PRINT_FEATURES( DISABLED_FEATURES "Disabled features:") + FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:") ENDFUNCTION(PRINT_DISABLED_FEATURES) + + +FUNCTION(FEATURE_SUMMARY) +# CMAKE_PARSE_ARGUMENTS( args...) + SET(options APPEND) + SET(oneValueArgs FILENAME VAR DESCRIPTION WHAT) + SET(multiValueArgs ) # none + + CMAKE_PARSE_ARGUMENTS(_FS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) + + IF(_FS_UNPARSED_ARGUMENTS) + MESSAGE(FATAL_ERROR "Unknown keywords given to FEATURE_SUMMARY(): \"${_FS_UNPARSED_ARGUMENTS}\"") + ENDIF(_FS_UNPARSED_ARGUMENTS) + + 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) + SET(_fullText "${_FS_DESCRIPTION}${_featureSummary}\n") + 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) + ELSE() + MESSAGE(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() is set to ${_FS_WHAT}, which is not a valid value.") + ENDIF() + + IF(_FS_FILENAME) + IF(_FS_APPEND) + FILE(APPEND "${_FS_FILENAME}" "${_fullText}") + ELSE(_FS_APPEND) + FILE(WRITE "${_FS_FILENAME}" "${_fullText}") + ENDIF(_FS_APPEND) + + ELSE(_FS_FILENAME) + IF(NOT _FS_VAR) + MESSAGE(STATUS "${_fullText}") + ENDIF(NOT _FS_VAR) + ENDIF(_FS_FILENAME) + + IF(_FS_VAR) + SET(${_FS_VAR} "${_fullText}" PARENT_SCOPE) + ENDIF(_FS_VAR) + +ENDFUNCTION(FEATURE_SUMMARY) diff --git a/Modules/FindALSA.cmake b/Modules/FindALSA.cmake index 7deefafc1..0ad7643a0 100644 --- a/Modules/FindALSA.cmake +++ b/Modules/FindALSA.cmake @@ -21,7 +21,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) find_path(ALSA_INCLUDE_DIR NAMES asoundlib.h @@ -35,7 +35,7 @@ find_library(ALSA_LIBRARY NAMES asound # handle the QUIETLY and REQUIRED arguments and set ALSA_FOUND to TRUE if # all listed variables are TRUE -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(ALSA DEFAULT_MSG ALSA_LIBRARY ALSA_INCLUDE_DIR) if(ALSA_FOUND) diff --git a/Modules/FindASPELL.cmake b/Modules/FindASPELL.cmake index a211ab06f..3319caac7 100644 --- a/Modules/FindASPELL.cmake +++ b/Modules/FindASPELL.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(ASPELL_INCLUDE_DIR aspell.h ) @@ -26,7 +26,7 @@ FIND_LIBRARY(ASPELL_LIBRARIES NAMES aspell aspell-15 libaspell-15 libaspell) # handle the QUIETLY and REQUIRED arguments and set ASPELL_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(ASPELL DEFAULT_MSG ASPELL_LIBRARIES ASPELL_INCLUDE_DIR) MARK_AS_ADVANCED(ASPELL_INCLUDE_DIR ASPELL_LIBRARIES) diff --git a/Modules/FindAVIFile.cmake b/Modules/FindAVIFile.cmake index 7272ba64e..afd380073 100644 --- a/Modules/FindAVIFile.cmake +++ b/Modules/FindAVIFile.cmake @@ -19,7 +19,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF (UNIX) @@ -37,7 +37,7 @@ ENDIF (UNIX) # handle the QUIETLY and REQUIRED arguments and set AVIFILE_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(AVIFile DEFAULT_MSG AVIFILE_INCLUDE_DIR AVIFILE_AVIPLAY_LIBRARY) IF (AVIFILE_FOUND) diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake index b604d0ba6..1120fc115 100644 --- a/Modules/FindBISON.cmake +++ b/Modules/FindBISON.cmake @@ -5,6 +5,9 @@ # BISON_VERSION - version of bison # BISON_FOUND - true if the program was found # +# The minimum required version of bison can be specified using the +# standard CMake syntax, e.g. find_package(BISON 2.1.3) +# # If bison is found, the module defines the macros: # BISON_TARGET( [VERBOSE ] # [COMPILE_FLAGS ]) @@ -41,7 +44,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PROGRAM(BISON_EXECUTABLE bison DOC "path to the bison executable") @@ -93,7 +96,7 @@ IF(BISON_EXECUTABLE) # MACRO(BISON_TARGET Name BisonInput BisonOutput) SET(BISON_TARGET_output_header "") - SET(BISON_TARGET_command_opt "") + SET(BISON_TARGET_cmdopt "") SET(BISON_TARGET_outputs "${BisonOutput}") IF(NOT ${ARGC} EQUAL 3 AND NOT ${ARGC} EQUAL 5 AND NOT ${ARGC} EQUAL 7) MESSAGE(SEND_ERROR "Usage") @@ -148,7 +151,8 @@ IF(BISON_EXECUTABLE) ENDIF(BISON_EXECUTABLE) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(BISON DEFAULT_MSG BISON_EXECUTABLE) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") +FIND_PACKAGE_HANDLE_STANDARD_ARGS(BISON REQUIRED_VARS BISON_EXECUTABLE + VERSION_VAR BISON_VERSION) # FindBISON.cmake ends here diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake index be41736ae..94bbed5ac 100644 --- a/Modules/FindBLAS.cmake +++ b/Modules/FindBLAS.cmake @@ -36,7 +36,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES) diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake index 2dcc9b457..0ef87fafa 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(BZIP2_INCLUDE_DIR bzlib.h ) @@ -26,7 +26,7 @@ FIND_LIBRARY(BZIP2_LIBRARIES NAMES bz2 bzip2 ) # handle the QUIETLY and REQUIRED arguments and set BZip2_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2 DEFAULT_MSG BZIP2_LIBRARIES BZIP2_INCLUDE_DIR) IF (BZIP2_FOUND) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index ea9eb2525..3ae4e1410 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -17,8 +17,9 @@ # # == Using actual libraries from within Boost: == # -# set(Boost_USE_STATIC_LIBS ON) -# set(Boost_USE_MULTITHREADED ON) +# set(Boost_USE_STATIC_LIBS ON) +# set(Boost_USE_MULTITHREADED ON) +# set(Boost_USE_STATIC_RUNTIME OFF) # find_package( Boost 1.36.0 COMPONENTS date_time filesystem system ... ) # # if(Boost_FOUND) @@ -63,7 +64,7 @@ # Currently this module searches for the following version numbers: # 1.33, 1.33.0, 1.33.1, 1.34, 1.34.0, 1.34.1, 1.35, 1.35.0, 1.35.1, # 1.36, 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.40, 1.40.0, 1.41, 1.41.0, 1.42, 1.42.0, 1.43, 1.43.0, 1.44, 1.44.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 @@ -84,6 +85,37 @@ # Boost_USE_STATIC_LIBS Can be set to ON to force the use of the static # boost libraries. Defaults to OFF. # +# Boost_NO_SYSTEM_PATHS Set to TRUE to suppress searching in system +# paths (or other locations outside of BOOST_ROOT +# or BOOST_INCLUDEDIR). Useful when specifying +# BOOST_ROOT. Defaults to OFF. +# [Since CMake 2.8.3] +# +# 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 +# ON or OFF because the default behavior +# if not specified is platform dependent +# for backwards compatibility. +# [Since CMake 2.8.3] +# +# Boost_USE_DEBUG_PYTHON If enabled, searches for boost libraries +# compiled against a special debug build of +# Python ('y' ABI tag). Defaults to OFF. +# [Since CMake 2.8.3] +# +# Boost_USE_STLPORT If enabled, searches for boost libraries +# compiled against the STLPort standard +# library ('p' ABI tag). Defaults to OFF. +# [Since CMake 2.8.3] +# +# Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS +# If enabled, searches for boost libraries +# compiled against the deprecated STLPort +# "native iostreams" feature ('n' ABI tag). +# Defaults to OFF. +# [Since CMake 2.8.3] +# # Other Variables used by this module which you may want to set. # # Boost_ADDITIONAL_VERSIONS A list of version numbers to use for searching @@ -105,12 +137,38 @@ # Boost_COMPILER Set this to the compiler suffix used by Boost # (e.g. "-gcc43") if FindBoost has problems finding # the proper Boost installation +# +# Boost_THREADAPI When building boost.thread, sometimes the name of the +# library contains an additional "pthread" or "win32" +# string known as the threadapi. This can happen when +# compiling against pthreads on Windows or win32 threads +# on Cygwin. You may specify this variable and if set +# when FindBoost searches for the Boost threading library +# it will first try to match the threadapi you specify. +# For Example: libboost_thread_win32-mgw45-mt-1_43.a +# might be found if you specified "win32" here before +# falling back on libboost_thread-mgw45-mt-1_43.a. +# [Since CMake 2.8.3] +# +# Boost_REALPATH Resolves symbolic links for discovered boost libraries +# to assist with packaging. For example, instead of +# Boost_SYSTEM_LIBRARY_RELEASE being resolved to +# "/usr/lib/libboost_system.so" it would be +# "/usr/lib/libboost_system.so.1.42.0" instead. +# This does not affect linking and should not be +# enabled unless the user needs this information. +# [Since CMake 2.8.3] +# + + # # These last three variables are available also as environment variables: # # BOOST_ROOT or BOOSTROOT The preferred installation prefix for searching for # Boost. Set this if the module has problems finding -# the proper Boost installation. +# the proper Boost installation. To prevent falling +# back on the system paths, set Boost_NO_SYSTEM_PATHS +# to true. # # BOOST_INCLUDEDIR Set this to the include directory of Boost, if the # module has problems finding the proper Boost installation @@ -165,7 +223,7 @@ # Copyright 2007 Wengo # Copyright 2007 Mike Jackson # Copyright 2008 Andreas Pakulat -# Copyright 2008-2009 Philip Lowman +# Copyright 2008-2010 Philip Lowman # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -174,7 +232,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) #------------------------------------------------------------------------------- @@ -275,6 +333,28 @@ function(_Boost_MARK_COMPONENTS_FOUND _yes_or_no) endforeach() endfunction() +# +# Take a list of libraries with "thread" in it +# and prepend duplicates with "thread_${Boost_THREADAPI}" +# at the front of the list +# +function(_Boost_PREPEND_LIST_WITH_THREADAPI _output) + set(_orig_libnames ${ARGN}) + string(REPLACE "thread" "thread_${Boost_THREADAPI}" _threadapi_libnames ${_orig_libnames}) + set(${_output} ${_threadapi_libnames} ${_orig_libnames} PARENT_SCOPE) +endfunction() + +# +# If a library is found, replace its cache entry with its REALPATH +# +function(_Boost_SWAP_WITH_REALPATH _library _docstring) + if(${_library}) + get_filename_component(_boost_filepathreal ${${_library}} REALPATH) + unset(${_library} CACHE) + set(${_library} ${_boost_filepathreal} CACHE FILEPATH "${_docstring}") + endif() +endfunction() + # # End functions/macros # @@ -297,6 +377,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.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" "1.34" "1.33.1" "1.33.0" "1.33") @@ -365,7 +446,7 @@ IF (_boost_IN_CACHE) if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "boost ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} " - "is already in the cache. For debugging messages, please clear the cache.") + "is already in the cache. To view debugging messages, please clear the cache.") endif() ELSE (_boost_IN_CACHE) # Need to search for boost @@ -379,6 +460,12 @@ ELSE (_boost_IN_CACHE) "Boost_USE_MULTITHREADED = ${Boost_USE_MULTITHREADED}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " "Boost_USE_STATIC_LIBS = ${Boost_USE_STATIC_LIBS}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Boost_USE_STATIC_RUNTIME = ${Boost_USE_STATIC_RUNTIME}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Boost_ADDITIONAL_VERSIONS = ${Boost_ADDITIONAL_VERSIONS}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Boost_NO_SYSTEM_PATHS = ${Boost_NO_SYSTEM_PATHS}") endif() IF(WIN32) @@ -403,7 +490,7 @@ ELSE (_boost_IN_CACHE) "-DBOOST_LIB_DIAGNOSTIC" CACHE STRING "Boost diagnostic define") ENDIF(WIN32) - SET(_boost_INCLUDE_SEARCH_DIRS + set(_boost_INCLUDE_SEARCH_DIRS_SYSTEM C:/boost/include C:/boost "$ENV{ProgramFiles}/boost/include" @@ -411,6 +498,13 @@ ELSE (_boost_IN_CACHE) /sw/local/include ) + # If Boost_ROOT was defined, gently correct the user + if(Boost_ROOT) + message("WARNING: Boost_ROOT was set which is incorrect and is being ignored. " + "You need to use BOOST_ROOT instead. " + "Also, we suggest setting Boost_NO_SYSTEM_PATHS.") + 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}) @@ -448,18 +542,25 @@ ELSE (_boost_IN_CACHE) "_boost_TEST_VERSIONS = ${_boost_TEST_VERSIONS}") endif() - IF( BOOST_ROOT ) - SET(_boost_INCLUDE_SEARCH_DIRS - ${BOOST_ROOT}/include + if( Boost_NO_SYSTEM_PATHS) + set(_boost_FIND_OPTIONS NO_CMAKE_SYSTEM_PATH) + else() + set(_boost_INCLUDE_SEARCH_DIRS ${_boost_INCLUDE_SEARCH_DIRS_SYSTEM}) + endif() + + if( BOOST_ROOT ) + set(_boost_INCLUDE_SEARCH_DIRS + ${BOOST_ROOT}/include ${BOOST_ROOT} ${_boost_INCLUDE_SEARCH_DIRS}) - ENDIF( BOOST_ROOT ) + endif() - IF( BOOST_INCLUDEDIR ) + # prepend BOOST_INCLUDEDIR to search path if specified + if( BOOST_INCLUDEDIR ) file(TO_CMAKE_PATH ${BOOST_INCLUDEDIR} BOOST_INCLUDEDIR) - SET(_boost_INCLUDE_SEARCH_DIRS + set(_boost_INCLUDE_SEARCH_DIRS ${BOOST_INCLUDEDIR} ${_boost_INCLUDE_SEARCH_DIRS}) - ENDIF( BOOST_INCLUDEDIR ) + endif( BOOST_INCLUDEDIR ) # ------------------------------------------------------------------------ # Search for Boost include DIR @@ -485,10 +586,7 @@ ELSE (_boost_IN_CACHE) ENDIF() list(APPEND _boost_PATH_SUFFIXES "boost-${_boost_BOOSTIFIED_VERSION}") - if(WIN32) - # For BoostPro's underscores (and others?) - list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}") - endif() + list(APPEND _boost_PATH_SUFFIXES "boost_${_boost_BOOSTIFIED_VERSION}") ENDFOREACH(_boost_VER) @@ -506,6 +604,7 @@ ELSE (_boost_IN_CACHE) NAMES boost/config.hpp HINTS ${_boost_INCLUDE_SEARCH_DIRS} PATH_SUFFIXES ${_boost_PATH_SUFFIXES} + ${_boost_FIND_OPTIONS} ) ENDIF( NOT Boost_INCLUDE_DIR ) @@ -555,7 +654,7 @@ ELSE (_boost_IN_CACHE) # Setting some more suffixes for the library SET (Boost_LIB_PREFIX "") - if ( WIN32 AND Boost_USE_STATIC_LIBS ) + if ( WIN32 AND Boost_USE_STATIC_LIBS AND NOT CYGWIN) SET (Boost_LIB_PREFIX "lib") endif() @@ -636,7 +735,7 @@ ELSE (_boost_IN_CACHE) endif() endif(Boost_COMPILER) - SET (_boost_MULTITHREADED "-mt") + set (_boost_MULTITHREADED "-mt") if( NOT Boost_USE_MULTITHREADED ) set (_boost_MULTITHREADED "") endif() @@ -645,32 +744,67 @@ ELSE (_boost_IN_CACHE) "_boost_MULTITHREADED = ${_boost_MULTITHREADED}") endif() - SET( _boost_STATIC_TAG "") - set( _boost_ABI_TAG "") - IF (WIN32) - IF(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" + #====================== + # Systematically build up the Boost ABI tag + # http://boost.org/doc/libs/1_41_0/more/getting_started/windows.html#library-naming + set( _boost_RELEASE_ABI_TAG "-") + set( _boost_DEBUG_ABI_TAG "-") + # Key Use this library when: + # s linking statically to the C++ standard library and + # compiler runtime support libraries. + if(Boost_USE_STATIC_RUNTIME) + set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}s") + set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}s") + endif() + # g using debug versions of the standard and runtime + # support libraries + if(WIN32) + if(MSVC OR "${CMAKE_CXX_COMPILER}" MATCHES "icl" OR "${CMAKE_CXX_COMPILER}" MATCHES "icpc") - SET (_boost_ABI_TAG "g") - ENDIF() - IF( Boost_USE_STATIC_LIBS ) - SET( _boost_STATIC_TAG "-s") - ENDIF( Boost_USE_STATIC_LIBS ) - ENDIF(WIN32) - SET (_boost_ABI_TAG "${_boost_ABI_TAG}d") + set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}g") + endif() + endif() + # y using special debug build of python + if(Boost_USE_DEBUG_PYTHON) + set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}y") + endif() + # d using a debug version of your code + set(_boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}d") + # p using the STLport standard library rather than the + # default one supplied with your compiler + if(Boost_USE_STLPORT) + set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}p") + set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}p") + endif() + # n using the STLport deprecated "native iostreams" feature + if(Boost_USE_STLPORT_DEPRECATED_NATIVE_IOSTREAMS) + set( _boost_RELEASE_ABI_TAG "${_boost_RELEASE_ABI_TAG}n") + set( _boost_DEBUG_ABI_TAG "${_boost_DEBUG_ABI_TAG}n") + endif() + if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_STATIC_TAG = ${_boost_STATIC_TAG}") + "_boost_RELEASE_ABI_TAG = ${_boost_RELEASE_ABI_TAG}") message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_ABI_TAG = ${_boost_ABI_TAG}") + "_boost_DEBUG_ABI_TAG = ${_boost_DEBUG_ABI_TAG}") endif() # ------------------------------------------------------------------------ # Begin finding boost libraries # ------------------------------------------------------------------------ - SET(_boost_LIBRARIES_SEARCH_DIRS + if(BOOST_ROOT) + set(_boost_LIBRARY_SEARCH_DIRS_ALWAYS + ${BOOST_ROOT}/lib + ${BOOST_ROOT}/stage/lib) + endif() + set(_boost_LIBRARY_SEARCH_DIRS_ALWAYS + ${_boost_LIBRARY_SEARCH_DIRS_ALWAYS} ${Boost_INCLUDE_DIR}/lib ${Boost_INCLUDE_DIR}/../lib + ${Boost_INCLUDE_DIR}/stage/lib + ) + set(_boost_LIBRARY_SEARCH_DIRS_SYSTEM C:/boost/lib C:/boost "$ENV{ProgramFiles}/boost/boost_${Boost_MAJOR_VERSION}_${Boost_MINOR_VERSION}_${Boost_SUBMINOR_VERSION}/lib" @@ -679,67 +813,146 @@ ELSE (_boost_IN_CACHE) "$ENV{ProgramFiles}/boost" /sw/local/lib ) - IF( BOOST_ROOT ) - SET(_boost_LIBRARIES_SEARCH_DIRS - ${BOOST_ROOT}/lib - ${BOOST_ROOT}/stage/lib - ${_boost_LIBRARIES_SEARCH_DIRS}) - ENDIF( BOOST_ROOT ) + set(_boost_LIBRARY_SEARCH_DIRS ${_boost_LIBRARY_SEARCH_DIRS_ALWAYS}) + if( Boost_NO_SYSTEM_PATHS ) + set(_boost_FIND_OPTIONS NO_CMAKE_SYSTEM_PATH) + else() + list(APPEND _boost_LIBRARY_SEARCH_DIRS ${_boost_LIBRARY_SEARCH_DIRS_SYSTEM}) + endif() - IF( BOOST_LIBRARYDIR ) + # prepend BOOST_LIBRARYDIR to search path if specified + if( BOOST_LIBRARYDIR ) file(TO_CMAKE_PATH ${BOOST_LIBRARYDIR} BOOST_LIBRARYDIR) - SET(_boost_LIBRARIES_SEARCH_DIRS - ${BOOST_LIBRARYDIR} ${_boost_LIBRARIES_SEARCH_DIRS}) - ENDIF( BOOST_LIBRARYDIR ) + set(_boost_LIBRARY_SEARCH_DIRS + ${BOOST_LIBRARYDIR} ${_boost_LIBRARY_SEARCH_DIRS}) + endif() if(Boost_DEBUG) message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " - "_boost_LIBRARIES_SEARCH_DIRS = ${_boost_LIBRARIES_SEARCH_DIRS}") + "_boost_LIBRARY_SEARCH_DIRS = ${_boost_LIBRARY_SEARCH_DIRS}") endif() - FOREACH(COMPONENT ${Boost_FIND_COMPONENTS}) - STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT) - SET( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" ) - SET( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" ) - SET( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND") - - # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES - IF( Boost_USE_STATIC_LIBS ) - SET( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) - IF(WIN32) - SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - ELSE(WIN32) - SET(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - ENDIF(WIN32) - ENDIF( Boost_USE_STATIC_LIBS ) - - FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE - NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT} - HINTS ${_boost_LIBRARIES_SEARCH_DIRS} + # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES + if( Boost_USE_STATIC_LIBS ) + set( _boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a ) + endif() + endif() + + # We want to use the tag inline below without risking double dashes + if(_boost_RELEASE_ABI_TAG) + if(${_boost_RELEASE_ABI_TAG} STREQUAL "-") + set(_boost_RELEASE_ABI_TAG "") + endif() + endif() + if(_boost_DEBUG_ABI_TAG) + if(${_boost_DEBUG_ABI_TAG} STREQUAL "-") + set(_boost_DEBUG_ABI_TAG "") + endif() + endif() + + # The previous behavior of FindBoost when Boost_USE_STATIC_LIBS was enabled + # on WIN32 was to: + # 1. Search for static libs compiled against a SHARED C++ standard runtime library (use if found) + # 2. Search for static libs compiled against a STATIC C++ standard runtime library (use if found) + # We maintain this behavior since changing it could break people's builds. + # To disable the ambiguous behavior, the user need only + # set Boost_USE_STATIC_RUNTIME either ON or OFF. + set(_boost_STATIC_RUNTIME_WORKAROUND false) + if(WIN32 AND Boost_USE_STATIC_LIBS) + if(NOT DEFINED Boost_USE_STATIC_RUNTIME) + set(_boost_STATIC_RUNTIME_WORKAROUND true) + endif() + endif() + + + foreach(COMPONENT ${Boost_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} UPPERCOMPONENT) + set( Boost_${UPPERCOMPONENT}_LIBRARY "Boost_${UPPERCOMPONENT}_LIBRARY-NOTFOUND" ) + set( Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE-NOTFOUND" ) + set( Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG-NOTFOUND") + + set( _boost_docstring_release "Boost ${COMPONENT} library (release)") + set( _boost_docstring_debug "Boost ${COMPONENT} library (debug)") + + # + # Find RELEASE libraries + # + set(_boost_RELEASE_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT} ) + if(_boost_STATIC_RUNTIME_WORKAROUND) + set(_boost_RELEASE_STATIC_ABI_TAG "-s${_boost_RELEASE_ABI_TAG}") + list(APPEND _boost_RELEASE_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_RELEASE_STATIC_ABI_TAG} ) + endif() + if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread") + _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_RELEASE_NAMES ${_boost_RELEASE_NAMES}) + endif() + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Searching for ${UPPERCOMPONENT}_LIBRARY_RELEASE: ${_boost_RELEASE_NAMES}") + endif() + find_library(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE + NAMES ${_boost_RELEASE_NAMES} + HINTS ${_boost_LIBRARY_SEARCH_DIRS} + ${_boost_FIND_OPTIONS} + DOC "${_boost_docstring_release}" ) - FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG - NAMES ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG}-${Boost_LIB_VERSION} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${_boost_ABI_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_STATIC_TAG}${_boost_ABI_TAG} - ${Boost_LIB_PREFIX}boost_${COMPONENT}-${_boost_ABI_TAG} - HINTS ${_boost_LIBRARIES_SEARCH_DIRS} + # + # Find DEBUG libraries + # + set(_boost_DEBUG_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED} + ${Boost_LIB_PREFIX}boost_${COMPONENT} ) + if(_boost_STATIC_RUNTIME_WORKAROUND) + set(_boost_DEBUG_STATIC_ABI_TAG "-s${_boost_DEBUG_ABI_TAG}") + list(APPEND _boost_DEBUG_NAMES + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG}-${Boost_LIB_VERSION} + ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}${_boost_DEBUG_STATIC_ABI_TAG} ) + endif() + if(Boost_THREADAPI AND ${COMPONENT} STREQUAL "thread") + _Boost_PREPEND_LIST_WITH_THREADAPI(_boost_DEBUG_NAMES ${_boost_DEBUG_NAMES}) + endif() + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Searching for ${UPPERCOMPONENT}_LIBRARY_DEBUG: ${_boost_DEBUG_NAMES}") + endif() + find_library(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG + NAMES ${_boost_DEBUG_NAMES} + HINTS ${_boost_LIBRARY_SEARCH_DIRS} + ${_boost_FIND_OPTIONS} + DOC "${_boost_docstring_debug}" ) + if(Boost_REALPATH) + _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE "${_boost_docstring_release}") + _Boost_SWAP_WITH_REALPATH(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG "${_boost_docstring_debug}" ) + endif() + _Boost_ADJUST_LIB_VARS(${UPPERCOMPONENT}) - IF( Boost_USE_STATIC_LIBS ) - SET(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) - ENDIF( Boost_USE_STATIC_LIBS ) - ENDFOREACH(COMPONENT) + + endforeach(COMPONENT) + + # Restore the original find library ordering + if( Boost_USE_STATIC_LIBS ) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_boost_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + endif() # ------------------------------------------------------------------------ # End finding boost libraries # ------------------------------------------------------------------------ diff --git a/Modules/FindBullet.cmake b/Modules/FindBullet.cmake index fe58f6045..50c852749 100644 --- a/Modules/FindBullet.cmake +++ b/Modules/FindBullet.cmake @@ -24,7 +24,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) macro(_FIND_BULLET_LIBRARY _var) @@ -69,7 +69,7 @@ _FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG BulletSoftBody_d) # handle the QUIETLY and REQUIRED arguments and set BULLET_FOUND to TRUE if # all listed variables are TRUE -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Bullet DEFAULT_MSG BULLET_DYNAMICS_LIBRARY BULLET_COLLISION_LIBRARY BULLET_MATH_LIBRARY BULLET_SOFTBODY_LIBRARY BULLET_INCLUDE_DIR) diff --git a/Modules/FindCABLE.cmake b/Modules/FindCABLE.cmake index 938c80590..678fb07ca 100644 --- a/Modules/FindCABLE.cmake +++ b/Modules/FindCABLE.cmake @@ -20,7 +20,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF(NOT CABLE) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 7099609f8..91215d572 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -165,7 +165,7 @@ # and will link in the resulting object file automatically. # # This script will also generate a separate cmake script that is used at -# build time to invoke nvcc. This is for serveral reasons. +# build time to invoke nvcc. This is for several reasons. # # 1. nvcc can return negative numbers as return values which confuses # Visual Studio into thinking that the command succeeded. The script now @@ -497,29 +497,6 @@ endif() # Always set this convenience variable set(CUDA_VERSION_STRING "${CUDA_VERSION}") -# Here we need to determine if the version we found is acceptable. We will -# assume that is unless CUDA_FIND_VERSION_EXACT or CUDA_FIND_VERSION is -# specified. The presence of either of these options checks the version -# string and signals if the version is acceptable or not. -set(_cuda_version_acceptable TRUE) -# -if(CUDA_FIND_VERSION_EXACT AND NOT CUDA_VERSION VERSION_EQUAL CUDA_FIND_VERSION) - set(_cuda_version_acceptable FALSE) -endif() -# -if(CUDA_FIND_VERSION AND CUDA_VERSION VERSION_LESS CUDA_FIND_VERSION) - set(_cuda_version_acceptable FALSE) -endif() -# -if(NOT _cuda_version_acceptable) - set(_cuda_error_message "Requested CUDA version ${CUDA_FIND_VERSION}, but found unacceptable version ${CUDA_VERSION}") - if(CUDA_FIND_REQUIRED) - message("${_cuda_error_message}") - elseif(NOT CUDA_FIND_QUIETLY) - message("${_cuda_error_message}") - endif() -endif() - # CUDA_TOOLKIT_INCLUDE find_path(CUDA_TOOLKIT_INCLUDE device_functions.h # Header included in toolkit @@ -537,11 +514,19 @@ set (CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE}) macro(FIND_LIBRARY_LOCAL_FIRST _var _names _doc) if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(_cuda_64bit_lib_dir "${CUDA_TOOLKIT_ROOT_DIR}/lib64") + # 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" + ) 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" ENV CUDA_LIB_PATH DOC ${_doc} @@ -601,9 +586,20 @@ macro(FIND_CUDA_HELPER_LIBS _name) mark_as_advanced(CUDA_${_name}_LIBRARY) endmacro(FIND_CUDA_HELPER_LIBS) +####################### +# Disable emulation for v3.1 onward +if(CUDA_VERSION VERSION_GREATER "3.0") + if(CUDA_BUILD_EMULATION) + message(FATAL_ERROR "CUDA_BUILD_EMULATION is not supported in version 3.1 and onwards. You must disable it to proceed. You have version ${CUDA_VERSION}.") + endif() +endif() + # Search for cufft and cublas libraries. -find_cuda_helper_libs(cufftemu) -find_cuda_helper_libs(cublasemu) +if(CUDA_VERSION VERSION_LESS "3.1") + # Emulation libraries aren't available in version 3.1 onward. + find_cuda_helper_libs(cufftemu) + find_cuda_helper_libs(cublasemu) +endif() find_cuda_helper_libs(cufft) find_cuda_helper_libs(cublas) @@ -616,8 +612,10 @@ else() endif() ######################## -# Look for the SDK stuff +# Look for the SDK stuff. As of CUDA 3.0 NVSDKCUDA_ROOT has been replaced with +# NVSDKCOMPUTE_ROOT with the old CUDA C contents moved into the C subdirectory find_path(CUDA_SDK_ROOT_DIR common/inc/cutil.h + "$ENV{NVSDKCOMPUTE_ROOT}/C" "$ENV{NVSDKCUDA_ROOT}" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Installed Products\\NVIDIA SDK 10\\Compute;InstallDir]" "/Developer/GPU\ Computing/C" @@ -686,13 +684,15 @@ set(CUDA_TOOLKIT_ROOT_DIR_INTERNAL "${CUDA_TOOLKIT_ROOT_DIR}" CACHE INTERNAL set(CUDA_SDK_ROOT_DIR_INTERNAL "${CUDA_SDK_ROOT_DIR}" CACHE INTERNAL "This is the value of the last time CUDA_SDK_ROOT_DIR was set successfully." FORCE) -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(CUDA DEFAULT_MSG - CUDA_TOOLKIT_ROOT_DIR - CUDA_NVCC_EXECUTABLE - CUDA_INCLUDE_DIRS - CUDA_CUDART_LIBRARY - _cuda_version_acceptable +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") +find_package_handle_standard_args(CUDA + REQUIRED_VARS + CUDA_TOOLKIT_ROOT_DIR + CUDA_NVCC_EXECUTABLE + CUDA_INCLUDE_DIRS + CUDA_CUDART_LIBRARY + VERSION_VAR + CUDA_VERSION ) @@ -811,7 +811,7 @@ 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 -# dependant upon the format parameter. The compiler is invoked once with -M +# dependent upon the format parameter. The compiler is invoked once with -M # to generate a dependency file and a second time with -cuda or -ptx to generate # a .cpp or .ptx file. # INPUT: @@ -943,8 +943,8 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files) # we convert the strings to lists (like we want). if(CUDA_PROPAGATE_HOST_FLAGS) - # nvcc chokes on -g3, so replace it with -g - if(CMAKE_COMPILER_IS_GNUCC) + # nvcc chokes on -g3 in versions previous to 3.0, so replace it with -g + if(CMAKE_COMPILER_IS_GNUCC AND CUDA_VERSION VERSION_LESS "3.0") string(REPLACE "-g3" "-g" _cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") else() set(_cuda_C_FLAGS "${CMAKE_${CUDA_C_OR_CXX}_FLAGS_${config_upper}}") diff --git a/Modules/FindCURL.cmake b/Modules/FindCURL.cmake index f301b2409..68aca2d8b 100644 --- a/Modules/FindCURL.cmake +++ b/Modules/FindCURL.cmake @@ -15,7 +15,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Look for the header file. @@ -34,7 +34,7 @@ MARK_AS_ADVANCED(CURL_LIBRARY) # handle the QUIETLY and REQUIRED arguments and set CURL_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(CURL DEFAULT_MSG CURL_LIBRARY CURL_INCLUDE_DIR) IF(CURL_FOUND) diff --git a/Modules/FindCVS.cmake b/Modules/FindCVS.cmake index ff9776207..844a4854a 100644 --- a/Modules/FindCVS.cmake +++ b/Modules/FindCVS.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # CVSNT @@ -65,5 +65,5 @@ mark_as_advanced(CVS_EXECUTABLE) # Handle the QUIETLY and REQUIRED arguments and set CVS_FOUND to TRUE if # all listed variables are TRUE -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") find_package_handle_standard_args(CVS DEFAULT_MSG CVS_EXECUTABLE) diff --git a/Modules/FindCoin3D.cmake b/Modules/FindCoin3D.cmake index 82d216a0c..d8b103a20 100644 --- a/Modules/FindCoin3D.cmake +++ b/Modules/FindCoin3D.cmake @@ -19,7 +19,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF (WIN32) @@ -76,7 +76,7 @@ ENDIF (WIN32) # handle the QUIETLY and REQUIRED arguments and set COIN3D_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Coin3D DEFAULT_MSG COIN3D_LIBRARIES COIN3D_INCLUDE_DIRS) MARK_AS_ADVANCED(COIN3D_INCLUDE_DIRS COIN3D_LIBRARIES ) diff --git a/Modules/FindCups.cmake b/Modules/FindCups.cmake index 5efc45b6e..7e3e10ab1 100644 --- a/Modules/FindCups.cmake +++ b/Modules/FindCups.cmake @@ -18,7 +18,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(CheckLibraryExists) diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake index 791e6a918..4fb6c3607 100644 --- a/Modules/FindCurses.cmake +++ b/Modules/FindCurses.cmake @@ -22,7 +22,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_LIBRARY(CURSES_CURSES_LIBRARY NAMES curses ) @@ -155,7 +155,7 @@ SET(CURSES_INCLUDE_DIR ${CURSES_INCLUDE_PATH}) # handle the QUIETLY and REQUIRED arguments and set CURSES_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Curses DEFAULT_MSG CURSES_LIBRARY CURSES_INCLUDE_PATH) diff --git a/Modules/FindCxxTest.cmake b/Modules/FindCxxTest.cmake index 5abf992ed..4ff6eba19 100644 --- a/Modules/FindCxxTest.cmake +++ b/Modules/FindCxxTest.cmake @@ -5,20 +5,37 @@ # # INPUT Variables # -# CXXTEST_USE_PYTHON -# If true, the CXXTEST_ADD_TEST macro will use -# the Python test generator instead of Perl. +# CXXTEST_USE_PYTHON [deprecated since 1.3] +# Only used in the case both Python & Perl +# are detected on the system to control +# which CxxTest code generator is used. +# +# NOTE: In older versions of this Find Module, +# this variable controlled if the Python test +# generator was used instead of the Perl one, +# regardless of which scripting language the +# user had installed. +# +# CXXTEST_TESTGEN_ARGS (since CMake 2.8.3) +# Specify a list of options to pass to the CxxTest code +# generator. If not defined, --error-printer is +# passed. # # OUTPUT Variables # # CXXTEST_FOUND # True if the CxxTest framework was found -# CXXTEST_INCLUDE_DIR +# CXXTEST_INCLUDE_DIRS # Where to find the CxxTest include directory # CXXTEST_PERL_TESTGEN_EXECUTABLE -# The perl-based test generator. +# The perl-based test generator # CXXTEST_PYTHON_TESTGEN_EXECUTABLE -# The python-based test generator. +# The python-based test generator +# CXXTEST_TESTGEN_EXECUTABLE (since CMake 2.8.3) +# The test generator that is actually used (chosen using user preferences +# and interpreters found in the system) +# CXXTEST_TESTGEN_INTERPRETER (since CMake 2.8.3) +# The full path to the Perl or Python executable on the system # # MACROS for optional use by CMake users: # @@ -26,9 +43,11 @@ # Creates a CxxTest runner and adds it to the CTest testing suite # Parameters: # test_name The name of the test -# gen_source_file The generated source filename to be generated by CxxTest +# gen_source_file The generated source filename to be +# generated by CxxTest # input_files_to_testgen The list of header files containing the -# CxxTest::TestSuite's to be included in this runner +# CxxTest::TestSuite's to be included in +# this runner # # #============== # Example Usage: @@ -65,8 +84,8 @@ # #============================================================================= -# Copyright 2008-2009 Kitware, Inc. -# Copyright 2008-2009 Philip Lowman +# Copyright 2008-2010 Kitware, Inc. +# Copyright 2008-2010 Philip Lowman # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -75,9 +94,17 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +# Version 1.3 (8/19/10) (CMake 2.8.3) +# Included patch by Simone Rossetto to check if either Python or Perl +# are present in the system. Whichever intepreter that is detected +# is now used to run the test generator program. If both interpreters +# are detected, the CXXTEST_USE_PYTHON variable is obeyed. +# +# Also added support for CXXTEST_TESTGEN_ARGS, for manually specifying +# options to the CxxTest code generator. # Version 1.2 (3/2/08) # Included patch from Tyler Roscoe to have the perl & python binaries # detected based on CXXTEST_INCLUDE_DIR @@ -95,17 +122,12 @@ #============================================================= macro(CXXTEST_ADD_TEST _cxxtest_testname _cxxtest_outfname) set(_cxxtest_real_outfname ${CMAKE_CURRENT_BINARY_DIR}/${_cxxtest_outfname}) - if(CXXTEST_USE_PYTHON) - set(_cxxtest_executable ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE}) - else() - set(_cxxtest_executable ${CXXTEST_PERL_TESTGEN_EXECUTABLE}) - endif() add_custom_command( OUTPUT ${_cxxtest_real_outfname} DEPENDS ${ARGN} - COMMAND ${_cxxtest_executable} - --error-printer -o ${_cxxtest_real_outfname} ${ARGN} + COMMAND ${CXXTEST_TESTGEN_INTERPRETER} + ${CXXTEST_TESTGEN_EXECUTABLE} ${CXXTEST_TESTGEN_ARGS} -o ${_cxxtest_real_outfname} ${ARGN} ) set_source_files_properties(${_cxxtest_real_outfname} PROPERTIES GENERATED true) @@ -124,14 +146,48 @@ endmacro(CXXTEST_ADD_TEST) #============================================================= # main() #============================================================= +if(NOT DEFINED CXXTEST_TESTGEN_ARGS) + set(CXXTEST_TESTGEN_ARGS --error-printer) +endif() + +find_package(PythonInterp QUIET) +find_package(Perl QUIET) find_path(CXXTEST_INCLUDE_DIR cxxtest/TestSuite.h) -find_program(CXXTEST_PERL_TESTGEN_EXECUTABLE cxxtestgen.pl - PATHS ${CXXTEST_INCLUDE_DIR}) find_program(CXXTEST_PYTHON_TESTGEN_EXECUTABLE cxxtestgen.py - PATHS ${CXXTEST_INCLUDE_DIR}) + PATHS ${CXXTEST_INCLUDE_DIR}) +find_program(CXXTEST_PERL_TESTGEN_EXECUTABLE cxxtestgen.pl + PATHS ${CXXTEST_INCLUDE_DIR}) + +if(PYTHONINTERP_FOUND OR PERL_FOUND) + include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") + + if(PYTHONINTERP_FOUND AND (CXXTEST_USE_PYTHON OR NOT PERL_FOUND)) + set(CXXTEST_TESTGEN_EXECUTABLE ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE}) + set(CXXTEST_TESTGEN_INTERPRETER ${PYTHON_EXECUTABLE}) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(CxxTest DEFAULT_MSG + CXXTEST_INCLUDE_DIR CXXTEST_PYTHON_TESTGEN_EXECUTABLE) + + elseif(PERL_FOUND) + set(CXXTEST_TESTGEN_EXECUTABLE ${CXXTEST_PERL_TESTGEN_EXECUTABLE}) + set(CXXTEST_TESTGEN_INTERPRETER ${PERL_EXECUTABLE}) + FIND_PACKAGE_HANDLE_STANDARD_ARGS(CxxTest DEFAULT_MSG + CXXTEST_INCLUDE_DIR CXXTEST_PERL_TESTGEN_EXECUTABLE) + endif() + + if(CXXTEST_FOUND) + set(CXXTEST_INCLUDE_DIRS ${CXXTEST_INCLUDE_DIR}) + endif() + +else() -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(CxxTest DEFAULT_MSG CXXTEST_INCLUDE_DIR) + set(CXXTEST_FOUND false) + if(NOT CxxTest_FIND_QUIETLY) + if(CxxTest_FIND_REQUIRED) + message(FATAL_ERROR "Neither Python nor Perl found, cannot use CxxTest, aborting!") + else() + message(STATUS "Neither Python nor Perl found, CxxTest will not be used.") + endif() + endif() -set(CXXTEST_INCLUDE_DIRS ${CXXTEST_INCLUDE_DIR}) +endif() diff --git a/Modules/FindCygwin.cmake b/Modules/FindCygwin.cmake index 5b2bc5939..28f55ba0c 100644 --- a/Modules/FindCygwin.cmake +++ b/Modules/FindCygwin.cmake @@ -11,13 +11,14 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF (WIN32) FIND_PATH(CYGWIN_INSTALL_PATH cygwin.bat - "C:/Cygwin" + "C:/Cygwin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Cygwin\\setup;rootdir]" "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts v2\\/;native]" ) diff --git a/Modules/FindDCMTK.cmake b/Modules/FindDCMTK.cmake index d35433a27..0bd84811b 100644 --- a/Modules/FindDCMTK.cmake +++ b/Modules/FindDCMTK.cmake @@ -23,7 +23,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # @@ -132,7 +132,7 @@ if(DCMTK_ofstd_INCLUDE_DIR) mark_as_advanced(DCMTK_dcmtk_INCLUDE_DIR) endif() -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") find_package_handle_standard_args(DCMTK DEFAULT_MSG DCMTK_config_INCLUDE_DIR DCMTK_ofstd_INCLUDE_DIR diff --git a/Modules/FindDart.cmake b/Modules/FindDart.cmake index 65da21a2b..afe5cf16c 100644 --- a/Modules/FindDart.cmake +++ b/Modules/FindDart.cmake @@ -13,7 +13,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(DART_ROOT README.INSTALL @@ -30,7 +30,7 @@ FIND_PATH(DART_ROOT README.INSTALL # handle the QUIETLY and REQUIRED arguments and set DART_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Dart DEFAULT_MSG DART_ROOT) MARK_AS_ADVANCED(DART_ROOT) diff --git a/Modules/FindDevIL.cmake b/Modules/FindDevIL.cmake index ae0f97d73..72d70d51b 100644 --- a/Modules/FindDevIL.cmake +++ b/Modules/FindDevIL.cmake @@ -19,13 +19,13 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # TODO: Add version support. # Tested under Linux and Windows (MSVC) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PATH(IL_INCLUDE_DIR il.h PATH_SUFFIXES include IL diff --git a/Modules/FindDoxygen.cmake b/Modules/FindDoxygen.cmake index 5e5ed1323..cc69d60d8 100644 --- a/Modules/FindDoxygen.cmake +++ b/Modules/FindDoxygen.cmake @@ -28,7 +28,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # For backwards compatibility support @@ -76,7 +76,7 @@ FIND_PROGRAM(DOXYGEN_EXECUTABLE DOC "Doxygen documentation generation tool (http://www.doxygen.org)" ) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Doxygen DEFAULT_MSG DOXYGEN_EXECUTABLE) # diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake index 22743b113..e97c31ecf 100644 --- a/Modules/FindEXPAT.cmake +++ b/Modules/FindEXPAT.cmake @@ -15,7 +15,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Look for the header file. @@ -26,7 +26,7 @@ FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat) # handle the QUIETLY and REQUIRED arguments and set EXPAT_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(EXPAT DEFAULT_MSG EXPAT_LIBRARY EXPAT_INCLUDE_DIR) # Copy the results to the output variables. diff --git a/Modules/FindFLEX.cmake b/Modules/FindFLEX.cmake index 068ee75d8..272cdc7ab 100644 --- a/Modules/FindFLEX.cmake +++ b/Modules/FindFLEX.cmake @@ -6,6 +6,10 @@ # FLEX_VERSION - the version of flex # FLEX_LIBRARIES - The flex libraries # +# The minimum required version of flex can be specified using the +# standard syntax, e.g. FIND_PACKAGE(FLEX 2.5.13) +# +# # If flex is found on the system, the module provides the macro: # FLEX_TARGET(Name FlexInput FlexOutput [COMPILE_FLAGS ]) # which creates a custom command to generate the file from @@ -55,7 +59,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PROGRAM(FLEX_EXECUTABLE flex DOC "path to the flex executable") @@ -74,7 +78,11 @@ IF(FLEX_EXECUTABLE) RESULT_VARIABLE FLEX_version_result OUTPUT_STRIP_TRAILING_WHITESPACE) IF(NOT ${FLEX_version_result} EQUAL 0) - MESSAGE(SEND_ERROR "Command \"${FLEX_EXECUTABLE} --version\" failed with output:\n${FLEX_version_error}") + IF(FLEX_FIND_REQUIRED) + MESSAGE(SEND_ERROR "Command \"${FLEX_EXECUTABLE} --version\" failed with output:\n${FLEX_version_output}\n${FLEX_version_error}") + ELSE() + MESSAGE("Command \"${FLEX_EXECUTABLE} --version\" failed with output:\n${FLEX_version_output}\n${FLEX_version_error}\nFLEX_VERSION will not be available") + ENDIF() ELSE() STRING(REGEX REPLACE "^flex (.*)$" "\\1" FLEX_VERSION "${FLEX_version_output}") @@ -135,7 +143,8 @@ IF(FLEX_EXECUTABLE) ENDIF(FLEX_EXECUTABLE) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(FLEX DEFAULT_MSG FLEX_EXECUTABLE) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") +FIND_PACKAGE_HANDLE_STANDARD_ARGS(FLEX REQUIRED_VARS FLEX_EXECUTABLE + VERSION_VAR FLEX_VERSION) # FindFLEX.cmake ends here diff --git a/Modules/FindFLTK.cmake b/Modules/FindFLTK.cmake index 02b201547..eb5db81cf 100644 --- a/Modules/FindFLTK.cmake +++ b/Modules/FindFLTK.cmake @@ -39,7 +39,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF(NOT FLTK_SKIP_OPENGL) @@ -67,11 +67,6 @@ IF(APPLE) SET( FLTK_PLATFORM_DEPENDENT_LIBS "-framework Carbon -framework Cocoa -framework ApplicationServices -lz") ENDIF(APPLE) -IF(CYGWIN) - FIND_LIBRARY(FLTK_MATH_LIBRARY m) - SET( FLTK_PLATFORM_DEPENDENT_LIBS ole32 uuid comctl32 wsock32 supc++ ${FLTK_MATH_LIBRARY} -lgdi32) -ENDIF(CYGWIN) - # If FLTK_INCLUDE_DIR is already defined we assigne its value to FLTK_DIR IF(FLTK_INCLUDE_DIR) SET(FLTK_DIR ${FLTK_INCLUDE_DIR}) @@ -297,7 +292,7 @@ ENDIF(NOT FLTK_DIR) ENDIF() LIST(APPEND FLTK_LIBRARIES ${FLTK_BASE_LIBRARY}) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") IF(FLTK_SKIP_FLUID) FIND_PACKAGE_HANDLE_STANDARD_ARGS(FLTK DEFAULT_MSG FLTK_LIBRARIES FLTK_INCLUDE_DIR) ELSE() diff --git a/Modules/FindFLTK2.cmake b/Modules/FindFLTK2.cmake index 6411ccbeb..436e280bc 100644 --- a/Modules/FindFLTK2.cmake +++ b/Modules/FindFLTK2.cmake @@ -20,7 +20,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) SET (FLTK2_DIR $ENV{FLTK2_DIR} ) @@ -45,10 +45,6 @@ IF(APPLE) SET( FLTK2_PLATFORM_DEPENDENT_LIBS "-framework Carbon -framework Cocoa -framework ApplicationServices -lz") ENDIF(APPLE) -IF(CYGWIN) - SET( FLTK2_PLATFORM_DEPENDENT_LIBS ole32 uuid comctl32 wsock32 supc++ -lm -lgdi32) -ENDIF(CYGWIN) - # If FLTK2_INCLUDE_DIR is already defined we assigne its value to FLTK2_DIR IF(FLTK2_INCLUDE_DIR) SET(FLTK2_DIR ${FLTK2_INCLUDE_DIR}) diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake index 0a6f93e6e..0adfdc270 100644 --- a/Modules/FindFreetype.cmake +++ b/Modules/FindFreetype.cmake @@ -21,7 +21,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Created by Eric Wing. @@ -88,7 +88,7 @@ SET(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}") # handle the QUIETLY and REQUIRED arguments and set FREETYPE_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Freetype DEFAULT_MSG FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS) diff --git a/Modules/FindGCCXML.cmake b/Modules/FindGCCXML.cmake index 52390c30a..261a5d180 100644 --- a/Modules/FindGCCXML.cmake +++ b/Modules/FindGCCXML.cmake @@ -13,7 +13,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PROGRAM(GCCXML diff --git a/Modules/FindGDAL.cmake b/Modules/FindGDAL.cmake index d3b198a63..4bc158016 100644 --- a/Modules/FindGDAL.cmake +++ b/Modules/FindGDAL.cmake @@ -20,7 +20,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # @@ -100,7 +100,7 @@ FIND_LIBRARY(GDAL_LIBRARY /usr/freeware ) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(GDAL DEFAULT_MSG GDAL_LIBRARY GDAL_INCLUDE_DIR) set(GDAL_LIBRARIES ${GDAL_LIBRARY}) diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake index 36bf1dcef..784b4ec32 100644 --- a/Modules/FindGIF.cmake +++ b/Modules/FindGIF.cmake @@ -16,7 +16,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Created by Eric Wing. @@ -60,7 +60,7 @@ SET(GIF_LIBRARIES ${GIF_LIBRARY}) # handle the QUIETLY and REQUIRED arguments and set GIF_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(GIF DEFAULT_MSG GIF_LIBRARY GIF_INCLUDE_DIR) MARK_AS_ADVANCED(GIF_INCLUDE_DIR GIF_LIBRARY) diff --git a/Modules/FindGLU.cmake b/Modules/FindGLU.cmake index 81b3364c1..5198f11e1 100644 --- a/Modules/FindGLU.cmake +++ b/Modules/FindGLU.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Use of this file is deprecated, and is here for backwards compatibility with CMake 1.4 diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index baf539af4..45df79e70 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF (WIN32) diff --git a/Modules/FindGTK.cmake b/Modules/FindGTK.cmake index 75890df31..e9cc62f20 100644 --- a/Modules/FindGTK.cmake +++ b/Modules/FindGTK.cmake @@ -14,7 +14,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # don't even bother under WIN32 diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake index c8714178d..d8b4f6313 100644 --- a/Modules/FindGTK2.cmake +++ b/Modules/FindGTK2.cmake @@ -28,6 +28,8 @@ # # GTK2_DEBUG - Enables verbose debugging of the module # GTK2_SKIP_MARK_AS_ADVANCED - Disable marking cache variables as advanced +# GTK2_ADDITIONAL_SUFFIXES - Allows defining additional directories to +# search for include files # #================= # Example Usage: @@ -61,9 +63,24 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +# Version 1.2 (8/30/2010) (CMake 2.8.3) +# * Merge patch for detecting gdk-pixbuf library (split off +# from core GTK in 2.21). Thanks to Vincent Untz for the patch +# and Ricardo Cruz for the heads up. +# Version 1.1 (8/19/2010) (CMake 2.8.3) +# * Add support for detecting GTK2 under macports (thanks to Gary Kramlich) +# Version 1.0 (8/12/2010) (CMake 2.8.3) +# * Add support for detecting new pangommconfig.h header file +# (Thanks to Sune Vuorela & the Debian Project for the patch) +# * Add support for detecting fontconfig.h header +# * Call find_package(Freetype) since it's required +# * Add support for allowing users to add additional library directories +# via the GTK2_ADDITIONAL_SUFFIXES variable (kind of a future-kludge in +# case the GTK developers change versions on any of the directories in the +# future). # Version 0.8 (1/4/2010) # * Get module working under MacOSX fink by adding /sw/include, /sw/lib # to PATHS and the gobject library @@ -131,13 +148,15 @@ function(_GTK2_FIND_INCLUDE_DIR _var _hdr) endif() set(_relatives - # FIXME + # If these ever change, things will break. + ${GTK2_ADDITIONAL_SUFFIXES} glibmm-2.4 glib-2.0 atk-1.0 atkmm-1.6 cairo cairomm-1.0 + gdk-pixbuf-2.0 gdkmm-2.4 giomm-2.4 gtk-2.0 @@ -172,6 +191,8 @@ function(_GTK2_FIND_INCLUDE_DIR _var _hdr) /usr/openwin/lib /sw/include /sw/lib + /opt/local/include + /opt/local/lib $ENV{GTKMM_BASEPATH}/include $ENV{GTKMM_BASEPATH}/lib [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/include @@ -390,6 +411,10 @@ endif() # Find all components # +find_package(Freetype) +list(APPEND GTK2_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS}) +list(APPEND GTK2_LIBRARIES ${FREETYPE_LIBRARIES}) + foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) if(_GTK2_component STREQUAL "gtk") _GTK2_FIND_INCLUDE_DIR(GTK2_GLIB_INCLUDE_DIR glib.h) @@ -399,27 +424,32 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_INCLUDE_DIR(GTK2_GOBJECT_INCLUDE_DIR gobject/gobject.h) _GTK2_FIND_LIBRARY (GTK2_GOBJECT_LIBRARY gobject false true) + _GTK2_FIND_INCLUDE_DIR(GTK2_GDK_PIXBUF_INCLUDE_DIR gdk-pixbuf/gdk-pixbuf.h) + _GTK2_FIND_LIBRARY (GTK2_GDK_PIXBUF_LIBRARY gdk_pixbuf false true) + _GTK2_FIND_INCLUDE_DIR(GTK2_GDK_INCLUDE_DIR gdk/gdk.h) _GTK2_FIND_INCLUDE_DIR(GTK2_GDKCONFIG_INCLUDE_DIR gdkconfig.h) - _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-x11 false true) - _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-win32 false true) - _GTK2_FIND_INCLUDE_DIR(GTK2_GTK_INCLUDE_DIR gtk/gtk.h) - _GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-x11 false true) - _GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-win32 false true) + + if(UNIX) + _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-x11 false true) + _GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-x11 false true) + else() + _GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-win32 false true) + _GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-win32 false true) + endif() _GTK2_FIND_INCLUDE_DIR(GTK2_CAIRO_INCLUDE_DIR cairo.h) _GTK2_FIND_LIBRARY (GTK2_CAIRO_LIBRARY cairo false false) + _GTK2_FIND_INCLUDE_DIR(GTK2_FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_PANGO_INCLUDE_DIR pango/pango.h) _GTK2_FIND_LIBRARY (GTK2_PANGO_LIBRARY pango false true) _GTK2_FIND_INCLUDE_DIR(GTK2_ATK_INCLUDE_DIR atk/atk.h) _GTK2_FIND_LIBRARY (GTK2_ATK_LIBRARY atk false true) - #elseif(_GTK2_component STREQUAL "gdk_pixbuf") - #_GTK2_FIND_INCLUDE_DIR(GTK2_GDKPIXBUF_INCLUDE_DIR gdk-pixbuf/gdk-pixbuf.h) - #_GTK2_FIND_LIBRARY (GTK2_GDKPIXBUF_LIBRARY gdk_pixbuf false true) elseif(_GTK2_component STREQUAL "gtkmm") @@ -439,6 +469,7 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) _GTK2_FIND_LIBRARY (GTK2_CAIROMM_LIBRARY cairomm true true) _GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMM_INCLUDE_DIR pangomm.h) + _GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMMCONFIG_INCLUDE_DIR pangommconfig.h) _GTK2_FIND_LIBRARY (GTK2_PANGOMM_LIBRARY pangomm true true) _GTK2_FIND_INCLUDE_DIR(GTK2_SIGC++_INCLUDE_DIR sigc++/sigc++.h) @@ -485,7 +516,7 @@ endif() set(_GTK2_did_we_find_everything true) # This gets set to GTK2_FOUND -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") foreach(_GTK2_component ${GTK2_FIND_COMPONENTS}) string(TOUPPER ${_GTK2_component} _COMPONENT_UPPER) diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake index 1bcd46956..720591a75 100644 --- a/Modules/FindGTest.cmake +++ b/Modules/FindGTest.cmake @@ -66,7 +66,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # # Thanks to Daniel Blezek for the GTEST_ADD_TESTS code @@ -146,7 +146,7 @@ else() _gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_maind) endif() -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTest DEFAULT_MSG GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY) if(GTEST_FOUND) diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake index cdef44f60..9398b5473 100644 --- a/Modules/FindGettext.cmake +++ b/Modules/FindGettext.cmake @@ -22,7 +22,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PROGRAM(GETTEXT_MSGMERGE_EXECUTABLE msgmerge) diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake index 2d8214287..818871516 100644 --- a/Modules/FindGit.cmake +++ b/Modules/FindGit.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Look for 'git' or 'eg' (easy git) @@ -42,5 +42,5 @@ mark_as_advanced(GIT_EXECUTABLE) # Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if # all listed variables are TRUE -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") find_package_handle_standard_args(Git DEFAULT_MSG GIT_EXECUTABLE) diff --git a/Modules/FindGnuTLS.cmake b/Modules/FindGnuTLS.cmake index 72ab51162..4363bf7fa 100644 --- a/Modules/FindGnuTLS.cmake +++ b/Modules/FindGnuTLS.cmake @@ -20,7 +20,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Note that this doesn't try to find the gnutls-extra package. @@ -56,7 +56,7 @@ MARK_AS_ADVANCED(GNUTLS_INCLUDE_DIR GNUTLS_LIBRARY) # handle the QUIETLY and REQUIRED arguments and set GNUTLS_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS DEFAULT_MSG GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR) IF(GNUTLS_FOUND) diff --git a/Modules/FindGnuplot.cmake b/Modules/FindGnuplot.cmake index a9b9ee5c9..e7375d463 100644 --- a/Modules/FindGnuplot.cmake +++ b/Modules/FindGnuplot.cmake @@ -15,7 +15,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(FindCygwin) @@ -34,7 +34,7 @@ SET(GNUPLOT ${GNUPLOT_EXECUTABLE}) # handle the QUIETLY and REQUIRED arguments and set GNUPLOT_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Gnuplot DEFAULT_MSG GNUPLOT_EXECUTABLE) MARK_AS_ADVANCED( GNUPLOT_EXECUTABLE ) diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake index a84e6779d..90c9de48e 100644 --- a/Modules/FindHDF5.cmake +++ b/Modules/FindHDF5.cmake @@ -51,13 +51,13 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is maintained by Will Dicharry . include(SelectLibraryConfigurations) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") # List of the valid HDF5 components set( HDF5_VALID_COMPONENTS @@ -293,7 +293,7 @@ else() # If the HDF5 include directory was found, open H5pubconf.h to determine if # HDF5 was compiled with parallel IO support set( HDF5_IS_PARALLEL FALSE ) - foreach( _dir HDF5_INCLUDE_DIRS ) + foreach( _dir IN LISTS HDF5_INCLUDE_DIRS ) if( EXISTS "${_dir}/H5pubconf.h" ) file( STRINGS "${_dir}/H5pubconf.h" HDF5_HAVE_PARALLEL_DEFINE diff --git a/Modules/FindHSPELL.cmake b/Modules/FindHSPELL.cmake index 21bc5fd29..283802726 100644 --- a/Modules/FindHSPELL.cmake +++ b/Modules/FindHSPELL.cmake @@ -21,7 +21,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(HSPELL_INCLUDE_DIR hspell.h) @@ -36,7 +36,7 @@ ENDIF() # handle the QUIETLY and REQUIRED arguments and set HSPELL_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(HSPELL DEFAULT_MSG HSPELL_LIBRARIES HSPELL_INCLUDE_DIR) MARK_AS_ADVANCED(HSPELL_INCLUDE_DIR HSPELL_LIBRARIES) diff --git a/Modules/FindHTMLHelp.cmake b/Modules/FindHTMLHelp.cmake index 2deb297aa..4455b0797 100644 --- a/Modules/FindHTMLHelp.cmake +++ b/Modules/FindHTMLHelp.cmake @@ -15,7 +15,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF(WIN32) diff --git a/Modules/FindITK.cmake b/Modules/FindITK.cmake index 40f03fb6c..244ce5486 100644 --- a/Modules/FindITK.cmake +++ b/Modules/FindITK.cmake @@ -30,7 +30,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) SET(ITK_DIR_STRING "directory containing ITKConfig.cmake. This is either the root of the build tree, or PREFIX/lib/InsightToolkit for an installation.") diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake index 33b8aad60..774b2addb 100644 --- a/Modules/FindImageMagick.cmake +++ b/Modules/FindImageMagick.cmake @@ -61,7 +61,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) #--------------------------------------------------------------------- @@ -171,7 +171,7 @@ SET(ImageMagick_LIBRARIES ${ImageMagick_LIBRARIES}) #--------------------------------------------------------------------- # Standard Package Output #--------------------------------------------------------------------- -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS( ImageMagick DEFAULT_MSG ImageMagick_FOUND ) diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index a61c683b6..d9395b863 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -23,30 +23,55 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Expand {libarch} occurences to java_libarch subdirectory(-ies) and set ${_var} MACRO(java_append_library_directories _var) # Determine java arch-specific library subdir - IF (CMAKE_SYSTEM_NAME MATCHES "Linux") - # Based on openjdk/jdk/make/common/shared/Platform.gmk as of 6b16 - # and kaffe as of 1.1.8 which uses the first part of the - # GNU config.guess platform triplet. - IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^i[3-9]86$") - SET(_java_libarch "i386") - ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") - SET(_java_libarch "amd64" "x86_64") - ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc") - SET(_java_libarch "ppc" "powerpc" "ppc64") - ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc") - SET(_java_libarch "sparc" "sparcv9") - ELSE(CMAKE_SYSTEM_PROCESSOR MATCHES "^i[3-9]86$") - SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}") - ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^i[3-9]86$") - ELSE(CMAKE_SYSTEM_NAME MATCHES "Linux") - SET(_java_libarch "i386" "amd64" "ppc") # previous default - ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux") + # Mostly based on openjdk/jdk/make/common/shared/Platform.gmk as of openjdk + # 1.6.0_18 + icedtea patches. However, it would be much better to base the + # guess on the first part of the GNU config.guess platform triplet. + IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + SET(_java_libarch "amd64") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") + SET(_java_libarch "i386") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha") + SET(_java_libarch "alpha") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") + # Subdir is "arm" for both big-endian (arm) and little-endian (armel). + SET(_java_libarch "arm") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips") + # mips* machines are bi-endian mostly so processor does not tell + # endianess of the underlying system. + SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64") + SET(_java_libarch "ppc64") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)") + SET(_java_libarch "ppc") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc") + # Both flavours can run on the same processor + SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)") + SET(_java_libarch "parisc" "parisc64") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390") + # s390 binaries can run on s390x machines + SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "s390" "s390x") + ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh") + SET(_java_libarch "sh") + ELSE(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + SET(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}") + ENDIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + + # Append default list architectures if CMAKE_SYSTEM_PROCESSOR was empty or + # system is non-Linux (where the code above has not been well tested) + IF(NOT _java_libarch OR NOT (CMAKE_SYSTEM_NAME MATCHES "Linux")) + LIST(APPEND _java_libarch "i386" "amd64" "ppc") + ENDIF(NOT _java_libarch OR NOT (CMAKE_SYSTEM_NAME MATCHES "Linux")) + + # Sometimes ${CMAKE_SYSTEM_PROCESSOR} is added to the list to prefer + # current value to a hardcoded list. Remove possible duplicates. + LIST(REMOVE_DUPLICATES _java_libarch) FOREACH(_path ${ARGN}) IF(_path MATCHES "{libarch}") @@ -207,7 +232,7 @@ FIND_PATH(JAVA_AWT_INCLUDE_PATH jawt.h ${JAVA_INCLUDE_PATH} ) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(JNI DEFAULT_MSG JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH) diff --git a/Modules/FindJPEG.cmake b/Modules/FindJPEG.cmake index 299e4588e..721f40030 100644 --- a/Modules/FindJPEG.cmake +++ b/Modules/FindJPEG.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(JPEG_INCLUDE_DIR jpeglib.h) @@ -27,7 +27,7 @@ FIND_LIBRARY(JPEG_LIBRARY NAMES ${JPEG_NAMES} ) # handle the QUIETLY and REQUIRED arguments and set JPEG_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(JPEG DEFAULT_MSG JPEG_LIBRARY JPEG_INCLUDE_DIR) IF(JPEG_FOUND) diff --git a/Modules/FindJasper.cmake b/Modules/FindJasper.cmake index 4f8ccb705..fde516501 100644 --- a/Modules/FindJasper.cmake +++ b/Modules/FindJasper.cmake @@ -16,7 +16,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PACKAGE(JPEG) @@ -27,7 +27,7 @@ FIND_LIBRARY(JASPER_LIBRARY NAMES jasper libjasper) # handle the QUIETLY and REQUIRED arguments and set JASPER_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Jasper DEFAULT_MSG JASPER_LIBRARY JASPER_INCLUDE_DIR JPEG_LIBRARIES) IF (JASPER_FOUND) diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index 4cd43899a..acdbb7050 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -13,6 +13,9 @@ # Java_VERSION_TWEAK = The tweak version of the package found (after '_') # Java_VERSION = This is set to: $major.$minor.$patch(.$tweak) # +# The minimum required version of Java can be specified using the +# standard CMake syntax, e.g. FIND_PACKAGE(Java 1.5) +# # NOTE: ${Java_VERSION} and ${Java_VERSION_STRING} are not guaranteed to be # identical. For example some java version may return: # Java_VERSION_STRING = 1.5.0_17 @@ -48,7 +51,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # The HINTS option should only be used for values computed from the system. @@ -83,7 +86,6 @@ FIND_PROGRAM(Java_JAVA_EXECUTABLE ) IF(Java_JAVA_EXECUTABLE) - set(_java_version_acceptable TRUE) EXECUTE_PROCESS(COMMAND ${Java_JAVA_EXECUTABLE} -version RESULT_VARIABLE res OUTPUT_VARIABLE var @@ -114,7 +116,6 @@ IF(Java_JAVA_EXECUTABLE) ELSE() IF(NOT Java_FIND_QUIETLY) message(WARNING "regex not supported: ${var}. Please report") - set(_java_version_acceptable FALSE) ENDIF(NOT Java_FIND_QUIETLY) ENDIF() STRING( REGEX REPLACE "([0-9]+).*" "\\1" Java_VERSION_MAJOR "${Java_VERSION_STRING}" ) @@ -134,17 +135,6 @@ IF(Java_JAVA_EXECUTABLE) ENDIF(NOT Java_FIND_QUIETLY) ENDIF() - # check version if requested: - if( Java_FIND_VERSION ) - if("${Java_VERSION}" VERSION_LESS "${Java_FIND_VERSION}") - set(_java_version_acceptable FALSE) - endif("${Java_VERSION}" VERSION_LESS "${Java_FIND_VERSION}") - if( Java_FIND_VERSION_EXACT ) - if("${Java_VERSION}" VERSION_GREATER "${Java_FIND_VERSION}") - set(_java_version_acceptable FALSE) - endif("${Java_VERSION}" VERSION_GREATER "${Java_FIND_VERSION}") - endif( Java_FIND_VERSION_EXACT ) - endif( Java_FIND_VERSION ) ENDIF(Java_JAVA_EXECUTABLE) @@ -160,22 +150,20 @@ FIND_PROGRAM(Java_JAVAC_EXECUTABLE PATHS ${_JAVA_PATHS} ) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") if(Java_FIND_COMPONENTS) foreach(component ${Java_FIND_COMPONENTS}) # User just want to execute some Java byte-compiled if(component STREQUAL "Runtime") - find_package_handle_standard_args(Java DEFAULT_MSG - Java_JAVA_EXECUTABLE - _java_version_acceptable - ) + find_package_handle_standard_args(Java + REQUIRED_VARS Java_JAVA_EXECUTABLE + VERSION_VAR Java_VERSION + ) elseif(component STREQUAL "Development") - find_package_handle_standard_args(Java DEFAULT_MSG - Java_JAVA_EXECUTABLE - Java_JAR_EXECUTABLE - Java_JAVAC_EXECUTABLE - _java_version_acceptable - ) + find_package_handle_standard_args(Java + REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE + VERSION_VAR Java_VERSION + ) else() message(FATAL_ERROR "Comp: ${component} is not handled") endif() @@ -183,12 +171,10 @@ if(Java_FIND_COMPONENTS) endforeach(component) else() # Check for everything - find_package_handle_standard_args(Java DEFAULT_MSG - Java_JAVA_EXECUTABLE - Java_JAR_EXECUTABLE - Java_JAVAC_EXECUTABLE - _java_version_acceptable - ) + find_package_handle_standard_args(Java + REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE + VERSION_VAR Java_VERSION + ) endif() diff --git a/Modules/FindKDE3.cmake b/Modules/FindKDE3.cmake index 5c5c5fed4..9d1081405 100644 --- a/Modules/FindKDE3.cmake +++ b/Modules/FindKDE3.cmake @@ -74,7 +74,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF(NOT UNIX AND KDE3_FIND_REQUIRED) diff --git a/Modules/FindKDE4.cmake b/Modules/FindKDE4.cmake index 42a15304a..ed4f270b0 100644 --- a/Modules/FindKDE4.cmake +++ b/Modules/FindKDE4.cmake @@ -20,7 +20,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # If Qt3 has already been found, fail. diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake index b89a997e1..40effb04d 100644 --- a/Modules/FindLAPACK.cmake +++ b/Modules/FindLAPACK.cmake @@ -33,7 +33,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES) diff --git a/Modules/FindLATEX.cmake b/Modules/FindLATEX.cmake index dbd96a778..950daca5a 100644 --- a/Modules/FindLATEX.cmake +++ b/Modules/FindLATEX.cmake @@ -21,7 +21,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF (WIN32) diff --git a/Modules/FindLibArchive.cmake b/Modules/FindLibArchive.cmake new file mode 100644 index 000000000..2104e700d --- /dev/null +++ b/Modules/FindLibArchive.cmake @@ -0,0 +1,63 @@ +# - Find libarchive library and headers +# The module defines the following variables: +# +# LibArchive_FOUND - true if libarchive was found +# LibArchive_INCLUDE_DIRS - include search path +# LibArchive_LIBRARIES - libraries to link +# LibArchive_VERSION - libarchive 3-component version number + +#============================================================================= +# Copyright 2010 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.) + +find_path(LibArchive_INCLUDE_DIR + NAMES archive.h + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\LibArchive;InstallPath]/include" + ) + +find_library(LibArchive_LIBRARY + NAMES archive libarchive + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\LibArchive;InstallPath]/lib" + ) + +mark_as_advanced(LibArchive_INCLUDE_DIR LibArchive_LIBRARY) + +# Extract the version number from the header. +if(LibArchive_INCLUDE_DIR AND EXISTS "${LibArchive_INCLUDE_DIR}/archive.h") + # The version string appears in one of two known formats in the header: + # #define ARCHIVE_LIBRARY_VERSION "libarchive 2.4.12" + # #define ARCHIVE_VERSION_STRING "libarchive 2.8.4" + # Match either format. + set(_LibArchive_VERSION_REGEX "^#define[ \t]+ARCHIVE[_A-Z]+VERSION[_A-Z]*[ \t]+\"libarchive +([0-9]+)\\.([0-9]+)\\.([0-9]+)[^\"]*\".*$") + file(STRINGS "${LibArchive_INCLUDE_DIR}/archive.h" _LibArchive_VERSION_STRING LIMIT_COUNT 1 REGEX "${_LibArchive_VERSION_REGEX}") + if(_LibArchive_VERSION_STRING) + string(REGEX REPLACE "${_LibArchive_VERSION_REGEX}" "\\1.\\2.\\3" LibArchive_VERSION "${_LibArchive_VERSION_STRING}") + endif() + unset(_LibArchive_VERSION_REGEX) + unset(_LibArchive_VERSION_STRING) +endif() + +# Handle the QUIETLY and REQUIRED arguments and set LIBARCHIVE_FOUND +# to TRUE if all listed variables are TRUE. +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") +find_package_handle_standard_args(LibArchive DEFAULT_MSG + LibArchive_LIBRARY LibArchive_INCLUDE_DIR + ) +set(LibArchive_FOUND ${LIBARCHIVE_FOUND}) +unset(LIBARCHIVE_FOUND) + +if(LibArchive_FOUND) + set(LibArchive_INCLUDE_DIRS ${LibArchive_INCLUDE_DIR}) + set(LibArchive_LIBRARIES ${LibArchive_LIBRARY}) +endif() diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake index 67db32122..6152bfd97 100644 --- a/Modules/FindLibXml2.cmake +++ b/Modules/FindLibXml2.cmake @@ -18,7 +18,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # use pkg-config to get the directories and then use these values @@ -46,7 +46,7 @@ SET(XMLLINT_EXECUTABLE "${LIBXML2_XMLLINT_EXECUTABLE}") # handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR) MARK_AS_ADVANCED(LIBXML2_INCLUDE_DIR LIBXML2_LIBRARIES LIBXML2_XMLLINT_EXECUTABLE) diff --git a/Modules/FindLibXslt.cmake b/Modules/FindLibXslt.cmake index a03aa7c80..cb05b636e 100644 --- a/Modules/FindLibXslt.cmake +++ b/Modules/FindLibXslt.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # use pkg-config to get the directories and then use these values @@ -40,7 +40,7 @@ FIND_LIBRARY(LIBXSLT_LIBRARIES NAMES xslt libxslt # handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +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) diff --git a/Modules/FindLua50.cmake b/Modules/FindLua50.cmake index 04f8b2855..cb979f1f0 100644 --- a/Modules/FindLua50.cmake +++ b/Modules/FindLua50.cmake @@ -21,7 +21,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(LUA_INCLUDE_DIR lua.h @@ -87,7 +87,7 @@ ELSE(${LUA_LIBRARY_lua} MATCHES "framework") ENDIF(${LUA_LIBRARY_lua} MATCHES "framework") -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if # all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua50 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR) diff --git a/Modules/FindLua51.cmake b/Modules/FindLua51.cmake index 473138d1d..ea3e8f661 100644 --- a/Modules/FindLua51.cmake +++ b/Modules/FindLua51.cmake @@ -21,7 +21,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(LUA_INCLUDE_DIR lua.h @@ -66,7 +66,7 @@ IF(LUA_LIBRARY) ENDIF(UNIX AND NOT APPLE) ENDIF(LUA_LIBRARY) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if # all listed variables are TRUE FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51 DEFAULT_MSG LUA_LIBRARIES LUA_INCLUDE_DIR) diff --git a/Modules/FindMFC.cmake b/Modules/FindMFC.cmake index 6a3a4b7ad..3df284241 100644 --- a/Modules/FindMFC.cmake +++ b/Modules/FindMFC.cmake @@ -14,7 +14,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Assume no MFC support diff --git a/Modules/FindMPEG.cmake b/Modules/FindMPEG.cmake index 0c06c94c6..6de6ce36e 100644 --- a/Modules/FindMPEG.cmake +++ b/Modules/FindMPEG.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(MPEG_INCLUDE_DIR mpeg2dec/include/video_out.h @@ -34,7 +34,7 @@ FIND_LIBRARY( MPEG_vo_LIBRARY vo # handle the QUIETLY and REQUIRED arguments and set MPEG2_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(MPEG DEFAULT_MSG MPEG_INCLUDE_DIR MPEG_mpeg2_LIBRARY MPEG_vo_LIBRARY) IF(MPEG_FOUND) diff --git a/Modules/FindMPEG2.cmake b/Modules/FindMPEG2.cmake index 7fa7d518c..6961e879d 100644 --- a/Modules/FindMPEG2.cmake +++ b/Modules/FindMPEG2.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(MPEG2_INCLUDE_DIR @@ -36,7 +36,7 @@ FIND_LIBRARY( MPEG2_vo_LIBRARY vo # handle the QUIETLY and REQUIRED arguments and set MPEG2_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(MPEG2 DEFAULT_MSG MPEG2_mpeg2_LIBRARY MPEG2_INCLUDE_DIR) IF(MPEG2_FOUND) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 481b0e994..78699cc65 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -62,7 +62,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is maintained by David Partyka . @@ -81,6 +81,7 @@ set(_MPI_PACKAGE_DIR lib/openmpi "MPICH/SDK" "Microsoft Compute Cluster Pack" + "Microsoft HPC Pack 2008 R2" ) set(_MPI_PREFIX_PATH) @@ -188,7 +189,7 @@ if (MPI_INCLUDE_PATH AND MPI_LIBRARY) # the cache, and we don't want to override those settings. elseif (MPI_COMPILE_CMDLINE) # Extract compile flags from the compile command line. - string(REGEX MATCHALL "-D([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}") + string(REGEX MATCHALL "(^| )-[Df]([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}") set(MPI_COMPILE_FLAGS_WORK) foreach(FLAG ${MPI_ALL_COMPILE_FLAGS}) if (MPI_COMPILE_FLAGS_WORK) @@ -199,10 +200,10 @@ elseif (MPI_COMPILE_CMDLINE) endforeach(FLAG) # Extract include paths from compile command line - string(REGEX MATCHALL "-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") + string(REGEX MATCHALL "(^| )-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") set(MPI_INCLUDE_PATH_WORK) foreach(IPATH ${MPI_ALL_INCLUDE_PATHS}) - string(REGEX REPLACE "^-I" "" IPATH ${IPATH}) + string(REGEX REPLACE "^ ?-I" "" IPATH ${IPATH}) string(REGEX REPLACE "//" "/" IPATH ${IPATH}) list(APPEND MPI_INCLUDE_PATH_WORK ${IPATH}) endforeach(IPATH) @@ -230,10 +231,10 @@ elseif (MPI_COMPILE_CMDLINE) endif (NOT MPI_INCLUDE_PATH_WORK) # Extract linker paths from the link command line - string(REGEX MATCHALL "-L([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") + string(REGEX MATCHALL "(^| |-Wl,)-L([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") set(MPI_LINK_PATH) foreach(LPATH ${MPI_ALL_LINK_PATHS}) - string(REGEX REPLACE "^-L" "" LPATH ${LPATH}) + string(REGEX REPLACE "^(| |-Wl,)-L" "" LPATH ${LPATH}) string(REGEX REPLACE "//" "/" LPATH ${LPATH}) list(APPEND MPI_LINK_PATH ${LPATH}) endforeach(LPATH) @@ -251,7 +252,7 @@ elseif (MPI_COMPILE_CMDLINE) endif (NOT MPI_LINK_PATH) # Extract linker flags from the link command line - string(REGEX MATCHALL "-Wl,([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") + string(REGEX MATCHALL "(^| )-Wl,([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") set(MPI_LINK_FLAGS_WORK) foreach(FLAG ${MPI_ALL_LINK_FLAGS}) if (MPI_LINK_FLAGS_WORK) @@ -263,20 +264,20 @@ elseif (MPI_COMPILE_CMDLINE) # Extract the set of libraries to link against from the link command # line - string(REGEX MATCHALL "-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") + string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") # Determine full path names for all of the libraries that one needs # to link against in an MPI program set(MPI_LIBRARIES) foreach(LIB ${MPI_LIBNAMES}) - string(REGEX REPLACE "^-l" "" LIB ${LIB}) + string(REGEX REPLACE "^ ?-l" "" LIB ${LIB}) set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) find_library(MPI_LIB ${LIB} HINTS ${MPI_LINK_PATH}) if (MPI_LIB) list(APPEND MPI_LIBRARIES ${MPI_LIB}) - else (MPI_LIB) - message(SEND_ERROR "Unable to find MPI library ${LIB}") - endif (MPI_LIB) + elseif (NOT MPI_FIND_QUIETLY) + message(WARNING "Unable to find MPI library ${LIB}") + endif () endforeach(LIB) set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI detection" FORCE) @@ -306,7 +307,7 @@ else (MPI_COMPILE_CMDLINE) # No MPI compiler to interogate so attempt to find everything with find functions. find_path(MPI_INCLUDE_PATH mpi.h HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} - PATH_SUFFIXES include + PATH_SUFFIXES include Inc ) # Decide between 32-bit and 64-bit libraries for Microsoft's MPI @@ -332,12 +333,6 @@ else (MPI_COMPILE_CMDLINE) set(MPI_LINK_FLAGS "" CACHE STRING "MPI linking flags") endif (MPI_INCLUDE_PATH AND MPI_LIBRARY) -# on BlueGene/L the MPI lib is named libmpich.rts.a, there also these additional libs are required -if("${MPI_LIBRARY}" MATCHES "mpich.rts") - set(MPI_EXTRA_LIBRARY ${MPI_EXTRA_LIBRARY} msglayer.rts devices.rts rts.rts devices.rts) - set(MPI_LIBRARY ${MPI_LIBRARY} msglayer.rts devices.rts rts.rts devices.rts) -endif("${MPI_LIBRARY}" MATCHES "mpich.rts") - # Set up extra variables to conform to if (MPI_EXTRA_LIBRARY) set(MPI_LIBRARIES ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY}) @@ -351,7 +346,7 @@ else (MPI_INCLUDE_PATH AND MPI_LIBRARY) set(MPI_FOUND FALSE) endif (MPI_INCLUDE_PATH AND MPI_LIBRARY) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") # handle the QUIETLY and REQUIRED arguments find_package_handle_standard_args(MPI DEFAULT_MSG MPI_LIBRARY MPI_INCLUDE_PATH) diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 13b961a8c..1cdb07174 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -16,7 +16,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) SET(MATLAB_FOUND 0) diff --git a/Modules/FindMotif.cmake b/Modules/FindMotif.cmake index c8715fdb3..8247afd97 100644 --- a/Modules/FindMotif.cmake +++ b/Modules/FindMotif.cmake @@ -14,7 +14,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) SET(MOTIF_FOUND 0) @@ -34,7 +34,7 @@ ENDIF(UNIX) # handle the QUIETLY and REQUIRED arguments and set MOTIF_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Motif DEFAULT_MSG MOTIF_LIBRARIES MOTIF_INCLUDE_DIR) diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake index f42a69acf..982b4fd3d 100644 --- a/Modules/FindOpenAL.cmake +++ b/Modules/FindOpenAL.cmake @@ -20,7 +20,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This makes the presumption that you are include al.h like @@ -97,7 +97,7 @@ FIND_LIBRARY(OPENAL_LIBRARY # handle the QUIETLY and REQUIRED arguments and set OPENAL_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR) MARK_AS_ADVANCED(OPENAL_LIBRARY OPENAL_INCLUDE_DIR) diff --git a/Modules/FindOpenGL.cmake b/Modules/FindOpenGL.cmake index 833d7eb96..21aafa927 100644 --- a/Modules/FindOpenGL.cmake +++ b/Modules/FindOpenGL.cmake @@ -25,7 +25,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF (WIN32) diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index 5ea329da4..30eb37af7 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -21,12 +21,12 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) include(CheckCSourceCompiles) include(CheckCXXSourceCompiles) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") set(OpenMP_C_FLAG_CANDIDATES #Gnu diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index 826ae096e..b599d99c8 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -20,7 +20,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # http://www.slproweb.com/products/Win32OpenSSL.html @@ -40,7 +40,7 @@ MARK_AS_ADVANCED(OPENSSL_ROOT_DIR) # Re-use the previous path: FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h - ${OPENSSL_ROOT_DIR}/include + PATHS ${OPENSSL_ROOT_DIR}/include ) IF(WIN32 AND NOT CYGWIN) @@ -61,21 +61,21 @@ IF(WIN32 AND NOT CYGWIN) # libeay32MD.lib is identical to ../libeay32.lib, and # ssleay32MD.lib is identical to ../ssleay32.lib FIND_LIBRARY(LIB_EAY_DEBUG NAMES libeay32MDd libeay32 - ${OPENSSL_ROOT_DIR}/lib/VC + PATHS ${OPENSSL_ROOT_DIR}/lib/VC ) FIND_LIBRARY(LIB_EAY_RELEASE NAMES libeay32MD libeay32 - ${OPENSSL_ROOT_DIR}/lib/VC + PATHS ${OPENSSL_ROOT_DIR}/lib/VC ) FIND_LIBRARY(SSL_EAY_DEBUG NAMES ssleay32MDd ssleay32 ssl - ${OPENSSL_ROOT_DIR}/lib/VC + PATHS ${OPENSSL_ROOT_DIR}/lib/VC ) FIND_LIBRARY(SSL_EAY_RELEASE NAMES ssleay32MD ssleay32 ssl - ${OPENSSL_ROOT_DIR}/lib/VC + PATHS ${OPENSSL_ROOT_DIR}/lib/VC ) if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) set( OPENSSL_LIBRARIES - optimized ${SSL_EAY_RELEASE} ${LIB_EAY_RELEASE} - debug ${SSL_EAY_DEBUG} ${LIB_EAY_DEBUG} + optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG} + optimized ${LIB_EAY_RELEASE} debug ${LIB_EAY_DEBUG} ) else() set( OPENSSL_LIBRARIES ${SSL_EAY_RELEASE} ${LIB_EAY_RELEASE} ) @@ -85,20 +85,20 @@ IF(WIN32 AND NOT CYGWIN) ELSEIF(MINGW) # same player, for MingW FIND_LIBRARY(LIB_EAY NAMES libeay32 - ${OPENSSL_ROOT_DIR}/lib/MinGW + PATHS ${OPENSSL_ROOT_DIR}/lib/MinGW ) FIND_LIBRARY(SSL_EAY NAMES ssleay32 - ${OPENSSL_ROOT_DIR}/lib/MinGW + PATHS ${OPENSSL_ROOT_DIR}/lib/MinGW ) MARK_AS_ADVANCED(SSL_EAY LIB_EAY) set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) ELSE(MSVC) # Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues: FIND_LIBRARY(LIB_EAY NAMES libeay32 - ${OPENSSL_ROOT_DIR}/lib + PATHS ${OPENSSL_ROOT_DIR}/lib ) FIND_LIBRARY(SSL_EAY NAMES ssleay32 - ${OPENSSL_ROOT_DIR}/lib + PATHS ${OPENSSL_ROOT_DIR}/lib ) MARK_AS_ADVANCED(SSL_EAY LIB_EAY) set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) @@ -113,7 +113,7 @@ ELSE(WIN32 AND NOT CYGWIN) ENDIF(WIN32 AND NOT CYGWIN) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") find_package_handle_standard_args(OpenSSL DEFAULT_MSG OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR diff --git a/Modules/FindOpenSceneGraph.cmake b/Modules/FindOpenSceneGraph.cmake index 25cf4ee15..c4048bdd2 100644 --- a/Modules/FindOpenSceneGraph.cmake +++ b/Modules/FindOpenSceneGraph.cmake @@ -58,7 +58,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # @@ -231,7 +231,7 @@ else() endif() endif() - include(FindPackageHandleStandardArgs) + include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSceneGraph DEFAULT_MSG OPENSCENEGRAPH_LIBRARIES OPENSCENEGRAPH_INCLUDE_DIR) endif() diff --git a/Modules/FindOpenThreads.cmake b/Modules/FindOpenThreads.cmake index be53953db..74aaa50e1 100644 --- a/Modules/FindOpenThreads.cmake +++ b/Modules/FindOpenThreads.cmake @@ -27,7 +27,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -118,6 +118,6 @@ else() set(OPENTHREADS_LIBRARIES ${OPENTHREADS_LIBRARY}) endif() -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenThreads DEFAULT_MSG OPENTHREADS_LIBRARY OPENTHREADS_INCLUDE_DIR) diff --git a/Modules/FindPHP4.cmake b/Modules/FindPHP4.cmake index 4afce99fe..8a20063ef 100644 --- a/Modules/FindPHP4.cmake +++ b/Modules/FindPHP4.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) SET(PHP4_POSSIBLE_INCLUDE_PATHS @@ -81,5 +81,5 @@ IF(APPLE) ENDFOREACH(symbol) ENDIF(APPLE) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(PHP4 DEFAULT_MSG PHP4_EXECUTABLE PHP4_INCLUDE_PATH) diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index bfc5d4aa1..c137172f0 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -20,7 +20,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) if(PNG_FIND_QUIETLY) @@ -55,7 +55,7 @@ endif(ZLIB_FOUND) # handle the QUIETLY and REQUIRED arguments and set PNG_FOUND to TRUE if # all listed variables are TRUE -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") find_package_handle_standard_args(PNG DEFAULT_MSG PNG_LIBRARY PNG_PNG_INCLUDE_DIR) mark_as_advanced(PNG_PNG_INCLUDE_DIR PNG_LIBRARY ) diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index e17105c3e..1acb021e8 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -1,21 +1,73 @@ -# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME (DEFAULT_MSG|"Custom failure message") VAR1 ... ) -# This macro is intended to be used in FindXXX.cmake modules files. -# It handles the REQUIRED and QUIET argument to FIND_PACKAGE() and -# it also sets the _FOUND variable. -# The package is found if all variables listed are TRUE. -# Example: +# FIND_PACKAGE_HANDLE_STANDARD_ARGS( ... ) # -# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR) +# This function is intended to be used in FindXXX.cmake modules files. +# It handles the REQUIRED, QUIET and version-related arguments to FIND_PACKAGE(). +# It also sets the _FOUND variable. +# The package is considered found if all variables ... listed contain +# valid results, e.g. valid filepaths. # -# LibXml2 is considered to be found, if both LIBXML2_LIBRARIES and -# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE. -# If it is not found and REQUIRED was used, it fails with FATAL_ERROR, -# independent whether QUIET was used or not. -# If it is found, the location is reported using the VAR1 argument, so -# here a message "Found LibXml2: /usr/lib/libxml2.so" will be printed out. -# If the second argument is DEFAULT_MSG, the message in the failure case will -# be "Could NOT find LibXml2", if you don't like this message you can specify -# your own custom failure message there. +# There are two modes of this function. The first argument in both modes is +# the name of the Find-module where it is called (in original casing). +# +# The first simple mode looks like this: +# FIND_PACKAGE_HANDLE_STANDARD_ARGS( (DEFAULT_MSG|"Custom failure message") ... ) +# If the variables to are all valid, then _FOUND +# will be set to TRUE. +# If DEFAULT_MSG is given as second argument, then the function will generate +# itself useful success and error messages. You can also supply a custom error message +# for the failure case. This is not recommended. +# +# The second mode is more powerful and also supports version checking: +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME [REQUIRED_VARS ...] +# [VERSION_VAR +# [CONFIG_MODE] +# [FAIL_MESSAGE "Custom failure message"] ) +# +# As above, if through are all valid, _FOUND +# will be set to TRUE. +# After REQUIRED_VARS the variables which are required for this package are listed. +# Following VERSION_VAR the name of the variable can be specified which holds +# the version of the package which has been found. If this is done, this version +# will be checked against the (potentially) specified required version used +# in the find_package() call. The EXACT keyword is also handled. The default +# messages include information about the required version and the version +# which has been actually found, both if the version is ok or not. +# Use the option CONFIG_MODE if your FindXXX.cmake module is a wrapper for +# a find_package(... NO_MODULE) call, in this case all the information +# provided by the config-mode of find_package() will be evaluated +# automatically. +# Via FAIL_MESSAGE a custom failure message can be specified, if this is not +# used, the default message will be displayed. +# +# Example for mode 1: +# +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) +# +# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and +# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE. +# If it is not found and REQUIRED was used, it fails with FATAL_ERROR, +# independent whether QUIET was used or not. +# If it is found, success will be reported, including the content of . +# On repeated Cmake runs, the same message won't be printed again. +# +# Example for mode 2: +# +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(BISON REQUIRED_VARS BISON_EXECUTABLE +# VERSION_VAR BISON_VERSION) +# In this case, BISON is considered to be found if the variable(s) listed +# after REQUIRED_VAR are all valid, i.e. BISON_EXECUTABLE in this case. +# Also the version of BISON will be checked by using the version contained +# in BISON_VERSION. +# Since no FAIL_MESSAGE is given, the default messages will be printed. +# +# Another example for mode 2: +# +# FIND_PACKAGE(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(Automoc4 CONFIG_MODE) +# In this case, FindAutmoc4.cmake wraps a call to FIND_PACKAGE(Automoc4 NO_MODULE) +# and adds an additional search directory for automoc4. +# The following FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper +# success/error message. #============================================================================= # Copyright 2007-2009 Kitware, Inc. @@ -27,34 +79,108 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(FindPackageMessage) -FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 ) +INCLUDE(CMakeParseArguments) + +# internal helper macro +MACRO(_FPHSA_FAILURE_MESSAGE _msg) + IF (${_NAME}_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "${_msg}") + ELSE (${_NAME}_FIND_REQUIRED) + IF (NOT ${_NAME}_FIND_QUIETLY) + MESSAGE(STATUS "${_msg}") + ENDIF (NOT ${_NAME}_FIND_QUIETLY) + ENDIF (${_NAME}_FIND_REQUIRED) +ENDMACRO(_FPHSA_FAILURE_MESSAGE _msg) + + +# internal helper macro to generate the failure message when used in CONFIG_MODE: +MACRO(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) + # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: + IF(${_NAME}_CONFIG) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") + ELSE(${_NAME}_CONFIG) + # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. + # List them all in the error message: + IF(${_NAME}_CONSIDERED_CONFIGS) + SET(configsText "") + LIST(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) + MATH(EXPR configsCount "${configsCount} - 1") + FOREACH(currentConfigIndex RANGE ${configsCount}) + LIST(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) + LIST(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) + SET(configsText "${configsText} ${filename} (version ${version})\n") + ENDFOREACH(currentConfigIndex) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") + + ELSE(${_NAME}_CONSIDERED_CONFIGS) + # Simple case: No Config-file was found at all: + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") + ENDIF(${_NAME}_CONSIDERED_CONFIGS) + ENDIF(${_NAME}_CONFIG) +ENDMACRO(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) + + +FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) + +# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in +# new extended or in the "old" mode: + SET(options CONFIG_MODE) + SET(oneValueArgs FAIL_MESSAGE VERSION_VAR) + SET(multiValueArgs REQUIRED_VARS) + SET(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) + LIST(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) + + IF(${INDEX} EQUAL -1) + SET(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) + SET(FPHSA_REQUIRED_VARS ${ARGN}) + SET(FPHSA_VERSION_VAR) + ELSE(${INDEX} EQUAL -1) + + CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) + + IF(FPHSA_UNPARSED_ARGUMENTS) + MESSAGE(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") + ENDIF(FPHSA_UNPARSED_ARGUMENTS) - IF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG") - SET(_FAIL_MESSAGE "Could NOT find ${_NAME}") - ELSE("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG") - SET(_FAIL_MESSAGE "${_FAIL_MSG}") - ENDIF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG") + IF(NOT FPHSA_FAIL_MESSAGE) + SET(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") + ENDIF(NOT FPHSA_FAIL_MESSAGE) + ENDIF(${INDEX} EQUAL -1) + +# now that we collected all arguments, process them + + IF("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") + SET(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") + ENDIF("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG") + + # In config-mode, we rely on the variable _CONFIG, which is set by find_package() + # when it successfully found the config-file, including version checking: + IF(FPHSA_CONFIG_MODE) + LIST(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) + LIST(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) + SET(FPHSA_VERSION_VAR ${_NAME}_VERSION) + ENDIF(FPHSA_CONFIG_MODE) + + IF(NOT FPHSA_REQUIRED_VARS) + MESSAGE(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") + ENDIF(NOT FPHSA_REQUIRED_VARS) + + LIST(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) STRING(TOUPPER ${_NAME} _NAME_UPPER) + STRING(TOLOWER ${_NAME} _NAME_LOWER) - # collect all variables which were not found, so they can be printed, so the + # collect all variables which were not found, so they can be printed, so the # user knows better what went wrong (#6375) SET(MISSING_VARS "") SET(DETAILS "") SET(${_NAME_UPPER}_FOUND TRUE) - IF(NOT ${_VAR1}) - SET(${_NAME_UPPER}_FOUND FALSE) - SET(MISSING_VARS " ${_VAR1}") - ELSE(NOT ${_VAR1}) - SET(DETAILS "${DETAILS}[${${_VAR1}}]") - ENDIF(NOT ${_VAR1}) - # check if all passed variables are valid - FOREACH(_CURRENT_VAR ${ARGN}) + FOREACH(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) IF(NOT ${_CURRENT_VAR}) SET(${_NAME_UPPER}_FOUND FALSE) SET(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}") @@ -63,18 +189,72 @@ FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 ) ENDIF(NOT ${_CURRENT_VAR}) ENDFOREACH(_CURRENT_VAR) + + # version handling: + SET(VERSION_MSG "") + SET(VERSION_OK TRUE) + SET(VERSION ${${FPHSA_VERSION_VAR}} ) + IF (${_NAME}_FIND_VERSION) + + IF(VERSION) + + IF(${_NAME}_FIND_VERSION_EXACT) # exact version required + IF (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + SET(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") + SET(VERSION_OK FALSE) + ELSE (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + SET(VERSION_MSG "(found suitable exact version \"${VERSION}\")") + ENDIF (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}") + + ELSE(${_NAME}_FIND_VERSION_EXACT) # minimum version specified: + IF ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + SET(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") + SET(VERSION_OK FALSE) + ELSE ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + SET(VERSION_MSG "(found suitable version \"${VERSION}\", required is \"${${_NAME}_FIND_VERSION}\")") + ENDIF ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}") + ENDIF(${_NAME}_FIND_VERSION_EXACT) + + ELSE(VERSION) + + # if the package was not found, but a version was given, add that to the output: + IF(${_NAME}_FIND_VERSION_EXACT) + SET(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") + ELSE(${_NAME}_FIND_VERSION_EXACT) + SET(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") + ENDIF(${_NAME}_FIND_VERSION_EXACT) + + ENDIF(VERSION) + ELSE (${_NAME}_FIND_VERSION) + IF(VERSION) + SET(VERSION_MSG "(found version \"${VERSION}\")") + ENDIF(VERSION) + ENDIF (${_NAME}_FIND_VERSION) + + IF(VERSION_OK) + SET(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]") + ELSE(VERSION_OK) + SET(${_NAME_UPPER}_FOUND FALSE) + ENDIF(VERSION_OK) + + + # print the result: IF (${_NAME_UPPER}_FOUND) - FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_VAR1}}" "${DETAILS}") + FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG}" "${DETAILS}") ELSE (${_NAME_UPPER}_FOUND) - IF (${_NAME}_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE} (missing: ${MISSING_VARS})") - ELSE (${_NAME}_FIND_REQUIRED) - IF (NOT ${_NAME}_FIND_QUIETLY) - MESSAGE(STATUS "${_FAIL_MESSAGE} (missing: ${MISSING_VARS})") - ENDIF (NOT ${_NAME}_FIND_QUIETLY) - ENDIF (${_NAME}_FIND_REQUIRED) + + IF(FPHSA_CONFIG_MODE) + _FPHSA_HANDLE_FAILURE_CONFIG_MODE() + ELSE(FPHSA_CONFIG_MODE) + IF(NOT VERSION_OK) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") + ELSE(NOT VERSION_OK) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") + ENDIF(NOT VERSION_OK) + ENDIF(FPHSA_CONFIG_MODE) + ENDIF (${_NAME_UPPER}_FOUND) SET(${_NAME_UPPER}_FOUND ${${_NAME_UPPER}_FOUND} PARENT_SCOPE) -ENDFUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS) +ENDFUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _FIRST_ARG) diff --git a/Modules/FindPackageMessage.cmake b/Modules/FindPackageMessage.cmake index aa1bbd97a..eb398b2ae 100644 --- a/Modules/FindPackageMessage.cmake +++ b/Modules/FindPackageMessage.cmake @@ -28,7 +28,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FUNCTION(FIND_PACKAGE_MESSAGE pkg msg details) diff --git a/Modules/FindPerl.cmake b/Modules/FindPerl.cmake index bf982b24f..85172d0b2 100644 --- a/Modules/FindPerl.cmake +++ b/Modules/FindPerl.cmake @@ -14,7 +14,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(FindCygwin) @@ -44,7 +44,7 @@ SET(PERL ${PERL_EXECUTABLE}) # handle the QUIETLY and REQUIRED arguments and set PERL_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Perl DEFAULT_MSG PERL_EXECUTABLE) MARK_AS_ADVANCED(PERL_EXECUTABLE) diff --git a/Modules/FindPerlLibs.cmake b/Modules/FindPerlLibs.cmake index 422282f5b..4cb026392 100644 --- a/Modules/FindPerlLibs.cmake +++ b/Modules/FindPerlLibs.cmake @@ -8,6 +8,9 @@ # PERL_LIBRARY = path to libperl # PERL_EXECUTABLE = full path to the perl binary # +# The minimum required version of Perl can be specified using the +# standard syntax, e.g. FIND_PACKAGE(PerlLibs 6.0) +# # The following variables are also available if needed # (introduced after CMake 2.6.4) # @@ -30,7 +33,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # find the perl executable @@ -227,8 +230,9 @@ endif (PERL_EXECUTABLE) # handle the QUIETLY and REQUIRED arguments and set PERLLIBS_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PerlLibs DEFAULT_MSG PERL_LIBRARY PERL_INCLUDE_PATH) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") +find_package_handle_standard_args(PerlLibs REQUIRED_VARS PERL_LIBRARY PERL_INCLUDE_PATH + VERSION_VAR PERL_VERSION) # Introduced after CMake 2.6.4 to bring module into compliance set(PERL_INCLUDE_DIR ${PERL_INCLUDE_PATH}) diff --git a/Modules/FindPhysFS.cmake b/Modules/FindPhysFS.cmake index 98bebe6eb..5694c1ed9 100644 --- a/Modules/FindPhysFS.cmake +++ b/Modules/FindPhysFS.cmake @@ -20,7 +20,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(PHYSFS_INCLUDE_DIR physfs.h @@ -56,6 +56,6 @@ FIND_LIBRARY(PHYSFS_LIBRARY # handle the QUIETLY and REQUIRED arguments and set PHYSFS_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(PhysFS DEFAULT_MSG PHYSFS_LIBRARY PHYSFS_INCLUDE_DIR) diff --git a/Modules/FindPike.cmake b/Modules/FindPike.cmake index d1b5ea6e2..125e42832 100644 --- a/Modules/FindPike.cmake +++ b/Modules/FindPike.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FILE(GLOB PIKE_POSSIBLE_INCLUDE_PATHS diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 3cbb7af76..c47f583cb 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -80,7 +80,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) ### Common stuff #### diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake new file mode 100644 index 000000000..6455c99e1 --- /dev/null +++ b/Modules/FindPostgreSQL.cmake @@ -0,0 +1,181 @@ +# Find the PostgreSQL installation. +# +# ---------------------------------------------------------------------------- +# Usage: +# In your CMakeLists.txt file do something like this: +# ... +# # PostgreSQL +# FIND_PACKAGE(PostgreSQL) +# ... +# 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. +# +# +# In Windows, we make the assumption that, if the PostgreSQL files are installed, the default directory +# will be C:\Program Files\PostgreSQL. +# + +#============================================================================= +# 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.) + +# ---------------------------------------------------------------------------- +# History: +# This module is derived from the module originally found in the VTK source tree. +# +# ---------------------------------------------------------------------------- +# Note: +# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the +# version mumber of the implementation of PostgreSQL. +# In Windows the default installation of PostgreSQL uses that as part of the path. +# E.g C:\Program Files\PostgreSQL\8.4. +# Currently, the following version numbers are known to this module: +# "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" +# +# To use this variable just do something like this: +# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4") +# before calling FIND_PACKAGE(PostgreSQL) in your CMakeLists.txt file. +# This will mean that the versions you set here will be found first in the order +# specified before the default ones are searched. +# +# ---------------------------------------------------------------------------- +# You may need to manually set: +# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are. +# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are. +# If FindPostgreSQL.cmake cannot find the include files or the library files. +# +# ---------------------------------------------------------------------------- +# The following variables are set if PostgreSQL is found: +# PostgreSQL_FOUND - Set to true when PostgreSQL is found. +# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL +# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries +# PostgreSQL_LIBRARIES - The PostgreSQL libraries. +# +# ---------------------------------------------------------------------------- +# If you have installed PostgreSQL in a non-standard location. +# (Please note that in the following comments, it is assumed that +# points to the root directory of the include directory of PostgreSQL.) +# Then you have three options. +# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to /include and +# PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is +# 2) Use CMAKE_INCLUDE_PATH to set a path to /PostgreSQL<-version>. This will allow find_path() +# to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file +# SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "/include") +# 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have +# installed PostgreSQL, e.g. . +# +# ---------------------------------------------------------------------------- + +set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include") +set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}") +set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.") +set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}") +set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4") + + +set(PostgreSQL_ROOT_DIRECTORIES $ENV{PostgreSQL_ROOT}) +if(PostgreSQL_ROOT_DIRECTORIES) + file(TO_CMAKE_PATH ${PostgreSQL_ROOT_DIRECTORIES} PostgreSQL_ROOT_DIRECTORIES) +endif(PostgreSQL_ROOT_DIRECTORIES) + +set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS} + "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0") + +# Define additional search paths for root directories. +if ( WIN32 ) + foreach (suffix ${PostgreSQL_KNOWN_VERSIONS} ) + set(PostgreSQL_ADDITIONAL_SEARCH_PATHS ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} "C:/Program Files/PostgreSQL/${suffix}" ) + endforeach(suffix) +endif( WIN32 ) +set( PostgreSQL_ROOT_DIRECTORIES + ${PostgreSQL_ROOT_DIRECTORIES} + ${PostgreSQL_ROOT} + ${PostgreSQL_ADDITIONAL_SEARCH_PATHS} +) + +# +# Look for an installation. +# +find_path(PostgreSQL_INCLUDE_DIR + NAMES libpq-fe.h + PATHS + # Look in other places. + ${PostgreSQL_ROOT_DIRECTORIES} + PATH_SUFFIXES + postgresql + include + # 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 +set (PostgreSQL_LIB_PREFIX "") +if ( WIN32 ) + set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib") + set ( PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND}) +endif() + +find_library( PostgreSQL_LIBRARY + NAMES ${PostgreSQL_LIBRARY_TO_FIND} + PATHS + ${PostgreSQL_ROOT_DIRECTORIES} + PATH_SUFFIXES + lib +) +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}" ) + +# 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}") + + #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) diff --git a/Modules/FindProducer.cmake b/Modules/FindProducer.cmake index 352550934..fcee1d984 100644 --- a/Modules/FindProducer.cmake +++ b/Modules/FindProducer.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -77,6 +77,6 @@ FIND_LIBRARY(PRODUCER_LIBRARY /opt ) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Producer DEFAULT_MSG PRODUCER_LIBRARY PRODUCER_INCLUDE_DIR) diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake index 1cd59e781..e79ae263b 100644 --- a/Modules/FindProtobuf.cmake +++ b/Modules/FindProtobuf.cmake @@ -48,7 +48,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) function(PROTOBUF_GENERATE_CPP SRCS HDRS) @@ -111,7 +111,7 @@ if(WIN32) set(CMAKE_FIND_LIBRARY_PREFIXES "${PROTOBUF_ORIG_FIND_LIBRARY_PREFIXES}") endif() -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROTOBUF DEFAULT_MSG PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR) diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake index 167f53358..645ca79c4 100644 --- a/Modules/FindPythonInterp.cmake +++ b/Modules/FindPythonInterp.cmake @@ -7,7 +7,7 @@ # #============================================================================= -# Copyright 2005-2009 Kitware, Inc. +# Copyright 2005-2010 Kitware, Inc. # # Distributed under the OSI-approved BSD License (the "License"); # see accompanying file Copyright.txt for details. @@ -16,12 +16,13 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PROGRAM(PYTHON_EXECUTABLE - NAMES python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python + NAMES python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python PATHS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.7\\InstallPath] [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.6\\InstallPath] [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.5\\InstallPath] [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.4\\InstallPath] @@ -35,7 +36,7 @@ FIND_PROGRAM(PYTHON_EXECUTABLE # handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonInterp DEFAULT_MSG PYTHON_EXECUTABLE) MARK_AS_ADVANCED(PYTHON_EXECUTABLE) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 1ba21b507..10e92416f 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -20,14 +20,14 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(CMakeFindFrameworks) # Search for the python framework on Apple. CMAKE_FIND_FRAMEWORKS(Python) -FOREACH(_CURRENT_VERSION 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) +FOREACH(_CURRENT_VERSION 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) STRING(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION}) IF(WIN32) FIND_LIBRARY(PYTHON_DEBUG_LIBRARY @@ -98,18 +98,16 @@ SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs DEFAULT_MSG PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS) # PYTHON_ADD_MODULE( src1 src2 ... srcN) is used to build modules for python. # PYTHON_WRITE_MODULES_HEADER() writes a header file you can include # in your sources to initialize the static python modules - -GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS - GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) - FUNCTION(PYTHON_ADD_MODULE _NAME ) + GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS + GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) OPTION(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE) OPTION(PYTHON_MODULE_${_NAME}_BUILD_SHARED "Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS}) @@ -130,6 +128,13 @@ FUNCTION(PYTHON_ADD_MODULE _NAME ) ADD_LIBRARY(${_NAME} ${PY_MODULE_TYPE} ${ARGN}) # TARGET_LINK_LIBRARIES(${_NAME} ${PYTHON_LIBRARIES}) + IF(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + SET_TARGET_PROPERTIES(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}") + IF(WIN32 AND NOT CYGWIN) + SET_TARGET_PROPERTIES(${_NAME} PROPERTIES SUFFIX ".pyd") + ENDIF(WIN32 AND NOT CYGWIN) + ENDIF(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + ENDIF(PYTHON_ENABLE_MODULE_${_NAME}) ENDFUNCTION(PYTHON_ADD_MODULE) diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake index 85213e842..2b8dfd7fb 100644 --- a/Modules/FindQt.cmake +++ b/Modules/FindQt.cmake @@ -27,7 +27,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # look for signs of qt3 installations diff --git a/Modules/FindQt3.cmake b/Modules/FindQt3.cmake index d2f2f9013..3606a5f4f 100644 --- a/Modules/FindQt3.cmake +++ b/Modules/FindQt3.cmake @@ -30,7 +30,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # If Qt4 has already been found, fail. diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 654879e3b..45bbd2e58 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -242,6 +242,7 @@ # QT_LIBRARY_DIR Path to "lib" of Qt4 # QT_PLUGINS_DIR Path to "plugins" for Qt4 # QT_TRANSLATIONS_DIR Path to "translations" of Qt4 +# QT_IMPORTS_DIR Path to "imports" of Qt4 # QT_DOC_DIR Path to "doc" of Qt4 # QT_MKSPECS_DIR Path to "mkspecs" of Qt4 # @@ -317,7 +318,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Use FIND_PACKAGE( Qt4 COMPONENTS ... ) to enable modules @@ -358,6 +359,102 @@ SET(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake) SET( QT_DEFINITIONS "") +# convenience macro for dealing with debug/release library names +MACRO (_QT4_ADJUST_LIB_VARS _camelCaseBasename) + + STRING(TOUPPER "${_camelCaseBasename}" basename) + + # The name of the imported targets, i.e. the prefix "Qt4::" must not change, + # since it is stored in EXPORT-files as name of a required library. If the name would change + # here, this would lead to the imported Qt4-library targets not being resolved by cmake anymore. + IF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) + + IF(NOT TARGET Qt4::${_camelCaseBasename}) + ADD_LIBRARY(Qt4::${_camelCaseBasename} UNKNOWN IMPORTED ) + + IF (QT_${basename}_LIBRARY_RELEASE) + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}" ) + ENDIF (QT_${basename}_LIBRARY_RELEASE) + + IF (QT_${basename}_LIBRARY_DEBUG) + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}" ) + ENDIF (QT_${basename}_LIBRARY_DEBUG) + ENDIF(NOT TARGET Qt4::${_camelCaseBasename}) + + # If QT_USE_IMPORTED_TARGETS is enabled, the QT_QTFOO_LIBRARY variables are set to point at these + # imported targets. This works better in general, and is also in almost all cases fully + # backward compatible. The only issue is when a project A which had this enabled then exports its + # libraries via export or EXPORT_LIBRARY_DEPENDENCIES(). In this case the libraries from project + # A will depend on the imported Qt targets, and the names of these imported targets will be stored + # in the dependency files on disk. This means when a project B then uses project A, these imported + # targets must be created again, otherwise e.g. "Qt4__QtCore" will be interpreted as name of a + # library file on disk, and not as a target, and linking will fail: + IF(QT_USE_IMPORTED_TARGETS) + SET(QT_${basename}_LIBRARY Qt4::${_camelCaseBasename} ) + SET(QT_${basename}_LIBRARIES Qt4::${_camelCaseBasename} ) + ELSE(QT_USE_IMPORTED_TARGETS) + + # if the release- as well as the debug-version of the library have been found: + IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) + # if the generator supports configuration types then set + # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value + IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + SET(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) + ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + # if there are no configuration types and CMAKE_BUILD_TYPE has no value + # then just use the release libraries + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE} ) + ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) + ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) + + # if only the release version was found, set the debug variable also to the release version + IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) + SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE}) + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE}) + SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_RELEASE}) + ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) + + # if only the debug version was found, set the release variable also to the debug version + IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) + SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG}) + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG}) + SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_DEBUG}) + ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) + + # put the value in the cache: + SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE STRING "The Qt ${basename} library" FORCE) + + ENDIF(QT_USE_IMPORTED_TARGETS) + + SET(QT_${basename}_FOUND 1) + + ELSE (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) + + SET(QT_${basename}_LIBRARY "" CACHE STRING "The Qt ${basename} library" FORCE) + + ENDIF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) + + IF (QT_${basename}_INCLUDE_DIR) + #add the include directory to QT_INCLUDES + SET(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES}) + ENDIF (QT_${basename}_INCLUDE_DIR) + + # Make variables changeble to the advanced user + MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR) +ENDMACRO (_QT4_ADJUST_LIB_VARS) + +function(_QT4_QUERY_QMAKE VAR RESULT) + exec_program(${QT_QMAKE_EXECUTABLE} ARGS "-query ${VAR}" RETURN_VALUE return_code OUTPUT_VARIABLE output ) + if(NOT return_code) + file(TO_CMAKE_PATH "${output}" output) + set(${RESULT} ${output} PARENT_SCOPE) + endif(NOT return_code) +endfunction(_QT4_QUERY_QMAKE) + + SET(QT4_INSTALLED_VERSION_TOO_OLD FALSE) GET_FILENAME_COMPONENT(qt_install_version "[HKEY_CURRENT_USER\\Software\\trolltech\\Versions;DefaultQtVersion]" NAME) @@ -382,7 +479,7 @@ IF (QT_QMAKE_EXECUTABLE) SET(QT4_QMAKE_FOUND FALSE) - EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION) + _qt4_query_qmake(QT_VERSION QTVERSION) # check for qt3 qmake and then try and find qmake4 or qmake-qt4 in the path IF("${QTVERSION}" MATCHES "Unknown") @@ -394,8 +491,7 @@ IF (QT_QMAKE_EXECUTABLE) DOC "The qmake executable for the Qt installation to use" ) IF(QT_QMAKE_EXECUTABLE) - EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_VERSION" OUTPUT_VARIABLE QTVERSION) + _qt4_query_qmake(QT_VERSION QTVERSION) ENDIF(QT_QMAKE_EXECUTABLE) ENDIF("${QTVERSION}" MATCHES "Unknown") @@ -468,106 +564,186 @@ ENDIF (QT_QMAKE_EXECUTABLE) IF (QT4_QMAKE_FOUND) - # ask qmake for the library dir - # Set QT_LIBRARY_DIR - IF (NOT QT_LIBRARY_DIR OR QT_QMAKE_CHANGED) - EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_LIBS" - OUTPUT_VARIABLE QT_LIBRARY_DIR_TMP ) - # make sure we have / and not \ as qmake gives on windows - FILE(TO_CMAKE_PATH "${QT_LIBRARY_DIR_TMP}" QT_LIBRARY_DIR_TMP) - IF(EXISTS "${QT_LIBRARY_DIR_TMP}") - SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE PATH "Qt library dir" FORCE) - ELSE(EXISTS "${QT_LIBRARY_DIR_TMP}") - MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}") - MESSAGE("Warning: ${QT_LIBRARY_DIR_TMP} does NOT exist, Qt must NOT be installed correctly.") - ENDIF(EXISTS "${QT_LIBRARY_DIR_TMP}") - ENDIF(NOT QT_LIBRARY_DIR OR QT_QMAKE_CHANGED) - + # ask qmake for the mkspecs directory + # we do this first because QT_LIBINFIX might be set + IF (NOT QT_MKSPECS_DIR OR QT_QMAKE_CHANGED) + _qt4_query_qmake(QMAKE_MKSPECS qt_mkspecs_dirs) + # do not replace : on windows as it might be a drive letter + # and windows should already use ; as a separator + IF(NOT WIN32) + STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}") + ENDIF(NOT WIN32) + set(qt_cross_paths) + foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH}) + set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/mkspecs") + endforeach(qt_cross_path) + SET(QT_MKSPECS_DIR NOTFOUND) + FIND_PATH(QT_MKSPECS_DIR NAMES qconfig.pri + HINTS ${qt_cross_paths} ${qt_mkspecs_dirs} + DOC "The location of the Qt mkspecs containing qconfig.pri") + ENDIF() + + IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") + FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents) + STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG "${_qconfig_FILE_contents}") + STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG "${_qconfig_FILE_contents}") + STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION "${_qconfig_FILE_contents}") + STRING(REGEX MATCH "QT_LIBINFIX[^\n]+" _qconfig_qt_libinfix "${_qconfig_FILE_contents}") + STRING(REGEX REPLACE "QT_LIBINFIX *= *([^\n]*)" "\\1" QT_LIBINFIX "${_qconfig_qt_libinfix}") + ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") + IF("${QT_EDITION}" MATCHES "DesktopLight") + SET(QT_EDITION_DESKTOPLIGHT 1) + ENDIF("${QT_EDITION}" MATCHES "DesktopLight") + + # ask qmake for the library dir as a hint, then search for QtCore library and use that as a reference for finding the + # others and for setting QT_LIBRARY_DIR + IF (NOT QT_QTCORE_LIBRARY OR QT_QMAKE_CHANGED) + _qt4_query_qmake(QT_INSTALL_LIBS QT_LIBRARY_DIR_TMP) + SET(QT_QTCORE_LIBRARY_RELEASE NOTFOUND) + SET(QT_QTCORE_LIBRARY_DEBUG NOTFOUND) + FIND_LIBRARY(QT_QTCORE_LIBRARY_RELEASE + NAMES QtCore${QT_LIBINFIX} QtCore${QT_LIBINFIX}4 + HINTS ${QT_LIBRARY_DIR_TMP} + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH + ) + FIND_LIBRARY(QT_QTCORE_LIBRARY_DEBUG + NAMES QtCore${QT_LIBINFIX}_debug QtCore${QT_LIBINFIX}d QtCore${QT_LIBINFIX}d4 + HINTS ${QT_LIBRARY_DIR_TMP} + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH + ) + + # try dropping a hint if trying to use Visual Studio with Qt built by mingw + IF(NOT QT_QTCORE_LIBRARY_RELEASE AND MSVC) + IF(EXISTS ${QT_LIBRARY_DIR_TMP}/libqtmain.a) + MESSAGE( FATAL_ERROR "It appears you're trying to use Visual Studio with Qt built by mingw. Those compilers do not produce code compatible with each other.") + ENDIF(EXISTS ${QT_LIBRARY_DIR_TMP}/libqtmain.a) + ENDIF(NOT QT_QTCORE_LIBRARY_RELEASE AND MSVC) + + ENDIF (NOT QT_QTCORE_LIBRARY OR QT_QMAKE_CHANGED) + + _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) + SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE) + SET(QT_QTCORE_FOUND 1) + ELSEIF(QT_QTCORE_LIBRARY_DEBUG) + GET_FILENAME_COMPONENT(QT_LIBRARY_DIR_TMP "${QT_QTCORE_LIBRARY_DEBUG}" PATH) + SET(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE) + SET(QT_QTCORE_FOUND 1) + ELSE() + MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_LIBS as ${QT_LIBRARY_DIR_TMP}") + MESSAGE("Warning: But QtCore couldn't be found. Qt must NOT be installed correctly, or it wasn't found for cross compiling.") + IF(Qt4_FIND_REQUIRED) + MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.") + ENDIF(Qt4_FIND_REQUIRED) + ENDIF() + IF (APPLE) IF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - SET(QT_USE_FRAMEWORKS ON - CACHE BOOL "Set to ON if Qt build uses frameworks." FORCE) + SET(QT_USE_FRAMEWORKS ON CACHE INTERNAL "" FORCE) ELSE (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - SET(QT_USE_FRAMEWORKS OFF - CACHE BOOL "Set to ON if Qt build uses frameworks." FORCE) + SET(QT_USE_FRAMEWORKS OFF CACHE INTERNAL "" FORCE) ENDIF (EXISTS ${QT_LIBRARY_DIR}/QtCore.framework) - MARK_AS_ADVANCED(QT_USE_FRAMEWORKS) ENDIF (APPLE) # ask qmake for the binary dir - IF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) - EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_BINS" - OUTPUT_VARIABLE qt_bins ) - # make sure we have / and not \ as qmake gives on windows - FILE(TO_CMAKE_PATH "${qt_bins}" qt_bins) - SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "" FORCE) - ENDIF (QT_LIBRARY_DIR AND NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) + IF (NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) + _qt4_query_qmake(QT_INSTALL_BINS qt_bins) + SET(QT_BINARY_DIR ${qt_bins} CACHE INTERNAL "" FORCE) + ENDIF (NOT QT_BINARY_DIR OR QT_QMAKE_CHANGED) # ask qmake for the include dir - IF (QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR OR QT_QMAKE_CHANGED) - EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_HEADERS" - OUTPUT_VARIABLE qt_headers ) - # make sure we have / and not \ as qmake gives on windows - FILE(TO_CMAKE_PATH "${qt_headers}" qt_headers) - SET(QT_HEADERS_DIR ${qt_headers} CACHE INTERNAL "" FORCE) - ENDIF (QT_LIBRARY_DIR AND NOT QT_HEADERS_DIR OR QT_QMAKE_CHANGED) + 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}/QtCore.framework/Headers + PATH_SUFFIXES QtCore + ) + + # Set QT_HEADERS_DIR based on finding QtCore header + IF(QT_QTCORE_INCLUDE_DIR) + IF(QT_USE_FRAMEWORKS) + SET(QT_HEADERS_DIR "${qt_headers}" CACHE INTERNAL "" FORCE) + ELSE(QT_USE_FRAMEWORKS) + GET_FILENAME_COMPONENT(qt_headers "${QT_QTCORE_INCLUDE_DIR}/../" ABSOLUTE) + SET(QT_HEADERS_DIR "${qt_headers}" CACHE INTERNAL "" FORCE) + ENDIF(QT_USE_FRAMEWORKS) + ELSEIF() + MESSAGE("Warning: QT_QMAKE_EXECUTABLE reported QT_INSTALL_HEADERS as ${qt_headers}") + MESSAGE("Warning: But QtCore couldn't be found. Qt must NOT be installed correctly.") + ENDIF() + ENDIF() + + # Set QT_INCLUDE_DIR based on QT_HEADERS_DIR + IF(QT_HEADERS_DIR) + IF(QT_USE_FRAMEWORKS) + # Qt/Mac frameworks has two include dirs. + # One is the framework include for which CMake will add a -F flag + # and the other is an include dir for non-framework Qt modules + SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR} ${QT_QTCORE_LIBRARY} ) + ELSE(QT_USE_FRAMEWORKS) + SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR}) + ENDIF(QT_USE_FRAMEWORKS) + ENDIF(QT_HEADERS_DIR) + + # Set QT_INCLUDES + SET( QT_INCLUDES ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} ${QT_QTCORE_INCLUDE_DIR}) # ask qmake for the documentation directory IF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR OR QT_QMAKE_CHANGED) - EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_DOCS" - OUTPUT_VARIABLE qt_doc_dir ) - # make sure we have / and not \ as qmake gives on windows - FILE(TO_CMAKE_PATH "${qt_doc_dir}" qt_doc_dir) + _qt4_query_qmake(QT_INSTALL_DOCS qt_doc_dir) SET(QT_DOC_DIR ${qt_doc_dir} CACHE PATH "The location of the Qt docs" FORCE) ENDIF (QT_LIBRARY_DIR AND NOT QT_DOC_DIR OR QT_QMAKE_CHANGED) - # ask qmake for the mkspecs directory - IF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR OR QT_QMAKE_CHANGED) - EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QMAKE_MKSPECS" - OUTPUT_VARIABLE qt_mkspecs_dirs ) - # do not replace : on windows as it might be a drive letter - # and windows should already use ; as a separator - IF(UNIX) - STRING(REPLACE ":" ";" qt_mkspecs_dirs "${qt_mkspecs_dirs}") - ENDIF(UNIX) - SET(QT_MKSPECS_DIR NOTFOUND) - FIND_PATH(QT_MKSPECS_DIR qconfig.pri PATHS ${qt_mkspecs_dirs} - DOC "The location of the Qt mkspecs containing qconfig.pri" - NO_DEFAULT_PATH ) - ENDIF (QT_LIBRARY_DIR AND NOT QT_MKSPECS_DIR OR QT_QMAKE_CHANGED) # ask qmake for the plugins directory IF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR OR QT_QMAKE_CHANGED) - EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_PLUGINS" - OUTPUT_VARIABLE qt_plugins_dir ) - # make sure we have / and not \ as qmake gives on windows - FILE(TO_CMAKE_PATH "${qt_plugins_dir}" qt_plugins_dir) - SET(QT_PLUGINS_DIR ${qt_plugins_dir} CACHE PATH "The location of the Qt plugins" FORCE) + _qt4_query_qmake(QT_INSTALL_PLUGINS qt_plugins_dir) + SET(QT_PLUGINS_DIR NOTFOUND) + foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH}) + set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/plugins") + endforeach(qt_cross_path) + FIND_PATH(QT_PLUGINS_DIR NAMES accessible imageformats sqldrivers codecs designer + HINTS ${qt_cross_paths} ${qt_plugins_dir} + DOC "The location of the Qt plugins") ENDIF (QT_LIBRARY_DIR AND NOT QT_PLUGINS_DIR OR QT_QMAKE_CHANGED) # ask qmake for the translations directory IF (QT_LIBRARY_DIR AND NOT QT_TRANSLATIONS_DIR OR QT_QMAKE_CHANGED) - EXEC_PROGRAM( ${QT_QMAKE_EXECUTABLE} - ARGS "-query QT_INSTALL_TRANSLATIONS" - OUTPUT_VARIABLE qt_translations_dir ) - # make sure we have / and not \ as qmake gives on windows - FILE(TO_CMAKE_PATH "${qt_translations_dir}" qt_translations_dir) + _qt4_query_qmake(QT_INSTALL_TRANSLATIONS qt_translations_dir) SET(QT_TRANSLATIONS_DIR ${qt_translations_dir} CACHE PATH "The location of the Qt translations" FORCE) ENDIF (QT_LIBRARY_DIR AND NOT QT_TRANSLATIONS_DIR OR QT_QMAKE_CHANGED) + # ask qmake for the imports directory + IF (QT_LIBRARY_DIR AND NOT QT_IMPORTS_DIR OR QT_QMAKE_CHANGED) + _qt4_query_qmake(QT_INSTALL_IMPORTS qt_imports_dir) + if(qt_imports_dir) + SET(QT_IMPORTS_DIR NOTFOUND) + foreach(qt_cross_path ${CMAKE_FIND_ROOT_PATH}) + set(qt_cross_paths ${qt_cross_paths} "${qt_cross_path}/imports") + endforeach(qt_cross_path) + FIND_PATH(QT_IMPORTS_DIR NAMES Qt + HINTS ${qt_cross_paths} ${qt_imports_dir} + DOC "The location of the Qt imports" + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + mark_as_advanced(QT_IMPORTS_DIR) + endif(qt_imports_dir) + ENDIF (QT_LIBRARY_DIR AND NOT QT_IMPORTS_DIR OR QT_QMAKE_CHANGED) + # Make variables changeble to the advanced user MARK_AS_ADVANCED( QT_LIBRARY_DIR QT_DOC_DIR QT_MKSPECS_DIR QT_PLUGINS_DIR QT_TRANSLATIONS_DIR) + + ############################################# # # Find out what window system we're using @@ -577,11 +753,7 @@ IF (QT4_QMAKE_FOUND) SET(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) SET(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) # Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES - SET(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_HEADERS_DIR}") - # On Mac OS X when Qt has framework support, also add the framework path - IF( QT_USE_FRAMEWORKS ) - SET(CMAKE_REQUIRED_FLAGS "-F${QT_LIBRARY_DIR} ") - ENDIF( QT_USE_FRAMEWORKS ) + 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) @@ -615,7 +787,7 @@ IF (QT4_QMAKE_FOUND) # ######################################## - SET(QT_MODULES QtCore QtGui Qt3Support QtSvg QtScript QtTest QtUiTools + SET(QT_MODULES QtGui Qt3Support QtSvg QtScript QtTest QtUiTools QtHelp QtWebKit QtXmlPatterns phonon QtNetwork QtMultimedia QtNsPlugin QtOpenGL QtSql QtXml QtDesigner QtDBus QtScriptTools QtDeclarative) @@ -648,10 +820,10 @@ IF (QT4_QMAKE_FOUND) SET(QT_QAXSERVER_INCLUDE_DIR NOTFOUND) SET(QT_QAXSERVER_LIBRARY_RELEASE NOTFOUND) SET(QT_QAXSERVER_LIBRARY_DEBUG NOTFOUND) - IF(WIN32) + IF(Q_WS_WIN) SET(QT_QTMAIN_LIBRARY_DEBUG NOTFOUND) SET(QT_QTMAIN_LIBRARY_RELEASE NOTFOUND) - ENDIF(WIN32) + ENDIF(Q_WS_WIN) ENDIF(QT_QMAKE_CHANGED) FOREACH(QT_MODULE ${QT_MODULES}) @@ -674,20 +846,18 @@ IF (QT4_QMAKE_FOUND) ENDIF(${QT_MODULE} STREQUAL "phonon") ENDFOREACH(QT_MODULE) - IF(WIN32) + IF(Q_WS_WIN) SET(QT_MODULES ${QT_MODULES} QAxContainer QAxServer) # Set QT_AXCONTAINER_INCLUDE_DIR and QT_AXSERVER_INCLUDE_DIR FIND_PATH(QT_QAXCONTAINER_INCLUDE_DIR ActiveQt - PATHS - ${QT_HEADERS_DIR}/ActiveQt + PATHS ${QT_HEADERS_DIR}/ActiveQt NO_DEFAULT_PATH ) FIND_PATH(QT_QAXSERVER_INCLUDE_DIR ActiveQt - PATHS - ${QT_HEADERS_DIR}/ActiveQt + PATHS ${QT_HEADERS_DIR}/ActiveQt NO_DEFAULT_PATH ) - ENDIF(WIN32) + ENDIF(Q_WS_WIN) # Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR FIND_PATH(QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR QDesignerComponents @@ -713,49 +883,6 @@ IF (QT4_QMAKE_FOUND) NO_DEFAULT_PATH ) - # Set QT_INCLUDE_DIR by removine "/QtCore" in the string ${QT_QTCORE_INCLUDE_DIR} - IF( QT_QTCORE_INCLUDE_DIR ) - IF (QT_USE_FRAMEWORKS) - SET(QT_INCLUDE_DIR ${QT_HEADERS_DIR}) - ELSE (QT_USE_FRAMEWORKS) - STRING( REGEX REPLACE "/QtCore$" "" qt4_include_dir ${QT_QTCORE_INCLUDE_DIR}) - SET( QT_INCLUDE_DIR ${qt4_include_dir}) - ENDIF (QT_USE_FRAMEWORKS) - ENDIF( QT_QTCORE_INCLUDE_DIR ) - - IF( NOT QT_INCLUDE_DIR) - IF(Qt4_FIND_REQUIRED) - MESSAGE( FATAL_ERROR "Could NOT find QtCore header") - ENDIF(Qt4_FIND_REQUIRED) - ENDIF( NOT QT_INCLUDE_DIR) - - # Make variables changeble to the advanced user - MARK_AS_ADVANCED( QT_INCLUDE_DIR ) - - # Set QT_INCLUDES - SET( QT_INCLUDES ${QT_MKSPECS_DIR}/default ${QT_INCLUDE_DIR} ) - - - - - - ####################################### - # - # Qt configuration - # - ####################################### - IF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") - FILE(READ ${QT_MKSPECS_DIR}/qconfig.pri _qconfig_FILE_contents) - STRING(REGEX MATCH "QT_CONFIG[^\n]+" QT_QCONFIG "${_qconfig_FILE_contents}") - STRING(REGEX MATCH "CONFIG[^\n]+" QT_CONFIG "${_qconfig_FILE_contents}") - STRING(REGEX MATCH "EDITION[^\n]+" QT_EDITION "${_qconfig_FILE_contents}") - STRING(REGEX MATCH "QT_LIBINFIX[^\n]+" _qconfig_qt_libinfix "${_qconfig_FILE_contents}") - STRING(REGEX REPLACE "QT_LIBINFIX *= *([^\n]*)" "\\1" QT_LIBINFIX "${_qconfig_qt_libinfix}") - ENDIF(EXISTS "${QT_MKSPECS_DIR}/qconfig.pri") - IF("${QT_EDITION}" MATCHES "DesktopLight") - SET(QT_EDITION_DESKTOPLIGHT 1) - ENDIF("${QT_EDITION}" MATCHES "DesktopLight") - ######################################## # # Setting the LIBRARY-Variables @@ -780,48 +907,32 @@ IF (QT4_QMAKE_FOUND) 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) - IF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE ) - - # try dropping a hint if trying to use Visual Studio with Qt built by mingw - IF(QT_LIBRARY_DIR AND MSVC) - IF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a) - MESSAGE( FATAL_ERROR "It appears you're trying to use Visual Studio with Qt built by mingw") - ENDIF(EXISTS ${QT_LIBRARY_DIR}/libqtmain.a) - ENDIF(QT_LIBRARY_DIR AND MSVC) - - IF(Qt4_FIND_REQUIRED) - MESSAGE( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.") - ENDIF(Qt4_FIND_REQUIRED) - ENDIF( NOT QT_QTCORE_LIBRARY_DEBUG AND NOT QT_QTCORE_LIBRARY_RELEASE ) - # Set QT_QTDESIGNERCOMPONENTS_LIBRARY - FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents${QT_LIBINFIX} QtDesignerComponents${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_RELEASE NAMES QtDesignerComponents${QT_LIBINFIX} QtDesignerComponents${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) FIND_LIBRARY(QT_QTDESIGNERCOMPONENTS_LIBRARY_DEBUG NAMES QtDesignerComponents${QT_LIBINFIX}_debug QtDesignerComponents${QT_LIBINFIX}d QtDesignerComponents${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTMAIN_LIBRARY - IF(WIN32) - FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR} - NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmain${QT_LIBINFIX}d PATHS ${QT_LIBRARY_DIR} - NO_DEFAULT_PATH) - ENDIF(WIN32) + IF(Q_WS_WIN) + FIND_LIBRARY(QT_QTMAIN_LIBRARY_RELEASE NAMES qtmain${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTMAIN_LIBRARY_DEBUG NAMES qtmain${QT_LIBINFIX}d PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + ENDIF(Q_WS_WIN) # Set QT_QTASSISTANTCLIENT_LIBRARY - FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTASSISTANTCLIENT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTASSISTANT_LIBRARY - FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 QtAssistant${QT_LIBINFIX} QtAssistant${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_RELEASE NAMES QtAssistantClient${QT_LIBINFIX} QtAssistantClient${QT_LIBINFIX}4 QtAssistant${QT_LIBINFIX} QtAssistant${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) FIND_LIBRARY(QT_QTASSISTANT_LIBRARY_DEBUG NAMES QtAssistantClient${QT_LIBINFIX}_debug QtAssistantClient${QT_LIBINFIX}d QtAssistantClient${QT_LIBINFIX}d4 QtAssistant${QT_LIBINFIX}_debug QtAssistant${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) # Set QT_QTHELP_LIBRARY - FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} QtCLucene${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) + FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} QtCLucene${QT_LIBINFIX}4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_DEBUG NAMES QtCLucene${QT_LIBINFIX}_debug QtCLucene${QT_LIBINFIX}d QtCLucene${QT_LIBINFIX}d4 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - # QtCLucene not with other frameworks with binary installation (in /usr/lib) IF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE) FIND_LIBRARY(QT_QTCLUCENE_LIBRARY_RELEASE NAMES QtCLucene${QT_LIBINFIX} PATHS ${QT_LIBRARY_DIR}) ENDIF(Q_WS_MAC AND QT_QTCORE_LIBRARY_RELEASE AND NOT QT_QTCLUCENE_LIBRARY_RELEASE) + ############################################ # # Check the existence of the libraries. @@ -835,137 +946,23 @@ IF (QT4_QMAKE_FOUND) ENDIF(QT_USE_FRAMEWORKS) - MACRO (_QT4_ADJUST_LIB_VARS _camelCaseBasename) - - STRING(TOUPPER "${_camelCaseBasename}" basename) - - # The name of the imported targets, i.e. the prefix "Qt4::" must not change, - # since it is stored in EXPORT-files as name of a required library. If the name would change - # here, this would lead to the imported Qt4-library targets not being resolved by cmake anymore. - IF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) - - IF(NOT TARGET Qt4::${_camelCaseBasename}) - ADD_LIBRARY(Qt4::${_camelCaseBasename} UNKNOWN IMPORTED ) - - IF (QT_${basename}_LIBRARY_RELEASE) - SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) - SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_RELEASE "${QT_${basename}_LIBRARY_RELEASE}" ) - ENDIF (QT_${basename}_LIBRARY_RELEASE) - - IF (QT_${basename}_LIBRARY_DEBUG) - SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) - SET_PROPERTY(TARGET Qt4::${_camelCaseBasename} PROPERTY IMPORTED_LOCATION_DEBUG "${QT_${basename}_LIBRARY_DEBUG}" ) - ENDIF (QT_${basename}_LIBRARY_DEBUG) - ENDIF(NOT TARGET Qt4::${_camelCaseBasename}) - - # If QT_USE_IMPORTED_TARGETS is enabled, the QT_QTFOO_LIBRARY variables are set to point at these - # imported targets. This works better in general, and is also in almost all cases fully - # backward compatible. The only issue is when a project A which had this enabled then exports its - # libraries via export or EXPORT_LIBRARY_DEPENDENCIES(). In this case the libraries from project - # A will depend on the imported Qt targets, and the names of these imported targets will be stored - # in the dependency files on disk. This means when a project B then uses project A, these imported - # targets must be created again, otherwise e.g. "Qt4__QtCore" will be interpreted as name of a - # library file on disk, and not as a target, and linking will fail: - IF(QT_USE_IMPORTED_TARGETS) - SET(QT_${basename}_LIBRARY Qt4::${_camelCaseBasename} ) - SET(QT_${basename}_LIBRARIES Qt4::${_camelCaseBasename} ) - ELSE(QT_USE_IMPORTED_TARGETS) - - # if the release- as well as the debug-version of the library have been found: - IF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) - # if the generator supports configuration types then set - # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value - IF (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - SET(QT_${basename}_LIBRARY optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) - ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - # if there are no configuration types and CMAKE_BUILD_TYPE has no value - # then just use the release libraries - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE} ) - ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) - SET(QT_${basename}_LIBRARIES optimized ${QT_${basename}_LIBRARY_RELEASE} debug ${QT_${basename}_LIBRARY_DEBUG}) - ENDIF (QT_${basename}_LIBRARY_DEBUG AND QT_${basename}_LIBRARY_RELEASE) - - # if only the release version was found, set the debug variable also to the release version - IF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) - SET(QT_${basename}_LIBRARY_DEBUG ${QT_${basename}_LIBRARY_RELEASE}) - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_RELEASE}) - SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_RELEASE}) - ENDIF (QT_${basename}_LIBRARY_RELEASE AND NOT QT_${basename}_LIBRARY_DEBUG) - - # if only the debug version was found, set the release variable also to the debug version - IF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) - SET(QT_${basename}_LIBRARY_RELEASE ${QT_${basename}_LIBRARY_DEBUG}) - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY_DEBUG}) - SET(QT_${basename}_LIBRARIES ${QT_${basename}_LIBRARY_DEBUG}) - ENDIF (QT_${basename}_LIBRARY_DEBUG AND NOT QT_${basename}_LIBRARY_RELEASE) - - # put the value in the cache: - SET(QT_${basename}_LIBRARY ${QT_${basename}_LIBRARY} CACHE STRING "The Qt ${basename} library" FORCE) - - ENDIF(QT_USE_IMPORTED_TARGETS) - -# message(STATUS "QT_${basename}_LIBRARY: ${QT_${basename}_LIBRARY}") - - SET(QT_${basename}_FOUND 1) - - ENDIF (QT_${basename}_LIBRARY_RELEASE OR QT_${basename}_LIBRARY_DEBUG) - - IF (QT_${basename}_INCLUDE_DIR) - #add the include directory to QT_INCLUDES - SET(QT_INCLUDES "${QT_${basename}_INCLUDE_DIR}" ${QT_INCLUDES}) - ENDIF (QT_${basename}_INCLUDE_DIR) - - # Make variables changeble to the advanced user - MARK_AS_ADVANCED(QT_${basename}_LIBRARY QT_${basename}_LIBRARY_RELEASE QT_${basename}_LIBRARY_DEBUG QT_${basename}_INCLUDE_DIR) - ENDMACRO (_QT4_ADJUST_LIB_VARS) - - # Set QT_xyz_LIBRARY variable and add # library include path to QT_INCLUDES - _QT4_ADJUST_LIB_VARS(QtCore) - _QT4_ADJUST_LIB_VARS(QtGui) - _QT4_ADJUST_LIB_VARS(Qt3Support) + FOREACH(QT_MODULE ${QT_MODULES}) + _QT4_ADJUST_LIB_VARS(${QT_MODULE}) + ENDFOREACH(QT_MODULE) + _QT4_ADJUST_LIB_VARS(QtAssistant) _QT4_ADJUST_LIB_VARS(QtAssistantClient) _QT4_ADJUST_LIB_VARS(QtCLucene) - _QT4_ADJUST_LIB_VARS(QtDBus) - _QT4_ADJUST_LIB_VARS(QtDeclarative) - _QT4_ADJUST_LIB_VARS(QtDesigner) _QT4_ADJUST_LIB_VARS(QtDesignerComponents) - _QT4_ADJUST_LIB_VARS(QtHelp) - _QT4_ADJUST_LIB_VARS(QtMultimedia) - _QT4_ADJUST_LIB_VARS(QtNetwork) - _QT4_ADJUST_LIB_VARS(QtNsPlugin) - _QT4_ADJUST_LIB_VARS(QtOpenGL) - _QT4_ADJUST_LIB_VARS(QtScript) - _QT4_ADJUST_LIB_VARS(QtScriptTools) - _QT4_ADJUST_LIB_VARS(QtSql) - _QT4_ADJUST_LIB_VARS(QtSvg) - _QT4_ADJUST_LIB_VARS(QtTest) - _QT4_ADJUST_LIB_VARS(QtUiTools) - _QT4_ADJUST_LIB_VARS(QtWebKit) - _QT4_ADJUST_LIB_VARS(QtXml) - _QT4_ADJUST_LIB_VARS(QtXmlPatterns) - _QT4_ADJUST_LIB_VARS(phonon) # platform dependent libraries - IF(Q_WS_X11) - _QT4_ADJUST_LIB_VARS(QtMotif) - ENDIF(Q_WS_X11) - IF(WIN32) + IF(Q_WS_WIN) _QT4_ADJUST_LIB_VARS(qtmain) _QT4_ADJUST_LIB_VARS(QAxServer) _QT4_ADJUST_LIB_VARS(QAxContainer) - ENDIF(WIN32) - - # If Qt is installed as a framework, we need to add QT_QTCORE_LIBRARY here (which - # is the framework directory in that case), since this will make the cmake include_directories() - # command recognize that we need the framework flag with the respective directory (-F) - IF(QT_USE_FRAMEWORKS) - SET(QT_INCLUDES ${QT_INCLUDES} ${QT_QTCORE_LIBRARY} ) - SET(QT_INCLUDE_DIR ${QT_INCLUDE_DIR} ${QT_QTCORE_LIBRARY} ) - ENDIF(QT_USE_FRAMEWORKS) - + ENDIF(Q_WS_WIN) ####################################### diff --git a/Modules/FindQuickTime.cmake b/Modules/FindQuickTime.cmake index f69354391..3638e77ac 100644 --- a/Modules/FindQuickTime.cmake +++ b/Modules/FindQuickTime.cmake @@ -19,7 +19,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # QuickTime on OS X looks different than QuickTime for Windows, @@ -43,5 +43,5 @@ ENDIF(APPLE) # handle the QUIETLY and REQUIRED arguments and set QUICKTIME_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(QuickTime DEFAULT_MSG QUICKTIME_LIBRARY QUICKTIME_INCLUDE_DIR) diff --git a/Modules/FindRTI.cmake b/Modules/FindRTI.cmake index aa4d5f6f1..9a01cde5e 100644 --- a/Modules/FindRTI.cmake +++ b/Modules/FindRTI.cmake @@ -26,7 +26,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(RTI_MESSAGE_QUIETLY QUIET TYPE MSG) @@ -95,7 +95,7 @@ ENDIF (RTI_INCLUDE_DIR) # Set the modified system variables back to the original value. SET(CMAKE_FIND_LIBRARY_PREFIXES "${RTI_OLD_FIND_LIBRARY_PREFIXES}") -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(RTI DEFAULT_MSG RTI_LIBRARY RTI_INCLUDE_DIR) diff --git a/Modules/FindRuby.cmake b/Modules/FindRuby.cmake index 45e2da61a..c54d5a168 100644 --- a/Modules/FindRuby.cmake +++ b/Modules/FindRuby.cmake @@ -1,7 +1,10 @@ # - Find Ruby # This module finds if Ruby is installed and determines where the include files -# and libraries are. Ruby 1.8 and 1.9 are supported. The minimum required version -# specified in the find_package() command is honored. +# and libraries are. Ruby 1.8 and 1.9 are supported. +# +# The minimum required version of Ruby can be specified using the +# standard syntax, e.g. FIND_PACKAGE(Ruby 1.8) +# # It also determines what the name of the library is. This # code sets the following variables: # @@ -24,7 +27,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # RUBY_ARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"archdir"@:>@)'` @@ -154,22 +157,6 @@ SET(_RUBY_VERSION_SHORT "${RUBY_VERSION_MAJOR}.${RUBY_VERSION_MINOR}") SET(_RUBY_VERSION_SHORT_NODOT "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}") SET(_RUBY_NODOT_VERSION "${RUBY_VERSION_MAJOR}${RUBY_VERSION_MINOR}${RUBY_VERSION_PATCH}") -# Now we know which version we found -IF(Ruby_FIND_VERSION) - IF(${RUBY_VERSION} VERSION_LESS ${Ruby_FIND_VERSION}) - # force running ruby the next time again - SET(RUBY_VERSION_MAJOR "" CACHE PATH "The Ruby major version" FORCE) - IF(Ruby_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Ruby version ${Ruby_FIND_VERSION} required, but only version ${RUBY_VERSION} found.") - ELSE(Ruby_FIND_REQUIRED) - IF(NOT Ruby_FIND_QUIETLY) - MESSAGE(STATUS "Ruby version ${Ruby_FIND_VERSION} required, but only version ${RUBY_VERSION} found.") - ENDIF(NOT Ruby_FIND_QUIETLY) - RETURN() - ENDIF(Ruby_FIND_REQUIRED) - ENDIF(${RUBY_VERSION} VERSION_LESS ${Ruby_FIND_VERSION}) -ENDIF(Ruby_FIND_VERSION) - FIND_PATH(RUBY_INCLUDE_DIR NAMES ruby.h HINTS @@ -222,7 +209,7 @@ ENDIF(WIN32) FIND_LIBRARY(RUBY_LIBRARY NAMES ${_RUBY_POSSIBLE_LIB_NAMES} HINTS ${RUBY_POSSIBLE_LIB_DIR} ) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") SET(_RUBY_REQUIRED_VARS RUBY_EXECUTABLE RUBY_INCLUDE_DIR RUBY_LIBRARY) IF(_RUBY_VERSION_SHORT_NODOT GREATER 18) LIST(APPEND _RUBY_REQUIRED_VARS RUBY_CONFIG_INCLUDE_DIR) @@ -240,7 +227,8 @@ IF(_RUBY_DEBUG_OUTPUT) MESSAGE(STATUS "--------------------") ENDIF(_RUBY_DEBUG_OUTPUT) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ruby DEFAULT_MSG ${_RUBY_REQUIRED_VARS}) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ruby REQUIRED_VARS ${_RUBY_REQUIRED_VARS} + VERSION_VAR RUBY_VERSION ) MARK_AS_ADVANCED( RUBY_EXECUTABLE diff --git a/Modules/FindSDL.cmake b/Modules/FindSDL.cmake index cc0711603..0dc02f5b6 100644 --- a/Modules/FindSDL.cmake +++ b/Modules/FindSDL.cmake @@ -62,7 +62,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(SDL_INCLUDE_DIR SDL.h diff --git a/Modules/FindSDL_image.cmake b/Modules/FindSDL_image.cmake index c853971e2..5a5f59ba8 100644 --- a/Modules/FindSDL_image.cmake +++ b/Modules/FindSDL_image.cmake @@ -22,7 +22,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(SDLIMAGE_INCLUDE_DIR SDL_image.h diff --git a/Modules/FindSDL_mixer.cmake b/Modules/FindSDL_mixer.cmake index a5e213f3c..e2b2294c4 100644 --- a/Modules/FindSDL_mixer.cmake +++ b/Modules/FindSDL_mixer.cmake @@ -22,7 +22,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(SDLMIXER_INCLUDE_DIR SDL_mixer.h diff --git a/Modules/FindSDL_net.cmake b/Modules/FindSDL_net.cmake index 169c8a547..730b129f0 100644 --- a/Modules/FindSDL_net.cmake +++ b/Modules/FindSDL_net.cmake @@ -22,7 +22,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(SDLNET_INCLUDE_DIR SDL_net.h diff --git a/Modules/FindSDL_sound.cmake b/Modules/FindSDL_sound.cmake index 20d8f4ff3..959f3ebe5 100644 --- a/Modules/FindSDL_sound.cmake +++ b/Modules/FindSDL_sound.cmake @@ -66,7 +66,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) SET(SDL_SOUND_EXTRAS "" CACHE STRING "SDL_sound extra flags") diff --git a/Modules/FindSDL_ttf.cmake b/Modules/FindSDL_ttf.cmake index 213b83584..b36ddd3b9 100644 --- a/Modules/FindSDL_ttf.cmake +++ b/Modules/FindSDL_ttf.cmake @@ -22,7 +22,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(SDLTTF_INCLUDE_DIR SDL_ttf.h diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake index 05c09b453..028fef5ab 100644 --- a/Modules/FindSWIG.cmake +++ b/Modules/FindSWIG.cmake @@ -5,7 +5,10 @@ # SWIG_EXECUTABLE - the path to the swig executable # SWIG_VERSION - the version number of the swig executable # -# All informations are collected from the SWIG_EXECUTABLE so the +# The minimum required version of SWIG can be specified using the +# standard syntax, e.g. FIND_PACKAGE(SWIG 1.1) +# +# All information is collected from the SWIG_EXECUTABLE so the # version to be found can be changed from the command line by # means of setting SWIG_EXECUTABLE # @@ -20,11 +23,9 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -SET(SWIG_FOUND FALSE) - FIND_PROGRAM(SWIG_EXECUTABLE swig) IF(SWIG_EXECUTABLE) @@ -45,7 +46,6 @@ IF(SWIG_EXECUTABLE) SET(SWIG_DIR SWIG_DIR-NOTFOUND) FIND_PATH(SWIG_DIR swig.swg PATHS ${SWIG_swiglib_output}) IF(SWIG_DIR) - SET(SWIG_FOUND 1) SET(SWIG_USE_FILE ${CMAKE_ROOT}/Modules/UseSWIG.cmake) EXECUTE_PROCESS(COMMAND ${SWIG_EXECUTABLE} -version OUTPUT_VARIABLE SWIG_version_output @@ -62,12 +62,6 @@ IF(SWIG_EXECUTABLE) ENDIF(SWIG_swiglib_result) ENDIF(SWIG_EXECUTABLE) -IF(NOT SWIG_FOUND) - IF(NOT SWIG_FIND_QUIETLY) - IF(SWIG_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "SWIG was not found. Please specify Swig executable location") - ELSE(SWIG_FIND_REQUIRED) - MESSAGE(STATUS "SWIG was not found. Please specify Swig executable location") - ENDIF(SWIG_FIND_REQUIRED) - ENDIF(NOT SWIG_FIND_QUIETLY) -ENDIF(NOT SWIG_FOUND) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SWIG REQUIRED_VARS SWIG_EXECUTABLE SWIG_DIR + VERSION_VAR SWIG_VERSION ) diff --git a/Modules/FindSelfPackers.cmake b/Modules/FindSelfPackers.cmake index 9fab6b9dc..ffca84200 100644 --- a/Modules/FindSelfPackers.cmake +++ b/Modules/FindSelfPackers.cmake @@ -15,7 +15,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(FindCygwin) diff --git a/Modules/FindSquish.cmake b/Modules/FindSquish.cmake index 2327186d8..b0b6b2f47 100644 --- a/Modules/FindSquish.cmake +++ b/Modules/FindSquish.cmake @@ -4,9 +4,6 @@ # # ---- Variables and Macros # SQUISH_FOUND If false, don't try to use Squish -# SQUISH_VERSION_MAJOR The major version of Squish found -# SQUISH_VERSION_MINOR The minor version of Squish found -# SQUISH_VERSION_PATCH The patch version of Squish found # # SQUISH_INSTALL_DIR The Squish installation directory (containing bin, lib, etc) # SQUISH_SERVER_EXECUTABLE The squishserver executable @@ -36,7 +33,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) SET(SQUISH_INSTALL_DIR_STRING "Directory containing the bin, doc, and lib directories for Squish; this should be the root of the installation directory.") diff --git a/Modules/FindSubversion.cmake b/Modules/FindSubversion.cmake index 58a179d04..11f66b05e 100644 --- a/Modules/FindSubversion.cmake +++ b/Modules/FindSubversion.cmake @@ -3,26 +3,35 @@ # Subversion_SVN_EXECUTABLE - path to svn command line client # Subversion_VERSION_SVN - version of svn command line client # Subversion_FOUND - true if the command line client was found -# If the command line client executable is found the macro +# SUBVERSION_FOUND - same as Subversion_FOUND, set for compatiblity reasons +# +# The minimum required version of Subversion can be specified using the +# standard syntax, e.g. FIND_PACKAGE(Subversion 1.4) +# +# If the command line client executable is found two macros are defined: # Subversion_WC_INFO( ) -# is defined to extract information of a subversion working copy at -# a given location. The macro defines the following variables: +# Subversion_WC_LOG( ) +# Subversion_WC_INFO extracts information of a subversion working copy at +# a given location. This macro defines the following variables: # _WC_URL - url of the repository (at ) # _WC_ROOT - root url of the repository # _WC_REVISION - current revision # _WC_LAST_CHANGED_AUTHOR - author of last commit # _WC_LAST_CHANGED_DATE - date of last commit # _WC_LAST_CHANGED_REV - revision of last commit -# _WC_LAST_CHANGED_LOG - last log of base revision # _WC_INFO - output of command `svn info ' +# Subversion_WC_LOG retrieves the log message of the base revision of a +# subversion working copy at a given location. This macro defines the +# variable: +# _LAST_CHANGED_LOG - last log of base revision # Example usage: # FIND_PACKAGE(Subversion) -# IF(Subversion_FOUND) +# IF(SUBVERSION_FOUND) # Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project) # MESSAGE("Current revision is ${Project_WC_REVISION}") # Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project) # MESSAGE("Last changed log is ${Project_LAST_CHANGED_LOG}") -# ENDIF(Subversion_FOUND) +# ENDIF(SUBVERSION_FOUND) #============================================================================= # Copyright 2006-2009 Kitware, Inc. @@ -35,19 +44,28 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -SET(Subversion_FOUND FALSE) -SET(Subversion_SVN_FOUND FALSE) - FIND_PROGRAM(Subversion_SVN_EXECUTABLE svn DOC "subversion command line client") MARK_AS_ADVANCED(Subversion_SVN_EXECUTABLE) IF(Subversion_SVN_EXECUTABLE) - SET(Subversion_SVN_FOUND TRUE) - SET(Subversion_FOUND TRUE) + # the subversion commands should be executed with the C locale, otherwise + # the message (which are parsed) may be translated, Alex + SET(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}") + SET(ENV{LC_ALL} C) + + EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} --version + OUTPUT_VARIABLE Subversion_VERSION_SVN + OUTPUT_STRIP_TRAILING_WHITESPACE) + + # restore the previous LC_ALL + SET(ENV{LC_ALL} ${_Subversion_SAVED_LC_ALL}) + + STRING(REGEX REPLACE "^(.*\n)?svn, version ([.0-9]+).*" + "\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}") MACRO(Subversion_WC_INFO dir prefix) # the subversion commands should be executed with the C locale, otherwise @@ -55,11 +73,6 @@ IF(Subversion_SVN_EXECUTABLE) SET(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}") SET(ENV{LC_ALL} C) - EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} --version - WORKING_DIRECTORY ${dir} - OUTPUT_VARIABLE Subversion_VERSION_SVN - OUTPUT_STRIP_TRAILING_WHITESPACE) - EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} info ${dir} OUTPUT_VARIABLE ${prefix}_WC_INFO ERROR_VARIABLE Subversion_svn_info_error @@ -70,10 +83,10 @@ IF(Subversion_SVN_EXECUTABLE) MESSAGE(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${Subversion_svn_info_error}") ELSE(NOT ${Subversion_svn_info_result} EQUAL 0) - STRING(REGEX REPLACE "^(.*\n)?svn, version ([.0-9]+).*" - "\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}") STRING(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*" "\\2" ${prefix}_WC_URL "${${prefix}_WC_INFO}") + STRING(REGEX REPLACE "^(.*\n)?Repository Root: ([^\n]+).*" + "\\2" ${prefix}_WC_ROOT "${${prefix}_WC_INFO}") STRING(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*" "\\2" ${prefix}_WC_REVISION "${${prefix}_WC_INFO}") STRING(REGEX REPLACE "^(.*\n)?Last Changed Author: ([^\n]+).*" @@ -109,5 +122,10 @@ IF(Subversion_SVN_EXECUTABLE) ENDIF(Subversion_SVN_EXECUTABLE) -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Subversion DEFAULT_MSG Subversion_SVN_EXECUTABLE) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Subversion REQUIRED_VARS Subversion_SVN_EXECUTABLE + VERSION_VAR Subversion_VERSION_SVN ) + +# for compatibility +SET(Subversion_FOUND ${SUBVERSION_FOUND}) +SET(Subversion_SVN_FOUND ${SUBVERSION_FOUND}) diff --git a/Modules/FindTCL.cmake b/Modules/FindTCL.cmake index 67a3f9a31..8d780c14a 100644 --- a/Modules/FindTCL.cmake +++ b/Modules/FindTCL.cmake @@ -41,7 +41,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(CMakeFindFrameworks) @@ -197,7 +197,7 @@ FIND_PATH(TK_INCLUDE_PATH # handle the QUIETLY and REQUIRED arguments and set TCL_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(TCL DEFAULT_MSG TCL_LIBRARY TCL_INCLUDE_PATH) SET(TCLTK_FIND_REQUIRED ${TCL_FIND_REQUIRED}) diff --git a/Modules/FindTIFF.cmake b/Modules/FindTIFF.cmake index 87116347d..a5a4d243c 100644 --- a/Modules/FindTIFF.cmake +++ b/Modules/FindTIFF.cmake @@ -17,17 +17,17 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(TIFF_INCLUDE_DIR tiff.h) -SET(TIFF_NAMES ${TIFF_NAMES} tiff libtiff libtiff3) +SET(TIFF_NAMES ${TIFF_NAMES} tiff libtiff tiff3 libtiff3) FIND_LIBRARY(TIFF_LIBRARY NAMES ${TIFF_NAMES} ) # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(TIFF DEFAULT_MSG TIFF_LIBRARY TIFF_INCLUDE_DIR) IF(TIFF_FOUND) diff --git a/Modules/FindTclStub.cmake b/Modules/FindTclStub.cmake index 896d4b13c..4db2716de 100644 --- a/Modules/FindTclStub.cmake +++ b/Modules/FindTclStub.cmake @@ -31,7 +31,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(FindTCL) diff --git a/Modules/FindTclsh.cmake b/Modules/FindTclsh.cmake index 9b7529b8a..390a68e98 100644 --- a/Modules/FindTclsh.cmake +++ b/Modules/FindTclsh.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF(CYGWIN) @@ -84,7 +84,7 @@ FIND_PROGRAM(TCL_TCLSH # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Tclsh DEFAULT_MSG TCL_TCLSH) MARK_AS_ADVANCED(TCL_TCLSH) diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index 2a74304c3..488bbd5ad 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -6,7 +6,7 @@ # CMAKE_USE_PTHREADS_INIT - are we using pthreads # CMAKE_HP_PTHREADS_INIT - are we using hp pthreads # For systems with multiple thread libraries, caller can set -# CMAKE_THREAD_PREFER_PTHREADS +# CMAKE_THREAD_PREFER_PTHREAD #============================================================================= # Copyright 2002-2009 Kitware, Inc. @@ -18,7 +18,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE (CheckIncludeFiles) @@ -153,5 +153,5 @@ IF(CMAKE_USE_PTHREADS_INIT) ENDIF() ENDIF(CMAKE_USE_PTHREADS_INIT) -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Threads DEFAULT_MSG Threads_FOUND) diff --git a/Modules/FindUnixCommands.cmake b/Modules/FindUnixCommands.cmake index c1d2c4574..9c0264d22 100644 --- a/Modules/FindUnixCommands.cmake +++ b/Modules/FindUnixCommands.cmake @@ -12,7 +12,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(FindCygwin) diff --git a/Modules/FindVTK.cmake b/Modules/FindVTK.cmake index 69e18742e..6b1772fa4 100644 --- a/Modules/FindVTK.cmake +++ b/Modules/FindVTK.cmake @@ -37,7 +37,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Assume not found. diff --git a/Modules/FindWget.cmake b/Modules/FindWget.cmake index c898b89c9..ef4623f75 100644 --- a/Modules/FindWget.cmake +++ b/Modules/FindWget.cmake @@ -14,7 +14,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(FindCygwin) @@ -26,7 +26,7 @@ FIND_PROGRAM(WGET_EXECUTABLE # handle the QUIETLY and REQUIRED arguments and set WGET_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(Wget DEFAULT_MSG WGET_EXECUTABLE) MARK_AS_ADVANCED( WGET_EXECUTABLE ) diff --git a/Modules/FindWish.cmake b/Modules/FindWish.cmake index c086da5ed..a4960cd17 100644 --- a/Modules/FindWish.cmake +++ b/Modules/FindWish.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF(UNIX) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index f05641302..df4497923 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -46,7 +46,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF (UNIX) diff --git a/Modules/FindXMLRPC.cmake b/Modules/FindXMLRPC.cmake index 48f87d7a3..eccfb487a 100644 --- a/Modules/FindXMLRPC.cmake +++ b/Modules/FindXMLRPC.cmake @@ -22,7 +22,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # First find the config script from which to obtain other values. diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index b437e6b87..9d4fc0e69 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -1,12 +1,20 @@ # - Find zlib -# Find the native ZLIB includes and library +# Find the native ZLIB includes and library. +# Once done this will define # # ZLIB_INCLUDE_DIRS - where to find zlib.h, etc. # ZLIB_LIBRARIES - List of libraries when using zlib. # ZLIB_FOUND - True if zlib found. # # ZLIB_VERSION_STRING - The version of zlib found (x.y.z) -# ZLIB_MAJOR_VERSION - the major version of zlib +# ZLIB_VERSION_MAJOR - The major version of zlib +# ZLIB_VERSION_MINOR - The minor version of zlib +# ZLIB_VERSION_PATCH - The patch version of zlib +# ZLIB_VERSION_TWEAK - The tweak version of zlib +# +# The following variable are provided for backward compatibility +# +# ZLIB_MAJOR_VERSION - The major version of zlib # ZLIB_MINOR_VERSION - The minor version of zlib # ZLIB_PATCH_VERSION - The patch version of zlib @@ -20,7 +28,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PATH(ZLIB_INCLUDE_DIR zlib.h @@ -36,18 +44,34 @@ FIND_LIBRARY(ZLIB_LIBRARY ) MARK_AS_ADVANCED(ZLIB_LIBRARY ZLIB_INCLUDE_DIR) -IF (ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") - FILE(READ "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H) - STRING(REGEX REPLACE ".*#define ZLIB_VERSION \"([0-9]+)\\.([0-9]+)\\.([0-9]+)\".*" "\\1.\\2.\\3" ZLIB_VERSION_STRING "${ZLIB_H}") +IF(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h") + FILE(STRINGS "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H REGEX "^#define ZLIB_VERSION \"[^\"]*\"$") + + STRING(REGEX REPLACE "^.*ZLIB_VERSION \"([0-9]+).*$" "\\1" ZLIB_VERSION_MAJOR "${ZLIB_H}") + STRING(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_MINOR "${ZLIB_H}") + STRING(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_PATCH "${ZLIB_H}") + SET(ZLIB_VERSION_STRING "${ZLIB_VERSION_MAJOR}.${ZLIB_VERSION_MINOR}.${ZLIB_VERSION_PATCH}") + + # only append a TWEAK version if it exists: + SET(ZLIB_VERSION_TWEAK "") + IF( "${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$") + SET(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_1}") + SET(ZLIB_VERSION_STRING "${ZLIB_VERSION_STRING}.${ZLIB_VERSION_TWEAK}") + ENDIF( "${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$") + + SET(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}") + SET(ZLIB_MINOR_VERSION "${ZLIB_VERSION_MINOR}") + SET(ZLIB_PATCH_VERSION "${ZLIB_VERSION_PATCH}") ENDIF() # handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if # all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB DEFAULT_MSG ZLIB_INCLUDE_DIR ZLIB_LIBRARY) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") +FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_INCLUDE_DIR ZLIB_LIBRARY + VERSION_VAR ZLIB_VERSION_STRING) -IF (ZLIB_FOUND) +IF(ZLIB_FOUND) SET(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR}) - SET(ZLIB_LIBRARIES ${ZLIB_LIBRARY}) + SET(ZLIB_LIBRARIES ${ZLIB_LIBRARY}) ENDIF() diff --git a/Modules/Findosg.cmake b/Modules/Findosg.cmake index 00e471129..3c884d4a8 100644 --- a/Modules/Findosg.cmake +++ b/Modules/Findosg.cmake @@ -39,7 +39,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -50,5 +50,5 @@ include(Findosg_functions) OSG_FIND_PATH (OSG osg/PositionAttitudeTransform) OSG_FIND_LIBRARY(OSG osg) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osg DEFAULT_MSG OSG_LIBRARY OSG_INCLUDE_DIR) diff --git a/Modules/FindosgAnimation.cmake b/Modules/FindosgAnimation.cmake index a4bbb44cb..6cfc78421 100644 --- a/Modules/FindosgAnimation.cmake +++ b/Modules/FindosgAnimation.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGANIMATION osgAnimation/Animation) OSG_FIND_LIBRARY(OSGANIMATION osgAnimation) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgAnimation DEFAULT_MSG OSGANIMATION_LIBRARY OSGANIMATION_INCLUDE_DIR) diff --git a/Modules/FindosgDB.cmake b/Modules/FindosgDB.cmake index d0d75b675..1da6cc014 100644 --- a/Modules/FindosgDB.cmake +++ b/Modules/FindosgDB.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGDB osgDB/DatabasePager) OSG_FIND_LIBRARY(OSGDB osgDB) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgDB DEFAULT_MSG OSGDB_LIBRARY OSGDB_INCLUDE_DIR) diff --git a/Modules/FindosgFX.cmake b/Modules/FindosgFX.cmake index cf1a98bcd..dd8d6d83a 100644 --- a/Modules/FindosgFX.cmake +++ b/Modules/FindosgFX.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGFX osgFX/BumpMapping) OSG_FIND_LIBRARY(OSGFX osgFX) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgFX DEFAULT_MSG OSGFX_LIBRARY OSGFX_INCLUDE_DIR) diff --git a/Modules/FindosgGA.cmake b/Modules/FindosgGA.cmake index ca7e55a39..ae96f817d 100644 --- a/Modules/FindosgGA.cmake +++ b/Modules/FindosgGA.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGGA osgGA/FlightManipulator) OSG_FIND_LIBRARY(OSGGA osgGA) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgGA DEFAULT_MSG OSGGA_LIBRARY OSGGA_INCLUDE_DIR) diff --git a/Modules/FindosgIntrospection.cmake b/Modules/FindosgIntrospection.cmake index 3045cd52c..b540cc073 100644 --- a/Modules/FindosgIntrospection.cmake +++ b/Modules/FindosgIntrospection.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGINTROSPECTION osgIntrospection/Reflection) OSG_FIND_LIBRARY(OSGINTROSPECTION osgIntrospection) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgIntrospection DEFAULT_MSG OSGINTROSPECTION_LIBRARY OSGINTROSPECTION_INCLUDE_DIR) diff --git a/Modules/FindosgManipulator.cmake b/Modules/FindosgManipulator.cmake index 6de812efa..b7cc02f72 100644 --- a/Modules/FindosgManipulator.cmake +++ b/Modules/FindosgManipulator.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGMANIPULATOR osgManipulator/TrackballDragger) OSG_FIND_LIBRARY(OSGMANIPULATOR osgManipulator) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgManipulator DEFAULT_MSG OSGMANIPULATOR_LIBRARY OSGMANIPULATOR_INCLUDE_DIR) diff --git a/Modules/FindosgParticle.cmake b/Modules/FindosgParticle.cmake index d693d044e..e204597b2 100644 --- a/Modules/FindosgParticle.cmake +++ b/Modules/FindosgParticle.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGPARTICLE osgParticle/FireEffect) OSG_FIND_LIBRARY(OSGPARTICLE osgParticle) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgParticle DEFAULT_MSG OSGPARTICLE_LIBRARY OSGPARTICLE_INCLUDE_DIR) diff --git a/Modules/FindosgProducer.cmake b/Modules/FindosgProducer.cmake index 2810d86b8..ea6b33a35 100644 --- a/Modules/FindosgProducer.cmake +++ b/Modules/FindosgProducer.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGPRODUCER osgProducer/OsgSceneHandler) OSG_FIND_LIBRARY(OSGPRODUCER osgProducer) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgProducer DEFAULT_MSG OSGPRODUCER_LIBRARY OSGPRODUCER_INCLUDE_DIR) diff --git a/Modules/FindosgShadow.cmake b/Modules/FindosgShadow.cmake index 60f29ff12..e569602cd 100644 --- a/Modules/FindosgShadow.cmake +++ b/Modules/FindosgShadow.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGSHADOW osgShadow/ShadowTexture) OSG_FIND_LIBRARY(OSGSHADOW osgShadow) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgShadow DEFAULT_MSG OSGSHADOW_LIBRARY OSGSHADOW_INCLUDE_DIR) diff --git a/Modules/FindosgSim.cmake b/Modules/FindosgSim.cmake index 8f28d55ae..865cb0b2c 100644 --- a/Modules/FindosgSim.cmake +++ b/Modules/FindosgSim.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGSIM osgSim/ImpostorSprite) OSG_FIND_LIBRARY(OSGSIM osgSim) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgSim DEFAULT_MSG OSGSIM_LIBRARY OSGSIM_INCLUDE_DIR) diff --git a/Modules/FindosgTerrain.cmake b/Modules/FindosgTerrain.cmake index 4fcd4bd63..4dc961d7f 100644 --- a/Modules/FindosgTerrain.cmake +++ b/Modules/FindosgTerrain.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGTERRAIN osgTerrain/Terrain) OSG_FIND_LIBRARY(OSGTERRAIN osgTerrain) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgTerrain DEFAULT_MSG OSGTERRAIN_LIBRARY OSGTERRAIN_INCLUDE_DIR) diff --git a/Modules/FindosgText.cmake b/Modules/FindosgText.cmake index 0c6c60604..ba78755b6 100644 --- a/Modules/FindosgText.cmake +++ b/Modules/FindosgText.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGTEXT osgText/Text) OSG_FIND_LIBRARY(OSGTEXT osgText) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgText DEFAULT_MSG OSGTEXT_LIBRARY OSGTEXT_INCLUDE_DIR) diff --git a/Modules/FindosgUtil.cmake b/Modules/FindosgUtil.cmake index f314d2372..4f93e4318 100644 --- a/Modules/FindosgUtil.cmake +++ b/Modules/FindosgUtil.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGUTIL osgUtil/SceneView) OSG_FIND_LIBRARY(OSGUTIL osgUtil) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgUtil DEFAULT_MSG OSGUTIL_LIBRARY OSGUTIL_INCLUDE_DIR) diff --git a/Modules/FindosgViewer.cmake b/Modules/FindosgViewer.cmake index 35be2f5bd..f434fe4ec 100644 --- a/Modules/FindosgViewer.cmake +++ b/Modules/FindosgViewer.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGVIEWER osgViewer/Viewer) OSG_FIND_LIBRARY(OSGVIEWER osgViewer) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgViewer DEFAULT_MSG OSGVIEWER_LIBRARY OSGVIEWER_INCLUDE_DIR) diff --git a/Modules/FindosgVolume.cmake b/Modules/FindosgVolume.cmake index f89bbddb1..4a46d1e8d 100644 --- a/Modules/FindosgVolume.cmake +++ b/Modules/FindosgVolume.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGVOLUME osgVolume/Volume) OSG_FIND_LIBRARY(OSGVOLUME osgVolume) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgVolume DEFAULT_MSG OSGVOLUME_LIBRARY OSGVOLUME_INCLUDE_DIR) diff --git a/Modules/FindosgWidget.cmake b/Modules/FindosgWidget.cmake index 45ad1a6d4..e722c2d40 100644 --- a/Modules/FindosgWidget.cmake +++ b/Modules/FindosgWidget.cmake @@ -35,7 +35,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Header files are presumed to be included like @@ -46,6 +46,6 @@ include(Findosg_functions) OSG_FIND_PATH (OSGWIDGET osgWidget/Widget) OSG_FIND_LIBRARY(OSGWIDGET osgWidget) -include(FindPackageHandleStandardArgs) +include("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(osgWidget DEFAULT_MSG OSGWIDGET_LIBRARY OSGWIDGET_INCLUDE_DIR) diff --git a/Modules/Findosg_functions.cmake b/Modules/Findosg_functions.cmake index bc6f2de45..ab836ff9f 100644 --- a/Modules/Findosg_functions.cmake +++ b/Modules/Findosg_functions.cmake @@ -14,7 +14,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 85c6568d7..b82ccd07d 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -4,7 +4,7 @@ # modules that you will use, you need to name them as components to # the package: # -# FIND_PACKAGE(wxWidgets COMPONENTS base core ...) +# FIND_PACKAGE(wxWidgets COMPONENTS core base ...) # # There are two search branches: a windows style and a unix style. For # windows, the following variables are searched for and set to @@ -32,7 +32,14 @@ # wxWidgets_USE_UNICODE # wxWidgets_USE_UNIVERSAL # wxWidgets_USE_STATIC -# +# +# There is also a wxWidgets_CONFIG_OPTIONS variable for all other +# options that need to be passed to the wx-config utility. For +# example, to use the base toolkit found in the /usr/local path, set +# the variable (before calling the FIND_PACKAGE command) as such: +# +# SET(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr) +# # The following are set after the configuration is done for both # windows and unix style: # @@ -54,17 +61,18 @@ # wxWidgets_USE_FILE - Convenience include file. # # Sample usage: -# FIND_PACKAGE(wxWidgets COMPONENTS base core gl net) +# # Note that for MinGW users the order of libs is important! +# FIND_PACKAGE(wxWidgets COMPONENTS net gl core base) # IF(wxWidgets_FOUND) # INCLUDE(${wxWidgets_USE_FILE}) -# # and for each of your dependant executable/library targets: +# # and for each of your dependent executable/library targets: # TARGET_LINK_LIBRARIES( ${wxWidgets_LIBRARIES}) # ENDIF(wxWidgets_FOUND) # # If wxWidgets is required (i.e., not an optional part): -# FIND_PACKAGE(wxWidgets REQUIRED base core gl net) +# FIND_PACKAGE(wxWidgets REQUIRED net gl core base) # INCLUDE(${wxWidgets_USE_FILE}) -# # and for each of your dependant executable/library targets: +# # and for each of your dependent executable/library targets: # TARGET_LINK_LIBRARIES( ${wxWidgets_LIBRARIES}) #============================================================================= @@ -78,7 +86,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # @@ -188,7 +196,7 @@ IF(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake") SET(wxWidgets_USE_FILE "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake") ELSE(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake") - SET(wxWidgets_USE_FILE UsewxWidgets.cmake) + SET(wxWidgets_USE_FILE UsewxWidgets) ENDIF(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake") #===================================================================== @@ -213,7 +221,7 @@ IF(wxWidgets_FIND_STYLE STREQUAL "win32") IF(wxWidgets_USE_MONOLITHIC) SET(wxWidgets_FIND_COMPONENTS mono) ELSE(wxWidgets_USE_MONOLITHIC) - SET(wxWidgets_FIND_COMPONENTS base core) # this is default + SET(wxWidgets_FIND_COMPONENTS core base) # this is default ENDIF(wxWidgets_USE_MONOLITHIC) ENDIF(NOT wxWidgets_FIND_COMPONENTS) @@ -252,7 +260,7 @@ IF(wxWidgets_FIND_STYLE STREQUAL "win32") # FIXME: What if both regex libs are available. regex should be # found outside the loop and only wx${LIB}${_UCD}${_DBG}. # Find wxWidgets common libraries. - FOREACH(LIB ${wxWidgets_COMMON_LIBRARIES}) + FOREACH(LIB ${wxWidgets_COMMON_LIBRARIES} scintilla) FIND_LIBRARY(WX_${LIB}${_DBG} NAMES wx${LIB}${_UCD}${_DBG} # for regex @@ -303,7 +311,8 @@ IF(wxWidgets_FIND_STYLE STREQUAL "win32") MARK_AS_ADVANCED(WX_mono${_DBG}) # Find wxWidgets multilib libraries. - FOREACH(LIB core adv aui html media xrc dbgrid gl qa richtext) + FOREACH(LIB core adv aui html media xrc dbgrid gl qa richtext + stc ribbon propgrid) FIND_LIBRARY(WX_${LIB}${_DBG} NAMES wxmsw${_UNV}29${_UCD}${_DBG}_${LIB} @@ -330,7 +339,7 @@ IF(wxWidgets_FIND_STYLE STREQUAL "win32") # Clear all debug or release library paths (arguments are "d" or ""). MACRO(WX_CLEAR_ALL_LIBS _DBG) # Clear wxWidgets common libraries. - FOREACH(LIB ${wxWidgets_COMMON_LIBRARIES}) + FOREACH(LIB ${wxWidgets_COMMON_LIBRARIES} scintilla) WX_CLEAR_LIB(WX_${LIB}${_DBG}) ENDFOREACH(LIB) @@ -344,7 +353,8 @@ IF(wxWidgets_FIND_STYLE STREQUAL "win32") WX_CLEAR_LIB(WX_mono${_DBG}) # Clear wxWidgets multilib libraries. - FOREACH(LIB core adv aui html media xrc dbgrid gl qa richtext) + FOREACH(LIB core adv aui html media xrc dbgrid gl qa richtext + stc ribbon propgrid) WX_CLEAR_LIB(WX_${LIB}${_DBG}) ENDFOREACH(LIB) ENDMACRO(WX_CLEAR_ALL_LIBS) @@ -561,23 +571,23 @@ IF(wxWidgets_FIND_STYLE STREQUAL "win32") # Get configuration parameters from the name. WX_GET_NAME_COMPONENTS(${wxWidgets_CONFIGURATION} UNV UCD DBG) - # Set wxWidgets main include directory. - IF(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h) - SET(wxWidgets_INCLUDE_DIRS ${WX_ROOT_DIR}/include) - ELSE(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h) - DBG_MSG("wxWidgets_FOUND FALSE because WX_ROOT_DIR=${WX_ROOT_DIR} has no ${WX_ROOT_DIR}/include/wx/wx.h") - SET(wxWidgets_FOUND FALSE) - ENDIF(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h) - # Set wxWidgets lib setup include directory. IF(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h) - LIST(APPEND wxWidgets_INCLUDE_DIRS + SET(wxWidgets_INCLUDE_DIRS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}) ELSE(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h) - DBG_MSG("WXWIDGET_FOUND FALSE because ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h does not exists.") + DBG_MSG("wxWidgets_FOUND FALSE because ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h does not exists.") SET(wxWidgets_FOUND FALSE) ENDIF(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h) + # Set wxWidgets main include directory. + IF(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h) + LIST(APPEND wxWidgets_INCLUDE_DIRS ${WX_ROOT_DIR}/include) + ELSE(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h) + DBG_MSG("wxWidgets_FOUND FALSE because WX_ROOT_DIR=${WX_ROOT_DIR} has no ${WX_ROOT_DIR}/include/wx/wx.h") + SET(wxWidgets_FOUND FALSE) + ENDIF(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h) + # Find wxWidgets libraries. WX_FIND_LIBS("${UNV}" "${UCD}" "${DBG}") IF(WX_USE_REL_AND_DBG) @@ -612,7 +622,8 @@ ELSE(wxWidgets_FIND_STYLE STREQUAL "win32") # MACRO(WX_CONFIG_SELECT_GET_DEFAULT) EXECUTE_PROCESS( - COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --selected-config + COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" + ${wxWidgets_CONFIG_OPTIONS} --selected-config OUTPUT_VARIABLE _wx_selected_config RESULT_VARIABLE _wx_result ERROR_QUIET @@ -640,13 +651,15 @@ ELSE(wxWidgets_FIND_STYLE STREQUAL "win32") # MACRO(WX_CONFIG_SELECT_QUERY_BOOL _OPT_NAME _OPT_HELP) EXECUTE_PROCESS( - COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --${_OPT_NAME}=yes + COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" + ${wxWidgets_CONFIG_OPTIONS} --${_OPT_NAME}=yes RESULT_VARIABLE _wx_result_yes OUTPUT_QUIET ERROR_QUIET ) EXECUTE_PROCESS( - COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" --${_OPT_NAME}=no + COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" + ${wxWidgets_CONFIG_OPTIONS} --${_OPT_NAME}=no RESULT_VARIABLE _wx_result_no OUTPUT_QUIET ERROR_QUIET @@ -672,7 +685,7 @@ ELSE(wxWidgets_FIND_STYLE STREQUAL "win32") # among multiple builds. # MACRO(WX_CONFIG_SELECT_SET_OPTIONS) - SET(wxWidgets_SELECT_OPTIONS "") + SET(wxWidgets_SELECT_OPTIONS ${wxWidgets_CONFIG_OPTIONS}) FOREACH(_opt_name debug static unicode universal) STRING(TOUPPER ${_opt_name} _upper_opt_name) IF(DEFINED wxWidgets_USE_${_upper_opt_name}) @@ -814,7 +827,7 @@ DBG_MSG("wxWidgets_USE_FILE : ${wxWidgets_USE_FILE}") #===================================================================== #===================================================================== -INCLUDE(FindPackageHandleStandardArgs) +INCLUDE("${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake") FIND_PACKAGE_HANDLE_STANDARD_ARGS(wxWidgets DEFAULT_MSG wxWidgets_FOUND) # Maintain consistency with all other variables. SET(wxWidgets_FOUND ${WXWIDGETS_FOUND}) diff --git a/Modules/FindwxWindows.cmake b/Modules/FindwxWindows.cmake index 4cb4c9e93..f55cf009f 100644 --- a/Modules/FindwxWindows.cmake +++ b/Modules/FindwxWindows.cmake @@ -58,7 +58,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # ------------------------------------------------------------------ diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake index a7d557136..90ef59be1 100644 --- a/Modules/FortranCInterface.cmake +++ b/Modules/FortranCInterface.cmake @@ -47,9 +47,9 @@ # MACRO_NAMESPACE "FC_" # SYMBOL_NAMESPACE "FC_" # SYMBOLS mysub mymod:my_sub) -# This creates a "FC.h" header that defines the same FC_*() mangling -# macros as the previous example plus preprocessor symbols FC_mysub -# and FC_mymod_my_sub. +# This creates a "FCMangle.h" header that defines the same FC_*() +# mangling macros as the previous example plus preprocessor symbols +# FC_mysub and FC_mymod_my_sub. # # Another function is provided to verify that the Fortran and C/C++ # compilers work together: @@ -91,7 +91,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) #----------------------------------------------------------------------------- diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 24cee55f9..853b1a1b6 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -1,14 +1,16 @@ -# GetPrerequisites.cmake -# -# This script provides functions to list the .dll, .dylib or .so files that an -# executable or shared library file depends on. (Its prerequisites.) +# - Functions to analyze and list executable file prerequisites. +# This module provides functions to list the .dll, .dylib or .so +# files that an executable or shared library file depends on. (Its +# prerequisites.) # # It uses various tools to obtain the list of required shared library files: # dumpbin (Windows) # ldd (Linux/Unix) # otool (Mac OSX) -# -# The following functions are provided by this script: +# The following functions are provided by this module: +# get_prerequisites +# list_prerequisites +# list_prerequisites_by_glob # gp_append_unique # is_file_executable # gp_item_default_embedded_path @@ -18,12 +20,91 @@ # gp_resolved_file_type # (projects can override with gp_resolved_file_type_override) # gp_file_type -# get_prerequisites -# list_prerequisites -# list_prerequisites_by_glob -# # Requires CMake 2.6 or greater because it uses function, break, return and # 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 +# required shared library files. +# +# is the full path to an executable file. is the +# name of a CMake variable to contain the results. must be 0 +# or 1 indicating whether to include or exclude "system" prerequisites. If +# is set to 1 all prerequisites will be found recursively, if set to +# 0 only direct prerequisites are listed. is the path to the top +# level executable used for @executable_path replacment on the Mac. is +# a list of paths where libraries might be found: these paths are searched +# first when a target without any path info is given. Then standard system +# locations are also searched: PATH, Framework locations, /usr/lib... +# +# LIST_PREREQUISITES( [ [ []]]) +# Print a message listing the prerequisites of . +# +# is the name of a shared library or executable target or the full +# path to a shared library or executable file. If is set to 1 all +# prerequisites will be found recursively, if set to 0 only direct +# prerequisites are listed. must be 0 or 1 indicating whether +# to include or exclude "system" prerequisites. With set to 0 only +# the full path names of the prerequisites are printed, set to 1 extra +# informatin will be displayed. +# +# LIST_PREREQUISITES_BY_GLOB( ) +# Print the prerequisites of shared library and executable files matching a +# globbing pattern. is GLOB or GLOB_RECURSE and is a +# globbing expression used with "file(GLOB" or "file(GLOB_RECURSE" to retrieve +# a list of matching files. If a matching file is executable, its prerequisites +# are listed. +# +# Any additional (optional) arguments provided are passed along as the +# optional arguments to the list_prerequisites calls. +# +# GP_APPEND_UNIQUE( ) +# Append to the list variable only if the value is not +# already in the list. +# +# IS_FILE_EXECUTABLE( ) +# Return 1 in if is a binary executable, 0 otherwise. +# +# GP_ITEM_DEFAULT_EMBEDDED_PATH( ) +# Return the path that others should refer to the item by when the item +# is embedded inside a bundle. +# +# Override on a per-project basis by providing a project-specific +# gp_item_default_embedded_path_override function. +# +# GP_RESOLVE_ITEM( ) +# Resolve an item into an existing full path file. +# +# Override on a per-project basis by providing a project-specific +# gp_resolve_item_override function. +# +# GP_RESOLVED_FILE_TYPE( ) +# Return the type of with respect to . String +# describing type of prerequisite is returned in variable named . +# +# Use and if necessary to resolve non-absolute +# values -- but only for non-embedded items. +# +# Possible types are: +# system +# local +# embedded +# other +# Override on a per-project basis by providing a project-specific +# gp_resolved_file_type_override function. +# +# GP_FILE_TYPE( ) +# Return the type of with respect to . String +# describing type of prerequisite is returned in variable named . +# +# Possible types are: +# system +# local +# embedded +# other #============================================================================= # Copyright 2008-2009 Kitware, Inc. @@ -35,14 +116,9 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -# gp_append_unique list_var value -# -# Append value to the list variable ${list_var} only if the value is not -# already in the list. -# function(gp_append_unique list_var value) set(contains 0) @@ -59,12 +135,6 @@ function(gp_append_unique list_var value) endfunction(gp_append_unique) -# is_file_executable file result_var -# -# Return 1 in ${result_var} if ${file} is a binary executable. -# -# Return 0 in ${result_var} otherwise. -# function(is_file_executable file result_var) # # A file is not executable until proven otherwise: @@ -76,7 +146,7 @@ function(is_file_executable file result_var) # If file name ends in .exe on Windows, *assume* executable: # - if(WIN32) + if(WIN32 AND NOT UNIX) if("${file_full_lower}" MATCHES "\\.exe$") set(${result_var} 1 PARENT_SCOPE) return() @@ -86,7 +156,7 @@ function(is_file_executable file result_var) # to determine ${result_var}. In 99%+? practical cases, the exe name # match will be sufficient... # - endif(WIN32) + endif(WIN32 AND NOT UNIX) # Use the information returned from the Unix shell command "file" to # determine if ${file_full} should be considered an executable file... @@ -132,14 +202,6 @@ function(is_file_executable file result_var) endfunction(is_file_executable) -# gp_item_default_embedded_path item default_embedded_path_var -# -# Return the path that others should refer to the item by when the item -# is embedded inside a bundle. -# -# Override on a per-project basis by providing a project-specific -# gp_item_default_embedded_path_override function. -# function(gp_item_default_embedded_path item default_embedded_path_var) # On Windows and Linux, "embed" prerequisites in the same directory @@ -193,13 +255,6 @@ function(gp_item_default_embedded_path item default_embedded_path_var) endfunction(gp_item_default_embedded_path) -# gp_resolve_item context item exepath dirs resolved_item_var -# -# Resolve an item into an existing full path file. -# -# Override on a per-project basis by providing a project-specific -# gp_resolve_item_override function. -# function(gp_resolve_item context item exepath dirs resolved_item_var) set(resolved 0) set(resolved_item "${item}") @@ -280,7 +335,7 @@ function(gp_resolve_item context item exepath dirs resolved_item_var) # Using find_program on Windows will find dll files that are in the PATH. # (Converting simple file names into full path names if found.) # - if(WIN32) + if(WIN32 AND NOT UNIX) if(NOT resolved) set(ri "ri-NOTFOUND") find_program(ri "${item}" PATHS "${exepath};${dirs}" NO_DEFAULT_PATH) @@ -292,7 +347,7 @@ function(gp_resolve_item context item exepath dirs resolved_item_var) set(ri "ri-NOTFOUND") endif(ri) endif(NOT resolved) - endif(WIN32) + endif(WIN32 AND NOT UNIX) # Provide a hook so that projects can override item resolution # by whatever logic they choose: @@ -332,23 +387,6 @@ warning: cannot resolve item '${item}' endfunction(gp_resolve_item) -# gp_resolved_file_type original_file file exepath dirs type_var -# -# Return the type of ${file} with respect to ${original_file}. String -# describing type of prerequisite is returned in variable named ${type_var}. -# -# Use ${exepath} and ${dirs} if necessary to resolve non-absolute ${file} -# values -- but only for non-embedded items. -# -# Possible types are: -# system -# local -# embedded -# other -# -# Override on a per-project basis by providing a project-specific -# gp_resolved_file_type_override function. -# function(gp_resolved_file_type original_file file exepath dirs type_var) #message(STATUS "**") @@ -375,7 +413,7 @@ function(gp_resolved_file_type original_file file exepath dirs type_var) string(TOLOWER "${resolved_file}" lower) if(UNIX) - if(resolved_file MATCHES "^(/lib/|/lib32/|/lib64/|/usr/lib/|/usr/lib32/|/usr/lib64/|/usr/X11R6/)") + if(resolved_file MATCHES "^(/lib/|/lib32/|/lib64/|/usr/lib/|/usr/lib32/|/usr/lib64/|/usr/X11R6/|/usr/bin/)") set(is_system 1) endif() endif() @@ -396,7 +434,27 @@ function(gp_resolved_file_type original_file file exepath dirs type_var) if(lower MATCHES "^(${sysroot}/sys(tem|wow)|${windir}/sys(tem|wow)|(.*/)*msvc[^/]+dll)") set(is_system 1) endif() - endif() + + if(UNIX) + # if cygwin, we can get the properly formed windows paths from cygpath + find_program(CYGPATH_EXECUTABLE cygpath) + + if(CYGPATH_EXECUTABLE) + execute_process(COMMAND ${CYGPATH_EXECUTABLE} -W + OUTPUT_VARIABLE env_windir + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND ${CYGPATH_EXECUTABLE} -S + OUTPUT_VARIABLE env_sysdir + OUTPUT_STRIP_TRAILING_WHITESPACE) + string(TOLOWER "${env_windir}" windir) + string(TOLOWER "${env_sysdir}" sysroot) + + if(lower MATCHES "^(${sysroot}/sys(tem|wow)|${windir}/sys(tem|wow)|(.*/)*msvc[^/]+dll)") + set(is_system 1) + endif() + endif(CYGPATH_EXECUTABLE) + endif(UNIX) + endif(WIN32) if(NOT is_system) get_filename_component(original_path "${original_lower}" PATH) @@ -445,17 +503,6 @@ function(gp_resolved_file_type original_file file exepath dirs type_var) endfunction() -# gp_file_type original_file file type_var -# -# Return the type of ${file} with respect to ${original_file}. String -# describing type of prerequisite is returned in variable named ${type_var}. -# -# Possible types are: -# system -# local -# embedded -# other -# function(gp_file_type original_file file type_var) if(NOT IS_ABSOLUTE "${original_file}") message(STATUS "warning: gp_file_type expects absolute full path for first arg original_file") @@ -470,30 +517,6 @@ function(gp_file_type original_file file type_var) endfunction(gp_file_type) -# get_prerequisites target prerequisites_var exclude_system recurse dirs -# -# Get the list of shared library files required by ${target}. The list in -# the variable named ${prerequisites_var} should be empty on first entry to -# this function. On exit, ${prerequisites_var} will contain the list of -# required shared library files. -# -# target is the full path to an executable file -# -# prerequisites_var is the name of a CMake variable to contain the results -# -# exclude_system is 0 or 1: 0 to include "system" prerequisites , 1 to -# exclude them -# -# recurse is 0 or 1: 0 for direct prerequisites only, 1 for all prerequisites -# recursively -# -# exepath is the path to the top level executable used for @executable_path -# replacment on the Mac -# -# dirs is a list of paths where libraries might be found: these paths are -# searched first when a target without any path info is given. Then standard -# system locations are also searched: PATH, Framework locations, /usr/lib... -# function(get_prerequisites target prerequisites_var exclude_system recurse exepath dirs) set(verbose 0) set(eol_char "E") @@ -516,9 +539,9 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa if(APPLE) set(gp_tool "otool") endif(APPLE) - if(WIN32) + if(WIN32 AND NOT UNIX) # This is how to check for cygwin, har! set(gp_tool "dumpbin") - endif(WIN32) + endif(WIN32 AND NOT UNIX) endif("${gp_tool}" STREQUAL "") set(gp_tool_known 0) @@ -526,6 +549,8 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa if("${gp_tool}" STREQUAL "ldd") set(gp_cmd_args "") set(gp_regex "^[\t ]*[^\t ]+ => ([^\t ]+).*${eol_char}$") + set(gp_regex_error "not found${eol_char}$") + set(gp_regex_fallback "^[\t ]*([^\t ]+) => ([^\t ]+).*${eol_char}$") set(gp_regex_cmp_count 1) set(gp_tool_known 1) endif("${gp_tool}" STREQUAL "ldd") @@ -533,6 +558,8 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa if("${gp_tool}" STREQUAL "otool") set(gp_cmd_args "-L") set(gp_regex "^\t([^\t]+) \\(compatibility version ([0-9]+.[0-9]+.[0-9]+), current version ([0-9]+.[0-9]+.[0-9]+)\\)${eol_char}$") + set(gp_regex_error "") + set(gp_regex_fallback "") set(gp_regex_cmp_count 3) set(gp_tool_known 1) endif("${gp_tool}" STREQUAL "otool") @@ -540,6 +567,8 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa if("${gp_tool}" STREQUAL "dumpbin") set(gp_cmd_args "/dependents") set(gp_regex "^ ([^ ].*[Dd][Ll][Ll])${eol_char}$") + set(gp_regex_error "") + set(gp_regex_fallback "") set(gp_regex_cmp_count 1) set(gp_tool_known 1) set(ENV{VS_UNICODE_OUTPUT} "") # Block extra output from inside VS IDE. @@ -578,11 +607,22 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa # get_filename_component(gp_cmd_dir "${gp_cmd}" PATH) get_filename_component(gp_cmd_dlls_dir "${gp_cmd_dir}/../../Common7/IDE" ABSOLUTE) + # Use cmake paths as a user may have a PATH element ending with a backslash. + # This will escape the list delimiter and create havoc! if(EXISTS "${gp_cmd_dlls_dir}") # only add to the path if it is not already in the path - if(NOT "$ENV{PATH}" MATCHES "${gp_cmd_dlls_dir}") + set(gp_found_cmd_dlls_dir 0) + file(TO_CMAKE_PATH "$ENV{PATH}" env_path) + foreach(gp_env_path_element ${env_path}) + if("${gp_env_path_element}" STREQUAL "${gp_cmd_dlls_dir}") + set(gp_found_cmd_dlls_dir 1) + endif() + endforeach(gp_env_path_element) + + if(NOT gp_found_cmd_dlls_dir) + file(TO_NATIVE_PATH "${gp_cmd_dlls_dir}" gp_cmd_dlls_dir) set(ENV{PATH} "$ENV{PATH};${gp_cmd_dlls_dir}") - endif(NOT "$ENV{PATH}" MATCHES "${gp_cmd_dlls_dir}") + endif() endif(EXISTS "${gp_cmd_dlls_dir}") endif("${gp_tool}" STREQUAL "dumpbin") # @@ -625,12 +665,34 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa string(REGEX REPLACE ";" "\\\\;" candidates "${gp_cmd_ov}") string(REGEX REPLACE "\n" "${eol_char};" candidates "${candidates}") + # check for install id and remove it from list, since otool -L can include a + # reference to itself + set(gp_install_id) + if("${gp_tool}" STREQUAL "otool") + execute_process( + COMMAND otool -D ${target} + OUTPUT_VARIABLE gp_install_id_ov + ) + # second line is install name + string(REGEX REPLACE ".*:\n" "" gp_install_id "${gp_install_id_ov}") + if(gp_install_id) + # trim + string(REGEX MATCH "[^\n ].*[^\n ]" gp_install_id "${gp_install_id}") + #message("INSTALL ID is \"${gp_install_id}\"") + endif(gp_install_id) + endif("${gp_tool}" STREQUAL "otool") + # Analyze each line for file names that match the regular expression: # foreach(candidate ${candidates}) if("${candidate}" MATCHES "${gp_regex}") + # Extract information from each candidate: - string(REGEX REPLACE "${gp_regex}" "\\1" raw_item "${candidate}") + if(gp_regex_error AND "${candidate}" MATCHES "${gp_regex_error}") + string(REGEX REPLACE "${gp_regex_fallback}" "\\1" raw_item "${candidate}") + else(gp_regex_error AND "${candidate}" MATCHES "${gp_regex_error}") + string(REGEX REPLACE "${gp_regex}" "\\1" raw_item "${candidate}") + endif(gp_regex_error AND "${candidate}" MATCHES "${gp_regex_error}") if(gp_regex_cmp_count GREATER 1) string(REGEX REPLACE "${gp_regex}" "\\2" raw_compat_version "${candidate}") @@ -656,14 +718,18 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa # set(add_item 1) - if(${exclude_system}) + if("${item}" STREQUAL "${gp_install_id}") + set(add_item 0) + endif("${item}" STREQUAL "${gp_install_id}") + + if(add_item AND ${exclude_system}) set(type "") gp_resolved_file_type("${target}" "${item}" "${exepath}" "${dirs}" type) if("${type}" STREQUAL "system") set(add_item 0) endif("${type}" STREQUAL "system") - endif(${exclude_system}) + endif(add_item AND ${exclude_system}) if(add_item) list(LENGTH ${prerequisites_var} list_length_before_append) @@ -706,19 +772,6 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa endfunction(get_prerequisites) -# list_prerequisites target all exclude_system verbose -# -# ARGV0 (target) is the full path to an executable file -# -# optional ARGV1 (all) is 0 or 1: 0 for direct prerequisites only, -# 1 for all prerequisites recursively -# -# optional ARGV2 (exclude_system) is 0 or 1: 0 to include "system" -# prerequisites , 1 to exclude them -# -# optional ARGV3 (verbose) is 0 or 1: 0 to print only full path -# names of prerequisites, 1 to print extra information -# function(list_prerequisites target) if("${ARGV1}" STREQUAL "") set(all 1) @@ -771,17 +824,6 @@ function(list_prerequisites target) endfunction(list_prerequisites) -# list_prerequisites_by_glob glob_arg glob_exp -# -# glob_arg is GLOB or GLOB_RECURSE -# -# glob_exp is a globbing expression used with "file(GLOB" to retrieve a list -# of matching files. If a matching file is executable, its prerequisites are -# listed. -# -# Any additional (optional) arguments provided are passed along as the -# optional arguments to the list_prerequisites calls. -# function(list_prerequisites_by_glob glob_arg glob_exp) message(STATUS "=============================================================================") message(STATUS "List prerequisites of executables matching ${glob_arg} '${glob_exp}'") diff --git a/Modules/ITKCompatibility.cmake b/Modules/ITKCompatibility.cmake index 3693abcd5..efd9c284e 100644 --- a/Modules/ITKCompatibility.cmake +++ b/Modules/ITKCompatibility.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # work around an old bug in ITK prior to verison 3.0 diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake index 97c6ccba2..b60fed8ea 100644 --- a/Modules/InstallRequiredSystemLibraries.cmake +++ b/Modules/InstallRequiredSystemLibraries.cmake @@ -22,7 +22,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF(MSVC) diff --git a/Modules/KDE3Macros.cmake b/Modules/KDE3Macros.cmake index 0f2d4790a..5b76000e8 100644 --- a/Modules/KDE3Macros.cmake +++ b/Modules/KDE3Macros.cmake @@ -11,7 +11,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # See FindKDE3.cmake for documentation. diff --git a/Modules/MacroAddFileDependencies.cmake b/Modules/MacroAddFileDependencies.cmake index e4a82d1a5..527447b80 100644 --- a/Modules/MacroAddFileDependencies.cmake +++ b/Modules/MacroAddFileDependencies.cmake @@ -1,6 +1,6 @@ # - MACRO_ADD_FILE_DEPENDENCIES(<_file> depend_files...) # Using the macro MACRO_ADD_FILE_DEPENDENCIES() is discouraged. There are usually -# better ways to specifiy the correct dependencies. +# better ways to specify the correct dependencies. # # MACRO_ADD_FILE_DEPENDENCIES(<_file> depend_files...) is just a convenience # wrapper around the OBJECT_DEPENDS source file property. You can just @@ -16,7 +16,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO (MACRO_ADD_FILE_DEPENDENCIES _file) diff --git a/Modules/Platform/AIX-GNU.cmake b/Modules/Platform/AIX-GNU.cmake index fc3880eee..79c06baa0 100644 --- a/Modules/Platform/AIX-GNU.cmake +++ b/Modules/Platform/AIX-GNU.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is shared by multiple languages; use include blocker. diff --git a/Modules/Platform/BlueGeneP-base.cmake b/Modules/Platform/BlueGeneP-base.cmake new file mode 100644 index 000000000..2ca920ff0 --- /dev/null +++ b/Modules/Platform/BlueGeneP-base.cmake @@ -0,0 +1,118 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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.) + +# +# BlueGeneP base platform file. +# +# NOTE: Do not set your platform to "BlueGeneP-base". This file is included +# by the real platform files. Use one of these two platforms instead: +# +# BlueGeneP-dynamic For dynamically linked builds +# BlueGeneP-static For statically linked builds +# +# This platform file tries its best to adhere to the behavior of the MPI +# compiler wrappers included with the latest BG/P drivers. +# + + +# +# For BGP builds, we're cross compiling, but we don't want to re-root things +# (e.g. with CMAKE_FIND_ROOT_PATH) because users may have libraries anywhere on +# the shared filesystems, and this may lie outside the root. Instead, we set the +# system directories so that the various system BGP CNK library locations are +# searched first. This is not the clearest thing in the world, given IBM's driver +# layout, but this should cover all the standard ones. +# +set(CMAKE_SYSTEM_LIBRARY_PATH + /bgsys/drivers/ppcfloor/comm/default/lib # default comm layer (used by mpi compiler wrappers) + /bgsys/drivers/ppcfloor/comm/sys/lib # DCMF, other lower-level comm libraries + /bgsys/drivers/ppcfloor/runtime/SPI # other low-level stuff + /bgsys/drivers/ppcfloor/gnu-linux/lib # CNK python installation directory + /bgsys/drivers/ppcfloor/gnu-linux/powerpc-bgp-linux/lib # CNK Linux image -- standard runtime libs, pthread, etc. +) + +# +# This adds directories that find commands should specifically ignore for cross compiles. +# Most of these directories are the includeand lib directories for the frontend on BG/P systems. +# Not ignoring these can cause things like FindX11 to find a frontend PPC version mistakenly. +# We use this on BG instead of re-rooting because backend libraries are typically strewn about +# the filesystem, and we can't re-root ALL backend libraries to a single place. +# +set(CMAKE_SYSTEM_IGNORE_PATH + /lib /lib64 /include + /usr/lib /usr/lib64 /usr/include + /usr/local/lib /usr/local/lib64 /usr/local/include + /usr/X11/lib /usr/X11/lib64 /usr/X11/include + /usr/lib/X11 /usr/lib64/X11 /usr/include/X11 + /usr/X11R6/lib /usr/X11R6/lib64 /usr/X11R6/include + /usr/X11R7/lib /usr/X11R7/lib64 /usr/X11R7/include +) + +# +# Indicate that this is a unix-like system +# +set(UNIX 1) + +# +# Library prefixes, suffixes, extra libs. +# +set(CMAKE_LINK_LIBRARY_SUFFIX "") +set(CMAKE_STATIC_LIBRARY_PREFIX "lib") # lib +set(CMAKE_STATIC_LIBRARY_SUFFIX ".a") # .a + +set(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib +set(CMAKE_SHARED_LIBRARY_SUFFIX ".so") # .so +set(CMAKE_EXECUTABLE_SUFFIX "") # .exe +set(CMAKE_DL_LIBS "dl") + +# +# This macro needs to be called for dynamic library support. Unfortunately on BGP, +# We can't support both static and dynamic links in the same platform file. The +# dynamic link platform file needs to call this explicitly to set up dynamic linking. +# +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") + 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") + 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 + + set(BGP_${lang}_DEFAULT_EXE_FLAGS + " -o ") + set(CMAKE_${lang}_LINK_EXECUTABLE + " -Wl,-relax ${BGP_${lang}_DYNAMIC_EXE_FLAGS} ${BGP_${lang}_DEFAULT_EXE_FLAGS}") +endmacro() + +# +# This macro needs to be called for static builds. Right now it just adds -Wl,-relax +# to the link line. +# +macro(__BlueGeneP_set_static_flags compiler_id lang) + set(BGP_${lang}_DEFAULT_EXE_FLAGS + " -o ") + set(CMAKE_${lang}_LINK_EXECUTABLE + " -Wl,-relax ${BGP_${lang}_DEFAULT_EXE_FLAGS}") +endmacro() diff --git a/Modules/Platform/BlueGeneP-dynamic-GNU-C.cmake b/Modules/Platform/BlueGeneP-dynamic-GNU-C.cmake new file mode 100644 index 000000000..bd4696b6b --- /dev/null +++ b/Modules/Platform/BlueGeneP-dynamic-GNU-C.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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.) + +__BlueGeneP_set_dynamic_flags(GNU C) diff --git a/Modules/Platform/BlueGeneP-dynamic-GNU-CXX.cmake b/Modules/Platform/BlueGeneP-dynamic-GNU-CXX.cmake new file mode 100644 index 000000000..9c995dc7b --- /dev/null +++ b/Modules/Platform/BlueGeneP-dynamic-GNU-CXX.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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.) + +__BlueGeneP_set_dynamic_flags(GNU CXX) diff --git a/Modules/Platform/BlueGeneP-dynamic-GNU-Fortran.cmake b/Modules/Platform/BlueGeneP-dynamic-GNU-Fortran.cmake new file mode 100644 index 000000000..19d6be8ec --- /dev/null +++ b/Modules/Platform/BlueGeneP-dynamic-GNU-Fortran.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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.) + +__BlueGeneP_set_dynamic_flags(GNU Fortran) diff --git a/Modules/Platform/BlueGeneP-dynamic-XL-C.cmake b/Modules/Platform/BlueGeneP-dynamic-XL-C.cmake new file mode 100644 index 000000000..2dbbbc0ec --- /dev/null +++ b/Modules/Platform/BlueGeneP-dynamic-XL-C.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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.) + +__BlueGeneP_set_dynamic_flags(XL C) diff --git a/Modules/Platform/BlueGeneP-dynamic-XL-CXX.cmake b/Modules/Platform/BlueGeneP-dynamic-XL-CXX.cmake new file mode 100644 index 000000000..2bc51272b --- /dev/null +++ b/Modules/Platform/BlueGeneP-dynamic-XL-CXX.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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.) + +__BlueGeneP_set_dynamic_flags(XL CXX) diff --git a/Modules/Platform/BlueGeneP-dynamic-XL-Fortran.cmake b/Modules/Platform/BlueGeneP-dynamic-XL-Fortran.cmake new file mode 100644 index 000000000..59da63da6 --- /dev/null +++ b/Modules/Platform/BlueGeneP-dynamic-XL-Fortran.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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.) + +__BlueGeneP_set_dynamic_flags(XL Fortran) diff --git a/Modules/Platform/BlueGeneP-dynamic.cmake b/Modules/Platform/BlueGeneP-dynamic.cmake new file mode 100644 index 000000000..8f96f2f13 --- /dev/null +++ b/Modules/Platform/BlueGeneP-dynamic.cmake @@ -0,0 +1,19 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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(Platform/BlueGeneP-base) +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) +set(CMAKE_FIND_LIBRARY_PREFIXES "lib") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a") diff --git a/Modules/Platform/BlueGeneP-static-GNU-C.cmake b/Modules/Platform/BlueGeneP-static-GNU-C.cmake new file mode 100644 index 000000000..412a7a3e5 --- /dev/null +++ b/Modules/Platform/BlueGeneP-static-GNU-C.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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.) + +__BlueGeneP_set_static_flags(GNU C) diff --git a/Modules/Platform/BlueGeneP-static-GNU-CXX.cmake b/Modules/Platform/BlueGeneP-static-GNU-CXX.cmake new file mode 100644 index 000000000..418f0d8d5 --- /dev/null +++ b/Modules/Platform/BlueGeneP-static-GNU-CXX.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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.) + +__BlueGeneP_set_static_flags(GNU CXX) diff --git a/Modules/Platform/BlueGeneP-static-GNU-Fortran.cmake b/Modules/Platform/BlueGeneP-static-GNU-Fortran.cmake new file mode 100644 index 000000000..119195b30 --- /dev/null +++ b/Modules/Platform/BlueGeneP-static-GNU-Fortran.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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.) + +__BlueGeneP_set_static_flags(GNU Fortran) diff --git a/Modules/Platform/BlueGeneP-static-XL-C.cmake b/Modules/Platform/BlueGeneP-static-XL-C.cmake new file mode 100644 index 000000000..1f2095932 --- /dev/null +++ b/Modules/Platform/BlueGeneP-static-XL-C.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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.) + +__BlueGeneP_set_static_flags(XL C) diff --git a/Modules/Platform/BlueGeneP-static-XL-CXX.cmake b/Modules/Platform/BlueGeneP-static-XL-CXX.cmake new file mode 100644 index 000000000..f027a533f --- /dev/null +++ b/Modules/Platform/BlueGeneP-static-XL-CXX.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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.) + +__BlueGeneP_set_static_flags(XL CXX) diff --git a/Modules/Platform/BlueGeneP-static-XL-Fortran.cmake b/Modules/Platform/BlueGeneP-static-XL-Fortran.cmake new file mode 100644 index 000000000..778d4bd91 --- /dev/null +++ b/Modules/Platform/BlueGeneP-static-XL-Fortran.cmake @@ -0,0 +1,16 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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.) + +__BlueGeneP_set_static_flags(XL Fortran) diff --git a/Modules/Platform/BlueGeneP-static.cmake b/Modules/Platform/BlueGeneP-static.cmake new file mode 100644 index 000000000..c4f5f21a6 --- /dev/null +++ b/Modules/Platform/BlueGeneP-static.cmake @@ -0,0 +1,19 @@ + +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2010 Todd Gamblin +# +# 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(Platform/BlueGeneP-base) +set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) +set(CMAKE_FIND_LIBRARY_PREFIXES "lib") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") diff --git a/Modules/Platform/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake index 24bb92aa2..6f72a75b7 100644 --- a/Modules/Platform/CYGWIN-GNU.cmake +++ b/Modules/Platform/CYGWIN-GNU.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is shared by multiple languages; use include blocker. diff --git a/Modules/Platform/Darwin-GNU.cmake b/Modules/Platform/Darwin-GNU.cmake index 4c2194a4d..f425eb9ac 100644 --- a/Modules/Platform/Darwin-GNU.cmake +++ b/Modules/Platform/Darwin-GNU.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is shared by multiple languages; use include blocker. diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index c8bcad1d0..db0642e99 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -235,4 +235,7 @@ SET(CMAKE_SYSTEM_APPBUNDLE_PATH /Developer/Applications) INCLUDE(Platform/UnixPaths) -LIST(APPEND CMAKE_SYSTEM_PREFIX_PATH /sw) +LIST(APPEND CMAKE_SYSTEM_PREFIX_PATH + /sw # Fink + /opt/local # MacPorts + ) diff --git a/Modules/Platform/GNU.cmake b/Modules/Platform/GNU.cmake index fe3d47b09..e0ed86cb7 100644 --- a/Modules/Platform/GNU.cmake +++ b/Modules/Platform/GNU.cmake @@ -4,5 +4,8 @@ SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") +SET(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") +SET(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") + INCLUDE(Platform/UnixPaths) diff --git a/Modules/Platform/HP-UX-GNU.cmake b/Modules/Platform/HP-UX-GNU.cmake index da9fe4835..eb909fe99 100644 --- a/Modules/Platform/HP-UX-GNU.cmake +++ b/Modules/Platform/HP-UX-GNU.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is shared by multiple languages; use include blocker. diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake index f8893d8d3..9d357c942 100644 --- a/Modules/Platform/HP-UX.cmake +++ b/Modules/Platform/HP-UX.cmake @@ -1,3 +1,5 @@ +SET(CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH /usr/lib) + SET(CMAKE_SHARED_LIBRARY_SUFFIX ".sl") # .so SET(CMAKE_DL_LIBS "dld") SET(CMAKE_FIND_LIBRARY_SUFFIXES ".sl" ".so" ".a") diff --git a/Modules/Platform/Linux-GNU.cmake b/Modules/Platform/Linux-GNU.cmake index d257f3413..0e254c6ea 100644 --- a/Modules/Platform/Linux-GNU.cmake +++ b/Modules/Platform/Linux-GNU.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is shared by multiple languages; use include blocker. diff --git a/Modules/Platform/Linux-Intel.cmake b/Modules/Platform/Linux-Intel.cmake index dff90e984..dea8b90dc 100644 --- a/Modules/Platform/Linux-Intel.cmake +++ b/Modules/Platform/Linux-Intel.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is shared by multiple languages; use include blocker. diff --git a/Modules/Platform/Linux-PGI.cmake b/Modules/Platform/Linux-PGI.cmake index 868ee33b6..ef06acd16 100644 --- a/Modules/Platform/Linux-PGI.cmake +++ b/Modules/Platform/Linux-PGI.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is shared by multiple languages; use include blocker. diff --git a/Modules/Platform/Linux-PathScale.cmake b/Modules/Platform/Linux-PathScale.cmake index 8537e4c0f..c131af272 100644 --- a/Modules/Platform/Linux-PathScale.cmake +++ b/Modules/Platform/Linux-PathScale.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is shared by multiple languages; use include blocker. diff --git a/Modules/Platform/SunOS-GNU.cmake b/Modules/Platform/SunOS-GNU.cmake index 613ea6bbf..7169056de 100644 --- a/Modules/Platform/SunOS-GNU.cmake +++ b/Modules/Platform/SunOS-GNU.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is shared by multiple languages; use include blocker. diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake index 025ae5102..5ee7ddbd6 100644 --- a/Modules/Platform/UnixPaths.cmake +++ b/Modules/Platform/UnixPaths.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Block multiple inclusion because "CMakeCInformation.cmake" includes @@ -51,7 +51,7 @@ LIST(APPEND CMAKE_SYSTEM_INCLUDE_PATH /usr/X11R6/include /usr/include/X11 # Other - /opt/local/include /usr/pkg/include + /usr/pkg/include /opt/csw/include /opt/include /usr/openwin/include ) @@ -64,7 +64,7 @@ LIST(APPEND CMAKE_SYSTEM_LIBRARY_PATH /usr/X11R6/lib /usr/lib/X11 # Other - /opt/local/lib /usr/pkg/lib + /usr/pkg/lib /opt/csw/lib /opt/lib /usr/openwin/lib ) diff --git a/Modules/Platform/Windows-Borland.cmake b/Modules/Platform/Windows-Borland.cmake index 7b7ae8493..5c402bd9f 100644 --- a/Modules/Platform/Windows-Borland.cmake +++ b/Modules/Platform/Windows-Borland.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is shared by multiple languages; use include blocker. diff --git a/Modules/Platform/Windows-GNU-Fortran.cmake b/Modules/Platform/Windows-GNU-Fortran.cmake index 8273a199f..c66feedbb 100644 --- a/Modules/Platform/Windows-GNU-Fortran.cmake +++ b/Modules/Platform/Windows-GNU-Fortran.cmake @@ -1,3 +1,2 @@ include(Platform/Windows-GNU) __windows_compiler_gnu(Fortran) -set(CMAKE_Fortran_USE_RESPONSE_FILE_FOR_OBJECTS 0) diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index af038417d..ac635a50e 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This module is shared by multiple languages; use include blocker. @@ -49,6 +49,13 @@ set(CMAKE_CREATE_WIN32_EXE "-mwindows") set(CMAKE_GNULD_IMAGE_VERSION "-Wl,--major-image-version,,--minor-image-version,") +# Check if GNU ld is too old to support @FILE syntax. +set(__WINDOWS_GNU_LD_RESPONSE 1) +execute_process(COMMAND ld -v OUTPUT_VARIABLE _help ERROR_VARIABLE _help) +if("${_help}" MATCHES "GNU ld .* 2\\.1[1-6]") + set(__WINDOWS_GNU_LD_RESPONSE 0) +endif() + macro(__windows_compiler_gnu lang) if(MSYS OR MINGW) @@ -68,8 +75,24 @@ macro(__windows_compiler_gnu lang) endif() set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") # No -fPIC on Windows - set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS 1) - set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-Wl,@") + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS ${__WINDOWS_GNU_LD_RESPONSE}) + + # We prefer "@" for response files but it is not supported by gcc 3. + execute_process(COMMAND ${CMAKE_${lang}_COMPILER} --version OUTPUT_VARIABLE _ver ERROR_VARIABLE _ver) + if("${_ver}" MATCHES "\\(GCC\\) 3\\.") + if("${lang}" STREQUAL "Fortran") + # The GNU Fortran compiler reports an error: + # no input files; unwilling to write output files + # when the response file is passed with "-Wl,@". + set(CMAKE_Fortran_USE_RESPONSE_FILE_FOR_OBJECTS 0) + else() + # Use "-Wl,@" to pass the response file to the linker. + set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "-Wl,@") + endif() + elseif(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS) + # Use "@" to pass the response file to the front-end. + set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@") + endif() # Binary link rules. set(CMAKE_${lang}_CREATE_SHARED_MODULE @@ -78,4 +101,21 @@ macro(__windows_compiler_gnu lang) " -o -Wl,--out-implib, ${CMAKE_GNULD_IMAGE_VERSION} ") set(CMAKE_${lang}_LINK_EXECUTABLE " -o -Wl,--out-implib, ${CMAKE_GNULD_IMAGE_VERSION} ") + + # 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) + # The gcc/collect2/ld toolchain does not use response files + # internally so we cannot pass long object lists. Instead pass + # the object file list in a response file to the archiver to put + # them in a temporary archive. Hand the archive to the linker. + string(REPLACE "" "-Wl,--whole-archive /objects.a -Wl,--no-whole-archive" + CMAKE_${lang}_${rule} "${CMAKE_${lang}_${rule}}") + set(CMAKE_${lang}_${rule} + " -E remove -f /objects.a" + " cr /objects.a " + "${CMAKE_${lang}_${rule}}" + ) + endforeach() + endif() endmacro() diff --git a/Modules/Platform/Windows-df.cmake b/Modules/Platform/Windows-df.cmake index 753b19873..f5046bf35 100644 --- a/Modules/Platform/Windows-df.cmake +++ b/Modules/Platform/Windows-df.cmake @@ -10,6 +10,8 @@ ELSE(CMAKE_VERBOSE_MAKEFILE) SET(CMAKE_CL_NOLOGO "/nologo") ENDIF(CMAKE_VERBOSE_MAKEFILE) +SET(CMAKE_Fortran_MODDIR_FLAG "-module:") + SET(CMAKE_Fortran_CREATE_SHARED_LIBRARY "link ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out: /dll ${CMAKE_END_TEMP_FILE}") diff --git a/Modules/Platform/Windows-icl.cmake b/Modules/Platform/Windows-icl.cmake index c717c7c1c..9088cc7d1 100644 --- a/Modules/Platform/Windows-icl.cmake +++ b/Modules/Platform/Windows-icl.cmake @@ -6,6 +6,10 @@ IF(CMAKE_VERBOSE_MAKEFILE) ELSE(CMAKE_VERBOSE_MAKEFILE) SET(CMAKE_CL_NOLOGO "/nologo") ENDIF(CMAKE_VERBOSE_MAKEFILE) + +SET(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1) +SET(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1) + # create a shared C++ library SET(CMAKE_CXX_CREATE_SHARED_LIBRARY "xilink ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out: /implib: /pdb: /dll ${CMAKE_END_TEMP_FILE}") diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index 7fc345fee..e96ebb5cd 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -12,17 +12,29 @@ ELSE(CMAKE_VERBOSE_MAKEFILE) SET(CMAKE_LIB_QUIET "-q") ENDIF(CMAKE_VERBOSE_MAKEFILE) +set(CMAKE_CREATE_WIN32_EXE "system nt_win" ) +SET(CMAKE_CREATE_CONSOLE_EXE "system nt" ) + +SET (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "debug all" ) +SET (CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT "debug all" ) +SET (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all" ) +SET (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all" ) + +set (CMAKE_SHARED_LIBRARY_C_FLAGS "-bd" ) + +SET(CMAKE_RC_COMPILER "rc" ) + SET(CMAKE_BUILD_TYPE_INIT Debug) SET (CMAKE_CXX_FLAGS_INIT "-w=3 -xs") -SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-br -bm -d2") +SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-br -bm -d2") SET (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-br -bm -os -dNDEBUG") SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-br -bm -ot -dNDEBUG") SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-br -bm -d2 -ot -dNDEBUG") SET (CMAKE_C_FLAGS_INIT "-w=3 ") -SET (CMAKE_C_FLAGS_DEBUG_INIT "-br -bm -od") +SET (CMAKE_C_FLAGS_DEBUG_INIT "-br -bm -d2 -od") SET (CMAKE_C_FLAGS_MINSIZEREL_INIT "-br -bm -os -dNDEBUG") SET (CMAKE_C_FLAGS_RELEASE_INIT "-br -bm -ot -dNDEBUG") -SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-br -bm -ot -dNDEBUG") +SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-br -bm -d2 -ot -dNDEBUG") SET (CMAKE_C_STANDARD_LIBRARIES_INIT "library clbrdll.lib library plbrdll.lib library kernel32.lib library user32.lib library gdi32.lib library winspool.lib library comdlg32.lib library advapi32.lib library shell32.lib library ole32.lib library oleaut32.lib library uuid.lib library odbc32.lib library odbccp32.lib") SET (CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") @@ -33,6 +45,7 @@ SET(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY}) SET(CMAKE_C_LINK_EXECUTABLE "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '' option caseexact file {} ${CMAKE_END_TEMP_FILE}") + SET(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE}) # compile a C++ file into an object file diff --git a/Modules/Platform/WindowsPaths.cmake b/Modules/Platform/WindowsPaths.cmake index 8c67175c2..c7b15b342 100644 --- a/Modules/Platform/WindowsPaths.cmake +++ b/Modules/Platform/WindowsPaths.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Block multiple inclusion because "CMakeCInformation.cmake" includes diff --git a/Modules/Qt4ConfigDependentSettings.cmake b/Modules/Qt4ConfigDependentSettings.cmake index 1d77c7ad4..bfb50de0a 100644 --- a/Modules/Qt4ConfigDependentSettings.cmake +++ b/Modules/Qt4ConfigDependentSettings.cmake @@ -10,7 +10,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) @@ -34,12 +34,12 @@ SET(QT_QTDBUS_LIB_DEPENDENCIES "") SET(QT_QTHELP_LIB_DEPENDENCIES ${QT_QTCLUCENE_LIBRARY}) -IF(WIN32) +IF(Q_WS_WIN) # On Windows, qconfig.pri has "static" for static library builds IF(QT_CONFIG MATCHES "static") SET(QT_IS_STATIC 1) ENDIF(QT_CONFIG MATCHES "static") -ELSE(WIN32) +ELSE(Q_WS_WIN) # On other platforms, check file extension to know if its static IF(QT_QTCORE_LIBRARY_RELEASE) GET_FILENAME_COMPONENT(qtcore_lib_ext "${QT_QTCORE_LIBRARY_RELEASE}" EXT) @@ -53,12 +53,12 @@ ELSE(WIN32) SET(QT_IS_STATIC 1) ENDIF(${qtcore_lib_ext} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX}) ENDIF(QT_QTCORE_LIBRARY_DEBUG) -ENDIF(WIN32) +ENDIF(Q_WS_WIN) # build using shared Qt needs -DQT_DLL on Windows -IF(WIN32 AND NOT QT_IS_STATIC) +IF(Q_WS_WIN AND NOT QT_IS_STATIC) SET(QT_DEFINITIONS ${QT_DEFINITIONS} -DQT_DLL) -ENDIF(WIN32 AND NOT QT_IS_STATIC) +ENDIF(Q_WS_WIN AND NOT QT_IS_STATIC) IF(NOT QT_IS_STATIC) RETURN() @@ -71,11 +71,8 @@ SET (QT_QTOPENGL_LIB_DEPENDENCIES ${OPENGL_glu_LIBRARY} ${OPENGL_gl_LIBRARY}) ## system png IF(QT_QCONFIG MATCHES "system-png") - FIND_LIBRARY(QT_PNG_LIBRARY NAMES png) - MARK_AS_ADVANCED(QT_PNG_LIBRARY) - IF(QT_PNG_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_PNG_LIBRARY}) - ENDIF(QT_PNG_LIBRARY) + find_package(PNG) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${PNG_LIBRARY}) ENDIF(QT_QCONFIG MATCHES "system-png") @@ -141,16 +138,6 @@ IF(QT_QCONFIG MATCHES "xfixes") ENDIF(QT_QCONFIG MATCHES "xfixes") -## system-freetype -IF(QT_QCONFIG MATCHES "system-freetype") - FIND_LIBRARY(QT_FREETYPE_LIBRARY NAMES freetype) - MARK_AS_ADVANCED(QT_FREETYPE_LIBRARY) - IF(QT_FREETYPE_LIBRARY) - SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${QT_FREETYPE_LIBRARY}) - ENDIF(QT_FREETYPE_LIBRARY) -ENDIF(QT_QCONFIG MATCHES "system-freetype") - - ## fontconfig IF(QT_QCONFIG MATCHES "fontconfig") FIND_LIBRARY(QT_FONTCONFIG_LIBRARY NAMES fontconfig) @@ -161,13 +148,19 @@ IF(QT_QCONFIG MATCHES "fontconfig") ENDIF(QT_QCONFIG MATCHES "fontconfig") +## system-freetype +IF(QT_QCONFIG MATCHES "system-freetype") + find_package(Freetype) + if(FREETYPE_LIBRARIES) + SET(QT_QTGUI_LIB_DEPENDENCIES ${QT_QTGUI_LIB_DEPENDENCIES} ${FREETYPE_LIBRARIES}) + endif(FREETYPE_LIBRARIES) +ENDIF(QT_QCONFIG MATCHES "system-freetype") + + ## system-zlib IF(QT_QCONFIG MATCHES "system-zlib") - FIND_LIBRARY(QT_ZLIB_LIBRARY NAMES z) - MARK_AS_ADVANCED(QT_ZLIB_LIBRARY) - IF(QT_ZLIB_LIBRARY) - SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${QT_ZLIB_LIBRARY}) - ENDIF(QT_ZLIB_LIBRARY) + find_package(ZLIB) + SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} ${ZLIB_LIBRARIES}) ENDIF(QT_QCONFIG MATCHES "system-zlib") @@ -192,29 +185,11 @@ ENDIF(NOT Q_WS_WIN) ## dbus IF(QT_QCONFIG MATCHES "dbus") - # if the dbus library isn't found, we'll assume its not required to build - # shared Qt on Linux doesn't require it - IF(NOT QT_DBUS_LIBRARY) - EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L dbus-1 - OUTPUT_VARIABLE _dbus_query_output - RESULT_VARIABLE _dbus_result - ERROR_VARIABLE _dbus_query_output ) - - IF(_dbus_result MATCHES 0) - STRING(REPLACE "-L" "" _dbus_query_output "${_dbus_query_output}") - SEPARATE_ARGUMENTS(_dbus_query_output) - ELSE(_dbus_result MATCHES 0) - SET(_dbus_query_output) - ENDIF(_dbus_result MATCHES 0) - - FIND_LIBRARY(QT_DBUS_LIBRARY NAMES dbus-1 PATHS ${_dbus_query_output} ) - - IF(QT_DBUS_LIBRARY) - SET(QT_QTDBUS_LIB_DEPENDENCIES ${QT_QTDBUS_LIB_DEPENDENCIES} ${QT_DBUS_LIBRARY}) - ENDIF(QT_DBUS_LIBRARY) - - MARK_AS_ADVANCED(QT_DBUS_LIBRARY) - ENDIF(NOT QT_DBUS_LIBRARY) + FIND_LIBRARY(QT_DBUS_LIBRARY NAMES dbus-1 ) + IF(QT_DBUS_LIBRARY) + SET(QT_QTDBUS_LIB_DEPENDENCIES ${QT_QTDBUS_LIB_DEPENDENCIES} ${QT_DBUS_LIBRARY}) + ENDIF(QT_DBUS_LIBRARY) + MARK_AS_ADVANCED(QT_DBUS_LIBRARY) ENDIF(QT_QCONFIG MATCHES "dbus") @@ -222,29 +197,11 @@ ENDIF(QT_QCONFIG MATCHES "dbus") ## glib IF(QT_QCONFIG MATCHES "glib") - # if the glib libraries aren't found, we'll assume its not required to build - # shared Qt on Linux doesn't require it - # Qt 4.2.0+ uses glib-2.0 - IF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY) - EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L glib-2.0 gthread-2.0 - OUTPUT_VARIABLE _glib_query_output - RESULT_VARIABLE _glib_result - ERROR_VARIABLE _glib_query_output ) - - IF(_glib_result MATCHES 0) - STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}") - SEPARATE_ARGUMENTS(_glib_query_output) - ELSE(_glib_result MATCHES 0) - SET(_glib_query_output) - ENDIF(_glib_result MATCHES 0) - - FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0 PATHS ${_glib_query_output} ) - FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0 PATHS ${_glib_query_output} ) - - MARK_AS_ADVANCED(QT_GLIB_LIBRARY) - MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY) - ENDIF(NOT QT_GLIB_LIBRARY OR NOT QT_GTHREAD_LIBRARY) + FIND_LIBRARY(QT_GLIB_LIBRARY NAMES glib-2.0 ) + FIND_LIBRARY(QT_GTHREAD_LIBRARY NAMES gthread-2.0 ) + MARK_AS_ADVANCED(QT_GLIB_LIBRARY) + MARK_AS_ADVANCED(QT_GTHREAD_LIBRARY) IF(QT_GLIB_LIBRARY AND QT_GTHREAD_LIBRARY) SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} @@ -254,23 +211,8 @@ IF(QT_QCONFIG MATCHES "glib") # Qt 4.5+ also links to gobject-2.0 IF(QT_VERSION_MINOR GREATER 4) - IF(NOT QT_GOBJECT_LIBRARY) - EXECUTE_PROCESS(COMMAND pkg-config --libs-only-L gobject-2.0 - OUTPUT_VARIABLE _glib_query_output - RESULT_VARIABLE _glib_result - ERROR_VARIABLE _glib_query_output ) - - IF(_glib_result MATCHES 0) - STRING(REPLACE "-L" "" _glib_query_output "${_glib_query_output}") - SEPARATE_ARGUMENTS(_glib_query_output) - ELSE(_glib_result MATCHES 0) - SET(_glib_query_output) - ENDIF(_glib_result MATCHES 0) - - FIND_LIBRARY(QT_GOBJECT_LIBRARY NAMES gobject-2.0 PATHS ${_glib_query_output} ) - - MARK_AS_ADVANCED(QT_GOBJECT_LIBRARY) - ENDIF(NOT QT_GOBJECT_LIBRARY) + FIND_LIBRARY(QT_GOBJECT_LIBRARY NAMES gobject-2.0 PATHS ${_glib_query_output} ) + MARK_AS_ADVANCED(QT_GOBJECT_LIBRARY) IF(QT_GOBJECT_LIBRARY) SET(QT_QTCORE_LIB_DEPENDENCIES ${QT_QTCORE_LIB_DEPENDENCIES} diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index bd72c8f64..700d3a246 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -10,7 +10,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) @@ -129,7 +129,11 @@ MACRO (QT4_GENERATE_MOC infile outfile ) # get include dirs and flags QT4_GET_MOC_FLAGS(moc_flags) GET_FILENAME_COMPONENT(abs_infile ${infile} ABSOLUTE) - QT4_CREATE_MOC_COMMAND(${abs_infile} ${outfile} "${moc_flags}" "") + SET(_outfile "${outfile}") + IF(NOT IS_ABSOLUTE "${outfile}") + SET(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}") + ENDIF(NOT IS_ABSOLUTE "${outfile}") + QT4_CREATE_MOC_COMMAND(${abs_infile} ${_outfile} "${moc_flags}" "") SET_SOURCE_FILES_PROPERTIES(${outfile} PROPERTIES SKIP_AUTOMOC TRUE) # dont run automoc on this file ENDMACRO (QT4_GENERATE_MOC) @@ -187,10 +191,9 @@ MACRO (QT4_ADD_RESOURCES outfiles ) SET(_RC_DEPENDS) FOREACH(_RC_FILE ${_RC_FILES}) STRING(REGEX REPLACE "^]*>" "" _RC_FILE "${_RC_FILE}") - STRING(REGEX MATCH "^/|([A-Za-z]:/)" _ABS_PATH_INDICATOR "${_RC_FILE}") - IF(NOT _ABS_PATH_INDICATOR) + IF(NOT IS_ABSOLUTE "${_RC_FILE}") SET(_RC_FILE "${rc_path}/${_RC_FILE}") - ENDIF(NOT _ABS_PATH_INDICATOR) + ENDIF(NOT IS_ABSOLUTE "${_RC_FILE}") SET(_RC_DEPENDS ${_RC_DEPENDS} "${_RC_FILE}") ENDFOREACH(_RC_FILE) ADD_CUSTOM_COMMAND(OUTPUT ${outfile} diff --git a/Modules/SelectLibraryConfigurations.cmake b/Modules/SelectLibraryConfigurations.cmake index edba5d9d6..51b4dda06 100644 --- a/Modules/SelectLibraryConfigurations.cmake +++ b/Modules/SelectLibraryConfigurations.cmake @@ -26,7 +26,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This macro was adapted from the FindQt4 CMake module and is maintained by Will diff --git a/Modules/SquishTestScript.cmake b/Modules/SquishTestScript.cmake index d42a84c21..9eac9707f 100644 --- a/Modules/SquishTestScript.cmake +++ b/Modules/SquishTestScript.cmake @@ -19,7 +19,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) cmake_minimum_required(VERSION 2.6 FATAL_ERROR) diff --git a/Modules/SystemInformation.cmake b/Modules/SystemInformation.cmake index ef9b427e2..d973e90f4 100644 --- a/Modules/SystemInformation.cmake +++ b/Modules/SystemInformation.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) PROJECT(DumpInformation) diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake index 751412799..996060210 100644 --- a/Modules/TestBigEndian.cmake +++ b/Modules/TestBigEndian.cmake @@ -14,7 +14,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(TEST_BIG_ENDIAN VARIABLE) diff --git a/Modules/TestCXXAcceptsFlag.cmake b/Modules/TestCXXAcceptsFlag.cmake index 98b2f9bcd..52d0cf3e6 100644 --- a/Modules/TestCXXAcceptsFlag.cmake +++ b/Modules/TestCXXAcceptsFlag.cmake @@ -17,7 +17,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) MACRO(CHECK_CXX_ACCEPTS_FLAG FLAGS VARIABLE) diff --git a/Modules/TestForANSIForScope.cmake b/Modules/TestForANSIForScope.cmake index 6581d07b1..ae2acef7e 100644 --- a/Modules/TestForANSIForScope.cmake +++ b/Modules/TestForANSIForScope.cmake @@ -13,7 +13,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF("CMAKE_ANSI_FOR_SCOPE" MATCHES "^CMAKE_ANSI_FOR_SCOPE$") diff --git a/Modules/TestForANSIStreamHeaders.cmake b/Modules/TestForANSIStreamHeaders.cmake index f62f3a4db..19c1ab2f2 100644 --- a/Modules/TestForANSIStreamHeaders.cmake +++ b/Modules/TestForANSIStreamHeaders.cmake @@ -13,7 +13,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) INCLUDE(CheckIncludeFileCXX) diff --git a/Modules/TestForSSTREAM.cmake b/Modules/TestForSSTREAM.cmake index 4c8b11b97..8dd53e744 100644 --- a/Modules/TestForSSTREAM.cmake +++ b/Modules/TestForSSTREAM.cmake @@ -13,7 +13,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF("CMAKE_HAS_ANSI_STRING_STREAM" MATCHES "^CMAKE_HAS_ANSI_STRING_STREAM$") diff --git a/Modules/TestForSTDNamespace.cmake b/Modules/TestForSTDNamespace.cmake index f0966d01d..932d6e994 100644 --- a/Modules/TestForSTDNamespace.cmake +++ b/Modules/TestForSTDNamespace.cmake @@ -13,7 +13,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF("CMAKE_STD_NAMESPACE" MATCHES "^CMAKE_STD_NAMESPACE$") diff --git a/Modules/UseEcos.cmake b/Modules/UseEcos.cmake index 9785cd533..60e1e46b4 100644 --- a/Modules/UseEcos.cmake +++ b/Modules/UseEcos.cmake @@ -26,7 +26,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # first check that ecosconfig is available diff --git a/Modules/UsePkgConfig.cmake b/Modules/UsePkgConfig.cmake index e8194d5d2..d101e61d0 100644 --- a/Modules/UsePkgConfig.cmake +++ b/Modules/UsePkgConfig.cmake @@ -20,7 +20,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config ) diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake index 63a091973..ab028ed98 100644 --- a/Modules/UseQt4.cmake +++ b/Modules/UseQt4.cmake @@ -13,7 +13,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) ADD_DEFINITIONS(${QT_DEFINITIONS}) @@ -27,9 +27,9 @@ INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}) SET(QT_LIBRARIES "") IF (QT_USE_QTMAIN) - IF (WIN32) + IF (Q_WS_WIN) SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY}) - ENDIF (WIN32) + ENDIF (Q_WS_WIN) ENDIF (QT_USE_QTMAIN) IF(QT_DONT_USE_QTGUI) diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake index c79efac0f..b547dc7dd 100644 --- a/Modules/UseSWIG.cmake +++ b/Modules/UseSWIG.cmake @@ -30,7 +30,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) SET(SWIG_CXX_EXTENSION "cxx") diff --git a/Modules/UseVTK40.cmake b/Modules/UseVTK40.cmake index 560039fd1..c1157d6be 100644 --- a/Modules/UseVTK40.cmake +++ b/Modules/UseVTK40.cmake @@ -10,7 +10,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This is an implementation detail for using VTK 4.0 with the diff --git a/Modules/UseVTKBuildSettings40.cmake b/Modules/UseVTKBuildSettings40.cmake index 693743c25..4df59b9dd 100644 --- a/Modules/UseVTKBuildSettings40.cmake +++ b/Modules/UseVTKBuildSettings40.cmake @@ -10,7 +10,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # Implementation detail for FindVTK.cmake to let it provide a diff --git a/Modules/UseVTKConfig40.cmake b/Modules/UseVTKConfig40.cmake index 2100d84e2..ca5e7aa3c 100644 --- a/Modules/UseVTKConfig40.cmake +++ b/Modules/UseVTKConfig40.cmake @@ -10,7 +10,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # This is an implementation detail for using VTK 4.0 with the diff --git a/Modules/Use_wxWindows.cmake b/Modules/Use_wxWindows.cmake index 2bae99c5f..01a15168e 100644 --- a/Modules/Use_wxWindows.cmake +++ b/Modules/Use_wxWindows.cmake @@ -24,7 +24,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # ----------------------------------------------------- diff --git a/Modules/UsewxWidgets.cmake b/Modules/UsewxWidgets.cmake index b001f6a81..9ecfff0cc 100644 --- a/Modules/UsewxWidgets.cmake +++ b/Modules/UsewxWidgets.cmake @@ -1,15 +1,13 @@ -# - Convenience include for using wxWidgets library -# Finds if wxWidgets is installed -# and set the appropriate libs, incdirs, flags etc. -# INCLUDE_DIRECTORIES, LINK_DIRECTORIES and ADD_DEFINITIONS -# are called. +# - Convenience include for using wxWidgets library. +# Determines if wxWidgets was FOUND and sets the appropriate libs, incdirs, +# flags, etc. INCLUDE_DIRECTORIES and LINK_DIRECTORIES are called. # # USAGE -# SET( wxWidgets_USE_LIBS gl xml xrc ) # optionally: more than wx std libs -# FIND_PACKAGE(wxWidgets REQUIRED) -# INCLUDE( ${xWidgets_USE_FILE} ) -# ... add your targets here, e.g. ADD_EXECUTABLE/ ADD_LIBRARY ... -# TARGET_LINK_LIBRARIERS( ${wxWidgets_LIBRARIES}) +# # Note that for MinGW users the order of libs is important! +# FIND_PACKAGE(wxWidgets REQUIRED net gl core base) +# INCLUDE(${wxWidgets_USE_FILE}) +# # and for each of your dependant executable/library targets: +# TARGET_LINK_LIBRARIES( ${wxWidgets_LIBRARIES}) # # DEPRECATED # LINK_LIBRARIES is not called in favor of adding dependencies per target. @@ -28,7 +26,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # debug message and logging. diff --git a/Modules/VTKCompatibility.cmake b/Modules/VTKCompatibility.cmake index c0b3d6226..802969f2f 100644 --- a/Modules/VTKCompatibility.cmake +++ b/Modules/VTKCompatibility.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) IF(APPLE) diff --git a/Modules/ecos_clean.cmake b/Modules/ecos_clean.cmake index b76137ce0..7a563ae23 100644 --- a/Modules/ecos_clean.cmake +++ b/Modules/ecos_clean.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) file(GLOB _files ${ECOS_DIR}/*) diff --git a/Modules/kde3uic.cmake b/Modules/kde3uic.cmake index b52dc093f..6f904ac92 100644 --- a/Modules/kde3uic.cmake +++ b/Modules/kde3uic.cmake @@ -10,7 +10,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) # used internally by KDE3Macros.cmake diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index dbbb558ea..71284b2dc 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -112,6 +112,7 @@ ENDIF(CMAKE_USE_ELF_PARSER) # SET(SRCS cmStandardIncludes.cxx + cmArchiveWrite.cxx cmBootstrapCommands.cxx cmCacheManager.cxx cmCacheManager.h @@ -350,7 +351,7 @@ ENDIF(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW) # CTestLib # INCLUDE_DIRECTORIES( - "${CMAKE_SOURCE_DIR}/Source/CTest" + "${CMake_SOURCE_DIR}/Source/CTest" ${CMAKE_XMLRPC_INCLUDES} ${CMAKE_CURL_INCLUDES} ) @@ -493,8 +494,8 @@ IF(BUILD_QtDialog) SUBDIRS(QtDialog) ENDIF(BUILD_QtDialog) -INCLUDE (${CMAKE_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL) -INCLUDE (${CMAKE_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL) +INCLUDE (${CMake_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL) +INCLUDE (${CMake_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL) INSTALL_TARGETS(/bin cmake) INSTALL_TARGETS(/bin ctest) diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx index a52d05eea..c86434e46 100644 --- a/Source/CPack/cmCPackArchiveGenerator.cxx +++ b/Source/CPack/cmCPackArchiveGenerator.cxx @@ -22,13 +22,12 @@ #include #include -#include -#include - +#include +#include //---------------------------------------------------------------------- -cmCPackArchiveGenerator::cmCPackArchiveGenerator(CompressType t, - ArchiveType at) +cmCPackArchiveGenerator::cmCPackArchiveGenerator(cmArchiveWrite::Compress t, + cmArchiveWrite::Type at) { this->Compress = t; this->Archive = at; @@ -39,222 +38,291 @@ cmCPackArchiveGenerator::~cmCPackArchiveGenerator() { } -static const size_t cmCPackTGZ_Data_BlockSize = 16384; - -// make this an anonymous namespace so that archive.h does not -// have to be included in the .h file for this class -namespace +//---------------------------------------------------------------------- +int cmCPackArchiveGenerator::InitializeInternal() { -bool SetArchiveType(struct archive* a, - cmCPackArchiveGenerator::CompressType ct, - cmCPackArchiveGenerator::ArchiveType at) + this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1"); + return this->Superclass::InitializeInternal(); +} +//---------------------------------------------------------------------- +int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive, + cmCPackComponent* component) { - int res = 0; - // pick the archive type - switch(at) - { - case cmCPackArchiveGenerator::TAR: - // maybe this: - res = archive_write_set_format_pax_restricted(a); - break; - case cmCPackArchiveGenerator::ZIP: - res = archive_write_set_format_zip(a); - break; - } - if(res != ARCHIVE_OK) - { - return false; - } - - // pick a compression type - switch(ct) - { - case cmCPackArchiveGenerator::GZIP: - res = archive_write_set_compression_gzip(a); - break; - case cmCPackArchiveGenerator::BZIP2: - res = archive_write_set_compression_bzip2(a); - break; - case cmCPackArchiveGenerator::COMPRESS: - res = archive_write_set_compression_compress(a); - break; - case cmCPackArchiveGenerator::LZMA: - res = archive_write_set_compression_lzma(a); - break; - case cmCPackArchiveGenerator::NONE: - default: - res = archive_write_set_compression_none(a); - } - if(res != ARCHIVE_OK) - { - return false; - } - // do not pad the last block!! - res = archive_write_set_bytes_in_last_block(a, 1); - if(res != ARCHIVE_OK) + cmCPackLogger(cmCPackLog::LOG_VERBOSE, " - packaging component: " + << component->Name + << std::endl); + // Add the files of this component to the archive + std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); + localToplevel += "/"+ component->Name; + std::string dir = cmSystemTools::GetCurrentWorkingDirectory(); + // Change to local toplevel + cmSystemTools::ChangeDirectory(localToplevel.c_str()); + std::vector::const_iterator fileIt; + for (fileIt = component->Files.begin(); fileIt != component->Files.end(); + ++fileIt ) { - return false; + cmCPackLogger(cmCPackLog::LOG_DEBUG,"Adding file: " + << (*fileIt) << std::endl); + archive.Add(*fileIt); + if (!archive) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, "ERROR while packaging files: " + << archive.GetError() + << std::endl); + return 0; + } } - - return true; + // Go back to previous dir + cmSystemTools::ChangeDirectory(dir.c_str()); + return 1; } - -struct StreamData -{ - StreamData(cmGeneratedFileStream* gfs, - cmCPackArchiveGenerator* ag) - { - this->GeneratedFileStream = gfs; - this->Generator = ag; - } - cmGeneratedFileStream* GeneratedFileStream; - cmCPackArchiveGenerator* Generator; -}; +/* + * The macro will open/create a file 'filename' + * an declare and open the associated + * cmArchiveWrite 'archive' object. + */ +#define DECLARE_AND_OPEN_ARCHIVE(filename,archive) \ +cmGeneratedFileStream gf; \ +gf.Open(filename.c_str(), false, true); \ +if (!GenerateHeader(&gf)) \ + { \ + cmCPackLogger(cmCPackLog::LOG_ERROR, \ + "Problem to generate Header for archive < " \ + << filename \ + << ">." << std::endl); \ + return 0; \ + } \ +cmArchiveWrite archive(gf,this->Compress, this->Archive); \ +if (!archive) \ + { \ + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem to create archive < " \ + << filename \ + << ">. ERROR =" \ + << archive.GetError() \ + << std::endl); \ + return 0; \ + } -extern "C" -{ -int OpenArchive(struct archive *, void *client_data) +//---------------------------------------------------------------------- +int cmCPackArchiveGenerator::PackageComponents(bool ignoreComponentGroup) { - struct StreamData *data = (StreamData*)client_data; - if(data->GeneratedFileStream && - *data->GeneratedFileStream) + packageFileNames.clear(); + // The default behavior is to have one package by component group + // unless CPACK_COMPONENTS_IGNORE_GROUP is specified. + if (!ignoreComponentGroup) { - if(data->Generator-> - GenerateHeader(data->GeneratedFileStream)) + std::map::iterator compGIt; + for (compGIt=this->ComponentGroups.begin(); + compGIt!=this->ComponentGroups.end(); ++compGIt) { - return ARCHIVE_OK; + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " + << compGIt->first + << std::endl); + // Begin the archive for this group + std::string packageFileName= std::string(toplevel); + packageFileName += "/" + +std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + +"-"+compGIt->first + this->GetOutputExtension(); + // open a block in order to automatically close archive + // at the end of the block + { + DECLARE_AND_OPEN_ARCHIVE(packageFileName,archive); + // now iterate over the component of this group + std::vector::iterator compIt; + for (compIt=(compGIt->second).Components.begin(); + compIt!=(compGIt->second).Components.end(); + ++compIt) + { + // Add the files of this component to the archive + addOneComponentToArchive(archive,*compIt); + } + } + // add the generated package to package file names list + packageFileNames.push_back(packageFileName); } } - return (ARCHIVE_FATAL); -} - -__LA_SSIZE_T WriteArchive(struct archive *, - void *client_data, - const void *buff, - size_t n) -{ - struct StreamData *data = (StreamData*)client_data; - data->GeneratedFileStream-> - write(reinterpret_cast(buff),n); - if(!data->GeneratedFileStream->bad()) + // CPACK_COMPONENTS_IGNORE_GROUPS is set + // We build 1 package per component + else { - return n; + std::map::iterator compIt; + for (compIt=this->Components.begin(); + compIt!=this->Components.end(); ++compIt ) + { + std::string localToplevel(this->GetOption("CPACK_TEMPORARY_DIRECTORY")); + std::string packageFileName = std::string(toplevel); + + localToplevel += "/"+ compIt->first; + packageFileName += "/" + +std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + +"-"+compIt->first + this->GetOutputExtension(); + { + DECLARE_AND_OPEN_ARCHIVE(packageFileName,archive); + // Add the files of this component to the archive + addOneComponentToArchive(archive,&(compIt->second)); + } + // add the generated package to package file names list + packageFileNames.push_back(packageFileName); + } } - return 0; + return 1; } - -int CloseArchive(struct archive *, void *client_data) +//---------------------------------------------------------------------- +int cmCPackArchiveGenerator::PackageComponentsAllInOne(bool allComponentInOne) { - struct StreamData *data = (StreamData*)client_data; - if(data->GeneratedFileStream->Close()) + // reset the package file names + packageFileNames.clear(); + packageFileNames.push_back(std::string(toplevel)); + packageFileNames[0] += "/" + +std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME")) + +"-ALL" + this->GetOutputExtension(); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, + "Packaging all groups in one package..." + "(CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE is set)" + << std::endl); + DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0],archive); + + // The ALL GROUP in ONE package case + if (! allComponentInOne) { + // iterate over the component groups + std::map::iterator compGIt; + for (compGIt=this->ComponentGroups.begin(); + compGIt!=this->ComponentGroups.end(); ++compGIt) + { + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Packaging component group: " + << compGIt->first + << std::endl); + // now iterate over the component of this group + std::vector::iterator compIt; + for (compIt=(compGIt->second).Components.begin(); + compIt!=(compGIt->second).Components.end(); + ++compIt) + { + // Add the files of this component to the archive + addOneComponentToArchive(archive,*compIt); + } + } + } + // The ALL COMPONENT in ONE package case + else { - delete data->GeneratedFileStream; - return ARCHIVE_OK; + std::map::iterator compIt; + for (compIt=this->Components.begin();compIt!=this->Components.end(); + ++compIt ) + { + // Add the files of this component to the archive + addOneComponentToArchive(archive,&(compIt->second)); + } } - return ARCHIVE_FATAL; + // archive goes out of scope so it will finalized and closed. + return 1; } -} //extern C -} // anon name space - //---------------------------------------------------------------------- -int cmCPackArchiveGenerator::InitializeInternal() +int cmCPackArchiveGenerator::PackageFiles() { - this->SetOptionIfNotSet("CPACK_INCLUDE_TOPLEVEL_DIRECTORY", "1"); - return this->Superclass::InitializeInternal(); -} + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Toplevel: " + << toplevel << std::endl); -int cmCPackArchiveGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector& files) -{ - int res = ARCHIVE_OK; -#define CHECK_ARCHIVE_ERROR(res, msg) \ - if(res != ARCHIVE_OK) \ - {\ - cmCPackLogger(cmCPackLog::LOG_ERROR, msg \ - << archive_error_string(a) \ - << cmSystemTools::GetLastSystemError() \ - << " " << res \ - << "\n"); \ + // The default behavior is to create 1 package by component group + // unless the user asked to put all COMPONENTS in a single package + bool allGroupInOne = (NULL != + (this->GetOption( + "CPACK_COMPONENTS_ALL_GROUPS_IN_ONE_PACKAGE"))); + bool allComponentInOne = (NULL != + (this->GetOption( + "CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE"))); + bool ignoreComponentGroup = ( NULL != + (this->GetOption( + "CPACK_COMPONENTS_IGNORE_GROUPS"))); + + std::string groupingType; + + // Second way to specify grouping + if (NULL != this->GetOption("CPACK_COMPONENTS_GROUPING")) { + groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING"); + } + + if (groupingType.length()>0) + { + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "[" + << this->Name << "]" + << " requested component grouping = "<< groupingType <Name << "]" + << " requested component grouping type <"<< groupingType + << "> UNKNOWN not in (ALL_GROUP_IN_ONE," + "ALL_COMPONENT_IN_ONE,IGNORE)" <Compress, this->Archive); - // Open binary stream - cmGeneratedFileStream* gf = new cmGeneratedFileStream; - gf->Open(outFileName, false, true); - StreamData data(gf, this); - // pass callbacks to archive_write_open to handle stream - res = archive_write_open(a, - &data, - OpenArchive, - WriteArchive, - CloseArchive); - CHECK_ARCHIVE_ERROR(res, "archive_write_open:"); - // create a new disk struct - struct archive* disk = archive_read_disk_new(); -#if !defined(_WIN32) || defined(__CYGWIN__) - res = archive_read_disk_set_standard_lookup(disk); -#endif - CHECK_ARCHIVE_ERROR(res, "archive_read_disk_set_standard_lookup:"); + + // Some components were defined but NO group + // force ignoreGroups + if (this->ComponentGroups.empty() && (!this->Components.empty()) + && (!ignoreComponentGroup)) { + cmCPackLogger(cmCPackLog::LOG_WARNING, "[" + << this->Name << "]" + << " Some Components defined but NO component group:" + << " Ignoring component group." + << std::endl); + ignoreComponentGroup = true; + } + // CASE 1 : COMPONENT ALL-IN-ONE package + // If ALL GROUPS or ALL COMPONENTS in ONE package has been requested + // then the package file is unique and should be open here. + if (allComponentInOne || (allGroupInOne && (!this->ComponentGroups.empty()))) + { + return PackageComponentsAllInOne(allComponentInOne); + } + // CASE 2 : COMPONENT CLASSICAL package(s) (i.e. not all-in-one) + // There will be 1 package for each component group + // however one may require to ignore component group and + // in this case you'll get 1 package for each component. + else if ((!this->ComponentGroups.empty()) || (ignoreComponentGroup)) + { + return PackageComponents(ignoreComponentGroup); + } + + // CASE 3 : NON COMPONENT package. + DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0],archive); std::vector::const_iterator fileIt; std::string dir = cmSystemTools::GetCurrentWorkingDirectory(); - cmSystemTools::ChangeDirectory(toplevel); + cmSystemTools::ChangeDirectory(toplevel.c_str()); for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt ) { - // create a new entry for each file - struct archive_entry *entry = archive_entry_new(); // Get the relative path to the file - std::string rp = cmSystemTools::RelativePath(toplevel, fileIt->c_str()); - // Set the name of the entry to the file name - archive_entry_set_pathname(entry, rp.c_str()); - res = archive_read_disk_entry_from_file(disk, entry, -1, 0); - CHECK_ARCHIVE_ERROR(res, "archive_read_disk_entry_from_file:"); - // write entry header - res = archive_write_header(a, entry); - CHECK_ARCHIVE_ERROR(res, "archive_write_header:"); - // the entry size can be 0 if it is a symlink - if(archive_entry_size(entry) > 0) + std::string rp = cmSystemTools::RelativePath(toplevel.c_str(), + fileIt->c_str()); + archive.Add(rp); + if(!archive) { - // now copy contents of file into archive a - FILE* file = fopen(fileIt->c_str(), "rb"); - if(!file) - { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem with fopen(): " - << fileIt->c_str() - << strerror(errno) - << std::endl); - return 0; - } - char buff[cmCPackTGZ_Data_BlockSize]; - size_t len = fread(buff, 1, sizeof(buff), file); - while (len > 0) - { - size_t wlen = archive_write_data(a, buff, len); - if(wlen != len) - { - cmCPackLogger(cmCPackLog::LOG_ERROR, "archive_write_data(): " - << "tried to write " << len << "\n" - << "write " << wlen << "\n"); - return 0; - } - len = fread(buff, 1, sizeof(buff), file); - } - // close the file and free the entry - fclose(file); + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem while adding file< " + << *fileIt + << "> to archive <" + << packageFileNames[0] << "> .ERROR =" + << archive.GetError() + << std::endl); + return 0; } - archive_entry_free(entry); } cmSystemTools::ChangeDirectory(dir.c_str()); - // close the archive and finish the write - archive_write_close(a); - archive_write_finish(a); - archive_read_finish(disk); + // The destructor of cmArchiveWrite will close and finish the write return 1; } @@ -263,3 +331,7 @@ int cmCPackArchiveGenerator::GenerateHeader(std::ostream*) { return 1; } + +bool cmCPackArchiveGenerator::SupportsComponentInstallation() const { + return true; +} diff --git a/Source/CPack/cmCPackArchiveGenerator.h b/Source/CPack/cmCPackArchiveGenerator.h index 486db8e5d..6e173bd9c 100644 --- a/Source/CPack/cmCPackArchiveGenerator.h +++ b/Source/CPack/cmCPackArchiveGenerator.h @@ -13,35 +13,62 @@ #ifndef cmCPackArchiveGenerator_h #define cmCPackArchiveGenerator_h +#include "cmArchiveWrite.h" #include "cmCPackGenerator.h" /** \class cmCPackArchiveGenerator - * \brief A generator base for libarchive generation + * \brief A generator base for libarchive generation. + * The generator itself uses the libarchive wrapper + * \ref cmArchiveWrite. * */ class cmCPackArchiveGenerator : public cmCPackGenerator -{ + { public: - enum CompressType{ GZIP, BZIP2, COMPRESS, LZMA, NONE}; - enum ArchiveType{ TAR, ZIP}; cmTypeMacro(cmCPackArchiveGenerator, cmCPackGenerator); /** * Construct generator */ - cmCPackArchiveGenerator(CompressType, ArchiveType); + cmCPackArchiveGenerator(cmArchiveWrite::Compress, cmArchiveWrite::Type); virtual ~cmCPackArchiveGenerator(); // Used to add a header to the archive virtual int GenerateHeader(std::ostream* os); - + // component support + virtual bool SupportsComponentInstallation() const; protected: virtual int InitializeInternal(); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector& files); + /** + * Add the files belonging to the specified component + * to the provided (already opened) archive. + * @param[in,out] archive the archive object + * @param[in] component the component whose file will be added to archive + */ + int addOneComponentToArchive(cmArchiveWrite& archive, + cmCPackComponent* component); + + /** + * The main package file method. + * If component install was required this + * method will call either PackageComponents or + * PackageComponentsAllInOne. + */ + int PackageFiles(); + /** + * The method used to package files when component + * install is used. This will create one + * archive for each component group. + */ + int PackageComponents(bool ignoreComponentGroup); + /** + * Special case of component install where all + * components will be put in a single installer. + */ + int PackageComponentsAllInOne(bool allComponentInOne); virtual const char* GetOutputExtension() = 0; - CompressType Compress; - ArchiveType Archive; -}; + cmArchiveWrite::Compress Compress; + cmArchiveWrite::Type Archive; + }; #endif diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index 247a04301..06a050992 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -53,10 +53,8 @@ const char* cmCPackBundleGenerator::GetPackagingInstallPrefix() } //---------------------------------------------------------------------- -int cmCPackBundleGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector& files) +int cmCPackBundleGenerator::PackageFiles() { - (void) files; // Get required arguments ... const std::string cpack_bundle_name = this->GetOption("CPACK_BUNDLE_NAME") @@ -167,5 +165,5 @@ int cmCPackBundleGenerator::CompressFiles(const char* outFileName, cmSystemTools::SetPermissions(command_target.str().c_str(), 0777); } - return this->CreateDMG(toplevel, outFileName); + return this->CreateDMG(); } diff --git a/Source/CPack/cmCPackBundleGenerator.h b/Source/CPack/cmCPackBundleGenerator.h index ce055419f..82814b0a5 100644 --- a/Source/CPack/cmCPackBundleGenerator.h +++ b/Source/CPack/cmCPackBundleGenerator.h @@ -31,8 +31,7 @@ public: protected: virtual int InitializeInternal(); virtual const char* GetPackagingInstallPrefix(); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector& files); + int PackageFiles(); std::string InstallPrefix; }; diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx index 853a1beb6..6c8fc54e0 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.cxx +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.cxx @@ -41,8 +41,7 @@ int cmCPackCygwinBinaryGenerator::InitializeInternal() } //---------------------------------------------------------------------- -int cmCPackCygwinBinaryGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector& files) +int cmCPackCygwinBinaryGenerator::PackageFiles() { std::string packageName = this->GetOption("CPACK_PACKAGE_NAME"); packageName += "-"; @@ -70,12 +69,10 @@ int cmCPackCygwinBinaryGenerator::CompressFiles(const char* outFileName, ofs << manifest << "\n"; } // add the manifest file to the list of all files - std::vector filesWithManifest = files; - filesWithManifest.push_back(manifestFile); + files.push_back(manifestFile); // create the bzip2 tar file - return this->Superclass::CompressFiles(outFileName, toplevel, - filesWithManifest); + return this->Superclass::PackageFiles(); } const char* cmCPackCygwinBinaryGenerator::GetOutputExtension() diff --git a/Source/CPack/cmCPackCygwinBinaryGenerator.h b/Source/CPack/cmCPackCygwinBinaryGenerator.h index 19b09f0b9..38f6df17d 100644 --- a/Source/CPack/cmCPackCygwinBinaryGenerator.h +++ b/Source/CPack/cmCPackCygwinBinaryGenerator.h @@ -30,8 +30,7 @@ public: virtual ~cmCPackCygwinBinaryGenerator(); protected: virtual int InitializeInternal(); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector& files); + int PackageFiles(); virtual const char* GetOutputExtension(); std::string OutputExtension; }; diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.cxx b/Source/CPack/cmCPackCygwinSourceGenerator.cxx index cca833854..597972992 100644 --- a/Source/CPack/cmCPackCygwinSourceGenerator.cxx +++ b/Source/CPack/cmCPackCygwinSourceGenerator.cxx @@ -48,21 +48,19 @@ int cmCPackCygwinSourceGenerator::InitializeInternal() } //---------------------------------------------------------------------- -int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector& files) +int cmCPackCygwinSourceGenerator::PackageFiles() { // Create a tar file of the sources std::string packageDirFileName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); packageDirFileName += ".tar.bz2"; + packageFileNames[0] = packageDirFileName; std::string output; // skip one parent up to the cmCPackTarBZip2Generator // to create tar.bz2 file with the list of source // files - this->Compress = BZIP2; - if ( !this->cmCPackTarBZip2Generator:: - CompressFiles(packageDirFileName.c_str(), - toplevel, files) ) + this->Compress = cmArchiveWrite::CompressBZip2; + if ( !this->cmCPackTarBZip2Generator::PackageFiles() ) { return 0; } @@ -135,21 +133,25 @@ int cmCPackCygwinSourceGenerator::CompressFiles(const char* outFileName, patchFile += "/"; patchFile += cmSystemTools::GetFilenameName( this->GetOption("CPACK_CYGWIN_PATCH_FILE")); - std::vector outerFiles; + std::string file = cmSystemTools::GetFilenameName(compressOutFile); std::string sourceTar = cmSystemTools::GetFilenamePath(compressOutFile); sourceTar += "/"; sourceTar += file; + /* reset list of file to be packaged */ + files.clear(); // a source release in cygwin should have the build script used // to build the package, the patch file that is different from the // regular upstream version of the sources, and a bziped tar file // of the original sources - outerFiles.push_back(buildScript); - outerFiles.push_back(patchFile); - outerFiles.push_back(sourceTar); - if ( !this->cmCPackTarBZip2Generator:: - CompressFiles(outerTarFile.c_str(), - tmpDir.c_str(), outerFiles) ) + files.push_back(buildScript); + files.push_back(patchFile); + files.push_back(sourceTar); + /* update the name of the produced package */ + packageFileNames[0] = outerTarFile; + /* update the toplevel dir */ + toplevel = tmpDir; + if ( !this->cmCPackTarBZip2Generator::PackageFiles() ) { return 0; } diff --git a/Source/CPack/cmCPackCygwinSourceGenerator.h b/Source/CPack/cmCPackCygwinSourceGenerator.h index 9817cf9ac..9d98a9b95 100644 --- a/Source/CPack/cmCPackCygwinSourceGenerator.h +++ b/Source/CPack/cmCPackCygwinSourceGenerator.h @@ -31,8 +31,7 @@ public: protected: const char* GetPackagingInstallPrefix(); virtual int InitializeInternal(); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector& files); + int PackageFiles(); virtual const char* GetOutputExtension(); std::string InstallPrefix; std::string OutputExtension; diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 9c77cc198..47a1ff64c 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -43,14 +43,15 @@ cmCPackDebGenerator::~cmCPackDebGenerator() int cmCPackDebGenerator::InitializeInternal() { this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr"); - + if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) + { + this->SetOption("CPACK_SET_DESTDIR", "I_ON"); + } return this->Superclass::InitializeInternal(); } //---------------------------------------------------------------------- -int cmCPackDebGenerator::CompressFiles(const char* outFileName, - const char* toplevel, - const std::vector& files) +int cmCPackDebGenerator::PackageFiles() { this->ReadListFile("CPackDeb.cmake"); const char* cmakeExecutable = this->GetOption("CMAKE_COMMAND"); @@ -87,10 +88,24 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName, // optional entries const char* debian_pkg_dep = this->GetOption("CPACK_DEBIAN_PACKAGE_DEPENDS"); - const char* debian_pkg_rec = + const char* debian_pkg_rec = this->GetOption("CPACK_DEBIAN_PACKAGE_RECOMMENDS"); - const char* debian_pkg_sug = + const char* debian_pkg_sug = this->GetOption("CPACK_DEBIAN_PACKAGE_SUGGESTS"); + const char* debian_pkg_url = + this->GetOption("CPACK_DEBIAN_PACKAGE_HOMEPAGE"); + const char* debian_pkg_predep = + this->GetOption("CPACK_DEBIAN_PACKAGE_PREDEPENDS"); + const char* debian_pkg_enhances = + this->GetOption("CPACK_DEBIAN_PACKAGE_ENHANCES"); + const char* debian_pkg_breaks = + this->GetOption("CPACK_DEBIAN_PACKAGE_BREAKS"); + const char* debian_pkg_conflicts = + this->GetOption("CPACK_DEBIAN_PACKAGE_CONFLICTS"); + const char* debian_pkg_provides = + this->GetOption("CPACK_DEBIAN_PACKAGE_PROVIDES"); + const char* debian_pkg_replaces = + this->GetOption("CPACK_DEBIAN_PACKAGE_REPLACES"); { // the scope is needed for cmGeneratedFileStream cmGeneratedFileStream out(ctlfilename.c_str()); @@ -99,18 +114,46 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName, out << "Section: " << debian_pkg_section << "\n"; out << "Priority: " << debian_pkg_priority << "\n"; out << "Architecture: " << debian_pkg_arch << "\n"; - if(debian_pkg_dep) + if(debian_pkg_dep && *debian_pkg_dep) { out << "Depends: " << debian_pkg_dep << "\n"; } - if(debian_pkg_rec) + if(debian_pkg_rec && *debian_pkg_rec) { out << "Recommends: " << debian_pkg_rec << "\n"; } - if(debian_pkg_sug) + if(debian_pkg_sug && *debian_pkg_sug) { out << "Suggests: " << debian_pkg_sug << "\n"; } + if(debian_pkg_url && *debian_pkg_url) + { + out << "Homepage: " << debian_pkg_url << "\n"; + } + if (debian_pkg_predep && *debian_pkg_predep) + { + out << "Pre-Depends: " << debian_pkg_predep << "\n"; + } + if (debian_pkg_enhances && *debian_pkg_enhances) + { + out << "Enhances: " << debian_pkg_enhances << "\n"; + } + if (debian_pkg_breaks && *debian_pkg_breaks) + { + out << "Breaks: " << debian_pkg_breaks << "\n"; + } + if (debian_pkg_conflicts && *debian_pkg_conflicts) + { + out << "Conflicts: " << debian_pkg_conflicts << "\n"; + } + if (debian_pkg_provides && *debian_pkg_provides) + { + out << "Provides: " << debian_pkg_provides << "\n"; + } + if (debian_pkg_replaces && *debian_pkg_replaces) + { + out << "Replaces: " << debian_pkg_replaces << "\n"; + } unsigned long totalSize = 0; { std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); @@ -121,7 +164,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName, totalSize += cmSystemTools::FileLength(fileIt->c_str()); } } - out << "Installed-Size: " << totalSize << "\n"; + out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n"; out << "Maintainer: " << maintainer << "\n"; out << "Description: " << desc << "\n"; out << std::endl; @@ -135,7 +178,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName, // now add all directories which have to be compressed // collect all top level install dirs for that // e.g. /opt/bin/foo, /usr/bin/bar and /usr/bin/baz would give /usr and /opt - int topLevelLength = strlen(toplevel); + size_t topLevelLength = toplevel.length(); std::set installDirs; for (std::vector::const_iterator fileIt = files.begin(); fileIt != files.end(); ++ fileIt ) @@ -154,7 +197,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName, std::string output; int retVal = -1; int res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, - &retVal, toplevel, this->GeneratorVerbose, 0); + &retVal, toplevel.c_str(), this->GeneratorVerbose, 0); if ( !res || retVal ) { @@ -190,7 +233,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName, //std::string output; //int retVal = -1; res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, - &retVal, toplevel, this->GeneratorVerbose, 0); + &retVal, toplevel.c_str(), this->GeneratorVerbose, 0); // debian md5sums entries are like this: // 014f3604694729f3bf19263bac599765 usr/bin/ccmake // thus strip the full path (with the trailing slash) @@ -231,7 +274,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName, } } res = cmSystemTools::RunSingleCommand(cmd.c_str(), &output, - &retVal, toplevel, this->GeneratorVerbose, 0); + &retVal, toplevel.c_str(), this->GeneratorVerbose, 0); if ( !res || retVal ) { @@ -257,7 +300,7 @@ int cmCPackDebGenerator::CompressFiles(const char* outFileName, arFiles.push_back(topLevelString + "debian-binary"); arFiles.push_back(topLevelString + "control.tar.gz"); arFiles.push_back(topLevelString + "data.tar.gz"); - res = ar_append(outFileName, arFiles); + res = ar_append(packageFileNames[0].c_str(), arFiles); if ( res!=0 ) { std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); @@ -371,7 +414,7 @@ static const char * ar_rname(const char *path) typedef struct ar_hdr HDR; static char ar_hb[sizeof(HDR) + 1]; /* real header */ -static int ar_already_written; +static size_t ar_already_written; /* copy_ar -- * Copy size bytes from one file to another - taking care to handle the @@ -431,7 +474,7 @@ static int put_arobj(CF *cfp, struct stat *sb) /* If not truncating names and the name is too long or contains * a space, use extended format 1. */ - unsigned int lname = strlen(name); + size_t lname = strlen(name); uid_t uid = sb->st_uid; gid_t gid = sb->st_gid; if (uid > USHRT_MAX) { @@ -441,7 +484,7 @@ static int put_arobj(CF *cfp, struct stat *sb) gid = USHRT_MAX; } if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) - (void)sprintf(ar_hb, HDR1, AR_EFMT1, lname, + (void)sprintf(ar_hb, HDR1, AR_EFMT1, (int)lname, (long int)sb->st_mtime, uid, gid, sb->st_mode, (long long)sb->st_size + lname, ARFMAG); else { diff --git a/Source/CPack/cmCPackDebGenerator.h b/Source/CPack/cmCPackDebGenerator.h index d2299449e..4a357d1d6 100644 --- a/Source/CPack/cmCPackDebGenerator.h +++ b/Source/CPack/cmCPackDebGenerator.h @@ -33,8 +33,7 @@ public: protected: virtual int InitializeInternal(); - virtual int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector& files); + virtual int PackageFiles(); virtual const char* GetOutputExtension() { return ".deb"; } }; diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 95324cf64..e9ce76c13 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -104,12 +104,10 @@ const char* cmCPackDragNDropGenerator::GetOutputExtension() } //---------------------------------------------------------------------- -int cmCPackDragNDropGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector& files) +int cmCPackDragNDropGenerator::PackageFiles() { - (void) files; - return this->CreateDMG(toplevel, outFileName); + return this->CreateDMG(); } //---------------------------------------------------------------------- @@ -161,8 +159,7 @@ bool cmCPackDragNDropGenerator::RunCommand(cmOStringStream& command, } //---------------------------------------------------------------------- -int cmCPackDragNDropGenerator::CreateDMG(const std::string& toplevel, - const std::string& outFileName) +int cmCPackDragNDropGenerator::CreateDMG() { // Get optional arguments ... const std::string cpack_package_icon = this->GetOption("CPACK_PACKAGE_ICON") @@ -475,7 +472,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& toplevel, final_image_command << cpack_dmg_format; final_image_command << " -imagekey"; final_image_command << " zlib-level=9"; - final_image_command << " -o \"" << outFileName << "\""; + final_image_command << " -o \"" << packageFileNames[0] << "\""; if(!this->RunCommand(final_image_command)) { diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h index 43a9617e0..dcef7fb28 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.h +++ b/Source/CPack/cmCPackDragNDropGenerator.h @@ -29,14 +29,12 @@ public: protected: virtual int InitializeInternal(); virtual const char* GetOutputExtension(); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector& files); + int PackageFiles(); bool CopyFile(cmOStringStream& source, cmOStringStream& target); bool RunCommand(cmOStringStream& command, std::string* output = 0); - virtual int CreateDMG(const std::string& installdir, - const std::string& outdmg); + int CreateDMG(); std::string InstallPrefix; }; diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 4a4b428fc..c39aea4f2 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -100,6 +100,7 @@ int cmCPackGenerator::PrepareNames() } std::string destFile = pdir; + this->SetOptionIfNotSet("CPACK_OUTPUT_FILE_PREFIX", destFile.c_str()); destFile += "/" + outName; std::string outFile = topDirectory + "/" + outName; this->SetOptionIfNotSet("CPACK_TOPLEVEL_DIRECTORY", topDirectory.c_str()); @@ -170,7 +171,9 @@ int cmCPackGenerator::InstallProject() std::string bareTempInstallDirectory = this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY"); std::string tempInstallDirectoryStr = bareTempInstallDirectory; - bool setDestDir = cmSystemTools::IsOn(this->GetOption("CPACK_SET_DESTDIR")); + bool setDestDir = cmSystemTools::IsOn(this->GetOption("CPACK_SET_DESTDIR")) + | cmSystemTools::IsInternallyOn( + this->GetOption("CPACK_SET_DESTDIR")); if (!setDestDir) { tempInstallDirectoryStr += this->GetPackagingInstallPrefix(); @@ -328,15 +331,16 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( it != installDirectoriesVector.end(); ++it ) { + std::list > symlinkedFiles; cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl); cmsys::Glob gl; - std::string toplevel = it->c_str(); + std::string top = it->c_str(); it ++; std::string subdir = it->c_str(); - std::string findExpr = toplevel; + std::string findExpr = top; findExpr += "/*"; cmCPackLogger(cmCPackLog::LOG_OUTPUT, - "- Install directory: " << toplevel << std::endl); + "- Install directory: " << top << std::endl); gl.RecurseOn(); if ( !gl.FindFiles(findExpr) ) { @@ -344,7 +348,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( "Cannot find any files in the installed directory" << std::endl); return 0; } - std::vector& files = gl.GetFiles(); + files = gl.GetFiles(); std::vector::iterator gfit; std::vector::iterator regIt; for ( gfit = files.begin(); gfit != files.end(); ++ gfit ) @@ -368,10 +372,21 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( } std::string filePath = tempDir; filePath += "/" + subdir + "/" - + cmSystemTools::RelativePath(toplevel.c_str(), gfit->c_str()); + + cmSystemTools::RelativePath(top.c_str(), gfit->c_str()); cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: " << inFile.c_str() << " -> " << filePath.c_str() << std::endl); - if ( !cmSystemTools::CopyFileIfDifferent(inFile.c_str(), + /* If the file is a symlink we will have to re-create it */ + if ( cmSystemTools::FileIsSymlink(inFile.c_str())) + { + std::string targetFile; + std::string inFileRelative = + cmSystemTools::RelativePath(top.c_str(),inFile.c_str()); + cmSystemTools::ReadSymlink(inFile.c_str(),targetFile); + symlinkedFiles.push_back(std::pair(targetFile,inFileRelative)); + } + /* If it is not a symlink then do a plain copy */ + else if ( !cmSystemTools::CopyFileIfDifferent(inFile.c_str(), filePath.c_str()) ) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: " @@ -379,6 +394,36 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( return 0; } } + /* rebuild symlinks in the installed tree */ + if (symlinkedFiles.size()>0) + { + std::list< std::pair >::iterator symlinkedIt; + std::string curDir = cmSystemTools::GetCurrentWorkingDirectory(); + std::string goToDir = tempDir; + goToDir += "/"+subdir; + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Change dir to: " << goToDir <second << "--> " + << symlinkedIt->first << std::endl); + if (!cmSystemTools::CreateSymlink((symlinkedIt->first).c_str(), + (symlinkedIt->second).c_str())) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create symlink: " + << symlinkedIt->second << "--> " + << symlinkedIt->first << std::endl); + return 0; + } + } + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: " + << curDir <GetOption("CPACK_INSTALL_PREFIX")) { dir += this->GetOption("CPACK_INSTALL_PREFIX"); @@ -458,6 +504,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( = this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS"); const char* cmakeGenerator = this->GetOption("CPACK_CMAKE_GENERATOR"); + std::string absoluteDestFiles; if ( cmakeProjects && *cmakeProjects ) { if ( !cmakeGenerator ) @@ -642,6 +689,18 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( // value of the project's CMAKE_INSTALL_PREFIX is sent in here as // the value of the CPACK_INSTALL_PREFIX variable. // + // If DESTDIR has been 'internally set ON' this means that + // the underlying CPack specific generator did ask for that + // In this case we may overrode CPACK_INSTALL_PREFIX with + // CPACK_PACKAGING_INSTALL_PREFIX + // I know this is tricky and awkward but it's the price for + // CPACK_SET_DESTDIR backward compatibility. + if (cmSystemTools::IsInternallyOn( + this->GetOption("CPACK_SET_DESTDIR"))) + { + this->SetOption("CPACK_INSTALL_PREFIX", + this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX")); + } std::string dir; if (this->GetOption("CPACK_INSTALL_PREFIX")) { @@ -722,6 +781,16 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( mf->AddDefinition("CMAKE_INSTALL_DO_STRIP", "1"); } int res = mf->ReadListFile(0, installFile.c_str()); + if (NULL !=mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) { + if (absoluteDestFiles.length()>0) { + absoluteDestFiles +=";"; + } + absoluteDestFiles += + mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"); + cmCPackLogger(cmCPackLog::LOG_DEBUG, + "Got some ABSOLUTE DESTINATION FILES: " + << absoluteDestFiles << std::endl); + } if ( cmSystemTools::GetErrorOccuredFlag() || !res ) { return 0; @@ -729,6 +798,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( } } } + this->SetOption("CPACK_ABSOLUTE_DESTINATION_FILES", + absoluteDestFiles.c_str()); return 1; } @@ -827,8 +898,8 @@ int cmCPackGenerator::DoPackage() return 0; } - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Compress package" << std::endl); - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Compress files to: " + cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Create package" << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Package files to: " << (tempPackageFileName ? tempPackageFileName : "(NULL)") << std::endl); if ( cmSystemTools::FileExists(tempPackageFileName) ) { @@ -843,7 +914,7 @@ int cmCPackGenerator::DoPackage() } // The files to be installed - std::vector files = gl.GetFiles(); + files = gl.GetFiles(); // For component installations, determine which files go into which // components. @@ -852,8 +923,12 @@ int cmCPackGenerator::DoPackage() std::vector::const_iterator it; for ( it = files.begin(); it != files.end(); ++ it ) { - std::string fileN = cmSystemTools::RelativePath(tempDirectory, - it->c_str()); + // beware we cannot just use tempDirectory as before + // because some generator will "CPACK_INCLUDE_TOPLEVEL_DIRECTORY" + // we really want "CPACK_TEMPORARY_DIRECTORY" + std::string fileN = + cmSystemTools::RelativePath( + this->GetOption("CPACK_TEMPORARY_DIRECTORY"), it->c_str()); // Determine which component we are in. std::string componentName = fileN.substr(0, fileN.find('/')); @@ -863,37 +938,65 @@ int cmCPackGenerator::DoPackage() // Add this file to the list of files for the component. this->Components[componentName].Files.push_back(fileN); + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Adding file <" + < to component <" + <"<CompressFiles(tempPackageFileName, - tempDirectory, files) || cmSystemTools::GetErrorOccuredFlag()) + + packageFileNames.clear(); + /* Put at least one file name into the list of + * wanted packageFileNames. The specific generator + * may update this during PackageFiles. + * (either putting several names or updating the provided one) + */ + packageFileNames.push_back(tempPackageFileName); + toplevel = tempDirectory; + if ( !this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem compressing the directory" << std::endl); return 0; } - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Finalize package" << std::endl); - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copy final package: " - << (tempPackageFileName ? tempPackageFileName : "(NULL)" ) - << " to " - << (packageFileName ? packageFileName : "(NULL)") - << std::endl); - if ( !cmSystemTools::CopyFileIfDifferent(tempPackageFileName, - packageFileName) ) + /* + * Copy the generated packages to final destination + * - there may be several of them + * - the initially provided name may have changed + * (because the specific generator did 'normalize' it) + */ + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Copying final package(s) [" + <::iterator it; + /* now copy package one by one */ + for (it=packageFileNames.begin();it!=packageFileNames.end();++it) { - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the package: " - << (tempPackageFileName ? tempPackageFileName : "(NULL)" ) - << " to " - << (packageFileName ? packageFileName : "(NULL)") - << std::endl); - return 0; + std::string tmpPF(this->GetOption("CPACK_OUTPUT_FILE_PREFIX")); + tempPackageFileName = it->c_str(); + tmpPF += "/"+cmSystemTools::GetFilenameName(*it); + packageFileName = tmpPF.c_str(); + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy final package(s): " + << (tempPackageFileName ? tempPackageFileName : "(NULL)" ) + << " to " + << (packageFileName ? packageFileName : "(NULL)") + << std::endl); + if ( !cmSystemTools::CopyFileIfDifferent(tempPackageFileName, + packageFileName) ) + { + cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the package: " + << (tempPackageFileName ? tempPackageFileName : "(NULL)" ) + << " to " + << (packageFileName ? packageFileName : "(NULL)") + << std::endl); + return 0; + } + cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- package: " + << packageFileName + << " generated." << std::endl); } - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "Package " - << (packageFileName ? packageFileName : "(NULL)") - << " generated." << std::endl); return 1; } @@ -984,12 +1087,8 @@ int cmCPackGenerator::SetCMakeRoot() } //---------------------------------------------------------------------- -int cmCPackGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector& files) +int cmCPackGenerator::PackageFiles() { - (void)outFileName; - (void)toplevel; - (void)files; return 0; } diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 45188fef5..74b780d5d 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -55,13 +55,22 @@ class cmCPackGenerator : public cmObject public: cmTypeMacro(cmCPackGenerator, cmObject); /** - * If verbose then more informaiton is printed out + * If verbose then more information is printed out */ void SetVerbose(bool val) { this->GeneratorVerbose = val; } /** - * Do the actual processing. Subclass has to override it. - * Return 0 if error. + * Do the actual whole package processing. + * Subclass may redefine it but its usually enough + * to redefine @ref PackageFiles, because in fact + * this method do call: + * - PrepareName + * - clean-up temp dirs + * - InstallProject (with the appropriate method) + * - prepare list of files and/or components to be package + * - PackageFiles + * - Copy produced packages at the expected place + * @return 0 if error. */ virtual int DoPackage(); @@ -94,13 +103,32 @@ public: bool ReadListFile(const char* moduleName); protected: + /** + * Prepare common used names by inspecting + * several CPACK_xxx var values. + */ int PrepareNames(); + + /** + * Install the project using appropriate method. + */ int InstallProject(); + int CleanTemporaryDirectory(); + virtual const char* GetOutputExtension() { return ".cpack"; } virtual const char* GetOutputPostfix() { return 0; } - virtual int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector& files); + + /** + * Package the list of files and/or components which + * has been prepared by the beginning of DoPackage. + * @pre @ref toplevel has been filled-in + * @pre the list of file @ref files has been populated + * @pre packageFileNames contains at least 1 entry + * @post packageFileNames may have been updated and contains + * the list of packages generated by the specific generator. + */ + virtual int PackageFiles(); virtual const char* GetInstallPath(); virtual const char* GetPackagingInstallPrefix(); @@ -134,11 +162,42 @@ protected: std::string InstallPath; + /** + * The list of package file names. + * At beginning of DoPackage the (generic) generator will populate + * the list of desired package file names then it will + * call the redefined method PackageFiles which is may + * either use this set of names (usually on entry there should be + * only a single name) or update the vector with the list + * of created package file names. + */ + std::vector packageFileNames; + + /** + * The directory where all the files to be packaged reside. + * If the installer support components there will be one + * sub-directory for each component. In those directories + * one will find the file belonging to the specified component. + */ + std::string toplevel; + + /** + * The complete list of files to be packaged. + * This list will be populated by DoPackage before + * PackageFiles is called. + */ + std::vector files; + std::string CPackSelf; std::string CMakeSelf; std::string CMakeRoot; std::map InstallationTypes; + /** + * The set of components. + * If component installation is supported then this map + * contains the component specified in CPACK_COMPONENTS_ALL + */ std::map Components; std::map ComponentGroups; diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index ad773862b..d0eda81e2 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -43,11 +43,10 @@ cmCPackNSISGenerator::~cmCPackNSISGenerator() } //---------------------------------------------------------------------- -int cmCPackNSISGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector& files) +int cmCPackNSISGenerator::PackageFiles() { - (void)outFileName; // TODO: Fix nsis to force out file name - (void)toplevel; + // TODO: Fix nsis to force out file name + std::string nsisInFileName = this->FindTemplate("NSIS.template.in"); if ( nsisInFileName.size() == 0 ) { @@ -74,7 +73,7 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, std::vector::const_iterator it; for ( it = files.begin(); it != files.end(); ++ it ) { - std::string fileN = cmSystemTools::RelativePath(toplevel, + std::string fileN = cmSystemTools::RelativePath(toplevel.c_str(), it->c_str()); if (!this->Components.empty()) { @@ -88,13 +87,14 @@ int cmCPackNSISGenerator::CompressFiles(const char* outFileName, << str.str().c_str() << std::endl); this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str()); std::vector dirs; - this->GetListOfSubdirectories(toplevel, dirs); + this->GetListOfSubdirectories(toplevel.c_str(), dirs); std::vector::const_iterator sit; cmOStringStream dstr; for ( sit = dirs.begin(); sit != dirs.end(); ++ sit ) { std::string componentName; - std::string fileN = cmSystemTools::RelativePath(toplevel, sit->c_str()); + std::string fileN = cmSystemTools::RelativePath(toplevel.c_str(), + sit->c_str()); if ( fileN.empty() ) { continue; @@ -758,7 +758,7 @@ CreateComponentDescription(cmCPackComponent *component, } // Create the NSIS code to download this file on-the-fly. - unsigned totalSizeInKbytes = (totalSize + 512) / 1024; + unsigned long totalSizeInKbytes = (totalSize + 512) / 1024; if (totalSizeInKbytes == 0) { totalSizeInKbytes = 1; diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h index dff5b8ff6..6ad103f11 100644 --- a/Source/CPack/cmCPackNSISGenerator.h +++ b/Source/CPack/cmCPackNSISGenerator.h @@ -37,8 +37,7 @@ protected: virtual int InitializeInternal(); void CreateMenuLinks( cmOStringStream& str, cmOStringStream& deleteStr); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector& files); + int PackageFiles(); virtual const char* GetOutputExtension() { return ".exe"; } virtual const char* GetOutputPostfix() { return "win32"; } diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index a3b575939..2d4bb97ff 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -33,12 +33,10 @@ cmCPackOSXX11Generator::~cmCPackOSXX11Generator() } //---------------------------------------------------------------------- -int cmCPackOSXX11Generator::CompressFiles(const char* outFileName, - const char* toplevel, - const std::vector& files) +int cmCPackOSXX11Generator::PackageFiles() { - (void) files; // TODO: Fix api to not need files. - (void) toplevel; // TODO: Use toplevel + // TODO: Use toplevel ? + // It is used! Is this an obsolete comment? const char* cpackPackageExecutables = this->GetOption("CPACK_PACKAGE_EXECUTABLES"); @@ -144,7 +142,7 @@ int cmCPackOSXX11Generator::CompressFiles(const char* outFileName, dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") << "\" create -ov -format UDZO -srcfolder \"" << diskImageDirectory.c_str() - << "\" \"" << outFileName << "\""; + << "\" \"" << packageFileNames[0] << "\""; int retVal = 1; cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Compress disk image using command: " diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h index 7fd60b4b1..b7bd24396 100644 --- a/Source/CPack/cmCPackOSXX11Generator.h +++ b/Source/CPack/cmCPackOSXX11Generator.h @@ -33,8 +33,7 @@ public: protected: virtual int InitializeInternal(); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector& files); + int PackageFiles(); virtual const char* GetPackagingInstallPrefix(); virtual const char* GetOutputExtension() { return ".dmg"; } diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 9333131f9..ef81da8fd 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -59,12 +59,10 @@ int cmCPackPackageMakerGenerator::CopyInstallScript(const char* resdir, } //---------------------------------------------------------------------- -int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, - const char* toplevel, - const std::vector& files) +int cmCPackPackageMakerGenerator::PackageFiles() { - (void) files; // TODO: Fix api to not need files. - (void) toplevel; // TODO: Use toplevel + // TODO: Use toplevel + // It is used! Is this an obsolete comment? std::string resDir; // Where this package's resources will go. std::string packageDirFileName @@ -318,7 +316,7 @@ int cmCPackPackageMakerGenerator::CompressFiles(const char* outFileName, cmOStringStream dmgCmd; dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE") << "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName - << "\" \"" << outFileName << "\""; + << "\" \"" << packageFileNames[0] << "\""; std::string output; int retVal = 1; int numTries = 4; diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h index 36cd5940e..2bab94791 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.h +++ b/Source/CPack/cmCPackPackageMakerGenerator.h @@ -42,8 +42,7 @@ protected: const char* script, const char* name); virtual int InitializeInternal(); - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector& files); + int PackageFiles(); virtual const char* GetOutputExtension() { return ".dmg"; } virtual const char* GetOutputPostfix() { return "darwin"; } diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index fb85581b8..0641418b4 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -11,6 +11,7 @@ ============================================================================*/ #include "cmCPackRPMGenerator.h" #include "cmCPackLog.h" +#include "cmSystemTools.h" //---------------------------------------------------------------------- cmCPackRPMGenerator::cmCPackRPMGenerator() @@ -26,14 +27,15 @@ cmCPackRPMGenerator::~cmCPackRPMGenerator() int cmCPackRPMGenerator::InitializeInternal() { this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr"); - + if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) + { + this->SetOption("CPACK_SET_DESTDIR", "I_ON"); + } return this->Superclass::InitializeInternal(); } //---------------------------------------------------------------------- -int cmCPackRPMGenerator::CompressFiles(const char* /*outFileName*/, - const char* /*toplevel*/, - const std::vector& /*files*/) +int cmCPackRPMGenerator::PackageFiles() { this->ReadListFile("CPackRPM.cmake"); if (!this->IsSet("RPMBUILD_EXECUTABLE")) diff --git a/Source/CPack/cmCPackRPMGenerator.h b/Source/CPack/cmCPackRPMGenerator.h index c607f3577..570e45f60 100644 --- a/Source/CPack/cmCPackRPMGenerator.h +++ b/Source/CPack/cmCPackRPMGenerator.h @@ -37,8 +37,7 @@ public: protected: virtual int InitializeInternal(); - virtual int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector& files); + virtual int PackageFiles(); virtual const char* GetOutputExtension() { return ".rpm"; } }; diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx index a687e0d45..184c557b8 100644 --- a/Source/CPack/cmCPackSTGZGenerator.cxx +++ b/Source/CPack/cmCPackSTGZGenerator.cxx @@ -52,14 +52,13 @@ int cmCPackSTGZGenerator::InitializeInternal() } //---------------------------------------------------------------------- -int cmCPackSTGZGenerator::CompressFiles(const char* outFileName, - const char* toplevel, const std::vector& files) +int cmCPackSTGZGenerator::PackageFiles() { - if ( !this->Superclass::CompressFiles(outFileName, toplevel, files) ) + if ( !this->Superclass::PackageFiles() ) { return 0; } - return cmSystemTools::SetPermissions(outFileName, + return cmSystemTools::SetPermissions(packageFileNames[0].c_str(), #if defined( _MSC_VER ) || defined( __MINGW32__ ) S_IREAD | S_IWRITE | S_IEXEC #elif defined( __BORLANDC__ ) diff --git a/Source/CPack/cmCPackSTGZGenerator.h b/Source/CPack/cmCPackSTGZGenerator.h index fc51e4d79..ccceec806 100644 --- a/Source/CPack/cmCPackSTGZGenerator.h +++ b/Source/CPack/cmCPackSTGZGenerator.h @@ -32,8 +32,7 @@ public: virtual ~cmCPackSTGZGenerator(); protected: - int CompressFiles(const char* outFileName, const char* toplevel, - const std::vector& files); + int PackageFiles(); virtual int InitializeInternal(); int GenerateHeader(std::ostream* os); virtual const char* GetOutputExtension() { return ".sh"; } diff --git a/Source/CPack/cmCPackTGZGenerator.cxx b/Source/CPack/cmCPackTGZGenerator.cxx index c6ef8ae1e..509c7f80a 100644 --- a/Source/CPack/cmCPackTGZGenerator.cxx +++ b/Source/CPack/cmCPackTGZGenerator.cxx @@ -14,8 +14,8 @@ //---------------------------------------------------------------------- cmCPackTGZGenerator::cmCPackTGZGenerator() - :cmCPackArchiveGenerator(cmCPackArchiveGenerator::GZIP, - cmCPackArchiveGenerator::TAR) + :cmCPackArchiveGenerator(cmArchiveWrite::CompressGZip, + cmArchiveWrite::TypeTAR) { } diff --git a/Source/CPack/cmCPackTarBZip2Generator.cxx b/Source/CPack/cmCPackTarBZip2Generator.cxx index 52826dc18..971d16667 100644 --- a/Source/CPack/cmCPackTarBZip2Generator.cxx +++ b/Source/CPack/cmCPackTarBZip2Generator.cxx @@ -13,8 +13,8 @@ #include "cmCPackTarBZip2Generator.h" //---------------------------------------------------------------------- cmCPackTarBZip2Generator::cmCPackTarBZip2Generator() - :cmCPackArchiveGenerator(cmCPackArchiveGenerator::BZIP2, - cmCPackArchiveGenerator::TAR) + :cmCPackArchiveGenerator(cmArchiveWrite::CompressBZip2, + cmArchiveWrite::TypeTAR) { } diff --git a/Source/CPack/cmCPackTarCompressGenerator.cxx b/Source/CPack/cmCPackTarCompressGenerator.cxx index e9b5e2e87..7a8f697c0 100644 --- a/Source/CPack/cmCPackTarCompressGenerator.cxx +++ b/Source/CPack/cmCPackTarCompressGenerator.cxx @@ -14,8 +14,8 @@ //---------------------------------------------------------------------- cmCPackTarCompressGenerator::cmCPackTarCompressGenerator() - :cmCPackArchiveGenerator(cmCPackArchiveGenerator::COMPRESS, - cmCPackArchiveGenerator::TAR) + :cmCPackArchiveGenerator(cmArchiveWrite::CompressCompress, + cmArchiveWrite::TypeTAR) { } diff --git a/Source/CPack/cmCPackZIPGenerator.cxx b/Source/CPack/cmCPackZIPGenerator.cxx index e195f83c7..e6e4e77d0 100644 --- a/Source/CPack/cmCPackZIPGenerator.cxx +++ b/Source/CPack/cmCPackZIPGenerator.cxx @@ -14,8 +14,8 @@ //---------------------------------------------------------------------- cmCPackZIPGenerator::cmCPackZIPGenerator() - :cmCPackArchiveGenerator(cmCPackArchiveGenerator::NONE, - cmCPackArchiveGenerator::ZIP) + :cmCPackArchiveGenerator(cmArchiveWrite::CompressNone, + cmArchiveWrite::TypeZIP) { } diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 243d9c995..9163af811 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -203,7 +203,7 @@ int main (int argc, char *argv[]) if ( verbose ) { log.SetVerbose(verbose); - cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Verbse" << std::endl); + cmCPack_Log(&log, cmCPackLog::LOG_OUTPUT, "Enable Verbose" << std::endl); } if ( debug ) { diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index bc02fbc6b..3c5993de6 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -65,7 +65,7 @@ static const char* cmCTestErrorMatches[] = { "^Unresolved:", "Undefined symbols:", "^Undefined[ \\t]+first referenced", - "^CMake Error:", + "^CMake Error.*:", ":[ \\t]cannot find", ":[ \\t]can't find", ": \\*\\*\\* No rule to make target \\`.*\\'. Stop", @@ -129,6 +129,7 @@ static const char* cmCTestWarningMatches[] = { "\\([0-9]*\\): remark #[0-9]*", "\".*\", line [0-9]+: remark\\([0-9]*\\):", "cc-[0-9]* CC: REMARK File = .*, Line = [0-9]*", + "^CMake Warning.*:", 0 }; @@ -174,8 +175,8 @@ cmCTestWarningErrorFileLine[] = { //---------------------------------------------------------------------- cmCTestBuildHandler::cmCTestBuildHandler() { - this->MaxPreContext = 6; - this->MaxPostContext = 6; + this->MaxPreContext = 10; + this->MaxPostContext = 10; this->MaxErrors = 50; this->MaxWarnings = 50; @@ -214,8 +215,8 @@ void cmCTestBuildHandler::Initialize() this->ErrorsAndWarnings.clear(); this->LastErrorOrWarning = this->ErrorsAndWarnings.end(); this->PostContextCount = 0; - this->MaxPreContext = 6; - this->MaxPostContext = 6; + this->MaxPreContext = 10; + this->MaxPostContext = 10; this->PreContext.clear(); this->TotalErrors = 0; @@ -249,6 +250,20 @@ void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile *mf) "CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS", this->MaxWarnings); + int n = -1; + this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_ERROR_PRE_CONTEXT", n); + if (n != -1) + { + this->MaxPreContext = static_cast(n); + } + + n = -1; + this->CTest->PopulateCustomInteger(mf, "CTEST_CUSTOM_ERROR_POST_CONTEXT", n); + if (n != -1) + { + this->MaxPostContext = static_cast(n); + } + // Record the user-specified custom warning rules. if(const char* customWarningMatchers = mf->GetDefinition("CTEST_CUSTOM_WARNING_MATCH")) @@ -959,7 +974,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command, this->ProcessBuffer(0, 0, tick, tick_len, ofs, &this->BuildProcessingErrorQueue); cmCTestLog(this->CTest, OUTPUT, " Size of output: " - << int(this->BuildOutputLogSize / 1024.0) << "K" << std::endl); + << ((this->BuildOutputLogSize + 512) / 1024) << "K" << std::endl); // Properly handle output of the build command cmsysProcess_WaitForExit(cp, 0); @@ -1171,7 +1186,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length, if ( tick % tick_line_len == 0 && tick > 0 ) { cmCTestLog(this->CTest, HANDLER_OUTPUT, " Size: " - << int((this->BuildOutputLogSize / 1024.0) + 1) << "K" << std::endl + << ((this->BuildOutputLogSize + 512) / 1024) << "K" << std::endl << " "); } } diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 55a5225e7..6863adce4 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -429,7 +429,7 @@ int cmCTestCoverageHandler::ProcessHandler() //std::string fullBinaryDir = binaryDir + "/"; cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl); cmCTestLog(this->CTest, HANDLER_OUTPUT, - " Acumulating results (each . represents one file):" << std::endl); + " Accumulating results (each . represents one file):" << std::endl); cmCTestLog(this->CTest, HANDLER_OUTPUT, " "); std::vector errorsWhileAccumulating; @@ -508,7 +508,7 @@ int cmCTestCoverageHandler::ProcessHandler() cmCTestCoverageHandlerContainer::SingleFileCoverageVector::size_type cc; std::string line; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Actually perfoming coverage for: " << fullFileName << std::endl); + "Actually performing coverage for: " << fullFileName << std::endl); for ( cc= 0; cc < fcov.size(); cc ++ ) { if ( !cmSystemTools::GetLineFromStream(ifs, line) && @@ -593,7 +593,7 @@ int cmCTestCoverageHandler::ProcessHandler() int untested = 0; std::string line; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Actually perfoming coverage for: " << i->c_str() << std::endl); + "Actually performing coverage for: " << i->c_str() << std::endl); while (cmSystemTools::GetLineFromStream(ifs, line)) { covLogFile << "\t\t" diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index a49c8521a..a6f10ec60 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -84,6 +84,75 @@ void cmCTestGIT::NoteNewRevision() << this->NewRevision << "\n"); } +//---------------------------------------------------------------------------- +std::string cmCTestGIT::FindGitDir() +{ + std::string git_dir; + + // Run "git rev-parse --git-dir" to locate the real .git directory. + const char* git = this->CommandLineTool.c_str(); + char const* git_rev_parse[] = {git, "rev-parse", "--git-dir", 0}; + std::string git_dir_line; + OneLineParser rev_parse_out(this, "rev-parse-out> ", git_dir_line); + OutputLogger rev_parse_err(this->Log, "rev-parse-err> "); + if(this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err)) + { + git_dir = git_dir_line; + } + if(git_dir.empty()) + { + git_dir = ".git"; + } + + // Git reports a relative path only when the .git directory is in + // the current directory. + if(git_dir[0] == '.') + { + git_dir = this->SourceDirectory + "/" + git_dir; + } +#if defined(_WIN32) && !defined(__CYGWIN__) + else if(git_dir[0] == '/') + { + // Cygwin Git reports a full path that Cygwin understands, but we + // are a Windows application. Run "cygpath" to get Windows path. + std::string cygpath_exe = cmSystemTools::GetFilenamePath(git); + cygpath_exe += "/cygpath.exe"; + if(cmSystemTools::FileExists(cygpath_exe.c_str())) + { + char const* cygpath[] = {cygpath_exe.c_str(), "-w", git_dir.c_str(), 0}; + OneLineParser cygpath_out(this, "cygpath-out> ", git_dir_line); + OutputLogger cygpath_err(this->Log, "cygpath-err> "); + if(this->RunChild(cygpath, &cygpath_out, &cygpath_err)) + { + git_dir = git_dir_line; + } + } + } +#endif + return git_dir; +} + +//---------------------------------------------------------------------------- +std::string cmCTestGIT::FindTopDir() +{ + std::string top_dir = this->SourceDirectory; + + // Run "git rev-parse --show-cdup" to locate the top of the tree. + const char* git = this->CommandLineTool.c_str(); + char const* git_rev_parse[] = {git, "rev-parse", "--show-cdup", 0}; + std::string cdup; + OneLineParser rev_parse_out(this, "rev-parse-out> ", cdup); + OutputLogger rev_parse_err(this->Log, "rev-parse-err> "); + if(this->RunChild(git_rev_parse, &rev_parse_out, &rev_parse_err) && + !cdup.empty()) + { + top_dir += "/"; + top_dir += cdup; + top_dir = cmSystemTools::CollapseFullPath(top_dir.c_str()); + } + return top_dir; +} + //---------------------------------------------------------------------------- bool cmCTestGIT::UpdateByFetchAndReset() { @@ -121,11 +190,17 @@ bool cmCTestGIT::UpdateByFetchAndReset() // Identify the merge head that would be used by "git pull". std::string sha1; { - std::string fetch_head = this->SourceDirectory + "/.git/FETCH_HEAD"; + std::string fetch_head = this->FindGitDir() + "/FETCH_HEAD"; std::ifstream fin(fetch_head.c_str(), std::ios::in | std::ios::binary); + if(!fin) + { + this->Log << "Unable to open " << fetch_head << "\n"; + return false; + } std::string line; while(sha1.empty() && cmSystemTools::GetLineFromStream(fin, line)) { + this->Log << "FETCH_HEAD> " << line << "\n"; if(line.find("\tnot-for-merge\t") == line.npos) { std::string::size_type pos = line.find('\t'); @@ -135,6 +210,11 @@ bool cmCTestGIT::UpdateByFetchAndReset() } } } + if(sha1.empty()) + { + this->Log << "FETCH_HEAD has no upstream branch candidate!\n"; + return false; + } } // Reset the local branch to point at that tracked from upstream. @@ -181,11 +261,13 @@ bool cmCTestGIT::UpdateImpl() return false; } + std::string top_dir = this->FindTopDir(); const char* git = this->CommandLineTool.c_str(); char const* git_submodule[] = {git, "submodule", "update", 0}; OutputLogger submodule_out(this->Log, "submodule-out> "); OutputLogger submodule_err(this->Log, "submodule-err> "); - return this->RunChild(git_submodule, &submodule_out, &submodule_err); + return this->RunChild(git_submodule, &submodule_out, &submodule_err, + top_dir.c_str()); } //---------------------------------------------------------------------------- diff --git a/Source/CTest/cmCTestGIT.h b/Source/CTest/cmCTestGIT.h index d8681fe4f..1765340d5 100644 --- a/Source/CTest/cmCTestGIT.h +++ b/Source/CTest/cmCTestGIT.h @@ -32,6 +32,9 @@ private: virtual void NoteNewRevision(); virtual bool UpdateImpl(); + std::string FindGitDir(); + std::string FindTopDir(); + bool UpdateByFetchAndReset(); bool UpdateByCustom(std::string const& custom); bool UpdateInternal(); diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 0d15ddc25..13a25cb5c 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -201,8 +201,7 @@ void cmCTestMemCheckHandler::Initialize() this->CustomMaximumPassedTestOutputSize = 0; this->CustomMaximumFailedTestOutputSize = 0; this->MemoryTester = ""; - this->MemoryTesterOptionsParsed.clear(); - this->MemoryTesterOptions = ""; + this->MemoryTesterOptions.clear(); this->MemoryTesterStyle = UNKNOWN; this->MemoryTesterOutputFile = ""; int cc; @@ -249,12 +248,12 @@ void cmCTestMemCheckHandler::GenerateTestCommand( std::vector::size_type pp; std::string memcheckcommand = ""; memcheckcommand = this->MemoryTester; - for ( pp = 0; pp < this->MemoryTesterOptionsParsed.size(); pp ++ ) + for ( pp = 0; pp < this->MemoryTesterOptions.size(); pp ++ ) { - args.push_back(this->MemoryTesterOptionsParsed[pp]); - memcheckcommand += " "; - memcheckcommand += cmSystemTools::EscapeSpaces( - this->MemoryTesterOptionsParsed[pp].c_str()); + args.push_back(this->MemoryTesterOptions[pp]); + memcheckcommand += " \""; + memcheckcommand += this->MemoryTesterOptions[pp]; + memcheckcommand += "\""; } cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Memory check command: " << memcheckcommand << std::endl); @@ -440,18 +439,21 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() } // Setup the options + std::string memoryTesterOptions; if ( this->CTest->GetCTestConfiguration( "MemoryCheckCommandOptions").size() ) { - this->MemoryTesterOptions = this->CTest->GetCTestConfiguration( + memoryTesterOptions = this->CTest->GetCTestConfiguration( "MemoryCheckCommandOptions"); } else if ( this->CTest->GetCTestConfiguration( "ValgrindCommandOptions").size() ) { - this->MemoryTesterOptions = this->CTest->GetCTestConfiguration( + memoryTesterOptions = this->CTest->GetCTestConfiguration( "ValgrindCommandOptions"); } + this->MemoryTesterOptions + = cmSystemTools::ParseArguments(memoryTesterOptions.c_str()); this->MemoryTesterOutputFile = this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.log"; @@ -459,10 +461,14 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() if ( this->MemoryTester.find("valgrind") != std::string::npos ) { this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND; - if ( !this->MemoryTesterOptions.size() ) + if ( this->MemoryTesterOptions.empty() ) { - this->MemoryTesterOptions = "-q --tool=memcheck --leak-check=yes " - "--show-reachable=yes --workaround-gcc296-bugs=yes --num-callers=50"; + this->MemoryTesterOptions.push_back("-q"); + this->MemoryTesterOptions.push_back("--tool=memcheck"); + this->MemoryTesterOptions.push_back("--leak-check=yes"); + this->MemoryTesterOptions.push_back("--show-reachable=yes"); + this->MemoryTesterOptions.push_back("--workaround-gcc296-bugs=yes"); + this->MemoryTesterOptions.push_back("--num-callers=50"); } if ( this->CTest->GetCTestConfiguration( "MemoryCheckSuppressionFile").size() ) @@ -476,17 +482,15 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() "MemoryCheckSuppressionFile").c_str() << std::endl); return false; } - this->MemoryTesterOptions += " --suppressions=" + - cmSystemTools::EscapeSpaces(this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str()) + ""; + std::string suppressions = "--suppressions=" + + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"); + this->MemoryTesterOptions.push_back(suppressions); } } else if ( this->MemoryTester.find("purify") != std::string::npos ) { this->MemoryTesterStyle = cmCTestMemCheckHandler::PURIFY; - std::string outputFile = - cmSystemTools::EscapeSpaces(this->MemoryTesterOutputFile.c_str()); - + std::string outputFile; #ifdef _WIN32 if( this->CTest->GetCTestConfiguration( "MemoryCheckSuppressionFile").size() ) @@ -500,31 +504,29 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() "MemoryCheckSuppressionFile").c_str() << std::endl); return false; } - this->MemoryTesterOptions += " /FilterFiles=" + - cmSystemTools::EscapeSpaces(this->CTest->GetCTestConfiguration( - "MemoryCheckSuppressionFile").c_str()); + std::string filterFiles = "/FilterFiles=" + + this->CTest->GetCTestConfiguration("MemoryCheckSuppressionFile"); + this->MemoryTesterOptions.push_back(filterFiles); } - this->MemoryTesterOptions += " /SAVETEXTDATA=" + outputFile; + outputFile = "/SAVETEXTDATA="; #else - this->MemoryTesterOptions += " -log-file=" + outputFile; + outputFile = "-log-file="; #endif + outputFile += this->MemoryTesterOutputFile; + this->MemoryTesterOptions.push_back(outputFile); } else if ( this->MemoryTester.find("BC") != std::string::npos ) { this->BoundsCheckerXMLFile = this->MemoryTesterOutputFile; - std::string outputFile = - cmSystemTools::EscapeSpaces(this->MemoryTesterOutputFile.c_str()); std::string dpbdFile = this->CTest->GetBinaryDir() + "/Testing/Temporary/MemoryChecker.DPbd"; - std::string errorFile = this->CTest->GetBinaryDir() - + "/Testing/Temporary/MemoryChecker.error"; - errorFile = cmSystemTools::EscapeSpaces(errorFile.c_str()); this->BoundsCheckerDPBDFile = dpbdFile; - dpbdFile = cmSystemTools::EscapeSpaces(dpbdFile.c_str()); this->MemoryTesterStyle = cmCTestMemCheckHandler::BOUNDS_CHECKER; - this->MemoryTesterOptions += " /B " + dpbdFile; - this->MemoryTesterOptions += " /X " + outputFile; - this->MemoryTesterOptions += " /M "; + this->MemoryTesterOptions.push_back("/B"); + this->MemoryTesterOptions.push_back(dpbdFile); + this->MemoryTesterOptions.push_back("/X"); + this->MemoryTesterOptions.push_back(this->MemoryTesterOutputFile); + this->MemoryTesterOptions.push_back("/M"); } else { @@ -534,8 +536,6 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking() return false; } - this->MemoryTesterOptionsParsed - = cmSystemTools::ParseArguments(this->MemoryTesterOptions.c_str()); std::vector::size_type cc; for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ ) { diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index db426f086..427d4717d 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -89,8 +89,7 @@ private: std::string BoundsCheckerDPBDFile; std::string BoundsCheckerXMLFile; std::string MemoryTester; - std::vector MemoryTesterOptionsParsed; - std::string MemoryTesterOptions; + std::vector MemoryTesterOptions; int MemoryTesterStyle; std::string MemoryTesterOutputFile; int MemoryTesterGlobalResults[NO_MEMORY_FAULT]; diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 1eb84e85b..0d14c2d74 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -18,6 +18,23 @@ #include #include +class TestComparator +{ +public: + TestComparator(cmCTestMultiProcessHandler* handler) : Handler(handler) {} + ~TestComparator() {} + + // Sorts tests in descending order of cost + bool operator() (int index1, int index2) const + { + return Handler->Properties[index1]->Cost > + Handler->Properties[index2]->Cost; + } + +private: + cmCTestMultiProcessHandler* Handler; +}; + cmCTestMultiProcessHandler::cmCTestMultiProcessHandler() { this->ParallelLevel = 1; @@ -154,15 +171,8 @@ void cmCTestMultiProcessHandler::UnlockResources(int index) void cmCTestMultiProcessHandler::EraseTest(int test) { this->Tests.erase(test); - for(TestCostMap::iterator i = this->TestCosts.begin(); - i != this->TestCosts.end(); ++i) - { - if(i->second.find(test) != i->second.end()) - { - i->second.erase(test); - return; - } - } + this->SortedTests.erase( + std::find(this->SortedTests.begin(), this->SortedTests.end(), test)); } //--------------------------------------------------------- @@ -244,41 +254,36 @@ void cmCTestMultiProcessHandler::StartNextTests() return; } - for(TestCostMap::reverse_iterator i = this->TestCosts.rbegin(); - i != this->TestCosts.rend(); ++i) + TestList copy = this->SortedTests; + for(TestList::iterator test = copy.begin(); test != copy.end(); ++test) { - TestSet tests = i->second; //copy the test set - for(TestSet::iterator test = tests.begin(); - test != tests.end(); ++test) + //in case this test has already been started due to dependency + if(this->TestRunningMap[*test] || this->TestFinishMap[*test]) { - //in case this test has already been started due to dependency - if(this->TestRunningMap[*test] || this->TestFinishMap[*test]) - { - continue; - } - size_t processors = GetProcessorsUsed(*test); - if(processors > numToStart) - { - return; - } - if(this->StartTest(*test)) - { - if(this->StopTimePassed) - { - return; - } - numToStart -= processors; - } - else - { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl - << "Test did not start waiting on depends to finish: " - << *test << "\n"); - } - if(numToStart == 0) + continue; + } + size_t processors = GetProcessorsUsed(*test); + if(processors > numToStart) + { + return; + } + if(this->StartTest(*test)) + { + if(this->StopTimePassed) { return; } + numToStart -= processors; + } + else + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl + << "Test did not start waiting on depends to finish: " + << *test << "\n"); + } + if(numToStart == 0) + { + return; } } } @@ -468,26 +473,22 @@ void cmCTestMultiProcessHandler::CreateTestCostList() for(TestMap::iterator i = this->Tests.begin(); i != this->Tests.end(); ++i) { - //We only want to schedule them by cost in a parallel situation - if(this->ParallelLevel > 1) - { - std::string name = this->Properties[i->first]->Name; - if(std::find(this->LastTestsFailed.begin(), this->LastTestsFailed.end(), - name) != this->LastTestsFailed.end()) - { - this->TestCosts[FLT_MAX].insert(i->first); - } - else - { - this->TestCosts[this->Properties[i->first]->Cost].insert(i->first); - } - } - else //we ignore their cost + SortedTests.push_back(i->first); + + //If the test failed last time, it should be run first, so max the cost + if(std::find(this->LastTestsFailed.begin(), + this->LastTestsFailed.end(), + this->Properties[i->first]->Name) + != this->LastTestsFailed.end()) { - this->TestCosts[this->Tests.size() - - this->Properties[i->first]->Index].insert(i->first); + this->Properties[i->first]->Cost = FLT_MAX; } } + if(this->ParallelLevel > 1) + { + TestComparator comp(this); + std::sort(SortedTests.begin(), SortedTests.end(), comp); + } } //--------------------------------------------------------- @@ -515,11 +516,13 @@ void cmCTestMultiProcessHandler::PrintTestList() { this->TestHandler->SetMaxIndex(this->FindMaxIndex()); int count = 0; + for (PropertiesMap::iterator it = this->Properties.begin(); it != this->Properties.end(); ++it) { count++; cmCTestTestHandler::cmCTestTestProperties& p = *it->second; + //push working dir std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory(); cmSystemTools::ChangeDirectory(p.Directory.c_str()); @@ -529,6 +532,20 @@ void cmCTestMultiProcessHandler::PrintTestList() testRun.SetTestProperties(&p); testRun.ComputeArguments(); //logs the command in verbose mode + if(p.Labels.size()) //print the labels + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Labels:"); + } + for(std::vector::iterator label = p.Labels.begin(); + label != p.Labels.end(); ++label) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " " << *label); + } + if(p.Labels.size()) //print the labels + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl); + } + if (this->TestHandler->MemCheck) { cmCTestLog(this->CTest, HANDLER_OUTPUT, " Memory Check"); @@ -547,10 +564,36 @@ void cmCTestMultiProcessHandler::PrintTestList() //pop working dir cmSystemTools::ChangeDirectory(current_dir.c_str()); } + cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl << "Total Tests: " << this->Total << std::endl); } +void cmCTestMultiProcessHandler::PrintLabels() +{ + std::set allLabels; + for (PropertiesMap::iterator it = this->Properties.begin(); + it != this->Properties.end(); ++it) + { + cmCTestTestHandler::cmCTestTestProperties& p = *it->second; + allLabels.insert(p.Labels.begin(), p.Labels.end()); + } + + if(allLabels.size()) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, "All Labels:" << std::endl); + } + else + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, "No Labels Exist" << std::endl); + } + for(std::set::iterator label = allLabels.begin(); + label != allLabels.end(); ++label) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, " " << *label << std::endl); + } +} + //--------------------------------------------------------- void cmCTestMultiProcessHandler::CheckResume() { @@ -610,7 +653,7 @@ int cmCTestMultiProcessHandler::FindMaxIndex() //Returns true if no cycles exist in the dependency graph bool cmCTestMultiProcessHandler::CheckCycles() { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Checking test dependency graph..." << std::endl); for(TestMap::iterator it = this->Tests.begin(); it != this->Tests.end(); ++it) @@ -618,34 +661,29 @@ bool cmCTestMultiProcessHandler::CheckCycles() //DFS from each element to itself std::stack s; std::vector visited; + s.push(it->first); - visited.push_back(it->first); while(!s.empty()) { int test = s.top(); s.pop(); - + for(TestSet::iterator d = this->Tests[test].begin(); d != this->Tests[test].end(); ++d) { - s.push(*d); - for(std::vector::iterator v = visited.begin(); - v != visited.end(); ++v) + if(std::find(visited.begin(), visited.end(), *d) != visited.end()) { - if(*v == *d) - { - //cycle exists - cmCTestLog(this->CTest, ERROR_MESSAGE, "Error: a cycle exists in " - "the test dependency graph for the test \"" - << this->Properties[*d]->Name << "\"." << std::endl - << "Please fix the cycle and run ctest again." << std::endl); - return false; - } + //cycle exists + cmCTestLog(this->CTest, ERROR_MESSAGE, "Error: a cycle exists in " + "the test dependency graph for the test \"" + << this->Properties[it->first]->Name << "\"." << std::endl + << "Please fix the cycle and run ctest again." << std::endl); + return false; } - visited.push_back(*d); + s.push(*d); } - visited.pop_back(); + visited.push_back(test); } } return true; diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h index 4f51b0b43..1483440c6 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.h +++ b/Source/CTest/cmCTestMultiProcessHandler.h @@ -23,10 +23,11 @@ */ class cmCTestMultiProcessHandler { + friend class TestComparator; public: struct TestSet : public std::set {}; struct TestMap : public std::map {}; - struct TestCostMap : public std::map {}; + struct TestList : public std::vector {}; struct PropertiesMap : public std::map {}; @@ -38,6 +39,7 @@ public: void SetParallelLevel(size_t); virtual void RunTests(); void PrintTestList(); + void PrintLabels(); void SetPassFailVectors(std::vector* passed, std::vector* failed) @@ -88,7 +90,7 @@ protected: void UnlockResources(int index); // map from test number to set of depend tests TestMap Tests; - TestCostMap TestCosts; + TestList SortedTests; //Total number of tests we'll be running size_t Total; //Number of tests that are complete diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h index c2cda667a..5765150f8 100644 --- a/Source/CTest/cmCTestRunScriptCommand.h +++ b/Source/CTest/cmCTestRunScriptCommand.h @@ -68,7 +68,7 @@ public: "Runs a script or scripts much like if it was run from ctest -S. " "If no argument is provided then the current script is run using " "the current settings of the variables. If NEW_PROCESS is specified " - "then each script will be run in a seperate process." + "then each script will be run in a separate process." "If RETURN_VALUE is specified the return value of the last script " "run will be put into var."; } diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 3719d45f2..76ff23a0d 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -83,7 +83,8 @@ void cmCTestRunTest::CompressOutput() reinterpret_cast( const_cast(this->ProcessOutput.c_str())); //zlib makes the guarantee that this is the maximum output size - int outSize = static_cast(this->ProcessOutput.size() * 1.001 + 13); + int outSize = static_cast( + static_cast(this->ProcessOutput.size()) * 1.001 + 13.0); unsigned char* out = new unsigned char[outSize]; strm.zalloc = Z_NULL; @@ -263,7 +264,17 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) { *this->TestHandler->LogFile << "Test time = " << buf << std::endl; } + + // Set the working directory to the tests directory + std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory(); + cmSystemTools::ChangeDirectory(this->TestProperties->Directory.c_str()); + this->DartProcessing(); + + // restore working directory + cmSystemTools::ChangeDirectory(oldpath.c_str()); + + // if this is doing MemCheck then all the output needs to be put into // Output since that is what is parsed by cmCTestMemCheckHandler if(!this->TestHandler->MemCheck && started) @@ -342,13 +353,14 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started) //---------------------------------------------------------------------- void cmCTestRunTest::ComputeWeightedCost() { - int prev = this->TestProperties->PreviousRuns; - float avgcost = this->TestProperties->Cost; + double prev = static_cast(this->TestProperties->PreviousRuns); + double avgcost = static_cast(this->TestProperties->Cost); double current = this->TestResult.ExecutionTime; if(this->TestResult.Status == cmCTestTestHandler::COMPLETED) { - this->TestProperties->Cost = ((prev * avgcost) + current) / (prev + 1); + this->TestProperties->Cost = + static_cast(((prev * avgcost) + current) / (prev + 1.0)); this->TestProperties->PreviousRuns++; } } @@ -469,7 +481,7 @@ void cmCTestRunTest::ComputeArguments() this->TestProperties->Args[1].c_str()); ++j; //skip the executable (it will be actualCommand) } - this->TestCommand + std::string testCommand = cmSystemTools::ConvertToOutputPath(this->ActualCommand.c_str()); //Prepends memcheck args to our command string @@ -477,22 +489,24 @@ void cmCTestRunTest::ComputeArguments() for(std::vector::iterator i = this->Arguments.begin(); i != this->Arguments.end(); ++i) { - this->TestCommand += " "; - this->TestCommand += cmSystemTools::EscapeSpaces(i->c_str()); + testCommand += " \""; + testCommand += *i; + testCommand += "\""; } for(;j != this->TestProperties->Args.end(); ++j) { - this->TestCommand += " "; - this->TestCommand += cmSystemTools::EscapeSpaces(j->c_str()); + testCommand += " \""; + testCommand += *j; + testCommand += "\""; this->Arguments.push_back(*j); } - this->TestResult.FullCommandLine = this->TestCommand; + this->TestResult.FullCommandLine = testCommand; cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl << this->Index << ": " << (this->TestHandler->MemCheck?"MemCheck":"Test") - << " command: " << this->TestCommand + << " command: " << testCommand << std::endl); } @@ -569,7 +583,7 @@ double cmCTestRunTest::ResolveTimeout() { stop_time += 24*60*60; } - int stop_timeout = (stop_time - current_time) % (24*60*60); + int stop_timeout = static_cast(stop_time - current_time) % (24*60*60); this->CTest->LastStopTimeout = stop_timeout; if(stop_timeout <= 0 || stop_timeout > this->CTest->LastStopTimeout) diff --git a/Source/CTest/cmCTestRunTest.h b/Source/CTest/cmCTestRunTest.h index e0cb888f8..66e6b7b49 100644 --- a/Source/CTest/cmCTestRunTest.h +++ b/Source/CTest/cmCTestRunTest.h @@ -89,7 +89,6 @@ private: cmCTestTestHandler::cmCTestTestResult TestResult; int Index; std::string StartTime; - std::string TestCommand; std::string ActualCommand; std::vector Arguments; bool StopTimePassed; diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index d1226da1f..24974e3bc 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -147,6 +147,13 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() static_cast(handler)->SelectParts(this->Parts); } + static_cast(handler)->SetOption("RetryDelay", + this->RetryDelay.c_str()); + static_cast(handler)->SetOption("RetryCount", + this->RetryCount.c_str()); + static_cast(handler)->SetOption("InternalTest", + this->InternalTest ? "ON" : "OFF"); + return handler; } @@ -169,6 +176,24 @@ bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg) return true; } + if(arg == "RETRY_COUNT") + { + this->ArgumentDoing = ArgumentDoingRetryCount; + return true; + } + + if(arg == "RETRY_DELAY") + { + this->ArgumentDoing = ArgumentDoingRetryDelay; + return true; + } + + if(arg == "INTERNAL_TEST_CHECKSUM") + { + this->InternalTest = true; + return true; + } + // Look for other arguments. return this->Superclass::CheckArgumentKeyword(arg); } @@ -213,6 +238,18 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg) return true; } + if(this->ArgumentDoing == ArgumentDoingRetryCount) + { + this->RetryCount = arg; + return true; + } + + if(this->ArgumentDoing == ArgumentDoingRetryDelay) + { + this->RetryDelay = arg; + return true; + } + // Look for other arguments. return this->Superclass::CheckArgumentValue(arg); } diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h index ccaef7e36..edc9c65b1 100644 --- a/Source/CTest/cmCTestSubmitCommand.h +++ b/Source/CTest/cmCTestSubmitCommand.h @@ -29,6 +29,9 @@ public: { this->PartsMentioned = false; this->FilesMentioned = false; + this->InternalTest = false; + this->RetryCount = ""; + this->RetryDelay = ""; } /** @@ -61,7 +64,8 @@ public: virtual const char* GetFullDocumentation() { return - " ctest_submit([PARTS ...] [FILES ...] [RETURN_VALUE res])\n" + " ctest_submit([PARTS ...] [FILES ...] [RETRY_COUNT count] " + " [RETRY_DELAY delay][RETURN_VALUE res])\n" "By default all available parts are submitted if no PARTS or FILES " "are specified. " "The PARTS option lists a subset of parts to be submitted. " @@ -77,7 +81,11 @@ public: " ExtraFiles = Files listed by CTEST_EXTRA_SUBMIT_FILES\n" " Submit = nothing\n" "The FILES option explicitly lists specific files to be submitted. " - "Each individual file must exist at the time of the call.\n"; + "Each individual file must exist at the time of the call.\n" + "The RETRY_DELAY option specifies how long in seconds to wait after " + "a timed-out submission before attempting to re-submit.\n" + "The RETRY_COUNT option specifies how many times to retry a timed-out " + "submission.\n"; } cmTypeMacro(cmCTestSubmitCommand, cmCTestHandlerCommand); @@ -92,13 +100,18 @@ protected: { ArgumentDoingParts = Superclass::ArgumentDoingLast1, ArgumentDoingFiles, + ArgumentDoingRetryDelay, + ArgumentDoingRetryCount, ArgumentDoingLast2 }; bool PartsMentioned; std::set Parts; bool FilesMentioned; + bool InternalTest; cmCTest::SetOfStrings Files; + std::string RetryCount; + std::string RetryDelay; }; diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 7b4f38b2c..9f9f85a83 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -15,6 +15,7 @@ #include "cmVersion.h" #include "cmGeneratedFileStream.h" #include "cmCTest.h" +#include "cmXMLParser.h" #include #include @@ -31,6 +32,90 @@ typedef std::vector cmCTestSubmitHandlerVectorOfChar; +//---------------------------------------------------------------------------- +class cmCTestSubmitHandler::ResponseParser: public cmXMLParser +{ +public: + ResponseParser() { this->Status = STATUS_OK; } + ~ResponseParser() {} + +public: + + enum StatusType + { + STATUS_OK, + STATUS_WARNING, + STATUS_ERROR + }; + + StatusType Status; + std::string CDashVersion; + std::string Filename; + std::string MD5; + std::string Message; + +private: + + std::vector CurrentValue; + + std::string GetCurrentValue() + { + std::string val; + if(this->CurrentValue.size()) + { + val.assign(&this->CurrentValue[0], this->CurrentValue.size()); + } + return val; + } + + virtual void StartElement(const char* name, const char** atts) + { + this->CurrentValue.clear(); + if(strcmp(name, "cdash") == 0) + { + this->CDashVersion = this->FindAttribute(atts, "version"); + } + } + + virtual void CharacterDataHandler(const char* data, int length) + { + this->CurrentValue.insert(this->CurrentValue.end(), data, data+length); + } + + virtual void EndElement(const char* name) + { + if(strcmp(name, "status") == 0) + { + std::string status = cmSystemTools::UpperCase(this->GetCurrentValue()); + if(status == "OK" || status == "SUCCESS") + { + this->Status = STATUS_OK; + } + else if(status == "WARNING") + { + this->Status = STATUS_WARNING; + } + else + { + this->Status = STATUS_ERROR; + } + } + else if(strcmp(name, "filename") == 0) + { + this->Filename = this->GetCurrentValue(); + } + else if(strcmp(name, "md5") == 0) + { + this->MD5 = this->GetCurrentValue(); + } + else if(strcmp(name, "message") == 0) + { + this->Message = this->GetCurrentValue(); + } + } +}; + + static size_t cmCTestSubmitHandlerWriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data) @@ -367,6 +452,20 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&") + "FileName=" + ofile; + upload_as += "&MD5="; + + if(cmSystemTools::IsOn(this->GetOption("InternalTest"))) + { + upload_as += "bad_md5sum"; + } + else + { + char md5[33]; + cmSystemTools::ComputeFileMD5(local_file.c_str(), md5); + md5[32] = 0; + upload_as += md5; + } + struct stat st; if ( ::stat(local_file.c_str(), &st) ) { @@ -382,7 +481,6 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, << local_file.c_str() << " to " << upload_as.c_str() << " Size: " << st.st_size << std::endl); - // specify target ::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str()); @@ -411,6 +509,19 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, // Now run off and do what you've been told! res = ::curl_easy_perform(curl); + if(cmSystemTools::IsOn(this->GetOption("InternalTest")) && + cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, + this->CTest->GetCDashVersion().c_str(), "1.7")) + { + // mock failure output for internal test case + std::string mock_output = "\n" + " ERROR\n" + " Checksum failed for file.\n" + "\n"; + chunk.clear(); + chunk.assign(mock_output.begin(), mock_output.end()); + } + if ( chunk.size() > 0 ) { cmCTestLog(this->CTest, DEBUG, "CURL output: [" @@ -425,6 +536,60 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix, << std::endl); } + // If curl failed for any reason, or checksum fails, wait and retry + // + if(res != CURLE_OK || this->HasErrors) + { + std::string retryDelay = this->GetOption("RetryDelay") == NULL ? + "" : this->GetOption("RetryDelay"); + std::string retryCount = this->GetOption("RetryCount") == NULL ? + "" : this->GetOption("RetryCount"); + + int delay = retryDelay == "" ? atoi(this->CTest->GetCTestConfiguration( + "CTestSubmitRetryDelay").c_str()) : atoi(retryDelay.c_str()); + int count = retryCount == "" ? atoi(this->CTest->GetCTestConfiguration( + "CTestSubmitRetryCount").c_str()) : atoi(retryCount.c_str()); + + for(int i = 0; i < count; i++) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Submit failed, waiting " << delay << " seconds...\n"); + + double stop = cmSystemTools::GetTime() + delay; + while(cmSystemTools::GetTime() < stop) + { + cmSystemTools::Delay(100); + } + + cmCTestLog(this->CTest, HANDLER_OUTPUT, + " Retry submission: Attempt " << (i + 1) << " of " + << count << std::endl); + + ::fclose(ftpfile); + ftpfile = ::fopen(local_file.c_str(), "rb"); + ::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile); + + chunk.clear(); + chunkDebug.clear(); + this->HasErrors = false; + + res = ::curl_easy_perform(curl); + + if ( chunk.size() > 0 ) + { + cmCTestLog(this->CTest, DEBUG, "CURL output: [" + << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]" + << std::endl); + this->ParseResponse(chunk); + } + + if(res == CURLE_OK && !this->HasErrors) + { + break; + } + } + } + fclose(ftpfile); if ( res ) { @@ -467,14 +632,22 @@ void cmCTestSubmitHandler ::ParseResponse(cmCTestSubmitHandlerVectorOfChar chunk) { std::string output = ""; + output.append(chunk.begin(), chunk.end()); - for(cmCTestSubmitHandlerVectorOfChar::iterator i = chunk.begin(); - i != chunk.end(); ++i) + if(output.find("HasErrors = true; + cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission failed: " << + parser.Message << std::endl); + return; + } } output = cmSystemTools::UpperCase(output); - if(output.find("WARNING") != std::string::npos) { this->HasWarnings = true; @@ -483,13 +656,12 @@ void cmCTestSubmitHandler { this->HasErrors = true; } - + if(this->HasWarnings || this->HasErrors) { cmCTestLog(this->CTest, HANDLER_OUTPUT, " Server Response:\n" << cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "\n"); } - } //---------------------------------------------------------------------------- @@ -589,7 +761,7 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP( << turl.c_str() << std::endl); cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: " << error_buffer << std::endl); - *this->LogFile << "\tTrigerring failed with error: " << error_buffer + *this->LogFile << "\tTriggering failed with error: " << error_buffer << std::endl << " Error message was: " << error_buffer << std::endl; diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h index 8b011ea19..e7755b138 100644 --- a/Source/CTest/cmCTestSubmitHandler.h +++ b/Source/CTest/cmCTestSubmitHandler.h @@ -79,6 +79,7 @@ private: std::string GetSubmitResultsPrefix(); + class ResponseParser; cmStdString HTTPProxy; int HTTPProxyType; cmStdString HTTPProxyAuth; diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index d2742ecf3..6dd348def 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -567,7 +567,7 @@ int cmCTestTestHandler::ProcessHandler() if (total == 0) { - if ( !this->CTest->GetShowOnly() ) + if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() ) { cmCTestLog(this->CTest, ERROR_MESSAGE, "No tests were found!!!" << std::endl); @@ -1048,7 +1048,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, if(randomSchedule) { - p.Cost = rand(); + p.Cost = static_cast(rand()); } if(p.Timeout == 0 && this->CTest->GetGlobalTimeout() != 0) @@ -1079,7 +1079,12 @@ void cmCTestTestHandler::ProcessDirectory(std::vector &passed, parallel->SetPassFailVectors(&passed, &failed); this->TestResults.clear(); parallel->SetTestResults(&this->TestResults); - if(this->CTest->GetShowOnly()) + + if(this->CTest->ShouldPrintLabels()) + { + parallel->PrintLabels(); + } + else if(this->CTest->GetShowOnly()) { parallel->PrintTestList(); } @@ -1309,7 +1314,8 @@ std::string cmCTestTestHandler::EncodeFile(std::string file) cmSystemTools::RemoveFile(tarFile.c_str()); unsigned char *encoded_buffer - = new unsigned char [ static_cast(len * 1.5 + 5) ]; + = new unsigned char [ static_cast( + static_cast(len) * 1.5 + 5.0) ]; unsigned long rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); @@ -1881,7 +1887,8 @@ std::string cmCTestTestHandler::GenerateRegressionImages( unsigned char *file_buffer = new unsigned char [ len + 1 ]; ifs.read(reinterpret_cast(file_buffer), len); unsigned char *encoded_buffer - = new unsigned char [ static_cast(len * 1.5 + 5) ]; + = new unsigned char [ static_cast( + static_cast(len) * 1.5 + 5.0) ]; unsigned long rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1); diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index c66147b31..1c48d8c7c 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -53,13 +53,13 @@ void cmCursesLongMessageForm::UpdateStatusBar() getmaxyx(stdscr, y, x); char bar[cmCursesMainForm::MAX_WIDTH]; - int size = strlen(this->Title.c_str()); + size_t size = strlen(this->Title.c_str()); if ( size >= cmCursesMainForm::MAX_WIDTH ) { size = cmCursesMainForm::MAX_WIDTH-1; } strncpy(bar, this->Title.c_str(), size); - for(int i=size-1; iFields = new FIELD*[3*this->NumberOfVisibleEntries+1]; - int cc; + size_t cc; for ( cc = 0; cc < 3 * this->NumberOfVisibleEntries+1; cc ++ ) { this->Fields[cc] = 0; @@ -454,7 +454,7 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */) if (cw) { sprintf(firstLine, "Page %d of %d", cw->GetPage(), this->NumberOfPages); - curses_move(0,65-strlen(firstLine)-1); + curses_move(0,65-static_cast(strlen(firstLine))-1); printw(firstLine); } // } @@ -526,10 +526,10 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) // Join the key, help string and pad with spaces // (or truncate) as necessary char bar[cmCursesMainForm::MAX_WIDTH]; - int i, curFieldLen = strlen(curField); - int helpLen = strlen(help); + size_t i, curFieldLen = strlen(curField); + size_t helpLen = strlen(help); - int width; + size_t width; if (x < cmCursesMainForm::MAX_WIDTH ) { width = x; @@ -592,7 +592,7 @@ void cmCursesMainForm::UpdateStatusBar(const char* message) char version[cmCursesMainForm::MAX_WIDTH]; char vertmp[128]; sprintf(vertmp,"CMake Version %s", cmVersion::GetCMakeVersion()); - int sideSpace = (width-strlen(vertmp)); + size_t sideSpace = (width-strlen(vertmp)); for(i=0; iEntries->size(); - for(int i=0; i < size; i++) + size_t size = this->Entries->size(); + for(size_t i=0; i < size; i++) { cmCacheManager::CacheIterator it = this->CMakeInstance->GetCacheManager()->GetCacheIterator( @@ -866,7 +866,7 @@ void cmCursesMainForm::HandleInput() std::string searchstr = "Search: " + this->SearchString; this->UpdateStatusBar( searchstr.c_str() ); this->PrintKeys(1); - curses_move(y-5,searchstr.size()); + curses_move(y-5,static_cast(searchstr.size())); //curses_move(1,1); touchwin(stdscr); refresh(); @@ -902,7 +902,7 @@ void cmCursesMainForm::HandleInput() this->SearchMode = false; if ( this->SearchString.size() > 0 ) { - this->JumpToCacheEntry(-1, this->SearchString.c_str()); + this->JumpToCacheEntry(this->SearchString.c_str()); this->OldSearchString = this->SearchString; } this->SearchString = ""; @@ -961,7 +961,7 @@ void cmCursesMainForm::HandleInput() else if ( key == KEY_DOWN || key == ctrl('n') ) { FIELD* cur = current_field(this->Form); - int findex = field_index(cur); + size_t findex = field_index(cur); if ( findex == 3*this->NumberOfVisibleEntries-1 ) { continue; @@ -1076,7 +1076,7 @@ void cmCursesMainForm::HandleInput() { if ( this->OldSearchString.size() > 0 ) { - this->JumpToCacheEntry(-1, this->OldSearchString.c_str()); + this->JumpToCacheEntry(this->OldSearchString.c_str()); } } // switch advanced on/off @@ -1108,7 +1108,7 @@ void cmCursesMainForm::HandleInput() { this->OkToGenerate = false; FIELD* cur = current_field(this->Form); - int findex = field_index(cur); + size_t findex = field_index(cur); // make the next or prev. current field after deletion // each entry consists of fields: label, isnew, value @@ -1191,7 +1191,7 @@ int cmCursesMainForm::LoadCache(const char *) return r; } -void cmCursesMainForm::JumpToCacheEntry(int idx, const char* astr) +void cmCursesMainForm::JumpToCacheEntry(const char* astr) { std::string str; if ( astr ) @@ -1199,18 +1199,14 @@ void cmCursesMainForm::JumpToCacheEntry(int idx, const char* astr) str = cmSystemTools::LowerCase(astr); } - if ( idx > this->NumberOfVisibleEntries ) - { - return; - } - if ( idx < 0 && str.size() == 0) + if(str.empty()) { return; } FIELD* cur = current_field(this->Form); int start_index = field_index(cur); int findex = start_index; - while ( (findex / 3) != idx ) + for(;;) { if ( str.size() > 0 ) { @@ -1232,7 +1228,7 @@ void cmCursesMainForm::JumpToCacheEntry(int idx, const char* astr) } } } - if ( findex >= 3* this->NumberOfVisibleEntries-1 ) + if ( size_t(findex) >= 3* this->NumberOfVisibleEntries-1 ) { set_current_field(this->Form, this->Fields[2]); } diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h index 975199988..3e191b497 100644 --- a/Source/CursesDialog/cmCursesMainForm.h +++ b/Source/CursesDialog/cmCursesMainForm.h @@ -122,9 +122,8 @@ protected: // Remove an entry from the interface and the cache. void RemoveEntry(const char* value); - // Jump to the cache value with index idx. If string str is - // specified, it will stop on widget that contain that string. - void JumpToCacheEntry(int idx, const char* str); + // Jump to the cache entry whose name matches the string. + void JumpToCacheEntry(const char* str); // Copies of cache entries stored in the user interface std::vector* Entries; @@ -147,7 +146,7 @@ protected: // Where is cmake executable std::string WhereCMake; // Number of entries shown (depends on mode -normal or advanced-) - int NumberOfVisibleEntries; + size_t NumberOfVisibleEntries; bool AdvancedMode; // Did the iteration converge (no new entries) ? bool OkToGenerate; diff --git a/Source/CursesDialog/form/fld_info.c b/Source/CursesDialog/form/fld_info.c index 7c50b1df0..1ba92c833 100644 --- a/Source/CursesDialog/form/fld_info.c +++ b/Source/CursesDialog/form/fld_info.c @@ -69,7 +69,7 @@ int field_info(const FIELD *field, | int *drows, int *dcols, | int *maxgrow) | -| Description : Retrieve informations about a dynamic fields current +| Description : Retrieve information about a dynamic fields current | dynamic parameters. | | Return Values : E_OK - success diff --git a/Source/CursesDialog/form/fld_user.c b/Source/CursesDialog/form/fld_user.c index 7ffca9c0e..3287b5b17 100644 --- a/Source/CursesDialog/form/fld_user.c +++ b/Source/CursesDialog/form/fld_user.c @@ -39,7 +39,7 @@ MODULE_ID("$Id$") | Function : int set_field_userptr(FIELD *field, void *usrptr) | | Description : Set the pointer that is reserved in any field to store -| application relevant informations +| application relevant information | | Return Values : E_OK - on success +--------------------------------------------------------------------------*/ @@ -54,7 +54,7 @@ int set_field_userptr(FIELD * field, void *usrptr) | Function : void *field_userptr(const FIELD *field) | | Description : Return the pointer that is reserved in any field to -| store application relevant informations. +| store application relevant information. | | Return Values : Value of pointer. If no such pointer has been set, | NULL is returned diff --git a/Source/CursesDialog/form/frm_user.c b/Source/CursesDialog/form/frm_user.c index 8f0edbcfe..f38bbbb8d 100644 --- a/Source/CursesDialog/form/frm_user.c +++ b/Source/CursesDialog/form/frm_user.c @@ -39,7 +39,7 @@ MODULE_ID("$Id$") | Function : int set_form_userptr(FORM *form, void *usrptr) | | Description : Set the pointer that is reserved in any form to store -| application relevant informations +| application relevant information | | Return Values : E_OK - on success +--------------------------------------------------------------------------*/ @@ -54,7 +54,7 @@ int set_form_userptr(FORM * form, void *usrptr) | Function : void *form_userptr(const FORM *form) | | Description : Return the pointer that is reserved in any form to -| store application relevant informations. +| store application relevant information. | | Return Values : Value of pointer. If no such pointer has been set, | NULL is returned diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 74a3d3594..29fcfc0ee 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -34,7 +34,7 @@ #include "FirstConfigure.h" #include "cmVersion.h" -QCMakeThread::QCMakeThread(QObject* p) +QCMakeThread::QCMakeThread(QObject* p) : QThread(p), CMakeInstance(NULL) { } @@ -76,7 +76,7 @@ CMakeSetupDialog::CMakeSetupDialog() this->ProgressBar->reset(); this->RemoveEntry->setEnabled(false); this->AddEntry->setEnabled(false); - + QByteArray p = settings.value("SplitterSizes").toByteArray(); this->Splitter->restoreState(p); @@ -84,50 +84,54 @@ CMakeSetupDialog::CMakeSetupDialog() this->setGroupedView(groupView); this->groupedCheck->setCheckState(groupView ? Qt::Checked : Qt::Unchecked); + bool advancedView = settings.value("AdvancedView", false).toBool(); + this->setAdvancedView(advancedView); + this->advancedCheck->setCheckState(advancedView?Qt::Checked : Qt::Unchecked); + QMenu* FileMenu = this->menuBar()->addMenu(tr("&File")); this->ReloadCacheAction = FileMenu->addAction(tr("&Reload Cache")); - QObject::connect(this->ReloadCacheAction, SIGNAL(triggered(bool)), + QObject::connect(this->ReloadCacheAction, SIGNAL(triggered(bool)), this, SLOT(doReloadCache())); this->DeleteCacheAction = FileMenu->addAction(tr("&Delete Cache")); - QObject::connect(this->DeleteCacheAction, SIGNAL(triggered(bool)), + QObject::connect(this->DeleteCacheAction, SIGNAL(triggered(bool)), this, SLOT(doDeleteCache())); this->ExitAction = FileMenu->addAction(tr("E&xit")); - QObject::connect(this->ExitAction, SIGNAL(triggered(bool)), + QObject::connect(this->ExitAction, SIGNAL(triggered(bool)), this, SLOT(close())); QMenu* ToolsMenu = this->menuBar()->addMenu(tr("&Tools")); this->ConfigureAction = ToolsMenu->addAction(tr("&Configure")); // prevent merging with Preferences menu item on Mac OS X this->ConfigureAction->setMenuRole(QAction::NoRole); - QObject::connect(this->ConfigureAction, SIGNAL(triggered(bool)), + QObject::connect(this->ConfigureAction, SIGNAL(triggered(bool)), this, SLOT(doConfigure())); this->GenerateAction = ToolsMenu->addAction(tr("&Generate")); - QObject::connect(this->GenerateAction, SIGNAL(triggered(bool)), + QObject::connect(this->GenerateAction, SIGNAL(triggered(bool)), this, SLOT(doGenerate())); QAction* showChangesAction = ToolsMenu->addAction(tr("&Show My Changes")); - QObject::connect(showChangesAction, SIGNAL(triggered(bool)), + QObject::connect(showChangesAction, SIGNAL(triggered(bool)), this, SLOT(showUserChanges())); #if defined(Q_WS_MAC) - this->InstallForCommandLineAction + this->InstallForCommandLineAction = ToolsMenu->addAction(tr("&Install For Command Line Use")); - QObject::connect(this->InstallForCommandLineAction, SIGNAL(triggered(bool)), + QObject::connect(this->InstallForCommandLineAction, SIGNAL(triggered(bool)), this, SLOT(doInstallForCommandLine())); -#endif +#endif QMenu* OptionsMenu = this->menuBar()->addMenu(tr("&Options")); this->SuppressDevWarningsAction = OptionsMenu->addAction(tr("&Suppress dev Warnings (-Wno-dev)")); this->SuppressDevWarningsAction->setCheckable(true); QAction* debugAction = OptionsMenu->addAction(tr("&Debug Output")); debugAction->setCheckable(true); - QObject::connect(debugAction, SIGNAL(toggled(bool)), + QObject::connect(debugAction, SIGNAL(toggled(bool)), this, SLOT(setDebugOutput(bool))); - + OptionsMenu->addSeparator(); QAction* expandAction = OptionsMenu->addAction(tr("&Expand Grouped Entries")); - QObject::connect(expandAction, SIGNAL(triggered(bool)), + QObject::connect(expandAction, SIGNAL(triggered(bool)), this->CacheValues, SLOT(expandAll())); QAction* collapseAction = OptionsMenu->addAction(tr("&Collapse Grouped Entries")); - QObject::connect(collapseAction, SIGNAL(triggered(bool)), + QObject::connect(collapseAction, SIGNAL(triggered(bool)), this->CacheValues, SLOT(collapseAll())); QMenu* HelpMenu = this->menuBar()->addMenu(tr("&Help")); @@ -137,17 +141,17 @@ CMakeSetupDialog::CMakeSetupDialog() a = HelpMenu->addAction(tr("Help")); QObject::connect(a, SIGNAL(triggered(bool)), this, SLOT(doHelp())); - + QShortcut* filterShortcut = new QShortcut(QKeySequence::Find, this); - QObject::connect(filterShortcut, SIGNAL(activated()), + QObject::connect(filterShortcut, SIGNAL(activated()), this, SLOT(startSearch())); - + this->setAcceptDrops(true); - + // get the saved binary directories QStringList buildPaths = this->loadBuildPaths(); this->BinaryDirectory->addItems(buildPaths); - + this->BinaryDirectory->setCompleter(new QCMakeFileCompleter(this, true)); this->SourceDirectory->setCompleter(new QCMakeFileCompleter(this, true)); @@ -159,23 +163,23 @@ CMakeSetupDialog::CMakeSetupDialog() // start the cmake worker thread this->CMakeThread = new QCMakeThread(this); QObject::connect(this->CMakeThread, SIGNAL(cmakeInitialized()), - this, SLOT(initialize()), Qt::QueuedConnection); + this, SLOT(initialize()), Qt::QueuedConnection); this->CMakeThread->start(); - + this->enterState(ReadyConfigure); } void CMakeSetupDialog::initialize() { // now the cmake worker thread is running, lets make our connections to it - QObject::connect(this->CMakeThread->cmakeInstance(), + QObject::connect(this->CMakeThread->cmakeInstance(), SIGNAL(propertiesChanged(const QCMakePropertyList&)), this->CacheValues->cacheModel(), SLOT(setProperties(const QCMakePropertyList&))); QObject::connect(this->ConfigureButton, SIGNAL(clicked(bool)), this, SLOT(doConfigure())); - QObject::connect(this->CMakeThread->cmakeInstance(), + QObject::connect(this->CMakeThread->cmakeInstance(), SIGNAL(configureDone(int)), this, SLOT(finishConfigure(int))); QObject::connect(this->CMakeThread->cmakeInstance(), @@ -184,12 +188,12 @@ void CMakeSetupDialog::initialize() QObject::connect(this->GenerateButton, SIGNAL(clicked(bool)), this, SLOT(doGenerate())); - + QObject::connect(this->BrowseSourceDirectoryButton, SIGNAL(clicked(bool)), this, SLOT(doSourceBrowse())); QObject::connect(this->BrowseBinaryDirectoryButton, SIGNAL(clicked(bool)), this, SLOT(doBinaryBrowse())); - + QObject::connect(this->BinaryDirectory, SIGNAL(editTextChanged(QString)), this, SLOT(onBinaryDirectoryChanged(QString))); QObject::connect(this->SourceDirectory, SIGNAL(textChanged(QString)), @@ -201,11 +205,11 @@ void CMakeSetupDialog::initialize() QObject::connect(this->CMakeThread->cmakeInstance(), SIGNAL(binaryDirChanged(QString)), this, SLOT(updateBinaryDirectory(QString))); - + QObject::connect(this->CMakeThread->cmakeInstance(), SIGNAL(progressChanged(QString, float)), this, SLOT(showProgress(QString,float))); - + QObject::connect(this->CMakeThread->cmakeInstance(), SIGNAL(errorMessage(QString)), this, SLOT(error(QString))); @@ -218,29 +222,29 @@ void CMakeSetupDialog::initialize() this, SLOT(setGroupedView(bool))); QObject::connect(this->advancedCheck, SIGNAL(toggled(bool)), this, SLOT(setAdvancedView(bool))); - QObject::connect(this->Search, SIGNAL(textChanged(QString)), + QObject::connect(this->Search, SIGNAL(textChanged(QString)), this, SLOT(setSearchFilter(QString))); - + QObject::connect(this->CMakeThread->cmakeInstance(), SIGNAL(generatorChanged(QString)), this, SLOT(updateGeneratorLabel(QString))); this->updateGeneratorLabel(QString()); - + QObject::connect(this->CacheValues->cacheModel(), - SIGNAL(dataChanged(QModelIndex,QModelIndex)), + SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(setCacheModified())); - + QObject::connect(this->CacheValues->selectionModel(), - SIGNAL(selectionChanged(QItemSelection,QItemSelection)), + SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged())); - QObject::connect(this->RemoveEntry, SIGNAL(clicked(bool)), + QObject::connect(this->RemoveEntry, SIGNAL(clicked(bool)), this, SLOT(removeSelectedCacheEntries())); - QObject::connect(this->AddEntry, SIGNAL(clicked(bool)), + QObject::connect(this->AddEntry, SIGNAL(clicked(bool)), this, SLOT(addCacheEntry())); - QObject::connect(this->SuppressDevWarningsAction, SIGNAL(triggered(bool)), + QObject::connect(this->SuppressDevWarningsAction, SIGNAL(triggered(bool)), this->CMakeThread->cmakeInstance(), SLOT(setSuppressDevWarnings(bool))); - + if(!this->SourceDirectory->text().isEmpty() || !this->BinaryDirectory->lineEdit()->text().isEmpty()) { @@ -265,7 +269,7 @@ CMakeSetupDialog::~CMakeSetupDialog() this->CMakeThread->quit(); this->CMakeThread->wait(2000); } - + void CMakeSetupDialog::doConfigure() { if(this->CurrentState == Configuring) @@ -287,7 +291,7 @@ void CMakeSetupDialog::doConfigure() msg += bindir; QString title = tr("Create Directory"); QMessageBox::StandardButton btn; - btn = QMessageBox::information(this, title, msg, + btn = QMessageBox::information(this, title, msg, QMessageBox::Yes | QMessageBox::No); if(btn == QMessageBox::No) { @@ -295,8 +299,8 @@ void CMakeSetupDialog::doConfigure() } if(!dir.mkpath(".")) { - QMessageBox::information(this, tr("Create Directory Failed"), - QString(tr("Failed to create directory %1")).arg(dir.path()), + QMessageBox::information(this, tr("Create Directory Failed"), + QString(tr("Failed to create directory %1")).arg(dir.path()), QMessageBox::Ok); return; @@ -314,12 +318,12 @@ void CMakeSetupDialog::doConfigure() // remember path this->addBinaryPath(dir.absolutePath()); - + this->enterState(Configuring); this->CacheValues->selectionModel()->clear(); QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), - "setProperties", Qt::QueuedConnection, + "setProperties", Qt::QueuedConnection, Q_ARG(QCMakePropertyList, this->CacheValues->cacheModel()->properties())); QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), @@ -337,11 +341,11 @@ void CMakeSetupDialog::finishConfigure(int err) this->enterState(ReadyConfigure); this->CacheValues->scrollToTop(); } - + if(err != 0) { - QMessageBox::critical(this, tr("Error"), - tr("Error in configuration process, project files may be invalid"), + QMessageBox::critical(this, tr("Error"), + tr("Error in configuration process, project files may be invalid"), QMessageBox::Ok); } } @@ -351,7 +355,7 @@ void CMakeSetupDialog::finishGenerate(int err) this->enterState(ReadyConfigure); if(err != 0) { - QMessageBox::critical(this, tr("Error"), + QMessageBox::critical(this, tr("Error"), tr("Error in generation process, project files may be invalid"), QMessageBox::Ok); } @@ -375,7 +379,7 @@ void CMakeSetupDialog::doGenerate() QMetaObject::invokeMethod(this->CMakeThread->cmakeInstance(), "generate", Qt::QueuedConnection); } - + void CMakeSetupDialog::closeEvent(QCloseEvent* e) { // prompt for close if there are unsaved changes, and we're not busy @@ -466,7 +470,7 @@ void CMakeSetupDialog::doInterrupt() void CMakeSetupDialog::doSourceBrowse() { - QString dir = QFileDialog::getExistingDirectory(this, + QString dir = QFileDialog::getExistingDirectory(this, tr("Enter Path to Source"), this->SourceDirectory->text()); if(!dir.isEmpty()) { @@ -496,7 +500,7 @@ void CMakeSetupDialog::updateBinaryDirectory(const QString& dir) void CMakeSetupDialog::doBinaryBrowse() { - QString dir = QFileDialog::getExistingDirectory(this, + QString dir = QFileDialog::getExistingDirectory(this, tr("Enter Path to Build"), this->BinaryDirectory->currentText()); if(!dir.isEmpty() && dir != this->BinaryDirectory->currentText()) { @@ -585,7 +589,7 @@ bool CMakeSetupDialog::setupFirstConfigure() { dialog.saveToSettings(); this->CMakeThread->cmakeInstance()->setGenerator(dialog.getGenerator()); - + QCMakeCacheModel* m = this->CacheValues->cacheModel(); if(dialog.compilerSetup()) @@ -593,20 +597,20 @@ bool CMakeSetupDialog::setupFirstConfigure() QString fortranCompiler = dialog.getFortranCompiler(); if(!fortranCompiler.isEmpty()) { - m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER", + m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER", "Fortran compiler.", fortranCompiler, false); } QString cxxCompiler = dialog.getCXXCompiler(); if(!cxxCompiler.isEmpty()) { - m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER", + m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER", "CXX compiler.", cxxCompiler, false); } - + QString cCompiler = dialog.getCCompiler(); if(!cCompiler.isEmpty()) { - m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER", + m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER", "C compiler.", cCompiler, false); } } @@ -615,38 +619,38 @@ bool CMakeSetupDialog::setupFirstConfigure() QString fortranCompiler = dialog.getFortranCompiler(); if(!fortranCompiler.isEmpty()) { - m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER", + m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_Fortran_COMPILER", "Fortran compiler.", fortranCompiler, false); } QString mode = dialog.getCrossIncludeMode(); - m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE", + m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_INCLUDE", "CMake Find Include Mode", mode, false); mode = dialog.getCrossLibraryMode(); - m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY", + m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_LIBRARY", "CMake Find Library Mode", mode, false); mode = dialog.getCrossProgramMode(); - m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM", + m->insertProperty(QCMakeProperty::STRING, "CMAKE_FIND_ROOT_PATH_MODE_PROGRAM", "CMake Find Program Mode", mode, false); - + QString rootPath = dialog.getCrossRoot(); - m->insertProperty(QCMakeProperty::PATH, "CMAKE_FIND_ROOT_PATH", + m->insertProperty(QCMakeProperty::PATH, "CMAKE_FIND_ROOT_PATH", "CMake Find Root Path", rootPath, false); QString systemName = dialog.getSystemName(); - m->insertProperty(QCMakeProperty::STRING, "CMAKE_SYSTEM_NAME", + m->insertProperty(QCMakeProperty::STRING, "CMAKE_SYSTEM_NAME", "CMake System Name", systemName, false); QString cxxCompiler = dialog.getCXXCompiler(); - m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER", + m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER", "CXX compiler.", cxxCompiler, false); QString cCompiler = dialog.getCCompiler(); - m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER", + m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_C_COMPILER", "C compiler.", cCompiler, false); } else if(dialog.crossCompilerToolChainFile()) { QString toolchainFile = dialog.getCrossCompilerToolChainFile(); - m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_TOOLCHAIN_FILE", + m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_TOOLCHAIN_FILE", "Cross Compile ToolChain File", toolchainFile, false); } return true; @@ -676,11 +680,11 @@ void CMakeSetupDialog::doReloadCache() } void CMakeSetupDialog::doDeleteCache() -{ +{ QString title = tr("Delete Cache"); QString msg = "Are you sure you want to delete the cache?"; QMessageBox::StandardButton btn; - btn = QMessageBox::information(this, title, msg, + btn = QMessageBox::information(this, title, msg, QMessageBox::Yes | QMessageBox::No); if(btn == QMessageBox::No) { @@ -721,7 +725,7 @@ void CMakeSetupDialog::setExitAfterGenerate(bool b) void CMakeSetupDialog::addBinaryPath(const QString& path) { QString cleanpath = QDir::cleanPath(path); - + // update UI this->BinaryDirectory->blockSignals(true); int idx = this->BinaryDirectory->findText(cleanpath); @@ -732,7 +736,7 @@ void CMakeSetupDialog::addBinaryPath(const QString& path) this->BinaryDirectory->insertItem(0, cleanpath); this->BinaryDirectory->setCurrentIndex(0); this->BinaryDirectory->blockSignals(false); - + // save to registry QStringList buildPaths = this->loadBuildPaths(); buildPaths.removeAll(cleanpath); @@ -742,7 +746,7 @@ void CMakeSetupDialog::addBinaryPath(const QString& path) void CMakeSetupDialog::dragEnterEvent(QDragEnterEvent* e) { - if(!(this->CurrentState == ReadyConfigure || + if(!(this->CurrentState == ReadyConfigure || this->CurrentState == ReadyGenerate)) { e->ignore(); @@ -752,7 +756,7 @@ void CMakeSetupDialog::dragEnterEvent(QDragEnterEvent* e) const QMimeData* dat = e->mimeData(); QList urls = dat->urls(); QString file = urls.count() ? urls[0].toLocalFile() : QString(); - if(!file.isEmpty() && + if(!file.isEmpty() && (file.endsWith("CMakeCache.txt", Qt::CaseInsensitive) || file.endsWith("CMakeLists.txt", Qt::CaseInsensitive) ) ) { @@ -766,7 +770,7 @@ void CMakeSetupDialog::dragEnterEvent(QDragEnterEvent* e) void CMakeSetupDialog::dropEvent(QDropEvent* e) { - if(!(this->CurrentState == ReadyConfigure || + if(!(this->CurrentState == ReadyConfigure || this->CurrentState == ReadyGenerate)) { return; @@ -801,7 +805,7 @@ QStringList CMakeSetupDialog::loadBuildPaths() QStringList buildPaths; for(int i=0; i<10; i++) - { + { QString p = settings.value(QString("WhereBuild%1").arg(i)).toString(); if(!p.isEmpty()) { @@ -823,11 +827,11 @@ void CMakeSetupDialog::saveBuildPaths(const QStringList& paths) } for(int i=0; iCacheModified = true; @@ -851,8 +855,8 @@ void CMakeSetupDialog::removeSelectedCacheEntries() void CMakeSetupDialog::selectionChanged() { QModelIndexList idxs = this->CacheValues->selectionModel()->selectedRows(); - if(idxs.count() && - (this->CurrentState == ReadyConfigure || + if(idxs.count() && + (this->CurrentState == ReadyConfigure || this->CurrentState == ReadyGenerate) ) { this->RemoveEntry->setEnabled(true); @@ -862,7 +866,7 @@ void CMakeSetupDialog::selectionChanged() this->RemoveEntry->setEnabled(false); } } - + void CMakeSetupDialog::enterState(CMakeSetupDialog::State s) { if(s == this->CurrentState) @@ -953,16 +957,19 @@ void CMakeSetupDialog::setGroupedView(bool v) { this->CacheValues->cacheModel()->setViewType(v ? QCMakeCacheModel::GroupView : QCMakeCacheModel::FlatView); this->CacheValues->setRootIsDecorated(v); - + QSettings settings; settings.beginGroup("Settings/StartPath"); settings.setValue("GroupView", v); - + } void CMakeSetupDialog::setAdvancedView(bool v) { this->CacheValues->setShowAdvanced(v); + QSettings settings; + settings.beginGroup("Settings/StartPath"); + settings.setValue("AdvancedView", v); } void CMakeSetupDialog::showUserChanges() @@ -984,7 +991,7 @@ void CMakeSetupDialog::showUserChanges() QString command; QString cache; - + foreach(QCMakeProperty prop, changes) { QString type; @@ -1020,13 +1027,13 @@ void CMakeSetupDialog::showUserChanges() command += QString("-D%1\"%2\" ").arg(line).arg(value); cache += QString("%1%2\n").arg(line).arg(value); } - + textedit->append(tr("Commandline options:")); textedit->append(command); textedit->append("\n"); textedit->append(tr("Cache file:")); textedit->append(cache); - + dialog.exec(); } diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx new file mode 100644 index 000000000..d9e4742a2 --- /dev/null +++ b/Source/cmArchiveWrite.cxx @@ -0,0 +1,299 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2010 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 "cmArchiveWrite.h" + +#include "cmSystemTools.h" +#include +#include +#include + +//---------------------------------------------------------------------------- +class cmArchiveWrite::Entry +{ + struct archive_entry* Object; +public: + Entry(): Object(archive_entry_new()) {} + ~Entry() { archive_entry_free(this->Object); } + operator struct archive_entry*() { return this->Object; } +}; + +//---------------------------------------------------------------------------- +struct cmArchiveWrite::Callback +{ + // archive_write_callback + static __LA_SSIZE_T Write(struct archive*, void *cd, + const void *b, size_t n) + { + cmArchiveWrite* self = static_cast(cd); + if(self->Stream.write(static_cast(b), + static_cast(n))) + { + return static_cast<__LA_SSIZE_T>(n); + } + else + { + return static_cast<__LA_SSIZE_T>(-1); + } + } +}; + +//---------------------------------------------------------------------------- +cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, Type t): + Stream(os), + Archive(archive_write_new()), + Disk(archive_read_disk_new()), + Verbose(false) +{ + switch (c) + { + case CompressNone: + if(archive_write_set_compression_none(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_compression_none: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; + case CompressCompress: + if(archive_write_set_compression_compress(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_compression_compress: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; + case CompressGZip: + if(archive_write_set_compression_gzip(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_compression_gzip: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; + case CompressBZip2: + if(archive_write_set_compression_bzip2(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_compression_bzip2: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; + case CompressLZMA: + if(archive_write_set_compression_lzma(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_compression_lzma: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; + case CompressXZ: + if(archive_write_set_compression_xz(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_compression_xz: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; + }; +#if !defined(_WIN32) || defined(__CYGWIN__) + if (archive_read_disk_set_standard_lookup(this->Disk) != ARCHIVE_OK) + { + this->Error = "archive_read_disk_set_standard_lookup: "; + this->Error += archive_error_string(this->Archive); + return;; + } +#endif + switch (t) + { + case TypeZIP: + if(archive_write_set_format_zip(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_format_zip: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; + case TypeTAR: + if(archive_write_set_format_pax_restricted(this->Archive) != ARCHIVE_OK) + { + this->Error = "archive_write_set_format_pax_restricted: "; + this->Error += archive_error_string(this->Archive); + return; + } + break; + } + + // do not pad the last block!! + if (archive_write_set_bytes_in_last_block(this->Archive, 1)) + { + this->Error = "archive_write_set_bytes_in_last_block: "; + this->Error += archive_error_string(this->Archive); + return; + } + + if(archive_write_open( + this->Archive, this, 0, + reinterpret_cast(&Callback::Write), + 0) != ARCHIVE_OK) + { + this->Error = "archive_write_open: "; + this->Error += archive_error_string(this->Archive); + return; + } +} + +//---------------------------------------------------------------------------- +cmArchiveWrite::~cmArchiveWrite() +{ + archive_read_finish(this->Disk); + archive_write_finish(this->Archive); +} + +//---------------------------------------------------------------------------- +bool cmArchiveWrite::Add(std::string path, size_t skip, const char* prefix) +{ + if(this->Okay()) + { + if(!path.empty() && path[path.size()-1] == '/') + { + path.erase(path.size()-1); + } + this->AddPath(path.c_str(), skip, prefix); + } + return this->Okay(); +} + +//---------------------------------------------------------------------------- +bool cmArchiveWrite::AddPath(const char* path, + size_t skip, const char* prefix) +{ + if(!this->AddFile(path, skip, prefix)) + { + return false; + } + if(!cmSystemTools::FileIsDirectory(path)) + { + return true; + } + cmsys::Directory d; + if(d.Load(path)) + { + std::string next = path; + next += "/"; + std::string::size_type end = next.size(); + unsigned long n = d.GetNumberOfFiles(); + for(unsigned long i = 0; i < n; ++i) + { + const char* file = d.GetFile(i); + if(strcmp(file, ".") != 0 && strcmp(file, "..") != 0) + { + next.erase(end); + next += file; + if(!this->AddPath(next.c_str(), skip, prefix)) + { + return false; + } + } + } + } + return true; +} + +//---------------------------------------------------------------------------- +bool cmArchiveWrite::AddFile(const char* file, + size_t skip, const char* prefix) +{ + // Skip the file if we have no name for it. This may happen on a + // top-level directory, which does not need to be included anyway. + if(skip >= strlen(file)) + { + return true; + } + const char* out = file + skip; + + // Meta-data. + std::string dest = prefix? prefix : ""; + dest += out; + if(this->Verbose) + { + std::cout << dest << "\n"; + } + Entry e; + archive_entry_copy_sourcepath(e, file); + archive_entry_set_pathname(e, dest.c_str()); + if(archive_read_disk_entry_from_file(this->Disk, e, -1, 0) != ARCHIVE_OK) + { + this->Error = "archive_read_disk_entry_from_file: "; + this->Error += archive_error_string(this->Disk); + return false; + } + if(archive_write_header(this->Archive, e) != ARCHIVE_OK) + { + this->Error = "archive_write_header: "; + this->Error += archive_error_string(this->Archive); + return false; + } + + // Content. + if(size_t size = static_cast(archive_entry_size(e))) + { + return this->AddData(file, size); + } + return true; +} + +//---------------------------------------------------------------------------- +bool cmArchiveWrite::AddData(const char* file, size_t size) +{ + std::ifstream fin(file, std::ios::in | cmsys_ios_binary); + if(!fin) + { + this->Error = "Error opening \""; + this->Error += file; + this->Error += "\": "; + this->Error += cmSystemTools::GetLastSystemError(); + return false; + } + + char buffer[16384]; + size_t nleft = size; + while(nleft > 0) + { + typedef cmsys_ios::streamsize ssize_type; + size_t const nnext = nleft > sizeof(buffer)? sizeof(buffer) : nleft; + ssize_type const nnext_s = static_cast(nnext); + fin.read(buffer, nnext_s); + // Some stream libraries (older HPUX) return failure at end of + // file on the last read even if some data were read. Check + // gcount instead of trusting the stream error status. + if(static_cast(fin.gcount()) != nnext) + { + break; + } + if(archive_write_data(this->Archive, buffer, nnext) != nnext_s) + { + this->Error = "archive_write_data: "; + this->Error += archive_error_string(this->Archive); + return false; + } + nleft -= nnext; + } + if(nleft > 0) + { + this->Error = "Error reading \""; + this->Error += file; + this->Error += "\": "; + this->Error += cmSystemTools::GetLastSystemError(); + return false; + } + return true; +} diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h new file mode 100644 index 000000000..3e3b2f0ca --- /dev/null +++ b/Source/cmArchiveWrite.h @@ -0,0 +1,94 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2010 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 cmArchiveWrite_h +#define cmArchiveWrite_h + +#include "cmStandardIncludes.h" + +#if !defined(CMAKE_BUILD_WITH_CMAKE) +# error "cmArchiveWrite not allowed during bootstrap build!" +#endif + +/** \class cmArchiveWrite + * \brief Wrapper around libarchive for writing. + * + */ +class cmArchiveWrite +{ + typedef void (cmArchiveWrite::* safe_bool)(); + void safe_bool_true() {} +public: + /** Compression type. */ + enum Compress + { + CompressNone, + CompressCompress, + CompressGZip, + CompressBZip2, + CompressLZMA, + CompressXZ + }; + + /** Archive Type */ + enum Type + { + TypeTAR, + TypeZIP + }; + + /** Construct with output stream to which to write archive. */ + cmArchiveWrite(std::ostream& os, Compress c = CompressNone, Type = TypeTAR); + ~cmArchiveWrite(); + + /** + * Add a path (file or directory) to the archive. Directories are + * added recursively. The "path" must be readable on disk, either + * full path or relative to current working directory. The "skip" + * value indicates how many leading bytes from the input path to + * skip. The remaining part of the input path is appended to the + * "prefix" value to construct the final name in the archive. + */ + bool Add(std::string path, size_t skip = 0, const char* prefix = 0); + + /** Returns true if there has been no error. */ + operator safe_bool() const + { return this->Okay()? &cmArchiveWrite::safe_bool_true : 0; } + + /** Returns true if there has been an error. */ + bool operator!() const { return !this->Okay(); } + + /** Return the error string; empty if none. */ + std::string GetError() const { return this->Error; } + + // TODO: More general callback instead of hard-coding calls to + // std::cout. + void SetVerbose(bool v) { this->Verbose = v; } + +private: + bool Okay() const { return this->Error.empty(); } + bool AddPath(const char* path, size_t skip, const char* prefix); + bool AddFile(const char* file, size_t skip, const char* prefix); + bool AddData(const char* file, size_t size); + + struct Callback; + friend struct Callback; + + class Entry; + + std::ostream& Stream; + struct archive* Archive; + struct archive* Disk; + bool Verbose; + std::string Error; +}; + +#endif diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index bd69d6c5e..2e05883e9 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -304,6 +304,7 @@ cmCTest::cmCTest() this->ShowOnly = false; this->RunConfigurationScript = false; this->UseHTTP10 = false; + this->PrintLabels = false; this->CompressTestOutput = true; this->ComputedCompressOutput = false; this->TestModel = cmCTest::EXPERIMENTAL; @@ -410,10 +411,14 @@ std::string cmCTest::GetCDashVersion() //First query the server. If that fails, fall back to the local setting std::string response; std::string url = "http://"; - url += this->GetCTestConfiguration("DropSite") + "/CDash/api/getversion.php"; - + url += this->GetCTestConfiguration("DropSite"); + + 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); - + return res ? this->GetCTestConfiguration("CDashVersion") : response; #else return this->GetCTestConfiguration("CDashVersion"); @@ -485,10 +490,6 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) return 0; } - // call this so that the information is cached up front - // and not the first time EndTest is called. - this->ShouldCompressTestOutput(); - if ( this->ProduceXML ) { // Verify "Testing" directory exists: @@ -1169,7 +1170,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output, if ( tick % tick_line_len == 0 && tick > 0 ) { cmCTestLog(this, HANDLER_OUTPUT, " Size: " - << int((output->size() / 1024.0) + 1) << "K" << std::endl + << int((double(output->size()) / 1024.0) + 1) << "K" << std::endl << " " << std::flush); } } @@ -1181,7 +1182,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output, } } cmCTestLog(this, OUTPUT, " Size of output: " - << int(output->size() / 1024.0) << "K" << std::endl); + << int(double(output->size()) / 1024.0) << "K" << std::endl); cmsysProcess_WaitForExit(cp, 0); @@ -1873,6 +1874,11 @@ void cmCTest::HandleCommandLineArguments(size_t &i, this->CompressTestOutput = false; } + if(this->CheckArgument(arg, "--print-labels")) + { + this->PrintLabels = true; + } + if(this->CheckArgument(arg, "--http1.0")) { this->UseHTTP10 = true; @@ -2121,7 +2127,7 @@ int cmCTest::Run(std::vector &args, std::string* output) i++; std::string targ = args[i]; // AddTestsForDashboard parses the dashborad type and converts it - // into the seperate stages + // into the separate stages if (!this->AddTestsForDashboardType(targ)) { performSomeTest = false; diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 3d7d1179b..e54a205c3 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -210,6 +210,8 @@ public: bool ShouldUseHTTP10() { return this->UseHTTP10; } + bool ShouldPrintLabels() { return this->PrintLabels; } + bool ShouldCompressTestOutput(); std::string GetCDashVersion(); @@ -413,6 +415,7 @@ private: bool ProduceXML; bool LabelSummary; bool UseHTTP10; + bool PrintLabels; bool Failover; bool BatchJobs; diff --git a/Source/cmComputeComponentGraph.cxx b/Source/cmComputeComponentGraph.cxx index 3f2a361dc..5bec6a1ec 100644 --- a/Source/cmComputeComponentGraph.cxx +++ b/Source/cmComputeComponentGraph.cxx @@ -71,8 +71,8 @@ void cmComputeComponentGraph::TarjanVisit(int i) this->TarjanStack.push(i); // Follow outgoing edges. - NodeList const& nl = this->InputGraph[i]; - for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) + EdgeList const& nl = this->InputGraph[i]; + for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { int j = *ni; @@ -142,14 +142,17 @@ void cmComputeComponentGraph::TransferEdges() for(int i=0; i < n; ++i) { int i_component = this->TarjanComponents[i]; - NodeList const& nl = this->InputGraph[i]; - for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) + EdgeList const& nl = this->InputGraph[i]; + for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { int j = *ni; int j_component = this->TarjanComponents[j]; if(i_component != j_component) { - this->ComponentGraph[i_component].push_back(j_component); + // We do not attempt to combine duplicate edges, but instead + // store the inter-component edges with suitable multiplicity. + this->ComponentGraph[i_component].push_back( + cmGraphEdge(j_component, ni->IsStrong())); } } } diff --git a/Source/cmComputeComponentGraph.h b/Source/cmComputeComponentGraph.h index 855a141f4..a2ce946c1 100644 --- a/Source/cmComputeComponentGraph.h +++ b/Source/cmComputeComponentGraph.h @@ -33,6 +33,7 @@ class cmComputeComponentGraph public: // Represent the graph with an adjacency list. typedef cmGraphNodeList NodeList; + typedef cmGraphEdgeList EdgeList; typedef cmGraphAdjacencyList Graph; cmComputeComponentGraph(Graph const& input); @@ -41,7 +42,7 @@ public: /** Get the adjacency list of the component graph. */ Graph const& GetComponentGraph() const { return this->ComponentGraph; } - NodeList const& GetComponentGraphEdges(int c) const + EdgeList const& GetComponentGraphEdges(int c) const { return this->ComponentGraph[c]; } /** Get map from component index to original node indices. */ diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index 24410ec3a..342c217d8 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -285,7 +285,7 @@ cmComputeLinkDepends::AllocateLinkEntry(std::string const& item) lei = this->LinkEntryIndex.insert(index_entry).first; this->EntryList.push_back(LinkEntry()); this->InferredDependSets.push_back(0); - this->EntryConstraintGraph.push_back(NodeList()); + this->EntryConstraintGraph.push_back(EdgeList()); return lei; } @@ -669,7 +669,7 @@ void cmComputeLinkDepends::CleanConstraintGraph() cmsys_stl::sort(i->begin(), i->end()); // Make the edge list unique. - NodeList::iterator last = cmsys_stl::unique(i->begin(), i->end()); + EdgeList::iterator last = cmsys_stl::unique(i->begin(), i->end()); i->erase(last, i->end()); } } @@ -681,9 +681,9 @@ void cmComputeLinkDepends::DisplayConstraintGraph() cmOStringStream e; for(unsigned int i=0; i < this->EntryConstraintGraph.size(); ++i) { - NodeList const& nl = this->EntryConstraintGraph[i]; + EdgeList const& nl = this->EntryConstraintGraph[i]; e << "item " << i << " is [" << this->EntryList[i].Item << "]\n"; - for(NodeList::const_iterator j = nl.begin(); j != nl.end(); ++j) + for(EdgeList::const_iterator j = nl.begin(); j != nl.end(); ++j) { e << " item " << *j << " must follow it\n"; } @@ -758,10 +758,11 @@ cmComputeLinkDepends::DisplayComponents() fprintf(stderr, " item %d [%s]\n", i, this->EntryList[i].Item.c_str()); } - NodeList const& ol = this->CCG->GetComponentGraphEdges(c); - for(NodeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi) + EdgeList const& ol = this->CCG->GetComponentGraphEdges(c); + for(EdgeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi) { - fprintf(stderr, " followed by Component (%d)\n", *oi); + int i = *oi; + fprintf(stderr, " followed by Component (%d)\n", i); } fprintf(stderr, " topo order index %d\n", this->ComponentOrder[c]); @@ -784,8 +785,8 @@ void cmComputeLinkDepends::VisitComponent(unsigned int c) // Visit the neighbors of the component first. // Run in reverse order so the topological order will preserve the // original order where there are no constraints. - NodeList const& nl = this->CCG->GetComponentGraphEdges(c); - for(NodeList::const_reverse_iterator ni = nl.rbegin(); + EdgeList const& nl = this->CCG->GetComponentGraphEdges(c); + for(EdgeList::const_reverse_iterator ni = nl.rbegin(); ni != nl.rend(); ++ni) { this->VisitComponent(*ni); @@ -856,8 +857,8 @@ void cmComputeLinkDepends::VisitEntry(int index) // are now pending. if(completed) { - NodeList const& ol = this->CCG->GetComponentGraphEdges(component); - for(NodeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi) + EdgeList const& ol = this->CCG->GetComponentGraphEdges(component); + for(EdgeList::const_iterator oi = ol.begin(); oi != ol.end(); ++oi) { // This entire component is now pending no matter whether it has // been partially seen already. diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index a08afb69c..e196e00ca 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -117,6 +117,7 @@ private: // Ordering constraint graph adjacency list. typedef cmGraphNodeList NodeList; + typedef cmGraphEdgeList EdgeList; typedef cmGraphAdjacencyList Graph; Graph EntryConstraintGraph; void CleanConstraintGraph(); diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 94b8527f0..313c680e5 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -129,7 +129,10 @@ bool cmComputeTargetDepends::Compute() } // Compute the final dependency graph. - this->ComputeFinalDepends(ccg); + if(!this->ComputeFinalDepends(ccg)) + { + return false; + } if(this->DebugMode) { this->DisplayGraph(this->FinalGraph, "final"); @@ -150,8 +153,8 @@ cmComputeTargetDepends::GetTargetDirectDepends(cmTarget* t, int i = tii->second; // Get its final dependencies. - NodeList const& nl = this->FinalGraph[i]; - for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) + EdgeList const& nl = this->FinalGraph[i]; + for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { deps.insert(this->Targets[*ni]); } @@ -195,15 +198,13 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) // Get the depender. cmTarget* depender = this->Targets[depender_index]; - // Keep track of dependencies already listed. - std::set emitted; - - // A target should not depend on itself. - emitted.insert(depender->GetName()); - // Loop over all targets linked directly. + { cmTarget::LinkLibraryVectorType const& tlibs = depender->GetOriginalLinkLibraries(); + std::set emitted; + // A target should not depend on itself. + emitted.insert(depender->GetName()); for(cmTarget::LinkLibraryVectorType::const_iterator lib = tlibs.begin(); lib != tlibs.end(); ++lib) { @@ -213,9 +214,14 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) this->AddTargetDepend(depender_index, lib->first.c_str(), true); } } + } // Loop over all utility dependencies. + { std::set const& tutils = depender->GetUtilities(); + std::set emitted; + // A target should not depend on itself. + emitted.insert(depender->GetName()); for(std::set::const_iterator util = tutils.begin(); util != tutils.end(); ++util) { @@ -225,6 +231,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) this->AddTargetDepend(depender_index, util->c_str(), false); } } + } } //---------------------------------------------------------------------------- @@ -272,7 +279,8 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, int dependee_index = tii->second; // Add this entry to the dependency graph. - this->InitialGraph[depender_index].push_back(dependee_index); + this->InitialGraph[depender_index].push_back( + cmGraphEdge(dependee_index, !linking)); } //---------------------------------------------------------------------------- @@ -283,16 +291,16 @@ cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name) int n = static_cast(graph.size()); for(int depender_index = 0; depender_index < n; ++depender_index) { - NodeList const& nl = graph[depender_index]; + EdgeList const& nl = graph[depender_index]; cmTarget* depender = this->Targets[depender_index]; fprintf(stderr, "target %d is [%s]\n", depender_index, depender->GetName()); - for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) + for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { int dependee_index = *ni; cmTarget* dependee = this->Targets[dependee_index]; - fprintf(stderr, " depends on target %d [%s]\n", dependee_index, - dependee->GetName()); + fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index, + dependee->GetName(), ni->IsStrong()? "strong" : "weak"); } } fprintf(stderr, "\n"); @@ -363,7 +371,8 @@ cmComputeTargetDepends //---------------------------------------------------------------------------- void cmComputeTargetDepends -::ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c) +::ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c, + bool strong) { // Construct the error message. cmOStringStream e; @@ -383,18 +392,27 @@ cmComputeTargetDepends << cmTarget::TargetTypeNames[depender->GetType()] << "\n"; // List its dependencies that are inside the component. - NodeList const& nl = this->InitialGraph[i]; - for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) + EdgeList const& nl = this->InitialGraph[i]; + for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { int j = *ni; if(cmap[j] == c) { cmTarget* dependee = this->Targets[j]; - e << " depends on \"" << dependee->GetName() << "\"\n"; + e << " depends on \"" << dependee->GetName() << "\"" + << " (" << (ni->IsStrong()? "strong" : "weak") << ")\n"; } } } - if(this->NoCycles) + if(strong) + { + // Custom command executable dependencies cannot occur within a + // component of static libraries. The cycle must appear in calls + // to add_dependencies. + e << "The component contains at least one cycle consisting of strong " + << "dependencies (created by add_dependencies) that cannot be broken."; + } + else if(this->NoCycles) { e << "The GLOBAL_DEPENDS_NO_CYCLES global property is enabled, so " << "cyclic dependencies are not allowed even among static libraries."; @@ -408,7 +426,49 @@ cmComputeTargetDepends } //---------------------------------------------------------------------------- -void +bool +cmComputeTargetDepends +::IntraComponent(std::vector const& cmap, int c, int i, int* head, + std::set& emitted, std::set& visited) +{ + if(!visited.insert(i).second) + { + // Cycle in utility depends! + return false; + } + if(emitted.insert(i).second) + { + // Honor strong intra-component edges in the final order. + EdgeList const& el = this->InitialGraph[i]; + for(EdgeList::const_iterator ei = el.begin(); ei != el.end(); ++ei) + { + int j = *ei; + if(cmap[j] == c && ei->IsStrong()) + { + this->FinalGraph[i].push_back(j); + if(!this->IntraComponent(cmap, c, j, head, emitted, visited)) + { + return false; + } + } + } + + // Prepend to a linear linked-list of intra-component edges. + if(*head >= 0) + { + this->FinalGraph[i].push_back(*head); + } + else + { + this->ComponentTail[c] = i; + } + *head = i; + } + return true; +} + +//---------------------------------------------------------------------------- +bool cmComputeTargetDepends ::ComputeFinalDepends(cmComputeComponentGraph const& ccg) { @@ -420,34 +480,43 @@ cmComputeTargetDepends this->FinalGraph.resize(0); this->FinalGraph.resize(this->InitialGraph.size()); + // Choose intra-component edges to linearize dependencies. + std::vector const& cmap = ccg.GetComponentMap(); + this->ComponentHead.resize(components.size()); + this->ComponentTail.resize(components.size()); + int nc = static_cast(components.size()); + for(int c=0; c < nc; ++c) + { + int head = -1; + std::set emitted; + NodeList const& nl = components[c]; + for(NodeList::const_reverse_iterator ni = nl.rbegin(); + ni != nl.rend(); ++ni) + { + std::set visited; + if(!this->IntraComponent(cmap, c, *ni, &head, emitted, visited)) + { + // Cycle in add_dependencies within component! + this->ComplainAboutBadComponent(ccg, c, true); + return false; + } + } + this->ComponentHead[c] = head; + } + // Convert inter-component edges to connect component tails to heads. int n = static_cast(cgraph.size()); for(int depender_component=0; depender_component < n; ++depender_component) { - int depender_component_tail = components[depender_component].back(); - NodeList const& nl = cgraph[depender_component]; - for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) + int depender_component_tail = this->ComponentTail[depender_component]; + EdgeList const& nl = cgraph[depender_component]; + for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni) { int dependee_component = *ni; - int dependee_component_head = components[dependee_component].front(); + int dependee_component_head = this->ComponentHead[dependee_component]; this->FinalGraph[depender_component_tail] .push_back(dependee_component_head); } } - - // Compute intra-component edges. - int nc = static_cast(components.size()); - for(int c=0; c < nc; ++c) - { - // Within the component each target depends on that following it. - NodeList const& nl = components[c]; - NodeList::const_iterator ni = nl.begin(); - int last_i = *ni; - for(++ni; ni != nl.end(); ++ni) - { - int i = *ni; - this->FinalGraph[last_i].push_back(i); - last_i = i; - } - } + return true; } diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index 68e3e47cb..240de7670 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -45,7 +45,7 @@ private: void CollectTargetDepends(int depender_index); void AddTargetDepend(int depender_index, const char* dependee_name, bool linking); - void ComputeFinalDepends(cmComputeComponentGraph const& ccg); + bool ComputeFinalDepends(cmComputeComponentGraph const& ccg); cmGlobalGenerator* GlobalGenerator; bool DebugMode; @@ -59,6 +59,7 @@ private: // top-level index corresponds to a depender whose dependencies are // listed. typedef cmGraphNodeList NodeList; + typedef cmGraphEdgeList EdgeList; typedef cmGraphAdjacencyList Graph; Graph InitialGraph; Graph FinalGraph; @@ -67,7 +68,13 @@ private: // Deal with connected components. void DisplayComponents(cmComputeComponentGraph const& ccg); bool CheckComponents(cmComputeComponentGraph const& ccg); - void ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c); + void ComplainAboutBadComponent(cmComputeComponentGraph const& ccg, int c, + bool strong = false); + + std::vector ComponentHead; + std::vector ComponentTail; + bool IntraComponent(std::vector const& cmap, int c, int i, int* head, + std::set& emitted, std::set& visited); }; #endif diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index dab0c0d1d..b8a0c95b1 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -175,6 +175,23 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv) { fprintf(fout, "SET(CMAKE_MODULE_PATH %s)\n", def); } + + const char* rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE"; + std::string rulesOverrideLang = + rulesOverrideBase + (lang ? std::string("_") + lang : std::string("")); + if(const char* rulesOverridePath = + this->Makefile->GetDefinition(rulesOverrideLang.c_str())) + { + fprintf(fout, "SET(%s \"%s\")\n", + rulesOverrideLang.c_str(), rulesOverridePath); + } + else if(const char* rulesOverridePath2 = + this->Makefile->GetDefinition(rulesOverrideBase)) + { + fprintf(fout, "SET(%s \"%s\")\n", + rulesOverrideBase, rulesOverridePath2); + } + if(lang) { fprintf(fout, "PROJECT(CMAKE_TRY_COMPILE %s)\n", lang); diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 2ed959f42..a877680de 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -2,7 +2,7 @@ #include "cmake.h" void cmDocumentVariables::DefineVariables(cmake* cm) -{ +{ // Subsection: variables defined by cmake, that give // information about the project, and cmake cm->DefineProperty @@ -18,21 +18,21 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "This is the full path to the CMake executable cmake which is " "useful from custom commands that want to use the cmake -E " "option for portable system commands. " - "(e.g. /usr/local/bin/cmake", false, + "(e.g. /usr/local/bin/cmake", false, "Variables that Provide Information"); cm->DefineProperty ("CMAKE_BINARY_DIR", cmProperty::VARIABLE, "The path to the top level of the build tree.", "This is the full path to the top level of the current CMake " "build tree. For an in-source build, this would be the same " - "as CMAKE_SOURCE_DIR. ", false, + "as CMAKE_SOURCE_DIR. ", false, "Variables that Provide Information"); cm->DefineProperty ("CMAKE_SOURCE_DIR", cmProperty::VARIABLE, "The path to the top level of the source tree.", "This is the full path to the top level of the current CMake " "source tree. For an in-source build, this would be the same " - "as CMAKE_BINARY_DIR. ", false, + "as CMAKE_BINARY_DIR. ", false, "Variables that Provide Information"); cm->DefineProperty ("CMAKE_CURRENT_BINARY_DIR", cmProperty::VARIABLE, @@ -42,13 +42,13 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "add_subdirectory will create a binary directory in the build " "tree, and as it is being processed this variable will be set. " "For in-source builds this is the current source directory " - "being processed.", false, + "being processed.", false, "Variables that Provide Information"); cm->DefineProperty ("CMAKE_CURRENT_SOURCE_DIR", cmProperty::VARIABLE, "The path to the source directory currently being processed.", "This the full path to the source directory that is currently " - "being processed by cmake. ", false, + "being processed by cmake. ", false, "Variables that Provide Information"); cm->DefineProperty @@ -74,8 +74,28 @@ void cmDocumentVariables::DefineVariables(cmake* cm) ("CMAKE_CURRENT_LIST_LINE", cmProperty::VARIABLE, "The line number of the current file being processed.", "This is the line number of the file currently being" - " processed by cmake.", false, + " processed by cmake.", false, "Variables that Provide Information"); + + cm->DefineProperty + ("CMAKE_CURRENT_LIST_DIR", cmProperty::VARIABLE, + "Full directory of the listfile currently being processed.", + "As CMake processes the listfiles in your project this " + "variable will always be set to the directory where the listfile which " + "is currently being processed (CMAKE_CURRENT_LIST_FILE) is located. " + "The value has dynamic scope. " + "When CMake starts processing commands in a source file " + "it sets this variable to the directory where this file is located. " + "When CMake finishes processing commands from the file it " + "restores the previous value. " + "Therefore the value of the variable inside a macro or " + "function is the directory of the file invoking the bottom-most entry on " + "the call stack, not the directory of the file containing the macro or " + "function definition." + "\n" + "See also CMAKE_CURRENT_LIST_FILE.",false, + "Variables that Provide Information"); + cm->DefineProperty ("CMAKE_BUILD_TOOL", cmProperty::VARIABLE, "Tool used for the actual build process.", @@ -87,7 +107,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "and for Visual Studio 7 it set to devenv. For " "Nmake Makefiles the value is nmake. This can be " "useful for adding special flags and commands based" - " on the final build environment. ", false, + " on the final build environment. ", false, "Variables that Provide Information"); cm->DefineProperty ("CMAKE_CROSSCOMPILING", cmProperty::VARIABLE, @@ -101,7 +121,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "The directory with the CMakeCache.txt file.", "This is the full path to the directory that has the " "CMakeCache.txt file in it. This is the same as " - "CMAKE_BINARY_DIR.", false, + "CMAKE_BINARY_DIR.", false, "Variables that Provide Information"); cm->DefineProperty ("CMAKE_CACHE_MAJOR_VERSION", cmProperty::VARIABLE, @@ -109,7 +129,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "This is stores the major version of CMake used to " "write a CMake cache file. It is only different when " "a different version of CMake is run on a previously " - "created cache file.", false, + "created cache file.", false, "Variables that Provide Information"); cm->DefineProperty ("CMAKE_CACHE_MINOR_VERSION", cmProperty::VARIABLE, @@ -117,18 +137,18 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "This is stores the minor version of CMake used to " "write a CMake cache file. It is only different when " "a different version of CMake is run on a previously " - "created cache file.", false, + "created cache file.", false, "Variables that Provide Information"); - + cm->DefineProperty ("CMAKE_CACHE_PATCH_VERSION", cmProperty::VARIABLE, "Patch version of CMake used to create the CMakeCache.txt file", "This is stores the patch version of CMake used to " "write a CMake cache file. It is only different when " "a different version of CMake is run on a previously " - "created cache file.", false, + "created cache file.", false, "Variables that Provide Information"); - + cm->DefineProperty ("CMAKE_CFG_INTDIR", cmProperty::VARIABLE, "Build-time reference to per-configuration output subdirectory.", @@ -168,7 +188,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "is passed as the value of preprocessor symbol \"CMAKE_INTDIR\" to " "the compilation of all source files.",false, "Variables that Provide Information"); - + cm->DefineProperty ("CMAKE_CTEST_COMMAND", cmProperty::VARIABLE, "Full path to ctest command installed with cmake.", @@ -442,7 +462,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables that Provide Information"); - // Variables defined by cmake, that change the behavior + // Variables defined by cmake, that change the behavior // of cmake cm->DefineProperty ("CMAKE_FIND_LIBRARY_PREFIXES", cmProperty::VARIABLE, @@ -587,7 +607,39 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "directories for the current system. It is NOT intended " "to be modified by the project, use CMAKE_PREFIX_PATH for this. See also " "CMAKE_SYSTEM_INCLUDE_PATH, CMAKE_SYSTEM_LIBRARY_PATH, " - "CMAKE_SYSTEM_PROGRAM_PATH.", false, + "CMAKE_SYSTEM_PROGRAM_PATH, and CMAKE_SYSTEM_IGNORE_PATH.", false, + "Variables That Change Behavior"); + + cm->DefineProperty + ("CMAKE_SYSTEM_IGNORE_PATH", cmProperty::VARIABLE, + "Path to be ignored by FIND_XXX() commands.", + "Specifies directories to be ignored by searches in FIND_XXX() commands " + "This is useful in cross-compiled environments where some system " + "directories contain incompatible but possibly linkable libraries. For " + "example, on cross-compiled cluster environments, this allows a user to " + "ignore directories containing libraries meant for the front-end " + "machine that modules like FindX11 (and others) would normally search. " + "By default this contains a list of directories containing incompatible " + "binaries for the host system. " + "See also CMAKE_SYSTEM_PREFIX_PATH, CMAKE_SYSTEM_LIBRARY_PATH, " + "CMAKE_SYSTEM_INCLUDE_PATH, and CMAKE_SYSTEM_PROGRAM_PATH.", false, + "Variables That Change Behavior"); + + cm->DefineProperty + ("CMAKE_IGNORE_PATH", cmProperty::VARIABLE, + "Path to be ignored by FIND_XXX() commands.", + "Specifies directories to be ignored by searches in FIND_XXX() commands " + "This is useful in cross-compiled environments where some system " + "directories contain incompatible but possibly linkable libraries. For " + "example, on cross-compiled cluster environments, this allows a user to " + "ignore directories containing libraries meant for the front-end " + "machine that modules like FindX11 (and others) would normally search. " + "By default this is empty; it is intended to be set by the project. " + "Note that CMAKE_IGNORE_PATH takes a list of directory names, NOT a " + "list of prefixes. If you want to ignore paths under prefixes (bin, " + "include, lib, etc.), you'll need to specify them explicitly. " + "See also CMAKE_PREFIX_PATH, CMAKE_LIBRARY_PATH, CMAKE_INCLUDE_PATH, " + "CMAKE_PROGRAM_PATH.", false, "Variables That Change Behavior"); cm->DefineProperty @@ -633,7 +685,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "to override any variables that need to be changed " "for some special project. ",false, "Variables That Change Behavior"); - + cm->DefineProperty ("BUILD_SHARED_LIBS", cmProperty::VARIABLE, "Global flag to cause add_library to create shared libraries if on.", @@ -644,14 +696,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "they want to build the project using shared or static " "libraries.",false, "Variables That Change Behavior"); - + cm->DefineProperty ("CMAKE_NOT_USING_CONFIG_FLAGS", cmProperty::VARIABLE, "Skip _BUILD_TYPE flags if true.", "This is an internal flag used by the generators in " "CMake to tell CMake to skip the _BUILD_TYPE flags.",false, "Variables That Change Behavior"); - + cm->DefineProperty ("CMAKE_MFC_FLAG", cmProperty::VARIABLE, "Tell cmake to use MFC for an executable or dll.", @@ -742,19 +794,19 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "True if running on Mac OSX.", "Set to true on Mac OSX.",false, "Variables That Describe the System"); - + cm->DefineProperty ("BORLAND", cmProperty::VARIABLE, "True of the borland compiler is being used.", "This is set to true if the Borland compiler is being used.",false, "Variables That Describe the System"); - + cm->DefineProperty ("CYGWIN", cmProperty::VARIABLE, "True for cygwin.", "Set to true when using CYGWIN.",false, "Variables That Describe the System"); - + cm->DefineProperty ("MSVC", cmProperty::VARIABLE, "True when using Microsoft Visual C", @@ -806,7 +858,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Set to true when the target system is UNIX or UNIX like " "(i.e. APPLE and CYGWIN).",false, "Variables That Describe the System"); - + cm->DefineProperty ("WIN32", cmProperty::VARIABLE, "True on windows systems, including win64.", @@ -833,7 +885,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Set to true when the host system is UNIX or UNIX like " "(i.e. APPLE and CYGWIN).",false, "Variables That Describe the System"); - + cm->DefineProperty ("CMAKE_HOST_WIN32", cmProperty::VARIABLE, "True on windows systems, including win64.", @@ -858,7 +910,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "The value must be an integer no less than 128.",false, "Variables That Describe the System"); - // Variables that affect the building of object files and + // Variables that affect the building of object files and // targets. // cm->DefineProperty @@ -1074,7 +1126,7 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "This is the command that will be used as the compiler. " "Once set, you can not change this variable.",false, "Variables for Languages"); - + cm->DefineProperty ("CMAKE__COMPILER_ID", cmProperty::VARIABLE, "An internal variable subject to change.", @@ -1118,54 +1170,54 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "If the selected compiler is the GNU " "compiler then this is TRUE, if not it is FALSE.",false, "Variables for Languages"); - + cm->DefineProperty ("CMAKE__FLAGS_DEBUG", cmProperty::VARIABLE, "Flags for Debug build type or configuration.", " flags used when CMAKE_BUILD_TYPE is Debug.",false, "Variables for Languages"); - + cm->DefineProperty ("CMAKE__FLAGS_MINSIZEREL", cmProperty::VARIABLE, "Flags for MinSizeRel build type or configuration.", " flags used when CMAKE_BUILD_TYPE is MinSizeRel." "Short for minimum size release.",false, "Variables for Languages"); - + cm->DefineProperty ("CMAKE__FLAGS_RELEASE", cmProperty::VARIABLE, "Flags for Release build type or configuration.", " flags used when CMAKE_BUILD_TYPE is Release",false, "Variables for Languages"); - + cm->DefineProperty ("CMAKE__FLAGS_RELWITHDEBINFO", cmProperty::VARIABLE, "Flags for RelWithDebInfo type or configuration.", " flags used when CMAKE_BUILD_TYPE is RelWithDebInfo. " "Short for Release With Debug Information.",false, "Variables for Languages"); - + cm->DefineProperty ("CMAKE__COMPILE_OBJECT", cmProperty::VARIABLE, "Rule variable to compile a single object file.", "This is a rule variable that tells CMake how to " "compile a single object file for for the language .",false, "Variables for Languages"); - + cm->DefineProperty ("CMAKE__CREATE_SHARED_LIBRARY", cmProperty::VARIABLE, "Rule variable to create a shared library.", "This is a rule variable that tells CMake how to " "create a shared library for the language .",false, "Variables for Languages"); - + cm->DefineProperty ("CMAKE__CREATE_SHARED_MODULE", cmProperty::VARIABLE, "Rule variable to create a shared module.", "This is a rule variable that tells CMake how to " "create a shared library for the language .",false, "Variables for Languages"); - + cm->DefineProperty ("CMAKE__CREATE_STATIC_LIBRARY", cmProperty::VARIABLE, "Rule variable to create a static library.", @@ -1257,20 +1309,20 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "See also the CMAKE__LINKER_PREFERENCE_PROPAGATES variable.", false, "Variables for Languages"); - + cm->DefineProperty ("CMAKE__LINK_EXECUTABLE ", cmProperty::VARIABLE, "Rule variable to link and executable.", "Rule variable to link and executable for the given language.",false, "Variables for Languages"); - + cm->DefineProperty ("CMAKE__OUTPUT_EXTENSION", cmProperty::VARIABLE, "Extension for the output of a compile for a single file.", "This is the extension for an object file for " "the given . For example .obj for C on Windows.",false, "Variables for Languages"); - + cm->DefineProperty ("CMAKE__SOURCE_FILE_EXTENSIONS", cmProperty::VARIABLE, "Extensions of source files for the given language.", @@ -1285,16 +1337,16 @@ void cmDocumentVariables::DefineVariables(cmake* cm) false,"Variables for Languages"); // variables that are used by cmake but not to be documented - cm->DefineProperty("CMAKE_MATCH_0", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_1", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_2", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_3", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_4", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_5", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_6", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_7", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_8", cmProperty::VARIABLE,0,0); - cm->DefineProperty("CMAKE_MATCH_9", cmProperty::VARIABLE,0,0); + cm->DefineProperty("CMAKE_MATCH_0", cmProperty::VARIABLE,0,0); + cm->DefineProperty("CMAKE_MATCH_1", cmProperty::VARIABLE,0,0); + cm->DefineProperty("CMAKE_MATCH_2", cmProperty::VARIABLE,0,0); + cm->DefineProperty("CMAKE_MATCH_3", cmProperty::VARIABLE,0,0); + cm->DefineProperty("CMAKE_MATCH_4", cmProperty::VARIABLE,0,0); + cm->DefineProperty("CMAKE_MATCH_5", cmProperty::VARIABLE,0,0); + cm->DefineProperty("CMAKE_MATCH_6", cmProperty::VARIABLE,0,0); + cm->DefineProperty("CMAKE_MATCH_7", cmProperty::VARIABLE,0,0); + cm->DefineProperty("CMAKE_MATCH_8", cmProperty::VARIABLE,0,0); + cm->DefineProperty("CMAKE_MATCH_9", cmProperty::VARIABLE,0,0); cm->DefineProperty("CMAKE__COMPILER_ARG1", cmProperty::VARIABLE,0,0); diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 147f6accb..1158fc0c0 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -576,7 +576,7 @@ unsigned int cmELFInternalImpl::GetDynamicEntryCount() return i; } } - return this->DynamicSectionEntries.size(); + return static_cast(this->DynamicSectionEntries.size()); } //---------------------------------------------------------------------------- @@ -687,7 +687,8 @@ cmELFInternalImpl::GetDynamicSectionString(int tag) // The value has been read successfully. Report it. se.Position = static_cast(strtab.sh_offset + first); se.Size = last - first; - se.IndexInSection = static_cast(di - this->DynamicSectionEntries.begin()); + se.IndexInSection = + static_cast(di - this->DynamicSectionEntries.begin()); return &se; } } diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 48c5c6e6a..cb614d4f3 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -152,11 +152,10 @@ bool cmExportCommand ebfg.SetCommand(this); // Compute the set of configurations exported. - if(const char* types = - this->Makefile->GetDefinition("CMAKE_CONFIGURATION_TYPES")) + std::vector configurationTypes; + this->Makefile->GetConfigurations(configurationTypes); + if(!configurationTypes.empty()) { - std::vector configurationTypes; - cmSystemTools::ExpandListArgument(types, configurationTypes); for(std::vector::const_iterator ci = configurationTypes.begin(); ci != configurationTypes.end(); ++ci) @@ -164,11 +163,6 @@ bool cmExportCommand ebfg.AddConfiguration(ci->c_str()); } } - else if(const char* config = - this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) - { - ebfg.AddConfiguration(config); - } else { ebfg.AddConfiguration(""); diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 4cb2b4860..e6d7a6d1f 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -289,14 +289,10 @@ void cmExtraCodeBlocksGenerator std::string fileName = *(splitted.end()-1); splitted.erase(splitted.end() - 1, splitted.end()); - // We don't want paths with ".." in them - // reasons are that we don't want files outside the project - // TODO: the path should be normalized first though // We don't want paths with CMakeFiles in them // or do we? // In speedcrunch those where purely internal if (splitted.size() >= 1 - && relative.find("..") == std::string::npos && relative.find("CMakeFiles") == std::string::npos) { tree.InsertPath(splitted, 1, fileName); diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 133c1a196..8ebd41f92 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2571,8 +2571,7 @@ cmFileCommand::HandleDownloadCommand(std::vector std::vector::const_iterator i = args.begin(); if(args.size() < 3) { - this->SetError("FILE(DOWNLOAD url file) must be called with " - "at least three arguments."); + this->SetError("DOWNLOAD must be called with at least three arguments."); return false; } ++i; // Get rid of subcommand @@ -2598,8 +2597,7 @@ cmFileCommand::HandleDownloadCommand(std::vector } else { - this->SetError("FILE(DOWNLOAD url file TIMEOUT time) missing " - "time for TIMEOUT."); + this->SetError("DOWNLOAD missing time for TIMEOUT."); return false; } } @@ -2608,8 +2606,7 @@ cmFileCommand::HandleDownloadCommand(std::vector ++i; if( i == args.end()) { - this->SetError("FILE(DOWNLOAD url file LOG VAR) missing " - "VAR for LOG."); + this->SetError("DOWNLOAD missing VAR for LOG."); return false; } verboseLog = *i; @@ -2619,8 +2616,7 @@ cmFileCommand::HandleDownloadCommand(std::vector ++i; if( i == args.end()) { - this->SetError("FILE(DOWNLOAD url file STATUS VAR) missing " - "VAR for STATUS."); + this->SetError("DOWNLOAD missing VAR for STATUS."); return false; } statusVar = *i; @@ -2630,8 +2626,7 @@ cmFileCommand::HandleDownloadCommand(std::vector ++i; if( i == args.end()) { - this->SetError("FILE(DOWNLOAD url file EXPECTED_MD5 sum) missing " - "sum value for EXPECTED_MD5."); + this->SetError("DOWNLOAD missing sum value for EXPECTED_MD5."); return false; } expectedMD5sum = cmSystemTools::LowerCase(*i); @@ -2654,8 +2649,7 @@ cmFileCommand::HandleDownloadCommand(std::vector if (!cmSystemTools::ComputeFileMD5(file.c_str(), computedMD5)) { - this->SetError("FILE(DOWNLOAD ) error; cannot compute MD5 sum on " - "pre-existing file"); + this->SetError("DOWNLOAD cannot compute MD5 sum on pre-existing file"); return false; } @@ -2665,7 +2659,7 @@ cmFileCommand::HandleDownloadCommand(std::vector if (expectedMD5sum == actualMD5sum) { this->Makefile->DisplayStatus( - "FILE(DOWNLOAD ) returning early: file already exists with " + "FILE(DOWNLOAD) returning early: file already exists with " "expected MD5 sum", -1); if(statusVar.size()) @@ -2698,8 +2692,7 @@ cmFileCommand::HandleDownloadCommand(std::vector std::ofstream fout(file.c_str(), std::ios::binary); if(!fout) { - this->SetError("FILE(DOWNLOAD url file TIMEOUT time) can not open " - "file for write."); + this->SetError("DOWNLOAD cannot open file for write."); return false; } @@ -2708,8 +2701,7 @@ cmFileCommand::HandleDownloadCommand(std::vector curl = ::curl_easy_init(); if(!curl) { - this->SetError("FILE(DOWNLOAD ) error " - "initializing curl."); + this->SetError("DOWNLOAD error initializing curl."); return false; } @@ -2718,9 +2710,9 @@ cmFileCommand::HandleDownloadCommand(std::vector ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); if (res != CURLE_OK) { - std::string errstring = "FILE(DOWNLOAD ) error; cannot set url: "; - errstring += ::curl_easy_strerror(res); - this->SetError(errstring.c_str()); + std::string e = "DOWNLOAD cannot set url: "; + e += ::curl_easy_strerror(res); + this->SetError(e.c_str()); return false; } @@ -2728,10 +2720,9 @@ cmFileCommand::HandleDownloadCommand(std::vector cmFileCommandWriteMemoryCallback); if (res != CURLE_OK) { - std::string errstring = - "FILE(DOWNLOAD ) error; cannot set write function: "; - errstring += ::curl_easy_strerror(res); - this->SetError(errstring.c_str()); + std::string e = "DOWNLOAD cannot set write function: "; + e += ::curl_easy_strerror(res); + this->SetError(e.c_str()); return false; } @@ -2739,10 +2730,9 @@ cmFileCommand::HandleDownloadCommand(std::vector cmFileCommandCurlDebugCallback); if (res != CURLE_OK) { - std::string errstring = - "FILE(DOWNLOAD ) error; cannot set debug function: "; - errstring += ::curl_easy_strerror(res); - this->SetError(errstring.c_str()); + std::string e = "DOWNLOAD cannot set debug function: "; + e += ::curl_easy_strerror(res); + this->SetError(e.c_str()); return false; } @@ -2752,27 +2742,27 @@ cmFileCommand::HandleDownloadCommand(std::vector if (res != CURLE_OK) { - std::string errstring = "FILE(DOWNLOAD ) error; cannot set write data: "; - errstring += ::curl_easy_strerror(res); - this->SetError(errstring.c_str()); + std::string e = "DOWNLOAD cannot set write data: "; + e += ::curl_easy_strerror(res); + this->SetError(e.c_str()); return false; } res = ::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug); if (res != CURLE_OK) { - std::string errstring = "FILE(DOWNLOAD ) error; cannot set debug data: "; - errstring += ::curl_easy_strerror(res); - this->SetError(errstring.c_str()); + std::string e = "DOWNLOAD cannot set debug data: "; + e += ::curl_easy_strerror(res); + this->SetError(e.c_str()); return false; } res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); if (res != CURLE_OK) { - std::string errstring = "FILE(DOWNLOAD ) error; cannot set follow-redirect option: "; - errstring += ::curl_easy_strerror(res); - this->SetError(errstring.c_str()); + std::string e = "DOWNLOAD cannot set follow-redirect option: "; + e += ::curl_easy_strerror(res); + this->SetError(e.c_str()); return false; } @@ -2782,9 +2772,9 @@ cmFileCommand::HandleDownloadCommand(std::vector if (res != CURLE_OK) { - std::string errstring = "FILE(DOWNLOAD ) error; cannot set verbose: "; - errstring += ::curl_easy_strerror(res); - this->SetError(errstring.c_str()); + std::string e = "DOWNLOAD cannot set verbose: "; + e += ::curl_easy_strerror(res); + this->SetError(e.c_str()); return false; } } @@ -2795,9 +2785,9 @@ cmFileCommand::HandleDownloadCommand(std::vector if (res != CURLE_OK) { - std::string errstring = "FILE(DOWNLOAD ) error; cannot set timeout: "; - errstring += ::curl_easy_strerror(res); - this->SetError(errstring.c_str()); + std::string e = "DOWNLOAD cannot set timeout: "; + e += ::curl_easy_strerror(res); + this->SetError(e.c_str()); return false; } } @@ -2815,9 +2805,9 @@ cmFileCommand::HandleDownloadCommand(std::vector CURLOPT_NOPROGRESS, 0); if (res != CURLE_OK) { - std::string errstring = "FILE(DOWNLOAD ) error; cannot set noprogress value: "; - errstring += ::curl_easy_strerror(res); - this->SetError(errstring.c_str()); + std::string e = "DOWNLOAD cannot set noprogress value: "; + e += ::curl_easy_strerror(res); + this->SetError(e.c_str()); return false; } @@ -2825,9 +2815,9 @@ cmFileCommand::HandleDownloadCommand(std::vector CURLOPT_PROGRESSFUNCTION, cmFileCommandCurlProgressCallback); if (res != CURLE_OK) { - std::string errstring = "FILE(DOWNLOAD ) error; cannot set progress function: "; - errstring += ::curl_easy_strerror(res); - this->SetError(errstring.c_str()); + std::string e = "DOWNLOAD cannot set progress function: "; + e += ::curl_easy_strerror(res); + this->SetError(e.c_str()); return false; } @@ -2835,9 +2825,9 @@ cmFileCommand::HandleDownloadCommand(std::vector CURLOPT_PROGRESSDATA, reinterpret_cast(&helper)); if (res != CURLE_OK) { - std::string errstring = "FILE(DOWNLOAD ) error; cannot set progress data: "; - errstring += ::curl_easy_strerror(res); - this->SetError(errstring.c_str()); + std::string e = "DOWNLOAD cannot set progress data: "; + e += ::curl_easy_strerror(res); + this->SetError(e.c_str()); return false; } } @@ -2871,8 +2861,7 @@ cmFileCommand::HandleDownloadCommand(std::vector if (!cmSystemTools::ComputeFileMD5(file.c_str(), computedMD5)) { - this->SetError("FILE(DOWNLOAD ) error; cannot compute MD5 sum on " - "downloaded file"); + this->SetError("DOWNLOAD cannot compute MD5 sum on downloaded file"); return false; } @@ -2882,8 +2871,7 @@ cmFileCommand::HandleDownloadCommand(std::vector if (expectedMD5sum != actualMD5sum) { cmOStringStream oss; - oss << "FILE(DOWNLOAD ) error; expected and actual MD5 sums differ" - << std::endl + oss << "DOWNLOAD MD5 mismatch" << std::endl << " for file: [" << file << "]" << std::endl << " expected MD5 sum: [" << expectedMD5sum << "]" << std::endl << " actual MD5 sum: [" << actualMD5sum << "]" << std::endl @@ -2913,8 +2901,7 @@ cmFileCommand::HandleDownloadCommand(std::vector return true; #else - this->SetError("FILE(DOWNLOAD ) " - "not supported in bootstrap cmake "); + this->SetError("DOWNLOAD not supported by bootstrap cmake."); return false; #endif } diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index a54ad7a90..e1188d5bb 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -269,6 +269,11 @@ bool cmFindBase::ParseArguments(std::vector const& argsIn) } this->ExpandPaths(); + // Filter out ignored paths from the prefix list + std::set ignored; + this->GetIgnoredPaths(ignored); + this->FilterPaths(this->SearchPaths, ignored); + // Handle search root stuff. this->RerootPaths(this->SearchPaths); diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index f35217262..b7d3e52f9 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -240,6 +240,63 @@ void cmFindCommon::RerootPaths(std::vector& paths) } } +//---------------------------------------------------------------------------- +void cmFindCommon::FilterPaths(std::vector& paths, + const std::set& ignore) +{ + // Now filter out anything that's in the ignore set. + std::vector unfiltered; + unfiltered.swap(paths); + + for(std::vector::iterator pi = unfiltered.begin(); + pi != unfiltered.end(); ++pi) + { + if (ignore.count(*pi) == 0) + { + paths.push_back(*pi); + } + } +} + + +//---------------------------------------------------------------------------- +void cmFindCommon::GetIgnoredPaths(std::vector& ignore) +{ + // null-terminated list of paths. + static const char *paths[] = + { "CMAKE_SYSTEM_IGNORE_PATH", "CMAKE_IGNORE_PATH", 0 }; + + // Construct the list of path roots with no trailing slashes. + for(const char **pathName = paths; *pathName; ++pathName) + { + // Get the list of paths to ignore from the variable. + const char* ignorePath = this->Makefile->GetDefinition(*pathName); + if((ignorePath == 0) || (strlen(ignorePath) == 0)) + { + continue; + } + + cmSystemTools::ExpandListArgument(ignorePath, ignore); + } + + for(std::vector::iterator i = ignore.begin(); + i != ignore.end(); ++i) + { + cmSystemTools::ConvertToUnixSlashes(*i); + } +} + + +//---------------------------------------------------------------------------- +void cmFindCommon::GetIgnoredPaths(std::set& ignore) +{ + std::vector ignoreVec; + GetIgnoredPaths(ignoreVec); + ignore.insert(ignoreVec.begin(), ignoreVec.end()); +} + + + //---------------------------------------------------------------------------- bool cmFindCommon::CheckCommonArgument(std::string const& arg) { diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h index 2ffbd0053..a4866ba6f 100644 --- a/Source/cmFindCommon.h +++ b/Source/cmFindCommon.h @@ -39,6 +39,14 @@ protected: /** Place a set of search paths under the search roots. */ void RerootPaths(std::vector& paths); + /** Get ignored paths from CMAKE_[SYSTEM_]IGNORE_path variables. */ + void GetIgnoredPaths(std::vector& ignore); + void GetIgnoredPaths(std::set& ignore); + + /** Remove paths in the ignore set from the supplied vector. */ + void FilterPaths(std::vector& paths, + const std::set& ignore); + /** Add trailing slashes to all search paths. */ void AddTrailingSlashes(std::vector& paths); diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index bd58f566a..ef0197a5a 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -156,6 +156,11 @@ cmFindPackageCommand::cmFindPackageCommand() "The full path to the configuration file is stored in the cmake " "variable _CONFIG." "\n" + "All configuration files which have been considered by CMake while " + "searching for an installation of the package with an appropriate " + "version are stored in the cmake variable _CONSIDERED_CONFIGS, " + "the associated versions in _CONSIDERED_VERSIONS. " + "\n" "If the package configuration file cannot be found CMake " "will generate an error describing the problem unless the QUIET " "argument is specified. If REQUIRED is specified and the package " @@ -596,6 +601,15 @@ bool cmFindPackageCommand } } + // get igonored paths from vars and reroot them. + std::vector ignored; + this->GetIgnoredPaths(ignored); + this->RerootPaths(ignored); + + // Construct a set of ignored paths + this->IgnoredPaths.clear(); + this->IgnoredPaths.insert(ignored.begin(), ignored.end()); + // Find and load the package. bool result = this->HandlePackageMode(); this->AppendSuccessInformation(); @@ -609,7 +623,7 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components) // Store the list of components. std::string components_var = this->Name + "_FIND_COMPONENTS"; this->AddFindDefinition(components_var.c_str(), components.c_str()); - + if(this->Quiet) { // Tell the module that is about to be read that it should find @@ -712,6 +726,8 @@ bool cmFindPackageCommand::FindModule(bool& found) //---------------------------------------------------------------------------- bool cmFindPackageCommand::HandlePackageMode() { + this->ConsideredConfigs.clear(); + // Support old capitalization behavior. std::string upperDir = cmSystemTools::UpperCase(this->Name); std::string upperFound = cmSystemTools::UpperCase(this->Name); @@ -800,36 +816,58 @@ bool cmFindPackageCommand::HandlePackageMode() { // The variable is not set. cmOStringStream e; - e << "Could not find "; - if(!this->NoModule) - { - e << "module Find" << this->Name << ".cmake or "; - } - e << "a configuration file for package " << this->Name << ".\n"; - if(!this->NoModule) - { - e << "Adjust CMAKE_MODULE_PATH to find Find" - << this->Name << ".cmake or set "; - } - else - { - e << "Set "; - } - e << this->Variable << " to the directory containing a CMake " - << "configuration file for " << this->Name << ". "; - if(this->Configs.size() == 1) - { - e << "The file will be called " << this->Configs[0]; + // If there are files in ConsideredConfigs, it means that FooConfig.cmake + // have been found, but they didn't have appropriate versions. + if (this->ConsideredConfigs.size() > 0) + { + e << "Could not find a configuration file for package \"" + << this->Name << "\" that " + << (this->VersionExact? "exactly matches" : "is compatible with") + << " requested version \"" << this->Version << "\".\n" + << "The following configuration files were considered but not " + "accepted:\n"; + for(std::vector::size_type i=0; + iConsideredConfigs.size(); i++) + { + e << " " << this->ConsideredConfigs[i].filename + << ", version: " << this->ConsideredConfigs[i].version << "\n"; + } } else { - e << "The file will have one of the following names:\n"; - for(std::vector::const_iterator ci = this->Configs.begin(); - ci != this->Configs.end(); ++ci) + e << "Could not find "; + if(!this->NoModule) + { + e << "module Find" << this->Name << ".cmake or "; + } + e << "a configuration file for package " << this->Name << ".\n"; + if(!this->NoModule) { - e << " " << *ci << "\n"; + e << "Adjust CMAKE_MODULE_PATH to find Find" + << this->Name << ".cmake or set "; + } + else + { + e << "Set "; + } + e << this->Variable << " to the directory containing a CMake " + << "configuration file for " << this->Name << ". "; + if(this->Configs.size() == 1) + { + e << "The file will be called " << this->Configs[0]; + } + else + { + e << "The file will have one of the following names:\n"; + for(std::vector::const_iterator ci=this->Configs.begin(); + ci != this->Configs.end(); ++ci) + { + e << " " << *ci << "\n"; + } } } + + this->Makefile->IssueMessage( this->Required? cmake::FATAL_ERROR : cmake::WARNING, e.str()); } @@ -888,6 +926,31 @@ bool cmFindPackageCommand::HandlePackageMode() } #endif + std::string consideredConfigsVar = this->Name; + consideredConfigsVar += "_CONSIDERED_CONFIGS"; + std::string consideredVersionsVar = this->Name; + consideredVersionsVar += "_CONSIDERED_VERSIONS"; + + std::string consideredConfigFiles; + std::string consideredVersions; + + const char* sep = ""; + for(std::vector::size_type i=0; + iConsideredConfigs.size(); i++) + { + consideredConfigFiles += sep; + consideredVersions += sep; + consideredConfigFiles += this->ConsideredConfigs[i].filename; + consideredVersions += this->ConsideredConfigs[i].version; + sep = ";"; + } + + this->Makefile->AddDefinition(consideredConfigsVar.c_str(), + consideredConfigFiles.c_str()); + + this->Makefile->AddDefinition(consideredVersionsVar.c_str(), + consideredVersions.c_str()); + return result; } @@ -1074,6 +1137,20 @@ void cmFindPackageCommand::AppendSuccessInformation() } } + // set a global property to record the required version of this package + std::string versionInfoPropName = "_CMAKE_"; + versionInfoPropName += this->Name; + versionInfoPropName += "_REQUIRED_VERSION"; + std::string versionInfo; + if(!this->Version.empty()) + { + versionInfo = this->VersionExact ? "==" : ">="; + versionInfo += " "; + versionInfo += this->Version; + } + this->Makefile->GetCMakeInstance()->SetProperty(versionInfoPropName.c_str(), + versionInfo.c_str()); + // Restore original state of "_FIND_" variables we set. this->RestoreFindDefinitions(); } @@ -1431,6 +1508,11 @@ bool cmFindPackageCommand::CheckDirectory(std::string const& dir) bool cmFindPackageCommand::FindConfigFile(std::string const& dir, std::string& file) { + if (this->IgnoredPaths.count(dir)) + { + return false; + } + for(std::vector::const_iterator ci = this->Configs.begin(); ci != this->Configs.end(); ++ci) { @@ -1453,6 +1535,10 @@ bool cmFindPackageCommand::FindConfigFile(std::string const& dir, //---------------------------------------------------------------------------- bool cmFindPackageCommand::CheckVersion(std::string const& config_file) { + bool result = false; // by default, assume the version is not ok. + bool haveResult = false; + std::string version = "unknown"; + // Get the filename without the .cmake extension. std::string::size_type pos = config_file.rfind('.'); std::string version_file_base = config_file.substr(0, pos); @@ -1460,31 +1546,42 @@ bool cmFindPackageCommand::CheckVersion(std::string const& config_file) // Look for foo-config-version.cmake std::string version_file = version_file_base; version_file += "-version.cmake"; - if(cmSystemTools::FileExists(version_file.c_str(), true)) + if ((haveResult == false) + && (cmSystemTools::FileExists(version_file.c_str(), true))) { - return this->CheckVersionFile(version_file); + result = this->CheckVersionFile(version_file, version); + haveResult = true; } // Look for fooConfigVersion.cmake version_file = version_file_base; version_file += "Version.cmake"; - if(cmSystemTools::FileExists(version_file.c_str(), true)) + if ((haveResult == false) + && (cmSystemTools::FileExists(version_file.c_str(), true))) { - return this->CheckVersionFile(version_file); + result = this->CheckVersionFile(version_file, version); + haveResult = true; } + // If no version was requested a versionless package is acceptable. - if(this->Version.empty()) + if ((haveResult == false) && (this->Version.empty())) { - return true; + result = true; + haveResult = true; } - // No version file found. Assume the version is incompatible. - return false; + ConfigFileInfo configFileInfo; + configFileInfo.filename = config_file; + configFileInfo.version = version; + this->ConsideredConfigs.push_back(configFileInfo); + + return result; } //---------------------------------------------------------------------------- -bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file) +bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file, + std::string& result_version) { // The version file will be loaded in an isolated scope. cmMakefile::ScopePushPop varScope(this->Makefile); @@ -1557,6 +1654,12 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file) } } + result_version = this->Makefile->GetSafeDefinition("PACKAGE_VERSION"); + if (result_version.empty()) + { + result_version = "unknown"; + } + // Succeed if the version is suitable. return suitable; } diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index 63f411161..57aeab969 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -98,7 +98,8 @@ private: bool CheckDirectory(std::string const& dir); bool FindConfigFile(std::string const& dir, std::string& file); bool CheckVersion(std::string const& config_file); - bool CheckVersionFile(std::string const& version_file); + bool CheckVersionFile(std::string const& version_file, + std::string& result_version); bool SearchPrefix(std::string const& prefix); bool SearchFrameworkPrefix(std::string const& prefix_in); bool SearchAppBundlePrefix(std::string const& prefix_in); @@ -136,6 +137,10 @@ private: bool PolicyScope; std::vector Names; std::vector Configs; + std::set IgnoredPaths; + + struct ConfigFileInfo { std::string filename; std::string version; }; + std::vector ConsideredConfigs; }; #endif diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index bd26b5fca..0def33640 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -863,19 +863,10 @@ void cmGlobalGenerator::Generate() } // Compute the inter-target dependencies. - { - cmComputeTargetDepends ctd(this); - if(!ctd.Compute()) + if(!this->ComputeTargetDepends()) { return; } - std::vector const& targets = ctd.GetTargets(); - for(std::vector::const_iterator ti = targets.begin(); - ti != targets.end(); ++ti) - { - ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]); - } - } // Create a map from local generator to the complete set of targets // it builds by default. @@ -907,6 +898,23 @@ void cmGlobalGenerator::Generate() this->CMakeInstance->UpdateProgress("Generating done", -1); } +//---------------------------------------------------------------------------- +bool cmGlobalGenerator::ComputeTargetDepends() +{ + cmComputeTargetDepends ctd(this); + if(!ctd.Compute()) + { + return false; + } + std::vector const& targets = ctd.GetTargets(); + for(std::vector::const_iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + ctd.GetTargetDirectDepends(*ti, this->TargetDependencies[*ti]); + } + return true; +} + //---------------------------------------------------------------------------- bool cmGlobalGenerator::CheckTargets() { @@ -1487,7 +1495,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap() // Add dependencies of the included target. An excluded // target may still be included if it is a dependency of a // non-excluded target. - TargetDependSet & tgtdeps = this->GetTargetDirectDepends(target); + TargetDependSet const& tgtdeps = this->GetTargetDirectDepends(target); for(TargetDependSet::const_iterator ti = tgtdeps.begin(); ti != tgtdeps.end(); ++ti) { @@ -1837,6 +1845,39 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets) } } +//---------------------------------------------------------------------------- +const char* cmGlobalGenerator::GetPredefinedTargetsFolder() +{ + const char* prop = + this->GetCMakeInstance()->GetProperty("PREDEFINED_TARGETS_FOLDER"); + + if (prop) + { + return prop; + } + + return "CMakePredefinedTargets"; +} + +//---------------------------------------------------------------------------- +bool cmGlobalGenerator::UseFolderProperty() +{ + const char* prop = this->GetCMakeInstance()->GetProperty("USE_FOLDERS"); + + // If this property is defined, let the setter turn this on or off... + // + if (prop) + { + return cmSystemTools::IsOn(prop); + } + + // By default, this feature is OFF, since it is not supported in the + // Visual Studio Express editions: + // + return false; +} + +//---------------------------------------------------------------------------- cmTarget cmGlobalGenerator::CreateGlobalTarget( const char* name, const char* message, const cmCustomCommandLines* commandLines, @@ -1866,6 +1907,14 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( { target.AddUtility(dit->c_str()); } + + // Organize in the "predefined targets" folder: + // + if (this->UseFolderProperty()) + { + target.SetProperty("FOLDER", this->GetPredefinedTargetsFolder()); + } + return target; } @@ -1879,7 +1928,7 @@ void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*, } //---------------------------------------------------------------------------- -cmGlobalGenerator::TargetDependSet & +cmGlobalGenerator::TargetDependSet const& cmGlobalGenerator::GetTargetDirectDepends(cmTarget & target) { return this->TargetDependencies[&target]; diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 878be1143..2aec19fc0 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -238,7 +238,7 @@ public: // what targets does the specified target depend on directly // via a target_link_libraries or add_dependencies - TargetDependSet & GetTargetDirectDepends(cmTarget & target); + TargetDependSet const& GetTargetDirectDepends(cmTarget & target); const std::map >& GetProjectMap() const {return this->ProjectMap;} @@ -275,6 +275,8 @@ protected: void SetLanguageEnabledMaps(const char* l, cmMakefile* mf); void FillExtensionToLanguageMap(const char* l, cmMakefile* mf); + virtual bool ComputeTargetDepends(); + virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS(); bool CheckTargets(); @@ -320,6 +322,9 @@ protected: // All targets in the entire project. std::map TotalTargets; + virtual const char* GetPredefinedTargetsFolder(); + virtual bool UseFolderProperty(); + private: float FirstTimeProgress; // If you add a new map here, make sure it is copied diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b687fe199..4e8e7e6d9 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -750,8 +750,9 @@ cmGlobalUnixMakefileGenerator3 cmLocalGenerator::FULL, cmLocalGenerator::SHELL); progCmd << " "; - std::vector &progFiles = this->ProgressMap[&t->second].Marks; - for (std::vector::iterator i = progFiles.begin(); + std::vector& progFiles = + this->ProgressMap[&t->second].Marks; + for (std::vector::iterator i = progFiles.begin(); i != progFiles.end(); ++i) { progCmd << " " << *i; diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 401888fa6..f4995368a 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -177,7 +177,7 @@ protected: TargetProgress(): NumberOfActions(0) {} unsigned long NumberOfActions; std::string VariableFile; - std::vector Marks; + std::vector Marks; void WriteProgressVariables(unsigned long total, unsigned long& current); }; struct ProgressMapCompare { bool operator()(cmTarget*,cmTarget*) const; }; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 691502f1a..403507f98 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -40,7 +40,7 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout) cmLocalGenerator *cmGlobalVisualStudio10Generator::CreateLocalGenerator() { cmLocalVisualStudio10Generator* lg = new cmLocalVisualStudio10Generator; - lg->SetPlatformName(this->PlatformName.c_str()); + lg->SetPlatformName(this->GetPlatformName()); lg->SetGlobalGenerator(this); return lg; } diff --git a/Source/cmGlobalVisualStudio10Win64Generator.cxx b/Source/cmGlobalVisualStudio10Win64Generator.cxx index 1004fa98f..109b60d1f 100644 --- a/Source/cmGlobalVisualStudio10Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio10Win64Generator.cxx @@ -16,7 +16,6 @@ //---------------------------------------------------------------------------- cmGlobalVisualStudio10Win64Generator::cmGlobalVisualStudio10Win64Generator() { - this->PlatformName = "x64"; } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalVisualStudio10Win64Generator.h b/Source/cmGlobalVisualStudio10Win64Generator.h index 98ba03ceb..39c9d081b 100644 --- a/Source/cmGlobalVisualStudio10Win64Generator.h +++ b/Source/cmGlobalVisualStudio10Win64Generator.h @@ -27,6 +27,8 @@ public: return cmGlobalVisualStudio10Win64Generator::GetActualName();} static const char* GetActualName() {return "Visual Studio 10 Win64";} + virtual const char* GetPlatformName() const {return "x64";} + /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry) const; diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx index d053ca2c3..203ca778d 100644 --- a/Source/cmGlobalVisualStudio6Generator.cxx +++ b/Source/cmGlobalVisualStudio6Generator.cxx @@ -13,6 +13,7 @@ #include "cmLocalVisualStudio6Generator.h" #include "cmMakefile.h" #include "cmake.h" +#include "cmGeneratedFileStream.h" // Utility function to make a valid VS6 *.dsp filename out // of a CMake target name: @@ -274,44 +275,33 @@ void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, fout << "Package=<5>\n{{{\n}}}\n\n"; fout << "Package=<4>\n"; fout << "{{{\n"; - - // insert Begin Project Dependency Project_Dep_Name project stuff here - if (target.GetType() != cmTarget::STATIC_LIBRARY) + VSDependSet const& depends = this->VSTargetDepends[&target]; + for(VSDependSet::const_iterator di = depends.begin(); + di != depends.end(); ++di) { - cmTarget::LinkLibraryVectorType::const_iterator j, jend; - j = target.GetLinkLibraries().begin(); - jend = target.GetLinkLibraries().end(); - for(;j!= jend; ++j) - { - if(j->first != dspname) - { - // is the library part of this DSW ? If so add dependency - if(this->FindTarget(0, j->first.c_str())) - { - fout << "Begin Project Dependency\n"; - fout << "Project_Dep_Name " - << GetVS6TargetName(j->first.c_str()) << "\n"; - fout << "End Project Dependency\n"; - } - } - } + const char* name = di->c_str(); + fout << "Begin Project Dependency\n"; + fout << "Project_Dep_Name " << GetVS6TargetName(name) << "\n"; + fout << "End Project Dependency\n"; } + fout << "}}}\n\n"; - std::set::const_iterator i, end; - // write utility dependencies. - i = target.GetUtilities().begin(); - end = target.GetUtilities().end(); - for(;i!= end; ++i) + UtilityDependsMap::iterator ui = this->UtilityDepends.find(&target); + if(ui != this->UtilityDepends.end()) { - if(*i != dspname) - { - std::string depName = this->GetUtilityForTarget(target, i->c_str()); - fout << "Begin Project Dependency\n"; - fout << "Project_Dep_Name " << GetVS6TargetName(depName) << "\n"; - fout << "End Project Dependency\n"; - } + const char* uname = ui->second.c_str(); + fout << "Project: \"" << uname << "\"=" + << dir << "\\" << uname << ".dsp - Package Owner=<4>\n\n"; + fout << + "Package=<5>\n{{{\n}}}\n\n" + "Package=<4>\n" + "{{{\n" + "Begin Project Dependency\n" + "Project_Dep_Name " << dspname << "\n" + "End Project Dependency\n" + "}}}\n\n"; + ; } - fout << "}}}\n\n"; } @@ -367,6 +357,49 @@ void cmGlobalVisualStudio6Generator::WriteDSWHeader(std::ostream& fout) fout << "# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n\n"; } +//---------------------------------------------------------------------------- +std::string +cmGlobalVisualStudio6Generator::WriteUtilityDepend(cmTarget* target) +{ + std::string pname = target->GetName(); + pname += "_UTILITY"; + pname = GetVS6TargetName(pname.c_str()); + std::string fname = target->GetMakefile()->GetStartOutputDirectory(); + fname += "/"; + fname += pname; + fname += ".dsp"; + cmGeneratedFileStream fout(fname.c_str()); + fout.SetCopyIfDifferent(true); + fout << + "# Microsoft Developer Studio Project File - Name=\"" + << pname << "\" - Package Owner=<4>\n" + "# Microsoft Developer Studio Generated Build File, Format Version 6.00\n" + "# ** DO NOT EDIT **\n" + "\n" + "# TARGTYPE \"Win32 (x86) Generic Project\" 0x010a\n" + "\n" + "CFG=" << pname << " - Win32 Debug\n" + "!MESSAGE \"" << pname << " - Win32 Debug\"" + " (based on \"Win32 (x86) Generic Project\")\n" + "!MESSAGE \"" << pname << " - Win32 Release\" " + "(based on \"Win32 (x86) Generic Project\")\n" + "!MESSAGE \"" << pname << " - Win32 MinSizeRel\" " + "(based on \"Win32 (x86) Generic Project\")\n" + "!MESSAGE \"" << pname << " - Win32 RelWithDebInfo\" " + "(based on \"Win32 (x86) Generic Project\")\n" + "\n" + "# Begin Project\n" + "# Begin Target\n" + "# Name \"" << pname << " - Win32 Debug\"\n" + "# Name \"" << pname << " - Win32 Release\"\n" + "# Name \"" << pname << " - Win32 MinSizeRel\"\n" + "# Name \"" << pname << " - Win32 RelWithDebInfo\"\n" + "# End Target\n" + "# End Project\n" + ; + return pname; +} + //---------------------------------------------------------------------------- void cmGlobalVisualStudio6Generator ::GetDocumentation(cmDocumentationEntry& entry) const diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h index 553c7beaf..77d537075 100644 --- a/Source/cmGlobalVisualStudio6Generator.h +++ b/Source/cmGlobalVisualStudio6Generator.h @@ -96,6 +96,7 @@ private: const char* name, const char* path, const std::set& dependencies); void WriteDSWFooter(std::ostream& fout); + virtual std::string WriteUtilityDepend(cmTarget* target); }; #endif diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 119157549..ba1868797 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -111,6 +111,13 @@ void cmGlobalVisualStudio71Generator OrderedTargetDependSet orderedProjectTargets(projectTargets); this->WriteTargetsToSolution(fout, root, orderedProjectTargets); + + bool useFolderProperty = this->UseFolderProperty(); + if (useFolderProperty) + { + this->WriteFolders(fout); + } + // Write out the configurations information for the solution fout << "Global\n"; // Write out the configurations for the solution @@ -120,6 +127,15 @@ void cmGlobalVisualStudio71Generator // Write out the configurations for all the targets in the project this->WriteTargetConfigurations(fout, root, orderedProjectTargets); fout << "\tEndGlobalSection\n"; + + if (useFolderProperty) + { + // Write out project folders + fout << "\tGlobalSection(NestedProjects) = preSolution\n"; + this->WriteFoldersContent(fout); + fout << "\tEndGlobalSection\n"; + } + // Write the footer for the SLN file this->WriteSLNFooter(fout); } @@ -163,16 +179,31 @@ cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, ext = targetExt; } + std::string guid = this->GetGUID(dspname); fout << project << dspname << "\", \"" << this->ConvertToSolutionPath(dir) - << "\\" << dspname << ext << "\", \"{" - << this->GetGUID(dspname) << "}\"\n"; + << "\\" << dspname << ext << "\", \"{" << guid << "}\"\n"; fout << "\tProjectSection(ProjectDependencies) = postProject\n"; this->WriteProjectDepends(fout, dspname, dir, t); fout << "\tEndProjectSection\n"; fout <<"EndProject\n"; + + UtilityDependsMap::iterator ui = this->UtilityDepends.find(&t); + if(ui != this->UtilityDepends.end()) + { + const char* uname = ui->second.c_str(); + fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" + << uname << "\", \"" + << this->ConvertToSolutionPath(dir) + << "\\" << uname << ".vcproj" << "\", \"{" + << this->GetGUID(uname) << "}\"\n" + << "\tProjectSection(ProjectDependencies) = postProject\n" + << "\t\t{" << guid << "} = {" << guid << "}\n" + << "\tEndProjectSection\n" + << "EndProject\n"; + } } //---------------------------------------------------------------------------- @@ -182,62 +213,24 @@ cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, void cmGlobalVisualStudio71Generator ::WriteProjectDepends(std::ostream& fout, - const char* dspname, + const char*, const char*, cmTarget& target) { -#if 0 - // Create inter-target dependencies in the solution file. For VS - // 7.1 and below we cannot let static libraries depend directly on - // targets to which they "link" because the librarian tool will copy - // the targets into the static library. See - // cmGlobalVisualStudioGenerator::FixUtilityDependsForTarget for a - // work-around. VS 8 and above do not have this problem. - if (!this->VSLinksDependencies() || - target.GetType() != cmTarget::STATIC_LIBRARY); -#else - if (target.GetType() != cmTarget::STATIC_LIBRARY) -#endif + VSDependSet const& depends = this->VSTargetDepends[&target]; + for(VSDependSet::const_iterator di = depends.begin(); + di != depends.end(); ++di) { - cmTarget::LinkLibraryVectorType::const_iterator j, jend; - j = target.GetLinkLibraries().begin(); - jend = target.GetLinkLibraries().end(); - for(;j!= jend; ++j) + const char* name = di->c_str(); + std::string guid = this->GetGUID(name); + if(guid.size() == 0) { - if(j->first != dspname) - { - // is the library part of this SLN ? If so add dependency - // find target anywhere because all depend libraries are - // brought in as well - if(this->FindTarget(0, j->first.c_str())) - { - fout << "\t\t{" << this->GetGUID(j->first.c_str()) << "} = {" - << this->GetGUID(j->first.c_str()) << "}\n"; - } - } - } - } - - std::set::const_iterator i, end; - // write utility dependencies. - i = target.GetUtilities().begin(); - end = target.GetUtilities().end(); - for(;i!= end; ++i) - { - if(*i != dspname) - { - std::string name = this->GetUtilityForTarget(target, i->c_str()); - std::string guid = this->GetGUID(name.c_str()); - if(guid.size() == 0) - { - std::string m = "Target: "; - m += target.GetName(); - m += " depends on unknown target: "; - m += name; - cmSystemTools::Error(m.c_str()); - } - - fout << "\t\t{" << guid << "} = {" << guid << "}\n"; + std::string m = "Target: "; + m += target.GetName(); + m += " depends on unknown target: "; + m += name; + cmSystemTools::Error(m.c_str()); } + fout << "\t\t{" << guid << "} = {" << guid << "}\n"; } } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 9631e9a31..2b9e5baef 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -300,6 +300,48 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( cmLocalGenerator::START_OUTPUT); this->WriteProject(fout, vcprojName, dir.c_str(), *target); + + // Create "solution folder" information from FOLDER target property + // + if (this->UseFolderProperty()) + { + const char *targetFolder = target->GetProperty("FOLDER"); + if (targetFolder) + { + std::vector tokens = + cmSystemTools::SplitString(targetFolder, '/', false); + + std::string cumulativePath = ""; + + for(std::vector::iterator iter = tokens.begin(); + iter != tokens.end(); ++iter) + { + if(!iter->size()) + { + continue; + } + + if (cumulativePath.empty()) + { + cumulativePath = "CMAKE_FOLDER_GUID_" + *iter; + } + else + { + VisualStudioFolders[cumulativePath].insert( + cumulativePath + "/" + *iter); + + cumulativePath = cumulativePath + "/" + *iter; + } + + this->CreateGUID(cumulativePath.c_str()); + } + + if (!cumulativePath.empty()) + { + VisualStudioFolders[cumulativePath].insert(target->GetName()); + } + } + } } } } @@ -327,6 +369,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends( } } +//---------------------------------------------------------------------------- // Write a SLN file to the stream void cmGlobalVisualStudio7Generator ::WriteSLNFile(std::ostream& fout, @@ -344,6 +387,13 @@ void cmGlobalVisualStudio7Generator OrderedTargetDependSet orderedProjectTargets(projectTargets); this->WriteTargetsToSolution(fout, root, orderedProjectTargets); + + bool useFolderProperty = this->UseFolderProperty(); + if (useFolderProperty) + { + this->WriteFolders(fout); + } + // Write out the configurations information for the solution fout << "Global\n" << "\tGlobalSection(SolutionConfiguration) = preSolution\n"; @@ -361,6 +411,14 @@ void cmGlobalVisualStudio7Generator this->WriteTargetDepends(fout, orderedProjectTargets); fout << "\tEndGlobalSection\n"; + if (useFolderProperty) + { + // Write out project folders + fout << "\tGlobalSection(NestedProjects) = preSolution\n"; + this->WriteFoldersContent(fout); + fout << "\tEndGlobalSection\n"; + } + // Write out the configurations for all the targets in the project fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n"; this->WriteTargetConfigurations(fout, root, orderedProjectTargets); @@ -370,6 +428,55 @@ void cmGlobalVisualStudio7Generator this->WriteSLNFooter(fout); } +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout) +{ + const char *prefix = "CMAKE_FOLDER_GUID_"; + const std::string::size_type skip_prefix = strlen(prefix); + std::string guidProjectTypeFolder = "2150E333-8FDC-42A3-9474-1A3956D46DE8"; + for(std::map >::iterator iter = + VisualStudioFolders.begin(); iter != VisualStudioFolders.end(); ++iter) + { + std::string fullName = iter->first; + std::string guid = this->GetGUID(fullName.c_str()); + + cmSystemTools::ReplaceString(fullName, "/", "\\"); + if (cmSystemTools::StringStartsWith(fullName.c_str(), prefix)) + { + fullName = fullName.substr(skip_prefix); + } + + std::string nameOnly = cmSystemTools::GetFilenameName(fullName); + + fout << "Project(\"{" << + guidProjectTypeFolder << "}\") = \"" << + nameOnly << "\", \"" << + fullName << "\", \"{" << + guid << + "}\"\nEndProject\n"; + } +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio7Generator::WriteFoldersContent(std::ostream& fout) +{ + for(std::map >::iterator iter = + VisualStudioFolders.begin(); iter != VisualStudioFolders.end(); ++iter) + { + std::string key(iter->first); + std::string guidParent(this->GetGUID(key.c_str())); + + for(std::set::iterator it = iter->second.begin(); + it != iter->second.end(); ++it) + { + std::string value(*it); + std::string guid(this->GetGUID(value.c_str())); + + fout << "\t\t{" << guid << "} = {" << guidParent << "}\n"; + } + } +} + //---------------------------------------------------------------------------- std::string cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path) @@ -408,6 +515,18 @@ void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout, << this->ConvertToSolutionPath(dir) << "\\" << dspname << ext << "\", \"{" << this->GetGUID(dspname) << "}\"\nEndProject\n"; + + UtilityDependsMap::iterator ui = this->UtilityDepends.find(&target); + if(ui != this->UtilityDepends.end()) + { + const char* uname = ui->second.c_str(); + fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" + << uname << "\", \"" + << this->ConvertToSolutionPath(dir) + << "\\" << uname << ".vcproj" << "\", \"{" + << this->GetGUID(uname) << "}\"\n" + << "EndProject\n"; + } } @@ -422,59 +541,30 @@ cmGlobalVisualStudio7Generator const char*, cmTarget& target) { int depcount = 0; - // insert Begin Project Dependency Project_Dep_Name project stuff here - if (target.GetType() != cmTarget::STATIC_LIBRARY) - { - cmTarget::LinkLibraryVectorType::const_iterator j, jend; - j = target.GetLinkLibraries().begin(); - jend = target.GetLinkLibraries().end(); - for(;j!= jend; ++j) + std::string dspguid = this->GetGUID(dspname); + VSDependSet const& depends = this->VSTargetDepends[&target]; + for(VSDependSet::const_iterator di = depends.begin(); + di != depends.end(); ++di) + { + const char* name = di->c_str(); + std::string guid = this->GetGUID(name); + if(guid.size() == 0) { - if(j->first != dspname) - { - // is the library part of this SLN ? If so add dependency - if(this->FindTarget(0, j->first.c_str())) - { - std::string guid = this->GetGUID(j->first.c_str()); - if(guid.size() == 0) - { - std::string m = "Target: "; - m += dspname; - m += " depends on unknown target: "; - m += j->first.c_str(); - cmSystemTools::Error(m.c_str()); - } - fout << "\t\t{" << this->GetGUID(dspname) << "}." - << depcount << " = {" << guid << "}\n"; - depcount++; - } - } + std::string m = "Target: "; + m += target.GetName(); + m += " depends on unknown target: "; + m += name; + cmSystemTools::Error(m.c_str()); } + fout << "\t\t{" << dspguid << "}." << depcount << " = {" << guid << "}\n"; + depcount++; } - std::set::const_iterator i, end; - // write utility dependencies. - i = target.GetUtilities().begin(); - end = target.GetUtilities().end(); - for(;i!= end; ++i) + UtilityDependsMap::iterator ui = this->UtilityDepends.find(&target); + if(ui != this->UtilityDepends.end()) { - if(*i != dspname) - { - std::string name = this->GetUtilityForTarget(target, i->c_str()); - std::string guid = this->GetGUID(name.c_str()); - if(guid.size() == 0) - { - std::string m = "Target: "; - m += dspname; - m += " depends on unknown target: "; - m += name.c_str(); - cmSystemTools::Error(m.c_str()); - } - - fout << "\t\t{" << this->GetGUID(dspname) << "}." << depcount << " = {" - << guid << "}\n"; - depcount++; - } + const char* uname = ui->second.c_str(); + fout << "\t\t{" << this->GetGUID(uname) << "}.0 = {" << dspguid << "}\n"; } } @@ -537,6 +627,61 @@ void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout) fout << "Microsoft Visual Studio Solution File, Format Version 7.00\n"; } +//---------------------------------------------------------------------------- +std::string +cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget* target) +{ + std::string pname = target->GetName(); + pname += "_UTILITY"; + std::string fname = target->GetMakefile()->GetStartOutputDirectory(); + fname += "/"; + fname += pname; + fname += ".vcproj"; + cmGeneratedFileStream fout(fname.c_str()); + fout.SetCopyIfDifferent(true); + this->CreateGUID(pname.c_str()); + std::string guid = this->GetGUID(pname.c_str()); + + fout << + "\n" + "GetIDEVersion() << "0\"\n" + "\tName=\"" << pname << "\"\n" + "\tProjectGUID=\"{" << guid << "}\"\n" + "\tKeyword=\"Win32Proj\">\n" + "\t\n" + "\t\n" + ; + for(std::vector::iterator i = this->Configurations.begin(); + i != this->Configurations.end(); ++i) + { + fout << + "\t\t\n" + "\t\t\n" + ; + } + fout << + "\t\n" + "\t\n" + "\t\n" + "\n" + ; + + if(fout.Close()) + { + this->FileReplacedDuringGenerate(fname); + } + return pname; +} + std::string cmGlobalVisualStudio7Generator::GetGUID(const char* name) { std::string guidStoreName = name; diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 85ba24495..b6c84e8ff 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -113,6 +113,7 @@ protected: bool partOfDefaultBuild); virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout); + virtual std::string WriteUtilityDepend(cmTarget* target); virtual void AddPlatformDefinitions(cmMakefile* mf); virtual void WriteTargetsToSolution( @@ -142,6 +143,10 @@ protected: std::vector Configurations; std::map GUIDMap; + virtual void WriteFolders(std::ostream& fout); + virtual void WriteFoldersContent(std::ostream& fout); + std::map > VisualStudioFolders; + // Set during OutputSLNFile with the name of the current project. // There is one SLN file per project. std::string CurrentProject; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 6e0f0480e..7c65c320e 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -21,7 +21,7 @@ cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator() { this->FindMakeProgramFile = "CMakeVS8FindMake.cmake"; this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms"; - this->PlatformName = "Win32"; + this->ArchitectureId = "X86"; } //---------------------------------------------------------------------------- @@ -30,6 +30,7 @@ cmLocalGenerator *cmGlobalVisualStudio8Generator::CreateLocalGenerator() { cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; lg->SetVersion8(); + lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); return lg; @@ -55,8 +56,8 @@ void cmGlobalVisualStudio8Generator //---------------------------------------------------------------------------- void cmGlobalVisualStudio8Generator::AddPlatformDefinitions(cmMakefile* mf) { - mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86"); - mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86"); + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId); mf->AddDefinition("MSVC80", "1"); } @@ -136,6 +137,13 @@ void cmGlobalVisualStudio8Generator::AddCheckTarget() no_working_directory, no_depends, noCommandLines); + // Organize in the "predefined targets" folder: + // + if (this->UseFolderProperty()) + { + tgt->SetProperty("FOLDER", this->GetPredefinedTargetsFolder()); + } + // Create a list of all stamp files for this project. std::vector stamps; std::string stampList = cmake::GetCMakeFilesDirectoryPostSlash(); @@ -252,8 +260,8 @@ cmGlobalVisualStudio8Generator for(std::vector::iterator i = this->Configurations.begin(); i != this->Configurations.end(); ++i) { - fout << "\t\t" << *i << "|" << this->PlatformName << " = " << *i << "|" - << this->PlatformName << "\n"; + fout << "\t\t" << *i << "|" << this->GetPlatformName() + << " = " << *i << "|" << this->GetPlatformName() << "\n"; } fout << "\tEndGlobalSection\n"; } @@ -269,13 +277,13 @@ cmGlobalVisualStudio8Generator i != this->Configurations.end(); ++i) { fout << "\t\t{" << guid << "}." << *i - << "|" << this->PlatformName << ".ActiveCfg = " - << *i << "|" << this->PlatformName << "\n"; + << "|" << this->GetPlatformName() << ".ActiveCfg = " + << *i << "|" << this->GetPlatformName() << "\n"; if(partOfDefaultBuild) { fout << "\t\t{" << guid << "}." << *i - << "|" << this->PlatformName << ".Build.0 = " - << *i << "|" << this->PlatformName << "\n"; + << "|" << this->GetPlatformName() << ".Build.0 = " + << *i << "|" << this->GetPlatformName() << "\n"; } } } diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 9d836bda3..e0d5d8044 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -32,14 +32,14 @@ public: return cmGlobalVisualStudio8Generator::GetActualName();} static const char* GetActualName() {return "Visual Studio 8 2005";} + virtual const char* GetPlatformName() const {return "Win32";} + /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry) const; ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); - std::string const& GetPlatformName() const { return this->PlatformName; } - /** * Override Configure and Generate to add the build-system check * target. @@ -78,6 +78,7 @@ protected: virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, bool partOfDefaultBuild); - std::string PlatformName; // Win32 or x64 + + const char* ArchitectureId; }; #endif diff --git a/Source/cmGlobalVisualStudio8Win64Generator.cxx b/Source/cmGlobalVisualStudio8Win64Generator.cxx index d5558bb91..3469b1710 100644 --- a/Source/cmGlobalVisualStudio8Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio8Win64Generator.cxx @@ -19,7 +19,7 @@ cmGlobalVisualStudio8Win64Generator::cmGlobalVisualStudio8Win64Generator() { - this->PlatformName = "x64"; + this->ArchitectureId = "x64"; } ///! Create a local generator appropriate to this Global Generator @@ -27,7 +27,7 @@ cmLocalGenerator *cmGlobalVisualStudio8Win64Generator::CreateLocalGenerator() { cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; lg->SetVersion8(); - lg->SetPlatformName(this->PlatformName.c_str()); + lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); return lg; @@ -48,6 +48,4 @@ void cmGlobalVisualStudio8Win64Generator { this->cmGlobalVisualStudio8Generator::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/cmGlobalVisualStudio8Win64Generator.h b/Source/cmGlobalVisualStudio8Win64Generator.h index 44c237cd4..084ba697c 100644 --- a/Source/cmGlobalVisualStudio8Win64Generator.h +++ b/Source/cmGlobalVisualStudio8Win64Generator.h @@ -33,6 +33,8 @@ public: return cmGlobalVisualStudio8Win64Generator::GetActualName();} static const char* GetActualName() {return "Visual Studio 8 2005 Win64";} + virtual const char* GetPlatformName() const {return "x64";} + /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry) const; diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index f6ae70599..f8ceea0b0 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -25,8 +25,8 @@ cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator() //---------------------------------------------------------------------------- void cmGlobalVisualStudio9Generator::AddPlatformDefinitions(cmMakefile* mf) { - mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", "X86"); - mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", "X86"); + mf->AddDefinition("MSVC_C_ARCHITECTURE_ID", this->ArchitectureId); + mf->AddDefinition("MSVC_CXX_ARCHITECTURE_ID", this->ArchitectureId); mf->AddDefinition("MSVC90", "1"); } @@ -42,6 +42,7 @@ cmLocalGenerator *cmGlobalVisualStudio9Generator::CreateLocalGenerator() { cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; lg->SetVersion9(); + lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); return lg; diff --git a/Source/cmGlobalVisualStudio9Win64Generator.cxx b/Source/cmGlobalVisualStudio9Win64Generator.cxx index c5b9babfd..ff4fd4f5d 100644 --- a/Source/cmGlobalVisualStudio9Win64Generator.cxx +++ b/Source/cmGlobalVisualStudio9Win64Generator.cxx @@ -16,7 +16,7 @@ cmGlobalVisualStudio9Win64Generator::cmGlobalVisualStudio9Win64Generator() { - this->PlatformName = "x64"; + this->ArchitectureId = "x64"; } ///! Create a local generator appropriate to this Global Generator @@ -24,7 +24,7 @@ cmLocalGenerator *cmGlobalVisualStudio9Win64Generator::CreateLocalGenerator() { cmLocalVisualStudio7Generator *lg = new cmLocalVisualStudio7Generator; lg->SetVersion9(); - lg->SetPlatformName(this->PlatformName.c_str()); + lg->SetPlatformName(this->GetPlatformName()); lg->SetExtraFlagTable(this->GetExtraFlagTableVS8()); lg->SetGlobalGenerator(this); return lg; @@ -45,6 +45,4 @@ void cmGlobalVisualStudio9Win64Generator { cmGlobalVisualStudio9Generator::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/cmGlobalVisualStudio9Win64Generator.h b/Source/cmGlobalVisualStudio9Win64Generator.h index 55abcfc56..f6dcc03cd 100644 --- a/Source/cmGlobalVisualStudio9Win64Generator.h +++ b/Source/cmGlobalVisualStudio9Win64Generator.h @@ -33,6 +33,8 @@ public: return cmGlobalVisualStudio9Win64Generator::GetActualName();} static const char* GetActualName() {return "Visual Studio 9 2008 Win64";} + virtual const char* GetPlatformName() const {return "x64";} + /** Get the documentation entry for this generator. */ virtual void GetDocumentation(cmDocumentationEntry& entry) const; diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 85b4a7139..bae18a311 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -56,6 +56,21 @@ void cmGlobalVisualStudioGenerator::Generate() AddUtilityCommand("ALL_BUILD", true, no_working_dir, no_depends, no_commands, false, "Build all projects"); + +#if 0 + // Can't activate this code because we want ALL_BUILD + // selected as the default "startup project" when first + // opened in Visual Studio... And if it's nested in a + // folder, then that doesn't happen. + // + // Organize in the "predefined targets" folder: + // + if (this->UseFolderProperty()) + { + allBuild->SetProperty("FOLDER", this->GetPredefinedTargetsFolder()); + } +#endif + // Now make all targets depend on the ALL_BUILD target cmTargets targets; for(std::vector::iterator i = gen.begin(); @@ -74,9 +89,6 @@ void cmGlobalVisualStudioGenerator::Generate() } } - // Fix utility dependencies to avoid linking to libraries. - this->FixUtilityDepends(); - // Configure CMake Visual Studio macros, for this user on this version // of Visual Studio. this->ConfigureCMakeVisualStudioMacros(); @@ -225,129 +237,59 @@ std::string cmGlobalVisualStudioGenerator::GetUserMacrosRegKeyBase() } //---------------------------------------------------------------------------- -void cmGlobalVisualStudioGenerator::FixUtilityDepends() +bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() { - // Skip for VS versions 8 and above. - if(!this->VSLinksDependencies()) + if(!this->cmGlobalGenerator::ComputeTargetDepends()) { - return; + return false; } - - // For VS versions before 8: - // - // When a target that links contains a project-level dependency on a - // library target that library is automatically linked. In order to - // allow utility-style project-level dependencies that do not - // actually link we need to automatically insert an intermediate - // custom target. - // - // Here we edit the utility dependencies of a target to add the - // intermediate custom target when necessary. - for(unsigned i = 0; i < this->LocalGenerators.size(); ++i) + std::map >::iterator it; + for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) { - cmTargets* targets = - &(this->LocalGenerators[i]->GetMakefile()->GetTargets()); - for(cmTargets::iterator tarIt = targets->begin(); - tarIt != targets->end(); ++tarIt) + std::vector& gen = it->second; + for(std::vector::iterator i = gen.begin(); + i != gen.end(); ++i) { - this->FixUtilityDependsForTarget(tarIt->second); + cmTargets& targets = (*i)->GetMakefile()->GetTargets(); + for(cmTargets::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + this->ComputeVSTargetDepends(ti->second); + } } } + return true; } //---------------------------------------------------------------------------- -void -cmGlobalVisualStudioGenerator::FixUtilityDependsForTarget(cmTarget& target) +void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(cmTarget& target) { - // Only targets that link need to be fixed. - if(target.GetType() != cmTarget::STATIC_LIBRARY && - target.GetType() != cmTarget::SHARED_LIBRARY && - target.GetType() != cmTarget::MODULE_LIBRARY && - target.GetType() != cmTarget::EXECUTABLE) + if(this->VSTargetDepends.find(&target) != this->VSTargetDepends.end()) { return; } - -#if 0 - // This feature makes a mess in SLN files for VS 7.1 and below. It - // creates an extra target for every target that is "linked" by a - // static library. Without this feature static libraries do not - // wait until their "link" dependencies are built to build. This is - // not a problem 99.9% of the time, and projects that do have the - // problem can enable this work-around by using add_dependencies. - - // Static libraries cannot depend directly on the targets to which - // they link because VS will copy those targets into the library - // (for VS < 8). To work around the problem we copy the - // dependencies to be utility dependencies so that the work-around - // below is used. - if(target.GetType() == cmTarget::STATIC_LIBRARY) + VSDependSet& vsTargetDepend = this->VSTargetDepends[&target]; + if(target.GetType() != cmTarget::STATIC_LIBRARY) { cmTarget::LinkLibraryVectorType const& libs = target.GetLinkLibraries(); - for(cmTarget::LinkLibraryVectorType::const_iterator i = libs.begin(); - i != libs.end(); ++i) - { - if(cmTarget* depTarget = this->FindTarget(0, i->first.c_str(), false)) - { - target.AddUtility(depTarget->GetName()); - } - } - } -#endif - - // Look at each utility dependency. - for(std::set::const_iterator ui = - target.GetUtilities().begin(); - ui != target.GetUtilities().end(); ++ui) - { - if(cmTarget* depTarget = this->FindTarget(0, ui->c_str())) + for(cmTarget::LinkLibraryVectorType::const_iterator j = libs.begin(); + j != libs.end(); ++j) { - if(depTarget->GetType() == cmTarget::STATIC_LIBRARY || - depTarget->GetType() == cmTarget::SHARED_LIBRARY || - depTarget->GetType() == cmTarget::MODULE_LIBRARY) + if(j->first != target.GetName() && + this->FindTarget(0, j->first.c_str())) { - // This utility dependency will cause an attempt to link. If - // the depender does not already link the dependee we need an - // intermediate target. - if(!this->CheckTargetLinks(target, ui->c_str())) - { - this->CreateUtilityDependTarget(*depTarget); - } + vsTargetDepend.insert(j->first); } } } -} - -//---------------------------------------------------------------------------- -void -cmGlobalVisualStudioGenerator::CreateUtilityDependTarget(cmTarget& target) -{ - // This target is a library on which a utility dependency exists. - // We need to create an intermediate custom target to hook up the - // dependency without causing a link. - const char* altName = target.GetProperty("ALTERNATIVE_DEPENDENCY_NAME"); - if(!altName) + std::set const& utils = target.GetUtilities(); + for(std::set::const_iterator i = utils.begin(); + i != utils.end(); ++i) { - // Create the intermediate utility target. - std::string altNameStr = target.GetName(); - altNameStr += "_UTILITY"; - const std::vector no_depends; - cmCustomCommandLines no_commands; - const char* no_working_dir = 0; - const char* no_comment = 0; - target.GetMakefile()->AddUtilityCommand(altNameStr.c_str(), true, - no_working_dir, no_depends, - no_commands, false, no_comment); - target.SetProperty("ALTERNATIVE_DEPENDENCY_NAME", altNameStr.c_str()); - - // Most targets have a GUID created in ConfigureFinalPass. Since - // that has already been called, create one for this target now. - this->CreateGUID(altNameStr.c_str()); - - // The intermediate target should depend on the original target. - if(cmTarget* alt = this->FindTarget(0, altNameStr.c_str())) + if(*i != target.GetName()) { - alt->AddUtility(target.GetName()); + std::string name = this->GetUtilityForTarget(target, i->c_str()); + vsTargetDepend.insert(name); } } } @@ -375,10 +317,28 @@ bool cmGlobalVisualStudioGenerator::CheckTargetLinks(cmTarget& target, } //---------------------------------------------------------------------------- -const char* +std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(cmTarget* target) +{ + UtilityDependsMap::iterator i = this->UtilityDepends.find(target); + if(i == this->UtilityDepends.end()) + { + std::string name = this->WriteUtilityDepend(target); + UtilityDependsMap::value_type entry(target, name); + i = this->UtilityDepends.insert(entry).first; + } + return i->second; +} + +//---------------------------------------------------------------------------- +std::string cmGlobalVisualStudioGenerator::GetUtilityForTarget(cmTarget& target, const char* name) { + if(!this->VSLinksDependencies()) + { + return name; + } + // Possibly depend on an intermediate utility target to avoid // linking. if(target.GetType() == cmTarget::STATIC_LIBRARY || @@ -386,19 +346,19 @@ cmGlobalVisualStudioGenerator::GetUtilityForTarget(cmTarget& target, target.GetType() == cmTarget::MODULE_LIBRARY || target.GetType() == cmTarget::EXECUTABLE) { - // The depender is a target that links. Lookup the dependee to - // see if it provides an alternative dependency name. + // The depender is a target that links. if(cmTarget* depTarget = this->FindTarget(0, name)) { - // Check for an alternative name created by FixUtilityDepends. - if(const char* altName = - depTarget->GetProperty("ALTERNATIVE_DEPENDENCY_NAME")) + if(depTarget->GetType() == cmTarget::STATIC_LIBRARY || + depTarget->GetType() == cmTarget::SHARED_LIBRARY || + depTarget->GetType() == cmTarget::MODULE_LIBRARY) { - // The alternative name is needed only if the depender does - // not really link to the dependee. + // This utility dependency will cause an attempt to link. If + // the depender does not already link the dependee we need an + // intermediate target. if(!this->CheckTargetLinks(target, name)) { - return altName; + return this->GetUtilityDepend(depTarget); } } } @@ -408,30 +368,6 @@ cmGlobalVisualStudioGenerator::GetUtilityForTarget(cmTarget& target, return name; } -//---------------------------------------------------------------------------- -void cmGlobalVisualStudioGenerator::GetTargetSets( - TargetDependSet& projectTargets, TargetDependSet& originalTargets, - cmLocalGenerator* root, GeneratorVector const& generators - ) -{ - this->cmGlobalGenerator::GetTargetSets(projectTargets, originalTargets, - root, generators); - - // Add alternative dependency targets created by FixUtilityDepends. - for(TargetDependSet::iterator ti = projectTargets.begin(); - ti != projectTargets.end(); ++ti) - { - cmTarget* tgt = *ti; - if(const char* altName = tgt->GetProperty("ALTERNATIVE_DEPENDENCY_NAME")) - { - if(cmTarget* alt = tgt->GetMakefile()->FindTarget(altName)) - { - projectTargets.insert(alt); - } - } - } -} - //---------------------------------------------------------------------------- #include diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index b0be0871d..c8ea339ce 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -61,7 +61,6 @@ public: // return true if target is fortran only bool TargetIsFortranOnly(cmTarget& t); - const char* GetUtilityForTarget(cmTarget& target, const char*); /** Get the top-level registry key for this VS version. */ std::string GetRegistryBase(); @@ -70,16 +69,6 @@ public: i.e. "Can I build Debug and Release in the same tree?" */ virtual bool IsMultiConfig() { return true; } -protected: - void FixUtilityDepends(); - - // Does this VS version link targets to each other if there are - // dependencies in the SLN file? This was done for VS versions - // below 8. - virtual bool VSLinksDependencies() const { return true; } - - virtual const char* GetIDEVersion() = 0; - struct TargetCompare { bool operator()(cmTarget const* l, cmTarget const* r) const; @@ -90,14 +79,26 @@ protected: OrderedTargetDependSet(cmGlobalGenerator::TargetDependSet const&); }; - virtual void GetTargetSets(TargetDependSet& projectTargets, - TargetDependSet& originalTargets, - cmLocalGenerator* root, GeneratorVector const&); +protected: + // Does this VS version link targets to each other if there are + // dependencies in the SLN file? This was done for VS versions + // below 8. + virtual bool VSLinksDependencies() const { return true; } + + virtual const char* GetIDEVersion() = 0; + + virtual bool ComputeTargetDepends(); + class VSDependSet: public std::set {}; + class VSDependMap: public std::map {}; + VSDependMap VSTargetDepends; + void ComputeVSTargetDepends(cmTarget&); bool CheckTargetLinks(cmTarget& target, const char* name); -private: - void FixUtilityDependsForTarget(cmTarget& target); - void CreateUtilityDependTarget(cmTarget& target); + std::string GetUtilityForTarget(cmTarget& target, const char*); + virtual std::string WriteUtilityDepend(cmTarget*) = 0; + std::string GetUtilityDepend(cmTarget* target); + typedef std::map UtilityDependsMap; + UtilityDependsMap UtilityDepends; }; #endif diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 537a88f30..2f7bc44ab 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -131,8 +131,8 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(std::string const& version) //---------------------------------------------------------------------------- cmGlobalGenerator* cmGlobalXCodeGenerator::New() -{ -#if defined(CMAKE_BUILD_WITH_CMAKE) +{ +#if defined(CMAKE_BUILD_WITH_CMAKE) cmXcodeVersionParser parser; parser.ParseFile ("/Developer/Applications/Xcode.app/Contents/version.plist"); @@ -156,7 +156,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::New() void cmGlobalXCodeGenerator::EnableLanguage(std::vectorconst& lang, cmMakefile * mf, bool optional) -{ +{ mf->AddDefinition("XCODE","1"); mf->AddDefinition("XCODE_VERSION", this->VersionString.c_str()); if(this->XcodeVersion == 15) @@ -175,12 +175,12 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vectorconst& mf->AddDefinition("CMAKE_GENERATOR_CC", "gcc"); mf->AddDefinition("CMAKE_GENERATOR_CXX", "g++"); mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); - // initialize Architectures so it can be used by + // initialize Architectures so it can be used by // GetTargetObjectFileDirectories this->cmGlobalGenerator::EnableLanguage(lang, mf, optional); - const char* osxArch = + const char* osxArch = mf->GetDefinition("CMAKE_OSX_ARCHITECTURES"); - const char* sysroot = + const char* sysroot = mf->GetDefinition("CMAKE_OSX_SYSROOT"); if(osxArch && sysroot) { @@ -193,10 +193,10 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vectorconst& //---------------------------------------------------------------------------- std::string cmGlobalXCodeGenerator ::GenerateBuildCommand(const char* makeProgram, - const char *projectName, - const char* additionalOptions, + const char *projectName, + const char* additionalOptions, const char *targetName, - const char* config, + const char* config, bool ignoreErrors, bool) { @@ -210,7 +210,7 @@ std::string cmGlobalXCodeGenerator "Generator cannot find the appropriate make command."); return ""; } - std::string makeCommand = + std::string makeCommand = cmSystemTools::ConvertToOutputPath(makeProgram); std::string lowerCaseCommand = makeCommand; cmSystemTools::LowerCase(lowerCaseCommand); @@ -284,7 +284,7 @@ void cmGlobalXCodeGenerator::Generate() // make sure extra targets are added before calling // the parent generate which will call trace depends for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) - { + { cmLocalGenerator* root = it->second[0]; this->SetGenerationRoot(root); // add ALL_BUILD, INSTALL, etc @@ -293,7 +293,7 @@ void cmGlobalXCodeGenerator::Generate() this->ForceLinkerLanguages(); this->cmGlobalGenerator::Generate(); for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it) - { + { cmLocalGenerator* root = it->second[0]; this->SetGenerationRoot(root); // now create the project @@ -319,8 +319,8 @@ void cmGlobalXCodeGenerator::SetGenerationRoot(cmLocalGenerator* root) } //---------------------------------------------------------------------------- -void -cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, +void +cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, std::vector& gens) { cmMakefile* mf = root->GetMakefile(); @@ -339,7 +339,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, listfile += "CMakeLists.txt"; allbuild->AddSource(listfile.c_str()); - // Add XCODE depend helper + // Add XCODE depend helper std::string dir = mf->GetCurrentOutputDirectory(); cmCustomCommandLine makecommand; makecommand.push_back("make"); @@ -361,7 +361,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, for(std::vector::iterator i = gens.begin(); i != gens.end(); ++i) { - cmLocalGenerator* lg = *i; + cmLocalGenerator* lg = *i; if(this->IsExcluded(root, *i)) { continue; @@ -370,7 +370,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) { cmTarget& target = l->second; - // make all exe, shared libs and modules + // 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 // things are up-to-date @@ -385,7 +385,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget::POST_BUILD, "Depend check for xcode", dir.c_str()); - + } if(!target.GetPropertyAsBool("EXCLUDE_FROM_ALL")) { @@ -407,8 +407,8 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(cmLocalGenerator* root) cmMakefile* mf = root->GetMakefile(); std::vector lfiles = mf->GetListFiles(); // sort the array - std::sort(lfiles.begin(), lfiles.end(), std::less()); - std::vector::iterator new_end = + std::sort(lfiles.begin(), lfiles.end(), std::less()); + std::vector::iterator new_end = std::unique(lfiles.begin(), lfiles.end()); lfiles.erase(new_end, lfiles.end()); std::string dir = mf->GetHomeOutputDirectory(); @@ -428,7 +428,7 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(cmLocalGenerator* root) makefileStream << "\\\n" << this->ConvertToRelativeForMake(i->c_str()); } std::string cmake = mf->GetRequiredDefinition("CMAKE_COMMAND"); - makefileStream << "\n\t" << this->ConvertToRelativeForMake(cmake.c_str()) + makefileStream << "\n\t" << this->ConvertToRelativeForMake(cmake.c_str()) << " -H" << this->ConvertToRelativeForMake( mf->GetHomeDirectory()) << " -B" << this->ConvertToRelativeForMake( @@ -451,7 +451,7 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects() } //---------------------------------------------------------------------------- -cmXCodeObject* +cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype) { cmXCodeObject* obj; @@ -468,7 +468,7 @@ cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype) } //---------------------------------------------------------------------------- -cmXCodeObject* +cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type) { cmXCodeObject* obj = new cmXCodeObject(cmXCodeObject::None, type); @@ -539,7 +539,7 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, buildFile->SetComment(fileRef->GetComment()); buildFile->AddAttribute("fileRef", this->CreateObjectReference(fileRef)); - cmXCodeObject* settings = + cmXCodeObject* settings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); settings->AddAttribute("COMPILER_FLAGS", this->CreateString(flags.c_str())); @@ -608,7 +608,7 @@ cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf, } fileRef->AddAttribute("fileEncoding", this->CreateString("4")); - const char* lang = + const char* lang = this->CurrentLocalGenerator->GetSourceFileLanguage(*sf); std::string sourcecode = "sourcecode"; std::string ext = sf->GetExtension(); @@ -643,7 +643,7 @@ cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf, sourcecode += ".c.h"; } else if(ext == "hxx" || ext == "hpp" || ext == "txx" - || ext == "pch") + || ext == "pch" || ext == "hh") { sourcecode += ".cpp.h"; } @@ -675,7 +675,7 @@ cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf, // // valid lastKnownFileType value. // } - fileRef->AddAttribute("lastKnownFileType", + fileRef->AddAttribute("lastKnownFileType", this->CreateString(sourcecode.c_str())); // Store the file path relative to the top of the source tree. @@ -717,31 +717,15 @@ void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen) std::string outdir = cmSystemTools::CollapseFullPath(this->CurrentMakefile-> GetCurrentOutputDirectory()); - cmSystemTools::SplitPath(outdir.c_str(), + cmSystemTools::SplitPath(outdir.c_str(), this->CurrentOutputDirectoryComponents); // Select the current set of configuration types. this->CurrentConfigurationTypes.clear(); - if(this->XcodeVersion > 20) - { - if(const char* types = - this->CurrentMakefile->GetDefinition("CMAKE_CONFIGURATION_TYPES")) - { - cmSystemTools::ExpandListArgument(types, - this->CurrentConfigurationTypes); - } - } + this->CurrentMakefile->GetConfigurations(this->CurrentConfigurationTypes); if(this->CurrentConfigurationTypes.empty()) { - if(const char* buildType = - this->CurrentMakefile->GetDefinition("CMAKE_BUILD_TYPE")) - { - this->CurrentConfigurationTypes.push_back(buildType); - } - else - { - this->CurrentConfigurationTypes.push_back(""); - } + this->CurrentConfigurationTypes.push_back(""); } } @@ -783,7 +767,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, this->CreateXCodeSourceFile(this->CurrentLocalGenerator, *i, cmtarget); cmXCodeObject* fr = xsf->GetObject("fileRef"); - cmXCodeObject* filetype = + cmXCodeObject* filetype = fr->GetObject()->GetObject("lastKnownFileType"); cmTarget::SourceFileFlags tsFlags = @@ -829,7 +813,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, sourceBuildPhase = this->CreateObject(cmXCodeObject::PBXSourcesBuildPhase); sourceBuildPhase->SetComment("Sources"); - sourceBuildPhase->AddAttribute("buildActionMask", + sourceBuildPhase->AddAttribute("buildActionMask", this->CreateString("2147483647")); buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); for(std::vector::iterator i = sourceFiles.begin(); @@ -838,7 +822,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, buildFiles->AddObject(*i); } sourceBuildPhase->AddAttribute("files", buildFiles); - sourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", + sourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", this->CreateString("0")); } @@ -931,7 +915,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, for ( sfIt = mit->second.begin(); sfIt != mit->second.end(); ++ sfIt ) { cmXCodeObject* xsf = - this->CreateXCodeSourceFile(this->CurrentLocalGenerator, + this->CreateXCodeSourceFile(this->CurrentLocalGenerator, *sfIt, cmtarget); buildFiles->AddObject(xsf); } @@ -955,12 +939,12 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, { buildFiles->AddObject(*i); } - frameworkBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", + frameworkBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", this->CreateString("0")); } // create list of build phases and create the XCode target - cmXCodeObject* buildPhases = + cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST); this->CreateCustomCommands(buildPhases, sourceBuildPhase, @@ -1049,15 +1033,15 @@ cmGlobalXCodeGenerator::CreateBuildPhase(const char* name, { return 0; } - cmXCodeObject* buildPhase = + cmXCodeObject* buildPhase = this->CreateObject(cmXCodeObject::PBXShellScriptBuildPhase); buildPhase->AddAttribute("buildActionMask", this->CreateString("2147483647")); cmXCodeObject* buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); buildPhase->AddAttribute("files", buildFiles); - buildPhase->AddAttribute("name", + buildPhase->AddAttribute("name", this->CreateString(name)); - buildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", + buildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", this->CreateString("0")); buildPhase->AddAttribute("shellPath", this->CreateString("/bin/sh")); @@ -1080,16 +1064,16 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, frameworkBuildPhase, cmTarget& cmtarget) { - std::vector const & prebuild + std::vector const & prebuild = cmtarget.GetPreBuildCommands(); - std::vector const & prelink + std::vector const & prelink = cmtarget.GetPreLinkCommands(); - std::vector const & postbuild + std::vector const & postbuild = cmtarget.GetPostBuildCommands(); std::vectorconst &classes = cmtarget.GetSourceFiles(); // add all the sources std::vector commands; - for(std::vector::const_iterator i = classes.begin(); + for(std::vector::const_iterator i = classes.begin(); i != classes.end(); ++i) { if((*i)->GetCustomCommand()) @@ -1098,7 +1082,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, } } std::vector reruncom; - cmXCodeObject* cmakeReRunPhase = + cmXCodeObject* cmakeReRunPhase = this->CreateBuildPhase("CMake ReRun", "cmakeReRunPhase", cmtarget, reruncom); buildPhases->AddObject(cmakeReRunPhase); @@ -1108,15 +1092,15 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases, "cmakeRulesBuildPhase", cmtarget, commands); // create prebuild phase - cmXCodeObject* preBuildPhase = + cmXCodeObject* preBuildPhase = this->CreateBuildPhase("CMake PreBuild Rules", "preBuildCommands", cmtarget, prebuild); // create prelink phase - cmXCodeObject* preLinkPhase = + cmXCodeObject* preLinkPhase = this->CreateBuildPhase("CMake PreLink Rules", "preLinkCommands", cmtarget, prelink); // create postbuild phase - cmXCodeObject* postBuildPhase = + cmXCodeObject* postBuildPhase = this->CreateBuildPhase("CMake PostBuild Rules", "postBuildPhase", cmtarget, postbuild); @@ -1183,10 +1167,10 @@ std::string cmGlobalXCodeGenerator::ExtractFlag(const char* flag, } //---------------------------------------------------------------------------- -void +void cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, cmTarget& target, - std::vector + std::vector const & commands, const char* name) { @@ -1197,7 +1181,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, std::string makecmd = "make -C "; makecmd += cdir; makecmd += " -f "; - makecmd += + makecmd += this->ConvertToRelativeForMake(this->CurrentReRunCMakeMakefile.c_str()); cmSystemTools::ReplaceString(makecmd, "\\ ", "\\\\ "); buildphase->AddAttribute("shellScript", @@ -1211,7 +1195,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, for(std::vector::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommand const& cc = *i; + cmCustomCommand const& cc = *i; if(!cc.GetCommandLines().empty()) { const std::vector& outputs = cc.GetOutputs(); @@ -1229,7 +1213,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, } } } - + std::string dir = this->CurrentMakefile->GetCurrentOutputDirectory(); dir += "/CMakeScripts"; cmSystemTools::MakeDirectory(dir.c_str()); @@ -1239,19 +1223,19 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, makefile += "_"; makefile += name; makefile += ".make"; - - for (std::vector::const_iterator currentConfig= + + for (std::vector::const_iterator currentConfig= this->CurrentConfigurationTypes.begin(); currentConfig!=this->CurrentConfigurationTypes.end(); currentConfig++ ) { - this->CreateCustomRulesMakefile(makefile.c_str(), - target, - commands, + this->CreateCustomRulesMakefile(makefile.c_str(), + target, + commands, currentConfig->c_str(), multipleOutputPairs); } - + std::string cdir = this->CurrentMakefile->GetCurrentOutputDirectory(); cdir = this->ConvertToRelativeForXCode(cdir.c_str()); std::string makecmd = "make -C "; @@ -1265,18 +1249,18 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase, } makecmd += " all"; cmSystemTools::ReplaceString(makecmd, "\\ ", "\\\\ "); - buildphase->AddAttribute("shellScript", + buildphase->AddAttribute("shellScript", this->CreateString(makecmd.c_str())); } //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator -::CreateCustomRulesMakefile(const char* makefileBasename, - cmTarget& target, - std::vector +::CreateCustomRulesMakefile(const char* makefileBasename, + cmTarget& target, + std::vector const & commands, const char* configName, - const std::map& multipleOutputPairs ) { @@ -1293,7 +1277,7 @@ void cmGlobalXCodeGenerator makefileStream.SetCopyIfDifferent(true); makefileStream << "# Generated by CMake, DO NOT EDIT\n"; makefileStream << "# Custom rules for " << target.GetName() << "\n"; - + // have all depend on all outputs makefileStream << "all: "; std::map tname; @@ -1301,7 +1285,7 @@ void cmGlobalXCodeGenerator for(std::vector::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommand const& cc = *i; + cmCustomCommand const& cc = *i; if(!cc.GetCommandLines().empty()) { const std::vector& outputs = cc.GetOutputs(); @@ -1315,10 +1299,10 @@ void cmGlobalXCodeGenerator } } else - { + { cmOStringStream str; str << "_buildpart_" << count++ ; - tname[&cc] = std::string(target.GetName()) + str.str(); + tname[&cc] = std::string(target.GetName()) + str.str(); makefileStream << "\\\n\t" << tname[&cc]; } } @@ -1327,7 +1311,7 @@ void cmGlobalXCodeGenerator for(std::vector::const_iterator i = commands.begin(); i != commands.end(); ++i) { - cmCustomCommand const& cc = *i; + cmCustomCommand const& cc = *i; if(!cc.GetCommandLines().empty()) { bool escapeOldStyle = cc.GetEscapeOldStyle(); @@ -1346,7 +1330,7 @@ void cmGlobalXCodeGenerator // There are no outputs. Use the generated force rule name. makefileStream << tname[&cc] << ": "; } - for(std::vector::const_iterator d = + for(std::vector::const_iterator d = cc.GetDepends().begin(); d != cc.GetDepends().end(); ++d) { @@ -1367,7 +1351,7 @@ void cmGlobalXCodeGenerator } // Add each command line to the set of commands. - for(cmCustomCommandLines::const_iterator cl = + for(cmCustomCommandLines::const_iterator cl = cc.GetCommandLines().begin(); cl != cc.GetCommandLines().end(); ++cl) { @@ -1375,7 +1359,7 @@ void cmGlobalXCodeGenerator const cmCustomCommandLine& commandLine = *cl; std::string cmd2 = this->CurrentLocalGenerator ->GetRealLocation(commandLine[0].c_str(), configName); - + cmSystemTools::ReplaceString(cmd2, "/./", "/"); cmd2 = this->ConvertToRelativeForMake(cmd2.c_str()); std::string cmd; @@ -1409,7 +1393,7 @@ void cmGlobalXCodeGenerator // Add rules to deal with multiple outputs of custom commands. if(!multipleOutputPairs.empty()) { - makefileStream << + makefileStream << "\n# Dependencies of multiple outputs to their primary outputs \n"; for(std::map::const_iterator o = @@ -1440,6 +1424,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string defFlags; bool shared = ((target.GetType() == cmTarget::SHARED_LIBRARY) || (target.GetType() == cmTarget::MODULE_LIBRARY)); + bool binary = ((target.GetType() == cmTarget::STATIC_LIBRARY) || + (target.GetType() == cmTarget::EXECUTABLE) || + shared); const char* lang = target.GetLinkerLanguage(configName); std::string cflags; @@ -1454,10 +1441,17 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Add language-specific flags. this->CurrentLocalGenerator->AddLanguageFlags(flags, lang, configName); - + // Add shared-library flags if needed. this->CurrentLocalGenerator->AddSharedFlags(flags, lang, shared); } + else if(binary) + { + cmSystemTools::Error + ("CMake can not determine linker language for target:", + target.GetName()); + return; + } // Add define flags this->CurrentLocalGenerator-> @@ -1492,11 +1486,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string extraLinkOptions; if(target.GetType() == cmTarget::EXECUTABLE) { - extraLinkOptions = + extraLinkOptions = this->CurrentMakefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS"); std::string var = "CMAKE_EXE_LINKER_FLAGS_"; var += cmSystemTools::UpperCase(configName); - std::string val = + std::string val = this->CurrentMakefile->GetSafeDefinition(var.c_str()); if(val.size()) { @@ -1595,9 +1589,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(pndir.c_str())); pndir = target.GetDirectory(configName); } - buildSettings->AddAttribute("EXECUTABLE_PREFIX", + buildSettings->AddAttribute("EXECUTABLE_PREFIX", this->CreateString(pnprefix.c_str())); - buildSettings->AddAttribute("EXECUTABLE_SUFFIX", + buildSettings->AddAttribute("EXECUTABLE_SUFFIX", this->CreateString(pnsuffix.c_str())); } buildSettings->AddAttribute("SYMROOT", @@ -1608,20 +1602,20 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { case cmTarget::STATIC_LIBRARY: { - buildSettings->AddAttribute("LIBRARY_STYLE", + buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("STATIC")); break; } - + case cmTarget::MODULE_LIBRARY: { - buildSettings->AddAttribute("LIBRARY_STYLE", + buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("BUNDLE")); if(this->XcodeVersion >= 22) { - buildSettings->AddAttribute("MACH_O_TYPE", + buildSettings->AddAttribute("MACH_O_TYPE", this->CreateString("mh_bundle")); - buildSettings->AddAttribute("GCC_DYNAMIC_NO_PIC", + buildSettings->AddAttribute("GCC_DYNAMIC_NO_PIC", this->CreateString("NO")); // Add the flags to create an executable. std::string createFlags = @@ -1706,7 +1700,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, plist.c_str()); std::string path = this->ConvertToRelativeForXCode(plist.c_str()); - buildSettings->AddAttribute("INFOPLIST_FILE", + buildSettings->AddAttribute("INFOPLIST_FILE", this->CreateString(path.c_str())); } @@ -1717,7 +1711,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } if(this->XcodeVersion >= 22) { - buildSettings->AddAttribute("PREBINDING", + buildSettings->AddAttribute("PREBINDING", this->CreateString("NO")); } @@ -1742,7 +1736,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } else { - std::string incpath = + std::string incpath = this->XCodeEscapePath(i->c_str()); dirs.Add(incpath.c_str()); } @@ -1761,12 +1755,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } if(!fdirs.IsEmpty()) { - buildSettings->AddAttribute("FRAMEWORK_SEARCH_PATHS", + buildSettings->AddAttribute("FRAMEWORK_SEARCH_PATHS", fdirs.CreateList()); } if(!dirs.IsEmpty()) { - buildSettings->AddAttribute("HEADER_SEARCH_PATHS", + buildSettings->AddAttribute("HEADER_SEARCH_PATHS", dirs.CreateList()); } std::string oflagc = this->ExtractFlag("-O", cflags); @@ -1808,11 +1802,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, if(gflagc.size() ==0 && gflag.size() == 0) { debugStr = "NO"; - } + } buildSettings->AddAttribute("GCC_GENERATE_DEBUGGING_SYMBOLS", this->CreateString(debugStr)); - buildSettings->AddAttribute("GCC_OPTIMIZATION_LEVEL", + buildSettings->AddAttribute("GCC_OPTIMIZATION_LEVEL", this->CreateString(optLevel)); buildSettings->AddAttribute("GCC_SYMBOLS_PRIVATE_EXTERN", this->CreateString("NO")); @@ -1822,11 +1816,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { flags += " "; flags += defFlags; - buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS", + buildSettings->AddAttribute("OTHER_CPLUSPLUSFLAGS", this->CreateString(flags.c_str())); cflags += " "; cflags += defFlags; - buildSettings->AddAttribute("OTHER_CFLAGS", + buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(cflags.c_str())); } @@ -1834,7 +1828,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, { flags += " "; flags += defFlags; - buildSettings->AddAttribute("OTHER_CFLAGS", + buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString(flags.c_str())); } @@ -1862,9 +1856,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, buildSettings->AddAttribute("INSTALL_PATH", this->CreateString(install_name_dir.c_str())); - buildSettings->AddAttribute("OTHER_LDFLAGS", + buildSettings->AddAttribute("OTHER_LDFLAGS", this->CreateString(extraLinkOptions.c_str())); - buildSettings->AddAttribute("OTHER_REZFLAGS", + buildSettings->AddAttribute("OTHER_REZFLAGS", this->CreateString("")); buildSettings->AddAttribute("SECTORDER_FLAGS", this->CreateString("")); @@ -1934,12 +1928,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } //---------------------------------------------------------------------------- -cmXCodeObject* +cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) { cmXCodeObject* shellBuildPhase = this->CreateObject(cmXCodeObject::PBXShellScriptBuildPhase); - shellBuildPhase->AddAttribute("buildActionMask", + shellBuildPhase->AddAttribute("buildActionMask", this->CreateString("2147483647")); cmXCodeObject* buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); shellBuildPhase->AddAttribute("files", buildFiles); @@ -1954,10 +1948,10 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) shellBuildPhase->AddAttribute("shellScript", this->CreateString( "# shell script goes here\nexit 0")); - cmXCodeObject* target = + cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXAggregateTarget); target->SetComment(cmtarget.GetName()); - cmXCodeObject* buildPhases = + cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST); std::vector emptyContentVector; this->CreateCustomCommands(buildPhases, 0, 0, 0, emptyContentVector, 0, @@ -1976,7 +1970,7 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) this->CreateBuildSettings(cmtarget, buildSettings, theConfig); target->AddAttribute("buildSettings", buildSettings); } - cmXCodeObject* dependencies = + cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST); target->AddAttribute("dependencies", dependencies); target->AddAttribute("name", this->CreateString(cmtarget.GetName())); @@ -2004,13 +1998,13 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget) std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target, cmTarget& cmtarget) { - std::string configTypes = + std::string configTypes = this->CurrentMakefile->GetRequiredDefinition("CMAKE_CONFIGURATION_TYPES"); std::vector configVectorIn; std::vector configVector; configVectorIn.push_back(configTypes); cmSystemTools::ExpandList(configVectorIn, configVector); - cmXCodeObject* configlist = + cmXCodeObject* configlist = this->CreateObject(cmXCodeObject::XCConfigurationList); cmXCodeObject* buildConfigurations = this->CreateObject(cmXCodeObject::OBJECT_LIST); @@ -2021,11 +2015,11 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target, comment += cmtarget.GetName(); comment += "\""; configlist->SetComment(comment.c_str()); - target->AddAttribute("buildConfigurationList", + target->AddAttribute("buildConfigurationList", this->CreateObjectReference(configlist)); for(unsigned int i = 0; i < configVector.size(); ++i) { - cmXCodeObject* config = + cmXCodeObject* config = this->CreateObject(cmXCodeObject::XCBuildConfiguration); buildConfigurations->AddObject(config); cmXCodeObject* buildSettings = @@ -2038,9 +2032,9 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target, } if(configVector.size()) { - configlist->AddAttribute("defaultConfigurationName", + configlist->AddAttribute("defaultConfigurationName", this->CreateString(configVector[0].c_str())); - configlist->AddAttribute("defaultConfigurationIsVisible", + configlist->AddAttribute("defaultConfigurationIsVisible", this->CreateString("0")); return configVector[0]; } @@ -2095,7 +2089,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, cmXCodeObject* buildPhases) { - cmXCodeObject* target = + cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget); target->AddAttribute("buildPhases", buildPhases); cmXCodeObject* buildRules = this->CreateObject(cmXCodeObject::OBJECT_LIST); @@ -2113,13 +2107,13 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, this->CreateBuildSettings(cmtarget, buildSettings, defConfig.c_str()); target->AddAttribute("buildSettings", buildSettings); } - cmXCodeObject* dependencies = + cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST); target->AddAttribute("dependencies", dependencies); target->AddAttribute("name", this->CreateString(cmtarget.GetName())); target->AddAttribute("productName",this->CreateString(cmtarget.GetName())); - cmXCodeObject* fileRef = + cmXCodeObject* fileRef = this->CreateObject(cmXCodeObject::PBXFileReference); if(const char* fileType = this->GetTargetFileType(cmtarget)) { @@ -2131,7 +2125,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, fileRef->AddAttribute("sourceTree", this->CreateString("BUILT_PRODUCTS_DIR")); fileRef->SetComment(cmtarget.GetName()); - target->AddAttribute("productReference", + target->AddAttribute("productReference", this->CreateObjectReference(fileRef)); if(const char* productType = this->GetTargetProductType(cmtarget)) { @@ -2172,20 +2166,20 @@ void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target, // now avoid circular references if dependTarget already // depends on target then skip it. Circular references crashes // xcode - cmXCodeObject* dependTargetDepends = + cmXCodeObject* dependTargetDepends = dependTarget->GetObject("dependencies"); if(dependTargetDepends) { if(dependTargetDepends->HasObject(target->GetPBXTargetDependency())) - { + { return; } } - + cmXCodeObject* targetdep = dependTarget->GetPBXTargetDependency(); if(!targetdep) { - cmXCodeObject* container = + cmXCodeObject* container = this->CreateObject(cmXCodeObject::PBXContainerItemProxy); container->SetComment("PBXContainerItemProxy"); container->AddAttribute("containerPortal", @@ -2193,25 +2187,25 @@ void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target, container->AddAttribute("proxyType", this->CreateString("1")); container->AddAttribute("remoteGlobalIDString", this->CreateObjectReference(dependTarget)); - container->AddAttribute("remoteInfo", + container->AddAttribute("remoteInfo", this->CreateString( dependTarget->GetTarget()->GetName())); - targetdep = + targetdep = this->CreateObject(cmXCodeObject::PBXTargetDependency); targetdep->SetComment("PBXTargetDependency"); targetdep->AddAttribute("target", this->CreateObjectReference(dependTarget)); - targetdep->AddAttribute("targetProxy", + targetdep->AddAttribute("targetProxy", this->CreateObjectReference(container)); dependTarget->SetPBXTargetDependency(targetdep); } - + cmXCodeObject* depends = target->GetObject("dependencies"); if(!depends) { cmSystemTools:: Error("target does not have dependencies attribute error.."); - + } else { @@ -2259,14 +2253,14 @@ void cmGlobalXCodeGenerator { // There are multiple configurations. Add the setting to the // buildSettings of the configuration name given. - cmXCodeObject* configurationList = + cmXCodeObject* configurationList = target->GetObject("buildConfigurationList")->GetObject(); - cmXCodeObject* buildConfigs = + cmXCodeObject* buildConfigs = configurationList->GetObject("buildConfigurations"); std::vector list = buildConfigs->GetObjectList(); - // each configuration and the target itself has a buildSettings in it + // each configuration and the target itself has a buildSettings in it //list.push_back(target); - for(std::vector::iterator i = list.begin(); + for(std::vector::iterator i = list.begin(); i != list.end(); ++i) { if(configName) @@ -2428,7 +2422,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, std::vector sourceGroups = mf->GetSourceGroups(); cmTargets &tgts = mf->GetTargets(); for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) - { + { cmTarget& cmtarget = l->second; // Same skipping logic here as in CreateXCodeTargets so that we do not @@ -2451,21 +2445,21 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root, std::vector classes = cmtarget.GetSourceFiles(); - for(std::vector::const_iterator s = classes.begin(); + for(std::vector::const_iterator s = classes.begin(); s != classes.end(); s++) { cmSourceFile* sf = *s; // Add the file to the list of sources. std::string const& source = sf->GetFullPath(); - cmSourceGroup& sourceGroup = + cmSourceGroup& sourceGroup = mf->FindSourceGroup(source.c_str(), sourceGroups); - cmXCodeObject* pbxgroup = + cmXCodeObject* pbxgroup = this->CreateOrGetPBXGroup(cmtarget, &sourceGroup); cmStdString key = GetGroupMapKey(cmtarget, sf); this->GroupMap[key] = pbxgroup; } } - } + } } //---------------------------------------------------------------------------- @@ -2491,7 +2485,7 @@ cmXCodeObject* cmGlobalXCodeGenerator { tgroup = this->CreateObject(cmXCodeObject::PBXGroup); this->TargetGroup[cmtarget.GetName()] = tgroup; - cmXCodeObject* tgroupChildren = + cmXCodeObject* tgroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); tgroup->AddAttribute("name", this->CreateString(cmtarget.GetName())); tgroup->AddAttribute("children", tgroupChildren); @@ -2514,7 +2508,7 @@ cmXCodeObject* cmGlobalXCodeGenerator cmXCodeObject* tgroupChildren = tgroup->GetObject("children"); cmXCodeObject* group = this->CreateObject(cmXCodeObject::PBXGroup); - cmXCodeObject* groupChildren = + cmXCodeObject* groupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); group->AddAttribute("name", this->CreateString(sg->GetName())); group->AddAttribute("children", groupChildren); @@ -2534,19 +2528,19 @@ void cmGlobalXCodeGenerator std::vector& generators) { - this->ClearXCodeObjects(); + this->ClearXCodeObjects(); this->RootObject = 0; this->SourcesGroupChildren = 0; this->ResourcesGroupChildren = 0; this->MainGroupChildren = 0; cmXCodeObject* group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO")); - cmXCodeObject* developBuildStyle = + cmXCodeObject* developBuildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle); cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::OBJECT_LIST); if(this->XcodeVersion == 15) { - developBuildStyle->AddAttribute("name", + developBuildStyle->AddAttribute("name", this->CreateString("Development")); developBuildStyle->AddAttribute("buildSettings", group); listObjs->AddObject(developBuildStyle); @@ -2562,7 +2556,7 @@ void cmGlobalXCodeGenerator { for(unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i) { - cmXCodeObject* buildStyle = + cmXCodeObject* buildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle); const char* name = this->CurrentConfigurationTypes[i].c_str(); buildStyle->AddAttribute("name", this->CreateString(name)); @@ -2576,7 +2570,7 @@ void cmGlobalXCodeGenerator } cmXCodeObject* mainGroup = this->CreateObject(cmXCodeObject::PBXGroup); - this->MainGroupChildren = + this->MainGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); mainGroup->AddAttribute("children", this->MainGroupChildren); if(this->XcodeVersion == 15) @@ -2586,7 +2580,7 @@ void cmGlobalXCodeGenerator mainGroup->AddAttribute("sourceTree", this->CreateString("")); cmXCodeObject* sourcesGroup = this->CreateObject(cmXCodeObject::PBXGroup); - this->SourcesGroupChildren = + this->SourcesGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); sourcesGroup->AddAttribute("name", this->CreateString("Sources")); sourcesGroup->AddAttribute("children", this->SourcesGroupChildren); @@ -2609,7 +2603,7 @@ void cmGlobalXCodeGenerator resourcesGroup->AddAttribute("sourceTree", this->CreateString("")); this->MainGroupChildren->AddObject(resourcesGroup); - // now create the cmake groups + // now create the cmake groups this->CreateGroups(root, generators); cmXCodeObject* productGroup = this->CreateObject(cmXCodeObject::PBXGroup); @@ -2619,16 +2613,16 @@ void cmGlobalXCodeGenerator productGroup->AddAttribute("refType", this->CreateString("4")); } productGroup->AddAttribute("sourceTree", this->CreateString("")); - cmXCodeObject* productGroupChildren = + cmXCodeObject* productGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); productGroup->AddAttribute("children", productGroupChildren); this->MainGroupChildren->AddObject(productGroup); - - + + this->RootObject = this->CreateObject(cmXCodeObject::PBXProject); this->RootObject->SetComment("Project object"); group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - this->RootObject->AddAttribute("mainGroup", + this->RootObject->AddAttribute("mainGroup", this->CreateObjectReference(mainGroup)); this->RootObject->AddAttribute("buildSettings", group); this->RootObject->AddAttribute("buildStyles", listObjs); @@ -2655,18 +2649,18 @@ void cmGlobalXCodeGenerator this->CreateString(pdir.c_str())); this->RootObject->AddAttribute("projectRoot", this->CreateString("")); } - cmXCodeObject* configlist = + cmXCodeObject* configlist = this->CreateObject(cmXCodeObject::XCConfigurationList); cmXCodeObject* buildConfigurations = this->CreateObject(cmXCodeObject::OBJECT_LIST); std::vector configs; if(this->XcodeVersion == 15) { - cmXCodeObject* configDebug = + cmXCodeObject* configDebug = this->CreateObject(cmXCodeObject::XCBuildConfiguration); configDebug->AddAttribute("name", this->CreateString("Debug")); configs.push_back(configDebug); - cmXCodeObject* configRelease = + cmXCodeObject* configRelease = this->CreateObject(cmXCodeObject::XCBuildConfiguration); configRelease->AddAttribute("name", this->CreateString("Release")); configs.push_back(configRelease); @@ -2676,7 +2670,7 @@ void cmGlobalXCodeGenerator for(unsigned int i = 0; i < this->CurrentConfigurationTypes.size(); ++i) { const char* name = this->CurrentConfigurationTypes[i].c_str(); - cmXCodeObject* config = + cmXCodeObject* config = this->CreateObject(cmXCodeObject::XCBuildConfiguration); config->AddAttribute("name", this->CreateString(name)); configs.push_back(config); @@ -2694,13 +2688,13 @@ void cmGlobalXCodeGenerator comment += this->CurrentProject; comment += "\""; configlist->SetComment(comment.c_str()); - configlist->AddAttribute("defaultConfigurationIsVisible", + configlist->AddAttribute("defaultConfigurationIsVisible", this->CreateString("0")); - configlist->AddAttribute("defaultConfigurationName", + configlist->AddAttribute("defaultConfigurationName", this->CreateString("Debug")); cmXCodeObject* buildSettings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - const char* osxArch = + const char* osxArch = this->CurrentMakefile->GetDefinition("CMAKE_OSX_ARCHITECTURES"); if(strlen(osxArch) == 0) { @@ -2725,11 +2719,11 @@ void cmGlobalXCodeGenerator this->CreateString("YES")); } - const char* sysroot = + const char* sysroot = this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT"); - const char* sysrootDefault = + const char* sysrootDefault = this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT_DEFAULT"); - const char* deploymentTarget = + const char* deploymentTarget = this->CurrentMakefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); if(osxArch && sysroot) { @@ -2739,22 +2733,24 @@ void cmGlobalXCodeGenerator cmSystemTools::ExpandListArgument(std::string(osxArch), this->Architectures); flagsUsed = true; - buildSettings->AddAttribute("SDKROOT", + buildSettings->AddAttribute("SDKROOT", this->CreateString(sysroot)); std::string archString; - for( std::vector::iterator i = + const char* sep = ""; + for( std::vector::iterator i = this->Architectures.begin(); i != this->Architectures.end(); ++i) { + archString += sep; archString += *i; - archString += " "; + sep = " "; } - buildSettings->AddAttribute("ARCHS", + buildSettings->AddAttribute("ARCHS", this->CreateString(archString.c_str())); if(!flagsUsed && sysrootDefault && strcmp(sysroot, sysrootDefault) != 0) { - buildSettings->AddAttribute("SDKROOT", + buildSettings->AddAttribute("SDKROOT", this->CreateString(sysroot)); } } @@ -2790,7 +2786,7 @@ void cmGlobalXCodeGenerator (*i)->AddAttribute("buildSettings", buildSettings); } - this->RootObject->AddAttribute("buildConfigurationList", + this->RootObject->AddAttribute("buildConfigurationList", this->CreateObjectReference(configlist)); std::vector targets; @@ -2815,7 +2811,7 @@ void cmGlobalXCodeGenerator cmXCodeObject* allTargets = this->CreateObject(cmXCodeObject::OBJECT_LIST); for(std::vector::iterator i = targets.begin(); i != targets.end(); ++i) - { + { cmXCodeObject* t = *i; allTargets->AddObject(t); cmXCodeObject* productRef = t->GetObject("productReference"); @@ -2828,11 +2824,11 @@ void cmGlobalXCodeGenerator } //---------------------------------------------------------------------------- -void +void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::vector& targets) -{ - cmGeneratedFileStream +{ + cmGeneratedFileStream makefileStream(this->CurrentXCodeHackMakefile.c_str()); if(!makefileStream) { @@ -2878,9 +2874,9 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( this->ConvertToRelativeForMake(tfull.c_str()); } } - makefileStream << "\n\n"; + makefileStream << "\n\n"; } - makefileStream + makefileStream << "# For each target create a dummy rule " "so the target does not have to exist\n"; std::set emitted; @@ -2890,7 +2886,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( cmXCodeObject* target = *i; std::map const& deplibs = target->GetDependLibraries(); - for(std::map::const_iterator ci + for(std::map::const_iterator ci = deplibs.begin(); ci != deplibs.end(); ++ci) { for(cmXCodeObject::StringVec::const_iterator d = ci->second.begin(); @@ -2898,7 +2894,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( { if(emitted.insert(*d).second) { - makefileStream << + makefileStream << this->ConvertToRelativeForMake(d->c_str()) << ":\n"; } } @@ -2907,10 +2903,10 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( makefileStream << "\n\n"; // Write rules to help Xcode relink things at the right time. - makefileStream << + makefileStream << "# Rules to remove targets that are older than anything to which they\n" "# link. This forces Xcode to relink the targets from scratch. It\n" - "# does not seem to check these dependencies itself.\n"; + "# does not seem to check these dependencies itself.\n"; for(std::vector::const_iterator ct = this->CurrentConfigurationTypes.begin(); ct != this->CurrentConfigurationTypes.end(); ++ct) @@ -2931,7 +2927,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( { // Create a rule for this target. std::string tfull = t->GetFullPath(configName); - makefileStream << this->ConvertToRelativeForMake(tfull.c_str()) + makefileStream << this->ConvertToRelativeForMake(tfull.c_str()) << ":"; // List dependencies if any exist. @@ -2943,7 +2939,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( for(std::vector::const_iterator d = deplibs.begin(); d != deplibs.end(); ++d) { - makefileStream << "\\\n\t" << + makefileStream << "\\\n\t" << this->ConvertToRelativeForMake(d->c_str()); } } @@ -2965,7 +2961,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( universal += "/"; universal += t->GetName(); universal += ".build/Objects-normal/"; - for( std::vector::iterator arch = + for( std::vector::iterator arch = this->Architectures.begin(); arch != this->Architectures.end(); ++arch) { @@ -2974,7 +2970,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( universalFile += "/"; universalFile += t->GetFullName(configName); makefileStream << "\t/bin/rm -f " - << + << this->ConvertToRelativeForMake(universalFile.c_str()) << "\n"; } @@ -2988,7 +2984,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root, - std::vector& + std::vector& generators) { if(generators.size() == 0) @@ -3028,7 +3024,7 @@ cmGlobalXCodeGenerator::OutputXCodeProject(cmLocalGenerator* root, } //---------------------------------------------------------------------------- -void +void cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout, cmLocalGenerator* , std::vector& ) @@ -3086,7 +3082,7 @@ std::string cmGlobalXCodeGenerator::ConvertToRelativeForMake(const char* p) } else { - std::string ret = + std::string ret = this->CurrentLocalGenerator-> ConvertToRelativePath(this->CurrentOutputDirectoryComponents, p); return cmSystemTools::ConvertToOutputPath(ret.c_str()); @@ -3102,7 +3098,7 @@ std::string cmGlobalXCodeGenerator::ConvertToRelativeForXCode(const char* p) } else { - std::string ret = + std::string ret = this->CurrentLocalGenerator-> ConvertToRelativePath(this->ProjectOutputDirectoryComponents, p); return cmSystemTools::ConvertToOutputPath(ret.c_str()); @@ -3142,7 +3138,7 @@ std::string cmGlobalXCodeGenerator::XCodeEscapePath(const char* p) //---------------------------------------------------------------------------- void cmGlobalXCodeGenerator:: GetTargetObjectFileDirectories(cmTarget* target, - std::vector& + std::vector& dirs) { std::string dir = this->CurrentMakefile->GetCurrentOutputDirectory(); @@ -3156,7 +3152,7 @@ GetTargetObjectFileDirectories(cmTarget* target, std::string dirsave = dir; if(this->Architectures.size()) { - for(std::vector::iterator i = this->Architectures.begin(); + for(std::vector::iterator i = this->Architectures.begin(); i != this->Architectures.end(); ++i) { dir += *i; diff --git a/Source/cmGraphAdjacencyList.h b/Source/cmGraphAdjacencyList.h index 779484012..0149d33bd 100644 --- a/Source/cmGraphAdjacencyList.h +++ b/Source/cmGraphAdjacencyList.h @@ -14,7 +14,27 @@ #include "cmStandardIncludes.h" +/** + * Graph edge representation. Most use cases just need the + * destination vertex, so we support conversion to/from an int. We + * also store boolean to indicate whether an edge is "strong". + */ +class cmGraphEdge +{ +public: + cmGraphEdge(): Dest(0), Strong(true) {} + cmGraphEdge(int n): Dest(n), Strong(true) {} + cmGraphEdge(int n, bool s): Dest(n), Strong(s) {} + cmGraphEdge(cmGraphEdge const& r): Dest(r.Dest), Strong(r.Strong) {} + operator int() const { return this->Dest; } + + bool IsStrong() const { return this->Strong; } +private: + int Dest; + bool Strong; +}; +struct cmGraphEdgeList: public std::vector {}; struct cmGraphNodeList: public std::vector {}; -struct cmGraphAdjacencyList: public std::vector {}; +struct cmGraphAdjacencyList: public std::vector {}; #endif diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index 1c1444bb1..9e6f4b6ef 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -63,7 +63,7 @@ bool cmIncludeDirectoryCommand // " /foo/bar // /boo/hoo /dingle/berry " // -// ideally that should be three seperate arguments but when sucking the +// ideally that should be three separate arguments but when sucking the // output from a program and passing it into a command the cleanup doesn't // always happen // diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h index ea0a1ece3..8f6232272 100644 --- a/Source/cmInstallCommand.h +++ b/Source/cmInstallCommand.h @@ -175,6 +175,7 @@ public: "The EXPORT option associates the installed target files with an " "export called . " "It must appear before any RUNTIME, LIBRARY, or ARCHIVE options. " + "To actually install the export file itself, call install(EXPORT). " "See documentation of the install(EXPORT ...) signature below for " "details." "\n" diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 47ca769fe..d7505dc9f 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -60,6 +60,29 @@ void cmInstallGenerator } os << indent; std::string dest = this->GetInstallDestination(); + if (cmSystemTools::FileIsFullPath(dest.c_str())) + { + os << "list(APPEND CPACK_ABSOLUTE_DESTINATION_FILES\n"; + os << indent << " \""; + for(std::vector::const_iterator fi = files.begin(); + fi != files.end(); ++fi) + { + if (fi!=files.begin()) + { + os << ";"; + } + os << dest << "/"; + if (rename && *rename) + { + os << rename; + } + else + { + os << cmSystemTools::GetFilenameName(*fi); + } + } + os << "\")\n"; + } os << "FILE(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str(); if(optional) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 13d875f9f..5bffd5236 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -278,16 +278,8 @@ void cmLocalGenerator::GenerateTestFiles() // Compute the set of configurations. std::vector configurationTypes; - if(const char* types = - this->Makefile->GetDefinition("CMAKE_CONFIGURATION_TYPES")) - { - cmSystemTools::ExpandListArgument(types, configurationTypes); - } - const char* config = 0; - if(configurationTypes.empty()) - { - config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); - } + const char* config = + this->Makefile->GetConfigurations(configurationTypes, false); std::string file = this->Makefile->GetStartOutputDirectory(); file += "/"; @@ -383,16 +375,8 @@ void cmLocalGenerator::GenerateInstallRules() // Compute the set of configurations. std::vector configurationTypes; - if(const char* types = - this->Makefile->GetDefinition("CMAKE_CONFIGURATION_TYPES")) - { - cmSystemTools::ExpandListArgument(types, configurationTypes); - } - const char* config = 0; - if(configurationTypes.empty()) - { - config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); - } + const char* config = + this->Makefile->GetConfigurations(configurationTypes, false); // Choose a default install configuration. const char* default_config = config; @@ -546,19 +530,7 @@ void cmLocalGenerator::GenerateTargetManifest() { // Collect the set of configuration types. std::vector configNames; - if(const char* configurationTypes = - this->Makefile->GetDefinition("CMAKE_CONFIGURATION_TYPES")) - { - cmSystemTools::ExpandListArgument(configurationTypes, configNames); - } - else if(const char* buildType = - this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) - { - if(*buildType) - { - configNames.push_back(buildType); - } - } + this->Makefile->GetConfigurations(configNames); // Add our targets to the manifest for each configuration. cmTargets& targets = this->Makefile->GetTargets(); @@ -2810,17 +2782,29 @@ cmLocalGenerator std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str) { std::string result; - bool forceOn = cmSystemTools::GetForceUnixPaths(); - if(forceOn && this->WindowsShell) +#if defined(_WIN32) && !defined(__CYGWIN__) + // if there are spaces + std::string temp = str; + if (temp.find(" ") != std::string::npos && + temp.find("\"")==std::string::npos) { - cmSystemTools::SetForceUnixPaths(false); + result = "\""; + result += str; + result += "\""; + return result; } - result = cmSystemTools::EscapeSpaces(str); - if(forceOn && this->WindowsShell) + return str; +#else + for(const char* ch = str; *ch != '\0'; ++ch) { - cmSystemTools::SetForceUnixPaths(true); + if(*ch == ' ') + { + result += '\\'; + } + result += *ch; } return result; +#endif } //---------------------------------------------------------------------------- @@ -3045,7 +3029,7 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const if(define.find_first_of("#") != define.npos) { cmOStringStream e; - e << "WARNING: Peprocessor definitions containing '#' may not be " + e << "WARNING: Preprocessor definitions containing '#' may not be " << "passed on the compiler command line because many compilers " << "do not support it.\n" << "CMake is dropping a preprocessor definition: " << define << "\n" diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 004d19a2d..f04d0a0ad 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1062,9 +1062,16 @@ cmLocalUnixMakefileGenerator3 } } } - if (useCall && launcher.empty()) + if (launcher.empty()) { - cmd = "call " + cmd; + if (useCall) + { + cmd = "call " + cmd; + } + else if (this->NMake && cmd[0]=='"') + { + cmd = "echo >nul && " + cmd; + } } commands1.push_back(cmd); } diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index 8df0ffaff..57d8653c4 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -37,7 +37,7 @@ class cmVS10XMLParser : public cmXMLParser { return; } - if(strcmp("ProjectGUID", name) == 0) + if(strcmp("ProjectGUID", name) == 0 || strcmp("ProjectGuid", name) == 0) { this->DoGUID = true; } diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 539816d3c..eb4e4a4f2 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1187,7 +1187,8 @@ void cmLocalVisualStudio6Generator extraLinkOptionsMinSizeRel += targetLinkFlags; } - if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_RELWITHDEBINFO")) + if(const char* targetLinkFlags = + target.GetProperty("LINK_FLAGS_RELWITHDEBINFO")) { extraLinkOptionsRelWithDebInfo += " "; extraLinkOptionsRelWithDebInfo += targetLinkFlags; @@ -1304,7 +1305,8 @@ void cmLocalVisualStudio6Generator optionsRelease); this->ComputeLinkOptions(target, "MinSizeRel", extraLinkOptionsMinSizeRel, optionsMinSizeRel); - this->ComputeLinkOptions(target, "RelWithDebInfo", extraLinkOptionsRelWithDebInfo, + this->ComputeLinkOptions(target, "RelWithDebInfo", + extraLinkOptionsRelWithDebInfo, optionsRelWithDebInfo); } diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index e411d3e54..cb34bb6cf 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -466,6 +466,8 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = {"GenerateManifest", "MANIFEST", "enable manifest generation", "TRUE", 0}, {"LinkIncremental", "INCREMENTAL:NO", "link incremental", "1", 0}, {"LinkIncremental", "INCREMENTAL:YES", "link incremental", "2", 0}, + {"EntryPointSymbol", "ENTRY:", "sets the starting address", "", + cmVS7FlagTable::UserValue}, {"IgnoreDefaultLibraryNames", "NODEFAULTLIB:", "default libs to ignore", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable}, {"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "ignore all default libs", @@ -480,6 +482,21 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = {"OptimizeReferences", "OPT:REF", "Eliminate unreferenced data", "2", 0}, {"TargetMachine", "MACHINE:I386", "Machine x86", "1", 0}, {"TargetMachine", "MACHINE:X86", "Machine x86", "1", 0}, + {"TargetMachine", "MACHINE:AM33", "Machine AM33", "2", 0}, + {"TargetMachine", "MACHINE:ARM", "Machine ARM", "3", 0}, + {"TargetMachine", "MACHINE:EBC", "Machine EBC", "4", 0}, + {"TargetMachine", "MACHINE:IA64", "Machine IA64", "5", 0}, + {"TargetMachine", "MACHINE:M32R", "Machine M32R", "6", 0}, + {"TargetMachine", "MACHINE:MIPS", "Machine MIPS", "7", 0}, + {"TargetMachine", "MACHINE:MIPS16", "Machine MIPS16", "8", 0}, + {"TargetMachine", "MACHINE:MIPSFPU)", "Machine MIPSFPU", "9", 0}, + {"TargetMachine", "MACHINE:MIPSFPU16", "Machine MIPSFPU16", "10", 0}, + {"TargetMachine", "MACHINE:MIPSR41XX", "Machine MIPSR41XX", "11", 0}, + {"TargetMachine", "MACHINE:SH3", "Machine SH3", "12", 0}, + {"TargetMachine", "MACHINE:SH3DSP", "Machine SH3DSP", "13", 0}, + {"TargetMachine", "MACHINE:SH4", "Machine SH4", "14", 0}, + {"TargetMachine", "MACHINE:SH5", "Machine SH5", "15", 0}, + {"TargetMachine", "MACHINE:THUMB", "Machine THUMB", "16", 0}, {"TargetMachine", "MACHINE:X64", "Machine x64", "17", 0}, {"ModuleDefinitionFile", "DEF:", "add an export def file", "", cmVS7FlagTable::UserValue}, diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8eece6b5a..56e0ed933 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -353,7 +353,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, // No error. return result; } - + std::string name = lff.Name; // Place this call on the call stack. @@ -377,7 +377,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, cmOStringStream msg; msg << lff.FilePath << "(" << lff.Line << "): "; msg << lff.Name << "("; - for(std::vector::const_iterator i = + for(std::vector::const_iterator i = lff.Arguments.begin(); i != lff.Arguments.end(); ++i) { msg << i->Value; @@ -610,6 +610,8 @@ bool cmMakefile::ReadListFile(const char* filename_in, } this->AddDefinition("CMAKE_CURRENT_LIST_FILE", filenametoread); + this->AddDefinition("CMAKE_CURRENT_LIST_DIR", + cmSystemTools::GetFilenamePath(filenametoread).c_str()); // try to see if the list file is the top most // list file for a project, and if it is, then it @@ -643,6 +645,8 @@ bool cmMakefile::ReadListFile(const char* filename_in, } this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str()); this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str()); + this->AddDefinition("CMAKE_CURRENT_LIST_DIR", + cmSystemTools::GetFilenamePath(currentFile).c_str()); return false; } // add this list file to the list of dependencies @@ -683,6 +687,8 @@ bool cmMakefile::ReadListFile(const char* filename_in, this->AddDefinition("CMAKE_PARENT_LIST_FILE", currentParentFile.c_str()); this->AddDefinition("CMAKE_CURRENT_LIST_FILE", currentFile.c_str()); + this->AddDefinition("CMAKE_CURRENT_LIST_DIR", + cmSystemTools::GetFilenamePath(currentFile).c_str()); // pop the listfile off the stack this->ListFileStack.pop_back(); @@ -894,6 +900,14 @@ cmMakefile::AddCustomCommandToOutput(const std::vector& outputs, // Construct a rule file associated with the first output produced. std::string outName = outputs[0]; outName += ".rule"; + const char* dir = + this->LocalGenerator->GetGlobalGenerator()-> + GetCMakeCFGInitDirectory(); + if(dir && dir[0] == '$') + { + cmSystemTools::ReplaceString(outName, dir, + cmake::GetCMakeFilesDirectory()); + } // Check if the rule file already exists. file = this->GetSource(outName.c_str()); if(file && file->GetCustomCommand() && !replace) @@ -1436,16 +1450,7 @@ void cmMakefile::InitializeFromParent() this->SetProperty("COMPILE_DEFINITIONS", parent->GetProperty("COMPILE_DEFINITIONS")); std::vector configs; - if(const char* configTypes = - this->GetDefinition("CMAKE_CONFIGURATION_TYPES")) - { - cmSystemTools::ExpandListArgument(configTypes, configs); - } - else if(const char* buildType = - this->GetDefinition("CMAKE_BUILD_TYPE")) - { - configs.push_back(buildType); - } + this->GetConfigurations(configs); for(std::vector::const_iterator ci = configs.begin(); ci != configs.end(); ++ci) { @@ -1743,8 +1748,8 @@ void cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, bool excludeFromAll) { // wrong type ? default to STATIC - if ( (type != cmTarget::STATIC_LIBRARY) - && (type != cmTarget::SHARED_LIBRARY) + if ( (type != cmTarget::STATIC_LIBRARY) + && (type != cmTarget::SHARED_LIBRARY) && (type != cmTarget::MODULE_LIBRARY)) { type = cmTarget::STATIC_LIBRARY; @@ -2326,14 +2331,14 @@ void cmMakefile::AddDefaultDefinitions() { /* Up to CMake 2.4 here only WIN32, UNIX and APPLE were set. With CMake must separate between target and host platform. In most cases - the tests for WIN32, UNIX and APPLE will be for the target system, so an + the tests for WIN32, UNIX and APPLE will be for the target system, so an additional set of variables for the host system is required -> CMAKE_HOST_WIN32, CMAKE_HOST_UNIX, CMAKE_HOST_APPLE. - WIN32, UNIX and APPLE are now set in the platform files in + WIN32, UNIX and APPLE are now set in the platform files in Modules/Platforms/. To keep cmake scripts (-P) and custom language and compiler modules working, these variables are still also set here in this place, but they - will be reset in CMakeSystemSpecificInformation.cmake before the platform + will be reset in CMakeSystemSpecificInformation.cmake before the platform files are executed. */ #if defined(_WIN32) || defined(__CYGWIN__) this->AddDefinition("WIN32", "1"); @@ -2367,6 +2372,31 @@ void cmMakefile::AddDefaultDefinitions() cmake::GetCMakeFilesDirectory()); } +//---------------------------------------------------------------------------- +const char* +cmMakefile::GetConfigurations(std::vector& configs, + bool single) const +{ + if(this->LocalGenerator->GetGlobalGenerator()->IsMultiConfig()) + { + if(const char* configTypes = + this->GetDefinition("CMAKE_CONFIGURATION_TYPES")) + { + cmSystemTools::ExpandListArgument(configTypes, configs); + } + return 0; + } + else + { + const char* buildType = this->GetDefinition("CMAKE_BUILD_TYPE"); + if(single && buildType && *buildType) + { + configs.push_back(buildType); + } + return buildType; + } +} + #if defined(CMAKE_BUILD_WITH_CMAKE) /** * Find a source group whose regular expression matches the filename @@ -2619,13 +2649,13 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName, } } -void cmMakefile::EnableLanguage(std::vector const & lang, +void cmMakefile::EnableLanguage(std::vector const & lang, bool optional) { this->AddDefinition("CMAKE_CFG_INTDIR", this->LocalGenerator->GetGlobalGenerator() ->GetCMakeCFGInitDirectory()); - this->LocalGenerator->GetGlobalGenerator()->EnableLanguage(lang, this, + this->LocalGenerator->GetGlobalGenerator()->EnableLanguage(lang, this, optional); } @@ -2701,7 +2731,7 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir, { cm.AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS", "FALSE", "", cmCacheManager::INTERNAL); - } + } if (cm.Configure() != 0) { cmSystemTools::Error( @@ -2989,7 +3019,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value) { return; } - + // handle special props std::string propname = prop; if ( propname == "INCLUDE_DIRECTORIES" ) @@ -3013,7 +3043,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value) this->SetLinkDirectories(varArgsExpanded); return; } - + if ( propname == "INCLUDE_REGULAR_EXPRESSION" ) { this->SetIncludeRegularExpression(value); @@ -3023,7 +3053,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value) if ( propname == "ADDITIONAL_MAKE_CLEAN_FILES" ) { // This property is not inherrited - if ( strcmp(this->GetCurrentDirectory(), + if ( strcmp(this->GetCurrentDirectory(), this->GetStartDirectory()) != 0 ) { return; @@ -3144,14 +3174,14 @@ const char *cmMakefile::GetProperty(const char* prop, return output.c_str(); } else if (!strcmp("DEFINITIONS",prop)) - { + { output += this->DefineFlagsOrig; return output.c_str(); } else if (!strcmp("INCLUDE_DIRECTORIES",prop) ) { cmOStringStream str; - for (std::vector::const_iterator + for (std::vector::const_iterator it = this->GetIncludeDirectories().begin(); it != this->GetIncludeDirectories().end(); ++ it ) @@ -3168,7 +3198,7 @@ const char *cmMakefile::GetProperty(const char* prop, else if (!strcmp("LINK_DIRECTORIES",prop)) { cmOStringStream str; - for (std::vector::const_iterator + for (std::vector::const_iterator it = this->GetLinkDirectories().begin(); it != this->GetLinkDirectories().end(); ++ it ) @@ -3582,7 +3612,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, msg = e.str(); return false; } - else + else { // target names must be globally unique switch (this->GetPolicyStatus(cmPolicies::CMP0002)) @@ -3601,7 +3631,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, case cmPolicies::NEW: break; } - + // The conflict is with a non-imported target. // Allow this if the user has requested support. cmake* cm = @@ -3750,7 +3780,7 @@ cmMakefile::GetPolicyStatusInternal(cmPolicies::PolicyID id) return this->GetPolicies()->GetPolicyStatus(id); } -bool cmMakefile::SetPolicy(const char *id, +bool cmMakefile::SetPolicy(const char *id, cmPolicies::PolicyStatus status) { cmPolicies::PolicyID pid; @@ -3880,7 +3910,7 @@ bool cmMakefile::SetPolicyVersion(const char *version) } cmPolicies *cmMakefile::GetPolicies() -{ +{ if (!this->GetCMakeInstance()) { return 0; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 4fae7eee2..8b8a3f858 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -309,7 +309,11 @@ public: { return this->ProjectName.c_str(); } - + + /** Get the configurations to be generated. */ + const char* GetConfigurations(std::vector& configs, + bool single = true) const; + /** * Set the name of the library. */ diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 93c981aa0..a5e319dd0 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -345,6 +345,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) vars.CMTarget = this->Target; vars.Language = linkLanguage; vars.Objects = buildObjs.c_str(); + std::string objdir = cmake::GetCMakeFilesDirectoryPostSlash(); + objdir += this->Target->GetName(); + objdir += ".dir"; + objdir = this->Convert(objdir.c_str(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL); + vars.ObjectDir = objdir.c_str(); vars.Target = targetOutPathReal.c_str(); vars.TargetPDB = targetOutPathPDB.c_str(); diff --git a/Source/cmOptionCommand.h b/Source/cmOptionCommand.h index 8670fc420..fa5abd87c 100644 --- a/Source/cmOptionCommand.h +++ b/Source/cmOptionCommand.h @@ -59,7 +59,10 @@ public: " option( \"help string describing option\"\n" " [initial value])\n" "Provide an option for the user to select as ON or OFF. If no " - "initial value is provided, OFF is used."; + "initial value is provided, OFF is used.\n" + "If you have options that depend on the values of other " + "options, see the module help for CMakeDependentOption." + ; } /** diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 69d3e5197..3fe92de7c 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -15,8 +15,8 @@ const char* cmPolicies::PolicyStatusNames[] = { class cmPolicy { -public: - cmPolicy(cmPolicies::PolicyID iD, +public: + cmPolicy(cmPolicies::PolicyID iD, const char *idString, const char *shortDescription, const char *longDescription, @@ -55,7 +55,7 @@ public: return v.str(); } - bool IsPolicyNewerThan(unsigned int majorV, + bool IsPolicyNewerThan(unsigned int majorV, unsigned int minorV, unsigned int patchV, unsigned int tweakV) @@ -86,7 +86,7 @@ public: } return (tweakV < this->TweakVersionIntroduced); } - + cmPolicies::PolicyID ID; std::string IDString; std::string ShortDescription; @@ -285,12 +285,12 @@ cmPolicies::cmPolicies() "The NEW behavior for this policy is to produce an error if a bundle " "target is installed without a BUNDLE DESTINATION.", 2,6,0,0, cmPolicies::WARN); - + this->DefinePolicy( CMP0007, "CMP0007", "list command no longer ignores empty elements.", "This policy determines whether the list command will " - "ignore empty elements in the list. " + "ignore empty elements in the list. " "CMake 2.4 and below list commands ignored all empty elements" " in the list. For example, a;b;;c would have length 3 and not 4. " "The OLD behavior for this policy is to ignore empty list elements. " @@ -426,7 +426,7 @@ cmPolicies::cmPolicies() this->DefinePolicy( CMP0015, "CMP0015", "link_directories() treats paths relative to the source dir.", - "In CMake 2.6.4 and lower the link_directories() command passed relative " + "In CMake 2.8.0 and lower the link_directories() command passed relative " "paths unchanged to the linker. " "In CMake 2.8.1 and above the link_directories() command prefers to " "interpret relative paths with respect to CMAKE_CURRENT_SOURCE_DIR, " @@ -437,12 +437,21 @@ cmPolicies::cmPolicies() "absolute paths by appending the relative path to " "CMAKE_CURRENT_SOURCE_DIR.", 2,8,1,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0016, "CMP0016", + "target_link_libraries() reports error if only argument is not a target.", + "In CMake 2.8.2 and lower the target_link_libraries() command silently " + "ignored if it was called with only one argument, and this argument " + "wasn't a valid target. " + "In CMake 2.8.3 and above it reports an error in this case.", + 2,8,3,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() { // free the policies - std::map::iterator i + std::map::iterator i = this->Policies.begin(); for (;i != this->Policies.end(); ++i) { @@ -451,7 +460,7 @@ cmPolicies::~cmPolicies() } void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD, - const char *idString, + const char *idString, const char *shortDescription, const char *longDescription, unsigned int majorVersionIntroduced, @@ -467,7 +476,7 @@ void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD, "ID ", this->GetPolicyIDString(iD).c_str()); return; } - + this->Policies[iD] = new cmPolicy(iD, idString, shortDescription, longDescription, @@ -480,7 +489,7 @@ void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD, } //---------------------------------------------------------------------------- -bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, +bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, const char *version) { std::string ver = "2.4.0"; @@ -505,7 +514,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, mf->IssueMessage(cmake::FATAL_ERROR, e.str()); return false; } - + // it is an error if the policy version is less than 2.4 if (majorVer < 2 || (majorVer == 2 && minorVer < 4)) { @@ -547,7 +556,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf, // now loop over all the policies and set them as appropriate std::vector ancientPolicies; - std::map::iterator i + std::map::iterator i = this->Policies.begin(); for (;i != this->Policies.end(); ++i) { @@ -589,7 +598,7 @@ bool cmPolicies::GetPolicyID(const char *id, cmPolicies::PolicyID &pid) { return false; } - std::map::iterator pos = + std::map::iterator pos = this->PolicyStringMap.find(id); if (pos == this->PolicyStringMap.end()) { @@ -601,7 +610,7 @@ bool cmPolicies::GetPolicyID(const char *id, cmPolicies::PolicyID &pid) std::string cmPolicies::GetPolicyIDString(cmPolicies::PolicyID pid) { - std::map::iterator pos = + std::map::iterator pos = this->Policies.find(pid); if (pos == this->Policies.end()) { @@ -614,7 +623,7 @@ std::string cmPolicies::GetPolicyIDString(cmPolicies::PolicyID pid) ///! return a warning string for a given policy std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id) { - std::map::iterator pos = + std::map::iterator pos = this->Policies.find(id); if (pos == this->Policies.end()) { @@ -633,12 +642,12 @@ std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id) "and suppress this warning."; return msg.str(); } - - + + ///! return an error string for when a required policy is unspecified std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id) { - std::map::iterator pos = + std::map::iterator pos = this->Policies.find(id); if (pos == this->Policies.end()) { @@ -664,25 +673,25 @@ std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id) } ///! Get the default status for a policy -cmPolicies::PolicyStatus +cmPolicies::PolicyStatus cmPolicies::GetPolicyStatus(cmPolicies::PolicyID id) { // if the policy is not know then what? - std::map::iterator pos = + std::map::iterator pos = this->Policies.find(id); if (pos == this->Policies.end()) { // TODO is this right? return cmPolicies::WARN; } - + return pos->second->Status; } void cmPolicies::GetDocumentation(std::vector& v) { // now loop over all the policies and set them as appropriate - std::map::iterator i + std::map::iterator i = this->Policies.begin(); for (;i != this->Policies.end(); ++i) { diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 23064dc34..fce33ac04 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -51,6 +51,7 @@ public: CMP0013, // Duplicate binary directories not allowed CMP0014, // Input directories must have CMakeLists.txt CMP0015, // link_directories() treats paths relative to source dir + CMP0016, // target_link_libraries() fails if only argument is not a target // Always the last entry. Useful mostly to avoid adding a comma // the last policy when adding a new one. @@ -60,10 +61,10 @@ public: ///! convert a string policy ID into a number bool GetPolicyID(const char *id, /* out */ cmPolicies::PolicyID &pid); std::string GetPolicyIDString(cmPolicies::PolicyID pid); - + ///! Get the default status for a policy cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id); - + ///! Define a Policy for CMake void DefinePolicy(cmPolicies::PolicyID id, const char *stringID, @@ -80,7 +81,7 @@ public: ///! return a warning string for a given policy std::string GetPolicyWarning(cmPolicies::PolicyID id); - + ///! return an error string for when a required policy is unspecified std::string GetRequiredPolicyError(cmPolicies::PolicyID id); diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h index fca5f1fc9..fc2b7a2bd 100644 --- a/Source/cmProjectCommand.h +++ b/Source/cmProjectCommand.h @@ -66,7 +66,7 @@ public: "Optionally you can specify which languages your project supports. " "Example languages are CXX (i.e. C++), C, Fortran, etc. " "By default C and CXX are enabled. E.g. if you do not have a " - "C++ compiler, you can disable the check for it by explicitely listing " + "C++ compiler, you can disable the check for it by explicitly listing " "the languages you want to support, e.g. C. By using the special " "language \"NONE\" all checks for any language can be disabled."; } diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx index 5fcbdba0a..d00fc86cf 100644 --- a/Source/cmSetCommand.cxx +++ b/Source/cmSetCommand.cxx @@ -99,7 +99,7 @@ bool cmSetCommand } } - // collect any values into a single semi-colon seperated value list + // collect any values into a single semi-colon separated value list if(static_cast(args.size()) > static_cast(1 + ignoreLastArgs)) { diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index bc52d7fd2..b793cd5fb 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -101,11 +101,11 @@ cmSourceFileLocation const& cmSourceFile::GetLocation() const } //---------------------------------------------------------------------------- -std::string const& cmSourceFile::GetFullPath() +std::string const& cmSourceFile::GetFullPath(std::string* error) { if(this->FullPath.empty()) { - if(this->FindFullPath()) + if(this->FindFullPath(error)) { this->CheckExtension(); } @@ -120,7 +120,7 @@ std::string const& cmSourceFile::GetFullPath() const } //---------------------------------------------------------------------------- -bool cmSourceFile::FindFullPath() +bool cmSourceFile::FindFullPath(std::string* error) { // If thie method has already failed once do not try again. if(this->FindFullPathFailed) @@ -199,7 +199,14 @@ bool cmSourceFile::FindFullPath() { e << " ." << *ext; } - this->Location.GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + if(error) + { + *error = e.str(); + } + else + { + this->Location.GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + } this->FindFullPathFailed = true; return false; } diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 937e4b736..2dc848815 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -60,7 +60,7 @@ public: * horrible interface, but is necessary for backwards * compatibility). */ - std::string const& GetFullPath(); + std::string const& GetFullPath(std::string* error = 0); std::string const& GetFullPath() const; /** @@ -108,7 +108,7 @@ private: std::string FullPath; bool FindFullPathFailed; - bool FindFullPath(); + bool FindFullPath(std::string* error); bool TryFullPath(const char* tryPath, const char* ext); void CheckExtension(); void CheckLanguage(std::string const& ext); diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 3bd47a433..19f5c0f22 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -739,7 +739,7 @@ bool cmStringCommand alphabet = cmStringCommandDefaultAlphabet; } - double sizeofAlphabet = alphabet.size(); + double sizeofAlphabet = static_cast(alphabet.size()); if ( sizeofAlphabet < 1 ) { this->SetError("sub-command RANDOM invoked with bad alphabet."); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 5f7cfa398..7bc89a4c4 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -23,8 +23,8 @@ #include #include #if defined(CMAKE_BUILD_WITH_CMAKE) -#include -#include +# include "cmArchiveWrite.h" +# include # include #endif #include @@ -191,49 +191,6 @@ std::string cmSystemTools::EscapeQuotes(const char* str) return result; } -std::string cmSystemTools::EscapeSpaces(const char* str) -{ -#if defined(_WIN32) && !defined(__CYGWIN__) - bool useDoubleQ = true; -#else - bool useDoubleQ = false; -#endif - if(cmSystemTools::s_ForceUnixPaths) - { - useDoubleQ = false; - } - - if(useDoubleQ) - { - std::string result; - - // if there are spaces - std::string temp = str; - if (temp.find(" ") != std::string::npos && - temp.find("\"")==std::string::npos) - { - result = "\""; - result += str; - result += "\""; - return result; - } - return str; - } - else - { - std::string result = ""; - for(const char* ch = str; *ch != '\0'; ++ch) - { - if(*ch == ' ') - { - result += '\\'; - } - result += *ch; - } - return result; - } -} - void cmSystemTools::Error(const char* m1, const char* m2, const char* m3, const char* m4) { @@ -326,7 +283,22 @@ void cmSystemTools::ReportLastSystemError(const char* msg) cmSystemTools::Error(m.c_str()); } - +bool cmSystemTools::IsInternallyOn(const char* val) +{ + if (!val) + { + return false; + } + std::basic_string v = val; + + for(std::basic_string::iterator c = v.begin(); + c != v.end(); c++) + { + *c = static_cast(toupper(*c)); + } + return (v == "I_ON" || v == "i_on"); +} + bool cmSystemTools::IsOn(const char* val) { if (!val) @@ -1204,6 +1176,8 @@ bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) // 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() @@ -1212,10 +1186,9 @@ bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out) while(fin) { fin.read(buffer, bufferSize); - if(fin.gcount()) + if(int gcount = static_cast(fin.gcount())) { - cmsysMD5_Append(md5, reinterpret_cast(buffer), - fin.gcount()); + cmsysMD5_Append(md5, buffer_uc, gcount); } } cmsysMD5_FinalizeHex(md5, md5out); @@ -1719,142 +1692,41 @@ bool cmSystemTools::CreateTar(const char* outFileName, bool gzip, bool bzip2, bool verbose) { #if defined(CMAKE_BUILD_WITH_CMAKE) - - // Create a macro to handle return from libarchive - // functions -#define CHECK_ARCHIVE_ERROR(res, msg)\ - if(res != ARCHIVE_OK)\ - {\ - cmSystemTools::Error(msg, \ - archive_error_string(a));\ - return false;\ - } - std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); - // recursively expand all directories in files so that we have a list - // of files - std::vector expandedFiles; + std::ofstream fout(outFileName, std::ios::out | cmsys_ios_binary); + if(!fout) + { + std::string e = "Cannot open output file \""; + e += outFileName; + e += "\": "; + e += cmSystemTools::GetLastSystemError(); + cmSystemTools::Error(e.c_str()); + return false; + } + cmArchiveWrite a(fout, (gzip? cmArchiveWrite::CompressGZip : + (bzip2? cmArchiveWrite::CompressBZip2 : + cmArchiveWrite::CompressNone)), + cmArchiveWrite::TypeTAR); + a.SetVerbose(verbose); for(std::vector::const_iterator i = files.begin(); i != files.end(); ++i) { - if(cmSystemTools::FileIsDirectory(i->c_str())) + std::string path = *i; + if(cmSystemTools::FileIsFullPath(path.c_str())) { - cmsys::Glob gl; - std::string findExpr = *i; - if ( findExpr[findExpr.size()-1] != '/' ) - { - findExpr +="/"; - } - findExpr += "*"; - gl.RecurseOn(); - if ( gl.FindFiles(findExpr) ) - { - std::vector dirfiles = gl.GetFiles(); - std::copy(dirfiles.begin(), dirfiles.end(), - std::back_inserter(expandedFiles)); - } + // Get the relative path to the file. + path = cmSystemTools::RelativePath(cwd.c_str(), path.c_str()); } - else + if(!a.Add(path)) { - if(!cmSystemTools::FileIsFullPath(i->c_str())) - { - std::string fullp = cwd + "/" + *i; - expandedFiles.push_back(fullp); - } - else - { - expandedFiles.push_back(*i); - } + break; } } - int res; - // create a new archive - struct archive* a = archive_write_new(); if(!a) { - cmSystemTools::Error("Unable to use create archive"); + cmSystemTools::Error(a.GetError().c_str()); return false; } - - if(gzip) - { - res = archive_write_set_compression_gzip(a); - CHECK_ARCHIVE_ERROR(res, "Can not set gzip:"); - } - if(bzip2) - { - res = archive_write_set_compression_bzip2(a); - CHECK_ARCHIVE_ERROR(res, "Can not set bzip2:"); - } - if(!bzip2 && !gzip) - { - res = archive_write_set_compression_none(a); - CHECK_ARCHIVE_ERROR(res, "Can not set none:"); - } - res = archive_write_set_format_pax_restricted(a); - CHECK_ARCHIVE_ERROR(res, "Can not set tar format:"); - res = archive_write_open_file(a, outFileName); - CHECK_ARCHIVE_ERROR(res, "write open:"); - // create a new disk struct - struct archive* disk = archive_read_disk_new(); - archive_read_disk_set_standard_lookup(disk); - std::vector::const_iterator fileIt; - for ( fileIt = expandedFiles.begin(); - fileIt != expandedFiles.end(); ++ fileIt ) - { - // create a new entry for each file - struct archive_entry *entry = archive_entry_new(); - // Get the relative path to the file - std::string rp = cmSystemTools::RelativePath(cwd.c_str(), - fileIt->c_str()); - if(verbose) - { - std::cout << rp << "\n"; - } - // Set the name of the entry to the file name - archive_entry_set_pathname(entry, rp.c_str()); - archive_read_disk_entry_from_file(disk, entry, -1, 0); - CHECK_ARCHIVE_ERROR(res, "read disk entry:"); - - // write entry header - res = archive_write_header(a, entry); - CHECK_ARCHIVE_ERROR(res, "write header: "); - if(archive_entry_size(entry) > 0) - { - // now copy contents of file into archive a - FILE* file = fopen(fileIt->c_str(), "rb"); - if(!file) - { - cmSystemTools::Error("Problem with fopen(): ", - fileIt->c_str()); - return false; - } - char buff[16384]; - size_t len = fread(buff, 1, sizeof(buff), file); - while (len > 0) - { - size_t wlen = archive_write_data(a, buff, len); - if(wlen != len) - { - cmOStringStream error; - error << "Problem with archive_write_data\n" - << "Tried to write [" << len << "] bytes.\n" - << "archive_write_data wrote [" << wlen << "] bytes.\n"; - cmSystemTools::Error(error.str().c_str(), - archive_error_string(a) - ); - return false; - } - len = fread(buff, 1, sizeof(buff), file); - } - // close the file and free the entry - fclose(file); - } - archive_entry_free(entry); - } - archive_write_close(a); - archive_write_finish(a); - archive_read_finish(disk); return true; #else (void)outFileName; @@ -1989,9 +1861,9 @@ namespace{ # pragma warn -8066 /* unreachable code */ #endif -int copy_data(struct archive *ar, struct archive *aw) +long copy_data(struct archive *ar, struct archive *aw) { - int r; + long r; const void *buff; size_t size; off_t offset; @@ -2060,12 +1932,20 @@ bool extract_tar(const char* outFileName, bool verbose, } if(extract) { + r = archive_write_disk_set_options(ext, ARCHIVE_EXTRACT_TIME); + if (r != ARCHIVE_OK) + { + cmSystemTools::Error( + "Problem with archive_write_disk_set_options(): ", + archive_error_string(ext)); + } + r = archive_write_header(ext, entry); if (r != ARCHIVE_OK) { cmSystemTools::Error("Problem with archive_write_header(): ", - archive_error_string(a)); - cmSystemTools::Error("Curren file:", + archive_error_string(ext)); + cmSystemTools::Error("Current file:", archive_entry_pathname(entry)); } else @@ -2136,7 +2016,7 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, } else if(*outiter == '\n' || *outiter == '\0') { - int length = outiter-out.begin(); + std::vector::size_type length = outiter-out.begin(); if(length > 1 && *(outiter-1) == '\r') { --length; @@ -2159,7 +2039,7 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, } else if(*erriter == '\n' || *erriter == '\0') { - int length = erriter-err.begin(); + std::vector::size_type length = erriter-err.begin(); if(length > 1 && *(erriter-1) == '\r') { --length; diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index da5da319b..6f9147c31 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -46,12 +46,6 @@ public: static void ExpandRegistryValues(std::string& source, KeyWOW64 view = KeyWOW64_Default); - /** - * Platform independent escape spaces, unix uses backslash, - * windows double quotes the string. - */ - static std::string EscapeSpaces(const char* str); - ///! Escape quotes in a string. static std::string EscapeQuotes(const char* str); @@ -109,6 +103,12 @@ public: 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. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 45ba35844..538025732 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -392,6 +392,24 @@ void cmTarget::DefineProperties(cmake *cm) "Configuration names correspond to those provided by the project " "from which the target is imported."); + cm->DefineProperty + ("IMPORTED_NO_SONAME", cmProperty::TARGET, + "Specifies that an IMPORTED shared library target has no \"soname\". ", + "Set this property to true for an imported shared library file that " + "has no \"soname\" field. " + "CMake may adjust generated link commands for some platforms to prevent " + "the linker from using the path to the library in place of its missing " + "soname. " + "Ignored for non-imported targets."); + + cm->DefineProperty + ("IMPORTED_NO_SONAME_", cmProperty::TARGET, + "Per-configuration version of IMPORTED_NO_SONAME property.", + "This property is used when loading settings for the " + "configuration of an imported target. " + "Configuration names correspond to those provided by the project " + "from which the target is imported."); + cm->DefineProperty ("EXCLUDE_FROM_ALL", cmProperty::TARGET, "Exclude the target from the all target.", @@ -816,12 +834,16 @@ void cmTarget::DefineProperties(cmake *cm) "executable with the TARGET_LINK_LIBRARIES command. " "On all platforms a target-level dependency on the executable is " "created for targets that link to it. " - "For non-DLL platforms the link rule is simply ignored since " - "the dynamic loader will automatically bind symbols when the " - "module is loaded. " "For DLL platforms an import library will be created for the " "exported symbols and then used for linking. " - "All Windows-based systems including Cygwin are DLL platforms."); + "All Windows-based systems including Cygwin are DLL platforms. " + "For non-DLL platforms that require all symbols to be resolved at " + "link time, such as Mac OS X, the module will \"link\" to the " + "executable using a flag like \"-bundle_loader\". " + "For other non-DLL platforms the link rule is simply ignored since " + "the dynamic loader will automatically bind symbols when the " + "module is loaded. " + ); cm->DefineProperty ("Fortran_MODULE_DIRECTORY", cmProperty::TARGET, @@ -853,11 +875,20 @@ void cmTarget::DefineProperties(cmake *cm) "The names returned are suitable for passing to the " "set_source_files_properties command."); + cm->DefineProperty + ("FOLDER", cmProperty::TARGET, + "Set the folder name. Use to organize targets in an IDE.", + "Targets with no FOLDER property will appear as top level " + "entities in IDEs like Visual Studio. Targets with the same " + "FOLDER property value will appear next to each other in a " + "folder of that name. To nest folders, use FOLDER values such " + "as 'GUI/Dialogs' with '/' characters separating folder levels."); + cm->DefineProperty ("PROJECT_LABEL", cmProperty::TARGET, "Change the name of a target in an IDE.", "Can be used to change the name of the target in an IDE " - "like visual stuido. "); + "like Visual Studio. "); cm->DefineProperty ("VS_KEYWORD", cmProperty::TARGET, "Visual Studio project keyword.", @@ -1031,18 +1062,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) // Collect the set of configuration types. std::vector configNames; - if(const char* configurationTypes = - mf->GetDefinition("CMAKE_CONFIGURATION_TYPES")) - { - cmSystemTools::ExpandListArgument(configurationTypes, configNames); - } - else if(const char* buildType = mf->GetDefinition("CMAKE_BUILD_TYPE")) - { - if(*buildType) - { - configNames.push_back(buildType); - } - } + mf->GetConfigurations(configNames); // Setup per-configuration property default values. const char* configProps[] = { @@ -1430,8 +1450,15 @@ bool cmTarget::FindSourceFiles() si = this->SourceFiles.begin(); si != this->SourceFiles.end(); ++si) { - if((*si)->GetFullPath().empty()) + std::string e; + if((*si)->GetFullPath(&e).empty()) { + if(!e.empty()) + { + cmake* cm = this->Makefile->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e, + this->GetBacktrace()); + } return false; } } diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index f1f76c88c..805959def 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -29,23 +29,64 @@ bool cmTargetLinkLibrariesCommand return false; } - // but we might not have any libs after variable expansion - if(args.size() < 2) - { - return true; - } - // Lookup the target for which libraries are specified. this->Target = this->Makefile->GetCMakeInstance() ->GetGlobalGenerator()->FindTarget(0, args[0].c_str()); if(!this->Target) { + cmake::MessageType t = cmake::FATAL_ERROR; // fail by default cmOStringStream e; e << "Cannot specify link libraries for target \"" << args[0] << "\" " << "which is not built by this project."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - cmSystemTools::SetFatalErrorOccured(); + // The bad target is the only argument. Check how policy CMP0016 is set, + // and accept, warn or fail respectively: + if (args.size() < 2) + { + switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0016)) + { + case cmPolicies::WARN: + t = cmake::AUTHOR_WARNING; + // Print the warning. + e << "\n" + << "CMake does not support this but it used to work accidentally " + << "and is being allowed for compatibility." + << "\n" << this->Makefile->GetPolicies()-> + GetPolicyWarning(cmPolicies::CMP0016); + break; + case cmPolicies::OLD: // OLD behavior does not warn. + t = cmake::MESSAGE; + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + e << "\n" << this->Makefile->GetPolicies()-> + GetRequiredPolicyError(cmPolicies::CMP0016); + break; + case cmPolicies::NEW: // NEW behavior prints the error. + default: + break; + } + } + + // now actually print the message + switch(t) + { + case cmake::AUTHOR_WARNING: + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str()); + break; + case cmake::FATAL_ERROR: + this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); + cmSystemTools::SetFatalErrorOccured(); + break; + default: + break; + } + return true; + } + + // but we might not have any libs after variable expansion + if(args.size() < 2) + { return true; } @@ -57,7 +98,7 @@ bool cmTargetLinkLibrariesCommand // specification when the keyword is encountered. this->DoingInterface = false; - // add libraries, nothe that there is an optional prefix + // add libraries, nothe that there is an optional prefix // of debug and optimized than can be used for(unsigned int i=1; i < args.size(); ++i) { @@ -118,7 +159,7 @@ bool cmTargetLinkLibrariesCommand llt = cmTarget::GENERAL; std::string linkType = args[0]; linkType += "_LINK_TYPE"; - const char* linkTypeString = + const char* linkTypeString = this->Makefile->GetDefinition( linkType.c_str() ); if(linkTypeString) { @@ -133,7 +174,7 @@ bool cmTargetLinkLibrariesCommand } this->HandleLibrary(args[i].c_str(), llt); } - } + } // Make sure the last argument was not a library type specifier. if(haveLLT) diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 3010fc9ad..4d31a1499 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -361,7 +361,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, std::string errorMessage = "TRY_RUN() invoked in cross-compiling mode, " "please set the following cache variables " - "appropriatly:\n"; + "appropriately:\n"; errorMessage += " " + this->RunResultVariable + " (advanced)\n"; if (out!=0) { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 59e20d50c..524be8b48 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -32,6 +32,30 @@ static std::string cmVS10EscapeXML(std::string arg) return arg; } +static std::string cmVS10EscapeComment(std::string comment) +{ + // MSBuild takes the CDATA of a element and just + // does "echo $CDATA" with no escapes. We must encode the string. + // http://technet.microsoft.com/en-us/library/cc772462%28WS.10%29.aspx + std::string echoable; + for(std::string::iterator c = comment.begin(); c != comment.end(); ++c) + { + switch (*c) + { + case '\r': break; + case '\n': echoable += '\t'; break; + case '"': /* no break */ + case '|': /* no break */ + case '&': /* no break */ + case '<': /* no break */ + case '>': /* no break */ + case '^': echoable += '^'; /* no break */ + default: echoable += *c; break; + } + } + return echoable; +} + cmVisualStudio10TargetGenerator:: cmVisualStudio10TargetGenerator(cmTarget* target, cmGlobalVisualStudio10Generator* gg) @@ -125,7 +149,10 @@ void cmVisualStudio10TargetGenerator::Generate() ".vcxproj"); if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY) { - this->ComputeClOptions(); + if(!this->ComputeClOptions()) + { + return; + } } cmMakefile* mf = this->Target->GetMakefile(); std::string path = mf->GetStartOutputDirectory(); @@ -155,6 +182,13 @@ void cmVisualStudio10TargetGenerator::Generate() this->WriteString("Win32Proj\n", 2); this->WriteString("", 2); (*this->BuildFileStream) << this->Platform << "\n"; + const char* projLabel = this->Target->GetProperty("PROJECT_LABEL"); + if(!projLabel) + { + projLabel = this->Name.c_str(); + } + this->WriteString("", 2); + (*this->BuildFileStream) << projLabel << "\n"; this->WriteString("\n", 1); this->WriteString("\n", @@ -318,6 +352,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, } cmLocalVisualStudio7Generator* lg = this->LocalGenerator; std::string comment = lg->ConstructComment(command); + comment = cmVS10EscapeComment(comment); std::vector *configs = static_cast (this->GlobalGenerator)->GetConfigurations(); @@ -340,7 +375,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, command.GetEscapeAllowMakeVars()) ); this->WritePlatformConfigTag("Message",i->c_str(), 3); - (*this->BuildFileStream ) << comment << "\n"; + (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "\n"; this->WritePlatformConfigTag("Command", i->c_str(), 3); (*this->BuildFileStream ) << script << "\n"; this->WritePlatformConfigTag("AdditionalInputs", i->c_str(), 3); @@ -760,7 +795,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( hasFlags = true; this->WriteString("", 3); (*this->BuildFileStream ) - << "$(Configuration)/" << objectName << "\n"; + << "$(IntDir)/" << objectName << "\n"; } std::vector *configs = static_cast @@ -807,10 +842,12 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() { - if(this->Target->GetType() > cmTarget::MODULE_LIBRARY) + cmTarget::TargetType ttype = this->Target->GetType(); + if(ttype > cmTarget::GLOBAL_TARGET) { return; } + this->WriteString("\n", 2); this->WriteString("<_ProjectFileVersion>10.0.20506.1" "\n", 3); @@ -820,36 +857,50 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() for(std::vector::iterator config = configs->begin(); config != configs->end(); ++config) { - std::string targetNameFull = - this->Target->GetFullName(config->c_str()); - std::string intermediateDir = this->LocalGenerator-> - GetTargetDirectory(*this->Target); - intermediateDir += "/"; - intermediateDir += *config; - intermediateDir += "/"; - this->ConvertToWindowsSlash(intermediateDir); - std::string outDir = this->Target->GetDirectory(config->c_str()); - this->ConvertToWindowsSlash(outDir); - this->WritePlatformConfigTag("OutDir", config->c_str(), 3); - *this->BuildFileStream << outDir - << "\\" - << "\n"; - this->WritePlatformConfigTag("IntDir", config->c_str(), 3); - *this->BuildFileStream << intermediateDir - << "\n"; - this->WritePlatformConfigTag("TargetName", config->c_str(), 3); - *this->BuildFileStream << cmSystemTools::GetFilenameWithoutExtension( - targetNameFull.c_str()) - << "\n"; - - this->WritePlatformConfigTag("TargetExt", config->c_str(), 3); - *this->BuildFileStream << cmSystemTools::GetFilenameLastExtension( - targetNameFull.c_str()) - << "\n"; - this->OutputLinkIncremental(*config); + if(ttype >= cmTarget::UTILITY) + { + this->WritePlatformConfigTag("IntDir", config->c_str(), 3); + *this->BuildFileStream + << "$(Platform)\\$(Configuration)\\$(ProjectName)\\" + << "\n"; + } + else + { + std::string targetNameFull = + this->Target->GetFullName(config->c_str()); + std::string intermediateDir = this->LocalGenerator-> + GetTargetDirectory(*this->Target); + intermediateDir += "/"; + intermediateDir += *config; + intermediateDir += "/"; + this->ConvertToWindowsSlash(intermediateDir); + std::string outDir = this->Target->GetDirectory(config->c_str()); + this->ConvertToWindowsSlash(outDir); + + this->WritePlatformConfigTag("OutDir", config->c_str(), 3); + *this->BuildFileStream << outDir + << "\\" + << "\n"; + + this->WritePlatformConfigTag("IntDir", config->c_str(), 3); + *this->BuildFileStream << intermediateDir + << "\n"; + + this->WritePlatformConfigTag("TargetName", config->c_str(), 3); + *this->BuildFileStream + << cmSystemTools::GetFilenameWithoutLastExtension( + targetNameFull.c_str()) + << "\n"; + + this->WritePlatformConfigTag("TargetExt", config->c_str(), 3); + *this->BuildFileStream + << cmSystemTools::GetFilenameLastExtension(targetNameFull.c_str()) + << "\n"; + + this->OutputLinkIncremental(*config); + } } this->WriteString("\n", 2); - } @@ -926,19 +977,23 @@ OutputLinkIncremental(std::string const& configName) } //---------------------------------------------------------------------------- -void cmVisualStudio10TargetGenerator::ComputeClOptions() +bool cmVisualStudio10TargetGenerator::ComputeClOptions() { std::vector const* configs = this->GlobalGenerator->GetConfigurations(); for(std::vector::const_iterator i = configs->begin(); i != configs->end(); ++i) { - this->ComputeClOptions(*i); + if(!this->ComputeClOptions(*i)) + { + return false; + } } + return true; } //---------------------------------------------------------------------------- -void cmVisualStudio10TargetGenerator::ComputeClOptions( +bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string const& configName) { // much of this was copied from here: @@ -961,7 +1016,7 @@ void cmVisualStudio10TargetGenerator::ComputeClOptions( cmSystemTools::Error ("CMake can not determine linker language for target:", this->Name.c_str()); - return; + return false; } if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0 || strcmp(linkLanguage, "Fortran") == 0) @@ -1021,6 +1076,7 @@ void cmVisualStudio10TargetGenerator::ComputeClOptions( } this->ClOptions[configName] = pOptions.release(); + return true; } //---------------------------------------------------------------------------- @@ -1033,6 +1089,15 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", ""); this->OutputIncludes(includes); clOptions.OutputFlagMap(*this->BuildFileStream, " "); + + // If not in debug mode, write the DebugInformationFormat field + // without value so PDBs don't get generated uselessly. + if(!clOptions.IsDebug()) + { + this->WriteString("" + "\n", 3); + } + clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ", "\n"); this->WriteString("", 3); @@ -1401,8 +1466,9 @@ void cmVisualStudio10TargetGenerator::WriteEvent( command.GetEscapeAllowMakeVars()) ); } + comment = cmVS10EscapeComment(comment); this->WriteString("",3); - (*this->BuildFileStream ) << comment << "\n"; + (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "\n"; this->WriteString("", 3); (*this->BuildFileStream ) << script; (*this->BuildFileStream ) << "" << "\n"; @@ -1413,10 +1479,13 @@ void cmVisualStudio10TargetGenerator::WriteEvent( void cmVisualStudio10TargetGenerator::WriteProjectReferences() { - cmGlobalGenerator::TargetDependSet& depends + cmGlobalGenerator::TargetDependSet const& unordered = this->GlobalGenerator->GetTargetDirectDepends(*this->Target); + typedef cmGlobalVisualStudioGenerator::OrderedTargetDependSet + OrderedTargetDependSet; + OrderedTargetDependSet depends(unordered); this->WriteString("\n", 1); - for( cmGlobalGenerator::TargetDependSet::const_iterator i = depends.begin(); + for( OrderedTargetDependSet::const_iterator i = depends.begin(); i != depends.end(); ++i) { cmTarget* dt = *i; diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 64b236147..c3c27f4ce 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -50,8 +50,8 @@ private: void WriteObjSources(); void WritePathAndIncrementalLinkOptions(); void WriteItemDefinitionGroups(); - void ComputeClOptions(); - void ComputeClOptions(std::string const& configName); + bool ComputeClOptions(); + bool ComputeClOptions(std::string const& configName); void WriteClOptions(std::string const& config, std::vector const & includes); void WriteRCOptions(std::string const& config, diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 051cc1fbe..972af955d 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -183,7 +183,7 @@ cmVisualStudioGeneratorOptions { fout << prefix << "PreprocessorDefinitions=\""; } - const char* comma = ""; + const char* sep = ""; for(std::vector::const_iterator di = this->Defines.begin(); di != this->Defines.end(); ++di) { @@ -208,15 +208,8 @@ cmVisualStudioGeneratorOptions define = cmVisualStudioGeneratorOptionsEscapeForXML(define.c_str()); } // Store the flag in the project file. - fout << comma << define; - if(this->Version == 10) - { - comma = ";"; - } - else - { - comma = ","; - } + fout << sep << define; + sep = ";"; } if(this->Version == 10) { diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index 07c7b8cf1..592047031 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -236,7 +236,7 @@ void cmXCodeObject::PrintString(std::ostream& os) const // considered special by the Xcode project file parser. bool needQuote = (this->String.empty() || - this->String.find_first_of(" <>.+-=@") != this->String.npos); + this->String.find_first_of(" <>.+-=@$") != this->String.npos); const char* quote = needQuote? "\"" : ""; // Print the string, quoted and escaped as necessary. diff --git a/Source/cm_utf8.c b/Source/cm_utf8.c index 3d4ca16ee..c9bf259ac 100644 --- a/Source/cm_utf8.c +++ b/Source/cm_utf8.c @@ -50,7 +50,7 @@ const char* cm_utf8_decode_character(const char* first, const char* last, unsigned int* pc) { /* Count leading ones in the first byte. */ - unsigned char c = *first++; + unsigned char c = (unsigned char)*first++; unsigned char const ones = cm_utf8_ones[c]; switch(ones) { @@ -62,10 +62,10 @@ const char* cm_utf8_decode_character(const char* first, const char* last, /* Extract bits from this multi-byte character. */ { unsigned int uc = c & cm_utf8_mask[ones]; - unsigned char left; + int left; for(left = ones-1; left && first != last; --left) { - c = *first++; + c = (unsigned char)*first++; if(cm_utf8_ones[c] != 1) { return 0; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index cb2006902..2ebd16592 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -954,7 +954,7 @@ void CMakeCommandUsage(const char* program) << " echo [string]... - displays arguments as text\n" << " echo_append [string]... - displays arguments as text but no new " "line\n" - << " environment - display the current enviroment\n" + << " environment - display the current environment\n" << " make_directory dir - create a directory\n" << " md5sum file1 [...] - compute md5sum of files\n" << " remove_directory dir - remove a directory and its contents\n" @@ -1574,6 +1574,24 @@ int cmake::ExecuteCMakeCommand(std::vector& args) cmSystemTools::Error("Problem extracting tar: ", outFile.c_str()); return 1; } +#ifdef WIN32 + // OK, on windows 7 after we untar some files, + // sometimes we can not rename the directory after + // the untar is done. This breaks the external project + // untar and rename code. So, by default we will wait + // 1/10th of a second after the untar. If CMAKE_UNTAR_DELAY + // is set in the env, its value will be used instead of 100. + int delay = 100; + const char* delayVar = cmSystemTools::GetEnv("CMAKE_UNTAR_DELAY"); + if(delayVar) + { + delay = atoi(delayVar); + } + if(delay) + { + cmSystemTools::Delay(delay); + } +#endif } return 0; } @@ -3483,6 +3501,23 @@ void cmake::DefineProperties(cmake *cm) "the value of this property. " "Non-Makefile generators currently ignore this property."); + cm->DefineProperty + ("USE_FOLDERS", cmProperty::GLOBAL, + "Use the FOLDER target property to organize targets into folders.", + "If not set, CMake treats this property as OFF by default. " + "CMake generators that are capable of organizing into a " + "hierarchy of folders use the values of the FOLDER target " + "property to name those folders. See also the documentation " + "for the FOLDER target property."); + + cm->DefineProperty + ("PREDEFINED_TARGETS_FOLDER", cmProperty::GLOBAL, + "Name of FOLDER for targets that are added automatically by CMake.", + "If not set, CMake uses \"CMakePredefinedTargets\" as a default " + "value for this property. Targets such as INSTALL, PACKAGE and " + "RUN_TESTS will be organized into this FOLDER. See also the " + "documentation for the FOLDER target property."); + // ================================================================ // define variables as well // ================================================================ diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 24921c428..3937d8d17 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -152,7 +152,7 @@ static const char * cmDocumentationOptions[][3] = "popups and interactive " "debugging."}, {"--no-label-summary", "Disable timing summary information for labels.", - "This option tells ctest to not print summary information for each label " + "This option tells ctest not to print summary information for each label " "associated with the tests run. If there are no labels on the " "tests, nothing extra is printed."}, {"--build-and-test", "Configure, build and run a test.", @@ -229,6 +229,9 @@ static const char * cmDocumentationOptions[][3] = "This flag will turn off automatic compression of test output. Use this " "to maintain compatibility with an older version of CDash which doesn't " "support compressed test output."}, + {"--print-labels", "Print all available test labels.", + "This option will not run any tests, it will simply print the list of " + "all labels associated with the test set."}, {"--help-command []", "Show help for a single command and exit.", "Prints the help for the command to stdout or to the specified file." }, {"--help-command-list []", "List available commands and exit.", diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index f440ff92a..bcc7a961c 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -141,12 +141,6 @@ IF(COMMAND SET_PROPERTY) "KWSYS_HEADER(%)=<${KWSYS_NAMESPACE}/%>" ) ENDIF(COMMAND SET_PROPERTY) -# add option to disable memory cleanup at exit of putenv memory -IF(DEFINED KWSYS_DO_NOT_CLEAN_PUTENV) - SET(KWSYS_DO_NOT_CLEAN_PUTENV 1) -ELSE(DEFINED KWSYS_DO_NOT_CLEAN_PUTENV) - SET(KWSYS_DO_NOT_CLEAN_PUTENV 0) -ENDIF(DEFINED KWSYS_DO_NOT_CLEAN_PUTENV) # Select library components. IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) @@ -604,6 +598,23 @@ ELSE(KWSYS_BUILD_SHARED) SET(KWSYS_LIBRARY_TYPE STATIC) ENDIF(KWSYS_BUILD_SHARED) +#----------------------------------------------------------------------------- +# Configure some implementation details. + +KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_PTRDIFF_T + "Checking whether C compiler has ptrdiff_t in stddef.h" DIRECT) +KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_SSIZE_T + "Checking whether C compiler has ssize_t in unistd.h" DIRECT) +SET_SOURCE_FILES_PROPERTIES(ProcessUNIX.c System.c PROPERTIES + COMPILE_FLAGS "-DKWSYS_C_HAS_PTRDIFF_T=${KWSYS_C_HAS_PTRDIFF_T} -DKWSYS_C_HAS_SSIZE_T=${KWSYS_C_HAS_SSIZE_T}" + ) + +IF(KWSYS_DO_NOT_CLEAN_PUTENV) + # Disable cleanup of putenv memory for issues with GCOV. + SET_SOURCE_FILES_PROPERTIES(SystemTools.cxx PROPERTIES + COMPILE_FLAGS -DKWSYS_DO_NOT_CLEAN_PUTENV=1) +ENDIF(KWSYS_DO_NOT_CLEAN_PUTENV) + #----------------------------------------------------------------------------- # Choose a directory for the generated headers. IF(NOT KWSYS_HEADER_ROOT) @@ -782,15 +793,6 @@ IF(KWSYS_USE_Process) ELSE(NOT UNIX) # Use the UNIX implementation. SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c) - - # Help ProcessUNIX.c compile properly on all platforms. - KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_PTRDIFF_T - "Checking whether C compiler has ptrdiff_t in stddef.h" DIRECT) - KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_SSIZE_T - "Checking whether C compiler has ssize_t in unistd.h" DIRECT) - SET_SOURCE_FILES_PROPERTIES(ProcessUNIX.c PROPERTIES - COMPILE_FLAGS "-DKWSYS_C_HAS_PTRDIFF_T=${KWSYS_C_HAS_PTRDIFF_T} -DKWSYS_C_HAS_SSIZE_T=${KWSYS_C_HAS_SSIZE_T}" - ) ENDIF(NOT UNIX) ENDIF(KWSYS_USE_Process) @@ -1095,6 +1097,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) FOREACH(n 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7}) ADD_TEST(kwsys.testProcess-${n} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n}) KWSYS_SET_PROPERTY(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST}) + SET_TESTS_PROPERTIES(kwsys.testProcess-${n} PROPERTIES TIMEOUT 120) ENDFOREACH(n) # Some Apple compilers produce bad optimizations in this source. @@ -1122,5 +1125,11 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) SET_TESTS_PROPERTIES(kwsys.testFail PROPERTIES MEASUREMENT "Some Key=Some Value") MESSAGE(STATUS "GET_TEST_PROPERTY returned: ${wfv}") ENDIF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE) + + # Suppress known consistent failures on buggy systems. + IF(KWSYS_TEST_BOGUS_FAILURES) + SET_TESTS_PROPERTIES(${KWSYS_TEST_BOGUS_FAILURES} PROPERTIES WILL_FAIL ON) + ENDIF() + ENDIF(BUILD_TESTING) ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR) diff --git a/Source/kwsys/Configure.hxx.in b/Source/kwsys/Configure.hxx.in index 9310d94fa..716b84f09 100644 --- a/Source/kwsys/Configure.hxx.in +++ b/Source/kwsys/Configure.hxx.in @@ -15,15 +15,6 @@ /* Include C configuration. */ #include <@KWSYS_NAMESPACE@/Configure.h> -/* Disable cleanup of putenv memory for issues with GCOV */ -#if @KWSYS_DO_NOT_CLEAN_PUTENV@ -#define KWSYS_DO_NOT_CLEAN_PUTENV -#else -#undef KWSYS_DO_NOT_CLEAN_PUTENV -#endif - - - /* Whether ANSI C++ stream headers are to be used. */ #define @KWSYS_NAMESPACE@_IOS_USE_ANSI @KWSYS_IOS_USE_ANSI@ diff --git a/Source/kwsys/MD5.c b/Source/kwsys/MD5.c index 1ea0a66b1..56776a324 100644 --- a/Source/kwsys/MD5.c +++ b/Source/kwsys/MD5.c @@ -29,6 +29,11 @@ it in a single source file instead of a separate header and implementation file. */ +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wcast-align" +#endif + /* Copyright (C) 1999, 2000, 2002 Aladdin Enterprises. All rights reserved. @@ -428,6 +433,10 @@ static void md5_finish(md5_state_t *pms, md5_byte_t digest[16]) digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3)); } +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + /*--------------------------------------------------------------------------*/ /* Wrap up the MD5 state in our opaque structure. */ struct kwsysMD5_s diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 315323551..8aa99ebe9 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -1405,6 +1405,10 @@ kwsys_stl::vector SystemTools::SplitString(const char* p, char se { kwsys_stl::string path = p; kwsys_stl::vector paths; + if(path.empty()) + { + return paths; + } if(isPath && path[0] == '/') { path.erase(path.begin()); @@ -3059,39 +3063,50 @@ kwsys_stl::string SystemTools::RelativePath(const char* local, const char* remot static int GetCasePathName(const kwsys_stl::string & pathIn, kwsys_stl::string & casePath) { - kwsys_stl::string::size_type iFound = pathIn.rfind('/'); - if (iFound > 1 && iFound != pathIn.npos) + kwsys_stl::vector path_components; + SystemTools::SplitPath(pathIn.c_str(), path_components); + if(path_components[0].empty()) // First component always exists. { - // recurse to peel off components - // - if (GetCasePathName(pathIn.substr(0, iFound), casePath) > 0) - { - casePath += '/'; - if (pathIn[1] != '/') - { - WIN32_FIND_DATA findData; + // Relative paths cannot be converted. + casePath = ""; + return 0; + } - // append the long component name to the path - // - HANDLE hFind = ::FindFirstFile(pathIn.c_str(), &findData); - if (INVALID_HANDLE_VALUE != hFind) - { - casePath += findData.cFileName; - ::FindClose(hFind); - } - else - { - // if FindFirstFile fails, return the error code - // - casePath = ""; - return 0; - } - } - } + // Start with root component. + kwsys_stl::vector::size_type idx = 0; + casePath = path_components[idx++]; + const char* sep = ""; + + // If network path, fill casePath with server/share so FindFirstFile + // will work after that. Maybe someday call other APIs to get + // actual case of servers and shares. + if(path_components.size() > 2 && path_components[0] == "//") + { + casePath += path_components[idx++]; + casePath += "/"; + casePath += path_components[idx++]; + sep = "/"; } - else + + for(; idx < path_components.size(); idx++) { - casePath = pathIn; + casePath += sep; + sep = "/"; + kwsys_stl::string test_str = casePath; + test_str += path_components[idx]; + + WIN32_FIND_DATA findData; + HANDLE hFind = ::FindFirstFile(test_str.c_str(), &findData); + if (INVALID_HANDLE_VALUE != hFind) + { + casePath += findData.cFileName; + ::FindClose(hFind); + } + else + { + casePath = ""; + return 0; + } } return (int)casePath.size(); } @@ -3104,28 +3119,29 @@ kwsys_stl::string SystemTools::GetActualCaseForPath(const char* p) #ifndef _WIN32 return p; #else + kwsys_stl::string casePath = p; + // make sure drive letter is always upper case + if(casePath.size() > 1 && casePath[1] == ':') + { + casePath[0] = toupper(casePath[0]); + } + // Check to see if actual case has already been called // for this path, and the result is stored in the LongPathMap - SystemToolsTranslationMap::iterator i = - SystemTools::LongPathMap->find(p); + SystemToolsTranslationMap::iterator i = + SystemTools::LongPathMap->find(casePath); if(i != SystemTools::LongPathMap->end()) { return i->second; } - kwsys_stl::string casePath; int len = GetCasePathName(p, casePath); if(len == 0 || len > MAX_PATH+1) { return p; } - // make sure drive letter is always upper case - if(casePath.size() > 1 && casePath[1] == ':') - { - casePath[0] = toupper(casePath[0]); - } (*SystemTools::LongPathMap)[p] = casePath; return casePath; -#endif +#endif } //---------------------------------------------------------------------------- @@ -3143,9 +3159,9 @@ const char* SystemTools::SplitPathRootComponent(const char* p, } c += 2; } - else if(c[0] == '/') + else if(c[0] == '/' || c[0] == '\\') { - // Unix path. + // Unix path (or Windows path w/out drive letter). if(root) { *root = "/"; diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index ec70320d4..cf4792304 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -372,8 +372,8 @@ public: * "c:/" = Windows full path (can be any drive letter) * "c:" = Windows drive-letter relative path (can be any drive letter) * "//" = Network path - * "~" = Home path for current user - * "~u" = Home path for user 'u' + * "~/" = Home path for current user + * "~u/" = Home path for user 'u' * "" = Relative path * * A pointer to the rest of the path after the root component is @@ -385,7 +385,7 @@ public: /** * Split a path name into its basic components. The first component - * is one of the roots returned by SplitPathRootComponent. + * always exists and is the root returned by SplitPathRootComponent. * The remaining components form the path. If there is a trailing * slash then the last component is the empty string. The * components can be recombined as "c[0]c[1]/c[2]/.../c[n]" to diff --git a/Source/kwsys/kwsysDateStamp.cmake b/Source/kwsys/kwsysDateStamp.cmake index 043f0d0b0..a20a71a84 100644 --- a/Source/kwsys/kwsysDateStamp.cmake +++ b/Source/kwsys/kwsysDateStamp.cmake @@ -15,7 +15,7 @@ SET(KWSYS_DATE_STAMP_YEAR 2010) # KWSys version date month component. Format is MM. -SET(KWSYS_DATE_STAMP_MONTH 06) +SET(KWSYS_DATE_STAMP_MONTH 11) # KWSys version date day component. Format is DD. -SET(KWSYS_DATE_STAMP_DAY 28) +SET(KWSYS_DATE_STAMP_DAY 03) diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c index 0060c4d1f..877002a14 100644 --- a/Source/kwsys/testProcess.c +++ b/Source/kwsys/testProcess.c @@ -94,7 +94,11 @@ int test4(int argc, const char* argv[]) fprintf(stderr, "Output before crash on stderr from crash test.\n"); fflush(stdout); fflush(stderr); +#if defined(__clang__) + *(int*)1 = 0; /* Clang warns about 0-ptr; undefined behavior. */ +#else *(int*)0 = 0; +#endif fprintf(stdout, "Output after crash on stdout from crash test.\n"); fprintf(stderr, "Output after crash on stderr from crash test.\n"); return 0; diff --git a/Tests/CMakeInstall.cmake b/Tests/CMakeInstall.cmake index f141b53a7..dabc85292 100644 --- a/Tests/CMakeInstall.cmake +++ b/Tests/CMakeInstall.cmake @@ -33,7 +33,7 @@ if(CMake_TEST_INSTALL) add_test(CMake.Install ${CMake_TEST_INSTALL_CTest} ${CMake_TEST_INSTALL_CONFIG} - --build-and-test ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} + --build-and-test ${CMake_SOURCE_DIR} ${CMake_BINARY_DIR} --build-generator ${CMAKE_GENERATOR} # Not CMAKE_TEST_GENERATOR --build-project CMake --build-makeprogram ${CMAKE_MAKE_PROGRAM} # Not CMAKE_TEST_MAKEPROGRAM diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2c7056d50..d618ab485 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -129,6 +129,9 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(MathTest MathTest) ADD_TEST_MACRO(Simple Simple) ADD_TEST_MACRO(PreOrder PreOrder) + 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 \"MissingSourceFile.c\"") ADD_TEST_MACRO(COnly COnly) ADD_TEST_MACRO(CxxOnly CxxOnly) ADD_TEST_MACRO(IPO COnly/COnly) @@ -150,6 +153,9 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(ExportImport ExportImport) ADD_TEST_MACRO(Unset Unset) ADD_TEST_MACRO(PolicyScope PolicyScope) + ADD_TEST_MACRO(EmptyLibrary EmptyLibrary) + SET_TESTS_PROPERTIES(EmptyLibrary PROPERTIES + PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target:test") ADD_TEST_MACRO(CrossCompile CrossCompile) SET_TESTS_PROPERTIES(CrossCompile PROPERTIES PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode") @@ -404,7 +410,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # --test-command t4 #--test-command "${CMAKE_COMMAND}" #"-DCONFIGURATION=\${CTEST_CONFIGURATION_TYPE}" - #-P "${CMAKE_BINARY_DIR}/Tests/SimpleExclude/run.cmake" + #-P "${CMake_BINARY_DIR}/Tests/SimpleExclude/run.cmake" #) # ADD_TEST(SameName ${CMAKE_CTEST_COMMAND} @@ -1051,7 +1057,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-target install # --build-target package --build-options "-DCMAKE_INSTALL_PREFIX:PATH=${BundleTestInstallDir}" - "-DCMake_SOURCE_DIR:PATH=${CMAKE_SOURCE_DIR}" + "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}" --test-command ${BundleTestInstallDir}/Applications/SecondBundleExe.app/Contents/MacOS/SecondBundleExe) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/BundleTest") @@ -1315,6 +1321,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log" ) + ADD_TEST(CTestTestPrintLabels ${CMAKE_CTEST_COMMAND} --print-labels) + SET_TESTS_PROPERTIES(CTestTestPrintLabels PROPERTIES LABELS "Label1;Label2") + SET_TESTS_PROPERTIES(CTestTestPrintLabels PROPERTIES PASS_REGULAR_EXPRESSION + "All Labels:.* Label1.* Label2") + CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Tests/CTestTestResourceLock/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestResourceLock/test.cmake" @@ -1373,7 +1384,29 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ) SET_TESTS_PROPERTIES(CTestTestTimeout PROPERTIES PASS_REGULAR_EXPRESSION "TestTimeout *\\.+ *\\*\\*\\*Timeout.*CheckChild *\\.+ *Passed") - + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestDepends/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestDepends ${CMAKE_CTEST_COMMAND} + -C "\${CTestTest_CONFIG}" + -S "${CMake_BINARY_DIR}/Tests/CTestTestDepends/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestDepends/testOutput.log" + ) + + CONFIGURE_FILE( + "${CMake_SOURCE_DIR}/Tests/CTestTestCycle/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake" + @ONLY ESCAPE_QUOTES) + ADD_TEST(CTestTestCycle ${CMAKE_CTEST_COMMAND} + -C "\${CTestTest_CONFIG}" + -S "${CMake_BINARY_DIR}/Tests/CTestTestCycle/test.cmake" -V + --output-log "${CMake_BINARY_DIR}/Tests/CTestTestCycle/testOutput.log" + ) + SET_TESTS_PROPERTIES(CTestTestCycle PROPERTIES + PASS_REGULAR_EXPRESSION "a cycle exists in the test dependency graph") + CONFIGURE_FILE( "${CMake_SOURCE_DIR}/Tests/CTestTestRunScript/test.cmake.in" "${CMake_BINARY_DIR}/Tests/CTestTestRunScript/test.cmake" @@ -1410,9 +1443,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ set(regex "${regex}|Error message was: ") set(regex "${regex}([Cc]ould *n.t resolve host") set(regex "${regex}|[Cc]ould *n.t connect to host") + set(regex "${regex}|Empty reply from server") set(regex "${regex}|The requested URL returned error") set(regex "${regex}|libcurl was built with SSL disabled. https: not supported)") set(regex "${regex}|Submission method .xmlrpc. not compiled into CTest") + set(regex "${regex}|Submission problem") set(regex "${regex}|Submission successful)") set(ctest_coverage_labels_args "") @@ -1470,6 +1505,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log" ) + CONFIGURE_FILE("${CMake_SOURCE_DIR}/Tests/CTestTestChecksum/test.cmake.in" + "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" @ONLY + ESCAPE_QUOTES) + ADD_TEST(CTestTestChecksum ${CMAKE_CTEST_COMMAND} + -S "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/test.cmake" -V + --output-log + "${CMake_BINARY_DIR}/Tests/CTestTestChecksum/testOutput.log" + ) + SET_TESTS_PROPERTIES(CTestTestChecksum PROPERTIES PASS_REGULAR_EXPRESSION + "Submission failed: Checksum failed for file") + # these tests take a long time, make sure they have it # if timeouts have not already been set GET_TEST_PROPERTY(CTestTest TIMEOUT PREVIOUS_TIMEOUT) @@ -1485,36 +1531,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ENDIF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) ENDIF (CTEST_TEST_CTEST AND CMAKE_RUN_LONG_TESTS AND CMAKE_TESTS_CDASH_SERVER) - IF(NOT DEFINED CTEST_RUN_CTestSubmitLargeOutput) - SET(CTEST_RUN_CTestSubmitLargeOutput OFF) - - IF (CMAKE_TESTS_CDASH_SERVER AND "${server}" STREQUAL "localhost") - SET(CTEST_RUN_CTestSubmitLargeOutput ON) - ENDIF (CMAKE_TESTS_CDASH_SERVER AND "${server}" STREQUAL "localhost") - ENDIF(NOT DEFINED CTEST_RUN_CTestSubmitLargeOutput) - - IF(CTEST_RUN_CTestSubmitLargeOutput) - CONFIGURE_FILE( - "${CMake_SOURCE_DIR}/Tests/CTestSubmitLargeOutput/test.cmake.in" - "${CMake_BINARY_DIR}/Tests/CTestSubmitLargeOutput/test.cmake" - @ONLY ESCAPE_QUOTES - ) - ADD_TEST(CTestSubmitLargeOutput ${CMAKE_CTEST_COMMAND} - -S "${CMake_BINARY_DIR}/Tests/CTestSubmitLargeOutput/test.cmake" -V - --output-log "${CMake_BINARY_DIR}/Tests/CTestSubmitLargeOutput/testOutput.log" - ) - - # This test only passes if it fails to submit properly... - # - SET_TESTS_PROPERTIES(CTestSubmitLargeOutput PROPERTIES - PASS_REGULAR_EXPRESSION "Errors occurred during submission") - - # Give this test plenty of time to run on slower machines: - # - SET_TESTS_PROPERTIES(CTestSubmitLargeOutput PROPERTIES - TIMEOUT ${CMAKE_LONG_TEST_TIMEOUT}) - ENDIF(CTEST_RUN_CTestSubmitLargeOutput) - IF (CMAKE_RUN_LONG_TESTS AND TEST_KDE4_STABLE_BRANCH) IF(UNIX) IF(NOT QT4_FOUND) @@ -1555,10 +1571,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ IF("${CMAKE_TEST_GENERATOR}" MATCHES Xcode) SET(CMAKE_SKIP_BOOTSTRAP_TEST 1) ENDIF("${CMAKE_TEST_GENERATOR}" MATCHES Xcode) - IF(EXISTS "${CMAKE_BINARY_DIR}/CMakeLists.txt") + IF(EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt") # If there is CMakeLists.txt in the binary tree, assume in-source build SET(CMAKE_SKIP_BOOTSTRAP_TEST 1) - ENDIF(EXISTS "${CMAKE_BINARY_DIR}/CMakeLists.txt") + ENDIF(EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt") SET(bootstrap "") IF(CMAKE_RUN_LONG_TESTS AND NOT CMAKE_SKIP_BOOTSTRAP_TEST) IF(UNIX) @@ -1619,8 +1635,16 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ENDIF() ENDIF() - IF(NOT CMAKE_TEST_GENERATOR MATCHES "Xcode") - INCLUDE(FindJava) + if(NOT DEFINED CTEST_RUN_Java) + if(APPLE) + set(CTEST_RUN_Java OFF) + else() + set(CTEST_RUN_Java ON) + endif() + endif() + + IF(CTEST_RUN_Java) + find_package(Java QUIET) IF(JAVA_COMPILE AND JAVA_RUNTIME AND JAVA_ARCHIVE AND NOT MINGW) GET_FILENAME_COMPONENT(JNIPATH ${JAVA_COMPILE} PATH) FIND_FILE(JNI_H jni.h @@ -1643,7 +1667,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ENDIF("${JNI_FILE}" MATCHES "JDK1_2") ENDIF(JNI_H) ENDIF(JAVA_COMPILE AND JAVA_RUNTIME AND JAVA_ARCHIVE AND NOT MINGW) - ENDIF(NOT CMAKE_TEST_GENERATOR MATCHES "Xcode") + ENDIF(CTEST_RUN_Java) # add some cross compiler tests, for now only with makefile based generators IF(CMAKE_TEST_GENERATOR MATCHES "Makefiles" OR CMAKE_TEST_GENERATOR MATCHES "KDevelop") @@ -1730,14 +1754,14 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ # If this is not an in-source build, provide a target to wipe out # all the test build directories. - IF(NOT EXISTS "${CMAKE_BINARY_DIR}/CMakeLists.txt") + IF(NOT EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt") CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/test_clean.cmake.in ${CMake_BINARY_DIR}/Tests/test_clean.cmake @ONLY) ADD_CUSTOM_TARGET(test_clean COMMAND ${CMAKE_COMMAND} -P ${CMake_BINARY_DIR}/Tests/test_clean.cmake COMMENT "Removing test build directories." ) - ENDIF(NOT EXISTS "${CMAKE_BINARY_DIR}/CMakeLists.txt") + ENDIF(NOT EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt") ADD_TEST(CMakeWizardTest ${CMAKE_CMAKE_COMMAND} -D build_dir:STRING=${CMAKE_CURRENT_BINARY_DIR}/CMakeWizardTest diff --git a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in index 9150aef5b..73f8b013d 100644 --- a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in +++ b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in @@ -149,26 +149,77 @@ if(is_git_checkout AND NOT GIT_EXECUTABLE) # from it: # if(ctest_ini_file) - file(STRINGS "${ctest_ini_file}" lines REGEX "^GITCommand: (.*)$") - string(REGEX REPLACE "^GITCommand: (.*)$" "\\1" exe "${lines}") + file(STRINGS "${ctest_ini_file}" line REGEX "^GITCommand: (.*)$") + string(REGEX REPLACE "^GITCommand: (.*)$" "\\1" line "${line}") + if("${line}" MATCHES "^\"") + string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}") + else() + string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}") + endif() + set(exe "${line}") if("${exe}" STREQUAL "GITCOMMAND-NOTFOUND") set(exe "") endif() + if(exe) + message("info: GIT_EXECUTABLE set by 'GITCommand:' from '${ctest_ini_file}'") + endif() if(NOT exe) - file(STRINGS "${ctest_ini_file}" lines REGEX "^UpdateCommand: (.*)$") - string(REGEX REPLACE "^UpdateCommand: (.*)$" "\\1" exe "${lines}") + file(STRINGS "${ctest_ini_file}" line REGEX "^UpdateCommand: (.*)$") + string(REGEX REPLACE "^UpdateCommand: (.*)$" "\\1" line "${line}") + if("${line}" MATCHES "^\"") + string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}") + else() + string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}") + endif() + set(exe "${line}") if("${exe}" STREQUAL "GITCOMMAND-NOTFOUND") set(exe "") endif() + if(exe) + message("info: GIT_EXECUTABLE set by 'UpdateCommand:' from '${ctest_ini_file}'") + endif() + endif() + else() + message("info: no DartConfiguration.tcl or CTestConfiguration.ini file...") + endif() + + # If we have still not grokked the exe, look in the Update.xml file to see + # if we can parse it from there... + # + if(NOT exe) + file(GLOB_RECURSE update_xml_file "${CMake_BINARY_DIR}/Testing/Update.xml") + if(update_xml_file) + file(STRINGS "${update_xml_file}" line + REGEX "^.*(.*)$" LIMIT_COUNT 1) + string(REPLACE ""\;" "\"" line "${line}") + string(REGEX REPLACE "^.*(.*)$" "\\1" line "${line}") + if("${line}" MATCHES "^\"") + string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}") + else() + string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}") + endif() + if(line) + set(exe "${line}") + endif() + if(exe) + message("info: GIT_EXECUTABLE set by '' from '${update_xml_file}'") + endif() + else() + message("info: no Update.xml file...") endif() endif() if(exe) set(GIT_EXECUTABLE "${exe}") - message("info: set GIT_EXECUTABLE to '${GIT_EXECUTABLE}' based on '${ctest_ini_file}'") + message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'") + message("") + + if(NOT EXISTS "${GIT_EXECUTABLE}") + message(FATAL_ERROR "GIT_EXECUTABLE does not exist...") + endif() else() - message(FATAL_ERROR "could not determine GIT_EXECUTABLE based on '${ctest_ini_file}'...") + message(FATAL_ERROR "could not determine GIT_EXECUTABLE...") endif() endif() diff --git a/Tests/CMakeTests/FindBaseTest.cmake.in b/Tests/CMakeTests/FindBaseTest.cmake.in index 02f700152..47c1692db 100644 --- a/Tests/CMakeTests/FindBaseTest.cmake.in +++ b/Tests/CMakeTests/FindBaseTest.cmake.in @@ -55,7 +55,7 @@ if(NOT "${FOO_H_5}" STREQUAL "${_HEADER_FULL}") message(FATAL_ERROR "Did not find \"${_HEADER_FULL}\"\ngot ${FOO_H_5} instead !") endif(NOT "${FOO_H_5}" STREQUAL "${_HEADER_FULL}") -# by explicitely disabling CMAKE_FIND_ROOT_PATH again it shouldn't be found +# by explicitly disabling CMAKE_FIND_ROOT_PATH again it shouldn't be found find_file(FOO_H_6 ${_HEADER} NO_CMAKE_FIND_ROOT_PATH) if(FOO_H_6) message(FATAL_ERROR "${_HEADER} found: ${FOO_H_6}, it should not exist !") diff --git a/Tests/CMakeTests/GetPrerequisitesTest.cmake.in b/Tests/CMakeTests/GetPrerequisitesTest.cmake.in index e8bfb47ae..daf467bcc 100644 --- a/Tests/CMakeTests/GetPrerequisitesTest.cmake.in +++ b/Tests/CMakeTests/GetPrerequisitesTest.cmake.in @@ -77,6 +77,11 @@ message(STATUS "") list_prerequisites("${CMAKE_COMMAND}" 0 0 1) message(STATUS "") +message(STATUS "=============================================================================") +string(LENGTH "$ENV{PATH}" PATH_LENGTH_BEGIN) +message(STATUS "Begin PATH length is: ${PATH_LENGTH_BEGIN}") +message(STATUS "") + # Leave the code for these tests in here, but turn them off by default... they # take longer than they're worth during development... @@ -116,11 +121,11 @@ message(STATUS "") message(STATUS "=============================================================================") message(STATUS "Test overriding 'gp_tool' with value unlikely to be found") message(STATUS "") -if(WIN32 OR APPLE) - set(gp_tool "ldd") -else(WIN32 OR APPLE) +if(APPLE) + set(gp_tool "dumpbin") +else() set(gp_tool "otool") -endif(WIN32 OR APPLE) +endif() set(gp_cmd "gp_cmd-NOTFOUND") list_prerequisites("${CMAKE_COMMAND}" 0 0 0) set(gp_cmd) @@ -139,6 +144,15 @@ foreach(v ${vs}) endforeach(v) message(STATUS "") +message(STATUS "=============================================================================") +string(LENGTH "$ENV{PATH}" PATH_LENGTH_END) +message(STATUS "Final PATH length is: ${PATH_LENGTH_END}") + +if(PATH_LENGTH_END GREATER ${PATH_LENGTH_BEGIN}) + message(FATAL_ERROR "list_prerequisties is endlessly appending the path of gp_tool to the PATH.") +endif() +message(STATUS "") + message(STATUS "=============================================================================") message(STATUS "End of test") diff --git a/Tests/CMakeTests/IncludeTest.cmake.in b/Tests/CMakeTests/IncludeTest.cmake.in index 01cec38f4..eca679b4a 100644 --- a/Tests/CMakeTests/IncludeTest.cmake.in +++ b/Tests/CMakeTests/IncludeTest.cmake.in @@ -35,3 +35,7 @@ if(NOT "${fileOne}" STREQUAL "${fileTwo}") message(FATAL_ERROR "Wrong CMake.cmake was included: \"${fileOne}\" expected \"${fileTwo}\"") endif(NOT "${fileOne}" STREQUAL "${fileTwo}") +# Check that CMAKE_CURRENT_LIST_DIR is working: +# Needs to be a file in the build tree, which is correct cmake script +# but doesn't do a lot, if possible only set() commands: +include(${CMAKE_CURRENT_LIST_DIR}/../../CTestCustom.cmake) diff --git a/Tests/CMakeTests/ModuleNoticesTest.cmake.in b/Tests/CMakeTests/ModuleNoticesTest.cmake.in index 4d295efd6..8ecebd338 100644 --- a/Tests/CMakeTests/ModuleNoticesTest.cmake.in +++ b/Tests/CMakeTests/ModuleNoticesTest.cmake.in @@ -3,7 +3,7 @@ # match any additional copyright holder notices. set(notice_regex " #============================================================================= -# Copyright (20[0-9][0-9]-)?20[0-9][0-9] Kitware[^\n]+( +# Copyright (20[0-9][0-9]-)?20[0-9][0-9] [^\n]+( # Copyright (20[0-9][0-9]-)?20[0-9][0-9] [^\n]+)* # # Distributed under the OSI-approved BSD License \\(the \"License\"\\); @@ -13,7 +13,7 @@ set(notice_regex " # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\\. # See the License for more information\\. #============================================================================= -# \\(To distributed this file outside of CMake, substitute the full +# \\(To distribute this file outside of CMake, substitute the full # License text for the above reference.\\) ") string(REPLACE "\n" "\r?\n" notice_regex "${notice_regex}") diff --git a/Tests/CTestSubmitLargeOutput/CMakeLists.txt b/Tests/CTestSubmitLargeOutput/CMakeLists.txt deleted file mode 100644 index 6c30e7a0d..000000000 --- a/Tests/CTestSubmitLargeOutput/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 2.8) -project(SubmitLargeOutput NONE) - -include(CTest) - -add_test(GenerateRandomOutput ${CMAKE_COMMAND} - -P ${CMAKE_CURRENT_SOURCE_DIR}/GenerateRandomOutput.cmake - ) diff --git a/Tests/CTestSubmitLargeOutput/GenerateRandomOutput.cmake b/Tests/CTestSubmitLargeOutput/GenerateRandomOutput.cmake deleted file mode 100644 index c7f4f299a..000000000 --- a/Tests/CTestSubmitLargeOutput/GenerateRandomOutput.cmake +++ /dev/null @@ -1,31 +0,0 @@ -# -# This script generates random lines of output. -# -# By default, it generates 100M of output (a million lines of 100 bytes each), -# but you can override that by passing in -D line_count and/or -D line_size... -# - -# Default values: -# -if(NOT DEFINED line_count) - set(line_count 1000000) -endif() - -if(NOT DEFINED line_size) - set(line_size 100) -endif() - -if(NOT DEFINED random_seed) - set(random_seed 1987) -endif() - -# Use RANDOM_SEED once before the loop: -# -string(RANDOM LENGTH ${line_size} RANDOM_SEED ${random_seed} s) - -# Emit line_count lines of random output: -# -foreach(i RANGE 1 ${line_count}) - string(RANDOM LENGTH ${line_size} s) - message(${s}) -endforeach() diff --git a/Tests/CTestSubmitLargeOutput/test.cmake.in b/Tests/CTestSubmitLargeOutput/test.cmake.in deleted file mode 100644 index 17a7c7d65..000000000 --- a/Tests/CTestSubmitLargeOutput/test.cmake.in +++ /dev/null @@ -1,27 +0,0 @@ -SET(CTEST_SITE "@SITE@") -SET(CTEST_BUILD_NAME "LargeOutput-@BUILDNAME@") -SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -SET(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") - -SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestSubmitLargeOutput") -SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestSubmitLargeOutput/build") -SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") - -CTEST_EMPTY_BINARY_DIRECTORY(${CTEST_BINARY_DIRECTORY}) - -CTEST_START(Experimental) -CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) -CTEST_READ_CUSTOM_FILES("${CTEST_BINARY_DIRECTORY}") -CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) - -SET(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 1000000000) -SET(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE 1000000000) -SET(CTEST_TEST_TIMEOUT @CMAKE_LONG_TEST_TIMEOUT@) - -CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) - -set(CTEST_DROP_METHOD "@protocol@") -set(CTEST_DROP_SITE "@server@") -set(CTEST_DROP_LOCATION "@path@/submit.php?project=PublicDashboard") - -CTEST_SUBMIT(RETURN_VALUE res) diff --git a/Tests/CTestTestChecksum/test.cmake.in b/Tests/CTestTestChecksum/test.cmake.in new file mode 100644 index 000000000..c3c41a5fe --- /dev/null +++ b/Tests/CTestTestChecksum/test.cmake.in @@ -0,0 +1,28 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Checksum") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestParallel") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestParallel") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") +SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") +SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res PARALLEL_LEVEL 4) + +SET(CTEST_DROP_METHOD "@protocol@") +SET(CTEST_DROP_SITE "@server@") +SET(CTEST_DROP_LOCATION "@path@/submit.php?project=PublicDashboard") + +CTEST_SUBMIT(RETRY_DELAY 3 RETRY_COUNT 2 INTERNAL_TEST_CHECKSUM RETURN_VALUE res) diff --git a/Tests/CTestTestCycle/CMakeLists.txt b/Tests/CTestTestCycle/CMakeLists.txt new file mode 100644 index 000000000..6ba6b8c95 --- /dev/null +++ b/Tests/CTestTestCycle/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required (VERSION 2.6) +project(CTestTestCycle) +include(CTest) + +add_executable (simple simple.cxx) +add_test (one simple) +add_test (two simple) +add_test (three simple) + +# Add cyclical test dependency +set_tests_properties(one PROPERTIES DEPENDS "two") +set_tests_properties(two PROPERTIES DEPENDS "three") +set_tests_properties(three PROPERTIES DEPENDS "one") diff --git a/Tests/CTestSubmitLargeOutput/CTestConfig.cmake b/Tests/CTestTestCycle/CTestConfig.cmake similarity index 57% rename from Tests/CTestSubmitLargeOutput/CTestConfig.cmake rename to Tests/CTestTestCycle/CTestConfig.cmake index ffd6efc2d..43e99863a 100644 --- a/Tests/CTestSubmitLargeOutput/CTestConfig.cmake +++ b/Tests/CTestTestCycle/CTestConfig.cmake @@ -1,5 +1,6 @@ -set(CTEST_PROJECT_NAME "SubmitLargeOutput") -set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") +set (CTEST_PROJECT_NAME "CTestTestCycle") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "www.cdash.org") set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") diff --git a/Tests/CTestTestCycle/simple.cxx b/Tests/CTestTestCycle/simple.cxx new file mode 100644 index 000000000..766b7751b --- /dev/null +++ b/Tests/CTestTestCycle/simple.cxx @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/CTestTestCycle/test.cmake.in b/Tests/CTestTestCycle/test.cmake.in new file mode 100644 index 000000000..a17adca01 --- /dev/null +++ b/Tests/CTestTestCycle/test.cmake.in @@ -0,0 +1,22 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Cycle") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCycle") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCycle") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") +SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") +SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestTestDepends/CMakeLists.txt b/Tests/CTestTestDepends/CMakeLists.txt new file mode 100644 index 000000000..26367a658 --- /dev/null +++ b/Tests/CTestTestDepends/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required (VERSION 2.6) +project(CTestTestDepends) +include(CTest) + +add_executable (simple simple.cxx) +add_test (one simple) +add_test (two simple) +add_test (three simple) + +# Add redundant (but not cyclical) dependencies +set_tests_properties(two PROPERTIES DEPENDS "one") +set_tests_properties(three PROPERTIES DEPENDS "one;two") diff --git a/Tests/CTestTestDepends/CTestConfig.cmake b/Tests/CTestTestDepends/CTestConfig.cmake new file mode 100644 index 000000000..e3af7dd8d --- /dev/null +++ b/Tests/CTestTestDepends/CTestConfig.cmake @@ -0,0 +1,7 @@ +set (CTEST_PROJECT_NAME "CTestTestDepends") +set (CTEST_NIGHTLY_START_TIME "21:00:00 EDT") +set (CTEST_DART_SERVER_VERSION "2") +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "www.cdash.org") +set(CTEST_DROP_LOCATION "/CDash/submit.php?project=PublicDashboard") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Tests/CTestTestDepends/simple.cxx b/Tests/CTestTestDepends/simple.cxx new file mode 100644 index 000000000..766b7751b --- /dev/null +++ b/Tests/CTestTestDepends/simple.cxx @@ -0,0 +1,5 @@ + +int main() +{ + return 0; +} diff --git a/Tests/CTestTestDepends/test.cmake.in b/Tests/CTestTestDepends/test.cmake.in new file mode 100644 index 000000000..ed4e18226 --- /dev/null +++ b/Tests/CTestTestDepends/test.cmake.in @@ -0,0 +1,22 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.1) + +# Settings: +SET(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest") +SET(CTEST_SITE "@SITE@") +SET(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Depends") + +SET(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestDepends") +SET(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestDepends") +SET(CTEST_CVS_COMMAND "@CVSCOMMAND@") +SET(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@") +SET(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") +SET(CTEST_MEMORYCHECK_COMMAND "@MEMORYCHECK_COMMAND@") +SET(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE "@MEMORYCHECK_SUPPRESSIONS_FILE@") +SET(CTEST_MEMORYCHECK_COMMAND_OPTIONS "@MEMORYCHECK_COMMAND_OPTIONS@") +SET(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@") +SET(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") + +CTEST_START(Experimental) +CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) +CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) diff --git a/Tests/CTestUpdateGIT.cmake.in b/Tests/CTestUpdateGIT.cmake.in index f672a524e..793b9870d 100644 --- a/Tests/CTestUpdateGIT.cmake.in +++ b/Tests/CTestUpdateGIT.cmake.in @@ -275,6 +275,11 @@ execute_process( WORKING_DIRECTORY \"${TOP}\" COMMAND \"${GIT}\" clone \"${REPO}\" dash-source ) + +# Test .git file. +file(RENAME \"${TOP}/dash-source/.git\" \"${TOP}/dash-source/repo.git\") +file(WRITE \"${TOP}/dash-source/.git\" \"gitdir: repo.git\n\") + execute_process( WORKING_DIRECTORY \"${TOP}/dash-source\" COMMAND \"${GIT}\" reset --hard ${revision1} diff --git a/Tests/CheckCompilerRelatedVariables/CMakeLists.txt b/Tests/CheckCompilerRelatedVariables/CMakeLists.txt index 7206f1daf..8095a1cf1 100644 --- a/Tests/CheckCompilerRelatedVariables/CMakeLists.txt +++ b/Tests/CheckCompilerRelatedVariables/CMakeLists.txt @@ -76,7 +76,8 @@ endif() file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cxx" - "int main() { return 0; }" + "int main() { return 0; } +" ) add_executable( diff --git a/Tests/CheckFortran.cmake b/Tests/CheckFortran.cmake index 8adcafcf8..ebbb426ce 100644 --- a/Tests/CheckFortran.cmake +++ b/Tests/CheckFortran.cmake @@ -9,7 +9,7 @@ # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the License for more information. #============================================================================= -# (To distributed this file outside of CMake, substitute the full +# (To distribute this file outside of CMake, substitute the full # License text for the above reference.) if(NOT DEFINED CMAKE_Fortran_COMPILER) diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index 4fc9fb5d4..76208d479 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -9,12 +9,16 @@ ADD_SUBDIRECTORY(GeneratedHeader) # # Lib and exe path # -SET (LIBRARY_OUTPUT_PATH - ${PROJECT_BINARY_DIR}/bin/ CACHE INTERNAL +IF(NOT DEFINED bin_dir) + SET(bin_dir "bin") +ENDIF() + +SET (LIBRARY_OUTPUT_PATH + ${PROJECT_BINARY_DIR}/${bin_dir} CACHE INTERNAL "Single output directory for building all libraries.") -SET (EXECUTABLE_OUTPUT_PATH - ${PROJECT_BINARY_DIR}/bin/ CACHE INTERNAL +SET (EXECUTABLE_OUTPUT_PATH + ${PROJECT_BINARY_DIR}/${bin_dir} CACHE INTERNAL "Single output directory for building all executables.") ################################################################ @@ -220,7 +224,12 @@ ADD_CUSTOM_COMMAND(OUTPUT gen_redirect.c ############################################################################## # Test non-trivial command line arguments in custom commands. SET(EXPECTED_ARGUMENTS) +SET(CHECK_ARGS) +IF(NOT MSVC71) + SET(CHECK_ARGS -DPATH=c:/posix/path) +ENDIF() SET(CHECK_ARGS + ${CHECK_ARGS} c:/posix/path c:\\windows\\path 'single-quotes' @@ -359,13 +368,16 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/check_command_line.c.in @ONLY IMMEDIATE) ADD_EXECUTABLE(check_command_line ${CMAKE_CURRENT_BINARY_DIR}/check_command_line.c) +SET(output_name "check_command_line") +SET_PROPERTY(TARGET check_command_line + PROPERTY OUTPUT_NAME ${output_name}) # SET_TARGET_PROPERTIES(check_command_line PROPERTIES # COMPILE_FLAGS -DCHECK_COMMAND_LINE_VERBOSE) ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/command_line_check COMMAND ${CMAKE_COMMAND} -DMARK_FILE=${CMAKE_CURRENT_BINARY_DIR}/check_mark.txt -P ${CMAKE_CURRENT_SOURCE_DIR}/check_mark.cmake - COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check_command_line + COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${output_name} ${CHECK_ARGS} "" VERBATIM COMMENT "Checking custom command line escapes (single'quote)" @@ -375,7 +387,7 @@ SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/command_line_check ADD_CUSTOM_TARGET(do_check_command_line ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/command_line_check COMMAND ${CMAKE_COMMAND} -E echo "Checking custom target command escapes" - COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/check_command_line + COMMAND ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${output_name} ${CHECK_ARGS} "" VERBATIM COMMENT "Checking custom target command line escapes ($dollar-signs$)" diff --git a/Tests/CxxOnly/CMakeLists.txt b/Tests/CxxOnly/CMakeLists.txt index bfc827116..5d278906c 100644 --- a/Tests/CxxOnly/CMakeLists.txt +++ b/Tests/CxxOnly/CMakeLists.txt @@ -2,7 +2,10 @@ project (CxxOnly CXX) set(CMAKE_DEBUG_POSTFIX "_test_debug_postfix") -add_library(testcxx1 STATIC libcxx1.cxx) +if(WIN32) + set(EXTRA_SRCS test.CPP) +endif() +add_library(testcxx1.my STATIC libcxx1.cxx ${EXTRA_SRCS}) add_library(testcxx2 SHARED libcxx2.cxx) add_executable (CxxOnly cxxonly.cxx) -target_link_libraries(CxxOnly testcxx1 testcxx2) +target_link_libraries(CxxOnly testcxx1.my testcxx2) diff --git a/Tests/CxxOnly/cxxonly.cxx b/Tests/CxxOnly/cxxonly.cxx index 99ccf3b61..9cf6f2d29 100644 --- a/Tests/CxxOnly/cxxonly.cxx +++ b/Tests/CxxOnly/cxxonly.cxx @@ -1,10 +1,16 @@ #include "libcxx1.h" #include "libcxx2.h" +#ifdef _MSC_VER +extern int testCPP; +#endif #include int main () { +#ifdef _MSC_VER + testCPP = 1; +#endif if ( LibCxx1Class::Method() != 2.0 ) { printf("Problem with libcxx1\n"); diff --git a/Tests/CxxOnly/test.CPP b/Tests/CxxOnly/test.CPP new file mode 100644 index 000000000..8a3cde262 --- /dev/null +++ b/Tests/CxxOnly/test.CPP @@ -0,0 +1 @@ +int testCPP; diff --git a/Tests/Dependency/Four/CMakeLists.txt b/Tests/Dependency/Four/CMakeLists.txt index ba3711fe6..df0f1624e 100644 --- a/Tests/Dependency/Four/CMakeLists.txt +++ b/Tests/Dependency/Four/CMakeLists.txt @@ -1,3 +1,6 @@ +INCLUDE_DIRECTORIES(${Dependency_BINARY_DIR}/Two) ADD_LIBRARY( Four FourSrc.c ) TARGET_LINK_LIBRARIES( Four One Two NoDepA ) +# TwoCustom must build before Four. +ADD_DEPENDENCIES(Four TwoCustom) diff --git a/Tests/Dependency/Four/FourSrc.c b/Tests/Dependency/Four/FourSrc.c index e8fefcda2..23a66a49a 100644 --- a/Tests/Dependency/Four/FourSrc.c +++ b/Tests/Dependency/Four/FourSrc.c @@ -1,3 +1,4 @@ +#include /* Requires TwoCustom to be built first. */ void NoDepAFunction(); void OneFunction(); void TwoFunction(); diff --git a/Tests/EmptyLibrary/CMakeLists.txt b/Tests/EmptyLibrary/CMakeLists.txt new file mode 100644 index 000000000..baddbbf5e --- /dev/null +++ b/Tests/EmptyLibrary/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 2.6) +project(TestEmptyLibrary) + +add_subdirectory(subdir) diff --git a/Tests/EmptyLibrary/subdir/CMakeLists.txt b/Tests/EmptyLibrary/subdir/CMakeLists.txt new file mode 100644 index 000000000..e273f8db9 --- /dev/null +++ b/Tests/EmptyLibrary/subdir/CMakeLists.txt @@ -0,0 +1 @@ +add_library(test test.h) diff --git a/Tests/EmptyLibrary/subdir/test.h b/Tests/EmptyLibrary/subdir/test.h new file mode 100644 index 000000000..8511f53d6 --- /dev/null +++ b/Tests/EmptyLibrary/subdir/test.h @@ -0,0 +1 @@ +extern int dummy; diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt index 99da9c466..a878194d7 100644 --- a/Tests/ExternalProject/CMakeLists.txt +++ b/Tests/ExternalProject/CMakeLists.txt @@ -7,9 +7,20 @@ find_package(CVS) find_package(Subversion) find_package(Git) +option(ExternalProjectTest_USE_FOLDERS "Enable folder grouping in IDEs." ON) +if(ExternalProjectTest_USE_FOLDERS) + set_property(GLOBAL PROPERTY USE_FOLDERS ON) +else() + set_property(GLOBAL PROPERTY USE_FOLDERS OFF) +endif() + +set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER + "CMakePredefinedTargets-in-ExternalProjectTest") + set(base "${CMAKE_BINARY_DIR}/CMakeExternals") set(binary_base "${base}/Build") set_property(DIRECTORY PROPERTY EP_BASE ${base}) +set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure build test) if(NOT DEFINED can_build_tutorial_step5) set(can_build_tutorial_step5 1) @@ -41,6 +52,31 @@ endif() # Empty projects that test all the known ExternalProject_Add argument key words: # +set(proj AAA-TestAlphabetization) +ExternalProject_Add(${proj} + BUILD_COMMAND "" + CONFIGURE_COMMAND "" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" +) + +set(proj ZZZ-TestAlphabetization) +ExternalProject_Add(${proj} + BUILD_COMMAND "" + CONFIGURE_COMMAND "" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" +) + +set(proj TargetNameSameAsFolder) +ExternalProject_Add(${proj} + BUILD_COMMAND "" + CONFIGURE_COMMAND "" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" +) +set_property(TARGET ${proj} PROPERTY FOLDER "${proj}") + set(proj MinimalNoOpProject) ExternalProject_Add(${proj} BUILD_COMMAND "" @@ -61,6 +97,7 @@ ExternalProject_Add(${proj} DOWNLOAD_COMMAND "" INSTALL_COMMAND "" PATCH_COMMAND "" + STEP_TARGETS install update SVN_REPOSITORY "" SVN_REVISION "" TEST_COMMAND "" @@ -69,6 +106,7 @@ ExternalProject_Add(${proj} URL_MD5 "" UPDATE_COMMAND "" ) +set_property(TARGET ${proj} PROPERTY FOLDER "") # Local DIR: @@ -79,7 +117,9 @@ if(can_build_tutorial_step5) URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= -G ${CMAKE_GENERATOR} TEST_BEFORE_INSTALL 1 + LOG_INSTALL 1 ) + set_property(TARGET ${proj} PROPERTY FOLDER "Local") ExternalProject_Get_Property(${proj} install_dir) set(TutorialStep5_install_dir ${install_dir}) @@ -88,7 +128,9 @@ if(can_build_tutorial_step5) URL "${CMAKE_CURRENT_SOURCE_DIR}/../Tutorial/Step5" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= -G ${CMAKE_GENERATOR} TEST_AFTER_INSTALL 1 + LOG_TEST 1 ) + set_property(TARGET ${proj} PROPERTY FOLDER "Local") endif() @@ -104,7 +146,9 @@ ExternalProject_Add(${proj} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= -DTEST_LIST:STRING=A::B::C INSTALL_COMMAND "" + LOG_CONFIGURE 1 ) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/TAR") set(proj TutorialStep1-LocalNoDirTAR) ExternalProject_Add(${proj} @@ -115,6 +159,7 @@ ExternalProject_Add(${proj} -DTEST_LIST:STRING=1@@2@@3 INSTALL_COMMAND "" ) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/TAR") ExternalProject_Add_Step(${proj} mypatch COMMAND ${CMAKE_COMMAND} -E echo "This is a custom external project step." COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/Step1Patch.cmake @@ -132,7 +177,9 @@ ExternalProject_Add(${proj} URL_MD5 38c648e817339c356f6be00eeed79bd0 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= -G ${CMAKE_GENERATOR} INSTALL_COMMAND "" + LOG_BUILD 1 ) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/TGZ") set(proj TutorialStep1-LocalNoDirTGZ) ExternalProject_Add(${proj} @@ -142,6 +189,7 @@ ExternalProject_Add(${proj} CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= INSTALL_COMMAND "" ) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/TGZ") # Local BZ2: @@ -158,6 +206,7 @@ ExternalProject_Add(${proj} BUILD_COMMAND "" INSTALL_COMMAND "" ) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/BZ2") set(proj TutorialStep1-LocalNoDirBZ2) ExternalProject_Add(${proj} @@ -166,6 +215,7 @@ ExternalProject_Add(${proj} BUILD_COMMAND "" INSTALL_COMMAND "" ) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/BZ2") # Local ZIP: @@ -182,6 +232,7 @@ ExternalProject_Add(${proj} BUILD_COMMAND "" INSTALL_COMMAND "" ) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/ZIP") set(proj TutorialStep1-LocalNoDirZIP) ExternalProject_Add(${proj} @@ -190,6 +241,7 @@ ExternalProject_Add(${proj} BUILD_COMMAND "" INSTALL_COMMAND "" ) +set_property(TARGET ${proj} PROPERTY FOLDER "Local/ZIP") # CVS-based tests: @@ -221,6 +273,8 @@ if(do_cvs_tests) CONFIGURE_COMMAND "${CVS_EXECUTABLE}" --version INSTALL_COMMAND "" ) + set_property(TARGET ${proj} + PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing") # CVS by date stamp: # @@ -235,6 +289,7 @@ if(do_cvs_tests) INSTALL_COMMAND "" DEPENDS "SetupLocalCVSRepository" ) + set_property(TARGET ${proj} PROPERTY FOLDER "CVS") # CVS by tag: # @@ -249,6 +304,7 @@ if(do_cvs_tests) INSTALL_COMMAND "" DEPENDS "SetupLocalCVSRepository" ) + set_property(TARGET ${proj} PROPERTY FOLDER "CVS") # Live CVS / HEAD (no CVS_TAG): # @@ -268,6 +324,7 @@ if(do_cvs_tests) DEPENDS "TutorialStep1-CVS-20090626" DEPENDS "TutorialStep1-CVS-testtag1" ) + set_property(TARGET ${proj} PROPERTY FOLDER "CVS") endif() @@ -320,6 +377,8 @@ if(do_svn_tests) CONFIGURE_COMMAND "${Subversion_SVN_EXECUTABLE}" --version INSTALL_COMMAND "" ) + set_property(TARGET ${proj} + PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing") # SVN by date stamp: # @@ -333,6 +392,7 @@ if(do_svn_tests) INSTALL_COMMAND "" DEPENDS "SetupLocalSVNRepository" ) + set_property(TARGET ${proj} PROPERTY FOLDER "SVN") # SVN by revision number: # @@ -346,6 +406,7 @@ if(do_svn_tests) INSTALL_COMMAND "" DEPENDS "SetupLocalSVNRepository" ) + set_property(TARGET ${proj} PROPERTY FOLDER "SVN") # Live SVN / trunk (no SVN_REVISION): # @@ -356,7 +417,9 @@ if(do_svn_tests) CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= INSTALL_COMMAND "" DEPENDS "SetupLocalSVNRepository" + LOG_DOWNLOAD 1 ) + set_property(TARGET ${proj} PROPERTY FOLDER "SVN") endif() @@ -394,6 +457,8 @@ if(do_git_tests) CONFIGURE_COMMAND "${GIT_EXECUTABLE}" --version INSTALL_COMMAND "" ) + set_property(TARGET ${proj} + PROPERTY FOLDER "SetupRepos/Local/Deeply/Nested/For/Testing") # git by commit id: # @@ -407,6 +472,7 @@ if(do_git_tests) INSTALL_COMMAND "" DEPENDS "SetupLocalGITRepository" ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") # git by explicit branch/tag name: # @@ -420,6 +486,7 @@ if(do_git_tests) INSTALL_COMMAND "" DEPENDS "SetupLocalGITRepository" ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") # Live git / master (no GIT_TAG): # @@ -430,7 +497,9 @@ if(do_git_tests) CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= INSTALL_COMMAND "" DEPENDS "SetupLocalGITRepository" + LOG_UPDATE 1 ) + set_property(TARGET ${proj} PROPERTY FOLDER "GIT") endif() diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 74cc11568..a472beab6 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -54,6 +54,10 @@ SET(CMAKE_FIND_APPBUNDLE FIRST) # Set the wrong answer for a find to make sure it re-finds. set(VersionedA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/cmake/zot-4.0) +# Test that CMAKE_IGNORE_PATH can ignore the purposely bad package +# files in the lib/cmake/zot-3.1 directory. +set(CMAKE_IGNORE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib/cmake/zot-3.1) + # Look for packages with new-style signatures. FIND_PACKAGE(foo NO_MODULE) FIND_PACKAGE(Foo CONFIGS FooConfig.cmake) diff --git a/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config-version.cmake b/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config-version.cmake new file mode 100644 index 000000000..bee2f0eea --- /dev/null +++ b/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config-version.cmake @@ -0,0 +1,4 @@ +# Claim to be any version to test that CMAKE_IGNORE_PATH hides us. +SET(PACKAGE_VERSION 3.1) +SET(PACKAGE_VERSION_COMPATIBLE 1) +SET(PACKAGE_VERSION_EXACT 1) diff --git a/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config.cmake b/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config.cmake new file mode 100644 index 000000000..2fbd525f3 --- /dev/null +++ b/Tests/FindPackageTest/lib/cmake/zot-3.1/zot-config.cmake @@ -0,0 +1,2 @@ +# Test config file. +message(WARNING "CMAKE_IGNORE_PATH failed to ignore this file!") diff --git a/Tests/FunctionTest/CMakeLists.txt b/Tests/FunctionTest/CMakeLists.txt index ef5517349..5d4f42d4a 100644 --- a/Tests/FunctionTest/CMakeLists.txt +++ b/Tests/FunctionTest/CMakeLists.txt @@ -166,3 +166,11 @@ ELSE(DEFINED SUBDIR_DEFINED) ENDIF(DEFINED SUBDIR_DEFINED) ADD_EXECUTABLE(FunctionTest functionTest.c) + +# Use the PROJECT_LABEL property: in IDEs, the project label should appear +# in the UI rather than the target name. If this were a good test of the +# property rather than just a smoke test, it would verify that the label +# actually appears in the UI of the IDE... Or at least that the text appears +# somewhere in the generated project files. +SET_PROPERTY(TARGET miniFunctionTest + PROPERTY PROJECT_LABEL "Test de Fonctionnement") diff --git a/Tests/MissingSourceFile/CMakeLists.txt b/Tests/MissingSourceFile/CMakeLists.txt new file mode 100644 index 000000000..42b7c5123 --- /dev/null +++ b/Tests/MissingSourceFile/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(MissingSourceFile C) +add_executable(MissingSourceFile MissingSourceFile.c) diff --git a/Utilities/Doxygen/CMakeLists.txt b/Utilities/Doxygen/CMakeLists.txt index 8888aba0d..5d076e041 100644 --- a/Utilities/Doxygen/CMakeLists.txt +++ b/Utilities/Doxygen/CMakeLists.txt @@ -27,15 +27,15 @@ IF (BUILD_DOCUMENTATION) ENDIF(NOT DOT_PATH) CONFIGURE_FILE( - ${CMAKE_SOURCE_DIR}/Utilities/Doxygen/doxyfile.in - ${CMAKE_BINARY_DIR}/Utilities/Doxygen/doxyfile) + ${CMake_SOURCE_DIR}/Utilities/Doxygen/doxyfile.in + ${CMake_BINARY_DIR}/Utilities/Doxygen/doxyfile) CONFIGURE_FILE( - ${CMAKE_SOURCE_DIR}/Utilities/Doxygen/doc_makeall.sh.in - ${CMAKE_BINARY_DIR}/Utilities/Doxygen/doc_makeall.sh) + ${CMake_SOURCE_DIR}/Utilities/Doxygen/doc_makeall.sh.in + ${CMake_BINARY_DIR}/Utilities/Doxygen/doc_makeall.sh) ADD_CUSTOM_TARGET(DoxygenDoc ${BASH} - ${CMAKE_BINARY_DIR}/Utilities/Doxygen/doc_makeall.sh) + ${CMake_BINARY_DIR}/Utilities/Doxygen/doc_makeall.sh) ENDIF (BUILD_DOCUMENTATION) diff --git a/Utilities/Doxygen/doc_makeall.sh.in b/Utilities/Doxygen/doc_makeall.sh.in index e5cf2406e..a1b00e7d0 100755 --- a/Utilities/Doxygen/doc_makeall.sh.in +++ b/Utilities/Doxygen/doc_makeall.sh.in @@ -48,7 +48,7 @@ export PATH_TO_VTK_DOX_SCRIPTS="@VTK_SOURCE_DIR@/Utilities/Doxygen" # Example: # SOURCE_DIR=@VTK_SOURCE_DIR@ # -export SOURCE_DIR="@CMAKE_SOURCE_DIR@" +export SOURCE_DIR="@CMake_SOURCE_DIR@" # REL_PATH_TO_TOP: # Relative path from the top directory of the source files to the directory @@ -71,7 +71,7 @@ export REL_PATH_TO_TOP=. # DOXTEMP=DOXTEMP=@VTK_BINARY_DIR@/Utilities/Doxygen # INTERMEDIATE_DOX_DIR=$DOXTEMP/dox # -export DOXTEMP="@CMAKE_BINARY_DIR@/Utilities/Doxygen" +export DOXTEMP="@CMake_BINARY_DIR@/Utilities/Doxygen" export INTERMEDIATE_DOX_DIR="$DOXTEMP/dox" # DOXYFILE: diff --git a/Utilities/Doxygen/doxyfile.in b/Utilities/Doxygen/doxyfile.in index ad5e3775f..c3d3a3869 100644 --- a/Utilities/Doxygen/doxyfile.in +++ b/Utilities/Doxygen/doxyfile.in @@ -31,19 +31,19 @@ GRAPHICAL_HIERARCHY = YES ALLEXTERNALS = NO -IMAGE_PATH = "@CMAKE_BINARY_DIR@/Utilities/Doxygen/contrib" +IMAGE_PATH = "@CMake_BINARY_DIR@/Utilities/Doxygen/contrib" -OUTPUT_DIRECTORY = "@CMAKE_BINARY_DIR@/Utilities/Doxygen/doc" +OUTPUT_DIRECTORY = "@CMake_BINARY_DIR@/Utilities/Doxygen/doc" INPUT = \ - "@CMAKE_SOURCE_DIR@/Source" \ - "@CMAKE_SOURCE_DIR@/Source/CPack" \ - "@CMAKE_SOURCE_DIR@/Source/CTest" \ - "@CMAKE_SOURCE_DIR@/Source/CursesDialog" \ - "@CMAKE_SOURCE_DIR@/Source/MFCDialog" \ - "@CMAKE_BINARY_DIR@/Source/kwsys" \ - "@CMAKE_BINARY_DIR@/Source/cmsys" \ - "@CMAKE_BINARY_DIR@/Utilities/Doxygen/dox/doc_CMake_contributors.dox" \ + "@CMake_SOURCE_DIR@/Source" \ + "@CMake_SOURCE_DIR@/Source/CPack" \ + "@CMake_SOURCE_DIR@/Source/CTest" \ + "@CMake_SOURCE_DIR@/Source/CursesDialog" \ + "@CMake_SOURCE_DIR@/Source/MFCDialog" \ + "@CMake_BINARY_DIR@/Source/kwsys" \ + "@CMake_BINARY_DIR@/Source/cmsys" \ + "@CMake_BINARY_DIR@/Utilities/Doxygen/dox/doc_CMake_contributors.dox" \ EXTRACT_ALL = YES EXTRACT_PRIVATE = NO diff --git a/Utilities/KWStyle/CMake.kws.xml.in b/Utilities/KWStyle/CMake.kws.xml.in index 9c5efeee0..c2b442940 100644 --- a/Utilities/KWStyle/CMake.kws.xml.in +++ b/Utilities/KWStyle/CMake.kws.xml.in @@ -2,7 +2,7 @@ 79