# Build the swiftObjC dylib.
set(SHARED_LIBRARY ON)

set(SWIFTOBJC_SOURCES
    ObjectiveC.swift)

# Definition of ObjCBool is platform-specific.
if (SWIFT_DEPLOYMENT_OS MATCHES "^macosx" 
    OR
    (SWIFT_DEPLOYMENT_OS MATCHES "^iphone" 
     AND NOT (CMAKE_OSX_ARCHITECTURES MATCHES "64$")))
  # OS X or 32-bit iOS: Objective-C BOOL is signed char
  list(APPEND SWIFTOBJC_SOURCES 
    ObjectiveC-BOOLchar.swift)
else()
  # Others: Objective-C BOOL is C99/C++ bool.
  list(APPEND SWIFTOBJC_SOURCES 
    ObjectiveC-BOOLbool.swift)
endif()

add_swift_library(swiftObjectiveC INSTALL
  ${SWIFTOBJC_SOURCES}
  DEPENDS swift_stdlib_core)

if(SWIFT_MODULE_CACHE_PATH)
  set(module_cache "${SWIFT_MODULE_CACHE_PATH}")
elseif(APPLE)
  execute_process(COMMAND getconf DARWIN_USER_CACHE_DIR
    OUTPUT_VARIABLE user_cache_dir OUTPUT_STRIP_TRAILING_WHITESPACE)
  if(user_cache_dir)
    set(module_cache "${user_cache_dir}/org.llvm.clang/ModuleCache")
  endif()
endif()
  
if(module_cache)
  add_custom_command(TARGET swiftObjectiveC PRE_BUILD
    COMMAND ${CMAKE_COMMAND} -E remove_directory "${module_cache}"
    COMMENT "Clearing Clang module cache")
endif()

add_subdirectory(Foundation)

if (SWIFT_DEPLOYMENT_OS MATCHES "^macosx")
  add_subdirectory(AppKit)
else()
  add_subdirectory(UIKit)
endif()

# Build the swiftObjC dylib.
set(SHARED_LIBRARY ON)

set(SWIFTOBJC_SOURCES
    ObjectiveC.swift)

# Definition of ObjCBool is platform-specific.
if (SWIFT_DEPLOYMENT_OS MATCHES "^macosx" 
    OR
    (SWIFT_DEPLOYMENT_OS MATCHES "^iphone" 
     AND NOT (CMAKE_OSX_ARCHITECTURES MATCHES "64$")))
  # OS X or 32-bit iOS: Objective-C BOOL is signed char
  list(APPEND SWIFTOBJC_SOURCES 
    ObjectiveC-BOOLchar.swift)
else()
  # Others: Objective-C BOOL is C99/C++ bool.
  list(APPEND SWIFTOBJC_SOURCES 
    ObjectiveC-BOOLbool.swift)
endif()

add_swift_library(swiftObjectiveC INSTALL
  ${SWIFTOBJC_SOURCES}
  DEPENDS swift_stdlib_core)

add_subdirectory(Foundation)

if (SWIFT_DEPLOYMENT_OS MATCHES "^macosx")
  add_subdirectory(AppKit)
else()
  add_subdirectory(UIKit)
endif()

Revert "[CMake] Clear the Clang module cache before building the ObjectiveC overlay."
Revert "[CMake] Clear the Clang module cache before building the ObjectiveC overlay."

This broke systems where it isn't appropriate to clear the module cache.
The build script already does this when you do a full build; for other
cases, we should just deal with it. (You can still specify a custom
MODULE_CACHE_PATH to make it easier to delete, rather than relying on the
system one.)

This reverts commit r14364.

<rdar://problem/16232176>

Swift SVN r14872
