Merge branch 'master' into CONFIG-LOCATION-CMP0026

This commit is contained in:
Brad King 2014-03-17 09:31:21 -04:00
commit 6e466c6f2e
701 changed files with 9599 additions and 7089 deletions

View File

@ -21,7 +21,9 @@ if(CMAKE_BOOTSTRAP)
unset(CMAKE_BOOTSTRAP CACHE)
endif()
if(NOT CMake_TEST_EXTERNAL_CMAKE)
set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin)
endif()
if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
# Disallow architecture-specific try_run. It may not run on the host.
@ -102,10 +104,12 @@ endmacro()
if(NOT CMake_TEST_EXTERNAL_CMAKE)
set(CMAKE_BUILD_ON_VISUAL_STUDIO 0)
if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW )
set(CMAKE_BUILD_ON_VISUAL_STUDIO 1)
endif()
endif()
#-----------------------------------------------------------------------
@ -114,29 +118,6 @@ endif()
#-----------------------------------------------------------------------
macro(CMAKE_SETUP_TESTING)
if(BUILD_TESTING)
set(CMAKE_TEST_GENERATOR "" CACHE STRING
"Generator used when running tests")
set(CMAKE_TEST_MAKEPROGRAM "" CACHE FILEPATH
"Generator used when running tests")
if(NOT CMAKE_TEST_GENERATOR)
set(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}")
set(CMAKE_TEST_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}")
else()
set(CMAKE_TEST_DIFFERENT_GENERATOR TRUE)
set(CMAKE_TEST_GENERATOR_TOOLSET "")
endif()
# Are we testing with the MSVC compiler?
set(CMAKE_TEST_MSVC 0)
if(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR)
set(CMAKE_TEST_MSVC 1)
else()
if("${CMAKE_TEST_GENERATOR}" MATCHES "NMake" OR
"${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio")
set(CMAKE_TEST_MSVC 1)
endif()
endif()
set(CMAKE_TEST_SYSTEM_LIBRARIES 0)
foreach(util CURL EXPAT XMLRPC ZLIB)
if(CMAKE_USE_SYSTEM_${util})
@ -149,10 +130,20 @@ macro(CMAKE_SETUP_TESTING)
# the ctest from this cmake is used for testing
# and not the ctest from the cmake building and testing
# cmake.
if(CMake_TEST_EXTERNAL_CMAKE)
set(CMAKE_CTEST_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/ctest")
set(CMAKE_CMAKE_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cmake")
set(CMAKE_CPACK_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cpack")
foreach(exe cmake ctest cpack)
add_executable(${exe} IMPORTED)
set_property(TARGET ${exe} PROPERTY IMPORTED_LOCATION ${CMake_TEST_EXTERNAL_CMAKE}/${exe})
endforeach()
else()
set(CMAKE_CTEST_COMMAND "${CMake_BIN_DIR}/ctest")
set(CMAKE_CMAKE_COMMAND "${CMake_BIN_DIR}/cmake")
set(CMAKE_CPACK_COMMAND "${CMake_BIN_DIR}/cpack")
endif()
endif()
# configure some files for testing
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Templates/CTestScript.cmake.in"
@ -164,8 +155,6 @@ macro(CMAKE_SETUP_TESTING)
${CMake_BINARY_DIR}/Modules/.NoDartCoverage)
configure_file(${CMake_SOURCE_DIR}/CTestCustom.cmake.in
${CMake_BINARY_DIR}/CTestCustom.cmake @ONLY)
configure_file(${CMake_SOURCE_DIR}/CTestCustom.ctest.in
${CMake_BINARY_DIR}/CTestCustom.ctest @ONLY)
if(BUILD_TESTING AND DART_ROOT)
configure_file(${CMake_SOURCE_DIR}/CMakeLogo.gif
${CMake_BINARY_DIR}/Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY)
@ -387,6 +376,7 @@ macro (CMAKE_BUILD_UTILITIES)
endmacro ()
#-----------------------------------------------------------------------
if(NOT CMake_TEST_EXTERNAL_CMAKE)
if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD")
execute_process(COMMAND ${CMAKE_CXX_COMPILER}
${CMAKE_CXX_COMPILER_ARG1} -dumpversion
@ -401,6 +391,7 @@ if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD")
"${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}")
endif()
endif()
endif()
#-----------------------------------------------------------------------
# The main section of the CMakeLists file
@ -417,6 +408,7 @@ include (${CMAKE_ROOT}/Modules/Dart.cmake)
set_directory_properties(PROPERTIES
TEST_INCLUDE_FILE "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake")
if(NOT CMake_TEST_EXTERNAL_CMAKE)
# where to write the resulting executables and libraries
set(BUILD_SHARED_LIBS OFF)
set(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.")
@ -441,6 +433,7 @@ include(CompileFlags.cmake)
include(CheckSymbolExists)
CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV)
CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
endif()
# CMAKE_TESTS_CDASH_SERVER: CDash server used by CMake/Tests.
#
@ -459,6 +452,7 @@ if("x${CMAKE_TESTS_CDASH_SERVER}" STREQUAL "x")
set(CMAKE_TESTS_CDASH_SERVER "http://www.cdash.org/CDash")
endif()
if(NOT CMake_TEST_EXTERNAL_CMAKE)
# build the utilities (a macro defined in this file)
CMAKE_BUILD_UTILITIES()
@ -523,6 +517,8 @@ add_custom_target(uninstall
include (CMakeCPack.cmake)
endif()
# setup some Testing support (a macro defined in this file)
CMAKE_SETUP_TESTING()
configure_file(
@ -530,6 +526,7 @@ configure_file(
"${CMAKE_CURRENT_BINARY_DIR}/DartLocal.conf"
COPYONLY)
if(NOT CMake_TEST_EXTERNAL_CMAKE)
if(NOT CMake_VERSION_IS_RELEASE)
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND
NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2)
@ -557,8 +554,11 @@ endif()
# build the remaining subdirectories
add_subdirectory(Source)
add_subdirectory(Utilities)
endif()
add_subdirectory(Tests)
if(NOT CMake_TEST_EXTERNAL_CMAKE)
if(BUILD_TESTING)
CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests")
endif()
@ -566,11 +566,13 @@ CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat")
if(TARGET documentation)
CMAKE_SET_TARGET_FOLDER(documentation "Documentation")
endif()
endif()
# add a test
add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
--system-information -G "${CMAKE_TEST_GENERATOR}" )
--system-information -G "${CMAKE_GENERATOR}" )
if(NOT CMake_TEST_EXTERNAL_CMAKE)
# Install license file as it requires.
install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR})
@ -589,3 +591,4 @@ install(
# Install auxiliary files integrating with other tools.
add_subdirectory(Auxiliary)
endif()

View File

@ -18,8 +18,3 @@ set(CTEST_DROP_LOCATION "/CDash/submit.php?project=CMake")
set(CTEST_DROP_SITE_CDASH TRUE)
set(CTEST_CDASH_VERSION "1.6")
set(CTEST_CDASH_QUERY_VERSION TRUE)
# use old trigger stuff so that cmake 2.4 and below will not
# get errors on trigger
set (TRIGGER_SITE
"http://public.kitware.com/cgi-bin/Submit-CMake-TestingResults.cgi")

View File

@ -39,6 +39,8 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION
"Warning: public.*BZ2_bz.*in module.*bzlib.*clashes with prior module.*bzlib.*"
"Warning: public.*_archive.*clashes with prior module.*"
"Warning: LINN32: Last line.*is less.*"
"Warning: Olimit was exceeded on function.*"
"Warning: To override Olimit for all functions in file.*"
"warning.*directory name.*CMake-Xcode.*/bin/.*does not exist.*"
"stl_deque.h:1051"
"(Lexer|Parser).*warning.*conversion.*may (alter its value|change the sign)"

View File

@ -1,3 +0,0 @@
# This file is provided for compatibility with CMake 2.2 and lower.
# Just include the custom file by its new name.
INCLUDE("CTestCustom.cmake")

View File

@ -55,7 +55,7 @@ used in a comparison with the iterator returned by ``end()``:
.. code-block:: c++
const std::set<cmStdString>& someSet = getSet();
const std::set<std::string>& someSet = getSet();
if (someSet.find("needle") == someSet.end()) // Wrong
{
// ...
@ -66,8 +66,8 @@ The return value of ``find()`` must be assigned to an intermediate
.. code-block:: c++
const std::set<cmStdString>& someSet;
const std::set<cmStdString>::const_iterator i = someSet.find("needle");
const std::set<std::string>& someSet;
const std::set<std::string>::const_iterator i = someSet.find("needle");
if (i != propSet.end()) // Ok
{
// ...
@ -110,7 +110,7 @@ conversion is not allowed:
.. code-block:: c++
std::set<cmStdString> theSet;
std::set<const char*> theSet;
std::vector<std::string> theVector;
theVector.insert(theVector.end(), theSet.begin(), theSet.end()); // Wrong
@ -118,9 +118,9 @@ A loop must be used instead:
.. code-block:: c++
std::set<cmStdString> theSet;
std::set<const char*> theSet;
std::vector<std::string> theVector;
for(std::set<cmStdString>::iterator li = theSet.begin();
for(std::set<const char*>::iterator li = theSet.begin();
li != theSet.end(); ++li)
{
theVector.push_back(*li);

View File

@ -138,6 +138,7 @@ All Modules
/module/FindMPEG
/module/FindMPI
/module/FindOpenAL
/module/FindOpenCL
/module/FindOpenGL
/module/FindOpenMP
/module/FindOpenSceneGraph

View File

@ -100,6 +100,10 @@ Properties on Targets
/prop_tgt/COMPILE_DEFINITIONS
/prop_tgt/COMPILE_FLAGS
/prop_tgt/COMPILE_OPTIONS
/prop_tgt/COMPILE_PDB_NAME
/prop_tgt/COMPILE_PDB_NAME_CONFIG
/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY
/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
/prop_tgt/CONFIG_OUTPUT_NAME
/prop_tgt/CONFIG_POSTFIX
/prop_tgt/DEBUG_POSTFIX

View File

@ -200,6 +200,8 @@ Variables that Control the Build
/variable/CMAKE_AUTOUIC
/variable/CMAKE_AUTOUIC_OPTIONS
/variable/CMAKE_BUILD_WITH_INSTALL_RPATH
/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
/variable/CMAKE_CONFIG_POSTFIX
/variable/CMAKE_DEBUG_POSTFIX
/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG

View File

@ -0,0 +1 @@
.. cmake-module:: ../../Modules/FindOpenCL.cmake

View File

@ -0,0 +1,11 @@
COMPILE_PDB_NAME
----------------
Output name for the MS debug symbol ``.pdb`` file generated by the
compiler while building source files.
This property specifies the base name for the debug symbols file.
If not set, the default is unspecified.
.. |PDB_XXX| replace:: :prop_tgt:`PDB_NAME`
.. include:: COMPILE_PDB_NOTE.txt

View File

@ -0,0 +1,10 @@
COMPILE_PDB_NAME_<CONFIG>
-------------------------
Per-configuration output name for the MS debug symbol ``.pdb`` file
generated by the compiler while building source files.
This is the configuration-specific version of :prop_tgt:`COMPILE_PDB_NAME`.
.. |PDB_XXX| replace:: :prop_tgt:`PDB_NAME_<CONFIG>`
.. include:: COMPILE_PDB_NOTE.txt

View File

@ -0,0 +1,8 @@
.. note::
The compiler-generated program database files are specified by the
``/Fd`` compiler flag and are not the same as linker-generated
program database files specified by the ``/pdb`` linker flag.
Use the |PDB_XXX| property to specify the latter.
This property is not implemented by the :generator:`Visual Studio 6`
generator.

View File

@ -0,0 +1,13 @@
COMPILE_PDB_OUTPUT_DIRECTORY
----------------------------
Output directory for the MS debug symbol ``.pdb`` file
generated by the compiler while building source files.
This property specifies the directory into which the MS debug symbols
will be placed by the compiler. This property is initialized by the
value of the :variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY` variable
if it is set when a target is created.
.. |PDB_XXX| replace:: :prop_tgt:`PDB_OUTPUT_DIRECTORY`
.. include:: COMPILE_PDB_NOTE.txt

View File

@ -0,0 +1,16 @@
COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>
-------------------------------------
Per-configuration output directory for the MS debug symbol ``.pdb`` file
generated by the compiler while building source files.
This is a per-configuration version of
:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY`,
but multi-configuration generators (VS, Xcode) do NOT append a
per-configuration subdirectory to the specified directory. This
property is initialized by the value of the
:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>` variable
if it is set when a target is created.
.. |PDB_XXX| replace:: :prop_tgt:`PDB_OUTPUT_DIRECTORY_<CONFIG>`
.. include:: COMPILE_PDB_NOTE.txt

View File

@ -7,7 +7,5 @@ linker for an executable or shared library target.
This property specifies the base name for the debug symbols file.
If not set, the logical target name is used by default.
.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_NAME`
.. include:: PDB_NOTE.txt
This property is not implemented by the :generator:`Visual Studio 6`
generator.

View File

@ -6,5 +6,5 @@ generated by the linker for an executable or shared library target.
This is the configuration-specific version of :prop_tgt:`PDB_NAME`.
This property is not implemented by the :generator:`Visual Studio 6`
generator.
.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_NAME_<CONFIG>`
.. include:: PDB_NOTE.txt

View File

@ -3,6 +3,10 @@
is invoked to produce them so they have no linker-generated ``.pdb`` file
containing debug symbols.
The compiler-generated program database files specified by the MSVC
``/Fd`` flag are not the same as linker-generated program database
files and so are not influenced by this property.
The linker-generated program database files are specified by the
``/pdb`` linker flag and are not the same as compiler-generated
program database files specified by the ``/Fd`` compiler flag.
Use the |COMPILE_PDB_XXX| property to specify the latter.
This property is not implemented by the :generator:`Visual Studio 6`
generator.

View File

@ -9,7 +9,5 @@ will be placed by the linker. This property is initialized by the
value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY` variable if it is
set when a target is created.
.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY`
.. include:: PDB_NOTE.txt
This property is not implemented by the :generator:`Visual Studio 6`
generator.

View File

@ -11,5 +11,5 @@ property is initialized by the value of the
:variable:`CMAKE_PDB_OUTPUT_DIRECTORY_<CONFIG>` variable if it is
set when a target is created.
This property is not implemented by the :generator:`Visual Studio 6`
generator.
.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>`
.. include:: PDB_NOTE.txt

View File

@ -0,0 +1,7 @@
0-sample-topic
--------------
* This is a sample release note for the change in a topic.
Developers should add similar notes for each topic branch
making a noteworthy change. Each document should be named
and titled to match the topic name to avoid merge conflicts.

View File

@ -0,0 +1,6 @@
ExternalProject-BUILD_ALWAYS
----------------------------
* The :module:`ExternalProject` module ``ExternalProject_Add`` command
learned a new ``BUILD_ALWAYS`` option to cause the external project
build step to run every time the host project is built.

View File

@ -0,0 +1,6 @@
FeatureSummary_combine_WHAT_values
----------------------------------
* The :module:`FeatureSummary` module ``feature_summary`` API
learned to accept multiple values for the ``WHAT`` option and
combine them appropriately.

View File

@ -0,0 +1,7 @@
FindGTest-AUTO-SOURCES
----------------------
* The :module:`FindGTest` module ``gtest_add_tests`` macro learned
a new ``AUTO`` option to automatically read the :prop_tgt:`SOURCES`
target property of the test executable and scan the source files
for tests to be added.

View File

@ -0,0 +1,5 @@
FindHg-WC_INFO
--------------
* The :module:`FindHg` module gained a new ``Hg_WC_INFO`` macro to
help run ``hg`` to extract information about a Mercurial work copy.

View File

@ -0,0 +1,5 @@
FindPkgConfig-PKG_CONFIG
------------------------
* The :module:`FindPkgConfig` module learned to use the ``PKG_CONFIG``
environment variable value as the ``pkg-config`` executable, if set.

View File

@ -0,0 +1,4 @@
add-FindOpenCL
--------------
* The :module:`FindOpenCL` module was introduced.

View File

@ -0,0 +1,6 @@
cpack-deb-compression-types
---------------------------
* The :module:`CPackDeb` module learned a new
:variable:`CPACK_DEBIAN_COMPRESSION_TYPE` variable to set the
tarball compression type.

View File

@ -0,0 +1,5 @@
ctest-coverage-extra
--------------------
* The :command:`ctest_coverage` command learned to read variable
``CTEST_COVERAGE_EXTRA_FLAGS`` to set ``CoverageExtraFlags``.

View File

@ -0,0 +1,5 @@
ctest-intel-coverage
--------------------
* The :command:`ctest_coverage` command learned to support
Intel coverage files with the ``codecov`` tool.

View File

@ -0,0 +1,6 @@
faster-parsers
--------------
* The :manual:`cmake-language(7)` internal implementation of generator
expression and list expansion parsers have been optimized and shows
non-trivial speedup on large projects.

View File

@ -0,0 +1,5 @@
link-libraries-response-files
-----------------------------
* The Makefile generators learned to use response files with GNU tools
on Windows to pass library directories and names to the linker.

View File

@ -0,0 +1,10 @@
msvc-compiler-pdb-files
-----------------------
* New :prop_tgt:`COMPILE_PDB_NAME` and
:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` target properties
were introduced to specify the MSVC compiler program database
file location (``cl /Fd``). This complements the existing
:prop_tgt:`PDB_NAME` and :prop_tgt:`PDB_OUTPUT_DIRECTORY`
target properties that specify the linker program database
file location (``link /pdb``).

View File

@ -5,6 +5,8 @@ CMake Release Notes
This file should include the adjacent "dev.txt" file
in development versions but not in release versions.
.. include:: dev.txt
Releases
========

View File

@ -0,0 +1,8 @@
CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
----------------------------------
Output directory for MS debug symbol ``.pdb`` files
generated by the compiler while building source files.
This variable is used to initialize the
:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` property on all the targets.

View File

@ -0,0 +1,11 @@
CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>
-------------------------------------------
Per-configuration output directory for MS debug symbol ``.pdb`` files
generated by the compiler while building source files.
This is a per-configuration version of
:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY`.
This variable is used to initialize the
:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>`
property on all the targets.

View File

@ -1,7 +1,10 @@
CMAKE_HOST_SYSTEM
-----------------
Name of system cmake is being run on.
Composit Name of OS CMake is being run on.
The same as CMAKE_SYSTEM but for the host system instead of the target
system when cross compiling.
This variable is the composite of :variable:`CMAKE_HOST_SYSTEM_NAME` and
:variable:`CMAKE_HOST_SYSTEM_VERSION`, e.g.
``${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_VERSION}``. If
:variable:`CMAKE_HOST_SYSTEM_VERSION` is not set, then this variable is
the same as :variable:`CMAKE_HOST_SYSTEM_NAME`.

View File

@ -3,5 +3,6 @@ CMAKE_HOST_SYSTEM_NAME
Name of the OS CMake is running on.
The same as CMAKE_SYSTEM_NAME but for the host system instead of the
target system when cross compiling.
On systems that have the uname command, this variable is set to the
output of uname -s. ``Linux``, ``Windows``, and ``Darwin`` for Mac OS X
are the values found on the big three operating systems.

View File

@ -3,5 +3,6 @@ CMAKE_HOST_SYSTEM_PROCESSOR
The name of the CPU CMake is running on.
The same as CMAKE_SYSTEM_PROCESSOR but for the host system instead of
the target system when cross compiling.
On systems that support uname, this variable is set to the output of
uname -p, on windows it is set to the value of the environment variable
``PROCESSOR_ARCHITECTURE``.

View File

@ -1,7 +1,8 @@
CMAKE_HOST_SYSTEM_VERSION
-------------------------
OS version CMake is running on.
The OS version CMake is running on.
The same as CMAKE_SYSTEM_VERSION but for the host system instead of
the target system when cross compiling.
A numeric version string for the system. On systems that support
uname, this variable is set to the output of uname -r. On other
systems this is set to major-minor version numbers.

View File

@ -1,9 +1,10 @@
CMAKE_SYSTEM
------------
Name of system cmake is compiling for.
Composit Name of OS CMake is compiling for.
This variable is the composite of CMAKE_SYSTEM_NAME and
CMAKE_SYSTEM_VERSION, like this
${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}. If CMAKE_SYSTEM_VERSION
is not set, then CMAKE_SYSTEM is the same as CMAKE_SYSTEM_NAME.
This variable is the composite of :variable:`CMAKE_SYSTEM_NAME` and
:variable:`CMAKE_SYSTEM_VERSION`, e.g.
``${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}``. If
:variable:`CMAKE_SYSTEM_VERSION` is not set, then this variable is
the same as :variable:`CMAKE_SYSTEM_NAME`.

View File

@ -3,7 +3,6 @@ CMAKE_SYSTEM_NAME
Name of the OS CMake is building for.
This is the name of the operating system on which CMake is targeting.
On systems that have the uname command, this variable is set to the
output of uname -s. Linux, Windows, and Darwin for Mac OS X are the
values found on the big three operating systems.
This is the name of the OS on which CMake is targeting. This variable
is the same as :variable:`CMAKE_HOST_SYSTEM_NAME` if you build for the
host system instead of the target system when cross compiling.

View File

@ -3,6 +3,6 @@ CMAKE_SYSTEM_PROCESSOR
The name of the CPU CMake is building for.
On systems that support uname, this variable is set to the output of
uname -p, on windows it is set to the value of the environment
variable PROCESSOR_ARCHITECTURE
This variable is the same as :variable:`CMAKE_HOST_SYSTEM_PROCESSOR` if
you build for the host system instead of the target system when
cross compiling.

View File

@ -1,8 +1,8 @@
CMAKE_SYSTEM_VERSION
--------------------
OS version CMake is building for.
The OS version CMake is building for.
A numeric version string for the system, on systems that support
uname, this variable is set to the output of uname -r. On other
systems this is set to major-minor version numbers.
This variable is the same as :variable:`CMAKE_HOST_SYSTEM_VERSION` if
you build for the host system instead of the target system when
cross compiling.

View File

@ -31,14 +31,17 @@ macro(find_dependency dep)
if (NOT ${dep}_FOUND)
set(cmake_fd_version)
if (${ARGC} GREATER 1)
if (${ARGV1} STREQUAL EXACT)
if ("${ARGV1}" STREQUAL "")
message(FATAL_ERROR "Invalid arguments to find_dependency. VERSION is empty")
endif()
if ("${ARGV1}" STREQUAL EXACT)
message(FATAL_ERROR "Invalid arguments to find_dependency. EXACT may only be specified if a VERSION is specified")
endif()
set(cmake_fd_version ${ARGV1})
endif()
set(cmake_fd_exact_arg)
if(${ARGC} GREATER 2)
if (NOT ${ARGV2} STREQUAL EXACT)
if (NOT "${ARGV2}" STREQUAL EXACT)
message(FATAL_ERROR "Invalid arguments to find_dependency")
endif()
set(cmake_fd_exact_arg EXACT)

View File

@ -67,7 +67,12 @@
# * Mandatory : YES
# * Default : 'devel'
#
# The debian package section
# .. variable:: CPACK_DEBIAN_COMPRESSION_TYPE
#
# * Mandatory : YES
# * Default : 'gzip'
#
# Possible values are: lzma, xz, bzip2 and gzip.
#
# .. variable:: CPACK_DEBIAN_PACKAGE_PRIORITY
#
@ -390,6 +395,12 @@ if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
endif()
# Compression: (recommended)
if(NOT CPACK_DEBIAN_COMPRESSION_TYPE)
set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip")
endif()
# Recommends:
# You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS

View File

@ -216,9 +216,24 @@
# allow other CMake projects to find your package with
# the :command:`find_package` command.
#
# .. variable:: CPACK_WIX_PROPERTY_<PROPERTY>
#
# This variable can be used to provide a value for
# the Windows Installer property ``<PROPERTY>``
#
# The follwing list contains some example properties that can be used to
# customize information under
# "Programs and Features" (also known as "Add or Remove Programs")
#
# * ARPCOMMENTS - Comments
# * ARPHELPLINK - Help and support information URL
# * ARPURLINFOABOUT - General information URL
# * URLUPDATEINFO - Update information URL
# * ARPHELPTELEPHONE - Help and support telephone number
# * ARPSIZE - Size (in kilobytes) of the application
#=============================================================================
# Copyright 2013 Kitware, Inc.
# Copyright 2014 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.

View File

@ -54,6 +54,7 @@
# [BINARY_DIR dir] # Specify build dir location
# [BUILD_COMMAND cmd...] # Command to drive the native build
# [BUILD_IN_SOURCE 1] # Use source dir for build dir
# [BUILD_ALWAYS 1] # No stamp file, build step always runs
# #--Install step---------------
# [INSTALL_DIR dir] # Installation prefix
# [INSTALL_COMMAND cmd...] # Command to drive install after build
@ -1716,10 +1717,18 @@ function(_ep_add_build_command name)
set(log "")
endif()
get_property(build_always TARGET ${name} PROPERTY _EP_BUILD_ALWAYS)
if(build_always)
set(always 1)
else()
set(always 0)
endif()
ExternalProject_Add_Step(${name} build
COMMAND ${cmd}
WORKING_DIRECTORY ${binary_dir}
DEPENDEES configure
ALWAYS ${always}
${log}
)
endfunction()

View File

@ -71,6 +71,13 @@
# RUNTIME_PACKAGES_FOUND: only those packages which have been found which have the type RUNTIME
# RUNTIME_PACKAGES_NOT_FOUND: only those packages which have not been found which have the type RUNTIME
#
# With the exception of the ``ALL`` value, these values can be combined
# in order to customize the output. For example:
#
# ::
#
# feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
#
#
#
# If a FILENAME is given, the information is printed into this file. If
@ -417,8 +424,8 @@ endfunction()
function(FEATURE_SUMMARY)
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...)
set(options APPEND INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
set(oneValueArgs FILENAME VAR DESCRIPTION WHAT)
set(multiValueArgs ) # none
set(oneValueArgs FILENAME VAR DESCRIPTION)
set(multiValueArgs WHAT)
CMAKE_PARSE_ARGUMENTS(_FS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
@ -451,7 +458,8 @@ function(FEATURE_SUMMARY)
set(requiredPackagesNotFound TRUE)
endif()
elseif("${_FS_WHAT}" STREQUAL "ALL")
else()
if("${_FS_WHAT}" STREQUAL "ALL")
set(allWhatParts "ENABLED_FEATURES"
"RUNTIME_PACKAGES_FOUND"
@ -466,8 +474,26 @@ function(FEATURE_SUMMARY)
"REQUIRED_PACKAGES_NOT_FOUND"
)
else()
set(allWhatParts)
foreach(part ${_FS_WHAT})
list(FIND validWhatParts "${part}" indexInList)
if(NOT "${indexInList}" STREQUAL "-1")
list(APPEND allWhatParts "${part}")
else()
if("${part}" STREQUAL "ALL")
message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() contains ALL, which cannot be combined with other values.")
else()
message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() contains ${part}, which is not a valid value.")
endif()
endif()
endforeach()
endif()
set(title_ENABLED_FEATURES "The following features have been enabled:")
set(title_DISABLED_FEATURES "The following features have been disabled:")
set(title_PACKAGES_FOUND "The following packages have been found:")
set(title_PACKAGES_NOT_FOUND "The following packages have not been found:")
set(title_OPTIONAL_PACKAGES_FOUND "The following OPTIONAL packages have been found:")
set(title_OPTIONAL_PACKAGES_NOT_FOUND "The following OPTIONAL packages have not been found:")
set(title_RECOMMENDED_PACKAGES_FOUND "The following RECOMMENDED packages have been found:")
@ -488,8 +514,6 @@ function(FEATURE_SUMMARY)
endif()
endif()
endforeach()
else()
message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() is set to ${_FS_WHAT}, which is not a valid value.")
endif()
if(_FS_FILENAME)

View File

@ -987,7 +987,7 @@ function(CUDA_COMPUTE_BUILD_PATH path build_path)
endif()
endif()
# This recipie is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the
# This recipe is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the
# CMake source.
# Remove leading /

View File

@ -62,7 +62,7 @@ find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
ENV GTKMM_BASEPATH
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
PATH_SUFFIXES include/freetype2 include
PATH_SUFFIXES include/freetype2 include freetype2
)
find_path(FREETYPE_INCLUDE_DIR_freetype2
@ -79,7 +79,7 @@ find_path(FREETYPE_INCLUDE_DIR_freetype2
ENV GTKMM_BASEPATH
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
PATH_SUFFIXES include/freetype2 include
PATH_SUFFIXES include/freetype2 include freetype2
)
find_library(FREETYPE_LIBRARY

View File

@ -79,7 +79,7 @@
# extra_args = Pass a list of extra arguments to be passed to
# executable enclosed in quotes (or "" for none)
# ARGN = A list of source files to search for tests & test
# fixtures.
# fixtures. Or AUTO to find them from executable target.
#
#
#
@ -88,7 +88,7 @@
# Example:
# set(FooTestArgs --foo 1 --bar 2)
# add_executable(FooTest FooUnitTest.cc)
# GTEST_ADD_TESTS(FooTest "${FooTestArgs}" FooUnitTest.cc)
# GTEST_ADD_TESTS(FooTest "${FooTestArgs}" AUTO)
#=============================================================================
# Copyright 2009 Kitware, Inc.
@ -111,6 +111,10 @@ function(GTEST_ADD_TESTS executable extra_args)
if(NOT ARGN)
message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS")
endif()
if(ARGN STREQUAL "AUTO")
# obtain sources used for building that executable
get_property(ARGN TARGET ${executable} PROPERTY SOURCES)
endif()
foreach(source ${ARGN})
file(READ "${source}" contents)
string(REGEX MATCHALL "TEST_?F?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})

View File

@ -2,7 +2,7 @@
# FindHg
# ------
#
#
# Extract information from a mercurial working copy.
#
# The module defines the following variables:
#
@ -12,6 +12,20 @@
# HG_FOUND - true if the command line client was found
# HG_VERSION_STRING - the version of mercurial found
#
# If the command line client executable is found the following macro is defined:
#
# ::
#
# HG_WC_INFO(<dir> <var-prefix>)
#
# Hg_WC_INFO extracts information of a mercurial working copy
# at a given location. This macro defines the following variables:
#
# ::
#
# <var-prefix>_WC_CHANGESET - current changeset
# <var-prefix>_WC_REVISION - current revision
#
# Example usage:
#
# ::
@ -19,11 +33,15 @@
# find_package(Hg)
# if(HG_FOUND)
# message("hg found: ${HG_EXECUTABLE}")
# HG_WC_INFO(${PROJECT_SOURCE_DIR} Project)
# message("Current revision is ${Project_WC_REVISION}")
# message("Current changeset is ${Project_WC_CHANGESET}")
# endif()
#=============================================================================
# Copyright 2010-2012 Kitware, Inc.
# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de>
# Copyright 2014 Matthaeus G. Chajdas
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
@ -37,6 +55,8 @@
find_program(HG_EXECUTABLE
NAMES hg
PATHS
[HKEY_LOCAL_MACHINE\\Software\\TortoiseHG]
PATH_SUFFIXES Mercurial
DOC "hg command line client"
)
@ -51,6 +71,21 @@ if(HG_EXECUTABLE)
set(HG_VERSION_STRING "${CMAKE_MATCH_1}")
endif()
unset(hg_version)
macro(HG_WC_INFO dir prefix)
execute_process(COMMAND ${HG_EXECUTABLE} id -i -n
WORKING_DIRECTORY ${dir}
RESULT_VARIABLE hg_id_result
ERROR_VARIABLE hg_id_error
OUTPUT_VARIABLE ${prefix}_WC_DATA
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ${hg_id_result} EQUAL 0)
message(SEND_ERROR "Command \"${HG_EXECUTBALE} id -n\" in directory ${dir} failed with output:\n${hg_id_error}")
endif()
string(REGEX REPLACE "([0-9a-f]+)\\+? [0-9]+\\+?" "\\1" ${prefix}_WC_CHANGESET ${${prefix}_WC_DATA})
string(REGEX REPLACE "[0-9a-f]+\\+? ([0-9]+)\\+?" "\\1" ${prefix}_WC_REVISION ${${prefix}_WC_DATA})
endmacro(HG_WC_INFO)
endif()
# Handle the QUIETLY and REQUIRED arguments and set HG_FOUND to TRUE if

134
Modules/FindOpenCL.cmake Normal file
View File

@ -0,0 +1,134 @@
#.rst:
# FindOpenCL
# ----------
#
# Try to find OpenCL
#
# Once done this will define::
#
# OpenCL_FOUND - True if OpenCL was found
# OpenCL_INCLUDE_DIRS - include directories for OpenCL
# OpenCL_LIBRARIES - link against this library to use OpenCL
# OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2)
# OpenCL_VERSION_MAJOR - The major version of the OpenCL implementation
# OpenCL_VERSION_MINOR - The minor version of the OpenCL implementation
#
# The module will also define two cache variables::
#
# OpenCL_INCLUDE_DIR - the OpenCL include directory
# OpenCL_LIBRARY - the path to the OpenCL library
#
#=============================================================================
# Copyright 2014 Matthaeus G. Chajdas
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
function(_FIND_OPENCL_VERSION)
include(CheckSymbolExists)
include(CMakePushCheckState)
CMAKE_PUSH_CHECK_STATE()
foreach(VERSION "2_0" "1_2" "1_1" "1_0")
set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}")
if(APPLE)
CHECK_SYMBOL_EXISTS(
CL_VERSION_${VERSION}
"${OpenCL_INCLUDE_DIR}/OpenCL/cl.h"
OPENCL_VERSION_${VERSION})
else()
CHECK_SYMBOL_EXISTS(
CL_VERSION_${VERSION}
"${OpenCL_INCLUDE_DIR}/CL/cl.h"
OPENCL_VERSION_${VERSION})
endif()
if(OPENCL_VERSION_${VERSION})
string(REPLACE "_" "." VERSION "${VERSION}")
set(OpenCL_VERSION_STRING ${VERSION} PARENT_SCOPE)
string(REGEX MATCHALL "[0-9]+" version_components "${VERSION}")
list(GET version_components 0 major_version)
list(GET version_components 1 minor_version)
set(OpenCL_VERSION_MAJOR ${major_version} PARENT_SCOPE)
set(OpenCL_VERSION_MINOR ${minor_version} PARENT_SCOPE)
break()
endif()
endforeach()
CMAKE_POP_CHECK_STATE()
endfunction()
find_path(OpenCL_INCLUDE_DIR
NAMES
CL/cl.h OpenCL/cl.h
PATHS ENV
"PROGRAMFILES(X86)"
AMDAPPSDKROOT
INTELOCLSDKROOT
NVSDKCOMPUTE_ROOT
CUDA_PATH
ATISTREAMSDKROOT
PATH_SUFFIXES
OpenCL/common/inc
"AMD APP/include")
_FIND_OPENCL_VERSION()
if(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
find_library(OpenCL_LIBRARY
NAMES OpenCL
PATHS ENV
"PROGRAMFILES(X86)"
AMDAPPSDKROOT
INTELOCLSDKROOT
CUDA_PATH
NVSDKCOMPUTE_ROOT
ATISTREAMSDKROOT
PATH_SUFFIXES
"AMD APP/lib/x86"
lib/x86
lib/Win32
OpenCL/common/lib/Win32)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
find_library(OpenCL_LIBRARY
NAMES OpenCL
PATHS ENV
"PROGRAMFILES(X86)"
AMDAPPSDKROOT
INTELOCLSDKROOT
CUDA_PATH
NVSDKCOMPUTE_ROOT
ATISTREAMSDKROOT
PATH_SUFFIXES
"AMD APP/lib/x86_64"
lib/x86_64
lib/x64
OpenCL/common/lib/x64)
endif()
else()
find_library(OpenCL_LIBRARY
NAMES OpenCL)
endif()
set(OpenCL_LIBRARIES ${OpenCL_LIBRARY})
set(OpenCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIR})
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(
OpenCL
FOUND_VAR OpenCL_FOUND
REQUIRED_VARS OpenCL_LIBRARY OpenCL_INCLUDE_DIR
VERSION_VAR OpenCL_VERSION_STRING)
mark_as_advanced(
OpenCL_INCLUDE_DIR
OpenCL_LIBRARY)

View File

@ -2,139 +2,19 @@
# FindPkgConfig
# -------------
#
# a pkg-config module for CMake
# A `pkg-config` module for CMake.
#
# Finds the ``pkg-config`` executable and add the
# :command:`pkg_check_modules` and :command:`pkg_search_module`
# commands.
#
#
# Usage:
#
# ::
#
# pkg_check_modules(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*)
# checks for all the given modules
#
#
#
# ::
#
# pkg_search_module(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*)
# checks for given modules and uses the first working one
#
#
#
# When the 'REQUIRED' argument was set, macros will fail with an error
# when module(s) could not be found
#
# When the 'QUIET' argument is set, no status messages will be printed.
#
# It sets the following variables:
#
# ::
#
# PKG_CONFIG_FOUND ... if pkg-config executable was found
# PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program
# PKG_CONFIG_VERSION_STRING ... the version of the pkg-config program found
# (since CMake 2.8.8)
#
#
#
# For the following variables two sets of values exist; first one is the
# common one and has the given PREFIX. The second set contains flags
# which are given out when pkgconfig was called with the '--static'
# option.
#
# ::
#
# <XPREFIX>_FOUND ... set to 1 if module(s) exist
# <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l')
# <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L')
# <XPREFIX>_LDFLAGS ... all required linker flags
# <XPREFIX>_LDFLAGS_OTHER ... all other linker flags
# <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I')
# <XPREFIX>_CFLAGS ... all required cflags
# <XPREFIX>_CFLAGS_OTHER ... the other compiler flags
#
#
#
# ::
#
# <XPREFIX> = <PREFIX> for common case
# <XPREFIX> = <PREFIX>_STATIC for static linking
#
#
#
# There are some special variables whose prefix depends on the count of
# given modules. When there is only one module, <PREFIX> stays
# unchanged. When there are multiple modules, the prefix will be
# changed to <PREFIX>_<MODNAME>:
#
# ::
#
# <XPREFIX>_VERSION ... version of the module
# <XPREFIX>_PREFIX ... prefix-directory of the module
# <XPREFIX>_INCLUDEDIR ... include-dir of the module
# <XPREFIX>_LIBDIR ... lib-dir of the module
#
#
#
# ::
#
# <XPREFIX> = <PREFIX> when |MODULES| == 1, else
# <XPREFIX> = <PREFIX>_<MODNAME>
#
#
#
# A <MODULE> parameter can have the following formats:
#
# ::
#
# {MODNAME} ... matches any version
# {MODNAME}>={VERSION} ... at least version <VERSION> is required
# {MODNAME}={VERSION} ... exactly version <VERSION> is required
# {MODNAME}<={VERSION} ... modules must not be newer than <VERSION>
#
#
#
# Examples
#
# ::
#
# pkg_check_modules (GLIB2 glib-2.0)
#
#
#
# ::
#
# pkg_check_modules (GLIB2 glib-2.0>=2.10)
# requires at least version 2.10 of glib2 and defines e.g.
# GLIB2_VERSION=2.10.3
#
#
#
# ::
#
# pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0)
# requires both glib2 and gtk2, and defines e.g.
# FOO_glib-2.0_VERSION=2.10.3
# FOO_gtk+-2.0_VERSION=2.8.20
#
#
#
# ::
#
# pkg_check_modules (XRENDER REQUIRED xrender)
# defines e.g.:
# XRENDER_LIBRARIES=Xrender;X11
# XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp
#
#
#
# ::
#
# pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2)
# In order to find the ``pkg-config`` executable, it uses the
# :variable:`PKG_CONFIG_EXECUTABLE` variable or the ``PKG_CONFIG``
# environment variable first.
#=============================================================================
# Copyright 2006-2009 Kitware, Inc.
# Copyright 2006-2014 Kitware, Inc.
# Copyright 2014 Christoph Grüninger <foss@grueninger.de>
# Copyright 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
#
# Distributed under the OSI-approved BSD License (the "License");
@ -150,6 +30,10 @@
### Common stuff ####
set(PKG_CONFIG_VERSION 1)
# find pkg-config, use PKG_CONFIG if set
if((NOT PKG_CONFIG_EXECUTABLE) AND (NOT "$ENV{PKG_CONFIG}" STREQUAL ""))
set(PKG_CONFIG_EXECUTABLE "$ENV{PKG_CONFIG}" CACHE FILEPATH "pkg-config executable")
endif()
find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable")
mark_as_advanced(PKG_CONFIG_EXECUTABLE)
@ -387,7 +271,94 @@ endmacro()
### User visible macros start here
###
###
#[========================================[.rst:
.. command:: pkg_check_modules
Checks for all the given modules. ::
pkg_check_modules(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*)
When the ``REQUIRED`` argument was set, macros will fail with an error
when module(s) could not be found.
When the ``QUIET`` argument is set, no status messages will be printed.
It sets the following variables: ::
PKG_CONFIG_FOUND ... if pkg-config executable was found
PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program
PKG_CONFIG_VERSION_STRING ... the version of the pkg-config program found
(since CMake 2.8.8)
For the following variables two sets of values exist; first one is the
common one and has the given PREFIX. The second set contains flags
which are given out when ``pkg-config`` was called with the ``--static``
option. ::
<XPREFIX>_FOUND ... set to 1 if module(s) exist
<XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l')
<XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L')
<XPREFIX>_LDFLAGS ... all required linker flags
<XPREFIX>_LDFLAGS_OTHER ... all other linker flags
<XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I')
<XPREFIX>_CFLAGS ... all required cflags
<XPREFIX>_CFLAGS_OTHER ... the other compiler flags
::
<XPREFIX> = <PREFIX> for common case
<XPREFIX> = <PREFIX>_STATIC for static linking
There are some special variables whose prefix depends on the count of
given modules. When there is only one module, <PREFIX> stays
unchanged. When there are multiple modules, the prefix will be
changed to <PREFIX>_<MODNAME>: ::
<XPREFIX>_VERSION ... version of the module
<XPREFIX>_PREFIX ... prefix-directory of the module
<XPREFIX>_INCLUDEDIR ... include-dir of the module
<XPREFIX>_LIBDIR ... lib-dir of the module
::
<XPREFIX> = <PREFIX> when |MODULES| == 1, else
<XPREFIX> = <PREFIX>_<MODNAME>
A <MODULE> parameter can have the following formats: ::
{MODNAME} ... matches any version
{MODNAME}>={VERSION} ... at least version <VERSION> is required
{MODNAME}={VERSION} ... exactly version <VERSION> is required
{MODNAME}<={VERSION} ... modules must not be newer than <VERSION>
Examples
.. code-block:: cmake
pkg_check_modules (GLIB2 glib-2.0)
.. code-block:: cmake
pkg_check_modules (GLIB2 glib-2.0>=2.10)
Requires at least version 2.10 of glib2 and defines e.g.
``GLIB2_VERSION=2.10.3``
.. code-block:: cmake
pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0)
Requires both glib2 and gtk2, and defines e.g.
``FOO_glib-2.0_VERSION=2.10.3`` and ``FOO_gtk+-2.0_VERSION=2.8.20``
.. code-block:: cmake
pkg_check_modules (XRENDER REQUIRED xrender)
Defines e.g.:
``XRENDER_LIBRARIES=Xrender;X11`` and
``XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp``
#]========================================]
macro(pkg_check_modules _prefix _module0)
# check cached value
if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND)
@ -398,7 +369,21 @@ macro(pkg_check_modules _prefix _module0)
endif()
endmacro()
###
#[========================================[.rst:
.. command:: pkg_search_module
Same as :command:`pkg_check_modules`, but instead it checks for given
modules and uses the first working one. ::
pkg_search_module(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*)
Examples
.. code-block:: cmake
pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2)
#]========================================]
macro(pkg_search_module _prefix _module0)
# check cached value
if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND)
@ -430,6 +415,14 @@ macro(pkg_search_module _prefix _module0)
endif()
endmacro()
#[========================================[.rst:
.. variable:: PKG_CONFIG_EXECUTABLE
Path to the pkg-config executable.
#]========================================]
### Local Variables:
### mode: cmake
### End:

View File

@ -27,6 +27,10 @@
# of version numbers that should be taken into account when searching
# for Python. You need to set this variable before calling
# find_package(PythonInterp).
#
# If also calling find_package(PythonLibs), call find_package(PythonInterp)
# first to get the currently active Python version by default with a consistent
# version of PYTHON_LIBRARIES.
#=============================================================================
# Copyright 2005-2010 Kitware, Inc.
@ -71,18 +75,23 @@ if(PythonInterp_FIND_VERSION)
else()
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS})
endif()
list(APPEND _Python_NAMES python)
# Search for the current active python version first
find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES})
# Set up the versions we know about, in the order we will search. Always add
# the user supplied additional versions to the front.
set(_Python_VERSIONS
${Python_ADDITIONAL_VERSIONS}
${_PYTHON_FIND_OTHER_VERSIONS}
)
set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS})
# If FindPythonInterp has already found the major and minor version,
# insert that version next to get consistent versions of the interpreter and
# library.
if(DEFINED PYTHONLIBS_VERSION_STRING)
string(REPLACE "." ";" _PYTHONLIBS_VERSION "${PYTHONLIBS_VERSION_STRING}")
list(GET _PYTHONLIBS_VERSION 0 _PYTHONLIBS_VERSION_MAJOR)
list(GET _PYTHONLIBS_VERSION 1 _PYTHONLIBS_VERSION_MINOR)
list(APPEND _Python_VERSIONS ${_PYTHONLIBS_VERSION_MAJOR}.${_PYTHONLIBS_VERSION_MINOR})
endif()
# Search for the current active python version first
list(APPEND _Python_VERSIONS ";")
list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS})
unset(_PYTHON_FIND_OTHER_VERSIONS)
unset(_PYTHON1_VERSIONS)
@ -91,7 +100,7 @@ unset(_PYTHON3_VERSIONS)
# Search for newest python version if python executable isn't found
if(NOT PYTHON_EXECUTABLE)
foreach(_CURRENT_VERSION ${_Python_VERSIONS})
foreach(_CURRENT_VERSION IN LISTS _Python_VERSIONS)
set(_Python_NAMES python${_CURRENT_VERSION})
if(WIN32)
list(APPEND _Python_NAMES python)

