summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/AutomocInfo.cmake.in5
-rw-r--r--Modules/FindImageMagick.cmake2
-rw-r--r--Modules/FindQt4.cmake54
-rw-r--r--Modules/Platform/Darwin.cmake13
-rw-r--r--Modules/Qt4Macros.cmake24
-rw-r--r--Modules/SelectLibraryConfigurations.cmake2
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmCommands.cxx2
-rw-r--r--Source/cmComputeLinkInformation.cxx60
-rw-r--r--Source/cmCoreTryCompile.cxx236
-rw-r--r--Source/cmDocumentGeneratorExpressions.h8
-rw-r--r--Source/cmExportBuildFileGenerator.cxx18
-rw-r--r--Source/cmExportBuildFileGenerator.h2
-rw-r--r--Source/cmExportFileGenerator.cxx6
-rw-r--r--Source/cmExportFileGenerator.h3
-rw-r--r--Source/cmExportInstallFileGenerator.cxx24
-rw-r--r--Source/cmExportInstallFileGenerator.h2
-rw-r--r--Source/cmExportTryCompileFileGenerator.cxx15
-rw-r--r--Source/cmExportTryCompileFileGenerator.h2
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx8
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.cxx8
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.h1
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx111
-rw-r--r--Source/cmGlobalGenerator.cxx2
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx130
-rw-r--r--Source/cmInstallTargetGenerator.cxx90
-rw-r--r--Source/cmLocalGenerator.cxx20
-rw-r--r--Source/cmLocalGenerator.h3
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx41
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx4
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx5
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx13
-rw-r--r--Source/cmMakefileTargetGenerator.cxx34
-rw-r--r--Source/cmMakefileTargetGenerator.h1
-rw-r--r--Source/cmMakefileUtilityTargetGenerator.cxx3
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx19
-rw-r--r--Source/cmNinjaTargetGenerator.cxx12
-rw-r--r--Source/cmOSXBundleGenerator.cxx102
-rw-r--r--Source/cmOSXBundleGenerator.h22
-rw-r--r--Source/cmOrderDirectories.cxx45
-rw-r--r--Source/cmQtAutomoc.cxx40
-rw-r--r--Source/cmSystemTools.cxx21
-rw-r--r--Source/cmSystemTools.h4
-rw-r--r--Source/cmTarget.cxx560
-rw-r--r--Source/cmTarget.h48
-rw-r--r--Source/cmTargetCompileOptionsCommand.cxx62
-rw-r--r--Source/cmTargetCompileOptionsCommand.h90
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx15
-rw-r--r--Tests/BundleUtilities/CMakeLists.txt3
-rw-r--r--Tests/CMakeCommands/target_compile_options/CMakeLists.txt35
-rw-r--r--Tests/CMakeCommands/target_compile_options/consumer.cpp18
-rw-r--r--Tests/CMakeCommands/target_compile_options/main.cpp18
-rw-r--r--Tests/CMakeLists.txt26
-rw-r--r--Tests/CompileOptions/CMakeLists.txt16
-rw-r--r--Tests/CompileOptions/main.cpp11
-rw-r--r--Tests/CompileOptions/other.cpp5
-rw-r--r--Tests/MacRuntimePath/A/CMakeLists.txt63
-rw-r--r--Tests/MacRuntimePath/A/framework.cpp8
-rw-r--r--Tests/MacRuntimePath/A/framework.h17
-rw-r--r--Tests/MacRuntimePath/A/shared.cpp8
-rw-r--r--Tests/MacRuntimePath/A/shared.h17
-rw-r--r--Tests/MacRuntimePath/A/test1.cpp8
-rw-r--r--Tests/MacRuntimePath/A/test2.cpp8
-rw-r--r--Tests/MacRuntimePath/A/test3.cpp8
-rw-r--r--Tests/MacRuntimePath/B/CMakeLists.txt17
-rw-r--r--Tests/MacRuntimePath/CMakeLists.txt72
-rw-r--r--Tests/MacRuntimePath/InitialCache.cmake.in13
-rw-r--r--Tests/Qt4And5Automoc/CMakeLists.txt13
-rw-r--r--Tests/Qt4And5Automoc/main.cpp18
-rw-r--r--Tests/Qt4And5Automoc/main_qt4.cpp4
-rw-r--r--Tests/Qt4And5Automoc/main_qt5.cpp4
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/try_compile/BadLinkLibraries-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/BadLinkLibraries-stderr.txt5
-rw-r--r--Tests/RunCMake/try_compile/BadLinkLibraries.cmake3
-rw-r--r--Tests/RunCMake/try_compile/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/try_compile/NoArgs-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/NoArgs-stderr.txt4
-rw-r--r--Tests/RunCMake/try_compile/NoArgs.cmake1
-rw-r--r--Tests/RunCMake/try_compile/NoCopyFile-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/NoCopyFile-stderr.txt4
-rw-r--r--Tests/RunCMake/try_compile/NoCopyFile.cmake2
-rw-r--r--Tests/RunCMake/try_compile/NoCopyFile2-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/NoCopyFile2-stderr.txt4
-rw-r--r--Tests/RunCMake/try_compile/NoCopyFile2.cmake2
-rw-r--r--Tests/RunCMake/try_compile/NoOutputVariable-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/NoOutputVariable-stderr.txt4
-rw-r--r--Tests/RunCMake/try_compile/NoOutputVariable.cmake2
-rw-r--r--Tests/RunCMake/try_compile/NoOutputVariable2-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/NoOutputVariable2-stderr.txt4
-rw-r--r--Tests/RunCMake/try_compile/NoOutputVariable2.cmake2
-rw-r--r--Tests/RunCMake/try_compile/NonSourceCompileDefinitions-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/NonSourceCompileDefinitions-stderr.txt4
-rw-r--r--Tests/RunCMake/try_compile/NonSourceCompileDefinitions.cmake2
-rw-r--r--Tests/RunCMake/try_compile/NonSourceCopyFile-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/NonSourceCopyFile-stderr.txt4
-rw-r--r--Tests/RunCMake/try_compile/NonSourceCopyFile.cmake2
-rw-r--r--Tests/RunCMake/try_compile/OneArg-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/OneArg-stderr.txt4
-rw-r--r--Tests/RunCMake/try_compile/OneArg.cmake1
-rw-r--r--Tests/RunCMake/try_compile/RunCMakeTest.cmake12
-rw-r--r--Tests/RunCMake/try_compile/TwoArgs-result.txt1
-rw-r--r--Tests/RunCMake/try_compile/TwoArgs-stderr.txt4
-rw-r--r--Tests/RunCMake/try_compile/TwoArgs.cmake1
-rw-r--r--Tests/RunCMake/try_compile/proj/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/try_compile/src.c1
106 files changed, 2040 insertions, 452 deletions
diff --git a/Modules/AutomocInfo.cmake.in b/Modules/AutomocInfo.cmake.in
index 640bf70..9cff735 100644
--- a/Modules/AutomocInfo.cmake.in
+++ b/Modules/AutomocInfo.cmake.in
@@ -6,10 +6,9 @@ set(AM_MOC_OPTIONS @_moc_options@)
set(AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE "@CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE@")
set(AM_CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@/")
set(AM_CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@/")
-set(AM_QT_MOC_EXECUTABLE "@QT_MOC_EXECUTABLE@")
+set(AM_QT_MOC_EXECUTABLE "@_qt_moc_executable@")
set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/")
set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/")
-set(AM_QT_VERSION_MAJOR "@QT_VERSION_MAJOR@" )
-set(AM_Qt5Core_VERSION_MAJOR "@Qt5Core_VERSION_MAJOR@" )
+set(AM_QT_VERSION_MAJOR "@_target_qt_version@")
set(AM_TARGET_NAME @_moc_target_name@)
set(AM_RELAXED_MODE "@_moc_relaxed_mode@")
diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake
index cd97b38..02a5777 100644
--- a/Modules/FindImageMagick.cmake
+++ b/Modules/FindImageMagick.cmake
@@ -81,7 +81,7 @@ function(FIND_IMAGEMAGICK_API component header)
${ImageMagick_INCLUDE_DIRS}
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\ImageMagick\\Current;BinPath]/include"
PATH_SUFFIXES
- ImageMagick
+ ImageMagick ImageMagick-6
DOC "Path to the ImageMagick include dir."
)
find_library(ImageMagick_${component}_LIBRARY
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake
index 68b37f3..8ce1934 100644
--- a/Modules/FindQt4.cmake
+++ b/Modules/FindQt4.cmake
@@ -884,16 +884,20 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION)
endforeach()
if(Q_WS_WIN)
- set(QT_MODULES ${QT_MODULES} QAxContainer QAxServer)
- # Set QT_AXCONTAINER_INCLUDE_DIR and QT_AXSERVER_INCLUDE_DIR
- find_path(QT_QAXCONTAINER_INCLUDE_DIR ActiveQt
- PATHS ${QT_HEADERS_DIR}/ActiveQt
- NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
- )
- find_path(QT_QAXSERVER_INCLUDE_DIR ActiveQt
- PATHS ${QT_HEADERS_DIR}/ActiveQt
- NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
- )
+ if (QT_QAXCONTAINER_FOUND)
+ set(QT_MODULES ${QT_MODULES} QAxContainer)
+ # Set QT_AXCONTAINER_INCLUDE_DIR and QT_AXSERVER_INCLUDE_DIR
+ find_path(QT_QAXCONTAINER_INCLUDE_DIR ActiveQt
+ PATHS ${QT_HEADERS_DIR}/ActiveQt
+ NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
+ )
+ endif()
+ if (QT_QAXSERVER_FOUND)
+ find_path(QT_QAXSERVER_INCLUDE_DIR ActiveQt
+ PATHS ${QT_HEADERS_DIR}/ActiveQt
+ NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
+ )
+ endif()
endif()
# Set QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR
@@ -1054,14 +1058,18 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION)
if(Q_WS_WIN)
_QT4_ADJUST_LIB_VARS(qtmain)
- _QT4_ADJUST_LIB_VARS(QAxServer)
- set_property(TARGET Qt4::QAxServer PROPERTY
- INTERFACE_QT4_NO_LINK_QTMAIN ON
- )
- set_property(TARGET Qt4::QAxServer APPEND PROPERTY
- COMPATIBLE_INTERFACE_BOOL QT4_NO_LINK_QTMAIN)
+ if(QT_QAXSERVER_FOUND)
+ _QT4_ADJUST_LIB_VARS(QAxServer)
+ set_property(TARGET Qt4::QAxServer PROPERTY
+ INTERFACE_QT4_NO_LINK_QTMAIN ON
+ )
+ set_property(TARGET Qt4::QAxServer APPEND PROPERTY
+ COMPATIBLE_INTERFACE_BOOL QT4_NO_LINK_QTMAIN)
+ endif()
- _QT4_ADJUST_LIB_VARS(QAxContainer)
+ if(QT_QAXCONTAINER_FOUND)
+ _QT4_ADJUST_LIB_VARS(QAxContainer)
+ endif()
endif()
# Only public dependencies are listed here.
@@ -1083,7 +1091,9 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION)
_qt4_add_target_depends(QtWebKit Gui Network)
_qt4_add_target_private_depends(Qt3Support Xml)
- _qt4_add_target_private_depends(QtSvg Xml)
+ if(QT_VERSION VERSION_GREATER 4.6)
+ _qt4_add_target_private_depends(QtSvg Xml)
+ endif()
_qt4_add_target_private_depends(QtDBus Xml)
_qt4_add_target_private_depends(QtUiTools Xml Gui)
_qt4_add_target_private_depends(QtHelp Sql Xml Network)
@@ -1093,8 +1103,12 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION)
_qt4_add_target_private_depends(QtDeclarative XmlPatterns Svg Sql Gui)
_qt4_add_target_private_depends(QtMultimedia Gui)
_qt4_add_target_private_depends(QtOpenGL Gui)
- _qt4_add_target_private_depends(QAxServer Gui)
- _qt4_add_target_private_depends(QAxContainer Gui)
+ if(QT_QAXSERVER_FOUND)
+ _qt4_add_target_private_depends(QAxServer Gui)
+ endif()
+ if(QT_QAXCONTAINER_FOUND)
+ _qt4_add_target_private_depends(QAxContainer Gui)
+ endif()
_qt4_add_target_private_depends(phonon Gui)
if(QT_QTDBUS_FOUND)
_qt4_add_target_private_depends(phonon DBus)
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
index 2e6b71e..f0652b9 100644
--- a/Modules/Platform/Darwin.cmake
+++ b/Modules/Platform/Darwin.cmake
@@ -30,6 +30,11 @@ set(CMAKE_SHARED_MODULE_SUFFIX ".so")
set(CMAKE_MODULE_EXISTS 1)
set(CMAKE_DL_LIBS "")
+# Enable rpath support for 10.5 and greater where it is known to work.
+if("${DARWIN_MAJOR_VERSION}" GREATER 8)
+ set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
+endif()
+
set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
@@ -207,12 +212,8 @@ if("${CMAKE_BACKWARDS_COMPATIBILITY}" MATCHES "^1\\.[0-6]$")
"${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -flat_namespace -undefined suppress")
endif()
-if(NOT XCODE)
- # Enable shared library versioning. This flag is not actually referenced
- # but the fact that the setting exists will cause the generators to support
- # soname computation.
- set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name")
-endif()
+# Enable shared library versioning.
+set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name")
# Xcode does not support -isystem yet.
if(XCODE)
diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake
index 251d57c..f6c8476 100644
--- a/Modules/Qt4Macros.cmake
+++ b/Modules/Qt4Macros.cmake
@@ -451,14 +451,22 @@ function(qt4_use_modules _target _link_type)
endif()
foreach(_module ${modules})
string(TOUPPER ${_module} _ucmodule)
- if (NOT QT_QT${_ucmodule}_FOUND)
- message(FATAL_ERROR "Can not use \"${_module}\" module which has not yet been found.")
- endif()
- if ("${_ucmodule}" STREQUAL "MAIN")
- message(FATAL_ERROR "Can not use \"${_module}\" module with qt4_use_modules.")
+ set(_targetPrefix QT_QT${_ucmodule})
+ if (_ucmodule STREQUAL QAXCONTAINER OR _ucmodule STREQUAL QAXSERVER)
+ if (NOT QT_Q${_ucmodule}_FOUND)
+ message(FATAL_ERROR "Can not use \"${_module}\" module which has not yet been found.")
+ endif()
+ set(_targetPrefix QT_Q${_ucmodule})
+ else()
+ if (NOT QT_QT${_ucmodule}_FOUND)
+ message(FATAL_ERROR "Can not use \"${_module}\" module which has not yet been found.")
+ endif()
+ if ("${_ucmodule}" STREQUAL "MAIN")
+ message(FATAL_ERROR "Can not use \"${_module}\" module with qt4_use_modules.")
+ endif()
endif()
- target_link_libraries(${_target} ${link_type} ${QT_QT${_ucmodule}_LIBRARY})
- set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${QT_QT${_ucmodule}_INCLUDE_DIR} ${QT_HEADERS_DIR} ${QT_MKSPECS_DIR}/default)
- set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${QT_QT${_ucmodule}_COMPILE_DEFINITIONS})
+ target_link_libraries(${_target} ${link_type} ${${_targetPrefix}_LIBRARIES})
+ set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${${_targetPrefix}_INCLUDE_DIR} ${QT_HEADERS_DIR} ${QT_MKSPECS_DIR}/default)
+ set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS ${${_targetPrefix}_COMPILE_DEFINITIONS})
endforeach()
endfunction()
diff --git a/Modules/SelectLibraryConfigurations.cmake b/Modules/SelectLibraryConfigurations.cmake
index 62137bb..5bca064 100644
--- a/Modules/SelectLibraryConfigurations.cmake
+++ b/Modules/SelectLibraryConfigurations.cmake
@@ -62,7 +62,7 @@ macro( select_library_configurations basename )
# if the generator supports configuration types or CMAKE_BUILD_TYPE
# is set, then set optimized and debug options.
if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
- set( ${basename}_LIBRARY )
+ set( ${basename}_LIBRARY "" )
foreach( _libname IN LISTS ${basename}_LIBRARY_RELEASE )
list( APPEND ${basename}_LIBRARY optimized "${_libname}" )
endforeach()
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 25d4e77..1230403 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -2,5 +2,5 @@
set(CMake_VERSION_MAJOR 2)
set(CMake_VERSION_MINOR 8)
set(CMake_VERSION_PATCH 11)
-set(CMake_VERSION_TWEAK 20130602)
+set(CMake_VERSION_TWEAK 20130603)
#set(CMake_VERSION_RC 1)
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index 227b226..75f2ae8 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -29,6 +29,7 @@
#include "cmSourceGroupCommand.cxx"
#include "cmSubdirDependsCommand.cxx"
#include "cmTargetCompileDefinitionsCommand.cxx"
+#include "cmTargetCompileOptionsCommand.cxx"
#include "cmTargetIncludeDirectoriesCommand.cxx"
#include "cmTargetPropCommandBase.cxx"
#include "cmUseMangledMesaCommand.cxx"
@@ -71,6 +72,7 @@ void GetPredefinedCommands(std::list<cmCommand*>&
commands.push_back(new cmSubdirDependsCommand);
commands.push_back(new cmTargetIncludeDirectoriesCommand);
commands.push_back(new cmTargetCompileDefinitionsCommand);
+ commands.push_back(new cmTargetCompileOptionsCommand);
commands.push_back(new cmUseMangledMesaCommand);
commands.push_back(new cmUtilitySourceCommand);
commands.push_back(new cmVariableRequiresCommand);
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 0158508..02495c4 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -1730,6 +1730,17 @@ void
cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath,
cmTarget* target)
{
+ // Ignore targets on Apple where install_name is not @rpath.
+ // The dependenty library can be found with other means such as
+ // @loader_path or full paths.
+ if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
+ {
+ if(!target->HasMacOSXRpath(this->Config))
+ {
+ return;
+ }
+ }
+
// Libraries with unknown type must be handled using just the file
// on disk.
if(target->GetType() == cmTarget::UNKNOWN_LIBRARY)
@@ -1762,25 +1773,60 @@ void
cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath)
{
// Get the name of the library from the file name.
+ bool is_shared_library = false;
std::string file = cmSystemTools::GetFilenameName(fullPath);
- if(!this->ExtractSharedLibraryName.find(file.c_str()))
+
+ if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
+ {
+ // Check that @rpath is part of the install name.
+ // If it isn't, return.
+ std::string soname;
+ if(!cmSystemTools::GuessLibraryInstallName(fullPath, soname))
+ {
+ return;
+ }
+
+ if(soname.find("@rpath") == std::string::npos)
+ {
+ return;
+ }
+ }
+
+ is_shared_library = this->ExtractSharedLibraryName.find(file.c_str());
+
+ if(!is_shared_library)
{
// On some platforms (AIX) a shared library may look static.
if(this->ArchivesMayBeShared)
{
- if(!this->ExtractStaticLibraryName.find(file.c_str()))
+ if(this->ExtractStaticLibraryName.find(file.c_str()))
{
- // This is not the name of a shared library or archive.
- return;
+ // This is the name of a shared library or archive.
+ is_shared_library = true;
}
}
- else
+ }
+
+ // It could be an Apple framework
+ if(!is_shared_library)
+ {
+ if(fullPath.find(".framework") != std::string::npos)
{
- // This is not the name of a shared library.
- return;
+ cmsys::RegularExpression splitFramework;
+ splitFramework.compile("^(.*)/(.*).framework/.*/(.*)$");
+ if(splitFramework.find(fullPath) &&
+ (splitFramework.match(2) == splitFramework.match(3)))
+ {
+ is_shared_library = true;
+ }
}
}
+ if(!is_shared_library)
+ {
+ return;
+ }
+
// Include this library in the runtime path ordering.
this->OrderRuntimeSearchPath->AddRuntimeLibrary(fullPath);
if(this->LinkWithRuntimePath)
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 85e49a9..bf28428 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -23,150 +23,130 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
this->BinaryDirectory = argv[1].c_str();
this->OutputFile = "";
// which signature were we called with ?
- this->SrcFileSignature = false;
- unsigned int i;
+ this->SrcFileSignature = true;
const char* sourceDirectory = argv[2].c_str();
const char* projectName = 0;
const char* targetName = 0;
- char targetNameBuf[64];
- int extraArgs = 0;
-
- // look for CMAKE_FLAGS and store them
std::vector<std::string> cmakeFlags;
- for (i = 3; i < argv.size(); ++i)
- {
- if (argv[i] == "CMAKE_FLAGS")
- {
- // CMAKE_FLAGS is the first argument because we need an argv[0] that
- // is not used, so it matches regular command line parsing which has
- // the program name as arg 0
- for (; i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" &&
- argv[i] != "OUTPUT_VARIABLE" &&
- argv[i] != "LINK_LIBRARIES";
- ++i)
- {
- extraArgs++;
- cmakeFlags.push_back(argv[i]);
- }
- break;
- }
- }
-
- // look for OUTPUT_VARIABLE and store them
+ std::vector<std::string> compileDefs;
std::string outputVariable;
- for (i = 3; i < argv.size(); ++i)
+ std::string copyFile;
+ std::vector<cmTarget*> targets;
+ std::string libsToLink = " ";
+ bool useOldLinkLibs = true;
+ char targetNameBuf[64];
+ bool didOutputVariable = false;
+ bool didCopyFile = false;
+
+ enum Doing { DoingNone, DoingCMakeFlags, DoingCompileDefinitions,
+ DoingLinkLibraries, DoingOutputVariable, DoingCopyFile };
+ Doing doing = DoingNone;
+ for(size_t i=3; i < argv.size(); ++i)
{
- if (argv[i] == "OUTPUT_VARIABLE")
+ if(argv[i] == "CMAKE_FLAGS")
{
- if ( argv.size() <= (i+1) )
- {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
- "OUTPUT_VARIABLE specified but there is no variable");
- return -1;
- }
- extraArgs += 2;
- outputVariable = argv[i+1];
- break;
+ doing = DoingCMakeFlags;
+ // CMAKE_FLAGS is the first argument because we need an argv[0] that
+ // is not used, so it matches regular command line parsing which has
+ // the program name as arg 0
+ cmakeFlags.push_back(argv[i]);
}
- }
-
- // look for COMPILE_DEFINITIONS and store them
- std::vector<std::string> compileFlags;
- for (i = 3; i < argv.size(); ++i)
- {
- if (argv[i] == "COMPILE_DEFINITIONS")
+ else if(argv[i] == "COMPILE_DEFINITIONS")
{
- extraArgs++;
- for (i = i + 1; i < argv.size() && argv[i] != "CMAKE_FLAGS" &&
- argv[i] != "OUTPUT_VARIABLE" &&
- argv[i] != "LINK_LIBRARIES";
- ++i)
- {
- extraArgs++;
- compileFlags.push_back(argv[i]);
- }
- break;
+ doing = DoingCompileDefinitions;
}
- }
-
- std::vector<cmTarget*> targets;
- std::string libsToLink = " ";
- bool useOldLinkLibs = true;
- for (i = 3; i < argv.size(); ++i)
- {
- if (argv[i] == "LINK_LIBRARIES")
+ else if(argv[i] == "LINK_LIBRARIES")
{
- if ( argv.size() <= (i+1) )
- {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
- "LINK_LIBRARIES specified but there is no content");
- return -1;
- }
- extraArgs++;
- ++i;
+ doing = DoingLinkLibraries;
useOldLinkLibs = false;
- for ( ; i < argv.size() && argv[i] != "CMAKE_FLAGS"
- && argv[i] != "COMPILE_DEFINITIONS" && argv[i] != "OUTPUT_VARIABLE";
- ++i)
+ }
+ else if(argv[i] == "OUTPUT_VARIABLE")
+ {
+ doing = DoingOutputVariable;
+ didOutputVariable = true;
+ }
+ else if(argv[i] == "COPY_FILE")
+ {
+ doing = DoingCopyFile;
+ didCopyFile = true;
+ }
+ else if(doing == DoingCMakeFlags)
+ {
+ cmakeFlags.push_back(argv[i]);
+ }
+ else if(doing == DoingCompileDefinitions)
+ {
+ compileDefs.push_back(argv[i]);
+ }
+ else if(doing == DoingLinkLibraries)
+ {
+ libsToLink += "\"" + cmSystemTools::TrimWhitespace(argv[i]) + "\" ";
+ if(cmTarget *tgt = this->Makefile->FindTargetToUse(argv[i].c_str()))
{
- extraArgs++;
- libsToLink += "\"" + cmSystemTools::TrimWhitespace(argv[i]) + "\" ";
- cmTarget *tgt = this->Makefile->FindTargetToUse(argv[i].c_str());
- if (!tgt)
- {
- continue;
- }
switch(tgt->GetType())
- {
- case cmTarget::SHARED_LIBRARY:
- case cmTarget::STATIC_LIBRARY:
- case cmTarget::UNKNOWN_LIBRARY:
- break;
- case cmTarget::EXECUTABLE:
- if (tgt->IsExecutableWithExports())
- {
+ {
+ case cmTarget::SHARED_LIBRARY:
+ case cmTarget::STATIC_LIBRARY:
+ case cmTarget::UNKNOWN_LIBRARY:
break;
- }
- default:
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
- "Only libraries may be used as try_compile IMPORTED "
- "LINK_LIBRARIES. Got " + std::string(tgt->GetName()) + " of "
- "type " + tgt->GetTargetTypeName(tgt->GetType()) + ".");
- return -1;
- }
- if (!tgt->IsImported())
+ case cmTarget::EXECUTABLE:
+ if (tgt->IsExecutableWithExports())
+ {
+ break;
+ }
+ default:
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ "Only libraries may be used as try_compile IMPORTED "
+ "LINK_LIBRARIES. Got " + std::string(tgt->GetName()) + " of "
+ "type " + tgt->GetTargetTypeName(tgt->GetType()) + ".");
+ return -1;
+ }
+ if (tgt->IsImported())
{
- continue;
+ targets.push_back(tgt);
}
- targets.push_back(tgt);
}
- break;
+ }
+ else if(doing == DoingOutputVariable)
+ {
+ outputVariable = argv[i].c_str();
+ doing = DoingNone;
+ }
+ else if(doing == DoingCopyFile)
+ {
+ copyFile = argv[i].c_str();
+ doing = DoingNone;
+ }
+ else if(i == 3)
+ {
+ this->SrcFileSignature = false;
+ projectName = argv[i].c_str();
+ }
+ else if(i == 4 && !this->SrcFileSignature)
+ {
+ targetName = argv[i].c_str();
+ }
+ else
+ {
+ cmOStringStream m;
+ m << "try_compile given unknown argument \"" << argv[i] << "\".";
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str());
}
}
- // look for COPY_FILE
- std::string copyFile;
- for (i = 3; i < argv.size(); ++i)
+ if(didCopyFile && copyFile.empty())
{
- if (argv[i] == "COPY_FILE")
- {
- if ( argv.size() <= (i+1) )
- {
- this->Makefile->IssueMessage(cmake::FATAL_ERROR,
- "COPY_FILE specified but there is no variable");
- return -1;
- }
- extraArgs += 2;
- copyFile = argv[i+1];
- break;
- }
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ "COPY_FILE must be followed by a file path");
+ return -1;
}
- // do we have a srcfile signature
- if (argv.size() - extraArgs == 3)
+ if(didOutputVariable && outputVariable.empty())
{
- this->SrcFileSignature = true;
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ "OUTPUT_VARIABLE must be followed by a variable name");
+ return -1;
}
// compute the binary dir when TRY_COMPILE is called with a src file
@@ -179,10 +159,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
else
{
// only valid for srcfile signatures
- if (compileFlags.size())
+ if (compileDefs.size())
{
this->Makefile->IssueMessage(cmake::FATAL_ERROR,
- "COMPILE_FLAGS specified on a srcdir type TRY_COMPILE");
+ "COMPILE_DEFINITIONS specified on a srcdir type TRY_COMPILE");
return -1;
}
if (copyFile.size())
@@ -297,12 +277,12 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
fprintf(fout, "SET(CMAKE_SUPPRESS_REGENERATION 1)\n");
fprintf(fout, "LINK_DIRECTORIES(${LINK_DIRECTORIES})\n");
// handle any compile flags we need to pass on
- if (compileFlags.size())
+ if (compileDefs.size())
{
fprintf(fout, "ADD_DEFINITIONS( ");
- for (i = 0; i < compileFlags.size(); ++i)
+ for (size_t i = 0; i < compileDefs.size(); ++i)
{
- fprintf(fout,"%s ",compileFlags[i].c_str());
+ fprintf(fout,"%s ",compileDefs[i].c_str());
}
fprintf(fout, ")\n");
}
@@ -398,16 +378,6 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
}
}
- // else the srcdir bindir project target signature
- else
- {
- projectName = argv[3].c_str();
-
- if (argv.size() - extraArgs == 5)
- {
- targetName = argv[4].c_str();
- }
- }
bool erroroc = cmSystemTools::GetErrorOccuredFlag();
cmSystemTools::ResetErrorOccuredFlag();
diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h
index 656810d..a8b3847 100644
--- a/Source/cmDocumentGeneratorExpressions.h
+++ b/Source/cmDocumentGeneratorExpressions.h
@@ -40,6 +40,14 @@
"is exported using export(), or when the target is used by another " \
"target in the same buildsystem. Expands to the empty string " \
"otherwise.\n" \
+ " $<C_COMPILER_ID> = The CMake-id of the C compiler " \
+ "used.\n" \
+ " $<C_COMPILER_ID:comp> = '1' if the CMake-id of the C " \
+ "compiler matches comp, otherwise '0'.\n" \
+ " $<CXX_COMPILER_ID> = The CMake-id of the CXX compiler " \
+ "used.\n" \
+ " $<CXX_COMPILER_ID:comp> = '1' if the CMake-id of the CXX " \
+ "compiler matches comp, otherwise '0'.\n" \
" $<TARGET_FILE:tgt> = main file (.exe, .so.1.2, .a)\n" \
" $<TARGET_LINKER_FILE:tgt> = file used to link (.a, .lib, .so)\n" \
" $<TARGET_SONAME_FILE:tgt> = file with soname (.so.3)\n" \
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index e1c26c6..39184fb 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -143,7 +143,7 @@ cmExportBuildFileGenerator
std::string prop = "IMPORTED_LOCATION";
prop += suffix;
std::string value;
- if(target->IsFrameworkOnApple() || target->IsAppBundleOnApple())
+ if(target->IsAppBundleOnApple())
{
value = target->GetFullPath(config, false);
}
@@ -211,3 +211,19 @@ cmExportBuildFileGenerator
<< "consider using the APPEND option with multiple separate calls.";
this->ExportCommand->ErrorMessage = e.str();
}
+
+std::string
+cmExportBuildFileGenerator::InstallNameDir(cmTarget* target,
+ const std::string& config)
+{
+ std::string install_name_dir;
+
+ cmMakefile* mf = target->GetMakefile();
+ if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
+ {
+ install_name_dir =
+ target->GetInstallNameDirForBuildTree(config.c_str());
+ }
+
+ return install_name_dir;
+}
diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h
index 5e1be16..3ffdf8b 100644
--- a/Source/cmExportBuildFileGenerator.h
+++ b/Source/cmExportBuildFileGenerator.h
@@ -61,6 +61,8 @@ protected:
cmTarget* target,
ImportPropertyMap& properties);
+ std::string InstallNameDir(cmTarget* target, const std::string& config);
+
std::vector<cmTarget*> const* Exports;
cmExportCommand* ExportCommand;
};
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index a6ccbd5..6bef017 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -624,8 +624,12 @@ cmExportFileGenerator
std::string value;
if(target->HasSOName(config))
{
+ if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
+ {
+ value = this->InstallNameDir(target, config);
+ }
prop = "IMPORTED_SONAME";
- value = target->GetSOName(config);
+ value += target->GetSOName(config);
}
else
{
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 9f958a2..ed2d93b 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -159,6 +159,9 @@ private:
std::vector<std::string> &missingTargets);
virtual void ReplaceInstallPrefix(std::string &input);
+
+ virtual std::string InstallNameDir(cmTarget* target,
+ const std::string& config) = 0;
};
#endif
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 55081a7..dfcf472 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -351,13 +351,7 @@ cmExportInstallFileGenerator
prop += suffix;
// Append the installed file name.
- if(target->IsFrameworkOnApple())
- {
- value += itgen->GetInstallFilename(target, config);
- value += ".framework/";
- value += itgen->GetInstallFilename(target, config);
- }
- else if(target->IsCFBundleOnApple())
+ if(target->IsCFBundleOnApple())
{
const char *ext = target->GetProperty("BUNDLE_EXTENSION");
if (!ext)
@@ -497,3 +491,19 @@ cmExportInstallFileGenerator
}
cmSystemTools::Error(e.str().c_str());
}
+
+std::string
+cmExportInstallFileGenerator::InstallNameDir(cmTarget* target,
+ const std::string&)
+{
+ std::string install_name_dir;
+
+ cmMakefile* mf = target->GetMakefile();
+ if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
+ {
+ install_name_dir =
+ target->GetInstallNameDirForInstallTree();
+ }
+
+ return install_name_dir;
+}
diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h
index 20dd57a..7c634a4 100644
--- a/Source/cmExportInstallFileGenerator.h
+++ b/Source/cmExportInstallFileGenerator.h
@@ -85,6 +85,8 @@ protected:
void ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen);
+ std::string InstallNameDir(cmTarget* target, const std::string& config);
+
cmInstallExportGenerator* IEGen;
std::string ImportPrefix;
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index 75f2651..948508b 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -112,3 +112,18 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget* target,
}
}
}
+std::string
+cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target,
+ const std::string& config)
+{
+ std::string install_name_dir;
+
+ cmMakefile* mf = target->GetMakefile();
+ if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
+ {
+ install_name_dir =
+ target->GetInstallNameDirForBuildTree(config.c_str());
+ }
+
+ return install_name_dir;
+}
diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h
index ed393ab..91b4a61 100644
--- a/Source/cmExportTryCompileFileGenerator.h
+++ b/Source/cmExportTryCompileFileGenerator.h
@@ -43,6 +43,8 @@ protected:
ImportPropertyMap& properties,
std::set<cmTarget*> &emitted);
+ std::string InstallNameDir(cmTarget* target,
+ const std::string& config);
private:
std::string FindTargets(const char *prop, cmTarget *tgt,
std::set<cmTarget*> &emitted);
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 62e9194..29d86a6 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -429,7 +429,9 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
lg->AppendFlags(flags, makefile->GetDefineFlags());
// Add target-specific flags.
- if(target->GetProperty("COMPILE_FLAGS"))
+ std::string targetFlags;
+ lg->GetCompileOptions(targetFlags, target, config);
+ if (!targetFlags.empty())
{
std::string langIncludeExpr = "CMAKE_";
langIncludeExpr += language;
@@ -440,7 +442,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
cmsys::RegularExpression r(regex);
std::vector<std::string> args;
cmSystemTools::
- ParseWindowsCommandLine(target->GetProperty("COMPILE_FLAGS"), args);
+ ParseWindowsCommandLine(targetFlags.c_str(), args);
for(std::vector<std::string>::iterator i = args.begin();
i != args.end(); ++i)
{
@@ -452,7 +454,7 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
}
else
{
- lg->AppendFlags(flags, target->GetProperty("COMPILE_FLAGS"));
+ lg->AppendFlags(flags, targetFlags.c_str());
}
}
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index 5cb50b9..e5ffb0c 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -168,3 +168,11 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingCompileDefinitions() const
|| strcmp(prop, "INTERFACE_COMPILE_DEFINITIONS") == 0
|| strncmp(prop, "COMPILE_DEFINITIONS_", 20) == 0);
}
+
+//----------------------------------------------------------------------------
+bool cmGeneratorExpressionDAGChecker::EvaluatingCompileOptions() const
+{
+ const char *prop = this->Property.c_str();
+ return (strcmp(prop, "COMPILE_OPTIONS") == 0
+ || strcmp(prop, "INTERFACE_COMPILE_OPTIONS") == 0 );
+}
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index 62a5cdf..8d9fd76 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -40,6 +40,7 @@ struct cmGeneratorExpressionDAGChecker
bool EvaluatingLinkLibraries();
bool EvaluatingIncludeDirectories() const;
bool EvaluatingCompileDefinitions() const;
+ bool EvaluatingCompileOptions() const;
private:
Result checkGraph() const;
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index df52368..5e7d00d 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -247,6 +247,104 @@ static const struct SemicolonNode : public cmGeneratorExpressionNode
} semicolonNode;
//----------------------------------------------------------------------------
+struct CompilerIdNode : public cmGeneratorExpressionNode
+{
+ CompilerIdNode() {}
+
+ virtual int NumExpectedParameters() const { return ZeroOrMoreParameters; }
+
+ std::string EvaluateWithLanguage(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *context,
+ const GeneratorExpressionContent *content,
+ cmGeneratorExpressionDAGChecker *,
+ const std::string &lang) const
+ {
+ const char *compilerId = context->Makefile ?
+ context->Makefile->GetSafeDefinition((
+ "CMAKE_" + lang + "_COMPILER_ID").c_str()) : "";
+ if (parameters.size() == 0)
+ {
+ return compilerId ? compilerId : "";
+ }
+ else
+ {
+ cmsys::RegularExpression compilerIdValidator;
+ compilerIdValidator.compile("^[A-Za-z0-9_]*$");
+ if (!compilerIdValidator.find(parameters.begin()->c_str()))
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "Expression syntax not recognized.");
+ return std::string();
+ }
+ if (!compilerId)
+ {
+ return parameters.front().empty() ? "1" : "0";
+ }
+
+ if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0)
+ {
+ return "1";
+ }
+ return "0";
+ }
+ }
+};
+
+//----------------------------------------------------------------------------
+static const struct CCompilerIdNode : public CompilerIdNode
+{
+ CCompilerIdNode() {}
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *context,
+ const GeneratorExpressionContent *content,
+ cmGeneratorExpressionDAGChecker *dagChecker) const
+ {
+ if (parameters.size() != 0 && parameters.size() != 1)
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<C_COMPILER_ID> expression requires one or two parameters");
+ return std::string();
+ }
+ if (!context->HeadTarget)
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<C_COMPILER_ID> may only be used with targets. It may not "
+ "be used with add_custom_command.");
+ }
+ return this->EvaluateWithLanguage(parameters, context, content,
+ dagChecker, "C");
+ }
+} cCompilerIdNode;
+
+//----------------------------------------------------------------------------
+static const struct CXXCompilerIdNode : public CompilerIdNode
+{
+ CXXCompilerIdNode() {}
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *context,
+ const GeneratorExpressionContent *content,
+ cmGeneratorExpressionDAGChecker *dagChecker) const
+ {
+ if (parameters.size() != 0 && parameters.size() != 1)
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<CXX_COMPILER_ID> expression requires one or two parameters");
+ return std::string();
+ }
+ if (!context->HeadTarget)
+ {
+ reportError(context, content->GetOriginalExpression(),
+ "$<CXX_COMPILER_ID> may only be used with targets. It may not "
+ "be used with add_custom_command.");
+ }
+ return this->EvaluateWithLanguage(parameters, context, content,
+ dagChecker, "CXX");
+ }
+} cxxCompilerIdNode;
+
+//----------------------------------------------------------------------------
static const struct ConfigurationNode : public cmGeneratorExpressionNode
{
ConfigurationNode() {}
@@ -397,6 +495,7 @@ static const struct JoinNode : public cmGeneratorExpressionNode
static const char* targetPropertyTransitiveWhitelist[] = {
"INTERFACE_INCLUDE_DIRECTORIES"
, "INTERFACE_COMPILE_DEFINITIONS"
+ , "INTERFACE_COMPILE_OPTIONS"
};
std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
@@ -604,7 +703,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
else
{
assert(dagCheckerParent->EvaluatingIncludeDirectories()
- || dagCheckerParent->EvaluatingCompileDefinitions());
+ || dagCheckerParent->EvaluatingCompileDefinitions()
+ || dagCheckerParent->EvaluatingCompileOptions());
}
}
@@ -623,6 +723,11 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
{
interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS";
}
+ else if (propertyName == "INTERFACE_COMPILE_OPTIONS"
+ || propertyName == "COMPILE_OPTIONS")
+ {
+ interfacePropertyName = "INTERFACE_COMPILE_OPTIONS";
+ }
const char **transBegin = targetPropertyTransitiveWhitelist;
const char **transEnd = targetPropertyTransitiveWhitelist
@@ -1055,6 +1160,10 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
return &orNode;
else if (identifier == "NOT")
return &notNode;
+ else if (identifier == "C_COMPILER_ID")
+ return &cCompilerIdNode;
+ else if (identifier == "CXX_COMPILER_ID")
+ return &cxxCompilerIdNode;
else if (identifier == "CONFIGURATION")
return &configurationNode;
else if (identifier == "CONFIG")
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 3496823..3e3e5e4 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -963,7 +963,7 @@ void cmGlobalGenerator::Generate()
for ( tit = targets->begin(); tit != targets->end(); ++ tit )
{
- tit->second.AppendBuildInterfaceIncludes();
+ tit->second.AppendBuildInterfaceIncludes();
}
}
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index bb1e792..2d76c82 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -681,9 +681,11 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
{
// Add flags from target and source file properties.
std::string flags;
- if(cmtarget.GetProperty("COMPILE_FLAGS"))
+ std::string targetFlags;
+ lg->GetCompileOptions(targetFlags, &cmtarget, 0); // TODO: Config?
+ if(!targetFlags.empty())
{
- lg->AppendFlags(flags, cmtarget.GetProperty("COMPILE_FLAGS"));
+ lg->AppendFlags(flags, targetFlags.c_str());
}
const char* srcfmt = sf->GetProperty("Fortran_FORMAT");
switch(this->CurrentLocalGenerator->GetFortranFormat(srcfmt))
@@ -1321,8 +1323,40 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
= cmtarget.GetPreBuildCommands();
std::vector<cmCustomCommand> const & prelink
= cmtarget.GetPreLinkCommands();
- std::vector<cmCustomCommand> const & postbuild
+ std::vector<cmCustomCommand> postbuild
= cmtarget.GetPostBuildCommands();
+
+ if(cmtarget.GetType() == cmTarget::SHARED_LIBRARY &&
+ !cmtarget.IsFrameworkOnApple())
+ {
+ cmCustomCommandLines cmd;
+ cmd.resize(1);
+ cmd[0].push_back(this->CurrentMakefile->GetDefinition("CMAKE_COMMAND"));
+ cmd[0].push_back("-E");
+ cmd[0].push_back("cmake_symlink_library");
+ std::string str_file = "$<TARGET_FILE:";
+ str_file += cmtarget.GetName();
+ str_file += ">";
+ std::string str_so_file = "$<TARGET_SONAME_FILE:";
+ str_so_file += cmtarget.GetName();
+ str_so_file += ">";
+ std::string str_link_file = "$<TARGET_LINKER_FILE:";
+ str_link_file += cmtarget.GetName();
+ str_link_file += ">";
+ cmd[0].push_back(str_file);
+ cmd[0].push_back(str_so_file);
+ cmd[0].push_back(str_link_file);
+
+ cmCustomCommand command(this->CurrentMakefile,
+ std::vector<std::string>(),
+ std::vector<std::string>(),
+ cmd,
+ "Creating symlinks",
+ "");
+
+ postbuild.push_back(command);
+ }
+
std::vector<cmSourceFile*>const &classes = cmtarget.GetSourceFiles();
// add all the sources
std::vector<cmCustomCommand> commands;
@@ -1795,9 +1829,34 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
std::string pnprefix;
std::string pnbase;
std::string pnsuffix;
-
target.GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName);
+ const char* version = target.GetProperty("VERSION");
+ const char* soversion = target.GetProperty("SOVERSION");
+ if(!target.HasSOName(configName) || target.IsFrameworkOnApple())
+ {
+ version = 0;
+ soversion = 0;
+ }
+ if(version && !soversion)
+ {
+ soversion = version;
+ }
+ if(!version && soversion)
+ {
+ version = soversion;
+ }
+
+ std::string realName = pnbase;
+ std::string soName = pnbase;
+ if(version && soversion)
+ {
+ realName += ".";
+ realName += version;
+ soName += ".";
+ soName += soversion;
+ }
+
// Set attributes to specify the proper name for the target.
std::string pndir = this->CurrentMakefile->GetCurrentOutputDirectory();
if(target.GetType() == cmTarget::STATIC_LIBRARY ||
@@ -1821,6 +1880,11 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
pndir = target.GetDirectory(configName);
}
+ if(target.IsFrameworkOnApple())
+ {
+ pnprefix = "";
+ }
+
buildSettings->AddAttribute("EXECUTABLE_PREFIX",
this->CreateString(pnprefix.c_str()));
buildSettings->AddAttribute("EXECUTABLE_SUFFIX",
@@ -1850,7 +1914,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
// Store the product name for all target types.
buildSettings->AddAttribute("PRODUCT_NAME",
- this->CreateString(pnbase.c_str()));
+ this->CreateString(realName.c_str()));
buildSettings->AddAttribute("SYMROOT",
this->CreateString(pndir.c_str()));
@@ -1928,9 +1992,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
{
if(target.GetPropertyAsBool("FRAMEWORK"))
{
- std::string version = target.GetFrameworkVersion();
+ std::string fw_version = target.GetFrameworkVersion();
buildSettings->AddAttribute("FRAMEWORK_VERSION",
- this->CreateString(version.c_str()));
+ this->CreateString(fw_version.c_str()));
std::string plist = this->ComputeInfoPListLocation(target);
// Xcode will create the final version of Info.plist at build time,
@@ -2154,25 +2218,55 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
if(target.GetType() == cmTarget::SHARED_LIBRARY)
{
// Get the install_name directory for the build tree.
- install_name_dir = target.GetInstallNameDirForBuildTree(configName, true);
- if(install_name_dir.empty())
- {
- // Xcode will not pass the -install_name option at all if INSTALL_PATH
- // is not given or is empty. We must explicitly put the flag in the
- // link flags to create an install_name with just the library soname.
- extraLinkOptions += " -install_name ";
- extraLinkOptions += target.GetFullName(configName);
- }
- else
+ install_name_dir = target.GetInstallNameDirForBuildTree(configName);
+ // Xcode doesn't create the correct install_name in some cases.
+ // That is, if the INSTALL_PATH is empty, or if we have versioning
+ // of dylib libraries, we want to specify the install_name.
+ // This is done by adding a link flag to create an install_name
+ // with just the library soname.
+ std::string install_name;
+ if(!install_name_dir.empty())
{
// Convert to a path for the native build tool.
cmSystemTools::ConvertToUnixSlashes(install_name_dir);
- // do not escape spaces on this since it is only a single path
+ install_name += install_name_dir;
+ install_name += "/";
+ }
+ install_name += target.GetSOName(configName);
+
+ if((realName != soName) || install_name_dir.empty())
+ {
+ install_name_dir = "";
+ extraLinkOptions += " -install_name ";
+ extraLinkOptions += XCodeEscapePath(install_name.c_str());
}
}
buildSettings->AddAttribute("INSTALL_PATH",
this->CreateString(install_name_dir.c_str()));
+ // Create the LD_RUNPATH_SEARCH_PATHS
+ cmComputeLinkInformation* pcli = target.GetLinkInformation(configName);
+ if(pcli)
+ {
+ std::string search_paths;
+ std::vector<std::string> runtimeDirs;
+ pcli->GetRPath(runtimeDirs, false);
+ for(std::vector<std::string>::const_iterator i = runtimeDirs.begin();
+ i != runtimeDirs.end(); ++i)
+ {
+ if(!search_paths.empty())
+ {
+ search_paths += " ";
+ }
+ search_paths += this->XCodeEscapePath((*i).c_str());
+ }
+ if(!search_paths.empty())
+ {
+ buildSettings->AddAttribute("LD_RUNPATH_SEARCH_PATHS",
+ this->CreateString(search_paths.c_str()));
+ }
+ }
+
buildSettings->AddAttribute("OTHER_LDFLAGS",
this->CreateString(extraLinkOptions.c_str()));
buildSettings->AddAttribute("OTHER_REZFLAGS",
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 5f9b658..ed01210 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -198,14 +198,12 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
// Install the whole framework directory.
type = cmInstallType_DIRECTORY;
literal_args += " USE_SOURCE_PERMISSIONS";
- std::string from1 = fromDirConfig + targetName + ".framework";
+
+ std::string from1 = fromDirConfig + targetName;
+ from1 = cmSystemTools::GetFilenamePath(from1);
// Tweaks apply to the binary inside the bundle.
- std::string to1 = toDir + targetName;
- to1 += ".framework/Versions/";
- to1 += this->Target->GetFrameworkVersion();
- to1 += "/";
- to1 += targetName;
+ std::string to1 = toDir + targetNameReal;
filesFrom.push_back(from1);
filesTo.push_back(to1);
@@ -528,7 +526,7 @@ cmInstallTargetGenerator
// components of the install_name field then we need to create a
// mapping to be applied after installation.
std::string for_build = tgt->GetInstallNameDirForBuildTree(config);
- std::string for_install = tgt->GetInstallNameDirForInstallTree(config);
+ std::string for_install = tgt->GetInstallNameDirForInstallTree();
if(for_build != for_install)
{
// The directory portions differ. Append the filename to
@@ -555,7 +553,7 @@ cmInstallTargetGenerator
std::string for_build =
this->Target->GetInstallNameDirForBuildTree(config);
std::string for_install =
- this->Target->GetInstallNameDirForInstallTree(config);
+ this->Target->GetInstallNameDirForInstallTree();
if(this->Target->IsFrameworkOnApple() && for_install.empty())
{
@@ -608,6 +606,12 @@ cmInstallTargetGenerator
return;
}
+ // Skip if on Apple
+ if(this->Target->GetMakefile()->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
+ {
+ return;
+ }
+
// Get the link information for this target.
// It can provide the RPATH.
cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config);
@@ -647,30 +651,62 @@ cmInstallTargetGenerator
return;
}
- // Construct the original rpath string to be replaced.
- std::string oldRpath = cli->GetRPathString(false);
-
- // Get the install RPATH from the link information.
- std::string newRpath = cli->GetChrpathString();
-
- // Skip the rule if the paths are identical
- if(oldRpath == newRpath)
+ if(this->Target->GetMakefile()->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
{
- return;
- }
+ // If using install_name_tool, set up the rules to modify the rpaths.
+ std::string installNameTool =
+ this->Target->GetMakefile()->
+ GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL");
+
+ std::vector<std::string> oldRuntimeDirs, newRuntimeDirs;
+ cli->GetRPath(oldRuntimeDirs, false);
+ cli->GetRPath(newRuntimeDirs, true);
+
+ // Note: These are separate commands to avoid install_name_tool
+ // corruption on 10.6.
+ for(std::vector<std::string>::const_iterator i = oldRuntimeDirs.begin();
+ i != oldRuntimeDirs.end(); ++i)
+ {
+ os << indent << "execute_process(COMMAND " << installNameTool << "\n";
+ os << indent << " -delete_rpath \"" << *i << "\"\n";
+ os << indent << " \"" << toDestDirPath << "\")\n";
+ }
- // Write a rule to run chrpath to set the install-tree RPATH
- if(newRpath.empty())
- {
- os << indent << "FILE(RPATH_REMOVE\n"
- << indent << " FILE \"" << toDestDirPath << "\")\n";
+ for(std::vector<std::string>::const_iterator i = newRuntimeDirs.begin();
+ i != newRuntimeDirs.end(); ++i)
+ {
+ os << indent << "execute_process(COMMAND " << installNameTool << "\n";
+ os << indent << " -add_rpath \"" << *i << "\"\n";
+ os << indent << " \"" << toDestDirPath << "\")\n";
+ }
}
else
{
- os << indent << "FILE(RPATH_CHANGE\n"
- << indent << " FILE \"" << toDestDirPath << "\"\n"
- << indent << " OLD_RPATH \"" << oldRpath << "\"\n"
- << indent << " NEW_RPATH \"" << newRpath << "\")\n";
+ // Construct the original rpath string to be replaced.
+ std::string oldRpath = cli->GetRPathString(false);
+
+ // Get the install RPATH from the link information.
+ std::string newRpath = cli->GetChrpathString();
+
+ // Skip the rule if the paths are identical
+ if(oldRpath == newRpath)
+ {
+ return;
+ }
+
+ // Write a rule to run chrpath to set the install-tree RPATH
+ if(newRpath.empty())
+ {
+ os << indent << "FILE(RPATH_REMOVE\n"
+ << indent << " FILE \"" << toDestDirPath << "\")\n";
+ }
+ else
+ {
+ os << indent << "FILE(RPATH_CHANGE\n"
+ << indent << " FILE \"" << toDestDirPath << "\"\n"
+ << indent << " OLD_RPATH \"" << oldRpath << "\"\n"
+ << indent << " NEW_RPATH \"" << newRpath << "\")\n";
+ }
}
}
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index d346f16..57e25a1 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1325,6 +1325,26 @@ std::string cmLocalGenerator::GetIncludeFlags(
}
//----------------------------------------------------------------------------
+void cmLocalGenerator::GetCompileOptions(std::string& flags,
+ cmTarget* target,
+ const char *config)
+{
+ // Add target-specific flags.
+ if(const char *prop = target->GetProperty("COMPILE_FLAGS"))
+ {
+ this->AppendFlags(flags, prop);
+ }
+
+ std::vector<std::string> opts; // TODO: Emitted.
+ target->GetCompileOptions(opts, config);
+ for(std::vector<std::string>::const_iterator li = opts.begin();
+ li != opts.end(); ++li)
+ {
+ this->AppendFlags(flags, li->c_str());
+ }
+}
+
+//----------------------------------------------------------------------------
void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
cmGeneratorTarget* target,
const char* lang,
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index a1c34f0..28c88e6 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -215,6 +215,9 @@ public:
cmGeneratorTarget* target,
const char* lang = "C", const char *config = 0,
bool stripImplicitInclDirs = true);
+ void GetCompileOptions(std::string& flags,
+ cmTarget* target,
+ const char *config);
/** Compute the language used to compile the given source file. */
const char* GetSourceFileLanguage(const cmSourceFile& source);
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index dc94476..4c78f7f 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -1639,9 +1639,9 @@ void cmLocalVisualStudio6Generator
// store flags for each configuration
std::string flags = " ";
std::string flagsRelease = " ";
- std::string flagsMinSize = " ";
+ std::string flagsMinSizeRel = " ";
std::string flagsDebug = " ";
- std::string flagsDebugRel = " ";
+ std::string flagsRelWithDebInfo = " ";
if(target.GetType() >= cmTarget::EXECUTABLE &&
target.GetType() <= cmTarget::OBJECT_LIBRARY)
{
@@ -1664,16 +1664,16 @@ void cmLocalVisualStudio6Generator
flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
flagVar = baseFlagVar + "_MINSIZEREL";
- flagsMinSize = this->Makefile->GetSafeDefinition(flagVar.c_str());
- flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
+ flagsMinSizeRel = this->Makefile->GetSafeDefinition(flagVar.c_str());
+ flagsMinSizeRel += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
flagVar = baseFlagVar + "_DEBUG";
flagsDebug = this->Makefile->GetSafeDefinition(flagVar.c_str());
flagsDebug += " -DCMAKE_INTDIR=\\\"Debug\\\" ";
flagVar = baseFlagVar + "_RELWITHDEBINFO";
- flagsDebugRel = this->Makefile->GetSafeDefinition(flagVar.c_str());
- flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
+ flagsRelWithDebInfo = this->Makefile->GetSafeDefinition(flagVar.c_str());
+ flagsRelWithDebInfo += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
}
// if _UNICODE and _SBCS are not found, then add -D_MBCS
@@ -1686,12 +1686,31 @@ void cmLocalVisualStudio6Generator
flags += " /D \"_MBCS\"";
}
+ {
+ std::string targetFlags;
+ this->GetCompileOptions(targetFlags, &target, 0);
// Add per-target flags.
- if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
+ if(!targetFlags.empty())
{
flags += " ";
flags += targetFlags;
}
+ }
+#define ADD_FLAGS(CONFIG) \
+ { \
+ std::string targetFlags; \
+ this->GetCompileOptions(targetFlags, &target, #CONFIG); \
+ if(!targetFlags.empty()) \
+ { \
+ flags ## CONFIG += " "; \
+ flags ## CONFIG += targetFlags; \
+ } \
+ }
+
+ ADD_FLAGS(Debug)
+ ADD_FLAGS(Release)
+ ADD_FLAGS(MinSizeRel)
+ ADD_FLAGS(RelWithDebInfo)
// Add per-target and per-configuration preprocessor definitions.
std::set<std::string> definesSet;
@@ -1731,19 +1750,19 @@ void cmLocalVisualStudio6Generator
flags += defines;
flagsDebug += debugDefines;
flagsRelease += releaseDefines;
- flagsMinSize += minsizeDefines;
- flagsDebugRel += debugrelDefines;
+ flagsMinSizeRel += minsizeDefines;
+ flagsRelWithDebInfo += debugrelDefines;
// The template files have CXX FLAGS in them, that need to be replaced.
// There are not separate CXX and C template files, so we use the same
// variable names. The previous code sets up flags* variables to contain
// the correct C or CXX flags
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL",
- flagsMinSize.c_str());
+ flagsMinSizeRel.c_str());
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG",
flagsDebug.c_str());
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELWITHDEBINFO",
- flagsDebugRel.c_str());
+ flagsRelWithDebInfo.c_str());
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE",
flagsRelease.c_str());
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS", flags.c_str());
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 58d28da..e7badf0 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -723,8 +723,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
}
}
+ std::string targetFlags;
+ this->GetCompileOptions(targetFlags, &target, configName);
// Add the target-specific flags.
- if(const char* targetFlags = target.GetProperty("COMPILE_FLAGS"))
+ if(!targetFlags.empty())
{
flags += " ";
flags += targetFlags;
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index b7a454b..e4219a9 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -30,11 +30,8 @@ cmMakefileExecutableTargetGenerator
this->TargetNamePDB, this->ConfigName);
this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target,
- this->TargetNameOut,
this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
- this->MacContentDirectory =
- this->OSXBundleGenerator->GetMacContentDirectory();
}
//----------------------------------------------------------------------------
@@ -103,11 +100,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Construct the full path version of the names.
std::string outpath = this->Target->GetDirectory(this->ConfigName);
- outpath += "/";
if(this->Target->IsAppBundleOnApple())
{
this->OSXBundleGenerator->CreateAppBundle(targetName, outpath);
}
+ outpath += "/";
std::string outpathImp;
if(relink)
{
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 5b4e4d7..3edaa44 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -32,11 +32,8 @@ cmMakefileLibraryTargetGenerator
this->TargetNameImport, this->TargetNamePDB, this->ConfigName);
this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target,
- this->TargetNameOut,
this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
- this->MacContentDirectory =
- this->OSXBundleGenerator->GetMacContentDirectory();
}
//----------------------------------------------------------------------------
@@ -292,14 +289,15 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string outpathImp;
if(this->Target->IsFrameworkOnApple())
{
- outpath = this->MacContentDirectory;
- this->OSXBundleGenerator->CreateFramework(targetName);
+ outpath = this->Target->GetDirectory(this->ConfigName);
+ this->OSXBundleGenerator->CreateFramework(targetName, outpath);
+ outpath += "/";
}
else if(this->Target->IsCFBundleOnApple())
{
outpath = this->Target->GetDirectory(this->ConfigName);
- outpath += "/";
this->OSXBundleGenerator->CreateCFBundle(targetName, outpath);
+ outpath += "/";
}
else if(relink)
{
@@ -727,7 +725,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
commands1.clear();
// Add a rule to create necessary symlinks for the library.
- if(targetOutPath != targetOutPathReal)
+ // Frameworks are handled by cmOSXBundleGenerator.
+ if(targetOutPath != targetOutPathReal && !this->Target->IsFrameworkOnApple())
{
std::string symlink = "$(CMAKE_COMMAND) -E cmake_symlink_library ";
symlink += targetOutPathReal;
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 4220ae1..699a7fd 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -332,21 +332,25 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
this->Makefile->GetSafeDefinition(compiler.c_str()) << "\n";
}
+ std::string targetFlags;
for(std::set<cmStdString>::const_iterator l = languages.begin();
l != languages.end(); ++l)
{
*this->FlagFileStream << *l << "_FLAGS = " << this->GetFlags(*l) << "\n\n";
*this->FlagFileStream << *l << "_DEFINES = " << this->GetDefines(*l) <<
"\n\n";
+ std::string targetLangFlags;
+ this->LocalGenerator->GetCompileOptions(targetLangFlags, this->Target,
+ this->LocalGenerator->ConfigurationName.c_str());
+ if (!targetFlags.empty() && targetFlags != targetLangFlags)
+ {
+ targetFlags += " " + targetLangFlags;
+ }
}
- // Add target-specific flags.
- if(this->Target->GetProperty("COMPILE_FLAGS"))
+ if (!targetFlags.empty())
{
- std::string flags;
- this->LocalGenerator->AppendFlags
- (flags, this->Target->GetProperty("COMPILE_FLAGS"));
- *this->FlagFileStream << "# TARGET_FLAGS = " << flags << "\n\n";
+ *this->FlagFileStream << "# TARGET_FLAGS = " << targetFlags << "\n\n";
}
}
@@ -357,7 +361,7 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
(cmSourceFile& source, const char* pkgloc)
{
// Skip OS X content when not building a Framework or Bundle.
- if(this->Generator->MacContentDirectory.empty())
+ if(!this->Generator->GetTarget()->IsBundleOnApple())
{
return;
}
@@ -532,8 +536,13 @@ cmMakefileTargetGenerator
langFlags += "_FLAGS)";
this->LocalGenerator->AppendFlags(flags, langFlags.c_str());
- // Add target-specific flags.
- if(this->Target->GetProperty("COMPILE_FLAGS"))
+ std::string configUpper =
+ cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
+
+ std::string targetFlags;
+ this->LocalGenerator->GetCompileOptions(targetFlags, this->Target,
+ configUpper.c_str());
+ if (!targetFlags.empty())
{
std::string langIncludeExpr = "CMAKE_";
langIncludeExpr += lang;
@@ -545,7 +554,7 @@ cmMakefileTargetGenerator
cmsys::RegularExpression r(regex);
std::vector<std::string> args;
cmSystemTools::ParseWindowsCommandLine(
- this->Target->GetProperty("COMPILE_FLAGS"),
+ targetFlags.c_str(),
args);
for(std::vector<std::string>::iterator i = args.begin();
i != args.end(); ++i)
@@ -559,8 +568,7 @@ cmMakefileTargetGenerator
}
else
{
- this->LocalGenerator->AppendFlags
- (flags, this->Target->GetProperty("COMPILE_FLAGS"));
+ this->LocalGenerator->AppendFlags(flags, targetFlags.c_str());
}
}
@@ -594,8 +602,6 @@ cmMakefileTargetGenerator
<< compile_defs << "\n"
<< "\n";
}
- std::string configUpper =
- cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += configUpper;
if(const char* config_compile_defs =
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 2798e54..f7a1e2e 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -233,7 +233,6 @@ protected:
std::string TargetNamePDB;
// Mac OS X content info.
- std::string MacContentDirectory;
std::set<cmStdString> MacContentFolders;
cmOSXBundleGenerator* OSXBundleGenerator;
MacOSXContentGeneratorType* MacOSXContentGenerator;
diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx
index 4456aa7..1fa4e95 100644
--- a/Source/cmMakefileUtilityTargetGenerator.cxx
+++ b/Source/cmMakefileUtilityTargetGenerator.cxx
@@ -25,11 +25,8 @@ cmMakefileUtilityTargetGenerator
{
this->CustomCommandDriver = OnUtility;
this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target,
- this->TargetNameOut,
this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
- this->MacContentDirectory =
- this->OSXBundleGenerator->GetMacContentDirectory();
}
//----------------------------------------------------------------------------
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index e5f3570..1bdaf90 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -61,7 +61,6 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
}
this->OSXBundleGenerator = new cmOSXBundleGenerator(target,
- this->TargetNameOut,
this->GetConfigName());
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
}
@@ -383,24 +382,32 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
if (this->GetTarget()->IsAppBundleOnApple())
{
// Create the app bundle
- std::string outpath;
+ std::string outpath =
+ this->GetTarget()->GetDirectory(this->GetConfigName());
this->OSXBundleGenerator->CreateAppBundle(this->TargetNameOut, outpath);
// Calculate the output path
- targetOutput = outpath + this->TargetNameOut;
+ targetOutput = outpath;
+ targetOutput += "/";
+ targetOutput += this->TargetNameOut;
targetOutput = this->ConvertToNinjaPath(targetOutput.c_str());
- targetOutputReal = outpath + this->TargetNameReal;
+ targetOutputReal = outpath;
+ targetOutputReal += "/";
+ targetOutputReal += this->TargetNameReal;
targetOutputReal = this->ConvertToNinjaPath(targetOutputReal.c_str());
}
else if (this->GetTarget()->IsFrameworkOnApple())
{
// Create the library framework.
- this->OSXBundleGenerator->CreateFramework(this->TargetNameOut);
+ std::string outpath =
+ this->GetTarget()->GetDirectory(this->GetConfigName());
+ this->OSXBundleGenerator->CreateFramework(this->TargetNameOut, outpath);
}
else if(this->GetTarget()->IsCFBundleOnApple())
{
// Create the core foundation bundle.
- std::string outpath;
+ std::string outpath =
+ this->GetTarget()->GetDirectory(this->GetConfigName());
this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut, outpath);
}
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 850e5ea..6f912b8 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -151,9 +151,9 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
this->GetConfigName());
// Add include directory flags.
+ const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
{
std::vector<std::string> includes;
- const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget,
language.c_str(), config);
@@ -171,7 +171,9 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
this->LocalGenerator->AppendFlags(flags, this->Makefile->GetDefineFlags());
// Add target-specific flags.
- if(this->Target->GetProperty("COMPILE_FLAGS"))
+ std::string targetFlags;
+ this->LocalGenerator->GetCompileOptions(targetFlags, this->Target, config);
+ if(!targetFlags.empty())
{
std::string langIncludeExpr = "CMAKE_";
langIncludeExpr += language;
@@ -183,7 +185,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
cmsys::RegularExpression r(regex);
std::vector<std::string> args;
cmSystemTools::ParseWindowsCommandLine(
- this->Target->GetProperty("COMPILE_FLAGS"),
+ targetFlags.c_str(),
args);
for(std::vector<std::string>::iterator i = args.begin();
i != args.end(); ++i)
@@ -198,7 +200,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
else
{
this->LocalGenerator->AppendFlags
- (flags, this->Target->GetProperty("COMPILE_FLAGS"));
+ (flags, targetFlags.c_str());
}
}
@@ -699,7 +701,7 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
cmSourceFile& source, const char* pkgloc)
{
// Skip OS X content when not building a Framework or Bundle.
- if(this->Generator->OSXBundleGenerator->GetMacContentDirectory().empty())
+ if(!this->Generator->GetTarget()->IsBundleOnApple())
{
return;
}
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index 42fad07..621a49f 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -28,26 +28,16 @@ void cmOSXBundleGenerator::PrepareTargetProperties(cmTarget* target)
//----------------------------------------------------------------------------
cmOSXBundleGenerator::
cmOSXBundleGenerator(cmTarget* target,
- std::string targetNameOut,
const char* configName)
: Target(target)
, Makefile(target->GetMakefile())
, LocalGenerator(Makefile->GetLocalGenerator())
- , TargetNameOut(targetNameOut)
, ConfigName(configName)
- , MacContentDirectory()
- , FrameworkVersion()
, MacContentFolders(0)
{
if (this->MustSkip())
return;
- this->MacContentDirectory =
- this->Target->GetMacContentDirectory(this->ConfigName,
- /*implib*/ false,
- /*includeMacOS*/ false);
- if(this->Target->IsFrameworkOnApple())
- this->FrameworkVersion = this->Target->GetFrameworkVersion();
}
//----------------------------------------------------------------------------
@@ -57,41 +47,60 @@ bool cmOSXBundleGenerator::MustSkip()
}
//----------------------------------------------------------------------------
-void cmOSXBundleGenerator::CreateAppBundle(std::string& targetName,
+void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
std::string& outpath)
{
if (this->MustSkip())
return;
// Compute bundle directory names.
- outpath = this->MacContentDirectory;
- outpath += "MacOS";
- cmSystemTools::MakeDirectory(outpath.c_str());
- outpath += "/";
- this->Makefile->AddCMakeOutputFile(outpath.c_str());
+ std::string out = outpath;
+ out += "/";
+ out += this->Target->GetAppBundleDirectory(this->ConfigName, false);
+ cmSystemTools::MakeDirectory(out.c_str());
+ this->Makefile->AddCMakeOutputFile(out.c_str());
+
+ std::string newoutpath = out;
// Configure the Info.plist file. Note that it needs the executable name
// to be set.
- std::string plist = this->MacContentDirectory + "Info.plist";
+ std::string plist = outpath;
+ plist += "/";
+ plist += this->Target->GetAppBundleDirectory(this->ConfigName, true);
+ plist += "/Info.plist";
this->LocalGenerator->GenerateAppleInfoPList(this->Target,
targetName.c_str(),
plist.c_str());
this->Makefile->AddCMakeOutputFile(plist.c_str());
+ outpath = newoutpath;
}
//----------------------------------------------------------------------------
-void cmOSXBundleGenerator::CreateFramework(std::string const& targetName)
+void cmOSXBundleGenerator::CreateFramework(
+ const std::string& targetName, const std::string& outpath)
{
if (this->MustSkip())
return;
assert(this->MacContentFolders);
+ // Compute the location of the top-level foo.framework directory.
+ std::string contentdir = outpath + "/" +
+ this->Target->GetFrameworkDirectory(this->ConfigName, true);
+ contentdir += "/";
+
+ std::string newoutpath = outpath + "/" +
+ this->Target->GetFrameworkDirectory(this->ConfigName, false);
+
+ std::string frameworkVersion = this->Target->GetFrameworkVersion();
+
// Configure the Info.plist file into the Resources directory.
this->MacContentFolders->insert("Resources");
- std::string plist = this->MacContentDirectory + "Resources/Info.plist";
+ std::string plist = newoutpath;
+ plist += "/Resources/Info.plist";
+ std::string name = cmSystemTools::GetFilenameName(targetName);
this->LocalGenerator->GenerateFrameworkInfoPList(this->Target,
- targetName.c_str(),
+ name.c_str(),
plist.c_str());
// TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to
@@ -99,25 +108,17 @@ void cmOSXBundleGenerator::CreateFramework(std::string const& targetName)
std::string oldName;
std::string newName;
- // Compute the location of the top-level foo.framework directory.
- std::string top = this->Target->GetDirectory(this->ConfigName);
- top += "/";
- top += this->TargetNameOut;
- top += ".framework/";
// Make foo.framework/Versions
- std::string versions = top;
+ std::string versions = contentdir;
versions += "Versions";
cmSystemTools::MakeDirectory(versions.c_str());
// Make foo.framework/Versions/version
- std::string version = versions;
- version += "/";
- version += this->FrameworkVersion;
- cmSystemTools::MakeDirectory(version.c_str());
+ cmSystemTools::MakeDirectory(newoutpath.c_str());
// Current -> version
- oldName = this->FrameworkVersion;
+ oldName = frameworkVersion;
newName = versions;
newName += "/Current";
cmSystemTools::RemoveFile(newName.c_str());
@@ -126,9 +127,9 @@ void cmOSXBundleGenerator::CreateFramework(std::string const& targetName)
// foo -> Versions/Current/foo
oldName = "Versions/Current/";
- oldName += this->TargetNameOut;
- newName = top;
- newName += this->TargetNameOut;
+ oldName += name;
+ newName = contentdir;
+ newName += name;
cmSystemTools::RemoveFile(newName.c_str());
cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
this->Makefile->AddCMakeOutputFile(newName.c_str());
@@ -138,7 +139,7 @@ void cmOSXBundleGenerator::CreateFramework(std::string const& targetName)
this->MacContentFolders->end())
{
oldName = "Versions/Current/Resources";
- newName = top;
+ newName = contentdir;
newName += "Resources";
cmSystemTools::RemoveFile(newName.c_str());
cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
@@ -150,7 +151,7 @@ void cmOSXBundleGenerator::CreateFramework(std::string const& targetName)
this->MacContentFolders->end())
{
oldName = "Versions/Current/Headers";
- newName = top;
+ newName = contentdir;
newName += "Headers";
cmSystemTools::RemoveFile(newName.c_str());
cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
@@ -162,7 +163,7 @@ void cmOSXBundleGenerator::CreateFramework(std::string const& targetName)
this->MacContentFolders->end())
{
oldName = "Versions/Current/PrivateHeaders";
- newName = top;
+ newName = contentdir;
newName += "PrivateHeaders";
cmSystemTools::RemoveFile(newName.c_str());
cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
@@ -171,27 +172,32 @@ void cmOSXBundleGenerator::CreateFramework(std::string const& targetName)
}
//----------------------------------------------------------------------------
-void cmOSXBundleGenerator::CreateCFBundle(std::string& targetName,
+void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName,
std::string& outpath)
{
if (this->MustSkip())
return;
// Compute bundle directory names.
- outpath = this->MacContentDirectory;
- outpath += "MacOS";
- cmSystemTools::MakeDirectory(outpath.c_str());
- outpath += "/";
- this->Makefile->AddCMakeOutputFile(outpath.c_str());
+ std::string out = outpath;
+ out += "/";
+ out += this->Target->GetCFBundleDirectory(this->ConfigName, true);
+ std::string top = out;
+ out += "/MacOS";
+ cmSystemTools::MakeDirectory(out.c_str());
+ this->Makefile->AddCMakeOutputFile(out.c_str());
+
+ std::string newoutpath = out;
// Configure the Info.plist file. Note that it needs the executable name
// to be set.
- std::string plist = this->MacContentDirectory;
- plist += "Info.plist";
+ std::string plist = top;
+ plist += "/Info.plist";
this->LocalGenerator->GenerateAppleInfoPList(this->Target,
targetName.c_str(),
plist.c_str());
this->Makefile->AddCMakeOutputFile(plist.c_str());
+ outpath = newoutpath;
}
//----------------------------------------------------------------------------
@@ -220,7 +226,11 @@ std::string
cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc)
{
// Construct the full path to the content subdirectory.
- std::string macdir = this->MacContentDirectory;
+
+ std::string macdir =
+ this->Target->GetMacContentDirectory(this->ConfigName,
+ /*implib*/ false);
+ macdir += "/";
macdir += pkgloc;
cmSystemTools::MakeDirectory(macdir.c_str());
diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h
index 01e3cbe..6cf81d2 100644
--- a/Source/cmOSXBundleGenerator.h
+++ b/Source/cmOSXBundleGenerator.h
@@ -28,12 +28,19 @@ public:
static void PrepareTargetProperties(cmTarget* target);
cmOSXBundleGenerator(cmTarget* target,
- std::string targetNameOut,
const char* configName);
- void CreateAppBundle(std::string& targetName, std::string& outpath);
- void CreateFramework(std::string const& targetName);
- void CreateCFBundle(std::string& targetName, std::string& outpath);
+ // create an app bundle at a given root, and return
+ // the directory within the bundle that contains the executable
+ void CreateAppBundle(const std::string& targetName, std::string& root);
+
+ // create a framework at a given root
+ void CreateFramework(const std::string& targetName,
+ const std::string& root);
+
+ // create a cf bundle at a given root and return the
+ // directory within the bundle that contains the library
+ void CreateCFBundle(const std::string& targetName, std::string& outpath);
struct MacOSXContentGeneratorType
{
@@ -46,10 +53,6 @@ public:
MacOSXContentGeneratorType* generator);
std::string InitMacOSXContentDirectory(const char* pkgloc);
- std::string GetMacContentDirectory() const
- { return this->MacContentDirectory; }
- std::string GetFrameworkVersion() const
- { return this->FrameworkVersion; }
void SetMacContentFolders(std::set<cmStdString>* macContentFolders)
{ this->MacContentFolders = macContentFolders; }
@@ -60,10 +63,7 @@ private:
cmTarget* Target;
cmMakefile* Makefile;
cmLocalGenerator* LocalGenerator;
- std::string TargetNameOut;
const char* ConfigName;
- std::string MacContentDirectory;
- std::string FrameworkVersion;
std::set<cmStdString>* MacContentFolders;
};
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index 6e41768..93885b2 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -36,8 +36,25 @@ public:
OD(od), GlobalGenerator(od->GlobalGenerator)
{
this->FullPath = file;
- this->Directory = cmSystemTools::GetFilenamePath(file);
- this->FileName = cmSystemTools::GetFilenameName(file);
+
+ if(file.rfind(".framework") != std::string::npos)
+ {
+ cmsys::RegularExpression splitFramework;
+ splitFramework.compile("^(.*)/(.*).framework/.*/(.*)$");
+ if(splitFramework.find(file) &&
+ (splitFramework.match(2) == splitFramework.match(3)))
+ {
+ this->Directory = splitFramework.match(1);
+ this->FileName =
+ std::string(file.begin() + this->Directory.size() + 1, file.end());
+ }
+ }
+
+ if(this->FileName.empty())
+ {
+ this->Directory = cmSystemTools::GetFilenamePath(file);
+ this->FileName = cmSystemTools::GetFilenameName(file);
+ }
}
virtual ~cmOrderDirectoriesConstraint() {}
@@ -301,22 +318,42 @@ void cmOrderDirectories::AddRuntimeLibrary(std::string const& fullPath,
// Add the runtime library at most once.
if(this->EmmittedConstraintSOName.insert(fullPath).second)
{
+ std::string soname2 = soname ? soname : "";
// Implicit link directories need special handling.
if(!this->ImplicitDirectories.empty())
{
std::string dir = cmSystemTools::GetFilenamePath(fullPath);
+
+ if(fullPath.rfind(".framework") != std::string::npos)
+ {
+ cmsys::RegularExpression splitFramework;
+ splitFramework.compile("^(.*)/(.*).framework/(.*)/(.*)$");
+ if(splitFramework.find(fullPath) &&
+ (splitFramework.match(2) == splitFramework.match(4)))
+ {
+ dir = splitFramework.match(1);
+ soname2 = splitFramework.match(2);
+ soname2 += ".framework/";
+ soname2 += splitFramework.match(3);
+ soname2 += "/";
+ soname2 += splitFramework.match(4);
+ }
+ }
+
if(this->ImplicitDirectories.find(dir) !=
this->ImplicitDirectories.end())
{
this->ImplicitDirEntries.push_back(
- new cmOrderDirectoriesConstraintSOName(this, fullPath, soname));
+ new cmOrderDirectoriesConstraintSOName(this, fullPath,
+ soname2.c_str()));
return;
}
}
// Construct the runtime information entry for this library.
this->ConstraintEntries.push_back(
- new cmOrderDirectoriesConstraintSOName(this, fullPath, soname));
+ new cmOrderDirectoriesConstraintSOName(this, fullPath,
+ soname2.c_str()));
}
else
{
diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index a468fa7..350b462 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -309,6 +309,46 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
cmLocalGenerator::EscapeForCMake(_moc_headers.c_str()).c_str());
makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE");
+ const char *qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR");
+ if (!qtVersion)
+ {
+ qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
+ }
+ if (const char *targetQtVersion =
+ target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", 0))
+ {
+ qtVersion = targetQtVersion;
+ }
+ if (qtVersion)
+ {
+ makefile->AddDefinition("_target_qt_version", qtVersion);
+ }
+
+ {
+ const char *qtMoc = makefile->GetSafeDefinition("QT_MOC_EXECUTABLE");
+ makefile->AddDefinition("_qt_moc_executable", qtMoc);
+ }
+
+ if (strcmp(qtVersion, "5") == 0)
+ {
+ cmTarget *qt5Moc = makefile->FindTargetToUse("Qt5::moc");
+ if (!qt5Moc)
+ {
+ cmSystemTools::Error("Qt5::moc target not found ",
+ automocTargetName.c_str());
+ return;
+ }
+ makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation(0));
+ }
+ else
+ {
+ if (strcmp(qtVersion, "4") != 0)
+ {
+ cmSystemTools::Error("The CMAKE_AUTOMOC feature supports only Qt 4 and "
+ "Qt 5 ", automocTargetName.c_str());
+ }
+ }
+
const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
std::string inputFile = cmakeRoot;
inputFile += "/Modules/AutomocInfo.cmake.in";
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 67f3023..803d0da 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -2413,6 +2413,27 @@ bool cmSystemTools::GuessLibrarySOName(std::string const& fullPath,
}
//----------------------------------------------------------------------------
+bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath,
+ std::string& soname)
+{
+ std::vector<cmStdString> cmds;
+ cmds.push_back("otool");
+ cmds.push_back("-D");
+ cmds.push_back(fullPath.c_str());
+
+ std::string output;
+ RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE);
+
+ std::vector<std::string> strs = cmSystemTools::tokenize(output, "\n");
+ if(strs.size() == 2)
+ {
+ soname = strs[1];
+ return true;
+ }
+ return false;
+}
+
+//----------------------------------------------------------------------------
#if defined(CMAKE_USE_ELF_PARSER)
std::string::size_type cmSystemToolsFindRPath(std::string const& have,
std::string const& want)
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 8355d78..f5be26b 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -439,6 +439,10 @@ public:
static bool GuessLibrarySOName(std::string const& fullPath,
std::string& soname);
+ /** Try to guess the install name of a shared library. */
+ static bool GuessLibraryInstallName(std::string const& fullPath,
+ std::string& soname);
+
/** Try to set the RPATH in an ELF binary. */
static bool ChangeRPath(std::string const& file,
std::string const& oldRPath,
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 75873ff..f1d0ac3 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -130,31 +130,35 @@ public:
typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType;
SourceEntriesType SourceEntries;
- struct IncludeDirectoriesEntry {
- IncludeDirectoriesEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge,
+ struct TargetPropertyEntry {
+ TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge,
const std::string &targetName = std::string())
: ge(cge), TargetName(targetName)
{}
const cmsys::auto_ptr<cmCompiledGeneratorExpression> ge;
- std::vector<std::string> CachedIncludes;
+ std::vector<std::string> CachedEntries;
const std::string TargetName;
};
- std::vector<IncludeDirectoriesEntry*> IncludeDirectoriesEntries;
- std::vector<cmValueWithOrigin> LinkInterfaceIncludeDirectoriesEntries;
+ std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
+ std::vector<TargetPropertyEntry*> CompileOptionsEntries;
+ std::vector<cmValueWithOrigin> LinkInterfacePropertyEntries;
- std::map<std::string, std::vector<IncludeDirectoriesEntry*> >
+ std::map<std::string, std::vector<TargetPropertyEntry*> >
CachedLinkInterfaceIncludeDirectoriesEntries;
+ std::map<std::string, std::vector<TargetPropertyEntry*> >
+ CachedLinkInterfaceCompileOptionsEntries;
std::map<std::string, std::string> CachedLinkInterfaceCompileDefinitions;
std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone;
std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone;
+ std::map<std::string, bool> CacheLinkInterfaceCompileOptionsDone;
};
//----------------------------------------------------------------------------
void deleteAndClear(
- std::vector<cmTargetInternals::IncludeDirectoriesEntry*> &entries)
+ std::vector<cmTargetInternals::TargetPropertyEntry*> &entries)
{
- for (std::vector<cmTargetInternals::IncludeDirectoriesEntry*>::const_iterator
+ for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
it = entries.begin(),
end = entries.end();
it != end; ++it)
@@ -167,10 +171,10 @@ void deleteAndClear(
//----------------------------------------------------------------------------
void deleteAndClear(
std::map<std::string,
- std::vector<cmTargetInternals::IncludeDirectoriesEntry*> > &entries)
+ std::vector<cmTargetInternals::TargetPropertyEntry*> > &entries)
{
for (std::map<std::string,
- std::vector<cmTargetInternals::IncludeDirectoriesEntry*> >::iterator
+ std::vector<cmTargetInternals::TargetPropertyEntry*> >::iterator
it = entries.begin(), end = entries.end(); it != end; ++it)
{
deleteAndClear(it->second);
@@ -181,6 +185,7 @@ void deleteAndClear(
cmTargetInternals::~cmTargetInternals()
{
deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries);
+ deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries);
}
//----------------------------------------------------------------------------
@@ -199,6 +204,7 @@ cmTarget::cmTarget()
this->IsImportedTarget = false;
this->BuildInterfaceIncludesAppended = false;
this->DebugIncludesDone = false;
+ this->DebugCompileOptionsDone = false;
}
//----------------------------------------------------------------------------
@@ -287,6 +293,32 @@ void cmTarget::DefineProperties(cmake *cm)
"This is the configuration-specific version of COMPILE_DEFINITIONS.");
cm->DefineProperty
+ ("COMPILE_OPTIONS", cmProperty::TARGET,
+ "List of options to pass to the compiler.",
+ "This property specifies the list of options specified "
+ "so far for this property. "
+ "This property exists on targets only. "
+ "\n"
+ "The target property values are used by the generators to set "
+ "the options for the compiler.\n"
+ "Contents of COMPILE_OPTIONS may use \"generator expressions\" with "
+ "the syntax \"$<...>\". "
+ CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
+ CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
+
+ cm->DefineProperty
+ ("INTERFACE_COMPILE_OPTIONS", cmProperty::TARGET,
+ "List of interface options to pass to the compiler.",
+ "Targets may populate this property to publish the compile options "
+ "required to compile against the headers for the target. Consuming "
+ "targets can add entries to their own COMPILE_OPTIONS property such "
+ "as $<TARGET_PROPERTY:foo,INTERFACE_COMPILE_OPTIONS> to use the "
+ "compile options specified in the interface of 'foo'."
+ "\n"
+ CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
+ CM_DOCUMENT_LANGUAGE_GENERATOR_EXPRESSIONS);
+
+ cm->DefineProperty
("DEFINE_SYMBOL", cmProperty::TARGET,
"Define a symbol when compiling this target's sources.",
"DEFINE_SYMBOL sets the name of the preprocessor symbol defined when "
@@ -1186,6 +1218,15 @@ void cmTarget::DefineProperties(cmake *cm)
"hard-code all the settings instead of using the target properties.");
cm->DefineProperty
+ ("MACOSX_RPATH", cmProperty::TARGET,
+ "Whether to use rpaths on Mac OS X.",
+ "When this property is set to true, the directory portion of the"
+ "\"install_name\" field of shared libraries will default to \"@rpath\"."
+ "Runtime paths will also be embedded in binaries using this target."
+ "This property is initialized by the value of the variable "
+ "CMAKE_MACOSX_RPATH if it is set when a target is created.");
+
+ cm->DefineProperty
("ENABLE_EXPORTS", cmProperty::TARGET,
"Specify whether an executable exports symbols for loadable modules.",
"Normally an executable does not export any symbols because it is "
@@ -1328,6 +1369,11 @@ void cmTarget::DefineProperties(cmake *cm)
"this value with \"ManagedCProj\", for example, in a Visual "
"Studio managed C++ unit test project.");
cm->DefineProperty
+ ("VS_GLOBAL_ROOTNAMESPACE", cmProperty::TARGET,
+ "Visual Studio project root namespace.",
+ "Sets the \"RootNamespace\" attribute for a generated Visual Studio "
+ "project. The attribute will be generated only if this is set.");
+ cm->DefineProperty
("VS_DOTNET_REFERENCES", cmProperty::TARGET,
"Visual Studio managed project .NET references",
"Adds one or more semicolon-delimited .NET references to a "
@@ -1513,6 +1559,8 @@ void cmTarget::SetMakefile(cmMakefile* mf)
this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0);
this->SetPropertyDefault("WIN32_EXECUTABLE", 0);
this->SetPropertyDefault("MACOSX_BUNDLE", 0);
+ this->SetPropertyDefault("MACOSX_RPATH", 0);
+
// Collect the set of configuration types.
std::vector<std::string> configNames;
@@ -1683,6 +1731,13 @@ bool cmTarget::IsCFBundleOnApple()
}
//----------------------------------------------------------------------------
+bool cmTarget::IsBundleOnApple()
+{
+ return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() ||
+ this->IsCFBundleOnApple();
+}
+
+//----------------------------------------------------------------------------
class cmTargetTraceDependencies
{
public:
@@ -2728,7 +2783,18 @@ void cmTarget::SetProperty(const char* prop, const char* value)
deleteAndClear(this->Internal->IncludeDirectoriesEntries);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
this->Internal->IncludeDirectoriesEntries.push_back(
- new cmTargetInternals::IncludeDirectoriesEntry(cge));
+ new cmTargetInternals::TargetPropertyEntry(cge));
+ return;
+ }
+ if(strcmp(prop,"COMPILE_OPTIONS") == 0)
+ {
+ cmListFileBacktrace lfbt;
+ this->Makefile->GetBacktrace(lfbt);
+ cmGeneratorExpression ge(lfbt);
+ deleteAndClear(this->Internal->CompileOptionsEntries);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+ this->Internal->CompileOptionsEntries.push_back(
+ new cmTargetInternals::TargetPropertyEntry(cge));
return;
}
if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
@@ -2741,14 +2807,14 @@ void cmTarget::SetProperty(const char* prop, const char* value)
}
if (strcmp(prop, "LINK_LIBRARIES") == 0)
{
- this->Internal->LinkInterfaceIncludeDirectoriesEntries.clear();
+ this->Internal->LinkInterfacePropertyEntries.clear();
if (cmGeneratorExpression::IsValidTargetName(value)
|| cmGeneratorExpression::Find(value) != std::string::npos)
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
cmValueWithOrigin entry(value, lfbt);
- this->Internal->LinkInterfaceIncludeDirectoriesEntries.push_back(entry);
+ this->Internal->LinkInterfacePropertyEntries.push_back(entry);
}
// Fall through
}
@@ -2770,7 +2836,16 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
this->Makefile->GetBacktrace(lfbt);
cmGeneratorExpression ge(lfbt);
this->Internal->IncludeDirectoriesEntries.push_back(
- new cmTargetInternals::IncludeDirectoriesEntry(ge.Parse(value)));
+ new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
+ return;
+ }
+ if(strcmp(prop,"COMPILE_OPTIONS") == 0)
+ {
+ cmListFileBacktrace lfbt;
+ this->Makefile->GetBacktrace(lfbt);
+ cmGeneratorExpression ge(lfbt);
+ this->Internal->CompileOptionsEntries.push_back(
+ new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
return;
}
if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
@@ -2789,7 +2864,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
cmValueWithOrigin entry(value, lfbt);
- this->Internal->LinkInterfaceIncludeDirectoriesEntries.push_back(entry);
+ this->Internal->LinkInterfacePropertyEntries.push_back(entry);
}
// Fall through
}
@@ -2854,17 +2929,31 @@ void cmTarget::InsertInclude(const cmValueWithOrigin &entry,
{
cmGeneratorExpression ge(entry.Backtrace);
- std::vector<cmTargetInternals::IncludeDirectoriesEntry*>::iterator position
+ std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position
= before ? this->Internal->IncludeDirectoriesEntries.begin()
: this->Internal->IncludeDirectoriesEntries.end();
this->Internal->IncludeDirectoriesEntries.insert(position,
- new cmTargetInternals::IncludeDirectoriesEntry(ge.Parse(entry.Value)));
+ new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value)));
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::InsertCompileOption(const cmValueWithOrigin &entry,
+ bool before)
+{
+ cmGeneratorExpression ge(entry.Backtrace);
+
+ std::vector<cmTargetInternals::TargetPropertyEntry*>::iterator position
+ = before ? this->Internal->CompileOptionsEntries.begin()
+ : this->Internal->CompileOptionsEntries.end();
+
+ this->Internal->CompileOptionsEntries.insert(position,
+ new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry.Value)));
}
//----------------------------------------------------------------------------
static void processIncludeDirectories(cmTarget *tgt,
- const std::vector<cmTargetInternals::IncludeDirectoriesEntry*> &entries,
+ const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
std::vector<std::string> &includes,
std::set<std::string> &uniqueIncludes,
cmGeneratorExpressionDAGChecker *dagChecker,
@@ -2872,12 +2961,12 @@ static void processIncludeDirectories(cmTarget *tgt,
{
cmMakefile *mf = tgt->GetMakefile();
- for (std::vector<cmTargetInternals::IncludeDirectoriesEntry*>::const_iterator
+ for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
it = entries.begin(), end = entries.end(); it != end; ++it)
{
bool testIsOff = true;
bool cacheIncludes = false;
- std::vector<std::string> entryIncludes = (*it)->CachedIncludes;
+ std::vector<std::string> entryIncludes = (*it)->CachedEntries;
if(!entryIncludes.empty())
{
testIsOff = false;
@@ -2980,7 +3069,7 @@ static void processIncludeDirectories(cmTarget *tgt,
}
if (cacheIncludes)
{
- (*it)->CachedIncludes = entryIncludes;
+ (*it)->CachedEntries = entryIncludes;
}
if (!usedIncludes.empty())
{
@@ -3000,8 +3089,8 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config)
cmListFileBacktrace lfbt;
cmGeneratorExpressionDAGChecker dagChecker(lfbt,
- this->GetName(),
- "INCLUDE_DIRECTORIES", 0, 0);
+ this->GetName(),
+ "INCLUDE_DIRECTORIES", 0, 0);
this->AppendBuildInterfaceIncludes();
@@ -3036,8 +3125,8 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config)
if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[configString])
{
for (std::vector<cmValueWithOrigin>::const_iterator
- it = this->Internal->LinkInterfaceIncludeDirectoriesEntries.begin(),
- end = this->Internal->LinkInterfaceIncludeDirectoriesEntries.end();
+ it = this->Internal->LinkInterfacePropertyEntries.begin(),
+ end = this->Internal->LinkInterfacePropertyEntries.end();
it != end; ++it)
{
{
@@ -3066,7 +3155,7 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config)
this->Internal
->CachedLinkInterfaceIncludeDirectoriesEntries[configString].push_back(
- new cmTargetInternals::IncludeDirectoriesEntry(cge,
+ new cmTargetInternals::TargetPropertyEntry(cge,
it->Value));
}
}
@@ -3094,6 +3183,159 @@ std::vector<std::string> cmTarget::GetIncludeDirectories(const char *config)
}
//----------------------------------------------------------------------------
+static void processCompileOptions(cmTarget *tgt,
+ const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
+ std::vector<std::string> &options,
+ std::set<std::string> &uniqueOptions,
+ cmGeneratorExpressionDAGChecker *dagChecker,
+ const char *config, bool debugOptions)
+{
+ cmMakefile *mf = tgt->GetMakefile();
+
+ for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
+ it = entries.begin(), end = entries.end(); it != end; ++it)
+ {
+ bool cacheOptions = false;
+ std::vector<std::string> entryOptions = (*it)->CachedEntries;
+ if(entryOptions.empty())
+ {
+ cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
+ config,
+ false,
+ tgt,
+ dagChecker),
+ entryOptions);
+ if (mf->IsGeneratingBuildSystem()
+ && !(*it)->ge->GetHadContextSensitiveCondition())
+ {
+ cacheOptions = true;
+ }
+ }
+ std::string usedOptions;
+ for(std::vector<std::string>::iterator
+ li = entryOptions.begin(); li != entryOptions.end(); ++li)
+ {
+ std::string opt = *li;
+
+ if(uniqueOptions.insert(opt).second)
+ {
+ options.push_back(opt);
+ if (debugOptions)
+ {
+ usedOptions += " * " + opt + "\n";
+ }
+ }
+ }
+ if (cacheOptions)
+ {
+ (*it)->CachedEntries = entryOptions;
+ }
+ if (!usedOptions.empty())
+ {
+ mf->GetCMakeInstance()->IssueMessage(cmake::LOG,
+ std::string("Used compile options for target ")
+ + tgt->GetName() + ":\n"
+ + usedOptions, (*it)->ge->GetBacktrace());
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::GetCompileOptions(std::vector<std::string> &result,
+ const char *config)
+{
+ std::set<std::string> uniqueOptions;
+ cmListFileBacktrace lfbt;
+
+ cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+ 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->IsGeneratingBuildSystem())
+ {
+ this->DebugCompileOptionsDone = true;
+ }
+
+ processCompileOptions(this,
+ this->Internal->CompileOptionsEntries,
+ result,
+ uniqueOptions,
+ &dagChecker,
+ config,
+ debugOptions);
+
+ std::string configString = config ? config : "";
+ if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[configString])
+ {
+ for (std::vector<cmValueWithOrigin>::const_iterator
+ it = this->Internal->LinkInterfacePropertyEntries.begin(),
+ end = this->Internal->LinkInterfacePropertyEntries.end();
+ it != end; ++it)
+ {
+ {
+ cmGeneratorExpression ge(lfbt);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
+ ge.Parse(it->Value);
+ std::string targetResult = cge->Evaluate(this->Makefile, config,
+ false, this, 0, 0);
+ if (!this->Makefile->FindTargetToUse(targetResult.c_str()))
+ {
+ continue;
+ }
+ }
+ std::string optionGenex = "$<TARGET_PROPERTY:" +
+ it->Value + ",INTERFACE_COMPILE_OPTIONS>";
+ if (cmGeneratorExpression::Find(it->Value) != std::string::npos)
+ {
+ // Because it->Value is a generator expression, ensure that it
+ // evaluates to the non-empty string before being used in the
+ // TARGET_PROPERTY expression.
+ optionGenex = "$<$<BOOL:" + it->Value + ">:" + optionGenex + ">";
+ }
+ cmGeneratorExpression ge(it->Backtrace);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(
+ optionGenex);
+
+ this->Internal
+ ->CachedLinkInterfaceCompileOptionsEntries[configString].push_back(
+ new cmTargetInternals::TargetPropertyEntry(cge,
+ it->Value));
+ }
+ }
+
+ processCompileOptions(this,
+ this->Internal->CachedLinkInterfaceCompileOptionsEntries[configString],
+ result,
+ uniqueOptions,
+ &dagChecker,
+ config,
+ debugOptions);
+
+ if (!this->Makefile->IsGeneratingBuildSystem())
+ {
+ deleteAndClear(this->Internal->CachedLinkInterfaceCompileOptionsEntries);
+ }
+ else
+ {
+ this->Internal->CacheLinkInterfaceCompileOptionsDone[configString] = true;
+ }
+}
+
+//----------------------------------------------------------------------------
std::string cmTarget::GetCompileDefinitions(const char *config)
{
const char *configProp = 0;
@@ -3379,17 +3621,23 @@ const char* cmTarget::NormalGetLocation(const char* config)
// Now handle the deprecated build-time configuration location.
this->Location = this->GetDirectory();
- if(!this->Location.empty())
- {
- this->Location += "/";
- }
const char* cfgid = this->Makefile->GetDefinition("CMAKE_CFG_INTDIR");
if(cfgid && strcmp(cfgid, ".") != 0)
{
- this->Location += cfgid;
this->Location += "/";
+ this->Location += cfgid;
+ }
+
+ if(this->IsCFBundleOnApple() || this->IsAppBundleOnApple())
+ {
+ std::string macdir = this->BuildMacContentDirectory("", config, false);
+ if(!macdir.empty())
+ {
+ this->Location += "/";
+ this->Location += macdir;
+ }
}
- this->Location = this->BuildMacContentDirectory(this->Location, config);
+ this->Location += "/";
this->Location += this->GetFullName(config, false);
return this->Location.c_str();
}
@@ -3512,9 +3760,9 @@ const char *cmTarget::GetProperty(const char* prop,
static std::string output;
output = "";
std::string sep;
- typedef cmTargetInternals::IncludeDirectoriesEntry
- IncludeDirectoriesEntry;
- for (std::vector<IncludeDirectoriesEntry*>::const_iterator
+ typedef cmTargetInternals::TargetPropertyEntry
+ TargetPropertyEntry;
+ for (std::vector<TargetPropertyEntry*>::const_iterator
it = this->Internal->IncludeDirectoriesEntries.begin(),
end = this->Internal->IncludeDirectoriesEntries.end();
it != end; ++it)
@@ -3525,6 +3773,24 @@ const char *cmTarget::GetProperty(const char* prop,
}
return output.c_str();
}
+ if(strcmp(prop,"COMPILE_OPTIONS") == 0)
+ {
+ static std::string output;
+ output = "";
+ std::string sep;
+ typedef cmTargetInternals::TargetPropertyEntry
+ TargetPropertyEntry;
+ for (std::vector<TargetPropertyEntry*>::const_iterator
+ it = this->Internal->CompileOptionsEntries.begin(),
+ end = this->Internal->CompileOptionsEntries.end();
+ it != end; ++it)
+ {
+ output += sep;
+ output += (*it)->ge->GetInput();
+ sep = ";";
+ }
+ return output.c_str();
+ }
if (strcmp(prop,"IMPORTED") == 0)
{
@@ -3873,6 +4139,10 @@ std::string cmTarget::GetSOName(const char* config)
else
{
// Use the soname given if any.
+ if(info->SOName.find("@rpath/") == 0)
+ {
+ return info->SOName.substr(6);
+ }
return info->SOName;
}
}
@@ -3895,6 +4165,75 @@ std::string cmTarget::GetSOName(const char* config)
}
//----------------------------------------------------------------------------
+bool cmTarget::HasMacOSXRpath(const char* config)
+{
+ bool install_name_is_rpath = false;
+ bool macosx_rpath = this->GetPropertyAsBool("MACOSX_RPATH");
+
+ if(!this->IsImportedTarget)
+ {
+ const char* install_name = this->GetProperty("INSTALL_NAME_DIR");
+ bool use_install_name =
+ this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH");
+ if(install_name && use_install_name &&
+ std::string(install_name) == "@rpath")
+ {
+ install_name_is_rpath = true;
+ }
+ }
+ else
+ {
+ // Lookup the imported soname.
+ if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, this))
+ {
+ if(!info->NoSOName && !info->SOName.empty())
+ {
+ if(info->SOName.find("@rpath/") == 0)
+ {
+ install_name_is_rpath = true;
+ }
+ }
+ else
+ {
+ std::string install_name;
+ cmSystemTools::GuessLibraryInstallName(info->Location, install_name);
+ if(install_name.find("@rpath") != std::string::npos)
+ {
+ install_name_is_rpath = true;
+ }
+ }
+ }
+ }
+
+ if(!install_name_is_rpath && !macosx_rpath)
+ {
+ return false;
+ }
+
+ if(!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG"))
+ {
+ cmOStringStream w;
+ w << "Attempting to use";
+ if(macosx_rpath)
+ {
+ w << " MACOSX_RPATH";
+ }
+ else
+ {
+ w << " @rpath";
+ }
+ w << " without CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG being set.";
+ w << " This could be because you are using a Mac OS X version";
+ w << " less than 10.5 or because CMake's platform configuration is";
+ w << " corrupt.";
+ cmake* cm = this->Makefile->GetCMakeInstance();
+ cm->IssueMessage(cmake::FATAL_ERROR, w.str(), this->GetBacktrace());
+ }
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config)
{
if(this->IsImported() && this->GetType() == cmTarget::SHARED_LIBRARY)
@@ -3991,7 +4330,13 @@ std::string cmTarget::GetFullPath(const char* config, bool implib,
std::string cmTarget::NormalGetFullPath(const char* config, bool implib,
bool realname)
{
- std::string fpath = this->GetMacContentDirectory(config, implib);
+ std::string fpath = this->GetDirectory(config, implib);
+ fpath += "/";
+ if(this->IsCFBundleOnApple() || this->IsAppBundleOnApple())
+ {
+ fpath = this->BuildMacContentDirectory(fpath, config, false);
+ fpath += "/";
+ }
// Add the full name of the target.
if(implib)
@@ -4123,10 +4468,13 @@ void cmTarget::GetFullNameInternal(const char* config,
targetSuffix = this->Makefile->GetSafeDefinition(suffixVar);
}
- // frameworks do not have a prefix or a suffix
+ // frameworks have directory prefix but no suffix
+ std::string fw_prefix;
if(this->IsFrameworkOnApple())
{
- targetPrefix = 0;
+ fw_prefix = this->GetOutputName(config, false);
+ fw_prefix += ".framework/";
+ targetPrefix = fw_prefix.c_str();
targetSuffix = 0;
}
@@ -4206,13 +4554,24 @@ void cmTarget::GetLibraryNames(std::string& name,
// The library name.
name = prefix+base+suffix;
- // The library's soname.
- this->ComputeVersionedName(soName, prefix, base, suffix,
- name, soversion);
-
- // The library's real name on disk.
- this->ComputeVersionedName(realName, prefix, base, suffix,
- name, version);
+ if(this->IsFrameworkOnApple())
+ {
+ realName = prefix;
+ realName += "Versions/";
+ realName += this->GetFrameworkVersion();
+ realName += "/";
+ realName += base;
+ soName = realName;
+ }
+ else
+ {
+ // The library's soname.
+ this->ComputeVersionedName(soName, prefix, base, suffix,
+ name, soversion);
+ // The library's real name on disk.
+ this->ComputeVersionedName(realName, prefix, base, suffix,
+ name, version);
+ }
// The import library name.
if(this->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -4500,14 +4859,13 @@ bool cmTarget::NeedRelinkBeforeInstall(const char* config)
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetInstallNameDirForBuildTree(const char* config,
- bool for_xcode)
+std::string cmTarget::GetInstallNameDirForBuildTree(const char* config)
{
// If building directly for installation then the build tree install_name
// is the same as the install tree.
if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH"))
{
- return GetInstallNameDirForInstallTree(config, for_xcode);
+ return GetInstallNameDirForInstallTree();
}
// Use the build tree directory for the target.
@@ -4515,12 +4873,16 @@ std::string cmTarget::GetInstallNameDirForBuildTree(const char* config,
!this->Makefile->IsOn("CMAKE_SKIP_RPATH") &&
!this->GetPropertyAsBool("SKIP_BUILD_RPATH"))
{
- std::string dir = this->GetDirectory(config);
- dir += "/";
- if(this->IsFrameworkOnApple() && !for_xcode)
+ std::string dir;
+ if(this->GetPropertyAsBool("MACOSX_RPATH"))
{
- dir += this->GetFrameworkDirectory(config);
+ dir = "@rpath";
}
+ else
+ {
+ dir = this->GetDirectory(config);
+ }
+ dir += "/";
return dir;
}
else
@@ -4530,8 +4892,7 @@ std::string cmTarget::GetInstallNameDirForBuildTree(const char* config,
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetInstallNameDirForInstallTree(const char* config,
- bool for_xcode)
+std::string cmTarget::GetInstallNameDirForInstallTree()
{
if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
{
@@ -4547,12 +4908,10 @@ std::string cmTarget::GetInstallNameDirForInstallTree(const char* config,
dir += "/";
}
}
-
- if(this->IsFrameworkOnApple() && !for_xcode)
+ if(dir.empty() && this->GetPropertyAsBool("MACOSX_RPATH"))
{
- dir += this->GetFrameworkDirectory(config);
+ dir = "@rpath/";
}
-
return dir;
}
else
@@ -5134,7 +5493,6 @@ void cmTarget::GetLanguages(std::set<cmStdString>& languages) const
//----------------------------------------------------------------------------
bool cmTarget::IsChrpathUsed(const char* config)
{
-#if defined(CMAKE_USE_ELF_PARSER)
// Only certain target types have an rpath.
if(!(this->GetType() == cmTarget::SHARED_LIBRARY ||
this->GetType() == cmTarget::MODULE_LIBRARY ||
@@ -5168,6 +5526,12 @@ bool cmTarget::IsChrpathUsed(const char* config)
return false;
}
+ if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
+ {
+ return true;
+ }
+
+#if defined(CMAKE_USE_ELF_PARSER)
// Enable if the rpath flag uses a separator and the target uses ELF
// binaries.
if(const char* ll = this->GetLinkerLanguage(config, this))
@@ -6010,59 +6374,86 @@ cmTarget::GetLinkInformation(const char* config, cmTarget *head)
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetFrameworkDirectory(const char* config)
+std::string cmTarget::GetFrameworkDirectory(const char* config,
+ bool rootDir)
{
std::string fpath;
- fpath += this->GetFullName(config, false);
- fpath += ".framework/Versions/";
- fpath += this->GetFrameworkVersion();
- fpath += "/";
+ fpath += this->GetOutputName(config, false);
+ fpath += ".framework";
+ if(!rootDir)
+ {
+ fpath += "/Versions/";
+ fpath += this->GetFrameworkVersion();
+ }
+ return fpath;
+}
+
+//----------------------------------------------------------------------------
+std::string cmTarget::GetCFBundleDirectory(const char* config,
+ bool contentOnly)
+{
+ std::string fpath;
+ fpath += this->GetOutputName(config, false);
+ fpath += ".";
+ const char *ext = this->GetProperty("BUNDLE_EXTENSION");
+ if (!ext)
+ {
+ ext = "bundle";
+ }
+ fpath += ext;
+ fpath += "/Contents";
+ if(!contentOnly)
+ fpath += "/MacOS";
+ return fpath;
+}
+
+//----------------------------------------------------------------------------
+std::string cmTarget::GetAppBundleDirectory(const char* config,
+ bool contentOnly)
+{
+ std::string fpath = this->GetFullName(config, false);
+ fpath += ".app/Contents";
+ if(!contentOnly)
+ fpath += "/MacOS";
return fpath;
}
//----------------------------------------------------------------------------
std::string cmTarget::BuildMacContentDirectory(const std::string& base,
const char* config,
- bool includeMacOS)
+ bool contentOnly)
{
std::string fpath = base;
if(this->IsAppBundleOnApple())
{
- fpath += this->GetFullName(config, false);
- fpath += ".app/Contents/";
- if(includeMacOS)
- fpath += "MacOS/";
+ fpath += this->GetAppBundleDirectory(config, contentOnly);
}
if(this->IsFrameworkOnApple())
{
- fpath += this->GetFrameworkDirectory(config);
+ fpath += this->GetFrameworkDirectory(config, contentOnly);
}
if(this->IsCFBundleOnApple())
{
- fpath += this->GetFullName(config, false);
- fpath += ".";
- const char *ext = this->GetProperty("BUNDLE_EXTENSION");
- if (!ext)
- {
- ext = "bundle";
- }
- fpath += ext;
- fpath += "/Contents/";
- if(includeMacOS)
- fpath += "MacOS/";
+ fpath += this->GetCFBundleDirectory(config, contentOnly);
}
return fpath;
}
//----------------------------------------------------------------------------
std::string cmTarget::GetMacContentDirectory(const char* config,
- bool implib,
- bool includeMacOS)
+ bool implib)
{
// Start with the output directory for the target.
std::string fpath = this->GetDirectory(config, implib);
fpath += "/";
- fpath = this->BuildMacContentDirectory(fpath, config, includeMacOS);
+ bool contentOnly = true;
+ if(this->IsFrameworkOnApple())
+ {
+ // additional files with a framework go into the version specific
+ // directory
+ contentOnly = false;
+ }
+ fpath = this->BuildMacContentDirectory(fpath, config, contentOnly);
return fpath;
}
@@ -6109,6 +6500,7 @@ cmTargetInternalPointer
cmTargetInternalPointer::~cmTargetInternalPointer()
{
deleteAndClear(this->Pointer->IncludeDirectoriesEntries);
+ deleteAndClear(this->Pointer->CompileOptionsEntries);
delete this->Pointer;
}
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 508fc11..3bc0ab2 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -367,6 +367,9 @@ public:
/** Get the soname of the target. Allowed only for a shared library. */
std::string GetSOName(const char* config);
+ /** Whether this library has @rpath and platform supports it. */
+ bool HasMacOSXRpath(const char* config);
+
/** Test for special case of a third-party shared library that has
no soname at all. */
bool IsImportedSharedLibWithoutSOName(const char* config);
@@ -412,10 +415,14 @@ public:
/** Return true if builtin chrpath will work for this target */
bool IsChrpathUsed(const char* config);
- std::string GetInstallNameDirForBuildTree(const char* config,
- bool for_xcode = false);
- std::string GetInstallNameDirForInstallTree(const char* config,
- bool for_xcode = false);
+ /** Return the install name directory for the target in the
+ * build tree. For example: "@rpath/", "@loader_path/",
+ * or "/full/path/to/library". */
+ std::string GetInstallNameDirForBuildTree(const char* config);
+
+ /** Return the install name directory for the target in the
+ * install tree. For example: "@rpath/" or "@loader_path/". */
+ std::string GetInstallNameDirForInstallTree();
cmComputeLinkInformation* GetLinkInformation(const char* config,
cmTarget *head = 0);
@@ -467,6 +474,10 @@ public:
/** Return whether this target is an executable Bundle on Apple. */
bool IsAppBundleOnApple();
+ /** Return whether this target is an executable Bundle, a framework
+ or CFBundle on Apple. */
+ bool IsBundleOnApple();
+
/** Return the framework version string. Undefined if
IsFrameworkOnApple returns false. */
std::string GetFrameworkVersion();
@@ -481,28 +492,33 @@ public:
directory. */
bool UsesDefaultOutputDir(const char* config, bool implib);
- /** Append to @a base the mac content directory and return it. */
- std::string BuildMacContentDirectory(const std::string& base,
- const char* config = 0,
- bool includeMacOS = true);
-
/** @return the mac content directory for this target. */
- std::string GetMacContentDirectory(const char* config = 0,
- bool implib = false,
- bool includeMacOS = true);
+ std::string GetMacContentDirectory(const char* config,
+ bool implib);
/** @return whether this target have a well defined output file name. */
bool HaveWellDefinedOutputFiles();
/** @return the Mac framework directory without the base. */
- std::string GetFrameworkDirectory(const char* config = 0);
+ std::string GetFrameworkDirectory(const char* config, bool rootDir);
+
+ /** @return the Mac CFBundle directory without the base */
+ std::string GetCFBundleDirectory(const char* config, bool contentOnly);
+
+ /** @return the Mac App directory without the base */
+ std::string GetAppBundleDirectory(const char* config, bool contentOnly);
std::vector<std::string> GetIncludeDirectories(const char *config);
void InsertInclude(const cmValueWithOrigin &entry,
bool before = false);
+ void InsertCompileOption(const cmValueWithOrigin &entry,
+ bool before = false);
void AppendBuildInterfaceIncludes();
+ void GetCompileOptions(std::vector<std::string> &result,
+ const char *config);
+
bool IsNullImpliedByLinkLibraries(const std::string &p);
bool IsLinkInterfaceDependentBoolProperty(const std::string &p,
const char *config);
@@ -601,6 +617,11 @@ private:
the same as GetFullName. */
std::string NormalGetRealName(const char* config);
+ /** Append to @a base the mac content directory and return it. */
+ std::string BuildMacContentDirectory(const std::string& base,
+ const char* config,
+ bool contentOnly);
+
private:
std::string Name;
std::vector<cmCustomCommand> PreBuildCommands;
@@ -627,6 +648,7 @@ private:
bool IsApple;
bool IsImportedTarget;
bool DebugIncludesDone;
+ bool DebugCompileOptionsDone;
mutable std::set<std::string> LinkImplicitNullProperties;
bool BuildInterfaceIncludesAppended;
diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx
new file mode 100644
index 0000000..e80c845
--- /dev/null
+++ b/Source/cmTargetCompileOptionsCommand.cxx
@@ -0,0 +1,62 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2013 Stephen Kelly <steveire@gmail.com>
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#include "cmTargetCompileOptionsCommand.h"
+
+bool cmTargetCompileOptionsCommand
+::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+{
+ return this->HandleArguments(args, "COMPILE_OPTIONS", PROCESS_BEFORE);
+}
+
+void cmTargetCompileOptionsCommand
+::HandleImportedTarget(const std::string &tgt)
+{
+ cmOStringStream e;
+ e << "Cannot specify compile options for imported target \""
+ << tgt << "\".";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+}
+
+void cmTargetCompileOptionsCommand
+::HandleMissingTarget(const std::string &name)
+{
+ cmOStringStream e;
+ e << "Cannot specify compile options for target \"" << name << "\" "
+ "which is not built by this project.";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+}
+
+//----------------------------------------------------------------------------
+std::string cmTargetCompileOptionsCommand
+::Join(const std::vector<std::string> &content)
+{
+ std::string defs;
+ std::string sep;
+ for(std::vector<std::string>::const_iterator it = content.begin();
+ it != content.end(); ++it)
+ {
+ defs += sep + *it;
+ sep = ";";
+ }
+ return defs;
+}
+
+//----------------------------------------------------------------------------
+void cmTargetCompileOptionsCommand
+::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
+ bool)
+{
+ cmListFileBacktrace lfbt;
+ this->Makefile->GetBacktrace(lfbt);
+ cmValueWithOrigin entry(this->Join(content), lfbt);
+ tgt->InsertCompileOption(entry);
+}
diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h
new file mode 100644
index 0000000..87fa1a7
--- /dev/null
+++ b/Source/cmTargetCompileOptionsCommand.h
@@ -0,0 +1,90 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2013 Stephen Kelly <steveire@gmail.com>
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#ifndef cmTargetCompileOptionsCommand_h
+#define cmTargetCompileOptionsCommand_h
+
+#include "cmTargetPropCommandBase.h"
+
+class cmTargetCompileOptionsCommand : public cmTargetPropCommandBase
+{
+public:
+ /**
+ * This is a virtual constructor for the command.
+ */
+ virtual cmCommand* Clone()
+ {
+ return new cmTargetCompileOptionsCommand;
+ }
+
+ /**
+ * This is called when the command is first encountered in
+ * the CMakeLists.txt file.
+ */
+ virtual bool InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus &status);
+
+ /**
+ * The name of the command as specified in CMakeList.txt.
+ */
+ virtual const char* GetName() const { return "target_compile_options";}
+
+ /**
+ * Succinct documentation.
+ */
+ virtual const char* GetTerseDocumentation() const
+ {
+ return
+ "Add compile options to a target.";
+ }
+
+ /**
+ * More documentation.
+ */
+ virtual const char* GetFullDocumentation() const
+ {
+ return
+ " target_compile_options(<target> [BEFORE] "
+ "<INTERFACE|PUBLIC|PRIVATE> [items1...]\n"
+ " [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])\n"
+ "Specify compile options to use when compiling a given target. "
+ "The named <target> must have been created by a command such as "
+ "add_executable or add_library and must not be an IMPORTED target. "
+ "If BEFORE is specified, the content will be prepended to the property "
+ "instead of being appended.\n"
+ "The INTERFACE, PUBLIC and PRIVATE keywords are required to specify "
+ "the scope of the following arguments. PRIVATE and PUBLIC items will "
+ "populate the COMPILE_OPTIONS property of <target>. PUBLIC and "
+ "INTERFACE items will populate the INTERFACE_COMPILE_OPTIONS "
+ "property of <target>. "
+ "The following arguments specify compile opitions. "
+ "Repeated calls for the same <target> append items in the order called."
+ "\n"
+ "Arguments to target_compile_options may use \"generator "
+ "expressions\" with the syntax \"$<...>\". "
+ CM_DOCUMENT_COMMAND_GENERATOR_EXPRESSIONS
+ ;
+ }
+
+ cmTypeMacro(cmTargetCompileOptionsCommand, cmTargetPropCommandBase);
+
+private:
+ virtual void HandleImportedTarget(const std::string &tgt);
+ virtual void HandleMissingTarget(const std::string &name);
+
+ virtual void HandleDirectContent(cmTarget *tgt,
+ const std::vector<std::string> &content,
+ bool prepend);
+ virtual std::string Join(const std::vector<std::string> &content);
+};
+
+#endif
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 88c4deb..f8de3a8 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -262,6 +262,15 @@ void cmVisualStudio10TargetGenerator::Generate()
"</Keyword>\n";
}
+ const char* vsGlobalRootNamespace =
+ this->Target->GetProperty("VS_GLOBAL_ROOTNAMESPACE");
+ if(vsGlobalRootNamespace)
+ {
+ this->WriteString("<RootNamespace>", 2);
+ (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalRootNamespace) <<
+ "</RootNamespace>\n";
+ }
+
this->WriteString("<Platform>", 2);
(*this->BuildFileStream) << this->Platform << "</Platform>\n";
const char* projLabel = this->Target->GetProperty("PROJECT_LABEL");
@@ -1261,8 +1270,12 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
flags += " /TP ";
}
}
+
+ std::string targetFlags;
+ this->LocalGenerator->GetCompileOptions(targetFlags, this->Target,
+ configName.c_str());
// Add the target-specific flags.
- if(const char* targetFlags = this->Target->GetProperty("COMPILE_FLAGS"))
+ if(!targetFlags.empty())
{
flags += " ";
flags += targetFlags;
diff --git a/Tests/BundleUtilities/CMakeLists.txt b/Tests/BundleUtilities/CMakeLists.txt
index 8f24afe..5cc7071 100644
--- a/Tests/BundleUtilities/CMakeLists.txt
+++ b/Tests/BundleUtilities/CMakeLists.txt
@@ -12,8 +12,7 @@ add_library(shared2 SHARED shared2.cpp shared2.h)
# a framework library
add_library(framework SHARED framework.cpp framework.h)
-# TODO: fix problems with local frameworks without rpaths
-#set_target_properties(framework PROPERTIES FRAMEWORK 1)
+set_target_properties(framework PROPERTIES FRAMEWORK 1)
# make sure rpaths are not helping BundleUtilities or the executables
set_target_properties(shared shared2 framework PROPERTIES
diff --git a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt
new file mode 100644
index 0000000..06a48fb
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt
@@ -0,0 +1,35 @@
+
+cmake_minimum_required(VERSION 2.8)
+
+project(target_compile_options)
+
+add_executable(target_compile_options
+ "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
+)
+target_compile_options(target_compile_options
+ PRIVATE $<$<CXX_COMPILER_ID:GNU>:-DMY_PRIVATE_DEFINE>
+ PUBLIC $<$<CXX_COMPILER_ID:GNU>:-DMY_PUBLIC_DEFINE>
+ INTERFACE $<$<CXX_COMPILER_ID:GNU>:-DMY_INTERFACE_DEFINE>
+)
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ target_compile_definitions(target_compile_options
+ PRIVATE
+ "DO_GNU_TESTS"
+ )
+endif()
+
+add_executable(consumer
+ "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp"
+)
+
+target_compile_options(consumer
+ PRIVATE $<$<CXX_COMPILER_ID:GNU>:$<TARGET_PROPERTY:target_compile_options,INTERFACE_COMPILE_OPTIONS>>
+)
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ target_compile_definitions(consumer
+ PRIVATE
+ "DO_GNU_TESTS"
+ )
+endif()
diff --git a/Tests/CMakeCommands/target_compile_options/consumer.cpp b/Tests/CMakeCommands/target_compile_options/consumer.cpp
new file mode 100644
index 0000000..1299606
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_options/consumer.cpp
@@ -0,0 +1,18 @@
+
+#ifdef DO_GNU_TESTS
+
+# ifdef MY_PRIVATE_DEFINE
+# error Unexpected MY_PRIVATE_DEFINE
+# endif
+
+# ifndef MY_PUBLIC_DEFINE
+# error Expected MY_PUBLIC_DEFINE
+# endif
+
+# ifndef MY_INTERFACE_DEFINE
+# error Expected MY_INTERFACE_DEFINE
+# endif
+
+#endif
+
+int main() { return 0; }
diff --git a/Tests/CMakeCommands/target_compile_options/main.cpp b/Tests/CMakeCommands/target_compile_options/main.cpp
new file mode 100644
index 0000000..961c06d
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_options/main.cpp
@@ -0,0 +1,18 @@
+
+#ifdef DO_GNU_TESTS
+
+# ifndef MY_PRIVATE_DEFINE
+# error Expected MY_PRIVATE_DEFINE
+# endif
+
+# ifndef MY_PUBLIC_DEFINE
+# error Expected MY_PUBLIC_DEFINE
+# endif
+
+# ifdef MY_INTERFACE_DEFINE
+# error Unexpected MY_INTERFACE_DEFINE
+# endif
+
+#endif
+
+int main() { return 0; }
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 0b221e8..ee6c3e6 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -245,6 +245,7 @@ if(BUILD_TESTING)
ADD_TEST_MACRO(PolicyScope PolicyScope)
ADD_TEST_MACRO(EmptyLibrary EmptyLibrary)
ADD_TEST_MACRO(CompileDefinitions CompileDefinitions)
+ ADD_TEST_MACRO(CompileOptions CompileOptions)
ADD_TEST_MACRO(CompatibleInterface CompatibleInterface)
set_tests_properties(EmptyLibrary PROPERTIES
PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target:test")
@@ -1044,6 +1045,20 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
--test-command ${CMAKE_CTEST_COMMAND} -V
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4Targets")
+
+ if(Qt5Widgets_FOUND AND NOT Qt5Widgets_VERSION VERSION_LESS 5.1.0)
+ add_test(Qt4And5Automoc ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/Qt4And5Automoc"
+ "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc"
+ ${build_generator_args}
+ --build-project Qt4And5Automoc
+ --build-exe-dir "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc"
+ --force-new-ctest-process
+ --test-command ${CMAKE_CTEST_COMMAND} -V
+ )
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Qt4And5Automoc")
+ endif()
endif()
add_test(ExternalProject ${CMAKE_CTEST_COMMAND}
@@ -1233,6 +1248,16 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
endif()
endif()
+ if(APPLE AND "${DARWIN_MAJOR_VERSION}" GREATER 9)
+ add_test(MacRuntimePath ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/MacRuntimePath"
+ "${CMake_BINARY_DIR}/Tests/MacRuntimePath"
+ ${build_generator_args}
+ --build-project MacRuntimePath
+ )
+ endif()
+
add_test(linkorder1 ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/LinkLineOrder"
@@ -1966,6 +1991,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries)
ADD_TEST_MACRO(CMakeCommands.target_include_directories target_include_directories)
ADD_TEST_MACRO(CMakeCommands.target_compile_definitions target_compile_definitions)
+ ADD_TEST_MACRO(CMakeCommands.target_compile_options target_compile_options)
configure_file(
"${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in"
diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt
new file mode 100644
index 0000000..6d8a96a
--- /dev/null
+++ b/Tests/CompileOptions/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 2.8)
+
+project(CompileOptions)
+
+add_library(testlib other.cpp)
+
+add_executable(CompileOptions main.cpp)
+set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:GNU>:-DTEST_DEFINE>")
+target_link_libraries(CompileOptions testlib)
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+ target_compile_definitions(CompileOptions
+ PRIVATE
+ "DO_GNU_TESTS"
+ )
+endif()
diff --git a/Tests/CompileOptions/main.cpp b/Tests/CompileOptions/main.cpp
new file mode 100644
index 0000000..0d39050
--- /dev/null
+++ b/Tests/CompileOptions/main.cpp
@@ -0,0 +1,11 @@
+
+#ifdef DO_GNU_TESTS
+# ifndef TEST_DEFINE
+# error Expected TEST_DEFINE
+# endif
+#endif
+
+int main(int argc, char **argv)
+{
+ return 0;
+}
diff --git a/Tests/CompileOptions/other.cpp b/Tests/CompileOptions/other.cpp
new file mode 100644
index 0000000..0e34375
--- /dev/null
+++ b/Tests/CompileOptions/other.cpp
@@ -0,0 +1,5 @@
+
+void foo(void)
+{
+
+}
diff --git a/Tests/MacRuntimePath/A/CMakeLists.txt b/Tests/MacRuntimePath/A/CMakeLists.txt
new file mode 100644
index 0000000..6e6de42
--- /dev/null
+++ b/Tests/MacRuntimePath/A/CMakeLists.txt
@@ -0,0 +1,63 @@
+cmake_minimum_required(VERSION 2.8)
+project(MacRuntimePath_A)
+
+# a shared library
+add_library(shared SHARED shared.cpp shared.h)
+set_target_properties(shared PROPERTIES MACOSX_RPATH 1)
+
+# a shared library with custom set @rpath
+add_library(shared2 SHARED shared.cpp shared.h)
+set_target_properties(shared2 PROPERTIES
+ BUILD_WITH_INSTALL_RPATH 1 INSTALL_NAME_DIR "@rpath")
+
+# a framework library
+add_library(framework SHARED framework.cpp framework.h)
+set_target_properties(framework PROPERTIES MACOSX_RPATH 1 FRAMEWORK 1)
+
+# executable to test a shared library dependency with install rpaths
+add_executable(test1 test1.cpp)
+target_link_libraries(test1 shared)
+set_target_properties(test1 PROPERTIES
+ BUILD_WITH_INSTALL_RPATH 1 INSTALL_RPATH "@loader_path/../lib")
+
+# executable to test a framework library dependency with install rpaths
+add_executable(test2 test2.cpp)
+target_link_libraries(test2 framework)
+set_target_properties(test2 PROPERTIES
+ BUILD_WITH_INSTALL_RPATH 1 INSTALL_RPATH "@loader_path/../lib")
+
+# executable to test a framework library dependency with build tree rpaths
+add_executable(test3 test3.cpp)
+target_link_libraries(test3 framework)
+
+# executable to test a framework library dependency with build tree rpaths
+add_executable(test4 test1.cpp)
+target_link_libraries(test4 shared2)
+
+set_target_properties(shared shared2 framework PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
+set_target_properties(test1 test2 test3 test4 PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
+foreach(config ${CMAKE_CONFIGURATION_TYPES})
+ string(TOUPPER ${config} CONFIG)
+ set_target_properties(shared shared2 framework PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY_${CONFIG}
+ "${CMAKE_CURRENT_BINARY_DIR}/${config}/lib")
+ set_target_properties(test1 test2 test3 test4 PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY_${CONFIG}
+ "${CMAKE_CURRENT_BINARY_DIR}/${config}/bin")
+endforeach()
+
+foreach(test test1 test2 test3 test4)
+ add_custom_target(${test}_run ALL
+ COMMAND ${test}
+ DEPENDS ${test}
+ )
+endforeach()
+
+export(TARGETS shared shared2 framework FILE "${CMAKE_CURRENT_BINARY_DIR}/exp.cmake")
+
+install(TARGETS shared EXPORT MyExport DESTINATION lib)
+install(TARGETS shared2 EXPORT MyExport DESTINATION lib2)
+install(TARGETS framework EXPORT MyExport DESTINATION lib-fw)
+install(EXPORT MyExport DESTINATION lib FILE exp.cmake)
diff --git a/Tests/MacRuntimePath/A/framework.cpp b/Tests/MacRuntimePath/A/framework.cpp
new file mode 100644
index 0000000..abda195
--- /dev/null
+++ b/Tests/MacRuntimePath/A/framework.cpp
@@ -0,0 +1,8 @@
+
+#include "framework.h"
+#include "stdio.h"
+
+void framework()
+{
+ printf("framework\n");
+}
diff --git a/Tests/MacRuntimePath/A/framework.h b/Tests/MacRuntimePath/A/framework.h
new file mode 100644
index 0000000..bdd10f0
--- /dev/null
+++ b/Tests/MacRuntimePath/A/framework.h
@@ -0,0 +1,17 @@
+
+#ifndef framework_h
+#define framework_h
+
+#ifdef WIN32
+# ifdef framework_EXPORTS
+# define FRAMEWORK_EXPORT __declspec(dllexport)
+# else
+# define FRAMEWORK_EXPORT __declspec(dllimport)
+# endif
+#else
+# define FRAMEWORK_EXPORT
+#endif
+
+void FRAMEWORK_EXPORT framework();
+
+#endif
diff --git a/Tests/MacRuntimePath/A/shared.cpp b/Tests/MacRuntimePath/A/shared.cpp
new file mode 100644
index 0000000..e5e7dc5
--- /dev/null
+++ b/Tests/MacRuntimePath/A/shared.cpp
@@ -0,0 +1,8 @@
+
+#include "shared.h"
+#include "stdio.h"
+
+void shared()
+{
+ printf("shared\n");
+}
diff --git a/Tests/MacRuntimePath/A/shared.h b/Tests/MacRuntimePath/A/shared.h
new file mode 100644
index 0000000..3588fb8
--- /dev/null
+++ b/Tests/MacRuntimePath/A/shared.h
@@ -0,0 +1,17 @@
+
+#ifndef shared_h
+#define shared_h
+
+#ifdef WIN32
+# ifdef shared_EXPORTS
+# define SHARED_EXPORT __declspec(dllexport)
+# else
+# define SHARED_EXPORT __declspec(dllimport)
+# endif
+#else
+# define SHARED_EXPORT
+#endif
+
+void SHARED_EXPORT shared();
+
+#endif
diff --git a/Tests/MacRuntimePath/A/test1.cpp b/Tests/MacRuntimePath/A/test1.cpp
new file mode 100644
index 0000000..cb93448
--- /dev/null
+++ b/Tests/MacRuntimePath/A/test1.cpp
@@ -0,0 +1,8 @@
+
+#include "shared.h"
+
+int main(int, char**)
+{
+ shared();
+ return 0;
+}
diff --git a/Tests/MacRuntimePath/A/test2.cpp b/Tests/MacRuntimePath/A/test2.cpp
new file mode 100644
index 0000000..26bc9dd
--- /dev/null
+++ b/Tests/MacRuntimePath/A/test2.cpp
@@ -0,0 +1,8 @@
+
+#include "framework.h"
+
+int main(int, char**)
+{
+ framework();
+ return 0;
+}
diff --git a/Tests/MacRuntimePath/A/test3.cpp b/Tests/MacRuntimePath/A/test3.cpp
new file mode 100644
index 0000000..26bc9dd
--- /dev/null
+++ b/Tests/MacRuntimePath/A/test3.cpp
@@ -0,0 +1,8 @@
+
+#include "framework.h"
+
+int main(int, char**)
+{
+ framework();
+ return 0;
+}
diff --git a/Tests/MacRuntimePath/B/CMakeLists.txt b/Tests/MacRuntimePath/B/CMakeLists.txt
new file mode 100644
index 0000000..c361620
--- /dev/null
+++ b/Tests/MacRuntimePath/B/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 2.8)
+project(MacRuntimePath_B)
+
+include(${MacRuntimePath_B_BINARY_DIR}/../Root/lib/exp.cmake)
+
+add_executable(testb ${MacRuntimePath_B_SOURCE_DIR}/../A/test3.cpp)
+
+# test link with rpath enabled targets
+target_link_libraries(testb shared framework)
+
+# test link with rpath enabled library by filename
+target_link_libraries(testb $<TARGET_LINKER_FILE:shared2> framework)
+
+add_custom_target(testb_run ALL
+ COMMAND testb
+ DEPENDS testb
+ )
diff --git a/Tests/MacRuntimePath/CMakeLists.txt b/Tests/MacRuntimePath/CMakeLists.txt
new file mode 100644
index 0000000..5e5b6c4
--- /dev/null
+++ b/Tests/MacRuntimePath/CMakeLists.txt
@@ -0,0 +1,72 @@
+cmake_minimum_required (VERSION 2.8)
+project(MacRuntimePath)
+
+
+# Wipe out the install tree to make sure the exporter works.
+add_custom_command(
+ OUTPUT ${MacRuntimePath_BINARY_DIR}/CleanupProject
+ COMMAND ${CMAKE_COMMAND} -E remove_directory ${MacRuntimePath_BINARY_DIR}/Root
+ )
+add_custom_target(CleanupTarget ALL DEPENDS ${MacRuntimePath_BINARY_DIR}/CleanupProject)
+set_property(
+ SOURCE ${MacRuntimePath_BINARY_DIR}/CleanupProject
+ PROPERTY SYMBOLIC 1
+ )
+
+configure_file(${MacRuntimePath_SOURCE_DIR}/InitialCache.cmake.in
+ ${MacRuntimePath_BINARY_DIR}/InitialCache.cmake @ONLY)
+
+if(CMAKE_CONFIGURATION_TYPES)
+ set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}")
+else()
+ if(CMAKE_BUILD_TYPE)
+ set(NESTED_CONFIG_TYPE -C "${CMAKE_BUILD_TYPE}")
+ else()
+ set(NESTED_CONFIG_TYPE)
+ endif()
+endif()
+
+# Build and install the exporter.
+add_custom_command(
+ OUTPUT ${MacRuntimePath_BINARY_DIR}/ExportProject
+ COMMAND ${CMAKE_CTEST_COMMAND} ${NESTED_CONFIG_TYPE}
+ --build-and-test
+ ${MacRuntimePath_SOURCE_DIR}/A
+ ${MacRuntimePath_BINARY_DIR}/A
+ --build-noclean
+ --build-project MacRuntimePath_A
+ --build-target install
+ --build-generator ${CMAKE_GENERATOR}
+ --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
+ --build-makeprogram ${CMAKE_MAKE_PROGRAM}
+ --build-options -C${MacRuntimePath_BINARY_DIR}/InitialCache.cmake
+ VERBATIM
+ )
+add_custom_target(ExportTarget ALL DEPENDS ${MacRuntimePath_BINARY_DIR}/ExportProject)
+add_dependencies(ExportTarget CleanupTarget)
+set_property(
+ SOURCE ${MacRuntimePath_BINARY_DIR}/ExportProject
+ PROPERTY SYMBOLIC 1
+ )
+
+# Build the importer.
+add_custom_command(
+ OUTPUT ${MacRuntimePath_BINARY_DIR}/ImportProject
+ COMMAND ${CMAKE_CTEST_COMMAND} ${NESTED_CONFIG_TYPE}
+ --build-and-test
+ ${MacRuntimePath_SOURCE_DIR}/B
+ ${MacRuntimePath_BINARY_DIR}/B
+ --build-noclean
+ --build-project MacRuntimePath_B
+ --build-generator ${CMAKE_GENERATOR}
+ --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
+ --build-makeprogram ${CMAKE_MAKE_PROGRAM}
+ --build-options -C${MacRuntimePath_BINARY_DIR}/InitialCache.cmake
+ VERBATIM
+ )
+add_custom_target(ImportTarget ALL DEPENDS ${MacRuntimePath_BINARY_DIR}/ImportProject)
+add_dependencies(ImportTarget ExportTarget)
+set_property(
+ SOURCE ${MacRuntimePath_BINARY_DIR}/ImportProject
+ PROPERTY SYMBOLIC 1
+ )
diff --git a/Tests/MacRuntimePath/InitialCache.cmake.in b/Tests/MacRuntimePath/InitialCache.cmake.in
new file mode 100644
index 0000000..be15eb3
--- /dev/null
+++ b/Tests/MacRuntimePath/InitialCache.cmake.in
@@ -0,0 +1,13 @@
+set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@" CACHE STRING "C Compiler")
+set(CMAKE_C_FLAGS "@CMAKE_C_FLAGS@" CACHE STRING "C Flags")
+set(CMAKE_C_FLAGS_DEBUG "@CMAKE_C_FLAGS_DEBUG@" CACHE STRING "C Flags")
+set(CMAKE_C_FLAGS_RELEASE "@CMAKE_C_FLAGS_RELEASE@" CACHE STRING "C Flags")
+set(CMAKE_C_FLAGS_MINSIZEREL "@CMAKE_C_FLAGS_MINSIZEREL@" CACHE STRING "C Flags")
+set(CMAKE_C_FLAGS_RELWITHDEBINFO "@CMAKE_C_FLAGS_RELWITHDEBINFO@" CACHE STRING "C Flags")
+set(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@" CACHE STRING "C++ Compiler")
+set(CMAKE_CXX_FLAGS "@CMAKE_CXX_FLAGS@" CACHE STRING "C++ Flags")
+set(CMAKE_CXX_FLAGS_DEBUG "@CMAKE_CXX_FLAGS_DEBUG@" CACHE STRING "C++ Flags")
+set(CMAKE_CXX_FLAGS_RELEASE "@CMAKE_CXX_FLAGS_RELEASE@" CACHE STRING "C++ Flags")
+set(CMAKE_CXX_FLAGS_MINSIZEREL "@CMAKE_CXX_FLAGS_MINSIZEREL@" CACHE STRING "C++ Flags")
+set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@" CACHE STRING "C++ Flags")
+set(CMAKE_INSTALL_PREFIX "@MacRuntimePath_BINARY_DIR@/Root" CACHE STRING "Installation Prefix")
diff --git a/Tests/Qt4And5Automoc/CMakeLists.txt b/Tests/Qt4And5Automoc/CMakeLists.txt
new file mode 100644
index 0000000..0cc80fe
--- /dev/null
+++ b/Tests/Qt4And5Automoc/CMakeLists.txt
@@ -0,0 +1,13 @@
+
+project(Qt4And5Automoc)
+
+find_package(Qt4 REQUIRED)
+find_package(Qt5Core REQUIRED)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+add_executable(qt4_exe main_qt4.cpp)
+target_link_libraries(qt4_exe Qt4::QtCore)
+add_executable(qt5_exe main_qt5.cpp)
+target_link_libraries(qt5_exe Qt5::Core)
diff --git a/Tests/Qt4And5Automoc/main.cpp b/Tests/Qt4And5Automoc/main.cpp
new file mode 100644
index 0000000..00fd641
--- /dev/null
+++ b/Tests/Qt4And5Automoc/main.cpp
@@ -0,0 +1,18 @@
+
+#include <QObject>
+
+class SomeObject : public QObject
+{
+ Q_OBJECT
+public:
+ explicit SomeObject(QObject *parent = 0)
+ : QObject(parent)
+ {
+
+ }
+};
+
+int main(int argc, char **argv)
+{
+ return 0;
+}
diff --git a/Tests/Qt4And5Automoc/main_qt4.cpp b/Tests/Qt4And5Automoc/main_qt4.cpp
new file mode 100644
index 0000000..a84ce89
--- /dev/null
+++ b/Tests/Qt4And5Automoc/main_qt4.cpp
@@ -0,0 +1,4 @@
+
+#include "main.cpp"
+
+#include "main_qt4.moc"
diff --git a/Tests/Qt4And5Automoc/main_qt5.cpp b/Tests/Qt4And5Automoc/main_qt5.cpp
new file mode 100644
index 0000000..287b261
--- /dev/null
+++ b/Tests/Qt4And5Automoc/main_qt5.cpp
@@ -0,0 +1,4 @@
+
+#include "main.cpp"
+
+#include "main_qt5.moc"
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 66f86b6..f1e01b1 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -76,6 +76,7 @@ add_RunCMake_test(if)
add_RunCMake_test(include)
add_RunCMake_test(include_directories)
add_RunCMake_test(list)
+add_RunCMake_test(try_compile)
add_RunCMake_test(CMP0004)
find_package(Qt4 QUIET)
diff --git a/Tests/RunCMake/try_compile/BadLinkLibraries-result.txt b/Tests/RunCMake/try_compile/BadLinkLibraries-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/BadLinkLibraries-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/BadLinkLibraries-stderr.txt b/Tests/RunCMake/try_compile/BadLinkLibraries-stderr.txt
new file mode 100644
index 0000000..eceffec
--- /dev/null
+++ b/Tests/RunCMake/try_compile/BadLinkLibraries-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at BadLinkLibraries.cmake:2 \(try_compile\):
+ Only libraries may be used as try_compile IMPORTED LINK_LIBRARIES. Got
+ not_a_library of type UTILITY.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/BadLinkLibraries.cmake b/Tests/RunCMake/try_compile/BadLinkLibraries.cmake
new file mode 100644
index 0000000..e8b5add
--- /dev/null
+++ b/Tests/RunCMake/try_compile/BadLinkLibraries.cmake
@@ -0,0 +1,3 @@
+add_custom_target(not_a_library)
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c
+ LINK_LIBRARIES not_a_library)
diff --git a/Tests/RunCMake/try_compile/CMakeLists.txt b/Tests/RunCMake/try_compile/CMakeLists.txt
new file mode 100644
index 0000000..e8db6b0
--- /dev/null
+++ b/Tests/RunCMake/try_compile/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/try_compile/NoArgs-result.txt b/Tests/RunCMake/try_compile/NoArgs-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoArgs-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/NoArgs-stderr.txt b/Tests/RunCMake/try_compile/NoArgs-stderr.txt
new file mode 100644
index 0000000..8808fd1
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoArgs-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at NoArgs.cmake:1 \(try_compile\):
+ try_compile unknown error.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/NoArgs.cmake b/Tests/RunCMake/try_compile/NoArgs.cmake
new file mode 100644
index 0000000..8f751d9
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoArgs.cmake
@@ -0,0 +1 @@
+try_compile()
diff --git a/Tests/RunCMake/try_compile/NoCopyFile-result.txt b/Tests/RunCMake/try_compile/NoCopyFile-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoCopyFile-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/NoCopyFile-stderr.txt b/Tests/RunCMake/try_compile/NoCopyFile-stderr.txt
new file mode 100644
index 0000000..d65d9488
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoCopyFile-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at NoCopyFile.cmake:1 \(try_compile\):
+ COPY_FILE must be followed by a file path
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/NoCopyFile.cmake b/Tests/RunCMake/try_compile/NoCopyFile.cmake
new file mode 100644
index 0000000..8c648ff
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoCopyFile.cmake
@@ -0,0 +1,2 @@
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c
+ COPY_FILE)
diff --git a/Tests/RunCMake/try_compile/NoCopyFile2-result.txt b/Tests/RunCMake/try_compile/NoCopyFile2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoCopyFile2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/NoCopyFile2-stderr.txt b/Tests/RunCMake/try_compile/NoCopyFile2-stderr.txt
new file mode 100644
index 0000000..e889524
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoCopyFile2-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at NoCopyFile2.cmake:1 \(try_compile\):
+ COPY_FILE must be followed by a file path
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/NoCopyFile2.cmake b/Tests/RunCMake/try_compile/NoCopyFile2.cmake
new file mode 100644
index 0000000..04b7f68
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoCopyFile2.cmake
@@ -0,0 +1,2 @@
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c
+ COPY_FILE CMAKE_FLAGS -DA=B)
diff --git a/Tests/RunCMake/try_compile/NoOutputVariable-result.txt b/Tests/RunCMake/try_compile/NoOutputVariable-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoOutputVariable-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/NoOutputVariable-stderr.txt b/Tests/RunCMake/try_compile/NoOutputVariable-stderr.txt
new file mode 100644
index 0000000..18ad751
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoOutputVariable-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at NoOutputVariable.cmake:1 \(try_compile\):
+ OUTPUT_VARIABLE must be followed by a variable name
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/NoOutputVariable.cmake b/Tests/RunCMake/try_compile/NoOutputVariable.cmake
new file mode 100644
index 0000000..3b9cb34
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoOutputVariable.cmake
@@ -0,0 +1,2 @@
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c
+ OUTPUT_VARIABLE)
diff --git a/Tests/RunCMake/try_compile/NoOutputVariable2-result.txt b/Tests/RunCMake/try_compile/NoOutputVariable2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoOutputVariable2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/NoOutputVariable2-stderr.txt b/Tests/RunCMake/try_compile/NoOutputVariable2-stderr.txt
new file mode 100644
index 0000000..8b2cc25
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoOutputVariable2-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at NoOutputVariable2.cmake:1 \(try_compile\):
+ OUTPUT_VARIABLE must be followed by a variable name
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/NoOutputVariable2.cmake b/Tests/RunCMake/try_compile/NoOutputVariable2.cmake
new file mode 100644
index 0000000..ad9ac9a
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NoOutputVariable2.cmake
@@ -0,0 +1,2 @@
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/src.c
+ OUTPUT_VARIABLE CMAKE_FLAGS -DA=B)
diff --git a/Tests/RunCMake/try_compile/NonSourceCompileDefinitions-result.txt b/Tests/RunCMake/try_compile/NonSourceCompileDefinitions-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NonSourceCompileDefinitions-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/NonSourceCompileDefinitions-stderr.txt b/Tests/RunCMake/try_compile/NonSourceCompileDefinitions-stderr.txt
new file mode 100644
index 0000000..025e658
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NonSourceCompileDefinitions-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at NonSourceCompileDefinitions.cmake:1 \(try_compile\):
+ COMPILE_DEFINITIONS specified on a srcdir type TRY_COMPILE
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/NonSourceCompileDefinitions.cmake b/Tests/RunCMake/try_compile/NonSourceCompileDefinitions.cmake
new file mode 100644
index 0000000..8eb0d47
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NonSourceCompileDefinitions.cmake
@@ -0,0 +1,2 @@
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/proj
+ TestProject COMPILE_DEFINITIONS DEF)
diff --git a/Tests/RunCMake/try_compile/NonSourceCopyFile-result.txt b/Tests/RunCMake/try_compile/NonSourceCopyFile-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NonSourceCopyFile-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/NonSourceCopyFile-stderr.txt b/Tests/RunCMake/try_compile/NonSourceCopyFile-stderr.txt
new file mode 100644
index 0000000..f5893e1
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NonSourceCopyFile-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at NonSourceCopyFile.cmake:1 \(try_compile\):
+ COPY_FILE specified on a srcdir type TRY_COMPILE
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/NonSourceCopyFile.cmake b/Tests/RunCMake/try_compile/NonSourceCopyFile.cmake
new file mode 100644
index 0000000..c44192f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/NonSourceCopyFile.cmake
@@ -0,0 +1,2 @@
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/proj
+ TestProject COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/result)
diff --git a/Tests/RunCMake/try_compile/OneArg-result.txt b/Tests/RunCMake/try_compile/OneArg-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/OneArg-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/OneArg-stderr.txt b/Tests/RunCMake/try_compile/OneArg-stderr.txt
new file mode 100644
index 0000000..12835be
--- /dev/null
+++ b/Tests/RunCMake/try_compile/OneArg-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at OneArg.cmake:1 \(try_compile\):
+ try_compile unknown error.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/OneArg.cmake b/Tests/RunCMake/try_compile/OneArg.cmake
new file mode 100644
index 0000000..e60a462
--- /dev/null
+++ b/Tests/RunCMake/try_compile/OneArg.cmake
@@ -0,0 +1 @@
+try_compile(RESULT)
diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
new file mode 100644
index 0000000..31643cf
--- /dev/null
+++ b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
@@ -0,0 +1,12 @@
+include(RunCMake)
+
+run_cmake(NoArgs)
+run_cmake(OneArg)
+run_cmake(TwoArgs)
+run_cmake(NoCopyFile)
+run_cmake(NoCopyFile2)
+run_cmake(NoOutputVariable)
+run_cmake(NoOutputVariable2)
+run_cmake(BadLinkLibraries)
+run_cmake(NonSourceCopyFile)
+run_cmake(NonSourceCompileDefinitions)
diff --git a/Tests/RunCMake/try_compile/TwoArgs-result.txt b/Tests/RunCMake/try_compile/TwoArgs-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/try_compile/TwoArgs-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/try_compile/TwoArgs-stderr.txt b/Tests/RunCMake/try_compile/TwoArgs-stderr.txt
new file mode 100644
index 0000000..b9c08fc
--- /dev/null
+++ b/Tests/RunCMake/try_compile/TwoArgs-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at TwoArgs.cmake:1 \(try_compile\):
+ try_compile unknown error.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/try_compile/TwoArgs.cmake b/Tests/RunCMake/try_compile/TwoArgs.cmake
new file mode 100644
index 0000000..7f2212d
--- /dev/null
+++ b/Tests/RunCMake/try_compile/TwoArgs.cmake
@@ -0,0 +1 @@
+try_compile(RESULT ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/Tests/RunCMake/try_compile/proj/CMakeLists.txt b/Tests/RunCMake/try_compile/proj/CMakeLists.txt
new file mode 100644
index 0000000..78a87c0
--- /dev/null
+++ b/Tests/RunCMake/try_compile/proj/CMakeLists.txt
@@ -0,0 +1,2 @@
+cmake_minimum_required(VERSION 2.8.10)
+project(TestProject NONE)
diff --git a/Tests/RunCMake/try_compile/src.c b/Tests/RunCMake/try_compile/src.c
new file mode 100644
index 0000000..78f2de1
--- /dev/null
+++ b/Tests/RunCMake/try_compile/src.c
@@ -0,0 +1 @@
+int main(void) { return 0; }