<commit_before># This file is released under terms of BSD license
# See LICENSE file for more information

# This CMakeLists.txt file is the entry point for the configuration and the
# compilation of the CLAW Compiler.

cmake_minimum_required(VERSION 3.0)

project("CLAW Compiler" VERSION 2.0.1)

# Add local cmake modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/module")

# Enable needed modules and languages
enable_language(Fortran)
enable_testing()
find_package(Ant 1.7.1 REQUIRED)
find_package(Java 1.8 REQUIRED)
include(ExternalProject)
include(cmake/git.cmake)
include(cmake/omni_compiler.cmake)

# Load all variables from file
include(properties.cmake)

set(OMNI_COMPILER_SUBMODULE ${CMAKE_SOURCE_DIR}/omni-compiler)

if(OFFLINE)
  message(STATUS "CLAW Compiler offline compilation enabled")
endif()

# Recover commit hash for the top repositiory
git_get_rev_hash(${CMAKE_SOURCE_DIR} CLAWFC_GIT_HASH)
message(STATUS "CLAW Compiler version ${CLAWFC_GIT_HASH}")

# Recover commit hash for the OMNI Compiler subumodule
git_get_rev_hash(${OMNI_COMPILER_SUBMODULE} OMNI_GIT_HASH)
message(STATUS "OMNI Compiler version ${OMNI_GIT_HASH}")

# Set the default install directory
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  set(
    CMAKE_INSTALL_PREFIX "/usr/local"
    CACHE PATH "default install path" FORCE
  )
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

# Set ant to be verbose
if(ANT_VERBOSE)
  set(ANT_FLAGS "-v")
endif()

# Define preprocessor information used in the driver and tests
# The driver uses preprocessed files only but the tests compile the code.
if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Cray")
  include(compiler/cray.cmake)
elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "PGI")
  include(compiler/pgi.cmake)
elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel")
  include(compiler/intel.cmake)
else()
  include(compiler/gnu.cmake)
endif()

message(
  STATUS
  "Configure preprocessor with ${CMAKE_Fortran_COMPILER_ID} compiler"
)

# Option to build OMNI Compiler as a submodule. Should be ON as CLAW uses a
# specific version of OMNI Compiler at the moment.
option(BUILD_OMNI "Build OMNI Compiler" ON)
option(OMNI_ENABLE_GNU_INTRINSIC "OMNI Compiler - Enable GNU intrinsic extensions" ON)

if(OMNI_ENABLE_GNU_INTRINSIC)
  list(APPEND OMNI_CONF_OPTION "--enable-gnu-extension")
endif()

# Build OMNI compiler
if(BUILD_OMNI)
  ExternalProject_Add(
    omni-compiler
    SOURCE_DIR ${OMNI_COMPILER_SUBMODULE}
    CONFIGURE_COMMAND
      touch
        ${OMNI_COMPILER_SUBMODULE}/configure.ac
        ${OMNI_COMPILER_SUBMODULE}/aclocal.m4
        ${OMNI_COMPILER_SUBMODULE}/configure
        ${OMNI_COMPILER_SUBMODULE}/Makefile.am
        ${OMNI_COMPILER_SUBMODULE}/Makefile.in
      && CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER}
      FC=${CMAKE_Fortran_COMPILER} JAVAC=${Java_JAVAC_EXECUTABLE}
      ${OMNI_COMPILER_SUBMODULE}/configure
      --prefix=${CMAKE_INSTALL_PREFIX} ${OMNI_TARGET} ${OMNI_CONF_OPTION}
      ${OMNI_MPI_CC} ${OMNI_MPI_FC}
    BUILD_COMMAND make -j 1 # Not safe yet with -j
    BUILD_IN_SOURCE 1
  )
endif()

# translator library and xcodeml manipulation library
add_subdirectory(cx2t)

# compiler driver
add_subdirectory(driver)
<commit_msg>ADD: possibility to use CMAKE_C_FLAGS=" "<commit_after># This file is released under terms of BSD license
# See LICENSE file for more information

