ENH: make sure flags set in CC or CXX environment variables stay with the compiler
This commit is contained in:
parent
ff250565a2
commit
b8b298104b
|
@ -1,4 +1,5 @@
|
||||||
SET(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@")
|
SET(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@")
|
||||||
|
SET(CMAKE_C_COMPILER_ARG1 @CMAKE_C_COMPILER_ARG1@)
|
||||||
SET(CMAKE_AR "@CMAKE_AR@")
|
SET(CMAKE_AR "@CMAKE_AR@")
|
||||||
SET(CMAKE_RANLIB "@CMAKE_RANLIB@")
|
SET(CMAKE_RANLIB "@CMAKE_RANLIB@")
|
||||||
SET(CMAKE_COMPILER_IS_GNUCC @CMAKE_COMPILER_IS_GNUCC@)
|
SET(CMAKE_COMPILER_IS_GNUCC @CMAKE_COMPILER_IS_GNUCC@)
|
||||||
|
|
|
@ -18,7 +18,7 @@ IF(NOT CMAKE_MODULE_EXISTS)
|
||||||
SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
|
SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
|
||||||
ENDIF(NOT CMAKE_MODULE_EXISTS)
|
ENDIF(NOT CMAKE_MODULE_EXISTS)
|
||||||
|
|
||||||
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_ENV_INIT} $ENV{CFLAGS} ${CMAKE_C_FLAGS_INIT}" CACHE STRING
|
SET (CMAKE_C_FLAGS "$ENV{CFLAGS} ${CMAKE_C_FLAGS_INIT}" CACHE STRING
|
||||||
"Flags for C compiler.")
|
"Flags for C compiler.")
|
||||||
|
|
||||||
IF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
|
IF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
SET(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@")
|
SET(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@")
|
||||||
|
SET(CMAKE_CXX_COMPILER_ARG1 @CMAKE_CXX_COMPILER_ARG1@)
|
||||||
SET(CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@)
|
SET(CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@)
|
||||||
SET(CMAKE_CXX_COMPILER_LOADED 1)
|
SET(CMAKE_CXX_COMPILER_LOADED 1)
|
||||||
SET(CMAKE_COMPILER_IS_GNUCXX_RUN 1)
|
SET(CMAKE_COMPILER_IS_GNUCXX_RUN 1)
|
||||||
|
|
|
@ -74,7 +74,7 @@ ENDIF(NOT CMAKE_SHARED_MODULE_RUNTIME_CXX_FLAG_SEP)
|
||||||
# on the initial values computed in the platform/*.cmake files
|
# on the initial values computed in the platform/*.cmake files
|
||||||
# use _INIT variables so that this only happens the first time
|
# use _INIT variables so that this only happens the first time
|
||||||
# and you can set these flags in the cmake cache
|
# and you can set these flags in the cmake cache
|
||||||
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_ENV_INIT} $ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS_INIT}" CACHE STRING
|
SET (CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS_INIT}" CACHE STRING
|
||||||
"Flags used by the compiler during all build types.")
|
"Flags used by the compiler during all build types.")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ IF(NOT CMAKE_C_COMPILER)
|
||||||
# prefer the environment variable CC
|
# prefer the environment variable CC
|
||||||
IF($ENV{CC} MATCHES ".+")
|
IF($ENV{CC} MATCHES ".+")
|
||||||
GET_FILENAME_COMPONENT(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS CMAKE_C_FLAGS_ENV_INIT)
|
GET_FILENAME_COMPONENT(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS CMAKE_C_FLAGS_ENV_INIT)
|
||||||
|
IF(CMAKE_C_FLAGS_ENV_INIT)
|
||||||
|
SET(CMAKE_C_COMPILER_ARG1 ${CMAKE_C_FLAGS_ENV_INIT} CACHE STRING "First argument to C compiler")
|
||||||
|
ENDIF(CMAKE_C_FLAGS_ENV_INIT)
|
||||||
IF(EXISTS ${CMAKE_C_COMPILER_INIT})
|
IF(EXISTS ${CMAKE_C_COMPILER_INIT})
|
||||||
ELSE(EXISTS ${CMAKE_C_COMPILER_INIT})
|
ELSE(EXISTS ${CMAKE_C_COMPILER_INIT})
|
||||||
MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable CC:\n$ENV{CC}.")
|
MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable CC:\n$ENV{CC}.")
|
||||||
|
|
|
@ -11,6 +11,9 @@ IF(NOT CMAKE_CXX_COMPILER)
|
||||||
# prefer the environment variable CXX
|
# prefer the environment variable CXX
|
||||||
IF($ENV{CXX} MATCHES ".+")
|
IF($ENV{CXX} MATCHES ".+")
|
||||||
GET_FILENAME_COMPONENT(CMAKE_CXX_COMPILER_INIT $ENV{CXX} PROGRAM PROGRAM_ARGS CMAKE_CXX_FLAGS_ENV_INIT)
|
GET_FILENAME_COMPONENT(CMAKE_CXX_COMPILER_INIT $ENV{CXX} PROGRAM PROGRAM_ARGS CMAKE_CXX_FLAGS_ENV_INIT)
|
||||||
|
IF(CMAKE_CXX_FLAGS_ENV_INIT)
|
||||||
|
SET(CMAKE_CXX_COMPILER_ARG1 ${CMAKE_CXX_FLAGS_ENV_INIT} CACHE STRING "First argument to CXX compiler")
|
||||||
|
ENDIF(CMAKE_CXX_FLAGS_ENV_INIT)
|
||||||
IF(EXISTS ${CMAKE_CXX_COMPILER_INIT})
|
IF(EXISTS ${CMAKE_CXX_COMPILER_INIT})
|
||||||
ELSE(EXISTS ${CMAKE_CXX_COMPILER_INIT})
|
ELSE(EXISTS ${CMAKE_CXX_COMPILER_INIT})
|
||||||
MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable CXX:\n$ENV{CXX}.\n${CMAKE_CXX_COMPILER_INIT}")
|
MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable CXX:\n$ENV{CXX}.\n${CMAKE_CXX_COMPILER_INIT}")
|
||||||
|
|
|
@ -8,6 +8,9 @@ IF(NOT CMAKE_Fortran_COMPILER)
|
||||||
# prefer the environment variable CC
|
# prefer the environment variable CC
|
||||||
IF($ENV{FC} MATCHES ".+")
|
IF($ENV{FC} MATCHES ".+")
|
||||||
GET_FILENAME_COMPONENT(CMAKE_Fortran_COMPILER_INIT $ENV{FC} PROGRAM PROGRAM_ARGS CMAKE_Fortran_FLAGS_ENV_INIT)
|
GET_FILENAME_COMPONENT(CMAKE_Fortran_COMPILER_INIT $ENV{FC} PROGRAM PROGRAM_ARGS CMAKE_Fortran_FLAGS_ENV_INIT)
|
||||||
|
IF(CMAKE_Fortran_FLAGS_ENV_INIT)
|
||||||
|
SET(CMAKE_Fortran_COMPILER_ARG1 ${CMAKE_Fortran_FLAGS_ENV_INIT} CACHE STRING "First argument to Fortran compiler")
|
||||||
|
ENDIF(CMAKE_Fortran_FLAGS_ENV_INIT)
|
||||||
IF(EXISTS ${CMAKE_Fortran_COMPILER_INIT})
|
IF(EXISTS ${CMAKE_Fortran_COMPILER_INIT})
|
||||||
ELSE(EXISTS ${CMAKE_Fortran_COMPILER_INIT})
|
ELSE(EXISTS ${CMAKE_Fortran_COMPILER_INIT})
|
||||||
MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable FC:\n$ENV{FC}.")
|
MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable FC:\n$ENV{FC}.")
|
||||||
|
|
|
@ -6,6 +6,9 @@ IF(NOT CMAKE_Java_COMPILER)
|
||||||
# prefer the environment variable CC
|
# prefer the environment variable CC
|
||||||
IF($ENV{JAVA_COMPILER} MATCHES ".+")
|
IF($ENV{JAVA_COMPILER} MATCHES ".+")
|
||||||
GET_FILENAME_COMPONENT(CMAKE_Java_COMPILER_INIT $ENV{JAVA_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT)
|
GET_FILENAME_COMPONENT(CMAKE_Java_COMPILER_INIT $ENV{JAVA_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT)
|
||||||
|
IF(CMAKE_Java_FLAGS_ENV_INIT)
|
||||||
|
SET(CMAKE_Java_COMPILER_ARG1 ${CMAKE_Java_FLAGS_ENV_INIT} CACHE STRING "First argument to Java compiler")
|
||||||
|
ENDIF(CMAKE_Java_FLAGS_ENV_INIT)
|
||||||
IF(EXISTS ${CMAKE_Java_COMPILER_INIT})
|
IF(EXISTS ${CMAKE_Java_COMPILER_INIT})
|
||||||
ELSE(EXISTS ${CMAKE_Java_COMPILER_INIT})
|
ELSE(EXISTS ${CMAKE_Java_COMPILER_INIT})
|
||||||
MESSAGE(SEND_ERROR "Could not find compiler set in environment variable JAVA_COMPILER:\n$ENV{JAVA_COMPILER}.")
|
MESSAGE(SEND_ERROR "Could not find compiler set in environment variable JAVA_COMPILER:\n$ENV{JAVA_COMPILER}.")
|
||||||
|
|
|
@ -8,6 +8,9 @@ IF(NOT CMAKE_RC_COMPILER)
|
||||||
# prefer the environment variable CC
|
# prefer the environment variable CC
|
||||||
IF($ENV{RC} MATCHES ".+")
|
IF($ENV{RC} MATCHES ".+")
|
||||||
GET_FILENAME_COMPONENT(CMAKE_RC_COMPILER_INIT $ENV{RC} PROGRAM PROGRAM_ARGS CMAKE_RC_FLAGS_ENV_INIT)
|
GET_FILENAME_COMPONENT(CMAKE_RC_COMPILER_INIT $ENV{RC} PROGRAM PROGRAM_ARGS CMAKE_RC_FLAGS_ENV_INIT)
|
||||||
|
IF(CMAKE_RC_FLAGS_ENV_INIT)
|
||||||
|
SET(CMAKE_RC_COMPILER_ARG1 ${CMAKE_RC_FLAGS_ENV_INIT} CACHE STRING "First argument to RC compiler")
|
||||||
|
ENDIF(CMAKE_RC_FLAGS_ENV_INIT)
|
||||||
IF(EXISTS ${CMAKE_RC_COMPILER_INIT})
|
IF(EXISTS ${CMAKE_RC_COMPILER_INIT})
|
||||||
ELSE(EXISTS ${CMAKE_RC_COMPILER_INIT})
|
ELSE(EXISTS ${CMAKE_RC_COMPILER_INIT})
|
||||||
MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable RC:\n$ENV{RC}.")
|
MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable RC:\n$ENV{RC}.")
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
SET(CMAKE_Fortran_COMPILER "@CMAKE_Fortran_COMPILER@")
|
SET(CMAKE_Fortran_COMPILER "@CMAKE_Fortran_COMPILER@")
|
||||||
|
SET(CMAKE_Fortran_COMPILER_ARG1 "@CMAKE_Fortran_COMPILER_ARG1@")
|
||||||
SET(CMAKE_AR "@CMAKE_AR@")
|
SET(CMAKE_AR "@CMAKE_AR@")
|
||||||
SET(CMAKE_RANLIB "@CMAKE_RANLIB@")
|
SET(CMAKE_RANLIB "@CMAKE_RANLIB@")
|
||||||
SET(CMAKE_COMPILER_IS_GNUG77 @CMAKE_COMPILER_IS_GNUG77@)
|
SET(CMAKE_COMPILER_IS_GNUG77 @CMAKE_COMPILER_IS_GNUG77@)
|
||||||
|
|
|
@ -69,7 +69,7 @@ ENDIF(NOT CMAKE_INCLUDE_FLAG_SEP_Fortran)
|
||||||
|
|
||||||
SET(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.")
|
SET(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.")
|
||||||
|
|
||||||
SET (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS_ENV_INIT} $ENV{FFLAGS} ${CMAKE_Fortran_FLAGS_INIT}" CACHE STRING
|
SET (CMAKE_Fortran_FLAGS "$ENV{FFLAGS} ${CMAKE_Fortran_FLAGS_INIT}" CACHE STRING
|
||||||
"Flags for Fortran compiler.")
|
"Flags for Fortran compiler.")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
SET(CMAKE_Java_COMPILER "@CMAKE_Java_COMPILER@")
|
SET(CMAKE_Java_COMPILER "@CMAKE_Java_COMPILER@")
|
||||||
|
SET(CMAKE_Java_COMPILER_ARG1 "@CMAKE_Java_COMPILER_ARG1@")
|
||||||
SET(CMAKE_Java_RUNTIME "@CMAKE_Java_RUNTIME@")
|
SET(CMAKE_Java_RUNTIME "@CMAKE_Java_RUNTIME@")
|
||||||
SET(CMAKE_Java_ARCHIVE "@CMAKE_Java_ARCHIVE@")
|
SET(CMAKE_Java_ARCHIVE "@CMAKE_Java_ARCHIVE@")
|
||||||
SET(CMAKE_Java_COMPILER_LOADED 1)
|
SET(CMAKE_Java_COMPILER_LOADED 1)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
SET(CMAKE_RC_COMPILER "@CMAKE_RC_COMPILER@")
|
SET(CMAKE_RC_COMPILER "@CMAKE_RC_COMPILER@")
|
||||||
|
SET(CMAKE_RC_COMPILER_ARG1 "@CMAKE_RC_COMPILER_ARG1@")
|
||||||
SET(CMAKE_RC_COMPILER_LOADED 1)
|
SET(CMAKE_RC_COMPILER_LOADED 1)
|
||||||
SET(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc)
|
SET(CMAKE_RC_SOURCE_FILE_EXTENSIONS rc)
|
||||||
SET(CMAKE_RC_OUTPUT_EXTENSION .res)
|
SET(CMAKE_RC_OUTPUT_EXTENSION .res)
|
||||||
|
|
|
@ -8,7 +8,7 @@ SET(CMAKE_SYSTEM_AND_RC_COMPILER_INFO_FILE
|
||||||
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
|
INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
|
||||||
|
|
||||||
|
|
||||||
SET (CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS_ENV_INIT} $ENV{RCFLAGS} ${CMAKE_RC_FLAGS_INIT}" CACHE STRING
|
SET (CMAKE_RC_FLAGS "$ENV{RCFLAGS} ${CMAKE_RC_FLAGS_INIT}" CACHE STRING
|
||||||
"Flags for Fortran compiler.")
|
"Flags for Fortran compiler.")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -833,6 +833,15 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
|
||||||
{
|
{
|
||||||
lang = i->c_str();
|
lang = i->c_str();
|
||||||
std::string actualReplace = ruleReplaceVars[pos];
|
std::string actualReplace = ruleReplaceVars[pos];
|
||||||
|
// 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;
|
||||||
|
if(actualReplace == "CMAKE_${LANG}_COMPILER")
|
||||||
|
{
|
||||||
|
std::string arg1 = actualReplace + "_ARG1";
|
||||||
|
cmSystemTools::ReplaceString(arg1, "${LANG}", lang);
|
||||||
|
compilerArg1 = m_Makefile->GetDefinition(arg1.c_str());
|
||||||
|
}
|
||||||
if(actualReplace.find("${LANG}") != actualReplace.npos)
|
if(actualReplace.find("${LANG}") != actualReplace.npos)
|
||||||
{
|
{
|
||||||
cmSystemTools::ReplaceString(actualReplace, "${LANG}", lang);
|
cmSystemTools::ReplaceString(actualReplace, "${LANG}", lang);
|
||||||
|
@ -843,7 +852,14 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
|
||||||
// if the variable is not a FLAG then treat it like a path
|
// if the variable is not a FLAG then treat it like a path
|
||||||
if(variable.find("_FLAG") == variable.npos)
|
if(variable.find("_FLAG") == variable.npos)
|
||||||
{
|
{
|
||||||
return this->ConvertToOutputForExisting(replace.c_str());
|
std::string ret = this->ConvertToOutputForExisting(replace.c_str());
|
||||||
|
// if there is a required first argument to the compiler add it to the compiler string
|
||||||
|
if(compilerArg1)
|
||||||
|
{
|
||||||
|
ret += " ";
|
||||||
|
ret += compilerArg1;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
return replace;
|
return replace;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue