From: Guy Harris Date: Sun, 8 Aug 2021 18:54:17 +0000 (-0700) Subject: Tell CMake not to check for a C++ compiler. X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/3834579486f1bb4a002e45ceb6c015cd28b84611 Tell CMake not to check for a C++ compiler. We only need a C compiler, and if either 1) the C and C++ compilers don't match (e.g., a defaults-to-64-bit GCC and a defaults-to-32-bit Oracle Studio C++) or 2) you set CFLAGS in the environment to force a 64-bit build but don't also set CXXFLAGS CMake will get confused and think it's doing a 32-bit build even though we'll be doing a 64-bit build, and all sorts of weirdness will occur. Just say "C" in the project() command. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index edd5fd19..8fa04bcf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,8 +30,6 @@ endif() set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) -project(tcpdump) - # # OK, this is a royal pain. # @@ -52,15 +50,17 @@ project(tcpdump) # but *not* in CXXFLAGS, the size for C++ will win, and hilarity # will ensue. # -# Make sure CMAKE_C_SIZEOF_DATA_PTR and CMAKE_CXX_SIZEOF_DATA_PTR -# have the same value, and warn if they don't. +# Or if, at least on Solaris, you have a newer version of GCC +# installed, but *not* a newer version of G++, and you have Oracle +# Studio installed, it will find GCC, which will default to building +# 64-bit, and Oracle Studio's C++ compiler, which will default to +# building 32-bit, the size for C++ will win, and, again, hilarity +# will ensue. # -# Yes, we have to do this even though there is currently *NO* C++ -# code in tcpdump.... +# So we *explicitly* state that only C is used; there is currently no +# C++ code in tcpdump. # -if(NOT "${CMAKE_C_SIZEOF_DATA_PTR}" EQUAL "${CMAKE_CXX_SIZEOF_DATA_PTR}") - message(FATAL_ERROR "Architecture flags must be set in both CFLAGS and CXXFLAGS") -endif() +project(tcpdump C) # # For checking if a compiler flag works and adding it if it does.