<commit_before>cmake_minimum_required(VERSION 3.1)

project(
  bezier
  VERSION 2021.2.12
  LANGUAGES Fortran C)
set(AUTHOR "<NAME>")
set(AUTHOR_DETAILS "<EMAIL>")
set(DESCRIPTION "Library for Bezier curves and triangles.")

option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(TARGET_NATIVE_ARCH "Optimize build for host (native) architecture" ON)

if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$")
  message(FATAL_ERROR "gfortran and ifort are the only supported compilers")
endif()

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Release)
endif()

if(WIN32 AND CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static")

  # Regarding `-Wl,--default-image-base-low`, see
  # - https://github.com/actions/virtual-environments/issues/2721
  # - https://github.com/msys2/MINGW-packages/issues/7023
  # - https://github.com/msys2/MINGW-packages/issues/6986
  # - https://www.msys2.org/news/#2021-01-31-aslr-enabled-by-default
  # - https://sourceware.org/bugzilla/show_bug.cgi?id=26659
  if(CMAKE_SIZEOF_VOID_P EQUAL "8")
    # Only add the flag for 64-bit MinGW `gfortran`
    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--default-image-base-low")
  elseif(NOT CMAKE_SIZEOF_VOID_P EQUAL "4")
    message(FATAL_ERROR "Unexpected pointer size: CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}")
  endif()

  if(NOT CMAKE_IMPORT_LIBRARY_SUFFIX_Fortran)
    set(CMAKE_IMPORT_LIBRARY_SUFFIX_Fortran ".lib")
  endif()
  if(NOT CMAKE_IMPORT_LIBRARY_PREFIX_Fortran)
    set(CMAKE_IMPORT_LIBRARY_PREFIX_Fortran "")
  endif()
  if(NOT CMAKE_SHARED_LIBRARY_PREFIX_Fortran)
    set(CMAKE_SHARED_LIBRARY_PREFIX_Fortran "")
  endif()
endif()

if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release)$")
  message(FATAL_ERROR "Debug and Release are the only supported build types")
endif()

# Unset all Fortran flags (instead rely on our flags).
set(OLD_CMAKE_Fortran_FLAGS ${CMAKE_Fortran_FLAGS})
set(OLD_CMAKE_Fortran_FLAGS_DEBUG ${CMAKE_Fortran_FLAGS_DEBUG})
set(OLD_CMAKE_Fortran_FLAGS_RELEASE ${CMAKE_Fortran_FLAGS_RELEASE})
set(CMAKE_Fortran_FLAGS "")
set(CMAKE_Fortran_FLAGS_DEBUG "")
set(CMAKE_Fortran_FLAGS_RELEASE "")

add_subdirectory(quadpack)

file(GLOB SOURCES *.f90)
add_library(bezier ${SOURCES} $<TARGET_OBJECTS:quadpack>)
unset(SOURCES)

if(${BUILD_SHARED_LIBS})
  set_target_properties(
    bezier PROPERTIES VERSION ${bezier_VERSION} SOVERSION 2021
                      POSITION_INDEPENDENT_CODE ON)
endif()

target_include_directories(bezier PUBLIC $<INSTALL_INTERFACE:include>)

if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
  # ``-Wextra`` includes ``no-compare-reals``, but we have comparisons like
  # ``value == 0.0_dp``.
  target_compile_options(
    bezier
    PRIVATE -fno-second-underscore
            -Wall
            -Wextra
            -Wno-compare-reals
            -Wno-conversion
            -Wimplicit-interface
            -fmax-errors=1
            -std=f2008)
  if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
    target_compile_options(bezier PRIVATE -fcheck=all -fbacktrace
                                          -fimplicit-none -pedantic)
    target_compile_options(bezier PUBLIC -g)
  elseif(CMAKE_BUILD_TYPE MATCHES "^Release$")
    target_compile_options(bezier PRIVATE -Werror)
    if(${TARGET_NATIVE_ARCH})
      target_compile_options(bezier PRIVATE -march=native)
    endif()<commit_msg>Re-ran `cmake-format` on two `CMakeLists.txt`.<commit_after>cmake_minimum_required(VERSION 3.1)

project(
  bezier
  VERSION 2021.2.12
  LANGUAGES Fortran C)
