<commit_before>cmake_minimum_required(VERSION 3.2.2)

# This is specific for using a Make-based build
# find_program(CCACHE_FOUND ccache)
# if(CCACHE_FOUND)
# 	set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
# 	set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
# endif(CCACHE_FOUND)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)

find_package(Qt5 REQUIRED Core Gui Widgets)
add_definitions(-D_REENTRANT)
add_definitions(-DDEBUG) # -DQT_NO_DEBUG <-- get rid of this

set(ENVISION_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)

set(BUILD_DIR ${ENVISION_ROOT_DIR}/DebugBuild)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
	set(BUILD_DIR ${ENVISION_ROOT_DIR}/DebugBuild)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Release")
	set(BUILD_DIR ${ENVISION_ROOT_DIR}/ReleaseBuild)
endif()

set(PLUGINS_DIR ${BUILD_DIR}/plugins)
include_directories(${ENVISION_ROOT_DIR})
link_directories(${BUILD_DIR} ${PLUGINS_DIR})

# ???
# CONFIG(debug, debug|release):DEFINES += DEBUG

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -pedantic-errors -Wall -W -Werror -Wextra -O2 -fno-omit-frame-pointer -Woverloaded-virtual -Winvalid-pch")

# ???
# clang:QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-private-field

# Enable linking to custom Qt version and libCore from both main executable and plugins
set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/..:$ORIGIN/qt:$ORIGIN/../qt")

if( WIN32 )
	set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-all-symbols'") #Export all symbols in Windows to save a hassle
endif()

set(COMMON_LIBS "")
if( UNIX )
	set(COMMON_LIBS "-lprofiler")
endif()

# ???
# QMAKE_POST_LINK += $${ENVISION_ROOT_DIR}/checkers/vera++-check-dir $$_PRO_FILE_PWD_

function(use_precompiled_header targetName)
	message("Using precompiled header for ${targetName} ")
    
	# A custom target name for the precompiled header
	set(precompiled ${targetName}-Precompiled-Header)
	
	# Create a cpp file which cmake can build to get the precompiled header file
	set(precompiled_cpp ${CMAKE_CURRENT_BINARY_DIR}/precompiled_cpp.cpp)
	file(WRITE ${precompiled_cpp} "\n")
	
	# The precompiled header target
	add_library(${precompiled} OBJECT src/precompiled.h ${precompiled_cpp})
	set_target_properties(${precompiled} PROPERTIES AUTOMOC OFF)
	target_compile_options(${precompiled} PRIVATE -include ${CMAKE_CURRENT_SOURCE_DIR}/src/precompiled.h -x c++-header)
	target_compile_definitions(${precompiled} PRIVATE ${targetName}_EXPORTS)
	
	# Inherited compilation flags
	get_transitive_link_dependencies_for_precompiled_header(${targetName} ${precompiled})

	# Add another target that will copy the object file generated by the precompiled target
	# and rename it to a suitable .gch file
	set(precompiledCopy ${targetName}-Precompiled-Header-CopyAndRename)
	set(precompiledSubDir ${precompiled})
	add_custom_target(${precompiledCopy}
		COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${precompiled}.dir/precompiled_cpp.cpp.o ${CMAKE_BINARY_DIR}/${precompiledSubDir}/precompiled.h.gch
		DEPENDS ${precompiled}
	)
		
	
	add_dependencies(${targetName} ${precompiledCopy})
	target_compile_options(${targetName} PRIVATE -include ${CMAKE_BINARY_DIR}/${precompiledSubDir}/precompiled.h)
endfunction(use_precompiled_header)

function(get_transitive_link_dependencies_for_precompiled_header targetName precompiledTargetName)<commit_msg>Don't invalidate precompiled headers on cmake run<commit_after>cmake_minimum_required(VERSION 3.2.2)

# This is specific for using a Make-based build
# find_program(CCACHE_FOUND ccache)
# if(CCACHE_FOUND)
# 	set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
# 	set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
# endif(CCACHE_FOUND)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)

