<commit_before>#
# Common setup
#

# an encourage to out of source builds 
INCLUDE(OutOfSourcesBuild)

INCLUDE(SiconosVersion)

# misc tools
INCLUDE(SiconosTools)

MACRO(SICONOS_PROJECT 
    _PROJECT_NAME)
  
  # Build options
  # Static and shared libs : defaults
  OPTION(BUILD_SHARED_LIBS "Building of shared libraries" ON)
  OPTION(BUILD_STATIC_LIBS "Building of static libraries" OFF)
  OPTION(WITH_TESTS_COVERAGE "Code coverage setup" OFF)
  OPTION(WITH_GIT "Consider sources are under GIT" OFF)
  OPTION(WITH_DEFAULT_BUILD_TYPE "Use a default build type (Release)" ON)
  OPTION(WITH_DOCUMENTATION "Build doxygen documentation with 'make doc'" OFF)
  OPTION(WITH_TESTING "Enable 'make test' target" ON)
  OPTION(WITH_TIMERS "Enable timers" OFF)
  OPTION(WITH_MUMPS "Compilation with MUMPS solver" OFF)
  OPTION(WITH_FCLIB "link with fclib when this mode is enable. Default = off." OFF)
  OPTION(WITH_SYSTEM_INFO "Print some CMake variables. Default = off." OFF)
  OPTION(WITH_CPACK "Configuration for cpack. Default = on." ON)
  OPTION(WITH_DOXYGEN_WARNINGS "Explore doxygen warnings." ON) # ON for developpers, OFF for distributed version
  OPTION(FUCK_DOXYGEN "At your convenience." OFF) 
  OPTION(DEV_MODE "Developer mode." ON)

  IF(FUCK_DOXYGEN OR NOT DEV_MODE)
    SET(WITH_DOXYGEN_WARNINGS OFF)
  ENDIF(FUCK_DOXYGEN OR NOT DEV_MODE)

  # get system architecture 
  # https://raw.github.com/petroules/solar-cmake/master/TargetArch.cmake
  INCLUDE(TargetArch)
  TARGET_ARCHITECTURE(SYSTEM_ARCHITECTURE)

  # some informations
  IF(WITH_SYSTEM_INFO)
    INCLUDE(CMakePrintSystemInformation)
    MESSAGE(STATUS "SYSTEM ARCHITECTURE: ${SYSTEM_ARCHITECTURE}")
  ENDIF(WITH_SYSTEM_INFO)

  # features summary
  INCLUDE(FeatureSummary)

  # Build type
  IF(WITH_DEFAULT_BUILD_TYPE)
    IF(NOT CMAKE_BUILD_TYPE)
      SET(CMAKE_BUILD_TYPE "Release")
    ENDIF(NOT CMAKE_BUILD_TYPE)
  ENDIF(WITH_DEFAULT_BUILD_TYPE)

  # Project version
  STRING(TOLOWER ${_PROJECT_NAME} _LPROJECT_NAME)
  
  SET(PROJECT_SHORT_NAME ${_PROJECT_NAME})
  
  SET(PROJECT_PACKAGE_NAME "siconos-${_LPROJECT_NAME}")

  # Install lib directory 32, 64 etc. on Fedora, Debian 
  # http://public.kitware.com/Bug/view.php?id=11964
  INCLUDE(GNUInstallDirs)
  ASSERT(CMAKE_INSTALL_LIBDIR)

  # PACKAGE PROJECT SETUP
  PROJECT(${PROJECT_PACKAGE_NAME})

  SET(VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")  
  
  # get git update command
  IF(WITH_GIT)
    FIND_PACKAGE(Git)
    MESSAGE(STATUS "git executable : ${GIT_EXECUTABLE}")
    MESSAGE(STATUS "git command : ${GITCOMMAND}")
    MESSAGE(STATUS "git update options : ${GIT_UPDATE_OPTIONS}")

    SET(CTEST_GIT_COMMAND "${GIT_EXECUTABLE}" )
    SET(UPDATE_COMMAND "${GITCOMMAND}")
    SET(UPDATE_OPTIONS "${GIT_UPDATE_OPTIONS}")

    EXECUTE_PROCESS(COMMAND 
      ${GIT_EXECUTABLE} log -n 1 --pretty=format:%h 
      OUTPUT_VARIABLE SOURCE_ABBREV_GIT_SHA1
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})

    EXECUTE_PROCESS(COMMAND 
      ${GIT_EXECUTABLE} log -n 1 --pretty=format:%H
      OUTPUT_VARIABLE SOURCE_GIT_SHA1
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
  ENDIF()
  # Some macros needed to check compilers environment
  INCLUDE(CheckSymbolExists)
  INCLUDE(CheckFunctionExists)
  INCLUDE(CheckIncludeFileCXX)
  INCLUDE(CheckIncludeFile)
  INCLUDE(CheckStructHasMember)

  # Get c compiler version (cf FindBoost.cmake version 2.8.7)
  IF(CMAKE_C_COMPILER)
    EXEC_PROGRAM(${CMAKE_C_COMPILER}
      ARGS -dumpversion
      OUTPUT_VARIABLE C_COMPILER_VERSION)
  ENDIF(CMAKE_C_COMPILER)

  # Get fortran compiler version (cf FindBoost.cmake version 2.8.7)
  IF(CMAKE_Fortran_COMPILER)
    EXEC_PROGRAM(${CMAKE_Fortran_COMPILER}
      ARGS -dumpversion
      OUTPUT_VARIABLE Fortran_COMPILER_VERSION)
  ENDIF(CMAKE_Fortran_COMPILER)

  # Get cxx compiler version (cf FindBoost.cmake version 2.8.7)
  IF(CMAKE_CXX_COMPILER)
    EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
      ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
      OUTPUT_VARIABLE CXX_COMPILER_VERSION)
  ENDIF(CMAKE_CXX_COMPILER)

  # check some headers
  IF(CMAKE_SYSTEM_NAME MATCHES Windows)
    CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_sec pthread.h HAVE_TIME_H)
  ELSE(CMAKE_SYSTEM_NAME MATCHES Windows)
    CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_sec time.h HAVE_TIME_H)
  ENDIF(CMAKE_SYSTEM_NAME MATCHES Windows)
  CHECK_FUNCTION_EXISTS(gettimeofday HAVE_SYSTIMES_H)
  IF(MSVC)
    SET(BUILD_AS_CPP TRUE)
  ENDIF(MSVC)

  # Link external lib statically. This comes handy when we want to distribute
  # Siconos on Mac or Windows
  # TODO complete this for other lib (gmp, boost, ...)
  IF(CROSSCOMPILING_LINUX_TO_WINDOWS)
    OPTION(LINK_STATICALLY "Link external libraries statically (on if crosscompiling from linux to windows)" ON)
  ENDIF(CROSSCOMPILING_LINUX_TO_WINDOWS)
  IF(LINK_STATICALLY)
    SET(Boost_USE_STATIC_LIBS TRUE)
    # For the compiler<commit_msg>[cmake] Add flags for MSVC directly in SiconosProject<commit_after>#
