made CMakeLib shared on windows

This commit is contained in:
Ken Martin 2002-08-21 11:57:12 -04:00
parent 38dfd36fda
commit 34c7c1b78d
7 changed files with 88 additions and 24 deletions

View File

@ -10,6 +10,8 @@ cmRegularExpression.cxx
cmSourceFile.cxx
cmSystemTools.cxx
cmDirectory.cxx
cmDynamicLoader.cxx
cmCPluginAPI.cxx
cmCommands.cxx
cmTarget.cxx
cmCustomCommand.cxx
@ -24,6 +26,7 @@ cmMakefileGenerator.h
cmRegularExpression.h
cmSourceFile.h
cmSystemTools.h
cmDynamicLoader.h
cmDirectory.h
cmCommands.h
cmTarget.h
@ -72,15 +75,23 @@ SET(SRCS ${SRCS} cmUnixMakefileGenerator.cxx cmUnixMakefileGenerator.h)
# create a library used by the command line and the GUI
ADD_LIBRARY(CMakeLib ${SRCS})
IF (WIN32)
ADD_LIBRARY(CMakeLib SHARED ${SRCS})
ELSE (WIN32)
ADD_LIBRARY(CMakeLib ${SRCS})
ENDIF (WIN32)
# always link in the library
LINK_LIBRARIES(CMakeLib)
# the library is found here
LINK_DIRECTORIES(${CMake_BINARY_DIR}/Source)
ADD_EXECUTABLE(cmake cmakemain.cxx)
ADD_EXECUTABLE(DumpDocumentation cmDumpDocumentation)
ADD_EXECUTABLE(ctest ctest.cxx cmSystemTools.cxx cmRegularExpression.cxx)
ADD_EXECUTABLE(ctest ctest.cxx)
TARGET_LINK_LIBRARIES(cmake CMakeLib)
TARGET_LINK_LIBRARIES(DumpDocumentation CMakeLib)
TARGET_LINK_LIBRARIES(ctest CMakeLib)
IF (UNIX)
INCLUDE (${CMake_SOURCE_DIR}/Modules/FindCurses.cmake OPTIONAL)
@ -98,8 +109,11 @@ CONFIGURE_FILE(
${CMake_SOURCE_DIR}/Source/cmaketest.h.in
${CMake_BINARY_DIR}/Source/cmaketest.h ESCAPE_QUOTES)
ADD_EXECUTABLE(cmaketest cmaketest.cxx cmSystemTools.cxx)
ADD_EXECUTABLE(cmaketest cmaketest.cxx)
TARGET_LINK_LIBRARIES(cmaketest CMakeLib)
#ADD_LIBRARY(TEST_PLUGIN SHARED cmSimpleCommandPlugin.c)
#TARGET_LINK_LIBRARIES(TEST_PLUGIN CMakeLib)
IF(BUILD_TESTING)
ADD_TEST(DumpDocumentation ${CMake_BINARY_DIR}/Source/DumpDocumentation

View File

@ -536,3 +536,18 @@ bool cmCacheManager::IsAdvanced(const char* key)
}
return false;
}
bool cmCacheManager::CacheIterator::IsAtEnd()
{
return position == m_Container.m_Cache.end();
}
void cmCacheManager::CacheIterator::Begin()
{
position = m_Container.m_Cache.begin();
}
void cmCacheManager::CacheIterator::Next()
{
++position;
}

View File

