<commit_before>#=============================================================================
#
# CMake configuration file for all Chrono libraries, demos, and tests.
#
#=============================================================================

#-----------------------------------------------------------------------------
# Optionally enable building the various programs
#-----------------------------------------------------------------------------

option(BUILD_DEMOS "Build demo programs" ON)
option(BUILD_BENCHMARKING "Build benchmark tests" OFF)

#-----------------------------------------------------------------------------
# Search prefixes specified by <PackageName>_ROOT
#-----------------------------------------------------------------------------
if (POLICY CMP0074)
  cmake_policy(SET CMP0074 NEW)
endif()

#-----------------------------------------------------------------------------
# Collect compiler flags required to build the Chrono libraries
#-----------------------------------------------------------------------------

set(CH_C_FLAGS "${CMAKE_C_FLAGS}")
set(CH_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

#-----------------------------------------------------------------------------
# Enable C++11 support.  Check for C++14 support
#-----------------------------------------------------------------------------

# Allow user to enforce strict C++11 standard
option(CH_ENFORCE_CXX11 "Enforce strict C++11 standard" OFF)

find_package(ModernCXX)

if (CH_ENFORCE_CXX11)
  set(CH_CXX_FLAGS "${CH_CXX_FLAGS} ${CMAKE_CXX11_STANDARD_COMPILE_OPTION}")
else()
  set(CH_CXX_FLAGS "${CH_CXX_FLAGS} ${CMAKE_CXX14_STANDARD_COMPILE_OPTION}")
endif()

# This is a hack -- look for a more robust solution
set(CH_CXX14 FALSE)

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
  message(STATUS "GCC version:  ${CMAKE_CXX_COMPILER_VERSION}")
  if(NOT CH_ENFORCE_CXX11 AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9.9)
    set(CH_CXX14 TRUE)
  endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  message(STATUS "Clang version:  ${CMAKE_CXX_COMPILER_VERSION}")
  if(NOT CH_ENFORCE_Cxx11 AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.4)
    set(CH_CXX14 TRUE)
  endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
  message(STATUS "Visual Studio version:  ${MSVC_VERSION}")
  if(NOT CH_ENFORCE_CXX11 AND MSVC_VERSION GREATER 1800)
    set(CH_CXX14 TRUE)
  endif()
endif()
message(STATUS "Compiler supports C++14:  ${CH_CXX14}")

# cmake/FindModernCXX.cmake behaves strangely with PGI compilers, don't trust it
if (CMAKE_CXX_COMPILER_ID MATCHES "PGI")
  set(CH_CXX_FLAGS "")
  message(STATUS "PGI version: ${CMAKE_CXX_COMPILER_VERSION}")
  if(NOT CH_ENFORCE_CXX11 AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.4)
    message(STATUS "CMAKE_CXX14_STANDARD_COMPILE_OPTION can't be trusted for PGI, manually adding C++14 support")
    set(CH_CXX14 TRUE)
    set(CH_CXX_FLAGS "-std=c++14")
  endif()
endif()

#-----------------------------------------------------------------------------
# Threads and OpenMP support
#-----------------------------------------------------------------------------

message(STATUS "Searching for Threads...")
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads)

