<commit_before># Copyright (c) 2015 Klaralvdalens Datakonsult AB (KDAB).
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.

find_package(Qt5 NO_MODULE REQUIRED COMPONENTS Gui PrintSupport)

#
# Source files.
#

# phantomjs sources.
set(PHANTOMJS_SRCS
  app.cpp
  handler.cpp
  print_handler.cpp
  main.cpp
  debug.cpp
)

if (OS_LINUX)
  LIST(APPEND PHANTOMJS_SRCS
    keyevents_linux.cpp
  )
endif()

qt5_add_resources(PHANTOMJS_SRCS resources.qrc)

#
# Shared configuration.
#

# Target executable names.
set(CEF_TARGET "phantomjs")
if(OS_MACOSX)
  set(CEF_HELPER_TARGET "phantomjs Helper")
endif()

# Logical target used to link the libcef library.
ADD_LOGICAL_TARGET("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}")

# Determine the target output directory.
SET_CEF_TARGET_OUT_DIR()

# Executable target.
add_executable(${CEF_TARGET} ${PHANTOMJS_SRCS})
add_dependencies(${CEF_TARGET} libcef_dll_wrapper)
message(STATUS "${_qt5Core_install_prefix}")
target_link_libraries(${CEF_TARGET}
  libcef_lib
  libcef_dll_wrapper
  ${CEF_STANDARD_LIBS}
  Qt5::Gui
  Qt5::PrintSupport
)

if (OS_WINDOWS)
    if (CMAKE_BUILD_TYPE STREQUAL "Release")
      set(d "")
    else() # Debug build
      set(d "d")
    endif()
    if (NOT EXISTS "${_qt5Core_install_prefix}/lib/qtharfbuzzng${d}.lib")
      message(FATAL_ERROR "PhantomJS only supports building on Windows against a static Qt configured with -static -static-runtime!")
    endif()
    target_link_libraries(${CEF_TARGET}
      "${_qt5Core_install_prefix}/lib/qtharfbuzzng${d}.lib"
      "${_qt5Core_install_prefix}/lib/qtpcre${d}.lib"
      "${_qt5Core_install_prefix}/lib/qtfreetype${d}.lib"
      "${_qt5Core_install_prefix}/lib/Qt5PlatformSupport${d}.lib"
      "${_qt5Core_install_prefix}/plugins/platforms/qwindows${d}.lib"
      "Ws2_32.lib"
      "Imm32.lib"
    )
endif()

if(OS_WINDOWS AND USE_SANDBOX)
  # Logical target used to link the cef_sandbox library.
  ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}")
  target_link_libraries(${CEF_TARGET} cef_sandbox_lib ${CEF_SANDBOX_STANDARD_LIBS})
endif()

# Set rpath so that libraries can be placed next to the executable.
set_target_properties(${CEF_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN")
set_target_properties(${CEF_TARGET} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
set_target_properties(${CEF_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR})

# Copy binary and resource files to the target output directory.
COPY_FILES("${CEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}")
COPY_FILES("${CEF_TARGET}" "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}")

#
# Linux configuration.<commit_msg>Fix build with msvc2015.<commit_after># Copyright (c) 2015 Klaralvdalens Datakonsult AB (KDAB).
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.

find_package(Qt5 NO_MODULE REQUIRED COMPONENTS Gui PrintSupport)

#
# Source files.
#

# phantomjs sources.
set(PHANTOMJS_SRCS
  app.cpp
  handler.cpp
  print_handler.cpp
  main.cpp
  debug.cpp
)

if (OS_LINUX)
  LIST(APPEND PHANTOMJS_SRCS
    keyevents_linux.cpp
  )
endif()

qt5_add_resources(PHANTOMJS_SRCS resources.qrc)

#
# Shared configuration.
#

# Target executable names.
set(CEF_TARGET "phantomjs")
if(OS_MACOSX)
  set(CEF_HELPER_TARGET "phantomjs Helper")
endif()

# Logical target used to link the libcef library.
ADD_LOGICAL_TARGET("libcef_lib" "${CEF_LIB_DEBUG}" "${CEF_LIB_RELEASE}")

# Determine the target output directory.
SET_CEF_TARGET_OUT_DIR()

# Executable target.
add_executable(${CEF_TARGET} ${PHANTOMJS_SRCS})
add_dependencies(${CEF_TARGET} libcef_dll_wrapper)
message(STATUS "${_qt5Core_install_prefix}")
target_link_libraries(${CEF_TARGET}
  libcef_lib
  libcef_dll_wrapper
  ${CEF_STANDARD_LIBS}
  Qt5::Gui
  Qt5::PrintSupport
)

if (OS_WINDOWS)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -EHsc -Wv:18")
    if (CMAKE_BUILD_TYPE STREQUAL "Release")
      set(d "")
    else() # Debug build
      set(d "d")
    endif()
    if (NOT EXISTS "${_qt5Core_install_prefix}/lib/qtharfbuzzng${d}.lib")
      message(FATAL_ERROR "PhantomJS only supports building on Windows against a static Qt configured with -static -static-runtime!")
    endif()
    target_link_libraries(${CEF_TARGET}
      "${_qt5Core_install_prefix}/lib/qtharfbuzzng${d}.lib"
      "${_qt5Core_install_prefix}/lib/qtpcre${d}.lib"
      "${_qt5Core_install_prefix}/lib/qtfreetype${d}.lib"
      "${_qt5Core_install_prefix}/lib/Qt5PlatformSupport${d}.lib"
      "${_qt5Core_install_prefix}/plugins/platforms/qwindows${d}.lib"
      "Ws2_32.lib"
      "Imm32.lib"
      "Winmm.lib"
    )
endif()

if(OS_WINDOWS AND USE_SANDBOX)
  # Logical target used to link the cef_sandbox library.
  ADD_LOGICAL_TARGET("cef_sandbox_lib" "${CEF_SANDBOX_LIB_DEBUG}" "${CEF_SANDBOX_LIB_RELEASE}")
  target_link_libraries(${CEF_TARGET} cef_sandbox_lib ${CEF_SANDBOX_STANDARD_LIBS})
endif()

# Set rpath so that libraries can be placed next to the executable.
set_target_properties(${CEF_TARGET} PROPERTIES INSTALL_RPATH "$ORIGIN")
set_target_properties(${CEF_TARGET} PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
set_target_properties(${CEF_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CEF_TARGET_OUT_DIR})

# Copy binary and resource files to the target output directory.
COPY_FILES("${CEF_TARGET}" "${CEF_BINARY_FILES}" "${CEF_BINARY_DIR}" "${CEF_TARGET_OUT_DIR}")
COPY_FILES("${CEF_TARGET}" "${CEF_RESOURCE_FILES}" "${CEF_RESOURCE_DIR}" "${CEF_TARGET_OUT_DIR}")

#
# Linux configuration.
{'fraction_non_alphanumeric': 0.11641896673743808, 'fraction_numerical': 0.008492569002123142, 'mean_word_length': 5.753882915173238, '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': '3984302', 'n_tokens_mistral': 2200, 'n_tokens_neox': 2102, 'n_words': 405}