<commit_before>cmake_minimum_required(VERSION 2.4)
project(cppa CXX)

# Prohibit in-source builds.
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
    message(FATAL_ERROR "In-source builds are not allowed. Please use "
                        "./configure to choose a build directory and "
                        "initialize the build configuration.")
endif ()

set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})

set(CMAKE_CXX_FLAGS                "-std=c++11 -Wextra -Wall -pedantic")
set(CMAKE_CXX_FLAGS_DEBUG          "-O0 -g")
set(CMAKE_CXX_FLAGS_MINSIZEREL     "-Os")
set(CMAKE_CXX_FLAGS_RELEASE        "-O4")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
if (ENABLE_DEBUG)
    set(CMAKE_BUILD_TYPE Debug)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCPPA_DEBUG")
else ()
    set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif ()

if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
    execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
                    OUTPUT_VARIABLE GCC_VERSION)
    if (NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
        message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.7 or greater.")
    endif ()
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
else()
    message(FATAL_ERROR "Your C++ compiler does not support C++11.")
endif ()

set(LIBCPPA_SRC
    src/abstract_tuple.cpp
    src/actor.cpp
    src/actor_count.cpp
    src/actor_proxy.cpp
    src/actor_proxy_cache.cpp
    src/actor_registry.cpp
    src/addressed_message.cpp
    src/any_tuple.cpp
    src/atom.cpp
    src/attachable.cpp
    src/behavior_stack.cpp
    src/binary_deserializer.cpp
    src/binary_serializer.cpp
    src/channel.cpp
    src/thread_mapped_actor.cpp
    src/demangle.cpp
    src/deserializer.cpp
    src/duration.cpp
    src/empty_tuple.cpp
    src/event_based_actor.cpp
    src/exception.cpp
    src/factory.cpp
    src/fiber.cpp
    src/group.cpp
    src/group_manager.cpp
    src/local_actor.cpp
    src/mailman.cpp
    src/native_socket.cpp
    src/network_manager.cpp
    src/object.cpp
    src/object_array.cpp
    src/partial_function.cpp
    src/pattern.cpp
    src/post_office.cpp
    src/primitive_variant.cpp
    src/process_information.cpp
    src/receive.cpp
    src/ripemd_160.cpp
    src/scheduled_actor.cpp
    src/scheduled_actor_dummy.cpp
    src/scheduler.cpp
    src/self.cpp
    src/serializer.cpp
    src/shared_spinlock.cpp
    src/singleton_manager.cpp
    src/string_serialization.cpp
    src/thread_pool_scheduler.cpp
    src/to_uniform_name.cpp
    src/unicast_network.cpp
    src/uniform_type_info.cpp
    src/yield_interface.cpp
    src/context_switching_actor.cpp
)

set(boost_context third_party/boost_context/)

# add third_party boost_context sources
if(APPLE)
  if(CMAKE_SIZEOF_VOID_P EQUAL 4)
    set_property(SOURCE
                 ${boost_context}/src/asm/fcontext_i386_sysv_macho_gas.S
                 PROPERTY LANGUAGE CXX)
    set(fcontext_asm ${boost_context}/src/asm/fcontext_i386_sysv_macho_gas.S)
  else()
    set_property(SOURCE
                 ${boost_context}/src/asm/fcontext_x86_64_sysv_macho_gas.S
                 PROPERTY LANGUAGE CXX)
    set(fcontext_asm ${boost_context}/src/asm/fcontext_x86_64_sysv_macho_gas.S)
  endif()
  set(LIBCPPA_SRC
      ${LIBCPPA_SRC}
      ${boost_context}/src/stack_utils_posix.cpp
      ${boost_context}/src/stack_allocator_posix.cpp
      ${boost_context}/src/fcontext.cpp
      ${fcontext_asm}
  )
elseif(UNIX)
  if(CMAKE_SIZEOF_VOID_P EQUAL 4)
    set_property(SOURCE
                 ${boost_context}/src/asm/fcontext_i386_sysv_elf_gas.S
                 PROPERTY LANGUAGE CXX)
    set(fcontext_asm ${boost_context}/src/asm/fcontext_i386_sysv_elf_gas.S)
  else()
    set_property(SOURCE
                 ${boost_context}/src/asm/fcontext_x86_64_sysv_elf_gas.S
                 PROPERTY LANGUAGE CXX)
    set(fcontext_asm ${boost_context}/src/asm/fcontext_x86_64_sysv_elf_gas.S)
  endif()
  set(LIBCPPA_SRC
      ${LIBCPPA_SRC}
      ${fcontext_asm}
      ${boost_context}/src/stack_utils_posix.cpp
      ${boost_context}/src/stack_allocator_posix.cpp
      ${boost_context}/src/fcontext.cpp
  )
endif()

find_package(Boost COMPONENTS thread REQUIRED)

link_directories(${Boost_LIBRARY_DIRS})
include_directories(. ${Boost_INCLUDE_DIRS} ${boost_context}/include)

add_library(libcppa SHARED ${LIBCPPA_SRC})

target_link_libraries(libcppa ${CMAKE_LD_LIBS} ${Boost_THREAD_LIBRARY})

set(LIBCPPA_VERSION_MAJOR 0)
set(LIBCPPA_VERSION_MINOR 2)
set(LIBCPPA_VERSION_PATCH 0)
set(LIBRARY_VERSION ${LIBCPPA_VERSION_MAJOR}.${LIBCPPA_VERSION_MINOR}.${LIBCPPA_VERSION_PATCH})
set(LIBRARY_SOVERSION ${LIBCPPA_VERSION_MAJOR})

set_target_properties(libcppa PROPERTIES SOVERSION ${LIBRARY_SOVERSION} VERSION ${LIBRARY_VERSION} OUTPUT_NAME cppa)
install(TARGETS libcppa LIBRARY DESTINATION lib)

# install includes
install(DIRECTORY cppa/ DESTINATION include/cppa
    FILES_MATCHING PATTERN "*.hpp")

# uninstall target
configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
    "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
    IMMEDIATE @ONLY)<commit_msg>reduced redundancy for  selection of platform dependent ASM file<commit_after>cmake_minimum_required(VERSION 2.4)