@ -36,7 +36,30 @@ public:
std::string m_HelpString;
CacheEntryType m_Type;
};
public:
class CacheIterator
{
public:
CM_EXPORT void Begin();
CM_EXPORT bool IsAtEnd();
CM_EXPORT void Next();
const char *GetName() {
return position->first.c_str(); }
CacheEntry const &GetEntry() {
return position->second; }
cmCacheManager const &m_Container;
std::map<cmStdString, CacheEntry>::const_iterator position;
CacheIterator(cmCacheManager const &foo) : m_Container(foo) {
this->Begin();
}
};
friend class cmCacheManager::CacheIterator;
///! return an iterator to iterate through the cache map
cmCacheManager::CacheIterator NewIterator()
{
return CacheIterator(*this);
}
typedef std::map<cmStdString, CacheEntry> CacheEntryMap;
/**
* Types for the cache entries. These are useful as
@ -47,35 +70,36 @@ public:
*/
static CacheEntryType StringToType(const char*);
///! Singleton pattern get instance of the cmCacheManager.
static cmCacheManager* GetInstance();
CM_EXPORT static cmCacheManager* GetInstance();
///! Load a cache for given makefile. Loads from ouput home.
bool LoadCache(cmMakefile*);
CM_EXPORT bool LoadCache(cmMakefile*);
///! Load a cache for given makefile. Loads from path/CMakeCache.txt.
bool LoadCache(const char* path);
bool LoadCache(const char* path, bool internal);
bool LoadCache(const char* path, bool internal,
CM_EXPORT bool LoadCache(const char* path);
CM_EXPORT bool LoadCache(const char* path, bool internal);
CM_EXPORT bool LoadCache(const char* path, bool internal,
std::set<std::string>& excludes,
std::set<std::string>& includes);
///! Save cache for given makefile. Saves to ouput home CMakeCache.txt.
bool SaveCache(cmMakefile*) ;
CM_EXPORT bool SaveCache(cmMakefile*) ;
///! Save cache for given makefile. Saves to ouput path/CMakeCache.txt
bool SaveCache(const char* path) ;
CM_EXPORT bool SaveCache(const char* path) ;
///! Print the cache to a stream
void PrintCache(std::ostream&) const;
///! Get the cache map ivar.
const CacheEntryMap &GetCacheMap() const { return m_Cache; }
///! Get a cache entry object for a key
CacheEntry *GetCacheEntry(const char *key);
CM_EXPORT CacheEntry *GetCacheEntry(const char *key);
bool IsAdvanced(const char* key);
CM_EXPORT bool IsAdvanced(const char* key);
///! Remove an entry from the cache
void RemoveCacheEntry(const char* key);
CM_EXPORT void RemoveCacheEntry(const char* key);
///! Get the number of entries in the cache
CM_EXPORT int GetSize() {
return m_Cache.size(); }
///! Break up a line like VAR:type="value" into var, type and value
static bool ParseEntry(const char* entry,

View File

@ -37,17 +37,17 @@ public:
* in that directory. 0 is returned if the directory can not be
* opened, 1 if it is opened.
*/
bool Load(const char* dir);
CM_EXPORT bool Load(const char* dir);
/**
* Return the number of files in the current directory.
*/
size_t GetNumberOfFiles() { return m_Files.size();}
CM_EXPORT size_t GetNumberOfFiles() { return m_Files.size();}
/**
* Return the file at the given index, the indexing is 0 based
*/
const char* GetFile(size_t );
CM_EXPORT const char* GetFile(size_t );
private:
std::vector<std::string> m_Files; // Array of Files

View File

@ -45,8 +45,8 @@ struct cmListFile
class cmListFileCache
{
public:
static cmListFileCache* GetInstance();
static void ClearCache();
static CM_EXPORT cmListFileCache* GetInstance();
static CM_EXPORT void ClearCache();
/** Return the cached version of the given file.

View File

@ -21,6 +21,17 @@
#ifndef cmStandardIncludes_h
#define cmStandardIncludes_h
/* CM_EXPORT is used by the plugin API */
#ifdef _WIN32
#ifdef CMakeLib_EXPORTS
#define CM_EXPORT __declspec( dllexport )
#else
#define CM_EXPORT __declspec( dllimport )
#endif
#else
#define CM_EXPORT
#endif
// include configure generated header to define
// CMAKE_NO_ANSI_STREAM_HEADERS and CMAKE_NO_STD_NAMESPACE
#if defined(CMAKE_HAS_AUTOCONF) || defined(CMAKE_BUILD_WITH_CMAKE)

View File

@ -27,7 +27,7 @@ class cmMakefile;
* cmSystemTools is a class that provides helper functions
* for the CMake build system.
*/
class cmSystemTools
class CM_EXPORT cmSystemTools
{
public:
/**