ENH: UNIX, CYGWIN, WIN32, APPLE, QNXNTO and BEOS are not longer set in

cmMakefile.cxx, but now in the platform files and are now valid for the
target platform, not the host platform.
New variables CMAKE_HOST_WIN32, CMAKE_HOST_UNIX, CMAKE_HOST_APPLE and
CMAKE_HOST_CYGWIN have been added in cmMakefile.cxx (...and have now to be
used in all cmake files which are executed before
CMakeSystemSpecificInformation.cmake is loaded). For compatibility the old
set is set to the new one in CMakeDetermineSystem.cmake and reset before the
system platform files are loaded, so custom language or compiler modules
which use these should still work.

Alex
This commit is contained in:
Alexander Neundorf 2007-08-09 14:45:23 -04:00
parent 9bd32386c2
commit 176fe63d15
10 changed files with 48 additions and 18 deletions

View File

@ -6,13 +6,13 @@
MACRO(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
# Store the compiler identification source file.
SET(CMAKE_${lang}_COMPILER_ID_SRC "${src}")
IF(WIN32 AND NOT CYGWIN)
IF(CMAKE_HOST_WIN32 AND NOT CMAKE_HOST_CYGWIN)
# This seems to escape spaces:
#FILE(TO_NATIVE_PATH "${CMAKE_${lang}_COMPILER_ID_SRC}"
# CMAKE_${lang}_COMPILER_ID_SRC)
STRING(REGEX REPLACE "/" "\\\\" CMAKE_${lang}_COMPILER_ID_SRC
"${CMAKE_${lang}_COMPILER_ID_SRC}")
ENDIF(WIN32 AND NOT CYGWIN)
ENDIF(CMAKE_HOST_WIN32 AND NOT CMAKE_HOST_CYGWIN)
# Make sure user-specified compiler flags are used.
IF(CMAKE_${lang}_FLAGS)

View File

@ -28,7 +28,7 @@
# find out on which system cmake runs
IF(UNIX)
IF(CMAKE_HOST_UNIX)
FIND_PROGRAM(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin )
IF(CMAKE_UNAME)
EXEC_PROGRAM(uname ARGS -s OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_NAME)
@ -53,12 +53,25 @@ IF(UNIX)
STRING(REGEX REPLACE "\"" "" CMAKE_HOST_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}")
STRING(REGEX REPLACE "/" "_" CMAKE_HOST_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}")
ENDIF(CMAKE_UNAME)
ELSE(UNIX)
IF(WIN32)
ELSE(CMAKE_HOST_UNIX)
IF(CMAKE_HOST_WIN32)
SET (CMAKE_HOST_SYSTEM_NAME "Windows")
SET (CMAKE_HOST_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITECTURE}")
ENDIF(WIN32)
ENDIF(UNIX)
ENDIF(CMAKE_HOST_WIN32)
ENDIF(CMAKE_HOST_UNIX)
# this is for compatibility
# with cmake 2.4 these variables were compiled in
# now that cmake has to separate between host and target platform
# two sets are needed. For compatibility the old set of variables is here
# set to the compiled-in values, so they still work in custom
# language or compiler modules where they might be used.
# After that they are reset in CMakeSystemSpecificInformation.cmake
# and then set according to the current target platform in the Modules/${CMAKE_SYSTEM_NAME}.cmake file
SET(APPLE ${CMAKE_HOST_APPLE})
SET(UNIX ${CMAKE_HOST_UNIX})
SET(CYGWIN ${CMAKE_HOST_CYGWIN})
SET(WIN32 ${CMAKE_HOST_WIN32})
# if a toolchain file is used, the user wants to cross compile.
# in this case read the toolchain file and keep the CMAKE_HOST_SYSTEM_*

View File

@ -3,6 +3,17 @@
# It is included after the compiler has been determined, so
# we know things like the compiler name and if the compiler is gnu.
# before cmake 2.6 these variables were compiled-in in cmake
# now they are set in the Modules/${CMAKE_SYSTEM_NAME}.cmake file
# In order to keep custom language or compiler files working which might use
# these variables, they are set to the value of the compiled-in variables in
# CMakeDetermineSystem.cmake and reset here.
SET(APPLE )
SET(UNIX )
SET(CYGWIN )
SET(WIN32 )
# include Generic system information
INCLUDE(CMakeGenericSystem)

View File

@ -1,3 +1,5 @@
SET(BEOS 1)
# GCC is the default compiler on BeOS.
INCLUDE(${CMAKE_ROOT}/Modules/Platform/gcc.cmake)

View File

@ -1,3 +1,6 @@
SET(WIN32 1)
SET(CYGWIN 1)
SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,--export-all-symbols -Wl,--enable-auto-import")
SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
SET(CMAKE_DL_LIBS "-lgdi32" )

View File

@ -1,3 +1,5 @@
SET(APPLE 1)
SET(CMAKE_SHARED_LIBRARY_PREFIX "lib")
SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
SET(CMAKE_SHARED_MODULE_PREFIX "lib")

View File

@ -1,3 +1,5 @@
SET(QNXNTO 1)
# GCC is the default compiler on QNX 6.3.
INCLUDE(${CMAKE_ROOT}/Modules/Platform/gcc.cmake)

View File

@ -1,3 +1,5 @@
SET(UNIX 1)
# also add the install directory of the running cmake to the search directories
# CMAKE_ROOT is CMAKE_INSTALL_PREFIX/share/cmake, so we need to go two levels up
GET_FILENAME_COMPONENT(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)

View File

@ -1,3 +1,5 @@
SET(WIN32 1)
SET(CMAKE_STATIC_LIBRARY_PREFIX "")
SET(CMAKE_STATIC_LIBRARY_SUFFIX ".lib")
SET(CMAKE_SHARED_LIBRARY_PREFIX "") # lib

View File

@ -1912,23 +1912,16 @@ void cmMakefile::RemoveVariablesInString(std::string& source,
void cmMakefile::AddDefaultDefinitions()
{
#if defined(_WIN32) || defined(__CYGWIN__)
this->AddDefinition("WIN32", "1");
this->AddDefinition("CMAKE_HOST_WIN32", "1");
#else
this->AddDefinition("UNIX", "1");
this->AddDefinition("CMAKE_HOST_UNIX", "1");
#endif
// Cygwin is more like unix so enable the unix commands
#if defined(__CYGWIN__)
this->AddDefinition("UNIX", "1");
this->AddDefinition("CYGWIN", "1");
this->AddDefinition("CMAKE_HOST_UNIX", "1");
#endif
#if defined(__APPLE__)
this->AddDefinition("APPLE", "1");
#endif
#if defined(__QNXNTO__)
this->AddDefinition("QNXNTO", "1");
#endif
#if defined(__BEOS__)
this->AddDefinition("BEOS", "1");
this->AddDefinition("CMAKE_HOST_APPLE", "1");
#endif
char temp[1024];