Skip to content

Commit

Permalink
CMake: Fix out of sync iOS/macOS deployment target
Browse files Browse the repository at this point in the history
The minimal sample doesn't have an implicit deployment target set, while
the library does through CMakeLists.txt in root. This can result in iOS
link errors when not explicitly setting CMAKE_OSX_DEPLOYMENT_TARGET as
the sample will then use a target OS with an architecture that may not
be present in the library with its current target OS version.

Fix by copying the part setting CMAKE_OSX_DEPLOYMENT_TARGET in the
library to the minimal sample as well. Both parts should be kept in sync
but that still seemed preferable to additionally polluting an example
file for CMake usage with a dependency by introducing a common include
file.
  • Loading branch information
discnl committed Jan 8, 2021
1 parent 161ecbf commit 086ad7b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
endif()

# This block, particularly the versions used, should be kept in sync with
# samples/minimal/CMakeLists.txt.
if(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
# If no deployment target has been set default to the minimum supported
# OS version (this has to be set before the first project() call)
Expand Down
10 changes: 10 additions & 0 deletions samples/minimal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
# Declare the minimum required CMake version
cmake_minimum_required(VERSION 2.8.12)

if(APPLE AND NOT CMAKE_OSX_DEPLOYMENT_TARGET)
# If no deployment target has been set default to the minimum supported
# OS version (this has to be set before the first project() call)
if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0 CACHE STRING "iOS Deployment Target")
else()
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10 CACHE STRING "macOS Deployment Target")
endif()
endif()

# Name the project
project(minimal)

Expand Down

0 comments on commit 086ad7b

Please sign in to comment.