Skip to content

[libc][cmake] reset COMPILE_DEFINITIONS #77810

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

Merged
merged 2 commits into from
Jan 16, 2024
Merged
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
22 changes: 18 additions & 4 deletions libc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,24 @@ endif()
include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
NO_POLICY_SCOPE)

# `llvm-project/llvm/CMakeLists.txt` adds the following directive
# `include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR})`
# We undo it to be able to precisely control what is getting included.
set_directory_properties(PROPERTIES INCLUDE_DIRECTORIES "")
if (LIBC_CMAKE_VERBOSE_LOGGING)
get_directory_property(LIBC_OLD_PREPROCESSOR_DEFS COMPILE_DEFINITIONS)
foreach(OLD_DEF ${LIBC_OLD_PREPROCESSOR_DEFS})
message(STATUS "Undefining ${OLD_DEF}")
endforeach()
endif()
set_directory_properties(PROPERTIES
# `llvm-project/llvm/CMakeLists.txt` adds the following directive
# `include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR})` We
# undo it to be able to precisely control what is getting included.
INCLUDE_DIRECTORIES ""
# `llvm/cmake/modules/HandleLLVMOptions.cmake` uses `add_compile_definitions`
# to set a few preprocessor defines which we do not want.
COMPILE_DEFINITIONS ""
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind checking what else will be set for the other two official CMake build types: RelWithDebInfo and MinSizeRel?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RelWithDebInfo (BEFORE): _GNU_SOURCE_FILE_OFFSET_BITS=64_LARGEFILE_SOURCE_FILE_OFFSET_BITS=64__STDC_CONSTANT_MACROS__STDC_FORMAT_MACROS__STDC_LIMIT_MACROS

(Nothing new)

MinSizeRel: (BEFORE):
_GNU_SOURCE_FILE_OFFSET_BITS=64_LARGEFILE_SOURCE_FILE_OFFSET_BITS=64__STDC_CONSTANT_MACROS__STDC_FORMAT_MACROS__STDC_LIMIT_MACROS

(Nothing new)

add_definitions("-D_DEBUG")
endif()

# Default to C++17
set(CMAKE_CXX_STANDARD 17)
Expand Down