11cmake_minimum_required (VERSION 3.20)
22
3+ # This is created if someone wants to use GCC still. Although I am targeting CLang, I am trying not to use non-GCC compatable
4+ # options. So if you really dont care, and want to try to make GCC build again, enable this option. It is only documented here
5+ #
6+ # To use just add -DI_WANT_TO_USE_GCC=YES to your cmake command.
7+
8+ option (I_WANT_TO_USE_GCC "I dont care, I want to use GCC even if its not supported anymore" OFF )
9+
310# We are going to force clang on both Linux and Windows builds to be uniform
4- set (CMAKE_C_COMPILER "clang" CACHE FILEPATH "C compiler" )
5- set (CMAKE_CXX_COMPILER "clang++" CACHE FILEPATH "C++ compiler" )
11+ if (NOT I_WANT_TO_USE_GCC)
12+ set (CMAKE_C_COMPILER "clang" CACHE FILEPATH "C compiler" )
13+ set (CMAKE_CXX_COMPILER "clang++" CACHE FILEPATH "C++ compiler" )
14+ endif ()
615
716project (PCem)
817
9- # Dont allow GCC Building anymore, force Clang
10- if (NOT (CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_ID MATCHES "Clang" ))
11- message (FATAL_ERROR "Detected compiler is not Clang! Please ensure Clang is in your PATH or specified correctly." )
18+ # Dont allow GCC Building anymore, force Clang, unless I_WANT_TO_USE_GCC is on
19+ if (NOT I_WANT_TO_USE_GCC)
20+ string (TOUPPER "${CMAKE_C_COMPILER_ID} " CMAKE_C_COMPILER_ID_UPPER) # This is to deal with some distros showing compiler id as clang instead of Clang
21+ string (TOUPPER "${CMAKE_CXX_COMPILER_ID} " CMAKE_CXX_COMPILER_ID_UPPER) # This is to deal with some distros showing compiler id as clang instead of Clang
22+
23+ if (NOT (CMAKE_C_COMPILER_ID_UPPER MATCHES "CLANG" AND CMAKE_CXX_COMPILER_ID_UPPER MATCHES "CLANG" ))
24+ message (FATAL_ERROR "Detected compiler is not Clang! Please ensure Clang is in your PATH or specified correctly." )
25+ endif ()
1226endif ()
1327
1428set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
@@ -25,21 +39,11 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -fomit-frame-pointer
2539set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -DDEBUG" )
2640set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -DDEBUG" )
2741
28- if (${PCEM_CPU_TYPE} STREQUAL "i386 " )
29- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 " )
30- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 " )
42+ if (${PCEM_CPU_TYPE} STREQUAL "x86_64 " )
43+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=x86-64-v2 " )
44+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=x86-64-v2 " )
3145endif ()
3246
33- # Turning this off, maybe this is whats causing issues as i noticed in an older build, 64-bit builds dont do stack realign
34- #if(NOT ${PCEM_CPU_TYPE} MATCHES "arm.*")
35- # set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -mstackrealign")
36- # set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mstackrealign")
37- #endif()
38-
39- if (UNIX )
40- add_definitions (-D_FILE_OFFSET_BITS=64)
41- endif ()
42-
4347set (PCEM_VERSION_STRING "vNext" CACHE STRING "PCem Version String" )
4448set (PCEM_DISPLAY_ENGINE "wxWidgets" CACHE STRING "PCem Display Engine" )
4549set (PCEM_DEFINES ${PCEM_DEFINES} PCEM_VERSION_STRING="${PCEM_VERSION_STRING} " )
@@ -61,9 +65,9 @@ option(USE_NETWORKING "Build PCem with networking support" ON)
6165message ("Networking Support: ${USE_NETWORKING} " )
6266
6367if (USE_NETWORKING)
64- set (CMAKE_C_FLAGS_RELEASE " ${CMAKE_C_FLAGS_RELEASE} -std=gnu17" )
65- message ( " Switching C to gnu17 to allow slirp to build " )
66-
68+ # Turning off to see if it does build with CLang, I think it passes warnings but still builds.
69+ # set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -std= gnu17")
70+ # message(" Switching C to gnu17 to allow slirp to build")
6771 option (USE_PCAP_NETWORKING "Build PCem with PCAP support" ON )
6872 message (" PCAP Networking Support: ${USE_PCAP_NETWORKING} " )
6973endif ()
0 commit comments