project(cppa CXX)

# Prohibit in-source builds.
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
    message(FATAL_ERROR "In-source builds are not allowed. Please use "
                        "./configure to choose a build directory and "
                        "initialize the build configuration.")
endif ()

set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})

set(CMAKE_CXX_FLAGS                "-std=c++11 -Wextra -Wall -pedantic")
set(CMAKE_CXX_FLAGS_DEBUG          "-O0 -g")
set(CMAKE_CXX_FLAGS_MINSIZEREL     "-Os")
set(CMAKE_CXX_FLAGS_RELEASE        "-O4")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
if (ENABLE_DEBUG)
    set(CMAKE_BUILD_TYPE Debug)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCPPA_DEBUG")
else ()
    set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif ()

if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
    execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
                    OUTPUT_VARIABLE GCC_VERSION)
    if (NOT (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7))
        message(FATAL_ERROR "${PROJECT_NAME} requires g++ 4.7 or greater.")
    endif ()
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
else()
    message(FATAL_ERROR "Your C++ compiler does not support C++11.")
endif ()

set(LIBCPPA_SRC
    src/abstract_tuple.cpp
    src/actor.cpp
    src/actor_count.cpp
    src/actor_proxy.cpp
    src/actor_proxy_cache.cpp
    src/actor_registry.cpp
    src/addressed_message.cpp
    src/any_tuple.cpp
    src/atom.cpp
    src/attachable.cpp
    src/behavior_stack.cpp
    src/binary_deserializer.cpp
    src/binary_serializer.cpp
    src/channel.cpp
    src/thread_mapped_actor.cpp
    src/demangle.cpp
    src/deserializer.cpp
    src/duration.cpp
    src/empty_tuple.cpp
    src/event_based_actor.cpp
    src/exception.cpp
    src/factory.cpp
    src/fiber.cpp
    src/group.cpp
    src/group_manager.cpp
    src/local_actor.cpp
    src/mailman.cpp
    src/native_socket.cpp
    src/network_manager.cpp
    src/object.cpp
    src/object_array.cpp
    src/partial_function.cpp
    src/pattern.cpp
    src/post_office.cpp
    src/primitive_variant.cpp
    src/process_information.cpp
    src/receive.cpp
    src/ripemd_160.cpp
    src/scheduled_actor.cpp
    src/scheduled_actor_dummy.cpp
    src/scheduler.cpp
    src/self.cpp
    src/serializer.cpp
    src/shared_spinlock.cpp
    src/singleton_manager.cpp
    src/string_serialization.cpp
    src/thread_pool_scheduler.cpp
    src/to_uniform_name.cpp
    src/unicast_network.cpp
    src/uniform_type_info.cpp
    src/yield_interface.cpp
    src/context_switching_actor.cpp
)