message(STATUS "  Thread library:      ${CMAKE_THREAD_LIBS_INIT}")
message(STATUS "  Using Win32 threads? ${CMAKE_USE_WIN32_THREADS_INIT}")
message(STATUS "  Using pthreads?      ${CMAKE_USE_PTHREADS_INIT}")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
set(CH_CXX_FLAGS "${CH_CXX_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
set(CH_C_FLAGS "${CH_C_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")

# We always look for OpenMP (which is required for the PARALLEL module).
# However, we allow the user to optionally disable OpenMP support in the
# main ChronoEngine library, regardless on whether or not OpenMP is found.

message(STATUS "Searching for OpenMP...")
find_package("OpenMP")

# Determine OpenMP version. Prepare substitution variables that can be used in
# generating configuration header files.

if(OPENMP_FOUND)
  include(CheckOpenMPVersion)
  message(STATUS "  OpenMP version:   ${OMP_VERSION}")
  set(CHRONO_OMP_FOUND "#define CHRONO_OMP_FOUND")
  set(CHRONO_OMP_VERSION "#define CHRONO_OMP_VERSION \"${OMP_VERSION}\"")
  if(OMP_20)
    set(CHRONO_OMP_20 "#define CHRONO_OMP_20")
  else()
    set(CHRONO_OMP_20 "")
  endif()
  if(OMP_30)
    set(CHRONO_OMP_30 "#define CHRONO_OMP_30")
  else()
    set(CHRONO_OMP_30 "")
  endif()
  if(OMP_40)
    set(CHRONO_OMP_40 "#define CHRONO_OMP_40")
  else()
    set(CHRONO_OMP_40 "")
  endif()
else()
  message(STATUS "  OpenMP not found")
endif()

# Provide an option (dependent on OPENMP_FOUND) for the user to disable OpenMP
# support in the Chrono libraries (note that some modules may override this).

cmake_dependent_option(ENABLE_OPENMP "Enable OpenMP support in Chrono::Engine" ON
                       "OPENMP_FOUND" OFF)

set(OPENMP_INCLUDE_DIR "")
set(OPENMP_LIBRARIES "")
if(ENABLE_OPENMP)
  message(STATUS "  OpenMP CXX flags: ${OpenMP_CXX_FLAGS}")
  message(STATUS "  OpenMP C flags:   ${OpenMP_C_FLAGS}")
  message(STATUS "  OpenMP includes:  ${OpenMP_CXX_INCLUDE_DIRS}")
  message(STATUS "  OpenMP library:   ${OpenMP_CXX_LIBRARY}")
  message(STATUS "  OpenMP libraries: ${OpenMP_CXX_LIBRARIES}")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  set(CH_CXX_FLAGS "${CH_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  set(CH_C_FLAGS "${CH_C_FLAGS} ${OpenMP_C_FLAGS}")
  set(OPENMP_INCLUDE_DIR "${OpenMP_CXX_INCLUDE_DIRS}")
  set(OPENMP_LIBRARIES "${OpenMP_CXX_LIBRARIES}")
else()
	# As an alternative, if TBB is located the Multicore module will use it for all thrust calls
	find_package("TBB")
	cmake_dependent_option(ENABLE_TBB "Enable TBB support in Chrono::Engine" ON "TBB_FOUND" OFF)
endif()

#-----------------------------------------------------------------------------
# SSE / AVX / FMA / NEON support
#-----------------------------------------------------------------------------

option(USE_SIMD "Enable use of SIMD if supported (SSE, AVX, NEON)" ON)

if(USE_SIMD)

   # Figure out SIMD level support
   message(STATUS "Seaching for SSE...")
   find_package(SSE)
   
   # Set substitution variables for configuration file
   if(SSE_FOUND)
     set(CHRONO_HAS_SSE "#define CHRONO_HAS_SSE")
     set(CHRONO_SSE_LEVEL "#define CHRONO_SSE_LEVEL \"${SSE_VERSION}\"")
     if(DETECTED_SSE_10)
       set(CHRONO_SSE_1_0 "#define CHRONO_SSE_1_0")
     endif()
     if(DETECTED_SSE_20)
       set(CHRONO_SSE_2_0 "#define CHRONO_SSE_2_0")
     endif()
     if(DETECTED_SSE_30)
       set(CHRONO_SSE_3_0 "#define CHRONO_SSE_3_0")
     endif()
     if(DETECTED_SSE_41)
       set(CHRONO_SSE_4_1 "#define CHRONO_SSE_4_1")
     endif()
     if(DETECTED_SSE_42)
       set(CHRONO_SSE_4_2 "#define CHRONO_SSE_4_2")
     endif()
   endif()
   
   # Figure out AVX level support
   message(STATUS "Searching for AVX...")
   find_package(AVX)
   
   # Set substitution variables for configuration file
   if(AVX_FOUND)
     set(CHRONO_HAS_AVX "#define CHRONO_HAS_AVX")
     set(CHRONO_AVX_LEVEL "#define CHRONO_AVX_LEVEL \"${AVX_VERSION}\"")
     if(DETECTED_AVX_10)
       set(CHRONO_AVX_1_0 "#define CHRONO_AVX_1_0")
     endif()
     if(DETECTED_AVX_20)
       set(CHRONO_AVX_2_0 "#define CHRONO_AVX_2_0")
     endif()
   endif()

   # Figure out FMA level support
   message(STATUS "Searching for FMA...")
   find_package(FMA)
   
   # Set substitution variables for configuration file
   if(FMA_FOUND)
     set(CHRONO_HAS_FMA "#define CHRONO_HAS_FMA")
   endif()
   
   # Add SSE, AVX, and FMA flags to Chrono compiler flags
   # Note that these flags are already added to CMake compiler flags
   set(CH_CXX_FLAGS "${CH_CXX_FLAGS} ${SSE_FLAGS} ${AVX_FLAGS} ${FMA_FLAGS}")
   set(CH_C_FLAGS "${CH_C_FLAGS} ${SSE_FLAGS} ${AVX_FLAGS} ${FMA_FLAGS}")
   
   # Check if the system has NEON support
   message(STATUS "Searching for NEON...")
   find_package(NEON)
   
   # Set substitution variables for configuration file.
   if (NEON_FOUND)
     set (CHRONO_HAS_NEON "#define CHRONO_HAS_NEON")
   endif()

   # Add NEON flags to Chrono compiler flags
   # Note that these flags are already added to CMake compiler flags
   set(CH_CXX_FLAGS "${CH_CXX_FLAGS} ${NEON_FLAGS}")
   set(CH_C_FLAGS "${CH_C_FLAGS} ${NEON_FLAGS}")

else()

   message(STATUS "SIMD support disabled")

endif() 

message(STATUS "C++ compiler flags: ${CH_CXX_FLAGS}")
message(STATUS "C compile flags:    ${CH_C_FLAGS}")


#-----------------------------------------------------------------------------
# Eigen library
#-----------------------------------------------------------------------------

message(STATUS "Searching for Eigen3...")
find_package(Eigen3 3.3.0)
if(EIGEN3_FOUND)
  message(STATUS "  Eigen3 version: ${EIGEN3_VERSION}")
  message(STATUS "  Eigen3 include directory: ${EIGEN3_INCLUDE_DIR}")
else()
  mark_as_advanced(CLEAR EIGEN3_INCLUDE_DIR)
  mark_as_advanced(FORCE Eigen3_DIR)
  message(FATAL_ERROR "  Eigen3 not found. Specify EIGEN3_INCLUDE_DIR")
endif()

# Fix for VS 2017 15.8 and newer to handle alignment specification with Eigen.
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
	if(MSVC AND ${MSVC_VERSION} GREATER_EQUAL 1915)
	  add_definitions( "-D_ENABLE_EXTENDED_ALIGNED_STORAGE" )
	endif()
endif()

cmake_dependent_option(USE_EIGEN_OPENMP "Compile Chrono with OpenMP support in Eigen" ON "ENABLE_OPENMP" OFF)

if (NOT USE_EIGEN_OPENMP)
  set(CH_CXX_FLAGS "${CH_CXX_FLAGS} -DEIGEN_DONT_PARALLELIZE")
  set(CH_C_FLAGS "${CH_C_FLAGS} -DEIGEN_DONT_PARALLELIZE")
endif()

#-----------------------------------------------------------------------------
# MPI support
#-----------------------------------------------------------------------------

message(STATUS "Searching for MPI...")
find_package(MPI)
message(STATUS "  MPI (C++) found: ${MPI_CXX_FOUND}")
if(MPI_CXX_FOUND)
  message(STATUS "  MPI compiler:      ${MPI_CXX_COMPILER}")
  message(STATUS "  MPI compile flags: ${MPI_CXX_COMPILE_FLAGS}")
  message(STATUS "  MPI include path:  ${MPI_CXX_INCLUDE_PATH}")
  message(STATUS "  MPI link flags:    ${MPI_CXX_LINK_FLAGS}")
  message(STATUS "  MPI libraries:     ${MPI_CXX_LIBRARIES}")
  message(STATUS "")
  message(STATUS "  MPIEXEC:               ${MPIEXEC}")
  message(STATUS "  MPIEXEC_NUMPROC_FLAG:  ${MPIEXEC_NUMPROC_FLAG}")
  message(STATUS "  MPIEXEC_PREFLAGS:      ${MPIEXEC_PREFLAGS}")
  message(STATUS "  MPIEXEC_POSTFLAGS:     ${MPIEXEC_POSTFLAGS}")
endif()

#-----------------------------------------------------------------------------
# CUDA support
#-----------------------------------------------------------------------------

message(STATUS "Searching for CUDA...")

find_package(CUDA QUIET)

if(CUDA_FOUND)
  message(STATUS "  CUDA version:          ${CUDA_VERSION_STRING}")
  message(STATUS "  CUDA toolkit root dir: ${CUDA_TOOLKIT_ROOT_DIR}")
  mark_as_advanced(FORCE CUDA_TOOLKIT_ROOT_DIR)
else()
  message(STATUS "  CUDA not found (consider manually setting CUDA_TOOLKIT_ROOT_DIR)")
  mark_as_advanced(CLEAR CUDA_TOOLKIT_ROOT_DIR)
  mark_as_advanced(FORCE CUDA_USE_STATIC_CUDA_RUNTIME)
endif()

mark_as_advanced(FORCE
    CUDA_BUILD_CUBIN
    CUDA_BUILD_EMULATION
    CUDA_SEPARABLE_COMPILATION
    CUDA_SDK_ROOT_DIR
    CUDA_HOST_COMPILER
    CUDA_rt_LIBRARY)

# Identify the CUDA architecture
if(CUDA_FOUND)

  mark_as_advanced(FORCE CUDA_USE_STATIC_CUDA_RUNTIME)

  set(CUDA_SEPARABLE_COMPILATION OFF)

  if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
    set(CUDA_SEPARABLE_COMPILATION OFF)
  elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    set(CUDA_PROPAGATE_HOST_FLAGS OFF)
    if(${CH_CXX14})
      		set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std c++14")
      		set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler -std=c++14")
    else()
      		set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std c++11")
      		set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler -std=c++11")
    endif()
    set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; --compiler-options -fPIC)
  elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; --compiler-options -fPIC)
  endif()

  include(${CMAKE_SOURCE_DIR}/cmake/FindCudaArch.cmake)
  SELECT_NVCC_ARCH_FLAGS(NVCC_FLAGS_EXTRA)
  list(APPEND CUDA_NVCC_FLAGS ${NVCC_FLAGS_EXTRA})

  message(STATUS "  CUDA compile flags:   ${CUDA_NVCC_FLAGS}")

