Skip to content

Commit

Permalink
Merge pull request #7559 from hughbe/cmake-dead-code
Browse files Browse the repository at this point in the history
[CMake] remove some unused functions and versioning dead code
  • Loading branch information
hughbe committed Feb 17, 2017
2 parents 5d30fe9 + 0c82511 commit 097a18e
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 76 deletions.
10 changes: 2 additions & 8 deletions CMakeLists.txt
Expand Up @@ -409,12 +409,6 @@ include(SwiftList)
# Configure swift include, install, build components.
swift_configure_components()

if("${CMAKE_VERSION}" VERSION_LESS "3.0")
set(SWIFT_CMAKE_HAS_GENERATOR_EXPRESSIONS FALSE)
else()
set(SWIFT_CMAKE_HAS_GENERATOR_EXPRESSIONS TRUE)
endif()

# lipo is used to create universal binaries.
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
include(SwiftDarwin)
Expand Down Expand Up @@ -847,8 +841,8 @@ foreach(sdk ${SWIFT_SDKS})
endforeach()

if(SWIFT_PARALLEL_LINK_JOBS)
if(CMAKE_VERSION VERSION_LESS 3.0 OR NOT CMAKE_MAKE_PROGRAM MATCHES "ninja")
message(WARNING "Job pooling is only available with Ninja generators and CMake 3.0 and later.")
if(NOT CMAKE_MAKE_PROGRAM MATCHES "ninja")
message(WARNING "Job pooling is only available with Ninja generators.")
else()
set_property(GLOBAL APPEND PROPERTY JOB_POOLS swift_link_job_pool=${SWIFT_PARALLEL_LINK_JOBS})
set(CMAKE_JOB_POOL_LINK swift_link_job_pool)
Expand Down
9 changes: 1 addition & 8 deletions cmake/modules/AddSwift.cmake
Expand Up @@ -428,14 +428,7 @@ function(_add_swift_lipo_target)
# Gather the source binaries.
set(source_binaries)
foreach(source_target ${source_targets})
if(SWIFT_CMAKE_HAS_GENERATOR_EXPRESSIONS)
list(APPEND source_binaries $<TARGET_FILE:${source_target}>)
else()
get_property(source_binary
TARGET ${source_target}
PROPERTY LOCATION)
list(APPEND source_binaries "${source_binary}")
endif()
list(APPEND source_binaries $<TARGET_FILE:${source_target}>)
endforeach()

is_darwin_based_sdk("${LIPO_SDK}" IS_DARWIN)
Expand Down
13 changes: 0 additions & 13 deletions cmake/modules/SwiftDarwin.cmake
@@ -1,16 +1,3 @@
# On Darwin platforms that have xcrun, returns the path to the
# default toolchain directory.
function(get_default_toolchain_dir result_var_name)
execute_process(
COMMAND "xcrun" "--toolchain" "default" "--find" "clang"
OUTPUT_VARIABLE toolchain_dir
OUTPUT_STRIP_TRAILING_WHITESPACE)
get_filename_component(toolchain_dir "${toolchain_dir}" PATH)
get_filename_component(toolchain_dir "${toolchain_dir}" PATH)
get_filename_component(toolchain_dir "${toolchain_dir}" PATH)
set("${result_var_name}" "${toolchain_dir}" PARENT_SCOPE)
endfunction()

function(find_toolchain_tool result_var_name toolchain tool)
execute_process(
COMMAND "xcrun" "--toolchain" "${toolchain}" "--find" "${tool}"
Expand Down
33 changes: 0 additions & 33 deletions cmake/modules/SwiftList.cmake
Expand Up @@ -59,39 +59,6 @@ function(list_replace input_list old new)
set("${input_list}" "${replaced_list}" PARENT_SCOPE)
endfunction()

function(list_has_duplicates l outvar)
set(LCOPY "${l}")
list(REMOVE_DUPLICATES "${LCOPY}")
list(LENGTH l L_LENGTH)
list(LENGTH LCOPY LCOPY_LENGTH)

if (${L_LENGTH} EQUAL ${LCOPY_LENGTH})
set(${outvar} FALSE PARENT_SCOPE)
else()
set(${outvar} TRUE PARENT_SCOPE)
endif()
endfunction()

function(precondition_list_is_set l)
list_has_duplicates(${l} HAS_DUPLICATES)
precondition(HAS_DUPLICATES NEGATE
MESSAGE "List ${l} has duplicate elements and thus is not a set. Contents: ${${l}}")
endfunction()

function(precondition_list_is_disjoint first)
set(RESULT "${${first}}")
set(REST ${ARGN})
foreach(l ${REST})
# First do a precondition check that RESULT and l are disjoint.
list_intersect("${RESULT}" "${${l}}" TMP_INTERSECTION)
list(LENGTH TMP_INTERSECTION TMP_INTERSECTION_LENGTH)
precondition_binary_op(EQUAL ${TMP_INTERSECTION_LENGTH} 0
MESSAGE "Found non-empty set intersection.")
# Then union l into RESULT so that we can check the next list.
list_union(RESULT "${${l}}" "${RESULT}")
endforeach()
endfunction()

function(precondition_list_empty l message)
precondition(l NEGATE MESSAGE "${message}")
endfunction()
13 changes: 0 additions & 13 deletions cmake/modules/SwiftSharedCMakeConfig.cmake
@@ -1,17 +1,4 @@
include(CMakeParseArguments)

# Use ${cmake_2_8_12_KEYWORD} instead of KEYWORD in target_link_libraries().
# These variables are used by LLVM's CMake code.
set(cmake_2_8_12_INTERFACE INTERFACE)
set(cmake_2_8_12_PRIVATE PRIVATE)

# Backwards compatible USES_TERMINAL, cargo culted from llvm's cmake configs.
if(CMAKE_VERSION VERSION_LESS 3.1.20141117)
set(cmake_3_2_USES_TERMINAL)
else()
set(cmake_3_2_USES_TERMINAL USES_TERMINAL)
endif()

include(SwiftXcodeSupport)

macro(swift_common_standalone_build_config_llvm product is_cross_compiling)
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Expand Up @@ -301,7 +301,7 @@ foreach(SDK ${SWIFT_SDKS})
${directories}
DEPENDS ${dependencies}
COMMENT "Running ${test_subset} Swift tests for ${VARIANT_TRIPLE}"
${cmake_3_2_USES_TERMINAL})
USES_TERMINAL)
endforeach()
endforeach()
endforeach()
Expand Down

0 comments on commit 097a18e

Please sign in to comment.