<commit_before>#
# CEN64: Cycle-Accurate Nintendo 64 Simulator.
# Copyright (C) 2014, <NAME>.
#
# This file is subject to the terms and conditions defined in
# 'LICENSE', which is part of this source code package.
#

cmake_minimum_required(VERSION 2.6)
project(cen64)

find_package(OpenGL REQUIRED)
find_package(Threads REQUIRED)

# If using GCC, configure it accordingly.
if (${CMAKE_C_COMPILER_ID} MATCHES GNU)
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -std=c99")

  # Enable processor-specific optimizations?
  option(NATIVE_BUILD "Build binary for native architecture?" OFF)

  if (NATIVE_BUILD)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
  endif (NATIVE_BUILD)

  # Include architecture-specify machinery.
  execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine
    OUTPUT_VARIABLE GCC_MACHINE)

  string(REGEX MATCH "([a-zA-Z0-9])+" GCC_MACHINE ${GCC_MACHINE})

  if (${GCC_MACHINE} MATCHES "x86.*" OR ${GCC_MACHINE} MATCHES "i.86.*")
    set(CEN64_ARCH_DIR "x86_64")

    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maccumulate-outgoing-args")

    if (${GCC_MACHINE} MATCHES "i.86.*")
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffixed-xmm5 -ffixed-xmm6 -ffixed-xmm7")
    else ()
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffixed-xmm13 -ffixed-xmm14 -ffixed-xmm15")
    endif()

    if (NOT NATIVE_BUILD)
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mssse3")
    endif (NOT NATIVE_BUILD)

    include_directories(${PROJECT_SOURCE_DIR}/os/unix/x86_64)
  endif (${GCC_MACHINE} MATCHES "x86.*" OR ${GCC_MACHINE} MATCHES "i.86.*")

  if (${GCC_MACHINE} STREQUAL "arm")
    set(CEN64_ARCH_DIR "arm")

    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard -mfpu=neon")
    include_directories(${PROJECT_SOURCE_DIR}/os/unix/arm)
  endif (${GCC_MACHINE} STREQUAL "arm")

  # Set architecture-independent flags.
  set(CMAKE_C_FLAGS_DEBUG "-ggdb3 -g3 -O0")
  set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG -s")
  set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG -s")
  set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Og")
  set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")

  # Enable link time optimization on recent versions.
  execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
    OUTPUT_VARIABLE GCC_VERSION)

  if (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)
    set(GCC_FLTO_FLAGS "-flto -flto-partition=none -fdata-sections -ffunction-sections")

    # When compiling with -flto, need to pass CFLAGS to the linker.
    set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${GCC_FLTO_FLAGS}")
    set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${GCC_FLTO_FLAGS}")
    set(CMAKE_EXE_LINKER_FLAGS_RELEASE ${CMAKE_EXE_LINKER_FLAGS_RELEASE} "-Wl,--gc-sections")
    set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} "-Wl,--gc-sections")
  endif (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)

  # Check for undefined behaviour when debugging.
  if (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)<commit_msg>Aggressively optimize loops when using GCC.<commit_after>#
# CEN64: Cycle-Accurate Nintendo 64 Simulator.
# Copyright (C) 2014, <NAME>.
#
# This file is subject to the terms and conditions defined in
# 'LICENSE', which is part of this source code package.
#

cmake_minimum_required(VERSION 2.6)
project(cen64)

find_package(OpenGL REQUIRED)
find_package(Threads REQUIRED)

# If using GCC, configure it accordingly.
if (${CMAKE_C_COMPILER_ID} MATCHES GNU)
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wno-unused-parameter -std=c99")

  # Enable processor-specific optimizations?
  option(NATIVE_BUILD "Build binary for native architecture?" OFF)

  if (NATIVE_BUILD)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=native")
  endif (NATIVE_BUILD)

  # Include architecture-specify machinery.
  execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine
    OUTPUT_VARIABLE GCC_MACHINE)

  string(REGEX MATCH "([a-zA-Z0-9])+" GCC_MACHINE ${GCC_MACHINE})

  if (${GCC_MACHINE} MATCHES "x86.*" OR ${GCC_MACHINE} MATCHES "i.86.*")
    set(CEN64_ARCH_DIR "x86_64")

    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maccumulate-outgoing-args")

    if (${GCC_MACHINE} MATCHES "i.86.*")
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffixed-xmm5 -ffixed-xmm6 -ffixed-xmm7")
    else ()
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffixed-xmm13 -ffixed-xmm14 -ffixed-xmm15")
    endif()

    if (NOT NATIVE_BUILD)
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mssse3")
    endif (NOT NATIVE_BUILD)

    include_directories(${PROJECT_SOURCE_DIR}/os/unix/x86_64)
  endif (${GCC_MACHINE} MATCHES "x86.*" OR ${GCC_MACHINE} MATCHES "i.86.*")

  if (${GCC_MACHINE} STREQUAL "arm")
    set(CEN64_ARCH_DIR "arm")

    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mfloat-abi=hard -mfpu=neon")
    include_directories(${PROJECT_SOURCE_DIR}/os/unix/arm)
  endif (${GCC_MACHINE} STREQUAL "arm")

  # Set architecture-independent flags.
  set(CMAKE_C_FLAGS_DEBUG "-ggdb3 -g3 -O0")
  set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG -s")
  set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG -s")
  set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Og")
  set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")

  # Enable link time optimization on recent versions.
  execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
    OUTPUT_VARIABLE GCC_VERSION)

  if (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)
    set(GCC_FLTO_FLAGS "-flto -flto-partition=none -fdata-sections -ffunction-sections")
    set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${GCC_FLTO_FLAGS}")
    set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${GCC_FLTO_FLAGS}")
    set(CMAKE_EXE_LINKER_FLAGS_RELEASE ${CMAKE_EXE_LINKER_FLAGS_RELEASE} "-Wl,--gc-sections")
    set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL ${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} "-Wl,--gc-sections")
  endif (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6)

  # Enable "unsafe" loop optimizations on recent versions.
  if (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
    set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -funsafe-loop-optimizations")
    set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -funsafe-loop-optimizations")
  endif (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)

    # When compiling with -flto, need to pass CFLAGS to the linker.

  # Check for undefined behaviour when debugging.
  if (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
{'fraction_non_alphanumeric': 0.11668991166899116, 'fraction_numerical': 0.021075468774213544, 'mean_word_length': 5.0374181478016835, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2702986', 'n_tokens_mistral': 2802, 'n_tokens_neox': 2496, 'n_words': 499}