Commit Graph

94 Commits

Author SHA1 Message Date
Flynn Marquardt 3189ed34b8 OS X: Fix app bundle search path during cross compiling (#14603)
In "Modules/Platform/Darwin.cmake" the variable _apps_paths stays empty
if cross compiling.  Do not de-duplicate an empty list.
2013-12-02 09:32:40 -05:00
Brad King 7d47c69365 Drop compatibility with CMake < 2.4
Drop all behavior activated by setting CMAKE_BACKWARDS_COMPATIBILITY to
a value lower than 2.4, and generate an error when projects or the user
attempt to do so.  In the error suggest using a CMake 2.8.x release.

Teach cmake_minimum_required to warn about projects that do not require
at least CMake 2.4.  They are not supported by CMake >= 3.0.

Replace the documentation of CMAKE_BACKWARDS_COMPATIBILITY with a
reference to policy CMP0001.
2013-10-23 08:54:31 -04:00
Brad King 2e13c36211 OS X: Encode -F framework search flag in per-language platform variable
Compilers for languages other than C and C++ on OS X may not understand
the -F framework search flag.  Create a new platform information
variable CMAKE_<LANG>_FRAMEWORK_SEARCH_FLAG to hold the flag, and set it
for C and CXX lanugages in the Platform/Darwin module.

Reported-by: Vittorio Giovara <vittorio.giovara@gmail.com>
2013-10-10 08:33:25 -04:00
Brad King 1fce189e53 OS X: Search system SDKs for frameworks
In Modules/Platform/Darwin.cmake set CMAKE_SYSTEM_FRAMEWORK_PATH to
include framework directories from inside the system SDK corresponding
to CMAKE_OSX_SYSROOT.

Suggested-by: Sean McBride <sean@rogue-research.com>
2013-09-27 10:18:46 -04:00
Brad King 335a1278eb OS X: Do not default to non-existent deployment target SDK
Since commit 95f78e08 (OS X: Search for SDK based on deployment target,
2013-08-02) we select the default OS X SDK path to match the deployment
target.  Fix this behavior in the case that the matching SDK does not
exist and fall back to the SDK for the current host OS X version.
2013-08-14 19:16:42 -04:00
Brad King 03ab170fe0 OS X: Enable command-line build without tools in PATH
Teach modules CMakeDetermineCompiler and CMakeUnixFindMake to ask Xcode
where to find the compiler or make tools, using 'xcrun --find', if none
is found in the PATH.  Teach module Platform/Darwin to add the path to
the SDK to CMAKE_SYSTEM_PREFIX_PATH so that find_* command look there.
Also add the SDK /usr/include directory to the implicit include list in
CMAKE_${lang}_IMPLICIT_INCLUDE_DIRECTORIES to suppress explicit -I
options for it.
2013-08-06 09:00:18 -04:00
Brad King 95f78e08fe OS X: Search for SDK based on deployment target (#14324)
When available, use CMAKE_OSX_DEPLOYMENT_TARGET instead of the host OS X
version to select the default SDK.  This makes sense because one should
use the SDK matching the deployment target.

Suggested-by: John Ralls <jralls@ceridwen.us>
2013-08-02 14:05:00 -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 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 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 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 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
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
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
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
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
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 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
David Cole d421a433a8 Strip trailing space from xcode-select output (#10723)
Otherwise, subsequent use of the output does not work
as intended.
2011-02-01 14:16:30 -05:00
Brad King eda7841fd2 Pass Mac linker flag through PGI compiler using "-Wl,"
The Mac linker defines -headerpad_max_install_names and the GCC
front-end passes this flag through.  The PGI compiler does not know
about this flag, so we must use -Wl,-headerpad_max_install_names to pass
it to the linker instead.
2010-11-22 08:43:13 -05:00
Brad King eae45a67e7 Search MacPorts /opt/local prefix on Mac
Include this prefix in CMAKE_SYSTEM_PREFIX_PATH so that it will be used
for all find* commands.  Previously only find_library and find_path
would look under /opt/local/lib and /opt/local/include, respectively.
2010-09-01 08:50:51 -04:00
David Cole 6ee87b2e5c Fix issue #10155 - default value of CMAKE_OSX_DEPLOYMENT_TARGET should always be the empty string. When the value of CMAKE_OSX_DEPLOYMENT_TARGET is the empty string, the -mmacosx-version-min flag should not show up on the compiler command line. The logic for selecting default value of CMAKE_OSX_SYSROOT is orthogonal to and independent of the value of the deployment target. The default value for CMAKE_OSX_SYSROOT is the SDK that corresponds to the current version of Mac OSX on which cmake is running. 2010-01-29 11:56:35 -05:00
David Cole 8d88de4b4a Fix issue with SDK not matching initial deployment target chosen by setting the MACOSX_DEPLOYMENT_TARGET environment variable. The problem was that we were setting the initial SDK value based on our own internal default value for deplyment target rather than the user's environment variable choice. The solution is to base the default value for the SDK on the deployment target variable after initially caching the deployment target... Every time I'm in this code I think I leave it cleaner, only to be proven otherwise. Let's give this one a whirl. Bleh. 2009-12-23 12:08:25 -05:00
David Cole a830786c44 Fix issues #9959 and #9898 - do not set CMAKE_OSX_DEPLOYMENT_TARGET if CMAKE_OSX_SYSROOT is set.
Default to "" for CMAKE_OSX_DEPLOYMENT_TARGET if CMAKE_OSX_SYSROOT is set. Also, add new error message to detect the case where there is a deployment target, but no SDK has been set. Fix args to STRING REGEX call so that it works even if _sdk_path variable is empty inside sanity check function.
2009-12-15 11:10:15 -05:00
Brad King 4d72006bd6 Reduce duplication in Platform/<os>.cmake files
Several platform-wide linker flag variables are defined in
Modules/Platform/<os>.cmake files for C and then copied by the
Modules/CMake<lang>Information.cmake file for each language.
We now use this approach for the variables

  CMAKE_EXE_EXPORTS_${lang}_FLAG
  CMAKE_SHARED_LIBRARY_SONAME_${lang}_FLAG
  CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS

to avoid duplication for multiple languages in each platform file.
2009-12-02 15:17:53 -05:00
Brad King 180c60a86f Fix check for -isysroot on OS X
Previously we checked for this flag by parsing the version number of GCC
out of 'gcc --version', but this is not reliable because the format can
vary greatly.  Now we run 'gcc -v --help' and look for '-isysroot' in
the list of options.

We also now store the result on a per-language basis in the per-compiler
info file "CMake<LANG>Compiler.cmake".  This is necessary to make it
accessible from try-compile projects so that they generate correctly.
2009-09-19 10:14:31 -04:00
Bill Hoffman 58818d5168 Add detection of gcc versions that do not support isysroot option and do not use it for them. 2009-09-18 14:22:20 -04:00
Bill Hoffman ea282284d5 Fix for bug #9466. Change the implementation of OSX arch lists. If no ARCHs are specified by the user then no flags are set. We no longer use CMAKE_OSX_ARCHITECTURES_DEFAULT. 2009-09-17 11:53:02 -04:00
Brad King 39f8b91125 BUG: Remove implicit include dir suppression
We used to suppress generation of -I/usr/include (and on OSX also
-I/usr/local/include).  This behavior seems to cause more trouble than
it's worth, so I'm removing it until someone encounters the original
problem it fixed.  See issue #8598.
2009-02-24 15:37:09 -05:00
David Cole 553ddde8d1 BUG: Allow third component of Mac OSX sw_vers output to be empty. Mac OSX 10.5 was recently reinstalled on dashmacmini3 and pointed out the fact that this expression is faulty when the reported version is simply 10.5 rather than 10.5.x... for example. This fixes it. 2009-02-17 16:59:58 -05:00
David Cole 75fb6798ab BUG: Remove unnecessary double quotes from SET statements. Hopefully resolves the strange and difficult to diagnose (or reproduce) test failures on the dashmacmini2 Continuous dashboard. 2009-01-29 14:57:38 -05:00
Brad King 7ca59f1724 BUG: Fix OS X dylib version flags for more linkers
Some OS X linkers want a 'dylib_' prefix on the -compatiblity_version
and -current_version flags while others do not.  This passes the flags
through gcc instead since it never wants the prefix and translates the
flags for the linker correctly.
2009-01-29 13:41:58 -05:00
David Cole 2cd839142d BUG: Fix careless typo that only caused test failures on clean builds... 2009-01-28 06:10:12 -05:00
David Cole 9e3705b5b8 BUG: Try to fix the universal binary continuous dashboard on dashmacmini2. I am deducing that the value of CMAKE_OSX_ARCHITECTURES_DEFAULT is responsible for the failure, although I cannot reproduce it on other builds or even by running the test via ctest interactively *on* the continuous dashboard's build... 2009-01-27 15:51:43 -05:00
David Cole 2853326e7a BUG: Only set CMAKE_OSX_DEPLOYMENT_TARGET on Mac OSX 10.4 or later. The gcc that runs on 10.3 and earlier does not understand the compiler flag it maps to... 2009-01-27 11:50:41 -05:00
David Cole 1dee719cdc BUG: Fix issue #6195. Add CMAKE_OSX_DEPLOYMENT_TARGET cache variable to specify the target deployment runtime OS version of the built executables on Mac OSX. Thanks to Mike Jackson for the patch. 2009-01-27 10:30:55 -05:00
David Cole b640257884 BUG: Fix install_name_tool problem on the Mac when a PROJECT(... NONE) is followed by multiple calls to ENABLE_LANGUAGE. Use find_program to set the CMAKE_INSTALL_NAME_TOOL variable so it gets saved in the cache as a full path to the install_name_tool executable rather than a simple set which eventually goes out of scope. 2008-12-30 09:11:54 -05:00
Bill Hoffman 736da84b4f BUG: fix for 6710 CMAKE_OSX_SYSROOT should be a PATH 2008-08-19 14:23:38 -04:00
Brad King 4e5e3161a3 BUG: Fix dylib versioning flags for old OSX.
- ld flags -dylib_compatibility_version and -dylib_current_version
    are libtool flags -compatibility_version and -current_version
  - OSX 10.3 does not like the dylib_ prefixes.
2008-07-09 17:45:45 -04:00
Brad King 0d54001276 ENH: Set version info for shared libs on OSX.
- Map SOVERSION major.minor.patch to compatibility_version
  - Map VERSION major.minor.patch to current_version
  - See issue #4383.
2008-07-09 10:09:46 -04:00
Bill Hoffman d4fdbeed64 ENH: allow users to set sysroot 2008-04-28 13:53:14 -04:00