aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2014-08-03 13:07:46 -0700
committerGuy Harris <guy@alum.mit.edu>2014-08-03 20:08:15 +0000
commit2d126cfec1ea0e9f9b0e345677d12b70838b7b49 (patch)
tree85e6d8deb7b5ba3c5e3a787f74fc9c0ca6e693a8 /CMakeLists.txt
parent27cfea6467d26ef44f73d4fce70a2895b3b98bdb (diff)
Add an OSX_DEPLOY_TARGET option to control building for a target OS version.
It should be set to an OS version, such as "10.5" or "10.6" or..., and, if set (and if you're building for "APPLE"), it'll try to find the SDK (and fail if it's not found), and add appropriate -isysroot, -mmacosx-version-min, and, if appropriate, -m32 compiler options. (It will need more work once we support building OS X app bundles and installers; pick up more stuff from configure.ac for that.) Change-Id: I0aebf2db8aa39304a41be4e2a9879dea6f308ec7 Reviewed-on: https://code.wireshark.org/review/3388 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt53
1 files changed, 53 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 90252ef406..3a3165d0b3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -196,6 +196,59 @@ if( CMAKE_C_COMPILER_ID MATCHES "MSVC")
${WARNINGS_CFLAGS}
)
else()
+ if(OSX_DEPLOY_TARGET)
+ if(APPLE)
+ if(${OSX_DEPLOY_TARGET} STREQUAL "10.0")
+ message(FATAL_ERROR "We don't support building for OS X 10.0")
+ elseif(${OSX_DEPLOY_TARGET} STREQUAL "10.1")
+ message(FATAL_ERROR "We don't support building for OS X 10.1")
+ elseif(${OSX_DEPLOY_TARGET} STREQUAL "10.2")
+ message(FATAL_ERROR "We don't support building for OS X 10.2")
+ elseif(${OSX_DEPLOY_TARGET} STREQUAL "10.3")
+ # XXX - never tested.
+ set(SDKPATH "/Developer/SDKs/MacOSX10.3.9.sdk")
+ else()
+ find_file(SDKPATH
+ MacOSX${OSX_DEPLOY_TARGET}.sdk
+ PATHS
+ /Developer/SDKs
+ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
+ /Library/Developer/CommandLineTools/SDKs
+ NO_DEFAULT_PATH
+ )
+ if(R{SDKPATH} STREQUAL "SDKPATH-NOTFOUND")
+ message(FATAL_ERROR "We couldn't find the SDK for OS X ${OSX_DEPLOY_TARGET}")
+ endif()
+ endif()
+ #
+ # Add a -mmacosx-version-min flag to force tests
+ # that use the compiler, as well as the build
+ # itself, not to, for example, use compiler or
+ # linker features not supported by the minimum
+ # targeted version of the OS.
+ #
+ # Add an -isysroot flag to use the SDK.
+ #
+ set(CMAKE_C_FLAGS "-mmacosx-version-min=${OSX_DEPLOY_TARGET} -isysroot ${SDKPATH} ${CMAKE_C_FLAGS}")
+ set(CMAKE_CXX_FLAGS "-mmacosx-version-min=${OSX_DEPLOY_TARGET} -isysroot ${SDKPATH} ${CMAKE_CXX_FLAGS}")
+ set(WS_LINK_FLAGS "-mmacosx-version-min=${OSX_DEPLOY_TARGET} -isysroot ${SDKPATH} ${WS_LINK_FLAGS}")
+ if(${OSX_DEPLOY_TARGET} STREQUAL "10.4" OR ${OSX_DEPLOY_TARGET} STREQUAL "10.5")
+ #
+ # Only 32-bit builds are supported. 10.5
+ # (and 10.4?) had a bug that causes some BPF
+ # functions not to work with 64-bit userland
+ # code, so capturing won't work.
+ #
+ set(CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}")
+ set(CMAKE_CXX_FLAGS "-m32 ${CMAKE_CXX_FLAGS}")
+ set(WS_LINK_FLAGS "-m32 ${WS_LINK_FLAGS}")
+ endif()
+ message(STATUS "Building for OS X ${OSX_DEPLOY_TARGET}")
+ else()
+ message(FATAL_ERROR "OSX_DEPLOY_TARGET only applies when building for OS X")
+ endif()
+ endif()
+
set(WIRESHARK_COMMON_FLAGS
# The following are for C and C++
# -O<X> and -g get set by the CMAKE_BUILD_TYPE