# This CMakeLists.txt file is the entry point for the configuration and the
# compilation of the CLAW Compiler.

cmake_minimum_required(VERSION 3.0)

project("CLAW Compiler" VERSION 2.0.1)

# Add local cmake modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/module")

# Enable needed modules and languages
enable_language(Fortran)
enable_testing()
find_package(Ant 1.7.1 REQUIRED)
find_package(Java 1.8 REQUIRED)
include(ExternalProject)
include(cmake/git.cmake)
include(cmake/omni_compiler.cmake)

# Load all variables from file
include(properties.cmake)

set(OMNI_COMPILER_SUBMODULE ${CMAKE_SOURCE_DIR}/omni-compiler)

if(OFFLINE)
  message(STATUS "CLAW Compiler offline compilation enabled")
endif()

# Recover commit hash for the top repositiory
git_get_rev_hash(${CMAKE_SOURCE_DIR} CLAWFC_GIT_HASH)
message(STATUS "CLAW Compiler version ${CLAWFC_GIT_HASH}")

# Recover commit hash for the OMNI Compiler subumodule
git_get_rev_hash(${OMNI_COMPILER_SUBMODULE} OMNI_GIT_HASH)
message(STATUS "OMNI Compiler version ${OMNI_GIT_HASH}")

# Set the default install directory
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  set(
    CMAKE_INSTALL_PREFIX "/usr/local"
    CACHE PATH "default install path" FORCE
  )
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

# Set ant to be verbose
if(ANT_VERBOSE)
  set(ANT_FLAGS "-v")
endif()

# Define preprocessor information used in the driver and tests
# The driver uses preprocessed files only but the tests compile the code.
if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Cray")
  include(compiler/cray.cmake)
elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "PGI")
  include(compiler/pgi.cmake)
elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel")
  include(compiler/intel.cmake)
else()
  include(compiler/gnu.cmake)
endif()

message(
  STATUS
  "Configure preprocessor with ${CMAKE_Fortran_COMPILER_ID} compiler"
)

# Option to build OMNI Compiler as a submodule. Should be ON as CLAW uses a
# specific version of OMNI Compiler at the moment.
option(BUILD_OMNI "Build OMNI Compiler" ON)
option(OMNI_ENABLE_GNU_INTRINSIC "OMNI Compiler - Enable GNU intrinsic extensions" ON)

if(OMNI_ENABLE_GNU_INTRINSIC)
  list(APPEND OMNI_CONF_OPTION "--enable-gnu-extension")
endif()

# Build OMNI compiler
if(BUILD_OMNI)
  ExternalProject_Add(
    omni-compiler
    SOURCE_DIR ${OMNI_COMPILER_SUBMODULE}
    CONFIGURE_COMMAND
      touch
        ${OMNI_COMPILER_SUBMODULE}/configure.ac
        ${OMNI_COMPILER_SUBMODULE}/aclocal.m4
        ${OMNI_COMPILER_SUBMODULE}/configure
        ${OMNI_COMPILER_SUBMODULE}/Makefile.am
        ${OMNI_COMPILER_SUBMODULE}/Makefile.in
      && CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER}
      FC=${CMAKE_Fortran_COMPILER} JAVAC=${Java_JAVAC_EXECUTABLE}
      ${OMNI_COMPILER_SUBMODULE}/configure
      CFLAGS=${CMAKE_C_FLAGS}
      --prefix=${CMAKE_INSTALL_PREFIX} ${OMNI_TARGET} ${OMNI_CONF_OPTION}
      ${OMNI_MPI_CC} ${OMNI_MPI_FC}
    BUILD_COMMAND make -j 1 # Not safe yet with -j
    BUILD_IN_SOURCE 1
  )
endif()

# translator library and xcodeml manipulation library
add_subdirectory(cx2t)

# compiler driver
add_subdirectory(driver)

{'fraction_non_alphanumeric': 0.08839779005524862, 'fraction_numerical': 0.004297114794352364, 'mean_word_length': 5.616243654822335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1721812', 'n_tokens_mistral': 2390, 'n_tokens_neox': 2243, 'n_words': 532}