set(boost_context third_party/boost_context)

# add third party Boost.Context sources
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
  if(APPLE)
    set(fcontext_asm ${boost_context}/src/asm/fcontext_i386_sysv_macho_gas.S)
  else()
    set(fcontext_asm ${boost_context}/src/asm/fcontext_i386_sysv_elf_gas.S)
  endif()
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
  if(APPLE)
    set(fcontext_asm ${boost_context}/src/asm/fcontext_x86_64_sysv_macho_gas.S)
  else()
    set(fcontext_asm ${boost_context}/src/asm/fcontext_x86_64_sysv_elf_gas.S)
  endif()
else()
  message(FATAL_ERROR "Unsupported platform (neither 32 nor 64 bit)")
endif()

set_property(SOURCE ${fcontext_asm} PROPERTY LANGUAGE CXX)
set(LIBCPPA_SRC
    ${LIBCPPA_SRC}
    ${fcontext_asm}
    ${boost_context}/src/stack_utils_posix.cpp
    ${boost_context}/src/stack_allocator_posix.cpp
    ${boost_context}/src/fcontext.cpp
)

find_package(Boost COMPONENTS thread REQUIRED)

link_directories(${Boost_LIBRARY_DIRS})
include_directories(. ${Boost_INCLUDE_DIRS} ${boost_context}/include)

add_library(libcppa SHARED ${LIBCPPA_SRC})

target_link_libraries(libcppa ${CMAKE_LD_LIBS} ${Boost_THREAD_LIBRARY})

set(LIBCPPA_VERSION_MAJOR 0)
set(LIBCPPA_VERSION_MINOR 2)
set(LIBCPPA_VERSION_PATCH 0)
set(LIBRARY_VERSION ${LIBCPPA_VERSION_MAJOR}.${LIBCPPA_VERSION_MINOR}.${LIBCPPA_VERSION_PATCH})
set(LIBRARY_SOVERSION ${LIBCPPA_VERSION_MAJOR})

set_target_properties(libcppa PROPERTIES SOVERSION ${LIBRARY_SOVERSION} VERSION ${LIBRARY_VERSION} OUTPUT_NAME cppa)
install(TARGETS libcppa LIBRARY DESTINATION lib)

# install includes
install(DIRECTORY cppa/ DESTINATION include/cppa
    FILES_MATCHING PATTERN "*.hpp")

# uninstall target
configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
    "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
    IMMEDIATE @ONLY)
{'fraction_non_alphanumeric': 0.09863771381747413, 'fraction_numerical': 0.009423332991908225, 'mean_word_length': 3.906532663316583, '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': '2678393', 'n_tokens_mistral': 3766, 'n_tokens_neox': 3597, 'n_words': 528}