Commit Graph

662 Commits

Author SHA1 Message Date
Brad King 4e5cb398ae Merge branch 'master' into vs12-generator
Resolve conflicts in Tests/Preprocess/CMakeLists.txt by keeping
the side from 'master'.
2013-06-28 18:29:54 -04:00
Brad King 77ac9b8b9c VS12: Add Visual Studio 12 generator (#14251)
Copy cmGlobalVisualStudio11Generator to cmGlobalVisualStudio12Generator
and update version numbers accordingly.  Add the VS12 enumeration value.
Add module CMakeVS12FindMake to find MSBuild.  Look for MSBuild in its
now-dedicated Windows Registry entry.  Teach the platform module
Windows-MSVC to set MSVC12 and document the variable.  Teach module
InstallRequiredSystemLibraries to look for the VS 12 runtime libraries.

Teach tests CheckCompilerRelatedVariables, Preprocess, VSExternalInclude,
and RunCMake.GeneratorToolset to treat VS 12 as they do VS 10 and 11.

Inspired-by: Minmin Gong <minmin.gong@gmail.com>
2013-06-28 18:13:14 -04:00
Brad King 0c9cc9a077 Embarcadero: Use response files only for includes, objects, and libs
Leave other flags directly in the Makefile command lines and outside
any special inline response file syntax.  Otherwise Borland does
not support flags with quotes in response files.
2013-06-27 12:57:31 -04:00
Stephen Kelly 2d9ec1dadf Add compiler target compile options.
For clang, this allows passing -target <triple> to the compiler, and
for qcc, -V<arch> using toolchain files containing something like

 set(triple arm-linux-gnueabihf)
 set(CMAKE_C_COMPILER "/usr/bin/clang")
 set(CMAKE_C_COMPILER_TARGET ${triple})
 set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
 set(CMAKE_CXX_COMPILER_TARGET ${triple})

or

 set(arch gcc_ntoarmv7le)
 set(CMAKE_C_COMPILER /opt/qnx650/host/linux/x86/usr/bin/qcc)
 set(CMAKE_C_COMPILER_TARGET ${arch})
 set(CMAKE_CXX_COMPILER /opt/qnx650/host/linux/x86/usr/bin/QCC)
 set(CMAKE_CXX_COMPILER_TARGET ${arch})

Both clang and qcc are inherently cross compiler( driver)s.
2013-06-11 14:41:16 +02:00
Brad King 3caf565d07 Merge topic 'rpath-on-mac'
dc1d025 OS X: Add test for rpaths on Mac.
8576b3f OS X: Add support for @rpath in export files.
00d71bd Xcode: Add rpath support in Xcode generator.
94e7fef OS X: Add RPATH support for Mac.
2013-06-03 09:56:44 -04:00
Brad King d444fea163 Merge topic 'xcode-shlib-versioning'
cbe3f20 Xcode: Add support for shared library versioning
2013-06-03 09:56:37 -04:00
Clinton Stimpson 94e7fef226 OS X: Add RPATH support for Mac.
RPATH support is activated on targets that have the MACOSX_RPATH
property turned on.
For install time, it is also useful to set INSTALL_RPATH to help
find dependent libraries with an @rpath in their install name.

Also adding detection of rpath conflicts when using frameworks.
2013-06-03 09:42:05 -04:00
Clinton Stimpson cbe3f2072b Xcode: Add support for shared library versioning
Add a post-build command to shared library targets to create the
versioning symbolic links.
2013-05-29 09:05:00 -04:00
Brad King f122dd3d47 Merge topic 'vs-configurations'
42bb42d VS: Always initialize CMAKE_CONFIGURATION_TYPES in IDE generators
2013-05-16 14:38:40 -04:00
Brad King 0dc0e7d885 Merge topic 'doc-improvements'
7cc2805 Docs: Clarify wording "flag used" => "flag (to|will) be used"
2378a69 Docs: Clarify that CMAKE_*_(PREFIX|SUFFIX) affect filenames
56ca34d Docs: Update description of CMAKE_(BUILD_TYPE|CONFIGURATION_TYPES)
2bab472 VS10: add detailed comment about MIDL processing
e619111 Explain distribution of Win9x binary on all Windows versions.
5ca4336 FindwxWidgets: add DOC strings with usual style
f57800d Fix spelling and typos (product names)
bf019d7 Fix spelling and typos (non-binary)
ddac8d3 Fix spelling and typos (affecting binary data / module messages)
86832ce Fix spelling and typos (affecting users)
2013-05-16 14:38:07 -04:00
Brad King 823022dd2e Merge topic 'WindowsPaths-MinGW-cross-compile-only'
f9eee7f Windows: Search '/' prefix only when cross compiling (#10994)
2013-05-16 14:37:28 -04:00
Brad King 42bb42d197 VS: Always initialize CMAKE_CONFIGURATION_TYPES in IDE generators
Initialize the CMAKE_CONFIGURATION_TYPES cache entry early during
EnableLanguage like the Xcode generator does.  Avoid depending on
the MSVC compiler information module to do it.  Otherwise code like

  project(MyProj NONE)

sets CMAKE_CONFIGURATION_TYPES late (in GenerateConfigurations), and
to only "Debug" and "Release" instead of the standard set of 4.

Reported-by: Paul Smith <paul@mad-scientist.net>
2013-05-13 11:07:46 -04:00
Andreas Mohr bf019d765d Fix spelling and typos (non-binary) 2013-05-07 08:39:19 -04:00
Brad King f9eee7f183 Windows: Search '/' prefix only when cross compiling (#10994)
Commit dac78148 (...makes the mingw cross compiler work out of the
box..., 2007-08-02) added to CMAKE_SYSTEM_PROGRAM_PATH and
CMAKE_SYSTEM_LIBRARY_PATH paths like "/bin" and "/lib" with no Windows
drive letter so that cross-compiling to Windows from Linux would search
these paths under CMAKE_FIND_ROOT_PATH.  Later commit 2a782880 (...use
CMAKE_SYSTEM_PREFIX_PATH when possible, 2008-01-16) generalized this
approach by instead adding "/" to CMAKE_SYSTEM_PREFIX_PATH.

Both commits assumed that the paths would never match anything on
Windows hosts without a drive letter.  However, Windows evaluates these
paths relative to the current working drive letter so find_* commands
may report paths like "/lib/..." when paths like "c:/lib/..." exist on
what happens to be current drive.  Such drive-less paths are not
reliable when the working drive changes, so we should not use them.

Fix WindowsPaths.cmake to add '/' to CMAKE_SYSTEM_PREFIX_PATH only when
cross-compiling to Windows from a non-Windows host.  This will avoid
searching and finding local paths without a drive letter on Windows.
2013-04-25 09:07:45 -04:00
Brad King fb9f73de64 MSVC: Invoke 'link' directly for executables
Update the CMAKE_<LANG>_LINK_EXECUTABLE rule variable to invoke the
linker directly instead of through the compiler.  We already do this
for DLL linking with CMAKE_<LANG>_CREATE_SHARED_LIBRARY.

This also works around a VS 6 cl bug.  While invoking the link tool
internally it fails to correctly quote flags like /pdb:... with spaces
in the value.
2013-04-08 13:03:56 -04:00
Brad King 42ba1b08f3 VS: Separate compiler and linker PDB files (#11899, #14062)
The MS tools create two types of PDB files as explained here:

 http://msdn.microsoft.com/en-us/library/yd4f8bd1%28v=vs.71%29.aspx
 http://msdn.microsoft.com/en-us/library/yd4f8bd1%28v=vs.80%29.aspx
 http://msdn.microsoft.com/en-us/library/yd4f8bd1%28v=vs.90%29.aspx
 http://msdn.microsoft.com/en-us/library/yd4f8bd1%28v=vs.100%29.aspx

One is created by the compiler (/Fd) and the other by the linker (/pdb).
The two options should not specify the same file.  Split them up.

In the VS IDE generators, simply drop ProgramDataBaseFileName to
take the VS default "/Fd$(IntDir)vc$(PlatformToolsetVersion).pdb".

In the Makefile generators, set "/Fd" on the compile line to be
the directory containing object files (with a trailing slash the
compiler will add the "vc$(PlatformToolsetVersion).pdb" filename
automatically).  Drop the /Fd option from the exe link command
line and add "/pdb" instead (already done for dll linking).
Update these rules for both MSVC and Intel tools.

Drop support for PDB_OUTPUT_DIRECTORY and PDB_NAME in STATIC
libraries because the generated .pdb files are only from /Fd
and not real linker-generated .pdb files.  Update documentation to
clarify that the PDB_* properties are only for linker .pdb files.

This regresses the PDBDirectoryAndName test for STATIC libraries.
Since it is not clear at this time what should be done for STATIC
library .pdb files, comment out the relevant portion of the test
and leave a TODO comment.
2013-04-05 11:25:09 -04:00
Brad King 28490ecccb Merge topic 'aix-shared-flags'
bce7a2a AIX: Do not use -brtl to create shared libraries (#13997)
2013-03-12 13:47:04 -04:00
Brad King bce7a2a3a5 AIX: Do not use -brtl to create shared libraries (#13997)
The flag was added incorrectly by commit 9c3a6eb4 (Need -brtl when creating
shared libraries, 2003-05-16).  According to "man ld" the -G option implies
"-brtl -bnortllib ...", -brtl implies "-brtllib", and -brtllib should only be
used for executables, not shared libraries.  Therefore it is incorrect and
unnecessary to specify -brtl explicitly after -G.

Reported-by: Kevin Burge <kcburge@gmail.com>
2013-03-11 09:01:27 -04:00
Brad King e85f1c28d4 Merge topic 'rpath-use-implicit-link-dirs'
95a9c80 Merge topic 'LINK_LIBRARIES-property' into rpath-use-implicit-link-dirs
baa33ac AIX-GNU: Put implicit link directories in runtime libpath (#13909)
171b099 Avoid duplicate RPATH entries
2013-02-15 13:12:31 -05:00
Brad King 95a9c80cac Merge topic 'LINK_LIBRARIES-property' into rpath-use-implicit-link-dirs
Resolve a logical conflict in the signature of cmTarget::GetLinkClosure.
2013-02-14 10:18:31 -05:00
Brad King baa33acbda AIX-GNU: Put implicit link directories in runtime libpath (#13909)
The GNU compiler front-ends on AIX invoke the linker with flags of the
form "-L/path/to/gnu/runtime/lib" to tell ld where to find the language
runtime libraries.  They depend on the default libpath behavior
documented in "man ld" to add the -L paths also to the runtime libpath
so the dynamic loader can find the language runtime libraries.  This
differs from platforms whose linkers have distinct -rpath flags that
non-system compilers can use to tell the dynamic loader where to find
their language runtime libraries.

Since commit 96fd5909 (Implement linking with paths to library files,
2008-01-22) CMake always passes "-Wl,-blibpath:" followed by any
project-defined RPATH plus "/usr/lib:/lib" in order to explicitly set
the runtime libpath and avoid getting all the project -L paths in the
runtime libpath.  The explicit libpath prevents the GNU compiler runtime
library -L paths from being placed in the libpath and then the dynamic
loader fails to find the language runtime libraries.

CMake already detects the implicit link directories for each language
since commit 07ea19ad (Implicit link info for C, CXX, and Fortran,
2009-07-23).  Add the implicit link directories to the explicit runtime
libpath for GNU compilers on AIX to fix this use case.
2013-02-14 10:16:36 -05:00
Brad King 188b0e9e37 Embarcadero: Fix default link stack/heap flags (#13912)
Since commit c70beb4b (change the default borland stack size, 2003-05-05),
commit 1b572eb9 (remove -H flags, 2003-05-08), and commit 2d411398 (Stack size
in generated programs should be 10 meg, 2003-06-12) CMake adds link flags to
select a 10MB stack.  At the time this was for consistency with our behavior on
MS, but that was recently removed by commit 51af1da3 (Remove "/STACK:10000000"
from default linker flags, 2012-11-23).

Change our Embarcadero link flags to select the default stack and heap settings
according to the compiler documentation.  This is more reliable than leaving
the flags out completely as it has been reported that the linker does not
always use its documented defaults.

Suggested-by: Mathäus Mendel <contato@mathausmendel.com>
2013-02-13 13:35:25 -05:00
Brad King fe664b5d1d MSVC: Fix CMAKE_CL_64 in CXX-only projects (#13896)
When CXX is enabled without C then MSVC_CXX_ARCHITECTURE_ID is set
instead but not MSVC_C_ARCHITECTURE_ID.  Test both.
2013-02-07 15:04:06 -05:00
Patrick Gansterer fd2a0d58c5 Set WINCE to 1 when building for WindowsCE
Introduce a new variable WINCE to make the WindowsCE
system more easy to use in if statements.
2013-02-01 23:26:03 +01:00
Brad King cc676c3a08 OS X: Detect implicit linker framework search paths
Previously we hard-coded a list of implicit framework directories but
did not account for CMAKE_OSX_SYSROOT or for changes to the list across
OS X versions.  Instead we should automatically detect the framework
directories for the active toolchain.

The parent commit added the "-Wl,-v" option to ask "ld" to print its
implicit directories.  It displays a block such as:

 Framework search paths:
	/...

Parse this block to extract the list of framework directories.

Detection may fail on toolchains that do not list their framework
directories, such as older OS X linkers.  Always treat the paths

 <sdk>/Library/Frameworks
 <sdk>/System/Library/Frameworks
 <sdk>/Network/Library/Frameworks # Older OS X only
 /System/Library/Frameworks

as implicit.  Note that /System/Library/Frameworks should always be
considered implicit so that frameworks CMake finds there will not
override the SDK copies.
2012-12-11 15:15:52 -05:00
Brad King 2dd67c7ea0 OS X: Detect implicit link directories on modern toolchains
We detect the implicit link directories for the toolchain by adding a
flag to get verbose output from the compiler front-end while linking the
ABI detection binary.  Newer OS X toolchains based on Clang do not add
the implicit link directories with -L options to their internal
invocation of "ld".  Instead they use a linker that comes with the
toolchain and is already configured with the proper directories.

Add the "-Wl,-v" option to ask "ld" to print its implicit directories.
It displays them in a block such as:

 Library search paths:
	/...

Parse this block to extract the implicit link directories.

While at it, remove the checks introduced by commit efaf335b (Skip
implicit link information on Xcode, 2009-07-23) and commit 5195a664
(Skip implicit link info for multiple OS X archs, 2009-09-22).  Discard
the non-system link directories added by Xcode.  Discard all detected
implicit libraries in the multi-architecture case but keep the
directories.  The directories are still useful without the libraries
just to suppress addition of explicit -L options for them.
2012-12-11 15:15:51 -05:00
Amit Kulkarni 288f75edee OpenBSD: Install shared libraries without executable permission 2012-12-04 08:25:33 -05:00
David Cole 51af1da3d2 CMake: Remove "/STACK:10000000" from default linker flags (#12437)
Modern apps that use multiple threads do NOT want 10 Megabytes of RAM
per thread being used for each thread's stack... Just leave off the
/STACK: argument, and let the compiler use a reasonable default value
for the stack size.

If existing single-threaded apps require the /STACK: argument because
they do need a very large stack size, they can add the flag in their
own CMakeLists files.
2012-11-23 11:41:58 -05:00
Brad King cd739794d6 MSVC: Drop default use of /Zm1000 for VS >= 7.1
From the option documentation of VS >= 7.1:

 "In earlier versions of Visual C++, the compiler used several discrete
  heaps, and each had a finite limit. Currently, the compiler dynamically
  grows the heaps as necessary up to a total heap size limit, and requires
  a fixed-size buffer only to construct precompiled headers. Consequently,
  the /Zm compiler option is rarely necessary."
 http://msdn.microsoft.com/en-us/library/bdscwf1c.aspx

Suggested-by: Adam Moss <adam@broadcom.com>
2012-11-16 12:52:59 -05:00
Brad King b35ba02d52 Merge topic 'osx-bad-sdk-xcode-3.2.6'
720d790 OS X: Warn about known SDK breakage by Xcode 3.2.6
2012-11-13 14:31:37 -05:00
Brad King 720d790f16 OS X: Warn about known SDK breakage by Xcode 3.2.6
Xcode 3.2.6 is known to break the SDK Library/Frameworks layout.
Detect and warn about this case to tell users to fix their system.

Reported-by: Matthew Brett <matthew.brett@gmail.com>
2012-11-08 09:18:59 -05:00
Brad King a574752f84 Merge topic 'osx-sysroot-cleanup'
15f5764 OS X: Fix default CMAKE_OSX_SYSROOT with deployment target
2012-11-06 14:13:22 -05:00
Brad King f058b27547 Merge branch 'osx-sysroot-cleanup' into release 2012-11-06 11:21:55 -05:00
Brad King 15f5764e2c OS X: Fix default CMAKE_OSX_SYSROOT with deployment target
Since commit 43b74793 (OS X: Further improve default CMAKE_OSX_SYSROOT
selection, 2012-09-21) we choose a default CMAKE_OSX_SYSROOT only when
one is needed.  However, the change forgot that we require a sysroot
when a deployment target is requested.  Teach Darwin.cmake to choose a
default CMAKE_OSX_SYSROOT when CMAKE_OSX_DEPLOYMENT_TARGET is set.

Reported-by: Matthew Brett <matthew.brett@gmail.com>
Reported-by: Bradley Giesbrecht <pixilla@macports.org>
2012-11-05 10:47:33 -05:00
Brad King 6f68ef426e BSD: Do not require dlfcn.h to build shared libs (#13573)
Remove ancient checks left from commit f5d95fb0 (Complete rework of
makefile generators expect trouble, 2002-11-08).  Modern FreeBSD and
NetBSD platforms support shared libraries.  When cross-compiling the
/usr/include/dlfcn.h may not exist on the host but the toolchain still
supports shared libraries.
2012-10-05 10:08:28 -04:00
Peter Kümmel e31df03939 Ninja: move <OBJECTS> in front of the first linker option
In the response file also linker options could be passed,
and because <OBJECTS> is replaced by a response file, it
is necessary that no compiler option follows <OBJECTS>.
2012-10-01 17:06:38 -04:00
Bill Hoffman dbd99d6fbb Revert "Ninja: don't expand any rsp files"
This reverts commit 5598d9b2a0.

Since commit f1670ab1 (Ninja: don't confuse ninja's rsp files with
nmake's, 2012-09-26) Ninja generator response files are placed in
CMakeFiles/ so the previously existing check already avoids expanding
them.
2012-10-01 17:06:37 -04:00
Brad King e7e613efbf OS X: Teach deployment target sanity check about SDK names
Since commit 1786b121 (OS X: Allow CMAKE_OSX_SYSROOT to be a logical SDK
name, 2012-09-21) we support names like "macosx" or "macosx10.7" as the
specified value of CMAKE_OSX_SYSROOT.  Extend the SDK name->path
conversion to save the original value and also convert into a temporary
variable for the Xcode generator.  Re-implement the deployment target
sanity check to detect the version from the transformed path.
2012-09-22 07:43:43 -04:00
Brad King 43b74793de OS X: Further improve default CMAKE_OSX_SYSROOT selection
Since commit 230ea218 (OS X: Improve default CMAKE_OSX_SYSROOT
selection, 2012-09-21) we always set CMAKE_OSX_SYSROOT if any SDK is
found in order to support Makefile generator builds with Xcode >= 4.3
without the command-line tools installed.  However, in the basic
POSIX-only case of the Makefile generator with command-line tools and no
CMAKE_OSX_ARCHITECTURES we should not select any SDK by default.
2012-09-21 14:45:54 -04:00
Brad King 2690738458 OS X: If CMAKE_OSX_SYSROOT is already set do not compute default
The default computation logic is non-trivial.  Do not bother with it if
the value is already known.
2012-09-21 14:45:54 -04:00
Brad King 7995722e91 OS X: Simplify selection of CMAKE_OSX_ARCHITECTURES
Incremental changes to the logic over time have led to simply
initializing the cache entry with the environment value.
2012-09-21 14:45:53 -04:00
Brad King 1786b121b4 OS X: Allow CMAKE_OSX_SYSROOT to be a logical SDK name
Xcode supports SDKROOT values that just name an SDK rather than
specifying the full path to it.  Recognize these values and handle them.
For Xcode we just put the value directly in the generated project file.
For Makefile generators we ask xcodebuild to provide the full path to
the named SDK.

Suggested-by: Jason DiCioccio <jd@ods.org>
2012-09-21 13:31:46 -04:00
Brad King 230ea218a7 OS X: Improve default CMAKE_OSX_SYSROOT selection
Simplify the search for OSX_DEVELOPER_ROOT and allow it to fail if no
"/Developer" exists.  When it does exist, always find a MacOSX SDK
inside it to use as the default CMAKE_OSX_SYSROOT.  Otherwise set
CMAKE_OSX_SYSROOT to empty.
2012-09-21 08:59:01 -04:00
Brad King a0a0877a1e OS X: Always generate -isysroot if any SDK is in use
Drop the last use of CMAKE_OSX_SYSROOT_DEFAULT.  Replace internal
platform variable CMAKE_${lang}_HAS_ISYSROOT with a more general
CMAKE_${lang}_SYSROOT_FLAG variable.  If the -isysroot flag exists and
CMAKE_OSX_SYSROOT points to an SDK (not "/") then always add it to
compiler command lines.  This is already done in the Xcode IDE.
2012-09-21 08:53:42 -04:00
Brad King 8fc88b7eb0 Merge topic 'vs-link-rsp'
5598d9b Ninja: don't expand any rsp files
2012-09-19 13:58:12 -04:00
Peter Kuemmel 5598d9b2a0 Ninja: don't expand any rsp files 2012-09-19 11:40:47 -04:00
Brad King 011d5a4b47 OS X: Add platform-specific Clang compiler info files (#13536)
Clang has the same interface as GNU except that we do not need to test
for the deployment target and sysroot flags.  Simply set variables

 CMAKE_${lang}_HAS_ISYSROOT
 CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG

to true because every version of Clang available on OS X supports these
flags.
2012-09-17 15:36:41 -04:00
Patrick Gansterer 28d744c9ea Add WindowsCE platform information files
This enables CMake to create Makefiles targeting Windows CE devices.
CMake needs to be run within a cross compile command prompt and requires
a toolchain file which sets CMAKE_SYSTEM_NAME to "WindowsCE" and
optionally CMAKE_SYSTEM_VERSION.
2012-09-05 07:38:45 -04:00
Brad King 25b0d94678 Merge topic 'msvc-compiler-info'
16fa7b7 VS: Fix MSVC_IDE definition recently broken by refactoring
2012-08-31 07:24:53 -04:00
Brad King 16fa7b7395 VS: Fix MSVC_IDE definition recently broken by refactoring
In commit 485a940e (VS: Simplify MSVC version reporting, 2012-08-23) we
accidentally flipped the 0/1 values of MSVC_IDE.  Flip them back and
teach the CheckCompilerRelatedVariables test to check the variable.
2012-08-30 16:18:05 -04:00
Brad King 98a6565b60 Merge topic 'mingw-unix-generator'
be9afbf Find mingw's windres also when Unix Makefiles are used
2012-08-30 11:54:32 -04:00
Brad King 32b7c72623 Merge branch 'cmake-platform-info-version' into msvc-compiler-info
Conflicts:
	Modules/CMakeTestCCompiler.cmake
	Modules/CMakeTestCXXCompiler.cmake
	Modules/Platform/Windows-cl.cmake
2012-08-30 09:45:17 -04:00
Brad King f3ddfef137 Modernize MSVC compiler information files
Remove the old-style "Windows-cl.cmake" and its helper "cl.cmake".  Load
the information through new-style "Platform/Windows-MSVC-<lang>.cmake"
files.  Factor information common to C and CXX into a helper file
"Platform/Windows-MSVC.cmake" loaded from the per-language files.
2012-08-30 09:42:49 -04:00
Brad King 485a940e4c VS: Simplify MSVC version reporting
Teach Windows-cl.cmake to use CMAKE_(C|CXX)_COMPILER_VERSION to set the
"MSVC##" and MSVC_VERSION variables.  It no longer needs the IDE generator
to dictate the version or to detect the version by running the
command-line tool for NMake and Ninja generators.  Drop configuration of
CMakeCPlatform.cmake and CMakeCXXPlatform.cmake from Windows-cl.cmake.in
because all the results it saved are now cheap to compute every time.
2012-08-30 09:42:40 -04:00
Peter Kümmel be9afbf453 Find mingw's windres also when Unix Makefiles are used 2012-08-27 16:54:21 +02:00
Brad King 7195aca54f Make platform information files specific to the CMake version
At the top of a build tree we configure inside the CMakeFiles directory
files such as "CMakeSystem.cmake" and "CMake<lang>Compiler.cmake" to
save information detected about the system and compilers in use.  The
method of detection and the exact results store varies across CMake
versions as things improve.  This leads to problems when loading files
configured by a different version of CMake.  Previously we ignored such
existing files only if the major.minor part of the CMake version
component changed, and depended on the CMakeCache.txt to tell us the
last version of CMake that wrote the files.  This led to problems if the
user deletes the CMakeCache.txt or we add required information to the
files in a patch-level release of CMake (still a "feature point" release
by modern CMake versioning convention).

Ensure that we always have version-consistent platform information files
by storing them in a subdirectory named with the CMake version.  Every
version of CMake will do its own system and compiler identification
checks even when a build tree has already been configured by another
version of CMake.  Stored results will not clobber those from other
versions of CMake which may be run again on the same tree in the future.
Loaded results will match what the system and language modules expect.

Rename the undocumented variable CMAKE_PLATFORM_ROOT_BIN to
CMAKE_PLATFORM_INFO_DIR to clarify its purpose.  The new variable points
at the version-specific directory while the old variable did not.
2012-08-24 10:52:23 -04:00
Brad King 32db033b27 VS: Remove support for "free" version 2003 tools
Several more recent Visual Studio Express editions are now available and
they support debug builds.  Simplify our VS platform files by removing
support for these old tools.  If anyone still uses them we can restore
support with a more modern way to test for them.
2012-08-23 10:51:27 -04:00
Kitware Robot 9db3116226 Remove CMake-language block-end command arguments
Ancient versions of CMake required else(), endif(), and similar block
termination commands to have arguments matching the command starting the
block.  This is no longer the preferred style.

Run the following shell code:

for c in else endif endforeach endfunction endmacro endwhile; do
    echo 's/\b'"$c"'\(\s*\)(.\+)/'"$c"'\1()/'
done >convert.sed &&
git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' |
egrep -z -v '^(Utilities/cm|Source/kwsys/)' |
egrep -z -v 'Tests/CMakeTests/While-Endwhile-' |
xargs -0 sed -i -f convert.sed &&
rm convert.sed
2012-08-13 14:19:16 -04:00
Kitware Robot 77543bde41 Convert CMake-language commands to lower case
Ancient CMake versions required upper-case commands.  Later command
names became case-insensitive.  Now the preferred style is lower-case.

Run the following shell code:

cmake --help-command-list |
grep -v "cmake version" |
while read c; do
    echo 's/\b'"$(echo $c | tr '[:lower:]' '[:upper:]')"'\(\s*\)(/'"$c"'\1(/g'
done >convert.sed &&
git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' |
egrep -z -v '^(Utilities/cm|Source/kwsys/)' |
xargs -0 sed -i -f convert.sed &&
rm convert.sed
2012-08-13 14:19:16 -04:00
Kitware Robot 7bbaa4283d Remove trailing whitespace from most CMake and C/C++ code
Our Git commit hooks disallow modification or addition of lines with
trailing whitespace.  Wipe out all remnants of trailing whitespace
everywhere except third-party code.

Run the following shell code:

git ls-files -z -- \
 bootstrap doxygen.config '*.readme' \
 '*.c' '*.cmake' '*.cpp' '*.cxx' \
 '*.el' '*.f' '*.f90' '*.h' '*.in' '*.in.l' '*.java' \
 '*.mm' '*.pike' '*.py' '*.txt' '*.vim' |
egrep -z -v '^(Utilities/cm|Source/(kwsys|CursesDialog/form)/)' |
egrep -z -v '^(Modules/CPack\..*\.in)' |
xargs -0 sed -i 's/ \+$//'
2012-08-13 14:18:39 -04:00
Brad King be9db98946 Merge topic 'watcom-compiler-version'
af42ae4 Watcom: Simplify compiler version detection (#11866)
2012-08-13 14:18:28 -04:00
Brad King af42ae4f81 Watcom: Simplify compiler version detection (#11866)
Since commit c198730b (Detect Watcom compiler version with its id,
2011-12-07) the CMAKE_(C|CXX)_COMPILER_VERSION variables are set for the
Watcom compiler.  Use these in Windows-wcl386.cmake to set the old
WATCOM1* version variables.  This avoids using the old EXECUTE_PROCESS
command which failed due to extra quotes anyway.
2012-08-13 08:19:23 -04:00
Brad King 7e58e5bb68 Prefer generic system compilers by default for C, C++, and Fortran
Teach CMake to prefer the system default compiler automatically when no
compiler is specified.  By default use "cc" for C, "CC" for C++, and
"f95" for Fortran.  Load a new Platform/<os>-<lang>.cmake module to
allow each platform to specify for each language its system compiler
name(s) and/or exclude certain names.

Create Platform/(CYGWIN|Darwin|Linux|Windows)-CXX.cmake modules to
specify "c++" as the system C++ compiler name for these platforms.  On
systems that use case-insensitive filesystems exclude C++ compiler names
that are distinguished from C compiler names only by case.

This will change the default compiler selection for existing build
scripts that do not specify a compiler when run on machines with
separate system and GNU compilers both installed in the PATH.  We do not
make this change in default behavior lightly.  However:

(1) If a given build really needs specific compilers one should specify
    them explicitly e.g. by setting CC, CXX, and FC in the environment.

(2) The motivating case is to prefer the system Clang on newer OS X
    systems over the older GNU compilers typically also installed.  On
    such systems the names "cc" and "c++" link to Clang.  This is the
    first platform known to CMake on which "c++" is not a GNU compiler.
    The old behavior selected "gcc" for C and "c++" C++ and therefore
    chooses GNU for C and Clang for C++ by default.  The new behavior
    selects GNU or Clang consistently for both languages on older or
    newer OS X systems, respectively.

(3) Other than the motivating OS X case the conditions under which the
    behavior changes do not tend to exist in default OS installations.
    They typically occur only on non-GNU systems with manually-installed
    GNU compilers.

(4) The consequences of the new behavior are not dire.  At worst the
    project fails to compile with the system compiler when it previously
    worked with the non-system GNU compiler.  Such failure is easy to
    work around (see #1).

In short this change creates a more sensible default behavior everywhere
and fixes poor default behavior on a widely-used platform at the cost of
a modest change in behavior in less-common conditions.
2012-08-02 13:26:01 -04:00
David Cole 58f5e77d6a Merge topic 'ninja-rspfile-link-libraries'
4bb94c9 Ninja: sysconf() is declared in unistd.h
bb36759 Ninja: enable response file support on Mac (length 262144)
3a2c8e8 Ninja: disable work around when linking with mingw
3856e66 Ninja: error on missing rspfile_content
8c1e35c Ninja: remove some unused default arguments
7f647cf Ninja: also write link libraries to rsp file
2012-07-12 16:00:42 -04:00
David Cole b1f6e688eb Merge topic 'aix-gnu-asm'
7755283 Add ASM platform information for GNU compiler on AIX (#13390)
2012-07-12 16:00:31 -04:00
Peter Kümmel 3a2c8e8e66 Ninja: disable work around when linking with mingw
The work around is only needed by older GCCs (only testet 4.4/4.7)
Ninja is very new so chances are high that there is also a new mingw.

Use slashes in link rsp file, because ar.exe can't handle \.
2012-07-11 08:55:00 +02:00
Brad King 7755283e89 Add ASM platform information for GNU compiler on AIX (#13390)
Among other flags this sets RPATH flags correctly so that CMake knows
how to treat CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH for the ASM language.
This is the GNU compiler equivalent to commit a0bab7ae (Add ASM platform
information for XL compiler on AIX, 2011-03-02), made for XL.
2012-07-10 15:18:55 -04:00
Brad King 767a7ad9da AIX-GNU: Link shared libs with -brtl,-bnoipath (#13352)
We already use these flags with the XL toolchain.  Use them for GNU too.
2012-07-09 17:18:41 -04:00
David Cole c95d1baa19 Merge topic 'position-independent-targets'
bd34963 Refactor generation of shared library flags
55d7aa4 Add platform variable for flags specific to shared libraries
31d7a0f Add platform variables for position independent code flags
2012-06-12 16:01:04 -04:00
Stephen Kelly 55d7aa4c44 Add platform variable for flags specific to shared libraries
Store in CMAKE_${lang}_COMPILE_OPTIONS_DLL flags from
CMAKE_SHARED_LIBRARY_${lang}_FLAGS that are truly exclusive to shared
libraries.
2012-06-12 15:38:48 -04:00
Stephen Kelly 31d7a0f2e3 Add platform variables for position independent code flags
Store in new platform variables

  CMAKE_${lang}_COMPILE_OPTIONS_PIC
  CMAKE_${lang}_COMPILE_OPTIONS_PIE

flags for position independent code generation.

In almost all cases, this means duplication of the
CMAKE_SHARED_LIBRARY_${lang}_FLAGS for the _PIC case and using the
assumed pie equivalent for the _PIE case.  Note that the GNU compiler
has supported -fPIE since 3.4 and that there is no -fPIC on GNU for
Windows or Cygwin.

There is a possibility that the _PIE variables are not correct.
However, as there is no backwards compatibility to be concerned about
(as the POSITION_INDEPENDENT_CODE property is not used anywhere yet),
the current state suffices.
2012-06-12 15:37:53 -04:00
Charlie Sharpsteen 8b2fb3310b Mac: Add guards to CMAKE_FIND_FRAMEWORK and CMAKE_FIND_APPBUNDLE defaults
The default for `CMAKE_FIND_FRAMEWORK`, defined in `Darwin.cmake` and
`Darwin-icc.cmake`, is now guarded so that it will not override command line
arguments passed by users.

Similarly for `CMAKE_FIND_APPBUNDLE`
2012-05-31 08:10:17 -04:00
David Cole 8df7aa54f0 Merge topic 'module-no-soname'
fdb3f87 Test NO_SONAME property (#13155)
e1409ac Support building shared libraries or modules without soname (#13155)
2012-05-01 14:09:59 -04:00
Modestas Vainius e1409ac59b Support building shared libraries or modules without soname (#13155)
Add a boolean target property NO_SONAME which may be used to disable
soname for the specified shared library or module even if the platform
supports it.  This property should be useful for private shared
libraries or various plugins which live in private directories and have
not been designed to be found or loaded globally.

Replace references to <CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG> and
hard-coded -install_name flags with a conditional <SONAME_FLAG> which is
expanded to the value of the CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG
definition as long as soname supports is enabled for the target in
question.  Keep expanding CMAKE_SHARED_LIBRARY_SONAME_${LANG}_FLAG in
rules in case third party projects still use it.  Such projects would
not yet use NO_SONAME so the adjacent <TARGET_SONAME> will always be
expanded.  Make <TARGET_INSTALLNAME_DIR> NO_SONAME aware as well.  Since
-install_name is soname on OS X, this should not be a problem if this
variable is expanded only if soname is enabled.

The Ninja generator performs rule variable substitution only once
globally per rule to put its own placeholders.  Final substitution is
performed by ninja at build time.  Therefore we cannot conditionally
replace the soname placeholders on a per-target basis.  Rather than
omitting $SONAME from rules.ninja, simply do not write its contents for
targets which have NO_SONAME.  Since 3 variables are affected by
NO_SONAME ($SONAME, $SONAME_FLAG, $INSTALLNAME_DIR), set them only if
soname is enabled.
2012-04-30 11:50:27 -04:00
Brad King dd08062ac2 Intel: On Windows use /RTC1 instead of deprecated /GZ (#13174) 2012-04-30 08:29:47 -04:00
Brad King 4f80896e6c Intel: On Windows use /EHsc instead of deprecated /GX (#13163)
Use of the deprecated option with Intel 2011 produces

 icl: command line remark #10010: option '/GX' is deprecated and will
 be removed in a future release. See '/help deprecated'

so use its replacement option which has been supported for several
older versions anyway.
2012-04-24 09:00:37 -04:00
David Cole 6190415436 OS X: Mark find_program results as advanced
Avoid cluttering the gui with variables nearly nobody needs
to see.
2012-04-06 11:15:39 -04:00
David Cole d9edf46760 OS X: Use correct extra path when searching for applicaton bundles (#13066)
The parent commit added a search path relative to OSX_DEVELOPER_ROOT.
But with Xcode 4.3 the nested Applications folder is in a different
relative location compared to that root. This commit makes the intent
of the previous commit work with older and newer Xcode directory layouts.

Furthermore, it only adds paths that exist to the search path.
2012-04-06 11:14:37 -04:00
Kashif Rasul 98b9a7f6ff OS X: Use OSX_DEVELOPER_ROOT for app search path (#13066)
Since commit 4693cf84 (Xcode: Detect new default locations of Xcode 4.3
bits and pieces) Darwin.cmake detects the developer application
directory instead of hard-coding /Developer.  Replace the hard-coded
path in CMAKE_SYSTEM_APPBUNDLE_PATH using the computed result.
2012-03-26 09:28:56 -04:00
Alex Neundorf 1ab4b3e123 guard eCos.cmake against multiple inclusion (#12987)
Alex
2012-03-20 22:13:47 +01:00
Brad King bfc8d137c5 Merge topic 'fix-12621-xcode43'
0f4dfa6 CPack: Use real path to PackageMaker to find its version file (#12621)
4693cf8 Xcode: Detect new default locations of Xcode 4.3 bits and pieces (#12621)
2012-03-19 14:41:43 -04:00
Brad King 572994bd9f Merge topic 'ninja-generator'
8485208 Ninja: shell escape $(CMAKE_SOURCE_DIR) and $(CMAKE_BINARY_DIR)
df84767 Ninja: add support for OBJECT_OUTPUTS, fix PrecompiledHeader test case
48eb7fc Ninja: Avoid using 'this' in member initializers
bba37dd Ninja: Fix for PDB files with spaces in the path.
ac800f4 Ninja: Constify use of cmCustomCommand
9a0d5a8 Ninja: add /DEF: flag to linker call
d40eebd Ninja: Add a cache option CMAKE_ENABLE_NINJA to enable the ninja generator.
8c63433 Ninja: Add friend struct so it can access the private ConvertToNinjaPath.
dbe3dce Ninja: add .def file support
f1bb08f Ninja: ensure the output dir exists at compile time
7a6b5f4 Ninja: Remove an unnecessary variable
80ff210 Ninja: Use cmSystemTools::ExpandListArgument to split compile/link commands
d2731a3 Ninja: Add a missed license header
eabc9b0 Ninja: CMake: Adapt Ninja generator for per-target include dirs
bada88e Merge branch 'target-include-directories' into ninja-generator
54bd175 Ninja: windows msvc: create for each target a .pdb file
...
2012-03-19 09:29:06 -04:00
David Cole 4693cf8492 Xcode: Detect new default locations of Xcode 4.3 bits and pieces (#12621)
Xcode 4.3 installs into "/Applications" by default, from the Mac App Store.

Also, the paths to the available SDKs changed: they are now within the
Xcode.app bundle.

PackageMaker is installed as a separate program, and may be installed
anywhere. It is not installed with Xcode 4.3 by default anymore.
Download the "Auxiliary Tools for Xcode" to get PackageMaker.
Put PackageMaker inside the Xcode.app bundle, in its nested Applications
folder, or put it alongside Xcode in "/Applications" and CMake will find
it.

Update references to "find" paths: add new possible locations for finding
Xcode.app and PackageMaker.app. Prefer the most recent version's locations
first, but keep the old locations as fallback search paths, too.

Thanks to all the contributors who provided and tested out various patches
for fixing this issue. Especially, but by no means limited to:
Francisco Requena Espí, Jamie Kirkpatrick and drfrogsplat.
2012-03-08 22:43:19 -05:00
Brad King bdbbf763d6 Recognize Embarcadero compiler (#12604)
The Borland compiler was re-branded as CodeGear during 2007-2009 and
since 2009 is the Embarcadero compiler.  They offer predefined macros:

  http://docwiki.embarcadero.com/RADStudio/en/Predefined_Macros

and distinguish themselves by __CODEGEARC__ and __CODEGEARC_VERSION__.

Version 6.30 (C++Builder XE) changed the meaning of some flags:

  http://docwiki.embarcadero.com/RADStudio/en/C%2B%2B_Compiler_Option_Changes_for_XE

Teach Embarcadero compiler information files to generate build rules
with flags matching the compiler version.  Leave the flags unchanged
for old Borland versions.  Always set the BORLAND toolchain indicator
for compatibility with existing projects that test it.  Also set the
EMBARCADERO indicator for newer toolchains.
2012-02-20 10:09:44 -05:00
Peter Kuemmel f999a59afe Ninja: don't define MSVC_IDE when using the ninja generator
Thanks to Oscar Fuentes
2012-02-18 11:24:41 +01:00
Brad King 3f78ced7c2 Rename Modules/Platform/Windows-{Borland => Embarcadero}.cmake
The Borland compiler is now the Embarcadero compiler.  Rename the shared
platform information file to reflect this.  This does not change the
interface, as old versions are still "Borland", but will allow new
versions released by Embarcadero to be supported cleanly.
2012-02-17 17:04:19 -05:00
Brad King 35a5838779 Intel: Fix Windows per-config Fortran flags (#12642)
Fix typo introduced in commit 66a08c10 (more uniform approach to enable
language, 2004-08-26).  The optimization option should be /O2 for
Release configurations and /O1 for MinSizeRel.

Suggested-by: He Yuqi <yuqi.he@gmail.com>
2012-01-02 13:56:33 -05:00
David Cole f7be6d616f Merge topic 'GNU-to-MS'
c213eb9 Windows-GNU: Remove extra quotes in GNUtoMS rule variable
2011-12-16 10:15:44 -05:00
David Cole 65db5b4a99 Merge topic 'osx-dependent-libraries'
5d99343 Do not link private dependent shared libraries on OS X > 10.4
2011-12-16 10:15:07 -05:00
Brad King 5d9934312d Do not link private dependent shared libraries on OS X > 10.4
The default OS X 10.4 linker incorrectly searches for dependencies of
linked shared libraries only under the -isysroot location.  It fails to
find dependencies of linked shared libraries in cases such as the
ExportImport test.  It produces errors like:

 /usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: warning can't open dynamic library:
 libtestLib3Imp.dylib
 referenced from: /.../ExportImport/Root/lib/libtestLib3lib.1.2.dylib
 (checking for undefined symbols may be affected) (No such file or directory, errno = 2)
 /usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: Undefined symbols: _testLib3Imp
 referenced from libtestLib3lib expected to be defined in
 libtestLib3Imp.dylib

or with CMAKE_SKIP_RPATH off to enable install_name in the Export side:

 /usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: warning can't open dynamic library:
 /Developer/SDKs/MacOSX10.4u.sdk/.../ExportImport/Export/impl/libtestLib3Imp.dylib
 referenced from: /.../ExportImport/Export/libtestLib3lib.1.2.dylib
 (checking for undefined symbols may be affected) (No such file or directory, errno = 2)
 /usr/libexec/gcc/i686-apple-darwin8/4.0.1/ld: Undefined symbols:_testLib3Imp
 referenced from libtestLib3lib expected to be defined in
 /.../ExportImport/Export/impl/libtestLib3Imp.dylib

Note how "/Developer/SDKs/MacOSX10.4u.sdk" is prepended to the dependent
library path.

Commit 2cff26fa (Support linking to shared libs with dependent libs,
2008-01-31) and commit 82fcaebe (Pass dependent library search path to
linker on some platforms, 2008-02-01) worked around the problem by
defining platform variable CMAKE_LINK_DEPENDENT_LIBRARY_FILES.  It tells
CMake to link to dependent libraries explicitly by their path thus
telling the linker where to find them.

Unfortunately the workaround had the side effect of linking dependent
libraries and defeats most benefits of LINK_INTERFACE_LIBRARIES.
Fortunately OS X 10.5 and above do not need to find transitive
dependencies at all so we can avoid the workaround on Modern OS X.
2011-12-15 08:14:30 -05:00
Brad King 5720e1f634 HP: Drive shared library linking with compiler front end
Previously we linked C, Fortran, and ASM shared libraries compiled with
the HP compiler using a direct invocation of the linker (ld).  This
behavior was left historically from support for an ancient HP C compiler
that did not know how to create shared libraries.  Fortran shared
libraries need to be linked with the compiler to get the language
runtime library dependencies as is already done for C++.

Update the HP-UX-HP* platform information to use the compiler front end
when linking shared libraries.  This works on modern HP tools and
produces correct behavior.  If there is a need to support older tools
again we can add a special case for them.
2011-12-14 09:32:27 -05:00
Brad King c213eb9cbf Windows-GNU: Remove extra quotes in GNUtoMS rule variable
CMake replaces the <TARGET...> tokens with properly quoted values so we
do not need an extra set of quotes around them.
2011-12-08 13:28:37 -05:00
David Cole 386cf3c593 Merge topic 'GNU-to-MS'
ae62a1c Test CMAKE_GNUtoMS option in ExportImport on MinGW and MSys
afb00fe Add CMAKE_GNUtoMS option to convert GNU .dll.a to MS .lib
61e8629 Factor makefile generator link rule lookup into helper function
a603250 Load platform files that need to know the ABI when possible
ecd8414 Fortran: Detect pointer size in gfortran on MinGW
2011-12-06 15:07:39 -05:00
Brad King afb00fef19 Add CMAKE_GNUtoMS option to convert GNU .dll.a to MS .lib
Teach the Windows-GNU.cmake platform file to look for Visual Studio
tools matching the target ABI.  Add an extra step to the link command
for shared libraries and executables that export symbols and on which a
new GNUtoMS property is set (initialized by the CMAKE_GNUtoMS option).
Tell the GNU linker to output a module definition (.def) file listing
exported symbols in addition to the GNU-format import library (.dll.a).
Pass the .def file to the MS "lib" tool to construct a MS-format DLL
import library (.lib).

Teach the install(TARGETS) command to install the MS import library next
to the GNU one.  Teach the install(EXPORT) and export() command to set
the IMPORTED_IMPLIB property pointing at the import library to use the
import library matching the tools in the importing project.
2011-12-05 18:13:49 -05:00
Brad King ecd8414757 Fortran: Detect pointer size in gfortran on MinGW
Use __SIZEOF_POINTER__ which the GNU Fortran compiler defines at least
on 64-bit MinGW.  Assume default size 4 on MinGW if gfortran does not
define the size.
2011-12-05 16:32:29 -05:00
Brad King ec636e299f TinyCC: Add compiler info for shared libs on Linux (#12605)
Use the "-shared" option to link shared libraries.  The compiler does
not support "-Wl," or "-rpath" but does know how to pass "-soname"
through to the linker.
2011-12-02 10:23:48 -05:00
Todd Gamblin 5993891e8d Fixed link bugs in BlueGeneP build.
- Build wasn't properly using -soname linker args, so installed libraries
  could depend on relative paths from the build directory.
- Consolidated GNU linker args to one place in the BlueGeneP-base platform
  file, since ld is used by both XL and GNU toolchains on BlueGene.
2011-08-28 22:08:11 -07:00
David Cole dfb307fef5 Merge topic 'fix-old-VisualAge-Fortran'
ad542d8 XL: Fix old VisualAge branding of Fortran compiler
2011-08-16 17:01:47 -04:00
Brad King ad542d821d XL: Fix old VisualAge branding of Fortran compiler
Commit 6d434ee6 (Split XL compiler information files, 2009-09-30)
added Platform/AIX-(XL|VisualAge)-(C|CXX|Fortran).cmake modules
to support the old and new compiler branding for all languages.
Add the "AIX-VisualAge-Fortran" combination that was left out
accidentally.
2011-08-02 17:26:29 -04:00
David Cole bd54141d5d Merge topic 'fix-11866-add-watcom-sys-libs'
ff59716 Watcom: Use correct args for execute_process call (#11866)
80769cd Add Watcom support to InstallRequiredSystemLibraries (#11866)
2011-08-02 15:11:35 -04:00