diff options
86 files changed, 1885 insertions, 275 deletions
diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index b14cf34..ded8cf6 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -48,3 +48,6 @@ SET(CMAKE_C_HAS_ISYSROOT "@CMAKE_C_HAS_ISYSROOT@") SET(CMAKE_C_IMPLICIT_LINK_LIBRARIES "@CMAKE_C_IMPLICIT_LINK_LIBRARIES@") SET(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_DIRECTORIES@") + +@SET_CMAKE_CMCLDEPS_EXECUTABLE@ +@SET_CMAKE_CL_SHOWINCLUDE_PREFIX@ diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index bc3bc2e..5b6376a 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -49,3 +49,6 @@ SET(CMAKE_CXX_HAS_ISYSROOT "@CMAKE_CXX_HAS_ISYSROOT@") SET(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "@CMAKE_CXX_IMPLICIT_LINK_LIBRARIES@") SET(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES@") + +@SET_CMAKE_CMCLDEPS_EXECUTABLE@ +@SET_CMAKE_CL_SHOWINCLUDE_PREFIX@ diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake index 608b833..9dc9cbd 100644 --- a/Modules/CMakeCXXInformation.cmake +++ b/Modules/CMakeCXXInformation.cmake @@ -100,6 +100,18 @@ IF(NOT CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS) SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}) ENDIF(NOT CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS) +IF(NOT CMAKE_CXX_COMPILE_OPTIONS_PIC) + SET(CMAKE_CXX_COMPILE_OPTIONS_PIC ${CMAKE_C_COMPILE_OPTIONS_PIC}) +ENDIF(NOT CMAKE_CXX_COMPILE_OPTIONS_PIC) + +IF(NOT CMAKE_CXX_COMPILE_OPTIONS_PIE) + SET(CMAKE_CXX_COMPILE_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE}) +ENDIF(NOT CMAKE_CXX_COMPILE_OPTIONS_PIE) + +IF(NOT CMAKE_CXX_COMPILE_OPTIONS_DLL) + SET(CMAKE_CXX_COMPILE_OPTIONS_DLL ${CMAKE_C_COMPILE_OPTIONS_DLL}) +ENDIF(NOT CMAKE_CXX_COMPILE_OPTIONS_DLL) + IF(NOT CMAKE_SHARED_LIBRARY_CXX_FLAGS) SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS}) ENDIF(NOT CMAKE_SHARED_LIBRARY_CXX_FLAGS) diff --git a/Modules/CMakeClDeps.cmake b/Modules/CMakeClDeps.cmake new file mode 100644 index 0000000..6815e2b --- /dev/null +++ b/Modules/CMakeClDeps.cmake @@ -0,0 +1,37 @@ + +#============================================================================= +# Copyright 2012 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# +# When using Ninja cl.exe is wrapped by cmcldeps to extract the included +# headers for dependency tracking. +# +# cmcldeps path is set, and cmcldeps needs to know the localized string +# in front of each include path, so it can remove it. +# + +IF(MSVC_C_ARCHITECTURE_ID AND CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_C_COMPILER AND CMAKE_COMMAND) + STRING(REPLACE "cmake.exe" "cmcldeps.exe" CMAKE_CMCLDEPS_EXECUTABLE ${CMAKE_COMMAND}) + SET(showdir ${CMAKE_BINARY_DIR}/CMakeFiles/ShowIncludes) + FILE(WRITE ${showdir}/foo.h "\n") + FILE(WRITE ${showdir}/main.c "#include \"foo.h\" \nint main(){}\n") + EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} /nologo /showIncludes ${showdir}/main.c + WORKING_DIRECTORY ${showdir} OUTPUT_VARIABLE showOut) + STRING(REPLACE main.c "" showOut1 ${showOut}) + STRING(REPLACE "/" "\\" header1 ${showdir}/foo.h) + STRING(TOLOWER ${header1} header2) + STRING(REPLACE ${header2} "" showOut2 ${showOut1}) + STRING(REPLACE "\n" "" showOut3 ${showOut2}) + SET(SET_CMAKE_CMCLDEPS_EXECUTABLE "SET(CMAKE_CMCLDEPS_EXECUTABLE \"${CMAKE_CMCLDEPS_EXECUTABLE}\")") + SET(SET_CMAKE_CL_SHOWINCLUDE_PREFIX "SET(CMAKE_CL_SHOWINCLUDE_PREFIX \"${showOut3}\")") +ENDIF() diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index e2e268f..53f558e 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -165,9 +165,7 @@ ENDIF (CMAKE_CROSSCOMPILING AND "${CMAKE_C_COMPILER_ID}" MATCHES "GNU" AND NOT _CMAKE_TOOLCHAIN_PREFIX) - - - +INCLUDE(${CMAKE_ROOT}/Modules/CMakeClDeps.cmake) INCLUDE(CMakeFindBinUtils) IF(MSVC_C_ARCHITECTURE_ID) SET(SET_MSVC_C_ARCHITECTURE_ID diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 8298369..7f8f3ec 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -173,6 +173,7 @@ ENDIF (CMAKE_CROSSCOMPILING AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND NOT _CMAKE_TOOLCHAIN_PREFIX) +INCLUDE(${CMAKE_ROOT}/Modules/CMakeClDeps.cmake) INCLUDE(CMakeFindBinUtils) IF(MSVC_CXX_ARCHITECTURE_ID) SET(SET_MSVC_CXX_ARCHITECTURE_ID diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 686cc9b..67f5a59 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -302,12 +302,6 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_VENDOR lang) TIMEOUT 10 ) - IF("${lang}" STREQUAL "ASM") - MESSAGE(STATUS "Checked for ${vendor}") - MESSAGE(STATUS " Output: -${output}-") - MESSAGE(STATUS " Result: -${result}-") - ENDIF("${lang}" STREQUAL "ASM") - IF("${output}" MATCHES "${regex}") FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Checking whether the ${lang} compiler is ${vendor} using \"${flags}\" " diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake index 2cbd7f8..d962f4c 100644 --- a/Modules/CMakeFortranInformation.cmake +++ b/Modules/CMakeFortranInformation.cmake @@ -74,6 +74,18 @@ ENDIF() # catch any modules SET(CMAKE_NEEDS_REQUIRES_STEP_Fortran_FLAG 1) +IF(NOT CMAKE_Fortran_COMPILE_OPTIONS_PIC) + SET(CMAKE_Fortran_COMPILE_OPTIONS_PIC ${CMAKE_C_COMPILE_OPTIONS_PIC}) +ENDIF(NOT CMAKE_Fortran_COMPILE_OPTIONS_PIC) + +IF(NOT CMAKE_Fortran_COMPILE_OPTIONS_PIE) + SET(CMAKE_Fortran_COMPILE_OPTIONS_PIE ${CMAKE_C_COMPILE_OPTIONS_PIE}) +ENDIF(NOT CMAKE_Fortran_COMPILE_OPTIONS_PIE) + +IF(NOT CMAKE_Fortran_COMPILE_OPTIONS_DLL) + SET(CMAKE_Fortran_COMPILE_OPTIONS_DLL ${CMAKE_C_COMPILE_OPTIONS_DLL}) +ENDIF(NOT CMAKE_Fortran_COMPILE_OPTIONS_DLL) + # Create a set of shared library variable specific to Fortran # For 90% of the systems, these are the same flags as the C versions # so if these are not set just copy the flags from the c version diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake index fe81dc9..bd3b94d 100644 --- a/Modules/CPackDeb.cmake +++ b/Modules/CPackDeb.cmake @@ -68,7 +68,11 @@ # CPACK_DEBIAN_PACKAGE_HOMEPAGE # Mandatory : NO # Default : - -# The URL of the web site for this package +# The URL of the web site for this package, preferably (when applicable) the +# site from which the original source can be obtained and any additional +# upstream documentation or information may be found. +# The content of this field is a simple URL without any surrounding +# characters such as <>. ##end ##variable # CPACK_DEBIAN_PACKAGE_SHLIBDEPS @@ -137,6 +141,30 @@ # Packages can declare in their control file that they should overwrite # files in certain other packages, or completely replace other packages. ##end +##variable +# CPACK_DEBIAN_PACKAGE_RECOMMENDS +# Mandatory : NO +# Default : - +# see http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps +# Allows packages to declare a strong, but not absolute, dependency on other packages. +##end +##variable +# CPACK_DEBIAN_PACKAGE_SUGGESTS +# Mandatory : NO +# Default : - +# see http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps +# Allows packages to declare a suggested package install grouping. +##end +##variable +# CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA +# Mandatory : NO +# Default : - +# This variable allow advanced user to add custom script to the control.tar.gz +# Typical usage is for conffiles, postinst, postrm, prerm. +# Usage: SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA +# "${CMAKE_CURRENT_SOURCE_DIR/prerm;${CMAKE_CURRENT_SOURCE_DIR}/postrm") +##end + #============================================================================= # Copyright 2007-2009 Kitware, Inc. diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake index cba746f..ae93512 100644 --- a/Modules/CPackRPM.cmake +++ b/Modules/CPackRPM.cmake @@ -488,7 +488,10 @@ FOREACH(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLIC MESSAGE("CPackRPM:Debug: User defined ${_PACKAGE_HEADER_NAME}:\n ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") ENDIF(CPACK_RPM_PACKAGE_DEBUG) SET(TMP_RPM_${_RPM_SPEC_HEADER} "${_PACKAGE_HEADER_NAME}: ${CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP}") -ENDIF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) + ELSE(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) + # Do not forget to unset previously set header (from previous component) + UNSET(TMP_RPM_${_RPM_SPEC_HEADER}) + ENDIF(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) ENDFOREACH(_RPM_SPEC_HEADER) # CPACK_RPM_SPEC_INSTALL_POST diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index c74c179..6aecf90 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -21,6 +21,10 @@ set(__COMPILER_GNU 1) macro(__compiler_gnu lang) # Feature flags. set(CMAKE_${lang}_VERBOSE_FLAG "-v") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4) + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") + endif() set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") diff --git a/Modules/Compiler/SCO.cmake b/Modules/Compiler/SCO.cmake index d3deeb1..f673c8f 100644 --- a/Modules/Compiler/SCO.cmake +++ b/Modules/Compiler/SCO.cmake @@ -20,6 +20,9 @@ set(__COMPILER_SCO 1) macro(__compiler_sco lang) # Feature flags. + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC -Kpic) + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE -Kpie) + set(CMAKE_${lang}_COMPILE_OPTIONS_DLL -belf) set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-Kpic -belf") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-belf -Wl,-Bexport") endmacro() diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index 656eea6..a1a3ae1 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -1,5 +1,7 @@ SET(CMAKE_C_VERBOSE_FLAG "-#") +SET(CMAKE_C_COMPILE_OPTIONS_PIC -KPIC) +SET(CMAKE_C_COMPILE_OPTIONS_PIE -KPIE) SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-KPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-G") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-R") diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index 3e07e8e..702e424 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -1,5 +1,7 @@ SET(CMAKE_CXX_VERBOSE_FLAG "-v") +SET(CMAKE_CXX_COMPILE_OPTIONS_PIC -KPIC) +SET(CMAKE_CXX_COMPILE_OPTIONS_PIE -KPIE) SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-KPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "-G") SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-R") diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake index 7130192..ce7f255 100644 --- a/Modules/FindBZip2.cmake +++ b/Modules/FindBZip2.cmake @@ -22,11 +22,15 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -FIND_PATH(BZIP2_INCLUDE_DIR bzlib.h ) +SET(_BZIP2_PATHS PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Bzip2;InstallPath]" + ) + +FIND_PATH(BZIP2_INCLUDE_DIR bzlib.h ${_BZIP2_PATHS} PATH_SUFFIXES include) IF (NOT BZIP2_LIBRARIES) - FIND_LIBRARY(BZIP2_LIBRARY_RELEASE NAMES bz2 bzip2 ) - FIND_LIBRARY(BZIP2_LIBRARY_DEBUG NAMES bzip2d ) + FIND_LIBRARY(BZIP2_LIBRARY_RELEASE NAMES bz2 bzip2 ${_BZIP2_PATHS} PATH_SUFFIXES lib) + FIND_LIBRARY(BZIP2_LIBRARY_DEBUG NAMES bzip2d ${_BZIP2_PATHS} PATH_SUFFIXES lib) INCLUDE(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) SELECT_LIBRARY_CONFIGURATIONS(BZIP2) diff --git a/Modules/FindBullet.cmake b/Modules/FindBullet.cmake index aea9158..c96755f 100644 --- a/Modules/FindBullet.cmake +++ b/Modules/FindBullet.cmake @@ -63,7 +63,7 @@ _FIND_BULLET_LIBRARY(BULLET_DYNAMICS_LIBRARY_DEBUG BulletDynamics_Debug BulletD _FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY BulletCollision) _FIND_BULLET_LIBRARY(BULLET_COLLISION_LIBRARY_DEBUG BulletCollision_Debug BulletCollision_d) _FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY BulletMath LinearMath) -_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG BulletMath_Debug BulletMath_d LinearMath_d) +_FIND_BULLET_LIBRARY(BULLET_MATH_LIBRARY_DEBUG BulletMath_Debug BulletMath_d LinearMath_Debug LinearMath_d) _FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY BulletSoftBody) _FIND_BULLET_LIBRARY(BULLET_SOFTBODY_LIBRARY_DEBUG BulletSoftBody_Debug BulletSoftBody_d) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 478ebcb..11ff196 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -45,13 +45,19 @@ IF(PythonLibs_FIND_VERSION) STRING(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" _PYTHON_FIND_MAJ_MIN "${PythonLibs_FIND_VERSION}") STRING(REGEX REPLACE "^([0-9]+).*" "\\1" _PYTHON_FIND_MAJ "${_PYTHON_FIND_MAJ_MIN}") UNSET(_PYTHON_FIND_OTHER_VERSIONS) - IF(NOT PythonLibs_FIND_VERSION_EXACT) + IF(PythonLibs_FIND_VERSION_EXACT) + IF(_PYTHON_FIND_MAJ_MIN STREQUAL PythonLibs_FIND_VERSION) + SET(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}") + ELSE(_PYTHON_FIND_MAJ_MIN STREQUAL PythonLibs_FIND_VERSION) + SET(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}" "${_PYTHON_FIND_MAJ_MIN}") + ENDIF(_PYTHON_FIND_MAJ_MIN STREQUAL PythonLibs_FIND_VERSION) + ELSE(PythonLibs_FIND_VERSION_EXACT) FOREACH(_PYTHON_V ${_PYTHON${_PYTHON_FIND_MAJ}_VERSIONS}) IF(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN) LIST(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V}) ENDIF() ENDFOREACH() - ENDIF(NOT PythonLibs_FIND_VERSION_EXACT) + ENDIF(PythonLibs_FIND_VERSION_EXACT) UNSET(_PYTHON_FIND_MAJ_MIN) UNSET(_PYTHON_FIND_MAJ) ELSE(PythonLibs_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$") diff --git a/Modules/Platform/BeOS.cmake b/Modules/Platform/BeOS.cmake index 41aa8f7..3ffb67c 100644 --- a/Modules/Platform/BeOS.cmake +++ b/Modules/Platform/BeOS.cmake @@ -1,6 +1,8 @@ SET(BEOS 1) SET(CMAKE_DL_LIBS root be) +SET(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") +SET(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-nostart") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") diff --git a/Modules/Platform/BlueGeneP-base.cmake b/Modules/Platform/BlueGeneP-base.cmake index 926dbc0..c0241e1 100644 --- a/Modules/Platform/BlueGeneP-base.cmake +++ b/Modules/Platform/BlueGeneP-base.cmake @@ -85,11 +85,15 @@ set(CMAKE_DL_LIBS "dl") macro(__BlueGeneP_set_dynamic_flags compiler_id lang) if (${compiler_id} STREQUAL XL) # Flags for XL compilers if we explicitly detected XL + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-qpic") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-qpie") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-qpic") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-qmkshrobj -qnostaticlink") set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-qnostaticlink -qnostaticlink=libgcc") else() # Assume flags for GNU compilers (if the ID is GNU *or* anything else). + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") set(BGP_${lang}_DYNAMIC_EXE_FLAGS "-dynamic") diff --git a/Modules/Platform/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake index 5aad45b..eae313a 100644 --- a/Modules/Platform/CYGWIN-GNU.cmake +++ b/Modules/Platform/CYGWIN-GNU.cmake @@ -35,7 +35,10 @@ macro(__cygwin_compiler_gnu lang) set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>") - set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") # No -fPIC on cygwin + # No -fPIC on cygwin + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") # Initialize C link type selection flags. These flags are used when # building a shared library, shared module, or executable that links diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake index 033db06..82fe961 100644 --- a/Modules/Platform/FreeBSD.cmake +++ b/Modules/Platform/FreeBSD.cmake @@ -1,6 +1,8 @@ IF(EXISTS /usr/include/dlfcn.h) SET(CMAKE_DL_LIBS "") - SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic + SET(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") + SET(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath diff --git a/Modules/Platform/HP-UX-HP.cmake b/Modules/Platform/HP-UX-HP.cmake index bce0a8b..871ea13 100644 --- a/Modules/Platform/HP-UX-HP.cmake +++ b/Modules/Platform/HP-UX-HP.cmake @@ -19,6 +19,7 @@ endif() set(__HPUX_COMPILER_HP 1) macro(__hpux_compiler_hp lang) + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "+Z") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "+Z") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-Wl,-E,+nodefaultrpath -b -L/usr/lib") set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-Wl,+s,-E,+nodefaultrpath") diff --git a/Modules/Platform/Haiku.cmake b/Modules/Platform/Haiku.cmake index 8277a24..9dda3c5 100644 --- a/Modules/Platform/Haiku.cmake +++ b/Modules/Platform/Haiku.cmake @@ -1,6 +1,8 @@ SET(BEOS 1) SET(CMAKE_DL_LIBS root be) +SET(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") +SET(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-nostart") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") diff --git a/Modules/Platform/Linux-Intel.cmake b/Modules/Platform/Linux-Intel.cmake index dea8b90..47bf246 100644 --- a/Modules/Platform/Linux-Intel.cmake +++ b/Modules/Platform/Linux-Intel.cmake @@ -31,6 +31,8 @@ if(NOT XIAR) endif(NOT XIAR) macro(__linux_compiler_intel lang) + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") diff --git a/Modules/Platform/Linux-PGI.cmake b/Modules/Platform/Linux-PGI.cmake index ef06acd..3cbb35c 100644 --- a/Modules/Platform/Linux-PGI.cmake +++ b/Modules/Platform/Linux-PGI.cmake @@ -20,6 +20,8 @@ set(__LINUX_COMPILER_PGI 1) macro(__linux_compiler_pgi lang) # Shared library compile and link flags. + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") endmacro() diff --git a/Modules/Platform/Linux-PathScale.cmake b/Modules/Platform/Linux-PathScale.cmake index c131af2..d230ab2 100644 --- a/Modules/Platform/Linux-PathScale.cmake +++ b/Modules/Platform/Linux-PathScale.cmake @@ -20,6 +20,8 @@ set(__LINUX_COMPILER_PATHSCALE 1) macro(__linux_compiler_pathscale lang) # Shared library compile and link flags. + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") endmacro() diff --git a/Modules/Platform/MP-RAS.cmake b/Modules/Platform/MP-RAS.cmake index 1e3e239..ff22a4f 100644 --- a/Modules/Platform/MP-RAS.cmake +++ b/Modules/Platform/MP-RAS.cmake @@ -1,6 +1,10 @@ IF(CMAKE_SYSTEM MATCHES "MP-RAS-02*.") + SET(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC) + SET(CMAKE_C_COMPILE_OPTIONS_PIE -K PIE) SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") ELSE(CMAKE_SYSTEM MATCHES "MP-RAS-02*.") + SET(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC) + SET(CMAKE_C_COMPILE_OPTIONS_PIE -K PIE) SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-Bexport") ENDIF(CMAKE_SYSTEM MATCHES "MP-RAS-02*.") diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake index 0fb8636..e1b66b8 100644 --- a/Modules/Platform/NetBSD.cmake +++ b/Modules/Platform/NetBSD.cmake @@ -1,6 +1,8 @@ IF(EXISTS /usr/include/dlfcn.h) SET(CMAKE_DL_LIBS "") - SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic + SET(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") + SET(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,") # -rpath diff --git a/Modules/Platform/OSF1.cmake b/Modules/Platform/OSF1.cmake index 076410a..49a30e9 100644 --- a/Modules/Platform/OSF1.cmake +++ b/Modules/Platform/OSF1.cmake @@ -4,7 +4,9 @@ IF(CMAKE_SYSTEM MATCHES "OSF1-1.[012]") ENDIF(CMAKE_SYSTEM MATCHES "OSF1-1.[012]") IF(CMAKE_SYSTEM MATCHES "OSF1-1.*") # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2 - SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fpic") # -pic + SET(CMAKE_C_COMPILE_OPTIONS_PIC "-fpic") + SET(CMAKE_C_COMPILE_OPTIONS_PIE "-fpie") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fpic") # -pic SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fpic") # -pic ENDIF(CMAKE_SYSTEM MATCHES "OSF1-1.*") diff --git a/Modules/Platform/SINIX.cmake b/Modules/Platform/SINIX.cmake index 4592fdd..e0809f8 100644 --- a/Modules/Platform/SINIX.cmake +++ b/Modules/Platform/SINIX.cmake @@ -1,2 +1,4 @@ +SET(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC) +SET(CMAKE_C_COMPILE_OPTIONS_PIE "") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") INCLUDE(Platform/UnixPaths) diff --git a/Modules/Platform/SunOS.cmake b/Modules/Platform/SunOS.cmake index 2291c34..de287aa 100644 --- a/Modules/Platform/SunOS.cmake +++ b/Modules/Platform/SunOS.cmake @@ -1,6 +1,8 @@ IF(CMAKE_SYSTEM MATCHES "SunOS-4.*") - SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-PIC") - SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-r") + SET(CMAKE_C_COMPILE_OPTIONS_PIC "-PIC") + SET(CMAKE_C_COMPILE_OPTIONS_PIE "-PIE") + SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-PIC") + SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-r") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-R") SET(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") ENDIF(CMAKE_SYSTEM MATCHES "SunOS-4.*") diff --git a/Modules/Platform/UNIX_SV.cmake b/Modules/Platform/UNIX_SV.cmake index 3b50e0a..869b3a6 100644 --- a/Modules/Platform/UNIX_SV.cmake +++ b/Modules/Platform/UNIX_SV.cmake @@ -1,3 +1,5 @@ +SET(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC) +SET(CMAKE_C_COMPILE_OPTIONS_PIE "") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-Wl,-Bexport") INCLUDE(Platform/UnixPaths) diff --git a/Modules/Platform/UnixWare.cmake b/Modules/Platform/UnixWare.cmake index c324bc8..3112ee1 100644 --- a/Modules/Platform/UnixWare.cmake +++ b/Modules/Platform/UnixWare.cmake @@ -1,3 +1,5 @@ +SET(CMAKE_C_COMPILE_OPTIONS_PIC -K PIC) +SET(CMAKE_C_COMPILE_OPTIONS_PIE "") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-K PIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-Wl,-Bexport") INCLUDE(Platform/UnixPaths) diff --git a/Modules/Platform/Windows-Embarcadero.cmake b/Modules/Platform/Windows-Embarcadero.cmake index 87b3767..62e8eb7 100644 --- a/Modules/Platform/Windows-Embarcadero.cmake +++ b/Modules/Platform/Windows-Embarcadero.cmake @@ -76,7 +76,8 @@ SET (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_SHARED_LINKER_FLAGS_R macro(__embarcadero_language lang) - set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "${_tD}") + set(CMAKE_${lang}_COMPILE_OPTIONS_DLL "${_tD}") # Note: This variable is a ';' separated list + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "${_tD}") # ... while this is a space separated string. # compile a source file into an object file # place <DEFINES> outside the response file because Borland refuses diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake index dd47692..1a2ee5e 100644 --- a/Modules/Platform/Windows-GNU.cmake +++ b/Modules/Platform/Windows-GNU.cmake @@ -77,7 +77,11 @@ macro(__windows_compiler_gnu lang) endforeach(type) endif() - set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") # No -fPIC on Windows + # No -fPIC on Windows + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "") + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "") + set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "") + set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS ${__WINDOWS_GNU_LD_RESPONSE}) set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1) diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake index e1140df..14b3b81 100644 --- a/Modules/Platform/Windows-wcl386.cmake +++ b/Modules/Platform/Windows-wcl386.cmake @@ -20,7 +20,8 @@ SET (CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT "debug all" ) SET (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all" ) SET (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all" ) -set (CMAKE_SHARED_LIBRARY_C_FLAGS "-bd" ) +set(CMAKE_C_COMPILE_OPTIONS_DLL "-bd") # Note: This variable is a ';' separated list +set(CMAKE_SHARED_LIBRARY_C_FLAGS "-bd") # ... while this is a space separated string. SET(CMAKE_RC_COMPILER "rc" ) diff --git a/Modules/Platform/syllable.cmake b/Modules/Platform/syllable.cmake index 3ce42f6..2d11d08 100644 --- a/Modules/Platform/syllable.cmake +++ b/Modules/Platform/syllable.cmake @@ -10,7 +10,9 @@ SET(CMAKE_DL_LIBS "dl") -SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic +SET(CMAKE_C_COMPILE_OPTIONS_PIC "-fPIC") +SET(CMAKE_C_COMPILE_OPTIONS_PIE "-fPIE") +SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") # -pic SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") # -shared SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") # +s, flag for exe link to use shared lib SET(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index 30cc920..0b2d1b8 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -533,9 +533,9 @@ function (find_jar VARIABLE) endif (${_state} STREQUAL "name") endforeach (arg ${ARGN}) - if (${_jar_names} STREQUAL "") + if (NOT _jar_names) message(FATAL_ERROR "find_jar: No name to search for given") - endif (${_jar_names} STREQUAL "") + endif (NOT _jar_names) foreach (jar_name ${_jar_names}) foreach (version ${_jar_versions}) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 46bdec6..2c6bc76 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -361,11 +361,11 @@ ENDIF (WIN32) # on platforms where it does not pass all tests. # Enforce Ninja support by setting CMAKE_USE_NINJA set(_CMAKE_DEFAULT_NINJA_VALUE TRUE) -if(WIN32 OR APPLE) +if(APPLE) SET(_CMAKE_DEFAULT_NINJA_VALUE FALSE) endif() SET(CMAKE_ENABLE_NINJA ${_CMAKE_DEFAULT_NINJA_VALUE} CACHE BOOL - "Enable the ninja generator for CMake. On Windows and OSX broken") + "Enable the ninja generator for CMake. When enabled, some CMake tests still fail on OSX") MARK_AS_ADVANCED(CMAKE_ENABLE_NINJA) IF(CMAKE_ENABLE_NINJA) MESSAGE(STATUS "Ninja generator enabled.") @@ -383,8 +383,13 @@ IF(CMAKE_ENABLE_NINJA) cmNinjaUtilityTargetGenerator.h ) ADD_DEFINITIONS(-DCMAKE_USE_NINJA) + IF(WIN32 AND NOT CYGWIN AND NOT BORLAND) + SET_SOURCE_FILES_PROPERTIES(cmcldeps.cxx PROPERTIES COMPILE_DEFINITIONS _WIN32_WINNT=0x0501) + ADD_EXECUTABLE(cmcldeps cmcldeps.cxx) + INSTALL_TARGETS(/bin cmcldeps) + ENDIF() ELSE() - MESSAGE(STATUS "Ninja generator disabled, enforce with -DCMAKE_ENABLE_NINJA=ON") + MESSAGE(STATUS "Ninja generator disabled, enable it with -DCMAKE_ENABLE_NINJA=ON") ENDIF() # create a library used by the command line and the GUI diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 174a317..3f48c27 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -2,5 +2,5 @@ SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MINOR 8) SET(CMake_VERSION_PATCH 8) -SET(CMake_VERSION_TWEAK 20120610) +SET(CMake_VERSION_TWEAK 20120619) #SET(CMake_VERSION_RC 1) diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index c1d0e9d..fd39eec 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -102,16 +102,17 @@ bool cmAddLibraryCommand STATIC. But at this point we know only the name of the target, but not yet its linker language. */ if ((type != cmTarget::STATIC_LIBRARY) && + (type != cmTarget::OBJECT_LIBRARY) && (this->Makefile->GetCMakeInstance()->GetPropertyAsBool( "TARGET_SUPPORTS_SHARED_LIBS") == false)) { - std::string msg = "ADD_LIBRARY for library "; - msg += args[0]; - msg += " is used with the "; - msg += type==cmTarget::SHARED_LIBRARY ? "SHARED" : "MODULE"; - msg += " option, but the target platform supports only STATIC libraries. " - "Building it STATIC instead. This may lead to problems."; - cmSystemTools::Message(msg.c_str() ,"Warning"); + cmOStringStream w; + w << + "ADD_LIBRARY called with " << + (type==cmTarget::SHARED_LIBRARY ? "SHARED" : "MODULE") << + " option but the target platform does not support dynamic linking. " + "Building a STATIC library instead. This may lead to problems."; + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str()); type = cmTarget::STATIC_LIBRARY; } diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index dc6b749..b410e44 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -240,6 +240,7 @@ bool cmArchiveWrite::AddFile(const char* file, // Clear acl and xattr fields not useful for distribution. archive_entry_acl_clear(e); archive_entry_xattr_clear(e); + archive_entry_set_fflags(e, 0, 0); if(archive_write_header(this->Archive, e) != ARCHIVE_OK) { this->Error = "archive_write_header: "; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index ed485e3..1ae7035 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -281,6 +281,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv) flag += this->Makefile->GetSafeDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); cmakeFlags.push_back(flag); } + if(this->Makefile->GetDefinition("CMAKE_POSITION_INDEPENDENT_CODE")!=0) + { + fprintf(fout, "SET(CMAKE_POSITION_INDEPENDENT_CODE \"ON\")\n"); + } /* Use a random file name to avoid rapid creation and deletion of the same executable name (some filesystems fail on that). */ diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index 9e33d75..592d931 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -1350,6 +1350,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm) "See that target property for additional information.", false, "Variables that Control the Build"); + cm->DefineProperty + ("CMAKE_POSITION_INDEPENDENT_FLAGS", cmProperty::VARIABLE, + "Default value for POSITION_INDEPENDENT_CODE of targets.", + "This variable is used to initialize the " + "POSITION_INDEPENDENT_CODE property on all the targets. " + "See that target property for additional information.", + false, + "Variables that Control the Build"); // Variables defined when the a language is enabled These variables will // also be defined whenever CMake has loaded its support for compiling (LANG) diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 65077b3..ab11307 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -34,6 +34,9 @@ cmExtraEclipseCDT4Generator this->SupportedGlobalGenerators.push_back("MinGW Makefiles"); // this->SupportedGlobalGenerators.push_back("MSYS Makefiles"); #endif +#ifdef CMAKE_USE_NINJA + this->SupportedGlobalGenerators.push_back("Ninja"); +#endif this->SupportedGlobalGenerators.push_back("Unix Makefiles"); this->SupportsVirtualFolders = true; @@ -286,6 +289,9 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() // set the make command std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"); + const std::string makeArgs = mf->GetSafeDefinition( + "CMAKE_ECLIPSE_MAKE_ARGUMENTS"); + fout << "\t\t\t\t<dictionary>\n" "\t\t\t\t\t<key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>\n" @@ -293,7 +299,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() "\t\t\t\t</dictionary>\n" "\t\t\t\t<dictionary>\n" "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.command</key>\n" - "\t\t\t\t\t<value>" + this->GetEclipsePath(make) + "</value>\n" + "\t\t\t\t\t<value>" << this->GetEclipsePath(make) << "</value>\n" "\t\t\t\t</dictionary>\n" "\t\t\t\t<dictionary>\n" "\t\t\t\t\t<key>org.eclipse.cdt.make.core.contents</key>\n" @@ -305,7 +311,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() "\t\t\t\t</dictionary>\n" "\t\t\t\t<dictionary>\n" "\t\t\t\t\t<key>org.eclipse.cdt.make.core.build.arguments</key>\n" - "\t\t\t\t\t<value></value>\n" + "\t\t\t\t\t<value>" << makeArgs << "</value>\n" "\t\t\t\t</dictionary>\n" "\t\t\t\t<dictionary>\n" "\t\t\t\t\t<key>org.eclipse.cdt.make.core.buildLocation</key>\n" @@ -1067,9 +1073,8 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const } //insert rules for compiling, preprocessing and assembling individual files - cmLocalUnixMakefileGenerator3* lumg=(cmLocalUnixMakefileGenerator3*)*it; std::vector<std::string> objectFileTargets; - lumg->GetIndividualFileTargets(objectFileTargets); + (*it)->GetIndividualFileTargets(objectFileTargets); for(std::vector<std::string>::const_iterator fit=objectFileTargets.begin(); fit != objectFileTargets.end(); ++fit) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index d69431e..5da5a01 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1003,7 +1003,9 @@ protected: // Match rules are case-insensitive on some platforms. #if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__) std::string lower = cmSystemTools::LowerCase(file); - file = lower.c_str(); + const char* file_to_match = lower.c_str(); +#else + const char* file_to_match = file; #endif // Collect properties from all matching rules. @@ -1012,7 +1014,7 @@ protected: for(std::vector<MatchRule>::iterator mr = this->MatchRules.begin(); mr != this->MatchRules.end(); ++mr) { - if(mr->Regex.find(file)) + if(mr->Regex.find(file_to_match)) { matched = true; result.Exclude |= mr->Properties.Exclude; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index f883041..a47ca36 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -586,6 +586,16 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages, } } // end if in try compile } // end need test language + // Store the shared library flags so that we can satisfy CMP0018 + std::string sharedLibFlagsVar = "CMAKE_SHARED_LIBRARY_"; + sharedLibFlagsVar += lang; + sharedLibFlagsVar += "_FLAGS"; + const char* sharedLibFlags = + mf->GetSafeDefinition(sharedLibFlagsVar.c_str()); + if (sharedLibFlags) + { + this->LanguageToOriginalSharedLibFlags[lang] = sharedLibFlags; + } } // end for each language // Now load files that can override any settings on the platform or for @@ -2107,6 +2117,17 @@ cmGlobalGenerator::GenerateRuleFile(std::string const& output) const } //---------------------------------------------------------------------------- +std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage( + std::string const& l) +{ + if(this->LanguageToOriginalSharedLibFlags.count(l) > 0) + { + return this->LanguageToOriginalSharedLibFlags[l]; + } + return ""; +} + +//---------------------------------------------------------------------------- void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*, const char*, std::string&) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 8535edc..ce91793 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -277,6 +277,8 @@ public: i.e. "Can I build Debug and Release in the same tree?" */ virtual bool IsMultiConfig() { return false; } + std::string GetSharedLibFlagsForLanguage(std::string const& lang); + /** Generate an <output>.rule file path for a given command output. */ virtual std::string GenerateRuleFile(std::string const& output) const; @@ -359,6 +361,7 @@ private: std::map<cmStdString, cmStdString> LanguageToOutputExtension; std::map<cmStdString, cmStdString> ExtensionToLanguage; std::map<cmStdString, int> LanguageToLinkerPreference; + std::map<cmStdString, cmStdString> LanguageToOriginalSharedLibFlags; // Record hashes for rules and outputs. struct RuleHash { char Data[32]; }; diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx index 56b9e9c..f699448 100644 --- a/Source/cmGlobalKdevelopGenerator.cxx +++ b/Source/cmGlobalKdevelopGenerator.cxx @@ -44,6 +44,9 @@ cmGlobalKdevelopGenerator::cmGlobalKdevelopGenerator() :cmExternalMakefileProjectGenerator() { this->SupportedGlobalGenerators.push_back("Unix Makefiles"); +#ifdef CMAKE_USE_NINJA + this->SupportedGlobalGenerators.push_back("Ninja"); +#endif } void cmGlobalKdevelopGenerator::Generate() diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 0e89fab..c3989c0 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -43,12 +43,13 @@ void cmGlobalNinjaGenerator::WriteComment(std::ostream& os, std::string replace = comment; std::string::size_type lpos = 0; std::string::size_type rpos; + os << "\n#############################################\n"; while((rpos = replace.find('\n', lpos)) != std::string::npos) { os << "# " << replace.substr(lpos, rpos - lpos) << "\n"; lpos = rpos + 1; } - os << "# " << replace.substr(lpos) << "\n"; + os << "# " << replace.substr(lpos) << "\n\n"; } static bool IsIdentChar(char c) @@ -66,7 +67,7 @@ std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string &ident, if (std::find_if(ident.begin(), ident.end(), std::not1(std::ptr_fun(IsIdentChar))) != ident.end()) { static unsigned VarNum = 0; - std::ostringstream names; + cmOStringStream names; names << "ident" << VarNum++; vars << names.str() << " = " << ident << "\n"; return "$" + names.str(); @@ -89,7 +90,10 @@ std::string cmGlobalNinjaGenerator::EncodePath(const std::string &path) { std::string result = path; #ifdef _WIN32 - cmSystemTools::ReplaceString(result, "/", "\\"); + if(UsingMinGW) + cmSystemTools::ReplaceString(result, "\\", "/"); + else + cmSystemTools::ReplaceString(result, "/", "\\"); #endif return EncodeLiteral(result); } @@ -101,7 +105,8 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, const cmNinjaDeps& explicitDeps, const cmNinjaDeps& implicitDeps, const cmNinjaDeps& orderOnlyDeps, - const cmNinjaVars& variables) + const cmNinjaVars& variables, + int cmdLineLimit) { // Make sure there is a rule. if(rule.empty()) @@ -123,50 +128,60 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os, cmGlobalNinjaGenerator::WriteComment(os, comment); - std::ostringstream builds; + cmOStringStream arguments; // TODO: Better formatting for when there are multiple input/output files. - // Write outputs files. - builds << "build"; - for(cmNinjaDeps::const_iterator i = outputs.begin(); - i != outputs.end(); - ++i) - builds << " " << EncodeIdent(EncodePath(*i), os); - builds << ":"; - - // Write the rule. - builds << " " << rule; - // Write explicit dependencies. for(cmNinjaDeps::const_iterator i = explicitDeps.begin(); i != explicitDeps.end(); ++i) - builds << " " << EncodeIdent(EncodePath(*i), os); + arguments << " " << EncodeIdent(EncodePath(*i), os); // Write implicit dependencies. if(!implicitDeps.empty()) { - builds << " |"; + arguments << " |"; for(cmNinjaDeps::const_iterator i = implicitDeps.begin(); i != implicitDeps.end(); ++i) - builds << " " << EncodeIdent(EncodePath(*i), os); + arguments << " " << EncodeIdent(EncodePath(*i), os); } // Write order-only dependencies. if(!orderOnlyDeps.empty()) { - builds << " ||"; + arguments << " ||"; for(cmNinjaDeps::const_iterator i = orderOnlyDeps.begin(); i != orderOnlyDeps.end(); ++i) - builds << " " << EncodeIdent(EncodePath(*i), os); + arguments << " " << EncodeIdent(EncodePath(*i), os); } - builds << "\n"; + arguments << "\n"; + + + cmOStringStream builds; + + // Write outputs files. + builds << "build"; + for(cmNinjaDeps::const_iterator i = outputs.begin(); + i != outputs.end(); + ++i) + builds << " " << EncodeIdent(EncodePath(*i), os); + builds << ":"; + - os << builds.str(); + // Write the rule. + builds << " " << rule; + + // check if a response file rule should be used + const std::string args = arguments.str(); + if (cmdLineLimit > 0 && + (args.size() + + builds.str().size()) > (size_t)cmdLineLimit) + builds << "_RSPFILE"; + + os << builds.str() << args; // Write the variables bound to this build statement. for(cmNinjaVars::const_iterator i = variables.begin(); @@ -200,6 +215,7 @@ void cmGlobalNinjaGenerator::AddCustomCommandRule() "$DESC", "Rule for running custom commands.", /*depfile*/ "", + /*rspfile*/ "", /*restat*/ true); } @@ -211,10 +227,17 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command, const cmNinjaDeps& deps, const cmNinjaDeps& orderOnlyDeps) { + std::string cmd = command; +#ifdef _WIN32 + if (cmd.empty()) + // TODO Shouldn't an empty command be handled by ninja? + cmd = "cmd.exe /c"; +#endif + this->AddCustomCommandRule(); cmNinjaVars vars; - vars["COMMAND"] = command; + vars["COMMAND"] = cmd; vars["DESC"] = EncodeLiteral(description); cmGlobalNinjaGenerator::WriteBuild(*this->BuildFileStream, @@ -233,6 +256,7 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, const std::string& description, const std::string& comment, const std::string& depfile, + const std::string& rspfile, bool restat, bool generator) { @@ -277,6 +301,14 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, os << "description = " << description << "\n"; } + if(!rspfile.empty()) + { + cmGlobalNinjaGenerator::Indent(os, 1); + os << "rspfile = " << rspfile << "\n"; + cmGlobalNinjaGenerator::Indent(os, 1); + os << "rspfile_content = $in" << "\n"; + } + if(restat) { cmGlobalNinjaGenerator::Indent(os, 1); @@ -288,6 +320,8 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os, cmGlobalNinjaGenerator::Indent(os, 1); os << "generator = 1\n"; } + + os << "\n"; } void cmGlobalNinjaGenerator::WriteVariable(std::ostream& os, @@ -350,6 +384,7 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator() this->FindMakeProgramFile = "CMakeNinjaFindMake.cmake"; } + //---------------------------------------------------------------------------- // Virtual public methods. @@ -404,16 +439,19 @@ void cmGlobalNinjaGenerator cmMakefile *mf, bool optional) { - this->cmGlobalGenerator::EnableLanguage(languages, mf, optional); std::string path; for(std::vector<std::string>::const_iterator l = languages.begin(); l != languages.end(); ++l) { + std::vector<std::string> language; + language.push_back(*l); + if(*l == "NONE") { + this->cmGlobalGenerator::EnableLanguage(language, mf, optional); continue; } - if(*l == "Fortran") + else if(*l == "Fortran") { std::string message = "The \""; message += this->GetName(); @@ -422,10 +460,25 @@ void cmGlobalNinjaGenerator message += "\" yet."; cmSystemTools::Error(message.c_str()); } + else if(*l == "RC") + { + // check if mingw is used + if(mf->IsOn("CMAKE_COMPILER_IS_MINGW")) + { + UsingMinGW = true; + std::string rc = cmSystemTools::FindProgram("windres"); + if(rc.empty()) + rc = "windres.exe";; + mf->AddDefinition("CMAKE_RC_COMPILER", rc.c_str()); + } + } + this->cmGlobalGenerator::EnableLanguage(language, mf, optional); this->ResolveLanguageCompiler(*l, mf, optional); } } +bool cmGlobalNinjaGenerator::UsingMinGW = false; + // Implemented by: // cmGlobalUnixMakefileGenerator3 // cmGlobalVisualStudio10Generator @@ -483,12 +536,15 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, const std::string& description, const std::string& comment, const std::string& depfile, + const std::string& rspfile, bool restat, bool generator) { // Do not add the same rule twice. if (this->HasRule(name)) + { return; + } this->Rules.insert(name); cmGlobalNinjaGenerator::WriteRule(*this->RulesFileStream, @@ -497,6 +553,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name, description, comment, depfile, + rspfile, restat, generator); } @@ -767,7 +824,7 @@ void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias, // Insert the alias into the map. If the alias was already present in the // map and referred to another target, mark it as ambiguous. std::pair<TargetAliasMap::iterator, bool> newAlias = - TargetAliases.insert(make_pair(alias, target)); + TargetAliases.insert(std::make_pair(alias, target)); if (newAlias.second && newAlias.first->second != target) newAlias.first->second = 0; } @@ -825,7 +882,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) cmLocalGenerator *lg = this->LocalGenerators[0]; cmMakefile* mfRoot = lg->GetMakefile(); - std::ostringstream cmd; + cmOStringStream cmd; cmd << lg->ConvertToOutputFormat( mfRoot->GetRequiredDefinition("CMAKE_COMMAND"), cmLocalGenerator::SHELL) @@ -841,6 +898,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) "Re-running CMake...", "Rule for re-running cmake.", /*depfile=*/ "", + /*rspfile=*/ "", /*restat=*/ false, /*generator=*/ true); @@ -870,14 +928,26 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os) cmNinjaDeps()); } +std::string cmGlobalNinjaGenerator::ninjaCmd() const +{ + cmLocalGenerator* lgen = this->LocalGenerators[0]; + if (lgen) { + return lgen->ConvertToOutputFormat( + lgen->GetMakefile()->GetRequiredDefinition("CMAKE_MAKE_PROGRAM"), + cmLocalGenerator::SHELL); + } + return "ninja"; +} + void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) { WriteRule(*this->RulesFileStream, "CLEAN", - "ninja -t clean", + (ninjaCmd() + " -t clean").c_str(), "Cleaning all built files...", "Rule for cleaning all built files.", /*depfile=*/ "", + /*rspfile=*/ "", /*restat=*/ false, /*generator=*/ false); WriteBuild(os, @@ -894,10 +964,11 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os) { WriteRule(*this->RulesFileStream, "HELP", - "ninja -t targets", + (ninjaCmd() + " -t tagets").c_str(), "All primary targets available:", "Rule for printing all primary targets available.", /*depfile=*/ "", + /*rspfile=*/ "", /*restat=*/ false, /*generator=*/ false); WriteBuild(os, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 7b6b9b7..e939f61 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -16,6 +16,8 @@ # include "cmGlobalGenerator.h" # include "cmNinjaTypes.h" +//#define NINJA_GEN_VERBOSE_FILES + class cmLocalGenerator; class cmGeneratedFileStream; class cmGeneratorTarget; @@ -81,7 +83,8 @@ public: const cmNinjaDeps& explicitDeps, const cmNinjaDeps& implicitDeps, const cmNinjaDeps& orderOnlyDeps, - const cmNinjaVars& variables); + const cmNinjaVars& variables, + int cmdLineLimit = -1); /** * Helper to write a build statement with the special 'phony' rule. @@ -113,6 +116,7 @@ public: const std::string& description, const std::string& comment = "", const std::string& depfile = "", + const std::string& rspfile = "" , bool restat = false, bool generator = false); @@ -143,6 +147,9 @@ public: const cmNinjaDeps& targets, const std::string& comment = ""); + + static bool IsMinGW() { return UsingMinGW; } + public: /// Default constructor. cmGlobalNinjaGenerator(); @@ -226,6 +233,7 @@ public: const std::string& description, const std::string& comment = "", const std::string& depfile = "", + const std::string& rspfile = "", bool restat = false, bool generator = false); @@ -309,6 +317,8 @@ private: ASD.insert(deps.begin(), deps.end()); } + std::string ninjaCmd() const; + private: /// The file containing the build statement. (the relation ship of the /// compilation DAG). @@ -341,6 +351,9 @@ private: TargetAliasMap TargetAliases; static cmLocalGenerator* LocalGenerator; + + static bool UsingMinGW; + }; #endif // ! cmGlobalNinjaGenerator_h diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 522f3da..938977b 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1594,14 +1594,14 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, if(strcmp(lang, "CXX") == 0) { this->CurrentLocalGenerator->AddLanguageFlags(cflags, "C", configName); - this->CurrentLocalGenerator->AddSharedFlags(cflags, lang, shared); + this->CurrentLocalGenerator->AddCMP0018Flags(cflags, &target, "C"); } // Add language-specific flags. this->CurrentLocalGenerator->AddLanguageFlags(flags, lang, configName); // Add shared-library flags if needed. - this->CurrentLocalGenerator->AddSharedFlags(flags, lang, shared); + this->CurrentLocalGenerator->AddCMP0018Flags(flags, &target, lang); } else if(binary) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 8265d72..46c92cb 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -872,6 +872,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable, return replaceValues.TargetPDB; } } + if(replaceValues.DependencyFile ) + { + if(variable == "DEP_FILE") + { + return replaceValues.DependencyFile; + } + } if(replaceValues.Target) { @@ -1549,12 +1556,6 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, return; } this->AddLanguageFlags(flags, linkLanguage, buildType.c_str()); - std::string sharedFlagsVar = "CMAKE_SHARED_LIBRARY_"; - sharedFlagsVar += linkLanguage; - sharedFlagsVar += "_FLAGS"; - flags += " "; - flags += this->Makefile->GetSafeDefinition(sharedFlagsVar.c_str()); - flags += " "; cmOStringStream linklibs; this->OutputLinkLibraries(linklibs, target, false); linkLibs = linklibs.str(); @@ -1963,6 +1964,111 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags, } //---------------------------------------------------------------------------- +void cmLocalGenerator::AddCMP0018Flags(std::string &flags, cmTarget* target, + std::string const& lang) +{ + int targetType = target->GetType(); + + bool shared = ((targetType == cmTarget::SHARED_LIBRARY) || + (targetType == cmTarget::MODULE_LIBRARY)); + + if (this->GetShouldUseOldFlags(shared, lang)) + { + this->AddSharedFlags(flags, lang.c_str(), shared); + } + else + { + // Add position independendent flags, if needed. + if (target->GetPropertyAsBool("POSITION_INDEPENDENT_CODE")) + { + this->AddPositionIndependentFlags(flags, lang, targetType); + } + if (shared) + { + this->AppendFeatureOptions(flags, lang.c_str(), "DLL"); + } + } +} + +//---------------------------------------------------------------------------- +bool cmLocalGenerator::GetShouldUseOldFlags(bool shared, + const std::string &lang) const +{ + std::string originalFlags = + this->GlobalGenerator->GetSharedLibFlagsForLanguage(lang); + if (shared) + { + std::string flagsVar = "CMAKE_SHARED_LIBRARY_"; + flagsVar += lang; + flagsVar += "_FLAGS"; + const char* flags = + this->Makefile->GetSafeDefinition(flagsVar.c_str()); + + if (flags && flags != originalFlags) + { + switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0018)) + { + case cmPolicies::WARN: + { + cmOStringStream e; + e << "Variable " << flagsVar << " has been modified. CMake " + "will ignore the POSITION_INDEPENDENT_CODE target property for " + "shared libraries and will use the " << flagsVar << " variable " + "instead. This may cause errors if the original content of " + << flagsVar << " was removed.\n" + << this->Makefile->GetPolicies()->GetPolicyWarning( + cmPolicies::CMP0018); + + this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str()); + // fall through to OLD behaviour + } + case cmPolicies::OLD: + return true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + default: + return false; + } + } + } + return false; +} + +//---------------------------------------------------------------------------- +void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, + std::string const& lang, + int targetType) +{ + const char* picFlags = 0; + + if(targetType == cmTarget::EXECUTABLE) + { + std::string flagsVar = "CMAKE_"; + flagsVar += lang; + flagsVar += "_COMPILE_OPTIONS_PIE"; + picFlags = this->Makefile->GetSafeDefinition(flagsVar.c_str()); + } + if (!picFlags) + { + std::string flagsVar = "CMAKE_"; + flagsVar += lang; + flagsVar += "_COMPILE_OPTIONS_PIC"; + picFlags = this->Makefile->GetSafeDefinition(flagsVar.c_str()); + } + if (picFlags) + { + std::vector<std::string> options; + cmSystemTools::ExpandListArgument(picFlags, options); + for(std::vector<std::string>::const_iterator oi = options.begin(); + oi != options.end(); ++oi) + { + this->AppendFlags(flags, this->EscapeForShell(oi->c_str()).c_str()); + } + } +} + +//---------------------------------------------------------------------------- void cmLocalGenerator::AddConfigVariableFlags(std::string& flags, const char* var, const char* config) diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index cb84a30..39b493f 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -140,7 +140,8 @@ public: void AddLanguageFlags(std::string& flags, const char* lang, const char* config); - void AddSharedFlags(std::string& flags, const char* lang, bool shared); + void AddCMP0018Flags(std::string &flags, cmTarget* target, + std::string const& lang); void AddConfigVariableFlags(std::string& flags, const char* var, const char* config); ///! Append flags to a string. @@ -204,6 +205,10 @@ public: /** Compute the language used to compile the given source file. */ const char* GetSourceFileLanguage(const cmSourceFile& source); + // Fill the vector with the target names for the object files, + // preprocessed files and assembly files. + virtual void GetIndividualFileTargets(std::vector<std::string>&) {} + // Create a struct to hold the varibles passed into // ExpandRuleVariables struct RuleVariables @@ -235,6 +240,7 @@ public: const char* LanguageCompileFlags; const char* Defines; const char* RuleLauncher; + const char* DependencyFile; }; /** Set whether to treat conversions to SHELL as a link script shell. */ @@ -425,6 +431,11 @@ protected: private: std::string ConvertToOutputForExistingCommon(const char* remote, std::string const& result); + + void AddSharedFlags(std::string& flags, const char* lang, bool shared); + bool GetShouldUseOldFlags(bool shared, const std::string &lang) const; + void AddPositionIndependentFlags(std::string& flags, std::string const& l, + int targetType); }; #endif diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 425b219..9a496f2 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -46,7 +46,9 @@ void cmLocalNinjaGenerator::Generate() this->SetConfigName(); this->WriteProcessedMakefile(this->GetBuildFileStream()); +#ifdef NINJA_GEN_VERBOSE_FILES this->WriteProcessedMakefile(this->GetRulesFileStream()); +#endif this->WriteBuildFileTop(); @@ -275,16 +277,16 @@ std::string cmLocalNinjaGenerator::BuildCommandLine( return ":"; #endif - // TODO: This will work only on Unix platforms. I don't - // want to use a link.txt file because I will lose the benefit of the - // $in variables. A discussion about dealing with multiple commands in - // a rule is started here: - // groups.google.com/group/ninja-build/browse_thread/thread/d515f23a78986008 - std::ostringstream cmd; + cmOStringStream cmd; for (std::vector<std::string>::const_iterator li = cmdLines.begin(); li != cmdLines.end(); ++li) { - if (li != cmdLines.begin()) + if (li != cmdLines.begin()) { cmd << " && "; +#ifdef _WIN32 + } else if (cmdLines.size() > 1) { + cmd << "cmd.exe /c "; +#endif + } cmd << *li; } return cmd.str(); @@ -299,7 +301,7 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc, if (!wd) wd = this->GetMakefile()->GetStartOutputDirectory(); - std::ostringstream cdCmd; + cmOStringStream cdCmd; cdCmd << "cd " << this->ConvertToOutputFormat(wd, SHELL); cmdLines.push_back(cdCmd.str()); } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index a645303..db93529 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -36,6 +36,30 @@ #include <queue> //---------------------------------------------------------------------------- +// Escape special characters in Makefile dependency lines +class cmMakeSafe +{ +public: + cmMakeSafe(const char* s): Data(s) {} + cmMakeSafe(std::string const& s): Data(s.c_str()) {} +private: + const char* Data; + friend std::ostream& operator<<(std::ostream& os, + cmMakeSafe const& self) + { + for(const char* c = self.Data; *c; ++c) + { + switch (*c) + { + case '=': os << "$(EQUALS)"; break; + default: os << *c; break; + } + } + return os; + } +}; + +//---------------------------------------------------------------------------- // Helper function used below. static std::string cmSplitExtension(std::string const& in, std::string& base) { @@ -555,28 +579,13 @@ cmLocalUnixMakefileGenerator3 space = " "; } - // Warn about paths not supported by Make tools. - std::string::size_type pos = tgt.find_first_of("="); - if(pos != std::string::npos) - { - cmOStringStream m; - m << - "Make rule for\n" - " " << tgt << "\n" - "has '=' on left hand side. " - "The make tool may not support this."; - cmListFileBacktrace bt; - this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, m.str(), bt); - } - // Mark the rule as symbolic if requested. if(symbolic) { if(const char* sym = this->Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE")) { - os << tgt.c_str() << space << ": " << sym << "\n"; + os << cmMakeSafe(tgt) << space << ": " << sym << "\n"; } } @@ -584,7 +593,7 @@ cmLocalUnixMakefileGenerator3 if(depends.empty()) { // No dependencies. The commands will always run. - os << tgt.c_str() << space << ":\n"; + os << cmMakeSafe(tgt) << space << ":\n"; } else { @@ -595,7 +604,7 @@ cmLocalUnixMakefileGenerator3 { replace = *dep; replace = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE); - os << tgt.c_str() << space << ": " << replace.c_str() << "\n"; + os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n"; } } @@ -608,7 +617,7 @@ cmLocalUnixMakefileGenerator3 } if(symbolic && !this->WatcomWMake) { - os << ".PHONY : " << tgt.c_str() << "\n"; + os << ".PHONY : " << cmMakeSafe(tgt) << "\n"; } os << "\n"; // Add the output to the local help if requested. @@ -687,6 +696,10 @@ cmLocalUnixMakefileGenerator3 << this->ConvertShellCommand(cmakecommand, FULL) << " -E remove -f\n" << "\n"; + makefileStream + << "# Escaping for special characters.\n" + << "EQUALS = =\n" + << "\n"; if(const char* edit_cmd = this->Makefile->GetDefinition("CMAKE_EDIT_COMMAND")) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 9faf46d..f2ab79d 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1933,9 +1933,11 @@ cmLocalVisualStudio7Generator vskey += "\\Packages\\" CM_INTEL_PLUGIN_GUID ";ProductVersion"; cmSystemTools::ReadRegistryValue(vskey.c_str(), intelVersion, cmSystemTools::KeyWOW64_32); - if (intelVersion.find("12") == 0 || (intelVersion.find("11") == 0)) + if (intelVersion.find("13") == 0 || + intelVersion.find("12") == 0 || + intelVersion.find("11") == 0) { - // Version 11.x and 12.x actually use 11.0 in project files! + // Version 11.x, 12.x, and 13.x actually use 11.0 in project files! intelVersion = "11.0" ; } else if(intelVersion.find("10") == 0) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 408f287..df89275 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -245,9 +245,6 @@ std::string cmMakefileTargetGenerator::GetFlags(const std::string &l) std::string flags; const char *lang = l.c_str(); - bool shared = ((this->Target->GetType() == cmTarget::SHARED_LIBRARY) || - (this->Target->GetType() == cmTarget::MODULE_LIBRARY)); - // Add language feature flags. this->AddFeatureFlags(flags, lang); @@ -260,8 +257,7 @@ std::string cmMakefileTargetGenerator::GetFlags(const std::string &l) this->AddFortranFlags(flags); } - // Add shared-library flags if needed. - this->LocalGenerator->AddSharedFlags(flags, lang, shared); + this->LocalGenerator->AddCMP0018Flags(flags, this->Target, lang); // Add include directory flags. this->AddIncludeFlags(flags, lang); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 8b86a98..01e8e73 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -55,21 +55,6 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator() { } -void -cmNinjaNormalTargetGenerator -::EnsureDirectoryExists(const std::string& dir) -{ - cmSystemTools::MakeDirectory(dir.c_str()); -} - -void -cmNinjaNormalTargetGenerator -::EnsureParentDirectoryExists(const std::string& path) -{ - EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str())); -} - - void cmNinjaNormalTargetGenerator::Generate() { if (!this->TargetLinkLanguage) { @@ -90,16 +75,17 @@ void cmNinjaNormalTargetGenerator::Generate() } else { - this->WriteLinkRule(); + this->WriteLinkRule(false); +#ifdef _WIN32 // TODO response file support only Linux + this->WriteLinkRule(true); +#endif this->WriteLinkStatement(); } - - this->GetBuildFileStream() << "\n"; - this->GetRulesFileStream() << "\n"; } void cmNinjaNormalTargetGenerator::WriteLanguagesRules() { +#ifdef NINJA_GEN_VERBOSE_FILES cmGlobalNinjaGenerator::WriteDivider(this->GetRulesFileStream()); this->GetRulesFileStream() << "# Rules for each languages for " @@ -107,6 +93,7 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules() << " target " << this->GetTargetName() << "\n\n"; +#endif std::set<cmStdString> languages; this->GetTarget()->GetLanguages(languages); @@ -144,27 +131,41 @@ cmNinjaNormalTargetGenerator void cmNinjaNormalTargetGenerator -::WriteLinkRule() +::WriteLinkRule(bool useResponseFile) { cmTarget::TargetType targetType = this->GetTarget()->GetType(); std::string ruleName = this->LanguageLinkerRule(); + if (useResponseFile) + ruleName += "_RSPFILE"; + + // Select whether to use a response file for objects. + std::string rspfile; if (!this->GetGlobalGenerator()->HasRule(ruleName)) { cmLocalGenerator::RuleVariables vars; vars.RuleLauncher = "RULE_LAUNCH_LINK"; vars.CMTarget = this->GetTarget(); vars.Language = this->TargetLinkLanguage; - vars.Objects = "$in"; - std::string objdir = - this->GetLocalGenerator()->GetHomeRelativeOutputPath(); - objdir += objdir.empty() ? "" : "/"; - objdir += cmake::GetCMakeFilesDirectoryPostSlash(); - objdir += this->GetTargetName(); - objdir += ".dir"; - objdir = this->GetLocalGenerator()->Convert(objdir.c_str(), - cmLocalGenerator::START_OUTPUT, - cmLocalGenerator::SHELL); - vars.ObjectDir = objdir.c_str(); + + std::string responseFlag; + if (!useResponseFile) { + vars.Objects = "$in"; + } else { + // handle response file + std::string cmakeLinkVar = std::string("CMAKE_") + + this->TargetLinkLanguage + "_RESPONSE_FILE_LINK_FLAG"; + const char * flag = GetMakefile()->GetDefinition(cmakeLinkVar.c_str()); + if(flag) { + responseFlag = flag; + } else { + responseFlag = "@"; + } + rspfile = "$out.rsp"; + responseFlag += rspfile; + vars.Objects = responseFlag.c_str(); + } + + vars.ObjectDir = "$OBJECT_DIR"; vars.Target = "$out"; vars.SONameFlag = "$SONAME_FLAG"; vars.TargetSOName = "$SONAME"; @@ -201,7 +202,7 @@ cmNinjaNormalTargetGenerator vars.LanguageCompileFlags = langFlags.c_str(); } - // Rule for linking library. + // Rule for linking library/executable. std::vector<std::string> linkCmds = this->ComputeLinkCmd(); for(std::vector<std::string>::iterator i = linkCmds.begin(); i != linkCmds.end(); @@ -214,17 +215,19 @@ cmNinjaNormalTargetGenerator std::string linkCmd = this->GetLocalGenerator()->BuildCommandLine(linkCmds); - // Write the linker rule. - std::ostringstream comment; + // Write the linker rule with response file if needed. + cmOStringStream comment; comment << "Rule for linking " << this->TargetLinkLanguage << " " << this->GetVisibleTypeName() << "."; - std::ostringstream description; + cmOStringStream description; description << "Linking " << this->TargetLinkLanguage << " " << this->GetVisibleTypeName() << " $out"; this->GetGlobalGenerator()->AddRule(ruleName, linkCmd, description.str(), - comment.str()); + comment.str(), + /*depfile*/ "", + rspfile); } if (this->TargetNameOut != this->TargetNameReal) { @@ -353,7 +356,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() /*implib=*/true).c_str()); // Compute the comment. - std::ostringstream comment; + cmOStringStream comment; comment << "Link the " << this->GetVisibleTypeName() << " " << targetOutputReal; @@ -375,13 +378,18 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() // Compute architecture specific link flags. Yes, these go into a different // variable for executables, probably due to a mistake made when duplicating // code between the Makefile executable and library generators. - this->GetLocalGenerator() - ->AddArchitectureFlags(targetType == cmTarget::EXECUTABLE + std::string flags = (targetType == cmTarget::EXECUTABLE ? vars["FLAGS"] - : vars["ARCH_FLAGS"], + : vars["ARCH_FLAGS"]); + this->GetLocalGenerator()->AddArchitectureFlags(flags, this->GetTarget(), this->TargetLinkLanguage, this->GetConfigName()); + if (targetType == cmTarget::EXECUTABLE) { + vars["FLAGS"] = flags; + } else { + vars["ARCH_FLAGS"] = flags; + } if (this->GetTarget()->HasSOName(this->GetConfigName())) { vars["SONAME_FLAG"] = this->GetMakefile()->GetSONameFlag(this->TargetLinkLanguage); @@ -407,10 +415,24 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() EnsureParentDirectoryExists(path); } - path = this->GetLocalGenerator()->ConvertToOutputFormat( - this->GetTargetPDB().c_str(), cmLocalGenerator::SHELL); - vars["TARGET_PDB"] = path; - EnsureParentDirectoryExists(path); + // TODO move to GetTargetPDB + cmMakefile* mf = this->GetMakefile(); + if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") || + mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID")) + { + path = this->GetTargetPDB(); + vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat( + ConvertToNinjaPath(path.c_str()).c_str(), + cmLocalGenerator::SHELL); + EnsureParentDirectoryExists(path); + } + + if (mf->IsOn("CMAKE_COMPILER_IS_MINGW")) + { + path = GetTarget()->GetSupportDirectory(); + vars["OBJECT_DIR"] = ConvertToNinjaPath(path.c_str()); + EnsureDirectoryExists(path); + } std::vector<cmCustomCommand> *cmdLists[3] = { &this->GetTarget()->GetPreBuildCommands(), @@ -456,6 +478,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() symlinkVars["POST_BUILD"] = postBuildCmdLine; } + int cmdLineLimit; +#ifdef _WIN32 + cmdLineLimit = 8000; +#else + cmdLineLimit = -1; // TODO +#endif + // Write the build statement for this target. cmGlobalNinjaGenerator::WriteBuild(this->GetBuildFileStream(), comment.str(), @@ -464,7 +493,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() explicitDeps, implicitDeps, emptyDeps, - vars); + vars, + cmdLineLimit); if (targetOutput != targetOutputReal) { if (targetType == cmTarget::EXECUTABLE) { diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h index 7acbe8f..1ef9567 100644 --- a/Source/cmNinjaNormalTargetGenerator.h +++ b/Source/cmNinjaNormalTargetGenerator.h @@ -30,14 +30,11 @@ private: std::string LanguageLinkerRule() const; const char* GetVisibleTypeName() const; void WriteLanguagesRules(); - void WriteLinkRule(); + void WriteLinkRule(bool useResponseFile); void WriteLinkStatement(); void WriteObjectLibStatement(); std::vector<std::string> ComputeLinkCmd(); - void EnsureDirectoryExists(const std::string& dir); - void EnsureParentDirectoryExists(const std::string& path); - private: // Target name info. std::string TargetNameOut; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index e419a4d..6157931 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -140,11 +140,8 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, // } // Add shared-library flags if needed. - { - bool shared = ((this->Target->GetType() == cmTarget::SHARED_LIBRARY) || - (this->Target->GetType() == cmTarget::MODULE_LIBRARY)); - this->GetLocalGenerator()->AddSharedFlags(flags, language.c_str(), shared); - } + this->LocalGenerator->AddCMP0018Flags(flags, this->Target, + language.c_str()); // TODO: Handle response file. // Add include directory flags. @@ -154,6 +151,8 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source, language.c_str()); std::string includeFlags = this->LocalGenerator->GetIncludeFlags(includes, language.c_str(), false); + if(cmGlobalNinjaGenerator::IsMinGW()) + cmSystemTools::ReplaceString(includeFlags, "\\", "/"); this->LocalGenerator->AppendFlags(flags, includeFlags.c_str()); } @@ -301,7 +300,7 @@ std::string cmNinjaTargetGenerator::GetTargetPDB() const targetFullPathPDB += this->Target->GetPDBName(this->GetConfigName()); } - return ConvertToNinjaPath(targetFullPathPDB.c_str()); + return targetFullPathPDB.c_str(); } @@ -309,10 +308,11 @@ void cmNinjaTargetGenerator ::WriteLanguageRules(const std::string& language) { +#ifdef NINJA_GEN_VERBOSE_FILES this->GetRulesFileStream() << "# Rules for language " << language << "\n\n"; +#endif this->WriteCompileRule(language); - this->GetRulesFileStream() << "\n"; } void @@ -330,20 +330,45 @@ cmNinjaTargetGenerator vars.Defines = "$DEFINES"; vars.TargetPDB = "$TARGET_PDB"; + + cmMakefile* mf = this->GetMakefile(); + + bool useClDeps = false; + std::string clDepsBinary; + std::string clShowPrefix; + if (lang == "C" || lang == "CXX" || lang == "RC") + { + const char* depsPtr = mf->GetDefinition("CMAKE_CMCLDEPS_EXECUTABLE"); + const char* showPtr = mf->GetDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX"); + if (depsPtr && showPtr) + { + // don't wrap for try_compile, + // TODO but why doesn't it work with cmcldeps? + const std::string projectName = mf->GetProjectName() ? + mf->GetProjectName() : ""; + if (projectName != "CMAKE_TRY_COMPILE") + { + useClDeps = true; + std::string qu = "\""; + clDepsBinary = qu + depsPtr + qu; + clShowPrefix = qu + showPtr + qu; + vars.DependencyFile = "$DEP_FILE"; + } + } + } + + std::string depfile; std::string depfileFlagsName = "CMAKE_DEPFILE_FLAGS_" + language; - const char *depfileFlags = - this->GetMakefile()->GetDefinition(depfileFlagsName.c_str()); - if (depfileFlags) { - std::string depfileFlagsStr = depfileFlags; - depfile = "$out.d"; - cmSystemTools::ReplaceString(depfileFlagsStr, "<DEPFILE>", - depfile.c_str()); - cmSystemTools::ReplaceString(depfileFlagsStr, "<OBJECT>", - "$out"); - cmSystemTools::ReplaceString(depfileFlagsStr, "<CMAKE_C_COMPILER>", - this->GetMakefile()->GetDefinition("CMAKE_C_COMPILER")); - flags += " " + depfileFlagsStr; + const char *depfileFlags = mf->GetDefinition(depfileFlagsName.c_str()); + if (depfileFlags || useClDeps) { + std::string depFlagsStr = depfileFlags ? depfileFlags : ""; + depfile = "$DEP_FILE"; + cmSystemTools::ReplaceString(depFlagsStr, "<DEPFILE>", "\"$DEP_FILE\""); + cmSystemTools::ReplaceString(depFlagsStr, "<OBJECT>", "$out"); + cmSystemTools::ReplaceString(depFlagsStr, "<CMAKE_C_COMPILER>", + mf->GetDefinition("CMAKE_C_COMPILER")); + flags += " " + depFlagsStr; } vars.Flags = flags.c_str(); @@ -352,8 +377,7 @@ cmNinjaTargetGenerator std::string compileCmdVar = "CMAKE_"; compileCmdVar += language; compileCmdVar += "_COMPILE_OBJECT"; - std::string compileCmd = - this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str()); + std::string compileCmd = mf->GetRequiredDefinition(compileCmdVar.c_str()); std::vector<std::string> compileCmds; cmSystemTools::ExpandListArgument(compileCmd, compileCmds); @@ -364,10 +388,18 @@ cmNinjaTargetGenerator std::string cmdLine = this->GetLocalGenerator()->BuildCommandLine(compileCmds); + if(useClDeps) + { + std::string cl = mf->GetDefinition("CMAKE_C_COMPILER"); + cl = "\"" + cl + "\" "; + cmdLine = clDepsBinary + " " + lang + " $in \"$DEP_FILE\" $out " + + clShowPrefix + " " + cl + cmdLine; + } + // Write the rule for compiling file of the given language. - std::ostringstream comment; + cmOStringStream comment; comment << "Rule for compiling " << language << " files."; - std::ostringstream description; + cmOStringStream description; description << "Building " << language << " object $out"; this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(language), cmdLine, @@ -484,8 +516,18 @@ cmNinjaTargetGenerator cmNinjaVars vars; vars["FLAGS"] = this->ComputeFlagsForObject(source, language); vars["DEFINES"] = this->ComputeDefines(source, language); - vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat( - this->GetTargetPDB().c_str(), cmLocalGenerator::SHELL); + vars["DEP_FILE"] = objectFileName + ".d";; + EnsureParentDirectoryExists(objectFileName); + + // TODO move to GetTargetPDB + cmMakefile* mf = this->GetMakefile(); + if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") || + mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID")) + { + vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat( + ConvertToNinjaPath(GetTargetPDB().c_str()).c_str(), + cmLocalGenerator::SHELL); + } if(this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS")) { @@ -566,3 +608,17 @@ cmNinjaTargetGenerator this->ModuleDefinitionFile.c_str())); this->LocalGenerator->AppendFlags(flags, flag.c_str()); } + +void +cmNinjaTargetGenerator +::EnsureDirectoryExists(const std::string& dir) +{ + cmSystemTools::MakeDirectory(dir.c_str()); +} + +void +cmNinjaTargetGenerator +::EnsureParentDirectoryExists(const std::string& path) +{ + EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str())); +} diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index b64ce1e..af43a8b 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -111,6 +111,9 @@ protected: // Helper to add flag for windows .def file. void AddModuleDefinitionFlag(std::string& flags); + void EnsureDirectoryExists(const std::string& dir); + void EnsureParentDirectoryExists(const std::string& path); + private: cmTarget* Target; cmGeneratorTarget* GeneratorTarget; diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 37070b6..79af4d7 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -463,6 +463,34 @@ cmPolicies::cmPolicies() "The OLD behaviour is to always prefer files from CMAKE_MODULE_PATH over " "files from the CMake modules directory.", 2,8,4,0, cmPolicies::WARN); + + this->DefinePolicy( + CMP0018, "CMP0018", + "Ignore CMAKE_SHARED_LIBRARY_<Lang>_FLAGS variable.", + "CMake 2.8.8 and lower compiled sources in SHARED and MODULE libraries " + "using the value of the undocumented CMAKE_SHARED_LIBRARY_<Lang>_FLAGS " + "platform variable. The variable contained platform-specific flags " + "needed to compile objects for shared libraries. Typically it included " + "a flag such as -fPIC for position independent code but also included " + "other flags needed on certain platforms. CMake 2.8.9 and higher " + "prefer instead to use the POSITION_INDEPENDENT_CODE target property to " + "determine what targets should be position independent, and new " + "undocumented platform variables to select flags while ignoring " + "CMAKE_SHARED_LIBRARY_<Lang>_FLAGS completely." + "\n" + "The default for either approach produces identical compilation flags, " + "but if a project modifies CMAKE_SHARED_LIBRARY_<Lang>_FLAGS from its " + "original value this policy determines which approach to use." + "\n" + "The OLD behavior for this policy is to ignore the " + "POSITION_INDEPENDENT_CODE property for all targets and use the modified " + "value of CMAKE_SHARED_LIBRARY_<Lang>_FLAGS for SHARED and MODULE " + "libraries." + "\n" + "The NEW behavior for this policy is to ignore " + "CMAKE_SHARED_LIBRARY_<Lang>_FLAGS whether it is modified or not and " + "honor the POSITION_INDEPENDENT_CODE target property.", + 2,8,9,0, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 3106248..6932565 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -65,6 +65,9 @@ public: /// target_link_libraries() fails if only argument is not a target CMP0016, CMP0017, ///< Prefer files in CMAKE_ROOT when including from CMAKE_ROOT + CMP0018, ///< Ignore language flags for shared libs, and adhere to + /// POSITION_INDEPENDENT_CODE property and *_COMPILE_OPTIONS_PI{E,C} + /// instead. /** \brief Always the last entry. * diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx index ca27530..65ecdf7 100644 --- a/Source/cmQtAutomoc.cxx +++ b/Source/cmQtAutomoc.cxx @@ -18,6 +18,7 @@ #include "cmSystemTools.h" #include <cmsys/Terminal.h> +#include <cmsys/ios/sstream> #include <string.h> #if defined(__APPLE__) @@ -244,6 +245,7 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target) bool cmQtAutomoc::Run(const char* targetDirectory) { + bool success = true; cmake cm; cmGlobalGenerator* gg = this->CreateGlobalGenerator(&cm, targetDirectory); cmMakefile* makefile = gg->GetCurrentLocalGenerator()->GetMakefile(); @@ -255,7 +257,7 @@ bool cmQtAutomoc::Run(const char* targetDirectory) if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") { - this->RunAutomoc(); + success = this->RunAutomoc(); } this->WriteOldMocDefinitionsFile(targetDirectory); @@ -263,7 +265,7 @@ bool cmQtAutomoc::Run(const char* targetDirectory) delete gg; gg = NULL; makefile = NULL; - return true; + return success; } @@ -549,7 +551,7 @@ bool cmQtAutomoc::RunAutomoc() this->GenerateMoc(it->first, it->second); } - std::stringstream outStream(std::stringstream::out); + cmsys_ios::stringstream outStream; outStream << "/* This file is autogenerated, do not edit*/\n"; bool automocCppChanged = false; @@ -577,7 +579,7 @@ bool cmQtAutomoc::RunAutomoc() if (this->RunMocFailed) { - std::cerr << "returning failed.."<< std::endl; + std::cerr << "moc failed..."<< std::endl; return false; } outStream.flush(); @@ -1077,7 +1079,7 @@ bool cmQtAutomoc::EndsWith(const std::string& str, const std::string& with) std::string cmQtAutomoc::ReadAll(const std::string& filename) { std::ifstream file(filename.c_str()); - std::stringstream stream; + cmsys_ios::stringstream stream; stream << file.rdbuf(); file.close(); return stream.str(); diff --git a/Source/cmSetCommand.h b/Source/cmSetCommand.h index 66b129e..2dd80e3 100644 --- a/Source/cmSetCommand.h +++ b/Source/cmSetCommand.h @@ -52,7 +52,7 @@ public: */ virtual const char* GetTerseDocumentation() const { - return "Set a CMAKE variable to a given value."; + return "Set a CMake, cache or environment variable to a given value."; } /** @@ -63,26 +63,37 @@ public: return " set(<variable> <value>\n" " [[CACHE <type> <docstring> [FORCE]] | PARENT_SCOPE])\n" - "Within CMake sets <variable> to the value <value>. <value> is expanded" - " before <variable> is set to it. If CACHE is present, then the " - "<variable> is put in the cache. <type> and <docstring> are then " - "required. <type> is used by the CMake GUI to choose a widget with " - "which the user sets a value. The value for <type> may be one of\n" + "Within CMake sets <variable> to the value <value>. " + "<value> is expanded before <variable> is set to it. " + "Normally, set will set a regular CMake variable. " + "If CACHE is present, then the <variable> is put in the cache " + "instead, unless it is already in the cache. " + "See section 'Variable types in CMake' below for details of " + "regular and cache variables and their interactions. " + "If CACHE is used, <type> and <docstring> are required. <type> is used " + "by the CMake GUI to choose a widget with which the user sets a value. " + "The value for <type> may be one of\n" " FILEPATH = File chooser dialog.\n" " PATH = Directory chooser dialog.\n" " STRING = Arbitrary string.\n" " BOOL = Boolean ON/OFF checkbox.\n" " INTERNAL = No GUI entry (used for persistent variables).\n" - "If <type> is INTERNAL, then the <value> is always written into the " - "cache, replacing any values existing in the cache. If it is not a " - "cache variable, then this always writes into the current makefile. The " - "FORCE option will overwrite the cache value removing any changes by " - "the user.\n" + "If <type> is INTERNAL, the cache variable is marked as internal, " + "and will not be shown to the user in tools like cmake-gui. " + "This is intended for values that should be persisted in the cache, " + "but which users should not normally change. INTERNAL implies FORCE." + "\n" + "Normally, set(...CACHE...) creates cache variables, but does not " + "modify them. " + "If FORCE is specified, the value of the cache variable is set, even " + "if the variable is already in the cache. This should normally be " + "avoided, as it will remove any changes to the cache variable's value " + "by the user.\n" "If PARENT_SCOPE is present, the variable will be set in the scope " "above the current scope. Each new directory or function creates a new " "scope. This command will set the value of a variable into the parent " "directory or calling function (whichever is applicable to the case at " - "hand).\n" + "hand). PARENT_SCOPE cannot be combined with CACHE.\n" "If <value> is not specified then the variable is removed " "instead of set. See also: the unset() command.\n" " set(<variable> <value1> ... <valueN>)\n" @@ -90,7 +101,58 @@ public: "values.\n" "<variable> can be an environment variable such as:\n" " set( ENV{PATH} /home/martink )\n" - "in which case the environment variable will be set."; + "in which case the environment variable will be set.\n" + "*** Variable types in CMake ***\n" + "In CMake there are two types of variables: normal variables and cache " + "variables. Normal variables are meant for the internal use of the " + "script (just like variables in most programming languages); they are " + "not persisted across CMake runs. " + "Cache variables (unless set with INTERNAL) are mostly intended for " + "configuration settings where the first CMake run determines a " + "suitable default value, which the user can then override, by editing " + "the cache with tools such as ccmake or cmake-gui. " + "Cache variables are stored in the CMake cache file, and " + "are persisted across CMake runs. \n" + "Both types can exist at the same time with the same name " + "but different values. " + "When ${FOO} is evaluated, CMake first looks for " + "a normal variable 'FOO' in scope and uses it if set. " + "If and only if no normal variable exists then it falls back to the " + "cache variable 'FOO'.\n" + "Some examples:\n" + "The code 'set(FOO \"x\")' sets the normal variable 'FOO'. It does not " + "touch the cache, but it will hide any existing cache value 'FOO'.\n" + "The code 'set(FOO \"x\" CACHE ...)' checks for 'FOO' in the cache, " + "ignoring any normal variable of the same name. If 'FOO' is in the " + "cache then nothing happens to either the normal variable or the cache " + "variable. If 'FOO' is not in the cache, then it is added to the " + "cache.\n" + "Finally, whenever a cache variable is added or modified by a command, " + "CMake also *removes* the normal variable of the same name from the " + "current scope so that an immediately following evaluation of " + "it will expose the newly cached value.\n" + "Normally projects should avoid using normal and cache variables of " + "the same name, as this interaction can be hard to follow. " + "However, in some situations it can be useful. " + "One example (used by some projects):" + "\n" + "A project has a subproject in its source tree. The child project has " + "its own CMakeLists.txt, which is included from the parent " + "CMakeLists.txt using add_subdirectory(). " + "Now, if the parent and the child project provide the same option " + "(for example a compiler option), the parent gets the first chance " + "to add a user-editable option to the cache. " + "Normally, the child would then use the same value " + "that the parent uses. " + "However, it may be necessary to hard-code the value for the child " + "project's option while still allowing the user to edit the value used " + "by the parent project. The parent project can achieve this simply by " + "setting a normal variable with the same name as the option in a scope " + "sufficient to hide the option's cache variable from the child " + "completely. The parent has already set the cache variable, so the " + "child's set(...CACHE...) will do nothing, and evaluating the option " + "variable will use the value from the normal variable, which hides the " + "cache variable."; } cmTypeMacro(cmSetCommand, cmCommand); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c5ef9ff..4f3f2c5 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -756,6 +756,14 @@ void cmTarget::DefineProperties(cmake *cm) "(such as \"lib\") on a library name."); cm->DefineProperty + ("POSITION_INDEPENDENT_CODE", cmProperty::TARGET, + "Whether to create a position-independent target", + "The POSITION_INDEPENDENT_CODE property determines whether position " + "independent executables or shared libraries will be created. " + "This property is true by default for SHARED and MODULE library " + "targets and false otherwise."); + + cm->DefineProperty ("POST_INSTALL_SCRIPT", cmProperty::TARGET, "Deprecated install support.", "The PRE_INSTALL_SCRIPT and POST_INSTALL_SCRIPT properties are the " @@ -1305,6 +1313,13 @@ void cmTarget::SetMakefile(cmMakefile* mf) this->SetProperty("INCLUDE_DIRECTORIES", this->Makefile->GetProperty("INCLUDE_DIRECTORIES")); + if(this->TargetTypeValue == cmTarget::SHARED_LIBRARY + || this->TargetTypeValue == cmTarget::MODULE_LIBRARY) + { + this->SetProperty("POSITION_INDEPENDENT_CODE", "True"); + } + this->SetPropertyDefault("POSITION_INDEPENDENT_CODE", 0); + // Record current policies for later use. this->PolicyStatusCMP0003 = this->Makefile->GetPolicyStatus(cmPolicies::CMP0003); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 2ffff42..451aec8 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1699,8 +1699,8 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) else if (args[1] == "cmake_automoc") { cmQtAutomoc automoc; - automoc.Run(args[2].c_str()); - return 0; + bool automocSuccess = automoc.Run(args[2].c_str()); + return automocSuccess ? 0 : 1; } #endif diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx new file mode 100644 index 0000000..7d3c4bd --- /dev/null +++ b/Source/cmcldeps.cxx @@ -0,0 +1,736 @@ +/* + ninja's subprocess.h +*/ + +// Copyright 2012 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef NINJA_SUBPROCESS_H_ +#define NINJA_SUBPROCESS_H_ + +#include <string> +#include <vector> +#include <queue> +#include <cstdio> +#include <algorithm> + + +#ifdef _WIN32 +#include <windows.h> +#else +#include <signal.h> +#endif + + +#if defined(_WIN64) +typedef unsigned __int64 cmULONG_PTR; +#else +typedef unsigned long cmULONG_PTR; +#endif + +//#include "exit_status.h" +enum ExitStatus { + ExitSuccess, + ExitFailure, + ExitInterrupted +}; + +/// Subprocess wraps a single async subprocess. It is entirely +/// passive: it expects the caller to notify it when its fds are ready +/// for reading, as well as call Finish() to reap the child once done() +/// is true. +struct Subprocess { + ~Subprocess(); + + /// Returns ExitSuccess on successful process exit, ExitInterrupted if + /// the process was interrupted, ExitFailure if it otherwise failed. + ExitStatus Finish(); + + bool Done() const; + + const std::string& GetOutput() const; + + int ExitCode() const { return exit_code_; } + + private: + Subprocess(); + bool Start(struct SubprocessSet* set, const std::string& command, + const std::string& dir); + void OnPipeReady(); + + std::string buf_; + +#ifdef _WIN32 + /// Set up pipe_ as the parent-side pipe of the subprocess; return the + /// other end of the pipe, usable in the child process. + HANDLE SetupPipe(HANDLE ioport); + + PROCESS_INFORMATION child_; + HANDLE pipe_; + OVERLAPPED overlapped_; + char overlapped_buf_[4 << 10]; + bool is_reading_; + int exit_code_; +#else + int fd_; + pid_t pid_; +#endif + + friend struct SubprocessSet; +}; + +/// SubprocessSet runs a ppoll/pselect() loop around a set of Subprocesses. +/// DoWork() waits for any state change in subprocesses; finished_ +/// is a queue of subprocesses as they finish. +struct SubprocessSet { + SubprocessSet(); + ~SubprocessSet(); + + Subprocess* Add(const std::string& command, const std::string& dir); + bool DoWork(); + Subprocess* NextFinished(); + void Clear(); + + std::vector<Subprocess*> running_; + std::queue<Subprocess*> finished_; + +#ifdef _WIN32 + static BOOL WINAPI NotifyInterrupted(DWORD dwCtrlType); + static HANDLE ioport_; +#else + static void SetInterruptedFlag(int signum); + static bool interrupted_; + + struct sigaction old_act_; + sigset_t old_mask_; +#endif +}; + +#endif // NINJA_SUBPROCESS_H_ + + +/* + ninja's util functions +*/ + + +static void Fatal(const char* msg, ...) { + va_list ap; + fprintf(stderr, "ninja: FATAL: "); + va_start(ap, msg); + vfprintf(stderr, msg, ap); + va_end(ap); + fprintf(stderr, "\n"); +#ifdef _WIN32 + // On Windows, some tools may inject extra threads. + // exit() may block on locks held by those threads, so forcibly exit. + fflush(stderr); + fflush(stdout); + ExitProcess(1); +#else + exit(1); +#endif +} + + +#ifdef _WIN32 +std::string GetLastErrorString() { + DWORD err = GetLastError(); + + char* msg_buf; + FormatMessageA( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + err, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (char*)&msg_buf, + 0, + NULL); + std::string msg = msg_buf; + LocalFree(msg_buf); + return msg; +} +#endif + +#define snprintf _snprintf + + +/* + ninja's subprocess-win32.cc +*/ + +// Copyright 2012 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//#include "subprocess.h" + +#include <stdio.h> + +#include <algorithm> + +//#include "util.h" + +namespace { + +void Win32Fatal(const char* function) { + Fatal("%s: %s", function, GetLastErrorString().c_str()); +} + +} // anonymous namespace + +Subprocess::Subprocess() : overlapped_(), is_reading_(false), + exit_code_(1) { + child_.hProcess = NULL; +} + +Subprocess::~Subprocess() { + if (pipe_) { + if (!CloseHandle(pipe_)) + Win32Fatal("CloseHandle"); + } + // Reap child if forgotten. + if (child_.hProcess) + Finish(); +} + +HANDLE Subprocess::SetupPipe(HANDLE ioport) { + char pipe_name[100]; + snprintf(pipe_name, sizeof(pipe_name), + "\\\\.\\pipe\\ninja_pid%u_sp%p", GetCurrentProcessId(), this); + + pipe_ = ::CreateNamedPipeA(pipe_name, + PIPE_ACCESS_INBOUND | FILE_FLAG_OVERLAPPED, + PIPE_TYPE_BYTE, + PIPE_UNLIMITED_INSTANCES, + 0, 0, INFINITE, NULL); + if (pipe_ == INVALID_HANDLE_VALUE) + Win32Fatal("CreateNamedPipe"); + + if (!CreateIoCompletionPort(pipe_, ioport, (cmULONG_PTR)this, 0)) + Win32Fatal("CreateIoCompletionPort"); + + memset(&overlapped_, 0, sizeof(overlapped_)); + if (!ConnectNamedPipe(pipe_, &overlapped_) && + GetLastError() != ERROR_IO_PENDING) { + Win32Fatal("ConnectNamedPipe"); + } + + // Get the write end of the pipe as a handle inheritable across processes. + HANDLE output_write_handle = CreateFile(pipe_name, GENERIC_WRITE, 0, + NULL, OPEN_EXISTING, 0, NULL); + HANDLE output_write_child; + if (!DuplicateHandle(GetCurrentProcess(), output_write_handle, + GetCurrentProcess(), &output_write_child, + 0, TRUE, DUPLICATE_SAME_ACCESS)) { + Win32Fatal("DuplicateHandle"); + } + CloseHandle(output_write_handle); + + return output_write_child; +} + +bool Subprocess::Start(SubprocessSet* set, const std::string& command, + const std::string& dir) { + HANDLE child_pipe = SetupPipe(set->ioport_); + + SECURITY_ATTRIBUTES security_attributes; + memset(&security_attributes, 0, sizeof(SECURITY_ATTRIBUTES)); + security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES); + security_attributes.bInheritHandle = TRUE; + // Must be inheritable so subprocesses can dup to children. + HANDLE nul = CreateFile("NUL", GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + &security_attributes, OPEN_EXISTING, 0, NULL); + if (nul == INVALID_HANDLE_VALUE) + Fatal("couldn't open nul"); + + STARTUPINFOA startup_info; + memset(&startup_info, 0, sizeof(startup_info)); + startup_info.cb = sizeof(STARTUPINFO); + startup_info.dwFlags = STARTF_USESTDHANDLES; + startup_info.hStdInput = nul; + startup_info.hStdOutput = child_pipe; + startup_info.hStdError = child_pipe; + + PROCESS_INFORMATION process_info; + memset(&process_info, 0, sizeof(process_info)); + + // Do not prepend 'cmd /c' on Windows, this breaks command + // lines greater than 8,191 chars. + if (!CreateProcessA(NULL, (char*)command.c_str(), NULL, NULL, + /* inherit handles */ TRUE, CREATE_NEW_PROCESS_GROUP, + NULL, (dir.empty() ? NULL : dir.c_str()), + &startup_info, &process_info)) { + DWORD error = GetLastError(); + if (error == ERROR_FILE_NOT_FOUND) { + // file (program) not found error is treated + // as a normal build action failure + if (child_pipe) + CloseHandle(child_pipe); + CloseHandle(pipe_); + CloseHandle(nul); + pipe_ = NULL; + // child_ is already NULL; + buf_ = + "CreateProcess failed: The system cannot find the file specified.\n"; + return true; + } else { + Win32Fatal("CreateProcess"); // pass all other errors to Win32Fatal + } + } + + // Close pipe channel only used by the child. + if (child_pipe) + CloseHandle(child_pipe); + CloseHandle(nul); + + CloseHandle(process_info.hThread); + child_ = process_info; + + return true; +} + +void Subprocess::OnPipeReady() { + DWORD bytes; + if (!GetOverlappedResult(pipe_, &overlapped_, &bytes, TRUE)) { + if (GetLastError() == ERROR_BROKEN_PIPE) { + CloseHandle(pipe_); + pipe_ = NULL; + return; + } + Win32Fatal("GetOverlappedResult"); + } + + if (is_reading_ && bytes) + buf_.append(overlapped_buf_, bytes); + + memset(&overlapped_, 0, sizeof(overlapped_)); + is_reading_ = true; + if (!::ReadFile(pipe_, overlapped_buf_, sizeof(overlapped_buf_), + &bytes, &overlapped_)) { + if (GetLastError() == ERROR_BROKEN_PIPE) { + CloseHandle(pipe_); + pipe_ = NULL; + return; + } + if (GetLastError() != ERROR_IO_PENDING) + Win32Fatal("ReadFile"); + } + + // Even if we read any bytes in the readfile call, we'll enter this + // function again later and get them at that point. +} + +ExitStatus Subprocess::Finish() { + if (!child_.hProcess) + return ExitFailure; + + // TODO: add error handling for all of these. + WaitForSingleObject(child_.hProcess, INFINITE); + + DWORD exit_code = 0; + GetExitCodeProcess(child_.hProcess, &exit_code); + + CloseHandle(child_.hProcess); + child_.hProcess = NULL; + exit_code_ = exit_code; + return exit_code == 0 ? ExitSuccess : + exit_code == CONTROL_C_EXIT ? ExitInterrupted : + ExitFailure; +} + +bool Subprocess::Done() const { + return pipe_ == NULL; +} + +const std::string& Subprocess::GetOutput() const { + return buf_; +} + +HANDLE SubprocessSet::ioport_; + +SubprocessSet::SubprocessSet() { + ioport_ = ::CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1); + if (!ioport_) + Win32Fatal("CreateIoCompletionPort"); + if (!SetConsoleCtrlHandler(NotifyInterrupted, TRUE)) + Win32Fatal("SetConsoleCtrlHandler"); +} + +SubprocessSet::~SubprocessSet() { + Clear(); + + SetConsoleCtrlHandler(NotifyInterrupted, FALSE); + CloseHandle(ioport_); +} + +BOOL WINAPI SubprocessSet::NotifyInterrupted(DWORD dwCtrlType) { + if (dwCtrlType == CTRL_C_EVENT || dwCtrlType == CTRL_BREAK_EVENT) { + if (!PostQueuedCompletionStatus(ioport_, 0, 0, NULL)) + Win32Fatal("PostQueuedCompletionStatus"); + return TRUE; + } + + return FALSE; +} + +Subprocess *SubprocessSet::Add(const std::string& command, + const std::string& dir) { + Subprocess *subprocess = new Subprocess; + if (!subprocess->Start(this, command, dir)) { + delete subprocess; + return 0; + } + if (subprocess->child_.hProcess) + running_.push_back(subprocess); + else + finished_.push(subprocess); + return subprocess; +} + +bool SubprocessSet::DoWork() { + DWORD bytes_read; + Subprocess* subproc; + OVERLAPPED* overlapped; + + if (!GetQueuedCompletionStatus(ioport_, &bytes_read, (cmULONG_PTR*)&subproc, + &overlapped, INFINITE)) { + if (GetLastError() != ERROR_BROKEN_PIPE) + Win32Fatal("GetQueuedCompletionStatus"); + } + + if (!subproc) // A NULL subproc indicates that we were interrupted and is + // delivered by NotifyInterrupted above. + return true; + + subproc->OnPipeReady(); + + if (subproc->Done()) { + std::vector<Subprocess*>::iterator end = + std::remove(running_.begin(), running_.end(), subproc); + if (running_.end() != end) { + finished_.push(subproc); + running_.resize(end - running_.begin()); + } + } + + return false; +} + +Subprocess* SubprocessSet::NextFinished() { + if (finished_.empty()) + return NULL; + Subprocess* subproc = finished_.front(); + finished_.pop(); + return subproc; +} + +void SubprocessSet::Clear() { + std::vector<Subprocess*>::iterator it = running_.begin(); + for (; it != running_.end(); ++it) { + if ((*it)->child_.hProcess) { + if (!GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, + (*it)->child_.dwProcessId)) + Win32Fatal("GenerateConsoleCtrlEvent"); + } + } + it = running_.begin(); + for (; it != running_.end(); ++it) + delete *it; + running_.clear(); +} + + +// Copyright 2011 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +// Wrapper around cl that adds /showIncludes to command line, and uses that to +// generate .d files that match the style from gcc -MD. +// +// /showIncludes is equivalent to -MD, not -MMD, that is, system headers are +// included. + + +#include <windows.h> +#include <sstream> +//#include "subprocess.h" +//#include "util.h" + +// We don't want any wildcard expansion. +// See http://msdn.microsoft.com/en-us/library/zay8tzh6(v=vs.85).aspx +void _setargv() {} + +static void usage(const char* msg) { + Fatal("%s\n\nusage:\n " + "cmcldeps " + "<language C, CXX or RC> " + "<source file path> " + "<output path for *.d file> " + "<output path for *.obj file> " + "<prefix of /showIncludes> " + "<path to cl.exe> " + "<path to tool (cl or rc)> " + "<rest of command ...>\n", msg); +} + +static std::string trimLeadingSpace(const std::string& cmdline) { + int i = 0; + for (; cmdline[i] == ' '; ++i) + ; + return cmdline.substr(i); +} + +static void doEscape(std::string& str, const std::string& search, + const std::string& repl) { + std::string::size_type pos = 0; + while ((pos = str.find(search, pos)) != std::string::npos) { + str.replace(pos, search.size(), repl); + pos += repl.size(); + } +} + +// Strips one argument from the cmdline and returns it. "surrounding quotes" +// are removed from the argument if there were any. +static std::string getArg(std::string& cmdline) { + std::string ret; + bool in_quoted = false; + unsigned int i = 0; + + cmdline = trimLeadingSpace(cmdline); + + for (;; ++i) { + if (i >= cmdline.size()) + usage("Couldn't parse arguments."); + if (!in_quoted && cmdline[i] == ' ') + break; // "a b" "x y" + if (cmdline[i] == '"') + in_quoted = !in_quoted; + } + + ret = cmdline.substr(0, i); + if (ret[0] == '"' && ret[i - 1] == '"') + ret = ret.substr(1, ret.size() - 2); + cmdline = cmdline.substr(i); + return ret; +} + +static void parseCommandLine(LPTSTR wincmdline, + std::string& lang, + std::string& srcfile, + std::string& dfile, + std::string& objfile, + std::string& prefix, + std::string& clpath, + std::string& binpath, + std::string& rest) { + std::string cmdline(wincmdline); + /* self */ getArg(cmdline); + lang = getArg(cmdline); + srcfile = getArg(cmdline); + dfile = getArg(cmdline); + objfile = getArg(cmdline); + prefix = getArg(cmdline); + clpath = getArg(cmdline); + binpath = getArg(cmdline); + rest = trimLeadingSpace(cmdline); +} + +static void outputDepFile(const std::string& dfile, const std::string& objfile, + std::vector<std::string>& incs) { + + if (dfile.empty()) + return; + + // strip duplicates + std::sort(incs.begin(), incs.end()); + incs.erase(std::unique(incs.begin(), incs.end()), incs.end()); + + FILE* out = fopen(dfile.c_str(), "wb"); + + // FIXME should this be fatal or not? delete obj? delete d? + if (!out) + return; + + std::string tmp = objfile; + doEscape(tmp, " ", "\\ "); + fprintf(out, "%s: \\\n", tmp.c_str()); + + std::vector<std::string>::iterator it = incs.begin(); + for (; it != incs.end(); ++it) { + tmp = *it; + doEscape(tmp, "\\", "/"); + doEscape(tmp, " ", "\\ "); + fprintf(out, "%s \\\n", tmp.c_str()); + } + + fprintf(out, "\n"); + fclose(out); +} + + +bool startsWith(const std::string& str, const std::string& what) { + return str.compare(0, what.size(), what) == 0; +} + +bool contains(const std::string& str, const std::string& what) { + return str.find(what) != std::string::npos; +} + +std::string replace(const std::string& str, const std::string& what, + const std::string& replacement) { + size_t pos = str.find(what); + if (pos == std::string::npos) + return str; + std::string replaced = str; + return replaced.replace(pos, what.size(), replacement); +} + + + +static int process( const std::string& srcfilename, + const std::string& dfile, + const std::string& objfile, + const std::string& prefix, + const std::string& cmd, + const std::string& dir = "", + bool quiet = false) { + + SubprocessSet subprocs; + Subprocess* subproc = subprocs.Add(cmd, dir); + + if(!subproc) + return 2; + + while ((subproc = subprocs.NextFinished()) == NULL) { + subprocs.DoWork(); + } + + bool success = subproc->Finish() == ExitSuccess; + int exit_code = subproc->ExitCode(); + + std::string output = subproc->GetOutput(); + delete subproc; + + // process the include directives and output everything else + std::stringstream ss(output); + std::string line; + std::vector<std::string> includes; + bool isFirstLine = true; // cl prints always first the source filename + while (std::getline(ss, line)) { + if (startsWith(line, prefix)) { + std::string inc = trimLeadingSpace(line.substr(prefix.size()).c_str()); + if (inc[inc.size() - 1] == '\r') // blech, stupid \r\n + inc = inc.substr(0, inc.size() - 1); + includes.push_back(inc); + } else { + if (!isFirstLine || !startsWith(line, srcfilename)) { + if (!quiet) { + fprintf(stdout, "%s\n", line.c_str()); + } + } else { + isFirstLine = false; + } + } + } + + if (!success) { + return exit_code; + } + + // don't update .d until/unless we succeed compilation + outputDepFile(dfile, objfile, includes); + + return 0; +} + + +int main() { + + // Use the Win32 api instead of argc/argv so we can avoid interpreting the + // rest of command line after the .d and .obj. Custom parsing seemed + // preferable to the ugliness you get into in trying to re-escape quotes for + // subprocesses, so by avoiding argc/argv, the subprocess is called with + // the same command line verbatim. + + std::string lang, srcfile, dfile, objfile, prefix, cl, binpath, rest; + parseCommandLine(GetCommandLine(), lang, srcfile, dfile, objfile, + prefix, cl, binpath, rest); + + // needed to suppress filename output of msvc tools + std::string srcfilename; + std::string::size_type pos = srcfile.rfind("\\"); + if (pos != std::string::npos) { + srcfilename = srcfile.substr(pos + 1); + } + + std::string nol = " /nologo "; + std::string show = " /showIncludes "; + if (lang == "C" || lang == "CXX") { + return process(srcfilename, dfile, objfile, prefix, + binpath + nol + show + rest); + } else if (lang == "RC") { + // "misuse" cl.exe to get headers from .rc files + + std::string clrest = rest; + // rc: /fo x.dir\x.rc.res -> cl: /out:x.dir\x.rc.res.dep.obj + clrest = replace(clrest, "/fo", "/out:"); + clrest = replace(clrest, objfile, objfile + ".dep.obj "); + // rc: src\x\x.rc -> cl: /Tc src\x\x.rc + clrest = replace(clrest, srcfile, "/Tc " + srcfile); + + cl = "\"" + cl + "\" /P /DRC_INVOKED "; + + // call cl in object dir so the .i is generated there + std::string objdir; + std::string::size_type pos = objfile.rfind("\\"); + if (pos != std::string::npos) { + objdir = objfile.substr(0, pos); + } + + // extract dependencies with cl.exe + process(srcfilename, dfile, objfile, + prefix, cl + nol + show + clrest, objdir, true); + + // compile rc file with rc.exe + return process(srcfilename, "" , objfile, prefix, binpath + " " + rest); + } + + usage("Invalid language specified."); + return 1; +} diff --git a/Source/kwsys/hashtable.hxx.in b/Source/kwsys/hashtable.hxx.in index db52fc8..c835503 100644 --- a/Source/kwsys/hashtable.hxx.in +++ b/Source/kwsys/hashtable.hxx.in @@ -394,7 +394,7 @@ enum { _stl_num_primes = 31 }; // create a function with a static local to that function that returns // the static -inline const unsigned long* get_stl_prime_list() { +static inline const unsigned long* get_stl_prime_list() { static const unsigned long _stl_prime_list[_stl_num_primes] = { diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt index aa32d67..5e36d11 100644 --- a/Tests/BuildDepends/CMakeLists.txt +++ b/Tests/BuildDepends/CMakeLists.txt @@ -28,6 +28,10 @@ function(help_xcode_depends) endif(HELP_XCODE) endfunction(help_xcode_depends) +if("${CMAKE_GENERATOR}" MATCHES "Ninja") + set(HELP_NINJA 1) # TODO Why is this needed? +endif() + # The Intel compiler causes the MSVC linker to crash during # incremental linking, so avoid the /INCREMENTAL:YES flag. if(WIN32 AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel") @@ -154,7 +158,7 @@ try_compile(RESULT OUTPUT_VARIABLE OUTPUT) # Xcode is in serious need of help here -if(HELP_XCODE) +if(HELP_XCODE OR HELP_NINJA) try_compile(RESULT ${BuildDepends_BINARY_DIR}/Project ${BuildDepends_SOURCE_DIR}/Project @@ -165,7 +169,7 @@ if(HELP_XCODE) ${BuildDepends_SOURCE_DIR}/Project testRebuild OUTPUT_VARIABLE OUTPUT) -endif(HELP_XCODE) +endif() message("Output from second build:\n${OUTPUT}") if(NOT RESULT) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index ef707e4..9deb8ac 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -315,6 +315,24 @@ IF(BUILD_TESTING) ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader) + if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag(-fPIE run_pic_test) + else() + if (CMAKE_CXX_COMPILER_ID MATCHES "PGI" + OR CMAKE_CXX_COMPILER_ID MATCHES "PathScale" + OR CMAKE_SYSTEM_NAME MATCHES "IRIX64" + OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") + set(run_pic_test 0) + else() + set(run_pic_test 1) + endif() + endif() + + if (run_pic_test) + ADD_TEST_MACRO(PositionIndependentTargets PositionIndependentTargets) + endif() + ADD_TEST(LinkFlags-prepare ${CMAKE_CTEST_COMMAND} -C \${CTEST_CONFIGURATION_TYPE} --build-and-test diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt index 2cf36f5..334b8be 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt @@ -5,9 +5,7 @@ project(TargetIncludeDirectories) macro(create_header _name) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_name}") - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_name}/${_name}.h" - "//${_name}.h - ") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_name}/${_name}.h" "//${_name}.h\n") endmacro() create_header(bar) diff --git a/Tests/PositionIndependentTargets/CMakeLists.txt b/Tests/PositionIndependentTargets/CMakeLists.txt new file mode 100644 index 0000000..eec893d --- /dev/null +++ b/Tests/PositionIndependentTargets/CMakeLists.txt @@ -0,0 +1,13 @@ + +cmake_minimum_required(VERSION 2.8) + +project(PositionIndependentTargets) + +include(CheckCXXSourceCompiles) + +include_directories("${CMAKE_CURRENT_SOURCE_DIR}") # For pic_test.h + +add_subdirectory(global) +add_subdirectory(targets) + +add_executable(PositionIndependentTargets main.cpp) diff --git a/Tests/PositionIndependentTargets/global/CMakeLists.txt b/Tests/PositionIndependentTargets/global/CMakeLists.txt new file mode 100644 index 0000000..1d662f8 --- /dev/null +++ b/Tests/PositionIndependentTargets/global/CMakeLists.txt @@ -0,0 +1,37 @@ + +set(CMAKE_POSITION_INDEPENDENT_CODE True) + +add_executable(test_target_executable_global + "${CMAKE_CURRENT_SOURCE_DIR}/../pic_main.cpp" +) + +add_library(test_target_shared_library_global + SHARED "${CMAKE_CURRENT_SOURCE_DIR}/../pic_lib.cpp" +) +set_target_properties(test_target_shared_library_global + PROPERTIES DEFINE_SYMBOL PIC_TEST_BUILD_DLL +) + +add_library(test_target_static_library_global + STATIC "${CMAKE_CURRENT_SOURCE_DIR}/../pic_lib.cpp" +) +set_target_properties(test_target_static_library_global + PROPERTIES COMPILE_DEFINITIONS PIC_TEST_STATIC_BUILD +) + + +file(READ + "${CMAKE_CURRENT_SOURCE_DIR}/../pic_test.h" + PIC_HEADER_CONTENT +) + +check_cxx_source_compiles( + " +${PIC_HEADER_CONTENT} +int main(int,char**) { return 0; }\n" + PIC_TRY_COMPILE_RESULT +) + +if (NOT PIC_TRY_COMPILE_RESULT) + message(SEND_ERROR "TRY_COMPILE with content requiring __PIC__ failed. ${OUTPUT}") +endif() diff --git a/Tests/PositionIndependentTargets/main.cpp b/Tests/PositionIndependentTargets/main.cpp new file mode 100644 index 0000000..e72cef7 --- /dev/null +++ b/Tests/PositionIndependentTargets/main.cpp @@ -0,0 +1,2 @@ + +int main(int,char**) { return 0; } diff --git a/Tests/PositionIndependentTargets/pic_lib.cpp b/Tests/PositionIndependentTargets/pic_lib.cpp new file mode 100644 index 0000000..b8b25a3 --- /dev/null +++ b/Tests/PositionIndependentTargets/pic_lib.cpp @@ -0,0 +1,12 @@ + +#include "pic_test.h" + +class PIC_TEST_EXPORT Dummy +{ + int dummy(); +}; + +int Dummy::dummy() +{ + return 0; +} diff --git a/Tests/PositionIndependentTargets/pic_main.cpp b/Tests/PositionIndependentTargets/pic_main.cpp new file mode 100644 index 0000000..6a41a7a --- /dev/null +++ b/Tests/PositionIndependentTargets/pic_main.cpp @@ -0,0 +1,4 @@ + +#include "pic_test.h" + +int main(int,char**) { return 0; } diff --git a/Tests/PositionIndependentTargets/pic_test.h b/Tests/PositionIndependentTargets/pic_test.h new file mode 100644 index 0000000..3f64557 --- /dev/null +++ b/Tests/PositionIndependentTargets/pic_test.h @@ -0,0 +1,20 @@ + +#if defined(__ELF__) +# if !defined(__PIC__) +# error "The POSITION_INDEPENDENT_CODE property should cause __PIC__ to be defined on ELF platforms." +# endif +#endif + +#if defined(PIC_TEST_STATIC_BUILD) +# define PIC_TEST_EXPORT +#else +# if defined(_WIN32) || defined(WIN32) /* Win32 version */ +# ifdef PIC_TEST_BUILD_DLL +# define PIC_TEST_EXPORT __declspec(dllexport) +# else +# define PIC_TEST_EXPORT __declspec(dllimport) +# endif +# else +# define PIC_TEST_EXPORT +# endif +#endif diff --git a/Tests/PositionIndependentTargets/targets/CMakeLists.txt b/Tests/PositionIndependentTargets/targets/CMakeLists.txt new file mode 100644 index 0000000..4724c85 --- /dev/null +++ b/Tests/PositionIndependentTargets/targets/CMakeLists.txt @@ -0,0 +1,20 @@ + +add_executable(test_target_executable_properties "${CMAKE_CURRENT_SOURCE_DIR}/../pic_main.cpp") +set_target_properties(test_target_executable_properties + PROPERTIES + POSITION_INDEPENDENT_CODE True +) + +add_library(test_target_shared_library_properties SHARED "${CMAKE_CURRENT_SOURCE_DIR}/../pic_lib.cpp") +set_target_properties(test_target_shared_library_properties + PROPERTIES + POSITION_INDEPENDENT_CODE True + DEFINE_SYMBOL PIC_TEST_BUILD_DLL +) + +add_library(test_target_static_library_properties STATIC "${CMAKE_CURRENT_SOURCE_DIR}/../pic_lib.cpp") +set_target_properties(test_target_static_library_properties + PROPERTIES + POSITION_INDEPENDENT_CODE True + COMPILE_DEFINITIONS PIC_TEST_STATIC_BUILD +) diff --git a/Tests/SystemInformation/SystemInformation.in b/Tests/SystemInformation/SystemInformation.in index 90ae20a..ecbc054 100644 --- a/Tests/SystemInformation/SystemInformation.in +++ b/Tests/SystemInformation/SystemInformation.in @@ -30,6 +30,9 @@ CMAKE_SHARED_LIBRARY_RUNTIME_FLAG == "${CMAKE_SHARED_LIBRARY_RUNTIME_FLAG}" CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP == "${CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP}" CMAKE_SHARED_LIBRARY_LINK_STATIC_C_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_STATIC_C_FLAGS}" CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_C_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_C_FLAGS}" +CMAKE_C_COMPILE_OPTIONS_PIC == "${CMAKE_C_COMPILE_OPTIONS_PIC}" +CMAKE_C_COMPILE_OPTIONS_PIE == "${CMAKE_C_COMPILE_OPTIONS_PIE}" +CMAKE_C_COMPILE_OPTIONS_DLL == "${CMAKE_C_COMPILE_OPTIONS_DLL}" // C shared module flags CMAKE_SHARED_MODULE_C_FLAGS == "${CMAKE_SHARED_MODULE_C_FLAGS}" @@ -49,6 +52,9 @@ CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG == "${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLA CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP == "${CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP}" CMAKE_SHARED_LIBRARY_LINK_STATIC_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_STATIC_CXX_FLAGS}" CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS == "${CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS}" +CMAKE_CXX_COMPILE_OPTIONS_PIC == "${CMAKE_CXX_COMPILE_OPTIONS_PIC}" +CMAKE_CXX_COMPILE_OPTIONS_PIE == "${CMAKE_CXX_COMPILE_OPTIONS_PIE}" +CMAKE_CXX_COMPILE_OPTIONS_DLL == "${CMAKE_CXX_COMPILE_OPTIONS_DLL}" // CXX shared module flags CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS == "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS}" diff --git a/Utilities/KWIML/INT.h.in b/Utilities/KWIML/INT.h.in index 3c1f05d..d40edcd 100644 --- a/Utilities/KWIML/INT.h.in +++ b/Utilities/KWIML/INT.h.in @@ -87,6 +87,10 @@ An includer may test the following macros after inclusion: The SCN*8 and SCN*64 format macros will not be defined on systems with scanf implementations known not to support them. + @KWIML@_INT_BROKEN_<fmt># = macro <fmt># is incorrect if defined + Some compilers define integer format macros incorrectly for their + own formatted print/scan implementations. + @KWIML@_INT_BROKEN_INT64_C = macro INT64_C is incorrect if defined @KWIML@_INT_BROKEN_UINT64_C = macro UINT64_C is incorrect if defined Some compilers define integer constant macros incorrectly and @@ -172,6 +176,65 @@ An includer may test the following macros after inclusion: #define @KWIML@_INT_HAVE_UINTPTR_T 1 #endif +#if defined(_AIX43) && !defined(_AIX50) && !defined(_AIX51) + /* AIX 4.3 defines these incorrectly with % and no quotes. */ +# define @KWIML@_INT_BROKEN_PRId8 +# define @KWIML@_INT_BROKEN_SCNd8 +# define @KWIML@_INT_BROKEN_PRIi8 +# define @KWIML@_INT_BROKEN_SCNi8 +# define @KWIML@_INT_BROKEN_PRIo8 +# define @KWIML@_INT_BROKEN_SCNo8 +# define @KWIML@_INT_BROKEN_PRIu8 +# define @KWIML@_INT_BROKEN_SCNu8 +# define @KWIML@_INT_BROKEN_PRIx8 +# define @KWIML@_INT_BROKEN_SCNx8 +# define @KWIML@_INT_BROKEN_PRIX8 +# define @KWIML@_INT_BROKEN_PRId16 +# define @KWIML@_INT_BROKEN_SCNd16 +# define @KWIML@_INT_BROKEN_PRIi16 +# define @KWIML@_INT_BROKEN_SCNi16 +# define @KWIML@_INT_BROKEN_PRIo16 +# define @KWIML@_INT_BROKEN_SCNo16 +# define @KWIML@_INT_BROKEN_PRIu16 +# define @KWIML@_INT_BROKEN_SCNu16 +# define @KWIML@_INT_BROKEN_PRIx16 +# define @KWIML@_INT_BROKEN_SCNx16 +# define @KWIML@_INT_BROKEN_PRIX16 +# define @KWIML@_INT_BROKEN_PRId32 +# define @KWIML@_INT_BROKEN_SCNd32 +# define @KWIML@_INT_BROKEN_PRIi32 +# define @KWIML@_INT_BROKEN_SCNi32 +# define @KWIML@_INT_BROKEN_PRIo32 +# define @KWIML@_INT_BROKEN_SCNo32 +# define @KWIML@_INT_BROKEN_PRIu32 +# define @KWIML@_INT_BROKEN_SCNu32 +# define @KWIML@_INT_BROKEN_PRIx32 +# define @KWIML@_INT_BROKEN_SCNx32 +# define @KWIML@_INT_BROKEN_PRIX32 +# define @KWIML@_INT_BROKEN_PRId64 +# define @KWIML@_INT_BROKEN_SCNd64 +# define @KWIML@_INT_BROKEN_PRIi64 +# define @KWIML@_INT_BROKEN_SCNi64 +# define @KWIML@_INT_BROKEN_PRIo64 +# define @KWIML@_INT_BROKEN_SCNo64 +# define @KWIML@_INT_BROKEN_PRIu64 +# define @KWIML@_INT_BROKEN_SCNu64 +# define @KWIML@_INT_BROKEN_PRIx64 +# define @KWIML@_INT_BROKEN_SCNx64 +# define @KWIML@_INT_BROKEN_PRIX64 +# define @KWIML@_INT_BROKEN_PRIdPTR +# define @KWIML@_INT_BROKEN_SCNdPTR +# define @KWIML@_INT_BROKEN_PRIiPTR +# define @KWIML@_INT_BROKEN_SCNiPTR +# define @KWIML@_INT_BROKEN_PRIoPTR +# define @KWIML@_INT_BROKEN_SCNoPTR +# define @KWIML@_INT_BROKEN_PRIuPTR +# define @KWIML@_INT_BROKEN_SCNuPTR +# define @KWIML@_INT_BROKEN_PRIxPTR +# define @KWIML@_INT_BROKEN_SCNxPTR +# define @KWIML@_INT_BROKEN_PRIXPTR +#endif + #if (defined(__SUNPRO_C)||defined(__SUNPRO_CC)) && defined(_CHAR_IS_UNSIGNED) # define @KWIML@_INT_BROKEN_INT8_T /* system type defined incorrectly */ #elif defined(__BORLANDC__) && defined(_CHAR_UNSIGNED) @@ -208,59 +271,70 @@ An includer may test the following macros after inclusion: #endif /* 8-bit d, i */ -#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(PRId8) +#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(PRId8) \ + && !defined(@KWIML@_INT_BROKEN_PRId8) # define @KWIML@_INT_PRId8 PRId8 #else # define @KWIML@_INT_PRId8 "d" #endif -#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(SCNd8) +#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(SCNd8) \ + && !defined(@KWIML@_INT_BROKEN_SCNd8) # define @KWIML@_INT_SCNd8 SCNd8 #elif !defined(@KWIML@_INT__NO_SCN8) # define @KWIML@_INT_SCNd8 "hhd" #endif -#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(PRIi8) +#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(PRIi8) \ + && !defined(@KWIML@_INT_BROKEN_PRIi8) # define @KWIML@_INT_PRIi8 PRIi8 #else # define @KWIML@_INT_PRIi8 "i" #endif -#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(SCNi8) +#if defined(@KWIML@_INT_HAVE_INT8_T) && defined(SCNi8) \ + && !defined(@KWIML@_INT_BROKEN_SCNi8) # define @KWIML@_INT_SCNi8 SCNi8 #elif !defined(@KWIML@_INT__NO_SCN8) # define @KWIML@_INT_SCNi8 "hhi" #endif /* 8-bit o, u, x, X */ -#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIo8) +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIo8) \ + && !defined(@KWIML@_INT_BROKEN_PRIo8) # define @KWIML@_INT_PRIo8 PRIo8 #else # define @KWIML@_INT_PRIo8 "o" #endif -#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNo8) +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNo8) \ + && !defined(@KWIML@_INT_BROKEN_SCNo8) # define @KWIML@_INT_SCNo8 SCNo8 #elif !defined(@KWIML@_INT__NO_SCN8) # define @KWIML@_INT_SCNo8 "hho" #endif -#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIu8) +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIu8) \ + && !defined(@KWIML@_INT_BROKEN_PRIu8) # define @KWIML@_INT_PRIu8 PRIu8 #else # define @KWIML@_INT_PRIu8 "u" #endif -#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNu8) +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNu8) \ + && !defined(@KWIML@_INT_BROKEN_SCNu8) # define @KWIML@_INT_SCNu8 SCNu8 #elif !defined(@KWIML@_INT__NO_SCN8) # define @KWIML@_INT_SCNu8 "hhu" #endif -#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIx8) +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIx8) \ + && !defined(@KWIML@_INT_BROKEN_PRIx8) # define @KWIML@_INT_PRIx8 PRIx8 #else # define @KWIML@_INT_PRIx8 "x" #endif -#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNx8) +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(SCNx8) \ + && !defined(@KWIML@_INT_BROKEN_SCNx8) # define @KWIML@_INT_SCNx8 SCNx8 #elif !defined(@KWIML@_INT__NO_SCN8) # define @KWIML@_INT_SCNx8 "hhx" #endif -#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIX8) +#if defined(@KWIML@_INT_HAVE_UINT8_T) && defined(PRIX8) \ + && !defined(@KWIML@_INT_BROKEN_PRIX8) # define @KWIML@_INT_PRIX8 PRIX8 #else # define @KWIML@_INT_PRIX8 "X" @@ -291,59 +365,70 @@ An includer may test the following macros after inclusion: #endif /* 16-bit d, i */ -#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(PRId16) +#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(PRId16) \ + && !defined(@KWIML@_INT_BROKEN_PRId16) # define @KWIML@_INT_PRId16 PRId16 #else # define @KWIML@_INT_PRId16 "d" #endif -#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(SCNd16) +#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(SCNd16) \ + && !defined(@KWIML@_INT_BROKEN_SCNd16) # define @KWIML@_INT_SCNd16 SCNd16 #else # define @KWIML@_INT_SCNd16 "hd" #endif -#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(PRIi16) +#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(PRIi16) \ + && !defined(@KWIML@_INT_BROKEN_PRIi16) # define @KWIML@_INT_PRIi16 PRIi16 #else # define @KWIML@_INT_PRIi16 "i" #endif -#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(SCNi16) +#if defined(@KWIML@_INT_HAVE_INT16_T) && defined(SCNi16) \ + && !defined(@KWIML@_INT_BROKEN_SCNi16) # define @KWIML@_INT_SCNi16 SCNi16 #else # define @KWIML@_INT_SCNi16 "hi" #endif /* 16-bit o, u, x, X */ -#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIo16) +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIo16) \ + && !defined(@KWIML@_INT_BROKEN_PRIo16) # define @KWIML@_INT_PRIo16 PRIo16 #else # define @KWIML@_INT_PRIo16 "o" #endif -#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNo16) +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNo16) \ + && !defined(@KWIML@_INT_BROKEN_SCNo16) # define @KWIML@_INT_SCNo16 SCNo16 #else # define @KWIML@_INT_SCNo16 "ho" #endif -#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIu16) +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIu16) \ + && !defined(@KWIML@_INT_BROKEN_PRIu16) # define @KWIML@_INT_PRIu16 PRIu16 #else # define @KWIML@_INT_PRIu16 "u" #endif -#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNu16) +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNu16) \ + && !defined(@KWIML@_INT_BROKEN_SCNu16) # define @KWIML@_INT_SCNu16 SCNu16 #else # define @KWIML@_INT_SCNu16 "hu" #endif -#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIx16) +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIx16) \ + && !defined(@KWIML@_INT_BROKEN_PRIx16) # define @KWIML@_INT_PRIx16 PRIx16 #else # define @KWIML@_INT_PRIx16 "x" #endif -#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNx16) +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(SCNx16) \ + && !defined(@KWIML@_INT_BROKEN_SCNx16) # define @KWIML@_INT_SCNx16 SCNx16 #else # define @KWIML@_INT_SCNx16 "hx" #endif -#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIX16) +#if defined(@KWIML@_INT_HAVE_UINT16_T) && defined(PRIX16) \ + && !defined(@KWIML@_INT_BROKEN_PRIX16) # define @KWIML@_INT_PRIX16 PRIX16 #else # define @KWIML@_INT_PRIX16 "X" @@ -374,59 +459,70 @@ An includer may test the following macros after inclusion: #endif /* 32-bit d, i */ -#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(PRId32) +#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(PRId32) \ + && !defined(@KWIML@_INT_BROKEN_PRId32) # define @KWIML@_INT_PRId32 PRId32 #else # define @KWIML@_INT_PRId32 "d" #endif -#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(SCNd32) +#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(SCNd32) \ + && !defined(@KWIML@_INT_BROKEN_SCNd32) # define @KWIML@_INT_SCNd32 SCNd32 #else # define @KWIML@_INT_SCNd32 "d" #endif -#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(PRIi32) +#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(PRIi32) \ + && !defined(@KWIML@_INT_BROKEN_PRIi32) # define @KWIML@_INT_PRIi32 PRIi32 #else # define @KWIML@_INT_PRIi32 "i" #endif -#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(SCNi32) +#if defined(@KWIML@_INT_HAVE_INT32_T) && defined(SCNi32) \ + && !defined(@KWIML@_INT_BROKEN_SCNi32) # define @KWIML@_INT_SCNi32 SCNi32 #else # define @KWIML@_INT_SCNi32 "i" #endif /* 32-bit o, u, x, X */ -#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIo32) +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIo32) \ + && !defined(@KWIML@_INT_BROKEN_PRIo32) # define @KWIML@_INT_PRIo32 PRIo32 #else # define @KWIML@_INT_PRIo32 "o" #endif -#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNo32) +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNo32) \ + && !defined(@KWIML@_INT_BROKEN_SCNo32) # define @KWIML@_INT_SCNo32 SCNo32 #else # define @KWIML@_INT_SCNo32 "o" #endif -#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIu32) +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIu32) \ + && !defined(@KWIML@_INT_BROKEN_PRIu32) # define @KWIML@_INT_PRIu32 PRIu32 #else # define @KWIML@_INT_PRIu32 "u" #endif -#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNu32) +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNu32) \ + && !defined(@KWIML@_INT_BROKEN_SCNu32) # define @KWIML@_INT_SCNu32 SCNu32 #else # define @KWIML@_INT_SCNu32 "u" #endif -#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIx32) +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIx32) \ + && !defined(@KWIML@_INT_BROKEN_PRIx32) # define @KWIML@_INT_PRIx32 PRIx32 #else # define @KWIML@_INT_PRIx32 "x" #endif -#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNx32) +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(SCNx32) \ + && !defined(@KWIML@_INT_BROKEN_SCNx32) # define @KWIML@_INT_SCNx32 SCNx32 #else # define @KWIML@_INT_SCNx32 "x" #endif -#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIX32) +#if defined(@KWIML@_INT_HAVE_UINT32_T) && defined(PRIX32) \ + && !defined(@KWIML@_INT_BROKEN_PRIX32) # define @KWIML@_INT_PRIX32 PRIX32 #else # define @KWIML@_INT_PRIX32 "X" @@ -498,59 +594,70 @@ An includer may test the following macros after inclusion: #endif /* 64-bit d, i */ -#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(PRId64) +#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(PRId64) \ + && !defined(@KWIML@_INT_BROKEN_PRId64) # define @KWIML@_INT_PRId64 PRId64 #elif defined(@KWIML@_INT__FMT64) # define @KWIML@_INT_PRId64 @KWIML@_INT__FMT64 "d" #endif -#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(SCNd64) +#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(SCNd64) \ + && !defined(@KWIML@_INT_BROKEN_SCNd64) # define @KWIML@_INT_SCNd64 SCNd64 #elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) # define @KWIML@_INT_SCNd64 @KWIML@_INT__FMT64 "d" #endif -#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(PRIi64) +#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(PRIi64) \ + && !defined(@KWIML@_INT_BROKEN_PRIi64) # define @KWIML@_INT_PRIi64 PRIi64 #elif defined(@KWIML@_INT__FMT64) # define @KWIML@_INT_PRIi64 @KWIML@_INT__FMT64 "d" #endif -#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(SCNi64) +#if defined(@KWIML@_INT_HAVE_INT64_T) && defined(SCNi64) \ + && !defined(@KWIML@_INT_BROKEN_SCNi64) # define @KWIML@_INT_SCNi64 SCNi64 #elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) # define @KWIML@_INT_SCNi64 @KWIML@_INT__FMT64 "d" #endif /* 64-bit o, u, x, X */ -#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIo64) +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIo64) \ + && !defined(@KWIML@_INT_BROKEN_PRIo64) # define @KWIML@_INT_PRIo64 PRIo64 #elif defined(@KWIML@_INT__FMT64) # define @KWIML@_INT_PRIo64 @KWIML@_INT__FMT64 "o" #endif -#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNo64) +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNo64) \ + && !defined(@KWIML@_INT_BROKEN_SCNo64) # define @KWIML@_INT_SCNo64 SCNo64 #elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) # define @KWIML@_INT_SCNo64 @KWIML@_INT__FMT64 "o" #endif -#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIu64) +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIu64) \ + && !defined(@KWIML@_INT_BROKEN_PRIu64) # define @KWIML@_INT_PRIu64 PRIu64 #elif defined(@KWIML@_INT__FMT64) # define @KWIML@_INT_PRIu64 @KWIML@_INT__FMT64 "u" #endif -#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNu64) +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNu64) \ + && !defined(@KWIML@_INT_BROKEN_SCNu64) # define @KWIML@_INT_SCNu64 SCNu64 #elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) # define @KWIML@_INT_SCNu64 @KWIML@_INT__FMT64 "u" #endif -#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIx64) +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIx64) \ + && !defined(@KWIML@_INT_BROKEN_PRIx64) # define @KWIML@_INT_PRIx64 PRIx64 #elif defined(@KWIML@_INT__FMT64) # define @KWIML@_INT_PRIx64 @KWIML@_INT__FMT64 "x" #endif -#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNx64) +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(SCNx64) \ + && !defined(@KWIML@_INT_BROKEN_SCNx64) # define @KWIML@_INT_SCNx64 SCNx64 #elif defined(@KWIML@_INT__FMT64) && !defined(@KWIML@_INT__NO_SCN64) # define @KWIML@_INT_SCNx64 @KWIML@_INT__FMT64 "x" #endif -#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIX64) +#if defined(@KWIML@_INT_HAVE_UINT64_T) && defined(PRIX64) \ + && !defined(@KWIML@_INT_BROKEN_PRIX64) # define @KWIML@_INT_PRIX64 PRIX64 #elif defined(@KWIML@_INT__FMT64) # define @KWIML@_INT_PRIX64 @KWIML@_INT__FMT64 "X" @@ -602,28 +709,32 @@ An includer may test the following macros after inclusion: # error "No type known for 'uintptr_t'." #endif -#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(PRIdPTR) +#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(PRIdPTR) \ + && !defined(@KWIML@_INT_BROKEN_PRIdPTR) # define @KWIML@_INT_PRIdPTR PRIdPTR #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 # define @KWIML@_INT_PRIdPTR @KWIML@_INT_PRId32 #elif !defined(@KWIML@_INT_NO_UINT64_T) # define @KWIML@_INT_PRIdPTR @KWIML@_INT_PRId64 #endif -#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(SCNdPTR) +#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(SCNdPTR) \ + && !defined(@KWIML@_INT_BROKEN_SCNdPTR) # define @KWIML@_INT_SCNdPTR SCNdPTR #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 # define @KWIML@_INT_SCNdPTR @KWIML@_INT_SCNd32 #elif !defined(@KWIML@_INT_NO_UINT64_T) # define @KWIML@_INT_SCNdPTR @KWIML@_INT_SCNd64 #endif -#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(PRIiPTR) +#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(PRIiPTR) \ + && !defined(@KWIML@_INT_BROKEN_PRIiPTR) # define @KWIML@_INT_PRIiPTR PRIiPTR #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 # define @KWIML@_INT_PRIiPTR @KWIML@_INT_PRIi32 #elif !defined(@KWIML@_INT_NO_UINT64_T) # define @KWIML@_INT_PRIiPTR @KWIML@_INT_PRIi64 #endif -#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(SCNiPTR) +#if defined(@KWIML@_INT_HAVE_INTPTR_T) && defined(SCNiPTR) \ + && !defined(@KWIML@_INT_BROKEN_SCNiPTR) # define @KWIML@_INT_SCNiPTR SCNiPTR #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 # define @KWIML@_INT_SCNiPTR @KWIML@_INT_SCNi32 @@ -631,49 +742,56 @@ An includer may test the following macros after inclusion: # define @KWIML@_INT_SCNiPTR @KWIML@_INT_SCNi64 #endif -#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIoPTR) +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIoPTR) \ + && !defined(@KWIML@_INT_BROKEN_PRIoPTR) # define @KWIML@_INT_PRIoPTR PRIoPTR #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 # define @KWIML@_INT_PRIoPTR @KWIML@_INT_PRIo32 #elif !defined(@KWIML@_INT_NO_UINT64_T) # define @KWIML@_INT_PRIoPTR @KWIML@_INT_PRIo64 #endif -#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNoPTR) +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNoPTR) \ + && !defined(@KWIML@_INT_BROKEN_SCNoPTR) # define @KWIML@_INT_SCNoPTR SCNoPTR #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 # define @KWIML@_INT_SCNoPTR @KWIML@_INT_SCNo32 #elif !defined(@KWIML@_INT_NO_UINT64_T) # define @KWIML@_INT_SCNoPTR @KWIML@_INT_SCNo64 #endif -#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIuPTR) +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIuPTR) \ + && !defined(@KWIML@_INT_BROKEN_PRIuPTR) # define @KWIML@_INT_PRIuPTR PRIuPTR #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 # define @KWIML@_INT_PRIuPTR @KWIML@_INT_PRIu32 #elif !defined(@KWIML@_INT_NO_UINT64_T) # define @KWIML@_INT_PRIuPTR @KWIML@_INT_PRIu64 #endif -#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNuPTR) +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNuPTR) \ + && !defined(@KWIML@_INT_BROKEN_SCNuPTR) # define @KWIML@_INT_SCNuPTR SCNuPTR #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 # define @KWIML@_INT_SCNuPTR @KWIML@_INT_SCNu32 #elif !defined(@KWIML@_INT_NO_UINT64_T) # define @KWIML@_INT_SCNuPTR @KWIML@_INT_SCNu64 #endif -#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIxPTR) +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIxPTR) \ + && !defined(@KWIML@_INT_BROKEN_PRIxPTR) # define @KWIML@_INT_PRIxPTR PRIxPTR #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 # define @KWIML@_INT_PRIxPTR @KWIML@_INT_PRIx32 #elif !defined(@KWIML@_INT_NO_UINT64_T) # define @KWIML@_INT_PRIxPTR @KWIML@_INT_PRIx64 #endif -#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNxPTR) +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(SCNxPTR) \ + && !defined(@KWIML@_INT_BROKEN_SCNxPTR) # define @KWIML@_INT_SCNxPTR SCNxPTR #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 # define @KWIML@_INT_SCNxPTR @KWIML@_INT_SCNx32 #elif !defined(@KWIML@_INT_NO_UINT64_T) # define @KWIML@_INT_SCNxPTR @KWIML@_INT_SCNx64 #endif -#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIXPTR) +#if defined(@KWIML@_INT_HAVE_UINTPTR_T) && defined(PRIXPTR) \ + && !defined(@KWIML@_INT_BROKEN_PRIXPTR) # define @KWIML@_INT_PRIXPTR PRIXPTR #elif @KWIML@_ABI_SIZEOF_DATA_PTR == 4 # define @KWIML@_INT_PRIXPTR @KWIML@_INT_PRIX32 diff --git a/Utilities/cmbzip2/sample1.bz2 b/Utilities/cmbzip2/sample1.bz2 Binary files differdeleted file mode 100644 index 4edda36..0000000 --- a/Utilities/cmbzip2/sample1.bz2 +++ /dev/null diff --git a/Utilities/cmbzip2/sample2.bz2 b/Utilities/cmbzip2/sample2.bz2 Binary files differdeleted file mode 100644 index 8e54297..0000000 --- a/Utilities/cmbzip2/sample2.bz2 +++ /dev/null diff --git a/Utilities/cmbzip2/sample3.bz2 b/Utilities/cmbzip2/sample3.bz2 Binary files differdeleted file mode 100644 index 1ebcc2a..0000000 --- a/Utilities/cmbzip2/sample3.bz2 +++ /dev/null diff --git a/Utilities/cmlibarchive/libarchive/archive_endian.h b/Utilities/cmlibarchive/libarchive/archive_endian.h index c3c78b3..bbf58fd 100644 --- a/Utilities/cmlibarchive/libarchive/archive_endian.h +++ b/Utilities/cmlibarchive/libarchive/archive_endian.h @@ -45,11 +45,14 @@ * - SGI MIPSpro * - Microsoft Visual C++ 6.0 (supposedly newer versions too) * - IBM VisualAge 6 (XL v6) + * - Sun WorkShop C (SunPro) before 5.9 */ #if defined(__WATCOMC__) || defined(__sgi) || defined(__hpux) || defined(__BORLANDC__) #define inline #elif defined(__IBMC__) && __IBMC__ < 700 #define inline +#elif defined(__SUNPRO_C) && __SUNPRO_C < 0x590 +#define inline #elif defined(_MSC_VER) || defined(__osf__) #define inline __inline #endif |