head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.2
	netbsd-11-0-RC3:1.1.1.2
	netbsd-11-0-RC2:1.1.1.2
	netbsd-11-0-RC1:1.1.1.2
	perseant-exfatfs-base-20250801:1.1.1.2
	netbsd-11:1.1.1.2.0.8
	netbsd-11-base:1.1.1.2
	netbsd-10-1-RELEASE:1.1.1.2
	perseant-exfatfs-base-20240630:1.1.1.2
	perseant-exfatfs:1.1.1.2.0.6
	perseant-exfatfs-base:1.1.1.2
	netbsd-10-0-RELEASE:1.1.1.2
	netbsd-10-0-RC6:1.1.1.2
	netbsd-10-0-RC5:1.1.1.2
	netbsd-10-0-RC4:1.1.1.2
	netbsd-10-0-RC3:1.1.1.2
	netbsd-10-0-RC2:1.1.1.2
	netbsd-10-0-RC1:1.1.1.2
	netbsd-10:1.1.1.2.0.4
	netbsd-10-base:1.1.1.2
	cjep_sun2x-base1:1.1.1.2
	cjep_sun2x:1.1.1.2.0.2
	cjep_sun2x-base:1.1.1.2
	cjep_staticlib_x-base1:1.1.1.2
	LLVM-249b40b558955afe5ac2b549edcf2d7f859c8cc9:1.1.1.2
	cjep_staticlib_x:1.1.1.1.0.4
	cjep_staticlib_x-base:1.1.1.1
	phil-wifi-20200421:1.1.1.1
	phil-wifi-20200411:1.1.1.1
	is-mlppp:1.1.1.1.0.2
	is-mlppp-base:1.1.1.1
	phil-wifi-20200406:1.1.1.1
	phil-wifi-20191119:1.1.1.1
	LLVM-01f3a59fb3e2542fce74c768718f594d0debd0da:1.1.1.1
	LLVM:1.1.1;
locks; strict;
comment	@# @;


1.1
date	2019.11.08.14.30.17;	author joerg;	state Exp;
branches
	1.1.1.1;
next	;
commitid	lIv69tfiG0KHw3KB;

1.1.1.1
date	2019.11.08.14.30.17;	author joerg;	state Exp;
branches
	1.1.1.1.4.1;
next	1.1.1.2;
commitid	lIv69tfiG0KHw3KB;

1.1.1.2
date	2021.05.30.01.25.15;	author joerg;	state Exp;
branches;
next	;
commitid	uhgdinROdC6tU6VC;

1.1.1.1.4.1
date	2021.05.31.22.07.22;	author cjep;	state Exp;
branches;
next	;
commitid	eWz9SBW0XqKjJlVC;


desc
@@


1.1
log
@Initial revision
@
text
@# TODO: Set the install directory.

include(ExternalProject)

set(known_subdirs
  "libcxx"
  )

foreach (dir ${known_subdirs})
  if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/CMakeLists.txt)
    add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${dir})
  endif()
endforeach()

function(get_ext_project_build_command out_var target)
  if (CMAKE_GENERATOR MATCHES "Make")
    # Use special command for Makefiles to support parallelism.
    set(${out_var} "$(MAKE)" "${target}" PARENT_SCOPE)
  else()
    set(${out_var} ${CMAKE_COMMAND} --build . --target ${target}
                                    --config $<CONFIG> PARENT_SCOPE)
  endif()
endfunction()

set(COMPILER_RT_SRC_ROOT ${LLVM_MAIN_SRC_DIR}/projects/compiler-rt)
# Fallback to the external path, if the other one isn't available.
# This is the same behavior (try "internal", then check the LLVM_EXTERNAL_...
# variable) as in add_llvm_external_project
if(NOT EXISTS ${COMPILER_RT_SRC_ROOT})
  # We don't want to set it if LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR is ""
  if(LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR)
    set(COMPILER_RT_SRC_ROOT ${LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR})
  endif()
endif()

