<commit_before>##
# Copyright (c) 2010 <NAME>, All rights reserved.
#               2011 <NAME> <<EMAIL>>
#
# This file is freely distributable without licensing fees and
# is provided without guarantee or warrantee expressed or implied.
# This file is -not- in the public domain.
##

include(ParseArguments)
include(PurpleInstallPDB)
include(PurpleExpandLibraries)
include(PurplePrecompileHeaders)

function(PURPLE_ADD_LIBRARY NAME)
  string(TOUPPER ${NAME} UPPER_NAME)

  set(ARG_NAMES
    SOURCES
    HEADERS
    HEADERS_PREFIX
    LINK_LIBRARIES
    INCLUDE_ALL_HEADER
    PRECOMPILE_HEADERS
    )

  set(OPTION_NAMES
    EXCLUDE_FROM_ALL
    SHARED
    STATIC
    #FRAMEWORK
    )

  parse_arguments(THIS "${ARG_NAMES}" "${OPTION_NAMES}" ${ARGN})
  string(REGEX MATCH "^[a-z]+" SHORT_NAME ${THIS_HEADERS_PREFIX})

  if(MSVC OR XCODE_VERSION)
    set(THIS_DEFINITIONS ${UPPER_NAME}_DSO_NAME=\"${CMAKE_SHARED_LIBRARY_PREFIX}${NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}\")
  else()
    if(APPLE)
      set(THIS_DEFINITIONS ${UPPER_NAME}_DSO_NAME=\"${CMAKE_SHARED_LIBRARY_PREFIX}${NAME}.${VERSION_ABI}${CMAKE_SHARED_LIBRARY_SUFFIX}\")
    else()
      set(THIS_DEFINITIONS ${UPPER_NAME}_DSO_NAME=\"${CMAKE_SHARED_LIBRARY_PREFIX}${NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}.${VERSION_ABI}\")
    endif()
  endif()

  if(THIS_PRECOMPILE_HEADERS)
    purple_pch_prepare(${NAME} THIS_SOURCES ${THIS_PRECOMPILE_HEADERS})
  endif(THIS_PRECOMPILE_HEADERS)

  if(THIS_INCLUDE_ALL_HEADER)
    purple_include_all_header(${THIS_INCLUDE_ALL_HEADER}
      ${THIS_HEADERS_PREFIX} ${THIS_HEADERS})
  endif(THIS_INCLUDE_ALL_HEADER)

  if(NOT THIS_SHARED AND NOT THIS_STATIC)
    set(THIS_SHARED ON)
    set(THIS_STATIC ON)
  endif(NOT THIS_SHARED AND NOT THIS_STATIC)

  if(THIS_EXCLUDE_FROM_ALL)
    set(THIS_EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL)
  else()
    unset(THIS_EXCLUDE_FROM_ALL)
  endif()

  set(THIS_TARGETS)

  if(THIS_SHARED)
    set(THIS_TARGET lib_${NAME}_shared)
    list(APPEND THIS_TARGETS ${THIS_TARGET})
    list(APPEND THIS_DEFINITIONS ${UPPER_NAME}_SHARED)

    add_library(${THIS_TARGET} SHARED ${THIS_EXCLUDE_FROM_ALL} ${THIS_HEADERS} ${THIS_SOURCES})
    purple_expand_libraries(LINK_LIBRARIES ${THIS_LINK_LIBRARIES})
    target_link_libraries(${THIS_TARGET} ${LINK_LIBRARIES})
    set_target_properties(${THIS_TARGET} PROPERTIES
      OUTPUT_NAME ${NAME}
      VERSION ${VERSION} SOVERSION ${VERSION_ABI}
      COMPILE_DEFINITIONS "${THIS_DEFINITIONS}"
      SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
      LINK_LIBRARIES "${THIS_LINK_LIBRARIES}"
      FOLDER "Libraries" PROJECT_LABEL "${NAME}"
      )

    if(NOT THIS_EXCLUDE_FROM_ALL)
      purple_install_pdb(${THIS_TARGET} DESTINATION bin COMPONENT ${SHORT_NAME}dev)
    endif(NOT THIS_EXCLUDE_FROM_ALL)
  endif(THIS_SHARED)

  if(THIS_STATIC)
    set(THIS_TARGET lib_${NAME}_static)
    list(APPEND THIS_TARGETS ${THIS_TARGET})
    list(APPEND THIS_DEFINITIONS ${UPPER_NAME}_STATIC)

    add_library(${THIS_TARGET} STATIC ${THIS_EXCLUDE_FROM_ALL} ${THIS_HEADERS} ${THIS_SOURCES})
    set_target_properties(${THIS_TARGET} PROPERTIES
      OUTPUT_NAME ${NAME}
      VERSION ${VERSION} SOVERSION ${VERSION_ABI}
      COMPILE_DEFINITIONS "${THIS_DEFINITIONS}"
      SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
      LINK_LIBRARIES "${THIS_LINK_LIBRARIES}"
      PREFIX lib
      )
  endif(THIS_STATIC)

  if(THIS_PRECOMPILE_HEADERS)
    purple_pch_use(${NAME} ${THIS_TARGETS})
  endif(THIS_PRECOMPILE_HEADERS)

  if(NOT THIS_EXCLUDE_FROM_ALL)
    set_property (GLOBAL APPEND PROPERTY ALL_TARGETS ${THIS_TARGETS})
  endif()

  foreach(HEADER ${THIS_HEADERS})
    string(REGEX MATCH "(.*)[/\\]" DIR ${HEADER})
    install(FILES ${HEADER}
      DESTINATION include/${THIS_HEADERS_PREFIX}/${DIR} COMPONENT ${SHORT_NAME}dev)
    #set_property(SOURCE ${HEADER} PROPERTY MACOSX_PACKAGE_LOCATION Headers/${DIR})
  endforeach(HEADER ${THIS_HEADERS})

  if(NOT THIS_EXCLUDE_FROM_ALL)
    install(TARGETS ${THIS_TARGETS}
      ARCHIVE DESTINATION ${LIBRARY_DIR} COMPONENT ${SHORT_NAME}dev
      RUNTIME DESTINATION bin COMPONENT ${SHORT_NAME}lib
      LIBRARY DESTINATION ${LIBRARY_DIR} COMPONENT ${SHORT_NAME}lib
      )
  endif(NOT THIS_EXCLUDE_FROM_ALL)
endfunction(PURPLE_ADD_LIBRARY NAME)
<commit_msg>Remove prefixing of install components, obsoleted by Collage separation<commit_after>##
# Copyright (c) 2010 <NAME>, All rights reserved.
#               2011 <NAME> <<EMAIL>>
#
# This file is freely distributable without licensing fees and
# is provided without guarantee or warrantee expressed or implied.
# This file is -not- in the public domain.
##

include(ParseArguments)
include(PurpleInstallPDB)
include(PurpleExpandLibraries)
include(PurplePrecompileHeaders)

function(PURPLE_ADD_LIBRARY NAME)
  string(TOUPPER ${NAME} UPPER_NAME)

  set(ARG_NAMES
    SOURCES
    HEADERS
    HEADERS_PREFIX
    LINK_LIBRARIES
    INCLUDE_ALL_HEADER
    PRECOMPILE_HEADERS
    )

  set(OPTION_NAMES
    EXCLUDE_FROM_ALL
    SHARED
    STATIC
    #FRAMEWORK
    )

  parse_arguments(THIS "${ARG_NAMES}" "${OPTION_NAMES}" ${ARGN})

  if(MSVC OR XCODE_VERSION)
    set(THIS_DEFINITIONS ${UPPER_NAME}_DSO_NAME=\"${CMAKE_SHARED_LIBRARY_PREFIX}${NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}\")
  else()
    if(APPLE)
      set(THIS_DEFINITIONS ${UPPER_NAME}_DSO_NAME=\"${CMAKE_SHARED_LIBRARY_PREFIX}${NAME}.${VERSION_ABI}${CMAKE_SHARED_LIBRARY_SUFFIX}\")
    else()
      set(THIS_DEFINITIONS ${UPPER_NAME}_DSO_NAME=\"${CMAKE_SHARED_LIBRARY_PREFIX}${NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}.${VERSION_ABI}\")
    endif()
  endif()

  if(THIS_PRECOMPILE_HEADERS)
    purple_pch_prepare(${NAME} THIS_SOURCES ${THIS_PRECOMPILE_HEADERS})
  endif(THIS_PRECOMPILE_HEADERS)

  if(THIS_INCLUDE_ALL_HEADER)
    purple_include_all_header(${THIS_INCLUDE_ALL_HEADER}
      ${THIS_HEADERS_PREFIX} ${THIS_HEADERS})
  endif(THIS_INCLUDE_ALL_HEADER)

  if(NOT THIS_SHARED AND NOT THIS_STATIC)
    set(THIS_SHARED ON)
    set(THIS_STATIC ON)
  endif(NOT THIS_SHARED AND NOT THIS_STATIC)

  if(THIS_EXCLUDE_FROM_ALL)
    set(THIS_EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL)
  else()
    unset(THIS_EXCLUDE_FROM_ALL)
  endif()

  set(THIS_TARGETS)

  if(THIS_SHARED)
    set(THIS_TARGET lib_${NAME}_shared)
    list(APPEND THIS_TARGETS ${THIS_TARGET})
    list(APPEND THIS_DEFINITIONS ${UPPER_NAME}_SHARED)

    add_library(${THIS_TARGET} SHARED ${THIS_EXCLUDE_FROM_ALL} ${THIS_HEADERS} ${THIS_SOURCES})
    purple_expand_libraries(LINK_LIBRARIES ${THIS_LINK_LIBRARIES})
    target_link_libraries(${THIS_TARGET} ${LINK_LIBRARIES})
    set_target_properties(${THIS_TARGET} PROPERTIES
      OUTPUT_NAME ${NAME}
      VERSION ${VERSION} SOVERSION ${VERSION_ABI}
      COMPILE_DEFINITIONS "${THIS_DEFINITIONS}"
      SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
      LINK_LIBRARIES "${THIS_LINK_LIBRARIES}"
      FOLDER "Libraries" PROJECT_LABEL "${NAME}"
      )
    if(NOT THIS_EXCLUDE_FROM_ALL)
      purple_install_pdb(${THIS_TARGET} DESTINATION bin COMPONENT dev)
    endif(NOT THIS_EXCLUDE_FROM_ALL)
  endif(THIS_SHARED)

  if(THIS_STATIC)
    set(THIS_TARGET lib_${NAME}_static)
    list(APPEND THIS_TARGETS ${THIS_TARGET})
    list(APPEND THIS_DEFINITIONS ${UPPER_NAME}_STATIC)

    add_library(${THIS_TARGET} STATIC ${THIS_EXCLUDE_FROM_ALL} ${THIS_HEADERS} ${THIS_SOURCES})
    set_target_properties(${THIS_TARGET} PROPERTIES
      OUTPUT_NAME ${NAME}
      VERSION ${VERSION} SOVERSION ${VERSION_ABI}
      COMPILE_DEFINITIONS "${THIS_DEFINITIONS}"
      SOURCE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
      LINK_LIBRARIES "${THIS_LINK_LIBRARIES}"
      PREFIX lib
      )
  endif(THIS_STATIC)

  if(THIS_PRECOMPILE_HEADERS)
    purple_pch_use(${NAME} ${THIS_TARGETS})
  endif(THIS_PRECOMPILE_HEADERS)

  if(NOT THIS_EXCLUDE_FROM_ALL)
    set_property (GLOBAL APPEND PROPERTY ALL_TARGETS ${THIS_TARGETS})
  endif()

  foreach(HEADER ${THIS_HEADERS})
    string(REGEX MATCH "(.*)[/\\]" DIR ${HEADER})
    install(FILES ${HEADER}
      DESTINATION include/${THIS_HEADERS_PREFIX}/${DIR} COMPONENT dev)
    #set_property(SOURCE ${HEADER} PROPERTY MACOSX_PACKAGE_LOCATION Headers/${DIR})
  endforeach(HEADER ${THIS_HEADERS})

  if(NOT THIS_EXCLUDE_FROM_ALL)
    install(TARGETS ${THIS_TARGETS}
      ARCHIVE DESTINATION ${LIBRARY_DIR} COMPONENT dev
      RUNTIME DESTINATION bin COMPONENT lib
      LIBRARY DESTINATION ${LIBRARY_DIR} COMPONENT lib
      )
  endif(NOT THIS_EXCLUDE_FROM_ALL)
endfunction(PURPLE_ADD_LIBRARY NAME)

{'fraction_non_alphanumeric': 0.10403800475059383, 'fraction_numerical': 0.0019002375296912114, 'mean_word_length': 5.210176991150442, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3061812', 'n_tokens_mistral': 3368, 'n_tokens_neox': 3041, 'n_words': 491}