View File

@ -31,6 +31,10 @@
#
# PYTHON_LIBRARY - path to the python library
# PYTHON_INCLUDE_DIR - path to where Python.h is found
#
# If also calling find_package(PythonInterp), call find_package(PythonInterp)
# first to get the currently active Python version by default with a consistent
# version of PYTHON_LIBRARIES.
#=============================================================================
# Copyright 2001-2009 Kitware, Inc.
@ -80,10 +84,14 @@ endif()
# Set up the versions we know about, in the order we will search. Always add
# the user supplied additional versions to the front.
set(_Python_VERSIONS
${Python_ADDITIONAL_VERSIONS}
${_PYTHON_FIND_OTHER_VERSIONS}
)
# If FindPythonInterp has already found the major and minor version,
# insert that version between the user supplied versions and the stock
# version list.
set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS})
if(DEFINED PYTHON_VERSION_MAJOR AND DEFINED PYTHON_VERSION_MINOR)
list(APPEND _Python_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
endif()
list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS})
unset(_PYTHON_FIND_OTHER_VERSIONS)
unset(_PYTHON1_VERSIONS)

View File

@ -54,7 +54,9 @@ find_path(SDL_IMAGE_INCLUDE_DIR SDL_image.h
HINTS
ENV SDLIMAGEDIR
ENV SDLDIR
PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
PATH_SUFFIXES SDL
# path suffixes to search inside ENV{SDLDIR}
include/SDL include/SDL12 include/SDL11 include
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)

