Author: phosek Date: Mon Feb 4 12:02:26 2019 New Revision: 353084 URL: http://llvm.org/viewvc/llvm-project?rev=353084&view=rev Log: [CMake] Support CMake variables for setting target, sysroot and toolchain
CMake has a standard way of setting target triple, sysroot and external toolchain through CMAKE_<LANG>_COMPILER_TARGET, CMAKE_SYSROOT and CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN. These are turned into corresponding --target=, --sysroot= and --gcc-toolchain= variables add included appended to CMAKE_<LANG>_FLAGS. libunwind, libc++abi, libc++ provides their own mechanism through <PROJECT>_TARGET_TRIPLE, <PROJECT>_SYSROOT and <PROJECT>_GCC_TOOLCHAIN variables. These are also passed to lit via lit.site.cfg, and lit config uses these to set the corresponding compiler flags when building tessts. This means that there are two different ways of setting target, sysroot and toolchain, but only one is properly supported in lit. This change extends CMake build for libunwind, libc++abi and libc++ to also support the CMake variables in addition to project specific ones in lit. Differential Revision: https://reviews.llvm.org/D57670 Modified: libunwind/trunk/CMakeLists.txt libunwind/trunk/test/lit.site.cfg.in Modified: libunwind/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=353084&r1=353083&r2=353084&view=diff ============================================================================== --- libunwind/trunk/CMakeLists.txt (original) +++ libunwind/trunk/CMakeLists.txt Mon Feb 4 12:02:26 2019 @@ -225,12 +225,22 @@ macro(add_target_flags_if condition var) endmacro() add_target_flags_if(LIBUNWIND_BUILD_32_BITS "-m32") -add_target_flags_if(LIBUNWIND_TARGET_TRIPLE - "--target=${LIBUNWIND_TARGET_TRIPLE}") -add_target_flags_if(LIBUNWIND_GCC_TOOLCHAIN - "--gcc-toolchain=${LIBUNWIND_GCC_TOOLCHAIN}") -add_target_flags_if(LIBUNWIND_SYSROOT - "--sysroot=${LIBUNWIND_SYSROOT}") + +if(LIBUNWIND_TARGET_TRIPLE) + add_target_flags("--target=${LIBUNWIND_TARGET_TRIPLE}") +elseif(CMAKE_CXX_COMPILER_TARGET) + set(LIBUNWIND_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}") +endif() +if(LIBUNWIND_GCC_TOOLCHAIN) + add_target_flags("--gcc-toolchain=${LIBUNWIND_GCC_TOOLCHAIN}") +elseif(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) + set(LIBUNWIND_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}") +endif() +if(LIBUNWIND_SYSROOT) + add_target_flags("--sysroot=${LIBUNWIND_SYSROOT}") +elseif(CMAKE_SYSROOT) + set(LIBUNWIND_SYSROOT "${CMAKE_SYSROOT}") +endif() if (LIBUNWIND_TARGET_TRIPLE) set(TARGET_TRIPLE "${LIBUNWIND_TARGET_TRIPLE}") Modified: libunwind/trunk/test/lit.site.cfg.in URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/test/lit.site.cfg.in?rev=353084&r1=353083&r2=353084&view=diff ============================================================================== --- libunwind/trunk/test/lit.site.cfg.in (original) +++ libunwind/trunk/test/lit.site.cfg.in Mon Feb 4 12:02:26 2019 @@ -20,7 +20,7 @@ config.enable_shared = "@LIBC config.enable_exceptions = "@LIBUNWIND_ENABLE_EXCEPTIONS@" config.host_triple = "@LLVM_HOST_TRIPLE@" config.target_triple = "@TARGET_TRIPLE@" -config.use_target = len("@LIBUNWIND_TARGET_TRIPLE@") > 0 +config.use_target = bool("@LIBUNWIND_TARGET_TRIPLE@") config.sysroot = "@LIBUNWIND_SYSROOT@" config.gcc_toolchain = "@LIBUNWIND_GCC_TOOLCHAIN@" config.cxx_ext_threads = "@LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY@" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits