diff options
132 files changed, 1366 insertions, 445 deletions
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index 52fdc91..bf5b5bc 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -637,7 +637,7 @@ if(CPACK_RPM_CHANGELOG_FILE) message(SEND_ERROR "CPackRPM:Warning: CPACK_RPM_CHANGELOG_FILE <${CPACK_RPM_CHANGELOG_FILE}> does not exists - ignoring") endif() else() - set(CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Erk <eric.noulard@gmail.com>\n Generated by CPack RPM (no Changelog file were provided)") + set(CPACK_RPM_SPEC_CHANGELOG "* Sun Jul 4 2010 Eric Noulard <eric.noulard@gmail.com> - ${CPACK_RPM_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}\n Generated by CPack RPM (no Changelog file were provided)") endif() # CPACK_RPM_SPEC_MORE_DEFINE @@ -876,6 +876,13 @@ if(CPACK_RPM_PACKAGE_DEBUG) message("CPackRPM:Debug: CPACK_TEMPORARY_PACKAGE_FILE_NAME = ${CPACK_TEMPORARY_PACKAGE_FILE_NAME}") endif() +# protect @ in pathname in order to avoid their +# interpretation during the configure_file step +set(CPACK_RPM_INSTALL_FILES_LIST "${CPACK_RPM_INSTALL_FILES}") +set(PROTECTED_AT "@") +string(REPLACE "@" "\@PROTECTED_AT\@" CPACK_RPM_INSTALL_FILES "${CPACK_RPM_INSTALL_FILES_LIST}") +set(CPACK_RPM_INSTALL_FILES_LIST "") + # # USER generated/provided spec file handling. # @@ -982,6 +989,9 @@ else() configure_file(${CPACK_RPM_BINARY_SPECFILE}.in ${CPACK_RPM_BINARY_SPECFILE} @ONLY) endif() +# remove AT protection +unset(PROTECTED_AT) + if(RPMBUILD_EXECUTABLE) # Now call rpmbuild using the SPECFILE execute_process( diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index e5e10c3..504704d 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -30,7 +30,6 @@ macro(__compiler_gnu lang) endif() set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") - set(CMAKE_SYSROOT_FLAG "--sysroot=") # Older versions of gcc (< 4.5) contain a bug causing them to report a missing # header file as a warning if depfiles are enabled, causing check_header_file diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 6afdb97..0781ea1 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -114,6 +114,15 @@ # and <TMP_DIR> # with corresponding property values. # +# Any builtin step that specifies a "<step>_COMMAND cmd..." or custom +# step that specifies a "COMMAND cmd..." may specify additional command +# lines using the form "COMMAND cmd...". At build time the commands will +# be executed in order and aborted if any one fails. For example: +# ... BUILD_COMMAND make COMMAND echo done ... +# specifies to run "make" and then "echo done" during the build step. +# Whether the current working directory is preserved between commands +# is not defined. Behavior of shell operators like "&&" is not defined. +# # The 'ExternalProject_Get_Property' function retrieves external project # target properties: # ExternalProject_Get_Property(<name> [prop1 [prop2 [...]]]) @@ -961,7 +970,7 @@ endif() set(sep ";") endif() endforeach() - set(code "set(ENV{VS_UNICODE_OUTPUT} \"\")\n${code}set(command \"${cmd}\")${code_execute_process}") + set(code "${code}set(command \"${cmd}\")${code_execute_process}") file(WRITE ${stamp_dir}/${name}-${step}-impl.cmake "${code}") set(command ${CMAKE_COMMAND} "-Dmake=\${make}" "-Dconfig=\${config}" -P ${stamp_dir}/${name}-${step}-impl.cmake) endif() @@ -971,7 +980,6 @@ endif() set(logbase ${stamp_dir}/${name}-${step}) file(WRITE ${script} " ${code_cygpath_make} -set(ENV{VS_UNICODE_OUTPUT} \"\") set(command \"${command}\") execute_process( COMMAND \${command} diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake index d96d2cc..fef4669 100644 --- a/Modules/FindPNG.cmake +++ b/Modules/FindPNG.cmake @@ -38,7 +38,10 @@ if(ZLIB_FOUND) /usr/local/include/libpng # OpenBSD ) - set(PNG_NAMES ${PNG_NAMES} png libpng png15 libpng15 png15d libpng15d png14 libpng14 png14d libpng14d png12 libpng12 png12d libpng12d) + list(APPEND PNG_NAMES png libpng) + foreach(v 16 15 14 12) + list(APPEND PNG_NAMES png${v} libpng${v} png${v}d libpng${v}d) + endforeach() find_library(PNG_LIBRARY NAMES ${PNG_NAMES} ) if (PNG_LIBRARY AND PNG_PNG_INCLUDE_DIR) diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake index 8ce1934..7b37e1e 100644 --- a/Modules/FindQt4.cmake +++ b/Modules/FindQt4.cmake @@ -100,6 +100,7 @@ # because you need a custom filename for the moc file or something similar. # # macro QT4_AUTOMOC(sourcefile1 sourcefile2 ... ) +# 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 @@ -174,6 +175,7 @@ # must exist and are not updated in any way. # # 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, # and add the relevant compiler defines for using the module. diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index 18f449d..9e89788 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -635,7 +635,6 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa set(gp_regex_fallback "") set(gp_regex_cmp_count 1) set(gp_tool_known 1) - set(ENV{VS_UNICODE_OUTPUT} "") # Block extra output from inside VS IDE. endif() if("${gp_tool}" STREQUAL "objdump") diff --git a/Modules/Platform/Darwin-Absoft-Fortran.cmake b/Modules/Platform/Darwin-Absoft-Fortran.cmake index beb41a3..dc62b0d 100644 --- a/Modules/Platform/Darwin-Absoft-Fortran.cmake +++ b/Modules/Platform/Darwin-Absoft-Fortran.cmake @@ -1 +1,18 @@ +#============================================================================= +# Copyright 2011 Kitware, Inc. +# Copyright 2013 OpenGamma Ltd. <graham@opengamma.com> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + set(CMAKE_Fortran_VERBOSE_FLAG "-X -v") # Runs gcc under the hood. + +set(CMAKE_Fortran_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") +set(CMAKE_Fortran_OSX_CURRENT_VERSION_FLAG "-current_version ") diff --git a/Modules/Platform/Darwin-GNU-Fortran.cmake b/Modules/Platform/Darwin-GNU-Fortran.cmake index 8e8acc3..f4b509a 100644 --- a/Modules/Platform/Darwin-GNU-Fortran.cmake +++ b/Modules/Platform/Darwin-GNU-Fortran.cmake @@ -1,2 +1,19 @@ +#============================================================================= +# Copyright 2009 Kitware, Inc. +# Copyright 2013 OpenGamma Ltd. <graham@opengamma.com> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + include(Platform/Darwin-GNU) __darwin_compiler_gnu(Fortran) + +set(CMAKE_Fortran_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") +set(CMAKE_Fortran_OSX_CURRENT_VERSION_FLAG "-current_version ") diff --git a/Modules/Platform/Darwin-Intel-Fortran.cmake b/Modules/Platform/Darwin-Intel-Fortran.cmake new file mode 100644 index 0000000..6bd45f1 --- /dev/null +++ b/Modules/Platform/Darwin-Intel-Fortran.cmake @@ -0,0 +1,15 @@ +#============================================================================= +# Copyright 2013 OpenGamma Ltd. <graham@opengamma.com> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +set(CMAKE_Fortran_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ") +set(CMAKE_Fortran_OSX_CURRENT_VERSION_FLAG "-current_version ") diff --git a/Modules/Platform/Darwin-NAG-Fortran.cmake b/Modules/Platform/Darwin-NAG-Fortran.cmake index 933f9e1..4c28e62 100644 --- a/Modules/Platform/Darwin-NAG-Fortran.cmake +++ b/Modules/Platform/Darwin-NAG-Fortran.cmake @@ -1,5 +1,26 @@ +#============================================================================= +# Copyright 2010 Kitware, Inc. +# Copyright 2013 OpenGamma Ltd. <graham@opengamma.com> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + set(CMAKE_Fortran_VERBOSE_FLAG "-Wl,-v") # Runs gcc under the hood. # Need -fpp explicitly on case-insensitive filesystem. set(CMAKE_Fortran_COMPILE_OBJECT "<CMAKE_Fortran_COMPILER> -fpp -o <OBJECT> <DEFINES> <FLAGS> -c <SOURCE>") + +set(CMAKE_Fortran_OSX_COMPATIBILITY_VERSION_FLAG "-Wl,-compatibility_version -Wl,") +set(CMAKE_Fortran_OSX_CURRENT_VERSION_FLAG "-Wl,-current_version -Wl,") +set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "-Wl,-shared") +set(CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG "-Wl,-install_name -Wl,") +set(CMAKE_Fortran_CREATE_SHARED_LIBRARY + "<CMAKE_Fortran_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG><TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>") diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake index a0b2e31..5e13b59 100644 --- a/Modules/Qt4Macros.cmake +++ b/Modules/Qt4Macros.cmake @@ -357,6 +357,17 @@ endmacro() macro(QT4_AUTOMOC) + if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.11) + if(CMAKE_WARN_DEPRECATED) + set(messageType WARNING) + endif() + if(CMAKE_ERROR_DEPRECATED) + set(messageType FATAL_ERROR) + endif() + if(messageType) + message(${messageType} "The qt4_automoc macro is obsolete. Use the CMAKE_AUTOMOC feature instead.") + endif() + endif() QT4_GET_MOC_FLAGS(_moc_INCS) set(_matching_FILES ) @@ -467,6 +478,17 @@ macro(QT4_ADD_TRANSLATION _qm_files) endmacro() function(qt4_use_modules _target _link_type) + if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.11) + if(CMAKE_WARN_DEPRECATED) + set(messageType WARNING) + endif() + if(CMAKE_ERROR_DEPRECATED) + set(messageType FATAL_ERROR) + endif() + if(messageType) + message(${messageType} "The qt4_use_modules function is obsolete. Use target_link_libraries with IMPORTED targets instead.") + endif() + endif() if ("${_link_type}" STREQUAL "LINK_PUBLIC" OR "${_link_type}" STREQUAL "LINK_PRIVATE") set(modules ${ARGN}) set(link_type ${_link_type}) diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 0242b24..f518b14 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -190,6 +190,7 @@ # #============================================================================= +# Copyright 2013 OpenGamma Ltd. <graham@opengamma.com> # Copyright 2010-2011 Andreas schneider <asn@redhat.com> # Copyright 2010 Ben Boeckel <ben.boeckel@kitware.com> # @@ -367,6 +368,11 @@ function(add_jar _TARGET_NAME) endif() if (_JAVA_COMPILE_FILES) + # Create the list of files to compile. + set(_JAVA_SOURCES_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_sources) + string(REPLACE ";" "\"\n\"" _JAVA_COMPILE_STRING "\"${_JAVA_COMPILE_FILES}\"") + file(WRITE ${_JAVA_SOURCES_FILE} ${_JAVA_COMPILE_STRING}) + # Compile the java files and create a list of class files add_custom_command( # NOTE: this command generates an artificial dependency file @@ -375,7 +381,7 @@ function(add_jar _TARGET_NAME) ${CMAKE_JAVA_COMPILE_FLAGS} -classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}" -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH} - ${_JAVA_COMPILE_FILES} + @${_JAVA_SOURCES_FILE} COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME} DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_DEPENDS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c63d2ba..8d486cb 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 11) -set(CMake_VERSION_TWEAK 20130707) +set(CMake_VERSION_TWEAK 20130717) #set(CMake_VERSION_RC 1) diff --git a/Source/CursesDialog/form/fty_ipv4.c b/Source/CursesDialog/form/fty_ipv4.c index 4ac8a50..c855af6 100644 --- a/Source/CursesDialog/form/fty_ipv4.c +++ b/Source/CursesDialog/form/fty_ipv4.c @@ -30,7 +30,7 @@ static bool Check_IPV4_Field(FIELD * field, const void * argp) { char *bp = field_buffer(field,0); int num = 0, len; - unsigned int d1, d2, d3, d4; + unsigned int d1=256, d2=256, d3=256, d4=256; argp=0; /* Silence unused parameter warning. */ diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 0ba0139..ab9eb14 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1884,8 +1884,6 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, } if(use_build_rpath || use_link_rpath) { - std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); - cmSystemTools::ConvertToUnixSlashes(rootPath); std::vector<std::string> const& rdirs = this->GetRuntimeSearchPath(); for(std::vector<std::string>::const_iterator ri = rdirs.begin(); ri != rdirs.end(); ++ri) @@ -1909,14 +1907,9 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs, !cmSystemTools::IsSubDirectory(ri->c_str(), topSourceDir) && !cmSystemTools::IsSubDirectory(ri->c_str(), topBinaryDir)) { - std::string d = *ri; - if (d.find(rootPath) == 0) + if(emitted.insert(*ri).second) { - d = d.substr(rootPath.size()); - } - if(emitted.insert(d).second) - { - runtimeDirs.push_back(d); + runtimeDirs.push_back(*ri); } } } diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 8fd95b9..0829add 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -282,6 +282,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index, if(emitted.insert(*lib).second) { this->AddTargetDepend(depender_index, lib->c_str(), true); + this->AddInterfaceDepends(depender_index, lib->c_str(), + true, emitted); } } } diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 860417f..086f27a 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -12,6 +12,7 @@ #include "cmCoreTryCompile.h" #include "cmake.h" #include "cmCacheManager.h" +#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmExportTryCompileFileGenerator.h" #include <cmsys/Directory.hxx> @@ -32,18 +33,20 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) std::vector<std::string> compileDefs; std::string outputVariable; std::string copyFile; + std::string copyFileError; std::vector<cmTarget*> targets; std::string libsToLink = " "; bool useOldLinkLibs = true; char targetNameBuf[64]; bool didOutputVariable = false; bool didCopyFile = false; + bool didCopyFileError = false; bool useSources = argv[2] == "SOURCES"; std::vector<std::string> sources; enum Doing { DoingNone, DoingCMakeFlags, DoingCompileDefinitions, DoingLinkLibraries, DoingOutputVariable, DoingCopyFile, - DoingSources }; + DoingCopyFileError, DoingSources }; Doing doing = useSources? DoingSources : DoingNone; for(size_t i=3; i < argv.size(); ++i) { @@ -74,6 +77,11 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) doing = DoingCopyFile; didCopyFile = true; } + else if(argv[i] == "COPY_FILE_ERROR") + { + doing = DoingCopyFileError; + didCopyFileError = true; + } else if(doing == DoingCMakeFlags) { cmakeFlags.push_back(argv[i]); @@ -121,6 +129,11 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) copyFile = argv[i].c_str(); doing = DoingNone; } + else if(doing == DoingCopyFileError) + { + copyFileError = argv[i].c_str(); + doing = DoingNone; + } else if(doing == DoingSources) { sources.push_back(argv[i]); @@ -149,6 +162,20 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) return -1; } + if(didCopyFileError && copyFileError.empty()) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "COPY_FILE_ERROR must be followed by a variable name"); + return -1; + } + + if(didCopyFileError && !didCopyFile) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, + "COPY_FILE_ERROR may be used only with COPY_FILE"); + return -1; + } + if(didOutputVariable && outputVariable.empty()) { this->Makefile->IssueMessage(cmake::FATAL_ERROR, @@ -214,8 +241,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) } // Detect languages to enable. - cmGlobalGenerator* gg = - this->Makefile->GetCMakeInstance()->GetGlobalGenerator(); + cmLocalGenerator* lg = this->Makefile->GetLocalGenerator(); + cmGlobalGenerator* gg = lg->GetGlobalGenerator(); std::set<std::string> testLangs; for(std::vector<std::string>::iterator si = sources.begin(); si != sources.end(); ++si) @@ -295,13 +322,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) for(std::set<std::string>::iterator li = testLangs.begin(); li != testLangs.end(); ++li) { - fprintf(fout, "SET(CMAKE_%s_FLAGS \"", li->c_str()); std::string langFlags = "CMAKE_" + *li + "_FLAGS"; - if(const char* flags = this->Makefile->GetDefinition(langFlags.c_str())) - { - fprintf(fout, " %s ", flags); - } - fprintf(fout, " ${COMPILE_DEFINITIONS}\")\n"); + const char* flags = this->Makefile->GetDefinition(langFlags.c_str()); + fprintf(fout, "SET(CMAKE_%s_FLAGS %s)\n", li->c_str(), + lg->EscapeForCMake(flags?flags:"").c_str()); + fprintf(fout, "SET(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}" + " ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str()); } fprintf(fout, "INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES})\n"); fprintf(fout, "SET(CMAKE_SUPPRESS_REGENERATION 1)\n"); @@ -444,6 +470,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) if (this->SrcFileSignature) { + std::string copyFileErrorMessage; this->FindOutputFile(targetName); if ((res==0) && (copyFile.size())) @@ -461,10 +488,23 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) { emsg << this->FindErrorMessage.c_str(); } - this->Makefile->IssueMessage(cmake::FATAL_ERROR, emsg.str()); - return -1; + if(copyFileError.empty()) + { + this->Makefile->IssueMessage(cmake::FATAL_ERROR, emsg.str()); + return -1; + } + else + { + copyFileErrorMessage = emsg.str(); + } } } + + if(!copyFileError.empty()) + { + this->Makefile->AddDefinition(copyFileError.c_str(), + copyFileErrorMessage.c_str()); + } } return res; } diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 0a78ccf..fcaa169 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -514,6 +514,13 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "analysis of libraries linked by a target.", false, "Variables that Provide Information"); + cm->DefineProperty + ("CMAKE_MINIMUM_REQUIRED_VERSION", cmProperty::VARIABLE, + "Version specified to cmake_minimum_required command", + "Variable containing the VERSION component specified in the " + "cmake_minimum_required command.", + false, + "Variables that Provide Information"); // Variables defined by cmake, that change the behavior @@ -561,16 +568,6 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables That Change Behavior"); cm->DefineProperty - ("CMAKE_SYSROOT", cmProperty::VARIABLE, - "Path to pass to the compiler in the --sysroot flag.", - "The CMAKE_SYSROOT content is passed to the compiler in the --sysroot " - "flag, if supported. The path is also stripped from the RPATH if " - "necessary on installation. The CMAKE_SYSROOT is also used to prefix " - "paths searched by the find_* commands.", - false, - "Variables That Change Behavior"); - - cm->DefineProperty ("CMAKE_FIND_LIBRARY_PREFIXES", cmProperty::VARIABLE, "Prefixes to prepend when looking for libraries.", "This specifies what prefixes to add to library names when " @@ -688,6 +685,23 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "Variables That Change Behavior"); cm->DefineProperty + ("CMAKE_WARN_DEPRECATED", cmProperty::VARIABLE, + "Whether to issue deprecation warnings for macros and functions.", + "If TRUE, this can be used by macros and functions to issue " + "deprecation warnings. This variable is FALSE by default.", + false, + "Variables That Change Behavior"); + + cm->DefineProperty + ("CMAKE_ERROR_DEPRECATED", cmProperty::VARIABLE, + "Whether to issue deprecation errors for macros and functions.", + "If TRUE, this can be used by macros and functions to issue " + "fatal errors when deprecated macros or functions are used. This " + "variable is FALSE by default.", + false, + "Variables That Change Behavior"); + + cm->DefineProperty ("CMAKE_PREFIX_PATH", cmProperty::VARIABLE, "Path used for searching by FIND_XXX(), with appropriate suffixes added.", "Specifies a path which will be used by the FIND_XXX() commands. It " diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 560882e..ce7afc5 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -127,6 +127,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateIncludeDirectoriesInterface(te, cmGeneratorExpression::InstallInterface, properties, missingTargets); + this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", + te, + cmGeneratorExpression::InstallInterface, + properties, missingTargets); this->PopulateInterfaceProperty("INTERFACE_COMPILE_DEFINITIONS", te, cmGeneratorExpression::InstallInterface, diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index f6f4cef..dfbb1c0 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -621,19 +621,15 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout, ->GetGeneratorTarget(target); // the compilerdefines for this target - std::string cdefs = target->GetCompileDefinitions(buildType); + std::vector<std::string> cdefs; + target->GetCompileDefinitions(cdefs, buildType); - if(!cdefs.empty()) + // Expand the list. + for(std::vector<std::string>::const_iterator di = cdefs.begin(); + di != cdefs.end(); ++di) { - // Expand the list. - std::vector<std::string> defs; - cmSystemTools::ExpandListArgument(cdefs.c_str(), defs); - for(std::vector<std::string>::const_iterator di = defs.begin(); - di != defs.end(); ++di) - { - cmXMLSafe safedef(di->c_str()); - fout <<" <Add option=\"-D" << safedef.str() << "\" />\n"; - } + cmXMLSafe safedef(di->c_str()); + fout <<" <Add option=\"-D" << safedef.str() << "\" />\n"; } // the include directories for this target diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 012013c..523fca9 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -421,7 +421,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source, std::vector<std::string> includes; lg->GetIncludeDirectories(includes, gtgt, language, config); std::string includeFlags = - lg->GetIncludeFlags(includes, language, true); // full include paths + lg->GetIncludeFlags(includes, gtgt, language, true); // full include paths lg->AppendFlags(flags, includeFlags.c_str()); } @@ -463,7 +463,7 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target, } // Add preprocessor definitions for this target and configuration. - lg->AppendDefines(defines, target->GetCompileDefinitions(config)); + lg->AddCompileDefinitions(defines, target, config); lg->AppendDefines(defines, source->GetProperty("COMPILE_DEFINITIONS")); { std::string defPropName = "COMPILE_DEFINITIONS_"; diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 5daa47d..b44864e 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -62,15 +62,10 @@ void cmFindCommon::GenerateDocumentation() "The CMake variable CMAKE_FIND_ROOT_PATH specifies one or more " "directories to be prepended to all other search directories. " "This effectively \"re-roots\" the entire search under given locations. " - "By default it is empty. " - "The variable CMAKE_SYSROOT can also be used to specify exactly one " - "directory to use as a prefix. Setting CMAKE_SYSROOT also has other " - "effects. See the documentation for that variable for more. " - "These are especially useful when " + "By default it is empty. It is especially useful when " "cross-compiling to point to the root directory of the " "target environment and CMake will search there too. By default at first " - "the CMAKE_SYSROOT directory is searched, then the directories listed in " - "CMAKE_FIND_ROOT_PATH and then the non-rooted " + "the directories listed in CMAKE_FIND_ROOT_PATH and then the non-rooted " "directories will be searched. " "The default behavior can be adjusted by setting " "CMAKE_FIND_ROOT_PATH_MODE_XXX. This behavior can be manually " @@ -192,27 +187,16 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths) { return; } - const char* sysroot = - this->Makefile->GetDefinition("CMAKE_SYSROOT"); const char* rootPath = this->Makefile->GetDefinition("CMAKE_FIND_ROOT_PATH"); - const bool noSysroot = !sysroot || !*sysroot; - const bool noRootPath = !rootPath || !*rootPath; - if(noSysroot && noRootPath) + if((rootPath == 0) || (strlen(rootPath) == 0)) { return; } // Construct the list of path roots with no trailing slashes. std::vector<std::string> roots; - if (sysroot) - { - roots.push_back(sysroot); - } - if (rootPath) - { - cmSystemTools::ExpandListArgument(rootPath, roots); - } + cmSystemTools::ExpandListArgument(rootPath, roots); for(std::vector<std::string>::iterator ri = roots.begin(); ri != roots.end(); ++ri) { diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 8b17c37..92dc054 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -187,6 +187,14 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingIncludeDirectories() const } //---------------------------------------------------------------------------- +bool +cmGeneratorExpressionDAGChecker::EvaluatingSystemIncludeDirectories() const +{ + const char *prop = this->Property.c_str(); + return strcmp(prop, "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES") == 0; +} + +//---------------------------------------------------------------------------- bool cmGeneratorExpressionDAGChecker::EvaluatingCompileDefinitions() const { const char *prop = this->Property.c_str(); diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 06b23f9..0b7ef02 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -18,11 +18,13 @@ #define CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(F) \ F(EvaluatingIncludeDirectories) \ + F(EvaluatingSystemIncludeDirectories) \ F(EvaluatingCompileDefinitions) \ F(EvaluatingCompileOptions) #define CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(F) \ F(INTERFACE_INCLUDE_DIRECTORIES) \ + F(INTERFACE_SYSTEM_INCLUDE_DIRECTORIES) \ F(INTERFACE_COMPILE_DEFINITIONS) \ F(INTERFACE_COMPILE_OPTIONS) diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 08d9d03..381ef7c 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -897,6 +897,10 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { interfacePropertyName = "INTERFACE_INCLUDE_DIRECTORIES"; } + else if (propertyName == "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES") + { + interfacePropertyName = "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES"; + } else if (propertyName == "INTERFACE_COMPILE_DEFINITIONS" || propertyName == "COMPILE_DEFINITIONS" || strncmp(propertyName.c_str(), "COMPILE_DEFINITIONS_", 20) == 0) @@ -1033,10 +1037,13 @@ static const struct TargetNameNode : public cmGeneratorExpressionNode //---------------------------------------------------------------------------- static const char* targetPolicyWhitelist[] = { - "CMP0003" - , "CMP0004" - , "CMP0008" - , "CMP0020" + 0 +#define TARGET_POLICY_STRING(POLICY) \ + , #POLICY + + CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_STRING) + +#undef TARGET_POLICY_STRING }; cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy) @@ -1047,10 +1054,7 @@ cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy) return tgt->GetPolicyStatus ## POLICY (); \ } \ - RETURN_POLICY(CMP0003) - RETURN_POLICY(CMP0004) - RETURN_POLICY(CMP0008) - RETURN_POLICY(CMP0020) + CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY) #undef RETURN_POLICY @@ -1066,10 +1070,7 @@ cmPolicies::PolicyID policyForString(const char *policy_id) return cmPolicies:: POLICY_ID; \ } \ - RETURN_POLICY_ID(CMP0003) - RETURN_POLICY_ID(CMP0004) - RETURN_POLICY_ID(CMP0008) - RETURN_POLICY_ID(CMP0020) + CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY_ID) #undef RETURN_POLICY_ID @@ -1099,7 +1100,7 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode context->HadContextSensitiveCondition = true; - for (size_t i = 0; + for (size_t i = 1; i < (sizeof(targetPolicyWhitelist) / sizeof(*targetPolicyWhitelist)); ++i) @@ -1125,8 +1126,17 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode } reportError(context, content->GetOriginalExpression(), "$<TARGET_POLICY:prop> may only be used with a limited number of " - "policies. Currently it may be used with policies CMP0003, CMP0004, " - "CMP0008 and CMP0020." + "policies. Currently it may be used with the following policies:\n" + +#define STRINGIFY_HELPER(X) #X +#define STRINGIFY(X) STRINGIFY_HELPER(X) + +#define TARGET_POLICY_LIST_ITEM(POLICY) \ + " * " STRINGIFY(POLICY) "\n" + + CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_LIST_ITEM) + +#undef TARGET_POLICY_LIST_ITEM ); return std::string(); } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f5d1560..5ce0e6b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -48,6 +48,51 @@ const char *cmGeneratorTarget::GetProperty(const char *prop) } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir, + const char *config) +{ + std::string config_upper; + if(config && *config) + { + config_upper = cmSystemTools::UpperCase(config); + } + + typedef std::map<std::string, std::vector<std::string> > IncludeCacheType; + IncludeCacheType::iterator iter = + this->SystemIncludesCache.find(config_upper); + + if (iter == this->SystemIncludesCache.end()) + { + std::vector<std::string> result; + for (std::set<cmStdString>::const_iterator + it = this->Target->GetSystemIncludeDirectories().begin(); + it != this->Target->GetSystemIncludeDirectories().end(); ++it) + { + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + + cmGeneratorExpressionDAGChecker dagChecker(lfbt, + this->GetName(), + "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", 0, 0); + + cmSystemTools::ExpandListArgument(ge.Parse(*it) + ->Evaluate(this->Makefile, + config, false, this->Target, + &dagChecker), result); + } + IncludeCacheType::value_type entry(config_upper, result); + iter = this->SystemIncludesCache.insert(entry).first; + } + + if (std::find(iter->second.begin(), + iter->second.end(), dir) != iter->second.end()) + { + return true; + } + return false; +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::GetPropertyAsBool(const char *prop) { return this->Target->GetPropertyAsBool(prop); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 5f7019d..dedfa60 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -72,10 +72,14 @@ public: /** Get the include directories for this target. */ std::vector<std::string> GetIncludeDirectories(const char *config); + bool IsSystemIncludeDirectory(const char *dir, const char *config); + private: void ClassifySources(); void LookupObjectLibraries(); + std::map<std::string, std::vector<std::string> > SystemIncludesCache; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ad74767..9b6ac93 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -892,12 +892,28 @@ void cmGlobalGenerator::Configure() if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE) { - const char* msg = "Configuring done"; + cmOStringStream msg; if(cmSystemTools::GetErrorOccuredFlag()) { - msg = "Configuring incomplete, errors occurred!"; + msg << "Configuring incomplete, errors occurred!"; + const char* logs[] = {"CMakeOutput.log", "CMakeError.log", 0}; + for(const char** log = logs; *log; ++log) + { + std::string f = this->CMakeInstance->GetHomeOutputDirectory(); + f += this->CMakeInstance->GetCMakeFilesDirectory(); + f += "/"; + f += *log; + if(cmSystemTools::FileExists(f.c_str())) + { + msg << "\nSee also \"" << f << "\"."; + } + } + } + else + { + msg << "Configuring done"; } - this->CMakeInstance->UpdateProgress(msg, -1); + this->CMakeInstance->UpdateProgress(msg.str().c_str(), -1); } } @@ -1001,6 +1017,17 @@ void cmGlobalGenerator::Generate() // it builds by default. this->FillLocalGeneratorToTargetMap(); + for (i = 0; i < this->LocalGenerators.size(); ++i) + { + cmMakefile* mf = this->LocalGenerators[i]->GetMakefile(); + cmTargets* targets = &(mf->GetTargets()); + for ( cmTargets::iterator it = targets->begin(); + it != targets->end(); ++ it ) + { + it->second.FinalizeSystemIncludeDirectories(); + } + } + // Generate project files for (i = 0; i < this->LocalGenerators.size(); ++i) { @@ -1121,8 +1148,9 @@ void cmGlobalGenerator::CreateGeneratorTargets() cmGeneratorTargetsType generatorTargets; cmMakefile *mf = this->LocalGenerators[i]->GetMakefile(); - const char *noconfig_compile_definitions = - mf->GetProperty("COMPILE_DEFINITIONS"); + + const std::vector<cmValueWithOrigin> noconfig_compile_definitions = + mf->GetCompileDefinitionsEntries(); std::vector<std::string> configs; mf->GetConfigurations(configs); @@ -1134,7 +1162,13 @@ void cmGlobalGenerator::CreateGeneratorTargets() cmTarget* t = &ti->second; { - t->AppendProperty("COMPILE_DEFINITIONS", noconfig_compile_definitions); + for (std::vector<cmValueWithOrigin>::const_iterator it + = noconfig_compile_definitions.begin(); + it != noconfig_compile_definitions.end(); ++it) + { + t->InsertCompileDefinition(*it); + } + for(std::vector<std::string>::const_iterator ci = configs.begin(); ci != configs.end(); ++ci) { diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 9cfbe42..63de1a5 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1741,8 +1741,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->AppendDefines(ppDefs, exportMacro); } cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); - this->AppendDefines(ppDefs, - target.GetCompileDefinitions(configName).c_str()); + std::vector<std::string> targetDefines; + target.GetCompileDefinitions(targetDefines, configName); + this->AppendDefines(ppDefs, targetDefines); buildSettings->AddAttribute ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList()); diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index 76a60cf..34a9c7c 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -165,6 +165,11 @@ void cmIDEOptions::AddDefines(const char* defines) cmSystemTools::ExpandListArgument(defines, this->Defines); } } +//---------------------------------------------------------------------------- +void cmIDEOptions::AddDefines(const std::vector<std::string> &defines) +{ + this->Defines.insert(this->Defines.end(), defines.begin(), defines.end()); +} //---------------------------------------------------------------------------- void cmIDEOptions::AddFlag(const char* flag, const char* value) diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h index e556bde..e78af3e 100644 --- a/Source/cmIDEOptions.h +++ b/Source/cmIDEOptions.h @@ -27,6 +27,7 @@ public: // Store definitions and flags. void AddDefine(const std::string& define); void AddDefines(const char* defines); + void AddDefines(const std::vector<std::string> &defines); void AddFlag(const char* flag, const char* value); void RemoveFlag(const char* flag); const char* GetFlag(const char* flag); diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h index c46c02d..d97b7c3 100644 --- a/Source/cmIncludeCommand.h +++ b/Source/cmIncludeCommand.h @@ -55,7 +55,7 @@ public: */ virtual const char* GetTerseDocumentation() const { - return "Read CMake listfile code from the given file."; + return "Load and run CMake code from a file or module."; } /** @@ -66,9 +66,10 @@ public: return " include(<file|module> [OPTIONAL] [RESULT_VARIABLE <VAR>]\n" " [NO_POLICY_SCOPE])\n" - "Reads CMake listfile code from the given file. Commands in the file " - "are processed immediately as if they were written in place of the " - "include command. If OPTIONAL is present, then no error " + "Load and run CMake code from the file given. " + "Variable reads and writes access the scope of the caller " + "(dynamic scoping). " + "If OPTIONAL is present, then no error " "is raised if the file does not exist. If RESULT_VARIABLE is given " "the variable will be set to the full filename which " "has been included or NOTFOUND if it failed.\n" diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 00846d5..4e871d6 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -55,7 +55,6 @@ cmLocalGenerator::cmLocalGenerator() this->UseRelativePaths = false; this->Configured = false; this->EmitUniversalBinaryFlags = true; - this->IsMakefileGenerator = false; this->RelativePathsConfigured = false; this->PathConversionsSetup = false; this->BackwardsCompatibility = 0; @@ -260,12 +259,7 @@ void cmLocalGenerator::TraceDependencies() cmTargets& targets = this->Makefile->GetTargets(); for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t) { - const char* projectFilename = 0; - if (this->IsMakefileGenerator == false) // only use of this variable - { - projectFilename = t->second.GetName(); - } - t->second.TraceDependencies(projectFilename); + t->second.TraceDependencies(); } } @@ -577,7 +571,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname, { std::vector<std::string> includes; this->GetIncludeDirectories(includes, &target, lang); - flags += this->GetIncludeFlags(includes, lang); + flags += this->GetIncludeFlags(includes, &target, lang); } flags += this->Makefile->GetDefineFlags(); @@ -1224,6 +1218,7 @@ cmLocalGenerator::ConvertToIncludeReference(std::string const& path) //---------------------------------------------------------------------------- std::string cmLocalGenerator::GetIncludeFlags( const std::vector<std::string> &includes, + cmGeneratorTarget* target, const char* lang, bool forResponseFile, const char *config) { @@ -1294,11 +1289,10 @@ std::string cmLocalGenerator::GetIncludeFlags( continue; } - std::string include = *i; if(!flagUsed || repeatFlag) { - if(sysIncludeFlag && - this->Makefile->IsSystemIncludeDirectory(i->c_str(), config)) + if(sysIncludeFlag && target && + target->IsSystemIncludeDirectory(i->c_str(), config)) { includeFlags << sysIncludeFlag; } @@ -1339,6 +1333,17 @@ std::string cmLocalGenerator::GetIncludeFlags( } //---------------------------------------------------------------------------- +void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines, + cmTarget* target, + const char* config) +{ + std::vector<std::string> targetDefines; + target->GetCompileDefinitions(targetDefines, + config); + this->AppendDefines(defines, targetDefines); +} + +//---------------------------------------------------------------------------- void cmLocalGenerator::AddCompileOptions( std::string& flags, cmTarget* target, const char* lang, const char* config @@ -1467,8 +1472,6 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, return; } - std::string rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); - std::vector<std::string> implicitDirs; // Load implicit include directories for this language. std::string impDirVar = "CMAKE_"; @@ -1481,9 +1484,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, for(std::vector<std::string>::const_iterator i = impDirVec.begin(); i != impDirVec.end(); ++i) { - std::string d = rootPath + *i; - cmSystemTools::ConvertToUnixSlashes(d); - emitted.insert(d); + emitted.insert(*i); if (!stripImplicitInclDirs) { implicitDirs.push_back(*i); @@ -2301,7 +2302,13 @@ void cmLocalGenerator::AppendDefines(std::set<std::string>& defines, // Expand the list of definitions. std::vector<std::string> defines_vec; cmSystemTools::ExpandListArgument(defines_list, defines_vec); + this->AppendDefines(defines, defines_vec); +} +//---------------------------------------------------------------------------- +void cmLocalGenerator::AppendDefines(std::set<std::string>& defines, + const std::vector<std::string> &defines_vec) +{ for(std::vector<std::string>::const_iterator di = defines_vec.begin(); di != defines_vec.end(); ++di) { diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index f35ef8e..ed0f6e3 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -152,6 +152,7 @@ public: virtual void AppendFlagEscape(std::string& flags, const char* rawFlag); ///! Get the include flags for the current makefile and language std::string GetIncludeFlags(const std::vector<std::string> &includes, + cmGeneratorTarget* target, const char* lang, bool forResponseFile = false, const char *config = 0); @@ -166,6 +167,9 @@ public: { this->AppendDefines(defines, defines_list.c_str()); } + void AppendDefines(std::set<std::string>& defines, + const std::vector<std::string> &defines_vec); + /** * Join a set of defines into a definesString with a space separator. */ @@ -220,6 +224,8 @@ public: bool stripImplicitInclDirs = true); void AddCompileOptions(std::string& flags, cmTarget* target, const char* lang, const char* config); + void AddCompileDefinitions(std::set<std::string>& defines, cmTarget* target, + const char* config); /** Compute the language used to compile the given source file. */ const char* GetSourceFileLanguage(const cmSourceFile& source); @@ -435,8 +441,6 @@ protected: bool IgnoreLibPrefix; bool Configured; bool EmitUniversalBinaryFlags; - // A type flag is not nice. It's used only in TraceDependencies(). - bool IsMakefileGenerator; // Hack for ExpandRuleVariable until object-oriented version is // committed. std::string TargetImplib; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index bdc3d80..a522e37 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -27,7 +27,6 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator() , ConfigName("") , HomeRelativeOutputPath("") { - this->IsMakefileGenerator = true; #ifdef _WIN32 this->WindowsShell = true; #endif diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 78a70f8..56da1f9 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -92,7 +92,6 @@ cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3() this->SkipPreprocessedSourceRules = false; this->SkipAssemblySourceRules = false; this->MakeCommandEscapeTargetTwice = false; - this->IsMakefileGenerator = true; this->BorlandMakeCurlyHack = false; } @@ -1962,8 +1961,8 @@ void cmLocalUnixMakefileGenerator3 // Build a list of preprocessor definitions for the target. std::set<std::string> defines; - this->AppendDefines(defines, target.GetCompileDefinitions( - this->ConfigurationName.c_str())); + this->AddCompileDefinitions(defines, &target, + this->ConfigurationName.c_str()); if(!defines.empty()) { cmakefileStream diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 0b61e1d..df6e1f1 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1701,21 +1701,11 @@ void cmLocalVisualStudio6Generator std::set<std::string> minsizeDefinesSet; std::set<std::string> debugrelDefinesSet; - this->AppendDefines( - definesSet, - target.GetCompileDefinitions(0)); - this->AppendDefines( - debugDefinesSet, - target.GetCompileDefinitions("DEBUG")); - this->AppendDefines( - releaseDefinesSet, - target.GetCompileDefinitions("RELEASE")); - this->AppendDefines( - minsizeDefinesSet, - target.GetCompileDefinitions("MINSIZEREL")); - this->AppendDefines( - debugrelDefinesSet, - target.GetCompileDefinitions("RELWITHDEBINFO")); + this->AddCompileDefinitions(definesSet, &target, 0); + this->AddCompileDefinitions(debugDefinesSet, &target, "DEBUG"); + this->AddCompileDefinitions(releaseDefinesSet, &target, "RELEASE"); + this->AddCompileDefinitions(minsizeDefinesSet, &target, "MINSIZEREL"); + this->AddCompileDefinitions(debugrelDefinesSet, &target, "RELWITHDEBINFO"); std::string defines = " "; std::string debugDefines = " "; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 1d2f709..9ecd53d 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -746,7 +746,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.ParseFinish(); cmGeneratorTarget* gt = this->GlobalGenerator->GetGeneratorTarget(&target); - targetOptions.AddDefines(target.GetCompileDefinitions(configName).c_str()); + std::vector<std::string> targetDefines; + target.GetCompileDefinitions(targetDefines, configName); + targetOptions.AddDefines(targetDefines); targetOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f3a66ba..818a580 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1505,6 +1505,12 @@ void cmMakefile::InitializeFromParent() parentOptions.begin(), parentOptions.end()); + const std::vector<cmValueWithOrigin> parentDefines = + parent->GetCompileDefinitionsEntries(); + this->CompileDefinitionsEntries.insert(this->CompileDefinitionsEntries.end(), + parentDefines.begin(), + parentDefines.end()); + this->SystemIncludeDirectories = parent->SystemIncludeDirectories; // define flags @@ -1675,27 +1681,13 @@ cmMakefile::AddSystemIncludeDirectories(const std::set<cmStdString> &incs) { this->SystemIncludeDirectories.insert(*li); } -} -//---------------------------------------------------------------------------- -bool cmMakefile::IsSystemIncludeDirectory(const char* dir, const char *config) -{ - for (std::set<cmStdString>::const_iterator - it = this->SystemIncludeDirectories.begin(); - it != this->SystemIncludeDirectories.end(); ++it) + for (cmTargets::iterator l = this->Targets.begin(); + l != this->Targets.end(); ++l) { - cmListFileBacktrace lfbt; - cmGeneratorExpression ge(lfbt); - - std::vector<std::string> incs; - cmSystemTools::ExpandListArgument(ge.Parse(*it) - ->Evaluate(this, config, false), incs); - if (std::find(incs.begin(), incs.end(), dir) != incs.end()) - { - return true; - } + cmTarget &t = l->second; + t.AddSystemIncludeDirectories(incs); } - return false; } void cmMakefile::AddDefinition(const char* name, const char* value) @@ -3493,6 +3485,19 @@ void cmMakefile::SetProperty(const char* prop, const char* value) this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt)); return; } + if (propname == "COMPILE_DEFINITIONS") + { + this->CompileDefinitionsEntries.clear(); + if (!value) + { + return; + } + cmListFileBacktrace lfbt; + this->GetBacktrace(lfbt); + cmValueWithOrigin entry(value, lfbt); + this->CompileDefinitionsEntries.push_back(entry); + return; + } if ( propname == "INCLUDE_REGULAR_EXPRESSION" ) { @@ -3540,6 +3545,14 @@ void cmMakefile::AppendProperty(const char* prop, const char* value, cmValueWithOrigin(value, lfbt)); return; } + if (propname == "COMPILE_DEFINITIONS") + { + cmListFileBacktrace lfbt; + this->GetBacktrace(lfbt); + this->CompileDefinitionsEntries.push_back( + cmValueWithOrigin(value, lfbt)); + return; + } if ( propname == "LINK_DIRECTORIES" ) { std::vector<std::string> varArgsExpanded; @@ -3679,6 +3692,20 @@ const char *cmMakefile::GetProperty(const char* prop, } return output.c_str(); } + else if (!strcmp("COMPILE_DEFINITIONS",prop)) + { + std::string sep; + for (std::vector<cmValueWithOrigin>::const_iterator + it = this->CompileDefinitionsEntries.begin(), + end = this->CompileDefinitionsEntries.end(); + it != end; ++it) + { + output += sep; + output += it->Value; + sep = ";"; + } + return output.c_str(); + } bool chain = false; const char *retVal = diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 4297155..871fa1b 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -871,10 +871,17 @@ public: { return this->CompileOptionsEntries; } + std::vector<cmValueWithOrigin> GetCompileDefinitionsEntries() const + { + return this->CompileDefinitionsEntries; + } bool IsGeneratingBuildSystem(){ return this->GeneratingBuildSystem; } void SetGeneratingBuildSystem(){ this->GeneratingBuildSystem = true; } + std::set<cmStdString> const & GetSystemIncludeDirectories() const + { return this->SystemIncludeDirectories; } + protected: // add link libraries and directories to the target void AddGlobalLinkInformation(const char* name, cmTarget& target); @@ -925,6 +932,7 @@ protected: std::vector<cmValueWithOrigin> IncludeDirectoriesEntries; std::vector<cmValueWithOrigin> CompileOptionsEntries; + std::vector<cmValueWithOrigin> CompileDefinitionsEntries; // Track the value of the computed DEFINITIONS property. void AddDefineFlag(const char*, std::string&); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 271183e..e4219a9 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -365,22 +365,6 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) vars.TargetVersionMajor = targetVersionMajor.c_str(); vars.TargetVersionMinor = targetVersionMinor.c_str(); - if (const char *rootPath = - this->Makefile->GetDefinition("CMAKE_SYSROOT")) - { - if (*rootPath) - { - if (const char *sysrootFlag = - this->Makefile->GetDefinition("CMAKE_SYSROOT_FLAG")) - { - flags += " "; - flags += sysrootFlag; - flags += this->LocalGenerator->EscapeForShell(rootPath); - flags += " "; - } - } - } - vars.LinkLibraries = linkLibs.c_str(); vars.Flags = flags.c_str(); vars.LinkFlags = linkFlags.c_str(); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 36d1a5a..347f26d 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -589,26 +589,6 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules cmLocalGenerator::SHELL); vars.ObjectDir = objdir.c_str(); vars.Target = targetOutPathReal.c_str(); - - if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) - { - if (const char *rootPath = - this->Makefile->GetSafeDefinition("CMAKE_SYSROOT")) - { - if (*rootPath) - { - if (const char *sysrootFlag = - this->Makefile->GetDefinition("CMAKE_SYSROOT_FLAG")) - { - linkFlags += " "; - linkFlags += sysrootFlag; - linkFlags += this->LocalGenerator->EscapeForShell(rootPath); - linkFlags += " "; - } - } - } - } - vars.LinkLibraries = linkLibs.c_str(); vars.ObjectsQuoted = buildObjs.c_str(); if (this->Target->HasSOName(this->ConfigName)) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1492dfa..0829cab 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -309,9 +309,8 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l) } // Add preprocessor definitions for this target and configuration. - this->LocalGenerator->AppendDefines - (defines, this->Target->GetCompileDefinitions( - this->LocalGenerator->ConfigurationName.c_str())); + this->LocalGenerator->AddCompileDefinitions(defines, this->Target, + this->LocalGenerator->ConfigurationName.c_str()); std::string definesString; this->LocalGenerator->JoinDefines(defines, definesString, lang); @@ -644,23 +643,6 @@ cmMakefileTargetGenerator cmLocalGenerator::START_OUTPUT, cmLocalGenerator::SHELL); vars.ObjectDir = objectDir.c_str(); - - if (const char *rootPath = - this->Makefile->GetSafeDefinition("CMAKE_SYSROOT")) - { - if (*rootPath) - { - if (const char *sysrootFlag = - this->Makefile->GetDefinition("CMAKE_SYSROOT_FLAG")) - { - flags += " "; - flags += sysrootFlag; - flags += this->LocalGenerator->EscapeForShell(rootPath); - flags += " "; - } - } - } - vars.Flags = flags.c_str(); std::string definesString = "$("; @@ -1853,7 +1835,8 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags, lang, config); std::string includeFlags = - this->LocalGenerator->GetIncludeFlags(includes, lang, useResponseFile); + this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget, + lang, useResponseFile); if(includeFlags.empty()) { return; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 921ca92..fa7e396 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -224,27 +224,7 @@ cmNinjaNormalTargetGenerator vars.TargetVersionMajor = targetVersionMajor.c_str(); vars.TargetVersionMinor = targetVersionMinor.c_str(); - - std::string flags = "$FLAGS"; - - if (const char *rootPath = - this->GetMakefile()->GetSafeDefinition("CMAKE_SYSROOT")) - { - if (*rootPath) - { - if (const char *sysrootFlag = - this->GetMakefile()->GetDefinition("CMAKE_SYSROOT_FLAG")) - { - flags += " "; - flags += sysrootFlag; - flags += this->GetLocalGenerator()->EscapeForShell(rootPath); - flags += " "; - } - } - } - - vars.Flags = flags.c_str(); - + vars.Flags = "$FLAGS"; vars.LinkFlags = "$LINK_FLAGS"; std::string langFlags; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 65173ca..898aa0e 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -161,7 +161,8 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, this->GeneratorTarget, language.c_str(), config); std::string includeFlags = - this->LocalGenerator->GetIncludeFlags(includes, language.c_str(), + this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget, + language.c_str(), language == "RC" ? true : false); // full include paths for RC // needed by cmcldeps if(cmGlobalNinjaGenerator::IsMinGW()) @@ -201,9 +202,8 @@ ComputeDefines(cmSourceFile *source, const std::string& language) } // Add preprocessor definitions for this target and configuration. - this->LocalGenerator->AppendDefines - (defines, - this->Target->GetCompileDefinitions(this->GetConfigName())); + this->LocalGenerator->AddCompileDefinitions(defines, this->Target, + this->GetConfigName()); this->LocalGenerator->AppendDefines (defines, source->GetProperty("COMPILE_DEFINITIONS")); @@ -384,23 +384,7 @@ cmNinjaTargetGenerator cmSystemTools::ReplaceString(depFlagsStr, "<CMAKE_C_COMPILER>", mf->GetDefinition("CMAKE_C_COMPILER")); flags += " " + depFlagsStr; - - if (const char *rootPath = - this->Makefile->GetSafeDefinition("CMAKE_SYSROOT")) - { - if (*rootPath) - { - if (const char *sysrootFlag = - this->Makefile->GetDefinition("CMAKE_SYSROOT_FLAG")) - { - flags += " "; - flags += sysrootFlag; - flags += this->LocalGenerator->EscapeForShell(rootPath); - flags += " "; - } - } - } - } + } vars.Flags = flags.c_str(); diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 15303c8..70c28d4 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -563,7 +563,11 @@ cmPolicies::cmPolicies() "INTERFACE_LINK_LIBRARIES property will be processed and generated for " "the IMPORTED target by default. A new option to the install(EXPORT) " "and export commands allows export of the old-style properties for " - "compatibility with downstream users of CMake versions older than 2.8.12." + "compatibility with downstream users of CMake versions older than " + "2.8.12. " + "The target_link_libraries command will no longer populate the " + "properties matching LINK_INTERFACE_LIBRARIES(_<CONFIG>)? if this policy " + "is NEW." "\n" "The OLD behavior for this policy is to ignore the " "INTERFACE_LINK_LIBRARIES property for in-build targets. " diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h index a53cb3f..9547c4c 100644 --- a/Source/cmProjectCommand.h +++ b/Source/cmProjectCommand.h @@ -71,7 +71,13 @@ public: "language \"NONE\" all checks for any language can be disabled. " "If a variable exists called CMAKE_PROJECT_<projectName>_INCLUDE, " "the file pointed to by that variable will be included as the last step " - "of the project command."; + "of the project command." + "\n" + "The top-level CMakeLists.txt file for a project must contain a " + "literal, direct call to the project() command; loading one through " + "the include() command is not sufficient. " + "If no such call exists CMake will implicitly add one to the top that " + "enables the default languages (C and CXX)."; } cmTypeMacro(cmProjectCommand, cmCommand); diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index 34b3c7e..93e39ab 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -175,15 +175,17 @@ static void GetCompileDefinitionsAndDirectories(cmTarget *target, incs += *incDirIt; } - defs = target->GetCompileDefinitions(config); + std::set<std::string> defines; + localGen->AddCompileDefinitions(defines, target, config); - const char *tmp = makefile->GetProperty("COMPILE_DEFINITIONS"); sep = ""; - if (tmp) + for(std::set<std::string>::const_iterator defIt = defines.begin(); + defIt != defines.end(); + ++defIt) { defs += sep; sep = ";"; - defs += tmp; + defs += *defIt; } } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index aa5fc94..c52c266 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1696,6 +1696,7 @@ cmSystemTools::SaveRestoreEnvironment::~SaveRestoreEnvironment() void cmSystemTools::EnableVSConsoleOutput() { +#ifdef _WIN32 // Visual Studio 8 2005 (devenv.exe or VCExpress.exe) will not // display output to the console unless this environment variable is // set. We need it to capture the output of these build tools. @@ -1703,8 +1704,15 @@ void cmSystemTools::EnableVSConsoleOutput() // either of these executables where NAME is created with // CreateNamedPipe. This would bypass the internal buffering of the // output and allow it to be captured on the fly. -#ifdef _WIN32 cmSystemTools::PutEnv("vsconsoleoutput=1"); + +# ifdef CMAKE_BUILD_WITH_CMAKE + // VS sets an environment variable to tell MS tools like "cl" to report + // output through a backdoor pipe instead of stdout/stderr. Unset the + // environment variable to close this backdoor for any path of process + // invocations that passes through CMake so we can capture the output. + cmSystemTools::UnsetEnv("VS_UNICODE_OUTPUT"); +# endif #endif } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index f08399f..70500cd 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -141,13 +141,15 @@ public: }; std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries; std::vector<TargetPropertyEntry*> CompileOptionsEntries; + std::vector<TargetPropertyEntry*> CompileDefinitionsEntries; std::vector<cmValueWithOrigin> LinkInterfacePropertyEntries; std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceIncludeDirectoriesEntries; std::map<std::string, std::vector<TargetPropertyEntry*> > CachedLinkInterfaceCompileOptionsEntries; - std::map<std::string, std::string> CachedLinkInterfaceCompileDefinitions; + std::map<std::string, std::vector<TargetPropertyEntry*> > + CachedLinkInterfaceCompileDefinitionsEntries; std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone; std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone; @@ -186,18 +188,20 @@ cmTargetInternals::~cmTargetInternals() { deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries); deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries); + deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries); } //---------------------------------------------------------------------------- cmTarget::cmTarget() { +#define INITIALIZE_TARGET_POLICY_MEMBER(POLICY) \ + this->PolicyStatus ## POLICY = cmPolicies::WARN; + + CM_FOR_EACH_TARGET_POLICY(INITIALIZE_TARGET_POLICY_MEMBER) + +#undef INITIALIZE_TARGET_POLICY_MEMBER + this->Makefile = 0; - this->PolicyStatusCMP0003 = cmPolicies::WARN; - this->PolicyStatusCMP0004 = cmPolicies::WARN; - this->PolicyStatusCMP0008 = cmPolicies::WARN; - this->PolicyStatusCMP0020 = cmPolicies::WARN; - this->PolicyStatusCMP0021 = cmPolicies::WARN; - this->PolicyStatusCMP0022 = cmPolicies::WARN; this->LinkLibrariesAnalyzed = false; this->HaveInstallRule = false; this->DLLPlatform = false; @@ -206,6 +210,7 @@ cmTarget::cmTarget() this->BuildInterfaceIncludesAppended = false; this->DebugIncludesDone = false; this->DebugCompileOptionsDone = false; + this->DebugCompileDefinitionsDone = false; } //---------------------------------------------------------------------------- @@ -869,6 +874,17 @@ void cmTarget::DefineProperties(cmake *cm) CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS); cm->DefineProperty + ("SYSTEM_INTERFACE_INCLUDE_DIRECTORIES", cmProperty::TARGET, + "List of public system include directories for a library.", + "Targets may populate this property to publish the include directories " + "which contain system headers, and therefore should not result in " + "compiler warnings. Consuming targets will then mark the same include " + "directories as system headers." + "\n" + CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS + CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS); + + cm->DefineProperty ("INTERFACE_COMPILE_DEFINITIONS", cmProperty::TARGET, "List of public compile definitions for a library.", "Targets may populate this property to publish the compile definitions " @@ -1673,6 +1689,17 @@ void cmTarget::SetMakefile(cmMakefile* mf) { this->InsertInclude(*it); } + + const std::set<cmStdString> parentSystemIncludes = + this->Makefile->GetSystemIncludeDirectories(); + + for (std::set<cmStdString>::const_iterator it + = parentSystemIncludes.begin(); + it != parentSystemIncludes.end(); ++it) + { + this->SystemIncludeDirectories.insert(*it); + } + const std::vector<cmValueWithOrigin> parentOptions = this->Makefile->GetCompileOptionsEntries(); @@ -1694,18 +1721,13 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", 0); // Record current policies for later use. - this->PolicyStatusCMP0003 = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0003); - this->PolicyStatusCMP0004 = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0004); - this->PolicyStatusCMP0008 = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0008); - this->PolicyStatusCMP0020 = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0020); - this->PolicyStatusCMP0021 = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0021); - this->PolicyStatusCMP0022 = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0022); +#define CAPTURE_TARGET_POLICY(POLICY) \ + this->PolicyStatus ## POLICY = \ + this->Makefile->GetPolicyStatus(cmPolicies::POLICY); + + CM_FOR_EACH_TARGET_POLICY(CAPTURE_TARGET_POLICY) + +#undef CAPTURE_TARGET_POLICY } //---------------------------------------------------------------------------- @@ -1817,8 +1839,7 @@ bool cmTarget::IsBundleOnApple() class cmTargetTraceDependencies { public: - cmTargetTraceDependencies(cmTarget* target, cmTargetInternals* internal, - const char* vsProjectFile); + cmTargetTraceDependencies(cmTarget* target, cmTargetInternals* internal); void Trace(); private: cmTarget* Target; @@ -1842,8 +1863,7 @@ private: //---------------------------------------------------------------------------- cmTargetTraceDependencies -::cmTargetTraceDependencies(cmTarget* target, cmTargetInternals* internal, - const char* vsProjectFile): +::cmTargetTraceDependencies(cmTarget* target, cmTargetInternals* internal): Target(target), Internal(internal) { // Convenience. @@ -1860,13 +1880,6 @@ cmTargetTraceDependencies this->QueueSource(*si); } - // Queue the VS project file to check dependencies on the rule to - // generate it. - if(vsProjectFile) - { - this->FollowName(vsProjectFile); - } - // Queue pre-build, pre-link, and post-build rule dependencies. this->CheckCustomCommands(this->Target->GetPreBuildCommands()); this->CheckCustomCommands(this->Target->GetPreLinkCommands()); @@ -2085,7 +2098,7 @@ cmTargetTraceDependencies } //---------------------------------------------------------------------------- -void cmTarget::TraceDependencies(const char* vsProjectFile) +void cmTarget::TraceDependencies() { // CMake-generated targets have no dependencies to trace. Normally tracing // would find nothing anyway, but when building CMake itself the "install" @@ -2097,7 +2110,7 @@ void cmTarget::TraceDependencies(const char* vsProjectFile) } // Use a helper object to trace the dependencies. - cmTargetTraceDependencies tracer(this, this->Internal.Get(), vsProjectFile); + cmTargetTraceDependencies tracer(this, this->Internal.Get()); tracer.Trace(); } @@ -2321,6 +2334,14 @@ void cmTarget::MergeLinkLibraries( cmMakefile& mf, { // We call this so that the dependencies get written to the cache this->AddLinkLibrary( mf, selfname, i->first.c_str(), i->second ); + + if (this->GetType() == cmTarget::STATIC_LIBRARY) + { + this->AppendProperty("INTERFACE_LINK_LIBRARIES", + ("$<LINK_ONLY:" + + this->GetDebugGeneratorExpressions(i->first.c_str(), i->second) + + ">").c_str()); + } } this->PrevLinkedLibraries = libs; } @@ -2552,6 +2573,61 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, //---------------------------------------------------------------------------- void +cmTarget::AddSystemIncludeDirectories(const std::set<cmStdString> &incs) +{ + for(std::set<cmStdString>::const_iterator li = incs.begin(); + li != incs.end(); ++li) + { + this->SystemIncludeDirectories.insert(*li); + } +} + +//---------------------------------------------------------------------------- +void +cmTarget::AddSystemIncludeDirectories(const std::vector<std::string> &incs) +{ + for(std::vector<std::string>::const_iterator li = incs.begin(); + li != incs.end(); ++li) + { + this->SystemIncludeDirectories.insert(*li); + } +} + +//---------------------------------------------------------------------------- +void cmTarget::FinalizeSystemIncludeDirectories() +{ + for (std::vector<cmValueWithOrigin>::const_iterator + it = this->Internal->LinkInterfacePropertyEntries.begin(), + end = this->Internal->LinkInterfacePropertyEntries.end(); + it != end; ++it) + { + { + cmListFileBacktrace lfbt; + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(it->Value); + std::string targetName = cge->Evaluate(this->Makefile, 0, + false, this, 0, 0); + if (!this->Makefile->FindTargetToUse(targetName.c_str())) + { + continue; + } + } + std::string includeGenex = "$<TARGET_PROPERTY:" + + it->Value + ",INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>"; + if (cmGeneratorExpression::Find(it->Value) != std::string::npos) + { + // Because it->Value is a generator expression, ensure that it + // evaluates to the non-empty string before being used in the + // TARGET_PROPERTY expression. + includeGenex = "$<$<BOOL:" + it->Value + ">:" + includeGenex + ">"; + } + this->SystemIncludeDirectories.insert(includeGenex); + } +} + +//---------------------------------------------------------------------------- +void cmTarget::AnalyzeLibDependencies( const cmMakefile& mf ) { // There are two key parts of the dependency analysis: (1) @@ -2873,6 +2949,17 @@ void cmTarget::SetProperty(const char* prop, const char* value) new cmTargetInternals::TargetPropertyEntry(cge)); return; } + if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) + { + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + deleteAndClear(this->Internal->CompileDefinitionsEntries); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value); + this->Internal->CompileDefinitionsEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); + return; + } if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported()) { cmOStringStream e; @@ -2924,6 +3011,15 @@ void cmTarget::AppendProperty(const char* prop, const char* value, new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); return; } + if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) + { + cmListFileBacktrace lfbt; + this->Makefile->GetBacktrace(lfbt); + cmGeneratorExpression ge(lfbt); + this->Internal->CompileDefinitionsEntries.push_back( + new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + return; + } if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported()) { cmOStringStream e; @@ -3028,6 +3124,20 @@ void cmTarget::InsertCompileOption(const cmValueWithOrigin &entry, } //---------------------------------------------------------------------------- +void cmTarget::InsertCompileDefinition(const cmValueWithOrigin &entry, + bool before) +{ + cmGeneratorExpression ge(entry.Backtrace); + + std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position + = before ? this->Internal->CompileDefinitionsEntries.begin() + : this->Internal->CompileDefinitionsEntries.end(); + + this->Internal->CompileDefinitionsEntries.insert(position, + new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value))); +} + +//---------------------------------------------------------------------------- static void processIncludeDirectories(cmTarget *tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &includes, @@ -3259,12 +3369,12 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config) } //---------------------------------------------------------------------------- -static void processCompileOptions(cmTarget *tgt, +static void processCompileOptionsInternal(cmTarget *tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &options, std::set<std::string> &uniqueOptions, cmGeneratorExpressionDAGChecker *dagChecker, - const char *config, bool debugOptions) + const char *config, bool debugOptions, const char *logName) { cmMakefile *mf = tgt->GetMakefile(); @@ -3309,7 +3419,8 @@ static void processCompileOptions(cmTarget *tgt, if (!usedOptions.empty()) { mf->GetCMakeInstance()->IssueMessage(cmake::LOG, - std::string("Used compile options for target ") + std::string("Used compile ") + logName + + std::string(" for target ") + tgt->GetName() + ":\n" + usedOptions, (*it)->ge->GetBacktrace()); } @@ -3317,6 +3428,18 @@ static void processCompileOptions(cmTarget *tgt, } //---------------------------------------------------------------------------- +static void processCompileOptions(cmTarget *tgt, + const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, + std::vector<std::string> &options, + std::set<std::string> &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const char *config, bool debugOptions) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "options"); +} + +//---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector<std::string> &result, const char *config) { @@ -3412,90 +3535,128 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result, } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompileDefinitions(const char *config) +static void processCompileDefinitions(cmTarget *tgt, + const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, + std::vector<std::string> &options, + std::set<std::string> &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const char *config, bool debugOptions) { - const char *configProp = 0; - if (config) - { - std::string configPropName; - configPropName = "COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config); - configProp = this->GetProperty(configPropName.c_str()); - } + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, + "definitions"); +} - const char *noconfigProp = this->GetProperty("COMPILE_DEFINITIONS"); +//---------------------------------------------------------------------------- +void cmTarget::GetCompileDefinitions(std::vector<std::string> &list, + const char *config) +{ + std::set<std::string> uniqueOptions; cmListFileBacktrace lfbt; + cmGeneratorExpressionDAGChecker dagChecker(lfbt, - this->GetName(), - "COMPILE_DEFINITIONS", 0, 0); + this->GetName(), + "COMPILE_DEFINITIONS", 0, 0); - std::string defsString = (noconfigProp ? noconfigProp : ""); - if (configProp && noconfigProp) + std::vector<std::string> debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) { - defsString += ";"; + cmSystemTools::ExpandListArgument(debugProp, debugProperties); } - defsString += (configProp ? configProp : ""); - cmGeneratorExpression ge(lfbt); - std::string result = ge.Parse(defsString.c_str())->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker); - - std::vector<std::string> libs; - this->GetDirectLinkLibraries(config, libs, this); + bool debugDefines = !this->DebugCompileDefinitionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_DEFINITIONS") + != debugProperties.end(); - if (libs.empty()) + if (this->Makefile->IsGeneratingBuildSystem()) { - return result; + this->DebugCompileDefinitionsDone = true; } - std::string sep; - std::string depString; - for (std::vector<std::string>::const_iterator it = libs.begin(); - it != libs.end(); ++it) - { - if ((cmGeneratorExpression::IsValidTargetName(it->c_str()) - || cmGeneratorExpression::Find(it->c_str()) != std::string::npos) - && this->Makefile->FindTargetToUse(it->c_str())) - { - depString += sep + "$<TARGET_PROPERTY:" - + *it + ",INTERFACE_COMPILE_DEFINITIONS>"; - sep = ";"; - } - } + processCompileDefinitions(this, + this->Internal->CompileDefinitionsEntries, + list, + uniqueOptions, + &dagChecker, + config, + debugDefines); std::string configString = config ? config : ""; if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString]) { - cmGeneratorExpression ge2(lfbt); - cmsys::auto_ptr<cmCompiledGeneratorExpression> cge2 = - ge2.Parse(depString); - this->Internal->CachedLinkInterfaceCompileDefinitions[configString] = - cge2->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker); - } - if (!this->Internal->CachedLinkInterfaceCompileDefinitions[configString] - .empty()) - { - result += (result.empty() ? "" : ";") - + this->Internal->CachedLinkInterfaceCompileDefinitions[configString]; + for (std::vector<cmValueWithOrigin>::const_iterator + it = this->Internal->LinkInterfacePropertyEntries.begin(), + end = this->Internal->LinkInterfacePropertyEntries.end(); + it != end; ++it) + { + { + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(it->Value); + std::string targetResult = cge->Evaluate(this->Makefile, config, + false, this, 0, 0); + if (!this->Makefile->FindTargetToUse(targetResult.c_str())) + { + continue; + } + } + std::string defsGenex = "$<TARGET_PROPERTY:" + + it->Value + ",INTERFACE_COMPILE_DEFINITIONS>"; + if (cmGeneratorExpression::Find(it->Value) != std::string::npos) + { + // Because it->Value is a generator expression, ensure that it + // evaluates to the non-empty string before being used in the + // TARGET_PROPERTY expression. + defsGenex = "$<$<BOOL:" + it->Value + ">:" + defsGenex + ">"; + } + cmGeneratorExpression ge(it->Backtrace); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse( + defsGenex); + + this->Internal + ->CachedLinkInterfaceCompileDefinitionsEntries[configString].push_back( + new cmTargetInternals::TargetPropertyEntry(cge, + it->Value)); + } + if (config) + { + std::string configPropName = "COMPILE_DEFINITIONS_" + + cmSystemTools::UpperCase(config); + const char *configProp = this->GetProperty(configPropName.c_str()); + std::string defsString = (configProp ? configProp : ""); + + cmGeneratorExpression ge(lfbt); + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = + ge.Parse(defsString); + this->Internal + ->CachedLinkInterfaceCompileDefinitionsEntries[configString].push_back( + new cmTargetInternals::TargetPropertyEntry(cge)); + } + } + processCompileDefinitions(this, + this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[configString], + list, + uniqueOptions, + &dagChecker, + config, + debugDefines); + if (!this->Makefile->IsGeneratingBuildSystem()) { - this->Internal->CachedLinkInterfaceCompileDefinitions[configString] = ""; + deleteAndClear(this->Internal + ->CachedLinkInterfaceCompileDefinitionsEntries); } else { this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString] = true; } - - return result; } //---------------------------------------------------------------------------- @@ -3897,6 +4058,24 @@ const char *cmTarget::GetProperty(const char* prop, } return output.c_str(); } + if(strcmp(prop,"COMPILE_DEFINITIONS") == 0) + { + static std::string output; + output = ""; + std::string sep; + typedef cmTargetInternals::TargetPropertyEntry + TargetPropertyEntry; + for (std::vector<TargetPropertyEntry*>::const_iterator + it = this->Internal->CompileDefinitionsEntries.begin(), + end = this->Internal->CompileDefinitionsEntries.end(); + it != end; ++it) + { + output += sep; + output += (*it)->ge->GetInput(); + sep = ";"; + } + return output.c_str(); + } if (strcmp(prop,"IMPORTED") == 0) { @@ -6750,6 +6929,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() { deleteAndClear(this->Pointer->IncludeDirectoriesEntries); deleteAndClear(this->Pointer->CompileOptionsEntries); + deleteAndClear(this->Pointer->CompileDefinitionsEntries); delete this->Pointer; } diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d7ee332..0da0f12 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -19,6 +19,14 @@ #include <cmsys/auto_ptr.hxx> +#define CM_FOR_EACH_TARGET_POLICY(F) \ + F(CMP0003) \ + F(CMP0004) \ + F(CMP0008) \ + F(CMP0020) \ + F(CMP0021) \ + F(CMP0022) + class cmake; class cmMakefile; class cmSourceFile; @@ -91,29 +99,13 @@ public: void SetMakefile(cmMakefile *mf); cmMakefile *GetMakefile() const { return this->Makefile;}; - /** Get the status of policy CMP0003 when the target was created. */ - cmPolicies::PolicyStatus GetPolicyStatusCMP0003() const - { return this->PolicyStatusCMP0003; } - - /** Get the status of policy CMP0004 when the target was created. */ - cmPolicies::PolicyStatus GetPolicyStatusCMP0004() const - { return this->PolicyStatusCMP0004; } - - /** Get the status of policy CMP0008 when the target was created. */ - cmPolicies::PolicyStatus GetPolicyStatusCMP0008() const - { return this->PolicyStatusCMP0008; } +#define DECLARE_TARGET_POLICY(POLICY) \ + cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \ + { return this->PolicyStatus ## POLICY; } - /** Get the status of policy CMP0020 when the target was created. */ - cmPolicies::PolicyStatus GetPolicyStatusCMP0020() const - { return this->PolicyStatusCMP0020; } + CM_FOR_EACH_TARGET_POLICY(DECLARE_TARGET_POLICY) - /** Get the status of policy CMP0021 when the target was created. */ - cmPolicies::PolicyStatus GetPolicyStatusCMP0021() const - { return this->PolicyStatusCMP0021; } - - /** Get the status of policy CMP0022 when the target was created. */ - cmPolicies::PolicyStatus GetPolicyStatusCMP0022() const - { return this->PolicyStatusCMP0022; } +#undef DECLARE_TARGET_POLICY /** * Get the list of the custom commands for this target @@ -348,7 +340,7 @@ public: * Trace through the source files in this target and add al source files * that they depend on, used by all generators */ - void TraceDependencies(const char* vsProjectFile); + void TraceDependencies(); /** * Make sure the full path to all source files is known. @@ -449,7 +441,8 @@ public: If no macro should be defined null is returned. */ const char* GetExportMacro(); - std::string GetCompileDefinitions(const char *config); + void GetCompileDefinitions(std::vector<std::string> &result, + const char *config); // Compute the set of languages compiled by the target. This is // computed every time it is called because the languages can change @@ -520,6 +513,8 @@ public: bool before = false); void InsertCompileOption(const cmValueWithOrigin &entry, bool before = false); + void InsertCompileDefinition(const cmValueWithOrigin &entry, + bool before = false); void AppendBuildInterfaceIncludes(); @@ -540,7 +535,19 @@ public: std::string GetDebugGeneratorExpressions(const std::string &value, cmTarget::LinkLibraryType llt); + + void AddSystemIncludeDirectories(const std::set<cmStdString> &incs); + void AddSystemIncludeDirectories(const std::vector<std::string> &incs); + std::set<cmStdString> const & GetSystemIncludeDirectories() const + { return this->SystemIncludeDirectories; } + + void FinalizeSystemIncludeDirectories(); + private: + // The set of include directories that are marked as system include + // directories. + std::set<cmStdString> SystemIncludeDirectories; + /** * A list of direct dependencies. Use in conjunction with DependencyMap. */ @@ -656,6 +663,7 @@ private: bool IsImportedTarget; bool DebugIncludesDone; bool DebugCompileOptionsDone; + bool DebugCompileDefinitionsDone; mutable std::set<std::string> LinkImplicitNullProperties; bool BuildInterfaceIncludesAppended; @@ -694,12 +702,12 @@ private: cmMakefile* Makefile; // Policy status recorded when target was created. - cmPolicies::PolicyStatus PolicyStatusCMP0003; - cmPolicies::PolicyStatus PolicyStatusCMP0004; - cmPolicies::PolicyStatus PolicyStatusCMP0008; - cmPolicies::PolicyStatus PolicyStatusCMP0020; - cmPolicies::PolicyStatus PolicyStatusCMP0021; - cmPolicies::PolicyStatus PolicyStatusCMP0022; +#define TARGET_POLICY_MEMBER(POLICY) \ + cmPolicies::PolicyStatus PolicyStatus ## POLICY; + + CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_MEMBER) + +#undef TARGET_POLICY_MEMBER // Internal representation details. friend class cmTargetInternals; diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx index ba0ad59..46c9666 100644 --- a/Source/cmTargetCompileDefinitionsCommand.cxx +++ b/Source/cmTargetCompileDefinitionsCommand.cxx @@ -60,7 +60,7 @@ std::string cmTargetCompileDefinitionsCommand //---------------------------------------------------------------------------- void cmTargetCompileDefinitionsCommand ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content, - bool) + bool, bool) { tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str()); } diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h index 22d8fa8..bc58b31 100644 --- a/Source/cmTargetCompileDefinitionsCommand.h +++ b/Source/cmTargetCompileDefinitionsCommand.h @@ -82,7 +82,7 @@ private: virtual void HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content, - bool prepend); + bool prepend, bool system); virtual std::string Join(const std::vector<std::string> &content); }; diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx index e80c845..254acc7 100644 --- a/Source/cmTargetCompileOptionsCommand.cxx +++ b/Source/cmTargetCompileOptionsCommand.cxx @@ -53,7 +53,7 @@ std::string cmTargetCompileOptionsCommand //---------------------------------------------------------------------------- void cmTargetCompileOptionsCommand ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content, - bool) + bool, bool) { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h index 87fa1a7..b9afd71 100644 --- a/Source/cmTargetCompileOptionsCommand.h +++ b/Source/cmTargetCompileOptionsCommand.h @@ -83,7 +83,7 @@ private: virtual void HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content, - bool prepend); + bool prepend, bool system); virtual std::string Join(const std::vector<std::string> &content); }; diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index 12d0a51..e7b906c 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -15,7 +15,8 @@ bool cmTargetIncludeDirectoriesCommand ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &) { - return this->HandleArguments(args, "INCLUDE_DIRECTORIES", PROCESS_BEFORE); + return this->HandleArguments(args, "INCLUDE_DIRECTORIES", + ArgumentFlags(PROCESS_BEFORE | PROCESS_SYSTEM)); } //---------------------------------------------------------------------------- @@ -65,10 +66,39 @@ std::string cmTargetIncludeDirectoriesCommand //---------------------------------------------------------------------------- void cmTargetIncludeDirectoriesCommand ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content, - bool prepend) + bool prepend, bool system) { cmListFileBacktrace lfbt; this->Makefile->GetBacktrace(lfbt); cmValueWithOrigin entry(this->Join(content), lfbt); tgt->InsertInclude(entry, prepend); + if (system) + { + tgt->AddSystemIncludeDirectories(content); + } +} + +//---------------------------------------------------------------------------- +void cmTargetIncludeDirectoriesCommand +::HandleInterfaceContent(cmTarget *tgt, + const std::vector<std::string> &content, + bool prepend, bool system) +{ + cmTargetPropCommandBase::HandleInterfaceContent(tgt, content, + prepend, system); + + if (system) + { + std::string joined; + std::string sep; + for(std::vector<std::string>::const_iterator it = content.begin(); + it != content.end(); ++it) + { + joined += sep; + sep = ";"; + joined += *it; + } + tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", + joined.c_str()); + } } diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h index 4a1a4df..2968618 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.h +++ b/Source/cmTargetIncludeDirectoriesCommand.h @@ -54,7 +54,7 @@ public: virtual const char* GetFullDocumentation() const { return - " target_include_directories(<target> [BEFORE] " + " target_include_directories(<target> [SYSTEM] [BEFORE] " "<INTERFACE|PUBLIC|PRIVATE> [items1...]\n" " [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])\n" "Specify include directories or targets to use when compiling a given " @@ -71,6 +71,14 @@ public: "The following arguments specify include directories. Specified " "include directories may be absolute paths or relative paths. " "Repeated calls for the same <target> append items in the order called." + "If SYSTEM is specified, the compiler will be told the " + "directories are meant as system include directories on some " + "platforms (signalling this setting might achieve effects such as " + "the compiler skipping warnings, or these fixed-install system files " + "not being considered in dependency calculations - see compiler " + "docs). If SYSTEM is used together with PUBLIC or INTERFACE, the " + "INTERFACE_SYSTEM_INCLUDE_DIRECTORIES target property will be " + "populated with the specified directories." "\n" "Arguments to target_include_directories may use \"generator " "expressions\" with the syntax \"$<...>\". " @@ -87,7 +95,11 @@ private: virtual void HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content, - bool prepend); + bool prepend, bool system); + virtual void HandleInterfaceContent(cmTarget *tgt, + const std::vector<std::string> &content, + bool prepend, bool system); + virtual std::string Join(const std::vector<std::string> &content); }; diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index b7b7691..c5f490e 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -224,12 +224,17 @@ bool cmTargetLinkLibrariesCommand cmSystemTools::SetFatalErrorOccured(); } + const cmPolicies::PolicyStatus policy22Status + = this->Target->GetPolicyStatusCMP0022(); + // If any of the LINK_ options were given, make sure the // LINK_INTERFACE_LIBRARIES target property exists. // Use of any of the new keywords implies awareness of // this property. And if no libraries are named, it should // result in an empty link interface. - if(this->CurrentProcessingState != ProcessingLinkLibraries && + if((policy22Status == cmPolicies::OLD || + policy22Status == cmPolicies::WARN) && + this->CurrentProcessingState != ProcessingLinkLibraries && !this->Target->GetProperty("LINK_INTERFACE_LIBRARIES")) { this->Target->SetProperty("LINK_INTERFACE_LIBRARIES", ""); @@ -263,11 +268,30 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib, ->AddLinkLibraryForTarget(this->Target->GetName(), lib, llt); if (this->CurrentProcessingState != ProcessingPublicInterface) { + if (this->Target->GetType() == cmTarget::STATIC_LIBRARY) + { + this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES", + ("$<LINK_ONLY:" + + this->Target->GetDebugGeneratorExpressions(lib, llt) + + ">").c_str()); + } // Not LINK_INTERFACE_LIBRARIES or LINK_PUBLIC, do not add to interface. return; } } + this->Target->AppendProperty("INTERFACE_LINK_LIBRARIES", + this->Target->GetDebugGeneratorExpressions(lib, llt).c_str()); + + const cmPolicies::PolicyStatus policy22Status + = this->Target->GetPolicyStatusCMP0022(); + + if (policy22Status != cmPolicies::OLD + && policy22Status != cmPolicies::WARN) + { + return; + } + // Get the list of configurations considered to be DEBUG. std::vector<std::string> const& debugConfigs = this->Makefile->GetCMakeInstance()->GetDebugConfigs(); diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h index c683016..ca651d0 100644 --- a/Source/cmTargetLinkLibrariesCommand.h +++ b/Source/cmTargetLinkLibrariesCommand.h @@ -92,7 +92,7 @@ public: "When this target is linked into another target then the libraries " "linked to this target will appear on the link line for the other " "target too. " - "See the LINK_INTERFACE_LIBRARIES target property to override the " + "See the INTERFACE_LINK_LIBRARIES target property to override the " "set of transitive link dependencies for a target. " "Calls to other signatures of this command may set the property " "making any libraries linked exclusively by this signature private." @@ -112,14 +112,19 @@ public: " target_link_libraries(<target> LINK_INTERFACE_LIBRARIES\n" " [[debug|optimized|general] <lib>] ...)\n" "The LINK_INTERFACE_LIBRARIES mode appends the libraries " - "to the LINK_INTERFACE_LIBRARIES and its per-configuration equivalent " - "target properties instead of using them for linking. " - "Libraries specified as \"debug\" are appended to the " + "to the INTERFACE_LINK_LIBRARIES target property instead of using them " + "for linking. If policy CMP0022 is not NEW, then this mode also " + "appends libraries to the LINK_INTERFACE_LIBRARIES and its " + "per-configuration equivalent. " + "Libraries specified as \"debug\" are wrapped in a generator " + "expression to correspond to debug builds. If policy CMP0022 is not " + "NEW, the libraries are also appended to the " "LINK_INTERFACE_LIBRARIES_DEBUG property (or to the properties " "corresponding to configurations listed in the DEBUG_CONFIGURATIONS " "global property if it is set). " "Libraries specified as \"optimized\" are appended to the " - "LINK_INTERFACE_LIBRARIES property. " + "INTERFACE_LINK_LIBRARIES property. If policy CMP0022 is not NEW, " + "they are also appended to the LINK_INTERFACE_LIBRARIES property. " "Libraries specified as \"general\" (or without any keyword) are " "treated as if specified for both \"debug\" and \"optimized\"." "\n" @@ -131,9 +136,11 @@ public: "The LINK_PUBLIC and LINK_PRIVATE modes can be used to specify both " "the link dependencies and the link interface in one command. " "Libraries and targets following LINK_PUBLIC are linked to, and are " - "made part of the LINK_INTERFACE_LIBRARIES. Libraries and targets " - "following LINK_PRIVATE are linked to, but are not made part of the " - "LINK_INTERFACE_LIBRARIES. " + "made part of the INTERFACE_LINK_LIBRARIES. If policy CMP0022 is not " + "NEW, they are also made part of the LINK_INTERFACE_LIBRARIES. " + "Libraries and targets following LINK_PRIVATE are linked to, but are " + "not made part of the INTERFACE_LINK_LIBRARIES (or " + "LINK_INTERFACE_LIBRARIES)." "\n" "The library dependency graph is normally acyclic (a DAG), but in the " "case of mutually-dependent STATIC libraries CMake allows the graph " diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 771097c..287ce46 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -48,8 +48,20 @@ bool cmTargetPropCommandBase return false; } + bool system = false; unsigned int argIndex = 1; + if ((flags & PROCESS_SYSTEM) && args[argIndex] == "SYSTEM") + { + if (args.size() < 4) + { + this->SetError("called with incorrect number of arguments"); + return false; + } + system = true; + ++argIndex; + } + bool prepend = false; if ((flags & PROCESS_BEFORE) && args[argIndex] == "BEFORE") { @@ -66,7 +78,7 @@ bool cmTargetPropCommandBase while (argIndex < args.size()) { - if (!this->ProcessContentArgs(args, argIndex, prepend)) + if (!this->ProcessContentArgs(args, argIndex, prepend, system)) { return false; } @@ -77,7 +89,7 @@ bool cmTargetPropCommandBase //---------------------------------------------------------------------------- bool cmTargetPropCommandBase ::ProcessContentArgs(std::vector<std::string> const& args, - unsigned int &argIndex, bool prepend) + unsigned int &argIndex, bool prepend, bool system) { const std::string scope = args[argIndex]; @@ -105,12 +117,12 @@ bool cmTargetPropCommandBase || args[i] == "PRIVATE" || args[i] == "INTERFACE" ) { - this->PopulateTargetProperies(scope, content, prepend); + this->PopulateTargetProperies(scope, content, prepend, system); return true; } content.push_back(args[i]); } - this->PopulateTargetProperies(scope, content, prepend); + this->PopulateTargetProperies(scope, content, prepend, system); return true; } @@ -118,27 +130,35 @@ bool cmTargetPropCommandBase void cmTargetPropCommandBase ::PopulateTargetProperies(const std::string &scope, const std::vector<std::string> &content, - bool prepend) + bool prepend, bool system) { if (scope == "PRIVATE" || scope == "PUBLIC") { - this->HandleDirectContent(this->Target, content, prepend); + this->HandleDirectContent(this->Target, content, prepend, system); } if (scope == "INTERFACE" || scope == "PUBLIC") { - if (prepend) - { - const std::string propName = std::string("INTERFACE_") + this->Property; - const char *propValue = this->Target->GetProperty(propName.c_str()); - const std::string totalContent = this->Join(content) + (propValue - ? std::string(";") + propValue - : std::string()); - this->Target->SetProperty(propName.c_str(), totalContent.c_str()); - } - else - { - this->Target->AppendProperty(("INTERFACE_" + this->Property).c_str(), - this->Join(content).c_str()); - } + this->HandleInterfaceContent(this->Target, content, prepend, system); + } +} + +//---------------------------------------------------------------------------- +void cmTargetPropCommandBase::HandleInterfaceContent(cmTarget *tgt, + const std::vector<std::string> &content, + bool prepend, bool) +{ + if (prepend) + { + const std::string propName = std::string("INTERFACE_") + this->Property; + const char *propValue = tgt->GetProperty(propName.c_str()); + const std::string totalContent = this->Join(content) + (propValue + ? std::string(";") + propValue + : std::string()); + tgt->SetProperty(propName.c_str(), totalContent.c_str()); + } + else + { + tgt->AppendProperty(("INTERFACE_" + this->Property).c_str(), + this->Join(content).c_str()); } } diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index 8047a48..690582f 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -25,7 +25,8 @@ public: enum ArgumentFlags { NO_FLAGS = 0, - PROCESS_BEFORE = 1 + PROCESS_BEFORE = 1, + PROCESS_SYSTEM = 2 }; bool HandleArguments(std::vector<std::string> const& args, @@ -36,20 +37,24 @@ protected: std::string Property; cmTarget *Target; + virtual void HandleInterfaceContent(cmTarget *tgt, + const std::vector<std::string> &content, + bool prepend, bool system); private: virtual void HandleImportedTarget(const std::string &tgt) = 0; virtual void HandleMissingTarget(const std::string &name) = 0; virtual void HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content, - bool prepend) = 0; + bool prepend, bool system) = 0; + virtual std::string Join(const std::vector<std::string> &content) = 0; bool ProcessContentArgs(std::vector<std::string> const& args, - unsigned int &argIndex, bool prepend); + unsigned int &argIndex, bool prepend, bool system); void PopulateTargetProperies(const std::string &scope, const std::vector<std::string> &content, - bool prepend); + bool prepend, bool system); }; #endif diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h index 163756d..a20594c 100644 --- a/Source/cmTryCompileCommand.h +++ b/Source/cmTryCompileCommand.h @@ -69,14 +69,14 @@ public: " [COMPILE_DEFINITIONS flags...]\n" " [LINK_LIBRARIES libs...]\n" " [OUTPUT_VARIABLE <var>]\n" - " [COPY_FILE <fileName>])\n" + " [COPY_FILE <fileName> [COPY_FILE_ERROR <var>]])\n" "Try building an executable from one or more source files. " "In this form the user need only supply one or more source files " "that include a definition for 'main'. " "CMake will create a CMakeLists.txt file to build the source(s) " "as an executable. " "Specify COPY_FILE to get a copy of the linked executable at the " - "given fileName." + "given fileName and optionally COPY_FILE_ERROR to capture any error." "\n" "In this version all files in bindir/CMakeFiles/CMakeTmp " "will be cleaned automatically. For debugging, --debug-trycompile can " diff --git a/Source/cmVS10LinkFlagTable.h b/Source/cmVS10LinkFlagTable.h index 64febbb..5d15620 100644 --- a/Source/cmVS10LinkFlagTable.h +++ b/Source/cmVS10LinkFlagTable.h @@ -201,7 +201,7 @@ static cmVS7FlagTable cmVS10LinkFlagTable[] = cmVS7FlagTable::UserValueRequired}, {"GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, - {"MapFileName", "MAP", "Generate Map File", "", + {"MapFileName", "MAP:", "Generate Map File", "", cmVS7FlagTable::UserValueRequired}, //String List Properties diff --git a/Source/cmVS11LinkFlagTable.h b/Source/cmVS11LinkFlagTable.h index ea0d0f0..b4587a8 100644 --- a/Source/cmVS11LinkFlagTable.h +++ b/Source/cmVS11LinkFlagTable.h @@ -227,7 +227,7 @@ static cmVS7FlagTable cmVS11LinkFlagTable[] = cmVS7FlagTable::UserValueRequired}, {"GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, - {"MapFileName", "MAP", "Generate Map File", "", + {"MapFileName", "MAP:", "Generate Map File", "", cmVS7FlagTable::UserValueRequired}, //String List Properties diff --git a/Source/cmVS12LinkFlagTable.h b/Source/cmVS12LinkFlagTable.h index ce32e38..73d450a 100644 --- a/Source/cmVS12LinkFlagTable.h +++ b/Source/cmVS12LinkFlagTable.h @@ -227,7 +227,7 @@ static cmVS7FlagTable cmVS12LinkFlagTable[] = cmVS7FlagTable::UserValueRequired}, {"GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::UserValueIgnored | cmVS7FlagTable::Continue}, - {"MapFileName", "MAP", "Generate Map File", "", + {"MapFileName", "MAP:", "Generate Map File", "", cmVS7FlagTable::UserValueRequired}, //String List Properties diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 50f195e..d59de11 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1337,8 +1337,9 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str()); clOptions.Parse(flags.c_str()); clOptions.Parse(defineFlags.c_str()); - clOptions.AddDefines(this->Target->GetCompileDefinitions( - configName.c_str()).c_str()); + std::vector<std::string> targetDefines; + this->Target->GetCompileDefinitions(targetDefines, configName.c_str()); + clOptions.AddDefines(targetDefines); clOptions.SetVerboseMakefile( this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE")); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index fcec068..290aff0 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -612,7 +612,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args) std::vector<std::string> includeDirs; cmSystemTools::ExpandListArgument(includes, includeDirs); - std::string includeFlags = lg->GetIncludeFlags(includeDirs, + std::string includeFlags = lg->GetIncludeFlags(includeDirs, 0, language.c_str(), false); std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS"); @@ -3667,11 +3667,11 @@ void cmake::RecordPropertyAccess(const char *name, void cmake::ReportUndefinedPropertyAccesses(const char *filename) { + if(!this->GlobalGenerator) + { return; } FILE *progFile = fopen(filename,"w"); - if (!progFile || !this->GlobalGenerator) - { - return; - } + if(!progFile) + { return; } // what are the enabled languages? std::vector<std::string> enLangs; diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 4d5af5e..935b836 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -4261,17 +4261,13 @@ bool SystemTools::IsSubDirectory(const char* cSubdir, const char* cDir) } kwsys_stl::string subdir = cSubdir; kwsys_stl::string dir = cDir; + SystemTools::ConvertToUnixSlashes(subdir); SystemTools::ConvertToUnixSlashes(dir); - kwsys_stl::string path = subdir; - do + if(subdir.size() > dir.size() && subdir[dir.size()] == '/') { - path = SystemTools::GetParentDirectory(path.c_str()); - if(SystemTools::ComparePath(dir.c_str(), path.c_str())) - { - return true; - } + std::string s = subdir.substr(0, dir.size()); + return SystemTools::ComparePath(s.c_str(), dir.c_str()); } - while ( path.size() > dir.size() ); return false; } diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt index b003a1b..2240539 100644 --- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt @@ -122,3 +122,5 @@ add_library(libConsumer empty.cpp) # evaluates to the empty string in non-Debug cases, ensure that that causes # no problems. target_link_libraries(libConsumer debug depA) + +add_subdirectory(cmp0022) diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt new file mode 100644 index 0000000..dd6ab41 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt @@ -0,0 +1,18 @@ + +include(GenerateExportHeader) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +cmake_policy(SET CMP0022 NEW) +add_library(cmp0022lib SHARED cmp0022lib.cpp) +generate_export_header(cmp0022lib) +add_library(cmp0022ifacelib SHARED cmp0022ifacelib.cpp) +generate_export_header(cmp0022ifacelib) +target_link_libraries(cmp0022lib LINK_PUBLIC cmp0022ifacelib) + +assert_property(cmp0022lib LINK_INTERFACE_LIBRARIES "") +assert_property(cmp0022ifacelib LINK_INTERFACE_LIBRARIES "") +assert_property(cmp0022lib INTERFACE_LINK_LIBRARIES "cmp0022ifacelib") +assert_property(cmp0022ifacelib INTERFACE_LINK_LIBRARIES "") + +add_executable(cmp0022exe cmp0022exe.cpp) +target_link_libraries(cmp0022exe cmp0022lib) diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022exe.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022exe.cpp new file mode 100644 index 0000000..008bb74 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022exe.cpp @@ -0,0 +1,7 @@ + +#include "cmp0022lib.h" + +int main(void) +{ + return cmp0022().Value; +} diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022ifacelib.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022ifacelib.cpp new file mode 100644 index 0000000..b285be0 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022ifacelib.cpp @@ -0,0 +1,9 @@ + +#include "cmp0022ifacelib.h" + +CMP0022Iface cmp0022iface() +{ + CMP0022Iface iface; + iface.Value = 0; + return iface; +} diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022ifacelib.h b/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022ifacelib.h new file mode 100644 index 0000000..616dbf6 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022ifacelib.h @@ -0,0 +1,9 @@ + +#include "cmp0022ifacelib_export.h" + +struct CMP0022Iface +{ + int Value; +}; + +CMP0022Iface CMP0022IFACELIB_EXPORT cmp0022iface(); diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022lib.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022lib.cpp new file mode 100644 index 0000000..381d463 --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022lib.cpp @@ -0,0 +1,7 @@ + +#include "cmp0022lib.h" + +CMP0022Iface cmp0022() +{ + return cmp0022iface(); +} diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022lib.h b/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022lib.h new file mode 100644 index 0000000..3235b9b --- /dev/null +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/cmp0022lib.h @@ -0,0 +1,6 @@ + +#include "cmp0022lib_export.h" + +#include "cmp0022ifacelib.h" + +CMP0022Iface CMP0022LIB_EXPORT cmp0022(); diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index 000e350..f810f3b 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -184,6 +184,9 @@ set_property(TARGET testSharedLibRequired APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/testSharedLibRequired>" "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}>" ) +set_property(TARGET testSharedLibRequired APPEND PROPERTY + INTERFACE_COMPILE_DEFINITIONS USING_TESTSHAREDLIBREQUIRED +) set_property(TARGET testSharedLibRequired APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL CUSTOM_PROP diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 376abac..aa8847b 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -228,3 +228,36 @@ target_compile_definitions(deps_shared_iface2 $<$<BOOL:$<TARGET_PROPERTY:CUSTOM_PROP>>:CUSTOM_PROPERTY_IS_ON> $<$<STREQUAL:$<TARGET_PROPERTY:CUSTOM_STRING>,testcontent>:CUSTOM_STRING_IS_MATCH> ) + +add_subdirectory(excludedFromAll) + +add_executable(iface_test_bld iface_test.cpp) +target_link_libraries(iface_test_bld bld_testSharedLibDepends) + +set_property(TARGET bld_testSharedLibRequired APPEND PROPERTY + LINK_INTERFACE_LIBRARIES + excludedFromAll +) +get_target_property(_configs bld_testSharedLibRequired IMPORTED_CONFIGURATIONS) +foreach(_config ${_configs}) + set_property(TARGET bld_testSharedLibRequired APPEND PROPERTY + IMPORTED_LINK_INTERFACE_LIBRARIES_${_config} + excludedFromAll + ) +endforeach() +unset(_configs) +add_executable(iface_test_exp iface_test.cpp) +target_link_libraries(iface_test_exp testSharedLibDepends) + +set_property(TARGET testSharedLibDepends APPEND PROPERTY + LINK_INTERFACE_LIBRARIES + excludedFromAll +) +get_target_property(_configs testSharedLibDepends IMPORTED_CONFIGURATIONS) +foreach(_config ${_configs}) + set_property(TARGET testSharedLibDepends APPEND PROPERTY + IMPORTED_LINK_INTERFACE_LIBRARIES_${_config} + excludedFromAll + ) +endforeach() +unset(_configs) diff --git a/Tests/ExportImport/Import/A/excludedFromAll/CMakeLists.txt b/Tests/ExportImport/Import/A/excludedFromAll/CMakeLists.txt new file mode 100644 index 0000000..cd5a59b --- /dev/null +++ b/Tests/ExportImport/Import/A/excludedFromAll/CMakeLists.txt @@ -0,0 +1,7 @@ + +set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +include(GenerateExportHeader) +add_library(excludedFromAll SHARED EXCLUDE_FROM_ALL excludedFromAll.cpp) +generate_export_header(excludedFromAll) diff --git a/Tests/ExportImport/Import/A/excludedFromAll/excludedFromAll.cpp b/Tests/ExportImport/Import/A/excludedFromAll/excludedFromAll.cpp new file mode 100644 index 0000000..2269a04 --- /dev/null +++ b/Tests/ExportImport/Import/A/excludedFromAll/excludedFromAll.cpp @@ -0,0 +1,7 @@ + +#include "excludedFromAll.h" + +int excludedFromAll() +{ + return 0; +} diff --git a/Tests/ExportImport/Import/A/excludedFromAll/excludedFromAll.h b/Tests/ExportImport/Import/A/excludedFromAll/excludedFromAll.h new file mode 100644 index 0000000..4820c76 --- /dev/null +++ b/Tests/ExportImport/Import/A/excludedFromAll/excludedFromAll.h @@ -0,0 +1,4 @@ + +#include "excludedfromall_export.h" + +int EXCLUDEDFROMALL_EXPORT excludedFromAll(); diff --git a/Tests/ExportImport/Import/A/iface_test.cpp b/Tests/ExportImport/Import/A/iface_test.cpp new file mode 100644 index 0000000..fa4474b --- /dev/null +++ b/Tests/ExportImport/Import/A/iface_test.cpp @@ -0,0 +1,11 @@ + +#ifndef USING_TESTSHAREDLIBREQUIRED +#error Expected USING_TESTSHAREDLIBREQUIRED +#endif + +#include "excludedFromAll.h" + +int main(void) +{ + return excludedFromAll(); +} diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt index 3e3ecc9..596a280 100644 --- a/Tests/IncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/CMakeLists.txt @@ -1,6 +1,23 @@ cmake_minimum_required (VERSION 2.6) project(IncludeDirectories) +if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4) + OR CMAKE_C_COMPILER_ID STREQUAL Clang) + AND (CMAKE_GENERATOR STREQUAL "Unix Makefiles" OR CMAKE_GENERATOR STREQUAL "Ninja")) + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag(-Wunused-variable run_sys_includes_test) + if(run_sys_includes_test) + # The Bullseye wrapper appears to break the -isystem effect. + execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE out ERROR_VARIABLE out) + if("x${out}" MATCHES "Bullseye") + set(run_sys_includes_test 0) + endif() + endif() + if (run_sys_includes_test) + add_subdirectory(SystemIncludeDirectories) + endif() +endif() + file(WRITE ${CMAKE_BINARY_DIR}/Flags/Flags.h "//Flags.h ") diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt new file mode 100644 index 0000000..aec6ff9 --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/CMakeLists.txt @@ -0,0 +1,19 @@ + +cmake_minimum_required(VERSION 2.8) + +project(SystemIncludeDirectories) + +add_library(systemlib systemlib.cpp) +target_include_directories(systemlib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/systemlib") + +add_library(upstream upstream.cpp) +target_link_libraries(upstream LINK_PUBLIC systemlib) +target_compile_options(upstream PRIVATE -Werror=unused-variable) + +target_include_directories(upstream SYSTEM PUBLIC + $<TARGET_PROPERTY:systemlib,INTERFACE_INCLUDE_DIRECTORIES> +) + +add_library(consumer consumer.cpp) +target_link_libraries(consumer upstream) +target_compile_options(consumer PRIVATE -Werror=unused-variable) diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp b/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp new file mode 100644 index 0000000..197dae8 --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/consumer.cpp @@ -0,0 +1,7 @@ + +#include "upstream.h" + +int consumer() +{ + return upstream(); +} diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib.cpp b/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib.cpp new file mode 100644 index 0000000..f111bfa --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib.cpp @@ -0,0 +1,4 @@ + +#include "systemlib.h" + +int systemlib() { return 0; } diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib/systemlib.h b/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib/systemlib.h new file mode 100644 index 0000000..c84de6a --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/systemlib/systemlib.h @@ -0,0 +1,19 @@ + +#ifndef SYSTEMLIB_H +#define SYSTEMLIB_H + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int systemlib(); + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int unusedFunc() +{ + int unused; + return systemlib(); +} + +#endif diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.cpp b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.cpp new file mode 100644 index 0000000..f716b99 --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.cpp @@ -0,0 +1,4 @@ + +#include "upstream.h" + +int upstream() { return systemlib(); } diff --git a/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h new file mode 100644 index 0000000..3628568 --- /dev/null +++ b/Tests/IncludeDirectories/SystemIncludeDirectories/upstream.h @@ -0,0 +1,12 @@ + +#ifndef UPSTREAM_H +#define UPSTREAM_H + +#include "systemlib.h" + +#ifdef _WIN32 +__declspec(dllexport) +#endif +int upstream(); + +#endif diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-link_libraries-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-link_libraries-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-link_libraries-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-link_libraries.cmake b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-link_libraries.cmake new file mode 100644 index 0000000..42c4084 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-NOWARN-static-link_libraries.cmake @@ -0,0 +1,9 @@ + +enable_language(CXX) + +add_subdirectory(dep1) +add_subdirectory(dep2) +add_subdirectory(dep3) + +add_library(somelib empty.cpp) +target_link_libraries(somelib dep3) diff --git a/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-result.txt b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt new file mode 100644 index 0000000..5a5ad27 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll-stderr.txt @@ -0,0 +1,8 @@ +CMake Warning \(dev\) in CMakeLists.txt: + Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link + interface. Run "cmake --help-policy CMP0022" for policy details. Use the + cmake_policy command to set the policy and suppress this warning. + + Target "bar" has a INTERFACE_LINK_LIBRARIES property which differs from its + LINK_INTERFACE_LIBRARIES properties. +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0022/CMP0022-WARN-tll.cmake b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll.cmake new file mode 100644 index 0000000..11b4e22 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-WARN-tll.cmake @@ -0,0 +1,11 @@ + +project(CMP0022-WARN-tll) + +add_library(foo SHARED empty_vs6_1.cpp) +add_library(bar SHARED empty_vs6_2.cpp) +add_library(bat SHARED empty_vs6_3.cpp) +target_link_libraries(bar LINK_PUBLIC foo) +set_property(TARGET bar PROPERTY LINK_INTERFACE_LIBRARIES bat) + +add_library(user SHARED empty.cpp) +target_link_libraries(user bar) diff --git a/Tests/RunCMake/CMP0022/RunCMakeTest.cmake b/Tests/RunCMake/CMP0022/RunCMakeTest.cmake index 616d664..dcef0f5 100644 --- a/Tests/RunCMake/CMP0022/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0022/RunCMakeTest.cmake @@ -1,7 +1,9 @@ include(RunCMake) run_cmake(CMP0022-WARN) +run_cmake(CMP0022-WARN-tll) run_cmake(CMP0022-WARN-static) run_cmake(CMP0022-NOWARN-static) +run_cmake(CMP0022-NOWARN-static-link_libraries) run_cmake(CMP0022-export) run_cmake(CMP0022-install-export) diff --git a/Tests/RunCMake/CMP0022/dep1/CMakeLists.txt b/Tests/RunCMake/CMP0022/dep1/CMakeLists.txt new file mode 100644 index 0000000..f0a8179 --- /dev/null +++ b/Tests/RunCMake/CMP0022/dep1/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_library(dep1 ../empty_vs6_1.cpp) diff --git a/Tests/RunCMake/CMP0022/dep2/CMakeLists.txt b/Tests/RunCMake/CMP0022/dep2/CMakeLists.txt new file mode 100644 index 0000000..4f90162 --- /dev/null +++ b/Tests/RunCMake/CMP0022/dep2/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_library(dep2 ../empty_vs6_2.cpp) diff --git a/Tests/RunCMake/CMP0022/dep3/CMakeLists.txt b/Tests/RunCMake/CMP0022/dep3/CMakeLists.txt new file mode 100644 index 0000000..e85cb54 --- /dev/null +++ b/Tests/RunCMake/CMP0022/dep3/CMakeLists.txt @@ -0,0 +1,5 @@ + +link_libraries(dep1) + +add_library(dep3 ../empty_vs6_3.cpp) +target_link_libraries(dep3 dep2) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index e07c42f..66ce3f1 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -57,6 +57,7 @@ add_RunCMake_test(CTest) if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles") add_RunCMake_test(CompilerChange) endif() +add_RunCMake_test(Configure) add_RunCMake_test(ExternalData) add_RunCMake_test(FPHSA) add_RunCMake_test(GeneratorExpression) @@ -96,12 +97,17 @@ add_RunCMake_test(list) add_RunCMake_test(try_compile) add_RunCMake_test(variable_watch) add_RunCMake_test(CMP0004) +add_RunCMake_test(TargetPolicies) find_package(Qt4 QUIET) find_package(Qt5Core QUIET) if (QT4_FOUND AND Qt5Core_FOUND AND NOT Qt5Core_VERSION VERSION_LESS 5.1.0) add_RunCMake_test(IncompatibleQt) endif() +if (QT4_FOUND) + set(ObsoleteQtMacros_ARGS -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}) + add_RunCMake_test(ObsoleteQtMacros) +endif() if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]") add_RunCMake_test(include_external_msproject) diff --git a/Tests/RunCMake/Configure/CMakeLists.txt b/Tests/RunCMake/Configure/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/Configure/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Configure/ErrorLogs-result.txt b/Tests/RunCMake/Configure/ErrorLogs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Configure/ErrorLogs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Configure/ErrorLogs-stderr.txt b/Tests/RunCMake/Configure/ErrorLogs-stderr.txt new file mode 100644 index 0000000..4eee45d --- /dev/null +++ b/Tests/RunCMake/Configure/ErrorLogs-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at ErrorLogs.cmake:3 \(message\): + Some error! +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/Configure/ErrorLogs-stdout.txt b/Tests/RunCMake/Configure/ErrorLogs-stdout.txt new file mode 100644 index 0000000..c467b62 --- /dev/null +++ b/Tests/RunCMake/Configure/ErrorLogs-stdout.txt @@ -0,0 +1,3 @@ +-- Configuring incomplete, errors occurred! +See also ".*/Tests/RunCMake/Configure/ErrorLogs-build/CMakeFiles/CMakeOutput\.log"\. +See also ".*/Tests/RunCMake/Configure/ErrorLogs-build/CMakeFiles/CMakeError\.log"\. diff --git a/Tests/RunCMake/Configure/ErrorLogs.cmake b/Tests/RunCMake/Configure/ErrorLogs.cmake new file mode 100644 index 0000000..e8cf062 --- /dev/null +++ b/Tests/RunCMake/Configure/ErrorLogs.cmake @@ -0,0 +1,3 @@ +file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Some detailed error information!\n") +message(SEND_ERROR "Some error!") diff --git a/Tests/RunCMake/Configure/RunCMakeTest.cmake b/Tests/RunCMake/Configure/RunCMakeTest.cmake new file mode 100644 index 0000000..46f9184 --- /dev/null +++ b/Tests/RunCMake/Configure/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(ErrorLogs) diff --git a/Tests/RunCMake/ObsoleteQtMacros/AutomocMacro-WARN-result.txt b/Tests/RunCMake/ObsoleteQtMacros/AutomocMacro-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/ObsoleteQtMacros/AutomocMacro-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/ObsoleteQtMacros/AutomocMacro-WARN-stderr.txt b/Tests/RunCMake/ObsoleteQtMacros/AutomocMacro-WARN-stderr.txt new file mode 100644 index 0000000..6f7e8ee --- /dev/null +++ b/Tests/RunCMake/ObsoleteQtMacros/AutomocMacro-WARN-stderr.txt @@ -0,0 +1,5 @@ +CMake Warning at .*/Modules/Qt4Macros.cmake:[^ ]+ \(message\): + The qt4_automoc macro is obsolete. Use the CMAKE_AUTOMOC feature instead. +Call Stack \(most recent call first\): + AutomocMacro-WARN.cmake:7 \(qt4_automoc\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObsoleteQtMacros/AutomocMacro-WARN.cmake b/Tests/RunCMake/ObsoleteQtMacros/AutomocMacro-WARN.cmake new file mode 100644 index 0000000..c0c64a5 --- /dev/null +++ b/Tests/RunCMake/ObsoleteQtMacros/AutomocMacro-WARN.cmake @@ -0,0 +1,7 @@ + +find_package(Qt4 REQUIRED) + +set(CMAKE_WARN_DEPRECATED 1) + +add_library(foo SHARED empty.cpp) +qt4_automoc(foo_moc_srcs empty.cpp) diff --git a/Tests/RunCMake/ObsoleteQtMacros/CMakeLists.txt b/Tests/RunCMake/ObsoleteQtMacros/CMakeLists.txt new file mode 100644 index 0000000..65ac8e8 --- /dev/null +++ b/Tests/RunCMake/ObsoleteQtMacros/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.11) +project(${RunCMake_TEST}) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/ObsoleteQtMacros/RunCMakeTest.cmake b/Tests/RunCMake/ObsoleteQtMacros/RunCMakeTest.cmake new file mode 100644 index 0000000..eee2cc3 --- /dev/null +++ b/Tests/RunCMake/ObsoleteQtMacros/RunCMakeTest.cmake @@ -0,0 +1,6 @@ +include(RunCMake) + +set(RunCMake_TEST_OPTIONS -DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}) + +run_cmake(UseModulesMacro-WARN) +run_cmake(AutomocMacro-WARN) diff --git a/Tests/RunCMake/ObsoleteQtMacros/UseModulesMacro-WARN-result.txt b/Tests/RunCMake/ObsoleteQtMacros/UseModulesMacro-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/ObsoleteQtMacros/UseModulesMacro-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/ObsoleteQtMacros/UseModulesMacro-WARN-stderr.txt b/Tests/RunCMake/ObsoleteQtMacros/UseModulesMacro-WARN-stderr.txt new file mode 100644 index 0000000..b90c665 --- /dev/null +++ b/Tests/RunCMake/ObsoleteQtMacros/UseModulesMacro-WARN-stderr.txt @@ -0,0 +1,6 @@ +CMake Warning at .*/Modules/Qt4Macros.cmake:[^ ]+ \(message\): + The qt4_use_modules function is obsolete. Use target_link_libraries with + IMPORTED targets instead. +Call Stack \(most recent call first\): + UseModulesMacro-WARN.cmake:[^ ]+ \(qt4_use_modules\) + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/ObsoleteQtMacros/UseModulesMacro-WARN.cmake b/Tests/RunCMake/ObsoleteQtMacros/UseModulesMacro-WARN.cmake new file mode 100644 index 0000000..e86a372 --- /dev/null +++ b/Tests/RunCMake/ObsoleteQtMacros/UseModulesMacro-WARN.cmake @@ -0,0 +1,7 @@ + +find_package(Qt4 REQUIRED) + +set(CMAKE_WARN_DEPRECATED 1) + +add_library(foo SHARED empty.cpp) +qt4_use_modules(foo LINK_PRIVATE Core) diff --git a/Tests/RunCMake/ObsoleteQtMacros/empty.cpp b/Tests/RunCMake/ObsoleteQtMacros/empty.cpp new file mode 100644 index 0000000..7279c5e --- /dev/null +++ b/Tests/RunCMake/ObsoleteQtMacros/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty(void) +{ + return 0; +} diff --git a/Tests/RunCMake/TargetPolicies/CMakeLists.txt b/Tests/RunCMake/TargetPolicies/CMakeLists.txt new file mode 100644 index 0000000..e8db6b0 --- /dev/null +++ b/Tests/RunCMake/TargetPolicies/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-result.txt b/Tests/RunCMake/TargetPolicies/PolicyList-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetPolicies/PolicyList-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt new file mode 100644 index 0000000..6533b75 --- /dev/null +++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt @@ -0,0 +1,13 @@ + Error evaluating generator expression: + + \$<TARGET_POLICY:NOT_A_POLICY> + + \$<TARGET_POLICY:prop> may only be used with a limited number of policies. + Currently it may be used with the following policies: + + \* CMP0003 + \* CMP0004 + \* CMP0008 + \* CMP0020 + \* CMP0021 + \* CMP0022 diff --git a/Tests/RunCMake/TargetPolicies/PolicyList.cmake b/Tests/RunCMake/TargetPolicies/PolicyList.cmake new file mode 100644 index 0000000..c290b65 --- /dev/null +++ b/Tests/RunCMake/TargetPolicies/PolicyList.cmake @@ -0,0 +1,8 @@ + +enable_language(CXX) + +add_library(empty empty.cpp) +target_compile_definitions(empty + PRIVATE + $<$<TARGET_POLICY:NOT_A_POLICY>:SOME_DEFINE> +) diff --git a/Tests/RunCMake/TargetPolicies/RunCMakeTest.cmake b/Tests/RunCMake/TargetPolicies/RunCMakeTest.cmake new file mode 100644 index 0000000..7a94630 --- /dev/null +++ b/Tests/RunCMake/TargetPolicies/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(PolicyList) diff --git a/Tests/RunCMake/TargetPolicies/empty.cpp b/Tests/RunCMake/TargetPolicies/empty.cpp new file mode 100644 index 0000000..7279c5e --- /dev/null +++ b/Tests/RunCMake/TargetPolicies/empty.cpp @@ -0,0 +1,7 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif +int empty(void) +{ + return 0; +} diff --git a/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile-result.txt b/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile-stderr.txt b/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile-stderr.txt new file mode 100644 index 0000000..5d09c0c --- /dev/null +++ b/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CopyFileErrorNoCopyFile.cmake:1 \(try_compile\): + COPY_FILE_ERROR may be used only with COPY_FILE +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile.cmake b/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile.cmake new file mode 100644 index 0000000..8d7cb0e --- /dev/null +++ b/Tests/RunCMake/try_compile/CopyFileErrorNoCopyFile.cmake @@ -0,0 +1,2 @@ +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c + COPY_FILE_ERROR _copied) diff --git a/Tests/RunCMake/try_compile/NoCopyFileError-result.txt b/Tests/RunCMake/try_compile/NoCopyFileError-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/try_compile/NoCopyFileError-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/try_compile/NoCopyFileError-stderr.txt b/Tests/RunCMake/try_compile/NoCopyFileError-stderr.txt new file mode 100644 index 0000000..ed552fd --- /dev/null +++ b/Tests/RunCMake/try_compile/NoCopyFileError-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at NoCopyFileError.cmake:1 \(try_compile\): + COPY_FILE_ERROR must be followed by a variable name +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/try_compile/NoCopyFileError.cmake b/Tests/RunCMake/try_compile/NoCopyFileError.cmake new file mode 100644 index 0000000..d4d69ee --- /dev/null +++ b/Tests/RunCMake/try_compile/NoCopyFileError.cmake @@ -0,0 +1,2 @@ +try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c + COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/copied.bin COPY_FILE_ERROR) diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake index 3494695..c934458 100644 --- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake +++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake @@ -1,10 +1,12 @@ include(RunCMake) +run_cmake(CopyFileErrorNoCopyFile) run_cmake(NoArgs) run_cmake(OneArg) run_cmake(TwoArgs) run_cmake(NoCopyFile) run_cmake(NoCopyFile2) +run_cmake(NoCopyFileError) run_cmake(NoOutputVariable) run_cmake(NoOutputVariable2) run_cmake(NoSources) diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index 4540fd0..a4d9490 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -44,6 +44,23 @@ else() file(REMOVE "${TryCompile_BINARY_DIR}/CopyOfPass") endif() +# try to compile a file that should compile +# also check that COPY_FILE_ERROR works +file(WRITE ${TryCompile_BINARY_DIR}/invalid "") +try_compile(SHOULD_PASS + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/pass.c + OUTPUT_VARIABLE TRY_OUT + COPY_FILE ${TryCompile_BINARY_DIR}/invalid/path + COPY_FILE_ERROR _captured + ) +if(NOT SHOULD_PASS) + message(SEND_ERROR "should pass failed ${TRY_OUT}") +endif() +if(NOT _captured MATCHES "Cannot copy output executable.*/invalid/path") + message(SEND_ERROR "COPY_FILE_ERROR did not capture expected message") +endif() + # try to compile a file that should not compile try_compile(SHOULD_FAIL ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp @@ -89,6 +106,24 @@ if(SHOULD_FAIL) message(SEND_ERROR "Should fail passed ${TRY_OUT}") endif() +# try to compile a file that should compile +set(_c_flags "${CMAKE_C_FLAGS}") +if(CMAKE_GENERATOR STREQUAL "Visual Studio 6") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D \"TESTDEF\"") +elseif(WATCOM) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -dTESTDEF") +else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} \"-DTESTDEF\"") +endif() +try_compile(SHOULD_PASS + ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp + ${TryCompile_SOURCE_DIR}/testdef.c + OUTPUT_VARIABLE TRY_OUT) +if(NOT SHOULD_PASS) + message(SEND_ERROR "should pass failed ${TRY_OUT}") +endif() +set(CMAKE_C_FLAGS "${_c_flags}") + if(NOT SHOULD_FAIL) if(SHOULD_PASS) message("All Tests passed, ignore all previous output.") diff --git a/Tests/TryCompile/testdef.c b/Tests/TryCompile/testdef.c new file mode 100644 index 0000000..5401e71 --- /dev/null +++ b/Tests/TryCompile/testdef.c @@ -0,0 +1,4 @@ +#ifndef TESTDEF +# error "TESTDEF should be defined!" +#endif +int main(void) { return 0; } diff --git a/Utilities/cmcurl/Testing/sepheaders.c b/Utilities/cmcurl/Testing/sepheaders.c index 8185787..fc5b783 100644 --- a/Utilities/cmcurl/Testing/sepheaders.c +++ b/Utilities/cmcurl/Testing/sepheaders.c @@ -56,6 +56,7 @@ int main(int argc, char **argv) bodyfile = fopen(bodyfilename,"w"); if (bodyfile == NULL) { curl_easy_cleanup(curl_handle); + fclose(headerfile); return -1; } @@ -70,6 +71,7 @@ int main(int argc, char **argv) /* close the header file */ fclose(headerfile); + fclose(bodyfile); /* cleanup curl stuff */ curl_easy_cleanup(curl_handle); diff --git a/Utilities/cmcurl/Testing/simplessl.c b/Utilities/cmcurl/Testing/simplessl.c index 9a53603..e307eaa 100644 --- a/Utilities/cmcurl/Testing/simplessl.c +++ b/Utilities/cmcurl/Testing/simplessl.c @@ -114,5 +114,7 @@ int main(int argc, char **argv) curl_global_cleanup(); + if (headerfile) + fclose(headerfile); return 0; } diff --git a/Utilities/cmcurl/cookie.c b/Utilities/cmcurl/cookie.c index 2856ad8..d8ea241 100644 --- a/Utilities/cmcurl/cookie.c +++ b/Utilities/cmcurl/cookie.c @@ -969,6 +969,8 @@ int Curl_cookie_output(struct CookieInfo *c, char *dumphere) format_ptr = get_netscape_format(co); if (format_ptr == NULL) { fprintf(out, "#\n# Fatal libcurl error\n"); + if(!use_stdout) + fclose(out); return 1; } fprintf(out, "%s\n", format_ptr); diff --git a/Utilities/cmlibarchive/libarchive/archive_string.c b/Utilities/cmlibarchive/libarchive/archive_string.c index cbfad2c..370a5fc 100644 --- a/Utilities/cmlibarchive/libarchive/archive_string.c +++ b/Utilities/cmlibarchive/libarchive/archive_string.c @@ -1248,8 +1248,8 @@ create_sconv_object(const char *fc, const char *tc, } sc->to_charset = strdup(tc); if (sc->to_charset == NULL) { - free(sc); free(sc->from_charset); + free(sc); return (NULL); } archive_string_init(&sc->utftmp); |