View File

@ -54,7 +54,9 @@ find_path(SDL_MIXER_INCLUDE_DIR SDL_mixer.h
HINTS
ENV SDLMIXERDIR
ENV SDLDIR
PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
PATH_SUFFIXES SDL
# path suffixes to search inside ENV{SDLDIR}
include/SDL include/SDL12 include/SDL11 include
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)

View File

@ -54,7 +54,9 @@ find_path(SDL_NET_INCLUDE_DIR SDL_net.h
HINTS
ENV SDLNETDIR
ENV SDLDIR
PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
PATH_SUFFIXES SDL
# path suffixes to search inside ENV{SDLDIR}
include/SDL include/SDL12 include/SDL11 include
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)

View File

@ -98,7 +98,9 @@ find_path(SDL_SOUND_INCLUDE_DIR SDL_sound.h
HINTS
ENV SDLSOUNDDIR
ENV SDLDIR
PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
PATH_SUFFIXES SDL
# path suffixes to search inside ENV{SDLDIR}
include/SDL include/SDL12 include/SDL11 include
)
find_library(SDL_SOUND_LIBRARY

View File

@ -54,7 +54,9 @@ find_path(SDL_TTF_INCLUDE_DIR SDL_ttf.h
HINTS
ENV SDLTTFDIR
ENV SDLDIR
PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
PATH_SUFFIXES SDL
# path suffixes to search inside ENV{SDLDIR}
include/SDL include/SDL12 include/SDL11 include
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)

View File

@ -366,18 +366,22 @@ endif()
if(WATCOM)
get_filename_component( CompilerPath ${CMAKE_C_COMPILER} PATH )
if(WATCOM17)
set( __install__libs ${CompilerPath}/clbr17.dll
${CompilerPath}/mt7r17.dll ${CompilerPath}/plbr17.dll )
if(CMAKE_C_COMPILER_VERSION)
set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
else()
set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
endif()
if(WATCOM18)
set( __install__libs ${CompilerPath}/clbr18.dll
${CompilerPath}/mt7r18.dll ${CompilerPath}/plbr18.dll )
endif()
if(WATCOM19)
set( __install__libs ${CompilerPath}/clbr19.dll
${CompilerPath}/mt7r19.dll ${CompilerPath}/plbr19.dll )
string(REGEX MATCHALL "[0-9]+" _watcom_version_list "${_compiler_version}")
list(GET _watcom_version_list 0 _watcom_major)
list(GET _watcom_version_list 1 _watcom_minor)
if(${_watcom_major} GREATER 11)
math(EXPR _watcom_major "${_watcom_major} - 11")
endif()
math(EXPR _watcom_minor "${_watcom_minor} / 10")
set( __install__libs
${CompilerPath}/clbr${_watcom_major}${_watcom_minor}.dll
${CompilerPath}/mt7r${_watcom_major}${_watcom_minor}.dll
${CompilerPath}/plbr${_watcom_major}${_watcom_minor}.dll )
foreach(lib
${__install__libs}
)

View File

@ -87,6 +87,7 @@ macro(__windows_compiler_gnu lang)
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "")
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS ${__WINDOWS_GNU_LD_RESPONSE})
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES ${__WINDOWS_GNU_LD_RESPONSE})
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1)
# We prefer "@" for response files but it is not supported by gcc 3.
@ -103,7 +104,9 @@ macro(__windows_compiler_gnu lang)
endif()
# The GNU 3.x compilers do not support response files (only linkers).
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 0)
elseif(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS)
# Link libraries are generated only for the front-end.
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 0)
else()
# Use "@" to pass the response file to the front-end.
set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@")
endif()

View File

@ -241,7 +241,7 @@ macro(__windows_compiler_msvc lang)
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_LINKER> /lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ")
set(CMAKE_${lang}_COMPILE_OBJECT
"<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> /Fo<OBJECT> /Fd<OBJECT_DIR>/${_FS_${lang}} -c <SOURCE>${CMAKE_END_TEMP_FILE}")
"<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> /Fo<OBJECT> /Fd<TARGET_COMPILE_PDB>${_FS_${lang}} -c <SOURCE>${CMAKE_END_TEMP_FILE}")
set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE
"<CMAKE_${lang}_COMPILER> > <PREPROCESSED_SOURCE> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> -E <SOURCE>${CMAKE_END_TEMP_FILE}")
set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE

View File

@ -40,7 +40,7 @@ set (CMAKE_C_STANDARD_LIBRARIES_INIT "library clbrdll.lib library plbrdll.lib l
set (CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}")
set(CMAKE_C_CREATE_IMPORT_LIBRARY
"wlib -c -q -n -b <TARGET_IMPLIB> +'<TARGET_UNQUOTED>'")
"wlib -c -q -n -b <TARGET_IMPLIB> +<TARGET_QUOTED>")
set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY})
set(CMAKE_C_LINK_EXECUTABLE
@ -65,11 +65,10 @@ set(CMAKE_C_CREATE_PREPROCESSED_SOURCE
set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE
"<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -dWIN32 -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}")
set(CMAKE_CXX_CREATE_SHARED_MODULE
"wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' <LINK_FLAGS> option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
set(CMAKE_CXX_CREATE_SHARED_LIBRARY
${CMAKE_CXX_CREATE_SHARED_MODULE}
${CMAKE_CXX_CREATE_IMPORT_LIBRARY})
"wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' <LINK_FLAGS> option implib=<TARGET_IMPLIB> option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
string(REPLACE " option implib=<TARGET_IMPLIB>" ""
CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
# create a C shared library
set(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY})
@ -78,7 +77,7 @@ set(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY})
set(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_MODULE})
# create a C++ static library
set(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -c -n -b '<TARGET_UNQUOTED>' <LINK_FLAGS> <OBJECTS> ")
set(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -c -n -b <TARGET_QUOTED> <LINK_FLAGS> <OBJECTS> ")
# create a C static library
set(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY})

View File

@ -98,7 +98,9 @@ foreach(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN
include_directories(SYSTEM ${QT_${module}_INCLUDE_DIR})
endif(QT_INCLUDE_DIRS_NO_SYSTEM)
endif()
if(QT_USE_${module} OR QT_IS_STATIC)
set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY})
endif()
set(QT_LIBRARIES_PLUGINS ${QT_LIBRARIES_PLUGINS} ${QT_${module}_PLUGINS})
if(QT_IS_STATIC)
set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIB_DEPENDENCIES})

View File

@ -85,9 +85,6 @@ macro(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile)
set(${outfiles} "")
get_source_file_property(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename
${infile} SWIG_MODULE_NAME)
if(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND")
get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${infile}" NAME_WE)
endif()
foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSION})
set(${outfiles} ${${outfiles}}
"${generatedpath}/${SWIG_GET_EXTRA_OUTPUT_FILES_module_basename}.${it}")
@ -103,6 +100,10 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
get_source_file_property(swig_source_file_generated ${infile} GENERATED)
get_source_file_property(swig_source_file_cplusplus ${infile} CPLUSPLUS)
get_source_file_property(swig_source_file_flags ${infile} SWIG_FLAGS)
get_source_file_property(_SWIG_MODULE_NAME ${infile} SWIG_MODULE_NAME)
if ( NOT _SWIG_MODULE_NAME )
set_source_files_properties(${infile} PROPERTIES SWIG_MODULE_NAME ${name})
endif ()
if("${swig_source_file_flags}" STREQUAL "NOTFOUND")
set(swig_source_file_flags "")
endif()

View File

@ -40,5 +40,7 @@
<FeatureRef Id="ProductFeature"/>
<UIRef Id="$(var.CPACK_WIX_UI_REF)" />
<?include "properties.wxi"?>
</Product>
</Wix>

View File

@ -562,7 +562,11 @@ if(WIN32)
set(CPACK_SRCS ${CPACK_SRCS}
CPack/WiX/cmCPackWIXGenerator.cxx
CPack/WiX/cmWIXSourceWriter.cxx
CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
CPack/WiX/cmWIXFeaturesSourceWriter.cxx
CPack/WiX/cmWIXFilesSourceWriter.cxx
CPack/WiX/cmWIXRichTextFormatWriter.cxx
CPack/WiX/cmWIXPatch.cxx
CPack/WiX/cmWIXPatchParser.cxx
)
endif()

View File

@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 0)
set(CMake_VERSION_PATCH 0)
set(CMake_VERSION_RC 1)
set(CMake_VERSION_PATCH 20140317)
#set(CMake_VERSION_RC 1)

View File

