summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/XcodeProject/XcodeRemoveExcessiveISystem.cmake
blob: 44052f035bbeedc1d7e7a142102b98e5353b9e8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
cmake_minimum_required (VERSION 3.14)

if(NOT "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")
  set(USE_SWIFT 1)
else()
  set(USE_SWIFT 0)
endif()

if(IOS)
  set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO)
  set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
  if(XCODE_VERSION VERSION_LESS 9)
    set(USE_SWIFT 0)
  endif()
endif ()

enable_language (CXX)

if(USE_SWIFT)
  enable_language (Swift)
  if(NOT XCODE_VERSION VERSION_LESS 10.2)
    set(CMAKE_Swift_LANGUAGE_VERSION 5.0)
  elseif(NOT XCODE_VERSION VERSION_LESS 8.0)
    set(CMAKE_Swift_LANGUAGE_VERSION 3.0)
  endif()
endif()

# Try to find ZLIB in the SDK rather than in system locations.
set(CMAKE_FIND_USE_PACKAGE_ROOT_PATH FALSE)
set(CMAKE_FIND_USE_CMAKE_PATH FALSE)
set(CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH FALSE)
set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH FALSE)
list(REMOVE_ITEM CMAKE_SYSTEM_PREFIX_PATH /usr/local /usr / /usr/X11R6 /usr/pkg /opt /sw /opt/local)

find_package(ZLIB REQUIRED)
add_library (framework_dependency STATIC)
target_sources (framework_dependency PRIVATE use_cmath.cpp)
target_link_libraries(framework_dependency INTERFACE ZLIB::ZLIB)

add_library (framework_test SHARED use_cmath.cpp)
if(USE_SWIFT)
  target_sources(framework_test PRIVATE foo.swift)
endif()
target_link_libraries (framework_test PRIVATE framework_dependency)

set_target_properties (framework_test PROPERTIES
    FRAMEWORK TRUE
    FRAMEWORK_VERSION A
    MACOSX_FRAMEWORK_IDENTIFIER "framework.test"
    VERSION "1.0"
    SOVERSION 1.0
  )