<commit_before>#
#  For more information, please see: http://software.sci.utah.edu
#
#  The MIT License
#
#  Copyright (c) 2015 Scientific Computing and Imaging Institute,
#  University of Utah.
#
#
#  Permission is hereby granted, free of charge, to any person obtaining a
#  copy of this software and associated documentation files (the "Software"),
#  to deal in the Software without restriction, including without limitation
#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
#  and/or sell copies of the Software, and to permit persons to whom the
#  Software is furnished to do so, subject to the following conditions:
#
#  The above copyright notice and this permission notice shall be included
#  in all copies or substantial portions of the Software.
#
#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
#  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
#  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.
#

SET(SCIRunMain_SOURCES
  scirunMain.cc
)

IF(BUILD_HEADLESS)
  ADD_DEFINITIONS(-DBUILD_HEADLESS)
ENDIF(BUILD_HEADLESS)

ADD_DEFINITIONS(-DAPPLICATION_NAME=${APPLICATION_NAME})

IF(APPLE)
  # TODO: temporary - until testing can be configured with app bundle
  ADD_EXECUTABLE(${TEST_APPLICATION_NAME}
    ${SCIRunMain_SOURCES}
  )

  IF(BUILD_HEADLESS)
    ADD_EXECUTABLE(${APPLICATION_NAME}
      ${SCIRunMain_SOURCES}
    )
  ELSE()
    LIST(APPEND SCIRunMain_SOURCES "${APPLICATION_OSX_ICON_FULL_PATH}")
    SET_SOURCE_FILES_PROPERTIES(${APPLICATION_OSX_ICON_FULL_PATH}
                                PROPERTIES
                                MACOSX_PACKAGE_LOCATION Resources)
    SET(MACOSX_BUNDLE_ICON_FILE "${APPLICATION_OSX_ICON}" )

    ADD_EXECUTABLE(${APPLICATION_NAME} MACOSX_BUNDLE
      ${SCIRunMain_SOURCES}
    )
  ENDIF()

ELSEIF(WIN32)
  # TODO: windows headless mode?

  SET(SCIRunMain_SOURCES ${SCIRunMain_SOURCES} "${APPLICATION_WINDOWS_RC}")
  IF(SCIRUN_SHOW_CONSOLE)
    ADD_DEFINITIONS(-DSCIRUN_SHOW_CONSOLE=1)
  ENDIF()

  ADD_EXECUTABLE(${APPLICATION_NAME} WIN32 ${SCIRunMain_SOURCES})

  # TODO: probably need this for Xcode
  IF(WIN32 AND MSVC)
    # TODO: more build types to be supported?
    # TODO: change $<CONFIGURATION> to $<CONFIG> when upgrading to cmake 3
    ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME}
      POST_BUILD
      COMMAND ${CMAKE_COMMAND}
      ARGS -E copy_directory
      ${SCIRun_BINARY_DIR}/Shaders
      ${SCIRun_BINARY_DIR}/$<CONFIGURATION>/Shaders
    )
    ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME}
      POST_BUILD
      COMMAND ${CMAKE_COMMAND}
      ARGS -E copy_directory
      ${SCIRun_BINARY_DIR}/Fonts
      ${SCIRun_BINARY_DIR}/$<CONFIGURATION>/Fonts
   )
   ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME}
     POST_BUILD
     COMMAND ${CMAKE_COMMAND}
     ARGS -E copy_directory
     ${SCIRun_BINARY_DIR}/Assets
     ${SCIRun_BINARY_DIR}/$<CONFIGURATION>/Assets
    )
  ENDIF()

ELSE()
  ADD_EXECUTABLE(${APPLICATION_NAME} ${SCIRunMain_SOURCES})
ENDIF()

SET(APPS ${APPLICATION_NAME})
IF(APPLE)
  LIST(APPEND APPS ${TEST_APPLICATION_NAME})
ENDIF()