@ -1,6 +1,6 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2013 Kitware, Inc., Insight Software Consortium
Copyright 2000-2014 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
@ -19,6 +19,9 @@
#include <CPack/cmCPackComponentGroup.h>
#include "cmWIXSourceWriter.h"
#include "cmWIXDirectoriesSourceWriter.h"
#include "cmWIXFeaturesSourceWriter.h"
#include "cmWIXFilesSourceWriter.h"
#include "cmWIXRichTextFormatWriter.h"
#include <cmsys/SystemTools.hxx>
@ -28,11 +31,9 @@
#include <rpc.h> // for GUID generation
#include <sys/types.h>
#include <sys/stat.h>
cmCPackWIXGenerator::cmCPackWIXGenerator():
HasDesktopShortcuts(false)
HasDesktopShortcuts(false),
Patch(Logger)
{
}
@ -44,15 +45,9 @@ int cmCPackWIXGenerator::InitializeInternal()
return this->Superclass::InitializeInternal();
}
bool cmCPackWIXGenerator::RunWiXCommand(const std::string& command)
bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command)
{
std::string cpackTopLevel;
if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
{
return false;
}
std::string logFileName = cpackTopLevel + "/wix.log";
std::string logFileName = this->CPackTopLevel + "/wix.log";
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Running WiX command: " << command << std::endl);
@ -81,7 +76,7 @@ bool cmCPackWIXGenerator::RunWiXCommand(const std::string& command)
}
bool cmCPackWIXGenerator::RunCandleCommand(
const std::string& sourceFile, const std::string& objectFile)
std::string const& sourceFile, std::string const& objectFile)
{
std::string executable;
if(!RequireOption("CPACK_WIX_CANDLE_EXECUTABLE", executable))
@ -108,7 +103,7 @@ bool cmCPackWIXGenerator::RunCandleCommand(
return RunWiXCommand(command.str());
}
bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles)
bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
{
std::string executable;
if(!RequireOption("CPACK_WIX_LIGHT_EXECUTABLE", executable))
@ -121,8 +116,8 @@ bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles)
command << " -nologo";
command << " -out " << QuotePath(packageFileNames.at(0));
for(extension_set_t::const_iterator i = LightExtensions.begin();
i != LightExtensions.end(); ++i)
for(extension_set_t::const_iterator i = this->LightExtensions.begin();
i != this->LightExtensions.end(); ++i)
{
command << " -ext " << QuotePath(*i);
}
@ -182,15 +177,14 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
"you might want to set this explicitly." << std::endl);
}
std::string cpackTopLevel;
if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", this->CPackTopLevel))
{
return false;
}
if(GetOption("CPACK_WIX_LICENSE_RTF") == 0)
{
std::string licenseFilename = cpackTopLevel + "/License.rtf";
std::string licenseFilename = this->CPackTopLevel + "/License.rtf";
SetOption("CPACK_WIX_LICENSE_RTF", licenseFilename.c_str());
if(!CreateLicenseFile())
@ -213,7 +207,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
{
std::string defaultRef = "WixUI_InstallDir";
if(Components.size())
if(this->Components.size())
{
defaultRef = "WixUI_FeatureTree";
}
@ -221,17 +215,24 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
SetOption("CPACK_WIX_UI_REF", defaultRef.c_str());
}
CollectExtensions("CPACK_WIX_EXTENSIONS", CandleExtensions);
CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", CandleExtensions);
const char* packageContact = GetOption("CPACK_PACKAGE_CONTACT");
if(packageContact != 0 &&
GetOption("CPACK_WIX_PROPERTY_ARPCONTACT") == 0)
{
SetOption("CPACK_WIX_PROPERTY_ARPCONTACT", packageContact);
}
LightExtensions.insert("WixUIExtension");
CollectExtensions("CPACK_WIX_EXTENSIONS", LightExtensions);
CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", LightExtensions);
CollectExtensions("CPACK_WIX_EXTENSIONS", this->CandleExtensions);
CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", this->CandleExtensions);
this->LightExtensions.insert("WixUIExtension");
CollectExtensions("CPACK_WIX_EXTENSIONS", this->LightExtensions);
CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", this->LightExtensions);
const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE");
if(patchFilePath)
{
LoadPatchFragments(patchFilePath);
this->Patch.LoadFragments(patchFilePath);
}
return true;
@ -244,10 +245,8 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
return false;
}
if(!CreateWiXVariablesIncludeFile())
{
return false;
}
CreateWiXVariablesIncludeFile();
CreateWiXPropertiesIncludeFile();
if(!CreateWiXSourceFiles())
{
@ -257,9 +256,9 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
AppendUserSuppliedExtraSources();
std::stringstream objectFiles;
for(size_t i = 0; i < WixSources.size(); ++i)
for(size_t i = 0; i < this->WixSources.size(); ++i)
{
const std::string& sourceFilename = WixSources[i];
std::string const& sourceFilename = this->WixSources[i];
std::string objectFilename =
cmSystemTools::GetFilenameWithoutExtension(sourceFilename) + ".wixobj";
@ -282,7 +281,7 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraSources()
const char *cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES");
if(!cpackWixExtraSources) return;
cmSystemTools::ExpandListArgument(cpackWixExtraSources, WixSources);
cmSystemTools::ExpandListArgument(cpackWixExtraSources, this->WixSources);
}
void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
@ -301,18 +300,14 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
}
}
bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
{
std::string cpackTopLevel;
if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
{
return false;
}
std::string includeFilename =
cpackTopLevel + "/cpack_variables.wxi";
this->CPackTopLevel + "/cpack_variables.wxi";
cmWIXSourceWriter includeFile(
this->Logger, includeFilename, true);
cmWIXSourceWriter includeFile(Logger, includeFilename, true);
CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_GUID");
CopyDefinition(includeFile, "CPACK_WIX_UPGRADE_GUID");
CopyDefinition(includeFile, "CPACK_PACKAGE_VENDOR");
@ -326,12 +321,39 @@ bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
GetOption("CPACK_PACKAGE_NAME"));
CopyDefinition(includeFile, "CPACK_WIX_PROGRAM_MENU_FOLDER");
CopyDefinition(includeFile, "CPACK_WIX_UI_REF");
}
return true;
void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
{
std::string includeFilename =
this->CPackTopLevel + "/properties.wxi";
cmWIXSourceWriter includeFile(
this->Logger, includeFilename, true);
std::string prefix = "CPACK_WIX_PROPERTY_";
std::vector<std::string> options = GetOptions();
for(size_t i = 0; i < options.size(); ++i)
{
std::string const& name = options[i];
if(name.length() > prefix.length() &&
name.substr(0, prefix.length()) == prefix)
{
std::string id = name.substr(prefix.length());
std::string value = GetOption(name.c_str());
includeFile.BeginElement("Property");
includeFile.AddAttribute("Id", id);
includeFile.AddAttribute("Value", value);
includeFile.EndElement("Property");
}
}
}
void cmCPackWIXGenerator::CopyDefinition(
cmWIXSourceWriter &source, const std::string &name)
cmWIXSourceWriter &source, std::string const& name)
{
const char* value = GetOption(name.c_str());
if(value)
@ -341,7 +363,7 @@ void cmCPackWIXGenerator::CopyDefinition(
}
void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source,
const std::string& name, const std::string& value)
std::string const& name, std::string const& value)
{
std::stringstream tmp;
tmp << name << "=\"" << value << '"';
@ -352,81 +374,47 @@ void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source,
bool cmCPackWIXGenerator::CreateWiXSourceFiles()
{
std::string cpackTopLevel;
if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
std::string directoryDefinitionsFilename =
this->CPackTopLevel + "/directories.wxs";
this->WixSources.push_back(directoryDefinitionsFilename);
cmWIXDirectoriesSourceWriter directoryDefinitions(
this->Logger, directoryDefinitionsFilename);
directoryDefinitions.BeginElement("Fragment");
std::string installRoot;
if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", installRoot))
{
return false;
}
std::string directoryDefinitionsFilename =
cpackTopLevel + "/directories.wxs";
WixSources.push_back(directoryDefinitionsFilename);
cmWIXSourceWriter directoryDefinitions(Logger, directoryDefinitionsFilename);
directoryDefinitions.BeginElement("Fragment");
directoryDefinitions.BeginElement("Directory");
directoryDefinitions.AddAttribute("Id", "TARGETDIR");
directoryDefinitions.AddAttribute("Name", "SourceDir");
directoryDefinitions.BeginElement("Directory");
if(GetArchitecture() == "x86")
{
directoryDefinitions.AddAttribute("Id", "ProgramFilesFolder");
}
else
{
directoryDefinitions.AddAttribute("Id", "ProgramFiles64Folder");
}
std::vector<std::string> install_root;
std::string tmp;
if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", tmp))
{
return false;
}
cmSystemTools::SplitPath(tmp.c_str(), install_root);
if(!install_root.empty() && install_root.back().empty())
{
install_root.pop_back();
}
for(size_t i = 1; i < install_root.size(); ++i)
{
directoryDefinitions.BeginElement("Directory");
if(i == install_root.size() - 1)
{
directoryDefinitions.AddAttribute("Id", "INSTALL_ROOT");
}
else
{
std::stringstream ss;
ss << "INSTALL_PREFIX_" << i;
directoryDefinitions.AddAttribute("Id", ss.str());
}
directoryDefinitions.AddAttribute("Name", install_root[i]);
}
size_t installRootSize =
directoryDefinitions.BeginInstallationPrefixDirectory(
GetProgramFilesFolderId(), installRoot);
std::string fileDefinitionsFilename =
cpackTopLevel + "/files.wxs";
this->CPackTopLevel + "/files.wxs";
WixSources.push_back(fileDefinitionsFilename);
this->WixSources.push_back(fileDefinitionsFilename);
cmWIXFilesSourceWriter fileDefinitions(
this->Logger, fileDefinitionsFilename);
cmWIXSourceWriter fileDefinitions(Logger, fileDefinitionsFilename);
fileDefinitions.BeginElement("Fragment");
std::string featureDefinitionsFilename =
cpackTopLevel +"/features.wxs";
this->CPackTopLevel +"/features.wxs";
WixSources.push_back(featureDefinitionsFilename);
this->WixSources.push_back(featureDefinitionsFilename);
cmWIXFeaturesSourceWriter featureDefinitions(
this->Logger, featureDefinitionsFilename);
cmWIXSourceWriter featureDefinitions(Logger, featureDefinitionsFilename);
featureDefinitions.BeginElement("Fragment");
featureDefinitions.BeginElement("Feature");
@ -439,13 +427,15 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
{
return false;
}
featureDefinitions.AddAttribute("Title", cpackPackageName);
featureDefinitions.AddAttribute("Title", cpackPackageName);
featureDefinitions.AddAttribute("Level", "1");
if(!CreateCMakePackageRegistryEntry(featureDefinitions))
const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY");
if(package)
{
return false;
featureDefinitions.CreateCMakePackageRegistryEntry(
package, GetOption("CPACK_WIX_UPGRADE_GUID"));
}
if(!CreateFeatureHierarchy(featureDefinitions))
@ -471,7 +461,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
else
{
for(std::map<std::string, cmCPackComponent>::const_iterator
i = Components.begin(); i != Components.end(); ++i)
i = this->Components.begin(); i != this->Components.end(); ++i)
{
cmCPackComponent const& component = i->second;
@ -513,31 +503,51 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
featureDefinitions.EndElement("Fragment");
fileDefinitions.EndElement("Fragment");
for(size_t i = 1; i < install_root.size(); ++i)
{
directoryDefinitions.EndElement("Directory");
}
directoryDefinitions.EndElement("Directory");
directoryDefinitions.EndInstallationPrefixDirectory(
installRootSize);
if(hasShortcuts)
{
CreateStartMenuFolder(directoryDefinitions);
directoryDefinitions.EmitStartMenuFolder(
GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"));
}
if(this->HasDesktopShortcuts)
{
CreateDesktopFolder(directoryDefinitions);
directoryDefinitions.EmitDesktopFolder();
}
directoryDefinitions.EndElement("Directory");
directoryDefinitions.EndElement("Fragment");
if(!GenerateMainSourceFileFromTemplate())
{
return false;
}
return this->Patch.CheckForUnappliedFragments();
}
std::string cmCPackWIXGenerator::GetProgramFilesFolderId() const
{
if(GetArchitecture() == "x86")
{
return "ProgramFilesFolder";
}
else
{
return "ProgramFiles64Folder";
}
}
bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
{
std::string wixTemplate = FindTemplate("WIX.template.in");
if(GetOption("CPACK_WIX_TEMPLATE") != 0)
{
wixTemplate = GetOption("CPACK_WIX_TEMPLATE");
}
if(wixTemplate.empty())
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
@ -545,7 +555,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
return false;
}
std::string mainSourceFilePath = cpackTopLevel + "/main.wxs";
std::string mainSourceFilePath = this->CPackTopLevel + "/main.wxs";
if(!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath .c_str()))
{
@ -556,68 +566,13 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
return false;
}
WixSources.push_back(mainSourceFilePath);
std::string fragmentList;
for(cmWIXPatchParser::fragment_map_t::const_iterator
i = Fragments.begin(); i != Fragments.end(); ++i)
{
if(!fragmentList.empty())
{
fragmentList += ", ";
}
fragmentList += "'";
fragmentList += i->first;
fragmentList += "'";
}
if(fragmentList.size())
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Some XML patch fragments did not have matching IDs: " <<
fragmentList << std::endl);
return false;
}
return true;
}
bool cmCPackWIXGenerator::CreateCMakePackageRegistryEntry(
cmWIXSourceWriter& featureDefinitions)
{
const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY");
if(!package)
{
return true;
}
featureDefinitions.BeginElement("Component");
featureDefinitions.AddAttribute("Id", "CM_PACKAGE_REGISTRY");
featureDefinitions.AddAttribute("Directory", "TARGETDIR");
featureDefinitions.AddAttribute("Guid", "*");
std::string registryKey =
std::string("Software\\Kitware\\CMake\\Packages\\") + package;
std::string upgradeGuid = GetOption("CPACK_WIX_UPGRADE_GUID");
featureDefinitions.BeginElement("RegistryValue");
featureDefinitions.AddAttribute("Root", "HKLM");
featureDefinitions.AddAttribute("Key", registryKey);
featureDefinitions.AddAttribute("Name", upgradeGuid);
featureDefinitions.AddAttribute("Type", "string");
featureDefinitions.AddAttribute("Value", "[INSTALL_ROOT]");
featureDefinitions.AddAttribute("KeyPath", "yes");
featureDefinitions.EndElement("RegistryValue");
featureDefinitions.EndElement("Component");
this->WixSources.push_back(mainSourceFilePath);
return true;
}
bool cmCPackWIXGenerator::CreateFeatureHierarchy(
cmWIXSourceWriter& featureDefinitions)
cmWIXFeaturesSourceWriter& featureDefinitions)
{
for(std::map<std::string, cmCPackComponentGroup>::const_iterator
i = ComponentGroups.begin(); i != ComponentGroups.end(); ++i)
@ -625,95 +580,20 @@ bool cmCPackWIXGenerator::CreateFeatureHierarchy(
cmCPackComponentGroup const& group = i->second;
if(group.ParentGroup == 0)
{
if(!EmitFeatureForComponentGroup(featureDefinitions, group))
{
return false;
}
featureDefinitions.EmitFeatureForComponentGroup(group);
}
}
for(std::map<std::string, cmCPackComponent>::const_iterator
i = Components.begin(); i != Components.end(); ++i)
i = this->Components.begin(); i != this->Components.end(); ++i)
{
cmCPackComponent const& component = i->second;
if(!component.Group)
{
if(!EmitFeatureForComponent(featureDefinitions, component))
{
return false;
featureDefinitions.EmitFeatureForComponent(component);
}
}
}
return true;
}
bool cmCPackWIXGenerator::EmitFeatureForComponentGroup(
cmWIXSourceWriter& featureDefinitions,
cmCPackComponentGroup const& group)
{
featureDefinitions.BeginElement("Feature");
featureDefinitions.AddAttribute("Id", "CM_G_" + group.Name);
if(group.IsExpandedByDefault)
{
featureDefinitions.AddAttribute("Display", "expand");
}
featureDefinitions.AddAttributeUnlessEmpty(
"Title", group.DisplayName);
featureDefinitions.AddAttributeUnlessEmpty(
"Description", group.Description);
for(std::vector<cmCPackComponentGroup*>::const_iterator
i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i)
{
if(!EmitFeatureForComponentGroup(featureDefinitions, **i))
{
return false;
}
}
for(std::vector<cmCPackComponent*>::const_iterator
i = group.Components.begin(); i != group.Components.end(); ++i)
{
if(!EmitFeatureForComponent(featureDefinitions, **i))
{
return false;
}
}
featureDefinitions.EndElement("Feature");
return true;
}
bool cmCPackWIXGenerator::EmitFeatureForComponent(
cmWIXSourceWriter& featureDefinitions,
cmCPackComponent const& component)
{
featureDefinitions.BeginElement("Feature");
featureDefinitions.AddAttribute("Id", "CM_C_" + component.Name);
featureDefinitions.AddAttributeUnlessEmpty(
"Title", component.DisplayName);
featureDefinitions.AddAttributeUnlessEmpty(
"Description", component.Description);
if(component.IsRequired)
{
featureDefinitions.AddAttribute("Absent", "disallow");
}
if(component.IsHidden)
{
featureDefinitions.AddAttribute("Display", "hidden");
}
featureDefinitions.EndElement("Feature");
return true;
}
@ -721,9 +601,9 @@ bool cmCPackWIXGenerator::EmitFeatureForComponent(
bool cmCPackWIXGenerator::AddComponentsToFeature(
std::string const& rootPath,
std::string const& featureId,
cmWIXSourceWriter& directoryDefinitions,
cmWIXSourceWriter& fileDefinitions,
cmWIXSourceWriter& featureDefinitions,
cmWIXDirectoriesSourceWriter& directoryDefinitions,
cmWIXFilesSourceWriter& fileDefinitions,
cmWIXFeaturesSourceWriter& featureDefinitions,
shortcut_map_t& shortcutMap)
{
featureDefinitions.BeginElement("FeatureRef");
@ -768,8 +648,8 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
std::string const& cpackComponentName,
std::string const& featureId,
shortcut_map_t& shortcutMap,
cmWIXSourceWriter& fileDefinitions,
cmWIXSourceWriter& featureDefinitions)
cmWIXFilesSourceWriter& fileDefinitions,
cmWIXFeaturesSourceWriter& featureDefinitions)
{
bool thisHasDesktopShortcuts = false;
@ -799,6 +679,7 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
fileDefinitions.BeginElement("DirectoryRef");
fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER");
fileDefinitions.BeginElement("Component");
fileDefinitions.AddAttribute("Id", componentId);
fileDefinitions.AddAttribute("Guid", "*");
@ -809,17 +690,7 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
std::string const& id = i->first;
cmWIXShortcut const& shortcut = i->second;
std::string shortcutId = std::string("CM_S") + id;
std::string fileId = std::string("CM_F") + id;
fileDefinitions.BeginElement("Shortcut");
fileDefinitions.AddAttribute("Id", shortcutId);
fileDefinitions.AddAttribute("Name", shortcut.textLabel);
std::string target = "[#" + fileId + "]";
fileDefinitions.AddAttribute("Target", target);
fileDefinitions.AddAttribute("WorkingDirectory",
shortcut.workingDirectoryId);
fileDefinitions.EndElement("Shortcut");
fileDefinitions.EmitShortcut(id, shortcut, false);
if(shortcut.desktop)
{
@ -829,41 +700,22 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
if(cpackComponentName.empty())
{
CreateUninstallShortcut(cpackPackageName, fileDefinitions);
fileDefinitions.EmitUninstallShortcut(cpackPackageName);
}
fileDefinitions.BeginElement("RemoveFolder");
fileDefinitions.AddAttribute("Id",
fileDefinitions.EmitRemoveFolder(
"CM_REMOVE_PROGRAM_MENU_FOLDER" + idSuffix);
fileDefinitions.AddAttribute("On", "uninstall");
fileDefinitions.EndElement("RemoveFolder");
std::string registryKey =
std::string("Software\\") + cpackVendor + "\\" + cpackPackageName;
fileDefinitions.BeginElement("RegistryValue");
fileDefinitions.AddAttribute("Root", "HKCU");
fileDefinitions.AddAttribute("Key", registryKey);
std::string valueName;
if(!cpackComponentName.empty())
{
valueName = cpackComponentName + "_";
}
valueName += "installed";
fileDefinitions.AddAttribute("Name", valueName);
fileDefinitions.AddAttribute("Type", "integer");
fileDefinitions.AddAttribute("Value", "1");
fileDefinitions.AddAttribute("KeyPath", "yes");
fileDefinitions.EndElement("RegistryValue");
fileDefinitions.EmitStartMenuShortcutRegistryValue(
registryKey, cpackComponentName);
fileDefinitions.EndElement("Component");
fileDefinitions.EndElement("DirectoryRef");
featureDefinitions.BeginElement("ComponentRef");
featureDefinitions.AddAttribute("Id", componentId);
featureDefinitions.EndElement("ComponentRef");
featureDefinitions.EmitComponentRef(componentId);
if(thisHasDesktopShortcuts)
{
@ -885,34 +737,16 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
if (!shortcut.desktop)
continue;
std::string shortcutId = std::string("CM_DS") + id;
std::string fileId = std::string("CM_F") + id;
fileDefinitions.BeginElement("Shortcut");
fileDefinitions.AddAttribute("Id", shortcutId);
fileDefinitions.AddAttribute("Name", shortcut.textLabel);
std::string target = "[#" + fileId + "]";
fileDefinitions.AddAttribute("Target", target);
fileDefinitions.AddAttribute("WorkingDirectory",
shortcut.workingDirectoryId);
fileDefinitions.EndElement("Shortcut");
fileDefinitions.EmitShortcut(id, shortcut, true);
}
fileDefinitions.BeginElement("RegistryValue");
fileDefinitions.AddAttribute("Root", "HKCU");
fileDefinitions.AddAttribute("Key", registryKey);
fileDefinitions.AddAttribute("Name", valueName + "_desktop");
fileDefinitions.AddAttribute("Type", "integer");
fileDefinitions.AddAttribute("Value", "1");
fileDefinitions.AddAttribute("KeyPath", "yes");
fileDefinitions.EndElement("RegistryValue");
fileDefinitions.EmitDesktopShortcutRegistryValue(
registryKey, cpackComponentName);
fileDefinitions.EndElement("Component");
fileDefinitions.EndElement("DirectoryRef");
featureDefinitions.BeginElement("ComponentRef");
featureDefinitions.AddAttribute("Id", componentId);
featureDefinitions.EndElement("ComponentRef");
featureDefinitions.EmitComponentRef(componentId);
}
featureDefinitions.EndElement("FeatureRef");
@ -920,19 +754,6 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
return true;
}
void cmCPackWIXGenerator::CreateUninstallShortcut(
std::string const& packageName,
cmWIXSourceWriter& fileDefinitions)
{
fileDefinitions.BeginElement("Shortcut");
fileDefinitions.AddAttribute("Id", "UNINSTALL");
fileDefinitions.AddAttribute("Name", "Uninstall " + packageName);
fileDefinitions.AddAttribute("Description", "Uninstalls " + packageName);
fileDefinitions.AddAttribute("Target", "[SystemFolder]msiexec.exe");
fileDefinitions.AddAttribute("Arguments", "/x [ProductCode]");
fileDefinitions.EndElement("Shortcut");
}
bool cmCPackWIXGenerator::CreateLicenseFile()
{
std::string licenseSourceFilename;
@ -981,11 +802,11 @@ bool cmCPackWIXGenerator::CreateLicenseFile()
}
void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
const std::string& topdir,
const std::string& directoryId,
cmWIXSourceWriter& directoryDefinitions,
cmWIXSourceWriter& fileDefinitions,
cmWIXSourceWriter& featureDefinitions,
std::string const& topdir,
std::string const& directoryId,
cmWIXDirectoriesSourceWriter& directoryDefinitions,
cmWIXFilesSourceWriter& fileDefinitions,
cmWIXFeaturesSourceWriter& featureDefinitions,
const std::vector<std::string>& packageExecutables,
const std::vector<std::string>& desktopExecutables,
shortcut_map_t& shortcutMap)
@ -993,6 +814,16 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
cmsys::Directory dir;
dir.Load(topdir.c_str());
if(dir.GetNumberOfFiles() == 2)
{
std::string componentId = fileDefinitions.EmitComponentCreateFolder(
directoryId, GenerateGUID());
featureDefinitions.EmitComponentRef(componentId);
return;
}
for(size_t i = 0; i < dir.GetNumberOfFiles(); ++i)
{
std::string fileName = dir.GetFile(static_cast<unsigned long>(i));
@ -1026,44 +857,15 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
desktopExecutables,
shortcutMap);
ApplyPatchFragment(subDirectoryId, directoryDefinitions);
this->Patch.ApplyFragment(subDirectoryId, directoryDefinitions);
directoryDefinitions.EndElement("Directory");
}
else
{
std::string componentId = std::string("CM_C") + id;
std::string fileId = std::string("CM_F") + id;
std::string componentId = fileDefinitions.EmitComponentFile(
directoryId, id, fullPath, this->Patch);
fileDefinitions.BeginElement("DirectoryRef");
fileDefinitions.AddAttribute("Id", directoryId);
fileDefinitions.BeginElement("Component");
fileDefinitions.AddAttribute("Id", componentId);
fileDefinitions.AddAttribute("Guid", "*");
fileDefinitions.BeginElement("File");
fileDefinitions.AddAttribute("Id", fileId);
fileDefinitions.AddAttribute("Source", fullPath);
fileDefinitions.AddAttribute("KeyPath", "yes");
mode_t fileMode = 0;
cmSystemTools::GetPermissions(fullPath.c_str(), fileMode);
if(!(fileMode & S_IWRITE))
{
fileDefinitions.AddAttribute("ReadOnly", "yes");
}
ApplyPatchFragment(fileId, fileDefinitions);
fileDefinitions.EndElement("File");
ApplyPatchFragment(componentId, fileDefinitions);
fileDefinitions.EndElement("Component");
fileDefinitions.EndElement("DirectoryRef");
featureDefinitions.BeginElement("ComponentRef");
featureDefinitions.AddAttribute("Id", componentId);
featureDefinitions.EndElement("ComponentRef");
featureDefinitions.EmitComponentRef(componentId);
for(size_t j = 0; j < packageExecutables.size(); ++j)
{
@ -1092,7 +894,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
}
bool cmCPackWIXGenerator::RequireOption(
const std::string& name, std::string &value) const
std::string const& name, std::string &value) const
{
const char* tmp = GetOption(name.c_str());
if(tmp)
@ -1140,13 +942,13 @@ std::string cmCPackWIXGenerator::GenerateGUID()
return cmSystemTools::UpperCase(result);
}
std::string cmCPackWIXGenerator::QuotePath(const std::string& path)
std::string cmCPackWIXGenerator::QuotePath(std::string const& path)
{
return std::string("\"") + path + '"';
}
std::string cmCPackWIXGenerator::GetRightmostExtension(
const std::string& filename)
std::string const& filename)
{
std::string extension;
@ -1159,7 +961,7 @@ std::string cmCPackWIXGenerator::GetRightmostExtension(
return cmSystemTools::LowerCase(extension);
}
std::string cmCPackWIXGenerator::PathToId(const std::string& path)
std::string cmCPackWIXGenerator::PathToId(std::string const& path)
{
id_map_t::const_iterator i = PathToIdMap.find(path);
if(i != PathToIdMap.end()) return i->second;
@ -1168,7 +970,7 @@ std::string cmCPackWIXGenerator::PathToId(const std::string& path)
return id;
}
std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path)
std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path)
{
std::vector<std::string> components;
cmSystemTools::SplitPath(path.c_str(), components, false);
@ -1222,7 +1024,7 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path)
}
std::string cmCPackWIXGenerator::CreateHashedId(
const std::string& path, const std::string& normalizedFilename)
std::string const& path, std::string const& normalizedFilename)
{
cmsys::auto_ptr<cmCryptoHash> sha1 = cmCryptoHash::New("SHA1");
std::string hash = sha1->HashString(path.c_str());
@ -1245,7 +1047,7 @@ std::string cmCPackWIXGenerator::CreateHashedId(
}
std::string cmCPackWIXGenerator::NormalizeComponentForId(
const std::string& component, size_t& replacementCount)
std::string const& component, size_t& replacementCount)
{
std::string result;
result.resize(component.size());
@ -1276,7 +1078,7 @@ bool cmCPackWIXGenerator::IsLegalIdCharacter(char c)
}
void cmCPackWIXGenerator::CollectExtensions(
const std::string& variableName, extension_set_t& extensions)
std::string const& variableName, extension_set_t& extensions)
{
const char *variableContent = GetOption(variableName.c_str());
if(!variableContent) return;
@ -1292,7 +1094,7 @@ void cmCPackWIXGenerator::CollectExtensions(
}
void cmCPackWIXGenerator::AddCustomFlags(
const std::string& variableName, std::ostream& stream)
std::string const& variableName, std::ostream& stream)
{
const char *variableContent = GetOption(variableName.c_str());
if(!variableContent) return;
@ -1306,69 +1108,3 @@ void cmCPackWIXGenerator::AddCustomFlags(
stream << " " << QuotePath(*i);
}
}
void cmCPackWIXGenerator::CreateStartMenuFolder(
cmWIXSourceWriter& directoryDefinitions)
{
directoryDefinitions.BeginElement("Directory");
directoryDefinitions.AddAttribute("Id", "ProgramMenuFolder");
directoryDefinitions.BeginElement("Directory");
directoryDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER");
const char *startMenuFolder = GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
directoryDefinitions.AddAttribute("Name", startMenuFolder);
directoryDefinitions.EndElement("Directory");
directoryDefinitions.EndElement("Directory");
}
void cmCPackWIXGenerator::CreateDesktopFolder(
cmWIXSourceWriter& directoryDefinitions)
{
directoryDefinitions.BeginElement("Directory");
directoryDefinitions.AddAttribute("Id", "DesktopFolder");
directoryDefinitions.AddAttribute("Name", "Desktop");
directoryDefinitions.EndElement("Directory");
}
void cmCPackWIXGenerator::LoadPatchFragments(const std::string& patchFilePath)
{
cmWIXPatchParser parser(Fragments, Logger);
parser.ParseFile(patchFilePath.c_str());
}
void cmCPackWIXGenerator::ApplyPatchFragment(
const std::string& id, cmWIXSourceWriter& writer)
{
cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id);
if(i == Fragments.end()) return;
const cmWIXPatchElement& fragment = i->second;
for(cmWIXPatchElement::child_list_t::const_iterator
j = fragment.children.begin(); j != fragment.children.end(); ++j)
{
ApplyPatchElement(**j, writer);
}
Fragments.erase(i);
}
void cmCPackWIXGenerator::ApplyPatchElement(
const cmWIXPatchElement& element, cmWIXSourceWriter& writer)
{
writer.BeginElement(element.name);
for(cmWIXPatchElement::attributes_t::const_iterator
i = element.attributes.begin(); i != element.attributes.end(); ++i)
{
writer.AddAttribute(i->first, i->second);
}
for(cmWIXPatchElement::child_list_t::const_iterator
i = element.children.begin(); i != element.children.end(); ++i)
{
ApplyPatchElement(**i, writer);
}
writer.EndElement(element.name);
}

