diff options
84 files changed, 785 insertions, 271 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f83015..b0793d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,13 @@ if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}") endmacro() endif() +# option to set the internal encoding of CMake to UTF-8 +option(CMAKE_ENCODING_UTF8 "Use UTF-8 encoding internally (experimental)." OFF) +mark_as_advanced(CMAKE_ENCODING_UTF8) +if(CMAKE_ENCODING_UTF8) + set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8) +endif() + #----------------------------------------------------------------------- # a macro to deal with system libraries, implemented as a macro # simply to improve readability of the main script diff --git a/Help/policy/CMP0026.rst b/Help/policy/CMP0026.rst index 460d2d1..177b655 100644 --- a/Help/policy/CMP0026.rst +++ b/Help/policy/CMP0026.rst @@ -3,7 +3,8 @@ CMP0026 Disallow use of the LOCATION target property. -CMake 2.8.12 and lower allowed reading the LOCATION target property to +CMake 2.8.12 and lower allowed reading the LOCATION target +property (and configuration-specific variants) to determine the eventual location of build targets. This relies on the assumption that all necessary information is available at configure-time to determine the final location and filename of the @@ -17,8 +18,8 @@ $<TARGET_FILE> generator expression together with the file(GENERATE) subcommand to generate a file containing the target location. The OLD behavior for this policy is to allow reading the LOCATION -property from build-targets. The NEW behavior for this policy is to -not to allow reading the LOCATION property from build-targets. +properties from build-targets. The NEW behavior for this policy is to +not to allow reading the LOCATION properties from build-targets. This policy was introduced in CMake version 3.0. CMake version |release| warns when the policy is not set and uses OLD behavior. Use diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 52f9590..561ccf2 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -14,7 +14,11 @@ /* __INTEL_COMPILER = VRP */ # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) -# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) +# if defined(__INTEL_COMPILER_UPDATE) +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) +# else +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) +# endif # if defined(__INTEL_COMPILER_BUILD_DATE) /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 25ceb3f..6c602d4 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -19,7 +19,11 @@ /* __INTEL_COMPILER = VRP */ # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) -# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) +# if defined(__INTEL_COMPILER_UPDATE) +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) +# else +# define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) +# endif # if defined(__INTEL_COMPILER_BUILD_DATE) /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index b0ceb2b..812bb92 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -99,9 +99,20 @@ macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp) endmacro() # Splits given arguments into options and a package list -macro(_pkgconfig_parse_options _result _is_req _is_silent) +macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path) set(${_is_req} 0) set(${_is_silent} 0) + set(${_no_cmake_path} 0) + set(${_no_cmake_environment_path} 0) + if(DEFINED PKG_CONFIG_USE_CMAKE_PREFIX_PATH) + if(NOT PKG_CONFIG_USE_CMAKE_PREFIX_PATH) + set(${_no_cmake_path} 1) + set(${_no_cmake_environment_path} 1) + endif() + elseif(${CMAKE_MINIMUM_REQUIRED_VERSION} VERSION_LESS 3.1) + set(${_no_cmake_path} 1) + set(${_no_cmake_environment_path} 1) + endif() foreach(_pkg ${ARGN}) if (_pkg STREQUAL "REQUIRED") @@ -110,15 +121,23 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent) if (_pkg STREQUAL "QUIET") set(${_is_silent} 1) endif () + if (_pkg STREQUAL "NO_CMAKE_PATH") + set(${_no_cmake_path} 1) + endif() + if (_pkg STREQUAL "NO_CMAKE_ENVIRONMENT_PATH") + set(${_no_cmake_environment_path} 1) + endif() endforeach() set(${_result} ${ARGN}) list(REMOVE_ITEM ${_result} "REQUIRED") list(REMOVE_ITEM ${_result} "QUIET") + list(REMOVE_ITEM ${_result} "NO_CMAKE_PATH") + list(REMOVE_ITEM ${_result} "NO_CMAKE_ENVIRONMENT_PATH") endmacro() ### -macro(_pkg_check_modules_internal _is_required _is_silent _prefix) +macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _prefix) _pkgconfig_unset(${_prefix}_FOUND) _pkgconfig_unset(${_prefix}_VERSION) _pkgconfig_unset(${_prefix}_PREFIX) @@ -157,6 +176,95 @@ macro(_pkg_check_modules_internal _is_required _is_silent _prefix) set(_pkg_check_modules_packages) set(_pkg_check_modules_failed) + set(_extra_paths) + + if(NOT _no_cmake_path) + if(NOT "${CMAKE_PREFIX_PATH}" STREQUAL "") + list(APPEND _extra_paths ${CMAKE_PREFIX_PATH}) + endif() + if(NOT "${CMAKE_FRAMEWORK_PATH}" STREQUAL "") + list(APPEND _extra_paths ${CMAKE_FRAMEWORK_PATH}) + endif() + if(NOT "${CMAKE_APPBUNDLE_PATH}" STREQUAL "") + list(APPEND _extra_paths ${CMAKE_FRAMEWORK_PATH}) + endif() + endif() + + if(NOT _no_cmake_environment_path) + if(NOT "$ENV{CMAKE_PREFIX_PATH}" STREQUAL "") + file(TO_CMAKE_PATH "$ENV{CMAKE_PREFIX_PATH}" _path) + list(APPEND _extra_paths ${_path}) + unset(_path) + endif() + if(NOT "$ENV{CMAKE_FRAMEWORK_PATH}" STREQUAL "") + file(TO_CMAKE_PATH "$ENV{CMAKE_FRAMEWORK_PATH}" _path) + list(APPEND _extra_paths ${_path}) + unset(_path) + endif() + if(NOT "$ENV{CMAKE_APPBUNDLE_PATH}" STREQUAL "") + file(TO_CMAKE_PATH "$ENV{CMAKE_APPBUNDLE_PATH}" _path) + list(APPEND _extra_paths ${_path}) + unset(_path) + endif() + endif() + + if(NOT "${_extra_paths}" STREQUAL "") + # Save the PKG_CONFIG_PATH environment variable, and add paths + # from the CMAKE_PREFIX_PATH variables + set(_pkgconfig_path_old $ENV{PKG_CONFIG_PATH}) + set(_pkgconfig_path ${_pkgconfig_path_old}) + if(NOT "${_pkgconfig_path}" STREQUAL "") + file(TO_CMAKE_PATH "${_pkgconfig_path}" _pkgconfig_path) + endif() + + # Create a list of the possible pkgconfig subfolder (depending on + # the system + set(_lib_dirs) + if(NOT DEFINED CMAKE_SYSTEM_NAME + OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" + AND NOT CMAKE_CROSSCOMPILING)) + if(EXISTS "/etc/debian_version") # is this a debian system ? + if(CMAKE_LIBRARY_ARCHITECTURE) + list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig") + endif() + else() + # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property + get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) + if(uselib64) + list(APPEND _lib_dirs "lib64/pkgconfig") + endif() + endif() + endif() + list(APPEND _lib_dirs "lib/pkgconfig") + + # Check if directories exist and eventually append them to the + # pkgconfig path list + foreach(_prefix_dir ${_extra_paths}) + foreach(_lib_dir ${_lib_dirs}) + if(EXISTS "${_prefix_dir}/${_lib_dir}") + list(APPEND _pkgconfig_path "${_prefix_dir}/${_lib_dir}") + list(REMOVE_DUPLICATES _pkgconfig_path) + endif() + endforeach() + endforeach() + + # Prepare and set the environment variable + if(NOT "${_pkgconfig_path}" STREQUAL "") + # remove empty values from the list + list(REMOVE_ITEM _pkgconfig_path "") + file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path) + if(UNIX) + string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}") + string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}") + endif() + set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path}) + endif() + + # Unset variables + unset(_lib_dirs) + unset(_pkgconfig_path) + endif() + # iterate through module list and check whether they exist and match the required version foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list}) set(_pkg_check_modules_exist_query) @@ -260,6 +368,14 @@ macro(_pkg_check_modules_internal _is_required _is_silent _prefix) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other ) endif() + + if(NOT "${_extra_paths}" STREQUAL "") + # Restore the environment variable + set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path}) + endif() + + unset(_extra_paths) + unset(_pkgconfig_path_old) else() if (${_is_required}) message(SEND_ERROR "pkg-config tool not found") @@ -276,13 +392,25 @@ endmacro() Checks for all the given modules. :: - pkg_check_modules(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*) + pkg_check_modules(<PREFIX> [REQUIRED] [QUIET] + [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH] + <MODULE> [<MODULE>]*) + When the ``REQUIRED`` argument was set, macros will fail with an error when module(s) could not be found. When the ``QUIET`` argument is set, no status messages will be printed. + By default, if :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` is 3.1 or + later, or if :variable:`PKG_CONFIG_USE_CMAKE_PREFIX_PATH` is set, the + :variable:`CMAKE_PREFIX_PATH`, :variable:`CMAKE_FRAMEWORK_PATH`, and + :variable:`CMAKE_APPBUNDLE_PATH` cache and environment variables will + be added to ``pkg-config`` search path. + The ``NO_CMAKE_PATH`` and ``NO_CMAKE_ENVIRONMENT_PATH`` arguments + disable this behavior for the cache variables and the environment + variables, respectively. + It sets the following variables: :: PKG_CONFIG_FOUND ... if pkg-config executable was found @@ -362,8 +490,8 @@ endmacro() macro(pkg_check_modules _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) - _pkgconfig_parse_options (_pkg_modules _pkg_is_required _pkg_is_silent "${_module0}" ${ARGN}) - _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" "${_prefix}" ${_pkg_modules}) + _pkgconfig_parse_options (_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN}) + _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" ${_pkg_modules}) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) endif() @@ -376,7 +504,9 @@ endmacro() Same as :command:`pkg_check_modules`, but instead it checks for given modules and uses the first working one. :: - pkg_search_module(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*) + pkg_search_module(<PREFIX> [REQUIRED] [QUIET] + [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH] + <MODULE> [<MODULE>]*) Examples @@ -388,7 +518,7 @@ macro(pkg_search_module _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) set(_pkg_modules_found 0) - _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent "${_module0}" ${ARGN}) + _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN}) if (NOT ${_pkg_is_silent}) message(STATUS "checking for one of the modules '${_pkg_modules_alt}'") @@ -397,7 +527,7 @@ macro(pkg_search_module _prefix _module0) # iterate through all modules and stop at the first working one. foreach(_pkg_alt ${_pkg_modules_alt}) if(NOT _pkg_modules_found) - _pkg_check_modules_internal(0 1 "${_prefix}" "${_pkg_alt}") + _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" "${_pkg_alt}") endif() if (${_prefix}_FOUND) @@ -420,6 +550,18 @@ endmacro() .. variable:: PKG_CONFIG_EXECUTABLE Path to the pkg-config executable. + + +.. variable:: PKG_CONFIG_USE_CMAKE_PREFIX_PATH + + Whether :command:`pkg_check_modules` and :command:`pkg_search_module` + should add the paths in :variable:`CMAKE_PREFIX_PATH`, + :variable:`CMAKE_FRAMEWORK_PATH`, and :variable:`CMAKE_APPBUNDLE_PATH` + cache and environment variables to ``pkg-config`` search path. + + If this variable is not set, this behavior is enabled by default if + :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` is 3.1 or later, disabled + otherwise. #]========================================] diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 966e0f6..9fb8d9a 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -24,6 +24,11 @@ endif() set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR}) +# ensure Unicode friendly APIs are used on Windows +if(WIN32) + add_definitions(-DUNICODE -D_UNICODE) +endif() + # configure the .h file configure_file( "${CMake_SOURCE_DIR}/Source/cmConfigure.cmake.h.in" diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 562040a..0744061 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 0) -set(CMake_VERSION_PATCH 20140317) +set(CMake_VERSION_PATCH 20140320) #set(CMake_VERSION_RC 1) diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index 0dd01d8..7885a0c 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -27,7 +27,9 @@ if (Qt5Widgets_FOUND) macro(qt4_add_resources) qt5_add_resources(${ARGN}) endmacro() - set(QT_LIBRARIES ${Qt5Widgets_LIBRARIES}) + set(CMake_QT_LIBRARIES ${Qt5Widgets_LIBRARIES}) + set(QT_QTMAIN_LIBRARY ${Qt5Core_QTMAIN_LIBRARIES}) + # Remove this when the minimum version of Qt is 4.6. add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0) @@ -47,6 +49,8 @@ else() include(${QT_USE_FILE}) + set(CMake_QT_LIBRARIES ${QT_LIBRARIES}) + if(WIN32 AND EXISTS "${QT_QMAKE_EXECUTABLE}") get_filename_component(_Qt_BIN_DIR "${QT_QMAKE_EXECUTABLE}" PATH) if(EXISTS "${_Qt_BIN_DIR}/QtCore4.dll") @@ -55,11 +59,6 @@ else() endif() endif() - -if(WIN32 AND KWSYS_ENCODING_DEFAULT_CODEPAGE MATCHES CP_UTF8) - add_definitions(-DKWSYS_CP_UTF8) -endif() - set(SRCS AddCacheEntry.cxx AddCacheEntry.h @@ -117,7 +116,7 @@ endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS}) -target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${QT_LIBRARIES}) +target_link_libraries(cmake-gui CMakeLib ${QT_QTMAIN_LIBRARY} ${CMake_QT_LIBRARIES}) if(Qt_BIN_DIR) set_property(TARGET cmake-gui PROPERTY Qt_BIN_DIR ${Qt_BIN_DIR}) endif() diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 1b04a00..82fa3a3 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -79,7 +79,7 @@ int main(int argc, char** argv) QApplication app(argc, argv); -#if defined(KWSYS_CP_UTF8) +#if defined(CMAKE_ENCODING_UTF8) QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForLocale(utf8_codec); #endif diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index c5e95d0..2b0280d 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -16,4 +16,5 @@ #cmakedefine HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE #cmakedefine HAVE_UNSETENV #cmakedefine CMAKE_USE_ELF_PARSER +#cmakedefine CMAKE_ENCODING_UTF8 #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index db88749..2a144c6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -97,7 +97,7 @@ struct DoAccept template<> struct DoAccept<true> { - static void Do(std::vector<cmSourceFile*>& files, cmSourceFile* f) + static void Do(std::vector<cmSourceFile const*>& files, cmSourceFile* f) { files.push_back(f); } @@ -120,7 +120,7 @@ struct DoAccept<true> }; //---------------------------------------------------------------------------- -template<typename Tag, typename DataType = std::vector<cmSourceFile*> > +template<typename Tag, typename DataType = std::vector<cmSourceFile const*> > struct TagVisitor { DataType& Data; @@ -241,7 +241,7 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const //---------------------------------------------------------------------------- std::vector<cmSourceFile*> const* -cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const +cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { SourceEntriesType::const_iterator i = this->SourceEntries.find(sf); if(i != this->SourceEntries.end()) @@ -306,13 +306,10 @@ static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt, //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetObjectSources(std::vector<cmSourceFile*> &data) const +cmGeneratorTarget +::GetObjectSources(std::vector<cmSourceFile const*> &data) const { IMPLEMENT_VISIT(ObjectSources); - if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY) - { - this->ObjectSources = data; - } } //---------------------------------------------------------------------------- @@ -321,13 +318,14 @@ const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file) return this->Objects[file]; } -void cmGeneratorTarget::AddObject(cmSourceFile *sf, std::string const&name) +void cmGeneratorTarget::AddObject(cmSourceFile const* sf, + std::string const&name) { this->Objects[sf] = name; } //---------------------------------------------------------------------------- -void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile* sf) +void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf) { this->ExplicitObjectName.insert(sf); } @@ -341,34 +339,39 @@ bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetIDLSources(std::vector<cmSourceFile*>& data) const +void cmGeneratorTarget +::GetIDLSources(std::vector<cmSourceFile const*>& data) const { IMPLEMENT_VISIT(IDLSources); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetHeaderSources(std::vector<cmSourceFile*>& data) const +cmGeneratorTarget +::GetHeaderSources(std::vector<cmSourceFile const*>& data) const { IMPLEMENT_VISIT(HeaderSources); } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetExtraSources(std::vector<cmSourceFile*>& data) const +void cmGeneratorTarget +::GetExtraSources(std::vector<cmSourceFile const*>& data) const { IMPLEMENT_VISIT(ExtraSources); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetCustomCommands(std::vector<cmSourceFile*>& data) const +cmGeneratorTarget +::GetCustomCommands(std::vector<cmSourceFile const*>& data) const { IMPLEMENT_VISIT(CustomCommands); } //---------------------------------------------------------------------------- void -cmGeneratorTarget::GetExternalObjects(std::vector<cmSourceFile*>& data) const +cmGeneratorTarget +::GetExternalObjects(std::vector<cmSourceFile const*>& data) const { IMPLEMENT_VISIT(ExternalObjects); } @@ -383,7 +386,8 @@ cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs) const } //---------------------------------------------------------------------------- -void cmGeneratorTarget::GetResxSources(std::vector<cmSourceFile*>& srcs) const +void cmGeneratorTarget +::GetResxSources(std::vector<cmSourceFile const*>& srcs) const { ResxData data; IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData) @@ -569,9 +573,11 @@ cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) const cmTarget* objLib = *ti; cmGeneratorTarget* ogt = this->GlobalGenerator->GetGeneratorTarget(objLib); - for(std::vector<cmSourceFile*>::const_iterator - si = ogt->ObjectSources.begin(); - si != ogt->ObjectSources.end(); ++si) + std::vector<cmSourceFile const*> objectSources; + ogt->GetObjectSources(objectSources); + for(std::vector<cmSourceFile const*>::const_iterator + si = objectSources.begin(); + si != objectSources.end(); ++si) { std::string obj = ogt->ObjectDirectory; obj += ogt->Objects[*si]; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 81a447f..53e27c5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -32,19 +32,19 @@ public: bool GetPropertyAsBool(const std::string& prop) const; void GetSourceFiles(std::vector<cmSourceFile*>& files) const; - void GetObjectSources(std::vector<cmSourceFile*> &) const; + void GetObjectSources(std::vector<cmSourceFile const*> &) const; const std::string& GetObjectName(cmSourceFile const* file); - void AddObject(cmSourceFile *sf, std::string const&name); + void AddObject(cmSourceFile const* sf, std::string const&name); bool HasExplicitObjectName(cmSourceFile const* file) const; - void AddExplicitObjectName(cmSourceFile* sf); - - void GetResxSources(std::vector<cmSourceFile*>&) const; - void GetIDLSources(std::vector<cmSourceFile*>&) const; - void GetExternalObjects(std::vector<cmSourceFile*>&) const; - void GetHeaderSources(std::vector<cmSourceFile*>&) const; - void GetExtraSources(std::vector<cmSourceFile*>&) const; - void GetCustomCommands(std::vector<cmSourceFile*>&) const; + void AddExplicitObjectName(cmSourceFile const* sf); + + void GetResxSources(std::vector<cmSourceFile const*>&) const; + void GetIDLSources(std::vector<cmSourceFile const*>&) const; + void GetExternalObjects(std::vector<cmSourceFile const*>&) const; + void GetHeaderSources(std::vector<cmSourceFile const*>&) const; + void GetExtraSources(std::vector<cmSourceFile const*>&) const; + void GetCustomCommands(std::vector<cmSourceFile const*>&) const; void GetExpectedResxHeaders(std::set<std::string>&) const; cmTarget* Target; @@ -87,7 +87,8 @@ public: void LookupObjectLibraries(); /** Get sources that must be built before the given source. */ - std::vector<cmSourceFile*> const* GetSourceDepends(cmSourceFile* sf) const; + std::vector<cmSourceFile*> const* + GetSourceDepends(cmSourceFile const* sf) const; /** * Flags for a given source file as used in this target. Typically assigned @@ -116,17 +117,16 @@ public: struct ResxData { mutable std::set<std::string> ExpectedResxHeaders; - mutable std::vector<cmSourceFile*> ResxSources; + mutable std::vector<cmSourceFile const*> ResxSources; }; private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector<cmSourceFile*> Depends; }; - typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType; + typedef std::map<cmSourceFile const*, SourceEntry> SourceEntriesType; SourceEntriesType SourceEntries; std::map<cmSourceFile const*, std::string> Objects; std::set<cmSourceFile const*> ExplicitObjectName; - mutable std::vector<cmSourceFile*> ObjectSources; std::vector<cmTarget*> ObjectLibraries; mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index b95ff81..5b6d729 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1449,6 +1449,7 @@ void cmGlobalGenerator::ComputeGeneratorTargetObjects() continue; } cmGeneratorTarget* gt = ti->second; + this->ComputeTargetObjectDirectory(gt); gt->LookupObjectLibraries(); this->ComputeTargetObjects(gt); } @@ -1515,9 +1516,31 @@ cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const } //---------------------------------------------------------------------------- -void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget*) const +void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const +{ + std::vector<cmSourceFile const*> objectSources; + gt->GetObjectSources(objectSources); + + std::map<cmSourceFile const*, std::string> mapping; + for(std::vector<cmSourceFile const*>::const_iterator it + = objectSources.begin(); it != objectSources.end(); ++it) + { + mapping[*it]; + } + + gt->LocalGenerator->ComputeObjectFilenames(mapping, gt); + + for(std::map<cmSourceFile const*, std::string>::const_iterator it + = mapping.begin(); it != mapping.end(); ++it) + { + assert(!it->second.empty()); + gt->AddObject(it->first, it->second); + } +} + +//---------------------------------------------------------------------------- +void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const { - // Implemented in generator subclasses that need this. } void cmGlobalGenerator::CheckLocalGenerators() diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 91e71a8..49a418d 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -323,6 +323,8 @@ public: GetExportedTargetsFile(const std::string &filename) const; void AddCMP0042WarnTarget(const std::string& target); + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; + protected: typedef std::vector<cmLocalGenerator*> GeneratorVector; // for a project collect all its targets by following depend @@ -441,7 +443,7 @@ private: void CreateGeneratorTargets(cmMakefile* mf); void CreateGeneratorTargets(); void ComputeGeneratorTargetObjects(); - virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; + void ComputeTargetObjects(cmGeneratorTarget* gt) const; void ClearGeneratorMembers(); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 0a05f5a..49ce1b5 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -19,6 +19,7 @@ #include "cmVersion.h" #include <algorithm> +#include <assert.h> const char* cmGlobalNinjaGenerator::NINJA_BUILD_FILE = "build.ninja"; const char* cmGlobalNinjaGenerator::NINJA_RULES_FILE = "rules.ninja"; @@ -631,8 +632,9 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const return cmSystemTools::GetCMakeGUICommand(); } -// TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl. -void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const +//---------------------------------------------------------------------------- +void cmGlobalNinjaGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { cmTarget* target = gt->Target; @@ -643,19 +645,6 @@ void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const dir_max += gt->LocalGenerator->GetTargetDirectory(*target); dir_max += "/"; gt->ObjectDirectory = dir_max; - - std::vector<cmSourceFile*> objectSources; - gt->GetObjectSources(objectSources); - // Compute the name of each object file. - for(std::vector<cmSourceFile*>::iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - std::string objectName = gt->LocalGenerator - ->GetObjectFileNameWithoutTarget(*sf, dir_max); - gt->AddObject(sf, objectName); - } } //---------------------------------------------------------------------------- diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 7725cf3..f2643af 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -299,7 +299,7 @@ public: void AddTargetAlias(const std::string& alias, cmTarget* target); - + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: /// Overloaded methods. @@ -310,8 +310,6 @@ protected: private: virtual std::string GetEditCacheCommand() const; - /// @see cmGlobalGenerator::ComputeTargetObjects - virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; void OpenBuildFileStream(); void CloseBuildFileStream(); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index f5c56a9..4632071 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -106,11 +106,9 @@ std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const //---------------------------------------------------------------------------- void cmGlobalUnixMakefileGenerator3 -::ComputeTargetObjects(cmGeneratorTarget* gt) const +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { cmTarget* target = gt->Target; - cmLocalUnixMakefileGenerator3* lg = - static_cast<cmLocalUnixMakefileGenerator3*>(gt->LocalGenerator); // Compute full path to object file directory for this target. std::string dir_max; @@ -119,22 +117,6 @@ cmGlobalUnixMakefileGenerator3 dir_max += gt->LocalGenerator->GetTargetDirectory(*target); dir_max += "/"; gt->ObjectDirectory = dir_max; - - std::vector<cmSourceFile*> objectSources; - gt->GetObjectSources(objectSources); - // Compute the name of each object file. - for(std::vector<cmSourceFile*>::iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - bool hasSourceExtension = true; - std::string objectName = gt->LocalGenerator - ->GetObjectFileNameWithoutTarget(*sf, dir_max, - &hasSourceExtension); - gt->AddObject(sf, objectName); - lg->AddLocalObjectFile(target, sf, objectName, hasSourceExtension); - } } void cmGlobalUnixMakefileGenerator3::Configure() diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 8115176..d003789 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -128,6 +128,7 @@ public: /** Does the make tool tolerate .NOTPARALLEL? */ virtual bool AllowNotParallel() const { return true; } + virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: void WriteMainMakefile2(); void WriteMainCMakefile(); @@ -198,7 +199,6 @@ protected: private: virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; } virtual std::string GetEditCacheCommand() const; - virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; }; #endif diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 840e888..37a416b 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -470,7 +470,7 @@ cmGlobalVisualStudio10Generator //---------------------------------------------------------------------------- void cmGlobalVisualStudio10Generator::PathTooLong( - cmTarget* target, cmSourceFile* sf, std::string const& sfRel) + cmTarget* target, cmSourceFile const* sf, std::string const& sfRel) { size_t len = (strlen(target->GetMakefile()->GetCurrentOutputDirectory()) + 1 + sfRel.length()); diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 999a9d5..ede6b1b 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -87,7 +87,7 @@ public: /** Generate an <output>.rule file path for a given command output. */ virtual std::string GenerateRuleFile(std::string const& output) const; - void PathTooLong(cmTarget* target, cmSourceFile* sf, + void PathTooLong(cmTarget* target, cmSourceFile const* sf, std::string const& sfRel); virtual const char* GetToolsVersion() { return "4.0"; } @@ -112,7 +112,7 @@ private: LongestSourcePath(): Length(0), Target(0), SourceFile(0) {} size_t Length; cmTarget* Target; - cmSourceFile* SourceFile; + cmSourceFile const* SourceFile; std::string SourceRel; }; LongestSourcePath LongestSource; diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 320b440..42033c5 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -873,7 +873,8 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target) std::string guid = this->GetGUID(pname.c_str()); fout << - "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n" + "<?xml version=\"1.0\" encoding = \"" + << this->Encoding() << "\"?>\n" "<VisualStudioProject\n" "\tProjectType=\"Visual C++\"\n" "\tVersion=\"" << this->GetIDEVersion() << "0\"\n" @@ -1038,3 +1039,14 @@ cmIDEFlagTable const* cmGlobalVisualStudio7Generator::GetExtraFlagTableVS7() { return cmVS7ExtraFlagTable; } + +std::string cmGlobalVisualStudio7Generator::Encoding() +{ + std::ostringstream encoding; +#ifdef CMAKE_ENCODING_UTF8 + encoding << "UTF-8"; +#else + encoding << "Windows-1252"; +#endif + return encoding.str(); +} diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 0d2e410..1dc709d 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -109,6 +109,9 @@ public: virtual void FindMakeProgram(cmMakefile*); + // Encoding for Visual Studio files + virtual std::string Encoding(); + protected: virtual const char* GetIDEVersion() { return "7.0"; } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 69c893c..38f709f 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -1,3 +1,4 @@ + /*============================================================================ CMake - Cross Platform Makefile Generator Copyright 2000-2009 Kitware, Inc., Insight Software Consortium @@ -118,51 +119,12 @@ void cmGlobalVisualStudioGenerator::Generate() } //---------------------------------------------------------------------------- -void -cmGlobalVisualStudioGenerator -::ComputeTargetObjects(cmGeneratorTarget* gt) const +void cmGlobalVisualStudioGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { - cmLocalVisualStudioGenerator* lg = - static_cast<cmLocalVisualStudioGenerator*>(gt->LocalGenerator); - std::string dir_max = lg->ComputeLongestObjectDirectory(*gt->Target); - - // Count the number of object files with each name. Note that - // windows file names are not case sensitive. - std::map<std::string, int> counts; - std::vector<cmSourceFile*> objectSources; - gt->GetObjectSources(objectSources); - for(std::vector<cmSourceFile*>::const_iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - std::string objectNameLower = cmSystemTools::LowerCase( - cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); - objectNameLower += ".obj"; - counts[objectNameLower] += 1; - } - - // For all source files producing duplicate names we need unique - // object name computation. - for(std::vector<cmSourceFile*>::const_iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - std::string objectName = - cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); - objectName += ".obj"; - if(counts[cmSystemTools::LowerCase(objectName)] > 1) - { - gt->AddExplicitObjectName(sf); - objectName = lg->GetObjectFileNameWithoutTarget(*sf, dir_max); - } - gt->AddObject(sf, objectName); - } - std::string dir = gt->Makefile->GetCurrentOutputDirectory(); dir += "/"; - std::string tgtDir = lg->GetTargetDirectory(*gt->Target); + std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(*gt->Target); if(!tgtDir.empty()) { dir += tgtDir; diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 7e8dcf8..1ab8990 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -88,6 +88,7 @@ public: virtual std::string ExpandCFGIntDir(const std::string& str, const std::string& config) const; + void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: // Does this VS version link targets to each other if there are // dependencies in the SLN file? This was done for VS versions @@ -116,7 +117,6 @@ private: virtual std::string GetVSMakeProgram() = 0; void PrintCompilerAdvice(std::ostream&, std::string const&, const char*) const {} - void ComputeTargetObjects(cmGeneratorTarget* gt) const; void FollowLinkDepends(cmTarget const* target, std::set<cmTarget const*>& linked); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 36196a2..d4eb85b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3934,37 +3934,10 @@ bool cmGlobalXCodeGenerator::IsMultiConfig() return true; } - //---------------------------------------------------------------------------- -void -cmGlobalXCodeGenerator -::ComputeTargetObjects(cmGeneratorTarget* gt) const +//---------------------------------------------------------------------------- +void cmGlobalXCodeGenerator +::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const { - // Count the number of object files with each name. Warn about duplicate - // names since Xcode names them uniquely automatically with a numeric suffix - // to avoid exact duplicate file names. Note that Mac file names are not - // typically case sensitive, hence the LowerCase. - std::map<std::string, int> counts; - std::vector<cmSourceFile*> objectSources; - gt->GetObjectSources(objectSources); - for(std::vector<cmSourceFile*>::const_iterator - si = objectSources.begin(); - si != objectSources.end(); ++si) - { - cmSourceFile* sf = *si; - std::string objectName = - cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); - objectName += ".o"; - - std::string objectNameLower = cmSystemTools::LowerCase(objectName); - counts[objectNameLower] += 1; - if (2 == counts[objectNameLower]) - { - // TODO: emit warning about duplicate name? - } - - gt->AddObject(sf, objectName); - } - const char* configName = this->GetCMakeCFGIntDir(); std::string dir = this->GetObjectsNormalDirectory( "$(PROJECT_NAME)", configName, gt->Target); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index be81cdc..23616b4 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -204,6 +204,7 @@ private: std::vector<std::string> const& defines, bool dflag = false); + void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const; protected: virtual const char* GetInstallTargetName() const { return "install"; } virtual const char* GetPackageTargetName() const { return "package"; } @@ -216,7 +217,6 @@ protected: private: void PrintCompilerAdvice(std::ostream&, std::string const&, const char*) const {} - void ComputeTargetObjects(cmGeneratorTarget* gt) const; std::string GetObjectsNormalDirectory( const std::string &projName, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index ebcfa08..c47147c 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -264,7 +264,8 @@ void cmLocalGenerator::TraceDependencies() for(cmGeneratorTargetsType::iterator t = targets.begin(); t != targets.end(); ++t) { - if (t->second->Target->IsImported()) + if (t->second->Target->IsImported() + || t->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY) { continue; } @@ -3081,6 +3082,14 @@ cmLocalGenerator } //---------------------------------------------------------------------------- +void cmLocalGenerator::ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>&, + cmGeneratorTarget const*) +{ + +} + +//---------------------------------------------------------------------------- std::string cmLocalGenerator ::GetObjectFileNameWithoutTarget(const cmSourceFile& source, diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index afcaee9..61488fe 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -372,6 +372,10 @@ public: std::string& linkPath, cmGeneratorTarget* target); + virtual void ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt = 0); + protected: ///! put all the libraries for a target on into the given stream virtual void OutputLinkLibraries(std::string& linkLibraries, diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 7c4aab8..2f763ce 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -267,6 +267,20 @@ void cmLocalNinjaGenerator::SetConfigName() } } +//---------------------------------------------------------------------------- +void cmLocalNinjaGenerator::ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt) +{ + for(std::map<cmSourceFile const*, std::string>::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + si->second = this->GetObjectFileNameWithoutTarget(*sf, + gt->ObjectDirectory); + } +} + void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os) { cmGlobalNinjaGenerator::WriteDivider(os); diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 9d0b7b5..e91e60b 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -101,6 +101,10 @@ public: virtual std::string ConvertToLinkReference(std::string const& lib, OutputFormat format = SHELL); + virtual void ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt = 0); + protected: virtual std::string ConvertToIncludeReference(std::string const& path, diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 9f12ffe..2d36089 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -172,26 +172,71 @@ void cmLocalUnixMakefileGenerator3::Generate() } //---------------------------------------------------------------------------- -void cmLocalUnixMakefileGenerator3::AddLocalObjectFile( - cmTarget* target, cmSourceFile* sf, std::string objNoTargetDir, - bool hasSourceExtension) +void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt) { - if(cmSystemTools::FileIsFullPath(objNoTargetDir.c_str())) + for(std::map<cmSourceFile const*, std::string>::iterator + si = mapping.begin(); si != mapping.end(); ++si) { - objNoTargetDir = cmSystemTools::GetFilenameName(objNoTargetDir); + cmSourceFile const* sf = si->first; + si->second = this->GetObjectFileNameWithoutTarget(*sf, + gt->ObjectDirectory); + } +} + +//---------------------------------------------------------------------------- +void cmLocalUnixMakefileGenerator3:: +GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles) +{ + std::set<std::string> emitted; + cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets(); + for(cmGeneratorTargetsType::iterator ti = targets.begin(); + ti != targets.end(); ++ti) + { + cmGeneratorTarget* gt = ti->second; + if (gt->GetType() == cmTarget::INTERFACE_LIBRARY) + { + continue; + } + std::vector<cmSourceFile const*> objectSources; + gt->GetObjectSources(objectSources); + // Compute full path to object file directory for this target. + std::string dir_max; + dir_max += gt->Makefile->GetCurrentOutputDirectory(); + dir_max += "/"; + dir_max += this->GetTargetDirectory(*gt->Target); + dir_max += "/"; + // Compute the name of each object file. + for(std::vector<cmSourceFile const*>::iterator + si = objectSources.begin(); + si != objectSources.end(); ++si) + { + cmSourceFile const* sf = *si; + bool hasSourceExtension = true; + std::string objectName = this->GetObjectFileNameWithoutTarget(*sf, + dir_max, + &hasSourceExtension); + if(cmSystemTools::FileIsFullPath(objectName.c_str())) + { + objectName = cmSystemTools::GetFilenameName(objectName); + } + LocalObjectInfo& info = localObjectFiles[objectName]; + info.HasSourceExtension = hasSourceExtension; + info.push_back(LocalObjectEntry(gt->Target, sf->GetLanguage())); + } } - LocalObjectInfo& info = this->LocalObjectFiles[objNoTargetDir]; - info.HasSourceExtension = hasSourceExtension; - info.push_back(LocalObjectEntry(target, sf->GetLanguage())); } //---------------------------------------------------------------------------- void cmLocalUnixMakefileGenerator3::GetIndividualFileTargets (std::vector<std::string>& targets) { + std::map<std::string, LocalObjectInfo> localObjectFiles; + this->GetLocalObjectFiles(localObjectFiles); for (std::map<std::string, LocalObjectInfo>::iterator lo = - this->LocalObjectFiles.begin(); - lo != this->LocalObjectFiles.end(); ++lo) + localObjectFiles.begin(); + lo != localObjectFiles.end(); ++lo) { targets.push_back(lo->first); @@ -253,11 +298,14 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile() bool do_assembly_rules = this->GetCreateAssemblySourceRules(); + std::map<std::string, LocalObjectInfo> localObjectFiles; + this->GetLocalObjectFiles(localObjectFiles); + // now write out the object rules // for each object file name for (std::map<std::string, LocalObjectInfo>::iterator lo = - this->LocalObjectFiles.begin(); - lo != this->LocalObjectFiles.end(); ++lo) + localObjectFiles.begin(); + lo != localObjectFiles.end(); ++lo) { // Add a convenience rule for building the object file. this->WriteObjectConvenienceRule(ruleFileStream, diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index d504247..14543fb 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -224,10 +224,6 @@ public: // write the target rules for the local Makefile into the stream void WriteLocalAllRules(std::ostream& ruleFileStream); - void AddLocalObjectFile(cmTarget* target, cmSourceFile* sf, - std::string objNoTargetDir, - bool hasSourceExtension); - std::vector<std::string> const& GetLocalHelp() { return this->LocalHelp; } /** Get whether to create rules to generate preprocessed and @@ -317,6 +313,10 @@ private: std::string MakeLauncher(cmCustomCommandGenerator const& ccg, cmTarget* target, RelativeRoot relative); + virtual void ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt = 0); + friend class cmMakefileTargetGenerator; friend class cmMakefileExecutableTargetGenerator; friend class cmMakefileLibraryTargetGenerator; @@ -366,7 +366,9 @@ private: LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false), HasAssembleRule(false) {} }; - std::map<std::string, LocalObjectInfo> LocalObjectFiles; + void GetLocalObjectFiles( + std::map<std::string, LocalObjectInfo> &localObjectFiles); + void WriteObjectConvenienceRule(std::ostream& ruleFileStream, const char* comment, const char* output, LocalObjectInfo const& info); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 14ad567..52524aa 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1975,7 +1975,8 @@ cmLocalVisualStudio7Generator cmGlobalVisualStudio7Generator* gg = static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); - fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n" + fout << "<?xml version=\"1.0\" encoding = \"" + << gg->Encoding() << "\"?>\n" << "<VisualStudioProject\n" << "\tProjectCreator=\"Intel Fortran\"\n" << "\tVersion=\"" << gg->GetIntelProjectVersion() << "\"\n"; @@ -2038,7 +2039,12 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, this->WriteProjectStartFortran(fout, libName, target); return; } - fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n" + + cmGlobalVisualStudio7Generator* gg = + static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); + + fout << "<?xml version=\"1.0\" encoding = \"" + << gg->Encoding() << "\"?>\n" << "<VisualStudioProject\n" << "\tProjectType=\"Visual C++\"\n"; if(this->Version == VS71) @@ -2059,8 +2065,6 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout, { keyword = "Win32Proj"; } - cmGlobalVisualStudio7Generator* gg = - static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); fout << "\tName=\"" << projLabel << "\"\n"; if(this->Version >= VS8) { diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 613ee97..9680d43 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/Source/cmLocalVisualStudioGenerator.cxx @@ -31,6 +31,46 @@ cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator() } //---------------------------------------------------------------------------- +void cmLocalVisualStudioGenerator::ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt) +{ + std::string dir_max = this->ComputeLongestObjectDirectory(*gt->Target); + + // Count the number of object files with each name. Note that + // windows file names are not case sensitive. + std::map<std::string, int> counts; + + for(std::map<cmSourceFile const*, std::string>::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + std::string objectNameLower = cmSystemTools::LowerCase( + cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath())); + objectNameLower += ".obj"; + counts[objectNameLower] += 1; + } + + // For all source files producing duplicate names we need unique + // object name computation. + + for(std::map<cmSourceFile const*, std::string>::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + std::string objectName = + cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); + objectName += ".obj"; + if(counts[cmSystemTools::LowerCase(objectName)] > 1) + { + const_cast<cmGeneratorTarget*>(gt)->AddExplicitObjectName(sf); + objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max); + } + si->second = objectName; + } +} + +//---------------------------------------------------------------------------- cmsys::auto_ptr<cmCustomCommand> cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target, const std::string& config, diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index a89e219..3bf4f43 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -61,6 +61,10 @@ public: virtual void AddCMakeListsRules() = 0; + virtual void ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* = 0); + protected: virtual const char* ReportErrorLabel() const; virtual bool CustomCommandUseLocal() const { return false; } diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx index 5857aef..8ff6c87 100644 --- a/Source/cmLocalXCodeGenerator.cxx +++ b/Source/cmLocalXCodeGenerator.cxx @@ -71,3 +71,31 @@ void cmLocalXCodeGenerator::GenerateInstallRules() t->HasMacOSXRpathInstallNameDir(""); } } + +//---------------------------------------------------------------------------- +void cmLocalXCodeGenerator::ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const*) +{ + // Count the number of object files with each name. Warn about duplicate + // names since Xcode names them uniquely automatically with a numeric suffix + // to avoid exact duplicate file names. Note that Mac file names are not + // typically case sensitive, hence the LowerCase. + std::map<std::string, int> counts; + for(std::map<cmSourceFile const*, std::string>::iterator + si = mapping.begin(); si != mapping.end(); ++si) + { + cmSourceFile const* sf = si->first; + std::string objectName = + cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()); + objectName += ".o"; + + std::string objectNameLower = cmSystemTools::LowerCase(objectName); + counts[objectNameLower] += 1; + if (2 == counts[objectNameLower]) + { + // TODO: emit warning about duplicate name? + } + si->second = objectName; + } +} diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index 3bfe3a3..f553a17 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -32,6 +32,9 @@ public: const std::string& rawFlag); virtual void Generate(); virtual void GenerateInstallRules(); + virtual void ComputeObjectFilenames( + std::map<cmSourceFile const*, std::string>& mapping, + cmGeneratorTarget const* gt = 0); private: }; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 58625fb..ad9de60 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -926,6 +926,14 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target, this->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } + if(ti->second.GetType() == cmTarget::INTERFACE_LIBRARY) + { + cmOStringStream e; + e << "Target \"" << target << "\" is an INTERFACE library " + "that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands."; + this->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } // Add the command to the appropriate build step for the target. std::vector<std::string> no_output; cmCustomCommand cc(this, no_output, depends, diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 3161aba..6759d05 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -153,9 +153,9 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() // First generate the object rule files. Save a list of all object // files for this target. - std::vector<cmSourceFile*> customCommands; + std::vector<cmSourceFile const*> customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { @@ -176,27 +176,27 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() } } } - std::vector<cmSourceFile*> headerSources; + std::vector<cmSourceFile const*> headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( headerSources, this->MacOSXContentGenerator); - std::vector<cmSourceFile*> extraSources; + std::vector<cmSourceFile const*> extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator); - std::vector<cmSourceFile*> externalObjects; + std::vector<cmSourceFile const*> externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { this->ExternalObjects.push_back((*si)->GetFullPath()); } - std::vector<cmSourceFile*> objectSources; + std::vector<cmSourceFile const*> objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { // Generate this object file's rule file. @@ -373,7 +373,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags() //---------------------------------------------------------------------------- void cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() - (cmSourceFile& source, const char* pkgloc) + (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. if(!this->Generator->GetTarget()->IsBundleOnApple()) @@ -423,7 +423,8 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() } //---------------------------------------------------------------------------- -void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) +void cmMakefileTargetGenerator +::WriteObjectRuleFiles(cmSourceFile const& source) { // Identify the language of the source file. const std::string& lang = @@ -498,7 +499,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source) //---------------------------------------------------------------------------- void cmMakefileTargetGenerator -::AppendFortranFormatFlags(std::string& flags, cmSourceFile& source) +::AppendFortranFormatFlags(std::string& flags, cmSourceFile const& source) { const char* srcfmt = source.GetProperty("Fortran_FORMAT"); cmLocalGenerator::FortranFormat format = @@ -529,7 +530,7 @@ void cmMakefileTargetGenerator ::WriteObjectBuildFile(std::string &obj, const std::string& lang, - cmSourceFile& source, + cmSourceFile const& source, std::vector<std::string>& depends) { this->LocalGenerator->AppendRuleDepend(depends, @@ -1194,7 +1195,7 @@ cmMakefileTargetGenerator //---------------------------------------------------------------------------- void cmMakefileTargetGenerator -::WriteObjectDependRules(cmSourceFile& source, +::WriteObjectDependRules(cmSourceFile const& source, std::vector<std::string>& depends) { // Create the list of dependencies known at cmake time. These are diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index 97c58b9..7ff6da9 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -81,7 +81,7 @@ protected: MacOSXContentGeneratorType(cmMakefileTargetGenerator* gen) : Generator(gen) {} - void operator()(cmSourceFile& source, const char* pkgloc); + void operator()(cmSourceFile const& source, const char* pkgloc); private: cmMakefileTargetGenerator* Generator; @@ -89,16 +89,16 @@ protected: friend struct MacOSXContentGeneratorType; // write the rules for an object - void WriteObjectRuleFiles(cmSourceFile& source); + void WriteObjectRuleFiles(cmSourceFile const& source); // write the build rule for an object void WriteObjectBuildFile(std::string &obj, const std::string& lang, - cmSourceFile& source, + cmSourceFile const& source, std::vector<std::string>& depends); // write the depend.make file for an object - void WriteObjectDependRules(cmSourceFile& source, + void WriteObjectDependRules(cmSourceFile const& source, std::vector<std::string>& depends); // write the build rule for a custom command @@ -126,7 +126,8 @@ protected: // Return the a string with -F flags on apple std::string GetFrameworkFlags(std::string const& l); - void AppendFortranFormatFlags(std::string& flags, cmSourceFile& source); + void AppendFortranFormatFlags(std::string& flags, + cmSourceFile const& source); // append intertarget dependencies void AppendTargetDepends(std::vector<std::string>& depends); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index ed3782c..4319f3c 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -126,7 +126,7 @@ void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags, // void cmMakefileTargetGenerator::WriteTargetLanguageFlags() // Refactor it. std::string -cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, +cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source, const std::string& language) { // TODO: Fortran support. @@ -211,7 +211,7 @@ bool cmNinjaTargetGenerator::needsDepFile(const std::string& lang) // void cmMakefileTargetGenerator::WriteTargetLanguageFlags(). std::string cmNinjaTargetGenerator:: -ComputeDefines(cmSourceFile *source, const std::string& language) +ComputeDefines(cmSourceFile const* source, const std::string& language) { std::set<std::string> defines; @@ -269,14 +269,14 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const std::string cmNinjaTargetGenerator -::GetSourceFilePath(cmSourceFile* source) const +::GetSourceFilePath(cmSourceFile const* source) const { return ConvertToNinjaPath(source->GetFullPath().c_str()); } std::string cmNinjaTargetGenerator -::GetObjectFilePath(cmSourceFile* source) const +::GetObjectFilePath(cmSourceFile const* source) const { std::string path = this->LocalGenerator->GetHomeRelativeOutputPath(); if(!path.empty()) @@ -480,36 +480,36 @@ cmNinjaTargetGenerator << this->GetTargetName() << "\n\n"; - std::vector<cmSourceFile*> customCommands; + std::vector<cmSourceFile const*> customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { cmCustomCommand const* cc = (*si)->GetCustomCommand(); this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget()); } - std::vector<cmSourceFile*> headerSources; + std::vector<cmSourceFile const*> headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( headerSources, this->MacOSXContentGenerator); - std::vector<cmSourceFile*> extraSources; + std::vector<cmSourceFile const*> extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->OSXBundleGenerator->GenerateMacOSXContentStatements( extraSources, this->MacOSXContentGenerator); - std::vector<cmSourceFile*> externalObjects; + std::vector<cmSourceFile const*> externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { this->Objects.push_back(this->GetSourceFilePath(*si)); } - std::vector<cmSourceFile*> objectSources; + std::vector<cmSourceFile const*> objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { this->WriteObjectBuildStatement(*si); @@ -536,7 +536,7 @@ cmNinjaTargetGenerator void cmNinjaTargetGenerator -::WriteObjectBuildStatement(cmSourceFile* source) +::WriteObjectBuildStatement(cmSourceFile const* source) { std::string comment; const std::string language = source->GetLanguage(); @@ -570,9 +570,9 @@ cmNinjaTargetGenerator } // Add order-only dependencies on custom command outputs. - std::vector<cmSourceFile*> customCommands; + std::vector<cmSourceFile const*> customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { @@ -733,7 +733,7 @@ cmNinjaTargetGenerator //---------------------------------------------------------------------------- void cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( - cmSourceFile& source, const char* pkgloc) + cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. if(!this->Generator->GetTarget()->IsBundleOnApple()) diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index e66e55f..8669e6e 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -79,10 +79,10 @@ protected: * @note Generally it is the value of the variable whose name is computed * by LanguageFlagsVarName(). */ - std::string ComputeFlagsForObject(cmSourceFile *source, + std::string ComputeFlagsForObject(cmSourceFile const* source, const std::string& language); - std::string ComputeDefines(cmSourceFile *source, + std::string ComputeDefines(cmSourceFile const* source, const std::string& language); std::string ConvertToNinjaPath(const char *path) const { @@ -96,10 +96,10 @@ protected: cmNinjaDeps ComputeLinkDeps() const; /// @return the source file path for the given @a source. - std::string GetSourceFilePath(cmSourceFile* source) const; + std::string GetSourceFilePath(cmSourceFile const* source) const; /// @return the object file path for the given @a source. - std::string GetObjectFilePath(cmSourceFile* source) const; + std::string GetObjectFilePath(cmSourceFile const* source) const; /// @return the file path where the target named @a name is generated. std::string GetTargetFilePath(const std::string& name) const; @@ -110,7 +110,7 @@ protected: void WriteLanguageRules(const std::string& language); void WriteCompileRule(const std::string& language); void WriteObjectBuildStatements(); - void WriteObjectBuildStatement(cmSourceFile* source); + void WriteObjectBuildStatement(cmSourceFile const* source); void WriteCustomCommandBuildStatement(cmCustomCommand *cc); cmNinjaDeps GetObjects() const @@ -129,7 +129,7 @@ protected: MacOSXContentGeneratorType(cmNinjaTargetGenerator* g) : Generator(g) {} - void operator()(cmSourceFile& source, const char* pkgloc); + void operator()(cmSourceFile const& source, const char* pkgloc); private: cmNinjaTargetGenerator* Generator; diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 835f892..6f16913 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -190,13 +190,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, //---------------------------------------------------------------------------- void cmOSXBundleGenerator:: -GenerateMacOSXContentStatements(std::vector<cmSourceFile*> const& sources, - MacOSXContentGeneratorType* generator) +GenerateMacOSXContentStatements( + std::vector<cmSourceFile const*> const& sources, + MacOSXContentGeneratorType* generator) { if (this->MustSkip()) return; - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = sources.begin(); si != sources.end(); ++si) { cmGeneratorTarget::SourceFileFlags tsFlags = diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index 95b4aef..f945c15 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -44,11 +44,12 @@ public: struct MacOSXContentGeneratorType { virtual ~MacOSXContentGeneratorType() {} - virtual void operator()(cmSourceFile& source, const char* pkgloc) = 0; + virtual void operator()(cmSourceFile const& source, + const char* pkgloc) = 0; }; void GenerateMacOSXContentStatements( - std::vector<cmSourceFile*> const& sources, + std::vector<cmSourceFile const*> const& sources, MacOSXContentGeneratorType* generator); std::string InitMacOSXContentDirectory(const char* pkgloc); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ca34aea..17c8a4d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2670,6 +2670,21 @@ const char *cmTarget::GetProperty(const std::string& prop, this->GetLocation(configName), cmProperty::TARGET); } + // Support "<CONFIG>_LOCATION". + if(cmHasLiteralSuffix(prop, "_LOCATION")) + { + std::string configName(prop.c_str(), prop.size() - 9); + if(configName != "IMPORTED") + { + if (!this->HandleLocationPropertyPolicy()) + { + return 0; + } + this->Properties.SetProperty(prop, + this->GetLocation(configName), + cmProperty::TARGET); + } + } } if(prop == "INCLUDE_DIRECTORIES") { diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 7c55f64..bb76b7f 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -222,7 +222,8 @@ void cmVisualStudio10TargetGenerator::Generate() //get the tools version to use const std::string toolsVer(this->GlobalGenerator->GetToolsVersion()); std::string project_defaults= - "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"; + "<?xml version=\"1.0\" encoding=\"" + + this->GlobalGenerator->Encoding() + "\"?>\n"; project_defaults.append("<Project DefaultTargets=\"Build\" ToolsVersion=\""); project_defaults.append(toolsVer +"\" "); project_defaults.append( @@ -377,12 +378,12 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences() void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup() { - std::vector<cmSourceFile*> resxObjs; + std::vector<cmSourceFile const*> resxObjs; this->GeneratorTarget->GetResxSources(resxObjs); if(!resxObjs.empty()) { this->WriteString("<ItemGroup>\n", 1); - for(std::vector<cmSourceFile*>::const_iterator oi = resxObjs.begin(); + for(std::vector<cmSourceFile const*>::const_iterator oi = resxObjs.begin(); oi != resxObjs.end(); ++oi) { std::string obj = (*oi)->GetFullPath(); @@ -551,9 +552,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues() void cmVisualStudio10TargetGenerator::WriteCustomCommands() { this->SourcesVisited.clear(); - std::vector<cmSourceFile*> customCommands; + std::vector<cmSourceFile const*> customCommands; this->GeneratorTarget->GetCustomCommands(customCommands); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = customCommands.begin(); si != customCommands.end(); ++si) { @@ -562,7 +563,8 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommands() } //---------------------------------------------------------------------------- -void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf) +void cmVisualStudio10TargetGenerator +::WriteCustomCommand(cmSourceFile const* sf) { if(this->SourcesVisited.insert(sf).second) { @@ -585,7 +587,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf) } void -cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source, +cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source, cmCustomCommand const & command) { @@ -732,7 +734,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups() //get the tools version to use const std::string toolsVer(this->GlobalGenerator->GetToolsVersion()); std::string project_defaults= - "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"; + "<?xml version=\"1.0\" encoding=\"" + + this->GlobalGenerator->Encoding() + "\"?>\n"; project_defaults.append("<Project ToolsVersion=\""); project_defaults.append(toolsVer +"\" "); project_defaults.append( @@ -745,12 +748,12 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteGroupSources(ti->first.c_str(), ti->second, sourceGroups); } - std::vector<cmSourceFile*> resxObjs; + std::vector<cmSourceFile const*> resxObjs; this->GeneratorTarget->GetResxSources(resxObjs); if(!resxObjs.empty()) { this->WriteString("<ItemGroup>\n", 1); - for(std::vector<cmSourceFile*>::const_iterator oi = resxObjs.begin(); + for(std::vector<cmSourceFile const*>::const_iterator oi = resxObjs.begin(); oi != resxObjs.end(); ++oi) { std::string obj = (*oi)->GetFullPath(); @@ -901,7 +904,7 @@ WriteGroupSources(const char* name, for(ToolSources::const_iterator s = sources.begin(); s != sources.end(); ++s) { - cmSourceFile* sf = s->SourceFile; + cmSourceFile const* sf = s->SourceFile; std::string const& source = sf->GetFullPath(); cmSourceGroup* sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), sourceGroups); @@ -928,7 +931,7 @@ WriteGroupSources(const char* name, } void cmVisualStudio10TargetGenerator::WriteSource( - const char* tool, cmSourceFile* sf, const char* end) + const char* tool, cmSourceFile const* sf, const char* end) { // Visual Studio tools append relative paths to the current dir, as in: // @@ -984,9 +987,9 @@ void cmVisualStudio10TargetGenerator::WriteSource( } void cmVisualStudio10TargetGenerator::WriteSources( - const char* tool, std::vector<cmSourceFile*> const& sources) + const char* tool, std::vector<cmSourceFile const*> const& sources) { - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = sources.begin(); si != sources.end(); ++si) { this->WriteSource(tool, *si); @@ -1001,16 +1004,16 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } this->WriteString("<ItemGroup>\n", 1); - std::vector<cmSourceFile*> headerSources; + std::vector<cmSourceFile const*> headerSources; this->GeneratorTarget->GetHeaderSources(headerSources); this->WriteSources("ClInclude", headerSources); - std::vector<cmSourceFile*> idlSources; + std::vector<cmSourceFile const*> idlSources; this->GeneratorTarget->GetIDLSources(idlSources); this->WriteSources("Midl", idlSources); - std::vector<cmSourceFile*> objectSources; + std::vector<cmSourceFile const*> objectSources; this->GeneratorTarget->GetObjectSources(objectSources); - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { @@ -1049,7 +1052,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } - std::vector<cmSourceFile*> externalObjects; + std::vector<cmSourceFile const*> externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects); if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10) { @@ -1061,7 +1064,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() { // If an object file is generated in this target, then vs10 will use // it in the build, and we have to list it as None instead of Object. - for(std::vector<cmSourceFile*>::const_iterator + for(std::vector<cmSourceFile const*>::const_iterator si = externalObjects.begin(); si != externalObjects.end(); ++si) { @@ -1071,7 +1074,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } } - std::vector<cmSourceFile*> extraSources; + std::vector<cmSourceFile const*> extraSources; this->GeneratorTarget->GetExtraSources(extraSources); this->WriteSources("None", extraSources); @@ -1091,9 +1094,9 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() } bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( - cmSourceFile* source) + cmSourceFile const* source) { - cmSourceFile& sf = *source; + cmSourceFile const& sf = *source; std::string objectName; if(this->GeneratorTarget->HasExplicitObjectName(&sf)) diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 02b951c..d72c6fd 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -45,7 +45,7 @@ public: private: struct ToolSource { - cmSourceFile* SourceFile; + cmSourceFile const* SourceFile; bool RelativePath; }; struct ToolSources: public std::vector<ToolSource> {}; @@ -55,8 +55,10 @@ private: void WriteString(const char* line, int indentLevel); void WriteProjectConfigurations(); void WriteProjectConfigurationValues(); - void WriteSource(const char* tool, cmSourceFile* sf, const char* end = 0); - void WriteSources(const char* tool, std::vector<cmSourceFile*> const&); + void WriteSource(const char* tool, cmSourceFile const* sf, + const char* end = 0); + void WriteSources(const char* tool, + std::vector<cmSourceFile const*> const&); void WriteAllSources(); void WriteDotNetReferences(); void WriteEmbeddedResourceGroup(); @@ -77,13 +79,13 @@ private: std::vector<std::string> const & includes); void OutputIncludes(std::vector<std::string> const & includes); void OutputLinkIncremental(std::string const& configName); - void WriteCustomRule(cmSourceFile* source, + void WriteCustomRule(cmSourceFile const* source, cmCustomCommand const & command); void WriteCustomCommands(); - void WriteCustomCommand(cmSourceFile* sf); + void WriteCustomCommand(cmSourceFile const* sf); void WriteGroups(); void WriteProjectReferences(); - bool OutputSourceSpecificFlags(cmSourceFile* source); + bool OutputSourceSpecificFlags(cmSourceFile const* source); void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring); void WriteLibOptions(std::string const& config); void WriteEvents(std::string const& configName); @@ -111,7 +113,7 @@ private: cmGlobalVisualStudio10Generator* GlobalGenerator; cmGeneratedFileStream* BuildFileStream; cmLocalVisualStudio7Generator* LocalGenerator; - std::set<cmSourceFile*> SourcesVisited; + std::set<cmSourceFile const*> SourcesVisited; typedef std::map<std::string, ToolSources> ToolSourceMap; ToolSourceMap Tools; diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-result.txt b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-stderr.txt new file mode 100644 index 0000000..07982bd --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at CMP0026-CONFIG-LOCATION-NEW.cmake:7 \(get_target_property\): + Policy CMP0026 is not set: Disallow use of the LOCATION target property. + Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The LOCATION property may not be read from target "somelib". Use the + target name directly with add_custom_command, or use the generator + expression \$<TARGET_FILE>, as appropriate. + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW.cmake b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW.cmake new file mode 100644 index 0000000..1b373e7 --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-NEW.cmake @@ -0,0 +1,7 @@ + +enable_language(CXX) + +cmake_policy(SET CMP0026 NEW) + +add_library(somelib empty.cpp) +get_target_property(_loc somelib Debug_LOCATION) diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-result.txt b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD.cmake b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD.cmake new file mode 100644 index 0000000..4166828 --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-OLD.cmake @@ -0,0 +1,7 @@ + +enable_language(CXX) + +cmake_policy(SET CMP0026 OLD) + +add_library(somelib empty.cpp) +get_target_property(_loc somelib Debug_LOCATION) diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-result.txt b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-stderr.txt new file mode 100644 index 0000000..d44dcb4 --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN-stderr.txt @@ -0,0 +1,12 @@ +CMake Warning \(dev\) at CMP0026-CONFIG-LOCATION-WARN.cmake:5 \(get_target_property\): + Policy CMP0026 is not set: Disallow use of the LOCATION target property. + Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The LOCATION property should not be read from target "somelib". Use the + target name directly with add_custom_command, or use the generator + expression \$<TARGET_FILE>, as appropriate. + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN.cmake b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN.cmake new file mode 100644 index 0000000..511056f --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-CONFIG-LOCATION-WARN.cmake @@ -0,0 +1,5 @@ + +enable_language(CXX) + +add_library(somelib empty.cpp) +get_target_property(_loc somelib Debug_LOCATION) diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-result.txt b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-stderr.txt new file mode 100644 index 0000000..0e90f96 --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW-stderr.txt @@ -0,0 +1,11 @@ +CMake Error at CMP0026-LOCATION-CONFIG-NEW.cmake:7 \(get_target_property\): + Policy CMP0026 is not set: Disallow use of the LOCATION target property. + Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The LOCATION property may not be read from target "somelib". Use the + target name directly with add_custom_command, or use the generator + expression \$<TARGET_FILE>, as appropriate. + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW.cmake b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW.cmake new file mode 100644 index 0000000..e6aa509 --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-NEW.cmake @@ -0,0 +1,7 @@ + +enable_language(CXX) + +cmake_policy(SET CMP0026 NEW) + +add_library(somelib empty.cpp) +get_target_property(_loc somelib LOCATION_Debug) diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-result.txt b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-stderr.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD-stderr.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD.cmake b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD.cmake new file mode 100644 index 0000000..482373d --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-OLD.cmake @@ -0,0 +1,7 @@ + +enable_language(CXX) + +cmake_policy(SET CMP0026 OLD) + +add_library(somelib empty.cpp) +get_target_property(_loc somelib LOCATION_Debug) diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-result.txt b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-stderr.txt b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-stderr.txt new file mode 100644 index 0000000..cd6f3d0 --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN-stderr.txt @@ -0,0 +1,12 @@ +CMake Warning \(dev\) at CMP0026-LOCATION-CONFIG-WARN.cmake:5 \(get_target_property\): + Policy CMP0026 is not set: Disallow use of the LOCATION target property. + Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy + command to set the policy and suppress this warning. + + The LOCATION property should not be read from target "somelib". Use the + target name directly with add_custom_command, or use the generator + expression \$<TARGET_FILE>, as appropriate. + +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN.cmake b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN.cmake new file mode 100644 index 0000000..85711c3 --- /dev/null +++ b/Tests/RunCMake/CMP0026/CMP0026-LOCATION-CONFIG-WARN.cmake @@ -0,0 +1,5 @@ + +enable_language(CXX) + +add_library(somelib empty.cpp) +get_target_property(_loc somelib LOCATION_Debug) diff --git a/Tests/RunCMake/CMP0026/RunCMakeTest.cmake b/Tests/RunCMake/CMP0026/RunCMakeTest.cmake index 68000a6..1824cc6 100644 --- a/Tests/RunCMake/CMP0026/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0026/RunCMakeTest.cmake @@ -3,3 +3,9 @@ include(RunCMake) run_cmake(CMP0026-WARN) run_cmake(CMP0026-NEW) run_cmake(CMP0026-IMPORTED) +run_cmake(CMP0026-CONFIG-LOCATION-NEW) +run_cmake(CMP0026-CONFIG-LOCATION-OLD) +run_cmake(CMP0026-CONFIG-LOCATION-WARN) +run_cmake(CMP0026-LOCATION-CONFIG-NEW) +run_cmake(CMP0026-LOCATION-CONFIG-OLD) +run_cmake(CMP0026-LOCATION-CONFIG-WARN) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 499d12b..f9d590a 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -107,6 +107,11 @@ if (QT4_FOUND) add_RunCMake_test(ObsoleteQtMacros) endif() +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + add_RunCMake_test(FindPkgConfig) +endif() + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio [^6]") add_RunCMake_test(include_external_msproject) add_RunCMake_test(SolutionGlobalSections) diff --git a/Tests/RunCMake/FindPkgConfig/CMakeLists.txt b/Tests/RunCMake/FindPkgConfig/CMakeLists.txt new file mode 100644 index 0000000..72abfc8 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.11) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake new file mode 100644 index 0000000..5f9913f --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake @@ -0,0 +1,51 @@ +# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS +enable_language(C) + +# Prepare environment and variables +set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE) +set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo") +if(WIN32) + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem") + set(ENV{PKG_CONFIG_PATH} "C:\\baz") +else() + set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh") + set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem") + set(ENV{PKG_CONFIG_PATH} "/baz") +endif() + + +find_package(PkgConfig) + + +if(NOT DEFINED CMAKE_SYSTEM_NAME + OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$" + AND NOT CMAKE_CROSSCOMPILING)) + if(EXISTS "/etc/debian_version") # is this a debian system ? + if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$") + # Cannot create directories for all the existing architectures... + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() + else() + # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property + get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS) + if(uselib64) + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() + endif() +else() + if(WIN32) + set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-foo\\lib\\pkgconfig;${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar\\lib\\pkgconfig") + else() + set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig") + endif() +endif() + + +pkg_check_modules (FOO "${expected_path}") + +if(NOT "FOO_FOUND") + message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".") +endif() diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake new file mode 100644 index 0000000..ad77ad0 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -0,0 +1,3 @@ +include(RunCMake) + +run_cmake(FindPkgConfig_PKGCONFIG_PATH) diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat new file mode 100755 index 0000000..b2096ed --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat @@ -0,0 +1,16 @@ +@ECHO OFF +IF "%1"=="" ( + EXIT /B 255 +) +IF "%1"=="--version" ( + ECHO 0.0-cmake-dummy + EXIT /B 0 +) + +IF "%1"=="--exists" ( + SHIFT + IF NOT "%*"=="%PKG_CONFIG_PATH%" ( + EXIT /B 1 + ) +) +EXIT /B 0 diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh new file mode 100755 index 0000000..e62bb74 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# This is a replacement for pkg-config that compares the string passed +# to the --exists argument with the PKG_CONFIG_PATH environment variable +# and returns 1 if they are different. + +case $1 in + --version) + echo "0.0-cmake-dummy" + ;; + --exists) + shift + echo "$@" + echo "${PKG_CONFIG_PATH}" + [ "$@" = "${PKG_CONFIG_PATH}" ] || exit 1 + ;; + *) + exit 255 + ;; +esac diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder diff --git a/Tests/RunCMake/interface_library/RunCMakeTest.cmake b/Tests/RunCMake/interface_library/RunCMakeTest.cmake index 3c457c5..08e81c6 100644 --- a/Tests/RunCMake/interface_library/RunCMakeTest.cmake +++ b/Tests/RunCMake/interface_library/RunCMakeTest.cmake @@ -8,3 +8,4 @@ run_cmake(invalid_signature) run_cmake(global-interface) run_cmake(genex_link) run_cmake(add_dependencies) +run_cmake(add_custom_command-TARGET) diff --git a/Tests/RunCMake/interface_library/add_custom_command-TARGET-result.txt b/Tests/RunCMake/interface_library/add_custom_command-TARGET-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/interface_library/add_custom_command-TARGET-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/interface_library/add_custom_command-TARGET-stderr.txt b/Tests/RunCMake/interface_library/add_custom_command-TARGET-stderr.txt new file mode 100644 index 0000000..c095262 --- /dev/null +++ b/Tests/RunCMake/interface_library/add_custom_command-TARGET-stderr.txt @@ -0,0 +1,5 @@ +CMake Error at add_custom_command-TARGET.cmake:4 \(add_custom_command\): + Target "iface" is an INTERFACE library that may not have PRE_BUILD, + PRE_LINK, or POST_BUILD commands. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/interface_library/add_custom_command-TARGET.cmake b/Tests/RunCMake/interface_library/add_custom_command-TARGET.cmake new file mode 100644 index 0000000..a5136ef --- /dev/null +++ b/Tests/RunCMake/interface_library/add_custom_command-TARGET.cmake @@ -0,0 +1,6 @@ + +add_library(iface INTERFACE) + +add_custom_command(TARGET iface + COMMAND "${CMAKE_COMMAND}" -E echo test +) |