From 2242006ca1f6834059d23b761dafd4ad7e70661b Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 2 May 2002 15:10:19 -0400 Subject: [PATCH] Debug optimized cache fixes --- Source/CMakeLists.txt | 17 ++++--- Source/cmMakefile.cxx | 17 ++++--- Source/cmTarget.cxx | 49 ++++++++++++++++--- Tests/Complex/Library/CMakeLists.txt | 11 +++++ Tests/ComplexOneConfig/Library/CMakeLists.txt | 11 +++++ .../Library/CMakeLists.txt | 11 +++++ 6 files changed, 92 insertions(+), 24 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 0a27df06b..589c52df7 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -67,14 +67,6 @@ IF (WIN32) ENDIF(NOT UNIX) ENDIF (WIN32) -IF (UNIX) - INCLUDE (${CMake_SOURCE_DIR}/Modules/FindCurses.cmake OPTIONAL) - IF (CURSES_LIBRARY) - SUBDIRS(CursesDialog/form) - INCLUDE(${CMake_SOURCE_DIR}/Source/CursesDialog/CMakeLists.txt) - ENDIF (CURSES_LIBRARY) -ENDIF (UNIX) - SET(SRCS ${SRCS} cmUnixMakefileGenerator.cxx cmUnixMakefileGenerator.h) @@ -91,6 +83,15 @@ ADD_EXECUTABLE(DumpDocumentation cmDumpDocumentation) ADD_EXECUTABLE(ctest ctest.cxx cmSystemTools.cxx cmRegularExpression.cxx) ADD_EXECUTABLE(ccommand ccommand.cxx cmSystemTools.cxx cmMakefile.cxx) + +IF (UNIX) + INCLUDE (${CMake_SOURCE_DIR}/Modules/FindCurses.cmake OPTIONAL) + IF (CURSES_LIBRARY) + SUBDIRS(CursesDialog/form) + INCLUDE(${CMake_SOURCE_DIR}/Source/CursesDialog/CMakeLists.txt) + ENDIF (CURSES_LIBRARY) +ENDIF (UNIX) + IF (NOT DART_ROOT) SET(MAKEPROGRAM ${CMAKE_MAKE_PROGRAM}) ENDIF (NOT DART_ROOT) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 4c31efa88..55acc50c9 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -665,7 +665,16 @@ void cmMakefile::AddLibrary(const char* lname, int shared, default: target.SetType(cmTarget::STATIC_LIBRARY); } + // Clear its dependencies. Otherwise, dependencies might persist + // over changes in CMakeLists.txt, making the information stale and + // hence useless. + std::string depname = lname; + depname += "_LIB_DEPENDS"; + cmCacheManager::GetInstance()-> + AddCacheEntry(depname.c_str(), "", + "Dependencies for target", cmCacheManager::INTERNAL); + target.SetInAll(true); target.GetSourceLists() = srcs; std::vector::iterator j; @@ -723,14 +732,6 @@ void cmMakefile::AddLibrary(const char* lname, int shared, cmCacheManager::INTERNAL); } - // Clear its dependencies. Otherwise, dependencies might persist - // over changes in CMakeLists.txt, making the information stale and - // hence useless. - std::string depname = lname; - depname += "_LIB_DEPENDS"; - cmCacheManager::GetInstance()-> - AddCacheEntry(depname.c_str(), "", - "Dependencies for target", cmCacheManager::INTERNAL); } void cmMakefile::AddExecutable(const char *exeName, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 59900da1c..7d3dda718 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -80,6 +80,25 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, { m_LinkLibraries.push_back( std::pair(lib,llt) ); + if(llt != cmTarget::GENERAL) + { + std::string linkTypeName = this->CanonicalLibraryName(lib); + linkTypeName += "_LINK_TYPE"; + switch(llt) + { + case cmTarget::DEBUG: + mf.AddCacheDefinition(linkTypeName.c_str(), + "debug", "Library is used for debug links only", + cmCacheManager::INTERNAL); + break; + case cmTarget::OPTIMIZED: + mf.AddCacheDefinition(linkTypeName.c_str(), + "optimized", "Library is used for debug links only", + cmCacheManager::INTERNAL); + break; + } + } + mf.AddDependencyToCache( target, lib ); } @@ -127,7 +146,7 @@ cmTarget::AnalyzeLibDependencies( const cmMakefile& mf ) // if a variable expands to nothing. if (lib->first.size() == 0) continue; - std::string cname = CanonicalLibraryName(lib->first); + std::string cname = this->CanonicalLibraryName(lib->first); lib_order.push_back( cname ); if( lib_map.end() == lib_map.find( cname ) ) { @@ -140,7 +159,7 @@ cmTarget::AnalyzeLibDependencies( const cmMakefile& mf ) // have specified them for( LinkLine::iterator i = orig_libs.begin(); i != orig_libs.end(); ++i ) { - GatherDependencies( mf, *i, dep_map, lib_map ); + this->GatherDependencies( mf, *i, dep_map, lib_map ); } // For the rest, get implicit dependencies. A library x depends @@ -193,7 +212,6 @@ cmTarget::AnalyzeLibDependencies( const cmMakefile& mf ) // for all the new libraries added by the dependency analysis. const char* libOutPath = mf.GetDefinition("LIBRARY_OUTPUT_PATH"); bool addLibDirs = (libOutPath==0 || strcmp(libOutPath,"")==0); - m_LinkLibraries.clear(); for( std::vector::reverse_iterator i = link_line.rbegin(); i != link_line.rend(); ++i ) @@ -217,7 +235,22 @@ cmTarget::AnalyzeLibDependencies( const cmMakefile& mf ) } } } - m_LinkLibraries.push_back( std::make_pair(*i,GENERAL) ); + std::string linkType = *i; + linkType += "_LINK_TYPE"; + cmTarget::LinkLibraryType llt = cmTarget::GENERAL; + const char* linkTypeString = mf.GetDefinition( linkType.c_str() ); + if(linkTypeString) + { + if(strcmp(linkTypeString, "debug") == 0) + { + llt = cmTarget::DEBUG; + } + if(strcmp(linkTypeString, "optimized") == 0) + { + llt = cmTarget::OPTIMIZED; + } + } + m_LinkLibraries.push_back( std::make_pair(*i,llt) ); } else { @@ -247,10 +280,10 @@ std::string cmTarget::CanonicalLibraryName( const std::string& lib ) const { return libname_noprefix.match(1); } - else - { - return file; - } + else + { + return file; + } } else { diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt index c354c342e..9feeb271b 100644 --- a/Tests/Complex/Library/CMakeLists.txt +++ b/Tests/Complex/Library/CMakeLists.txt @@ -20,6 +20,17 @@ SOURCE_FILES(LibrarySources SOURCE_FILES_REMOVE(LibrarySources create_file.cxx GENERATED nonexisting_file) ADD_LIBRARY(CMakeTestLibrary LibrarySources) +IF(WIN32) + IF(NOT CYGWIN) + TARGET_LINK_LIBRARIES(CMakeTestLibrary + debug + user32.lib) + TARGET_LINK_LIBRARIES(CMakeTestLibrary + optimized + kernel32.lib) + ENDIF(NOT CYGWIN) +ENDIF(WIN32) + # # Create shared library # diff --git a/Tests/ComplexOneConfig/Library/CMakeLists.txt b/Tests/ComplexOneConfig/Library/CMakeLists.txt index c354c342e..9feeb271b 100644 --- a/Tests/ComplexOneConfig/Library/CMakeLists.txt +++ b/Tests/ComplexOneConfig/Library/CMakeLists.txt @@ -20,6 +20,17 @@ SOURCE_FILES(LibrarySources SOURCE_FILES_REMOVE(LibrarySources create_file.cxx GENERATED nonexisting_file) ADD_LIBRARY(CMakeTestLibrary LibrarySources) +IF(WIN32) + IF(NOT CYGWIN) + TARGET_LINK_LIBRARIES(CMakeTestLibrary + debug + user32.lib) + TARGET_LINK_LIBRARIES(CMakeTestLibrary + optimized + kernel32.lib) + ENDIF(NOT CYGWIN) +ENDIF(WIN32) + # # Create shared library # diff --git a/Tests/ComplexRelativePaths/Library/CMakeLists.txt b/Tests/ComplexRelativePaths/Library/CMakeLists.txt index c354c342e..9feeb271b 100644 --- a/Tests/ComplexRelativePaths/Library/CMakeLists.txt +++ b/Tests/ComplexRelativePaths/Library/CMakeLists.txt @@ -20,6 +20,17 @@ SOURCE_FILES(LibrarySources SOURCE_FILES_REMOVE(LibrarySources create_file.cxx GENERATED nonexisting_file) ADD_LIBRARY(CMakeTestLibrary LibrarySources) +IF(WIN32) + IF(NOT CYGWIN) + TARGET_LINK_LIBRARIES(CMakeTestLibrary + debug + user32.lib) + TARGET_LINK_LIBRARIES(CMakeTestLibrary + optimized + kernel32.lib) + ENDIF(NOT CYGWIN) +ENDIF(WIN32) + # # Create shared library #