View File

@ -13,25 +13,18 @@
#ifndef cmCPackWIXGenerator_h
#define cmCPackWIXGenerator_h
#include "cmWIXPatchParser.h"
#include "cmWIXPatch.h"
#include "cmWIXShortcut.h"
#include <CPack/cmCPackGenerator.h>
#include <string>
#include <map>
struct cmWIXShortcut
{
cmWIXShortcut()
:desktop(false)
{}
std::string textLabel;
std::string workingDirectoryId;
bool desktop;
};
class cmWIXSourceWriter;
class cmWIXDirectoriesSourceWriter;
class cmWIXFilesSourceWriter;
class cmWIXFeaturesSourceWriter;
/** \class cmCPackWIXGenerator
* \brief A generator for WIX files
@ -78,48 +71,39 @@ private:
bool PackageFilesImpl();
bool CreateWiXVariablesIncludeFile();
void CreateWiXVariablesIncludeFile();
void CreateWiXPropertiesIncludeFile();
void CopyDefinition(
cmWIXSourceWriter &source, const std::string &name);
cmWIXSourceWriter &source, std::string const& name);
void AddDefinition(cmWIXSourceWriter& source,
const std::string& name, const std::string& value);
std::string const& name, std::string const& value);
bool CreateWiXSourceFiles();
bool CreateCMakePackageRegistryEntry(
cmWIXSourceWriter& featureDefinitions);
std::string GetProgramFilesFolderId() const;
bool GenerateMainSourceFileFromTemplate();
bool CreateFeatureHierarchy(
cmWIXSourceWriter& featureDefinitions);
bool EmitFeatureForComponentGroup(
cmWIXSourceWriter& featureDefinitions,
cmCPackComponentGroup const& group);
bool EmitFeatureForComponent(
cmWIXSourceWriter& featureDefinitions,
cmCPackComponent const& component);
cmWIXFeaturesSourceWriter& featureDefinitions);
bool AddComponentsToFeature(
std::string const& rootPath,
std::string const& featureId,
cmWIXSourceWriter& directoryDefinitions,
cmWIXSourceWriter& fileDefinitions,
cmWIXSourceWriter& featureDefinitions,
cmWIXDirectoriesSourceWriter& directoryDefinitions,
cmWIXFilesSourceWriter& fileDefinitions,
cmWIXFeaturesSourceWriter& featureDefinitions,
shortcut_map_t& shortcutMap);
bool CreateStartMenuShortcuts(
std::string const& cpackComponentName,
std::string const& featureId,
shortcut_map_t& shortcutMap,
cmWIXSourceWriter& fileDefinitions,
cmWIXSourceWriter& featureDefinitions);
void CreateUninstallShortcut(
std::string const& packageName,
cmWIXSourceWriter& fileDefinitions);
cmWIXFilesSourceWriter& fileDefinitions,
cmWIXFeaturesSourceWriter& featureDefinitions);
void AppendUserSuppliedExtraSources();
@ -127,60 +111,49 @@ private:
bool CreateLicenseFile();
bool RunWiXCommand(const std::string& command);
bool RunWiXCommand(std::string const& command);
bool RunCandleCommand(
const std::string& sourceFile, const std::string& objectFile);
std::string const& sourceFile, std::string const& objectFile);
bool RunLightCommand(const std::string& objectFiles);
bool RunLightCommand(std::string const& objectFiles);
void AddDirectoryAndFileDefinitons(const std::string& topdir,
const std::string& directoryId,
cmWIXSourceWriter& directoryDefinitions,
cmWIXSourceWriter& fileDefinitions,
cmWIXSourceWriter& featureDefinitions,
void AddDirectoryAndFileDefinitons(std::string const& topdir,
std::string const& directoryId,
cmWIXDirectoriesSourceWriter& directoryDefinitions,
cmWIXFilesSourceWriter& fileDefinitions,
cmWIXFeaturesSourceWriter& featureDefinitions,
const std::vector<std::string>& pkgExecutables,
const std::vector<std::string>& desktopExecutables,
shortcut_map_t& shortcutMap);
bool RequireOption(const std::string& name, std::string& value) const;
bool RequireOption(std::string const& name, std::string& value) const;
std::string GetArchitecture() const;
static std::string GenerateGUID();
static std::string QuotePath(const std::string& path);
static std::string QuotePath(std::string const& path);
static std::string GetRightmostExtension(const std::string& filename);
static std::string GetRightmostExtension(std::string const& filename);
std::string PathToId(const std::string& path);
std::string PathToId(std::string const& path);
std::string CreateNewIdForPath(const std::string& path);
std::string CreateNewIdForPath(std::string const& path);
static std::string CreateHashedId(
const std::string& path, const std::string& normalizedFilename);
std::string const& path, std::string const& normalizedFilename);
std::string NormalizeComponentForId(
const std::string& component, size_t& replacementCount);
std::string const& component, size_t& replacementCount);
static bool IsLegalIdCharacter(char c);
void CollectExtensions(
const std::string& variableName, extension_set_t& extensions);
std::string const& variableName, extension_set_t& extensions);
void AddCustomFlags(
const std::string& variableName, std::ostream& stream);
void CreateStartMenuFolder(cmWIXSourceWriter& directoryDefinitions);
void CreateDesktopFolder(cmWIXSourceWriter& directoryDefinitions);
void LoadPatchFragments(const std::string& patchFilePath);
void ApplyPatchFragment(const std::string& id, cmWIXSourceWriter& writer);
void ApplyPatchElement(const cmWIXPatchElement& element,
cmWIXSourceWriter& writer);
std::string const& variableName, std::ostream& stream);
std::vector<std::string> WixSources;
id_map_t PathToIdMap;
@ -189,9 +162,11 @@ private:
extension_set_t CandleExtensions;
extension_set_t LightExtensions;
cmWIXPatchParser::fragment_map_t Fragments;
bool HasDesktopShortcuts;
std::string CPackTopLevel;
cmWIXPatch Patch;
};
#endif

View File

@ -0,0 +1,87 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2014 Kitware, Inc.
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#include "cmWIXDirectoriesSourceWriter.h"
cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(cmCPackLog* logger,
std::string const& filename):
cmWIXSourceWriter(logger, filename)
{
}
void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder(
std::string const& startMenuFolder)
{
BeginElement("Directory");
AddAttribute("Id", "ProgramMenuFolder");
BeginElement("Directory");
AddAttribute("Id", "PROGRAM_MENU_FOLDER");
AddAttribute("Name", startMenuFolder);
EndElement("Directory");
EndElement("Directory");
}
void cmWIXDirectoriesSourceWriter::EmitDesktopFolder()
{
BeginElement("Directory");
AddAttribute("Id", "DesktopFolder");
AddAttribute("Name", "Desktop");
EndElement("Directory");
}
size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
std::string const& programFilesFolderId,
std::string const& installRootString)
{
BeginElement("Directory");
AddAttribute("Id", programFilesFolderId);
std::vector<std::string> installRoot;
cmSystemTools::SplitPath(installRootString.c_str(), installRoot);
if(!installRoot.empty() && installRoot.back().empty())
{
installRoot.pop_back();
}
for(size_t i = 1; i < installRoot.size(); ++i)
{
BeginElement("Directory");
if(i == installRoot.size() - 1)
{
AddAttribute("Id", "INSTALL_ROOT");
}
else
{
std::stringstream tmp;
tmp << "INSTALL_PREFIX_" << i;
AddAttribute("Id", tmp.str());
}
AddAttribute("Name", installRoot[i]);
}
return installRoot.size();
}
void cmWIXDirectoriesSourceWriter::EndInstallationPrefixDirectory(size_t size)
{
for(size_t i = 0; i < size; ++i)
{
EndElement("Directory");
}
}

View File

@ -0,0 +1,42 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2014 Kitware, Inc.
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifndef cmWIXDirectoriesSourceWriter_h
#define cmWIXDirectoriesSourceWriter_h
#include "cmWIXSourceWriter.h"
#include <CPack/cmCPackGenerator.h>
#include <string>
/** \class cmWIXDirectoriesSourceWriter
* \brief Helper class to generate directories.wxs
*/
class cmWIXDirectoriesSourceWriter : public cmWIXSourceWriter
{
public:
cmWIXDirectoriesSourceWriter(cmCPackLog* logger,
std::string const& filename);
void EmitStartMenuFolder(std::string const& startMenuFolder);
void EmitDesktopFolder();
size_t BeginInstallationPrefixDirectory(
std::string const& programFilesFolderId,
std::string const& installRootString);
void EndInstallationPrefixDirectory(size_t size);
};
#endif

