File: CMakeLists.txt

package info (click to toggle)
cmake 2.8.11.1-1~bpo70+1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 37,056 kB
  • sloc: cpp: 157,219; ansic: 137,155; yacc: 3,254; sh: 2,745; xml: 2,483; lex: 1,028; lisp: 215; python: 199; objc: 134; f90: 105; perl: 99; fortran: 93; makefile: 65; tcl: 55; asm: 28; php: 25; ruby: 22; java: 20
file content (59 lines) | stat: -rw-r--r-- 1,643 bytes parent folder | download | duplicates (2)
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
53
54
55
56
57
58
59
cmake_minimum_required(VERSION 2.8)
project(Architecture C)

function(test_for_xcode4 result_var)
  set(${result_var} 0 PARENT_SCOPE)
  if(APPLE)
    execute_process(COMMAND xcodebuild -version
      OUTPUT_VARIABLE ov RESULT_VARIABLE rv
      )
    if("${rv}" STREQUAL "0")
      if(ov MATCHES "^Xcode 4.[0-9].*$")
        set(${result_var} 1 PARENT_SCOPE)
      endif()
    endif()
  endif()
endfunction()

test_for_xcode4(is_xcode4)

set(arch0 i386)
set(arch1 ppc)

if(is_xcode4)
  # Xcode 4, use modern architectures as defaults
  # Arch 'ppc' no longer works: tools no longer available starting with Xcode 4
  set(arch0 i386)
  set(arch1 x86_64)
endif()

add_library(foo foo.c)
if(CMAKE_OSX_ARCHITECTURES)
  get_property(archs TARGET foo PROPERTY OSX_ARCHITECTURES)
  if(NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "${archs}")
    message(FATAL_ERROR
      "OSX_ARCHITECTURES property not initialized by CMAKE_OSX_ARCHITECTURES.\n"
      "Expected [${CMAKE_OSX_ARCHITECTURES}], got [${archs}]."
      )
  endif()
  list(LENGTH archs archs_len)
  if(archs_len GREATER 1)
    list(GET archs 0 arch0)
    list(GET archs 1 arch1)
  endif()
endif()

message("is_xcode4='${is_xcode4}'")
message("archs='${archs}'")
message("arch0='${arch0}'")
message("arch1='${arch1}'")

set_property(TARGET foo PROPERTY OSX_ARCHITECTURES ${arch0})
set_property(TARGET foo PROPERTY OSX_ARCHITECTURES_DEBUG ${arch1})

add_executable(bar bar.c)
target_link_libraries(bar foo)

set_property(TARGET bar PROPERTY OUTPUT_NAME Architecture)
set_property(TARGET bar PROPERTY OSX_ARCHITECTURES ${arch1})
set_property(TARGET bar PROPERTY OSX_ARCHITECTURES_DEBUG ${arch0})