ENH: fix up several problems with new stuff

This commit is contained in:
Bill Hoffman 2002-11-11 18:10:30 -05:00
parent 928b9dee06
commit 36db45082e
7 changed files with 224 additions and 17 deletions

View File

@ -74,7 +74,7 @@ ENDIF(CMAKE_CXX_COMPILER)
# so unless the variable CMAKE_MODULE_EXISTS is set just
# copy the values from the LIBRARY variables
IF(NOT CMAKE_MODULE_EXISTS)
SET(CMAKE_SHARED_MODULE_C_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS)
SET(CMAKE_SHARED_MODULE_C_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS})
SET(CMAKE_SHARED_MODULE_CXX_FLAGS ${CMAKE_SHARED_LIBRARY_CXX_FLAGS})
SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
SET(CMAKE_SHARED_MODULE_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
@ -161,6 +161,59 @@ SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT}" CAC
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_INIT}" CACHE STRING
"Flags for C compiler.")
SET (CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS_INIT}
CACHE STRING "Flags used by the linker.")
SET (CMAKE_EXE_LINKER_FLAGS_DEBUG ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT} CACHE STRING
"Flags used by the linker during debug builds.")
SET (CMAKE_EXE_LINKER_FLAGS_MINSIZEREL ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT} CACHE STRING
"Flags used by the linker during release minsize builds.")
SET (CMAKE_EXE_LINKER_FLAGS_RELEASE ${CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT} "" CACHE STRING
"Flags used by the linker during release builds.")
SET (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
"Flags used by the linker during Release with Debug Info builds.")
# shared linker flags
SET (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_INIT}
CACHE STRING "Flags used by the linker.")
SET (CMAKE_SHARED_LINKER_FLAGS_DEBUG ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT} CACHE STRING
"Flags used by the linker during debug builds.")
SET (CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL ${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL_INIT}
CACHE STRING
"Flags used by the linker during release minsize builds.")
SET (CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT} "" CACHE STRING
"Flags used by the linker during release builds.")
SET (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
"Flags used by the linker during Release with Debug Info builds.")
# module linker flags
SET (CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_INIT}
CACHE STRING "Flags used by the linker.")
SET (CMAKE_MODULE_LINKER_FLAGS_DEBUG ${CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT} CACHE STRING
"Flags used by the linker during debug builds.")
SET (CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL ${CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL_INIT}
CACHE STRING
"Flags used by the linker during release minsize builds.")
SET (CMAKE_MODULE_LINKER_FLAGS_RELEASE ${CMAKE_MODULE_LINKER_FLAGS_RELEASE_INIT} "" CACHE STRING
"Flags used by the linker during release builds.")
SET (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
"Flags used by the linker during Release with Debug Info builds.")
MARK_AS_ADVANCED(
CMAKE_VERBOSE_MAKEFILE
CMAKE_CXX_FLAGS
@ -169,5 +222,24 @@ CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_DEBUG
CMAKE_C_FLAGS
CMAKE_EXE_LINKER_FLAGS
CMAKE_EXE_LINKER_FLAGS_DEBUG
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
CMAKE_EXE_LINKER_FLAGS_RELEASE
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_SHARED_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS_DEBUG
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
CMAKE_SHARED_LINKER_FLAGS_RELEASE
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_MODULE_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS_DEBUG
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
CMAKE_MODULE_LINKER_FLAGS_RELEASE
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
)
SET(CMAKE_SYSTEM_SPECIFIC_INFORMATION_LOADED 1)

View File

@ -57,6 +57,17 @@ SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-Od")
SET (CMAKE_C_FLAGS_INIT "-w- -whid -waus -tWM")
SET (CMAKE_EXE_LINKER_FLAGS_INIT "-tWM")
SET (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "-v")
SET (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "-v")
SET (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS_INIT})
SET (CMAKE_SHARED_LINKER_FLAGS_DEBUG ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT})
SET (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT})
SET (CMAKE_MODULE_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
SET (CMAKE_MODULE_LINKER_FLAGS_DEBUG ${CMAKE_MODULE_LINKER_FLAGS_DEBUG})
SET (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT})
SET (CMAKE_STANDARD_LIBRARIES "import32.lib" CACHE STRING
"Libraries linked by defalut with all applications.")

View File

@ -57,3 +57,17 @@ MARK_AS_ADVANCED(CMAKE_STANDARD_LIBRARIES)
FIND_PROGRAM(CMAKE_MAKE_PROGRAM NAMES nmake )
SET(CMAKE_BUILD_TOOL ${CMAKE_MAKE_PROGRAM} CACHE INTERNAL
"What is the target build tool cmake is generating for.")
# executable linker flags
SET (CMAKE_EXE_LINKER_FLAGS_INIT "/nologo /STACK:10000000 /machine:I386 /INCREMENTAL:YES")
SET (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug /pdbtype:sept")
SET (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug /pdbtype:sept")
SET (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS_INIT})
SET (CMAKE_SHARED_LINKER_FLAGS_DEBUG ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT})
SET (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT})
SET (CMAKE_MODULE_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}
SET (CMAKE_MODULE_LINKER_FLAGS_DEBUG ${CMAKE_MODULE_LINKER_FLAGS_DEBUG})
SET (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT})

