summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/CMakeCCompiler.cmake.in3
-rw-r--r--Modules/CMakeCXXCompiler.cmake.in3
-rw-r--r--Modules/CMakeClDeps.cmake37
-rw-r--r--Modules/CMakeDetermineCCompiler.cmake6
-rw-r--r--Modules/CMakeDetermineCXXCompiler.cmake1
-rw-r--r--Modules/CPackDeb.cmake30
-rw-r--r--Modules/FindArmadillo.cmake2
-rw-r--r--Modules/FindBullet.cmake2
-rw-r--r--Modules/FindCUDA.cmake2
-rw-r--r--Modules/FindDevIL.cmake21
-rw-r--r--Modules/FindFLTK.cmake10
-rw-r--r--Modules/FindFLTK2.cmake14
-rw-r--r--Modules/FindLua50.cmake6
-rw-r--r--Modules/FindLua51.cmake4
-rw-r--r--Modules/FindOpenAL.cmake4
-rw-r--r--Modules/FindPhysFS.cmake4
-rw-r--r--Modules/FindProducer.cmake4
-rw-r--r--Modules/FindQt4.cmake25
-rw-r--r--Modules/FindSDL_image.cmake4
-rw-r--r--Modules/FindSDL_mixer.cmake4
-rw-r--r--Modules/FindSDL_net.cmake4
-rw-r--r--Modules/FindSDL_sound.cmake20
-rw-r--r--Modules/FindSDL_ttf.cmake4
-rw-r--r--Modules/FindSquish.cmake8
-rw-r--r--Modules/FindTCL.cmake4
-rw-r--r--Modules/FindTclStub.cmake2
-rw-r--r--Modules/FindwxWindows.cmake2
-rw-r--r--Modules/Qt4Macros.cmake37
-rw-r--r--Source/CMakeLists.txt11
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CTest/cmCTestBZR.cxx3
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx6
-rw-r--r--Source/cmGlobalKdevelopGenerator.cxx3
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx127
-rw-r--r--Source/cmGlobalNinjaGenerator.h15
-rw-r--r--Source/cmLocalGenerator.cxx18
-rw-r--r--Source/cmLocalGenerator.h5
-rw-r--r--Source/cmLocalNinjaGenerator.cxx14
-rw-r--r--Source/cmMakefile.cxx8
-rw-r--r--Source/cmMakefileTargetGenerator.cxx6
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx114
-rw-r--r--Source/cmNinjaNormalTargetGenerator.h5
-rw-r--r--Source/cmNinjaTargetGenerator.cxx95
-rw-r--r--Source/cmNinjaTargetGenerator.h3
-rw-r--r--Source/cmOrderDirectories.h1
-rw-r--r--Source/cmQtAutomoc.cxx7
-rw-r--r--Source/cmSetCommand.h88
-rw-r--r--Source/cmake.cxx4
-rw-r--r--Source/cmcldeps.cxx736
-rw-r--r--Tests/Assembler/CMakeLists.txt1
-rw-r--r--Tests/BuildDepends/CMakeLists.txt8
-rw-r--r--Tests/CMakeLib/run_compile_commands.cxx4
-rw-r--r--Tests/CTestUpdateGIT.cmake.in3
-rw-r--r--Tests/FindPackageModeMakefileTest/Makefile.in25
-rw-r--r--Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/Languages/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/Languages/NoLangSHARED-result.txt1
-rw-r--r--Tests/RunCMake/Languages/NoLangSHARED-stderr.txt1
-rw-r--r--Tests/RunCMake/Languages/NoLangSHARED.cmake1
-rw-r--r--Tests/RunCMake/Languages/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/Languages/foo.nolang0
-rw-r--r--Tests/VSGNUFortran/c_code/main.c2
63 files changed, 1320 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/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..9028e8e 100644
--- a/Modules/CMakeDetermineCCompiler.cmake
+++ b/Modules/CMakeDetermineCCompiler.cmake
@@ -32,7 +32,7 @@
# _CMAKE_TOOLCHAIN_PREFIX
IF(NOT CMAKE_C_COMPILER)
- SET(CMAKE_CXX_COMPILER_INIT NOTFOUND)
+ SET(CMAKE_C_COMPILER_INIT NOTFOUND)
# prefer the environment variable CC
IF($ENV{CC} MATCHES ".+")
@@ -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/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/FindArmadillo.cmake b/Modules/FindArmadillo.cmake
index 50eb787..84ed3ca 100644
--- a/Modules/FindArmadillo.cmake
+++ b/Modules/FindArmadillo.cmake
@@ -74,7 +74,7 @@ endif (ARMADILLO_INCLUDE_DIR)
#======================
-# Checks 'RECQUIRED', 'QUIET' and versions.
+# Checks 'REQUIRED', 'QUIET' and versions.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Armadillo
REQUIRED_VARS ARMADILLO_LIBRARY ARMADILLO_INCLUDE_DIR
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/FindCUDA.cmake b/Modules/FindCUDA.cmake
index 9f8d575..56a92c1 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -540,7 +540,7 @@ set (CUDA_INCLUDE_DIRS ${CUDA_TOOLKIT_INCLUDE})
macro(FIND_LIBRARY_LOCAL_FIRST _var _names _doc)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
- # CUDA 3.2+ on Windows moved the library directoryies, so we need the new
+ # CUDA 3.2+ on Windows moved the library directories, so we need the new
# and old paths.
set(_cuda_64bit_lib_dir "lib/x64" "lib64" )
endif()
diff --git a/Modules/FindDevIL.cmake b/Modules/FindDevIL.cmake
index 0e21284..4a0fbe0 100644
--- a/Modules/FindDevIL.cmake
+++ b/Modules/FindDevIL.cmake
@@ -2,11 +2,22 @@
# http://openil.sourceforge.net/
#
# This module sets:
-# IL_LIBRARIES the name of the IL library. These include the full path to the core DevIL library. This one has to be linked into the application.
-# ILU_LIBRARIES the name of the ILU library. Again, the full path. This library is for filters and effects, not actual loading. It doesn't have to be linked if the functionality it provides is not used.
-# ILUT_LIBRARIES the name of the ILUT library. Full path. This part of the library interfaces with OpenGL. It is not strictly needed in applications.
-# IL_INCLUDE_DIR where to find the il.h, ilu.h and ilut.h files.
-# IL_FOUND this is set to TRUE if all the above variables were set. This will be set to false if ILU or ILUT are not found, even if they are not needed. In most systems, if one library is found all the others are as well. That's the way the DevIL developers release it.
+# IL_LIBRARIES - the name of the IL library. These include the full path to
+# the core DevIL library. This one has to be linked into the
+# application.
+# ILU_LIBRARIES - the name of the ILU library. Again, the full path. This
+# library is for filters and effects, not actual loading. It
+# doesn't have to be linked if the functionality it provides
+# is not used.
+# ILUT_LIBRARIES - the name of the ILUT library. Full path. This part of the
+# library interfaces with OpenGL. It is not strictly needed
+# in applications.
+# IL_INCLUDE_DIR - where to find the il.h, ilu.h and ilut.h files.
+# IL_FOUND - this is set to TRUE if all the above variables were set.
+# This will be set to false if ILU or ILUT are not found,
+# even if they are not needed. In most systems, if one
+# library is found all the others are as well. That's the
+# way the DevIL developers release it.
#=============================================================================
# Copyright 2008-2009 Kitware, Inc.
diff --git a/Modules/FindFLTK.cmake b/Modules/FindFLTK.cmake
index bb18a2e..bdea95b 100644
--- a/Modules/FindFLTK.cmake
+++ b/Modules/FindFLTK.cmake
@@ -79,18 +79,14 @@ SET(FLTK_DIR_STRING "directory containing FLTKConfig.cmake. This is either the
# Search only if the location is not already known.
IF(NOT FLTK_DIR)
# Get the system search path as a list.
- IF(UNIX)
- STRING(REGEX MATCHALL "[^:]+" FLTK_DIR_SEARCH1 "$ENV{PATH}")
- ELSE(UNIX)
- STRING(REGEX REPLACE "\\\\" "/" FLTK_DIR_SEARCH1 "$ENV{PATH}")
- ENDIF(UNIX)
- STRING(REGEX REPLACE "/;" ";" FLTK_DIR_SEARCH2 ${FLTK_DIR_SEARCH1})
+ FILE(TO_CMAKE_PATH "$ENV{PATH}" FLTK_DIR_SEARCH2)
# Construct a set of paths relative to the system search path.
SET(FLTK_DIR_SEARCH "")
FOREACH(dir ${FLTK_DIR_SEARCH2})
SET(FLTK_DIR_SEARCH ${FLTK_DIR_SEARCH} "${dir}/../lib/fltk")
ENDFOREACH(dir)
+ STRING(REPLACE "//" "/" FLTK_DIR_SEARCH "${FLTK_DIR_SEARCH}")
#
# Look for an installation or build tree.
@@ -105,8 +101,6 @@ IF(NOT FLTK_DIR)
# Look in standard UNIX install locations.
/usr/local/lib/fltk
/usr/lib/fltk
- /usr/local/include
- /usr/include
/usr/local/fltk
/usr/X11R6/include
diff --git a/Modules/FindFLTK2.cmake b/Modules/FindFLTK2.cmake
index 436e280..9164745 100644
--- a/Modules/FindFLTK2.cmake
+++ b/Modules/FindFLTK2.cmake
@@ -59,18 +59,14 @@ SET(FLTK2_DIR_STRING "directory containing FLTK2Config.cmake. This is either th
# Search only if the location is not already known.
IF(NOT FLTK2_DIR)
# Get the system search path as a list.
- IF(UNIX)
- STRING(REGEX MATCHALL "[^:]+" FLTK2_DIR_SEARCH1 "$ENV{PATH}")
- ELSE(UNIX)
- STRING(REGEX REPLACE "\\\\" "/" FLTK2_DIR_SEARCH1 "$ENV{PATH}")
- ENDIF(UNIX)
- STRING(REGEX REPLACE "/;" ";" FLTK2_DIR_SEARCH2 ${FLTK2_DIR_SEARCH1})
+ FILE(TO_CMAKE_PATH "$ENV{PATH}" FLTK2_DIR_SEARCH2)
# Construct a set of paths relative to the system search path.
SET(FLTK2_DIR_SEARCH "")
FOREACH(dir ${FLTK2_DIR_SEARCH2})
SET(FLTK2_DIR_SEARCH ${FLTK2_DIR_SEARCH} "${dir}/../lib/fltk")
ENDFOREACH(dir)
+ STRING(REPLACE "//" "/" FLTK2_DIR_SEARCH "${FLTK2_DIR_SEARCH}")
#
# Look for an installation or build tree.
@@ -85,8 +81,6 @@ IF(NOT FLTK2_DIR)
# Look in standard UNIX install locations.
/usr/local/lib/fltk2
/usr/lib/fltk2
- /usr/local/include
- /usr/include
/usr/local/fltk2
/usr/X11R6/include
@@ -193,8 +187,6 @@ IF(FLTK2_DIR)
ENDIF(FLTK2_FLUID_EXECUTABLE)
SET(FLTK2_INCLUDE_SEARCH_PATH ${FLTK2_INCLUDE_SEARCH_PATH}
- /usr/local/include
- /usr/include
/usr/local/fltk2
/usr/X11R6/include
)
@@ -202,8 +194,6 @@ IF(FLTK2_DIR)
FIND_PATH(FLTK2_INCLUDE_DIR fltk/run.h ${FLTK2_INCLUDE_SEARCH_PATH})
SET(FLTK2_LIBRARY_SEARCH_PATH ${FLTK2_LIBRARY_SEARCH_PATH}
- /usr/lib
- /usr/local/lib
/usr/local/fltk2/lib
/usr/X11R6/lib
${FLTK2_INCLUDE_DIR}/lib
diff --git a/Modules/FindLua50.cmake b/Modules/FindLua50.cmake
index ee8b84e..9a5cc17 100644
--- a/Modules/FindLua50.cmake
+++ b/Modules/FindLua50.cmake
@@ -31,8 +31,6 @@ FIND_PATH(LUA_INCLUDE_DIR lua.h
PATHS
~/Library/Frameworks
/Library/Frameworks
- /usr/local
- /usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
@@ -47,8 +45,6 @@ FIND_LIBRARY(LUA_LIBRARY_lua
PATHS
~/Library/Frameworks
/Library/Frameworks
- /usr/local
- /usr
/sw
/opt/local
/opt/csw
@@ -67,8 +63,6 @@ ELSE(${LUA_LIBRARY_lua} MATCHES "framework")
$ENV{LUA_DIR}
PATH_SUFFIXES lib64 lib
PATHS
- /usr/local
- /usr
/sw
/opt/local
/opt/csw
diff --git a/Modules/FindLua51.cmake b/Modules/FindLua51.cmake
index b67dd4c..e111d36 100644
--- a/Modules/FindLua51.cmake
+++ b/Modules/FindLua51.cmake
@@ -32,8 +32,6 @@ FIND_PATH(LUA_INCLUDE_DIR lua.h
PATHS
~/Library/Frameworks
/Library/Frameworks
- /usr/local
- /usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
@@ -48,8 +46,6 @@ FIND_LIBRARY(LUA_LIBRARY
PATHS
~/Library/Frameworks
/Library/Frameworks
- /usr/local
- /usr
/sw
/opt/local
/opt/csw
diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake
index bcba6e2..cb3ce48 100644
--- a/Modules/FindOpenAL.cmake
+++ b/Modules/FindOpenAL.cmake
@@ -68,8 +68,6 @@ FIND_PATH(OPENAL_INCLUDE_DIR al.h
PATHS
~/Library/Frameworks
/Library/Frameworks
- /usr/local
- /usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
@@ -85,8 +83,6 @@ FIND_LIBRARY(OPENAL_LIBRARY
PATHS
~/Library/Frameworks
/Library/Frameworks
- /usr/local
- /usr
/sw
/opt/local
/opt/csw
diff --git a/Modules/FindPhysFS.cmake b/Modules/FindPhysFS.cmake
index 80dfd51..2e3ac14 100644
--- a/Modules/FindPhysFS.cmake
+++ b/Modules/FindPhysFS.cmake
@@ -30,8 +30,6 @@ FIND_PATH(PHYSFS_INCLUDE_DIR physfs.h
PATHS
~/Library/Frameworks
/Library/Frameworks
- /usr/local
- /usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
@@ -46,8 +44,6 @@ FIND_LIBRARY(PHYSFS_LIBRARY
PATHS
~/Library/Frameworks
/Library/Frameworks
- /usr/local
- /usr
/sw
/opt/local
/opt/csw
diff --git a/Modules/FindProducer.cmake b/Modules/FindProducer.cmake
index 39a9436..26c804a 100644
--- a/Modules/FindProducer.cmake
+++ b/Modules/FindProducer.cmake
@@ -51,8 +51,6 @@ FIND_PATH(PRODUCER_INCLUDE_DIR Producer/CameraGroup
PATHS
~/Library/Frameworks
/Library/Frameworks
- /usr/local/include
- /usr/include
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
@@ -69,8 +67,6 @@ FIND_LIBRARY(PRODUCER_LIBRARY
$ENV{OSGDIR}
PATH_SUFFIXES lib64 lib
PATHS
- /usr/local
- /usr
/sw
/opt/local
/opt/csw
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake
index 391797e..2f1708d 100644
--- a/Modules/FindQt4.cmake
+++ b/Modules/FindQt4.cmake
@@ -102,15 +102,28 @@
# accompanying header file foo.h.
# If a source file has the SKIP_AUTOMOC property set it will be ignored by this macro.
#
+# You should have a look on the AUTOMOC property for targets to achieve the same results.
+#
# macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename)
-# create a the interface header and implementation files with the
+# Create a the interface header and implementation files with the
# given basename from the given interface xml file and add it to
-# the list of sources
+# the list of sources.
+#
+# You can pass additional parameters to the qdbusxml2cpp call by setting
+# properties on the input file:
+#
+# INCLUDE the given file will be included in the generate interface header
+#
+# CLASSNAME the generated class is named accordingly
+#
+# NO_NAMESPACE the generated class is not wrapped in a namespace
#
# macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... )
-# create the interface header and implementation files
-# for all listed interface xml files
-# the name will be automatically determined from the name of the xml file
+# Create the interface header and implementation files
+# for all listed interface xml files.
+# The basename will be automatically determined from the name of the xml file.
+#
+# The source file properties described for QT4_ADD_DBUS_INTERFACE also apply here.
#
# macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname [basename] [classname])
# create a dbus adaptor (header and implementation file) from the xml file
@@ -217,7 +230,7 @@
# QT_QAXCONTAINER_INCLUDE_DIR Path to "include/ActiveQt" (Windows only)
# QT_QAXSERVER_INCLUDE_DIR Path to "include/ActiveQt" (Windows only)
# QT_QTCORE_INCLUDE_DIR Path to "include/QtCore"
-# QT_QTDBUS_INCLUDE_DIR Path to "include/QtDBus"
+# QT_QTDBUS_INCLUDE_DIR Path to "include/QtDBus"
# QT_QTDESIGNER_INCLUDE_DIR Path to "include/QtDesigner"
# QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR Path to "include/QtDesigner"
# QT_QTGUI_INCLUDE_DIR Path to "include/QtGui"
diff --git a/Modules/FindSDL_image.cmake b/Modules/FindSDL_image.cmake
index 9a130fa..f215bda 100644
--- a/Modules/FindSDL_image.cmake
+++ b/Modules/FindSDL_image.cmake
@@ -39,8 +39,6 @@ FIND_PATH(SDLIMAGE_INCLUDE_DIR SDL_image.h
/usr/local/include/SDL11 # FreeBSD ports
/usr/include/SDL12
/usr/include/SDL11
- /usr/local/include
- /usr/include
/sw/include/SDL # Fink
/sw/include
/opt/local/include/SDL # DarwinPorts
@@ -60,8 +58,6 @@ FIND_LIBRARY(SDLIMAGE_LIBRARY
PATHS
~/Library/Frameworks
/Library/Frameworks
- /usr/local
- /usr
/sw
/opt/local
/opt/csw
diff --git a/Modules/FindSDL_mixer.cmake b/Modules/FindSDL_mixer.cmake
index ce1ae9e..7cc1a6b 100644
--- a/Modules/FindSDL_mixer.cmake
+++ b/Modules/FindSDL_mixer.cmake
@@ -39,8 +39,6 @@ FIND_PATH(SDLMIXER_INCLUDE_DIR SDL_mixer.h
/usr/local/include/SDL11 # FreeBSD ports
/usr/include/SDL12
/usr/include/SDL11
- /usr/local/include
- /usr/include
/sw/include/SDL # Fink
/sw/include
/opt/local/include/SDL # DarwinPorts
@@ -60,8 +58,6 @@ FIND_LIBRARY(SDLMIXER_LIBRARY
PATHS
~/Library/Frameworks
/Library/Frameworks
- /usr/local
- /usr
/sw
/opt/local
/opt/csw
diff --git a/Modules/FindSDL_net.cmake b/Modules/FindSDL_net.cmake
index b5ada54..ca1de79 100644
--- a/Modules/FindSDL_net.cmake
+++ b/Modules/FindSDL_net.cmake
@@ -39,8 +39,6 @@ FIND_PATH(SDLNET_INCLUDE_DIR SDL_net.h
/usr/local/include/SDL11 # FreeBSD ports
/usr/include/SDL12
/usr/include/SDL11
- /usr/local/include
- /usr/include
/sw/include/SDL # Fink
/sw/include
/opt/local/include/SDL # DarwinPorts
@@ -59,8 +57,6 @@ FIND_LIBRARY(SDLNET_LIBRARY
PATHS
~/Library/Frameworks
/Library/Frameworks
- /usr/local
- /usr
/sw
/opt/local
/opt/csw
diff --git a/Modules/FindSDL_sound.cmake b/Modules/FindSDL_sound.cmake
index 8edf6ca..35294a5 100644
--- a/Modules/FindSDL_sound.cmake
+++ b/Modules/FindSDL_sound.cmake
@@ -86,8 +86,6 @@ FIND_PATH(SDL_SOUND_INCLUDE_DIR SDL_sound.h
/usr/local/include/SDL11 # FreeBSD ports
/usr/include/SDL12
/usr/include/SDL11
- /usr/local/include
- /usr/include
/sw/include/SDL # Fink
/sw/include
/opt/local/include/SDL # DarwinPorts
@@ -106,8 +104,6 @@ FIND_LIBRARY(SDL_SOUND_LIBRARY
$ENV{SDLDIR}/lib
$ENV{SDLDIR}
PATHS
- /usr/local/lib
- /usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
@@ -222,8 +218,6 @@ IF(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
$ENV{SDLSOUNDDIR}
$ENV{SDLDIR}/lib
$ENV{SDLDIR}
- /usr/local/lib
- /usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
@@ -245,8 +239,6 @@ IF(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
$ENV{SDLSOUNDDIR}
$ENV{SDLDIR}/lib
$ENV{SDLDIR}
- /usr/local/lib
- /usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
@@ -271,8 +263,6 @@ IF(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
$ENV{SDLSOUNDDIR}
$ENV{SDLDIR}/lib
$ENV{SDLDIR}
- /usr/local/lib
- /usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
@@ -293,8 +283,6 @@ IF(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
$ENV{SDLSOUNDDIR}
$ENV{SDLDIR}/lib
$ENV{SDLDIR}
- /usr/local/lib
- /usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
@@ -317,8 +305,6 @@ IF(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
$ENV{SDLSOUNDDIR}
$ENV{SDLDIR}/lib
$ENV{SDLDIR}
- /usr/local/lib
- /usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
@@ -341,8 +327,6 @@ IF(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
$ENV{SDLSOUNDDIR}
$ENV{SDLDIR}/lib
$ENV{SDLDIR}
- /usr/local/lib
- /usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
@@ -368,8 +352,6 @@ IF(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
$ENV{SDLSOUNDDIR}
$ENV{SDLDIR}/lib
$ENV{SDLDIR}
- /usr/local/lib
- /usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
@@ -395,8 +377,6 @@ IF(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
$ENV{SDLSOUNDDIR}
$ENV{SDLDIR}/lib
$ENV{SDLDIR}
- /usr/local/lib
- /usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
diff --git a/Modules/FindSDL_ttf.cmake b/Modules/FindSDL_ttf.cmake
index 3d07ab7..184b6c3 100644
--- a/Modules/FindSDL_ttf.cmake
+++ b/Modules/FindSDL_ttf.cmake
@@ -39,8 +39,6 @@ FIND_PATH(SDLTTF_INCLUDE_DIR SDL_ttf.h
/usr/local/include/SDL11 # FreeBSD ports
/usr/include/SDL12
/usr/include/SDL11
- /usr/local/include
- /usr/include
/sw/include/SDL # Fink
/sw/include
/opt/local/include/SDL # DarwinPorts
@@ -59,8 +57,6 @@ FIND_LIBRARY(SDLTTF_LIBRARY
PATHS
~/Library/Frameworks
/Library/Frameworks
- /usr/local
- /usr
/sw
/opt/local
/opt/csw
diff --git a/Modules/FindSquish.cmake b/Modules/FindSquish.cmake
index b0b6b2f..48d195a 100644
--- a/Modules/FindSquish.cmake
+++ b/Modules/FindSquish.cmake
@@ -43,18 +43,14 @@ SET(SQUISH_CLIENT_EXECUTABLE_STRING "The squishclient executable program.")
# Search only if the location is not already known.
IF(NOT SQUISH_INSTALL_DIR)
# Get the system search path as a list.
- IF(UNIX)
- STRING(REGEX MATCHALL "[^:]+" SQUISH_INSTALL_DIR_SEARCH1 "$ENV{PATH}")
- ELSE(UNIX)
- STRING(REGEX REPLACE "\\\\" "/" SQUISH_INSTALL_DIR_SEARCH1 "$ENV{PATH}")
- ENDIF(UNIX)
- STRING(REGEX REPLACE "/;" ";" SQUISH_INSTALL_DIR_SEARCH2 ${SQUISH_INSTALL_DIR_SEARCH1})
+ FILE(TO_CMAKE_PATH "$ENV{PATH}" SQUISH_INSTALL_DIR_SEARCH2)
# Construct a set of paths relative to the system search path.
SET(SQUISH_INSTALL_DIR_SEARCH "")
FOREACH(dir ${SQUISH_INSTALL_DIR_SEARCH2})
SET(SQUISH_INSTALL_DIR_SEARCH ${SQUISH_INSTALL_DIR_SEARCH} "${dir}/../lib/fltk")
ENDFOREACH(dir)
+ STRING(REPLACE "//" "/" SQUISH_INSTALL_DIR_SEARCH "${SQUISH_INSTALL_DIR_SEARCH}")
# Look for an installation
FIND_PATH(SQUISH_INSTALL_DIR bin/squishrunner
diff --git a/Modules/FindTCL.cmake b/Modules/FindTCL.cmake
index f2c776f..7f6d3a7 100644
--- a/Modules/FindTCL.cmake
+++ b/Modules/FindTCL.cmake
@@ -82,8 +82,6 @@ SET(TCLTK_POSSIBLE_LIB_PATHS
"${TK_LIBRARY_PATH}"
"${TCL_TCLSH_PATH_PARENT}/lib"
"${TK_WISH_PATH_PARENT}/lib"
- /usr/lib
- /usr/local/lib
)
IF(WIN32)
@@ -162,8 +160,6 @@ SET(TCLTK_POSSIBLE_INCLUDE_PATHS
${TK_FRAMEWORK_INCLUDES}
"${TCL_TCLSH_PATH_PARENT}/include"
"${TK_WISH_PATH_PARENT}/include"
- /usr/include
- /usr/local/include
/usr/include/tcl${TK_LIBRARY_VERSION}
/usr/include/tcl${TCL_LIBRARY_VERSION}
/usr/include/tcl8.6
diff --git a/Modules/FindTclStub.cmake b/Modules/FindTclStub.cmake
index 4db2716..79d14ae 100644
--- a/Modules/FindTclStub.cmake
+++ b/Modules/FindTclStub.cmake
@@ -66,8 +66,6 @@ SET(TCLTK_POSSIBLE_LIB_PATHS
"${TK_LIBRARY_PATH}"
"${TCL_TCLSH_PATH_PARENT}/lib"
"${TK_WISH_PATH_PARENT}/lib"
- /usr/lib
- /usr/local/lib
)
IF(WIN32)
diff --git a/Modules/FindwxWindows.cmake b/Modules/FindwxWindows.cmake
index f55cf00..dfb28ff 100644
--- a/Modules/FindwxWindows.cmake
+++ b/Modules/FindwxWindows.cmake
@@ -139,7 +139,7 @@ IF(WIN32_STYLE_FIND)
## find libs for combination of static/shared with release/debug
## be careful if you add something here,
## avoid mixing of headers and libs of different wx versions,
- ## there may be multiple WX version s installed.
+ ## there may be multiple WX versions installed.
SET (WXWINDOWS_POSSIBLE_LIB_PATHS
"${WXWINDOWS_ROOT_DIR}/lib"
)
diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake
index f867bc5..68f3c80 100644
--- a/Modules/Qt4Macros.cmake
+++ b/Modules/Qt4Macros.cmake
@@ -220,9 +220,9 @@ ENDMACRO (QT4_ADD_RESOURCES)
MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
- SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
- SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
- SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
+ SET(_header "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h")
+ SET(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp")
+ SET(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc")
GET_SOURCE_FILE_PROPERTY(_nonamespace ${_interface} NO_NAMESPACE)
IF(_nonamespace)
@@ -241,16 +241,16 @@ MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
SET(_params ${_params} -i ${_include})
ENDIF(_include)
- ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
+ ADD_CUSTOM_COMMAND(OUTPUT "${_impl}" "${_header}"
COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile}
DEPENDS ${_infile} VERBATIM)
- SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
+ SET_SOURCE_FILES_PROPERTIES("${_impl}" PROPERTIES SKIP_AUTOMOC TRUE)
- QT4_GENERATE_MOC(${_header} ${_moc})
+ QT4_GENERATE_MOC("${_header}" "${_moc}")
- SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
- MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
+ LIST(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}")
+ MACRO_ADD_FILE_DEPENDENCIES("${_impl}" "${_moc}")
ENDMACRO(QT4_ADD_DBUS_INTERFACE)
@@ -258,9 +258,10 @@ ENDMACRO(QT4_ADD_DBUS_INTERFACE)
MACRO(QT4_ADD_DBUS_INTERFACES _sources)
FOREACH (_current_FILE ${ARGN})
GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE)
+ GET_FILENAME_COMPONENT(_basename ${_current_FILE} NAME)
# get the part before the ".xml" suffix
- STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE})
STRING(TOLOWER ${_basename} _basename)
+ STRING(REGEX REPLACE "(.*\\.)?([^\\.]+)\\.xml" "\\2" _basename ${_basename})
QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface)
ENDFOREACH (_current_FILE)
ENDMACRO(QT4_ADD_DBUS_INTERFACES)
@@ -305,27 +306,27 @@ MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optional
ENDIF (_optionalBasename)
SET(_optionalClassName "${ARGV5}")
- SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
- SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
- SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
+ SET(_header "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h")
+ SET(_impl "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp")
+ SET(_moc "${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc")
IF(_optionalClassName)
- ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
+ ADD_CUSTOM_COMMAND(OUTPUT "${_impl}" "${_header}"
COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
DEPENDS ${_infile} VERBATIM
)
ELSE(_optionalClassName)
- ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
+ ADD_CUSTOM_COMMAND(OUTPUT "${_impl}" "${_header}"
COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
DEPENDS ${_infile} VERBATIM
)
ENDIF(_optionalClassName)
- QT4_GENERATE_MOC(${_header} ${_moc})
- SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
- MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
+ QT4_GENERATE_MOC("${_header}" "${_moc}")
+ SET_SOURCE_FILES_PROPERTIES("${_impl}" PROPERTIES SKIP_AUTOMOC TRUE)
+ MACRO_ADD_FILE_DEPENDENCIES("${_impl}" "${_moc}")
- SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
+ LIST(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}")
ENDMACRO(QT4_ADD_DBUS_ADAPTOR)
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 ba80ba9..7feb0d7 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 20120618)
+SET(CMake_VERSION_TWEAK 20120709)
#SET(CMake_VERSION_RC 1)
diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx
index 36302df..381c70c 100644
--- a/Source/CTest/cmCTestBZR.cxx
+++ b/Source/CTest/cmCTestBZR.cxx
@@ -128,13 +128,12 @@ class cmCTestBZR::RevnoParser: public cmCTestVC::LineParser
{
public:
RevnoParser(cmCTestBZR* bzr, const char* prefix, std::string& rev):
- BZR(bzr), Rev(rev)
+ Rev(rev)
{
this->SetLog(&bzr->Log, prefix);
this->RegexRevno.compile("^([0-9]+)$");
}
private:
- cmCTestBZR* BZR;
std::string& Rev;
cmsys::RegularExpression RegexRevno;
virtual bool ProcessLine()
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index dc9eb6a..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;
@@ -1070,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/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 f21cddb..8014c41 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)
@@ -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);
- cmOStringStream 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 << ":";
+
+
+ // 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();
+ 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);
}
@@ -776,7 +833,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;
}
@@ -850,6 +907,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
"Re-running CMake...",
"Rule for re-running cmake.",
/*depfile=*/ "",
+ /*rspfile=*/ "",
/*restat=*/ false,
/*generator=*/ true);
@@ -879,14 +937,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,
@@ -903,10 +973,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/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 5fc5f05..0cfb36b 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)
{
@@ -2858,10 +2865,13 @@ cmLocalGenerator
bool replaceExt = this->NeedBackwardsCompatibility(2, 4);
if(!replaceExt)
{
- std::string repVar = "CMAKE_";
- repVar += source.GetLanguage();
- repVar += "_OUTPUT_EXTENSION_REPLACE";
- replaceExt = this->Makefile->IsOn(repVar.c_str());
+ if(const char* lang = source.GetLanguage())
+ {
+ std::string repVar = "CMAKE_";
+ repVar += lang;
+ repVar += "_OUTPUT_EXTENSION_REPLACE";
+ replaceExt = this->Makefile->IsOn(repVar.c_str());
+ }
}
// Remove the source extension if it is to be replaced.
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 1d8a7d1..39b493f 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -205,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
@@ -236,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. */
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index f6a6bc2..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
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();
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index a60896f..7b6c450 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2203,8 +2203,12 @@ bool cmMakefile::PlatformIs64Bit() const
const char* cmMakefile::GetSONameFlag(const char* language) const
{
- std::string name = "CMAKE_SHARED_LIBRARY_SONAME_";
- name += language;
+ std::string name = "CMAKE_SHARED_LIBRARY_SONAME";
+ if(language)
+ {
+ name += "_";
+ name += language;
+ }
name += "_FLAG";
return GetDefinition(name.c_str());
}
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index df89275..16e3e02 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1416,10 +1416,9 @@ class cmMakefileTargetGeneratorObjectStrings
{
public:
cmMakefileTargetGeneratorObjectStrings(std::vector<std::string>& strings,
- cmMakefile* mf,
cmLocalUnixMakefileGenerator3* lg,
std::string::size_type limit):
- Strings(strings), Makefile(mf), LocalGenerator(lg), LengthLimit(limit)
+ Strings(strings), LocalGenerator(lg), LengthLimit(limit)
{
this->Space = "";
}
@@ -1454,7 +1453,6 @@ public:
}
private:
std::vector<std::string>& Strings;
- cmMakefile* Makefile;
cmLocalUnixMakefileGenerator3* LocalGenerator;
std::string::size_type LengthLimit;
std::string CurrentString;
@@ -1469,7 +1467,7 @@ cmMakefileTargetGenerator
std::string::size_type limit)
{
cmMakefileTargetGeneratorObjectStrings
- helper(objStrings, this->Makefile, this->LocalGenerator, limit);
+ helper(objStrings, this->LocalGenerator, limit);
for(std::vector<std::string>::const_iterator i = this->Objects.begin();
i != this->Objects.end(); ++i)
{
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 1751091..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,7 +215,7 @@ cmNinjaNormalTargetGenerator
std::string linkCmd =
this->GetLocalGenerator()->BuildCommandLine(linkCmds);
- // Write the linker rule.
+ // Write the linker rule with response file if needed.
cmOStringStream comment;
comment << "Rule for linking " << this->TargetLinkLanguage << " "
<< this->GetVisibleTypeName() << ".";
@@ -224,7 +225,9 @@ cmNinjaNormalTargetGenerator
this->GetGlobalGenerator()->AddRule(ruleName,
linkCmd,
description.str(),
- comment.str());
+ comment.str(),
+ /*depfile*/ "",
+ rspfile);
}
if (this->TargetNameOut != this->TargetNameReal) {
@@ -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 e130065..4758989 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -151,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());
}
@@ -298,7 +300,7 @@ std::string cmNinjaTargetGenerator::GetTargetPDB() const
targetFullPathPDB += this->Target->GetPDBName(this->GetConfigName());
}
- return ConvertToNinjaPath(targetFullPathPDB.c_str());
+ return targetFullPathPDB.c_str();
}
@@ -306,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
@@ -327,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();
@@ -349,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);
@@ -361,6 +388,14 @@ 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.
cmOStringStream comment;
comment << "Rule for compiling " << language << " files.";
@@ -481,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"))
{
@@ -575,3 +620,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/cmOrderDirectories.h b/Source/cmOrderDirectories.h
index 775a4eb..96a75de 100644
--- a/Source/cmOrderDirectories.h
+++ b/Source/cmOrderDirectories.h
@@ -48,7 +48,6 @@ private:
std::vector<std::string> OrderedDirectories;
- bool OrderedDirectoriesComputed;
std::vector<cmOrderDirectoriesConstraint*> ConstraintEntries;
std::vector<cmOrderDirectoriesConstraint*> ImplicitDirEntries;
std::vector<std::string> UserDirectories;
diff --git a/Source/cmQtAutomoc.cxx b/Source/cmQtAutomoc.cxx
index 113d678..65ecdf7 100644
--- a/Source/cmQtAutomoc.cxx
+++ b/Source/cmQtAutomoc.cxx
@@ -245,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();
@@ -256,7 +257,7 @@ bool cmQtAutomoc::Run(const char* targetDirectory)
if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5")
{
- this->RunAutomoc();
+ success = this->RunAutomoc();
}
this->WriteOldMocDefinitionsFile(targetDirectory);
@@ -264,7 +265,7 @@ bool cmQtAutomoc::Run(const char* targetDirectory)
delete gg;
gg = NULL;
makefile = NULL;
- return true;
+ return success;
}
@@ -578,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();
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/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/Tests/Assembler/CMakeLists.txt b/Tests/Assembler/CMakeLists.txt
index ad27e57..456e496 100644
--- a/Tests/Assembler/CMakeLists.txt
+++ b/Tests/Assembler/CMakeLists.txt
@@ -23,6 +23,7 @@ endif("${CMAKE_GENERATOR}" MATCHES "Makefile")
if(SRCS)
+ set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS}")
enable_language(ASM OPTIONAL)
else(SRCS)
message(STATUS "No assembler enabled, using C")
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/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx
index 434cbee..dc1ce24 100644
--- a/Tests/CMakeLib/run_compile_commands.cxx
+++ b/Tests/CMakeLib/run_compile_commands.cxx
@@ -63,12 +63,12 @@ private:
void ParseString()
{
- this->String.clear();
+ this->String = "";
if(!Expect('"')) return;
while (!Expect('"'))
{
Expect('\\');
- this->String.push_back(C);
+ this->String.append(1,C);
Next();
}
}
diff --git a/Tests/CTestUpdateGIT.cmake.in b/Tests/CTestUpdateGIT.cmake.in
index 793b987..eb9f987 100644
--- a/Tests/CTestUpdateGIT.cmake.in
+++ b/Tests/CTestUpdateGIT.cmake.in
@@ -91,6 +91,9 @@ run_child(WORKING_DIRECTORY ${TOP}/import
COMMAND ${GIT} add .
)
run_child(WORKING_DIRECTORY ${TOP}/import
+ COMMAND ${GIT} config core.safecrlf false
+ )
+run_child(WORKING_DIRECTORY ${TOP}/import
COMMAND ${GIT} submodule add ${MOD_REPO} module
)
run_child(WORKING_DIRECTORY ${TOP}/import
diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in
index 073d82e..f647901 100644
--- a/Tests/FindPackageModeMakefileTest/Makefile.in
+++ b/Tests/FindPackageModeMakefileTest/Makefile.in
@@ -1,10 +1,29 @@
+CMAKE = "@cmakeExecutable@"
+CMAKE_CURRENT_BINARY_DIR = "@CMAKE_CURRENT_BINARY_DIR@"
+CMAKE_CXX_COMPILER = "@CMAKE_CXX_COMPILER@"
+CMAKE_CXX_COMPILER_ID = "@CMAKE_CXX_COMPILER_ID@"
+
+CMAKE_FOO = $(CMAKE) --find-package -DCMAKE_MODULE_PATH=$(CMAKE_CURRENT_BINARY_DIR) -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=$(CMAKE_CXX_COMPILER_ID)
+
+tmp = tmp.txt
+
all: clean pngtest
main.o: main.cpp
- "@CMAKE_CXX_COMPILER@" $(CXXFLAGS) -c $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE) main.cpp
+ @$(CMAKE_FOO) -DMODE=COMPILE >$(tmp)
+ @foo="`cat $(tmp)`"; \
+ printf '"%s" %s %s -c main.cpp\n' $(CMAKE_CXX_COMPILER) "$(CXXFLAGS)" "$$foo" >$(tmp)
+ @cat $(tmp)
+ @sh $(tmp)
+ @rm -f $(tmp)
pngtest: main.o
- "@CMAKE_CXX_COMPILER@" $(LDFLAGS) -o pngtest main.o $(shell "@cmakeExecutable@" --find-package -DCMAKE_MODULE_PATH="@CMAKE_CURRENT_BINARY_DIR@" -DNAME=Foo -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK)
+ @$(CMAKE_FOO) -DMODE=LINK >$(tmp)
+ @foo="`cat $(tmp)`"; \
+ printf '"%s" %s %s -o pngtest main.o %s\n' $(CMAKE_CXX_COMPILER) "$(CXXFLAGS)" "$(LDFLAGS)" "$$foo" >$(tmp)
+ @cat $(tmp)
+ @sh $(tmp)
+ @rm -f $(tmp)
clean:
- rm -f *.o pngtest
+ rm -f $(tmp) *.o pngtest
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/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 1c6db39..23fc086 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -45,6 +45,7 @@ macro(add_RunCMake_test test)
)
endmacro()
+add_RunCMake_test(Languages)
add_RunCMake_test(ObjectLibrary)
add_RunCMake_test(build_command)
diff --git a/Tests/RunCMake/Languages/CMakeLists.txt b/Tests/RunCMake/Languages/CMakeLists.txt
new file mode 100644
index 0000000..e8db6b0
--- /dev/null
+++ b/Tests/RunCMake/Languages/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/Languages/NoLangSHARED-result.txt b/Tests/RunCMake/Languages/NoLangSHARED-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Languages/NoLangSHARED-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Languages/NoLangSHARED-stderr.txt b/Tests/RunCMake/Languages/NoLangSHARED-stderr.txt
new file mode 100644
index 0000000..3f93cf8
--- /dev/null
+++ b/Tests/RunCMake/Languages/NoLangSHARED-stderr.txt
@@ -0,0 +1 @@
+CMake Error: CMake can not determine linker language for target:NoLang
diff --git a/Tests/RunCMake/Languages/NoLangSHARED.cmake b/Tests/RunCMake/Languages/NoLangSHARED.cmake
new file mode 100644
index 0000000..de6adf7
--- /dev/null
+++ b/Tests/RunCMake/Languages/NoLangSHARED.cmake
@@ -0,0 +1 @@
+add_library(NoLang SHARED foo.nolang)
diff --git a/Tests/RunCMake/Languages/RunCMakeTest.cmake b/Tests/RunCMake/Languages/RunCMakeTest.cmake
new file mode 100644
index 0000000..a99548f
--- /dev/null
+++ b/Tests/RunCMake/Languages/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(NoLangSHARED)
diff --git a/Tests/RunCMake/Languages/foo.nolang b/Tests/RunCMake/Languages/foo.nolang
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/Languages/foo.nolang
diff --git a/Tests/VSGNUFortran/c_code/main.c b/Tests/VSGNUFortran/c_code/main.c
index 391bf26..9157cc5 100644
--- a/Tests/VSGNUFortran/c_code/main.c
+++ b/Tests/VSGNUFortran/c_code/main.c
@@ -1,4 +1,4 @@
-#include <HelloWorldFCMangle.h> // created by FortranCInterface
+#include <HelloWorldFCMangle.h> /* created by FortranCInterface */
extern void FC_hello(void);
int main()
{