find_package(Qt5 REQUIRED Core Gui Widgets)
add_definitions(-D_REENTRANT)
add_definitions(-DDEBUG) # -DQT_NO_DEBUG <-- get rid of this

set(ENVISION_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)

set(BUILD_DIR ${ENVISION_ROOT_DIR}/DebugBuild)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
	set(BUILD_DIR ${ENVISION_ROOT_DIR}/DebugBuild)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Release")
	set(BUILD_DIR ${ENVISION_ROOT_DIR}/ReleaseBuild)
endif()

set(PLUGINS_DIR ${BUILD_DIR}/plugins)
include_directories(${ENVISION_ROOT_DIR})
link_directories(${BUILD_DIR} ${PLUGINS_DIR})

# ???
# CONFIG(debug, debug|release):DEFINES += DEBUG

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -pedantic-errors -Wall -W -Werror -Wextra -O2 -fno-omit-frame-pointer -Woverloaded-virtual -Winvalid-pch")

# ???
# clang:QMAKE_CXXFLAGS_WARN_ON += -Wno-unused-private-field

# Enable linking to custom Qt version and libCore from both main executable and plugins
set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/..:$ORIGIN/qt:$ORIGIN/../qt")

if( WIN32 )
	set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--export-all-symbols'") #Export all symbols in Windows to save a hassle
endif()

set(COMMON_LIBS "")
if( UNIX )
	set(COMMON_LIBS "-lprofiler")
endif()

# ???
# QMAKE_POST_LINK += $${ENVISION_ROOT_DIR}/checkers/vera++-check-dir $$_PRO_FILE_PWD_

function(use_precompiled_header targetName)
	message("Using precompiled header for ${targetName} ")
    
	# A custom target name for the precompiled header
	set(precompiled ${targetName}-Precompiled-Header)
	
	# Create a cpp file which cmake can build to get the precompiled header file
	set(precompiled_cpp ${CMAKE_CURRENT_BINARY_DIR}/precompiled_cpp.cpp)
	if(NOT EXISTS ${precompiled_cpp})
		file(WRITE ${precompiled_cpp} "\n")
	endif()
	
	# The precompiled header target
	add_library(${precompiled} OBJECT src/precompiled.h ${precompiled_cpp})
	set_target_properties(${precompiled} PROPERTIES AUTOMOC OFF)
	target_compile_options(${precompiled} PRIVATE -include ${CMAKE_CURRENT_SOURCE_DIR}/src/precompiled.h -x c++-header)
	target_compile_definitions(${precompiled} PRIVATE ${targetName}_EXPORTS)
	
	# Inherited compilation flags
	get_transitive_link_dependencies_for_precompiled_header(${targetName} ${precompiled})

	# Add another target that will copy the object file generated by the precompiled target
	# and rename it to a suitable .gch file
	set(precompiledCopy ${targetName}-Precompiled-Header-CopyAndRename)
	set(precompiledSubDir ${precompiled})
	add_custom_target(${precompiledCopy}
		COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${precompiled}.dir/precompiled_cpp.cpp.o ${CMAKE_BINARY_DIR}/${precompiledSubDir}/precompiled.h.gch
		DEPENDS ${precompiled}
	)
	
	add_dependencies(${targetName} ${precompiledCopy})
	target_compile_options(${targetName} PRIVATE -include ${CMAKE_BINARY_DIR}/${precompiledSubDir}/precompiled.h)
endfunction(use_precompiled_header)

function(get_transitive_link_dependencies_for_precompiled_header targetName precompiledTargetName)
{'fraction_non_alphanumeric': 0.1098744292237443, 'fraction_numerical': 0.00228310502283105, 'mean_word_length': 7.2168815943728015, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4694141', 'n_tokens_mistral': 2604, 'n_tokens_neox': 2427, 'n_words': 487}