View File

@ -0,0 +1,102 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2014 Kitware, Inc.
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#include "cmWIXFeaturesSourceWriter.h"
cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(cmCPackLog* logger,
std::string const& filename):
cmWIXSourceWriter(logger, filename)
{
}
void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
std::string const& package,
std::string const& upgradeGuid)
{
BeginElement("Component");
AddAttribute("Id", "CM_PACKAGE_REGISTRY");
AddAttribute("Directory", "TARGETDIR");
AddAttribute("Guid", "*");
std::string registryKey =
std::string("Software\\Kitware\\CMake\\Packages\\") + package;
BeginElement("RegistryValue");
AddAttribute("Root", "HKLM");
AddAttribute("Key", registryKey);
AddAttribute("Name", upgradeGuid);
AddAttribute("Type", "string");
AddAttribute("Value", "[INSTALL_ROOT]");
AddAttribute("KeyPath", "yes");
EndElement("RegistryValue");
EndElement("Component");
}
void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
cmCPackComponentGroup const& group)
{
BeginElement("Feature");
AddAttribute("Id", "CM_G_" + group.Name);
if(group.IsExpandedByDefault)
{
AddAttribute("Display", "expand");
}
AddAttributeUnlessEmpty("Title", group.DisplayName);
AddAttributeUnlessEmpty("Description", group.Description);
for(std::vector<cmCPackComponentGroup*>::const_iterator
i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i)
{
EmitFeatureForComponentGroup(**i);
}
for(std::vector<cmCPackComponent*>::const_iterator
i = group.Components.begin(); i != group.Components.end(); ++i)
{
EmitFeatureForComponent(**i);
}
EndElement("Feature");
}
void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
cmCPackComponent const& component)
{
BeginElement("Feature");
AddAttribute("Id", "CM_C_" + component.Name);
AddAttributeUnlessEmpty("Title", component.DisplayName);
AddAttributeUnlessEmpty("Description", component.Description);
if(component.IsRequired)
{
AddAttribute("Absent", "disallow");
}
if(component.IsHidden)
{
AddAttribute("Display", "hidden");
}
EndElement("Feature");
}
void cmWIXFeaturesSourceWriter::EmitComponentRef(std::string const& id)
{
BeginElement("ComponentRef");
AddAttribute("Id", id);
EndElement("ComponentRef");
}

View File

@ -0,0 +1,39 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2014 Kitware, Inc.
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifndef cmWIXFeaturesSourceWriter_h
#define cmWIXFeaturesSourceWriter_h
#include "cmWIXSourceWriter.h"
#include <CPack/cmCPackGenerator.h>
/** \class cmWIXFeaturesSourceWriter
* \brief Helper class to generate features.wxs
*/
class cmWIXFeaturesSourceWriter : public cmWIXSourceWriter
{
public:
cmWIXFeaturesSourceWriter(cmCPackLog* logger,
std::string const& filename);
void CreateCMakePackageRegistryEntry(
std::string const& package,
std::string const& upgradeGuid);
void EmitFeatureForComponentGroup(const cmCPackComponentGroup& group);
void EmitFeatureForComponent(const cmCPackComponent& component);
void EmitComponentRef(std::string const& id);
};
#endif

View File

@ -0,0 +1,171 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2014 Kitware, Inc.
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#include "cmWIXFilesSourceWriter.h"
#include <sys/types.h>
#include <sys/stat.h>
cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger,
std::string const& filename):
cmWIXSourceWriter(logger, filename)
{
}
void cmWIXFilesSourceWriter::EmitShortcut(
std::string const& id,
cmWIXShortcut const& shortcut,
bool desktop)
{
std::string shortcutId;
if(desktop)
{
shortcutId = "CM_DS";
}
else
{
shortcutId = "CM_S";
}
shortcutId += id;
std::string fileId = std::string("CM_F") + id;
BeginElement("Shortcut");
AddAttribute("Id", shortcutId);
AddAttribute("Name", shortcut.textLabel);
std::string target = "[#" + fileId + "]";
AddAttribute("Target", target);
AddAttribute("WorkingDirectory", shortcut.workingDirectoryId);
EndElement("Shortcut");
}
void cmWIXFilesSourceWriter::EmitRemoveFolder(std::string const& id)
{
BeginElement("RemoveFolder");
AddAttribute("Id", id);
AddAttribute("On", "uninstall");
EndElement("RemoveFolder");
}
void cmWIXFilesSourceWriter::EmitStartMenuShortcutRegistryValue(
std::string const& registryKey,
std::string const& cpackComponentName)
{
EmitInstallRegistryValue(registryKey, cpackComponentName, std::string());
}
void cmWIXFilesSourceWriter::EmitDesktopShortcutRegistryValue(
std::string const& registryKey,
std::string const& cpackComponentName)
{
EmitInstallRegistryValue(registryKey, cpackComponentName, "_desktop");
}
void cmWIXFilesSourceWriter::EmitInstallRegistryValue(
std::string const& registryKey,
std::string const& cpackComponentName,
std::string const& suffix)
{
std::string valueName;
if(!cpackComponentName.empty())
{
valueName = cpackComponentName + "_";
}
valueName += "installed";
valueName += suffix;
BeginElement("RegistryValue");
AddAttribute("Root", "HKCU");
AddAttribute("Key", registryKey);
AddAttribute("Name", valueName);
AddAttribute("Type", "integer");
AddAttribute("Value", "1");
AddAttribute("KeyPath", "yes");
EndElement("RegistryValue");
}
void cmWIXFilesSourceWriter::EmitUninstallShortcut(
std::string const& packageName)
{
BeginElement("Shortcut");
AddAttribute("Id", "UNINSTALL");
AddAttribute("Name", "Uninstall " + packageName);
AddAttribute("Description", "Uninstalls " + packageName);
AddAttribute("Target", "[SystemFolder]msiexec.exe");
AddAttribute("Arguments", "/x [ProductCode]");
EndElement("Shortcut");
}
std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
std::string const& directoryId, std::string const& guid)
{
std::string componentId =
std::string("CM_C_EMPTY_") + directoryId;
BeginElement("DirectoryRef");
AddAttribute("Id", directoryId);
BeginElement("Component");
AddAttribute("Id", componentId);
AddAttribute("Guid", guid);
BeginElement("CreateFolder");
EndElement("CreateFolder");
EndElement("Component");
EndElement("DirectoryRef");
return componentId;
}
std::string cmWIXFilesSourceWriter::EmitComponentFile(
std::string const& directoryId,
std::string const& id,
std::string const& filePath,
cmWIXPatch &patch)
{
std::string componentId = std::string("CM_C") + id;
std::string fileId = std::string("CM_F") + id;
BeginElement("DirectoryRef");
AddAttribute("Id", directoryId);
BeginElement("Component");
AddAttribute("Id", componentId);
AddAttribute("Guid", "*");
BeginElement("File");
AddAttribute("Id", fileId);
AddAttribute("Source", filePath);
AddAttribute("KeyPath", "yes");
mode_t fileMode = 0;
cmSystemTools::GetPermissions(filePath.c_str(), fileMode);
if(!(fileMode & S_IWRITE))
{
AddAttribute("ReadOnly", "yes");
}
patch.ApplyFragment(fileId, *this);
EndElement("File");
patch.ApplyFragment(componentId, *this);
EndElement("Component");
EndElement("DirectoryRef");
return componentId;
}

View File

@ -0,0 +1,66 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2014 Kitware, Inc.
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifndef cmWIXFilesSourceWriter_h
#define cmWIXFilesSourceWriter_h
#include "cmWIXSourceWriter.h"
#include "cmWIXShortcut.h"
#include "cmWIXPatch.h"
#include <CPack/cmCPackGenerator.h>
/** \class cmWIXFilesSourceWriter
* \brief Helper class to generate files.wxs
*/
class cmWIXFilesSourceWriter : public cmWIXSourceWriter
{
public:
cmWIXFilesSourceWriter(cmCPackLog* logger,
std::string const& filename);
void EmitShortcut(
std::string const& id,
cmWIXShortcut const& shortcut,
bool desktop);
void EmitRemoveFolder(std::string const& id);
void EmitStartMenuShortcutRegistryValue(
std::string const& registryKey,
std::string const& cpackComponentName);
void EmitDesktopShortcutRegistryValue(
std::string const& registryKey,
std::string const& cpackComponentName);
void EmitUninstallShortcut(std::string const& packageName);
std::string EmitComponentCreateFolder(
std::string const& directoryId,
std::string const& guid);
std::string EmitComponentFile(
std::string const& directoryId,
std::string const& id,
std::string const& filePath,
cmWIXPatch &patch);
private:
void EmitInstallRegistryValue(
std::string const& registryKey,
std::string const& cpackComponentName,
std::string const& suffix);
};
#endif

View File

@ -0,0 +1,91 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2014 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 "cmWIXPatch.h"
#include <CPack/cmCPackGenerator.h>
cmWIXPatch::cmWIXPatch(cmCPackLog* logger):
Logger(logger)
{
}
void cmWIXPatch::LoadFragments(std::string const& patchFilePath)
{
cmWIXPatchParser parser(Fragments, Logger);
parser.ParseFile(patchFilePath.c_str());
}
void cmWIXPatch::ApplyFragment(
std::string const& id, cmWIXSourceWriter& writer)
{
cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id);
if(i == Fragments.end()) return;
const cmWIXPatchElement& fragment = i->second;
for(cmWIXPatchElement::child_list_t::const_iterator
j = fragment.children.begin(); j != fragment.children.end(); ++j)
{
ApplyElement(**j, writer);
}
Fragments.erase(i);
}
void cmWIXPatch::ApplyElement(
const cmWIXPatchElement& element, cmWIXSourceWriter& writer)
{
writer.BeginElement(element.name);
for(cmWIXPatchElement::attributes_t::const_iterator
i = element.attributes.begin(); i != element.attributes.end(); ++i)
{
writer.AddAttribute(i->first, i->second);
}
for(cmWIXPatchElement::child_list_t::const_iterator
i = element.children.begin(); i != element.children.end(); ++i)
{
ApplyElement(**i, writer);
}
writer.EndElement(element.name);
}
bool cmWIXPatch::CheckForUnappliedFragments()
{
std::string fragmentList;
for(cmWIXPatchParser::fragment_map_t::const_iterator
i = Fragments.begin(); i != Fragments.end(); ++i)
{
if(!fragmentList.empty())
{
fragmentList += ", ";
}
fragmentList += "'";
fragmentList += i->first;
fragmentList += "'";
}
if(fragmentList.size())
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Some XML patch fragments did not have matching IDs: " <<
fragmentList << std::endl);
return false;
}
return true;
}

View File

@ -0,0 +1,45 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2014 Kitware, Inc.
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifndef cmWIXPatch_h
#define cmWIXPatch_h
#include "cmWIXSourceWriter.h"
#include "cmWIXPatchParser.h"
#include <string>
/** \class cmWIXPatch
* \brief Class that maintains and applies patch fragments
*/
class cmWIXPatch
{
public:
cmWIXPatch(cmCPackLog* logger);
void LoadFragments(std::string const& patchFilePath);
void ApplyFragment(std::string const& id, cmWIXSourceWriter& writer);
bool CheckForUnappliedFragments();
private:
void ApplyElement(const cmWIXPatchElement& element,
cmWIXSourceWriter& writer);
cmCPackLog* Logger;
cmWIXPatchParser::fragment_map_t Fragments;
};
#endif

View File