View File

@ -135,6 +135,11 @@ IF(BUILD_TESTING)
ADD_TEST(DumpDocumentation ${CMake_BINARY_DIR}/Source/DumpDocumentation
${CMake_BINARY_DIR}/CMakeDoc.html)
ADD_TEST(SystemInformation ${CMake_BINARY_DIR}/Source/cmaketest
${CMake_SOURCE_DIR}/Tests/SystemInformation
${CMake_BINARY_DIR}/Tests/SystemInformation
DumpInformation)
ADD_TEST(simple ${CMake_BINARY_DIR}/Source/cmaketest
${CMake_SOURCE_DIR}/Tests/Simple
${CMake_BINARY_DIR}/Tests/Simple

View File

@ -1,4 +1,9 @@
link flags
.def file in link shared
CMAKE_CXX_FLAGS are used to link executables
Variables:
@ -52,3 +57,53 @@ CMAKE_X_LIBS
CMAKE_X_CFLAGS
CMAKE_HAS_X
# executable linker flags
SET (CMAKE_EXE_LINKER_FLAGS "/nologo /STACK:10000000 /machine:I386 /INCREMENTAL:YES"
CACHE STRING "Flags used by the linker.")
SET (CMAKE_EXE_LINKER_FLAGS_DEBUG "/debug /pdbtype:sept" CACHE STRING
"Flags used by the linker during debug builds.")
SET (CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "" CACHE STRING
"Flags used by the linker during release minsize builds.")
SET (CMAKE_EXE_LINKER_FLAGS_RELEASE "" CACHE STRING
"Flags used by the linker during release builds.")
SET (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/debug /pdbtype:sept" CACHE STRING
"Flags used by the linker during Release with Debug Info builds.")
# shared linker flags
SET (CMAKE_SHARED_LINKER_FLAGS "/nologo /STACK:10000000 /machine:I386 /INCREMENTAL:YES"
CACHE STRING "Flags used by the linker.")
SET (CMAKE_SHARED_LINKER_FLAGS_DEBUG "/debug /pdbtype:sept" CACHE STRING
"Flags used by the linker during debug builds.")
SET (CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "" CACHE STRING
"Flags used by the linker during release minsize builds.")
SET (CMAKE_SHARED_LINKER_FLAGS_RELEASE "" CACHE STRING
"Flags used by the linker during release builds.")
SET (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "/debug /pdbtype:sept" CACHE STRING
"Flags used by the linker during Release with Debug Info builds.")
# module linker flags
SET (CMAKE_MODULE_LINKER_FLAGS "/nologo /STACK:10000000 /machine:I386 /INCREMENTAL:YES"
CACHE STRING "Flags used by the linker.")
SET (CMAKE_MODULE_LINKER_FLAGS_DEBUG "/debug /pdbtype:sept" CACHE STRING
"Flags used by the linker during debug builds.")
SET (CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "" CACHE STRING
"Flags used by the linker during release minsize builds.")
SET (CMAKE_MODULE_LINKER_FLAGS_RELEASE "" CACHE STRING
"Flags used by the linker during release builds.")
SET (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "/debug /pdbtype:sept" CACHE STRING
"Flags used by the linker during Release with Debug Info builds.")

View File

@ -558,10 +558,9 @@ void cmLocalUnixMakefileGenerator::OutputLinkLibraries(std::ostream& fout,
runtimeDirs.push_back( libpath );
}
}
cmRegularExpression reg(regexp.c_str());
cmRegularExpression reg(regexp.c_str());
cmRegularExpression libname("lib([^/]*)(\\.so|\\.lib|\\.dll|\\.sl|\\.a|\\.dylib).*");
cmRegularExpression libname_noprefix("([^/]*)(\\.so|\\.lib|\\.dll|\\.sl|\\.a|\\.dylib).*");
if(libname.find(file))
{
librariesLinked += libLinkFlag;
@ -696,8 +695,13 @@ cmLocalUnixMakefileGenerator::ExpandRuleVariables(std::string& s,
const char* object,
const char* flags,
const char* objectsquoted,
const char* targetBase)
const char* targetBase,
const char* linkFlags)
{
if(linkFlags)
{
cmSystemTools::ReplaceString(s, "<LINK_FLAGS>", linkFlags);
}
if(flags)
{
cmSystemTools::ReplaceString(s, "<FLAGS>", flags);
@ -748,7 +752,8 @@ void cmLocalUnixMakefileGenerator::OutputLibraryRule(std::ostream& fout,
const char* prefix,
const char* suffix,
const char* createVariable,
const char* comment
const char* comment,
const char* linkFlags
)
{
// create the library name
@ -796,7 +801,8 @@ void cmLocalUnixMakefileGenerator::OutputLibraryRule(std::ostream& fout,
targetFullPath.c_str(),
linklibs.str().c_str(),
0, 0, 0, objsQuoted.c_str(),
targetBaseFullPath.c_str());
targetBaseFullPath.c_str(),
linkFlags);
}
this->OutputMakeRule(fout, comment,
targetFullPath.c_str(),
@ -817,11 +823,24 @@ void cmLocalUnixMakefileGenerator::OutputSharedLibraryRule(std::ostream& fout,
{
createRule = "CMAKE_C_CREATE_SHARED_LIBRARY";
}
std::string buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE");
buildType = cmSystemTools::UpperCase(buildType);
std::string linkFlags = this->GetSafeDefinition("CMAKE_SHARED_LINKER_FLAGS");
linkFlags += " ";
if(buildType.size())
{
std::string build = "CMAKE_SHARED_LINKER_FLAGS_";
build += buildType;
linkFlags += this->GetSafeDefinition(build.c_str());
linkFlags += " ";
}
this->OutputLibraryRule(fout, name, t,
this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_PREFIX"),
this->GetSafeDefinition("CMAKE_SHARED_LIBRARY_SUFFIX"),
createRule,
"shared library");
"shared library",
linkFlags.c_str());
}
void cmLocalUnixMakefileGenerator::OutputModuleLibraryRule(std::ostream& fout,
@ -837,11 +856,23 @@ void cmLocalUnixMakefileGenerator::OutputModuleLibraryRule(std::ostream& fout,
{
createRule = "CMAKE_C_CREATE_SHARED_MODULE";
}
std::string buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE");
buildType = cmSystemTools::UpperCase(buildType);
std::string linkFlags = this->GetSafeDefinition("CMAKE_MODULE_LINKER_FLAGS");
linkFlags += " ";
if(buildType.size())
{
std::string build = "CMAKE_MODULE_LINKER_FLAGS_";
build += buildType;
linkFlags += this->GetSafeDefinition(build.c_str());
linkFlags += " ";
}
this->OutputLibraryRule(fout, name, t,
this->GetSafeDefinition("CMAKE_SHARED_MODULE_PREFIX"),
this->GetSafeDefinition("CMAKE_SHARED_MODULE_SUFFIX"),
createRule,
"shared module");
"shared module",
linkFlags.c_str());
}
@ -862,14 +893,18 @@ void cmLocalUnixMakefileGenerator::OutputStaticLibraryRule(std::ostream& fout,
this->GetSafeDefinition("CMAKE_STATIC_LIBRARY_PREFIX"),
this->GetSafeDefinition("CMAKE_STATIC_LIBRARY_SUFFIX"),
createRule,
"static library");
"static library", 0);
}
void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout,
const char* name,
const cmTarget &t)
const char* name,
const cmTarget &t)
{
std::string linkFlags;
std::string buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE");
buildType = cmSystemTools::UpperCase(buildType);
std::string flags;
std::string target = m_ExecutableOutputPath + name
+ cmSystemTools::GetExecutableExtension();
@ -878,6 +913,15 @@ void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout,
depend += this->CreateMakeVariable(name, "_SRC_OBJS")
+ ") $(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")";
std::vector<std::string> rules;
linkFlags += this->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS");
linkFlags += " ";
if(buildType.size())
{
std::string build = "CMAKE_EXE_LINKER_FLAGS_";
build += buildType;
linkFlags += this->GetSafeDefinition(build.c_str());
linkFlags += " ";
}
if(t.HasCxx())
{
rules.push_back(m_Makefile->GetDefinition("CMAKE_CXX_LINK_EXECUTABLE"));
@ -901,7 +945,6 @@ void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout,
{
commands.push_back(customCommands.c_str());
}
std::string linkFlags;
if(t.GetType() == cmTarget::WIN32_EXECUTABLE)
{
linkFlags += this->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE");
@ -912,16 +955,21 @@ void cmLocalUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout,
linkFlags += this->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE");
linkFlags += " ";
}
for(std::vector<std::string>::iterator i = commands.begin();
i != commands.end(); ++i)
{
cmSystemTools::ReplaceString(*i, "<LINK_FLAGS>", linkFlags.c_str());
this->ExpandRuleVariables(*i,
objs.c_str(),
target.c_str(),
linklibs.str().c_str(),
0, 0, flags.c_str());
0,
0,
flags.c_str(),
0,
0,
linkFlags.c_str());
}
this->OutputMakeRule(fout,
comment.c_str(),
@ -2169,7 +2217,7 @@ OutputBuildObjectFromSource(std::ostream& fout,
0, // no link libs
sourceFile.c_str(),
objectFile.c_str(),
flags.c_str() );
flags.c_str());
}
this->OutputMakeRule(fout,
comment.c_str(),

View File

@ -88,7 +88,8 @@ protected:
const char* prefix,
const char* suffix,
const char* createRule,
const char* comment
const char* comment,
const char* linkFlags
);
void ExpandRuleVariables(std::string& string,
const char* objects=0,
@ -98,7 +99,8 @@ protected:
const char* object =0,
const char* flags = 0,
const char* objectsquoted = 0,
const char* targetBase = 0);
const char* targetBase = 0,
const char* linkFlags = 0);
virtual void OutputSharedLibraryRule(std::ostream&, const char* name,
const cmTarget &);
virtual void OutputModuleLibraryRule(std::ostream&, const char* name,