FOREACH(app ${APPS})
  TARGET_LINK_LIBRARIES(${app}
    Core_Util_Legacy
  )

  IF(BUILD_HEADLESS)
    TARGET_LINK_LIBRARIES(${app}
      Core_ConsoleApplication
    )
  ELSE()
    TARGET_LINK_LIBRARIES(${app}
      Interface_Application
    )
  ENDIF()

  IF(BUILD_WITH_PYTHON)
    TARGET_LINK_LIBRARIES(${app}
      Core_Python
    )
  ENDIF()
ENDFOREACH()

OPTION(BUILD_BUNDLE "Build Mac bundle" ON)
MARK_AS_ADVANCED(BUILD_BUNDLE)

IF(BUILD_HEADLESS)
  SET(BUILD_BUNDLE OFF)
ENDIF()

MESSAGE(STATUS "Build Mac bundle: ${BUILD_BUNDLE}")

IF(APPLE AND BUILD_BUNDLE)
  IF(${MACDEPLOYQT} MATCHES "NOTFOUND" OR ${SED} MATCHES "NOTFOUND" OR ${AWK} MATCHES "NOTFOUND")
    SET(BUILD_BUNDLE FALSE)
    MESSAGE(WARNING "macdeployqt, sed and awk are required to build the SCIRun app bundle. Please ensure that all are installed and in your path.")
  ENDIF()
ENDIF()

