]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Tell CMake not to check for a C++ compiler.
authorGuy Harris <[email protected]>
Sun, 8 Aug 2021 18:54:17 +0000 (11:54 -0700)
committerGuy Harris <[email protected]>
Sun, 8 Aug 2021 18:54:17 +0000 (11:54 -0700)
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.

CMakeLists.txt

index edd5fd19a79e85cc1866fa12ef38a76dadfc80d1..8fa04bcfc370b7b06e5f519690f19e292253fd7a 100644 (file)
@@ -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.