summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt11
-rw-r--r--CTestCustom.cmake.in1
-rw-r--r--Help/release/dev/java-updates.rst3
-rw-r--r--Modules/FindJNI.cmake10
-rw-r--r--Modules/GenerateExportHeader.cmake2
-rw-r--r--Modules/Platform/Darwin.cmake2
-rw-r--r--Modules/UseJava.cmake157
-rw-r--r--Source/CMakeLists.txt7
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/cmCPackGenerator.cxx6
-rw-r--r--Source/CPack/cpack.cxx10
-rw-r--r--Source/CTest/cmCTestBZR.cxx1
-rw-r--r--Source/CTest/cmCTestGIT.cxx1
-rw-r--r--Source/CTest/cmCTestLaunch.cxx5
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx16
-rw-r--r--Source/CTest/cmCTestP4.cxx1
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx46
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx7
-rw-r--r--Source/cmCPluginAPI.cxx4
-rw-r--r--Source/cmCTest.cxx12
-rw-r--r--Source/cmComputeLinkDepends.cxx28
-rw-r--r--Source/cmComputeLinkDepends.h2
-rw-r--r--Source/cmComputeLinkInformation.cxx12
-rw-r--r--Source/cmComputeTargetDepends.cxx7
-rw-r--r--Source/cmExportFileGenerator.cxx10
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx2
-rw-r--r--Source/cmExtraKateGenerator.cxx1
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx1
-rw-r--r--Source/cmGeneratorExpressionNode.cxx4
-rw-r--r--Source/cmGeneratorTarget.cxx1229
-rw-r--r--Source/cmGeneratorTarget.h83
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx9
-rw-r--r--Source/cmGlobalBorlandMakefileGenerator.cxx4
-rw-r--r--Source/cmGlobalBorlandMakefileGenerator.h3
-rw-r--r--Source/cmGlobalGenerator.cxx149
-rw-r--r--Source/cmGlobalGenerator.h15
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx5
-rw-r--r--Source/cmGlobalGhsMultiGenerator.h3
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx5
-rw-r--r--Source/cmGlobalNinjaGenerator.h14
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx44
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.h4
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx7
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h3
-rw-r--r--Source/cmGlobalVisualStudio6Generator.cxx5
-rw-r--r--Source/cmGlobalVisualStudio6Generator.h5
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx7
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h3
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx8
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx30
-rw-r--r--Source/cmGlobalXCodeGenerator.h3
-rw-r--r--Source/cmGraphVizWriter.cxx5
-rw-r--r--Source/cmLinkItem.h62
-rw-r--r--Source/cmLocalCommonGenerator.cxx5
-rw-r--r--Source/cmLocalCommonGenerator.h4
-rw-r--r--Source/cmLocalGenerator.cxx85
-rw-r--r--Source/cmLocalGenerator.h15
-rw-r--r--Source/cmLocalGhsMultiGenerator.cxx5
-rw-r--r--Source/cmLocalGhsMultiGenerator.h3
-rw-r--r--Source/cmLocalNinjaGenerator.cxx5
-rw-r--r--Source/cmLocalNinjaGenerator.h3
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx9
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.h4
-rw-r--r--Source/cmLocalVisualStudio10Generator.cxx6
-rw-r--r--Source/cmLocalVisualStudio10Generator.h4
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx11
-rw-r--r--Source/cmLocalVisualStudio6Generator.h4
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx15
-rw-r--r--Source/cmLocalVisualStudio7Generator.h4
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx6
-rw-r--r--Source/cmLocalVisualStudioGenerator.h4
-rw-r--r--Source/cmLocalXCodeGenerator.cxx5
-rw-r--r--Source/cmLocalXCodeGenerator.h4
-rw-r--r--Source/cmMakefile.cxx57
-rw-r--r--Source/cmMakefile.h18
-rw-r--r--Source/cmMakefileTargetGenerator.cxx2
-rw-r--r--Source/cmProjectCommand.cxx2
-rw-r--r--Source/cmQtAutoGenerators.cxx21
-rw-r--r--Source/cmState.cxx34
-rw-r--r--Source/cmState.h12
-rw-r--r--Source/cmSystemTools.cxx91
-rw-r--r--Source/cmSystemTools.h3
-rw-r--r--Source/cmTarget.cxx1287
-rw-r--r--Source/cmTarget.h109
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx20
-rw-r--r--Source/cmake.cxx20
-rw-r--r--Source/cmcmd.cxx5
-rw-r--r--Source/kwsys/CMakeEmptyInputFile.in1
-rw-r--r--Source/kwsys/CMakeLists.txt12
-rw-r--r--Source/kwsys/SystemTools.cxx71
-rw-r--r--Source/kwsys/SystemTools.hxx.in156
-rw-r--r--Source/kwsys/testProcess.c28
-rw-r--r--Source/kwsys/testSystemTools.cxx196
-rw-r--r--Tests/CMakeLists.txt25
-rw-r--r--Tests/JavaJavah/B.cpp10
-rw-r--r--Tests/JavaJavah/B.java19
-rw-r--r--Tests/JavaJavah/CMakeLists.txt20
-rw-r--r--Tests/JavaJavah/HelloWorld2.java10
-rw-r--r--Tests/Module/GenerateExportHeader/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/CPackConfig/CMakeLists.txt6
-rw-r--r--Tests/RunCMake/CPackConfig/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/CPackConfig/Simple-check.cmake3
-rw-r--r--Tests/RunCMake/CPackConfig/Simple.cmake1
-rw-r--r--Tests/RunCMake/CPackConfig/check.cmake7
-rw-r--r--Tests/RunCMake/XcodeProject/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeTbdStub-stdout.txt1
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeTbdStub.cmake2
-rw-r--r--Tests/RunCMake/XcodeProject/osx.cmake18
110 files changed, 2675 insertions, 1885 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 36244dd..5e13a7e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -144,17 +144,6 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
endmacro()
-
-
-
-if(NOT CMake_TEST_EXTERNAL_CMAKE)
- set(CMAKE_BUILD_ON_VISUAL_STUDIO 0)
- if(WIN32 AND NOT UNIX AND NOT MINGW)
- set(CMAKE_BUILD_ON_VISUAL_STUDIO 1)
- endif()
-endif()
-
-
#-----------------------------------------------------------------------
# a macro to determine the generator and ctest executable to use
# for testing. Simply to improve readability of the main script.
diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in
index f29ac70..d3cff51 100644
--- a/CTestCustom.cmake.in
+++ b/CTestCustom.cmake.in
@@ -32,6 +32,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION
"remark: .*LOOP WAS VECTORIZED"
"warning .980: wrong number of actual arguments to intrinsic function .std::basic_"
"LINK : warning LNK4089: all references to.*ADVAPI32.dll.*discarded by /OPT:REF"
+ "LINK : warning LNK4089: all references to.*CRYPT32.dll.*discarded by /OPT:REF"
"LINK : warning LNK4089: all references to.*PSAPI.DLL.*discarded by /OPT:REF"
"LINK : warning LNK4089: all references to.*RPCRT4.dll.*discarded by /OPT:REF"
"LINK : warning LNK4089: all references to.*SHELL32.dll.*discarded by /OPT:REF"
diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst
index b777807..8fd4ed6 100644
--- a/Help/release/dev/java-updates.rst
+++ b/Help/release/dev/java-updates.rst
@@ -11,3 +11,6 @@ java-updates
* The :module:`UseJava` module ``install_jar`` function learned
new ``DESTINATION`` and ``COMPONENT`` options to specify
the corresponding :command:`install` command options.
+
+* The :module:`UseJava` module gained a new ``create_javah``
+ function to create C headers from Java classes.
diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake
index d31fea3..cbe21d7 100644
--- a/Modules/FindJNI.cmake
+++ b/Modules/FindJNI.cmake
@@ -57,7 +57,7 @@ macro(java_append_library_directories _var)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
# mips* machines are bi-endian mostly so processor does not tell
# endianess of the underlying system.
- set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb")
+ set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "mips" "mipsel" "mipseb" "mips64" "mips64el" "mipsn32" "mipsn32el")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64le")
set(_java_libarch "ppc64" "ppc64le")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
@@ -156,6 +156,9 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
/usr/local/jre-1.7.0/lib/{libarch}
/usr/local/jdk-1.6.0/jre/lib/{libarch}
/usr/local/jre-1.6.0/lib/{libarch}
+ # SuSE specific paths for default JVM
+ /usr/lib64/jvm/java/jre/lib/{libarch}
+ /usr/lib64/jvm/jre/lib/{libarch}
)
set(JAVA_JVM_LIBRARY_DIRECTORIES)
@@ -164,6 +167,9 @@ foreach(dir ${JAVA_AWT_LIBRARY_DIRECTORIES})
"${dir}"
"${dir}/client"
"${dir}/server"
+ # IBM SDK, Java Technology Edition, specific paths
+ "${dir}/j9vm"
+ "${dir}/default"
)
endforeach()
@@ -193,6 +199,8 @@ list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES
# OpenBSD specific path for default JVM
/usr/local/jdk-1.7.0/include
/usr/local/jdk-1.6.0/include
+ # SuSE specific paths for default JVM
+ /usr/lib64/jvm/java/include
)
foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake
index aab29ea..8205425 100644
--- a/Modules/GenerateExportHeader.cmake
+++ b/Modules/GenerateExportHeader.cmake
@@ -268,7 +268,7 @@ macro(_DO_SET_MACRO_VALUES TARGET_LIBRARY)
get_property(type TARGET ${TARGET_LIBRARY} PROPERTY TYPE)
if(NOT ${type} STREQUAL "STATIC_LIBRARY")
- if(WIN32)
+ if(WIN32 OR CYGWIN)
set(DEFINE_EXPORT "__declspec(dllexport)")
set(DEFINE_IMPORT "__declspec(dllimport)")
elseif(COMPILER_HAS_HIDDEN_VISIBILITY AND USE_COMPILER_HIDDEN_VISIBILITY)
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
index 4e4810a..bb085ac 100644
--- a/Modules/Platform/Darwin.cmake
+++ b/Modules/Platform/Darwin.cmake
@@ -53,7 +53,7 @@ set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names")
set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
-set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
+set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a")
# hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree
# (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake
index c61591d..dced6ec 100644
--- a/Modules/UseJava.cmake
+++ b/Modules/UseJava.cmake
@@ -309,6 +309,65 @@
#
#
# if you don't set the INSTALLPATH.
+#
+# ::
+#
+# create_javah(TARGET <target>
+# GENERATED_FILES <VAR>
+# CLASSES <class>...
+# [CLASSPATH <classpath>...]
+# [DEPENDS <depend>...]
+# [OUTPUT_NAME <path>|OUTPUT_DIR <path>]
+# )
+#
+# Create C header files from java classes. These files provide the connective glue
+# that allow your Java and C code to interact.
+#
+# There are two main signatures for create_javah. The first signature
+# returns generated files throught variable specified by GENERATED_FILES option:
+#
+# ::
+#
+# Example:
+# Create_javah(GENERATED_FILES files_headers
+# CLASSES org.cmake.HelloWorld
+# CLASSPATH hello.jar
+# )
+#
+#
+#
+# The second signature for create_javah creates a target which encapsulates
+# header files generation.
+#
+# ::
+#
+# Example:
+# Create_javah(TARGET target_headers
+# CLASSES org.cmake.HelloWorld
+# CLASSPATH hello.jar
+# )
+#
+#
+#
+# Both signatures share same options.
+#
+# ``CLASSES <class>...``
+# Specifies Java classes used to generate headers.
+#
+# ``CLASSPATH <classpath>...``
+# Specifies various paths to look up classes. Here .class files, jar files or targets
+# created by command add_jar can be used.
+#
+# ``DEPENDS <depend>...``
+# Targets on which the javah target depends
+#
+# ``OUTPUT_NAME <path>``
+# Concatenates the resulting header files for all the classes listed by option CLASSES
+# into <path>. Same behavior as option '-o' of javah tool.
+#
+# ``OUTPUT_DIR <path>``
+# Sets the directory where the header files will be generated. Same behavior as option
+# '-d' of javah tool. If not specified, ${CMAKE_CURRENT_BINARY_DIR} is used as output directory.
#=============================================================================
# Copyright 2013 OpenGamma Ltd. <graham@opengamma.com>
@@ -1131,3 +1190,101 @@ function(create_javadoc _target)
DESTINATION ${_javadoc_installpath}
)
endfunction()
+
+function (create_javah)
+ cmake_parse_arguments(_create_javah
+ ""
+ "TARGET;GENERATED_FILES;OUTPUT_NAME;OUTPUT_DIR"
+ "CLASSES;CLASSPATH;DEPENDS"
+ ${ARGN})
+
+ # ckeck parameters
+ if (NOT _create_javah_TARGET AND NOT _create_javah_GENERATED_FILES)
+ message (FATAL_ERROR "create_javah: TARGET or GENERATED_FILES must be specified.")
+ endif()
+ if (_create_javah_OUTPUT_NAME AND _create_javah_OUTPUT_DIR)
+ message (FATAL_ERROR "create_javah: OUTPUT_NAME and OUTPUT_DIR are mutually exclusive.")
+ endif()
+
+ if (NOT _create_javah_CLASSES)
+ message (FATAL_ERROR "create_javah: CLASSES is a required parameter.")
+ endif()
+
+ set (_output_files)
+ if (WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
+ set(_classpath_sep ";")
+ else ()
+ set(_classpath_sep ":")
+ endif()
+
+ # handle javah options
+ set (_javah_options)
+
+ if (_create_javah_CLASSPATH)
+ # CLASSPATH can specify directories, jar files or targets created with add_jar command
+ set (_classpath)
+ foreach (_path IN LISTS _create_javah_CLASSPATH)
+ if (TARGET ${_path})
+ get_target_property (_jar_path ${_path} JAR_FILE)
+ if (_jar_path)
+ list (APPEND _classpath "${_jar_path}")
+ list (APPEND _create_javah_DEPENDS "${_path}")
+ else()
+ message(SEND_ERROR "create_javah: CLASSPATH target ${_path} is not a jar.")
+ endif()
+ elseif (EXISTS "${_path}")
+ list (APPEND _classpath "${_path}")
+ if (NOT IS_DIRECTORY "${_path}")
+ list (APPEND _create_javah_DEPENDS "${_path}")
+ endif()
+ else()
+ message(SEND_ERROR "create_javah: CLASSPATH entry ${_path} does not exist.")
+ endif()
+ endforeach()
+ string (REPLACE ";" "${_classpath_sep}" _classpath "${_classpath}")
+ list (APPEND _javah_options -classpath ${_classpath})
+ endif()
+
+ if (_create_javah_OUTPUT_DIR)
+ list (APPEND _javah_options -d "${_create_javah_OUTPUT_DIR}")
+ endif()
+
+ if (_create_javah_OUTPUT_NAME)
+ list (APPEND _javah_options -o "${_create_javah_OUTPUT_NAME}")
+ set (_output_files "${_create_javah_OUTPUT_NAME}")
+
+ get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_NAME}" DIRECTORY)
+ get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_DIR}" ABSOLUTE)
+ endif()
+
+ if (NOT _create_javah_OUTPUT_DIR)
+ set (_create_javah_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+ endif()
+
+ if (NOT _create_javah_OUTPUT_NAME)
+ # compute output names
+ foreach (_class IN LISTS _create_javah_CLASSES)
+ string (REPLACE "." "_" _c_header "${_class}")
+ set (_c_header "${_create_javah_OUTPUT_DIR}/${_c_header}.h")
+ list (APPEND _output_files "${_c_header}")
+ endforeach()
+ endif()
+
+ # finalize custom command arguments
+ if (_create_javah_DEPENDS)
+ list (INSERT _create_javah_DEPENDS 0 DEPENDS)
+ endif()
+
+ add_custom_command (OUTPUT ${_output_files}
+ COMMAND "${Java_JAVAH_EXECUTABLE}" ${_javah_options} -jni ${_create_javah_CLASSES}
+ ${_create_javah_DEPENDS}
+ WORKING_DIRECTORY ${_create_javah_OUTPUT_DIR}
+ COMMENT "Building C header files from classes...")
+
+ if (_create_javah_TARGET)
+ add_custom_target (${_create_javah_TARGET} ALL DEPENDS ${_output_files})
+ endif()
+ if (_create_javah_GENERATED_FILES)
+ set (${_create_javah_GENERATED_FILES} ${_output_files} PARENT_SCOPE)
+ endif()
+endfunction()
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 428b364..16b9ea1 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -556,9 +556,10 @@ if(APPLE)
target_link_libraries(CMakeLib "-framework CoreFoundation")
endif()
-if(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW)
- # We need the rpcrt4 library for at least the VS7-VC10 generators.
- target_link_libraries(CMakeLib rpcrt4)
+if(WIN32 AND NOT UNIX)
+ # We need the rpcrt4 library on Windows.
+ # We need the crypt32 library on Windows for crypto/cert APIs.
+ target_link_libraries(CMakeLib rpcrt4 crypt32)
endif()
#
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 4e0b28c..f7d1ba6 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 3)
-set(CMake_VERSION_PATCH 20150825)
+set(CMake_VERSION_PATCH 20150901)
#set(CMake_VERSION_RC 1)
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index bf4df60..92a4b2b 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -716,8 +716,10 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
cm.AddCMakePaths();
cm.SetProgressCallback(cmCPackGeneratorProgress, this);
cmGlobalGenerator gg(&cm);
- cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
- cmMakefile *mf = lg->GetMakefile();
+ cmsys::auto_ptr<cmMakefile> mf(
+ new cmMakefile(&gg, cm.GetCurrentSnapshot()));
+ cmsys::auto_ptr<cmLocalGenerator> lg(
+ gg.CreateLocalGenerator(mf.get()));
std::string realInstallDirectory = tempInstallDirectory;
if ( !installSubDirectory.empty() && installSubDirectory != "/" )
{
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index c2fe763..cb9cbc4 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -202,8 +202,10 @@ int main (int argc, char const* const* argv)
cminst.SetHomeOutputDirectory("");
cminst.GetState()->RemoveUnscriptableCommands();
cmGlobalGenerator cmgg(&cminst);
- cmsys::auto_ptr<cmLocalGenerator> cmlg(cmgg.MakeLocalGenerator());
- cmMakefile* globalMF = cmlg->GetMakefile();
+ cmsys::auto_ptr<cmMakefile> globalMF(
+ new cmMakefile(&cmgg, cminst.GetCurrentSnapshot()));
+ cmsys::auto_ptr<cmLocalGenerator> cmlg(
+ cmgg.CreateLocalGenerator(globalMF.get()));
#if defined(__CYGWIN__)
globalMF->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
#endif
@@ -357,8 +359,8 @@ int main (int argc, char const* const* argv)
++it )
{
const char* gen = it->c_str();
- cmMakefile::ScopePushPop raii(globalMF);
- cmMakefile* mf = globalMF;
+ cmMakefile::ScopePushPop raii(globalMF.get());
+ cmMakefile* mf = globalMF.get();
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Specified generator: " << gen << std::endl);
if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx
index 3014a93..587b583 100644
--- a/Source/CTest/cmCTestBZR.cxx
+++ b/Source/CTest/cmCTestBZR.cxx
@@ -14,7 +14,6 @@
#include "cmCTest.h"
#include "cmSystemTools.h"
#include "cmXMLParser.h"
-#include "cmXMLSafe.h"
#include <cmsys/RegularExpression.hxx>
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx
index 5b9208a..bbb3b9d 100644
--- a/Source/CTest/cmCTestGIT.cxx
+++ b/Source/CTest/cmCTestGIT.cxx
@@ -14,7 +14,6 @@
#include "cmCTest.h"
#include "cmSystemTools.h"
#include "cmAlgorithms.h"
-#include "cmXMLSafe.h"
#include <cmsys/RegularExpression.hxx>
#include <cmsys/Process.h>
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index 0f588c5..fb0cce6 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -738,8 +738,9 @@ void cmCTestLaunch::LoadConfig()
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg(&cm);
- cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
- cmMakefile* mf = lg->GetMakefile();
+ cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
+ cmsys::auto_ptr<cmLocalGenerator> lg(
+ gg.CreateLocalGenerator(mf.get()));
std::string fname = this->LogDir;
fname += "CTestLaunchConfig.cmake";
if(cmSystemTools::FileExists(fname.c_str()) &&
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index 8f26716..acf527a 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -80,8 +80,8 @@ public:
int i = 0;
for(; atts[i] != 0; i+=2)
{
- ostr << " " << cmXMLSafe(atts[i])
- << " - " << cmXMLSafe(atts[i+1]) << "\n";
+ ostr << " " << atts[i]
+ << " - " << atts[i+1] << "\n";
}
ostr << "\n";
this->Log += ostr.str();
@@ -856,7 +856,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
defects++;
ostr << "<b>" << this->ResultStrings[idx] << "</b> ";
}
- ostr << cmXMLSafe(*i) << std::endl;
+ ostr << *i << std::endl;
}
log = ostr.str();
if(defects)
@@ -908,7 +908,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
results[failure] ++;
defects ++;
}
- ostr << cmXMLSafe(*i) << std::endl;
+ ostr << *i << std::endl;
}
log = ostr.str();
@@ -1056,7 +1056,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
defects ++;
}
totalOutputSize += lines[cc].size();
- ostr << cmXMLSafe(lines[cc]) << std::endl;
+ ostr << lines[cc] << std::endl;
}
else
{
@@ -1070,11 +1070,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
nonValGrindOutput.begin(); i != nonValGrindOutput.end(); ++i)
{
totalOutputSize += lines[*i].size();
- cmCTestOptionalLog(this->CTest, DEBUG, "before xml safe "
- << lines[*i] << std::endl, this->Quiet);
- cmCTestOptionalLog(this->CTest, DEBUG, "after xml safe "
- << cmXMLSafe(lines[*i]) << std::endl, this->Quiet);
- ostr << cmXMLSafe(lines[*i]) << std::endl;
+ ostr << lines[*i] << std::endl;
if(!unlimitedOutput && totalOutputSize >
static_cast<size_t>(this->CustomMaximumFailedTestOutputSize))
{
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx
index 5ce431a..5e0c54a 100644
--- a/Source/CTest/cmCTestP4.cxx
+++ b/Source/CTest/cmCTestP4.cxx
@@ -13,7 +13,6 @@
#include "cmCTest.h"
#include "cmSystemTools.h"
-#include "cmXMLSafe.h"
#include <cmsys/RegularExpression.hxx>
#include <cmsys/Process.h>
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 047bd98..c1ba279 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -125,42 +125,25 @@ void cmCTestScriptHandler::Initialize()
// what time in seconds did this script start running
this->ScriptStartTime = 0;
+ delete this->Makefile;
this->Makefile = 0;
- if (this->LocalGenerator)
- {
- delete this->LocalGenerator;
- }
+
+ delete this->LocalGenerator;
this->LocalGenerator = 0;
- if (this->GlobalGenerator)
- {
- delete this->GlobalGenerator;
- }
+
+ delete this->GlobalGenerator;
this->GlobalGenerator = 0;
- if (this->CMake)
- {
- delete this->CMake;
- }
+
+ delete this->CMake;
}
//----------------------------------------------------------------------
cmCTestScriptHandler::~cmCTestScriptHandler()
{
- // local generator owns the makefile
- this->Makefile = 0;
- if (this->LocalGenerator)
- {
- delete this->LocalGenerator;
- }
- this->LocalGenerator = 0;
- if (this->GlobalGenerator)
- {
- delete this->GlobalGenerator;
- }
- this->GlobalGenerator = 0;
- if (this->CMake)
- {
- delete this->CMake;
- }
+ delete this->Makefile;
+ delete this->LocalGenerator;
+ delete this->GlobalGenerator;
+ delete this->CMake;
}
@@ -334,6 +317,7 @@ void cmCTestScriptHandler::CreateCMake()
delete this->CMake;
delete this->GlobalGenerator;
delete this->LocalGenerator;
+ delete this->Makefile;
}
this->CMake = new cmake;
this->CMake->SetHomeDirectory("");
@@ -341,8 +325,10 @@ void cmCTestScriptHandler::CreateCMake()
this->CMake->AddCMakePaths();
this->GlobalGenerator = new cmGlobalGenerator(this->CMake);
- this->LocalGenerator = this->GlobalGenerator->MakeLocalGenerator();
- this->Makefile = this->LocalGenerator->GetMakefile();
+ cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot();
+ this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot);
+ this->LocalGenerator =
+ this->GlobalGenerator->CreateLocalGenerator(this->Makefile);
this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest);
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index c8a0d27..f9678e7 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -1592,8 +1592,9 @@ void cmCTestTestHandler::GetListOfTests()
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg(&cm);
- cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
- cmMakefile *mf = lg->GetMakefile();
+ cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
+ cmsys::auto_ptr<cmLocalGenerator> lg(
+ gg.CreateLocalGenerator(mf.get()));
mf->AddDefinition("CTEST_CONFIGURATION_TYPE",
this->CTest->GetConfigType().c_str());
@@ -2091,7 +2092,7 @@ bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t length)
}
current = next;
}
- else // Bad byte will be handled by cmXMLSafe.
+ else // Bad byte will be handled by cmXMLWriter.
{
++current;
}
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index 591a2cd..7da334e 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -115,7 +115,9 @@ void CCONV cmAddCacheDefinition(void *arg, const char* name,
const char* CCONV cmGetProjectName(void *arg)
{
cmMakefile *mf = static_cast<cmMakefile *>(arg);
- return mf->GetProjectName();
+ static std::string name;
+ name = mf->GetProjectName();
+ return name.c_str();
}
const char* CCONV cmGetHomeDirectory(void *arg)
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index b976469..b2ad4a8 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -22,7 +22,6 @@
#include <cmsys/FStream.hxx>
#include "cmDynamicLoader.h"
#include "cmGeneratedFileStream.h"
-#include "cmXMLSafe.h"
#include "cmVersionMacros.h"
#include "cmCTestCommand.h"
#include "cmCTestStartCommand.h"
@@ -156,7 +155,7 @@ std::string cmCTest::CurrentTime()
strftime(current_time, 1000, "%a %b %d %H:%M:%S %Z %Y", t);
}
cmCTestLog(this, DEBUG, " Current_Time: " << current_time << std::endl);
- return cmXMLSafe(cmCTest::CleanString(current_time)).str();
+ return cmCTest::CleanString(current_time);
}
//----------------------------------------------------------------------
@@ -520,9 +519,10 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg(&cm);
- cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
- cmMakefile *mf = lg->GetMakefile();
- if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) )
+ cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
+ cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator(mf.get()));
+ if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(),
+ mf.get()) )
{
cmCTestOptionalLog(this, DEBUG,
"Cannot find custom configuration file tree" << std::endl, quiet);
@@ -1497,8 +1497,6 @@ std::string cmCTest::SafeBuildIdField(const std::string& value)
cmSystemTools::ReplaceString(safevalue, replace, "");
}
}
-
- safevalue = cmXMLSafe(safevalue).str();
}
if (safevalue == "")
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 59590fd..1b5c9f4 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -12,6 +12,7 @@
#include "cmComputeLinkDepends.h"
#include "cmComputeComponentGraph.h"
+#include "cmLocalGenerator.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmTarget.h"
@@ -177,7 +178,8 @@ cmComputeLinkDepends
// Store context information.
this->Target = target;
this->Makefile = this->Target->Target->GetMakefile();
- this->GlobalGenerator = this->Makefile->GetGlobalGenerator();
+ this->GlobalGenerator =
+ this->Target->GetLocalGenerator()->GetGlobalGenerator();
this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
// The configuration being linked.
@@ -360,9 +362,11 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe)
// Follow the item's dependencies.
if(entry.Target)
{
+ cmGeneratorTarget* gtgt =
+ this->GlobalGenerator->GetGeneratorTarget(entry.Target);
// Follow the target dependencies.
- if(cmTarget::LinkInterface const* iface =
- entry.Target->GetLinkInterface(this->Config, this->Target->Target))
+ if(cmLinkInterface const* iface =
+ gtgt->GetLinkInterface(this->Config, this->Target->Target))
{
const bool isIface =
entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY;
@@ -396,7 +400,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe)
//----------------------------------------------------------------------------
void
cmComputeLinkDepends
-::FollowSharedDeps(int depender_index, cmTarget::LinkInterface const* iface,
+::FollowSharedDeps(int depender_index, cmLinkInterface const* iface,
bool follow_interface)
{
// Follow dependencies if we have not followed them already.
@@ -459,8 +463,10 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
// Target items may have their own dependencies.
if(entry.Target)
{
- if(cmTarget::LinkInterface const* iface =
- entry.Target->GetLinkInterface(this->Config, this->Target->Target))
+ cmGeneratorTarget* gtgt =
+ this->GlobalGenerator->GetGeneratorTarget(entry.Target);
+ if(cmLinkInterface const* iface =
+ gtgt->GetLinkInterface(this->Config, this->Target->Target))
{
// Follow public and private dependencies transitively.
this->FollowSharedDeps(index, iface, true);
@@ -550,8 +556,8 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
void cmComputeLinkDepends::AddDirectLinkEntries()
{
// Add direct link dependencies in this configuration.
- cmTarget::LinkImplementation const* impl =
- this->Target->Target->GetLinkImplementation(this->Config);
+ cmLinkImplementation const* impl =
+ this->Target->GetLinkImplementation(this->Config);
this->AddLinkEntries(-1, impl->Libraries);
for(std::vector<cmLinkItem>::const_iterator
wi = impl->WrongConfigLibraries.begin();
@@ -930,8 +936,10 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
{
if(cmTarget const* target = this->EntryList[*ni].Target)
{
- if(cmTarget::LinkInterface const* iface =
- target->GetLinkInterface(this->Config, this->Target->Target))
+ cmGeneratorTarget* gtgt =
+ this->GlobalGenerator->GetGeneratorTarget(target);
+ if(cmLinkInterface const* iface =
+ gtgt->GetLinkInterface(this->Config, this->Target->Target))
{
if(iface->Multiplicity > count)
{
diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h
index b925a4f..2cbb430 100644
--- a/Source/cmComputeLinkDepends.h
+++ b/Source/cmComputeLinkDepends.h
@@ -102,7 +102,7 @@ private:
std::queue<SharedDepEntry> SharedDepQueue;
std::set<int> SharedDepFollowed;
void FollowSharedDeps(int depender_index,
- cmTarget::LinkInterface const* iface,
+ cmLinkInterface const* iface,
bool follow_interface = false);
void QueueSharedDependencies(int depender_index,
std::vector<cmLinkItem> const& deps);
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 6ba0eed..d35b566 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -522,10 +522,9 @@ bool cmComputeLinkInformation::Compute()
// libraries are found.
const char* lss =
this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC");
- if(lss)
+ if(cmSystemTools::IsOn(lss))
{
- this->SetCurrentLinkType(
- cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared);
+ this->SetCurrentLinkType(LinkStatic);
}
else
{
@@ -769,7 +768,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item,
std::string lib;
if(tgt)
{
- gtgt = tgt->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(tgt);
+ gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt);
lib = gtgt->GetFullPath(this->Config, this->UseImportLibrary);
this->AddLibraryRuntimeInfo(lib, tgt);
@@ -863,8 +862,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo()
const char* lss =
this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC");
this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared;
- this->CurrentLinkType = LinkUnknown;
- this->SetCurrentLinkType(this->StartLinkType);
+ this->CurrentLinkType = this->StartLinkType;
}
//----------------------------------------------------------------------------
@@ -1925,7 +1923,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
(outputRuntime && this->Target->Target->HaveInstallTreeRPATH() &&
linking_for_install);
bool use_build_rpath =
- (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) &&
+ (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) &&
!linking_for_install);
bool use_link_rpath =
outputRuntime && linking_for_install &&
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index c4a03a0..9e37c35 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -252,8 +252,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
}
}
- cmTarget::LinkImplementation const* impl =
- depender->Target->GetLinkImplementation(*it);
+ cmLinkImplementation const* impl = depender->GetLinkImplementation(*it);
// A target should not depend on itself.
emitted.insert(depender->GetName());
@@ -296,8 +295,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
std::set<std::string> &emitted)
{
cmGeneratorTarget const* depender = this->Targets[depender_index];
- if(cmTarget::LinkInterface const* iface =
- dependee->Target->GetLinkInterface(config,
+ if(cmLinkInterface const* iface =
+ dependee->GetLinkInterface(config,
depender->Target))
{
for(std::vector<cmLinkItem>::const_iterator
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index cae60b7..9a7d73f 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -796,9 +796,8 @@ cmExportFileGenerator
std::vector<std::string>& missingTargets)
{
// Add the transitive link dependencies for this configuration.
- cmTarget::LinkInterface const* iface = target->Target->GetLinkInterface(
- config,
- target->Target);
+ cmLinkInterface const* iface = target->GetLinkInterface(config,
+ target->Target);
if (!iface)
{
return;
@@ -909,9 +908,8 @@ cmExportFileGenerator
}
// Add the transitive link dependencies for this configuration.
- if(cmTarget::LinkInterface const* iface =
- target->Target
- ->GetLinkInterface(config, target->Target))
+ if(cmLinkInterface const* iface =
+ target->GetLinkInterface(config, target->Target))
{
this->SetImportLinkProperty(suffix, target,
"IMPORTED_LINK_INTERFACE_LANGUAGES",
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 933a256..dfd51c7 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -609,7 +609,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
// the compilerdefines for this target
std::vector<std::string> cdefs;
- target->GetCompileDefinitions(cdefs, buildType, "C");
+ gtgt->GetCompileDefinitions(cdefs, buildType, "C");
// Expand the list.
for(std::vector<std::string>::const_iterator di = cdefs.begin();
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx
index 578e7d3..f83b5cf 100644
--- a/Source/cmExtraKateGenerator.cxx
+++ b/Source/cmExtraKateGenerator.cxx
@@ -19,7 +19,6 @@
#include "cmGeneratedFileStream.h"
#include "cmTarget.h"
#include "cmSystemTools.h"
-#include "cmXMLSafe.h"
#include <cmsys/SystemTools.hxx>
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 4e721d4..163a75b 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -21,7 +21,6 @@
#include "cmSourceFile.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
-#include "cmXMLSafe.h"
#include <cmsys/SystemTools.hxx>
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 03bc83a..31b6766 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -1108,8 +1108,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
if(isInterfaceProperty)
{
- if(cmTarget::LinkInterfaceLibraries const* iface =
- target->GetLinkInterfaceLibraries(context->Config, headTarget, true))
+ if(cmLinkInterfaceLibraries const* iface =
+ gtgt->GetLinkInterfaceLibraries(context->Config, headTarget, true))
{
linkedTargetsContent =
getLinkedTargetsContent(iface->Libraries, target,
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index dd58e7b..09387b7 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -34,6 +34,18 @@
#define UNORDERED_SET std::set
#endif
+class cmGeneratorTarget::TargetPropertyEntry {
+ static cmLinkImplItem NoLinkImplItem;
+public:
+ TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge,
+ cmLinkImplItem const& item = NoLinkImplItem)
+ : ge(cge), LinkImplItem(item)
+ {}
+ const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge;
+ cmLinkImplItem const& LinkImplItem;
+};
+cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem;
+
//----------------------------------------------------------------------------
void reportBadObjLib(std::vector<cmSourceFile*> const& badObjLib,
cmGeneratorTarget const* target, cmake *cm)
@@ -227,18 +239,64 @@ struct TagVisitor
}
};
+void CreatePropertyGeneratorExpressions(
+ cmStringRange const& entries,
+ cmBacktraceRange const& backtraces,
+ std::vector<cmGeneratorTarget::TargetPropertyEntry*>& items,
+ bool evaluateForBuildsystem = false)
+{
+ std::vector<cmListFileBacktrace>::const_iterator btIt = backtraces.begin();
+ for (std::vector<std::string>::const_iterator it = entries.begin();
+ it != entries.end(); ++it, ++btIt)
+ {
+ cmGeneratorExpression ge(*btIt);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*it);
+ cge->SetEvaluateForBuildsystem(evaluateForBuildsystem);
+ items.push_back(new cmGeneratorTarget::TargetPropertyEntry(cge));
+ }
+}
+
//----------------------------------------------------------------------------
cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
: Target(t),
- SourceFileFlagsConstructed(false)
+ SourceFileFlagsConstructed(false),
+ PolicyWarnedCMP0022(false),
+ DebugIncludesDone(false),
+ DebugCompileOptionsDone(false),
+ DebugCompileFeaturesDone(false),
+ DebugCompileDefinitionsDone(false)
{
this->Makefile = this->Target->GetMakefile();
this->LocalGenerator = lg;
this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator();
+
+ CreatePropertyGeneratorExpressions(
+ t->GetIncludeDirectoriesEntries(),
+ t->GetIncludeDirectoriesBacktraces(),
+ this->IncludeDirectoriesEntries);
+
+ CreatePropertyGeneratorExpressions(
+ t->GetCompileOptionsEntries(),
+ t->GetCompileOptionsBacktraces(),
+ this->CompileOptionsEntries);
+
+ CreatePropertyGeneratorExpressions(
+ t->GetCompileFeaturesEntries(),
+ t->GetCompileFeaturesBacktraces(),
+ this->CompileFeaturesEntries);
+
+ CreatePropertyGeneratorExpressions(
+ t->GetCompileDefinitionsEntries(),
+ t->GetCompileDefinitionsBacktraces(),
+ this->CompileDefinitionsEntries);
}
cmGeneratorTarget::~cmGeneratorTarget()
{
+ cmDeleteAll(this->IncludeDirectoriesEntries);
+ cmDeleteAll(this->CompileOptionsEntries);
+ cmDeleteAll(this->CompileFeaturesEntries);
+ cmDeleteAll(this->CompileDefinitionsEntries);
cmDeleteAll(this->LinkInformation);
this->LinkInformation.clear();
}
@@ -851,7 +909,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const
// If either a build or install tree rpath is set then the rpath
// will likely change between the build tree and install tree and
// this target must be relinked.
- return this->Target->HaveBuildTreeRPATH(config)
+ return this->HaveBuildTreeRPATH(config)
|| this->Target->HaveInstallTreeRPATH();
}
@@ -1172,9 +1230,11 @@ public:
{
return;
}
-
- cmTarget::LinkInterface const* iface =
- item.Target->GetLinkInterface(this->Config, this->HeadTarget);
+ cmGeneratorTarget* gtgt =
+ this->Target->GetLocalGenerator()->GetGlobalGenerator()
+ ->GetGeneratorTarget(item.Target);
+ cmLinkInterface const* iface =
+ gtgt->GetLinkInterface(this->Config, this->HeadTarget);
if(!iface) { return; }
for(std::vector<std::string>::const_iterator
@@ -1228,7 +1288,7 @@ public:
: Preference(0), Target(target)
{
this->Makefile = this->Target->Makefile;
- this->GG = this->Makefile->GetGlobalGenerator();
+ this->GG = this->Target->GetLocalGenerator()->GetGlobalGenerator();
}
void Consider(const char* lang)
{
@@ -1275,8 +1335,8 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config,
{
// Get languages built in this target.
UNORDERED_SET<std::string> languages;
- cmTarget::LinkImplementation const* impl =
- this->Target->GetLinkImplementation(config);
+ cmLinkImplementation const* impl =
+ this->GetLinkImplementation(config);
assert(impl);
for(std::vector<std::string>::const_iterator li = impl->Languages.begin();
li != impl->Languages.end(); ++li)
@@ -1403,7 +1463,7 @@ cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo(
msg += this->GetName();
msg += " which has type ";
msg += cmTarget::GetTargetTypeName(this->Target->GetType());
- this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg);
+ this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
return 0;
}
@@ -1505,20 +1565,22 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string> &result,
void processILibs(const std::string& config,
cmTarget const* headTarget,
cmLinkItem const& item,
+ cmGlobalGenerator* gg,
std::vector<cmTarget const*>& tgts,
std::set<cmTarget const*>& emitted)
{
if (item.Target && emitted.insert(item.Target).second)
{
tgts.push_back(item.Target);
- if(cmTarget::LinkInterfaceLibraries const* iface =
- item.Target->GetLinkInterfaceLibraries(config, headTarget, true))
+ cmGeneratorTarget* gt = gg->GetGeneratorTarget(item.Target);
+ if(cmLinkInterfaceLibraries const* iface =
+ gt->GetLinkInterfaceLibraries(config, headTarget, true))
{
for(std::vector<cmLinkItem>::const_iterator
it = iface->Libraries.begin();
it != iface->Libraries.end(); ++it)
{
- processILibs(config, headTarget, *it, tgts, emitted);
+ processILibs(config, headTarget, *it, gg, tgts, emitted);
}
}
}
@@ -1543,7 +1605,9 @@ cmGeneratorTarget::GetLinkImplementationClosure(
it = impl->Libraries.begin();
it != impl->Libraries.end(); ++it)
{
- processILibs(config, this->Target, *it, tgts , emitted);
+ processILibs(config, this->Target, *it,
+ this->LocalGenerator->GetGlobalGenerator(),
+ tgts , emitted);
}
}
return tgts;
@@ -1957,17 +2021,540 @@ cmGeneratorTarget::GetCreateRuleVariable(std::string const& lang,
}
return "";
}
+//----------------------------------------------------------------------------
+static void processIncludeDirectories(cmGeneratorTarget const* tgt,
+ const std::vector<cmGeneratorTarget::TargetPropertyEntry*> &entries,
+ std::vector<std::string> &includes,
+ UNORDERED_SET<std::string> &uniqueIncludes,
+ cmGeneratorExpressionDAGChecker *dagChecker,
+ const std::string& config, bool debugIncludes,
+ const std::string& language)
+{
+ cmMakefile *mf = tgt->Target->GetMakefile();
+
+ for (std::vector<cmGeneratorTarget::TargetPropertyEntry*>::const_iterator
+ it = entries.begin(), end = entries.end(); it != end; ++it)
+ {
+ cmLinkImplItem const& item = (*it)->LinkImplItem;
+ std::string const& targetName = item;
+ bool const fromImported = item.Target && item.Target->IsImported();
+ bool const checkCMP0027 = item.FromGenex;
+ std::vector<std::string> entryIncludes;
+ cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
+ config,
+ false,
+ tgt->Target,
+ dagChecker, language),
+ entryIncludes);
+
+ std::string usedIncludes;
+ for(std::vector<std::string>::iterator
+ li = entryIncludes.begin(); li != entryIncludes.end(); ++li)
+ {
+ if (fromImported
+ && !cmSystemTools::FileExists(li->c_str()))
+ {
+ std::ostringstream e;
+ cmake::MessageType messageType = cmake::FATAL_ERROR;
+ if (checkCMP0027)
+ {
+ switch(tgt->Target->GetPolicyStatusCMP0027())
+ {
+ case cmPolicies::WARN:
+ e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n";
+ case cmPolicies::OLD:
+ messageType = cmake::AUTHOR_WARNING;
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW:
+ break;
+ }
+ }
+ e << "Imported target \"" << targetName << "\" includes "
+ "non-existent path\n \"" << *li << "\"\nin its "
+ "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n"
+ "* The path was deleted, renamed, or moved to another "
+ "location.\n"
+ "* An install or uninstall procedure did not complete "
+ "successfully.\n"
+ "* The installation package was faulty and references files it "
+ "does not provide.\n";
+ tgt->GetLocalGenerator()->IssueMessage(messageType, e.str());
+ return;
+ }
+
+ if (!cmSystemTools::FileIsFullPath(li->c_str()))
+ {
+ std::ostringstream e;
+ bool noMessage = false;
+ cmake::MessageType messageType = cmake::FATAL_ERROR;
+ if (!targetName.empty())
+ {
+ e << "Target \"" << targetName << "\" contains relative "
+ "path in its INTERFACE_INCLUDE_DIRECTORIES:\n"
+ " \"" << *li << "\"";
+ }
+ else
+ {
+ switch(tgt->Target->GetPolicyStatusCMP0021())
+ {
+ case cmPolicies::WARN:
+ {
+ e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n";
+ messageType = cmake::AUTHOR_WARNING;
+ }
+ break;
+ case cmPolicies::OLD:
+ noMessage = true;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ // Issue the fatal message.
+ break;
+ }
+ e << "Found relative path while evaluating include directories of "
+ "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n";
+ }
+ if (!noMessage)
+ {
+ tgt->GetLocalGenerator()->IssueMessage(messageType, e.str());
+ if (messageType == cmake::FATAL_ERROR)
+ {
+ return;
+ }
+ }
+ }
+
+ if (!cmSystemTools::IsOff(li->c_str()))
+ {
+ cmSystemTools::ConvertToUnixSlashes(*li);
+ }
+ std::string inc = *li;
+
+ if(uniqueIncludes.insert(inc).second)
+ {
+ includes.push_back(inc);
+ if (debugIncludes)
+ {
+ usedIncludes += " * " + inc + "\n";
+ }
+ }
+ }
+ if (!usedIncludes.empty())
+ {
+ mf->GetCMakeInstance()->IssueMessage(cmake::LOG,
+ std::string("Used includes for target ")
+ + tgt->GetName() + ":\n"
+ + usedIncludes, (*it)->ge->GetBacktrace());
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+static void AddInterfaceEntries(
+ cmGeneratorTarget const* thisTarget, std::string const& config,
+ std::string const& prop,
+ std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries)
+{
+ if(cmLinkImplementationLibraries const* impl =
+ thisTarget->Target->GetLinkImplementationLibraries(config))
+ {
+ for (std::vector<cmLinkImplItem>::const_iterator
+ it = impl->Libraries.begin(), end = impl->Libraries.end();
+ it != end; ++it)
+ {
+ if(it->Target)
+ {
+ std::string genex =
+ "$<TARGET_PROPERTY:" + *it + "," + prop + ">";
+ cmGeneratorExpression ge(it->Backtrace);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(genex);
+ cge->SetEvaluateForBuildsystem(true);
+ entries.push_back(
+ new cmGeneratorTarget::TargetPropertyEntry(cge, *it));
+ }
+ }
+ }
+}
//----------------------------------------------------------------------------
std::vector<std::string>
cmGeneratorTarget::GetIncludeDirectories(const std::string& config,
const std::string& lang) const
{
- return this->Target->GetIncludeDirectories(config, lang);
+ std::vector<std::string> includes;
+ UNORDERED_SET<std::string> uniqueIncludes;
+
+ cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
+ "INCLUDE_DIRECTORIES", 0, 0);
+
+ std::vector<std::string> debugProperties;
+ const char *debugProp =
+ this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+ if (debugProp)
+ {
+ cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+ }
+
+ bool debugIncludes = !this->DebugIncludesDone
+ && std::find(debugProperties.begin(),
+ debugProperties.end(),
+ "INCLUDE_DIRECTORIES")
+ != debugProperties.end();
+
+ if (this->Makefile->IsConfigured())
+ {
+ this->DebugIncludesDone = true;
+ }
+
+ processIncludeDirectories(this,
+ this->IncludeDirectoriesEntries,
+ includes,
+ uniqueIncludes,
+ &dagChecker,
+ config,
+ debugIncludes,
+ lang);
+
+ std::vector<cmGeneratorTarget::TargetPropertyEntry*>
+ linkInterfaceIncludeDirectoriesEntries;
+ AddInterfaceEntries(
+ this, config, "INTERFACE_INCLUDE_DIRECTORIES",
+ linkInterfaceIncludeDirectoriesEntries);
+
+ if(this->Makefile->IsOn("APPLE"))
+ {
+ cmLinkImplementationLibraries const* impl =
+ this->Target->GetLinkImplementationLibraries(config);
+ for(std::vector<cmLinkImplItem>::const_iterator
+ it = impl->Libraries.begin();
+ it != impl->Libraries.end(); ++it)
+ {
+ std::string libDir = cmSystemTools::CollapseFullPath(*it);
+
+ static cmsys::RegularExpression
+ frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$");
+ if(!frameworkCheck.find(libDir))
+ {
+ continue;
+ }
+
+ libDir = frameworkCheck.match(1);
+
+ cmGeneratorExpression ge;
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
+ ge.Parse(libDir.c_str());
+ linkInterfaceIncludeDirectoriesEntries
+ .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge));
+ }
+ }
+
+ processIncludeDirectories(this,
+ linkInterfaceIncludeDirectoriesEntries,
+ includes,
+ uniqueIncludes,
+ &dagChecker,
+ config,
+ debugIncludes,
+ lang);
+
+ cmDeleteAll(linkInterfaceIncludeDirectoriesEntries);
+
+ return includes;
+}
+
+//----------------------------------------------------------------------------
+static void processCompileOptionsInternal(cmGeneratorTarget const* tgt,
+ const std::vector<cmGeneratorTarget::TargetPropertyEntry*> &entries,
+ std::vector<std::string> &options,
+ UNORDERED_SET<std::string> &uniqueOptions,
+ cmGeneratorExpressionDAGChecker *dagChecker,
+ const std::string& config, bool debugOptions, const char *logName,
+ std::string const& language)
+{
+ cmMakefile *mf = tgt->Target->GetMakefile();
+
+ for (std::vector<cmGeneratorTarget::TargetPropertyEntry*>::const_iterator
+ it = entries.begin(), end = entries.end(); it != end; ++it)
+ {
+ std::vector<std::string> entryOptions;
+ cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
+ config,
+ false,
+ tgt->Target,
+ dagChecker,
+ language),
+ entryOptions);
+ std::string usedOptions;
+ for(std::vector<std::string>::iterator
+ li = entryOptions.begin(); li != entryOptions.end(); ++li)
+ {
+ std::string const& opt = *li;
+
+ if(uniqueOptions.insert(opt).second)
+ {
+ options.push_back(opt);
+ if (debugOptions)
+ {
+ usedOptions += " * " + opt + "\n";
+ }
+ }
+ }
+ if (!usedOptions.empty())
+ {
+ mf->GetCMakeInstance()->IssueMessage(cmake::LOG,
+ std::string("Used compile ") + logName
+ + std::string(" for target ")
+ + tgt->GetName() + ":\n"
+ + usedOptions, (*it)->ge->GetBacktrace());
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+static void processCompileOptions(cmGeneratorTarget const* tgt,
+ const std::vector<cmGeneratorTarget::TargetPropertyEntry*> &entries,
+ std::vector<std::string> &options,
+ UNORDERED_SET<std::string> &uniqueOptions,
+ cmGeneratorExpressionDAGChecker *dagChecker,
+ const std::string& config, bool debugOptions,
+ std::string const& language)
+{
+ processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
+ dagChecker, config, debugOptions, "options",
+ language);
+}
+
+//----------------------------------------------------------------------------
+void cmGeneratorTarget::GetCompileOptions(std::vector<std::string> &result,
+ const std::string& config,
+ const std::string& language) const
+{
+ UNORDERED_SET<std::string> uniqueOptions;
+
+ cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
+ "COMPILE_OPTIONS", 0, 0);
+
+ std::vector<std::string> debugProperties;
+ const char *debugProp =
+ this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+ if (debugProp)
+ {
+ cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+ }
+
+ bool debugOptions = !this->DebugCompileOptionsDone
+ && std::find(debugProperties.begin(),
+ debugProperties.end(),
+ "COMPILE_OPTIONS")
+ != debugProperties.end();
+
+ if (this->Makefile->IsConfigured())
+ {
+ this->DebugCompileOptionsDone = true;
+ }
+
+ processCompileOptions(this,
+ this->CompileOptionsEntries,
+ result,
+ uniqueOptions,
+ &dagChecker,
+ config,
+ debugOptions,
+ language);
+
+ std::vector<cmGeneratorTarget::TargetPropertyEntry*>
+ linkInterfaceCompileOptionsEntries;
+
+ AddInterfaceEntries(
+ this, config, "INTERFACE_COMPILE_OPTIONS",
+ linkInterfaceCompileOptionsEntries);
+
+ processCompileOptions(this,
+ linkInterfaceCompileOptionsEntries,
+ result,
+ uniqueOptions,
+ &dagChecker,
+ config,
+ debugOptions,
+ language);
+
+ cmDeleteAll(linkInterfaceCompileOptionsEntries);
+}
+
+//----------------------------------------------------------------------------
+static void processCompileFeatures(cmGeneratorTarget const* tgt,
+ const std::vector<cmGeneratorTarget::TargetPropertyEntry*> &entries,
+ std::vector<std::string> &options,
+ UNORDERED_SET<std::string> &uniqueOptions,
+ cmGeneratorExpressionDAGChecker *dagChecker,
+ const std::string& config, bool debugOptions)
+{
+ processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
+ dagChecker, config, debugOptions, "features",
+ std::string());
}
//----------------------------------------------------------------------------
-void cmGeneratorTarget::GenerateTargetManifest(
+void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string> &result,
+ const std::string& config) const
+{
+ UNORDERED_SET<std::string> uniqueFeatures;
+
+ cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
+ "COMPILE_FEATURES",
+ 0, 0);
+
+ std::vector<std::string> debugProperties;
+ const char *debugProp =
+ this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+ if (debugProp)
+ {
+ cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+ }
+
+ bool debugFeatures = !this->DebugCompileFeaturesDone
+ && std::find(debugProperties.begin(),
+ debugProperties.end(),
+ "COMPILE_FEATURES")
+ != debugProperties.end();
+
+ if (this->Makefile->IsConfigured())
+ {
+ this->DebugCompileFeaturesDone = true;
+ }
+
+ processCompileFeatures(this,
+ this->CompileFeaturesEntries,
+ result,
+ uniqueFeatures,
+ &dagChecker,
+ config,
+ debugFeatures);
+
+ std::vector<cmGeneratorTarget::TargetPropertyEntry*>
+ linkInterfaceCompileFeaturesEntries;
+ AddInterfaceEntries(
+ this, config, "INTERFACE_COMPILE_FEATURES",
+ linkInterfaceCompileFeaturesEntries);
+
+ processCompileFeatures(this,
+ linkInterfaceCompileFeaturesEntries,
+ result,
+ uniqueFeatures,
+ &dagChecker,
+ config,
+ debugFeatures);
+
+ cmDeleteAll(linkInterfaceCompileFeaturesEntries);
+}
+
+//----------------------------------------------------------------------------
+static void processCompileDefinitions(cmGeneratorTarget const* tgt,
+ const std::vector<cmGeneratorTarget::TargetPropertyEntry*> &entries,
+ std::vector<std::string> &options,
+ UNORDERED_SET<std::string> &uniqueOptions,
+ cmGeneratorExpressionDAGChecker *dagChecker,
+ const std::string& config, bool debugOptions,
+ std::string const& language)
+{
+ processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
+ dagChecker, config, debugOptions,
+ "definitions", language);
+}
+
+//----------------------------------------------------------------------------
+void cmGeneratorTarget::GetCompileDefinitions(std::vector<std::string> &list,
+ const std::string& config,
+ const std::string& language) const
+{
+ UNORDERED_SET<std::string> uniqueOptions;
+
+ cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
+ "COMPILE_DEFINITIONS", 0, 0);
+
+ std::vector<std::string> debugProperties;
+ const char *debugProp =
+ this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+ if (debugProp)
+ {
+ cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+ }
+
+ bool debugDefines = !this->DebugCompileDefinitionsDone
+ && std::find(debugProperties.begin(),
+ debugProperties.end(),
+ "COMPILE_DEFINITIONS")
+ != debugProperties.end();
+
+ if (this->Makefile->IsConfigured())
+ {
+ this->DebugCompileDefinitionsDone = true;
+ }
+
+ processCompileDefinitions(this,
+ this->CompileDefinitionsEntries,
+ list,
+ uniqueOptions,
+ &dagChecker,
+ config,
+ debugDefines,
+ language);
+
+ std::vector<cmGeneratorTarget::TargetPropertyEntry*>
+ linkInterfaceCompileDefinitionsEntries;
+ AddInterfaceEntries(
+ this, config, "INTERFACE_COMPILE_DEFINITIONS",
+ linkInterfaceCompileDefinitionsEntries);
+ if (!config.empty())
+ {
+ std::string configPropName = "COMPILE_DEFINITIONS_"
+ + cmSystemTools::UpperCase(config);
+ const char *configProp = this->Target->GetProperty(configPropName);
+ if (configProp)
+ {
+ switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043))
+ {
+ case cmPolicies::WARN:
+ {
+ std::ostringstream e;
+ e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043);
+ this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING,
+ e.str());
+ }
+ case cmPolicies::OLD:
+ {
+ cmGeneratorExpression ge;
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
+ ge.Parse(configProp);
+ linkInterfaceCompileDefinitionsEntries
+ .push_back(new cmGeneratorTarget::TargetPropertyEntry(cge));
+ }
+ break;
+ case cmPolicies::NEW:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ break;
+ }
+ }
+ }
+
+ processCompileDefinitions(this,
+ linkInterfaceCompileDefinitionsEntries,
+ list,
+ uniqueOptions,
+ &dagChecker,
+ config,
+ debugDefines,
+ language);
+
+ cmDeleteAll(linkInterfaceCompileDefinitionsEntries);
+}
+
+//----------------------------------------------------------------------------
+void cmGeneratorTarget::ComputeTargetManifest(
const std::string& config) const
{
if (this->Target->IsImported())
@@ -2093,7 +2680,7 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const
{
std::string msg = "NormalGetRealName called on imported target: ";
msg += this->GetName();
- this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg);
+ this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg);
}
if(this->GetType() == cmTarget::EXECUTABLE)
@@ -3354,3 +3941,613 @@ cmGeneratorTarget::ReportPropertyOrigin(const std::string &p,
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport);
}
+
+//----------------------------------------------------------------------------
+void cmGeneratorTarget::LookupLinkItems(std::vector<std::string> const& names,
+ std::vector<cmLinkItem>& items) const
+{
+ for(std::vector<std::string>::const_iterator i = names.begin();
+ i != names.end(); ++i)
+ {
+ std::string name = this->Target->CheckCMP0004(*i);
+ if(name == this->GetName() || name.empty())
+ {
+ continue;
+ }
+ items.push_back(cmLinkItem(name, this->Target->FindTargetToLink(name)));
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmGeneratorTarget::ExpandLinkItems(std::string const& prop,
+ std::string const& value,
+ std::string const& config,
+ cmTarget const* headTarget,
+ bool usage_requirements_only,
+ std::vector<cmLinkItem>& items,
+ bool& hadHeadSensitiveCondition) const
+{
+ cmGeneratorExpression ge;
+ cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0);
+ // The $<LINK_ONLY> expression may be in a link interface to specify private
+ // link dependencies that are otherwise excluded from usage requirements.
+ if(usage_requirements_only)
+ {
+ dagChecker.SetTransitivePropertiesOnly();
+ }
+ std::vector<std::string> libs;
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+ cmSystemTools::ExpandListArgument(cge->Evaluate(
+ this->Makefile,
+ config,
+ false,
+ headTarget,
+ this->Target, &dagChecker), libs);
+ this->LookupLinkItems(libs, items);
+ hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition();
+}
+
+//----------------------------------------------------------------------------
+cmLinkInterface const*
+cmGeneratorTarget::GetLinkInterface(const std::string& config,
+ cmTarget const* head) const
+{
+ // Imported targets have their own link interface.
+ if(this->IsImported())
+ {
+ return this->GetImportLinkInterface(config, head, false);
+ }
+
+ // Link interfaces are not supported for executables that do not
+ // export symbols.
+ if(this->GetType() == cmTarget::EXECUTABLE &&
+ !this->Target->IsExecutableWithExports())
+ {
+ return 0;
+ }
+
+ // Lookup any existing link interface for this configuration.
+ cmHeadToLinkInterfaceMap& hm =
+ this->GetHeadToLinkInterfaceMap(config);
+
+ // If the link interface does not depend on the head target
+ // then return the one we computed first.
+ if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition)
+ {
+ return &hm.begin()->second;
+ }
+
+ cmOptionalLinkInterface& iface = hm[head];
+ if(!iface.LibrariesDone)
+ {
+ iface.LibrariesDone = true;
+ this->ComputeLinkInterfaceLibraries(
+ config, iface, head, false);
+ }
+ if(!iface.AllDone)
+ {
+ iface.AllDone = true;
+ if(iface.Exists)
+ {
+ this->ComputeLinkInterface(config, iface, head);
+ }
+ }
+
+ return iface.Exists? &iface : 0;
+}
+
+//----------------------------------------------------------------------------
+void cmGeneratorTarget::ComputeLinkInterface(const std::string& config,
+ cmOptionalLinkInterface &iface,
+ cmTarget const* headTarget) const
+{
+ if(iface.ExplicitLibraries)
+ {
+ if(this->GetType() == cmTarget::SHARED_LIBRARY
+ || this->GetType() == cmTarget::STATIC_LIBRARY
+ || this->GetType() == cmTarget::INTERFACE_LIBRARY)
+ {
+ // Shared libraries may have runtime implementation dependencies
+ // on other shared libraries that are not in the interface.
+ UNORDERED_SET<std::string> emitted;
+ for(std::vector<cmLinkItem>::const_iterator
+ li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li)
+ {
+ emitted.insert(*li);
+ }
+ if (this->GetType() != cmTarget::INTERFACE_LIBRARY)
+ {
+ cmLinkImplementation const* impl =
+ this->GetLinkImplementation(config);
+ for(std::vector<cmLinkImplItem>::const_iterator
+ li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li)
+ {
+ if(emitted.insert(*li).second)
+ {
+ if(li->Target)
+ {
+ // This is a runtime dependency on another shared library.
+ if(li->Target->GetType() == cmTarget::SHARED_LIBRARY)
+ {
+ iface.SharedDeps.push_back(*li);
+ }
+ }
+ else
+ {
+ // TODO: Recognize shared library file names. Perhaps this
+ // should be moved to cmComputeLinkInformation, but that creates
+ // a chicken-and-egg problem since this list is needed for its
+ // construction.
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN
+ || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD)
+ {
+ // The link implementation is the default link interface.
+ cmLinkImplementationLibraries const*
+ impl = this->Target->GetLinkImplementationLibrariesInternal(config,
+ headTarget);
+ iface.ImplementationIsInterface = true;
+ iface.WrongConfigLibraries = impl->WrongConfigLibraries;
+ }
+
+ if(this->Target->LinkLanguagePropagatesToDependents())
+ {
+ // Targets using this archive need its language runtime libraries.
+ if(cmLinkImplementation const* impl =
+ this->GetLinkImplementation(config))
+ {
+ iface.Languages = impl->Languages;
+ }
+ }
+
+ if(this->GetType() == cmTarget::STATIC_LIBRARY)
+ {
+ // Construct the property name suffix for this configuration.
+ std::string suffix = "_";
+ if(!config.empty())
+ {
+ suffix += cmSystemTools::UpperCase(config);
+ }
+ else
+ {
+ suffix += "NOCONFIG";
+ }
+
+ // How many repetitions are needed if this library has cyclic
+ // dependencies?
+ std::string propName = "LINK_INTERFACE_MULTIPLICITY";
+ propName += suffix;
+ if(const char* config_reps = this->GetProperty(propName))
+ {
+ sscanf(config_reps, "%u", &iface.Multiplicity);
+ }
+ else if(const char* reps =
+ this->GetProperty("LINK_INTERFACE_MULTIPLICITY"))
+ {
+ sscanf(reps, "%u", &iface.Multiplicity);
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+const cmLinkInterfaceLibraries *
+cmGeneratorTarget::GetLinkInterfaceLibraries(const std::string& config,
+ cmTarget const* head,
+ bool usage_requirements_only) const
+{
+ // Imported targets have their own link interface.
+ if(this->IsImported())
+ {
+ return this->GetImportLinkInterface(config, head,
+ usage_requirements_only);
+ }
+
+ // Link interfaces are not supported for executables that do not
+ // export symbols.
+ if(this->GetType() == cmTarget::EXECUTABLE &&
+ !this->Target->IsExecutableWithExports())
+ {
+ return 0;
+ }
+
+ // Lookup any existing link interface for this configuration.
+ std::string CONFIG = cmSystemTools::UpperCase(config);
+ cmHeadToLinkInterfaceMap& hm =
+ (usage_requirements_only ?
+ this->GetHeadToLinkInterfaceUsageRequirementsMap(config) :
+ this->GetHeadToLinkInterfaceMap(config));
+
+ // If the link interface does not depend on the head target
+ // then return the one we computed first.
+ if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition)
+ {
+ return &hm.begin()->second;
+ }
+
+ cmOptionalLinkInterface& iface = hm[head];
+ if(!iface.LibrariesDone)
+ {
+ iface.LibrariesDone = true;
+ this->ComputeLinkInterfaceLibraries(
+ config, iface, head, usage_requirements_only);
+ }
+
+ return iface.Exists? &iface : 0;
+}
+
+//----------------------------------------------------------------------------
+void
+cmGeneratorTarget::ComputeLinkInterfaceLibraries(
+ const std::string& config,
+ cmOptionalLinkInterface& iface,
+ cmTarget const* headTarget,
+ bool usage_requirements_only) const
+{
+ // Construct the property name suffix for this configuration.
+ std::string suffix = "_";
+ if(!config.empty())
+ {
+ suffix += cmSystemTools::UpperCase(config);
+ }
+ else
+ {
+ suffix += "NOCONFIG";
+ }
+
+ // An explicit list of interface libraries may be set for shared
+ // libraries and executables that export symbols.
+ const char* explicitLibraries = 0;
+ std::string linkIfaceProp;
+ if(this->Target->GetPolicyStatusCMP0022() != cmPolicies::OLD &&
+ this->Target->GetPolicyStatusCMP0022() != cmPolicies::WARN)
+ {
+ // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES.
+ linkIfaceProp = "INTERFACE_LINK_LIBRARIES";
+ explicitLibraries = this->GetProperty(linkIfaceProp);
+ }
+ else if(this->GetType() == cmTarget::SHARED_LIBRARY ||
+ this->Target->IsExecutableWithExports())
+ {
+ // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a
+ // shared lib or executable.
+
+ // Lookup the per-configuration property.
+ linkIfaceProp = "LINK_INTERFACE_LIBRARIES";
+ linkIfaceProp += suffix;
+ explicitLibraries = this->GetProperty(linkIfaceProp);
+
+ // If not set, try the generic property.
+ if(!explicitLibraries)
+ {
+ linkIfaceProp = "LINK_INTERFACE_LIBRARIES";
+ explicitLibraries = this->GetProperty(linkIfaceProp);
+ }
+ }
+
+ if(explicitLibraries &&
+ this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN &&
+ !this->PolicyWarnedCMP0022)
+ {
+ // Compare the explicitly set old link interface properties to the
+ // preferred new link interface property one and warn if different.
+ const char* newExplicitLibraries =
+ this->GetProperty("INTERFACE_LINK_LIBRARIES");
+ if (newExplicitLibraries
+ && strcmp(newExplicitLibraries, explicitLibraries) != 0)
+ {
+ std::ostringstream w;
+ w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n"
+ "Target \"" << this->GetName() << "\" has an "
+ "INTERFACE_LINK_LIBRARIES property which differs from its " <<
+ linkIfaceProp << " properties."
+ "\n"
+ "INTERFACE_LINK_LIBRARIES:\n"
+ " " << newExplicitLibraries << "\n" <<
+ linkIfaceProp << ":\n"
+ " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n";
+ this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->PolicyWarnedCMP0022 = true;
+ }
+ }
+
+ // There is no implicit link interface for executables or modules
+ // so if none was explicitly set then there is no link interface.
+ if(!explicitLibraries &&
+ (this->GetType() == cmTarget::EXECUTABLE ||
+ (this->GetType() == cmTarget::MODULE_LIBRARY)))
+ {
+ return;
+ }
+ iface.Exists = true;
+ iface.ExplicitLibraries = explicitLibraries;
+
+ if(explicitLibraries)
+ {
+ // The interface libraries have been explicitly set.
+ this->ExpandLinkItems(linkIfaceProp, explicitLibraries,
+ config,
+ headTarget, usage_requirements_only,
+ iface.Libraries,
+ iface.HadHeadSensitiveCondition);
+ }
+ else if (this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN
+ || this->Target->GetPolicyStatusCMP0022() == cmPolicies::OLD)
+ // If CMP0022 is NEW then the plain tll signature sets the
+ // INTERFACE_LINK_LIBRARIES, so if we get here then the project
+ // cleared the property explicitly and we should not fall back
+ // to the link implementation.
+ {
+ // The link implementation is the default link interface.
+ cmLinkImplementationLibraries const* impl =
+ this->Target->GetLinkImplementationLibrariesInternal(config,
+ headTarget);
+ iface.Libraries.insert(iface.Libraries.end(),
+ impl->Libraries.begin(), impl->Libraries.end());
+ if(this->Target->GetPolicyStatusCMP0022() == cmPolicies::WARN &&
+ !this->PolicyWarnedCMP0022 && !usage_requirements_only)
+ {
+ // Compare the link implementation fallback link interface to the
+ // preferred new link interface property and warn if different.
+ std::vector<cmLinkItem> ifaceLibs;
+ static const std::string newProp = "INTERFACE_LINK_LIBRARIES";
+ if(const char* newExplicitLibraries = this->GetProperty(newProp))
+ {
+ bool hadHeadSensitiveConditionDummy = false;
+ this->ExpandLinkItems(newProp, newExplicitLibraries, config,
+ headTarget, usage_requirements_only,
+ ifaceLibs, hadHeadSensitiveConditionDummy);
+ }
+ if (ifaceLibs != iface.Libraries)
+ {
+ std::string oldLibraries = cmJoin(impl->Libraries, ";");
+ std::string newLibraries = cmJoin(ifaceLibs, ";");
+ if(oldLibraries.empty())
+ { oldLibraries = "(empty)"; }
+ if(newLibraries.empty())
+ { newLibraries = "(empty)"; }
+
+ std::ostringstream w;
+ w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n"
+ "Target \"" << this->GetName() << "\" has an "
+ "INTERFACE_LINK_LIBRARIES property. "
+ "This should be preferred as the source of the link interface "
+ "for this library but because CMP0022 is not set CMake is "
+ "ignoring the property and using the link implementation "
+ "as the link interface instead."
+ "\n"
+ "INTERFACE_LINK_LIBRARIES:\n"
+ " " << newLibraries << "\n"
+ "Link implementation:\n"
+ " " << oldLibraries << "\n";
+ this->LocalGenerator->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ this->PolicyWarnedCMP0022 = true;
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+const cmLinkInterface *
+cmGeneratorTarget::GetImportLinkInterface(const std::string& config,
+ cmTarget const* headTarget,
+ bool usage_requirements_only) const
+{
+ cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config);
+ if(!info)
+ {
+ return 0;
+ }
+
+ std::string CONFIG = cmSystemTools::UpperCase(config);
+ cmHeadToLinkInterfaceMap& hm =
+ (usage_requirements_only ?
+ this->GetHeadToLinkInterfaceUsageRequirementsMap(config) :
+ this->GetHeadToLinkInterfaceMap(config));
+
+ // If the link interface does not depend on the head target
+ // then return the one we computed first.
+ if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition)
+ {
+ return &hm.begin()->second;
+ }
+
+ cmOptionalLinkInterface& iface = hm[headTarget];
+ if(!iface.AllDone)
+ {
+ iface.AllDone = true;
+ iface.Multiplicity = info->Multiplicity;
+ cmSystemTools::ExpandListArgument(info->Languages, iface.Languages);
+ this->ExpandLinkItems(info->LibrariesProp, info->Libraries,
+ config,
+ headTarget, usage_requirements_only,
+ iface.Libraries,
+ iface.HadHeadSensitiveCondition);
+ std::vector<std::string> deps;
+ cmSystemTools::ExpandListArgument(info->SharedDeps, deps);
+ this->LookupLinkItems(deps, iface.SharedDeps);
+ }
+
+ return &iface;
+}
+
+cmHeadToLinkInterfaceMap&
+cmGeneratorTarget::GetHeadToLinkInterfaceMap(const std::string &config) const
+{
+ std::string CONFIG = cmSystemTools::UpperCase(config);
+ return this->LinkInterfaceMap[CONFIG];
+}
+
+cmHeadToLinkInterfaceMap&
+cmGeneratorTarget::GetHeadToLinkInterfaceUsageRequirementsMap(
+ const std::string &config) const
+{
+ std::string CONFIG = cmSystemTools::UpperCase(config);
+ return this->LinkInterfaceUsageRequirementsOnlyMap[CONFIG];
+}
+
+//----------------------------------------------------------------------------
+const cmLinkImplementation *
+cmGeneratorTarget::GetLinkImplementation(const std::string& config) const
+{
+ // There is no link implementation for imported targets.
+ if(this->Target->IsImported())
+ {
+ return 0;
+ }
+
+ cmOptionalLinkImplementation& impl = this->Target->GetLinkImplMap(config);
+ if(!impl.LibrariesDone)
+ {
+ impl.LibrariesDone = true;
+ this->Target->ComputeLinkImplementationLibraries(config, impl,
+ this->Target);
+ }
+ if(!impl.LanguagesDone)
+ {
+ impl.LanguagesDone = true;
+ this->ComputeLinkImplementationLanguages(config, impl);
+ }
+ return &impl;
+}
+
+//----------------------------------------------------------------------------
+bool cmGeneratorTarget::GetConfigCommonSourceFiles(
+ std::vector<cmSourceFile*>& files) const
+{
+ std::vector<std::string> configs;
+ this->Makefile->GetConfigurations(configs);
+ if (configs.empty())
+ {
+ configs.push_back("");
+ }
+
+ std::vector<std::string>::const_iterator it = configs.begin();
+ const std::string& firstConfig = *it;
+ this->Target->GetSourceFiles(files, firstConfig);
+
+ for ( ; it != configs.end(); ++it)
+ {
+ std::vector<cmSourceFile*> configFiles;
+ this->Target->GetSourceFiles(configFiles, *it);
+ if (configFiles != files)
+ {
+ std::string firstConfigFiles;
+ const char* sep = "";
+ for (std::vector<cmSourceFile*>::const_iterator fi = files.begin();
+ fi != files.end(); ++fi)
+ {
+ firstConfigFiles += sep;
+ firstConfigFiles += (*fi)->GetFullPath();
+ sep = "\n ";
+ }
+
+ std::string thisConfigFiles;
+ sep = "";
+ for (std::vector<cmSourceFile*>::const_iterator fi = configFiles.begin();
+ fi != configFiles.end(); ++fi)
+ {
+ thisConfigFiles += sep;
+ thisConfigFiles += (*fi)->GetFullPath();
+ sep = "\n ";
+ }
+ std::ostringstream e;
+ e << "Target \"" << this->GetName()
+ << "\" has source files which vary by "
+ "configuration. This is not supported by the \""
+ << this->GlobalGenerator->GetName()
+ << "\" generator.\n"
+ "Config \"" << firstConfig << "\":\n"
+ " " << firstConfigFiles << "\n"
+ "Config \"" << *it << "\":\n"
+ " " << thisConfigFiles << "\n";
+ this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return false;
+ }
+ }
+ return true;
+}
+
+//----------------------------------------------------------------------------
+void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages,
+ const std::string& config) const
+{
+ std::vector<cmSourceFile*> sourceFiles;
+ this->GetSourceFiles(sourceFiles, config);
+ for(std::vector<cmSourceFile*>::const_iterator
+ i = sourceFiles.begin(); i != sourceFiles.end(); ++i)
+ {
+ const std::string& lang = (*i)->GetLanguage();
+ if(!lang.empty())
+ {
+ languages.insert(lang);
+ }
+ }
+
+ std::vector<cmGeneratorTarget*> objectLibraries;
+ std::vector<cmSourceFile const*> externalObjects;
+ if (!this->Makefile->IsConfigured())
+ {
+ std::vector<cmTarget*> objectTargets;
+ this->Target->GetObjectLibrariesCMP0026(objectTargets);
+ objectLibraries.reserve(objectTargets.size());
+ for (std::vector<cmTarget*>::const_iterator it = objectTargets.begin();
+ it != objectTargets.end(); ++it)
+ {
+ objectLibraries.push_back(this->GlobalGenerator
+ ->GetGeneratorTarget(*it));
+ }
+ }
+ else
+ {
+ this->GetExternalObjects(externalObjects, config);
+ for(std::vector<cmSourceFile const*>::const_iterator
+ i = externalObjects.begin(); i != externalObjects.end(); ++i)
+ {
+ std::string objLib = (*i)->GetObjectLibrary();
+ if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib))
+ {
+ objectLibraries.push_back(this->GlobalGenerator
+ ->GetGeneratorTarget(tgt));
+ }
+ }
+ }
+ for(std::vector<cmGeneratorTarget*>::const_iterator
+ i = objectLibraries.begin(); i != objectLibraries.end(); ++i)
+ {
+ (*i)->GetLanguages(languages, config);
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmGeneratorTarget::ComputeLinkImplementationLanguages(
+ const std::string& config,
+ cmOptionalLinkImplementation& impl) const
+{
+ // This target needs runtime libraries for its source languages.
+ std::set<std::string> languages;
+ // Get languages used in our source files.
+ this->GetLanguages(languages, config);
+ // Copy the set of langauges to the link implementation.
+ impl.Languages.insert(impl.Languages.begin(),
+ languages.begin(), languages.end());
+}
+
+//----------------------------------------------------------------------------
+bool cmGeneratorTarget::HaveBuildTreeRPATH(const std::string& config) const
+{
+ if (this->Target->GetPropertyAsBool("SKIP_BUILD_RPATH"))
+ {
+ return false;
+ }
+ if(cmLinkImplementationLibraries const* impl =
+ this->Target->GetLinkImplementationLibraries(config))
+ {
+ return !impl->Libraries.empty();
+ }
+ return false;
+}
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 15b3335..06d9a1f 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -12,7 +12,7 @@
#ifndef cmGeneratorTarget_h
#define cmGeneratorTarget_h
-#include "cmStandardIncludes.h"
+#include "cmLinkItem.h"
class cmCustomCommand;
class cmGlobalGenerator;
@@ -106,6 +106,21 @@ public:
const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p,
const std::string& config) const;
+ cmLinkInterface const* GetLinkInterface(const std::string& config,
+ cmTarget const* headTarget) const;
+ void ComputeLinkInterface(const std::string& config,
+ cmOptionalLinkInterface& iface,
+ cmTarget const* head) const;
+
+ cmLinkInterfaceLibraries const*
+ GetLinkInterfaceLibraries(const std::string& config,
+ cmTarget const* headTarget,
+ bool usage_requirements_only) const;
+
+ void ComputeLinkInterfaceLibraries(const std::string& config,
+ cmOptionalLinkInterface &iface,
+ cmTarget const* head,
+ bool usage_requirements_only) const;
/** Get the full path to the target according to the settings in its
makefile and the configuration type. */
@@ -183,6 +198,25 @@ public:
LinkClosure const* GetLinkClosure(const std::string& config) const;
void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const;
+ cmLinkImplementation const*
+ GetLinkImplementation(const std::string& config) const;
+
+ void ComputeLinkImplementationLanguages(const std::string& config,
+ cmOptionalLinkImplementation& impl
+ ) const;
+
+ // Compute the set of languages compiled by the target. This is
+ // computed every time it is called because the languages can change
+ // when source file properties are changed and we do not have enough
+ // information to forward these property changes to the targets
+ // until we have per-target object file properties.
+ void GetLanguages(std::set<std::string>& languages,
+ std::string const& config) const;
+
+ bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const;
+
+ bool HaveBuildTreeRPATH(const std::string& config) const;
+
/** Full path with trailing slash to the top-level directory
holding object files for this target. Includes the build
time config name placeholder if needed for the generator. */
@@ -202,11 +236,22 @@ public:
std::vector<std::string> GetIncludeDirectories(
const std::string& config, const std::string& lang) const;
+ void GetCompileOptions(std::vector<std::string> &result,
+ const std::string& config,
+ const std::string& language) const;
+
+ void GetCompileFeatures(std::vector<std::string> &features,
+ const std::string& config) const;
+
+ void GetCompileDefinitions(std::vector<std::string> &result,
+ const std::string& config,
+ const std::string& language) const;
+
bool IsSystemIncludeDirectory(const std::string& dir,
const std::string& config) const;
/** Add the target output files to the global generator manifest. */
- void GenerateTargetManifest(const std::string& config) const;
+ void ComputeTargetManifest(const std::string& config) const;
/**
* Trace through the source files in this target and add al source files
@@ -317,6 +362,8 @@ public:
const std::string &report,
const std::string &compatibilityType) const;
+ class TargetPropertyEntry;
+
private:
friend class cmTargetTraceDependencies;
struct SourceEntry { std::vector<cmSourceFile*> Depends; };
@@ -375,9 +422,41 @@ private:
};
mutable std::map<std::string, LinkImplClosure> LinkImplClosureMap;
+ typedef std::map<std::string, cmHeadToLinkInterfaceMap>
+ LinkInterfaceMapType;
+ mutable LinkInterfaceMapType LinkInterfaceMap;
+ mutable LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap;
+
+ cmHeadToLinkInterfaceMap&
+ GetHeadToLinkInterfaceMap(std::string const& config) const;
+ cmHeadToLinkInterfaceMap& GetHeadToLinkInterfaceUsageRequirementsMap(
+ std::string const& config) const;
+
+ cmLinkInterface const*
+ GetImportLinkInterface(const std::string& config, cmTarget const* head,
+ bool usage_requirements_only) const;
+
+ std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
+ std::vector<TargetPropertyEntry*> CompileOptionsEntries;
+ std::vector<TargetPropertyEntry*> CompileFeaturesEntries;
+ std::vector<TargetPropertyEntry*> CompileDefinitionsEntries;
+
+ void ExpandLinkItems(std::string const& prop, std::string const& value,
+ std::string const& config, cmTarget const* headTarget,
+ bool usage_requirements_only,
+ std::vector<cmLinkItem>& items,
+ bool& hadHeadSensitiveCondition) const;
+ void LookupLinkItems(std::vector<std::string> const& names,
+ std::vector<cmLinkItem>& items) const;
+
typedef std::pair<std::string, bool> OutputNameKey;
typedef std::map<OutputNameKey, std::string> OutputNameMapType;
mutable OutputNameMapType OutputNameMap;
+ mutable bool PolicyWarnedCMP0022;
+ mutable bool DebugIncludesDone;
+ mutable bool DebugCompileOptionsDone;
+ mutable bool DebugCompileFeaturesDone;
+ mutable bool DebugCompileDefinitionsDone;
public:
std::vector<cmTarget const*> const&
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index 1e57c33..846b6e2 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -330,7 +330,8 @@ void cmGhsMultiTargetGenerator::WriteCompilerDefinitions(
const std::string &config, const std::string &language)
{
std::vector<std::string> compileDefinitions;
- this->Target->GetCompileDefinitions(compileDefinitions, config, language);
+ this->GeneratorTarget->GetCompileDefinitions(compileDefinitions,
+ config, language);
for (std::vector<std::string>::const_iterator cdI =
compileDefinitions.begin();
cdI != compileDefinitions.end(); ++cdI)
@@ -343,7 +344,7 @@ void cmGhsMultiTargetGenerator::WriteIncludes(const std::string &config,
const std::string &language)
{
std::vector<std::string> includes =
- this->Target->GetIncludeDirectories(config, language);
+ this->GeneratorTarget->GetIncludeDirectories(config, language);
for (std::vector<std::string>::const_iterator includes_i = includes.begin();
includes_i != includes.end(); ++includes_i)
{
@@ -558,7 +559,7 @@ bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const &config,
{
bool output;
std::vector<std::string> options;
- this->Target->GetCompileOptions(options, config, language);
+ this->GeneratorTarget->GetCompileOptions(options, config, language);
output =
options.end() == std::find(options.begin(), options.end(), "-kernel");
return output;
@@ -587,7 +588,7 @@ bool cmGhsMultiTargetGenerator::DetermineIfDynamicDownload(
{
std::vector<std::string> options;
bool output = false;
- this->Target->GetCompileOptions(options, config, language);
+ this->GeneratorTarget->GetCompileOptions(options, config, language);
for (std::vector<std::string>::const_iterator options_i = options.begin();
options_i != options.end(); ++options_i)
{
diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx
index 87665a0..40e8d29 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.cxx
+++ b/Source/cmGlobalBorlandMakefileGenerator.cxx
@@ -44,10 +44,10 @@ void cmGlobalBorlandMakefileGenerator
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator(
- cmLocalGenerator* parent, cmState::Snapshot snapshot)
+ cmMakefile *mf)
{
cmLocalUnixMakefileGenerator3* lg =
- new cmLocalUnixMakefileGenerator3(this, parent, snapshot);
+ new cmLocalUnixMakefileGenerator3(this, mf);
lg->SetMakefileVariableSize(32);
lg->SetMakeCommandEscapeTargetTwice(true);
lg->SetBorlandMakeCurlyHack(true);
diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h
index 2ec510d..b59c86d 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.h
+++ b/Source/cmGlobalBorlandMakefileGenerator.h
@@ -36,8 +36,7 @@ public:
static void GetDocumentation(cmDocumentationEntry& entry);
///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
/**
* Try to determine system information such as shared library
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 40f1fcf..49f3b29 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1127,23 +1127,40 @@ void cmGlobalGenerator::Configure()
this->FirstTimeProgress = 0.0f;
this->ClearGeneratorMembers();
- // start with this directory
- cmLocalGenerator *lg = this->MakeLocalGenerator();
- this->Makefiles.push_back(lg->GetMakefile());
+ cmMakefile* dirMf =
+ new cmMakefile(this, this->GetCMakeInstance()->GetCurrentSnapshot());
+ this->Makefiles.push_back(dirMf);
+ cmLocalGenerator *lg = this->CreateLocalGenerator(dirMf);
this->LocalGenerators.push_back(lg);
// set the Start directories
- lg->GetMakefile()->SetCurrentSourceDirectory
+ dirMf->SetCurrentSourceDirectory
(this->CMakeInstance->GetHomeDirectory());
- lg->GetMakefile()->SetCurrentBinaryDirectory
+ dirMf->SetCurrentBinaryDirectory
(this->CMakeInstance->GetHomeOutputDirectory());
this->BinaryDirectories.insert(
this->CMakeInstance->GetHomeOutputDirectory());
// now do it
- lg->GetMakefile()->Configure();
- lg->GetMakefile()->EnforceDirectoryLevelRules();
+ dirMf->Configure();
+ dirMf->EnforceDirectoryLevelRules();
+
+ // Put a copy of each global target in every directory.
+ cmTargets globalTargets;
+ this->CreateDefaultGlobalTargets(&globalTargets);
+
+ for (unsigned int i = 0; i < this->Makefiles.size(); ++i)
+ {
+ cmMakefile* mf = this->Makefiles[i];
+ cmTargets* targets = &(mf->GetTargets());
+ cmTargets::iterator tit;
+ for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit )
+ {
+ (*targets)[tit->first] = tit->second;
+ (*targets)[tit->first].SetMakefile(mf);
+ }
+ }
// update the cache entry for the number of local generators, this is used
// for progress
@@ -1155,11 +1172,7 @@ void cmGlobalGenerator::Configure()
// check for link libraries and include directories containing "NOTFOUND"
// and for infinite loops
- this->CheckLocalGenerators();
-
- // at this point this->LocalGenerators has been filled,
- // so create the map from project name to vector of local generators
- this->FillProjectMap();
+ this->CheckTargetProperties();
if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE)
{
@@ -1186,25 +1199,6 @@ void cmGlobalGenerator::Configure()
}
this->CMakeInstance->UpdateProgress(msg.str().c_str(), -1);
}
-
- unsigned int i;
-
- // Put a copy of each global target in every directory.
- cmTargets globalTargets;
- this->CreateDefaultGlobalTargets(&globalTargets);
-
- for (i = 0; i < this->Makefiles.size(); ++i)
- {
- cmMakefile* mf = this->Makefiles[i];
- cmTargets* targets = &(mf->GetTargets());
- cmTargets::iterator tit;
- for ( tit = globalTargets.begin(); tit != globalTargets.end(); ++ tit )
- {
- (*targets)[tit->first] = tit->second;
- (*targets)[tit->first].SetMakefile(mf);
- }
- }
-
}
void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes)
@@ -1267,6 +1261,10 @@ bool cmGlobalGenerator::Compute()
this->CreateGenerationObjects();
+ // at this point this->LocalGenerators has been filled,
+ // so create the map from project name to vector of local generators
+ this->FillProjectMap();
+
#ifdef CMAKE_BUILD_WITH_CMAKE
// Iterate through all targets and set up automoc for those which have
// the AUTOMOC, AUTOUIC or AUTORCC property set
@@ -1327,11 +1325,9 @@ void cmGlobalGenerator::Generate()
// Compute the manifest of main targets generated.
for (i = 0; i < this->LocalGenerators.size(); ++i)
{
- this->LocalGenerators[i]->GenerateTargetManifest();
+ this->LocalGenerators[i]->ComputeTargetManifest();
}
- this->ProcessEvaluationFiles();
-
// Compute the inter-target dependencies.
if(!this->ComputeTargetDepends())
{
@@ -1342,6 +1338,8 @@ void cmGlobalGenerator::Generate()
// it builds by default.
this->InitializeProgressMarks();
+ this->ProcessEvaluationFiles();
+
for (i = 0; i < this->LocalGenerators.size(); ++i)
{
this->LocalGenerators[i]->ComputeHomeRelativeOutputPath();
@@ -1550,7 +1548,6 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes,
ti != targets.end(); ++ti)
{
cmTarget* t = &ti->second;
- t->Compute();
cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg);
this->GeneratorTargets[t] = gt;
generatorTargets[t] = gt;
@@ -1601,6 +1598,7 @@ void cmGlobalGenerator::ClearGeneratorMembers()
cmDeleteAll(this->BuildExportSets);
this->BuildExportSets.clear();
+ cmDeleteAll(this->Makefiles);
this->Makefiles.clear();
cmDeleteAll(this->LocalGenerators);
@@ -1635,7 +1633,7 @@ void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const
{
}
-void cmGlobalGenerator::CheckLocalGenerators()
+void cmGlobalGenerator::CheckTargetProperties()
{
std::map<std::string, std::string> notFoundMap;
// std::set<std::string> notFoundMap;
@@ -1670,8 +1668,7 @@ void cmGlobalGenerator::CheckLocalGenerators()
text += "\n linked by target \"";
text += l->second.GetName();
text += "\" in directory ";
- text+=this->LocalGenerators[i]->GetMakefile()
- ->GetCurrentSourceDirectory();
+ text+=this->Makefiles[i]->GetCurrentSourceDirectory();
notFoundMap[varName] = text;
}
}
@@ -1986,23 +1983,10 @@ void cmGlobalGenerator::EnableInstallTarget()
this->InstallTargetEnabled = true;
}
-cmLocalGenerator *
-cmGlobalGenerator::MakeLocalGenerator(cmState::Snapshot snapshot,
- cmLocalGenerator *parent)
-{
- if (!snapshot.IsValid())
- {
- snapshot = this->CMakeInstance->GetCurrentSnapshot();
- }
-
- return this->CreateLocalGenerator(parent, snapshot);
-}
-
cmLocalGenerator*
-cmGlobalGenerator::CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot)
+cmGlobalGenerator::CreateLocalGenerator(cmMakefile* mf)
{
- return new cmLocalGenerator(this, parent, snapshot);
+ return new cmLocalGenerator(this, mf);
}
void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen,
@@ -2041,24 +2025,37 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen)
}
}
-bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
- cmLocalGenerator* gen) const
+bool cmGlobalGenerator::IsExcluded(cmState::Snapshot const& rootSnp,
+ cmState::Snapshot const& snp_) const
{
- if(!gen || gen == root)
+ cmState::Snapshot snp = snp_;
+ while (snp.IsValid())
{
- // No directory excludes itself.
- return false;
- }
+ if(snp == rootSnp)
+ {
+ // No directory excludes itself.
+ return false;
+ }
- if(gen->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
- {
- // This directory is excluded from its parent.
- return true;
+ if(snp.GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL"))
+ {
+ // This directory is excluded from its parent.
+ return true;
+ }
+ snp = snp.GetBuildsystemDirectoryParent();
}
+ return false;
+}
+
+bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
+ cmLocalGenerator* gen) const
+{
+ assert(gen);
- // This directory is included in its parent. Check whether the
- // parent is excluded.
- return this->IsExcluded(root, gen->GetParent());
+ cmState::Snapshot rootSnp = root->GetStateSnapshot();
+ cmState::Snapshot snp = gen->GetStateSnapshot();
+
+ return this->IsExcluded(rootSnp, snp);
}
bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
@@ -2070,12 +2067,9 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
// This target is excluded from its directory.
return true;
}
- else
- {
- // This target is included in its directory. Check whether the
- // directory is excluded.
- return this->IsExcluded(root, target->GetLocalGenerator());
- }
+ // This target is included in its directory. Check whether the
+ // directory is excluded.
+ return this->IsExcluded(root, target->GetLocalGenerator());
}
void
@@ -2102,18 +2096,19 @@ void cmGlobalGenerator::FillProjectMap()
for(i = 0; i < this->LocalGenerators.size(); ++i)
{
// for each local generator add all projects
- cmLocalGenerator *lg = this->LocalGenerators[i];
+ cmState::Snapshot snp = this->LocalGenerators[i]->GetStateSnapshot();
std::string name;
do
{
- if (name != lg->GetMakefile()->GetProjectName())
+ std::string snpProjName = snp.GetProjectName();
+ if (name != snpProjName)
{
- name = lg->GetMakefile()->GetProjectName();
+ name = snpProjName;
this->ProjectMap[name].push_back(this->LocalGenerators[i]);
}
- lg = lg->GetParent();
+ snp = snp.GetBuildsystemDirectoryParent();
}
- while (lg);
+ while (snp.IsValid());
}
}
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index fe710f1..9fc2d45 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -56,9 +56,8 @@ public:
cmGlobalGenerator(cmake* cm);
virtual ~cmGlobalGenerator();
- cmLocalGenerator* MakeLocalGenerator(
- cmState::Snapshot snapshot = cmState::Snapshot(),
- cmLocalGenerator* parent = 0);
+ virtual cmLocalGenerator*
+ CreateLocalGenerator(cmMakefile* mf);
///! Get the name for this generator
virtual std::string GetName() const { return "Generic"; }
@@ -242,7 +241,7 @@ public:
#if defined(_WIN32) && !defined(__CYGWIN__)
/** Is this the Visual Studio 6 generator? */
- virtual bool IsForVS6() const { return false; }
+ bool IsForVS6() const { return this->GetName() == "Visual Studio 6"; }
#endif
///! Find a target by name by searching the local generators.
@@ -395,7 +394,9 @@ protected:
// Fill the ProjectMap, this must be called after LocalGenerators
// has been populated.
void FillProjectMap();
- void CheckLocalGenerators();
+ void CheckTargetProperties();
+ bool IsExcluded(cmState::Snapshot const& root,
+ cmState::Snapshot const& snp) const;
bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const;
bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const;
virtual void InitializeProgressMarks() {}
@@ -439,10 +440,6 @@ protected:
virtual bool UseFolderProperty();
private:
- ///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
-
cmMakefile* TryCompileOuterMakefile;
// If you add a new map here, make sure it is copied
// in EnableLanguagesFromGenerator
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index f764418..6dde1e3 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -33,10 +33,9 @@ cmGlobalGhsMultiGenerator::~cmGlobalGhsMultiGenerator()
}
cmLocalGenerator *
-cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot)
+cmGlobalGhsMultiGenerator::CreateLocalGenerator(cmMakefile* mf)
{
- return new cmLocalGhsMultiGenerator(this, parent, snapshot);
+ return new cmLocalGhsMultiGenerator(this, mf);
}
void cmGlobalGhsMultiGenerator::GetDocumentation(cmDocumentationEntry &entry)
diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h
index f1a3ed7..8f88d4f 100644
--- a/Source/cmGlobalGhsMultiGenerator.h
+++ b/Source/cmGlobalGhsMultiGenerator.h
@@ -31,8 +31,7 @@ public:
{ return new cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>(); }
///! create the correct local generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
/// @return the name of this generator.
static std::string GetActualName() { return "Green Hills MULTI"; }
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index b92ad32..120bb03 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -528,10 +528,9 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm)
// Virtual public methods.
cmLocalGenerator*
-cmGlobalNinjaGenerator::CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot)
+cmGlobalNinjaGenerator::CreateLocalGenerator(cmMakefile* mf)
{
- return new cmLocalNinjaGenerator(this, parent, snapshot);
+ return new cmLocalNinjaGenerator(this, mf);
}
void cmGlobalNinjaGenerator
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index f103801..d204a50 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -162,33 +162,24 @@ public:
public:
cmGlobalNinjaGenerator(cmake* cm);
- /// Convenience method for creating an instance of this class.
static cmGlobalGeneratorFactory* NewFactory() {
return new cmGlobalGeneratorSimpleFactory<cmGlobalNinjaGenerator>(); }
- /// Destructor.
virtual ~cmGlobalNinjaGenerator() { }
- /// Overloaded methods. @see cmGlobalGenerator::CreateLocalGenerator()
- virtual cmLocalGenerator* CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
- /// Overloaded methods. @see cmGlobalGenerator::GetName().
virtual std::string GetName() const {
return cmGlobalNinjaGenerator::GetActualName(); }
- /// @return the name of this generator.
static std::string GetActualName() { return "Ninja"; }
- /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
static void GetDocumentation(cmDocumentationEntry& entry);
- /// Overloaded methods. @see cmGlobalGenerator::EnableLanguage()
virtual void EnableLanguage(std::vector<std::string>const& languages,
cmMakefile* mf,
bool optional);
- /// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand()
virtual void GenerateBuildCommand(
std::vector<std::string>& makeCommand,
const std::string& makeProgram,
@@ -307,11 +298,8 @@ public:
protected:
- /// Overloaded methods. @see cmGlobalGenerator::Generate()
virtual void Generate();
- /// Overloaded methods.
- /// @see cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS()
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const { return true; }
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index b240924..cf4fd69 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -59,11 +59,10 @@ void cmGlobalUnixMakefileGenerator3
}
///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot)
+cmLocalGenerator* cmGlobalUnixMakefileGenerator3::CreateLocalGenerator(
+ cmMakefile* mf)
{
- return new cmLocalUnixMakefileGenerator3(this, parent, snapshot);
+ return new cmLocalUnixMakefileGenerator3(this, mf);
}
//----------------------------------------------------------------------------
@@ -495,12 +494,12 @@ cmGlobalUnixMakefileGenerator3
// The directory-level rule should depend on the directory-level
// rules of the subdirectories.
- for(std::vector<cmLocalGenerator*>::iterator sdi =
- lg->GetChildren().begin(); sdi != lg->GetChildren().end(); ++sdi)
+ std::vector<cmState::Snapshot> children
+ = lg->GetMakefile()->GetStateSnapshot().GetChildren();
+ for(std::vector<cmState::Snapshot>::const_iterator
+ ci = children.begin(); ci != children.end(); ++ci)
{
- cmLocalUnixMakefileGenerator3* slg =
- static_cast<cmLocalUnixMakefileGenerator3*>(*sdi);
- std::string subdir = slg->GetMakefile()->GetCurrentBinaryDirectory();
+ std::string subdir = ci->GetDirectory().GetCurrentBinary();
subdir += "/";
subdir += pass;
depends.push_back(subdir);
@@ -578,16 +577,20 @@ void cmGlobalUnixMakefileGenerator3
makeOptions.begin(), makeOptions.end());
if (!targetName.empty())
{
+ cmMakefile* mf;
cmLocalUnixMakefileGenerator3 *lg;
if (!this->LocalGenerators.empty())
{
lg = static_cast<cmLocalUnixMakefileGenerator3 *>
(this->LocalGenerators[0]);
+ mf = lg->GetMakefile();
}
else
{
+ cmState::Snapshot snapshot = this->CMakeInstance->GetCurrentSnapshot();
+ mf = new cmMakefile(this, snapshot);
lg = static_cast<cmLocalUnixMakefileGenerator3 *>
- (this->MakeLocalGenerator());
+ (this->CreateLocalGenerator(mf));
// set the Start directories
lg->GetMakefile()->SetCurrentSourceDirectory
(this->CMakeInstance->GetHomeDirectory());
@@ -606,6 +609,7 @@ void cmGlobalUnixMakefileGenerator3
if (this->LocalGenerators.empty())
{
delete lg;
+ delete mf;
}
}
}
@@ -936,14 +940,25 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks()
cmGeneratorTarget* gt = this->GetGeneratorTarget(&target);
+ cmLocalGenerator* tlg = gt->GetLocalGenerator();
+
+ if(gt->GetType() == cmTarget::INTERFACE_LIBRARY
+ || gt->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
+ {
+ continue;
+ }
+
+ cmState::Snapshot csnp = lg->GetStateSnapshot();
+ cmState::Snapshot tsnp = tlg->GetStateSnapshot();
+
// Consider the directory containing the target and all its
// parents until something excludes the target.
- for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt);
- clg = clg->GetParent())
+ for( ; csnp.IsValid() && !this->IsExcluded(csnp, tsnp);
+ csnp = csnp.GetBuildsystemDirectoryParent())
{
// This local generator includes the target.
std::set<cmGeneratorTarget const*>& targetSet =
- this->DirectoryTargetsMap[clg->GetStateSnapshot()];
+ this->DirectoryTargetsMap[csnp];
targetSet.insert(gt);
// Add dependencies of the included target. An excluded
@@ -1134,7 +1149,8 @@ bool cmGlobalUnixMakefileGenerator3
::NeedRequiresStep(cmTarget const& target)
{
std::set<std::string> languages;
- target.GetLanguages(languages,
+ cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&target);
+ gtgt->GetLanguages(languages,
target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for(std::set<std::string>::const_iterator l = languages.begin();
l != languages.end(); ++l)
diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h
index c738c16..5f39c79 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.h
+++ b/Source/cmGlobalUnixMakefileGenerator3.h
@@ -67,9 +67,7 @@ public:
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
- ///! Create a local generator appropriate to this Global Generator3
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
/**
* Try to determine system information such as shared library
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 8ec4fd9..44d632d 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -306,11 +306,10 @@ void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
}
///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalVisualStudio10Generator::CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot)
+cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator(
+ cmMakefile* mf)
{
- return new cmLocalVisualStudio10Generator(this, parent, snapshot);
+ return new cmLocalVisualStudio10Generator(this, mf);
}
//----------------------------------------------------------------------------
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 3d34a3f..8de7b09 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -48,8 +48,7 @@ public:
virtual bool Compute();
///! create the correct local generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
/**
* Try to determine system information such as shared library
diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
index b7c897c..df49948 100644
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ b/Source/cmGlobalVisualStudio6Generator.cxx
@@ -173,10 +173,9 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand(
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *
-cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot)
+cmGlobalVisualStudio6Generator::CreateLocalGenerator(cmMakefile* mf)
{
- return new cmLocalVisualStudio6Generator(this, parent, snapshot);
+ return new cmLocalVisualStudio6Generator(this, mf);
}
diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h
index 2460158..e9b24ea 100644
--- a/Source/cmGlobalVisualStudio6Generator.h
+++ b/Source/cmGlobalVisualStudio6Generator.h
@@ -39,8 +39,7 @@ public:
static void GetDocumentation(cmDocumentationEntry& entry);
///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
/**
* Try to determine system information such as shared library
@@ -85,8 +84,6 @@ public:
virtual void FindMakeProgram(cmMakefile*);
- virtual bool IsForVS6() const { return true; }
-
protected:
virtual void Generate();
virtual const char* GetIDEVersion() { return "6.0"; }
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 2660d23..0175062 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -279,12 +279,11 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
}
///! Create a local generator appropriate to this Global Generator
-cmLocalGenerator *
-cmGlobalVisualStudio7Generator::CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot)
+cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator(
+ cmMakefile* mf)
{
cmLocalVisualStudio7Generator *lg =
- new cmLocalVisualStudio7Generator(this, parent, snapshot);
+ new cmLocalVisualStudio7Generator(this, mf);
return lg;
}
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index 931ac9c..35575d1 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -43,8 +43,7 @@ public:
std::string const& GetPlatformName() const;
///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile* mf);
virtual bool SetSystemName(std::string const& s, cmMakefile* mf);
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 51dcab0..28f0425 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -254,7 +254,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false,
no_working_directory, no_depends,
noCommandLines);
- tgt->Compute();
+
cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg);
mf->AddGeneratorTarget(tgt, gt);
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index b0aa243..2bf04b4 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -90,7 +90,7 @@ bool cmGlobalVisualStudioGenerator::Compute()
AddUtilityCommand("ALL_BUILD", true, no_working_dir,
no_depends, no_commands, false,
"Build all projects");
- allBuild->Compute();
+
cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]);
allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt);
@@ -836,17 +836,19 @@ void RegisterVisualStudioMacros(const std::string& macrosFile,
bool
cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target)
{
+ cmGeneratorTarget* gt = this->GetGeneratorTarget(&target);
+
// check to see if this is a fortran build
std::set<std::string> languages;
{
// Issue diagnostic if the source files depend on the config.
std::vector<cmSourceFile*> sources;
- if (!target.GetConfigCommonSourceFiles(sources))
+ if (!gt->GetConfigCommonSourceFiles(sources))
{
return false;
}
}
- target.GetLanguages(languages, "");
+ gt->GetLanguages(languages, "");
if(languages.size() == 1)
{
if(*languages.begin() == "Fortran")
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 4ba29f5..33babec 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -371,10 +371,9 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
//----------------------------------------------------------------------------
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *
-cmGlobalXCodeGenerator::CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot)
+cmGlobalXCodeGenerator::CreateLocalGenerator(cmMakefile* mf)
{
- return new cmLocalXCodeGenerator(this, parent, snapshot);
+ return new cmLocalXCodeGenerator(this, mf);
}
//----------------------------------------------------------------------------
@@ -463,7 +462,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends,
no_working_directory,
"echo", "Build all projects");
- allbuild->Compute();
+
cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root);
mf->AddGeneratorTarget(allbuild, allBuildGt);
@@ -498,7 +497,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
true, no_depends,
no_working_directory,
"make", "-f", file.c_str());
- check->Compute();
+
cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root);
mf->AddGeneratorTarget(check, checkGt);
}
@@ -1124,7 +1123,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
// organize the sources
std::vector<cmSourceFile*> classes;
- if (!cmtarget.GetConfigCommonSourceFiles(classes))
+ if (!gtgt->GetConfigCommonSourceFiles(classes))
{
return false;
}
@@ -1383,8 +1382,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget)
if(llang.empty()) { return; }
// If the language is compiled as a source trust Xcode to link with it.
- cmTarget::LinkImplementation const* impl =
- cmtarget.GetLinkImplementation("NOCONFIG");
+ cmLinkImplementation const* impl =
+ gtgt->GetLinkImplementation("NOCONFIG");
for(std::vector<std::string>::const_iterator li = impl->Languages.begin();
li != impl->Languages.end(); ++li)
{
@@ -1505,7 +1504,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
}
std::vector<cmSourceFile*> classes;
- if (!cmtarget.GetConfigCommonSourceFiles(classes))
+ cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
+ if (!gtgt->GetConfigCommonSourceFiles(classes))
{
return;
}
@@ -1805,7 +1805,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
// Compute the compilation flags for each language.
std::set<std::string> languages;
- target.GetLanguages(languages, configName);
+ cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target);
+ gtgt->GetLanguages(languages, configName);
std::map<std::string, std::string> cflags;
for (std::set<std::string>::iterator li = languages.begin();
li != languages.end(); ++li)
@@ -1827,7 +1828,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
AddCompileOptions(flags, &target, lang, configName);
}
- cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target);
std::string llang = gtgt->GetLinkerLanguage(configName);
if(binary && llang.empty())
{
@@ -1855,7 +1855,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
this->AppendDefines(ppDefs, exportMacro);
}
std::vector<std::string> targetDefines;
- target.GetCompileDefinitions(targetDefines, configName, "C");
+ gtgt->GetCompileDefinitions(targetDefines, configName, "C");
this->AppendDefines(ppDefs, targetDefines);
buildSettings->AddAttribute
("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList());
@@ -2557,7 +2557,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
if(cmtarget.GetType() == cmTarget::UTILITY)
{
std::vector<cmSourceFile*> sources;
- if (!cmtarget.GetConfigCommonSourceFiles(sources))
+ cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
+ if (!gtgt->GetConfigCommonSourceFiles(sources))
{
return 0;
}
@@ -3085,7 +3086,8 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
}
std::vector<cmSourceFile*> classes;
- if (!cmtarget.GetConfigCommonSourceFiles(classes))
+ cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
+ if (!gtgt->GetConfigCommonSourceFiles(classes))
{
return false;
}
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index ee8bf2c..102c036 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -41,8 +41,7 @@ public:
static void GetDocumentation(cmDocumentationEntry& entry);
///! Create a local generator appropriate to this Global Generator
- virtual cmLocalGenerator *CreateLocalGenerator(cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ virtual cmLocalGenerator *CreateLocalGenerator(cmMakefile *mf);
/**
* Try to determine system information such as shared library
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index fa29b4f..2023697 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -68,8 +68,9 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
cmGlobalGenerator ggi(&cm);
- cmsys::auto_ptr<cmLocalGenerator> lg(ggi.MakeLocalGenerator());
- cmMakefile *mf = lg->GetMakefile();
+ cmsys::auto_ptr<cmMakefile> mf(
+ new cmMakefile(&ggi, cm.GetCurrentSnapshot()));
+ cmsys::auto_ptr<cmLocalGenerator> lg(ggi.CreateLocalGenerator(mf.get()));
const char* inFileName = settingsFileName;
diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h
index a5427de..10dd465 100644
--- a/Source/cmLinkItem.h
+++ b/Source/cmLinkItem.h
@@ -56,4 +56,66 @@ struct cmLinkImplementationLibraries
std::vector<cmLinkItem> WrongConfigLibraries;
};
+struct cmLinkInterfaceLibraries
+{
+ // Libraries listed in the interface.
+ std::vector<cmLinkItem> Libraries;
+};
+
+struct cmLinkInterface: public cmLinkInterfaceLibraries
+{
+ // Languages whose runtime libraries must be linked.
+ std::vector<std::string> Languages;
+
+ // Shared library dependencies needed for linking on some platforms.
+ std::vector<cmLinkItem> SharedDeps;
+
+ // Number of repetitions of a strongly connected component of two
+ // or more static libraries.
+ int Multiplicity;
+
+ // Libraries listed for other configurations.
+ // Needed only for OLD behavior of CMP0003.
+ std::vector<cmLinkItem> WrongConfigLibraries;
+
+ bool ImplementationIsInterface;
+
+ cmLinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {}
+};
+
+struct cmOptionalLinkInterface: public cmLinkInterface
+{
+ cmOptionalLinkInterface():
+ LibrariesDone(false), AllDone(false),
+ Exists(false), HadHeadSensitiveCondition(false),
+ ExplicitLibraries(0) {}
+ bool LibrariesDone;
+ bool AllDone;
+ bool Exists;
+ bool HadHeadSensitiveCondition;
+ const char* ExplicitLibraries;
+};
+
+struct cmHeadToLinkInterfaceMap:
+ public std::map<cmTarget const*, cmOptionalLinkInterface>
+{
+};
+
+struct cmLinkImplementation: public cmLinkImplementationLibraries
+{
+ // Languages whose runtime libraries must be linked.
+ std::vector<std::string> Languages;
+};
+
+// Cache link implementation computation from each configuration.
+struct cmOptionalLinkImplementation: public cmLinkImplementation
+{
+ cmOptionalLinkImplementation():
+ LibrariesDone(false), LanguagesDone(false),
+ HadHeadSensitiveCondition(false) {}
+ bool LibrariesDone;
+ bool LanguagesDone;
+ bool HadHeadSensitiveCondition;
+};
+
#endif
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx
index 4583446..5a18e2f 100644
--- a/Source/cmLocalCommonGenerator.cxx
+++ b/Source/cmLocalCommonGenerator.cxx
@@ -14,9 +14,8 @@
#include "cmMakefile.h"
cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot):
- cmLocalGenerator(gg, parent, snapshot)
+ cmMakefile* mf):
+ cmLocalGenerator(gg, mf)
{
}
diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h
index af94cda..6b4b1cd 100644
--- a/Source/cmLocalCommonGenerator.h
+++ b/Source/cmLocalCommonGenerator.h
@@ -22,9 +22,7 @@ class cmCommonTargetGenerator;
class cmLocalCommonGenerator: public cmLocalGenerator
{
public:
- cmLocalCommonGenerator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
~cmLocalCommonGenerator();
std::string const& GetConfigName() { return this->ConfigName; }
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index edb644d..b360c22 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -43,19 +43,13 @@
#endif
cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot)
- : cmOutputConverter(snapshot), StateSnapshot(snapshot)
+ cmMakefile* makefile)
+ : cmOutputConverter(makefile->GetStateSnapshot()),
+ StateSnapshot(makefile->GetStateSnapshot())
{
- assert(snapshot.IsValid());
this->GlobalGenerator = gg;
- this->Parent = parent;
- if (parent)
- {
- parent->AddChild(this);
- }
- this->Makefile = new cmMakefile(this);
+ this->Makefile = makefile;
this->EmitUniversalBinaryFlags = true;
this->BackwardsCompatibility = 0;
@@ -64,7 +58,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg,
cmLocalGenerator::~cmLocalGenerator()
{
- delete this->Makefile;
}
void cmLocalGenerator::IssueMessage(cmake::MessageType t,
@@ -199,18 +192,16 @@ void cmLocalGenerator::GenerateTestFiles()
(*gi)->Compute(this);
(*gi)->Generate(fout, config, configurationTypes);
}
- if (!this->Children.empty())
+ size_t i;
+ std::vector<cmState::Snapshot> children
+ = this->Makefile->GetStateSnapshot().GetChildren();
+ for(i = 0; i < children.size(); ++i)
{
- size_t i;
- for(i = 0; i < this->Children.size(); ++i)
- {
- // TODO: Use add_subdirectory instead?
- fout << "subdirs(";
- std::string outP =
- this->Children[i]->GetMakefile()->GetCurrentBinaryDirectory();
- fout << this->Convert(outP,START_OUTPUT);
- fout << ")" << std::endl;
- }
+ // TODO: Use add_subdirectory instead?
+ fout << "subdirs(";
+ std::string outP = children[i].GetDirectory().GetCurrentBinary();
+ fout << this->Convert(outP,START_OUTPUT);
+ fout << ")" << std::endl;
}
}
@@ -416,16 +407,18 @@ void cmLocalGenerator::GenerateInstallRules()
this->GenerateTargetInstallRules(fout, config, configurationTypes);
// Include install scripts from subdirectories.
- if(!this->Children.empty())
+ std::vector<cmState::Snapshot> children
+ = this->Makefile->GetStateSnapshot().GetChildren();
+ if(!children.empty())
{
fout << "if(NOT CMAKE_INSTALL_LOCAL_ONLY)\n";
fout << " # Include the install script for each subdirectory.\n";
- for(std::vector<cmLocalGenerator*>::const_iterator
- ci = this->Children.begin(); ci != this->Children.end(); ++ci)
+ for(std::vector<cmState::Snapshot>::const_iterator
+ ci = children.begin(); ci != children.end(); ++ci)
{
- if(!(*ci)->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
+ if(!ci->GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL"))
{
- std::string odir = (*ci)->GetMakefile()->GetCurrentBinaryDirectory();
+ std::string odir = ci->GetDirectory().GetCurrentBinary();
cmSystemTools::ConvertToUnixSlashes(odir);
fout << " include(\"" << odir
<< "/cmake_install.cmake\")" << std::endl;
@@ -454,7 +447,7 @@ void cmLocalGenerator::GenerateInstallRules()
}
//----------------------------------------------------------------------------
-void cmLocalGenerator::GenerateTargetManifest()
+void cmLocalGenerator::ComputeTargetManifest()
{
// Collect the set of configuration types.
std::vector<std::string> configNames;
@@ -482,7 +475,7 @@ void cmLocalGenerator::GenerateTargetManifest()
ci != configNames.end(); ++ci)
{
const char* config = ci->c_str();
- target.GenerateTargetManifest(config);
+ target.ComputeTargetManifest(config);
}
}
}
@@ -1083,7 +1076,8 @@ void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines,
const std::string& lang)
{
std::vector<std::string> targetDefines;
- target->GetCompileDefinitions(targetDefines, config, lang);
+ cmGeneratorTarget* gtgt = this->GlobalGenerator->GetGeneratorTarget(target);
+ gtgt->GetCompileDefinitions(targetDefines, config, lang);
this->AppendDefines(defines, targetDefines);
}
@@ -1094,6 +1088,10 @@ void cmLocalGenerator::AddCompileOptions(
)
{
std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX";
+
+ cmGeneratorTarget* gtgt =
+ this->GlobalGenerator->GetGeneratorTarget(target);
+
if(const char* langFlagRegexStr =
this->Makefile->GetDefinition(langFlagRegexVar))
{
@@ -1104,7 +1102,7 @@ void cmLocalGenerator::AddCompileOptions(
{
cmSystemTools::ParseWindowsCommandLine(targetFlags, opts);
}
- target->GetCompileOptions(opts, config, lang);
+ gtgt->GetCompileOptions(opts, config, lang);
for(std::vector<std::string>::const_iterator i = opts.begin();
i != opts.end(); ++i)
{
@@ -1125,7 +1123,7 @@ void cmLocalGenerator::AddCompileOptions(
this->AppendFlags(flags, targetFlags);
}
std::vector<std::string> opts;
- target->GetCompileOptions(opts, config, lang);
+ gtgt->GetCompileOptions(opts, config, lang);
for(std::vector<std::string>::const_iterator i = opts.begin();
i != opts.end(); ++i)
{
@@ -1134,7 +1132,7 @@ void cmLocalGenerator::AddCompileOptions(
}
}
std::vector<std::string> features;
- target->GetCompileFeatures(features, config);
+ gtgt->GetCompileFeatures(features, config);
for(std::vector<std::string>::const_iterator it = features.begin();
it != features.end(); ++it)
{
@@ -2368,25 +2366,22 @@ void cmLocalGenerator::AppendFeatureOptions(
const char* cmLocalGenerator::GetFeature(const std::string& feature,
const std::string& config)
{
+ std::string featureName = feature;
// TODO: Define accumulation policy for features (prepend, append, replace).
// Currently we always replace.
if(!config.empty())
{
- std::string featureConfig = feature;
- featureConfig += "_";
- featureConfig += cmSystemTools::UpperCase(config);
- if(const char* value = this->Makefile->GetProperty(featureConfig))
+ featureName += "_";
+ featureName += cmSystemTools::UpperCase(config);
+ }
+ cmState::Snapshot snp = this->StateSnapshot;
+ while(snp.IsValid())
+ {
+ if(const char* value = snp.GetDirectory().GetProperty(featureName))
{
return value;
}
- }
- if(const char* value = this->Makefile->GetProperty(feature))
- {
- return value;
- }
- if(cmLocalGenerator* parent = this->GetParent())
- {
- return parent->GetFeature(feature, config);
+ snp = snp.GetBuildsystemDirectoryParent();
}
return 0;
}
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 1c18788..b051e5d 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -36,8 +36,7 @@ class cmCustomCommandGenerator;
class cmLocalGenerator : public cmOutputConverter
{
public:
- cmLocalGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile);
virtual ~cmLocalGenerator();
/**
@@ -67,7 +66,7 @@ public:
/**
* Generate a manifest of target files that will be built.
*/
- void GenerateTargetManifest();
+ void ComputeTargetManifest();
///! Get the makefile for this generator
cmMakefile *GetMakefile() {
@@ -86,14 +85,6 @@ public:
cmState* GetState() const;
cmState::Snapshot GetStateSnapshot() const;
- ///! set/get the parent generator
- cmLocalGenerator* GetParent() const {return this->Parent;}
-
- ///! set/get the children
- void AddChild(cmLocalGenerator* g) { this->Children.push_back(g); }
- std::vector<cmLocalGenerator*>& GetChildren() { return this->Children; }
-
-
void AddArchitectureFlags(std::string& flags,
cmGeneratorTarget const* target,
const std::string&lang, const std::string& config);
@@ -348,8 +339,6 @@ protected:
cmMakefile *Makefile;
cmState::Snapshot StateSnapshot;
cmGlobalGenerator *GlobalGenerator;
- cmLocalGenerator* Parent;
- std::vector<cmLocalGenerator*> Children;
std::map<std::string, std::string> UniqueObjectNamesMap;
std::string::size_type ObjectPathMax;
std::set<std::string> ObjectMaxPathViolations;
diff --git a/Source/cmLocalGhsMultiGenerator.cxx b/Source/cmLocalGhsMultiGenerator.cxx
index 8e498dd..bac989f 100644
--- a/Source/cmLocalGhsMultiGenerator.cxx
+++ b/Source/cmLocalGhsMultiGenerator.cxx
@@ -17,9 +17,8 @@
#include "cmGeneratedFileStream.h"
cmLocalGhsMultiGenerator::cmLocalGhsMultiGenerator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot)
- : cmLocalGenerator(gg, parent, snapshot)
+ cmMakefile* mf)
+ : cmLocalGenerator(gg, mf)
{
}
diff --git a/Source/cmLocalGhsMultiGenerator.h b/Source/cmLocalGhsMultiGenerator.h
index f52ef39..b6a9a33 100644
--- a/Source/cmLocalGhsMultiGenerator.h
+++ b/Source/cmLocalGhsMultiGenerator.h
@@ -25,8 +25,7 @@ class cmGeneratedFileStream;
class cmLocalGhsMultiGenerator : public cmLocalGenerator
{
public:
- cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ cmLocalGhsMultiGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
virtual ~cmLocalGhsMultiGenerator();
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index cfca418..7525bf2 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -23,9 +23,8 @@
#include <assert.h>
cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot)
- : cmLocalCommonGenerator(gg, parent, snapshot)
+ cmMakefile* mf)
+ : cmLocalCommonGenerator(gg, mf)
, HomeRelativeOutputPath("")
{
this->TargetImplib = "$TARGET_IMPLIB";
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index d10be0c..8d3d49c 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -31,8 +31,7 @@ class cmake;
class cmLocalNinjaGenerator : public cmLocalCommonGenerator
{
public:
- cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
virtual ~cmLocalNinjaGenerator();
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index ce370bc..b131a63 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -80,9 +80,8 @@ static std::string cmSplitExtension(std::string const& in, std::string& base)
//----------------------------------------------------------------------------
cmLocalUnixMakefileGenerator3::
-cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmLocalGenerator* parent,
- cmState::Snapshot snapshot)
- : cmLocalCommonGenerator(gg, parent, snapshot)
+cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf)
+ : cmLocalCommonGenerator(gg, mf)
{
this->MakefileVariableSize = 0;
this->ColorMakefile = false;
@@ -1257,7 +1256,9 @@ cmLocalUnixMakefileGenerator3
{
// Get the set of source languages in the target.
std::set<std::string> languages;
- target.GetLanguages(languages,
+ cmGeneratorTarget *gtgt =
+ this->GlobalGenerator->GetGeneratorTarget(&target);
+ gtgt->GetLanguages(languages,
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
fout << "\n"
<< "# Per-language clean rules from dependency scanning.\n"
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index 01ac01b..98f15e6 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -34,9 +34,7 @@ class cmSourceFile;
class cmLocalUnixMakefileGenerator3 : public cmLocalCommonGenerator
{
public:
- cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ cmLocalUnixMakefileGenerator3(cmGlobalGenerator* gg, cmMakefile* mf);
virtual ~cmLocalUnixMakefileGenerator3();
virtual void ComputeHomeRelativeOutputPath();
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index 9e3185c..b043b00 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -62,10 +62,8 @@ class cmVS10XMLParser : public cmXMLParser
//----------------------------------------------------------------------------
cmLocalVisualStudio10Generator
-::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot):
- cmLocalVisualStudio7Generator(gg, parent, snapshot)
+::cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf):
+ cmLocalVisualStudio7Generator(gg, mf)
{
}
diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h
index c588aaf..e187590 100644
--- a/Source/cmLocalVisualStudio10Generator.h
+++ b/Source/cmLocalVisualStudio10Generator.h
@@ -25,9 +25,7 @@ class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator
{
public:
///! Set cache only and recurse to false by default.
- cmLocalVisualStudio10Generator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf);
virtual ~cmLocalVisualStudio10Generator();
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index 0d07536..cc94cd4 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -24,10 +24,8 @@
#include <cmsys/FStream.hxx>
cmLocalVisualStudio6Generator
-::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot):
- cmLocalVisualStudioGenerator(gg, parent, snapshot)
+::cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf):
+ cmLocalVisualStudioGenerator(gg, mf)
{
}
@@ -305,9 +303,12 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
// We may be modifying the source groups temporarily, so make a copy.
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
+ cmGeneratorTarget* gt =
+ this->GlobalGenerator->GetGeneratorTarget(&target);
+
// get the classes from the source lists then add them to the groups
std::vector<cmSourceFile*> classes;
- if (!target.GetConfigCommonSourceFiles(classes))
+ if (!gt->GetConfigCommonSourceFiles(classes))
{
return;
}
diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h
index a44e61d..828d252 100644
--- a/Source/cmLocalVisualStudio6Generator.h
+++ b/Source/cmLocalVisualStudio6Generator.h
@@ -29,9 +29,7 @@ class cmLocalVisualStudio6Generator : public cmLocalVisualStudioGenerator
{
public:
///! Set cache only and recurse to false by default.
- cmLocalVisualStudio6Generator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ cmLocalVisualStudio6Generator(cmGlobalGenerator* gg, cmMakefile* mf);
virtual ~cmLocalVisualStudio6Generator();
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 5de6d37..cf67251 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -53,10 +53,8 @@ static void cmConvertToWindowsSlash(std::string& s)
//----------------------------------------------------------------------------
cmLocalVisualStudio7Generator
-::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot):
- cmLocalVisualStudioGenerator(gg, parent, snapshot)
+::cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf):
+ cmLocalVisualStudioGenerator(gg, mf)
{
this->Internal = new cmLocalVisualStudio7GeneratorInternals(this);
}
@@ -763,7 +761,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
targetOptions.Parse(defineFlags.c_str());
targetOptions.ParseFinish();
std::vector<std::string> targetDefines;
- target.GetCompileDefinitions(targetDefines, configName, "CXX");
+ gt->GetCompileDefinitions(targetDefines, configName, "CXX");
targetOptions.AddDefines(targetDefines);
targetOptions.SetVerboseMakefile(
this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
@@ -1469,10 +1467,13 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
// We may be modifying the source groups temporarily, so make a copy.
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
+ cmGeneratorTarget* gt =
+ this->GlobalGenerator->GetGeneratorTarget(&target);
+
// get the classes from the source lists then add them to the groups
this->ModuleDefinitionFile = "";
std::vector<cmSourceFile*> classes;
- if (!target.GetConfigCommonSourceFiles(classes))
+ if (!gt->GetConfigCommonSourceFiles(classes))
{
return;
}
@@ -1514,8 +1515,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
{
// VS >= 8 support per-config source locations so we
// list object library content as external objects.
- cmGeneratorTarget* gt =
- this->GlobalGenerator->GetGeneratorTarget(&target);
std::vector<std::string> objs;
gt->UseObjectLibraries(objs, "");
if(!objs.empty())
diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h
index 43f3af9..bc05a06 100644
--- a/Source/cmLocalVisualStudio7Generator.h
+++ b/Source/cmLocalVisualStudio7Generator.h
@@ -35,9 +35,7 @@ class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator
{
public:
///! Set cache only and recurse to false by default.
- cmLocalVisualStudio7Generator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf);
virtual ~cmLocalVisualStudio7Generator();
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index 3588853..c0072de 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -19,10 +19,8 @@
//----------------------------------------------------------------------------
cmLocalVisualStudioGenerator
-::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot)
- : cmLocalGenerator(gg, parent, snapshot)
+::cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf)
+ : cmLocalGenerator(gg, mf)
{
}
diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h
index d414651..071bfb3 100644
--- a/Source/cmLocalVisualStudioGenerator.h
+++ b/Source/cmLocalVisualStudioGenerator.h
@@ -31,9 +31,7 @@ class cmCustomCommandGenerator;
class cmLocalVisualStudioGenerator : public cmLocalGenerator
{
public:
- cmLocalVisualStudioGenerator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ cmLocalVisualStudioGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
virtual ~cmLocalVisualStudioGenerator();
/** Construct a script from the given list of command lines. */
diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx
index 804dd7d..b19112d 100644
--- a/Source/cmLocalXCodeGenerator.cxx
+++ b/Source/cmLocalXCodeGenerator.cxx
@@ -16,9 +16,8 @@
//----------------------------------------------------------------------------
cmLocalXCodeGenerator::cmLocalXCodeGenerator(cmGlobalGenerator* gg,
- cmLocalGenerator* parent,
- cmState::Snapshot snapshot)
- : cmLocalGenerator(gg, parent, snapshot)
+ cmMakefile* mf)
+ : cmLocalGenerator(gg, mf)
{
// the global generator does this, so do not
// put these flags into the language flags
diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h
index 26fff9c..6d0926f 100644
--- a/Source/cmLocalXCodeGenerator.h
+++ b/Source/cmLocalXCodeGenerator.h
@@ -24,8 +24,8 @@ class cmLocalXCodeGenerator : public cmLocalGenerator
{
public:
///! Set cache only and recurse to false by default.
- cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmLocalGenerator* parent,
- cmState::Snapshot snapshot);
+ cmLocalXCodeGenerator(cmGlobalGenerator* gg,
+ cmMakefile* mf);
virtual ~cmLocalXCodeGenerator();
virtual std::string GetTargetDirectory(cmTarget const& target) const;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 2296d5a..8a3d197 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -16,7 +16,6 @@
#include "cmSourceFileLocation.h"
#include "cmSystemTools.h"
#include "cmGlobalGenerator.h"
-#include "cmLocalGenerator.h"
#include "cmCommands.h"
#include "cmState.h"
#include "cmOutputConverter.h"
@@ -43,19 +42,13 @@
#include <ctype.h> // for isspace
#include <assert.h>
-class cmMakefile::Internals
-{
-public:
- bool IsSourceFileTryCompile;
-};
-
// default is not to be building executables
-cmMakefile::cmMakefile(cmLocalGenerator* localGenerator)
- : Internal(new Internals),
- LocalGenerator(localGenerator),
- StateSnapshot(localGenerator->GetStateSnapshot())
+cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator,
+ cmState::Snapshot const& snapshot)
+ : GlobalGenerator(globalGenerator),
+ StateSnapshot(snapshot)
{
- this->Internal->IsSourceFileTryCompile = false;
+ this->IsSourceFileTryCompile = false;
// Initialize these first since AddDefaultDefinitions calls AddDefinition
this->WarnUnused = this->GetCMakeInstance()->GetWarnUnused();
@@ -1525,7 +1518,7 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent)
parent->GetProperty("LINK_DIRECTORIES"));
// the initial project name
- this->ProjectName = parent->ProjectName;
+ this->SetProjectName(parent->GetProjectName());
// Copy include regular expressions.
this->ComplainFileRegularExpression = parent->ComplainFileRegularExpression;
@@ -1760,14 +1753,14 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath,
this->ContextStack.back()->Name,
this->ContextStack.back()->Line);
+ cmMakefile* subMf = new cmMakefile(this->GlobalGenerator, newSnapshot);
+ this->GetGlobalGenerator()->AddMakefile(subMf);
+
// create a new local generator and set its parent
cmLocalGenerator *lg2 = this->GetGlobalGenerator()
- ->MakeLocalGenerator(newSnapshot, this->LocalGenerator);
- this->GetGlobalGenerator()->AddMakefile(lg2->GetMakefile());
+ ->CreateLocalGenerator(subMf);
this->GetGlobalGenerator()->AddLocalGenerator(lg2);
- cmMakefile* subMf = lg2->GetMakefile();
-
// set the subdirs start dirs
subMf->SetCurrentSourceDirectory(srcPath);
subMf->SetCurrentBinaryDirectory(binPath);
@@ -2044,11 +2037,15 @@ void cmMakefile::RemoveCacheDefinition(const std::string& name)
this->GetState()->RemoveCacheEntry(name);
}
-void cmMakefile::SetProjectName(const char* p)
+void cmMakefile::SetProjectName(std::string const& p)
{
- this->ProjectName = p;
+ this->StateSnapshot.SetProjectName(p);
}
+std::string cmMakefile::GetProjectName() const
+{
+ return this->StateSnapshot.GetProjectName();
+}
void cmMakefile::AddGlobalLinkInformation(const std::string& name,
cmTarget& target)
@@ -2079,7 +2076,8 @@ void cmMakefile::AddGlobalLinkInformation(const std::string& name,
if(std::find(this->LinkDirectories.begin(),
this->LinkDirectories.end(), newdir)
== this->LinkDirectories.end())
- {target.AddLinkDirectory(*j);
+ {
+ target.AddLinkDirectory(*j);
}
}
}
@@ -2336,7 +2334,8 @@ void cmMakefile::ExpandVariablesCMP0019()
l != this->Targets.end(); ++l)
{
cmTarget &t = l->second;
- if (t.GetType() == cmTarget::INTERFACE_LIBRARY)
+ if (t.GetType() == cmTarget::INTERFACE_LIBRARY
+ || t.GetType() == cmTarget::GLOBAL_TARGET)
{
continue;
}
@@ -3616,7 +3615,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
const std::vector<std::string> *cmakeArgs,
std::string& output)
{
- this->Internal->IsSourceFileTryCompile = fast;
+ this->IsSourceFileTryCompile = fast;
// does the binary directory exist ? If not create it...
if (!cmSystemTools::FileIsDirectory(bindir))
{
@@ -3641,7 +3640,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
"Internal CMake error, TryCompile bad GlobalGenerator");
// return to the original directory
cmSystemTools::ChangeDirectory(cwd);
- this->Internal->IsSourceFileTryCompile = false;
+ this->IsSourceFileTryCompile = false;
return 1;
}
cm.SetGlobalGenerator(gg);
@@ -3712,7 +3711,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
"Internal CMake error, TryCompile configure of cmake failed");
// return to the original directory
cmSystemTools::ChangeDirectory(cwd);
- this->Internal->IsSourceFileTryCompile = false;
+ this->IsSourceFileTryCompile = false;
return 1;
}
@@ -3722,7 +3721,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
"Internal CMake error, TryCompile generation of cmake failed");
// return to the original directory
cmSystemTools::ChangeDirectory(cwd);
- this->Internal->IsSourceFileTryCompile = false;
+ this->IsSourceFileTryCompile = false;
return 1;
}
@@ -3735,23 +3734,23 @@ int cmMakefile::TryCompile(const std::string& srcdir,
this);
cmSystemTools::ChangeDirectory(cwd);
- this->Internal->IsSourceFileTryCompile = false;
+ this->IsSourceFileTryCompile = false;
return ret;
}
bool cmMakefile::GetIsSourceFileTryCompile() const
{
- return this->Internal->IsSourceFileTryCompile;
+ return this->IsSourceFileTryCompile;
}
cmake *cmMakefile::GetCMakeInstance() const
{
- return this->GetGlobalGenerator()->GetCMakeInstance();
+ return this->GlobalGenerator->GetCMakeInstance();
}
cmGlobalGenerator* cmMakefile::GetGlobalGenerator() const
{
- return this->LocalGenerator->GetGlobalGenerator();
+ return this->GlobalGenerator;
}
#ifdef CMAKE_BUILD_WITH_CMAKE
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 055170a..3cf20a6 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -42,7 +42,6 @@
class cmFunctionBlocker;
class cmCommand;
class cmInstallGenerator;
-class cmLocalGenerator;
class cmMakeDepend;
class cmSourceFile;
class cmTest;
@@ -62,8 +61,6 @@ class cmGeneratorExpressionEvaluationFile;
*/
class cmMakefile
{
- class Internals;
- cmsys::auto_ptr<Internals> Internal;
public:
/* Mark a variable as used */
void MarkVariableAsUsed(const std::string& var);
@@ -73,7 +70,8 @@ public:
/**
* Construct an empty makefile.
*/
- cmMakefile(cmLocalGenerator* localGenerator);
+ cmMakefile(cmGlobalGenerator* globalGenerator,
+ const cmState::Snapshot& snapshot);
/**
* Destructor.
@@ -274,15 +272,12 @@ public:
/**
* Specify the name of the project for this build.
*/
- void SetProjectName(const char*);
+ void SetProjectName(std::string const& name);
/**
* Get the name of the project for this build.
*/
- const char* GetProjectName() const
- {
- return this->ProjectName.c_str();
- }
+ std::string GetProjectName() const;
/** Get the configurations to be generated. */
std::string GetConfigurations(std::vector<std::string>& configs,
@@ -813,8 +808,6 @@ protected:
mutable std::set<cmListFileContext> CMP0054ReportedIds;
- std::string ProjectName; // project name
-
// libraries, classes, and executables
mutable cmTargets Targets;
#if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -863,7 +856,7 @@ protected:
#endif
std::vector<cmCommand*> FinalPassCommands;
- cmLocalGenerator* LocalGenerator;
+ cmGlobalGenerator* GlobalGenerator;
bool IsFunctionBlocked(const cmListFileFunction& lff,
cmExecutionStatus &status);
@@ -996,6 +989,7 @@ private:
bool CheckSystemVars;
bool CheckCMP0000;
bool Configured;
+ bool IsSourceFileTryCompile;
mutable bool SuppressWatches;
};
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 0b3df90..cf88a74 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -276,7 +276,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
{
// write language flags for target
std::set<std::string> languages;
- this->Target->GetLanguages(languages,
+ this->GeneratorTarget->GetLanguages(languages,
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
// put the compiler in the rules.make file so that if it changes
// things rebuild
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index 46d7e01..7123125 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -20,7 +20,7 @@ bool cmProjectCommand
this->SetError("PROJECT called with incorrect number of arguments");
return false;
}
- this->Makefile->SetProjectName(args[0].c_str());
+ this->Makefile->SetProjectName(args[0]);
std::string bindir = args[0];
bindir += "_BINARY_DIR";
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index f85e70e..becfeba 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -403,7 +403,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
)
{
std::vector<cmSourceFile*> srcFiles;
- target->GetConfigCommonSourceFiles(srcFiles);
+ cmGeneratorTarget* gtgt =
+ lg->GetGlobalGenerator()->GetGeneratorTarget(target);
+ gtgt->GetConfigCommonSourceFiles(srcFiles);
for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
fileIt != srcFiles.end();
++fileIt)
@@ -474,8 +476,6 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
/*byproducts=*/rcc_output, depends,
commandLines, false, autogenComment.c_str());
- autogenTarget->Compute();
-
cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
makefile->AddGeneratorTarget(autogenTarget, gt);
@@ -663,7 +663,10 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target)
const char* sepHeaders = "";
std::vector<cmSourceFile*> srcFiles;
- target->GetConfigCommonSourceFiles(srcFiles);
+ cmGeneratorTarget *gtgt = target->GetMakefile()
+ ->GetGlobalGenerator()
+ ->GetGeneratorTarget(target);
+ gtgt->GetConfigCommonSourceFiles(srcFiles);
const char *skipMocSep = "";
const char *skipUicSep = "";
@@ -1048,7 +1051,10 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
cmMakefile *makefile = target->GetMakefile();
std::vector<cmSourceFile*> srcFiles;
- target->GetConfigCommonSourceFiles(srcFiles);
+ cmGeneratorTarget *gtgt = target->GetMakefile()
+ ->GetGlobalGenerator()
+ ->GetGeneratorTarget(target);
+ gtgt->GetConfigCommonSourceFiles(srcFiles);
std::string qrcInputs;
const char* qrcInputsSep = "";
@@ -1211,7 +1217,9 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
cm.SetHomeDirectory(targetDirectory);
cmGlobalGenerator gg(&cm);
- cmLocalGenerator* lg = gg.MakeLocalGenerator();
+ cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
+ cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, snapshot));
+ cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator(mf.get()));
lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory);
lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory);
gg.SetCurrentMakefile(lg->GetMakefile());
@@ -1228,7 +1236,6 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
this->WriteOldMocDefinitionsFile(targetDirectory);
- delete lg;
return success;
}
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 53fdae0..b30c10b 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -75,7 +75,11 @@ struct cmState::BuildsystemDirectoryStateType
std::vector<std::string> CompileOptions;
std::vector<cmListFileBacktrace> CompileOptionsBacktraces;
+ std::string ProjectName;
+
cmPropertyMap Properties;
+
+ std::vector<cmState::Snapshot> Children;
};
cmState::cmState(cmake* cm)
@@ -274,6 +278,7 @@ cmState::Snapshot cmState::Reset()
it->CompileOptionsBacktraces.clear();
it->DirectoryEnd = pos;
it->Properties.clear();
+ it->Children.clear();
}
this->PolicyStack.Clear();
@@ -800,7 +805,9 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot,
pos->Parent = origin;
pos->Root = origin;
pos->Vars = this->VarTree.Extend(origin);
- return cmState::Snapshot(this, pos);
+ cmState::Snapshot snapshot = cmState::Snapshot(this, pos);
+ originSnapshot.Position->BuildSystemDirectory->Children.push_back(snapshot);
+ return snapshot;
}
cmState::Snapshot
@@ -938,6 +945,11 @@ cmState::Snapshot::Snapshot(cmState* state)
{
}
+std::vector<cmState::Snapshot> cmState::Snapshot::GetChildren()
+{
+ return this->Position->BuildSystemDirectory->Children;
+}
+
cmState::Snapshot::Snapshot(cmState* state, PositionType position)
: State(state),
Position(position)
@@ -1312,6 +1324,16 @@ cmState::Directory cmState::Snapshot::GetDirectory() const
return Directory(this->Position->BuildSystemDirectory, *this);
}
+void cmState::Snapshot::SetProjectName(const std::string& name)
+{
+ this->Position->BuildSystemDirectory->ProjectName = name;
+}
+
+std::string cmState::Snapshot::GetProjectName() const
+{
+ return this->Position->BuildSystemDirectory->ProjectName;
+}
+
cmState::Directory::Directory(
cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter,
const cmState::Snapshot& snapshot)
@@ -1701,3 +1723,13 @@ std::vector<std::string> cmState::Directory::GetPropertyKeys() const
}
return keys;
}
+
+bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs)
+{
+ return lhs.Position == rhs.Position;
+}
+
+bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs)
+{
+ return lhs.Position != rhs.Position;
+}
diff --git a/Source/cmState.h b/Source/cmState.h
index e503cd2..99e537c 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -65,6 +65,8 @@ public:
void SetListFile(std::string const& listfile);
std::string GetExecutionListFile() const;
+
+ std::vector<Snapshot> GetChildren();
std::string GetEntryPointCommand() const;
long GetEntryPointLine() const;
@@ -86,6 +88,9 @@ public:
Directory GetDirectory() const;
+ void SetProjectName(std::string const& name);
+ std::string GetProjectName() const;
+
struct StrictWeakOrder
{
bool operator()(const cmState::Snapshot& lhs,
@@ -93,6 +98,10 @@ public:
};
private:
+ friend bool operator==(const cmState::Snapshot& lhs,
+ const cmState::Snapshot& rhs);
+ friend bool operator!=(const cmState::Snapshot& lhs,
+ const cmState::Snapshot& rhs);
friend class cmState;
friend class Directory;
friend struct StrictWeakOrder;
@@ -314,4 +323,7 @@ private:
bool MSYSShell;
};
+bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs);
+bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs);
+
#endif
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 3f03b51..cac6a12 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1012,6 +1012,95 @@ std::string cmSystemTools::ComputeStringMD5(const std::string& input)
#endif
}
+//----------------------------------------------------------------------------
+std::string cmSystemTools::ComputeCertificateThumbprint(
+ const std::string& source)
+{
+ std::string thumbprint;
+
+#ifdef _WIN32
+ BYTE* certData = NULL;
+ CRYPT_INTEGER_BLOB cryptBlob;
+ HCERTSTORE certStore = NULL;
+ PCCERT_CONTEXT certContext = NULL;
+
+ HANDLE certFile =
+ CreateFileW(cmsys::Encoding::ToWide(source.c_str()).c_str(),
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
+ if (certFile != INVALID_HANDLE_VALUE && certFile != NULL)
+ {
+ DWORD fileSize = GetFileSize(certFile, NULL);
+ if (fileSize != INVALID_FILE_SIZE)
+ {
+ certData = new BYTE[fileSize];
+ if (certData != NULL)
+ {
+ DWORD dwRead = 0;
+ if (ReadFile(certFile, certData, fileSize, &dwRead, NULL))
+ {
+ cryptBlob.cbData = fileSize;
+ cryptBlob.pbData = certData;
+
+ // Verify that this is a valid cert
+ if (PFXIsPFXBlob(&cryptBlob))
+ {
+ // Open the certificate as a store
+ certStore = PFXImportCertStore(
+ &cryptBlob, NULL, CRYPT_EXPORTABLE);
+ if (certStore != NULL)
+ {
+ // There should only be 1 cert.
+ certContext = CertEnumCertificatesInStore(certStore,
+ certContext);
+ if (certContext != NULL)
+ {
+ // The hash is 20 bytes
+ BYTE hashData[20];
+ DWORD hashLength = 20;
+
+ // Buffer to print the hash. Each byte takes 2 chars +
+ // terminating character
+ char hashPrint[41];
+ char *pHashPrint = hashPrint;
+ // Get the hash property from the certificate
+ if (CertGetCertificateContextProperty(certContext,
+ CERT_HASH_PROP_ID, hashData, &hashLength))
+ {
+ for (DWORD i = 0; i < hashLength; i++)
+ {
+ // Convert each byte to hexadecimal
+ sprintf(pHashPrint, "%02X", hashData[i]);
+ pHashPrint += 2;
+ }
+ *pHashPrint = '\0';
+ thumbprint = hashPrint;
+ }
+ CertFreeCertificateContext(certContext);
+ }
+ CertCloseStore(certStore, 0);
+ }
+ }
+ }
+ delete[] certData;
+ }
+ }
+ CloseHandle(certFile);
+ }
+#else
+ (void)source;
+ cmSystemTools::Message("ComputeCertificateThumbprint is not implemented",
+ "Error");
+#endif
+
+ return thumbprint;
+}
+
void cmSystemTools::Glob(const std::string& directory,
const std::string& regexp,
std::vector<std::string>& files)
@@ -2314,7 +2403,7 @@ void cmSystemTools::MakefileColorEcho(int color, const char* message,
assumeTTY = 0;
}
- if(enabled)
+ if(enabled && color != cmsysTerminal_Color_Normal)
{
// Print with color. Delay the newline until later so that
// all color restore sequences appear before it.
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index fb58307..c12a1db 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -194,6 +194,9 @@ public:
/** Compute the md5sum of a string. */
static std::string ComputeStringMD5(const std::string& input);
+ ///! Get the SHA thumbprint for a certificate file
+ static std::string ComputeCertificateThumbprint(const std::string& source);
+
/**
* Run a single executable command
*
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index d6d509c..590654d 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -77,13 +77,11 @@ public:
cmTargetInternals()
: Backtrace()
{
- this->PolicyWarnedCMP0022 = false;
this->UtilityItemsDone = false;
}
cmTargetInternals(cmTargetInternals const&)
: Backtrace()
{
- this->PolicyWarnedCMP0022 = false;
this->UtilityItemsDone = false;
}
~cmTargetInternals();
@@ -91,64 +89,14 @@ public:
// The backtrace when the target was created.
cmListFileBacktrace Backtrace;
- // Cache link interface computation from each configuration.
- struct OptionalLinkInterface: public cmTarget::LinkInterface
- {
- OptionalLinkInterface():
- LibrariesDone(false), AllDone(false),
- Exists(false), HadHeadSensitiveCondition(false),
- ExplicitLibraries(0) {}
- bool LibrariesDone;
- bool AllDone;
- bool Exists;
- bool HadHeadSensitiveCondition;
- const char* ExplicitLibraries;
- };
- void ComputeLinkInterface(cmTarget const* thisTarget,
- const std::string& config,
- OptionalLinkInterface& iface,
- cmTarget const* head) const;
- void ComputeLinkInterfaceLibraries(cmTarget const* thisTarget,
- const std::string& config,
- OptionalLinkInterface& iface,
- cmTarget const* head,
- bool usage_requirements_only);
-
- struct HeadToLinkInterfaceMap:
- public std::map<cmTarget const*, OptionalLinkInterface> {};
- typedef std::map<std::string, HeadToLinkInterfaceMap>
- LinkInterfaceMapType;
- LinkInterfaceMapType LinkInterfaceMap;
- LinkInterfaceMapType LinkInterfaceUsageRequirementsOnlyMap;
- bool PolicyWarnedCMP0022;
-
typedef std::map<std::string, cmTarget::OutputInfo> OutputInfoMapType;
OutputInfoMapType OutputInfoMap;
typedef std::map<std::string, cmTarget::ImportInfo> ImportInfoMapType;
ImportInfoMapType ImportInfoMap;
- // Cache link implementation computation from each configuration.
- struct OptionalLinkImplementation: public cmTarget::LinkImplementation
- {
- OptionalLinkImplementation():
- LibrariesDone(false), LanguagesDone(false),
- HadHeadSensitiveCondition(false) {}
- bool LibrariesDone;
- bool LanguagesDone;
- bool HadHeadSensitiveCondition;
- };
- void ComputeLinkImplementationLibraries(cmTarget const* thisTarget,
- const std::string& config,
- OptionalLinkImplementation& impl,
- cmTarget const* head) const;
- void ComputeLinkImplementationLanguages(cmTarget const* thisTarget,
- const std::string& config,
- OptionalLinkImplementation& impl
- ) const;
-
struct HeadToLinkImplementationMap:
- public std::map<cmTarget const*, OptionalLinkImplementation> {};
+ public std::map<cmTarget const*, cmOptionalLinkImplementation> {};
typedef std::map<std::string,
HeadToLinkImplementationMap> LinkImplMapType;
LinkImplMapType LinkImplMap;
@@ -172,16 +120,12 @@ public:
};
std::vector<std::string> IncludeDirectoriesEntries;
std::vector<cmListFileBacktrace> IncludeDirectoriesBacktraces;
- std::vector<TargetPropertyEntry*> IncludeDirectoriesItems;
std::vector<std::string> CompileOptionsEntries;
std::vector<cmListFileBacktrace> CompileOptionsBacktraces;
- std::vector<TargetPropertyEntry*> CompileOptionsItems;
std::vector<std::string> CompileFeaturesEntries;
std::vector<cmListFileBacktrace> CompileFeaturesBacktraces;
- std::vector<TargetPropertyEntry*> CompileFeaturesItems;
std::vector<std::string> CompileDefinitionsEntries;
std::vector<cmListFileBacktrace> CompileDefinitionsBacktraces;
- std::vector<TargetPropertyEntry*> CompileDefinitionsItems;
std::vector<TargetPropertyEntry*> SourceEntries;
std::vector<cmValueWithOrigin> LinkImplementationPropertyEntries;
@@ -210,10 +154,6 @@ cmTarget::cmTarget()
this->IsApple = false;
this->IsImportedTarget = false;
this->BuildInterfaceIncludesAppended = false;
- this->DebugIncludesDone = false;
- this->DebugCompileOptionsDone = false;
- this->DebugCompileFeaturesDone = false;
- this->DebugCompileDefinitionsDone = false;
this->DebugSourcesDone = false;
this->LinkImplementationLanguageIsContextDependent = true;
}
@@ -456,29 +396,6 @@ void CreatePropertyGeneratorExpressions(
}
}
-void cmTarget::Compute()
-{
- CreatePropertyGeneratorExpressions(
- this->Internal->IncludeDirectoriesEntries,
- this->Internal->IncludeDirectoriesBacktraces,
- this->Internal->IncludeDirectoriesItems);
-
- CreatePropertyGeneratorExpressions(
- this->Internal->CompileOptionsEntries,
- this->Internal->CompileOptionsBacktraces,
- this->Internal->CompileOptionsItems);
-
- CreatePropertyGeneratorExpressions(
- this->Internal->CompileFeaturesEntries,
- this->Internal->CompileFeaturesBacktraces,
- this->Internal->CompileFeaturesItems);
-
- CreatePropertyGeneratorExpressions(
- this->Internal->CompileDefinitionsEntries,
- this->Internal->CompileDefinitionsBacktraces,
- this->Internal->CompileDefinitionsItems);
-}
-
//----------------------------------------------------------------------------
void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile)
{
@@ -538,8 +455,6 @@ void cmTarget::ClearLinkMaps()
{
this->LinkImplementationLanguageIsContextDependent = true;
this->Internal->LinkImplMap.clear();
- this->Internal->LinkInterfaceMap.clear();
- this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear();
this->Internal->SourceFilesMap.clear();
}
@@ -810,62 +725,6 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files,
}
//----------------------------------------------------------------------------
-bool
-cmTarget::GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const
-{
- std::vector<std::string> configs;
- this->Makefile->GetConfigurations(configs);
- if (configs.empty())
- {
- configs.push_back("");
- }
-
- std::vector<std::string>::const_iterator it = configs.begin();
- const std::string& firstConfig = *it;
- this->GetSourceFiles(files, firstConfig);
-
- for ( ; it != configs.end(); ++it)
- {
- std::vector<cmSourceFile*> configFiles;
- this->GetSourceFiles(configFiles, *it);
- if (configFiles != files)
- {
- std::string firstConfigFiles;
- const char* sep = "";
- for (std::vector<cmSourceFile*>::const_iterator fi = files.begin();
- fi != files.end(); ++fi)
- {
- firstConfigFiles += sep;
- firstConfigFiles += (*fi)->GetFullPath();
- sep = "\n ";
- }
-
- std::string thisConfigFiles;
- sep = "";
- for (std::vector<cmSourceFile*>::const_iterator fi = configFiles.begin();
- fi != configFiles.end(); ++fi)
- {
- thisConfigFiles += sep;
- thisConfigFiles += (*fi)->GetFullPath();
- sep = "\n ";
- }
- std::ostringstream e;
- e << "Target \"" << this->Name << "\" has source files which vary by "
- "configuration. This is not supported by the \""
- << this->Makefile->GetGlobalGenerator()->GetName()
- << "\" generator.\n"
- "Config \"" << firstConfig << "\":\n"
- " " << firstConfigFiles << "\n"
- "Config \"" << *it << "\":\n"
- " " << thisConfigFiles << "\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
- return false;
- }
- }
- return true;
-}
-
-//----------------------------------------------------------------------------
void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
const std::string& config) const
{
@@ -1354,6 +1213,46 @@ cmTarget::AddSystemIncludeDirectories(const std::set<std::string> &incs)
this->SystemIncludeDirectories.insert(incs.begin(), incs.end());
}
+cmStringRange cmTarget::GetIncludeDirectoriesEntries() const
+{
+ return cmMakeRange(this->Internal->IncludeDirectoriesEntries);
+}
+
+cmBacktraceRange cmTarget::GetIncludeDirectoriesBacktraces() const
+{
+ return cmMakeRange(this->Internal->IncludeDirectoriesBacktraces);
+}
+
+cmStringRange cmTarget::GetCompileOptionsEntries() const
+{
+ return cmMakeRange(this->Internal->CompileOptionsEntries);
+}
+
+cmBacktraceRange cmTarget::GetCompileOptionsBacktraces() const
+{
+ return cmMakeRange(this->Internal->CompileOptionsBacktraces);
+}
+
+cmStringRange cmTarget::GetCompileFeaturesEntries() const
+{
+ return cmMakeRange(this->Internal->CompileFeaturesEntries);
+}
+
+cmBacktraceRange cmTarget::GetCompileFeaturesBacktraces() const
+{
+ return cmMakeRange(this->Internal->CompileFeaturesBacktraces);
+}
+
+cmStringRange cmTarget::GetCompileDefinitionsEntries() const
+{
+ return cmMakeRange(this->Internal->CompileDefinitionsEntries);
+}
+
+cmBacktraceRange cmTarget::GetCompileDefinitionsBacktraces() const
+{
+ return cmMakeRange(this->Internal->CompileDefinitionsBacktraces);
+}
+
#if defined(_WIN32) && !defined(__CYGWIN__)
//----------------------------------------------------------------------------
void
@@ -1842,12 +1741,12 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
- this->Internal->SourceFilesMap.clear();
- cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
- cmGeneratorExpression ge(lfbt);
- cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
- this->Internal->SourceEntries.push_back(
- new cmTargetInternals::TargetPropertyEntry(cge));
+ this->Internal->SourceFilesMap.clear();
+ cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
+ cmGeneratorExpression ge(lfbt);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+ this->Internal->SourceEntries.push_back(
+ new cmTargetInternals::TargetPropertyEntry(cge));
}
else
{
@@ -1951,510 +1850,6 @@ void cmTarget::InsertCompileDefinition(std::string const& entry,
}
//----------------------------------------------------------------------------
-static void processIncludeDirectories(cmTarget const* tgt,
- const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
- std::vector<std::string> &includes,
- UNORDERED_SET<std::string> &uniqueIncludes,
- cmGeneratorExpressionDAGChecker *dagChecker,
- const std::string& config, bool debugIncludes,
- const std::string& language)
-{
- cmMakefile *mf = tgt->GetMakefile();
-
- for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
- it = entries.begin(), end = entries.end(); it != end; ++it)
- {
- cmLinkImplItem const& item = (*it)->LinkImplItem;
- std::string const& targetName = item;
- bool const fromImported = item.Target && item.Target->IsImported();
- bool const checkCMP0027 = item.FromGenex;
- std::vector<std::string> entryIncludes;
- cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
- config,
- false,
- tgt,
- dagChecker, language),
- entryIncludes);
-
- std::string usedIncludes;
- for(std::vector<std::string>::iterator
- li = entryIncludes.begin(); li != entryIncludes.end(); ++li)
- {
- if (fromImported
- && !cmSystemTools::FileExists(li->c_str()))
- {
- std::ostringstream e;
- cmake::MessageType messageType = cmake::FATAL_ERROR;
- if (checkCMP0027)
- {
- switch(tgt->GetPolicyStatusCMP0027())
- {
- case cmPolicies::WARN:
- e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0027) << "\n";
- case cmPolicies::OLD:
- messageType = cmake::AUTHOR_WARNING;
- break;
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::NEW:
- break;
- }
- }
- e << "Imported target \"" << targetName << "\" includes "
- "non-existent path\n \"" << *li << "\"\nin its "
- "INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:\n"
- "* The path was deleted, renamed, or moved to another "
- "location.\n"
- "* An install or uninstall procedure did not complete "
- "successfully.\n"
- "* The installation package was faulty and references files it "
- "does not provide.\n";
- tgt->GetMakefile()->IssueMessage(messageType, e.str());
- return;
- }
-
- if (!cmSystemTools::FileIsFullPath(li->c_str()))
- {
- std::ostringstream e;
- bool noMessage = false;
- cmake::MessageType messageType = cmake::FATAL_ERROR;
- if (!targetName.empty())
- {
- e << "Target \"" << targetName << "\" contains relative "
- "path in its INTERFACE_INCLUDE_DIRECTORIES:\n"
- " \"" << *li << "\"";
- }
- else
- {
- switch(tgt->GetPolicyStatusCMP0021())
- {
- case cmPolicies::WARN:
- {
- e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0021) << "\n";
- messageType = cmake::AUTHOR_WARNING;
- }
- break;
- case cmPolicies::OLD:
- noMessage = true;
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::NEW:
- // Issue the fatal message.
- break;
- }
- e << "Found relative path while evaluating include directories of "
- "\"" << tgt->GetName() << "\":\n \"" << *li << "\"\n";
- }
- if (!noMessage)
- {
- tgt->GetMakefile()->IssueMessage(messageType, e.str());
- if (messageType == cmake::FATAL_ERROR)
- {
- return;
- }
- }
- }
-
- if (!cmSystemTools::IsOff(li->c_str()))
- {
- cmSystemTools::ConvertToUnixSlashes(*li);
- }
- std::string inc = *li;
-
- if(uniqueIncludes.insert(inc).second)
- {
- includes.push_back(inc);
- if (debugIncludes)
- {
- usedIncludes += " * " + inc + "\n";
- }
- }
- }
- if (!usedIncludes.empty())
- {
- mf->GetCMakeInstance()->IssueMessage(cmake::LOG,
- std::string("Used includes for target ")
- + tgt->GetName() + ":\n"
- + usedIncludes, (*it)->ge->GetBacktrace());
- }
- }
-}
-
-//----------------------------------------------------------------------------
-std::vector<std::string>
-cmTarget::GetIncludeDirectories(const std::string& config,
- const std::string& language) const
-{
- std::vector<std::string> includes;
- UNORDERED_SET<std::string> uniqueIncludes;
-
- cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
- "INCLUDE_DIRECTORIES", 0, 0);
-
- std::vector<std::string> debugProperties;
- const char *debugProp =
- this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
- if (debugProp)
- {
- cmSystemTools::ExpandListArgument(debugProp, debugProperties);
- }
-
- bool debugIncludes = !this->DebugIncludesDone
- && std::find(debugProperties.begin(),
- debugProperties.end(),
- "INCLUDE_DIRECTORIES")
- != debugProperties.end();
-
- if (this->Makefile->IsConfigured())
- {
- this->DebugIncludesDone = true;
- }
-
- processIncludeDirectories(this,
- this->Internal->IncludeDirectoriesItems,
- includes,
- uniqueIncludes,
- &dagChecker,
- config,
- debugIncludes,
- language);
-
- std::vector<cmTargetInternals::TargetPropertyEntry*>
- linkInterfaceIncludeDirectoriesEntries;
- this->Internal->AddInterfaceEntries(
- this, config, "INTERFACE_INCLUDE_DIRECTORIES",
- linkInterfaceIncludeDirectoriesEntries);
-
- if(this->Makefile->IsOn("APPLE"))
- {
- cmLinkImplementationLibraries const* impl =
- this->GetLinkImplementationLibraries(config);
- for(std::vector<cmLinkImplItem>::const_iterator
- it = impl->Libraries.begin();
- it != impl->Libraries.end(); ++it)
- {
- std::string libDir = cmSystemTools::CollapseFullPath(*it);
-
- static cmsys::RegularExpression
- frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$");
- if(!frameworkCheck.find(libDir))
- {
- continue;
- }
-
- libDir = frameworkCheck.match(1);
-
- cmGeneratorExpression ge;
- cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
- ge.Parse(libDir.c_str());
- linkInterfaceIncludeDirectoriesEntries
- .push_back(new cmTargetInternals::TargetPropertyEntry(cge));
- }
- }
-
- processIncludeDirectories(this,
- linkInterfaceIncludeDirectoriesEntries,
- includes,
- uniqueIncludes,
- &dagChecker,
- config,
- debugIncludes,
- language);
-
- cmDeleteAll(linkInterfaceIncludeDirectoriesEntries);
-
- return includes;
-}
-
-//----------------------------------------------------------------------------
-static void processCompileOptionsInternal(cmTarget const* tgt,
- const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
- std::vector<std::string> &options,
- UNORDERED_SET<std::string> &uniqueOptions,
- cmGeneratorExpressionDAGChecker *dagChecker,
- const std::string& config, bool debugOptions, const char *logName,
- std::string const& language)
-{
- cmMakefile *mf = tgt->GetMakefile();
-
- for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
- it = entries.begin(), end = entries.end(); it != end; ++it)
- {
- std::vector<std::string> entryOptions;
- cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
- config,
- false,
- tgt,
- dagChecker,
- language),
- entryOptions);
- std::string usedOptions;
- for(std::vector<std::string>::iterator
- li = entryOptions.begin(); li != entryOptions.end(); ++li)
- {
- std::string const& opt = *li;
-
- if(uniqueOptions.insert(opt).second)
- {
- options.push_back(opt);
- if (debugOptions)
- {
- usedOptions += " * " + opt + "\n";
- }
- }
- }
- if (!usedOptions.empty())
- {
- mf->GetCMakeInstance()->IssueMessage(cmake::LOG,
- std::string("Used compile ") + logName
- + std::string(" for target ")
- + tgt->GetName() + ":\n"
- + usedOptions, (*it)->ge->GetBacktrace());
- }
- }
-}
-
-//----------------------------------------------------------------------------
-static void processCompileOptions(cmTarget const* tgt,
- const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
- std::vector<std::string> &options,
- UNORDERED_SET<std::string> &uniqueOptions,
- cmGeneratorExpressionDAGChecker *dagChecker,
- const std::string& config, bool debugOptions,
- std::string const& language)
-{
- processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
- dagChecker, config, debugOptions, "options",
- language);
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::GetCompileOptions(std::vector<std::string> &result,
- const std::string& config,
- const std::string& language) const
-{
- UNORDERED_SET<std::string> uniqueOptions;
-
- cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
- "COMPILE_OPTIONS", 0, 0);
-
- std::vector<std::string> debugProperties;
- const char *debugProp =
- this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
- if (debugProp)
- {
- cmSystemTools::ExpandListArgument(debugProp, debugProperties);
- }
-
- bool debugOptions = !this->DebugCompileOptionsDone
- && std::find(debugProperties.begin(),
- debugProperties.end(),
- "COMPILE_OPTIONS")
- != debugProperties.end();
-
- if (this->Makefile->IsConfigured())
- {
- this->DebugCompileOptionsDone = true;
- }
-
- processCompileOptions(this,
- this->Internal->CompileOptionsItems,
- result,
- uniqueOptions,
- &dagChecker,
- config,
- debugOptions,
- language);
-
- std::vector<cmTargetInternals::TargetPropertyEntry*>
- linkInterfaceCompileOptionsEntries;
-
- this->Internal->AddInterfaceEntries(
- this, config, "INTERFACE_COMPILE_OPTIONS",
- linkInterfaceCompileOptionsEntries);
-
- processCompileOptions(this,
- linkInterfaceCompileOptionsEntries,
- result,
- uniqueOptions,
- &dagChecker,
- config,
- debugOptions,
- language);
-
- cmDeleteAll(linkInterfaceCompileOptionsEntries);
-}
-
-//----------------------------------------------------------------------------
-static void processCompileDefinitions(cmTarget const* tgt,
- const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
- std::vector<std::string> &options,
- UNORDERED_SET<std::string> &uniqueOptions,
- cmGeneratorExpressionDAGChecker *dagChecker,
- const std::string& config, bool debugOptions,
- std::string const& language)
-{
- processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
- dagChecker, config, debugOptions,
- "definitions", language);
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
- const std::string& config,
- const std::string& language) const
-{
- UNORDERED_SET<std::string> uniqueOptions;
-
- cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
- "COMPILE_DEFINITIONS", 0, 0);
-
- std::vector<std::string> debugProperties;
- const char *debugProp =
- this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
- if (debugProp)
- {
- cmSystemTools::ExpandListArgument(debugProp, debugProperties);
- }
-
- bool debugDefines = !this->DebugCompileDefinitionsDone
- && std::find(debugProperties.begin(),
- debugProperties.end(),
- "COMPILE_DEFINITIONS")
- != debugProperties.end();
-
- if (this->Makefile->IsConfigured())
- {
- this->DebugCompileDefinitionsDone = true;
- }
-
- processCompileDefinitions(this,
- this->Internal->CompileDefinitionsItems,
- list,
- uniqueOptions,
- &dagChecker,
- config,
- debugDefines,
- language);
-
- std::vector<cmTargetInternals::TargetPropertyEntry*>
- linkInterfaceCompileDefinitionsEntries;
- this->Internal->AddInterfaceEntries(
- this, config, "INTERFACE_COMPILE_DEFINITIONS",
- linkInterfaceCompileDefinitionsEntries);
- if (!config.empty())
- {
- std::string configPropName = "COMPILE_DEFINITIONS_"
- + cmSystemTools::UpperCase(config);
- const char *configProp = this->GetProperty(configPropName);
- if (configProp)
- {
- switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043))
- {
- case cmPolicies::WARN:
- {
- std::ostringstream e;
- e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0043);
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
- e.str());
- }
- case cmPolicies::OLD:
- {
- cmGeneratorExpression ge;
- cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
- ge.Parse(configProp);
- linkInterfaceCompileDefinitionsEntries
- .push_back(new cmTargetInternals::TargetPropertyEntry(cge));
- }
- break;
- case cmPolicies::NEW:
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::REQUIRED_IF_USED:
- break;
- }
- }
- }
-
- processCompileDefinitions(this,
- linkInterfaceCompileDefinitionsEntries,
- list,
- uniqueOptions,
- &dagChecker,
- config,
- debugDefines,
- language);
-
- cmDeleteAll(linkInterfaceCompileDefinitionsEntries);
-}
-
-//----------------------------------------------------------------------------
-static void processCompileFeatures(cmTarget const* tgt,
- const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
- std::vector<std::string> &options,
- UNORDERED_SET<std::string> &uniqueOptions,
- cmGeneratorExpressionDAGChecker *dagChecker,
- const std::string& config, bool debugOptions)
-{
- processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
- dagChecker, config, debugOptions, "features",
- std::string());
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::GetCompileFeatures(std::vector<std::string> &result,
- const std::string& config) const
-{
- UNORDERED_SET<std::string> uniqueFeatures;
-
- cmGeneratorExpressionDAGChecker dagChecker(this->GetName(),
- "COMPILE_FEATURES",
- 0, 0);
-
- std::vector<std::string> debugProperties;
- const char *debugProp =
- this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
- if (debugProp)
- {
- cmSystemTools::ExpandListArgument(debugProp, debugProperties);
- }
-
- bool debugFeatures = !this->DebugCompileFeaturesDone
- && std::find(debugProperties.begin(),
- debugProperties.end(),
- "COMPILE_FEATURES")
- != debugProperties.end();
-
- if (this->Makefile->IsConfigured())
- {
- this->DebugCompileFeaturesDone = true;
- }
-
- processCompileFeatures(this,
- this->Internal->CompileFeaturesItems,
- result,
- uniqueFeatures,
- &dagChecker,
- config,
- debugFeatures);
-
- std::vector<cmTargetInternals::TargetPropertyEntry*>
- linkInterfaceCompileFeaturesEntries;
- this->Internal->AddInterfaceEntries(
- this, config, "INTERFACE_COMPILE_FEATURES",
- linkInterfaceCompileFeaturesEntries);
-
- processCompileFeatures(this,
- linkInterfaceCompileFeaturesEntries,
- result,
- uniqueFeatures,
- &dagChecker,
- config,
- debugFeatures);
-
- cmDeleteAll(linkInterfaceCompileFeaturesEntries);
-}
-
-//----------------------------------------------------------------------------
void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop)
{
// Wipe out maps caching information affected by this property.
@@ -3096,51 +2491,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const
}
//----------------------------------------------------------------------------
-void cmTarget::ExpandLinkItems(std::string const& prop,
- std::string const& value,
- std::string const& config,
- cmTarget const* headTarget,
- bool usage_requirements_only,
- std::vector<cmLinkItem>& items,
- bool& hadHeadSensitiveCondition) const
-{
- cmGeneratorExpression ge;
- cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), prop, 0, 0);
- // The $<LINK_ONLY> expression may be in a link interface to specify private
- // link dependencies that are otherwise excluded from usage requirements.
- if(usage_requirements_only)
- {
- dagChecker.SetTransitivePropertiesOnly();
- }
- std::vector<std::string> libs;
- cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
- cmSystemTools::ExpandListArgument(cge->Evaluate(
- this->Makefile,
- config,
- false,
- headTarget,
- this, &dagChecker), libs);
- this->LookupLinkItems(libs, items);
- hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition();
-}
-
-//----------------------------------------------------------------------------
-void cmTarget::LookupLinkItems(std::vector<std::string> const& names,
- std::vector<cmLinkItem>& items) const
-{
- for(std::vector<std::string>::const_iterator i = names.begin();
- i != names.end(); ++i)
- {
- std::string name = this->CheckCMP0004(*i);
- if(name == this->GetName() || name.empty())
- {
- continue;
- }
- items.push_back(cmLinkItem(name, this->FindTargetToLink(name)));
- }
-}
-
-//----------------------------------------------------------------------------
const char* cmTarget::GetSuffixVariableInternal(bool implib) const
{
switch(this->GetType())
@@ -3404,21 +2754,6 @@ void cmTarget::SetPropertyDefault(const std::string& property,
}
//----------------------------------------------------------------------------
-bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const
-{
- if (this->GetPropertyAsBool("SKIP_BUILD_RPATH"))
- {
- return false;
- }
- if(cmLinkImplementationLibraries const* impl =
- this->GetLinkImplementationLibraries(config))
- {
- return !impl->Libraries.empty();
- }
- return false;
-}
-
-//----------------------------------------------------------------------------
bool cmTarget::HaveInstallTreeRPATH() const
{
const char* install_rpath = this->GetProperty("INSTALL_RPATH");
@@ -3739,50 +3074,6 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const
}
//----------------------------------------------------------------------------
-void cmTarget::GetLanguages(std::set<std::string>& languages,
- const std::string& config) const
-{
- std::vector<cmSourceFile*> sourceFiles;
- this->GetSourceFiles(sourceFiles, config);
- for(std::vector<cmSourceFile*>::const_iterator
- i = sourceFiles.begin(); i != sourceFiles.end(); ++i)
- {
- const std::string& lang = (*i)->GetLanguage();
- if(!lang.empty())
- {
- languages.insert(lang);
- }
- }
-
- std::vector<cmTarget*> objectLibraries;
- std::vector<cmSourceFile const*> externalObjects;
- if (!this->Makefile->IsConfigured())
- {
- this->GetObjectLibrariesCMP0026(objectLibraries);
- }
- else
- {
- cmGeneratorTarget* gt = this->Makefile->GetGlobalGenerator()
- ->GetGeneratorTarget(this);
- gt->GetExternalObjects(externalObjects, config);
- for(std::vector<cmSourceFile const*>::const_iterator
- i = externalObjects.begin(); i != externalObjects.end(); ++i)
- {
- std::string objLib = (*i)->GetObjectLibrary();
- if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib))
- {
- objectLibraries.push_back(tgt);
- }
- }
- }
- for(std::vector<cmTarget*>::const_iterator
- i = objectLibraries.begin(); i != objectLibraries.end(); ++i)
- {
- (*i)->GetLanguages(languages, config);
- }
-}
-
-//----------------------------------------------------------------------------
cmTarget::ImportInfo const*
cmTarget::GetImportInfo(const std::string& config) const
{
@@ -4132,393 +3423,6 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
}
//----------------------------------------------------------------------------
-cmTarget::LinkInterface const* cmTarget::GetLinkInterface(
- const std::string& config,
- cmTarget const* head) const
-{
- // Imported targets have their own link interface.
- if(this->IsImported())
- {
- return this->GetImportLinkInterface(config, head, false);
- }
-
- // Link interfaces are not supported for executables that do not
- // export symbols.
- if(this->GetType() == cmTarget::EXECUTABLE &&
- !this->IsExecutableWithExports())
- {
- return 0;
- }
-
- // Lookup any existing link interface for this configuration.
- std::string CONFIG = cmSystemTools::UpperCase(config);
- cmTargetInternals::HeadToLinkInterfaceMap& hm =
- this->Internal->LinkInterfaceMap[CONFIG];
-
- // If the link interface does not depend on the head target
- // then return the one we computed first.
- if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition)
- {
- return &hm.begin()->second;
- }
-
- cmTargetInternals::OptionalLinkInterface& iface = hm[head];
- if(!iface.LibrariesDone)
- {
- iface.LibrariesDone = true;
- this->Internal->ComputeLinkInterfaceLibraries(
- this, config, iface, head, false);
- }
- if(!iface.AllDone)
- {
- iface.AllDone = true;
- if(iface.Exists)
- {
- this->Internal->ComputeLinkInterface(this, config, iface, head);
- }
- }
-
- return iface.Exists? &iface : 0;
-}
-
-//----------------------------------------------------------------------------
-cmTarget::LinkInterfaceLibraries const*
-cmTarget::GetLinkInterfaceLibraries(const std::string& config,
- cmTarget const* head,
- bool usage_requirements_only) const
-{
- // Imported targets have their own link interface.
- if(this->IsImported())
- {
- return this->GetImportLinkInterface(config, head, usage_requirements_only);
- }
-
- // Link interfaces are not supported for executables that do not
- // export symbols.
- if(this->GetType() == cmTarget::EXECUTABLE &&
- !this->IsExecutableWithExports())
- {
- return 0;
- }
-
- // Lookup any existing link interface for this configuration.
- std::string CONFIG = cmSystemTools::UpperCase(config);
- cmTargetInternals::HeadToLinkInterfaceMap& hm =
- (usage_requirements_only ?
- this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] :
- this->Internal->LinkInterfaceMap[CONFIG]);
-
- // If the link interface does not depend on the head target
- // then return the one we computed first.
- if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition)
- {
- return &hm.begin()->second;
- }
-
- cmTargetInternals::OptionalLinkInterface& iface = hm[head];
- if(!iface.LibrariesDone)
- {
- iface.LibrariesDone = true;
- this->Internal->ComputeLinkInterfaceLibraries(
- this, config, iface, head, usage_requirements_only);
- }
-
- return iface.Exists? &iface : 0;
-}
-
-//----------------------------------------------------------------------------
-cmTarget::LinkInterface const*
-cmTarget::GetImportLinkInterface(const std::string& config,
- cmTarget const* headTarget,
- bool usage_requirements_only) const
-{
- cmTarget::ImportInfo const* info = this->GetImportInfo(config);
- if(!info)
- {
- return 0;
- }
-
- std::string CONFIG = cmSystemTools::UpperCase(config);
- cmTargetInternals::HeadToLinkInterfaceMap& hm =
- (usage_requirements_only ?
- this->Internal->LinkInterfaceUsageRequirementsOnlyMap[CONFIG] :
- this->Internal->LinkInterfaceMap[CONFIG]);
-
- // If the link interface does not depend on the head target
- // then return the one we computed first.
- if(!hm.empty() && !hm.begin()->second.HadHeadSensitiveCondition)
- {
- return &hm.begin()->second;
- }
-
- cmTargetInternals::OptionalLinkInterface& iface = hm[headTarget];
- if(!iface.AllDone)
- {
- iface.AllDone = true;
- iface.Multiplicity = info->Multiplicity;
- cmSystemTools::ExpandListArgument(info->Languages, iface.Languages);
- this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config,
- headTarget, usage_requirements_only,
- iface.Libraries,
- iface.HadHeadSensitiveCondition);
- std::vector<std::string> deps;
- cmSystemTools::ExpandListArgument(info->SharedDeps, deps);
- this->LookupLinkItems(deps, iface.SharedDeps);
- }
-
- return &iface;
-}
-
-//----------------------------------------------------------------------------
-void
-cmTargetInternals::ComputeLinkInterfaceLibraries(
- cmTarget const* thisTarget,
- const std::string& config,
- OptionalLinkInterface& iface,
- cmTarget const* headTarget,
- bool usage_requirements_only)
-{
- // Construct the property name suffix for this configuration.
- std::string suffix = "_";
- if(!config.empty())
- {
- suffix += cmSystemTools::UpperCase(config);
- }
- else
- {
- suffix += "NOCONFIG";
- }
-
- // An explicit list of interface libraries may be set for shared
- // libraries and executables that export symbols.
- const char* explicitLibraries = 0;
- std::string linkIfaceProp;
- if(thisTarget->GetPolicyStatusCMP0022() != cmPolicies::OLD &&
- thisTarget->GetPolicyStatusCMP0022() != cmPolicies::WARN)
- {
- // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES.
- linkIfaceProp = "INTERFACE_LINK_LIBRARIES";
- explicitLibraries = thisTarget->GetProperty(linkIfaceProp);
- }
- else if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY ||
- thisTarget->IsExecutableWithExports())
- {
- // CMP0022 OLD behavior is to use LINK_INTERFACE_LIBRARIES if set on a
- // shared lib or executable.
-
- // Lookup the per-configuration property.
- linkIfaceProp = "LINK_INTERFACE_LIBRARIES";
- linkIfaceProp += suffix;
- explicitLibraries = thisTarget->GetProperty(linkIfaceProp);
-
- // If not set, try the generic property.
- if(!explicitLibraries)
- {
- linkIfaceProp = "LINK_INTERFACE_LIBRARIES";
- explicitLibraries = thisTarget->GetProperty(linkIfaceProp);
- }
- }
-
- if(explicitLibraries &&
- thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN &&
- !this->PolicyWarnedCMP0022)
- {
- // Compare the explicitly set old link interface properties to the
- // preferred new link interface property one and warn if different.
- const char* newExplicitLibraries =
- thisTarget->GetProperty("INTERFACE_LINK_LIBRARIES");
- if (newExplicitLibraries
- && strcmp(newExplicitLibraries, explicitLibraries) != 0)
- {
- std::ostringstream w;
- w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n"
- "Target \"" << thisTarget->GetName() << "\" has an "
- "INTERFACE_LINK_LIBRARIES property which differs from its " <<
- linkIfaceProp << " properties."
- "\n"
- "INTERFACE_LINK_LIBRARIES:\n"
- " " << newExplicitLibraries << "\n" <<
- linkIfaceProp << ":\n"
- " " << (explicitLibraries ? explicitLibraries : "(empty)") << "\n";
- thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
- this->PolicyWarnedCMP0022 = true;
- }
- }
-
- // There is no implicit link interface for executables or modules
- // so if none was explicitly set then there is no link interface.
- if(!explicitLibraries &&
- (thisTarget->GetType() == cmTarget::EXECUTABLE ||
- (thisTarget->GetType() == cmTarget::MODULE_LIBRARY)))
- {
- return;
- }
- iface.Exists = true;
- iface.ExplicitLibraries = explicitLibraries;
-
- if(explicitLibraries)
- {
- // The interface libraries have been explicitly set.
- thisTarget->ExpandLinkItems(linkIfaceProp, explicitLibraries, config,
- headTarget, usage_requirements_only,
- iface.Libraries,
- iface.HadHeadSensitiveCondition);
- }
- else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN
- || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD)
- // If CMP0022 is NEW then the plain tll signature sets the
- // INTERFACE_LINK_LIBRARIES, so if we get here then the project
- // cleared the property explicitly and we should not fall back
- // to the link implementation.
- {
- // The link implementation is the default link interface.
- cmLinkImplementationLibraries const* impl =
- thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget);
- iface.Libraries.insert(iface.Libraries.end(),
- impl->Libraries.begin(), impl->Libraries.end());
- if(thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN &&
- !this->PolicyWarnedCMP0022 && !usage_requirements_only)
- {
- // Compare the link implementation fallback link interface to the
- // preferred new link interface property and warn if different.
- std::vector<cmLinkItem> ifaceLibs;
- static const std::string newProp = "INTERFACE_LINK_LIBRARIES";
- if(const char* newExplicitLibraries = thisTarget->GetProperty(newProp))
- {
- bool hadHeadSensitiveConditionDummy = false;
- thisTarget->ExpandLinkItems(newProp, newExplicitLibraries, config,
- headTarget, usage_requirements_only,
- ifaceLibs, hadHeadSensitiveConditionDummy);
- }
- if (ifaceLibs != iface.Libraries)
- {
- std::string oldLibraries = cmJoin(impl->Libraries, ";");
- std::string newLibraries = cmJoin(ifaceLibs, ";");
- if(oldLibraries.empty())
- { oldLibraries = "(empty)"; }
- if(newLibraries.empty())
- { newLibraries = "(empty)"; }
-
- std::ostringstream w;
- w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n"
- "Target \"" << thisTarget->GetName() << "\" has an "
- "INTERFACE_LINK_LIBRARIES property. "
- "This should be preferred as the source of the link interface "
- "for this library but because CMP0022 is not set CMake is "
- "ignoring the property and using the link implementation "
- "as the link interface instead."
- "\n"
- "INTERFACE_LINK_LIBRARIES:\n"
- " " << newLibraries << "\n"
- "Link implementation:\n"
- " " << oldLibraries << "\n";
- thisTarget->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
- this->PolicyWarnedCMP0022 = true;
- }
- }
- }
-}
-
-//----------------------------------------------------------------------------
-void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget,
- const std::string& config,
- OptionalLinkInterface& iface,
- cmTarget const* headTarget) const
-{
- if(iface.ExplicitLibraries)
- {
- if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY
- || thisTarget->GetType() == cmTarget::STATIC_LIBRARY
- || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY)
- {
- // Shared libraries may have runtime implementation dependencies
- // on other shared libraries that are not in the interface.
- UNORDERED_SET<std::string> emitted;
- for(std::vector<cmLinkItem>::const_iterator
- li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li)
- {
- emitted.insert(*li);
- }
- if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY)
- {
- cmTarget::LinkImplementation const* impl =
- thisTarget->GetLinkImplementation(config);
- for(std::vector<cmLinkImplItem>::const_iterator
- li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li)
- {
- if(emitted.insert(*li).second)
- {
- if(li->Target)
- {
- // This is a runtime dependency on another shared library.
- if(li->Target->GetType() == cmTarget::SHARED_LIBRARY)
- {
- iface.SharedDeps.push_back(*li);
- }
- }
- else
- {
- // TODO: Recognize shared library file names. Perhaps this
- // should be moved to cmComputeLinkInformation, but that creates
- // a chicken-and-egg problem since this list is needed for its
- // construction.
- }
- }
- }
- }
- }
- }
- else if (thisTarget->GetPolicyStatusCMP0022() == cmPolicies::WARN
- || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD)
- {
- // The link implementation is the default link interface.
- cmLinkImplementationLibraries const*
- impl = thisTarget->GetLinkImplementationLibrariesInternal(config,
- headTarget);
- iface.ImplementationIsInterface = true;
- iface.WrongConfigLibraries = impl->WrongConfigLibraries;
- }
-
- if(thisTarget->LinkLanguagePropagatesToDependents())
- {
- // Targets using this archive need its language runtime libraries.
- if(cmTarget::LinkImplementation const* impl =
- thisTarget->GetLinkImplementation(config))
- {
- iface.Languages = impl->Languages;
- }
- }
-
- if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY)
- {
- // Construct the property name suffix for this configuration.
- std::string suffix = "_";
- if(!config.empty())
- {
- suffix += cmSystemTools::UpperCase(config);
- }
- else
- {
- suffix += "NOCONFIG";
- }
-
- // How many repetitions are needed if this library has cyclic
- // dependencies?
- std::string propName = "LINK_INTERFACE_MULTIPLICITY";
- propName += suffix;
- if(const char* config_reps = thisTarget->GetProperty(propName))
- {
- sscanf(config_reps, "%u", &iface.Multiplicity);
- }
- else if(const char* reps =
- thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY"))
- {
- sscanf(reps, "%u", &iface.Multiplicity);
- }
- }
-}
-
-//----------------------------------------------------------------------------
void cmTargetInternals::AddInterfaceEntries(
cmTarget const* thisTarget, std::string const& config,
std::string const& prop, std::vector<TargetPropertyEntry*>& entries)
@@ -4544,32 +3448,12 @@ void cmTargetInternals::AddInterfaceEntries(
}
}
-//----------------------------------------------------------------------------
-cmTarget::LinkImplementation const*
-cmTarget::GetLinkImplementation(const std::string& config) const
+cmOptionalLinkImplementation&
+cmTarget::GetLinkImplMap(std::string const& config) const
{
- // There is no link implementation for imported targets.
- if(this->IsImported())
- {
- return 0;
- }
-
// Populate the link implementation for this configuration.
std::string CONFIG = cmSystemTools::UpperCase(config);
- cmTargetInternals::OptionalLinkImplementation&
- impl = this->Internal->LinkImplMap[CONFIG][this];
- if(!impl.LibrariesDone)
- {
- impl.LibrariesDone = true;
- this->Internal
- ->ComputeLinkImplementationLibraries(this, config, impl, this);
- }
- if(!impl.LanguagesDone)
- {
- impl.LanguagesDone = true;
- this->Internal->ComputeLinkImplementationLanguages(this, config, impl);
- }
- return &impl;
+ return Internal->LinkImplMap[CONFIG][this];
}
//----------------------------------------------------------------------------
@@ -4602,39 +3486,36 @@ cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config,
return &hm.begin()->second;
}
- cmTargetInternals::OptionalLinkImplementation& impl = hm[head];
+ cmOptionalLinkImplementation& impl = hm[head];
if(!impl.LibrariesDone)
{
impl.LibrariesDone = true;
- this->Internal
- ->ComputeLinkImplementationLibraries(this, config, impl, head);
+ this->ComputeLinkImplementationLibraries(config, impl, head);
}
return &impl;
}
//----------------------------------------------------------------------------
-void
-cmTargetInternals::ComputeLinkImplementationLibraries(
- cmTarget const* thisTarget,
+void cmTarget::ComputeLinkImplementationLibraries(
const std::string& config,
- OptionalLinkImplementation& impl,
+ cmOptionalLinkImplementation& impl,
cmTarget const* head) const
{
// Collect libraries directly linked in this configuration.
for (std::vector<cmValueWithOrigin>::const_iterator
- le = this->LinkImplementationPropertyEntries.begin(),
- end = this->LinkImplementationPropertyEntries.end();
+ le = this->Internal->LinkImplementationPropertyEntries.begin(),
+ end = this->Internal->LinkImplementationPropertyEntries.end();
le != end; ++le)
{
std::vector<std::string> llibs;
cmGeneratorExpressionDAGChecker dagChecker(
- thisTarget->GetName(),
+ this->GetName(),
"LINK_LIBRARIES", 0, 0);
cmGeneratorExpression ge(le->Backtrace);
cmsys::auto_ptr<cmCompiledGeneratorExpression> const cge =
ge.Parse(le->Value);
std::string const evaluated =
- cge->Evaluate(thisTarget->Makefile, config, false, head, &dagChecker);
+ cge->Evaluate(this->Makefile, config, false, head, &dagChecker);
cmSystemTools::ExpandListArgument(evaluated, llibs);
if(cge->GetHadHeadSensitiveCondition())
{
@@ -4645,15 +3526,15 @@ cmTargetInternals::ComputeLinkImplementationLibraries(
li != llibs.end(); ++li)
{
// Skip entries that resolve to the target itself or are empty.
- std::string name = thisTarget->CheckCMP0004(*li);
- if(name == thisTarget->GetName() || name.empty())
+ std::string name = this->CheckCMP0004(*li);
+ if(name == this->GetName() || name.empty())
{
- if(name == thisTarget->GetName())
+ if(name == this->GetName())
{
bool noMessage = false;
cmake::MessageType messageType = cmake::FATAL_ERROR;
std::ostringstream e;
- switch(thisTarget->GetPolicyStatusCMP0038())
+ switch(this->GetPolicyStatusCMP0038())
{
case cmPolicies::WARN:
{
@@ -4672,9 +3553,9 @@ cmTargetInternals::ComputeLinkImplementationLibraries(
if(!noMessage)
{
- e << "Target \"" << thisTarget->GetName() << "\" links to itself.";
- thisTarget->Makefile->GetCMakeInstance()->IssueMessage(
- messageType, e.str(), thisTarget->GetBacktrace());
+ e << "Target \"" << this->GetName() << "\" links to itself.";
+ this->Makefile->GetCMakeInstance()->IssueMessage(
+ messageType, e.str(), this->GetBacktrace());
if (messageType == cmake::FATAL_ERROR)
{
return;
@@ -4686,7 +3567,7 @@ cmTargetInternals::ComputeLinkImplementationLibraries(
// The entry is meant for this configuration.
impl.Libraries.push_back(
- cmLinkImplItem(name, thisTarget->FindTargetToLink(name),
+ cmLinkImplItem(name, this->FindTargetToLink(name),
le->Backtrace, evaluated != le->Value));
}
@@ -4694,51 +3575,35 @@ cmTargetInternals::ComputeLinkImplementationLibraries(
for (std::set<std::string>::const_iterator it = seenProps.begin();
it != seenProps.end(); ++it)
{
- if (!thisTarget->GetProperty(*it))
+ if (!this->GetProperty(*it))
{
- thisTarget->LinkImplicitNullProperties.insert(*it);
+ this->LinkImplicitNullProperties.insert(*it);
}
}
- cge->GetMaxLanguageStandard(thisTarget, thisTarget->MaxLanguageStandards);
+ cge->GetMaxLanguageStandard(this, this->MaxLanguageStandards);
}
- cmTarget::LinkLibraryType linkType = thisTarget->ComputeLinkType(config);
+ cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config);
cmTarget::LinkLibraryVectorType const& oldllibs =
- thisTarget->GetOriginalLinkLibraries();
+ this->GetOriginalLinkLibraries();
for(cmTarget::LinkLibraryVectorType::const_iterator li = oldllibs.begin();
li != oldllibs.end(); ++li)
{
if(li->second != cmTarget::GENERAL && li->second != linkType)
{
- std::string name = thisTarget->CheckCMP0004(li->first);
- if(name == thisTarget->GetName() || name.empty())
+ std::string name = this->CheckCMP0004(li->first);
+ if(name == this->GetName() || name.empty())
{
continue;
}
// Support OLD behavior for CMP0003.
impl.WrongConfigLibraries.push_back(
- cmLinkItem(name, thisTarget->FindTargetToLink(name)));
+ cmLinkItem(name, this->FindTargetToLink(name)));
}
}
}
//----------------------------------------------------------------------------
-void
-cmTargetInternals::ComputeLinkImplementationLanguages(
- cmTarget const* thisTarget,
- const std::string& config,
- OptionalLinkImplementation& impl) const
-{
- // This target needs runtime libraries for its source languages.
- std::set<std::string> languages;
- // Get languages used in our source files.
- thisTarget->GetLanguages(languages, config);
- // Copy the set of langauges to the link implementation.
- impl.Languages.insert(impl.Languages.begin(),
- languages.begin(), languages.end());
-}
-
-//----------------------------------------------------------------------------
cmTarget const* cmTarget::FindTargetToLink(std::string const& name) const
{
cmTarget const* tgt = this->Makefile->FindTargetToUse(name);
@@ -4845,10 +3710,6 @@ cmTargetInternalPointer
//----------------------------------------------------------------------------
cmTargetInternalPointer::~cmTargetInternalPointer()
{
- cmDeleteAll(this->Pointer->IncludeDirectoriesItems);
- cmDeleteAll(this->Pointer->CompileOptionsItems);
- cmDeleteAll(this->Pointer->CompileFeaturesItems);
- cmDeleteAll(this->Pointer->CompileDefinitionsItems);
cmDeleteAll(this->Pointer->SourceEntries);
delete this->Pointer;
}
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 2007b40..c86ec24 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -132,15 +132,11 @@ public:
void AddPostBuildCommand(cmCustomCommand const &cmd)
{this->PostBuildCommands.push_back(cmd);}
- void Compute();
-
/**
* Get the list of the source files used by this target
*/
void GetSourceFiles(std::vector<cmSourceFile*> &files,
const std::string& config) const;
- bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const;
-
/**
* Add sources to the target.
*/
@@ -233,54 +229,16 @@ public:
void GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const;
- /** The link interface specifies transitive library dependencies and
- other information needed by targets that link to this target. */
- struct LinkInterfaceLibraries
- {
- // Libraries listed in the interface.
- std::vector<cmLinkItem> Libraries;
- };
- struct LinkInterface: public LinkInterfaceLibraries
- {
- // Languages whose runtime libraries must be linked.
- std::vector<std::string> Languages;
-
- // Shared library dependencies needed for linking on some platforms.
- std::vector<cmLinkItem> SharedDeps;
-
- // Number of repetitions of a strongly connected component of two
- // or more static libraries.
- int Multiplicity;
-
- // Libraries listed for other configurations.
- // Needed only for OLD behavior of CMP0003.
- std::vector<cmLinkItem> WrongConfigLibraries;
-
- bool ImplementationIsInterface;
-
- LinkInterface(): Multiplicity(0), ImplementationIsInterface(false) {}
- };
-
- /** Get the link interface for the given configuration. Returns 0
- if the target cannot be linked. */
- LinkInterface const* GetLinkInterface(const std::string& config,
- cmTarget const* headTarget) const;
- LinkInterfaceLibraries const*
- GetLinkInterfaceLibraries(const std::string& config,
- cmTarget const* headTarget,
- bool usage_requirements_only) const;
-
- struct LinkImplementation: public cmLinkImplementationLibraries
- {
- // Languages whose runtime libraries must be linked.
- std::vector<std::string> Languages;
- };
- LinkImplementation const*
- GetLinkImplementation(const std::string& config) const;
-
cmLinkImplementationLibraries const*
GetLinkImplementationLibraries(const std::string& config) const;
+ void ComputeLinkImplementationLibraries(const std::string& config,
+ cmOptionalLinkImplementation& impl,
+ cmTarget const* head) const;
+
+ cmOptionalLinkImplementation&
+ GetLinkImplMap(std::string const& config) const;
+
cmTarget const* FindTargetToLink(std::string const& name) const;
/** Strip off leading and trailing whitespace from an item named in
@@ -331,7 +289,6 @@ public:
bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out,
const char* newExt = 0) const;
- bool HaveBuildTreeRPATH(const std::string& config) const;
bool HaveInstallTreeRPATH() const;
// Get the properties
@@ -346,18 +303,6 @@ public:
If no macro should be defined null is returned. */
const char* GetExportMacro() const;
- void GetCompileDefinitions(std::vector<std::string> &result,
- const std::string& config,
- const std::string& language) const;
-
- // Compute the set of languages compiled by the target. This is
- // computed every time it is called because the languages can change
- // when source file properties are changed and we do not have enough
- // information to forward these property changes to the targets
- // until we have per-target object file properties.
- void GetLanguages(std::set<std::string>& languages,
- std::string const& config) const;
-
/** Return whether this target is an executable with symbol exports
enabled. */
bool IsExecutableWithExports() const;
@@ -401,9 +346,6 @@ public:
/** @return whether this target have a well defined output file name. */
bool HaveWellDefinedOutputFiles() const;
- std::vector<std::string> GetIncludeDirectories(
- const std::string& config,
- const std::string& language) const;
void InsertInclude(std::string const& entry,
cmListFileBacktrace const& bt,
bool before = false);
@@ -415,12 +357,6 @@ public:
void AppendBuildInterfaceIncludes();
- void GetCompileOptions(std::vector<std::string> &result,
- const std::string& config,
- const std::string& language) const;
- void GetCompileFeatures(std::vector<std::string> &features,
- const std::string& config) const;
-
bool IsNullImpliedByLinkLibraries(const std::string &p) const;
std::string GetDebugGeneratorExpressions(const std::string &value,
@@ -439,6 +375,18 @@ public:
return this->MaxLanguageStandards;
}
+ cmStringRange GetIncludeDirectoriesEntries() const;
+ cmBacktraceRange GetIncludeDirectoriesBacktraces() const;
+
+ cmStringRange GetCompileOptionsEntries() const;
+ cmBacktraceRange GetCompileOptionsBacktraces() const;
+
+ cmStringRange GetCompileFeaturesEntries() const;
+ cmBacktraceRange GetCompileFeaturesBacktraces() const;
+
+ cmStringRange GetCompileDefinitionsEntries() const;
+ cmBacktraceRange GetCompileDefinitionsBacktraces() const;
+
#if defined(_WIN32) && !defined(__CYGWIN__)
const LinkLibraryVectorType &GetLinkLibrariesForVS6() const {
return this->LinkLibrariesForVS6;}
@@ -553,11 +501,7 @@ private:
bool IsApple;
bool IsImportedTarget;
bool BuildInterfaceIncludesAppended;
- mutable bool DebugIncludesDone;
- mutable bool DebugCompileOptionsDone;
- mutable bool DebugCompileDefinitionsDone;
mutable bool DebugSourcesDone;
- mutable bool DebugCompileFeaturesDone;
mutable bool LinkImplementationLanguageIsContextDependent;
#if defined(_WIN32) && !defined(__CYGWIN__)
bool LinkLibrariesForVS6Analyzed;
@@ -591,31 +535,16 @@ private:
void ComputeImportInfo(std::string const& desired_config,
ImportInfo& info) const;
-
- LinkInterface const*
- GetImportLinkInterface(const std::string& config, cmTarget const* head,
- bool usage_requirements_only) const;
-
cmLinkImplementationLibraries const*
GetLinkImplementationLibrariesInternal(const std::string& config,
cmTarget const* head) const;
- void ExpandLinkItems(std::string const& prop, std::string const& value,
- std::string const& config, cmTarget const* headTarget,
- bool usage_requirements_only,
- std::vector<cmLinkItem>& items,
- bool& hadHeadSensitiveCondition) const;
- void LookupLinkItems(std::vector<std::string> const& names,
- std::vector<cmLinkItem>& items) const;
-
std::string ProcessSourceItemCMP0049(const std::string& s);
void ClearLinkMaps();
void MaybeInvalidatePropertyCache(const std::string& prop);
- void ProcessSourceExpression(std::string const& expr);
-
// Internal representation details.
friend class cmTargetInternals;
friend class cmGeneratorTarget;
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 823b550..4c380f7 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -965,7 +965,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
std::vector<cmSourceGroup> sourceGroups =
this->Makefile->GetSourceGroups();
std::vector<cmSourceFile*> classes;
- if (!this->Target->GetConfigCommonSourceFiles(classes))
+ if (!this->GeneratorTarget->GetConfigCommonSourceFiles(classes))
{
return;
}
@@ -1934,7 +1934,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
clOptions.Parse(flags.c_str());
clOptions.Parse(defineFlags.c_str());
std::vector<std::string> targetDefines;
- this->Target->GetCompileDefinitions(targetDefines,
+ this->GeneratorTarget->GetCompileDefinitions(targetDefines,
configName.c_str(), "CXX");
clOptions.AddDefines(targetDefines);
if(this->MSTools)
@@ -2893,7 +2893,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
(*this->BuildFileStream) << cmVS10EscapeXML(artifactDir) <<
"\\</AppxPackageArtifactsDir>\n";
this->WriteString("<ProjectPriFullPath>"
- "$(TargetDir)resources.pri</ProjectPriFullPath>", 2);
+ "$(TargetDir)resources.pri</ProjectPriFullPath>\n", 2);
// If we are missing files and we don't have a certificate and
// aren't targeting WP8.0, add a default certificate
@@ -2911,6 +2911,13 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
this->WriteString("<", 2);
(*this->BuildFileStream) << "PackageCertificateKeyFile>"
<< pfxFile << "</PackageCertificateKeyFile>\n";
+ std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile);
+ if (!thumb.empty())
+ {
+ this->WriteString("<PackageCertificateThumbprint>", 2);
+ (*this->BuildFileStream) << thumb
+ << "</PackageCertificateThumbprint>\n";
+ }
this->WriteString("</PropertyGroup>\n", 1);
}
else if(!pfxFile.empty())
@@ -2919,6 +2926,13 @@ void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
this->WriteString("<", 2);
(*this->BuildFileStream) << "PackageCertificateKeyFile>"
<< pfxFile << "</PackageCertificateKeyFile>\n";
+ std::string thumb = cmSystemTools::ComputeCertificateThumbprint(pfxFile);
+ if (!thumb.empty())
+ {
+ this->WriteString("<PackageCertificateThumbprint>", 2);
+ (*this->BuildFileStream) << thumb
+ << "</PackageCertificateThumbprint>\n";
+ }
this->WriteString("</PropertyGroup>\n", 1);
}
}
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 1f5c4d4..f069481 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -429,7 +429,9 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
std::string homeOutputDir = this->GetHomeOutputDirectory();
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
- cmsys::auto_ptr<cmLocalGenerator> lg(gg->MakeLocalGenerator());
+ cmState::Snapshot snapshot = this->GetCurrentSnapshot();
+ cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot));
+ cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator(mf.get()));
lg->GetMakefile()->SetCurrentBinaryDirectory
(cmSystemTools::GetCurrentWorkingDirectory());
lg->GetMakefile()->SetCurrentSourceDirectory
@@ -469,9 +471,10 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
cmGlobalGenerator *gg = new cmGlobalGenerator(this);
this->SetGlobalGenerator(gg);
+ cmState::Snapshot snapshot = this->GetCurrentSnapshot();
// read in the list file to fill the cache
- cmsys::auto_ptr<cmLocalGenerator> lg(gg->MakeLocalGenerator());
- cmMakefile* mf = lg->GetMakefile();
+ cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(gg, snapshot));
+ cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator(mf.get()));
mf->SetCurrentBinaryDirectory
(cmSystemTools::GetCurrentWorkingDirectory());
mf->SetCurrentSourceDirectory
@@ -2059,8 +2062,8 @@ int cmake::CheckBuildSystem()
cm.SetHomeDirectory("");
cm.SetHomeOutputDirectory("");
cmGlobalGenerator gg(&cm);
- cmsys::auto_ptr<cmLocalGenerator> lg(gg.MakeLocalGenerator());
- cmMakefile* mf = lg->GetMakefile();
+ cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(&gg, cm.GetCurrentSnapshot()));
+ cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator(mf.get()));
if(!mf->ReadListFile(this->CheckBuildSystemArgument.c_str()) ||
cmSystemTools::GetErrorOccuredFlag())
{
@@ -2089,8 +2092,11 @@ int cmake::CheckBuildSystem()
ggd(this->CreateGlobalGenerator(genName));
if(ggd.get())
{
- cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->MakeLocalGenerator());
- lgd->ClearDependencies(mf, verbose);
+ cmsys::auto_ptr<cmMakefile> mfd(new cmMakefile(ggd.get(),
+ cm.GetCurrentSnapshot()));
+ cmsys::auto_ptr<cmLocalGenerator> lgd(
+ ggd->CreateLocalGenerator(mfd.get()));
+ lgd->ClearDependencies(mfd.get(), verbose);
}
}
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 7bee0ea..aa70aa0 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -768,7 +768,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen))
{
cm.SetGlobalGenerator(ggd);
- cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->MakeLocalGenerator());
+ cmState::Snapshot snapshot = cm.GetCurrentSnapshot();
+ cmsys::auto_ptr<cmMakefile> mf(new cmMakefile(ggd, snapshot));
+ cmsys::auto_ptr<cmLocalGenerator> lgd(
+ ggd->CreateLocalGenerator(mf.get()));
lgd->GetMakefile()->SetCurrentSourceDirectory(startDir);
lgd->GetMakefile()->SetCurrentBinaryDirectory(startOutDir);
diff --git a/Source/kwsys/CMakeEmptyInputFile.in b/Source/kwsys/CMakeEmptyInputFile.in
deleted file mode 100644
index 40b7ea2..0000000
--- a/Source/kwsys/CMakeEmptyInputFile.in
+++ /dev/null
@@ -1 +0,0 @@
-@CMAKE_EMPTY_INPUT_FILE_CONTENT@
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 017d619..c1229ff 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -91,6 +91,7 @@ ENDIF()
IF(POLICY CMP0056)
CMAKE_POLICY(SET CMP0056 NEW)
ENDIF()
+SET(CMAKE_LEGACY_CYGWIN_WIN32 0)
#-----------------------------------------------------------------------------
# If a namespace is not specified, use "kwsys" and enable testing.
@@ -311,6 +312,15 @@ IF(NOT CMAKE_COMPILER_IS_GNUCXX)
ENDIF()
ENDIF()
ENDIF()
+IF(KWSYS_STANDALONE)
+ IF(CMAKE_CXX_COMPILER_ID STREQUAL SunPro)
+ IF(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")
+ ELSE()
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stlport4")
+ ENDIF()
+ ENDIF()
+ENDIF()
#-----------------------------------------------------------------------------
# Configure Large File Support.
@@ -1071,7 +1081,7 @@ IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
# Apply user-defined target properties to the library.
IF(KWSYS_PROPERTIES_C)
- SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES
+ SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE}_c PROPERTIES
${KWSYS_PROPERTIES_C}
)
ENDIF()
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 0714344..f12a06c 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -68,6 +68,10 @@
#include <sys/stat.h>
#include <time.h>
+#ifdef _MSC_VER
+# define umask _umask // Note this is still umask on Borland
+#endif
+
// support for realpath call
#ifndef _WIN32
#include <sys/time.h>
@@ -1233,13 +1237,11 @@ bool SystemTools::FileExists(const kwsys_stl::string& filename)
//----------------------------------------------------------------------------
bool SystemTools::FileExists(const char* filename, bool isFile)
{
- if(SystemTools::FileExists(filename))
+ if(!filename)
{
- // If isFile is set return not FileIsDirectory,
- // so this will only be true if it is a file
- return !isFile || !SystemTools::FileIsDirectory(filename);
+ return false;
}
- return false;
+ return SystemTools::FileExists(kwsys_stl::string(filename), isFile);
}
//----------------------------------------------------------------------------
@@ -1255,6 +1257,43 @@ bool SystemTools::FileExists(const kwsys_stl::string& filename, bool isFile)
}
//----------------------------------------------------------------------------
+bool SystemTools::TestFileAccess(const char* filename,
+ TestFilePermissions permissions)
+{
+ if(!filename)
+ {
+ return false;
+ }
+ return SystemTools::TestFileAccess(kwsys_stl::string(filename),
+ permissions);
+}
+
+//----------------------------------------------------------------------------
+bool SystemTools::TestFileAccess(const kwsys_stl::string& filename,
+ TestFilePermissions permissions)
+{
+ if(filename.empty())
+ {
+ return false;
+ }
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ // If execute set, change to read permission (all files on Windows
+ // are executable if they are readable). The CRT will always fail
+ // if you pass an execute bit.
+ if(permissions & TEST_FILE_EXECUTE)
+ {
+ permissions &= ~TEST_FILE_EXECUTE;
+ permissions |= TEST_FILE_READ;
+ }
+ return _waccess(
+ SystemTools::ConvertToWindowsExtendedPath(filename).c_str(),
+ permissions) == 0;
+#else
+ return access(filename.c_str(), permissions) == 0;
+#endif
+}
+
+//----------------------------------------------------------------------------
#ifdef __CYGWIN__
bool SystemTools::PathCygwinToWin32(const char *path, char *win32_path)
{
@@ -4745,21 +4784,35 @@ bool SystemTools::GetPermissions(const kwsys_stl::string& file, mode_t& mode)
return true;
}
-bool SystemTools::SetPermissions(const char* file, mode_t mode)
+bool SystemTools::SetPermissions(const char* file,
+ mode_t mode,
+ bool honor_umask)
{
if ( !file )
{
return false;
}
- return SystemTools::SetPermissions(kwsys_stl::string(file), mode);
+ return SystemTools::SetPermissions(
+ kwsys_stl::string(file), mode, honor_umask);
}
-bool SystemTools::SetPermissions(const kwsys_stl::string& file, mode_t mode)
+bool SystemTools::SetPermissions(const kwsys_stl::string& file,
+ mode_t mode,
+ bool honor_umask)
{
- if ( !SystemTools::FileExists(file) )
+ // TEMPORARY / TODO: After FileExists calls lstat() instead of
+ // access(), change this call to FileExists instead of
+ // TestFileAccess so that we don't follow symlinks.
+ if ( !SystemTools::TestFileAccess(file, TEST_FILE_OK) )
{
return false;
}
+ if (honor_umask)
+ {
+ mode_t currentMask = umask(0);
+ umask(currentMask);
+ mode &= ~currentMask;
+ }
#ifdef _WIN32
if ( _wchmod(SystemTools::ConvertToWindowsExtendedPath(file).c_str(),
mode) < 0 )
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index 7899141..164c5e0 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -21,6 +21,9 @@
#include <@KWSYS_NAMESPACE@/String.hxx>
#include <sys/types.h>
+#if !defined(_WIN32) || defined(__CYGWIN__)
+# include <unistd.h> // For access permissions for use with access()
+#endif
// Required for va_list
#include <stdarg.h>
@@ -68,10 +71,28 @@ public:
};
// This instance will show up in any translation unit that uses
-// SystemTools. It will make sure SystemTools is initialized
+// SystemTools. It will make sure SystemTools is initialized
// before it is used and is the last static object destroyed.
static SystemToolsManager SystemToolsManagerInstance;
+// Flags for use with TestFileAccess. Use a typedef in case any operating
+// system in the future needs a special type. These are flags that may be
+// combined using the | operator.
+typedef int TestFilePermissions;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ // On Windows (VC and Borland), no system header defines these constants...
+ static const TestFilePermissions TEST_FILE_OK = 0;
+ static const TestFilePermissions TEST_FILE_READ = 4;
+ static const TestFilePermissions TEST_FILE_WRITE = 2;
+ static const TestFilePermissions TEST_FILE_EXECUTE = 1;
+#else
+ // Standard POSIX constants
+ static const TestFilePermissions TEST_FILE_OK = F_OK;
+ static const TestFilePermissions TEST_FILE_READ = R_OK;
+ static const TestFilePermissions TEST_FILE_WRITE = W_OK;
+ static const TestFilePermissions TEST_FILE_EXECUTE = X_OK;
+#endif
+
/** \class SystemTools
* \brief A collection of useful platform-independent system functions.
*/
@@ -113,34 +134,34 @@ public:
* all other are lowercased).
*/
static kwsys_stl::string Capitalized(const kwsys_stl::string&);
-
+
/**
* Return a 'capitalized words' string (i.e the first letter of each word
* is uppercased all other are left untouched though).
*/
static kwsys_stl::string CapitalizedWords(const kwsys_stl::string&);
-
+
/**
* Return a 'uncapitalized words' string (i.e the first letter of each word
* is lowercased all other are left untouched though).
*/
static kwsys_stl::string UnCapitalizedWords(const kwsys_stl::string&);
-
+
/**
* Return a lower case string
*/
static kwsys_stl::string LowerCase(const kwsys_stl::string&);
-
+
/**
* Return a lower case string
*/
static kwsys_stl::string UpperCase(const kwsys_stl::string&);
-
+
/**
* Count char in string
*/
static size_t CountChar(const char* str, char c);
-
+
/**
* Remove some characters from a string.
* Return a pointer to the new resulting string (allocated with 'new')
@@ -152,13 +173,13 @@ public:
* Return a pointer to the new resulting string (allocated with 'new')
*/
static char* RemoveCharsButUpperHex(const char* str);
-
+
/**
* Replace some characters by another character in a string (in-place)
* Return a pointer to string
*/
static char* ReplaceChars(char* str, const char *toreplace,char replacement);
-
+
/**
* Returns true if str1 starts (respectively ends) with str2
*/
@@ -171,25 +192,25 @@ public:
* Returns a pointer to the last occurence of str2 in str1
*/
static const char* FindLastString(const char* str1, const char* str2);
-
+
/**
* Make a duplicate of the string similar to the strdup C function
* but use new to create the 'new' string, so one can use
* 'delete' to remove it. Returns 0 if the input is empty.
*/
static char* DuplicateString(const char* str);
-
+
/**
* Return the string cropped to a given length by removing chars in the
* center of the string and replacing them with an ellipsis (...)
*/
static kwsys_stl::string CropString(const kwsys_stl::string&,size_t max_len);
-
+
/** split a path by separator into an array of strings, default is /.
If isPath is true then the string is treated like a path and if
s starts with a / then the first element of the returned array will
be /, so /foo/bar will be [/, foo, bar]
- */
+ */
static kwsys_stl::vector<String> SplitString(const kwsys_stl::string& s, char separator = '/',
bool isPath = false);
/**
@@ -197,7 +218,7 @@ public:
*/
static int Strucmp(const char *s1, const char *s2);
- /**
+ /**
* Convert a string in __DATE__ or __TIMESTAMP__ format into a time_t.
* Return false on error, true on success
*/
@@ -210,11 +231,11 @@ public:
*/
static bool Split(const kwsys_stl::string& s, kwsys_stl::vector<kwsys_stl::string>& l);
static bool Split(const kwsys_stl::string& s, kwsys_stl::vector<kwsys_stl::string>& l, char separator);
-
- /**
+
+ /**
* Return string with space added between capitalized words
* (i.e. EatMyShorts becomes Eat My Shorts )
- * (note that IEatShorts becomes IEat Shorts)
+ * (note that IEatShorts becomes IEat Shorts)
*/
static kwsys_stl::string AddSpaceBetweenCapitalizedWords(
const kwsys_stl::string&);
@@ -290,9 +311,11 @@ public:
/**
* Return true if a file exists in the current directory.
- * If isFile = true, then make sure the file is a file and
+ * If isFile = true, then make sure the file is a file and
* not a directory. If isFile = false, then return true
- * if it is a file or a directory.
+ * if it is a file or a directory. Note that the file will
+ * also be checked for read access. (Currently, this check
+ * for read access is only done on POSIX systems.)
*/
static bool FileExists(const char* filename, bool isFile);
static bool FileExists(const kwsys_stl::string& filename, bool isFile);
@@ -300,6 +323,21 @@ public:
static bool FileExists(const kwsys_stl::string& filename);
/**
+ * Test if a file exists and can be accessed with the requested
+ * permissions. Symbolic links are followed. Returns true if
+ * the access test was successful.
+ *
+ * On POSIX systems (including Cygwin), this maps to the access
+ * function. On Windows systems, all existing files are
+ * considered readable, and writable files are considered to
+ * have the read-only file attribute cleared.
+ */
+ static bool TestFileAccess(const char* filename,
+ TestFilePermissions permissions);
+ static bool TestFileAccess(const kwsys_stl::string& filename,
+ TestFilePermissions permissions);
+
+ /**
* Converts Cygwin path to Win32 path. Uses dictionary container for
* caching and calls to cygwin_conv_to_win32_path from Cygwin dll
* for actual translation. Returns true on success, else false.
@@ -317,7 +355,7 @@ public:
Change the modification time or create a file
*/
static bool Touch(const kwsys_stl::string& filename, bool create);
-
+
/**
* Compare file modification times.
* Return true for successful comparison and false for error.
@@ -360,7 +398,7 @@ public:
* to the running executable. If argv0 is not a full path,
* then this will try to find the full path. If the path is not
* found false is returned, if found true is returned. An error
- * message of the attempted paths is stored in errorMsg.
+ * message of the attempted paths is stored in errorMsg.
* exeName is the name of the executable.
* buildDir is a possibly null path to the build directory.
* installPrefix is a possibly null pointer to the install directory.
@@ -384,7 +422,7 @@ public:
static kwsys_stl::string CollapseFullPath(const kwsys_stl::string& in_relative,
const kwsys_stl::string& in_base);
- /**
+ /**
* Get the real path for a given path, removing all symlinks. In
* the event of an error (non-existent path, permissions issue,
* etc.) the original path is returned if errorMessage pointer is
@@ -469,31 +507,31 @@ public:
*/
static kwsys_stl::string GetFilenameLastExtension(
const kwsys_stl::string& filename);
-
+
/**
* Return file name without extension of a full filename
*/
static kwsys_stl::string GetFilenameWithoutExtension(
const kwsys_stl::string&);
-
+
/**
* Return file name without its last (shortest) extension
*/
static kwsys_stl::string GetFilenameWithoutLastExtension(
const kwsys_stl::string&);
-
+
/**
* Return whether the path represents a full path (not relative)
*/
static bool FileIsFullPath(const kwsys_stl::string&);
static bool FileIsFullPath(const char*);
-
+
/**
* For windows return the short path for the given path,
* Unix just a pass through
*/
static bool GetShortPath(const kwsys_stl::string& path, kwsys_stl::string& result);
-
+
/**
* Read line from file. Make sure to get everything. Due to a buggy stream
* library on the HP and another on Mac OS X, we need this very carefully
@@ -501,7 +539,7 @@ public:
* end-of-file was reached. If the has_newline argument is specified, it will
* be true when the line read had a newline character.
*/
- static bool GetLineFromStream(kwsys_ios::istream& istr,
+ static bool GetLineFromStream(kwsys_ios::istream& istr,
kwsys_stl::string& line,
bool* has_newline=0,
long sizeLimit=-1);
@@ -529,7 +567,7 @@ public:
/**
* Make a new directory if it is not there. This function
* can make a full path even if none of the directories existed
- * prior to calling this function.
+ * prior to calling this function.
*/
static bool MakeDirectory(const char* path);
static bool MakeDirectory(const kwsys_stl::string& path);
@@ -572,12 +610,12 @@ public:
*/
static bool CopyADirectory(const kwsys_stl::string& source, const kwsys_stl::string& destination,
bool always = true);
-
+
/**
* Remove a file
*/
static bool RemoveFile(const kwsys_stl::string& source);
-
+
/**
* Remove a directory
*/
@@ -593,7 +631,7 @@ public:
*/
static kwsys_stl::string FindFile(
const kwsys_stl::string& name,
- const kwsys_stl::vector<kwsys_stl::string>& path =
+ const kwsys_stl::vector<kwsys_stl::string>& path =
kwsys_stl::vector<kwsys_stl::string>(),
bool no_system_path = false);
@@ -602,7 +640,7 @@ public:
*/
static kwsys_stl::string FindDirectory(
const kwsys_stl::string& name,
- const kwsys_stl::vector<kwsys_stl::string>& path =
+ const kwsys_stl::vector<kwsys_stl::string>& path =
kwsys_stl::vector<kwsys_stl::string>(),
bool no_system_path = false);
@@ -631,17 +669,17 @@ public:
static kwsys_stl::string FindLibrary(
const kwsys_stl::string& name,
const kwsys_stl::vector<kwsys_stl::string>& path);
-
+
/**
* Return true if the file is a directory
*/
static bool FileIsDirectory(const kwsys_stl::string& name);
-
+
/**
* Return true if the file is a symlink
*/
static bool FileIsSymlink(const kwsys_stl::string& name);
-
+
/**
* Return true if the file has a given signature (first set of bytes)
*/
@@ -657,15 +695,15 @@ public:
* The algorithm is simplistic, and should probably check for usual file
* extensions, 'magic' signature, unicode, etc.
*/
- enum FileTypeEnum
- {
+ enum FileTypeEnum
+ {
FileTypeUnknown,
FileTypeBinary,
FileTypeText
};
static SystemTools::FileTypeEnum DetectFileType(
- const char* filename,
- unsigned long length = 256,
+ const char* filename,
+ unsigned long length = 256,
double percent_bin = 0.05);
/**
@@ -690,18 +728,18 @@ public:
* 'filename_found' is assigned the fully qualified name/path of the file
* if it is found (not touched otherwise).
* If 'try_filename_dirs' is true, try to find the file using the
- * components of its path, i.e. if we are looking for c:/foo/bar/bill.txt,
+ * components of its path, i.e. if we are looking for c:/foo/bar/bill.txt,
* first look for bill.txt in 'dir', then in 'dir'/bar, then in 'dir'/foo/bar
* etc.
* Return true if the file was found, false otherwise.
*/
- static bool LocateFileInDir(const char *filename,
- const char *dir,
+ static bool LocateFileInDir(const char *filename,
+ const char *dir,
kwsys_stl::string& filename_found,
int try_filename_dirs = 0);
- /** compute the relative path from local to remote. local must
- be a directory. remote can be a file or a directory.
+ /** compute the relative path from local to remote. local must
+ be a directory. remote can be a file or a directory.
Both remote and local must be full paths. Basically, if
you are in directory local and you want to access the file in remote
what is the relative path to do that. For example:
@@ -720,17 +758,27 @@ public:
*/
static long int CreationTime(const kwsys_stl::string& filename);
+ /**
+ * Visual C++ does not define mode_t (note that Borland does, however).
+ */
#if defined( _MSC_VER )
typedef unsigned short mode_t;
#endif
/**
- * Get and set permissions of the file.
+ * Get and set permissions of the file. If honor_umask is set, the umask
+ * is queried and applied to the given permissions. Returns false if
+ * failure.
+ *
+ * WARNING: A non-thread-safe method is currently used to get the umask
+ * if a honor_umask parameter is set to true.
*/
static bool GetPermissions(const char* file, mode_t& mode);
static bool GetPermissions(const kwsys_stl::string& file, mode_t& mode);
- static bool SetPermissions(const char* file, mode_t mode);
- static bool SetPermissions(const kwsys_stl::string& file, mode_t mode);
+ static bool SetPermissions(
+ const char* file, mode_t mode, bool honor_umask = false);
+ static bool SetPermissions(
+ const kwsys_stl::string& file, mode_t mode, bool honor_umask = false);
/** -----------------------------------------------------------------
* Time Manipulation Routines
@@ -891,11 +939,11 @@ public:
* Return true if the string matches the format; false otherwise.
*/
static bool ParseURL( const kwsys_stl::string& URL,
- kwsys_stl::string& protocol,
- kwsys_stl::string& username,
- kwsys_stl::string& password,
- kwsys_stl::string& hostname,
- kwsys_stl::string& dataport,
+ kwsys_stl::string& protocol,
+ kwsys_stl::string& username,
+ kwsys_stl::string& password,
+ kwsys_stl::string& hostname,
+ kwsys_stl::string& dataport,
kwsys_stl::string& datapath );
private:
@@ -936,7 +984,7 @@ private:
*/
static kwsys_stl::string FindName(
const kwsys_stl::string& name,
- const kwsys_stl::vector<kwsys_stl::string>& path =
+ const kwsys_stl::vector<kwsys_stl::string>& path =
kwsys_stl::vector<kwsys_stl::string>(),
bool no_system_path = false);
diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c
index d0e20c1..8fd3382 100644
--- a/Source/kwsys/testProcess.c
+++ b/Source/kwsys/testProcess.c
@@ -21,6 +21,7 @@
#endif
#include <assert.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -74,6 +75,16 @@ int runChild(const char* cmd[], int state, int exception, int value,
static int test1(int argc, const char* argv[])
{
+ /* This is a very basic functional test of kwsysProcess. It is repeated
+ numerous times to verify that there are no resource leaks in kwsysProcess
+ that eventually lead to an error. Many versions of OS X will fail after
+ 256 leaked file handles, so 257 iterations seems to be a good test. On
+ the other hand, too many iterations will cause the test to time out -
+ especially if the test is instrumented with e.g. valgrind.
+
+ If you have problems with this test timing out on your system, or want to
+ run more than 257 iterations, you can change the number of iterations by
+ setting the KWSYS_TEST_PROCESS_1_COUNT environment variable. */
(void)argc; (void)argv;
fprintf(stdout, "Output on stdout from test returning 0.\n");
fprintf(stderr, "Output on stderr from test returning 0.\n");
@@ -557,6 +568,10 @@ int runChild(const char* cmd[], int state, int exception, int value,
result = runChild2(kp, cmd, state, exception, value, share,
output, delay, timeout, poll, disown, createNewGroup,
interruptDelay);
+ if(result)
+ {
+ break;
+ }
}
kwsysProcess_Delete(kp);
return result;
@@ -660,13 +675,24 @@ int main(int argc, const char* argv[])
int delays[10] = {0, 0, 0, 0, 0, 1, 0, 0, 0, 0};
double timeouts[10] = {10, 10, 10, 30, 30, 10, -1, 10, 6, 4};
int polls[10] = {0, 0, 0, 0, 0, 0, 1, 0, 0, 0};
- int repeat[10] = {2, 1, 1, 1, 1, 1, 1, 1, 1, 1};
+ int repeat[10] = {257, 1, 1, 1, 1, 1, 1, 1, 1, 1};
int createNewGroups[10] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1};
unsigned int interruptDelays[10] = {0, 0, 0, 0, 0, 0, 0, 0, 3, 2};
int r;
const char* cmd[4];
#ifdef _WIN32
char* argv0 = 0;
+#endif
+ char* test1IterationsStr = getenv("KWSYS_TEST_PROCESS_1_COUNT");
+ if(test1IterationsStr)
+ {
+ long int test1Iterations = strtol(test1IterationsStr, 0, 10);
+ if(test1Iterations > 10 && test1Iterations != LONG_MAX)
+ {
+ repeat[0] = (int)test1Iterations;
+ }
+ }
+#ifdef _WIN32
if(n == 0 && (argv0 = strdup(argv[0])))
{
/* Try converting to forward slashes to see if it works. */
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index 7b5c025..bc9ca5e 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -30,6 +30,17 @@
#include <testSystemTools.h>
#include <string.h> /* strcmp */
+#if defined(_WIN32) && !defined(__CYGWIN__)
+# include <io.h> /* _umask (MSVC) / umask (Borland) */
+# ifdef _MSC_VER
+# define umask _umask // Note this is still umask on Borland
+# endif
+#endif
+#include <sys/stat.h> /* umask (POSIX), _S_I* constants (Windows) */
+// Visual C++ does not define mode_t (note that Borland does, however).
+#if defined( _MSC_VER )
+typedef unsigned short mode_t;
+#endif
//----------------------------------------------------------------------------
static const char* toUnixPaths[][2] =
@@ -170,6 +181,135 @@ static bool CheckFileOperations()
res = false;
}
+ // Reset umask
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ // NOTE: Windows doesn't support toggling _S_IREAD.
+ mode_t fullMask = _S_IWRITE;
+#else
+ // On a normal POSIX platform, we can toggle all permissions.
+ mode_t fullMask = S_IRWXU | S_IRWXG | S_IRWXO;
+#endif
+ mode_t orig_umask = umask(fullMask);
+
+ // Test file permissions without umask
+ mode_t origPerm, thisPerm;
+ if (!kwsys::SystemTools::GetPermissions(testNewFile, origPerm))
+ {
+ kwsys_ios::cerr
+ << "Problem with GetPermissions (1) for: "
+ << testNewFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (!kwsys::SystemTools::SetPermissions(testNewFile, 0))
+ {
+ kwsys_ios::cerr
+ << "Problem with SetPermissions (1) for: "
+ << testNewFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (!kwsys::SystemTools::GetPermissions(testNewFile, thisPerm))
+ {
+ kwsys_ios::cerr
+ << "Problem with GetPermissions (2) for: "
+ << testNewFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ if ((thisPerm & fullMask) != 0)
+ {
+ kwsys_ios::cerr
+ << "SetPermissions failed to set permissions (1) for: "
+ << testNewFile << ": actual = " << thisPerm << "; expected = "
+ << 0 << kwsys_ios::endl;
+ res = false;
+ }
+
+ // While we're at it, check proper TestFileAccess functionality.
+ if (kwsys::SystemTools::TestFileAccess(testNewFile,
+ kwsys::TEST_FILE_WRITE))
+ {
+ kwsys_ios::cerr
+ << "TestFileAccess incorrectly indicated that this is a writable file:"
+ << testNewFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (!kwsys::SystemTools::TestFileAccess(testNewFile,
+ kwsys::TEST_FILE_OK))
+ {
+ kwsys_ios::cerr
+ << "TestFileAccess incorrectly indicated that this file does not exist:"
+ << testNewFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ // Test restoring/setting full permissions.
+ if (!kwsys::SystemTools::SetPermissions(testNewFile, fullMask))
+ {
+ kwsys_ios::cerr
+ << "Problem with SetPermissions (2) for: "
+ << testNewFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (!kwsys::SystemTools::GetPermissions(testNewFile, thisPerm))
+ {
+ kwsys_ios::cerr
+ << "Problem with GetPermissions (3) for: "
+ << testNewFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ if ((thisPerm & fullMask) != fullMask)
+ {
+ kwsys_ios::cerr
+ << "SetPermissions failed to set permissions (2) for: "
+ << testNewFile << ": actual = " << thisPerm << "; expected = "
+ << fullMask << kwsys_ios::endl;
+ res = false;
+ }
+
+ // Test setting file permissions while honoring umask
+ if (!kwsys::SystemTools::SetPermissions(testNewFile, fullMask, true))
+ {
+ kwsys_ios::cerr
+ << "Problem with SetPermissions (3) for: "
+ << testNewFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ if (!kwsys::SystemTools::GetPermissions(testNewFile, thisPerm))
+ {
+ kwsys_ios::cerr
+ << "Problem with GetPermissions (4) for: "
+ << testNewFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ if ((thisPerm & fullMask) != 0)
+ {
+ kwsys_ios::cerr
+ << "SetPermissions failed to honor umask for: "
+ << testNewFile << ": actual = " << thisPerm << "; expected = "
+ << 0 << kwsys_ios::endl;
+ res = false;
+ }
+
+ // Restore umask
+ umask(orig_umask);
+
+ // Restore file permissions
+ if (!kwsys::SystemTools::SetPermissions(testNewFile, origPerm))
+ {
+ kwsys_ios::cerr
+ << "Problem with SetPermissions (4) for: "
+ << testNewFile << kwsys_ios::endl;
+ res = false;
+ }
+
+ // Remove the test file
if (!kwsys::SystemTools::RemoveFile(testNewFile))
{
kwsys_ios::cerr
@@ -271,48 +411,48 @@ static bool CheckStringOperations()
kwsys_ios::cerr
<< "Problem with CapitalizedWords "
<< '"' << test << '"' << kwsys_ios::endl;
- res = false;
+ res = false;
}
test = "Mary Had A Little Lamb.";
- if (kwsys::SystemTools::UnCapitalizedWords(test) !=
+ if (kwsys::SystemTools::UnCapitalizedWords(test) !=
"mary had a little lamb.")
{
kwsys_ios::cerr
<< "Problem with UnCapitalizedWords "
<< '"' << test << '"' << kwsys_ios::endl;
- res = false;
+ res = false;
}
test = "MaryHadTheLittleLamb.";
- if (kwsys::SystemTools::AddSpaceBetweenCapitalizedWords(test) !=
+ if (kwsys::SystemTools::AddSpaceBetweenCapitalizedWords(test) !=
"Mary Had The Little Lamb.")
{
kwsys_ios::cerr
<< "Problem with AddSpaceBetweenCapitalizedWords "
<< '"' << test << '"' << kwsys_ios::endl;
- res = false;
+ res = false;
}
- char * cres =
+ char * cres =
kwsys::SystemTools::AppendStrings("Mary Had A"," Little Lamb.");
if (strcmp(cres,"Mary Had A Little Lamb."))
{
kwsys_ios::cerr
<< "Problem with AppendStrings "
<< "\"Mary Had A\" \" Little Lamb.\"" << kwsys_ios::endl;
- res = false;
+ res = false;
}
delete [] cres;
- cres =
+ cres =
kwsys::SystemTools::AppendStrings("Mary Had"," A ","Little Lamb.");
if (strcmp(cres,"Mary Had A Little Lamb."))
{
kwsys_ios::cerr
<< "Problem with AppendStrings "
<< "\"Mary Had\" \" A \" \"Little Lamb.\"" << kwsys_ios::endl;
- res = false;
+ res = false;
}
delete [] cres;
@@ -321,28 +461,28 @@ static bool CheckStringOperations()
kwsys_ios::cerr
<< "Problem with CountChar "
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
- res = false;
+ res = false;
}
- cres =
+ cres =
kwsys::SystemTools::RemoveChars("Mary Had A Little Lamb.","aeiou");
if (strcmp(cres,"Mry Hd A Lttl Lmb."))
{
kwsys_ios::cerr
<< "Problem with RemoveChars "
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
- res = false;
+ res = false;
}
delete [] cres;
- cres =
+ cres =
kwsys::SystemTools::RemoveCharsButUpperHex("Mary Had A Little Lamb.");
if (strcmp(cres,"A"))
{
kwsys_ios::cerr
<< "Problem with RemoveCharsButUpperHex "
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
- res = false;
+ res = false;
}
delete [] cres;
@@ -354,7 +494,7 @@ static bool CheckStringOperations()
kwsys_ios::cerr
<< "Problem with ReplaceChars "
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
- res = false;
+ res = false;
}
delete [] cres2;
@@ -364,7 +504,7 @@ static bool CheckStringOperations()
kwsys_ios::cerr
<< "Problem with StringStartsWith "
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
- res = false;
+ res = false;
}
if (!kwsys::SystemTools::StringEndsWith("Mary Had A Little Lamb.",
@@ -373,7 +513,7 @@ static bool CheckStringOperations()
kwsys_ios::cerr
<< "Problem with StringEndsWith "
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
- res = false;
+ res = false;
}
cres = kwsys::SystemTools::DuplicateString("Mary Had A Little Lamb.");
@@ -382,18 +522,18 @@ static bool CheckStringOperations()
kwsys_ios::cerr
<< "Problem with DuplicateString "
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
- res = false;
+ res = false;
}
delete [] cres;
test = "Mary Had A Little Lamb.";
- if (kwsys::SystemTools::CropString(test,13) !=
+ if (kwsys::SystemTools::CropString(test,13) !=
"Mary ...Lamb.")
{
kwsys_ios::cerr
<< "Problem with CropString "
<< "\"Mary Had A Little Lamb.\"" << kwsys_ios::endl;
- res = false;
+ res = false;
}
kwsys_stl::vector<kwsys_stl::string> lines;
@@ -515,36 +655,36 @@ static bool CheckStringOperations()
#endif
if (kwsys::SystemTools::ConvertToWindowsOutputPath
- ("L://Local Mojo/Hex Power Pack/Iffy Voodoo") !=
+ ("L://Local Mojo/Hex Power Pack/Iffy Voodoo") !=
"\"L:\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\"")
{
kwsys_ios::cerr
<< "Problem with ConvertToWindowsOutputPath "
<< "\"L://Local Mojo/Hex Power Pack/Iffy Voodoo\""
<< kwsys_ios::endl;
- res = false;
+ res = false;
}
-
+
if (kwsys::SystemTools::ConvertToWindowsOutputPath
- ("//grayson/Local Mojo/Hex Power Pack/Iffy Voodoo") !=
+ ("//grayson/Local Mojo/Hex Power Pack/Iffy Voodoo") !=
"\"\\\\grayson\\Local Mojo\\Hex Power Pack\\Iffy Voodoo\"")
{
kwsys_ios::cerr
<< "Problem with ConvertToWindowsOutputPath "
<< "\"//grayson/Local Mojo/Hex Power Pack/Iffy Voodoo\""
<< kwsys_ios::endl;
- res = false;
+ res = false;
}
if (kwsys::SystemTools::ConvertToUnixOutputPath
- ("//Local Mojo/Hex Power Pack/Iffy Voodoo") !=
+ ("//Local Mojo/Hex Power Pack/Iffy Voodoo") !=
"//Local\\ Mojo/Hex\\ Power\\ Pack/Iffy\\ Voodoo")
{
kwsys_ios::cerr
<< "Problem with ConvertToUnixOutputPath "
<< "\"//Local Mojo/Hex Power Pack/Iffy Voodoo\""
<< kwsys_ios::endl;
- res = false;
+ res = false;
}
return res;
@@ -672,7 +812,7 @@ int testSystemTools(int, char*[])
for (cc = 0; checkEscapeChars[cc][0]; cc ++ )
{
- res &= CheckEscapeChars(checkEscapeChars[cc][0], checkEscapeChars[cc][1],
+ res &= CheckEscapeChars(checkEscapeChars[cc][0], checkEscapeChars[cc][1],
*checkEscapeChars[cc][2], checkEscapeChars[cc][3]);
}
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 35b29bf..801d7e8 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -3036,6 +3036,31 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-options ${build_options}
--test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList")
+
+ # For next test, java tool must have same architecture as toolchain
+ math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8")
+ execute_process(
+ COMMAND "${Java_JAVA_EXECUTABLE}" -d${_object_mode} -version
+ OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result
+ )
+ if(_result EQUAL 0)
+ if(CMAKE_CONFIGURATION_TYPES)
+ set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$<CONFIGURATION>)
+ else()
+ set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah)
+ endif()
+ add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/JavaJavah"
+ "${CMake_BINARY_DIR}/Tests/JavaJavah"
+ ${build_generator_args}
+ --build-project helloJavah
+ --build-two-config
+ --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/"
+ --build-options ${build_options}
+ --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2)
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah")
+ endif()
endif()
endif()
endif()
diff --git a/Tests/JavaJavah/B.cpp b/Tests/JavaJavah/B.cpp
new file mode 100644
index 0000000..2666757
--- /dev/null
+++ b/Tests/JavaJavah/B.cpp
@@ -0,0 +1,10 @@
+
+#include <jni.h>
+#include <stdio.h>
+
+#include "B.h"
+
+JNIEXPORT void JNICALL Java_B_printName(JNIEnv *, jobject)
+{
+ printf("B\n");
+}
diff --git a/Tests/JavaJavah/B.java b/Tests/JavaJavah/B.java
new file mode 100644
index 0000000..d731f39
--- /dev/null
+++ b/Tests/JavaJavah/B.java
@@ -0,0 +1,19 @@
+class B
+{
+ public B()
+ {
+ }
+
+ public native void printName();
+
+ static {
+ try {
+
+ System.loadLibrary("B");
+
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load.\n" + e);
+ System.exit(1);
+ }
+ }
+}
diff --git a/Tests/JavaJavah/CMakeLists.txt b/Tests/JavaJavah/CMakeLists.txt
new file mode 100644
index 0000000..83b0ad0
--- /dev/null
+++ b/Tests/JavaJavah/CMakeLists.txt
@@ -0,0 +1,20 @@
+project(helloJavah Java CXX)
+
+cmake_minimum_required (VERSION 2.6)
+set(CMAKE_VERBOSE_MAKEFILE 1)
+
+find_package(Java COMPONENTS Development)
+include (UseJava)
+
+# JNI support
+find_package(JNI)
+
+add_jar(hello3 B.java HelloWorld2.java)
+create_javah(TARGET B_javah CLASSES B CLASSPATH hello3)
+
+add_library(B SHARED B.cpp)
+add_dependencies(B B_javah)
+
+target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
+ ${JAVA_INCLUDE_PATH}
+ ${JAVA_INCLUDE_PATH2})
diff --git a/Tests/JavaJavah/HelloWorld2.java b/Tests/JavaJavah/HelloWorld2.java
new file mode 100644
index 0000000..faf7277
--- /dev/null
+++ b/Tests/JavaJavah/HelloWorld2.java
@@ -0,0 +1,10 @@
+class HelloWorld2
+{
+ public static void main(String args[])
+ {
+ B b;
+ b = new B();
+ b.printName();
+ System.out.println("Hello World!");
+ }
+}
diff --git a/Tests/Module/GenerateExportHeader/CMakeLists.txt b/Tests/Module/GenerateExportHeader/CMakeLists.txt
index b52c44d..8cd25a4 100644
--- a/Tests/Module/GenerateExportHeader/CMakeLists.txt
+++ b/Tests/Module/GenerateExportHeader/CMakeLists.txt
@@ -106,10 +106,10 @@ endif()
add_executable(GenerateExportHeader exportheader_test.cpp)
target_link_libraries(GenerateExportHeader ${link_libraries})
-if (WIN32)
+if (WIN32 OR CYGWIN)
if(MSVC AND COMPILER_HAS_DEPRECATED)
set(_platform Win32)
- elseif(MINGW AND COMPILER_HAS_DEPRECATED)
+ elseif((MINGW OR CYGWIN) AND COMPILER_HAS_DEPRECATED)
set(_platform MinGW)
else()
set(_platform WinEmpty)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index c274d8f..2955db2 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -239,6 +239,7 @@ add_RunCMake_test(CommandLine)
add_RunCMake_test(CommandLineTar)
add_RunCMake_test(install)
+add_RunCMake_test(CPackConfig)
add_RunCMake_test(CPackInstallProperties)
add_RunCMake_test(ExternalProject)
add_RunCMake_test(CTestCommandLine)
diff --git a/Tests/RunCMake/CPackConfig/CMakeLists.txt b/Tests/RunCMake/CPackConfig/CMakeLists.txt
new file mode 100644
index 0000000..9a9e7b4
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.3)
+
+project(${RunCMake_TEST})
+include(${RunCMake_TEST}.cmake)
+
+include(CPack)
diff --git a/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake
new file mode 100644
index 0000000..6787eb8
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(Simple)
diff --git a/Tests/RunCMake/CPackConfig/Simple-check.cmake b/Tests/RunCMake/CPackConfig/Simple-check.cmake
new file mode 100644
index 0000000..6e0cf6f
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/Simple-check.cmake
@@ -0,0 +1,3 @@
+include(${RunCMake_SOURCE_DIR}/check.cmake)
+
+test_variable(CPACK_FOO "bar baz;quux")
diff --git a/Tests/RunCMake/CPackConfig/Simple.cmake b/Tests/RunCMake/CPackConfig/Simple.cmake
new file mode 100644
index 0000000..c9f6541
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/Simple.cmake
@@ -0,0 +1 @@
+set(CPACK_FOO "bar baz;quux")
diff --git a/Tests/RunCMake/CPackConfig/check.cmake b/Tests/RunCMake/CPackConfig/check.cmake
new file mode 100644
index 0000000..2fc9f11
--- /dev/null
+++ b/Tests/RunCMake/CPackConfig/check.cmake
@@ -0,0 +1,7 @@
+function(test_variable NAME EXPECTED_VALUE)
+ if(NOT "${${NAME}}" STREQUAL "${EXPECTED_VALUE}")
+ message(FATAL_ERROR "${NAME}: variable mismatch; expected [${EXPECTED_VALUE}] actual [${${NAME}}]")
+ endif()
+endfunction()
+
+include(${RunCMake_TEST_BINARY_DIR}/CPackConfig.cmake)
diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
index 382c990..8ab618b 100644
--- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake
@@ -53,3 +53,9 @@ if(NOT XCODE_VERSION VERSION_LESS 5)
unset(RunCMake_TEST_NO_CLEAN)
unset(RunCMake_TEST_OPTIONS)
endif()
+
+if(NOT XCODE_VERSION VERSION_LESS 7)
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/osx.cmake")
+ run_cmake(XcodeTbdStub)
+ unset(RunCMake_TEST_OPTIONS)
+endif()
diff --git a/Tests/RunCMake/XcodeProject/XcodeTbdStub-stdout.txt b/Tests/RunCMake/XcodeProject/XcodeTbdStub-stdout.txt
new file mode 100644
index 0000000..9d9e143
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeTbdStub-stdout.txt
@@ -0,0 +1 @@
+.*/libz\.tbd.*
diff --git a/Tests/RunCMake/XcodeProject/XcodeTbdStub.cmake b/Tests/RunCMake/XcodeProject/XcodeTbdStub.cmake
new file mode 100644
index 0000000..e83d7f3
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/XcodeTbdStub.cmake
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 3.3)
+find_package(ZLIB REQUIRED)
diff --git a/Tests/RunCMake/XcodeProject/osx.cmake b/Tests/RunCMake/XcodeProject/osx.cmake
new file mode 100644
index 0000000..e021fcd
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/osx.cmake
@@ -0,0 +1,18 @@
+set(CMAKE_SYSTEM_NAME Darwin)
+set(CMAKE_SYSTEM_VERSION 1)
+set(UNIX True)
+set(APPLE True)
+
+find_program(XCRUN_EXECUTABLE xcrun)
+if(NOT XCRUN_EXECUTABLE)
+ message(FATAL_ERROR "xcrun not found")
+endif()
+
+execute_process(
+ COMMAND ${XCRUN_EXECUTABLE} --sdk macosx --show-sdk-path
+ OUTPUT_VARIABLE OSX_SDK_PATH
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+set(CMAKE_OSX_SYSROOT ${OSX_SDK_PATH} CACHE PATH "Sysroot used for OSX support")
+
+set(CMAKE_FIND_ROOT_PATH ${OSX_SDK_PATH} CACHE PATH "Find search path root")