@ -34,12 +34,11 @@ cmWIXPatchParser::cmWIXPatchParser(
}
void cmWIXPatchParser::StartElement(const char *name, const char **atts)
void cmWIXPatchParser::StartElement(const std::string& name, const char **atts)
{
std::string name_str = name;
if(State == BEGIN_DOCUMENT)
{
if(name_str == "CPackWiXPatch")
if(name == "CPackWiXPatch")
{
State = BEGIN_FRAGMENTS;
}
@ -50,7 +49,7 @@ void cmWIXPatchParser::StartElement(const char *name, const char **atts)
}
else if(State == BEGIN_FRAGMENTS)
{
if(name_str == "CPackWiXFragment")
if(name == "CPackWiXFragment")
{
State = INSIDE_FRAGMENT;
StartFragment(atts);
@ -107,12 +106,11 @@ void cmWIXPatchParser::StartFragment(const char **attributes)
}
}
void cmWIXPatchParser::EndElement(const char *name)
void cmWIXPatchParser::EndElement(const std::string& name)
{
std::string name_str = name;
if(State == INSIDE_FRAGMENT)
{
if(name_str == "CPackWiXFragment")
if(name == "CPackWiXFragment")
{
State = BEGIN_FRAGMENTS;
ElementStack.clear();
@ -132,7 +130,7 @@ void cmWIXPatchParser::ReportError(int line, int column, const char* msg)
Valid = false;
}
void cmWIXPatchParser::ReportValidationError(const std::string& message)
void cmWIXPatchParser::ReportValidationError(std::string const& message)
{
ReportError(XML_GetCurrentLineNumber(Parser),
XML_GetCurrentColumnNumber(Parser),

View File

@ -43,14 +43,14 @@ public:
cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger);
private:
virtual void StartElement(const char *name, const char **atts);
virtual void StartElement(const std::string& name, const char **atts);
void StartFragment(const char **attributes);
virtual void EndElement(const char *name);
virtual void EndElement(const std::string& name);
virtual void ReportError(int line, int column, const char* msg);
void ReportValidationError(const std::string& message);
void ReportValidationError(std::string const& message);
bool IsValid() const;

View File

@ -15,7 +15,7 @@
#include <cmVersion.h>
cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter(
const std::string& filename):
std::string const& filename):
File(filename.c_str(), std::ios::binary)
{
StartGroup();
@ -33,7 +33,7 @@ cmWIXRichTextFormatWriter::~cmWIXRichTextFormatWriter()
File.put(0);
}
void cmWIXRichTextFormatWriter::AddText(const std::string& text)
void cmWIXRichTextFormatWriter::AddText(std::string const& text)
{
typedef unsigned char rtf_byte_t;
@ -167,12 +167,12 @@ void cmWIXRichTextFormatWriter::WriteDocumentPrefix()
ControlWord("fs20");
}
void cmWIXRichTextFormatWriter::ControlWord(const std::string& keyword)
void cmWIXRichTextFormatWriter::ControlWord(std::string const& keyword)
{
File << "\\" << keyword;
}
void cmWIXRichTextFormatWriter::NewControlWord(const std::string& keyword)
void cmWIXRichTextFormatWriter::NewControlWord(std::string const& keyword)
{
File << "\\*\\" << keyword;
}

View File

@ -22,10 +22,10 @@
class cmWIXRichTextFormatWriter
{
public:
cmWIXRichTextFormatWriter(const std::string& filename);
cmWIXRichTextFormatWriter(std::string const& filename);
~cmWIXRichTextFormatWriter();
void AddText(const std::string& text);
void AddText(std::string const& text);
private:
void WriteHeader();
@ -35,8 +35,8 @@ private:
void WriteDocumentPrefix();
void ControlWord(const std::string& keyword);
void NewControlWord(const std::string& keyword);
void ControlWord(std::string const& keyword);
void NewControlWord(std::string const& keyword);
void StartGroup();
void EndGroup();

View File

@ -0,0 +1,29 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2014 Kitware, Inc.
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifndef cmWIXFilesShortcut_h
#define cmWIXFilesShortcut_h
#include <string>
struct cmWIXShortcut
{
cmWIXShortcut()
:desktop(false)
{}
std::string textLabel;
std::string workingDirectoryId;
bool desktop;
};
#endif

View File

@ -17,7 +17,7 @@
#include <windows.h>
cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
const std::string& filename,
std::string const& filename,
bool isIncludeFile):
Logger(logger),
File(filename.c_str()),
@ -51,7 +51,7 @@ cmWIXSourceWriter::~cmWIXSourceWriter()
EndElement(Elements.back());
}
void cmWIXSourceWriter::BeginElement(const std::string& name)
void cmWIXSourceWriter::BeginElement(std::string const& name)
{
if(State == BEGIN)
{
@ -101,7 +101,7 @@ void cmWIXSourceWriter::EndElement(std::string const& name)
}
void cmWIXSourceWriter::AddProcessingInstruction(
const std::string& target, const std::string& content)
std::string const& target, std::string const& content)
{
if(State == BEGIN)
{
@ -116,7 +116,7 @@ void cmWIXSourceWriter::AddProcessingInstruction(
}
void cmWIXSourceWriter::AddAttribute(
const std::string& key, const std::string& value)
std::string const& key, std::string const& value)
{
std::string utf8 = WindowsCodepageToUtf8(value);
@ -124,7 +124,7 @@ void cmWIXSourceWriter::AddAttribute(
}
void cmWIXSourceWriter::AddAttributeUnlessEmpty(
const std::string& key, const std::string& value)
std::string const& key, std::string const& value)
{
if(value.size())
{
@ -132,7 +132,7 @@ void cmWIXSourceWriter::AddAttributeUnlessEmpty(
}
}
std::string cmWIXSourceWriter::WindowsCodepageToUtf8(const std::string& value)
std::string cmWIXSourceWriter::WindowsCodepageToUtf8(std::string const& value)
{
if(value.empty())
{
@ -184,7 +184,7 @@ void cmWIXSourceWriter::Indent(size_t count)
}
std::string cmWIXSourceWriter::EscapeAttributeValue(
const std::string& value)
std::string const& value)
{
std::string result;
result.reserve(value.size());

View File

@ -26,24 +26,24 @@ class cmWIXSourceWriter
{
public:
cmWIXSourceWriter(cmCPackLog* logger,
const std::string& filename, bool isIncludeFile = false);
std::string const& filename, bool isIncludeFile = false);
~cmWIXSourceWriter();
void BeginElement(const std::string& name);
void BeginElement(std::string const& name);
void EndElement(const std::string& name);
void EndElement(std::string const& name);
void AddProcessingInstruction(
const std::string& target, const std::string& content);
std::string const& target, std::string const& content);
void AddAttribute(
const std::string& key, const std::string& value);
std::string const& key, std::string const& value);
void AddAttributeUnlessEmpty(
const std::string& key, const std::string& value);
std::string const& key, std::string const& value);
static std::string WindowsCodepageToUtf8(const std::string& value);
static std::string WindowsCodepageToUtf8(std::string const& value);
private:
enum State
@ -56,7 +56,7 @@ private:
void Indent(size_t count);
static std::string EscapeAttributeValue(const std::string& value);
static std::string EscapeAttributeValue(std::string const& value);
cmCPackLog* Logger;

View File

@ -16,7 +16,8 @@
#include <string>
//----------------------------------------------------------------------
unsigned long cmCPackComponent::GetInstalledSize(const char* installDir) const
unsigned long cmCPackComponent::GetInstalledSize(
const std::string& installDir) const
{
if (this->TotalSize != 0)
{
@ -37,7 +38,7 @@ unsigned long cmCPackComponent::GetInstalledSize(const char* installDir) const
//----------------------------------------------------------------------
unsigned long
cmCPackComponent::GetInstalledSizeInKbytes(const char* installDir) const
cmCPackComponent::GetInstalledSizeInKbytes(const std::string& installDir) const
{
unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
return result? result : 1;

View File

@ -94,11 +94,11 @@ public:
/// Get the total installed size of all of the files in this
/// component, in bytes. installDir is the directory into which the
/// component was installed.
unsigned long GetInstalledSize(const char* installDir) const;
unsigned long GetInstalledSize(const std::string& installDir) const;
/// Identical to GetInstalledSize, but returns the result in
/// kilobytes.
unsigned long GetInstalledSizeInKbytes(const char* installDir) const;
unsigned long GetInstalledSizeInKbytes(const std::string& installDir) const;
private:
mutable unsigned long TotalSize;

View File

@ -403,9 +403,39 @@ int cmCPackDebGenerator::createDeb()
if (NULL != this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE")) {
cmd += this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE");
}
cmd += " \"";
cmd += cmakeExecutable;
cmd += "\" -E tar cfz data.tar.gz ";
const char* debian_compression_type =
this->GetOption("CPACK_DEBIAN_COMPRESSION_TYPE");
if(!debian_compression_type)
{
debian_compression_type = "gzip";
}
std::string cmake_tar = " ", compression_modifier = "a", compression_suffix;
if(!strcmp(debian_compression_type, "lzma")) {
compression_suffix = ".lzma";
} else if(!strcmp(debian_compression_type, "xz")) {
compression_suffix = ".xz";
} else if(!strcmp(debian_compression_type, "bzip2")) {
compression_suffix = ".bz2";
compression_modifier = "j";
cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
} else if(!strcmp(debian_compression_type, "gzip")) {
compression_suffix = ".gz";
compression_modifier = "z";
cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
} else if(!strcmp(debian_compression_type, "none")) {
compression_suffix = "";
compression_modifier = "";
cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
} else {
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Error unrecognized compression type: "
<< debian_compression_type << std::endl);
}
cmd += cmake_tar + "tar c" + compression_modifier + "f data.tar"
+ compression_suffix;
// now add all directories which have to be compressed
// collect all top level install dirs for that
@ -444,13 +474,13 @@ int cmCPackDebGenerator::createDeb()
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/Deb.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << cmd.c_str() << std::endl
ofs << "# Run command: " << cmd << std::endl
<< "# Working directory: " << toplevel << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
<< output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: "
<< cmd.c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
<< cmd << std::endl
<< "Please check " << tmpFile << " for errors" << std::endl);
return 0;
}
@ -493,9 +523,7 @@ int cmCPackDebGenerator::createDeb()
{
cmd = this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE");
}
cmd += " \"";
cmd += cmakeExecutable;
cmd += "\" -E tar cfz control.tar.gz ./control ./md5sums";
cmd += cmake_tar + "tar czf control.tar.gz ./control ./md5sums";
const char* controlExtra =
this->GetOption("CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA");
if( controlExtra )
@ -506,7 +534,7 @@ int cmCPackDebGenerator::createDeb()
controlExtraList.begin(); i != controlExtraList.end(); ++i)
{
std::string filenamename =
cmsys::SystemTools::GetFilenameName(i->c_str());
cmsys::SystemTools::GetFilenameName(*i);
std::string localcopy = this->GetOption("WDIR");
localcopy += "/";
localcopy += filenamename;
@ -514,7 +542,7 @@ int cmCPackDebGenerator::createDeb()
if( cmsys::SystemTools::CopyFileIfDifferent(
i->c_str(), localcopy.c_str()) )
{
// debian is picky and need relative to ./ path in the tar.gz
// debian is picky and need relative to ./ path in the tar.*
cmd += " ./";
cmd += filenamename;
}
@ -528,17 +556,17 @@ int cmCPackDebGenerator::createDeb()
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/Deb.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << cmd.c_str() << std::endl
ofs << "# Run command: " << cmd << std::endl
<< "# Working directory: " << toplevel << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
<< output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: "
<< cmd.c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
<< cmd << std::endl
<< "Please check " << tmpFile << " for errors" << std::endl);
return 0;
}
// ar -r your-package-name.deb debian-binary control.tar.gz data.tar.gz
// ar -r your-package-name.deb debian-binary control.tar.* data.tar.*
// since debian packages require BSD ar (most Linux distros and even
// FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here.
std::vector<std::string> arFiles;
@ -546,7 +574,7 @@ int cmCPackDebGenerator::createDeb()
topLevelString += "/";
arFiles.push_back(topLevelString + "debian-binary");
arFiles.push_back(topLevelString + "control.tar.gz");
arFiles.push_back(topLevelString + "data.tar.gz");
arFiles.push_back(topLevelString + "data.tar" + compression_suffix);
std::string outputFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
outputFileName += "/";
outputFileName += this->GetOption("CPACK_OUTPUT_FILE_NAME");
@ -588,9 +616,9 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
// the current COMPONENT belongs to.
std::string groupVar = "CPACK_COMPONENT_" +
cmSystemTools::UpperCase(componentName) + "_GROUP";
if (NULL != GetOption(groupVar.c_str()))
if (NULL != GetOption(groupVar))
{
return std::string(GetOption(groupVar.c_str()));
return std::string(GetOption(groupVar));
}
else
{

View File

@ -254,7 +254,7 @@ int cmCPackGenerator::InstallProject()
// If the project is a CMAKE project then run pre-install
// and then read the cmake_install script to run it
if ( !this->InstallProjectViaInstallCMakeProjects(
setDestDir, bareTempInstallDirectory.c_str()) )
setDestDir, bareTempInstallDirectory) )
{
return 0;
}
@ -269,7 +269,7 @@ int cmCPackGenerator::InstallProject()
//----------------------------------------------------------------------
int cmCPackGenerator::InstallProjectViaInstallCommands(
bool setDestDir, const char* tempInstallDirectory)
bool setDestDir, const std::string& tempInstallDirectory)
{
(void) setDestDir;
const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS");
@ -285,7 +285,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
it != installCommandsVector.end();
++it )
{
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << it->c_str()
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << *it
<< std::endl);
std::string output;
int retVal = 1;
@ -296,12 +296,12 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/InstallOutput.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << it->c_str() << std::endl
ofs << "# Run command: " << *it << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
<< output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem running install command: " << it->c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors"
"Problem running install command: " << *it << std::endl
<< "Please check " << tmpFile << " for errors"
<< std::endl);
return 0;
}
@ -312,7 +312,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
//----------------------------------------------------------------------
int cmCPackGenerator::InstallProjectViaInstalledDirectories(
bool setDestDir, const char* tempInstallDirectory)
bool setDestDir, const std::string& tempInstallDirectory)
{
(void)setDestDir;
(void)tempInstallDirectory;
@ -329,7 +329,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
++it )
{
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"Create ignore files regex for: " << it->c_str() << std::endl);
"Create ignore files regex for: " << *it << std::endl);
ignoreFilesRegex.push_back(it->c_str());
}
}
@ -349,7 +349,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
return 0;
}
std::vector<std::string>::iterator it;
const char* tempDir = tempInstallDirectory;
const std::string& tempDir = tempInstallDirectory;
for ( it = installDirectoriesVector.begin();
it != installDirectoriesVector.end();
++it )
@ -357,9 +357,9 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
std::list<std::pair<std::string,std::string> > symlinkedFiles;
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
cmsys::Glob gl;
std::string top = it->c_str();
std::string top = *it;
it ++;
std::string subdir = it->c_str();
std::string subdir = *it;
std::string findExpr = top;
findExpr += "/*";
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
@ -385,7 +385,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
if ( regIt->find(inFile.c_str()) )
{
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Ignore file: "
<< inFile.c_str() << std::endl);
<< inFile << std::endl);
skip = true;
}
}
@ -397,7 +397,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
filePath += "/" + subdir + "/"
+ cmSystemTools::RelativePath(top.c_str(), gfit->c_str());
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: "
<< inFile.c_str() << " -> " << filePath.c_str() << std::endl);
<< inFile << " -> " << filePath << std::endl);
/* If the file is a symlink we will have to re-create it */
if ( cmSystemTools::FileIsSymlink(inFile.c_str()))
{
@ -416,7 +416,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: "
<< inFile.c_str() << " -> " << filePath.c_str() << std::endl);
<< inFile << " -> " << filePath << std::endl);
return 0;
}
}
@ -457,7 +457,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
//----------------------------------------------------------------------
int cmCPackGenerator::InstallProjectViaInstallScript(
bool setDestDir, const char* tempInstallDirectory)
bool setDestDir, const std::string& tempInstallDirectory)
{
const char* cmakeScripts
= this->GetOption("CPACK_INSTALL_SCRIPT");
@ -473,7 +473,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript(
it != cmakeScriptsVector.end();
++it )
{
std::string installScript = it->c_str();
std::string installScript = *it;
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"- Install script: " << installScript << std::endl);
@ -499,7 +499,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript(
}
else
{
this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory);
this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory.c_str());
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"- Using non-DESTDIR install... (this->SetOption)" << std::endl);
@ -509,9 +509,9 @@ int cmCPackGenerator::InstallProjectViaInstallScript(
}
this->SetOptionIfNotSet("CMAKE_CURRENT_BINARY_DIR",
tempInstallDirectory);
tempInstallDirectory.c_str());
this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR",
tempInstallDirectory);
tempInstallDirectory.c_str());
int res = this->MakefileMap->ReadListFile(0, installScript.c_str());
if ( cmSystemTools::GetErrorOccuredFlag() || !res )
{
@ -524,7 +524,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript(
//----------------------------------------------------------------------
int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
bool setDestDir, const char* baseTempInstallDirectory)
bool setDestDir, const std::string& baseTempInstallDirectory)
{
const char* cmakeProjects
= this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS");
@ -562,13 +562,13 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
<< std::endl);
return 0;
}
std::string installDirectory = it->c_str();
std::string installDirectory = *it;
++it;
std::string installProjectName = it->c_str();
std::string installProjectName = *it;
++it;
std::string installComponent = it->c_str();
std::string installComponent = *it;
++it;
std::string installSubDirectory = it->c_str();
std::string installSubDirectory = *it;
std::string installFile = installDirectory + "/cmake_install.cmake";
std::vector<std::string> componentsVector;
@ -586,7 +586,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
// Determine the installation types for this project (if provided).
std::string installTypesVar = "CPACK_"
+ cmSystemTools::UpperCase(installComponent) + "_INSTALL_TYPES";
const char *installTypes = this->GetOption(installTypesVar.c_str());
const char *installTypes = this->GetOption(installTypesVar);
if (installTypes && *installTypes)
{
std::vector<std::string> installTypesVector;
@ -596,15 +596,15 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
installTypeIt != installTypesVector.end();
++installTypeIt)
{
this->GetInstallationType(installProjectName.c_str(),
installTypeIt->c_str());
this->GetInstallationType(installProjectName,
*installTypeIt);
}
}
// Determine the set of components that will be used in this project
std::string componentsVar
= "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(installComponent);
const char *components = this->GetOption(componentsVar.c_str());
const char *components = this->GetOption(componentsVar);
if (components && *components)
{
cmSystemTools::ExpandListArgument(components, componentsVector);
@ -613,7 +613,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
compIt != componentsVector.end();
++compIt)
{
GetComponent(installProjectName.c_str(), compIt->c_str());
GetComponent(installProjectName, *compIt);
}
componentInstall = true;
}
@ -623,7 +623,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
componentsVector.push_back(installComponent);
}
const char* buildConfig = this->GetOption("CPACK_BUILD_CONFIG");
const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG");
std::string buildConfig = buildConfigCstr ? buildConfigCstr : "";
cmGlobalGenerator* globalGenerator
= this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator(
cmakeGenerator);
@ -640,7 +641,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
= this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM");
std::vector<std::string> buildCommand;
globalGenerator->GenerateBuildCommand(buildCommand, cmakeMakeProgram,
installProjectName.c_str(), installDirectory.c_str(),
installProjectName, installDirectory,
globalGenerator->GetPreinstallTargetName(),
buildConfig, false);
std::string buildCommandStr =
@ -662,14 +663,14 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/PreinstallOutput.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << buildCommandStr.c_str() << std::endl
<< "# Directory: " << installDirectory.c_str() << std::endl
ofs << "# Run command: " << buildCommandStr << std::endl
<< "# Directory: " << installDirectory << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
<< output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem running install command: " << buildCommandStr.c_str()
"Problem running install command: " << buildCommandStr
<< std::endl
<< "Please check " << tmpFile.c_str() << " for errors"
<< "Please check " << tmpFile << " for errors"
<< std::endl);
return 0;
}
@ -822,9 +823,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
<< "'" << std::endl);
}
if ( buildConfig && *buildConfig )
if (!buildConfig.empty())
{
mf->AddDefinition("BUILD_TYPE", buildConfig);
mf->AddDefinition("BUILD_TYPE", buildConfig.c_str());
}
std::string installComponentLowerCase
= cmSystemTools::LowerCase(installComponent);
@ -931,19 +932,19 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
std::string absoluteDestFileComponent =
std::string("CPACK_ABSOLUTE_DESTINATION_FILES")
+ "_" + GetComponentInstallDirNameSuffix(installComponent);
if (NULL != this->GetOption(absoluteDestFileComponent.c_str()))
if (NULL != this->GetOption(absoluteDestFileComponent))
{
std::string absoluteDestFilesListComponent =
this->GetOption(absoluteDestFileComponent.c_str());
this->GetOption(absoluteDestFileComponent);
absoluteDestFilesListComponent +=";";
absoluteDestFilesListComponent +=
mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
this->SetOption(absoluteDestFileComponent.c_str(),
this->SetOption(absoluteDestFileComponent,
absoluteDestFilesListComponent.c_str());
}
else
{
this->SetOption(absoluteDestFileComponent.c_str(),
this->SetOption(absoluteDestFileComponent,
mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
}
}
@ -972,7 +973,7 @@ bool cmCPackGenerator::ReadListFile(const char* moduleName)
}
//----------------------------------------------------------------------
void cmCPackGenerator::SetOptionIfNotSet(const char* op,
void cmCPackGenerator::SetOptionIfNotSet(const std::string& op,
const char* value)
{
const char* def = this->MakefileMap->GetDefinition(op);
@ -984,12 +985,8 @@ void cmCPackGenerator::SetOptionIfNotSet(const char* op,
}
//----------------------------------------------------------------------
void cmCPackGenerator::SetOption(const char* op, const char* value)
void cmCPackGenerator::SetOption(const std::string& op, const char* value)
{
if ( !op )
{
return;
}
if ( !value )
{
this->MakefileMap->RemoveDefinition(op);
@ -1004,7 +1001,7 @@ void cmCPackGenerator::SetOption(const char* op, const char* value)
int cmCPackGenerator::DoPackage()
{
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"Create package using " << this->Name.c_str() << std::endl);
"Create package using " << this->Name << std::endl);
// Prepare CPack internal name and check
// values for many CPACK_xxx vars
@ -1092,7 +1089,7 @@ int cmCPackGenerator::DoPackage()
* may update this during PackageFiles.
* (either putting several names or updating the provided one)
*/
packageFileNames.push_back(tempPackageFileName);
packageFileNames.push_back(tempPackageFileName ? tempPackageFileName : "");
toplevel = tempDirectory;
if ( !this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag())
{
@ -1142,7 +1139,7 @@ int cmCPackGenerator::DoPackage()
}
//----------------------------------------------------------------------
int cmCPackGenerator::Initialize(const char* name, cmMakefile* mf)
int cmCPackGenerator::Initialize(const std::string& name, cmMakefile* mf)
{
this->MakefileMap = mf;
this->Name = name;
@ -1176,19 +1173,19 @@ int cmCPackGenerator::InitializeInternal()
}
//----------------------------------------------------------------------
bool cmCPackGenerator::IsSet(const char* name) const
bool cmCPackGenerator::IsSet(const std::string& name) const
{
return this->MakefileMap->IsSet(name);
}
//----------------------------------------------------------------------
bool cmCPackGenerator::IsOn(const char* name) const
bool cmCPackGenerator::IsOn(const std::string& name) const
{
return cmSystemTools::IsOn(GetOption(name));
}
//----------------------------------------------------------------------
const char* cmCPackGenerator::GetOption(const char* op) const
const char* cmCPackGenerator::GetOption(const std::string& op) const
{
const char* ret = this->MakefileMap->GetDefinition(op);
if(!ret)
@ -1201,6 +1198,12 @@ const char* cmCPackGenerator::GetOption(const char* op) const
return ret;
}
//----------------------------------------------------------------------
std::vector<std::string> cmCPackGenerator::GetOptions() const
{
return this->MakefileMap->GetDefinitions();
}
//----------------------------------------------------------------------
int cmCPackGenerator::PackageFiles()
{
@ -1266,7 +1269,7 @@ std::string cmCPackGenerator::FindTemplate(const char* name)
<< (name ? name : "(NULL)") << std::endl);
std::string ffile = this->MakefileMap->GetModulesFile(name);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: "
<< ffile.c_str() << std::endl);
<< ffile << std::endl);
return ffile;
}
@ -1425,14 +1428,14 @@ std::string cmCPackGenerator::GetComponentPackageFileName(
std::string suffix="-"+groupOrComponentName;
/* check if we should use DISPLAY name */
std::string dispNameVar = "CPACK_"+Name+"_USE_DISPLAY_NAME_IN_FILENAME";
if (IsOn(dispNameVar.c_str()))
if (IsOn(dispNameVar))
{
/* the component Group case */
if (isGroupName)
{
std::string groupDispVar = "CPACK_COMPONENT_GROUP_"
+ cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
const char* groupDispName = GetOption(groupDispVar.c_str());
const char* groupDispName = GetOption(groupDispVar);
if (groupDispName)
{
suffix = "-"+std::string(groupDispName);
@ -1443,7 +1446,7 @@ std::string cmCPackGenerator::GetComponentPackageFileName(
{
std::string dispVar = "CPACK_COMPONENT_"
+ cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
const char* dispName = GetOption(dispVar.c_str());
const char* dispName = GetOption(dispVar);
if(dispName)
{
suffix = "-"+std::string(dispName);
@ -1480,8 +1483,8 @@ bool cmCPackGenerator::WantsComponentInstallation() const
//----------------------------------------------------------------------
cmCPackInstallationType*
cmCPackGenerator::GetInstallationType(const char *projectName,
const char *name)
cmCPackGenerator::GetInstallationType(const std::string& projectName,
const std::string& name)
{
(void) projectName;
bool hasInstallationType = this->InstallationTypes.count(name) != 0;
@ -1494,7 +1497,7 @@ cmCPackGenerator::GetInstallationType(const char *projectName,
installType->Name = name;
const char* displayName
= this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str());
= this->GetOption(macroPrefix + "_DISPLAY_NAME");
if (displayName && *displayName)
{
installType->DisplayName = displayName;
@ -1512,7 +1515,8 @@ cmCPackGenerator::GetInstallationType(const char *projectName,
//----------------------------------------------------------------------
cmCPackComponent*
cmCPackGenerator::GetComponent(const char *projectName, const char *name)
cmCPackGenerator::GetComponent(const std::string& projectName,
const std::string& name)
{
bool hasComponent = this->Components.count(name) != 0;
cmCPackComponent *component = &this->Components[name];
@ -1523,7 +1527,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name)
+ cmsys::SystemTools::UpperCase(name);
component->Name = name;
const char* displayName
= this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str());
= this->GetOption(macroPrefix + "_DISPLAY_NAME");
if (displayName && *displayName)
{
component->DisplayName = displayName;
@ -1533,23 +1537,23 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name)
component->DisplayName = component->Name;
}
component->IsHidden
= this->IsOn((macroPrefix + "_HIDDEN").c_str());
= this->IsOn(macroPrefix + "_HIDDEN");
component->IsRequired
= this->IsOn((macroPrefix + "_REQUIRED").c_str());
= this->IsOn(macroPrefix + "_REQUIRED");
component->IsDisabledByDefault
= this->IsOn((macroPrefix + "_DISABLED").c_str());
= this->IsOn(macroPrefix + "_DISABLED");
component->IsDownloaded
= this->IsOn((macroPrefix + "_DOWNLOADED").c_str())
= this->IsOn(macroPrefix + "_DOWNLOADED")
|| cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL"));
const char* archiveFile = this->GetOption((macroPrefix +
"_ARCHIVE_FILE").c_str());
const char* archiveFile = this->GetOption(macroPrefix +
"_ARCHIVE_FILE");
if (archiveFile && *archiveFile)
{
component->ArchiveFile = archiveFile;
}
const char* groupName = this->GetOption((macroPrefix + "_GROUP").c_str());
const char* groupName = this->GetOption(macroPrefix + "_GROUP");
if (groupName && *groupName)
{
component->Group = GetComponentGroup(projectName, groupName);
@ -1561,7 +1565,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name)
}
const char* description
= this->GetOption((macroPrefix + "_DESCRIPTION").c_str());
= this->GetOption(macroPrefix + "_DESCRIPTION");
if (description && *description)
{
component->Description = description;
@ -1569,7 +1573,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name)
// Determine the installation types.
const char *installTypes
= this->GetOption((macroPrefix + "_INSTALL_TYPES").c_str());
= this->GetOption(macroPrefix + "_INSTALL_TYPES");
if (installTypes && *installTypes)
{
std::vector<std::string> installTypesVector;
@ -1580,12 +1584,12 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name)
++installTypesIt)
{
component->InstallationTypes.push_back(
this->GetInstallationType(projectName, installTypesIt->c_str()));
this->GetInstallationType(projectName, *installTypesIt));
}
}
// Determine the component dependencies.
const char *depends = this->GetOption((macroPrefix + "_DEPENDS").c_str());
const char *depends = this->GetOption(macroPrefix + "_DEPENDS");
if (depends && *depends)
{
std::vector<std::string> dependsVector;
@ -1596,7 +1600,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name)
++dependIt)
{
cmCPackComponent *child = GetComponent(projectName,
dependIt->c_str());
*dependIt);
component->Dependencies.push_back(child);
child->ReverseDependencies.push_back(component);
}
@ -1607,7 +1611,8 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name)
//----------------------------------------------------------------------
cmCPackComponentGroup*
cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name)
cmCPackGenerator::GetComponentGroup(const std::string& projectName,
const std::string& name)
{
(void) projectName;
std::string macroPrefix = "CPACK_COMPONENT_GROUP_"
@ -1619,7 +1624,7 @@ cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name)
// Define the group
group->Name = name;
const char* displayName
= this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str());
= this->GetOption(macroPrefix + "_DISPLAY_NAME");
if (displayName && *displayName)
{
group->DisplayName = displayName;
@ -1630,17 +1635,17 @@ cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name)
}
const char* description
= this->GetOption((macroPrefix + "_DESCRIPTION").c_str());
= this->GetOption(macroPrefix + "_DESCRIPTION");
if (description && *description)
{
group->Description = description;
}
group->IsBold
= this->IsOn((macroPrefix + "_BOLD_TITLE").c_str());
= this->IsOn(macroPrefix + "_BOLD_TITLE");
group->IsExpandedByDefault
= this->IsOn((macroPrefix + "_EXPANDED").c_str());
= this->IsOn(macroPrefix + "_EXPANDED");
const char* parentGroupName
= this->GetOption((macroPrefix + "_PARENT_GROUP").c_str());
= this->GetOption(macroPrefix + "_PARENT_GROUP");
if (parentGroupName && *parentGroupName)
{
group->ParentGroup = GetComponentGroup(projectName, parentGroupName);

View File

@ -90,7 +90,7 @@ public:
/**
* Initialize generator
*/
int Initialize(const char* name, cmMakefile* mf);
int Initialize(const std::string& name, cmMakefile* mf);
/**
* Construct generator
@ -99,11 +99,12 @@ public:
virtual ~cmCPackGenerator();
//! Set and get the options
void SetOption(const char* op, const char* value);
void SetOptionIfNotSet(const char* op, const char* value);
const char* GetOption(const char* op) const;
bool IsSet(const char* name) const;
bool IsOn(const char* name) const;
void SetOption(const std::string& op, const char* value);
void SetOptionIfNotSet(const std::string& op, const char* value);
const char* GetOption(const std::string& op) const;
std::vector<std::string> GetOptions() const;
bool IsSet(const std::string& name) const;
bool IsOn(const std::string& name) const;
//! Set the logger
void SetLogger(cmCPackLog* log) { this->Logger = log; }
@ -189,13 +190,13 @@ protected:
//! Run install commands if specified
virtual int InstallProjectViaInstallCommands(
bool setDestDir, const char* tempInstallDirectory);
bool setDestDir, const std::string& tempInstallDirectory);
virtual int InstallProjectViaInstallScript(
bool setDestDir, const char* tempInstallDirectory);
bool setDestDir, const std::string& tempInstallDirectory);
virtual int InstallProjectViaInstalledDirectories(
bool setDestDir, const char* tempInstallDirectory);
bool setDestDir, const std::string& tempInstallDirectory);
virtual int InstallProjectViaInstallCMakeProjects(
bool setDestDir, const char* tempInstallDirectory);
bool setDestDir, const std::string& tempInstallDirectory);
/**
* The various level of support of
@ -244,12 +245,14 @@ protected:
* @return true if component installation is supported and wanted.
*/
virtual bool WantsComponentInstallation() const;
virtual cmCPackInstallationType* GetInstallationType(const char *projectName,
const char* name);
virtual cmCPackComponent* GetComponent(const char *projectName,
const char* name);
virtual cmCPackComponentGroup* GetComponentGroup(const char *projectName,
const char* name);
virtual cmCPackInstallationType* GetInstallationType(
const std::string& projectName,
const std::string& name);
virtual cmCPackComponent* GetComponent(const std::string& projectName,
const std::string& name);
virtual cmCPackComponentGroup* GetComponentGroup(
const std::string& projectName,
const std::string& name);
cmSystemTools::OutputOption GeneratorVerbose;
std::string Name;

View File

@ -151,7 +151,8 @@ cmCPackGeneratorFactory::~cmCPackGeneratorFactory()
}
//----------------------------------------------------------------------
cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(const char* name)
cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(
const std::string& name)
{
cmCPackGenerator* gen = this->NewGeneratorInternal(name);
if ( !gen )
@ -165,12 +166,8 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(const char* name)
//----------------------------------------------------------------------
cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal(
const char* name)
const std::string& name)
{
if ( !name )
{
return 0;
}
cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it
= this->GeneratorCreators.find(name);
if ( it == this->GeneratorCreators.end() )
@ -181,11 +178,11 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal(
}
//----------------------------------------------------------------------
void cmCPackGeneratorFactory::RegisterGenerator(const char* name,
void cmCPackGeneratorFactory::RegisterGenerator(const std::string& name,
const char* generatorDescription,
CreateGeneratorCall* createGenerator)
{
if ( !name || !createGenerator )
if ( !createGenerator )
{
cmCPack_Log(this->Logger, cmCPackLog::LOG_ERROR,
"Cannot register generator" << std::endl);

View File

@ -31,26 +31,26 @@ public:
~cmCPackGeneratorFactory();
//! Get the generator
cmCPackGenerator* NewGenerator(const char* name);
cmCPackGenerator* NewGenerator(const std::string& name);
void DeleteGenerator(cmCPackGenerator* gen);
typedef cmCPackGenerator* CreateGeneratorCall();
void RegisterGenerator(const char* name,
void RegisterGenerator(const std::string& name,
const char* generatorDescription,
CreateGeneratorCall* createGenerator);
void SetLogger(cmCPackLog* logger) { this->Logger = logger; }
typedef std::map<cmStdString, cmStdString> DescriptionsMap;
typedef std::map<std::string, std::string> DescriptionsMap;
const DescriptionsMap& GetGeneratorsList() const
{ return this->GeneratorDescriptions; }
private:
cmCPackGenerator* NewGeneratorInternal(const char* name);
cmCPackGenerator* NewGeneratorInternal(const std::string& name);
std::vector<cmCPackGenerator*> Generators;
typedef std::map<cmStdString, CreateGeneratorCall*> t_GeneratorCreatorsMap;
typedef std::map<std::string, CreateGeneratorCall*> t_GeneratorCreatorsMap;
t_GeneratorCreatorsMap GeneratorCreators;
DescriptionsMap GeneratorDescriptions;
cmCPackLog* Logger;

View File

@ -169,27 +169,27 @@ void cmCPackLog::Log(int tag, const char* file, int line,
{
if ( error && !this->ErrorPrefix.empty() )
{
*this->DefaultError << this->ErrorPrefix.c_str();
*this->DefaultError << this->ErrorPrefix;
}
else if ( warning && !this->WarningPrefix.empty() )
{
*this->DefaultError << this->WarningPrefix.c_str();
*this->DefaultError << this->WarningPrefix;
}
else if ( output && !this->OutputPrefix.empty() )
{
*this->DefaultOutput << this->OutputPrefix.c_str();
*this->DefaultOutput << this->OutputPrefix;
}
else if ( verbose && !this->VerbosePrefix.empty() )
{
*this->DefaultOutput << this->VerbosePrefix.c_str();
*this->DefaultOutput << this->VerbosePrefix;
}
else if ( debug && !this->DebugPrefix.empty() )
{
*this->DefaultOutput << this->DebugPrefix.c_str();
*this->DefaultOutput << this->DebugPrefix;
}
else if ( !this->Prefix.empty() )
{
*this->DefaultOutput << this->Prefix.c_str();
*this->DefaultOutput << this->Prefix;
}
if ( useFileAndLine )
{

View File

@ -83,10 +83,10 @@ int cmCPackNSISGenerator::PackageFiles()
fileN = fileN.substr(fileN.find('/')+1, std::string::npos);
}
cmSystemTools::ReplaceString(fileN, "/", "\\");
str << " Delete \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl;
str << " Delete \"$INSTDIR\\" << fileN << "\"" << std::endl;
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: "
<< str.str().c_str() << std::endl);
<< str.str() << std::endl);
this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str());
std::vector<std::string> dirs;
this->GetListOfSubdirectories(toplevel.c_str(), dirs);
@ -117,14 +117,14 @@ int cmCPackNSISGenerator::PackageFiles()
}
}
cmSystemTools::ReplaceString(fileN, "/", "\\");
dstr << " RMDir \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl;
dstr << " RMDir \"$INSTDIR\\" << fileN << "\"" << std::endl;
if (!componentName.empty())
{
this->Components[componentName].Directories.push_back(fileN);
}
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: "
<< dstr.str().c_str() << std::endl);
<< dstr.str() << std::endl);
this->SetOptionIfNotSet("CPACK_NSIS_DELETE_DIRECTORIES",
dstr.str().c_str());
@ -320,7 +320,7 @@ int cmCPackNSISGenerator::PackageFiles()
std::string nsisCmd = "\"";
nsisCmd += this->GetOption("CPACK_INSTALLER_PROGRAM");
nsisCmd += "\" \"" + nsisFileName + "\"";
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd.c_str()
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd
<< std::endl);
std::string output;
int retVal = 1;
@ -329,12 +329,12 @@ int cmCPackNSISGenerator::PackageFiles()
if ( !res || retVal )
{
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << nsisCmd.c_str() << std::endl
ofs << "# Run command: " << nsisCmd << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
<< output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running NSIS command: "
<< nsisCmd.c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
<< nsisCmd << std::endl
<< "Please check " << tmpFile << " for errors" << std::endl);
return 0;
}
return 1;
@ -427,7 +427,7 @@ int cmCPackNSISGenerator::InitializeInternal()
std::string nsisCmd = "\"" + nsisPath + "\" " NSIS_OPT "VERSION";
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: "
<< nsisCmd.c_str() << std::endl);
<< nsisCmd << std::endl);
std::string output;
int retVal = 1;
bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(),
@ -442,13 +442,13 @@ int cmCPackNSISGenerator::InitializeInternal()
std::string tmpFile = topDir ? topDir : ".";
tmpFile += "/NSISOutput.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << nsisCmd.c_str() << std::endl
ofs << "# Run command: " << nsisCmd << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
<< output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem checking NSIS version with command: "
<< nsisCmd.c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
<< nsisCmd << std::endl
<< "Please check " << tmpFile << " for errors" << std::endl);
return 0;
}
if ( versionRex.find(output))
@ -470,7 +470,7 @@ int cmCPackNSISGenerator::InitializeInternal()
{
// No version check for NSIS cvs build
cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: CVS "
<< versionRexCVS.match(1).c_str() << std::endl);
<< versionRexCVS.match(1) << std::endl);
}
this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str());
this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLES_DIRECTORY", "bin");
@ -629,7 +629,7 @@ void cmCPackNSISGenerator::CreateMenuLinks( cmOStringStream& str,
// if so add a desktop link
std::string desktop = "CPACK_CREATE_DESKTOP_LINK_";
desktop += linkName;
if(this->IsSet(desktop.c_str()))
if(this->IsSet(desktop))
{
str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
str << " CreateShortCut \"$DESKTOP\\"
@ -844,12 +844,12 @@ CreateComponentDescription(cmCPackComponent *component,
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/CompressZip.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
ofs << "# Run command: " << cmd.c_str() << std::endl
ofs << "# Run command: " << cmd << std::endl
<< "# Output:" << std::endl
<< output.c_str() << std::endl;
<< output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running zip command: "
<< cmd.c_str() << std::endl
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
<< cmd << std::endl
<< "Please check " << tmpFile << " for errors" << std::endl);
return "";
}
@ -891,7 +891,7 @@ CreateComponentDescription(cmCPackComponent *component,
path = *pathIt;
cmSystemTools::ReplaceString(path, "/", "\\");
macrosOut << " Delete \"$INSTDIR\\"
<< path.c_str()
<< path
<< "\"\n";
}
for (pathIt = component->Directories.begin();
@ -901,7 +901,7 @@ CreateComponentDescription(cmCPackComponent *component,
path = *pathIt;
cmSystemTools::ReplaceString(path, "/", "\\");
macrosOut << " RMDir \"$INSTDIR\\"
<< path.c_str()
<< path
<< "\"\n";
}
macrosOut << " noremove_" << component->Name << ":\n";

View File

@ -227,7 +227,7 @@ int cmCPackOSXX11Generator::InitializeInternal()
//----------------------------------------------------------------------
/*
bool cmCPackOSXX11Generator::CopyCreateResourceFile(const char* name)
bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name)
{
std::string uname = cmSystemTools::UpperCase(name);
std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
@ -271,8 +271,8 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const char* name)
*/
//----------------------------------------------------------------------
bool cmCPackOSXX11Generator::CopyResourcePlistFile(const char* name,
const char* dir, const char* outputFileName /* = 0 */,
bool cmCPackOSXX11Generator::CopyResourcePlistFile(const std::string& name,
const std::string& dir, const char* outputFileName /* = 0 */,
bool copyOnly /* = false */)
{
std::string inFName = "CPack.";
@ -288,7 +288,7 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile(const char* name,
if ( !outputFileName )
{
outputFileName = name;
outputFileName = name.c_str();
}
std::string destFileName = dir;

View File

@ -37,8 +37,9 @@ protected:
virtual const char* GetPackagingInstallPrefix();
virtual const char* GetOutputExtension() { return ".dmg"; }
//bool CopyCreateResourceFile(const char* name, const char* dir);
bool CopyResourcePlistFile(const char* name, const char* dir,
//bool CopyCreateResourceFile(const std::string& name,
// const std::string& dir);
bool CopyResourcePlistFile(const std::string& name, const std::string& dir,
const char* outputFileName = 0, bool copyOnly = false);
std::string InstallPrefix;
};

View File

@ -43,14 +43,14 @@ bool cmCPackPackageMakerGenerator::SupportsComponentInstallation() const
}
//----------------------------------------------------------------------
int cmCPackPackageMakerGenerator::CopyInstallScript(const char* resdir,
const char* script,
const char* name)
int cmCPackPackageMakerGenerator::CopyInstallScript(const std::string& resdir,
const std::string& script,
const std::string& name)
{
std::string dst = resdir;
dst += "/";
dst += name;
cmSystemTools::CopyFileAlways(script, dst.c_str());
cmSystemTools::CopyFileAlways(script.c_str(), dst.c_str());
cmSystemTools::SetPermissions(dst.c_str(),0777);
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"copy script : " << script << "\ninto " << dst.c_str() <<
@ -553,8 +553,9 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
}
//----------------------------------------------------------------------
bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name,
const char* dirName)
bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(
const std::string& name,
const std::string& dirName)
{
std::string uname = cmSystemTools::UpperCase(name);
std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
@ -563,7 +564,7 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name,
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: " << cpackVar.c_str()
<< " not specified. It should point to "
<< (name ? name : "(NULL)")
<< (!name.empty() ? name : "<empty>")
<< ".rtf, " << name
<< ".html, or " << name << ".txt file" << std::endl);
return false;
@ -571,7 +572,7 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name,
if ( !cmSystemTools::FileExists(inFileName) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find "
<< (name ? name : "(NULL)")
<< (!name.empty() ? name : "<empty>")
<< " resource file: " << inFileName << std::endl);
return false;
}
@ -600,12 +601,13 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name,
return true;
}
bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(const char* name,
bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(
const std::string& name,
const char* outName)
{
if (!outName)
{
outName = name;
outName = name.c_str();
}
std::string inFName = "CPack.";

View File

@ -38,9 +38,9 @@ public:
virtual bool SupportsComponentInstallation() const;
protected:
int CopyInstallScript(const char* resdir,
const char* script,
const char* name);
int CopyInstallScript(const std::string& resdir,
const std::string& script,
const std::string& name);
virtual int InitializeInternal();
int PackageFiles();
virtual const char* GetOutputExtension() { return ".dmg"; }
@ -51,8 +51,9 @@ protected:
// CPACK_RESOURCE_FILE_${NAME} (where ${NAME} is the uppercased
// version of name) specifies the input file to use for this file,
// which will be configured via ConfigureFile.
bool CopyCreateResourceFile(const char* name, const char *dirName);
bool CopyResourcePlistFile(const char* name, const char* outName = 0);
bool CopyCreateResourceFile(const std::string& name,
const std::string& dirName);
bool CopyResourcePlistFile(const std::string& name, const char* outName = 0);
// Run PackageMaker with the given command line, which will (if
// successful) produce the given package file. Returns true if

Some files were not shown because too many files have changed in this diff Show More