# Common setup
#

# an encourage to out of source builds 
INCLUDE(OutOfSourcesBuild)

INCLUDE(SiconosVersion)

# misc tools
INCLUDE(SiconosTools)

MACRO(SICONOS_PROJECT 
    _PROJECT_NAME)
  
  # Build options
  # Static and shared libs : defaults
  OPTION(BUILD_SHARED_LIBS "Building of shared libraries" ON)
  OPTION(BUILD_STATIC_LIBS "Building of static libraries" OFF)
  OPTION(WITH_TESTS_COVERAGE "Code coverage setup" OFF)
  OPTION(WITH_GIT "Consider sources are under GIT" OFF)
  OPTION(WITH_DEFAULT_BUILD_TYPE "Use a default build type (Release)" ON)
  OPTION(WITH_DOCUMENTATION "Build doxygen documentation with 'make doc'" OFF)
  OPTION(WITH_TESTING "Enable 'make test' target" ON)
  OPTION(WITH_TIMERS "Enable timers" OFF)
  OPTION(WITH_MUMPS "Compilation with MUMPS solver" OFF)
  OPTION(WITH_FCLIB "link with fclib when this mode is enable. Default = off." OFF)
  OPTION(WITH_SYSTEM_INFO "Print some CMake variables. Default = off." OFF)
  OPTION(WITH_CPACK "Configuration for cpack. Default = on." ON)
  OPTION(WITH_DOXYGEN_WARNINGS "Explore doxygen warnings." ON) # ON for developpers, OFF for distributed version
  OPTION(FUCK_DOXYGEN "At your convenience." OFF) 
  OPTION(DEV_MODE "Developer mode." ON)

  IF(FUCK_DOXYGEN OR NOT DEV_MODE)
    SET(WITH_DOXYGEN_WARNINGS OFF)
  ENDIF(FUCK_DOXYGEN OR NOT DEV_MODE)

  # get system architecture 
  # https://raw.github.com/petroules/solar-cmake/master/TargetArch.cmake
  INCLUDE(TargetArch)
  TARGET_ARCHITECTURE(SYSTEM_ARCHITECTURE)

  # some informations
  IF(WITH_SYSTEM_INFO)
    INCLUDE(CMakePrintSystemInformation)
    MESSAGE(STATUS "SYSTEM ARCHITECTURE: ${SYSTEM_ARCHITECTURE}")
  ENDIF(WITH_SYSTEM_INFO)

  # features summary
  INCLUDE(FeatureSummary)

  # Build type
  IF(WITH_DEFAULT_BUILD_TYPE)
    IF(NOT CMAKE_BUILD_TYPE)
      SET(CMAKE_BUILD_TYPE "Release")
    ENDIF(NOT CMAKE_BUILD_TYPE)
  ENDIF(WITH_DEFAULT_BUILD_TYPE)

  # Project version
  STRING(TOLOWER ${_PROJECT_NAME} _LPROJECT_NAME)
  
  SET(PROJECT_SHORT_NAME ${_PROJECT_NAME})
  
  SET(PROJECT_PACKAGE_NAME "siconos-${_LPROJECT_NAME}")

  # Install lib directory 32, 64 etc. on Fedora, Debian 
  # http://public.kitware.com/Bug/view.php?id=11964
  INCLUDE(GNUInstallDirs)
  ASSERT(CMAKE_INSTALL_LIBDIR)

  # PACKAGE PROJECT SETUP
  PROJECT(${PROJECT_PACKAGE_NAME})

  SET(VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")  
  
  # get git update command
  IF(WITH_GIT)
    FIND_PACKAGE(Git)
    MESSAGE(STATUS "git executable : ${GIT_EXECUTABLE}")
    MESSAGE(STATUS "git command : ${GITCOMMAND}")
    MESSAGE(STATUS "git update options : ${GIT_UPDATE_OPTIONS}")

    SET(CTEST_GIT_COMMAND "${GIT_EXECUTABLE}" )
    SET(UPDATE_COMMAND "${GITCOMMAND}")
    SET(UPDATE_OPTIONS "${GIT_UPDATE_OPTIONS}")

    EXECUTE_PROCESS(COMMAND 
      ${GIT_EXECUTABLE} log -n 1 --pretty=format:%h 
      OUTPUT_VARIABLE SOURCE_ABBREV_GIT_SHA1
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})

    EXECUTE_PROCESS(COMMAND 
      ${GIT_EXECUTABLE} log -n 1 --pretty=format:%H
      OUTPUT_VARIABLE SOURCE_GIT_SHA1
      WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
  ENDIF()
  # Some macros needed to check compilers environment
  INCLUDE(CheckSymbolExists)
  INCLUDE(CheckFunctionExists)
  INCLUDE(CheckIncludeFileCXX)
  INCLUDE(CheckIncludeFile)
  INCLUDE(CheckStructHasMember)

  # Get c compiler version (cf FindBoost.cmake version 2.8.7)
  IF(CMAKE_C_COMPILER)
    EXEC_PROGRAM(${CMAKE_C_COMPILER}
      ARGS -dumpversion
      OUTPUT_VARIABLE C_COMPILER_VERSION)
  ENDIF(CMAKE_C_COMPILER)

  # Get fortran compiler version (cf FindBoost.cmake version 2.8.7)
  IF(CMAKE_Fortran_COMPILER)
    EXEC_PROGRAM(${CMAKE_Fortran_COMPILER}
      ARGS -dumpversion
      OUTPUT_VARIABLE Fortran_COMPILER_VERSION)
  ENDIF(CMAKE_Fortran_COMPILER)

  # Get cxx compiler version (cf FindBoost.cmake version 2.8.7)
  IF(CMAKE_CXX_COMPILER)
    EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
      ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
      OUTPUT_VARIABLE CXX_COMPILER_VERSION)
  ENDIF(CMAKE_CXX_COMPILER)

  # check some headers
  IF(CMAKE_SYSTEM_NAME MATCHES Windows)
    CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_sec pthread.h HAVE_TIME_H)
  ELSE(CMAKE_SYSTEM_NAME MATCHES Windows)
    CHECK_STRUCT_HAS_MEMBER("struct timespec" tv_sec time.h HAVE_TIME_H)
  ENDIF(CMAKE_SYSTEM_NAME MATCHES Windows)
  CHECK_FUNCTION_EXISTS(gettimeofday HAVE_SYSTIMES_H)
  IF(MSVC)
    SET(BUILD_AS_CPP TRUE)
    ADD_DEFINITIONS("-DBOOST_ALL_NO_LIB")
    ADD_DEFINITIONS("-DEHsc") # this shoule be define by CMake, see Windows-MSVC.cmake
  ENDIF(MSVC)

  # Link external lib statically. This comes handy when we want to distribute
  # Siconos on Mac or Windows
  # TODO complete this for other lib (gmp, boost, ...)
  IF(CROSSCOMPILING_LINUX_TO_WINDOWS)
    OPTION(LINK_STATICALLY "Link external libraries statically (on if crosscompiling from linux to windows)" ON)
  ENDIF(CROSSCOMPILING_LINUX_TO_WINDOWS)
  IF(LINK_STATICALLY)
    SET(Boost_USE_STATIC_LIBS TRUE)
    # For the compiler
{'fraction_non_alphanumeric': 0.08305681246857717, 'fraction_numerical': 0.004625439919557567, 'mean_word_length': 4.937910447761194, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3610573', 'n_tokens_mistral': 3834, 'n_tokens_neox': 3533, 'n_words': 758}