Merge topic 'COMPILER_TARGET'

2d9ec1d Add compiler target compile options.
This commit is contained in:
Brad King 2013-06-26 09:01:57 -04:00 committed by CMake Topic Stage
commit 1c51798940
4 changed files with 21 additions and 0 deletions

View File

@ -28,6 +28,9 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
if(DEFINED CMAKE_${lang}_VERBOSE_FLAG)
set(CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}")
endif()
if(CMAKE_${lang}_COMPILER_TARGET)
set(CMAKE_FLAGS "${CMAKE_FLAGS} -DCMAKE_${lang}_COMPILER_TARGET=${CMAKE_${lang}_COMPILER_TARGET}")
endif()
try_compile(CMAKE_${lang}_ABI_COMPILED
${CMAKE_BINARY_DIR} ${src}
CMAKE_FLAGS "${CMAKE_FLAGS}"

View File

@ -25,4 +25,5 @@ macro(__compiler_clang lang)
set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
set(CMAKE_${lang}_COMPILE_OPTION_TARGET "-target ")
endmacro()

View File

@ -13,6 +13,9 @@ set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,")
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")
# http://www.qnx.com/developers/docs/6.4.0/neutrino/utilities/q/qcc.html#examples
set(CMAKE_C_COMPILE_OPTION_TARGET "-V")
set(CMAKE_CXX_COMPILE_OPTION_TARGET "-V")
# Shared libraries with no builtin soname may not be linked safely by
# specifying the file path.

View File

@ -1044,11 +1044,20 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
// If this is the compiler then look for the extra variable
// _COMPILER_ARG1 which must be the first argument to the compiler
const char* compilerArg1 = 0;
const char* compilerTarget = 0;
const char* compilerOptionTarget = 0;
if(actualReplace == "CMAKE_${LANG}_COMPILER")
{
std::string arg1 = actualReplace + "_ARG1";
cmSystemTools::ReplaceString(arg1, "${LANG}", lang);
compilerArg1 = this->Makefile->GetDefinition(arg1.c_str());
compilerTarget
= this->Makefile->GetDefinition(
(std::string("CMAKE_") + lang + "_COMPILER_TARGET").c_str());
compilerOptionTarget
= this->Makefile->GetDefinition(
(std::string("CMAKE_") + lang +
"_COMPILE_OPTION_TARGET").c_str());
}
if(actualReplace.find("${LANG}") != actualReplace.npos)
{
@ -1069,6 +1078,11 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
ret += " ";
ret += compilerArg1;
}
if (compilerTarget && compilerOptionTarget)
{
ret += compilerOptionTarget;
ret += compilerTarget;
}
return ret;
}
return replace;