set(AUTHOR "<NAME>")
set(AUTHOR_DETAILS "<EMAIL>")
set(DESCRIPTION "Library for Bezier curves and triangles.")

option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(TARGET_NATIVE_ARCH "Optimize build for host (native) architecture" ON)

if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU|Intel)$")
  message(FATAL_ERROR "gfortran and ifort are the only supported compilers")
endif()

if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Release)
endif()

if(WIN32 AND CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
  set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static")

  # Regarding `-Wl,--default-image-base-low`, see:
  # https://github.com/actions/virtual-environments/issues/2721
  # https://github.com/msys2/MINGW-packages/issues/7023
  # https://github.com/msys2/MINGW-packages/issues/6986
  # https://www.msys2.org/news/#2021-01-31-aslr-enabled-by-default
  # https://sourceware.org/bugzilla/show_bug.cgi?id=26659
  if(CMAKE_SIZEOF_VOID_P EQUAL "8")
    # Only add the flag for 64-bit MinGW `gfortran`
    set(CMAKE_SHARED_LINKER_FLAGS
        "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--default-image-base-low")
  elseif(NOT CMAKE_SIZEOF_VOID_P EQUAL "4")
    message(
      FATAL_ERROR
        "Unexpected pointer size: CMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}")
  endif()

  if(NOT CMAKE_IMPORT_LIBRARY_SUFFIX_Fortran)
    set(CMAKE_IMPORT_LIBRARY_SUFFIX_Fortran ".lib")
  endif()
  if(NOT CMAKE_IMPORT_LIBRARY_PREFIX_Fortran)
    set(CMAKE_IMPORT_LIBRARY_PREFIX_Fortran "")
  endif()
  if(NOT CMAKE_SHARED_LIBRARY_PREFIX_Fortran)
    set(CMAKE_SHARED_LIBRARY_PREFIX_Fortran "")
  endif()
endif()

if(NOT CMAKE_BUILD_TYPE MATCHES "^(Debug|Release)$")
  message(FATAL_ERROR "Debug and Release are the only supported build types")
endif()

# Unset all Fortran flags (instead rely on our flags).
set(OLD_CMAKE_Fortran_FLAGS ${CMAKE_Fortran_FLAGS})
set(OLD_CMAKE_Fortran_FLAGS_DEBUG ${CMAKE_Fortran_FLAGS_DEBUG})
set(OLD_CMAKE_Fortran_FLAGS_RELEASE ${CMAKE_Fortran_FLAGS_RELEASE})
set(CMAKE_Fortran_FLAGS "")
set(CMAKE_Fortran_FLAGS_DEBUG "")
set(CMAKE_Fortran_FLAGS_RELEASE "")

add_subdirectory(quadpack)

file(GLOB SOURCES *.f90)
add_library(bezier ${SOURCES} $<TARGET_OBJECTS:quadpack>)
unset(SOURCES)

if(${BUILD_SHARED_LIBS})
  set_target_properties(
    bezier
    PROPERTIES VERSION ${bezier_VERSION}
               SOVERSION 2021
               POSITION_INDEPENDENT_CODE ON)
endif()

target_include_directories(bezier PUBLIC $<INSTALL_INTERFACE:include>)

if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
  # ``-Wextra`` includes ``no-compare-reals``, but we have comparisons like
  # ``value == 0.0_dp``.
  target_compile_options(
    bezier
    PRIVATE -fno-second-underscore
            -Wall
            -Wextra
            -Wno-compare-reals
            -Wno-conversion
            -Wimplicit-interface
            -fmax-errors=1
            -std=f2008)
  if(CMAKE_BUILD_TYPE MATCHES "^Debug$")
    target_compile_options(bezier PRIVATE -fcheck=all -fbacktrace
                                          -fimplicit-none -pedantic)
    target_compile_options(bezier PUBLIC -g)
  elseif(CMAKE_BUILD_TYPE MATCHES "^Release$")
    target_compile_options(bezier PRIVATE -Werror)
    if(${TARGET_NATIVE_ARCH})
      target_compile_options(bezier PRIVATE -march=native)
    endif()
{'fraction_non_alphanumeric': 0.10807652986709508, 'fraction_numerical': 0.016357528844749527, 'mean_word_length': 4.513687600644122, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 10, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '634214', 'n_tokens_mistral': 2776, 'n_tokens_neox': 2490, 'n_words': 420}