endif()

#-----------------------------------------------------------------------------

if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
    if(MSVC)
        add_definitions( "-D_CRT_SECURE_NO_DEPRECATE" )  # avoids deprecation warnings
        add_definitions( "-D_SCL_SECURE_NO_DEPRECATE" )  # avoids deprecation warnings
        add_definitions( "-DNOMINMAX" ) # do not use MSVC's min/max macros
        add_definitions( "-MP" ) # perform parallel builds

        set(CH_CXX_FLAGS "${CH_CXX_FLAGS} /Zc:__cplusplus")
    endif(MSVC)

    if(MINGW OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
        set(CH_CXX_FLAGS "${CH_CXX_FLAGS} -D_MINGW -D_WINDOWS")
        set(CH_C_FLAGS "${CH_C_FLAGS} -D_MINGW -D_WINDOWS")
        set(CH_LINKERFLAG_EXE "-Wl,--enable-runtime-pseudo-reloc")
        set(CH_LINKERFLAG_SHARED "-Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc")

        if(CMAKE_SIZEOF_VOID_P MATCHES 8)
            set(CH_CXX_FLAGS "${CH_CXX_FLAGS} -m64")
            set(CH_C_FLAGS "${CH_C_FLAGS} -m64")
        endif()
    endif()
endif()


if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  message("ADDED CLANG FLAG!!!!")
  add_definitions(-Wno-unknown-warning-option -Wno-reorder-ctor -Wno-pragma-pack)<commit_msg>Ignore clang warnings about unused typedefs (triggered by rapidJSON in Release builds)<commit_after>#=============================================================================
#
# CMake configuration file for all Chrono libraries, demos, and tests.
#
#=============================================================================

#-----------------------------------------------------------------------------
# Optionally enable building the various programs
#-----------------------------------------------------------------------------

option(BUILD_DEMOS "Build demo programs" ON)
option(BUILD_BENCHMARKING "Build benchmark tests" OFF)

#-----------------------------------------------------------------------------
# Search prefixes specified by <PackageName>_ROOT
#-----------------------------------------------------------------------------
if (POLICY CMP0074)
  cmake_policy(SET CMP0074 NEW)
endif()

#-----------------------------------------------------------------------------
# Collect compiler flags required to build the Chrono libraries
#-----------------------------------------------------------------------------

set(CH_C_FLAGS "${CMAKE_C_FLAGS}")
set(CH_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

#-----------------------------------------------------------------------------
# Enable C++11 support.  Check for C++14 support
#-----------------------------------------------------------------------------

# Allow user to enforce strict C++11 standard
option(CH_ENFORCE_CXX11 "Enforce strict C++11 standard" OFF)

find_package(ModernCXX)

if (CH_ENFORCE_CXX11)
  set(CH_CXX_FLAGS "${CH_CXX_FLAGS} ${CMAKE_CXX11_STANDARD_COMPILE_OPTION}")
else()
  set(CH_CXX_FLAGS "${CH_CXX_FLAGS} ${CMAKE_CXX14_STANDARD_COMPILE_OPTION}")
endif()

# This is a hack -- look for a more robust solution
set(CH_CXX14 FALSE)

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
  message(STATUS "GCC version:  ${CMAKE_CXX_COMPILER_VERSION}")
  if(NOT CH_ENFORCE_CXX11 AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9.9)
    set(CH_CXX14 TRUE)
  endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  message(STATUS "Clang version:  ${CMAKE_CXX_COMPILER_VERSION}")
  if(NOT CH_ENFORCE_Cxx11 AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.4)
    set(CH_CXX14 TRUE)
  endif()
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
  message(STATUS "Visual Studio version:  ${MSVC_VERSION}")
  if(NOT CH_ENFORCE_CXX11 AND MSVC_VERSION GREATER 1800)
    set(CH_CXX14 TRUE)
  endif()
endif()
message(STATUS "Compiler supports C++14:  ${CH_CXX14}")

# cmake/FindModernCXX.cmake behaves strangely with PGI compilers, don't trust it
if (CMAKE_CXX_COMPILER_ID MATCHES "PGI")
  set(CH_CXX_FLAGS "")
  message(STATUS "PGI version: ${CMAKE_CXX_COMPILER_VERSION}")
  if(NOT CH_ENFORCE_CXX11 AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 17.4)
    message(STATUS "CMAKE_CXX14_STANDARD_COMPILE_OPTION can't be trusted for PGI, manually adding C++14 support")
    set(CH_CXX14 TRUE)
    set(CH_CXX_FLAGS "-std=c++14")
  endif()
endif()

#-----------------------------------------------------------------------------
# Threads and OpenMP support
#-----------------------------------------------------------------------------

message(STATUS "Searching for Threads...")
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads)

message(STATUS "  Thread library:      ${CMAKE_THREAD_LIBS_INIT}")
message(STATUS "  Using Win32 threads? ${CMAKE_USE_WIN32_THREADS_INIT}")
message(STATUS "  Using pthreads?      ${CMAKE_USE_PTHREADS_INIT}")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
set(CH_CXX_FLAGS "${CH_CXX_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
set(CH_C_FLAGS "${CH_C_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")

# We always look for OpenMP (which is required for the PARALLEL module).
# However, we allow the user to optionally disable OpenMP support in the
# main ChronoEngine library, regardless on whether or not OpenMP is found.

message(STATUS "Searching for OpenMP...")
find_package("OpenMP")

# Determine OpenMP version. Prepare substitution variables that can be used in
# generating configuration header files.

if(OPENMP_FOUND)
  include(CheckOpenMPVersion)
  message(STATUS "  OpenMP version:   ${OMP_VERSION}")
  set(CHRONO_OMP_FOUND "#define CHRONO_OMP_FOUND")
  set(CHRONO_OMP_VERSION "#define CHRONO_OMP_VERSION \"${OMP_VERSION}\"")
  if(OMP_20)
    set(CHRONO_OMP_20 "#define CHRONO_OMP_20")
  else()
    set(CHRONO_OMP_20 "")
  endif()
  if(OMP_30)
    set(CHRONO_OMP_30 "#define CHRONO_OMP_30")
  else()
    set(CHRONO_OMP_30 "")
  endif()
  if(OMP_40)
    set(CHRONO_OMP_40 "#define CHRONO_OMP_40")
  else()
    set(CHRONO_OMP_40 "")
  endif()
else()
  message(STATUS "  OpenMP not found")
endif()

# Provide an option (dependent on OPENMP_FOUND) for the user to disable OpenMP
# support in the Chrono libraries (note that some modules may override this).

cmake_dependent_option(ENABLE_OPENMP "Enable OpenMP support in Chrono::Engine" ON
                       "OPENMP_FOUND" OFF)

set(OPENMP_INCLUDE_DIR "")
set(OPENMP_LIBRARIES "")
if(ENABLE_OPENMP)
  message(STATUS "  OpenMP CXX flags: ${OpenMP_CXX_FLAGS}")
  message(STATUS "  OpenMP C flags:   ${OpenMP_C_FLAGS}")
  message(STATUS "  OpenMP includes:  ${OpenMP_CXX_INCLUDE_DIRS}")
  message(STATUS "  OpenMP library:   ${OpenMP_CXX_LIBRARY}")
  message(STATUS "  OpenMP libraries: ${OpenMP_CXX_LIBRARIES}")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
  set(CH_CXX_FLAGS "${CH_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
  set(CH_C_FLAGS "${CH_C_FLAGS} ${OpenMP_C_FLAGS}")
  set(OPENMP_INCLUDE_DIR "${OpenMP_CXX_INCLUDE_DIRS}")
  set(OPENMP_LIBRARIES "${OpenMP_CXX_LIBRARIES}")
else()
	# As an alternative, if TBB is located the Multicore module will use it for all thrust calls
	find_package("TBB")
	cmake_dependent_option(ENABLE_TBB "Enable TBB support in Chrono::Engine" ON "TBB_FOUND" OFF)
endif()

#-----------------------------------------------------------------------------
# SSE / AVX / FMA / NEON support
#-----------------------------------------------------------------------------

option(USE_SIMD "Enable use of SIMD if supported (SSE, AVX, NEON)" ON)

if(USE_SIMD)

   # Figure out SIMD level support
   message(STATUS "Seaching for SSE...")
   find_package(SSE)
   
   # Set substitution variables for configuration file
   if(SSE_FOUND)
     set(CHRONO_HAS_SSE "#define CHRONO_HAS_SSE")
     set(CHRONO_SSE_LEVEL "#define CHRONO_SSE_LEVEL \"${SSE_VERSION}\"")
     if(DETECTED_SSE_10)
       set(CHRONO_SSE_1_0 "#define CHRONO_SSE_1_0")
     endif()
     if(DETECTED_SSE_20)
       set(CHRONO_SSE_2_0 "#define CHRONO_SSE_2_0")
     endif()
     if(DETECTED_SSE_30)
       set(CHRONO_SSE_3_0 "#define CHRONO_SSE_3_0")
     endif()
     if(DETECTED_SSE_41)
       set(CHRONO_SSE_4_1 "#define CHRONO_SSE_4_1")
     endif()
     if(DETECTED_SSE_42)
       set(CHRONO_SSE_4_2 "#define CHRONO_SSE_4_2")
     endif()
   endif()
   
   # Figure out AVX level support
   message(STATUS "Searching for AVX...")
   find_package(AVX)
   
   # Set substitution variables for configuration file
   if(AVX_FOUND)
     set(CHRONO_HAS_AVX "#define CHRONO_HAS_AVX")
     set(CHRONO_AVX_LEVEL "#define CHRONO_AVX_LEVEL \"${AVX_VERSION}\"")
     if(DETECTED_AVX_10)
       set(CHRONO_AVX_1_0 "#define CHRONO_AVX_1_0")
     endif()
     if(DETECTED_AVX_20)
       set(CHRONO_AVX_2_0 "#define CHRONO_AVX_2_0")
     endif()
   endif()

   # Figure out FMA level support
   message(STATUS "Searching for FMA...")
   find_package(FMA)
   
   # Set substitution variables for configuration file
   if(FMA_FOUND)
     set(CHRONO_HAS_FMA "#define CHRONO_HAS_FMA")
   endif()
   
   # Add SSE, AVX, and FMA flags to Chrono compiler flags
   # Note that these flags are already added to CMake compiler flags
   set(CH_CXX_FLAGS "${CH_CXX_FLAGS} ${SSE_FLAGS} ${AVX_FLAGS} ${FMA_FLAGS}")
   set(CH_C_FLAGS "${CH_C_FLAGS} ${SSE_FLAGS} ${AVX_FLAGS} ${FMA_FLAGS}")
   
   # Check if the system has NEON support
   message(STATUS "Searching for NEON...")
   find_package(NEON)
   
   # Set substitution variables for configuration file.
   if (NEON_FOUND)
     set (CHRONO_HAS_NEON "#define CHRONO_HAS_NEON")
   endif()

   # Add NEON flags to Chrono compiler flags
   # Note that these flags are already added to CMake compiler flags
   set(CH_CXX_FLAGS "${CH_CXX_FLAGS} ${NEON_FLAGS}")
   set(CH_C_FLAGS "${CH_C_FLAGS} ${NEON_FLAGS}")

else()

   message(STATUS "SIMD support disabled")

endif() 

message(STATUS "C++ compiler flags: ${CH_CXX_FLAGS}")
message(STATUS "C compile flags:    ${CH_C_FLAGS}")


#-----------------------------------------------------------------------------
# Eigen library
#-----------------------------------------------------------------------------

message(STATUS "Searching for Eigen3...")
find_package(Eigen3 3.3.0)
if(EIGEN3_FOUND)
  message(STATUS "  Eigen3 version: ${EIGEN3_VERSION}")
  message(STATUS "  Eigen3 include directory: ${EIGEN3_INCLUDE_DIR}")
else()
  mark_as_advanced(CLEAR EIGEN3_INCLUDE_DIR)
  mark_as_advanced(FORCE Eigen3_DIR)
  message(FATAL_ERROR "  Eigen3 not found. Specify EIGEN3_INCLUDE_DIR")
endif()

# Fix for VS 2017 15.8 and newer to handle alignment specification with Eigen.
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
	if(MSVC AND ${MSVC_VERSION} GREATER_EQUAL 1915)
	  add_definitions( "-D_ENABLE_EXTENDED_ALIGNED_STORAGE" )
	endif()
endif()

cmake_dependent_option(USE_EIGEN_OPENMP "Compile Chrono with OpenMP support in Eigen" ON "ENABLE_OPENMP" OFF)

if (NOT USE_EIGEN_OPENMP)
  set(CH_CXX_FLAGS "${CH_CXX_FLAGS} -DEIGEN_DONT_PARALLELIZE")
  set(CH_C_FLAGS "${CH_C_FLAGS} -DEIGEN_DONT_PARALLELIZE")
endif()

#-----------------------------------------------------------------------------
# MPI support
#-----------------------------------------------------------------------------

message(STATUS "Searching for MPI...")
find_package(MPI)
message(STATUS "  MPI (C++) found: ${MPI_CXX_FOUND}")
if(MPI_CXX_FOUND)
  message(STATUS "  MPI compiler:      ${MPI_CXX_COMPILER}")
  message(STATUS "  MPI compile flags: ${MPI_CXX_COMPILE_FLAGS}")
  message(STATUS "  MPI include path:  ${MPI_CXX_INCLUDE_PATH}")
  message(STATUS "  MPI link flags:    ${MPI_CXX_LINK_FLAGS}")
  message(STATUS "  MPI libraries:     ${MPI_CXX_LIBRARIES}")
  message(STATUS "")
  message(STATUS "  MPIEXEC:               ${MPIEXEC}")
  message(STATUS "  MPIEXEC_NUMPROC_FLAG:  ${MPIEXEC_NUMPROC_FLAG}")
  message(STATUS "  MPIEXEC_PREFLAGS:      ${MPIEXEC_PREFLAGS}")
  message(STATUS "  MPIEXEC_POSTFLAGS:     ${MPIEXEC_POSTFLAGS}")
endif()

#-----------------------------------------------------------------------------
# CUDA support
#-----------------------------------------------------------------------------

message(STATUS "Searching for CUDA...")

find_package(CUDA QUIET)

if(CUDA_FOUND)
  message(STATUS "  CUDA version:          ${CUDA_VERSION_STRING}")
  message(STATUS "  CUDA toolkit root dir: ${CUDA_TOOLKIT_ROOT_DIR}")
  mark_as_advanced(FORCE CUDA_TOOLKIT_ROOT_DIR)
else()
  message(STATUS "  CUDA not found (consider manually setting CUDA_TOOLKIT_ROOT_DIR)")
  mark_as_advanced(CLEAR CUDA_TOOLKIT_ROOT_DIR)
  mark_as_advanced(FORCE CUDA_USE_STATIC_CUDA_RUNTIME)
endif()

mark_as_advanced(FORCE
    CUDA_BUILD_CUBIN
    CUDA_BUILD_EMULATION
    CUDA_SEPARABLE_COMPILATION
    CUDA_SDK_ROOT_DIR
    CUDA_HOST_COMPILER
    CUDA_rt_LIBRARY)

# Identify the CUDA architecture
if(CUDA_FOUND)

  mark_as_advanced(FORCE CUDA_USE_STATIC_CUDA_RUNTIME)

  set(CUDA_SEPARABLE_COMPILATION OFF)

  if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
    set(CUDA_SEPARABLE_COMPILATION OFF)
  elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    set(CUDA_PROPAGATE_HOST_FLAGS OFF)
    if(${CH_CXX14})
      		set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std c++14")
      		set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler -std=c++14")
    else()
      		set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std c++11")
      		set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Xcompiler -std=c++11")
    endif()
    set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; --compiler-options -fPIC)
  elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
    set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; --compiler-options -fPIC)
  endif()

  include(${CMAKE_SOURCE_DIR}/cmake/FindCudaArch.cmake)
  SELECT_NVCC_ARCH_FLAGS(NVCC_FLAGS_EXTRA)
  list(APPEND CUDA_NVCC_FLAGS ${NVCC_FLAGS_EXTRA})

  message(STATUS "  CUDA compile flags:   ${CUDA_NVCC_FLAGS}")

endif()

#-----------------------------------------------------------------------------

if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
    if(MSVC)
        add_definitions( "-D_CRT_SECURE_NO_DEPRECATE" )  # avoids deprecation warnings
        add_definitions( "-D_SCL_SECURE_NO_DEPRECATE" )  # avoids deprecation warnings
        add_definitions( "-DNOMINMAX" ) # do not use MSVC's min/max macros
        add_definitions( "-MP" ) # perform parallel builds

        set(CH_CXX_FLAGS "${CH_CXX_FLAGS} /Zc:__cplusplus")
    endif(MSVC)

    if(MINGW OR CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
        set(CH_CXX_FLAGS "${CH_CXX_FLAGS} -D_MINGW -D_WINDOWS")
        set(CH_C_FLAGS "${CH_C_FLAGS} -D_MINGW -D_WINDOWS")
        set(CH_LINKERFLAG_EXE "-Wl,--enable-runtime-pseudo-reloc")
        set(CH_LINKERFLAG_SHARED "-Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc")

        if(CMAKE_SIZEOF_VOID_P MATCHES 8)
            set(CH_CXX_FLAGS "${CH_CXX_FLAGS} -m64")
            set(CH_C_FLAGS "${CH_C_FLAGS} -m64")
        endif()
    endif()
endif()


if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_definitions(-Wno-unknown-warning-option -Wno-reorder-ctor -Wno-pragma-pack -Wno-unused-local-typedef)
{'fraction_non_alphanumeric': 0.2148453157453631, 'fraction_numerical': 0.012680829355391174, 'mean_word_length': 2.8982954545454547, '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': '2803740', 'n_tokens_mistral': 10069, 'n_tokens_neox': 9323, 'n_words': 1896}