Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Use CMAKE_USER_MAKE_RULES_OVERRIDE_<LANG> #240

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
# So disable this tool check in further enable_language() commands.
set(CMAKE_PLATFORM_HAS_INSTALLNAME FALSE)
endif()
set(APPEND_CPPFLAGS "" CACHE STRING "Preprocessor flags that are appended to the flags added by the build system.")
set(APPEND_CFLAGS "" CACHE STRING "C compiler flags that are appended to the flags added by the build system.")
set(APPEND_CXXFLAGS "" CACHE STRING "(Objective) C++ compiler flags that are appended to the flags added by the build system.")
set(APPEND_LDFLAGS "" CACHE STRING "Linker flags that are appended to the flags added by the build system.")
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${PROJECT_SOURCE_DIR}/cmake/module/OverrideCXX.cmake)
enable_language(CXX)
unset(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down Expand Up @@ -165,14 +171,6 @@ cmake_dependent_option(ENABLE_FUZZ "Build for fuzzing. Enabling this will disabl

option(INSTALL_MAN "Install man pages." ON)

set(APPEND_CPPFLAGS "" CACHE STRING "Preprocessor flags that are appended to the flags added by the build system.")
set(APPEND_CFLAGS "" CACHE STRING "C compiler flags that are appended to the flags added by the build system.")
set(APPEND_CXXFLAGS "" CACHE STRING "(Objective) C++ compiler flags that are appended to the flags added by the build system.")
set(APPEND_LDFLAGS "" CACHE STRING "Linker flags that are appended to the flags added by the build system.")
string(APPEND CMAKE_CXX_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS}")
string(APPEND CMAKE_CXX_CREATE_SHARED_LIBRARY " ${APPEND_LDFLAGS}")
string(APPEND CMAKE_CXX_LINK_EXECUTABLE " ${APPEND_LDFLAGS}")

set(configure_warnings)

include(CheckPIESupported)
Expand Down
15 changes: 15 additions & 0 deletions cmake/module/OverrideCXX.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2024-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.

if(NOT "${APPEND_CPPFLAGS}${APPEND_CXXFLAGS}" STREQUAL "")
set(CMAKE_CXX_COMPILE_OBJECT
"<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS} -o <OBJECT> -c <SOURCE>"
)
endif()

if(NOT "${APPEND_LDFLAGS}" STREQUAL "")
set(CMAKE_CXX_LINK_EXECUTABLE
"<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> ${APPEND_LDFLAGS} <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"
)
endif()
9 changes: 9 additions & 0 deletions cmake/module/OverrideOBJCXX.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2024-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.

if(NOT "${APPEND_CPPFLAGS}${APPEND_CXXFLAGS}" STREQUAL "")
set(CMAKE_OBJCXX_COMPILE_OBJECT
"<CMAKE_OBJCXX_COMPILER> <DEFINES> <INCLUDES> -x objective-c++ <FLAGS> ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS} -o <OBJECT> -c <SOURCE>"
)
endif()
3 changes: 2 additions & 1 deletion src/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ find_package(Qt5 5.11.3 MODULE REQUIRED
unset(qt_components)

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_USER_MAKE_RULES_OVERRIDE_OBJCXX ${PROJECT_SOURCE_DIR}/cmake/module/OverrideOBJCXX.cmake)
enable_language(OBJCXX)
unset(CMAKE_USER_MAKE_RULES_OVERRIDE_OBJCXX)
set(CMAKE_OBJCXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
set(CMAKE_OBJCXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_OBJCXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_OBJCXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
string(APPEND CMAKE_OBJCXX_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS}")
endif()

function(import_plugins target)
Expand Down
Loading