if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)

  # Add compiler-rt as an external project.
  set(COMPILER_RT_PREFIX ${CMAKE_BINARY_DIR}/projects/compiler-rt)

  set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-stamps/)
  set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/compiler-rt-bins/)

  add_custom_target(compiler-rt-clear
    COMMAND ${CMAKE_COMMAND} -E remove_directory ${BINARY_DIR}
    COMMAND ${CMAKE_COMMAND} -E remove_directory ${STAMP_DIR}
    COMMENT "Clobberring compiler-rt build and stamp directories"
    )

  # Find all variables that start with COMPILER_RT and populate a variable with
  # them.
  get_cmake_property(variableNames VARIABLES)
  foreach(variableName ${variableNames})
    if(variableName MATCHES "^COMPILER_RT")
      string(REPLACE ";" "\;" value "${${variableName}}")
      list(APPEND COMPILER_RT_PASSTHROUGH_VARIABLES
        -D${variableName}=${value})
    endif()
  endforeach()

  set(compiler_rt_configure_deps)
  if(TARGET cxx-headers)
    list(APPEND compiler_rt_configure_deps "cxx-headers")
  endif()
  if(LLVM_INCLUDE_TESTS)
    list(APPEND compiler_rt_configure_deps LLVMTestingSupport)
  endif()

  ExternalProject_Add(compiler-rt
    DEPENDS llvm-config clang ${compiler_rt_configure_deps}
    PREFIX ${COMPILER_RT_PREFIX}
    SOURCE_DIR ${COMPILER_RT_SRC_ROOT}
    STAMP_DIR ${STAMP_DIR}
    BINARY_DIR ${BINARY_DIR}
    CMAKE_ARGS ${CLANG_COMPILER_RT_CMAKE_ARGS}
               -DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
               -DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
               -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
               -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
               -DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config
               -DLLVM_LIT_ARGS=${LLVM_LIT_ARGS}
               -DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}
               -DCOMPILER_RT_EXEC_OUTPUT_DIR=${LLVM_RUNTIME_OUTPUT_INTDIR}
               -DCOMPILER_RT_INSTALL_PATH:STRING=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
               -DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
               -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
               -DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
               -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_RUNTIME_OUTPUT_INTDIR}
               -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
               -DCMAKE_OSX_SYSROOT:PATH=${CMAKE_OSX_SYSROOT}
               ${COMPILER_RT_PASSTHROUGH_VARIABLES}
    INSTALL_COMMAND ""
    STEP_TARGETS configure build
    USES_TERMINAL_CONFIGURE 1
    USES_TERMINAL_BUILD 1
    USES_TERMINAL_INSTALL 1
    )

  get_ext_project_build_command(run_clean_compiler_rt clean)
  ExternalProject_Add_Step(compiler-rt clean
    COMMAND ${run_clean_compiler_rt}
    COMMENT "Cleaning compiler-rt..."
    DEPENDEES configure
    DEPENDERS build
    DEPENDS clang
    WORKING_DIRECTORY ${BINARY_DIR}
    )

  install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P ${BINARY_DIR}/cmake_install.cmake \)"
    COMPONENT compiler-rt)

  add_llvm_install_targets(install-compiler-rt
                           DEPENDS compiler-rt
                           COMPONENT compiler-rt)

  # Add top-level targets that build specific compiler-rt runtimes.
  set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan ubsan ubsan-minimal)
  foreach(runtime ${COMPILER_RT_RUNTIMES})
    get_ext_project_build_command(build_runtime_cmd ${runtime})
    add_custom_target(${runtime}
      COMMAND ${build_runtime_cmd}
      DEPENDS compiler-rt-configure
      WORKING_DIRECTORY ${BINARY_DIR}
      VERBATIM USES_TERMINAL)
  endforeach()

  if(LLVM_INCLUDE_TESTS)
    # Add binaries that compiler-rt tests depend on.
    set(COMPILER_RT_TEST_DEPENDENCIES
      FileCheck count not llvm-nm llvm-objdump llvm-symbolizer)

    # Add top-level targets for various compiler-rt test suites.
    set(COMPILER_RT_TEST_SUITES check-fuzzer check-asan check-hwasan check-asan-dynamic check-dfsan
      check-lsan check-msan check-sanitizer check-tsan check-ubsan check-ubsan-minimal
      check-profile check-cfi check-cfi-and-supported check-safestack check-gwp_asan)
    foreach(test_suite ${COMPILER_RT_TEST_SUITES})
      get_ext_project_build_command(run_test_suite ${test_suite})
      add_custom_target(${test_suite}
        COMMAND ${run_test_suite}
        DEPENDS compiler-rt-build ${COMPILER_RT_TEST_DEPENDENCIES}
        WORKING_DIRECTORY ${BINARY_DIR}
        VERBATIM
        USES_TERMINAL
        )
    endforeach()

    # Add special target to run all compiler-rt test suites.
    get_ext_project_build_command(run_check_compiler_rt check-all)
    add_custom_target(check-compiler-rt
      COMMAND ${run_check_compiler_rt}
      DEPENDS compiler-rt-build ${COMPILER_RT_TEST_DEPENDENCIES}
      WORKING_DIRECTORY ${BINARY_DIR}
      VERBATIM USES_TERMINAL)

    # Add special target to run all compiler-rt test suites.
    get_ext_project_build_command(run_check_compiler_rt compiler-rt-test-depends)
    add_custom_target(compiler-rt-test-depends
      COMMAND ${run_check_compiler_rt}
      DEPENDS compiler-rt-build ${COMPILER_RT_TEST_DEPENDENCIES}
      WORKING_DIRECTORY ${BINARY_DIR}
      VERBATIM USES_TERMINAL)
    set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_DEPENDS compiler-rt-test-depends)
    set_property(GLOBAL APPEND PROPERTY LLVM_ADDITIONAL_TEST_TARGETS check-compiler-rt)
  endif()
endif()
@


1.1.1.1
log
@Import 01f3a59fb3e2542fce74c768718f594d0debd0da from the LLVM mono-repo:
clang (without test/, unittests/, www/)
llvm (without test/, unittests/)
@
text
@@


1.1.1.1.4.1
log
@sync with head
@
text
@a77 1
               -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
a96 2
    # Always run the build command so that incremental builds are correct.
    BUILD_ALWAYS 1
@


1.1.1.2
log
@Import clang 249b40b558955afe5ac2b549edcf2d7f859c8cc9.
@
text
@a77 1
               -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
a96 2
    # Always run the build command so that incremental builds are correct.
    BUILD_ALWAYS 1
@

