<commit_before># cmake global
cmake_minimum_required(VERSION 2.8.12)
# let cmake autolink dependencies on windows
# it's specified globally, cause qt libraries requires that on windows and they are also found globally
cmake_policy(SET CMP0020 NEW)

project(ethereum)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")


######################################################################################################

# user defined, defaults
# Normally, set(...CACHE...) creates cache variables, but does not modify them.
function(createDefaultCacheConfig)
	set(HEADLESS OFF CACHE BOOL "Do not compile GUI (AlethZero)")
	set(VMTRACE OFF CACHE BOOL "VM tracing and run-time checks (useful for cross-implementation VM debugging)")
	set(PARANOIA OFF CACHE BOOL "Additional run-time checks")
	set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on")
	set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)")
	set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.")
	set(JUSTTESTS OFF CACHE BOOL "Build only for tests.")
	set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)")
endfunction()


# propagates CMake configuration options to the compiler
function(configureProject)
	if (PARANOIA)
		if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
			add_definitions(-DETH_PARANOIA)
		else ()
			message(FATAL_ERROR "Paranoia requires debug.")
		endif ()
	endif ()

	if (VMTRACE)
		if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
			add_definitions(-DETH_VMTRACE)
		else ()
			message(FATAL_ERROR "VM tracing requires debug.")
		endif ()
	endif ()

	if (EVMJIT)
		add_definitions(-DETH_EVMJIT)
	endif()

	if (FATDB)
		add_definitions(-DETH_FATDB)
	endif()

	if (SOLIDITY)
		add_definitions(-DETH_SOLIDITY)
	endif()

	if (HEADLESS OR JUSTTESTS)
		add_definitions(-DETH_HEADLESS)
	endif()
endfunction()

set(CPPETHEREUM 1)

function(createBuildInfo)
	# Set build platform; to be written to BuildInfo.h
	set(ETH_BUILD_PLATFORM "${TARGET_PLATFORM}")
	if (CMAKE_COMPILER_IS_MINGW)
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/mingw")
	elseif (CMAKE_COMPILER_IS_MSYS)
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/msys")
	elseif (CMAKE_COMPILER_IS_GNUCXX)
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/g++")
	elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/msvc")
	elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/clang")
	else ()
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/unknown")
	endif ()

	if (EVMJIT)
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/JIT")
	else ()
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/int")
	endif ()

	if (PARANOIA)
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/PARA")
	endif ()

	#cmake build type may be not specified when using msvc
	if (CMAKE_BUILD_TYPE)
		set(_cmake_build_type ${CMAKE_BUILD_TYPE})
	else()
		set(_cmake_build_type "${CMAKE_CFG_INTDIR}")
	endif()

	# Generate header file containing useful build information
	add_custom_target(BuildInfo.h ALL
		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
		COMMAND ${CMAKE_COMMAND} -DETH_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -DETH_DST_DIR="${CMAKE_BINARY_DIR}"
			-DETH_BUILD_TYPE="${_cmake_build_type}" -DETH_BUILD_PLATFORM="${ETH_BUILD_PLATFORM}" 
			-P "${ETH_SCRIPTS_DIR}/buildinfo.cmake"
		)
	include_directories(${CMAKE_CURRENT_BINARY_DIR})

	set(CMAKE_INCLUDE_CURRENT_DIR ON)
	set(SRC_LIST BuildInfo.h)
endfunction()



######################################################################################################


set(CMAKE_AUTOMOC ON)
cmake_policy(SET CMP0015 NEW)


createDefaultCacheConfig()
configureProject()

# TODO: Move to some other place / remove once we make Qt5.4 mandatory.
find_package (Qt5WebEngine QUIET)
if ("${Qt5WebEngine_VERSION_STRING}" VERSION_GREATER "5.3.0")
	set (ETH_HAVE_WEBENGINE 1)
else()
	set (ETH_HAVE_WEBENGINE 0)
endif()

message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}")
message("-- VMTRACE: ${VMTRACE}; PARANOIA: ${PARANOIA}; HEADLESS: ${HEADLESS}; JSONRPC: ${JSONRPC}; EVMJIT: ${EVMJIT}; FATDB: ${FATDB}; CHROMIUM: ${ETH_HAVE_WEBENGINE}")


# Default TARGET_PLATFORM to "linux".
set(TARGET_PLATFORM CACHE STRING "linux")
if ("x${TARGET_PLATFORM}" STREQUAL "x")
	set(TARGET_PLATFORM "linux")
endif ()

if ("${TARGET_PLATFORM}" STREQUAL "linux")
	set(CMAKE_THREAD_LIBS_INIT pthread)
endif ()

include(EthCompilerSettings)
message("-- CXXFLAGS: ${CMAKE_CXX_FLAGS}")


# this must be an include, as a function it would messs up with variable scope!
include(EthDependencies)
include(EthExecutableHelper)

createBuildInfo()

if (EVMJIT)
	set(EVMJIT_CPP TRUE) # include CPP-JIT connector<commit_msg>Force chromium to be built.<commit_after># cmake global
cmake_minimum_required(VERSION 2.8.12)
# let cmake autolink dependencies on windows
# it's specified globally, cause qt libraries requires that on windows and they are also found globally
cmake_policy(SET CMP0020 NEW)

