Skip to content

Commit

Permalink
cmake: add USE_COMPILER_BUILTINS CMake option
Browse files Browse the repository at this point in the history
This introduces USE_COMPILER_BUILTINS CMake option. It is enabled
by default.

Disabling it is meant to test the unknown compiler code.
  • Loading branch information
illwieckz committed May 16, 2024
1 parent 23bd10b commit 738c5b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions cmake/DaemonFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ include(CheckCXXCompilerFlag)

add_definitions(-DDAEMON_BUILD_${CMAKE_BUILD_TYPE})

option(USE_COMPILER_BUILTINS "Enable usage of compiler builtins" ON)

if (USE_COMPILER_BUILTINS)
add_definitions(-DDAEMON_USE_COMPILER_BUILTINS=1)
message(STATUS "Enabling compiler builtins")
else()
message(STATUS "Disabling compiler builtins")
endif()

# Set flag without checking, optional argument specifies build type
macro(set_c_flag FLAG)
if (${ARGC} GREATER 1)
Expand Down
4 changes: 2 additions & 2 deletions src/common/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int CountTrailingZeroes(unsigned long long x);
#endif

// GCC and Clang
#if defined(__GNUC__)
#if defined(DAEMON_USE_COMPILER_BUILTINS) && defined(__GNUC__)

// Emit a nice warning when a function is used
#define DEPRECATED __attribute__((__deprecated__))
Expand Down Expand Up @@ -180,7 +180,7 @@ See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0627r0.pdf */
#endif

// Microsoft Visual C++
#elif defined(_MSC_VER)
#elif defined(DAEMON_USE_COMPILER_BUILTINS) && defined(_MSC_VER)

// Disable some warnings
#pragma warning(disable : 4100) // unreferenced formal parameter
Expand Down

0 comments on commit 738c5b1

Please sign in to comment.