IF(APPLE)
  IF(BUILD_BUNDLE)
    IF(NOT BUILD_HEADLESS)
      MESSAGE(STATUS "Building Mac OS X bundle")
      SET(APP_PATH "${CMAKE_CFG_INTDIR}/${APPLICATION_NAME}.app/Contents")

      IF(${CMAKE_GENERATOR} MATCHES "Xcode")
        SET(SCIRUN_LIB_DIR ${SCIRun_BINARY_DIR}/lib/$<CONFIGURATION>)
      ELSE()
        SET(SCIRUN_LIB_DIR ${SCIRun_BINARY_DIR}/lib)
      ENDIF()

      # otool can be used to check list of dependent dylibs
      ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME}
        POST_BUILD
        # clean out libraries
        COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${APP_PATH}/Frameworks/*${CMAKE_SHARED_LIBRARY_SUFFIX}
        COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory ${SCIRUN_LIB_DIR} ${APP_PATH}/Frameworks
        WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
      )

      IF(BUILD_WITH_PYTHON)
        SET(VERSION_PATH Versions/${SCI_PYTHON_VERSION_SHORT})
        SET(FRAMEWORK_PATH Frameworks/Python.framework)
        SET(PYTHON_PATH ${APP_PATH}/${FRAMEWORK_PATH}/${VERSION_PATH})
        ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME}
          POST_BUILD
          # macdeployqt puts frameworks in app/Content/Frameworks
          # TODO: when CMake 2.8 support is dropped, and CMP0042 new is enabled, change to @rpath
          COMMAND ${CMAKE_COMMAND} ARGS -E chdir ${APP_PATH}/Frameworks tar xf ${SCI_PYTHON_FRAMEWORK_ARCHIVE}
          COMMAND chmod u+w  ${PYTHON_PATH}/Python
          COMMAND install_name_tool -id Python ${PYTHON_PATH}/Python
          COMMAND install_name_tool -change ${SCI_PYTHON_FRAMEWORK}/${VERSION_PATH}/Python
            @executable_path/../${FRAMEWORK_PATH}/${VERSION_PATH}/Python
            ${APP_PATH}/MacOS/${APPLICATION_NAME}
            WORKING_DIRECTORY ${SCIRun_BINARY_DIR})

        SET(SCIRUN_LIBS "Core_Application"
                        "Core_Application_Preferences"
                        "Core_Python"
                        "SCIRunPythonAPI"
                        "Interface_Application"
                        "Engine_Network"
                        "Interface_Modules_Factory"
                        "Interface_Modules_Render"
                        "Interface_Modules_Python"
                        "Core_ConsoleApplication"
                        "Modules_Factory"
                        "Modules_Python"
        )

        FOREACH(lib ${SCIRUN_LIBS})
          ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME}
            POST_BUILD
            COMMAND install_name_tool -change ${SCI_PYTHON_FRAMEWORK}/${VERSION_PATH}/Python
              @executable_path/../${FRAMEWORK_PATH}/${VERSION_PATH}/Python
              ${APP_PATH}/Frameworks/${CMAKE_SHARED_LIBRARY_PREFIX}${lib}${CMAKE_SHARED_LIBRARY_SUFFIX}
            WORKING_DIRECTORY ${SCIRun_BINARY_DIR})
        ENDFOREACH()
      ENDIF()

      ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME}
        POST_BUILD
        # configure Qt libs
        # Note: macdeployqt also processes SCIRun dynamically linked libraries under the lib directory
        COMMAND ${MACDEPLOYQT} ${APPLICATION_NAME}.app -verbose=${MACDEPLOYQT_OUTPUT_LEVEL}
        COMMAND ${CMAKE_COMMAND} ARGS -E copy ${SCIRun_SOURCE_DIR}/CMake/qt.conf ${APPLICATION_NAME}.app/Contents/Resources
        COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
          ${SCIRun_BINARY_DIR}/Shaders ${APP_PATH}/MacOS/Shaders
        COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
          ${SCIRun_BINARY_DIR}/Assets ${APP_PATH}/MacOS/Assets
        COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
          ${SCIRun_BINARY_DIR}/Fonts ${APP_PATH}/MacOS/Fonts
        WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
      )

      INSTALL(TARGETS ${APPLICATION_NAME} RUNTIME DESTINATION . BUNDLE DESTINATION . )<commit_msg>Add lib to list<commit_after>#
#  For more information, please see: http://software.sci.utah.edu
#
#  The MIT License
#
#  Copyright (c) 2015 Scientific Computing and Imaging Institute,
#  University of Utah.
#
#
#  Permission is hereby granted, free of charge, to any person obtaining a
#  copy of this software and associated documentation files (the "Software"),
#  to deal in the Software without restriction, including without limitation
#  the rights to use, copy, modify, merge, publish, distribute, sublicense,
#  and/or sell copies of the Software, and to permit persons to whom the
#  Software is furnished to do so, subject to the following conditions:
#
#  The above copyright notice and this permission notice shall be included
#  in all copies or substantial portions of the Software.
#
#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
#  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
#  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
#  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
#  DEALINGS IN THE SOFTWARE.
#

SET(SCIRunMain_SOURCES
  scirunMain.cc
)

IF(BUILD_HEADLESS)
  ADD_DEFINITIONS(-DBUILD_HEADLESS)
ENDIF(BUILD_HEADLESS)

ADD_DEFINITIONS(-DAPPLICATION_NAME=${APPLICATION_NAME})

IF(APPLE)
  # TODO: temporary - until testing can be configured with app bundle
  ADD_EXECUTABLE(${TEST_APPLICATION_NAME}
    ${SCIRunMain_SOURCES}
  )

  IF(BUILD_HEADLESS)
    ADD_EXECUTABLE(${APPLICATION_NAME}
      ${SCIRunMain_SOURCES}
    )
  ELSE()
    LIST(APPEND SCIRunMain_SOURCES "${APPLICATION_OSX_ICON_FULL_PATH}")
    SET_SOURCE_FILES_PROPERTIES(${APPLICATION_OSX_ICON_FULL_PATH}
                                PROPERTIES
                                MACOSX_PACKAGE_LOCATION Resources)
    SET(MACOSX_BUNDLE_ICON_FILE "${APPLICATION_OSX_ICON}" )

    ADD_EXECUTABLE(${APPLICATION_NAME} MACOSX_BUNDLE
      ${SCIRunMain_SOURCES}
    )
  ENDIF()

ELSEIF(WIN32)
  # TODO: windows headless mode?

  SET(SCIRunMain_SOURCES ${SCIRunMain_SOURCES} "${APPLICATION_WINDOWS_RC}")
  IF(SCIRUN_SHOW_CONSOLE)
    ADD_DEFINITIONS(-DSCIRUN_SHOW_CONSOLE=1)
  ENDIF()

  ADD_EXECUTABLE(${APPLICATION_NAME} WIN32 ${SCIRunMain_SOURCES})

  # TODO: probably need this for Xcode
  IF(WIN32 AND MSVC)
    # TODO: more build types to be supported?
    # TODO: change $<CONFIGURATION> to $<CONFIG> when upgrading to cmake 3
    ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME}
      POST_BUILD
      COMMAND ${CMAKE_COMMAND}
      ARGS -E copy_directory
      ${SCIRun_BINARY_DIR}/Shaders
      ${SCIRun_BINARY_DIR}/$<CONFIGURATION>/Shaders
    )
    ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME}
      POST_BUILD
      COMMAND ${CMAKE_COMMAND}
      ARGS -E copy_directory
      ${SCIRun_BINARY_DIR}/Fonts
      ${SCIRun_BINARY_DIR}/$<CONFIGURATION>/Fonts
   )
   ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME}
     POST_BUILD
     COMMAND ${CMAKE_COMMAND}
     ARGS -E copy_directory
     ${SCIRun_BINARY_DIR}/Assets
     ${SCIRun_BINARY_DIR}/$<CONFIGURATION>/Assets
    )
  ENDIF()

ELSE()
  ADD_EXECUTABLE(${APPLICATION_NAME} ${SCIRunMain_SOURCES})
ENDIF()

SET(APPS ${APPLICATION_NAME})
IF(APPLE)
  LIST(APPEND APPS ${TEST_APPLICATION_NAME})
ENDIF()

FOREACH(app ${APPS})
  TARGET_LINK_LIBRARIES(${app}
    Core_Util_Legacy
  )

  IF(BUILD_HEADLESS)
    TARGET_LINK_LIBRARIES(${app}
      Core_ConsoleApplication
    )
  ELSE()
    TARGET_LINK_LIBRARIES(${app}
      Interface_Application
    )
  ENDIF()

  IF(BUILD_WITH_PYTHON)
    TARGET_LINK_LIBRARIES(${app}
      Core_Python
    )
  ENDIF()
ENDFOREACH()

OPTION(BUILD_BUNDLE "Build Mac bundle" ON)
MARK_AS_ADVANCED(BUILD_BUNDLE)

IF(BUILD_HEADLESS)
  SET(BUILD_BUNDLE OFF)
ENDIF()

MESSAGE(STATUS "Build Mac bundle: ${BUILD_BUNDLE}")

IF(APPLE AND BUILD_BUNDLE)
  IF(${MACDEPLOYQT} MATCHES "NOTFOUND" OR ${SED} MATCHES "NOTFOUND" OR ${AWK} MATCHES "NOTFOUND")
    SET(BUILD_BUNDLE FALSE)
    MESSAGE(WARNING "macdeployqt, sed and awk are required to build the SCIRun app bundle. Please ensure that all are installed and in your path.")
  ENDIF()
ENDIF()

IF(APPLE)
  IF(BUILD_BUNDLE)
    IF(NOT BUILD_HEADLESS)
      MESSAGE(STATUS "Building Mac OS X bundle")
      SET(APP_PATH "${CMAKE_CFG_INTDIR}/${APPLICATION_NAME}.app/Contents")

      IF(${CMAKE_GENERATOR} MATCHES "Xcode")
        SET(SCIRUN_LIB_DIR ${SCIRun_BINARY_DIR}/lib/$<CONFIGURATION>)
      ELSE()
        SET(SCIRUN_LIB_DIR ${SCIRun_BINARY_DIR}/lib)
      ENDIF()

      # otool can be used to check list of dependent dylibs
      ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME}
        POST_BUILD
        # clean out libraries
        COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${APP_PATH}/Frameworks/*${CMAKE_SHARED_LIBRARY_SUFFIX}
        COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory ${SCIRUN_LIB_DIR} ${APP_PATH}/Frameworks
        WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
      )

      IF(BUILD_WITH_PYTHON)
        SET(VERSION_PATH Versions/${SCI_PYTHON_VERSION_SHORT})
        SET(FRAMEWORK_PATH Frameworks/Python.framework)
        SET(PYTHON_PATH ${APP_PATH}/${FRAMEWORK_PATH}/${VERSION_PATH})
        ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME}
          POST_BUILD
          # macdeployqt puts frameworks in app/Content/Frameworks
          # TODO: when CMake 2.8 support is dropped, and CMP0042 new is enabled, change to @rpath
          COMMAND ${CMAKE_COMMAND} ARGS -E chdir ${APP_PATH}/Frameworks tar xf ${SCI_PYTHON_FRAMEWORK_ARCHIVE}
          COMMAND chmod u+w  ${PYTHON_PATH}/Python
          COMMAND install_name_tool -id Python ${PYTHON_PATH}/Python
          COMMAND install_name_tool -change ${SCI_PYTHON_FRAMEWORK}/${VERSION_PATH}/Python
            @executable_path/../${FRAMEWORK_PATH}/${VERSION_PATH}/Python
            ${APP_PATH}/MacOS/${APPLICATION_NAME}
            WORKING_DIRECTORY ${SCIRun_BINARY_DIR})

        SET(SCIRUN_LIBS "Core_Application"
                        "Core_Application_Preferences"
                        "Core_Python"
                        "SCIRunPythonAPI"
                        "Interface_Application"
                        "Engine_Network"
                        "Interface_Modules_Factory"
                        "Interface_Modules_Render"
                        "Interface_Modules_Python"
                        "Interface_Modules_Visualization"
                        "Core_ConsoleApplication"
                        "Modules_Factory"
                        "Modules_Python"
        )

        FOREACH(lib ${SCIRUN_LIBS})
          ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME}
            POST_BUILD
            COMMAND install_name_tool -change ${SCI_PYTHON_FRAMEWORK}/${VERSION_PATH}/Python
              @executable_path/../${FRAMEWORK_PATH}/${VERSION_PATH}/Python
              ${APP_PATH}/Frameworks/${CMAKE_SHARED_LIBRARY_PREFIX}${lib}${CMAKE_SHARED_LIBRARY_SUFFIX}
            WORKING_DIRECTORY ${SCIRun_BINARY_DIR})
        ENDFOREACH()
      ENDIF()

      ADD_CUSTOM_COMMAND(TARGET ${APPLICATION_NAME}
        POST_BUILD
        # configure Qt libs
        # Note: macdeployqt also processes SCIRun dynamically linked libraries under the lib directory
        COMMAND ${MACDEPLOYQT} ${APPLICATION_NAME}.app -verbose=${MACDEPLOYQT_OUTPUT_LEVEL}
        COMMAND ${CMAKE_COMMAND} ARGS -E copy ${SCIRun_SOURCE_DIR}/CMake/qt.conf ${APPLICATION_NAME}.app/Contents/Resources
        COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
          ${SCIRun_BINARY_DIR}/Shaders ${APP_PATH}/MacOS/Shaders
        COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
          ${SCIRun_BINARY_DIR}/Assets ${APP_PATH}/MacOS/Assets
        COMMAND ${CMAKE_COMMAND} ARGS -E copy_directory
          ${SCIRun_BINARY_DIR}/Fonts ${APP_PATH}/MacOS/Fonts
        WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
      )

      INSTALL(TARGETS ${APPLICATION_NAME} RUNTIME DESTINATION . BUNDLE DESTINATION . )
{'fraction_non_alphanumeric': 0.08903000871622463, 'fraction_numerical': 0.0022413149047441168, 'mean_word_length': 3.293771718791767, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '3479765', 'n_tokens_mistral': 5593, 'n_tokens_neox': 5232, 'n_words': 1140}