Skip to content

Commit

Permalink
Try fixing 32-bit windows-xbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Nov 5, 2023
1 parent 80b5478 commit 34fad6a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
cmake_minimum_required(VERSION 3.9 FATAL_ERROR)

project(rgbds
LANGUAGES CXX)
LANGUAGES C CXX)

# get real path of source and binary directories
get_filename_component(srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
Expand All @@ -31,6 +31,10 @@ if(MSVC)
# "macro expansion producing 'defined' has undefined behavior"
add_compile_options(/MP /wd5105)
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
# Also, CMake appears not to pass the C11-enabling flag, so we must add it manually... but only for C!
if(NOT CMAKE_C_FLAGS MATCHES "std:c11") # The flag may already have been injected by an earlier CMake invocation, so don't add it twice
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std:c11" CACHE STRING "Flags used by the C compiler during all build types." FORCE)
endif()

if(SANITIZERS)
set(SAN_FLAGS /fsanitize=address)
Expand All @@ -40,7 +44,7 @@ if(MSVC)
else()
# TODO: use -pedantic after non-C++ idioms are gone
add_compile_options(-Wall)
add_definitions(-D_POSIX_C_SOURCE=200809L)
add_definitions(-D_POSIX_C_SOURCE=200809L -D_ISOC11_SOURCE)
if(SANITIZERS)
set(SAN_FLAGS -fsanitize=shift -fsanitize=integer-divide-by-zero
-fsanitize=unreachable -fsanitize=vla-bound
Expand All @@ -52,6 +56,7 @@ else()
add_definitions(-D_GLIBCXX_ASSERTIONS)
# A non-zero optimization level is desired in debug mode, but allow overriding it nonetheless
# TODO: this overrides anything previously set... that's a bit sloppy!
set(CMAKE_C_FLAGS_DEBUG "-g -Og -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "-g -Og -fno-omit-frame-pointer -fno-optimize-sibling-calls" CACHE STRING "" FORCE)
endif()

Expand Down Expand Up @@ -97,6 +102,8 @@ endif()

include_directories("${PROJECT_SOURCE_DIR}/include")

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED True)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)

Expand Down

0 comments on commit 34fad6a

Please sign in to comment.