Skip to content

Commit

Permalink
Merge #49: cmake: Fix and improve toolchain input file for old CMake
Browse files Browse the repository at this point in the history
e2361c7 fixup! build: Generate `share/toolchain.cmake` in  depends (Hennadii Stepanov)
7115bdd fixup! build: Generate `share/toolchain.cmake` in  depends (Hennadii Stepanov)
9fa62a4 fixup! build: Generate `share/toolchain.cmake` in  depends (Hennadii Stepanov)
a24bb49 fixup! build: Generate `share/toolchain.cmake` in  depends (Hennadii Stepanov)
7ad2a93 fixup! build: Generate `share/toolchain.cmake` in  depends (Hennadii Stepanov)

Pull request description:

  For details see the commit messages.

  Can be tested, for example, like that:
  ```sh
  make -j $(nproc) -C depends CC="clang -march=x86-64-v4" CXX="clang++ -march=x86-64-v4 -stdlib=libc++" NO_QT=1 NO_WALLET=1 NO_NATPMP=1 NO_UPNP=1 NO_ZMQ=1 NO_USDT=1
  ~/cmake-3.18.6-Linux-x86_64/bin/cmake -B build -DCMAKE_TOOLCHAIN_FILE=depends/x86_64-pc-linux-gnu/share/toolchain.cmake
  ```

ACKs for top commit:
  pablomartin4btc:
    tACK e2361c7

Tree-SHA512: 499be084d79c14c800a96453105ad6f4e0691aea6d2bd14e8c15929f0e2e0f7891d3c296a5b37726c7dede47bc0b83cb1d66d5d4bc410190c93ed3cc6ff0f4cc
  • Loading branch information
hebasto committed Nov 15, 2023
2 parents 7400ca5 + e2361c7 commit 466bc36
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions depends/toolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ if(NOT CMAKE_C_COMPILER)
set(CMAKE_C_LINKER_LAUNCHER ${CMAKE_C_COMPILER_LAUNCHER})
endif()
if(CMAKE_VERSION VERSION_LESS 3.19)
# Being provided with CC="compiler -arg1 -arg2", the old CMake cannot
# store the compiler arguments in the CMAKE_C_COMPILER variable.
# Therefore, we have to store them separately.
set(mandatory_c_compiler_flags ${CMAKE_C_COMPILER})
list(REMOVE_AT mandatory_c_compiler_flags 0)
list(POP_FRONT mandatory_c_compiler_flags CMAKE_C_COMPILER)
list(JOIN mandatory_c_compiler_flags " " mandatory_c_compiler_flags)
set(CMAKE_C_FLAGS_INIT ${CMAKE_C_FLAGS_INIT} ${mandatory_c_compiler_flags})
list(GET CMAKE_C_COMPILER 0 CMAKE_C_COMPILER)
string(PREPEND CMAKE_C_FLAGS_INIT "${mandatory_c_compiler_flags} ")
unset(mandatory_c_compiler_flags)
endif()
set(DEPENDS_C_COMPILER_FLAGS @CFLAGS@)
endif()
Expand All @@ -51,14 +54,17 @@ if(NOT CMAKE_CXX_COMPILER)
set(CMAKE_CXX_LINKER_LAUNCHER ${CMAKE_CXX_COMPILER_LAUNCHER})
endif()
if(CMAKE_VERSION VERSION_LESS 3.19)
# Handle CXX='clang++ -stdlib=libc++' properly.
# See: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4136.
# Being provided with CXX="compiler -arg1 -arg2", the old CMake cannot
# store the compiler arguments in the CMAKE_CXX_COMPILER variable.
# Therefore, we have to store them separately.
set(mandatory_cxx_compiler_flags ${CMAKE_CXX_COMPILER})
list(REMOVE_AT mandatory_cxx_compiler_flags 0)
list(POP_FRONT mandatory_cxx_compiler_flags CMAKE_CXX_COMPILER)
list(JOIN mandatory_cxx_compiler_flags " " mandatory_cxx_compiler_flags)
set(CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT} ${mandatory_cxx_compiler_flags})
set(CMAKE_EXE_LINKER_FLAGS_INIT ${CMAKE_EXE_LINKER_FLAGS_INIT} ${mandatory_cxx_compiler_flags})
list(GET CMAKE_CXX_COMPILER 0 CMAKE_CXX_COMPILER)
string(PREPEND CMAKE_CXX_FLAGS_INIT "${mandatory_cxx_compiler_flags} ")
string(PREPEND CMAKE_OBJCXX_FLAGS_INIT "${mandatory_cxx_compiler_flags} ")
string(PREPEND CMAKE_EXE_LINKER_FLAGS_INIT "${mandatory_cxx_compiler_flags} ")
string(PREPEND CMAKE_SHARED_LINKER_FLAGS_INIT "${mandatory_cxx_compiler_flags} ")
unset(mandatory_cxx_compiler_flags)
endif()
set(DEPENDS_CXX_COMPILER_FLAGS @CXXFLAGS@)

Expand Down

0 comments on commit 466bc36

Please sign in to comment.