ENH: add support for language flags at rule expansion time
This commit is contained in:
parent
36080b04bb
commit
3f532f5489
|
@ -86,7 +86,7 @@ INCLUDE(CMakeCommonLanguageInclude)
|
|||
# create a C shared library
|
||||
IF(NOT CMAKE_C_CREATE_SHARED_LIBRARY)
|
||||
SET(CMAKE_C_CREATE_SHARED_LIBRARY
|
||||
"<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
"<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
ENDIF(NOT CMAKE_C_CREATE_SHARED_LIBRARY)
|
||||
|
||||
# create a C shared module just copy the shared library rule
|
||||
|
|
|
@ -137,7 +137,7 @@ INCLUDE(CMakeCommonLanguageInclude)
|
|||
# create a shared C++ library
|
||||
IF(NOT CMAKE_CXX_CREATE_SHARED_LIBRARY)
|
||||
SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
|
||||
"<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
"<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
ENDIF(NOT CMAKE_CXX_CREATE_SHARED_LIBRARY)
|
||||
|
||||
# create a c++ shared module copy the shared library rule by default
|
||||
|
|
|
@ -102,7 +102,7 @@ INCLUDE(CMakeCommonLanguageInclude)
|
|||
# create a Fortran shared library
|
||||
IF(NOT CMAKE_Fortran_CREATE_SHARED_LIBRARY)
|
||||
SET(CMAKE_Fortran_CREATE_SHARED_LIBRARY
|
||||
"<CMAKE_Fortran_COMPILER> <CMAKE_SHARED_LIBRARY_Fortran_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
"<CMAKE_Fortran_COMPILER> <CMAKE_SHARED_LIBRARY_Fortran_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_Fortran_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
ENDIF(NOT CMAKE_Fortran_CREATE_SHARED_LIBRARY)
|
||||
|
||||
# create a Fortran shared module just copy the shared library rule
|
||||
|
|
|
@ -19,12 +19,12 @@ SET(CMAKE_FIND_LIBRARY_PREFIXES "cyg" "lib")
|
|||
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dll" ".dll.a" ".a")
|
||||
|
||||
SET(CMAKE_C_CREATE_SHARED_MODULE
|
||||
"<CMAKE_C_COMPILER> <CMAKE_SHARED_MODULE_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
"<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
SET(CMAKE_CXX_CREATE_SHARED_MODULE
|
||||
"<CMAKE_CXX_COMPILER> <CMAKE_SHARED_MODULE_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
"<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_MODULE_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
|
||||
SET(CMAKE_C_CREATE_SHARED_LIBRARY
|
||||
"<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> <OBJECTS> <LINK_LIBRARIES>")
|
||||
"<CMAKE_C_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> <OBJECTS> <LINK_LIBRARIES>")
|
||||
SET(CMAKE_CXX_CREATE_SHARED_LIBRARY
|
||||
"<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> <OBJECTS> <LINK_LIBRARIES>")
|
||||
"<CMAKE_CXX_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> <OBJECTS> <LINK_LIBRARIES>")
|
||||
INCLUDE(Platform/UnixPaths)
|
||||
|
|
|
@ -604,6 +604,10 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
|
|||
return targetQuoted;
|
||||
}
|
||||
}
|
||||
if(variable == "LANGUAGE_COMPILE_FLAGS")
|
||||
{
|
||||
return replaceValues.LanguageCompileFlags;
|
||||
}
|
||||
if(variable == "TARGET")
|
||||
{
|
||||
return replaceValues.Target;
|
||||
|
|
|
@ -196,6 +196,7 @@ public:
|
|||
const char* TargetSOName;
|
||||
const char* TargetInstallNameDir;
|
||||
const char* LinkFlags;
|
||||
const char* LanguageCompileFlags;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
|
|
@ -431,7 +431,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
|
|||
vars.TargetInstallNameDir = install_name_dir.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
std::string langFlags;
|
||||
this->LocalGenerator
|
||||
->AddLanguageFlags(langFlags, linkLanguage,
|
||||
this->LocalGenerator->m_ConfigurationName.c_str());
|
||||
vars.LanguageCompileFlags = langFlags.c_str();
|
||||
// Expand placeholders in the commands.
|
||||
this->LocalGenerator->m_TargetImplib = targetOutPathImport;
|
||||
for(std::vector<std::string>::iterator i = commands.begin();
|
||||
|
|
Loading…
Reference in New Issue