project(ethereum)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")


######################################################################################################

# user defined, defaults
# Normally, set(...CACHE...) creates cache variables, but does not modify them.
function(createDefaultCacheConfig)
	set(HEADLESS OFF CACHE BOOL "Do not compile GUI (AlethZero)")
	set(VMTRACE OFF CACHE BOOL "VM tracing and run-time checks (useful for cross-implementation VM debugging)")
	set(PARANOIA OFF CACHE BOOL "Additional run-time checks")
	set(JSONRPC ON CACHE BOOL "Build with jsonprc. default on")
	set(EVMJIT OFF CACHE BOOL "Build a just-in-time compiler for EVM code (requires LLVM)")
	set(FATDB OFF CACHE BOOL "Build with ability to list entries in the Trie. Doubles DB size, slows everything down, but good for looking at state diffs and trie contents.")
	set(JUSTTESTS OFF CACHE BOOL "Build only for tests.")
	set(SOLIDITY ON CACHE BOOL "Build the Solidity language components (requried unless HEADLESS)")
endfunction()


# propagates CMake configuration options to the compiler
function(configureProject)
	if (PARANOIA)
		if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
			add_definitions(-DETH_PARANOIA)
		else ()
			message(FATAL_ERROR "Paranoia requires debug.")
		endif ()
	endif ()

	if (VMTRACE)
		if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
			add_definitions(-DETH_VMTRACE)
		else ()
			message(FATAL_ERROR "VM tracing requires debug.")
		endif ()
	endif ()

	if (EVMJIT)
		add_definitions(-DETH_EVMJIT)
	endif()

	if (FATDB)
		add_definitions(-DETH_FATDB)
	endif()

	if (SOLIDITY)
		add_definitions(-DETH_SOLIDITY)
	endif()

	if (HEADLESS OR JUSTTESTS)
		add_definitions(-DETH_HEADLESS)
	endif()
endfunction()

set(CPPETHEREUM 1)

function(createBuildInfo)
	# Set build platform; to be written to BuildInfo.h
	set(ETH_BUILD_PLATFORM "${TARGET_PLATFORM}")
	if (CMAKE_COMPILER_IS_MINGW)
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/mingw")
	elseif (CMAKE_COMPILER_IS_MSYS)
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/msys")
	elseif (CMAKE_COMPILER_IS_GNUCXX)
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/g++")
	elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/msvc")
	elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/clang")
	else ()
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/unknown")
	endif ()

	if (EVMJIT)
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/JIT")
	else ()
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/int")
	endif ()

	if (PARANOIA)
		set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/PARA")
	endif ()

	#cmake build type may be not specified when using msvc
	if (CMAKE_BUILD_TYPE)
		set(_cmake_build_type ${CMAKE_BUILD_TYPE})
	else()
		set(_cmake_build_type "${CMAKE_CFG_INTDIR}")
	endif()

	# Generate header file containing useful build information
	add_custom_target(BuildInfo.h ALL
		WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
		COMMAND ${CMAKE_COMMAND} -DETH_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -DETH_DST_DIR="${CMAKE_BINARY_DIR}"
			-DETH_BUILD_TYPE="${_cmake_build_type}" -DETH_BUILD_PLATFORM="${ETH_BUILD_PLATFORM}" 
			-P "${ETH_SCRIPTS_DIR}/buildinfo.cmake"
		)
	include_directories(${CMAKE_CURRENT_BINARY_DIR})

	set(CMAKE_INCLUDE_CURRENT_DIR ON)
	set(SRC_LIST BuildInfo.h)
endfunction()



######################################################################################################


set(CMAKE_AUTOMOC ON)
cmake_policy(SET CMP0015 NEW)


createDefaultCacheConfig()
configureProject()

# Force chromium.
set (ETH_HAVE_WEBENGINE 1)

message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}")
message("-- VMTRACE: ${VMTRACE}; PARANOIA: ${PARANOIA}; HEADLESS: ${HEADLESS}; JSONRPC: ${JSONRPC}; EVMJIT: ${EVMJIT}; FATDB: ${FATDB}; CHROMIUM: ${ETH_HAVE_WEBENGINE}")


# Default TARGET_PLATFORM to "linux".
set(TARGET_PLATFORM CACHE STRING "linux")
if ("x${TARGET_PLATFORM}" STREQUAL "x")
	set(TARGET_PLATFORM "linux")
endif ()

if ("${TARGET_PLATFORM}" STREQUAL "linux")
	set(CMAKE_THREAD_LIBS_INIT pthread)
endif ()

include(EthCompilerSettings)
message("-- CXXFLAGS: ${CMAKE_CXX_FLAGS}")


# this must be an include, as a function it would messs up with variable scope!
include(EthDependencies)
include(EthExecutableHelper)

createBuildInfo()

if (EVMJIT)
	set(EVMJIT_CPP TRUE) # include CPP-JIT connector
{'fraction_non_alphanumeric': 0.15127556398903647, 'fraction_numerical': 0.003795066413662239, 'mean_word_length': 6.535345512311358, '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': '5472044', 'n_tokens_mistral': 3606, 'n_tokens_neox': 3329, 'n_words': 793}