diff options
90 files changed, 856 insertions, 588 deletions
diff --git a/CompileFlags.cmake b/CompileFlags.cmake index 20f5dec..24ac58d 100644 --- a/CompileFlags.cmake +++ b/CompileFlags.cmake @@ -66,5 +66,5 @@ endif () # avoid binutils problem with large binaries, e.g. when building CMake in debug mode # See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50230 if (CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL parisc) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--unique=.text.*") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--unique=.text._*") endif () diff --git a/Help/command/if.rst b/Help/command/if.rst index 49c356e..a45b995 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -187,7 +187,7 @@ above-documented signature accepts ``<variable|string>``: variables, if so their defined values are used otherwise the original value is used. -* Both left and right hand argumemnts to ``VERSION_LESS``, +* Both left and right hand arguments to ``VERSION_LESS``, ``VERSION_EQUAL``, and ``VERSION_GREATER`` are independently tested to see if they are defined variables, if so their defined values are used otherwise the original value is used. diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst index 3f819d6..7a06be6 100644 --- a/Help/manual/cmake-modules.7.rst +++ b/Help/manual/cmake-modules.7.rst @@ -214,8 +214,6 @@ All Modules /module/InstallRequiredSystemLibraries /module/MacroAddFileDependencies /module/ProcessorCount - /module/Qt4ConfigDependentSettings - /module/Qt4Macros /module/SelectLibraryConfigurations /module/SquishTestScript /module/TestBigEndian @@ -229,7 +227,6 @@ All Modules /module/UseJava /module/UseJavaSymlinks /module/UsePkgConfig - /module/UseQt4 /module/UseSWIG /module/UsewxWidgets /module/Use_wxWindows diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 891333c..02f596b 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -98,3 +98,4 @@ All Policies /policy/CMP0044 /policy/CMP0045 /policy/CMP0046 + /policy/CMP0047 diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index c0ec0fe..d315fcb 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -48,6 +48,7 @@ Properties on Directories /prop_dir/ADDITIONAL_MAKE_CLEAN_FILES /prop_dir/CACHE_VARIABLES /prop_dir/CLEAN_NO_CUSTOM + /prop_dir/CMAKE_CONFIGURE_DEPENDS /prop_dir/COMPILE_DEFINITIONS_CONFIG /prop_dir/COMPILE_DEFINITIONS /prop_dir/COMPILE_OPTIONS diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index cdd996c..832bd99 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -214,6 +214,9 @@ Variables that Control the Build /variable/CMAKE_MODULE_LINKER_FLAGS /variable/CMAKE_NO_BUILTIN_CHRPATH /variable/CMAKE_NO_SYSTEM_FROM_IMPORTED + /variable/CMAKE_OSX_ARCHITECTURES + /variable/CMAKE_OSX_DEPLOYMENT_TARGET + /variable/CMAKE_OSX_SYSROOT /variable/CMAKE_PDB_OUTPUT_DIRECTORY /variable/CMAKE_PDB_OUTPUT_DIRECTORY_CONFIG /variable/CMAKE_POSITION_INDEPENDENT_CODE diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index d209b8b..5743ab7 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -39,7 +39,7 @@ Options that can be used on all systems. Run with -E help for the usage information. Commands available are: chdir, compare_files, copy, copy_directory, copy_if_different, echo, echo_append, environment, - make_directory, md5sum, remove, remove_directory, rename, tar, time, + make_directory, md5sum, remove, remove_directory, rename, sleep, tar, time, touch, touch_nocreate. In addition, some platform specific commands are available. On Windows: delete_regv, write_regv. On UNIX: create_symlink. diff --git a/Help/module/Qt4ConfigDependentSettings.rst b/Help/module/Qt4ConfigDependentSettings.rst deleted file mode 100644 index 7002f53..0000000 --- a/Help/module/Qt4ConfigDependentSettings.rst +++ /dev/null @@ -1 +0,0 @@ -.. cmake-module:: ../../Modules/Qt4ConfigDependentSettings.cmake diff --git a/Help/module/Qt4Macros.rst b/Help/module/Qt4Macros.rst deleted file mode 100644 index 6448d53..0000000 --- a/Help/module/Qt4Macros.rst +++ /dev/null @@ -1 +0,0 @@ -.. cmake-module:: ../../Modules/Qt4Macros.cmake diff --git a/Help/module/UseQt4.rst b/Help/module/UseQt4.rst deleted file mode 100644 index c2f2ea8..0000000 --- a/Help/module/UseQt4.rst +++ /dev/null @@ -1 +0,0 @@ -.. cmake-module:: ../../Modules/UseQt4.cmake diff --git a/Help/policy/CMP0047.rst b/Help/policy/CMP0047.rst new file mode 100644 index 0000000..7b87c4d --- /dev/null +++ b/Help/policy/CMP0047.rst @@ -0,0 +1,16 @@ +CMP0047 +------- + +Use QCC compiler id for the qcc drivers on QNX. + +CMake 2.8.12 and lower assigned the QNX qcc and QCC compiler drivers the "GNU" +compiler id. + +The OLD behavior for this policy is to use the "GNU" compiler id for the qcc +and QCC compiler drivers. The NEW behavior for this policy is to use the "QCC" +compiler id for those drivers. + +This policy was introduced in CMake version 3.0.0. +CMake version |release| warns when the policy is not set and uses +OLD behavior. Use the cmake_policy command to set it to OLD or +NEW explicitly. diff --git a/Help/prop_dir/CMAKE_CONFIGURE_DEPENDS.rst b/Help/prop_dir/CMAKE_CONFIGURE_DEPENDS.rst new file mode 100644 index 0000000..b1aef19 --- /dev/null +++ b/Help/prop_dir/CMAKE_CONFIGURE_DEPENDS.rst @@ -0,0 +1,9 @@ +CMAKE_CONFIGURE_DEPENDS +----------------------- + +Tell CMake about additional input files to the configuration process. +If any named file is modified the build system will re-run CMake to +re-configure the file and generate the build system again. + +Specify files as a semicolon-separated list of paths. Relative paths +are interpreted as relative to the current source directory. diff --git a/Help/prop_tgt/OSX_ARCHITECTURES.rst b/Help/prop_tgt/OSX_ARCHITECTURES.rst index 68ff970..cefe03f 100644 --- a/Help/prop_tgt/OSX_ARCHITECTURES.rst +++ b/Help/prop_tgt/OSX_ARCHITECTURES.rst @@ -3,9 +3,9 @@ OSX_ARCHITECTURES Target specific architectures for OS X. -The OSX_ARCHITECTURES property sets the target binary architecture for -targets on OS X. This property is initialized by the value of the -variable CMAKE_OSX_ARCHITECTURES if it is set when a target is -created. Use OSX_ARCHITECTURES_<CONFIG> to set the binary -architectures on a per-configuration basis. <CONFIG> is an upper-case -name (ex: "OSX_ARCHITECTURES_DEBUG"). +The ``OSX_ARCHITECTURES`` property sets the target binary architecture for +targets on OS X (``-arch``). This property is initialized by the value of the +variable :variable:`CMAKE_OSX_ARCHITECTURES` if it is set when a target is +created. Use :prop_tgt:`OSX_ARCHITECTURES_<CONFIG>` to set the binary +architectures on a per-configuration basis, where ``<CONFIG>`` is an +upper-case name (e.g. ``OSX_ARCHITECTURES_DEBUG``). diff --git a/Help/prop_tgt/OSX_ARCHITECTURES_CONFIG.rst b/Help/prop_tgt/OSX_ARCHITECTURES_CONFIG.rst index ea05bea..f8fdcff 100644 --- a/Help/prop_tgt/OSX_ARCHITECTURES_CONFIG.rst +++ b/Help/prop_tgt/OSX_ARCHITECTURES_CONFIG.rst @@ -4,4 +4,4 @@ OSX_ARCHITECTURES_<CONFIG> Per-configuration OS X binary architectures for a target. This property is the configuration-specific version of -OSX_ARCHITECTURES. +:prop_tgt:`OSX_ARCHITECTURES`. diff --git a/Help/variable/CMAKE_OSX_ARCHITECTURES.rst b/Help/variable/CMAKE_OSX_ARCHITECTURES.rst new file mode 100644 index 0000000..b9de518 --- /dev/null +++ b/Help/variable/CMAKE_OSX_ARCHITECTURES.rst @@ -0,0 +1,10 @@ +CMAKE_OSX_ARCHITECTURES +----------------------- + +Target specific architectures for OS X. + +This variable is used to initialize the :prop_tgt:`OSX_ARCHITECTURES` +property on each target as it is creaed. See that target property +for additional information. + +.. include:: CMAKE_OSX_VARIABLE.txt diff --git a/Help/variable/CMAKE_OSX_DEPLOYMENT_TARGET.rst b/Help/variable/CMAKE_OSX_DEPLOYMENT_TARGET.rst new file mode 100644 index 0000000..4fb2caa --- /dev/null +++ b/Help/variable/CMAKE_OSX_DEPLOYMENT_TARGET.rst @@ -0,0 +1,13 @@ +CMAKE_OSX_DEPLOYMENT_TARGET +--------------------------- + +Specify the minimum version of OS X on which the target binaries are +to be deployed. CMake uses this value for the ``-mmacosx-version-min`` +flag and to help choose the default SDK +(see :variable:`CMAKE_OSX_SYSROOT`). + +If not set explicitly the value is initialized by the +``MACOSX_DEPLOYMENT_TARGET`` environment variable, if set, +and otherwise computed based on the host platform. + +.. include:: CMAKE_OSX_VARIABLE.txt diff --git a/Help/variable/CMAKE_OSX_SYSROOT.rst b/Help/variable/CMAKE_OSX_SYSROOT.rst new file mode 100644 index 0000000..f1d58c6 --- /dev/null +++ b/Help/variable/CMAKE_OSX_SYSROOT.rst @@ -0,0 +1,13 @@ +CMAKE_OSX_SYSROOT +----------------- + +Specify the location or name of the OS X platform SDK to be used. +CMake uses this value to compute the value of the ``-isysroot`` flag +or equivalent and to help the ``find_*`` commands locate files in +the SDK. + +If not set explicitly the value is initialized by the ``SDKROOT`` +environment variable, if set, and otherwise computed based on the +:variable:`CMAKE_OSX_DEPLOYMENT_TARGET` or the host platform. + +.. include:: CMAKE_OSX_VARIABLE.txt diff --git a/Help/variable/CMAKE_OSX_VARIABLE.txt b/Help/variable/CMAKE_OSX_VARIABLE.txt new file mode 100644 index 0000000..385f871 --- /dev/null +++ b/Help/variable/CMAKE_OSX_VARIABLE.txt @@ -0,0 +1,6 @@ +The value of this variable should be set prior to the first +:command:`project` or :command:`enable_language` command invocation +because it may influence configuration of the toolchain and flags. +It is intended to be set locally by the user creating a build tree. + +This variable is ignored on platforms other than OS X. diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index d53247a..52f9590 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -227,6 +227,10 @@ char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; #endif +#ifdef __QNXNTO__ +char const* qnxnto = "INFO" ":" "qnxnto"; +#endif + @CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@ @CMAKE_C_COMPILER_ID_ERROR_FOR_TEST@ diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index b5d498d..25ceb3f 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -220,6 +220,10 @@ char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; #endif +#ifdef __QNXNTO__ +char const* qnxnto = "INFO" ":" "qnxnto"; +#endif + @CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@ @CMAKE_CXX_COMPILER_ID_ERROR_FOR_TEST@ diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 247de6f..ca7eb8b 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -124,7 +124,7 @@ endif() # e.g. powerpc-linux-gas, arm-elf-gas or i586-mingw32msvc-gas , optionally # with a 3-component version number at the end # The other tools of the toolchain usually have the same prefix -# NAME_WE cannot be used since then this test will fail for names lile +# NAME_WE cannot be used since then this test will fail for names like # "arm-unknown-nto-qnx6.3.0-gas.exe", where BASENAME would be # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" if (NOT _CMAKE_TOOLCHAIN_PREFIX) diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 438a98a..c3f5a66 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -149,7 +149,7 @@ endif () # e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc, optionally # with a 3-component version number at the end (e.g. arm-eabi-gcc-4.5.2). # The other tools of the toolchain usually have the same prefix -# NAME_WE cannot be used since then this test will fail for names lile +# NAME_WE cannot be used since then this test will fail for names like # "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 5f9d9bf..21864f1 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -145,7 +145,7 @@ endif () # e.g. powerpc-linux-g++, arm-elf-g++ or i586-mingw32msvc-g++ , optionally # with a 3-component version number at the end (e.g. arm-eabi-gcc-4.5.2). # The other tools of the toolchain usually have the same prefix -# NAME_WE cannot be used since then this test will fail for names lile +# NAME_WE cannot be used since then this test will fail for names like # "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 2bcf3d1..067892d 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -48,6 +48,21 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) CMAKE_DETERMINE_COMPILER_ID_VENDOR(${lang}) endif() + if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL GNU) + execute_process( + COMMAND "${CMAKE_${lang}_COMPILER}" + -V + OUTPUT_VARIABLE output ERROR_VARIABLE output + RESULT_VARIABLE result + TIMEOUT 10 + ) + if (output MATCHES "targets available") + set(CMAKE_${lang}_COMPILER_ID QCC) + # http://community.qnx.com/sf/discussion/do/listPosts/projects.community/discussion.qnx_momentics_community_support.topc3555?_pagenum=2 + # The qcc driver does not itself have a version. + endif() + endif() + # if the format is unknown after all files have been checked, put "Unknown" in the cache if(NOT CMAKE_EXECUTABLE_FORMAT) set(CMAKE_EXECUTABLE_FORMAT "Unknown" CACHE INTERNAL "Executable file format") @@ -369,6 +384,9 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) string(REGEX REPLACE "^0+([0-9])" "\\1" SIMULATE_VERSION "${SIMULATE_VERSION}") string(REGEX REPLACE "\\.0+([0-9])" ".\\1" SIMULATE_VERSION "${SIMULATE_VERSION}") endif() + if("${info}" MATCHES ".*INFO:qnxnto") + set(COMPILER_QNXNTO 1) + endif() endforeach() # Detect the exact architecture from the PE header. @@ -459,6 +477,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) set(CMAKE_${lang}_SIMULATE_ID "${CMAKE_${lang}_SIMULATE_ID}" PARENT_SCOPE) set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE) set(CMAKE_EXECUTABLE_FORMAT "${CMAKE_EXECUTABLE_FORMAT}" PARENT_SCOPE) + set(COMPILER_QNXNTO "${COMPILER_QNXNTO}" PARENT_SCOPE) endfunction() #----------------------------------------------------------------------------- diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 8e2065d..4c8a8f2 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -193,7 +193,7 @@ endif () # e.g. powerpc-linux-gfortran, arm-elf-gfortran or i586-mingw32msvc-gfortran , optionally # with a 3-component version number at the end (e.g. arm-eabi-gcc-4.5.2). # The other tools of the toolchain usually have the same prefix -# NAME_WE cannot be used since then this test will fail for names lile +# NAME_WE cannot be used since then this test will fail for names like # "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake index 7756273..f1bad99 100644 --- a/Modules/CMakeDetermineSystem.cmake +++ b/Modules/CMakeDetermineSystem.cmake @@ -47,9 +47,14 @@ if(CMAKE_HOST_UNIX) if(CMAKE_UNAME) exec_program(uname ARGS -s OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_NAME) exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION) - if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*") + if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|CYGWIN.*|Darwin") exec_program(uname ARGS -m OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) + if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND + CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "Power Macintosh") + # OS X ppc 'uname -m' may report 'Power Macintosh' instead of 'powerpc' + set(CMAKE_HOST_SYSTEM_PROCESSOR "powerpc") + endif() elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "OpenBSD") exec_program(arch ARGS -s OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_PROCESSOR RETURN_VALUE val) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 9be4270..0bf2b99 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -1,109 +1,118 @@ #.rst: # FindQt4 -# ------- +# ******* # -# Find Qt 4 +# Finding and Using Qt4 +# ===================== # # This module can be used to find Qt4. The most important issue is that # the Qt4 qmake is available via the system path. This qmake is then # used to detect basically everything else. This module defines a -# number of key variables and macros. The variable QT_USE_FILE is set -# which is the path to a CMake file that can be included to compile Qt 4 -# applications and libraries. It sets up the compilation environment -# for include directories, preprocessor defines and populates a -# QT_LIBRARIES variable. +# number of :prop_tgt:`IMPORTED` targets, macros and variables. # # Typical usage could be something like: # -# :: +# .. code-block:: cmake # -# find_package(Qt4 4.4.3 REQUIRED QtCore QtGui QtXml) -# include(${QT_USE_FILE}) +# set(CMAKE_AUTOMOC ON) +# set(CMAKE_INCLUDE_CURRENT_DIR ON) +# find_package(Qt4 4.4.3 REQUIRED QtGui QtXml) # add_executable(myexe main.cpp) -# target_link_libraries(myexe ${QT_LIBRARIES}) -# -# -# -# The minimum required version can be specified using the standard -# find_package()-syntax (see example above). For compatibility with -# older versions of FindQt4.cmake it is also possible to set the -# variable QT_MIN_VERSION to the minimum required version of Qt4 before -# the find_package(Qt4) command. If both are used, the version used in -# the find_package() command overrides the one from QT_MIN_VERSION. -# -# When using the components argument, QT_USE_QT* variables are -# automatically set for the QT_USE_FILE to pick up. If one wishes to -# manually set them, the available ones to set include: -# -# :: -# -# QT_DONT_USE_QTCORE -# QT_DONT_USE_QTGUI -# QT_USE_QT3SUPPORT -# QT_USE_QTASSISTANT -# QT_USE_QAXCONTAINER -# QT_USE_QAXSERVER -# QT_USE_QTDESIGNER -# QT_USE_QTMOTIF -# QT_USE_QTMAIN -# QT_USE_QTMULTIMEDIA -# QT_USE_QTNETWORK -# QT_USE_QTNSPLUGIN -# QT_USE_QTOPENGL -# QT_USE_QTSQL -# QT_USE_QTXML -# QT_USE_QTSVG -# QT_USE_QTTEST -# QT_USE_QTUITOOLS -# QT_USE_QTDBUS -# QT_USE_QTSCRIPT -# QT_USE_QTASSISTANTCLIENT -# QT_USE_QTHELP -# QT_USE_QTWEBKIT -# QT_USE_QTXMLPATTERNS -# QT_USE_PHONON -# QT_USE_QTSCRIPTTOOLS -# QT_USE_QTDECLARATIVE -# -# -# -# :: -# -# QT_USE_IMPORTED_TARGETS -# If this variable is set to TRUE, FindQt4.cmake will create imported -# library targets for the various Qt libraries and set the -# library variables like QT_QTCORE_LIBRARY to point at these imported -# targets instead of the library file on disk. This provides much better -# handling of the release and debug versions of the Qt libraries and is -# also always backwards compatible, except for the case that dependencies -# of libraries are exported, these will then also list the names of the -# imported targets as dependency and not the file location on disk. This -# is much more flexible, but requires that FindQt4.cmake is executed before -# such an exported dependency file is processed. -# -# -# -# :: -# -# Note that if using IMPORTED targets, the qtmain.lib static library is -# automatically linked on Windows. To disable that globally, set the -# QT4_NO_LINK_QTMAIN variable before finding Qt4. To disable that for a -# particular executable, set the QT4_NO_LINK_QTMAIN target property to -# True on the executable. -# -# -# -# :: -# -# QT_INCLUDE_DIRS_NO_SYSTEM -# If this variable is set to TRUE, the Qt include directories -# in the QT_USE_FILE will NOT have the SYSTEM keyword set. -# -# -# -# There are also some files that need processing by some Qt tools such -# as moc and uic. Listed below are macros that may be used to process -# those files. +# target_link_libraries(myexe Qt4::QtGui Qt4::QtXml) +# +# .. note:: +# +# When using :prop_tgt:`IMPORTED` targets, the qtmain.lib static library is +# automatically linked on Windows. To disable that globally, set the +# ``QT4_NO_LINK_QTMAIN`` variable before finding Qt4. To disable that +# for a particular executable, set the ``QT4_NO_LINK_QTMAIN`` target +# property to ``TRUE`` on the executable. +# +# Qt Build Tools +# ============== +# +# Qt relies on some bundled tools for code generation, such as ``moc`` for +# meta-object code generation,``uic`` for widget layout and population, +# and ``rcc`` for virtual filesystem content generation. These tools may be +# automatically invoked by :manual:`cmake(1)` if the appropriate conditions +# are met. +# +# The tools are executed as part of a synthesized custom target generated by +# CMake. Target dependencies may be added to that custom target by adding them +# to the :prop_tgt:`AUTOGEN_TARGET_DEPENDS` target property. +# +# AUTOMOC +# ''''''' +# +# The :prop_tgt:`AUTOMOC` target property controls whether :manual:`cmake(1)` +# inspects the C++ files in the target to determine if they require ``moc`` to +# be run, and to create rules to execute ``moc`` at the appropriate time. +# +# If a ``Q_OBJECT`` or ``Q_GADGET`` macro is found in a header file, ``moc`` +# will be run on the file. The result will be put into a file named according +# to ``moc_<basename>.cpp``. If the macro is found in a C++ implementation +# file, the moc output will be put into a file named according to +# ``<basename>.moc``, following the Qt conventions. The ``moc file`` may be +# included by the user in the C++ implementation file with a preprocessor +# ``#include``. If it is not so included, it will be added to a separate file +# which is compiled into the target. +# +# Generated ``moc_*.cpp`` and ``*.moc`` files are placed in the build directory +# so it is convenient to set the :variable:`CMAKE_INCLUDE_CURRENT_DIR` +# variable. The :prop_tgt:`AUTOMOC` target property may be pre-set for all +# following targets by setting the :variable:`CMAKE_AUTOMOC` variable. The +# :prop_tgt:`AUTOMOC_MOC_OPTIONS` target property may be populated to set +# options to pass to ``moc``. The :variable:`CMAKE_AUTOMOC_MOC_OPTIONS` +# variable may be populated to pre-set the options for all following targets. +# +# AUTOUIC +# ''''''' +# +# The :prop_tgt:`AUTOUIC` target property controls whether :manual:`cmake(1)` +# inspects the C++ files in the target to determine if they require ``uic`` to +# be run, and to create rules to execute ``uic`` at the appropriate time. +# +# If a preprocessor ``#include`` directive is found which matches +# ``ui_<basename>.h``, and a ``<basename>.ui`` file exists, then ``uic`` will +# be executed to generate the appropriate file. +# +# Generated ``ui_*.h`` files are placed in the build directory so it is +# convenient to set the :variable:`CMAKE_INCLUDE_CURRENT_DIR` variable. The +# :prop_tgt:`AUTOUIC` target property may be pre-set for all following targets +# by setting the :variable:`CMAKE_AUTOUIC` variable. The +# :prop_tgt:`AUTOUIC_OPTIONS` target property may be populated to set options +# to pass to ``uic``. The :variable:`CMAKE_AUTOUIC_OPTIONS` variable may be +# populated to pre-set the options for all following targets. The +# :prop_sf:`AUTOUIC_OPTIONS` source file property may be set on the +# ``<basename>.ui`` file to set particular options for the file. This +# overrides options from the :prop_tgt:`AUTOUIC_OPTIONS` target property. +# +# AUTORCC +# ''''''' +# +# The :prop_tgt:`AUTORCC` target property controls whether :manual:`cmake(1)` +# creates rules to execute ``rcc`` at the appropriate time on source files +# which have the suffix ``.qrc``. +# +# .. code-block:: cmake +# +# add_executable(myexe main.cpp resource_file.qrc) +# +# The :prop_tgt:`AUTORCC` target property may be pre-set for all following targets +# by setting the :variable:`CMAKE_AUTORCC` variable. The +# :prop_tgt:`AUTORCC_OPTIONS` target property may be populated to set options +# to pass to ``rcc``. The :variable:`CMAKE_AUTORCC_OPTIONS` variable may be +# populated to pre-set the options for all following targets. The +# :prop_sf:`AUTORCC_OPTIONS` source file property may be set on the +# ``<name>.qrc`` file to set particular options for the file. This +# overrides options from the :prop_tgt:`AUTORCC_OPTIONS` target property. +# +# +# Qt Macros +# ========= +# +# In some cases it can be necessary or useful to invoke the Qt build tools in a +# more-manual way. Several macros are available to add targets for such uses. # # :: # @@ -116,7 +125,6 @@ # those found when executing "moc -help". # # -# # :: # # macro QT4_WRAP_UI(outfiles inputfile ... OPTIONS ...) @@ -125,7 +133,6 @@ # when executing "uic -help" # # -# # :: # # macro QT4_ADD_RESOURCES(outfiles inputfile ... OPTIONS ...) @@ -134,7 +141,6 @@ # when executing "rcc -help" # # -# # :: # # macro QT4_GENERATE_MOC(inputfile outputfile [TARGET tgt]) @@ -146,32 +152,6 @@ # the <tgt> are passed to moc. # # -# -# :: -# -# macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... [TARGET tgt]) -# The qt4_automoc macro is obsolete. Use the CMAKE_AUTOMOC feature instead. -# This macro is still experimental. -# It can be used to have moc automatically handled. -# So if you have the files foo.h and foo.cpp, and in foo.h a -# a class uses the Q_OBJECT macro, moc has to run on it. If you don't -# want to use QT4_WRAP_CPP() (which is reliable and mature), you can insert -# #include "foo.moc" -# in foo.cpp and then give foo.cpp as argument to QT4_AUTOMOC(). This will the -# scan all listed files at cmake-time for such included moc files and if it finds -# them cause a rule to be generated to run moc at build time on the -# accompanying header file foo.h. -# If a source file has the SKIP_AUTOMOC property set it will be ignored by this macro. -# If the <tgt> is specified, the INTERFACE_INCLUDE_DIRECTORIES and -# INTERFACE_COMPILE_DEFINITIONS from the <tgt> are passed to moc. -# -# -# :: -# -# You should have a look on the AUTOMOC property for targets to achieve the same results. -# -# -# # :: # # macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename) @@ -179,33 +159,16 @@ # given basename from the given interface xml file and add it to # the list of sources. # -# -# -# :: -# # You can pass additional parameters to the qdbusxml2cpp call by setting # properties on the input file: # -# -# -# :: -# # INCLUDE the given file will be included in the generate interface header # -# -# -# :: -# # CLASSNAME the generated class is named accordingly # -# -# -# :: -# # NO_NAMESPACE the generated class is not wrapped in a namespace # # -# # :: # # macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... ) @@ -213,14 +176,9 @@ # for all listed interface xml files. # The basename will be automatically determined from the name of the xml file. # -# -# -# :: -# # The source file properties described for QT4_ADD_DBUS_INTERFACE also apply here. # # -# # :: # # macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname [basename] [classname]) @@ -233,7 +191,6 @@ # adaptor itself. # # -# # :: # # macro QT4_GENERATE_DBUS_INTERFACE( header [interfacename] OPTIONS ...) @@ -244,7 +201,6 @@ # Options may be given to qdbuscpp2xml, such as those found when executing "qdbuscpp2xml --help" # # -# # :: # # macro QT4_CREATE_TRANSLATION( qm_files directories ... sources ... @@ -263,7 +219,6 @@ # they get updated/generated. # # -# # :: # # macro QT4_ADD_TRANSLATION( qm_files ts_files ... ) @@ -274,11 +229,28 @@ # must exist and are not updated in any way. # # +# :: +# +# macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... [TARGET tgt]) +# The qt4_automoc macro is obsolete. Use the CMAKE_AUTOMOC feature instead. +# This macro is still experimental. +# It can be used to have moc automatically handled. +# So if you have the files foo.h and foo.cpp, and in foo.h a +# a class uses the Q_OBJECT macro, moc has to run on it. If you don't +# want to use QT4_WRAP_CPP() (which is reliable and mature), you can insert +# #include "foo.moc" +# in foo.cpp and then give foo.cpp as argument to QT4_AUTOMOC(). This will the +# scan all listed files at cmake-time for such included moc files and if it finds +# them cause a rule to be generated to run moc at build time on the +# accompanying header file foo.h. +# If a source file has the SKIP_AUTOMOC property set it will be ignored by this macro. +# If the <tgt> is specified, the INTERFACE_INCLUDE_DIRECTORIES and +# INTERFACE_COMPILE_DEFINITIONS from the <tgt> are passed to moc. # -# function QT4_USE_MODULES( target [link_type] modules...) # # :: # +# function QT4_USE_MODULES( target [link_type] modules...) # This function is obsolete. Use target_link_libraries with IMPORTED targets instead. # Make <target> use the <modules> from Qt. Using a Qt module means # to link to the library, add the relevant include directories for the module, @@ -291,227 +263,100 @@ # to the target_link_libraries call. # # -# -# -# -# :: +# IMPORTED Targets +# ================ +# +# A particular Qt library may be used by using the corresponding +# :prop_tgt:`IMPORTED` target with the :command:`target_link_libraries` +# command: +# +# .. code-block:: cmake +# +# target_link_libraries(myexe Qt4::QtGui Qt4::QtXml) +# +# Using a target in this way causes :cmake(1)` to use the appropriate include +# directories and compile definitions for the target when compiling ``myexe``. +# +# Targets are aware of their dependencies, so for example it is not necessary +# to list ``Qt4::QtCore`` if another Qt library is listed, and it is not +# necessary to list ``Qt4::QtGui`` if ``Qt4::QtDeclarative`` is listed. +# Targets may be tested for existence in the usual way with the +# :command:`if(TARGET)` command. +# +# The Qt toolkit may contain both debug and release libraries. +# :manual:`cmake(1)` will choose the appropriate version based on the build +# configuration. +# +# ``Qt4::QtCore`` +# The QtCore target +# ``Qt4::QtGui`` +# The QtGui target +# ``Qt4::Qt3Support`` +# The Qt3Support target +# ``Qt4::QtAssistant`` +# The QtAssistant target +# ``Qt4::QtAssistantClient`` +# The QtAssistantClient target +# ``Qt4::QAxContainer`` +# The QAxContainer target (Windows only) +# ``Qt4::QAxServer`` +# The QAxServer target (Windows only) +# ``Qt4::QtDBus`` +# The QtDBus target +# ``Qt4::QtDesigner`` +# The QtDesigner target +# ``Qt4::QtDesignerComponents`` +# The QtDesignerComponents target +# ``Qt4::QtHelp`` +# The QtHelp target +# ``Qt4::QtMotif`` +# The QtMotif target +# ``Qt4::QtMultimedia`` +# The QtMultimedia target +# ``Qt4::QtNetwork`` +# The QtNetwork target +# ``Qt4::QtNsPLugin`` +# The QtNsPLugin target +# ``Qt4::QtOpenGL`` +# The QtOpenGL target +# ``Qt4::QtScript`` +# The QtScript target +# ``Qt4::QtScriptTools`` +# The QtScriptTools target +# ``Qt4::QtSql`` +# The QtSql target +# ``Qt4::QtSvg`` +# The QtSvg target +# ``Qt4::QtTest`` +# The QtTest target +# ``Qt4::QtUiTools`` +# The QtUiTools target +# ``Qt4::QtWebKit`` +# The QtWebKit target +# ``Qt4::QtXml`` +# The QtXml target +# ``Qt4::QtXmlPatterns`` +# The QtXmlPatterns target +# ``Qt4::phonon`` +# The phonon target +# +# Result Variables +# ================ # # Below is a detailed list of variables that FindQt4.cmake sets. -# QT_FOUND If false, don't try to use Qt. -# Qt4_FOUND If false, don't try to use Qt 4. -# QT4_FOUND If false, don't try to use Qt 4. This variable is for compatibility only. -# -# -# -# :: -# -# QT_VERSION_MAJOR The major version of Qt found. -# QT_VERSION_MINOR The minor version of Qt found. -# QT_VERSION_PATCH The patch version of Qt found. -# -# -# -# :: -# -# QT_EDITION Set to the edition of Qt (i.e. DesktopLight) -# QT_EDITION_DESKTOPLIGHT True if QT_EDITION == DesktopLight -# QT_QTCORE_FOUND True if QtCore was found. -# QT_QTGUI_FOUND True if QtGui was found. -# QT_QT3SUPPORT_FOUND True if Qt3Support was found. -# QT_QTASSISTANT_FOUND True if QtAssistant was found. -# QT_QTASSISTANTCLIENT_FOUND True if QtAssistantClient was found. -# QT_QAXCONTAINER_FOUND True if QAxContainer was found (Windows only). -# QT_QAXSERVER_FOUND True if QAxServer was found (Windows only). -# QT_QTDBUS_FOUND True if QtDBus was found. -# QT_QTDESIGNER_FOUND True if QtDesigner was found. -# QT_QTDESIGNERCOMPONENTS True if QtDesignerComponents was found. -# QT_QTHELP_FOUND True if QtHelp was found. -# QT_QTMOTIF_FOUND True if QtMotif was found. -# QT_QTMULTIMEDIA_FOUND True if QtMultimedia was found (since Qt 4.6.0). -# QT_QTNETWORK_FOUND True if QtNetwork was found. -# QT_QTNSPLUGIN_FOUND True if QtNsPlugin was found. -# QT_QTOPENGL_FOUND True if QtOpenGL was found. -# QT_QTSQL_FOUND True if QtSql was found. -# QT_QTSVG_FOUND True if QtSvg was found. -# QT_QTSCRIPT_FOUND True if QtScript was found. -# QT_QTSCRIPTTOOLS_FOUND True if QtScriptTools was found. -# QT_QTTEST_FOUND True if QtTest was found. -# QT_QTUITOOLS_FOUND True if QtUiTools was found. -# QT_QTWEBKIT_FOUND True if QtWebKit was found. -# QT_QTXML_FOUND True if QtXml was found. -# QT_QTXMLPATTERNS_FOUND True if QtXmlPatterns was found. -# QT_PHONON_FOUND True if phonon was found. -# QT_QTDECLARATIVE_FOUND True if QtDeclarative was found. -# -# -# -# :: -# -# QT_MAC_USE_COCOA For Mac OS X, its whether Cocoa or Carbon is used. -# In general, this should not be used, but its useful -# when having platform specific code. -# -# -# -# :: -# -# QT_DEFINITIONS Definitions to use when compiling code that uses Qt. -# You do not need to use this if you include QT_USE_FILE. -# The QT_USE_FILE will also define QT_DEBUG and QT_NO_DEBUG -# to fit your current build type. Those are not contained -# in QT_DEFINITIONS. -# -# -# -# :: -# -# QT_INCLUDES List of paths to all include directories of -# Qt4 QT_INCLUDE_DIR and QT_QTCORE_INCLUDE_DIR are -# always in this variable even if NOTFOUND, -# all other INCLUDE_DIRS are -# only added if they are found. -# You do not need to use this if you include QT_USE_FILE. -# -# -# -# -# -# :: -# -# Include directories for the Qt modules are listed here. -# You do not need to use these variables if you include QT_USE_FILE. -# -# -# -# :: -# -# QT_INCLUDE_DIR Path to "include" of Qt4 -# QT_QT3SUPPORT_INCLUDE_DIR Path to "include/Qt3Support" -# QT_QTASSISTANT_INCLUDE_DIR Path to "include/QtAssistant" -# QT_QTASSISTANTCLIENT_INCLUDE_DIR Path to "include/QtAssistant" -# QT_QAXCONTAINER_INCLUDE_DIR Path to "include/ActiveQt" (Windows only) -# QT_QAXSERVER_INCLUDE_DIR Path to "include/ActiveQt" (Windows only) -# QT_QTCORE_INCLUDE_DIR Path to "include/QtCore" -# QT_QTDBUS_INCLUDE_DIR Path to "include/QtDBus" -# QT_QTDESIGNER_INCLUDE_DIR Path to "include/QtDesigner" -# QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR Path to "include/QtDesigner" -# QT_QTGUI_INCLUDE_DIR Path to "include/QtGui" -# QT_QTHELP_INCLUDE_DIR Path to "include/QtHelp" -# QT_QTMOTIF_INCLUDE_DIR Path to "include/QtMotif" -# QT_QTMULTIMEDIA_INCLUDE_DIR Path to "include/QtMultimedia" -# QT_QTNETWORK_INCLUDE_DIR Path to "include/QtNetwork" -# QT_QTNSPLUGIN_INCLUDE_DIR Path to "include/QtNsPlugin" -# QT_QTOPENGL_INCLUDE_DIR Path to "include/QtOpenGL" -# QT_QTSCRIPT_INCLUDE_DIR Path to "include/QtScript" -# QT_QTSQL_INCLUDE_DIR Path to "include/QtSql" -# QT_QTSVG_INCLUDE_DIR Path to "include/QtSvg" -# QT_QTTEST_INCLUDE_DIR Path to "include/QtTest" -# QT_QTWEBKIT_INCLUDE_DIR Path to "include/QtWebKit" -# QT_QTXML_INCLUDE_DIR Path to "include/QtXml" -# QT_QTXMLPATTERNS_INCLUDE_DIR Path to "include/QtXmlPatterns" -# QT_PHONON_INCLUDE_DIR Path to "include/phonon" -# QT_QTSCRIPTTOOLS_INCLUDE_DIR Path to "include/QtScriptTools" -# QT_QTDECLARATIVE_INCLUDE_DIR Path to "include/QtDeclarative" -# -# -# -# :: -# -# QT_BINARY_DIR Path to "bin" of Qt4 -# QT_LIBRARY_DIR Path to "lib" of Qt4 -# QT_PLUGINS_DIR Path to "plugins" for Qt4 -# QT_TRANSLATIONS_DIR Path to "translations" of Qt4 -# QT_IMPORTS_DIR Path to "imports" of Qt4 -# QT_DOC_DIR Path to "doc" of Qt4 -# QT_MKSPECS_DIR Path to "mkspecs" of Qt4 -# -# -# -# -# -# The Qt toolkit may contain both debug and release libraries. In that -# case, the following library variables will contain both. You do not -# need to use these variables if you include QT_USE_FILE, and use -# QT_LIBRARIES. -# -# :: -# -# QT_QT3SUPPORT_LIBRARY The Qt3Support library -# QT_QTASSISTANT_LIBRARY The QtAssistant library -# QT_QTASSISTANTCLIENT_LIBRARY The QtAssistantClient library -# QT_QAXCONTAINER_LIBRARY The QAxContainer library (Windows only) -# QT_QAXSERVER_LIBRARY The QAxServer library (Windows only) -# QT_QTCORE_LIBRARY The QtCore library -# QT_QTDBUS_LIBRARY The QtDBus library -# QT_QTDESIGNER_LIBRARY The QtDesigner library -# QT_QTDESIGNERCOMPONENTS_LIBRARY The QtDesignerComponents library -# QT_QTGUI_LIBRARY The QtGui library -# QT_QTHELP_LIBRARY The QtHelp library -# QT_QTMOTIF_LIBRARY The QtMotif library -# QT_QTMULTIMEDIA_LIBRARY The QtMultimedia library -# QT_QTNETWORK_LIBRARY The QtNetwork library -# QT_QTNSPLUGIN_LIBRARY The QtNsPLugin library -# QT_QTOPENGL_LIBRARY The QtOpenGL library -# QT_QTSCRIPT_LIBRARY The QtScript library -# QT_QTSQL_LIBRARY The QtSql library -# QT_QTSVG_LIBRARY The QtSvg library -# QT_QTTEST_LIBRARY The QtTest library -# QT_QTUITOOLS_LIBRARY The QtUiTools library -# QT_QTWEBKIT_LIBRARY The QtWebKit library -# QT_QTXML_LIBRARY The QtXml library -# QT_QTXMLPATTERNS_LIBRARY The QtXmlPatterns library -# QT_QTMAIN_LIBRARY The qtmain library for Windows -# QT_PHONON_LIBRARY The phonon library -# QT_QTSCRIPTTOOLS_LIBRARY The QtScriptTools library -# -# -# -# The QtDeclarative library: QT_QTDECLARATIVE_LIBRARY -# -# also defined, but NOT for general use are -# -# :: -# -# QT_MOC_EXECUTABLE Where to find the moc tool. -# QT_UIC_EXECUTABLE Where to find the uic tool. -# QT_UIC3_EXECUTABLE Where to find the uic3 tool. -# QT_RCC_EXECUTABLE Where to find the rcc tool -# QT_DBUSCPP2XML_EXECUTABLE Where to find the qdbuscpp2xml tool. -# QT_DBUSXML2CPP_EXECUTABLE Where to find the qdbusxml2cpp tool. -# QT_LUPDATE_EXECUTABLE Where to find the lupdate tool. -# QT_LRELEASE_EXECUTABLE Where to find the lrelease tool. -# QT_QCOLLECTIONGENERATOR_EXECUTABLE Where to find the qcollectiongenerator tool. -# QT_DESIGNER_EXECUTABLE Where to find the Qt designer tool. -# QT_LINGUIST_EXECUTABLE Where to find the Qt linguist tool. -# -# -# -# -# -# These are around for backwards compatibility they will be set -# -# :: -# -# QT_WRAP_CPP Set true if QT_MOC_EXECUTABLE is found -# QT_WRAP_UI Set true if QT_UIC_EXECUTABLE is found -# -# -# -# These variables do _NOT_ have any effect anymore (compared to -# FindQt.cmake) -# -# :: -# -# QT_MT_REQUIRED Qt4 is now always multithreaded -# -# -# -# These variables are set to "" Because Qt structure changed (They make -# no sense in Qt4) -# -# :: # -# QT_QT_LIBRARY Qt-Library is now split +# ``Qt4_FOUND`` +# If false, don't try to use Qt 4. +# ``QT_FOUND`` +# If false, don't try to use Qt. This variable is for compatibility only. +# ``QT4_FOUND`` +# If false, don't try to use Qt 4. This variable is for compatibility only. +# ``QT_VERSION_MAJOR`` +# The major version of Qt found. +# ``QT_VERSION_MINOR`` +# The minor version of Qt found. +# ``QT_VERSION_PATCH`` +# The patch version of Qt found. #============================================================================= # Copyright 2005-2009 Kitware, Inc. diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake index 9f5b8a4..d868cb3 100644 --- a/Modules/GNUInstallDirs.cmake +++ b/Modules/GNUInstallDirs.cmake @@ -85,7 +85,31 @@ if(NOT DEFINED CMAKE_INSTALL_LOCALSTATEDIR) set(CMAKE_INSTALL_LOCALSTATEDIR "var" CACHE PATH "modifiable single-machine data (var)") endif() -if(NOT DEFINED CMAKE_INSTALL_LIBDIR) +# We check if the variable was manually set and not cached, in order to +# allow projects to set the values as normal variables before including +# GNUInstallDirs to avoid having the entries cached or user-editable. It +# replaces the "if(NOT DEFINED CMAKE_INSTALL_XXX)" checks in all the +# other cases. +# If CMAKE_INSTALL_LIBDIR is defined, if _libdir_set is false, then the +# variable is a normal one, otherwise it is a cache one. +get_property(_libdir_set CACHE CMAKE_INSTALL_LIBDIR PROPERTY TYPE SET) +if(NOT DEFINED CMAKE_INSTALL_LIBDIR OR (_libdir_set + AND DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX + AND NOT "${_GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX}" STREQUAL "${CMAKE_INSTALL_PREFIX}")) + # If CMAKE_INSTALL_LIBDIR is not defined, it is always executed. + # Otherwise: + # * if _libdir_set is false it is not executed (meaning that it is + # not a cache variable) + # * if _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX is not defined it is + # not executed + # * if _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX and + # CMAKE_INSTALL_PREFIX are the same string it is not executed. + # _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX is updated after the + # execution, of this part of code, therefore at the next inclusion + # of the file, CMAKE_INSTALL_LIBDIR is defined, and the 2 strings + # are equal, meaning that the if is not executed the code the + # second time. + set(_LIBDIR_DEFAULT "lib") # Override this default 'lib' with 'lib64' iff: # - we are on Linux system but NOT cross-compiling @@ -94,13 +118,30 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR) # reason is: amd64 ABI: http://www.x86-64.org/documentation/abi.pdf # For Debian with multiarch, use 'lib/${CMAKE_LIBRARY_ARCHITECTURE}' if # CMAKE_LIBRARY_ARCHITECTURE is set (which contains e.g. "i386-linux-gnu" + # and CMAKE_INSTALL_PREFIX is "/usr" # See http://wiki.debian.org/Multiarch + if(DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX) + set(__LAST_LIBDIR_DEFAULT "lib") + # __LAST_LIBDIR_DEFAULT is the default value that we compute from + # _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX, not a cache entry for + # the value that was last used as the default. + # This value is used to figure out whether the user changed the + # CMAKE_INSTALL_LIBDIR value manually, or if the value was the + # default one. When CMAKE_INSTALL_PREFIX changes, the value is + # updated to the new default, unless the user explicitly changed it. + endif() if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" AND NOT CMAKE_CROSSCOMPILING) if (EXISTS "/etc/debian_version") # is this a debian system ? - if(CMAKE_LIBRARY_ARCHITECTURE) - set(_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}") - endif() + if(CMAKE_LIBRARY_ARCHITECTURE) + if("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/?$") + set(_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}") + endif() + if(DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX + AND "${_GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/?$") + set(__LAST_LIBDIR_DEFAULT "lib/${CMAKE_LIBRARY_ARCHITECTURE}") + endif() + endif() else() # not debian, rely on CMAKE_SIZEOF_VOID_P: if(NOT DEFINED CMAKE_SIZEOF_VOID_P) message(AUTHOR_WARNING @@ -109,12 +150,25 @@ if(NOT DEFINED CMAKE_INSTALL_LIBDIR) else() if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") set(_LIBDIR_DEFAULT "lib64") + if(DEFINED _GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX) + set(__LAST_LIBDIR_DEFAULT "lib64") + endif() endif() endif() endif() endif() - set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "object code libraries (${_LIBDIR_DEFAULT})") + if(NOT DEFINED CMAKE_INSTALL_LIBDIR) + set(CMAKE_INSTALL_LIBDIR "${_LIBDIR_DEFAULT}" CACHE PATH "object code libraries (${_LIBDIR_DEFAULT})") + elseif(DEFINED __LAST_LIBDIR_DEFAULT + AND "${__LAST_LIBDIR_DEFAULT}" STREQUAL "${CMAKE_INSTALL_LIBDIR}") + set_property(CACHE CMAKE_INSTALL_LIBDIR PROPERTY VALUE "${_LIBDIR_DEFAULT}") + endif() endif() +# Save for next run +set(_GNUInstallDirs_LAST_CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE INTERNAL "CMAKE_INSTALL_PREFIX during last run") +unset(_libdir_set) +unset(__LAST_LIBDIR_DEFAULT) + if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR) set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "C header files (include)") diff --git a/Modules/Platform/QNX-QCC-C.cmake b/Modules/Platform/QNX-QCC-C.cmake new file mode 100644 index 0000000..e5721a7 --- /dev/null +++ b/Modules/Platform/QNX-QCC-C.cmake @@ -0,0 +1,4 @@ + +include(Platform/QNX) + +__compiler_qcc(C) diff --git a/Modules/Platform/QNX-QCC-CXX.cmake b/Modules/Platform/QNX-QCC-CXX.cmake new file mode 100644 index 0000000..e490bbe --- /dev/null +++ b/Modules/Platform/QNX-QCC-CXX.cmake @@ -0,0 +1,4 @@ + +include(Platform/QNX) + +__compiler_qcc(CXX) diff --git a/Modules/Platform/QNX.cmake b/Modules/Platform/QNX.cmake index 9afde05..cc551bd 100644 --- a/Modules/Platform/QNX.cmake +++ b/Modules/Platform/QNX.cmake @@ -1,24 +1,6 @@ set(QNXNTO 1) -# The QNX GCC does not seem to have -isystem so remove the flag. -set(CMAKE_INCLUDE_SYSTEM_FLAG_C) -set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX) -# ... Nor does the driver support appropriate flags to create depfiles. -set(CMAKE_DEPFILE_FLAGS_C) -set(CMAKE_DEPFILE_FLAGS_CXX) - set(CMAKE_DL_LIBS "") -set(CMAKE_SHARED_LIBRARY_C_FLAGS "") -set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") -set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") -set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") -set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") -set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") -set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") -set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") -# http://www.qnx.com/developers/docs/6.4.0/neutrino/utilities/q/qcc.html#examples -set(CMAKE_C_COMPILE_OPTIONS_TARGET "-V") -set(CMAKE_CXX_COMPILE_OPTIONS_TARGET "-V") # Shared libraries with no builtin soname may not be linked safely by # specifying the file path. @@ -32,8 +14,22 @@ foreach(type SHARED_LIBRARY SHARED_MODULE EXE) set(CMAKE_${type}_LINK_STATIC_C_FLAGS "-Wl,-Bstatic") set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-Bdynamic") endforeach() -# force the language to be c++ since qnx only has gcc and not g++ and c++? -set(CMAKE_CXX_COMPILE_OBJECT - "<CMAKE_CXX_COMPILER> -x c++ <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>") -include(Platform/UnixPaths) +include(Platform/GNU) +unset(CMAKE_LIBRARY_ARCHITECTURE_REGEX) + +macro(__compiler_qcc lang) + # http://www.qnx.com/developers/docs/6.4.0/neutrino/utilities/q/qcc.html#examples + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-V") + + set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-Wp,-isystem,") + set(CMAKE_DEPFILE_FLAGS_${lang} "-Wc,-MMD,<DEPFILE>,-MT,<OBJECT>,-MF,<DEPFILE>") + + if (lang STREQUAL CXX) + # If the toolchain uses qcc for CMAKE_CXX_COMPILER instead of QCC, the + # default for the driver is not c++. + set(CMAKE_CXX_COMPILE_OBJECT + "<CMAKE_CXX_COMPILER> -lang-c++ <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>") + endif() + +endmacro() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d79ac73..301eff0 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ set(CMake_VERSION_MAJOR 2) set(CMake_VERSION_MINOR 8) set(CMake_VERSION_PATCH 12) -set(CMake_VERSION_TWEAK 20140115) +set(CMake_VERSION_TWEAK 20140127) #set(CMake_VERSION_RC 1) diff --git a/Source/QtDialog/AddCacheEntry.cxx b/Source/QtDialog/AddCacheEntry.cxx index e7fedc5..3881045 100644 --- a/Source/QtDialog/AddCacheEntry.cxx +++ b/Source/QtDialog/AddCacheEntry.cxx @@ -15,14 +15,16 @@ #include <QCompleter> static const int NumTypes = 4; +static const int DefaultTypeIndex = 0; static const QByteArray TypeStrings[NumTypes] = { "BOOL", "PATH", "FILEPATH", "STRING" }; static const QCMakeProperty::PropertyType Types[NumTypes] = { QCMakeProperty::BOOL, QCMakeProperty::PATH, QCMakeProperty::FILEPATH, QCMakeProperty::STRING}; -AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& completions) - : QWidget(p) +AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& varNames, + const QStringList& varTypes) + : QWidget(p), VarNames(varNames), VarTypes(varTypes) { this->setupUi(this); for(int i=0; i<NumTypes; i++) @@ -43,7 +45,10 @@ AddCacheEntry::AddCacheEntry(QWidget* p, const QStringList& completions) this->setTabOrder(path, filepath); this->setTabOrder(filepath, string); this->setTabOrder(string, this->Description); - this->Name->setCompleter(new QCompleter(completions, this)); + QCompleter *completer = new QCompleter(this->VarNames, this); + this->Name->setCompleter(completer); + connect(completer, SIGNAL(activated(const QString&)), + this, SLOT(onCompletionActivated(const QString&))); } QString AddCacheEntry::name() const @@ -77,7 +82,32 @@ QCMakeProperty::PropertyType AddCacheEntry::type() const { return Types[idx]; } - return QCMakeProperty::BOOL; + return Types[DefaultTypeIndex]; } +QString AddCacheEntry::typeString() const +{ + int idx = this->Type->currentIndex(); + if(idx >= 0 && idx < NumTypes) + { + return TypeStrings[idx]; + } + return TypeStrings[DefaultTypeIndex]; +} +void AddCacheEntry::onCompletionActivated(const QString &text) +{ + int idx = this->VarNames.indexOf(text); + if (idx != -1) + { + QString vartype = this->VarTypes[idx]; + for (int i = 0; i < NumTypes; i++) + { + if (TypeStrings[i] == vartype) + { + this->Type->setCurrentIndex(i); + break; + } + } + } +} diff --git a/Source/QtDialog/AddCacheEntry.h b/Source/QtDialog/AddCacheEntry.h index e219d4e..38c3a74 100644 --- a/Source/QtDialog/AddCacheEntry.h +++ b/Source/QtDialog/AddCacheEntry.h @@ -24,12 +24,21 @@ class AddCacheEntry : public QWidget, public Ui::AddCacheEntry { Q_OBJECT public: - AddCacheEntry(QWidget* p, const QStringList& completions); + AddCacheEntry(QWidget* p, const QStringList& varNames, + const QStringList& varTypes); QString name() const; QVariant value() const; QString description() const; QCMakeProperty::PropertyType type() const; + QString typeString() const; + +private slots: + void onCompletionActivated(const QString &text); + +private: + const QStringList& VarNames; + const QStringList& VarTypes; }; #endif diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index 1903c02..f62afd6 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -70,8 +70,10 @@ CMakeSetupDialog::CMakeSetupDialog() restoreGeometry(settings.value("geometry").toByteArray()); restoreState(settings.value("windowState").toByteArray()); - this->AddVariableCompletions = settings.value("AddVariableCompletionEntries", + this->AddVariableNames = settings.value("AddVariableNames", QStringList("CMAKE_INSTALL_PREFIX")).toStringList(); + this->AddVariableTypes = settings.value("AddVariableTypes", + QStringList("PATH")).toStringList(); QWidget* cont = new QWidget(this); this->setupUi(cont); @@ -1049,7 +1051,8 @@ void CMakeSetupDialog::addCacheEntry() dialog.resize(400, 200); dialog.setWindowTitle(tr("Add Cache Entry")); QVBoxLayout* l = new QVBoxLayout(&dialog); - AddCacheEntry* w = new AddCacheEntry(&dialog, this->AddVariableCompletions); + AddCacheEntry* w = new AddCacheEntry(&dialog, this->AddVariableNames, + this->AddVariableTypes); QDialogButtonBox* btns = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &dialog); @@ -1064,23 +1067,26 @@ void CMakeSetupDialog::addCacheEntry() m->insertProperty(w->type(), w->name(), w->description(), w->value(), false); // only add variable names to the completion which are new - if (!this->AddVariableCompletions.contains(w->name())) + if (!this->AddVariableNames.contains(w->name())) { - this->AddVariableCompletions << w->name(); + this->AddVariableNames << w->name(); + this->AddVariableTypes << w->typeString(); // limit to at most 100 completion items - if (this->AddVariableCompletions.size() > 100) + if (this->AddVariableNames.size() > 100) { - this->AddVariableCompletions.removeFirst(); + this->AddVariableNames.removeFirst(); + this->AddVariableTypes.removeFirst(); } // make sure CMAKE_INSTALL_PREFIX is always there - if (!this->AddVariableCompletions.contains("CMAKE_INSTALL_PREFIX")) + if (!this->AddVariableNames.contains("CMAKE_INSTALL_PREFIX")) { - this->AddVariableCompletions << QString("CMAKE_INSTALL_PREFIX"); + this->AddVariableNames << "CMAKE_INSTALL_PREFIX"; + this->AddVariableTypes << "PATH"; } QSettings settings; settings.beginGroup("Settings/StartPath"); - settings.setValue("AddVariableCompletionEntries", - this->AddVariableCompletions); + settings.setValue("AddVariableNames", this->AddVariableNames); + settings.setValue("AddVariableTypes", this->AddVariableTypes); } } } diff --git a/Source/QtDialog/CMakeSetupDialog.h b/Source/QtDialog/CMakeSetupDialog.h index 963c7d1..1b26c64 100644 --- a/Source/QtDialog/CMakeSetupDialog.h +++ b/Source/QtDialog/CMakeSetupDialog.h @@ -110,7 +110,8 @@ protected: QTextCharFormat ErrorFormat; QTextCharFormat MessageFormat; - QStringList AddVariableCompletions; + QStringList AddVariableNames; + QStringList AddVariableTypes; QStringList FindHistory; QEventLoop LocalLoop; diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index a7ffded..b55334f 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -24,14 +24,14 @@ bool cmAddDependenciesCommand } std::string target_name = args[0]; - if(this->Makefile->IsAlias(target_name.c_str())) + if(this->Makefile->IsAlias(target_name)) { cmOStringStream e; e << "Cannot add target-level dependencies to alias target \"" << target_name << "\".\n"; this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); } - if(cmTarget* target = this->Makefile->FindTargetToUse(target_name.c_str())) + if(cmTarget* target = this->Makefile->FindTargetToUse(target_name)) { if (target->GetType() == cmTarget::INTERFACE_LIBRARY) { diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index a352be0..62b6667 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -201,7 +201,7 @@ bool cmAddExecutableCommand if(importTarget) { // Make sure the target does not already exist. - if(this->Makefile->FindTargetToUse(exename.c_str())) + if(this->Makefile->FindTargetToUse(exename)) { cmOStringStream e; e << "cannot create imported target \"" << exename diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 2627445..a29f784 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -363,7 +363,7 @@ bool cmAddLibraryCommand } // Make sure the target does not already exist. - if(this->Makefile->FindTargetToUse(libName.c_str())) + if(this->Makefile->FindTargetToUse(libName)) { cmOStringStream e; e << "cannot create imported target \"" << libName diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index a848e4f..6511510 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -411,7 +411,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index, i != utils.end(); ++i) { if(cmTarget const* transitive_dependee = - dependee->GetMakefile()->FindTargetToUse(i->c_str())) + dependee->GetMakefile()->FindTargetToUse(*i)) { this->AddTargetDepend(depender_index, transitive_dependee, false); } diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 78bb9a6..bbdb3a1 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -93,7 +93,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) else if(doing == DoingLinkLibraries) { libsToLink += "\"" + cmSystemTools::TrimWhitespace(argv[i]) + "\" "; - if(cmTarget *tgt = this->Makefile->FindTargetToUse(argv[i].c_str())) + if(cmTarget *tgt = this->Makefile->FindTargetToUse(argv[i])) { switch(tgt->GetType()) { diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index f2f77ee..f24dfa2 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -41,7 +41,7 @@ unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const { std::string const& argv0 = this->CC.GetCommandLines()[c][0]; - cmTarget* target = this->Makefile->FindTargetToUse(argv0.c_str()); + cmTarget* target = this->Makefile->FindTargetToUse(argv0); if(target && target->GetType() == cmTarget::EXECUTABLE && (target->IsImported() || !this->Makefile->IsOn("CMAKE_CROSSCOMPILING"))) { diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index b669cd1..858f76c 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -35,7 +35,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) tei = targets.begin(); tei != targets.end(); ++tei) { - cmTarget *te = this->Makefile->FindTargetToUse(tei->c_str()); + cmTarget *te = this->Makefile->FindTargetToUse(*tei); expectedTargets += sep + this->Namespace + te->GetExportName(); sep = " "; if(this->ExportedTargets.insert(te).second) diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index 7c97d8d..db56aaf 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -159,7 +159,7 @@ bool cmExportCommand currentTarget != this->Targets.GetVector().end(); ++currentTarget) { - if (this->Makefile->IsAlias(currentTarget->c_str())) + if (this->Makefile->IsAlias(*currentTarget)) { cmOStringStream e; e << "given ALIAS target \"" << *currentTarget diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 13bff19..4a161ee 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -534,7 +534,7 @@ cmExportFileGenerator::AddTargetNamespace(std::string &input, { cmMakefile *mf = target->GetMakefile(); - cmTarget *tgt = mf->FindTargetToUse(input.c_str()); + cmTarget *tgt = mf->FindTargetToUse(input); if (!tgt) { return false; diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 8d37b62..a8a91d6 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -109,7 +109,7 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, for(std::vector<std::string>::const_iterator li = depends.begin(); li != depends.end(); ++li) { - cmTarget *tgt = target->GetMakefile()->FindTargetToUse(li->c_str()); + cmTarget *tgt = target->GetMakefile()->FindTargetToUse(*li); if(tgt && emitted.insert(tgt).second) { this->Exports.push_back(tgt); diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx index 0312488..d0f83b2 100644 --- a/Source/cmExtraKateGenerator.cxx +++ b/Source/cmExtraKateGenerator.cxx @@ -70,7 +70,7 @@ void cmExtraKateGenerator::CreateKateProjectFile(const cmMakefile* mf) const } std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); - std::string args = mf->GetRequiredDefinition("CMAKE_KATE_MAKE_ARGUMENTS"); + std::string args = mf->GetSafeDefinition("CMAKE_KATE_MAKE_ARGUMENTS"); fout << "{\n" diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index 4ce1ea5..4dd81be 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -120,7 +120,7 @@ void cmFLTKWrapUICommand::FinalPass() // people should add the srcs to the target themselves, but the old command // didn't support that, so check and see if they added the files in and if // they didn;t then print a warning and add then anyhow - cmTarget* target = this->Makefile->FindTarget(this->Target.c_str()); + cmTarget* target = this->Makefile->FindTarget(this->Target); if(!target) { std::string msg = diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 1feb03a..7036992 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -822,7 +822,7 @@ std::string getLinkedTargetsContent(const std::vector<std::string> &libraries, // self-referencing loop. continue; } - if (context->Makefile->FindTargetToUse(it->c_str())) + if (context->Makefile->FindTargetToUse(*it)) { depString += sep + "$<TARGET_PROPERTY:" + *it + "," + interfacePropertyName + ">"; @@ -912,18 +912,16 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } if(propertyName == "ALIASED_TARGET") { - if(context->Makefile->IsAlias(targetName.c_str())) + if(context->Makefile->IsAlias(targetName)) { - if(cmTarget* tgt = - context->Makefile->FindTargetToUse(targetName.c_str())) + if(cmTarget* tgt = context->Makefile->FindTargetToUse(targetName)) { return tgt->GetName(); } } return ""; } - target = context->Makefile->FindTargetToUse( - targetName.c_str()); + target = context->Makefile->FindTargetToUse(targetName); if (!target) { @@ -1476,7 +1474,7 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode "Expression syntax not recognized."); return std::string(); } - cmTarget* target = context->Makefile->FindTargetToUse(name.c_str()); + cmTarget* target = context->Makefile->FindTargetToUse(name); if(!target) { ::reportError(context, content->GetOriginalExpression(), diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0fcee3e..2573c85 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -68,7 +68,7 @@ static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name, std::vector<std::string>& result, bool excludeImported) { - cmTarget* depTgt = mf->FindTargetToUse(name.c_str()); + cmTarget* depTgt = mf->FindTargetToUse(name); if (!depTgt) { @@ -230,7 +230,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, { if (uniqueDeps.insert(*li).second) { - cmTarget* tgt = this->Makefile->FindTargetToUse(li->c_str()); + cmTarget* tgt = this->Makefile->FindTargetToUse(*li); if (!tgt) { @@ -394,7 +394,7 @@ void cmGeneratorTarget::LookupObjectLibraries() oli != objLibs.end(); ++oli) { std::string const& objLibName = *oli; - if(cmTarget* objLib = this->Makefile->FindTargetToUse(objLibName.c_str())) + if(cmTarget* objLib = this->Makefile->FindTargetToUse(objLibName)) { if(objLib->GetType() == cmTarget::OBJECT_LIBRARY) { @@ -607,7 +607,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep) } // Check for a target with this name. - if(cmTarget* t = this->Makefile->FindTargetToUse(util.c_str())) + if(cmTarget* t = this->Makefile->FindTargetToUse(util)) { // If we find the target and the dep was given as a full path, // then make sure it was not a full path to something else, and @@ -661,7 +661,7 @@ cmTargetTraceDependencies { std::string const& command = *cit->begin(); // Check for a target with this name. - if(cmTarget* t = this->Makefile->FindTargetToUse(command.c_str())) + if(cmTarget* t = this->Makefile->FindTargetToUse(command)) { if(t->GetType() == cmTarget::EXECUTABLE) { diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index a1454a3..33c43ca 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -290,17 +290,17 @@ bool cmGetPropertyCommand::HandleTargetMode() if(this->PropertyName == "ALIASED_TARGET") { - if(this->Makefile->IsAlias(this->Name.c_str())) + if(this->Makefile->IsAlias(this->Name)) { if(cmTarget* target = - this->Makefile->FindTargetToUse(this->Name.c_str())) + this->Makefile->FindTargetToUse(this->Name)) { return this->StoreResult(target->GetName()); } } return this->StoreResult((this->Variable + "-NOTFOUND").c_str()); } - if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name.c_str())) + if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name)) { return this->StoreResult(target->GetProperty(this->PropertyName.c_str())); } diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx index 488cc28..4aa49fe 100644 --- a/Source/cmGetTargetPropertyCommand.cxx +++ b/Source/cmGetTargetPropertyCommand.cxx @@ -21,7 +21,7 @@ bool cmGetTargetPropertyCommand return false; } std::string var = args[0].c_str(); - const char* targetName = args[1].c_str(); + const std::string& targetName = args[1]; const char *prop = 0; if(args[2] == "ALIASED_TARGET") diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 8a7eee4..03486d8 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -748,7 +748,12 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, { std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID"; const char* compilerId = mf->GetDefinition(compilerIdVar.c_str()); - if(compilerId && strcmp(compilerId, "AppleClang") == 0) + if(!compilerId) + { + return; + } + + if(strcmp(compilerId, "AppleClang") == 0) { cmPolicies* policies = this->CMakeInstance->GetPolicies(); switch(mf->GetPolicyStatus(cmPolicies::CMP0025)) @@ -778,6 +783,37 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf, break; } } + + if(strcmp(compilerId, "QCC") == 0) + { + cmPolicies* policies = this->CMakeInstance->GetPolicies(); + switch(mf->GetPolicyStatus(cmPolicies::CMP0047)) + { + case cmPolicies::WARN: + if(!this->CMakeInstance->GetIsInTryCompile()) + { + cmOStringStream w; + w << policies->GetPolicyWarning(cmPolicies::CMP0047) << "\n" + "Converting " << lang << + " compiler id \"QCC\" to \"GNU\" for compatibility." + ; + mf->IssueMessage(cmake::AUTHOR_WARNING, w.str()); + } + case cmPolicies::OLD: + // OLD behavior is to convert QCC to GNU. + mf->AddDefinition(compilerIdVar.c_str(), "GNU"); + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + mf->IssueMessage( + cmake::FATAL_ERROR, + policies->GetRequiredPolicyError(cmPolicies::CMP0047) + ); + case cmPolicies::NEW: + // NEW behavior is to keep QCC. + break; + } + } } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 65b01db..5e1f1ed 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1107,46 +1107,24 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) /*deptype=*/ "", /*rspfile=*/ "", /*rspcontent*/ "", - /*restat=*/ true, + /*restat=*/ false, /*generator=*/ true); - cmNinjaDeps implicitDeps, outputs, temp; - outputs.push_back(NINJA_BUILD_FILE); + cmNinjaDeps implicitDeps; for (std::vector<cmLocalGenerator *>::const_iterator i = this->LocalGenerators.begin(); i != this->LocalGenerators.end(); ++i) { const std::vector<std::string>& lf = (*i)->GetMakefile()->GetListFiles(); implicitDeps.insert(implicitDeps.end(), lf.begin(), lf.end()); - - const std::vector<std::string>& of = (*i)->GetMakefile()->GetOutputFiles(); - temp.insert(temp.end(), of.begin(), of.end()); } - - //Add the CMakeCache.txt file to the implicit depends so that we catch - //when somebody manually modifies the file. - implicitDeps.push_back("CMakeCache.txt"); - - //make sure nothing is in implicit depends twice std::sort(implicitDeps.begin(), implicitDeps.end()); implicitDeps.erase(std::unique(implicitDeps.begin(), implicitDeps.end()), implicitDeps.end()); - - - //make sure nothing is in outputs depends twice - std::sort(temp.begin(), temp.end()); - temp.erase(std::unique(temp.begin(), temp.end()), - temp.end()); - - //make sure that anything that is in implicitDeps is also NOT in outputs - std::set_difference(temp.begin(), - temp.end(), - implicitDeps.begin(), - implicitDeps.end(), - std::back_inserter(outputs)); + implicitDeps.push_back("CMakeCache.txt"); this->WriteBuild(os, "Re-run CMake if any of its inputs changed.", "RERUN_CMAKE", - outputs, + /*outputs=*/ cmNinjaDeps(1, NINJA_BUILD_FILE), /*explicitDeps=*/ cmNinjaDeps(), implicitDeps, /*orderOnlyDeps=*/ cmNinjaDeps(), diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index f7a42fc..41961ed 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -753,7 +753,8 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, //---------------------------------------------------------------------------- std::string GetSourcecodeValueFromFileExtension(const std::string& _ext, - const std::string& lang) + const std::string& lang, + bool& keepLastKnownFileType) { std::string ext = cmSystemTools::LowerCase(_ext); std::string sourcecode = "sourcecode"; @@ -764,10 +765,12 @@ GetSourcecodeValueFromFileExtension(const std::string& _ext, } else if(ext == "xib") { + keepLastKnownFileType = true; sourcecode = "file.xib"; } else if(ext == "storyboard") { + keepLastKnownFileType = true; sourcecode = "file.storyboard"; } else if(ext == "mm") @@ -778,10 +781,6 @@ GetSourcecodeValueFromFileExtension(const std::string& _ext, { sourcecode += ".c.objc"; } - else if(ext == "xib") - { - sourcecode += ".file.xib"; - } else if(ext == "plist") { sourcecode += ".text.plist"; @@ -797,6 +796,7 @@ GetSourcecodeValueFromFileExtension(const std::string& _ext, } else if(ext == "png" || ext == "gif" || ext == "jpg") { + keepLastKnownFileType = true; sourcecode = "image"; } else if(ext == "txt") @@ -875,8 +875,10 @@ cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath( } else { - std::string sourcecode = GetSourcecodeValueFromFileExtension(ext, lang); - const char* attribute = (sourcecode == "file.storyboard") ? + bool keepLastKnownFileType = false; + std::string sourcecode = GetSourcecodeValueFromFileExtension(ext, + lang, keepLastKnownFileType); + const char* attribute = keepLastKnownFileType ? "lastKnownFileType" : "explicitFileType"; fileRef->AddAttribute(attribute, diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 57cec5b..ee95c05 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -543,7 +543,7 @@ namespace if (*arg == "TARGET" && argP1 != newArgs.end()) { HandlePredicate( - makefile->FindTargetToUse((argP1)->c_str())? true:false, + makefile->FindTargetToUse(*argP1)?true:false, reducible, arg, newArgs, argP1, argP2); } // is a variable defined diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 10578f2..6f2dd65 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -363,7 +363,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) ++targetIt) { - if (this->Makefile->IsAlias(targetIt->c_str())) + if (this->Makefile->IsAlias(*targetIt)) { cmOStringStream e; e << "TARGETS given target \"" << (*targetIt) @@ -372,7 +372,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args) return false; } // Lookup this target in the current directory. - if(cmTarget* target=this->Makefile->FindTarget(targetIt->c_str())) + if(cmTarget* target=this->Makefile->FindTarget(*targetIt)) { // Found the target. Check its type. if(target->GetType() != cmTarget::EXECUTABLE && diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3effe38..c13b8ee 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -114,6 +114,8 @@ void cmLocalGenerator::Configure() } } + this->Makefile->AddCMakeDependFilesFromUser(); + // Check whether relative paths should be used for optionally // relative paths. this->UseRelativePaths = this->Makefile->IsOn("CMAKE_USE_RELATIVE_PATHS"); @@ -2021,7 +2023,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName, } // Look for a CMake target with the given name. - if(cmTarget* target = this->Makefile->FindTargetToUse(name.c_str())) + if(cmTarget* target = this->Makefile->FindTargetToUse(name)) { // make sure it is not just a coincidence that the target name // found is part of the inName diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 479e712..856462e 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3859,7 +3859,8 @@ const char* cmMakefile::GetFeature(const char* feature, const char* config) return 0; } -cmTarget* cmMakefile::FindTarget(const char* name, bool excludeAliases) const +cmTarget* cmMakefile::FindTarget(const std::string& name, + bool excludeAliases) const { if (!excludeAliases) { @@ -3912,6 +3913,30 @@ cmTest* cmMakefile::GetTest(const char* testName) const return 0; } +void cmMakefile::AddCMakeDependFilesFromUser() +{ + std::vector<std::string> deps; + if(const char* deps_str = this->GetProperty("CMAKE_CONFIGURE_DEPENDS")) + { + cmSystemTools::ExpandListArgument(deps_str, deps); + } + for(std::vector<std::string>::iterator i = deps.begin(); + i != deps.end(); ++i) + { + if(cmSystemTools::FileIsFullPath(i->c_str())) + { + this->AddCMakeDependFile(*i); + } + else + { + std::string f = this->GetCurrentDirectory(); + f += "/"; + f += *i; + this->AddCMakeDependFile(f); + } + } +} + std::string cmMakefile::GetListFileStack() { cmOStringStream tmp; @@ -4063,7 +4088,8 @@ cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type, } //---------------------------------------------------------------------------- -cmTarget* cmMakefile::FindTargetToUse(const char* name, bool excludeAliases) +cmTarget* cmMakefile::FindTargetToUse(const std::string& name, + bool excludeAliases) { // Look for an imported target. These take priority because they // are more local in scope and do not have to be globally unique. @@ -4081,16 +4107,18 @@ cmTarget* cmMakefile::FindTargetToUse(const char* name, bool excludeAliases) } // Look for a target built in this project. - return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, name, + return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0, + name.c_str(), excludeAliases); } //---------------------------------------------------------------------------- -bool cmMakefile::IsAlias(const char *name) +bool cmMakefile::IsAlias(const std::string& name) { if (this->AliasTargets.find(name) != this->AliasTargets.end()) return true; - return this->GetLocalGenerator()->GetGlobalGenerator()->IsAlias(name); + return this->GetLocalGenerator()->GetGlobalGenerator()->IsAlias( + name.c_str()); } //---------------------------------------------------------------------------- @@ -4107,7 +4135,7 @@ cmGeneratorTarget* cmMakefile::FindGeneratorTargetToUse(const char* name) bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, bool isCustom) { - if(this->IsAlias(name.c_str())) + if(this->IsAlias(name)) { cmOStringStream e; e << "cannot create target \"" << name @@ -4115,7 +4143,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg, msg = e.str(); return false; } - if(cmTarget* existing = this->FindTargetToUse(name.c_str())) + if(cmTarget* existing = this->FindTargetToUse(name)) { // The name given conflicts with an existing target. Produce an // error in a compatible way. diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index d9fc93c..dadf7ff 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -533,12 +533,14 @@ public: this->GeneratorTargets = targets; } - cmTarget* FindTarget(const char* name, bool excludeAliases = false) const; + cmTarget* FindTarget(const std::string& name, + bool excludeAliases = false) const; /** Find a target to use in place of the given name. The target returned may be imported or built within the project. */ - cmTarget* FindTargetToUse(const char* name, bool excludeAliases = false); - bool IsAlias(const char *name); + cmTarget* FindTargetToUse(const std::string& name, + bool excludeAliases = false); + bool IsAlias(const std::string& name); cmGeneratorTarget* FindGeneratorTargetToUse(const char* name); /** @@ -648,6 +650,7 @@ public: ///! When the file changes cmake will be re-run from the build system. void AddCMakeDependFile(const std::string& file) { this->ListFiles.push_back(file);} + void AddCMakeDependFilesFromUser(); /** * Get the list file stack as a string diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 020a782..a1451f1 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -336,6 +336,11 @@ cmPolicies::cmPolicies() CMP0046, "CMP0046", "Error on non-existent dependency in add_dependencies.", 3,0,0,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0047, "CMP0047", + "Use QCC compiler id for the qcc drivers on QNX.", + 3,0,0,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 38f47f1..d1bba7b 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -100,6 +100,7 @@ public: CMP0044, ///< Case sensitive <LANG>_COMPILER_ID generator expressions CMP0045, ///< Error on non-existent target in get_target_property CMP0046, ///< Error on non-existent dependency in add_dependencies + CMP0047, ///< Use QCC compiler id for the qcc drivers on QNX. /** \brief Always the last entry. * diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 4207860..1a6f1d6 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -244,12 +244,12 @@ bool cmSetPropertyCommand::HandleTargetMode() for(std::set<cmStdString>::const_iterator ni = this->Names.begin(); ni != this->Names.end(); ++ni) { - if (this->Makefile->IsAlias(ni->c_str())) + if (this->Makefile->IsAlias(*ni)) { this->SetError("can not be used on an ALIAS target."); return false; } - if(cmTarget* target = this->Makefile->FindTargetToUse(ni->c_str())) + if(cmTarget* target = this->Makefile->FindTargetToUse(*ni)) { // Handle the current target. if(!this->HandleTarget(target)) diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx index 78ef393..dab4180 100644 --- a/Source/cmSetTargetPropertiesCommand.cxx +++ b/Source/cmSetTargetPropertiesCommand.cxx @@ -72,7 +72,7 @@ bool cmSetTargetPropertiesCommand int i; for(i = 0; i < numFiles; ++i) { - if (this->Makefile->IsAlias(args[i].c_str())) + if (this->Makefile->IsAlias(args[i])) { this->SetError("can not be used on an ALIAS target."); return false; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 24fa0c5..21f8d4c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1681,14 +1681,14 @@ static void processIncludeDirectories(cmTarget const* tgt, evaluatedTargetName = cge->Evaluate(mf, config, false, tgt, 0, 0); } - cmTarget *dependentTarget = mf->FindTargetToUse(targetName.c_str()); + cmTarget *dependentTarget = mf->FindTargetToUse(targetName); const bool fromImported = dependentTarget && dependentTarget->IsImported(); cmTarget *evaluatedDependentTarget = (targetName != evaluatedTargetName) - ? mf->FindTargetToUse(evaluatedTargetName.c_str()) + ? mf->FindTargetToUse(evaluatedTargetName) : 0; targetName = evaluatedTargetName; @@ -1860,7 +1860,7 @@ cmTarget::GetIncludeDirectories(const char *config) const ge.Parse(it->Value); std::string result = cge->Evaluate(this->Makefile, config, false, this, 0, 0); - if (!this->Makefile->FindTargetToUse(result.c_str())) + if (!this->Makefile->FindTargetToUse(result)) { continue; } @@ -2089,7 +2089,7 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result, ge.Parse(it->Value); std::string targetResult = cge->Evaluate(this->Makefile, config, false, this, 0, 0); - if (!this->Makefile->FindTargetToUse(targetResult.c_str())) + if (!this->Makefile->FindTargetToUse(targetResult)) { continue; } @@ -2202,7 +2202,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, ge.Parse(it->Value); std::string targetResult = cge->Evaluate(this->Makefile, config, false, this, 0, 0); - if (!this->Makefile->FindTargetToUse(targetResult.c_str())) + if (!this->Makefile->FindTargetToUse(targetResult)) { continue; } @@ -2861,7 +2861,7 @@ public: for(std::vector<std::string>::const_iterator li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) { - this->Visit(mf->FindTargetToUse(li->c_str())); + this->Visit(mf->FindTargetToUse(*li)); } } private: @@ -2969,7 +2969,7 @@ void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc, for(std::vector<std::string>::const_iterator li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li) { - cll.Visit(this->Makefile->FindTargetToUse(li->c_str())); + cll.Visit(this->Makefile->FindTargetToUse(*li)); } // Store the transitive closure of languages. @@ -5414,7 +5414,7 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface, { if(emitted.insert(*li).second) { - if(cmTarget* tgt = this->Makefile->FindTargetToUse(li->c_str())) + if(cmTarget* tgt = this->Makefile->FindTargetToUse(*li)) { // This is a runtime dependency on another shared library. if(tgt->GetType() == cmTarget::SHARED_LIBRARY) @@ -5624,7 +5624,7 @@ void cmTarget::ComputeLinkImplementation(const char* config, } continue; } - cmTarget *tgt = this->Makefile->FindTargetToUse(li->c_str()); + cmTarget *tgt = this->Makefile->FindTargetToUse(*li); if(!tgt && std::string(item).find("::") != std::string::npos) { @@ -5695,7 +5695,7 @@ void cmTarget::ComputeLinkImplementation(const char* config, i = this->ObjectLibraries.begin(); i != this->ObjectLibraries.end(); ++i) { - if(cmTarget* objLib = this->Makefile->FindTargetToUse(i->c_str())) + if(cmTarget* objLib = this->Makefile->FindTargetToUse(*i)) { if(objLib->GetType() == cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 209609d..02da933 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -31,7 +31,7 @@ bool cmTargetLinkLibrariesCommand return false; } - if (this->Makefile->IsAlias(args[0].c_str())) + if (this->Makefile->IsAlias(args[0])) { this->SetError("can not be used on an ALIAS target."); return false; diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index e7b6999..195690e 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -26,7 +26,7 @@ bool cmTargetPropCommandBase } // Lookup the target for which libraries are specified. - if (this->Makefile->IsAlias(args[0].c_str())) + if (this->Makefile->IsAlias(args[0])) { this->SetError("can not be used on an ALIAS target."); return false; @@ -36,7 +36,7 @@ bool cmTargetPropCommandBase ->GetGlobalGenerator()->FindTarget(0, args[0].c_str()); if(!this->Target) { - this->Target = this->Makefile->FindTargetToUse(args[0].c_str()); + this->Target = this->Makefile->FindTargetToUse(args[0]); } if(!this->Target) { diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index d962fb2..5dc3e60 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -82,7 +82,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // be translated. std::string exe = command[0]; cmMakefile* mf = this->Test->GetMakefile(); - cmTarget* target = mf->FindTargetToUse(exe.c_str()); + cmTarget* target = mf->FindTargetToUse(exe); if(target && target->GetType() == cmTarget::EXECUTABLE) { // Use the target file on disk. diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 7891969..4ac1986 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -71,6 +71,7 @@ void CMakeCommandUsage(const char* program) "(on one volume)\n" << " tar [cxt][vfz][cvfj] file.tar [file/dir1 file/dir2 ...]\n" << " - create or extract a tar or zip archive\n" + << " sleep <number>... - sleep for given number of seconds\n" << " time command [args] ... - run command and return elapsed time\n" << " touch file - touch a file.\n" << " touch_nocreate file - touch a file but do not create it.\n" @@ -279,6 +280,33 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) return 0; } + // Sleep command + else if (args[1] == "sleep" && args.size() > 2) + { + double total = 0; + for(size_t i = 2; i < args.size(); ++i) + { + double num = 0.0; + char unit; + char extra; + int n = sscanf(args[i].c_str(), "%lg%c%c", &num, &unit, &extra); + if((n == 1 || (n == 2 && unit == 's')) && num >= 0) + { + total += num; + } + else + { + std::cerr << "Unknown sleep time format \"" << args[i] << "\".\n"; + return 1; + } + } + if(total > 0) + { + cmSystemTools::Delay(static_cast<unsigned int>(total*1000)); + } + return 0; + } + // Clock command else if (args[1] == "time" && args.size() > 2) { @@ -460,23 +488,25 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) else if (args[1] == "create_symlink" && args.size() == 4) { const char* destinationFileName = args[3].c_str(); - if ( cmSystemTools::FileExists(destinationFileName) ) + if((cmSystemTools::FileExists(destinationFileName) || + cmSystemTools::FileIsSymlink(destinationFileName)) && + !cmSystemTools::RemoveFile(destinationFileName)) { - if ( cmSystemTools::FileIsSymlink(destinationFileName) ) - { - if ( !cmSystemTools::RemoveFile(destinationFileName) || - cmSystemTools::FileExists(destinationFileName) ) - { - return 0; - } - } - else - { - return 0; - } + std::string emsg = cmSystemTools::GetLastSystemError(); + std::cerr << + "failed to create symbolic link '" << destinationFileName << + "' because existing path cannot be removed: " << emsg << "\n"; + return 1; + } + if(!cmSystemTools::CreateSymlink(args[2].c_str(), args[3].c_str())) + { + std::string emsg = cmSystemTools::GetLastSystemError(); + std::cerr << + "failed to create symbolic link '" << destinationFileName << + "': " << emsg << "\n"; + return 1; } - return cmSystemTools::CreateSymlink(args[2].c_str(), - args[3].c_str())? 0:1; + return 0; } // Internal CMake shared library support. diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 1c23bcd..9646e67 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -1,39 +1,4 @@ -# This directory contains tests that run CMake to configure a project -# but do not actually build anything. To add a test: -# -# 1.) Add a subdirectory named for the test. -# -# 2.) Call add_RunCMake_test and pass the test directory name. -# -# 3.) Create a RunCMakeTest.cmake script in the directory containing -# include(RunCMake) -# run_cmake(SubTest1) -# ... -# run_cmake(SubTestN) -# where SubTest1..SubTestN are sub-test names each corresponding to -# an independent CMake run and project configuration. -# -# 3.) Create a CMakeLists.txt file in the directory containing -# cmake_minimum_required(...) -# project(${RunCMake_TEST} NONE) # or languages needed -# include(${RunCMake_TEST}.cmake) -# where "${RunCMake_TEST}" is literal. A value for RunCMake_TEST -# will be passed to CMake by the run_cmake macro when running each -# sub-test. -# -# 4.) Create a <SubTest>.cmake file for each sub-test named above -# containing the actual test code. Optionally create files -# containing expected test results: -# <SubTest>-result.txt = Process result expected if not "0" -# <SubTest>-stdout.txt = Regex matching expected stdout content -# <SubTest>-stderr.txt = Regex matching expected stderr content -# <SubTest>-check.cmake = Custom result check -# Note that trailing newlines will be stripped from actual and expected test -# output before matching against the stdout and stderr expressions. -# The code in <SubTest>-check.cmake may use variables -# RunCMake_TEST_SOURCE_DIR = Top of test source tree -# RunCMake_TEST_BINARY_DIR = Top of test binary tree -# and an failure must store a message in RunCMake_TEST_FAILED. +# See adjacent README.rst for documentation of this test infrastructure. macro(add_RunCMake_test test) add_test(RunCMake.${test} ${CMAKE_CMAKE_COMMAND} @@ -146,5 +111,6 @@ add_RunCMake_test(File_Generate) add_RunCMake_test(ExportWithoutLanguage) add_RunCMake_test(target_link_libraries) add_RunCMake_test(CheckModules) +add_RunCMake_test(CommandLine) add_RunCMake_test(install) diff --git a/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake b/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake new file mode 100644 index 0000000..d7e652d --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_symlink-broken-create-check.cmake @@ -0,0 +1,6 @@ +if(NOT IS_SYMLINK ${RunCMake_TEST_BINARY_DIR}/L) + set(RunCMake_TEST_FAILED "Symlink 'L' incorrectly not created!") +endif() +if(EXISTS ${RunCMake_TEST_BINARY_DIR}/L) + set(RunCMake_TEST_FAILED "Symlink 'L' not broken!") +endif() diff --git a/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake b/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake new file mode 100644 index 0000000..c078ae8 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_symlink-broken-replace-check.cmake @@ -0,0 +1,3 @@ +if(NOT IS_DIRECTORY ${RunCMake_TEST_BINARY_DIR}/L) + set(RunCMake_TEST_FAILED "Symlink 'L' not replaced correctly!") +endif() diff --git a/Tests/RunCMake/CommandLine/E_create_symlink-missing-dir-result.txt b/Tests/RunCMake/CommandLine/E_create_symlink-missing-dir-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_symlink-missing-dir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_create_symlink-missing-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_create_symlink-missing-dir-stderr.txt new file mode 100644 index 0000000..7a6d84b --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_symlink-missing-dir-stderr.txt @@ -0,0 +1 @@ +failed to create symbolic link 'missing-dir/L': diff --git a/Tests/RunCMake/CommandLine/E_create_symlink-no-replace-dir-result.txt b/Tests/RunCMake/CommandLine/E_create_symlink-no-replace-dir-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_symlink-no-replace-dir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_create_symlink-no-replace-dir-stderr.txt b/Tests/RunCMake/CommandLine/E_create_symlink-no-replace-dir-stderr.txt new file mode 100644 index 0000000..ebed0d6 --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_create_symlink-no-replace-dir-stderr.txt @@ -0,0 +1 @@ +failed to create symbolic link '\.' because existing path cannot be removed: diff --git a/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-result.txt b/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-stderr.txt b/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-stderr.txt new file mode 100644 index 0000000..45e6ebc --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sleep-bad-arg1-stderr.txt @@ -0,0 +1 @@ +^Unknown sleep time format "x"\.$ diff --git a/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-result.txt b/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-stderr.txt b/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-stderr.txt new file mode 100644 index 0000000..399d47f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sleep-bad-arg2-stderr.txt @@ -0,0 +1 @@ +^Unknown sleep time format "-1"\.$ diff --git a/Tests/RunCMake/CommandLine/E_sleep-no-args-result.txt b/Tests/RunCMake/CommandLine/E_sleep-no-args-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sleep-no-args-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/E_sleep-no-args-stderr.cmake b/Tests/RunCMake/CommandLine/E_sleep-no-args-stderr.cmake new file mode 100644 index 0000000..977f1ef --- /dev/null +++ b/Tests/RunCMake/CommandLine/E_sleep-no-args-stderr.cmake @@ -0,0 +1,2 @@ +Usage: .*/cmake -E \[command\] \[arguments \.\.\.\] +Available commands: diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake new file mode 100644 index 0000000..ada4cab --- /dev/null +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -0,0 +1,30 @@ +include(RunCMake) + +if(UNIX) + run_cmake_command(E_create_symlink-missing-dir + ${CMAKE_COMMAND} -E create_symlink T missing-dir/L + ) + + # Use a single build tree for a few tests without cleaning. + set(RunCMake_TEST_BINARY_DIR + ${RunCMake_BINARY_DIR}/E_create_symlink-broken-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + run_cmake_command(E_create_symlink-broken-create + ${CMAKE_COMMAND} -E create_symlink T L + ) + run_cmake_command(E_create_symlink-broken-replace + ${CMAKE_COMMAND} -E create_symlink . L + ) + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) + + run_cmake_command(E_create_symlink-no-replace-dir + ${CMAKE_COMMAND} -E create_symlink T . + ) +endif() + +run_cmake_command(E_sleep-no-args ${CMAKE_COMMAND} -E sleep) +run_cmake_command(E_sleep-bad-arg1 ${CMAKE_COMMAND} -E sleep x) +run_cmake_command(E_sleep-bad-arg2 ${CMAKE_COMMAND} -E sleep 1 -1) +run_cmake_command(E_sleep-one-tenth ${CMAKE_COMMAND} -E sleep 0.1) diff --git a/Tests/RunCMake/Configure/RerunCMake-build1-check.cmake b/Tests/RunCMake/Configure/RerunCMake-build1-check.cmake new file mode 100644 index 0000000..dbf8f67 --- /dev/null +++ b/Tests/RunCMake/Configure/RerunCMake-build1-check.cmake @@ -0,0 +1,9 @@ +file(READ ${stamp} content) +if(NOT content STREQUAL 1) + set(RunCMake_TEST_FAILED "Expected stamp '1' but got: '${content}'") +endif() + +file(READ ${output} content) +if(NOT content STREQUAL 1) + set(RunCMake_TEST_FAILED "Expected output '1' but got: '${content}'") +endif() diff --git a/Tests/RunCMake/Configure/RerunCMake-build2-check.cmake b/Tests/RunCMake/Configure/RerunCMake-build2-check.cmake new file mode 100644 index 0000000..a4897e5 --- /dev/null +++ b/Tests/RunCMake/Configure/RerunCMake-build2-check.cmake @@ -0,0 +1,9 @@ +file(READ ${stamp} content) +if(NOT content STREQUAL 2) + set(RunCMake_TEST_FAILED "Expected stamp '2' but got: '${content}'") +endif() + +file(READ ${output} content) +if(NOT content STREQUAL 2) + set(RunCMake_TEST_FAILED "Expected output '2' but got: '${content}'") +endif() diff --git a/Tests/RunCMake/Configure/RerunCMake.cmake b/Tests/RunCMake/Configure/RerunCMake.cmake new file mode 100644 index 0000000..5a561bf --- /dev/null +++ b/Tests/RunCMake/Configure/RerunCMake.cmake @@ -0,0 +1,11 @@ +set(input ${CMAKE_CURRENT_BINARY_DIR}/CustomCMakeInput.txt) +set(stamp ${CMAKE_CURRENT_BINARY_DIR}/CustomCMakeStamp.txt) +file(READ ${input} content) +file(WRITE ${stamp} "${content}") + +set(depend ${CMAKE_CURRENT_BINARY_DIR}/CustomCMakeDepend.txt) +set(output ${CMAKE_CURRENT_BINARY_DIR}/CustomCMakeOutput.txt) +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${depend}) +file(READ ${depend} content) +file(WRITE ${output} "${content}") +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS RerunCMake.txt) diff --git a/Tests/RunCMake/Configure/RerunCMake.txt b/Tests/RunCMake/Configure/RerunCMake.txt new file mode 100644 index 0000000..15598c1 --- /dev/null +++ b/Tests/RunCMake/Configure/RerunCMake.txt @@ -0,0 +1 @@ +Source-tree dependency for "RerunCMake.cmake". diff --git a/Tests/RunCMake/Configure/RunCMakeTest.cmake b/Tests/RunCMake/Configure/RunCMakeTest.cmake index 79e4060..5ef0384 100644 --- a/Tests/RunCMake/Configure/RunCMakeTest.cmake +++ b/Tests/RunCMake/Configure/RunCMakeTest.cmake @@ -2,3 +2,23 @@ include(RunCMake) run_cmake(ErrorLogs) run_cmake(FailCopyFileABI) + +# Use a single build tree for a few tests without cleaning. +set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/RerunCMake-build) +set(RunCMake_TEST_NO_CLEAN 1) +file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") +file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") +set(input "${RunCMake_TEST_BINARY_DIR}/CustomCMakeInput.txt") +set(stamp "${RunCMake_TEST_BINARY_DIR}/CustomCMakeStamp.txt") +set(depend "${RunCMake_TEST_BINARY_DIR}/CustomCMakeDepend.txt") +set(output "${RunCMake_TEST_BINARY_DIR}/CustomCMakeOutput.txt") +file(WRITE "${input}" "1") +file(WRITE "${depend}" "1") +run_cmake(RerunCMake) +execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1) # handle 1s resolution +file(WRITE "${input}" "2") +run_cmake_command(RerunCMake-build1 ${CMAKE_COMMAND} --build .) +file(WRITE "${depend}" "2") +run_cmake_command(RerunCMake-build2 ${CMAKE_COMMAND} --build .) +unset(RunCMake_TEST_BINARY_DIR) +unset(RunCMake_TEST_NO_CLEAN) diff --git a/Tests/RunCMake/README.rst b/Tests/RunCMake/README.rst new file mode 100644 index 0000000..536cff2 --- /dev/null +++ b/Tests/RunCMake/README.rst @@ -0,0 +1,57 @@ +This directory contains tests that run CMake to configure a project +but do not actually build anything. To add a test: + +1. Add a subdirectory named for the test, say ``<Test>/``. + +2. In ``./CMakeLists.txt`` call ``add_RunCMake_test`` and pass the + test directory name ``<Test>``. + +3. Create script ``<Test>/RunCMakeTest.cmake`` in the directory containing:: + + include(RunCMake) + run_cmake(SubTest1) + ... + run_cmake(SubTestN) + + where ``SubTest1`` through ``SubTestN`` are sub-test names each + corresponding to an independent CMake run and project configuration. + + One may also add calls of the form:: + + run_cmake_command(SubTestI ${CMAKE_COMMAND} ...) + + to fully customize the test case command-line. + +4. Create file ``<Test>/CMakeLists.txt`` in the directory containing:: + + cmake_minimum_required(...) + project(${RunCMake_TEST} NONE) # or languages needed + include(${RunCMake_TEST}.cmake) + + where ``${RunCMake_TEST}`` is literal. A value for ``RunCMake_TEST`` + will be passed to CMake by the ``run_cmake`` macro when running each + sub-test. + +5. Create a ``<Test>/<SubTest>.cmake`` file for each sub-test named + above containing the actual test code. Optionally create files + containing expected test results: + + ``<SubTest>-result.txt`` + Process result expected if not "0" + ``<SubTest>-stdout.txt`` + Regex matching expected stdout content + ``<SubTest>-stderr.txt`` + Regex matching expected stderr content + ``<SubTest>-check.cmake`` + Custom result check. + + Note that trailing newlines will be stripped from actual and expected + test output before matching against the stdout and stderr expressions. + The code in ``<SubTest>-check.cmake`` may use variables + + ``RunCMake_TEST_SOURCE_DIR`` + Top of test source tree + ``RunCMake_TEST_BINARY_DIR`` + Top of test binary tree + + and an failure must store a message in ``RunCMake_TEST_FAILED``. diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 5c7c05c..1d1c523 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -39,17 +39,27 @@ function(run_cmake test) if(APPLE) list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW) endif() - execute_process( - COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}" - -G "${RunCMake_GENERATOR}" - -T "${RunCMake_GENERATOR_TOOLSET}" - -DRunCMake_TEST=${test} - ${RunCMake_TEST_OPTIONS} - WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" - OUTPUT_VARIABLE actual_stdout - ERROR_VARIABLE actual_stderr - RESULT_VARIABLE actual_result - ) + if(RunCMake_TEST_COMMAND) + execute_process( + COMMAND ${RunCMake_TEST_COMMAND} + WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" + OUTPUT_VARIABLE actual_stdout + ERROR_VARIABLE actual_stderr + RESULT_VARIABLE actual_result + ) + else() + execute_process( + COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}" + -G "${RunCMake_GENERATOR}" + -T "${RunCMake_GENERATOR_TOOLSET}" + -DRunCMake_TEST=${test} + ${RunCMake_TEST_OPTIONS} + WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}" + OUTPUT_VARIABLE actual_stdout + ERROR_VARIABLE actual_stderr + RESULT_VARIABLE actual_result + ) + endif() set(msg "") if(NOT "${actual_result}" STREQUAL "${expect_result}") set(msg "${msg}Result is [${actual_result}], not [${expect_result}].\n") @@ -86,3 +96,8 @@ function(run_cmake test) message(STATUS "${test} - PASSED") endif() endfunction() + +function(run_cmake_command test) + set(RunCMake_TEST_COMMAND "${ARGN}") + run_cmake(${test}) +endfunction() |