<commit_before># check cmake version
CMAKE_MINIMUM_REQUIRED(VERSION 3.9)

# project name, and type
PROJECT(OpenApoc CXX C)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

include(ccache)

# check compiler
INCLUDE(CheckCXXCompilerFlag)
INCLUDE(CheckCCompilerFlag)

# Sanitize doesn't seem to work with pch on gcc
string(TOLOWER "${CMAKE_BUILD_TYPE}" lower_build_type)

option(LTO "Build using link-time-optimisations" OFF)
option(MSVC_PDB "Always generate PDB files" OFF)
option(ENABLE_TESTS "Build some unit tests" ON)
option(EXTRACT_DATA "Run the data extractor as part of the default target" ON)

set(CD_PATH ${CMAKE_SOURCE_DIR}/data/cd.iso CACHE STRING "Path to cd.iso (used
by test and extractor")

if (${EXTRACT_DATA} AND NOT EXISTS ${CD_PATH})
		message(FATAL_ERROR "CD_PATH \"${CD_PATH}\" points at non-existant file")
endif()

message("Using CD at \"${CD_PATH}\"")

set(CMAKE_C_FLAGS_SANITIZE "-O1 -g -fsanitize=address")
set(CMAKE_CXX_FLAGS_SANITIZE "-O1 -g -fsanitize=address")

set(CMAKE_C_FLAGS_QUICK "-O1 -g1")
set(CMAKE_CXX_FLAGS_QUICK "-O1 -g1")


CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden"
	CXX_COMPILER_SUPPORTS_HIDDEN_VISIBILITY)
CHECK_C_COMPILER_FLAG("-fvisibility=hidden"
	C_COMPILER_SUPPORTS_HIDDEN_VISIBILITY)

if (CXX_COMPILER_SUPPORTS_HIDDEN_VISIBILITY)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()
if (C_COMPILER_SUPPORTS_HIDDEN_VISIBILITY)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
endif()

if (LTO)
	include(CheckIPOSupported)
	check_ipo_supported(RESULT result OUTPUT output)
	message("Enabling LTO")
	if (result)
			set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
			message("LTO supported")
	else()
		message(WARNING "LTO not supported by this compiler :" ${output})
	endif()
endif(LTO)

# MSVC has default flags that CMake doesn't set
if (MSVC)
	add_definitions(-DUNICODE -D_UNICODE)
	if (MSVC_VERSION GREATER_EQUAL 1910)
		set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-")
		set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /permissive-")
	endif()
	if (MSVC_PDB)
		set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
		set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
	endif()
endif()<commit_msg>Workaround bug in visual studio 16.9 compiler<commit_after># check cmake version
CMAKE_MINIMUM_REQUIRED(VERSION 3.9)

# project name, and type
PROJECT(OpenApoc CXX C)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

include(ccache)

# check compiler
INCLUDE(CheckCXXCompilerFlag)
INCLUDE(CheckCCompilerFlag)

# Sanitize doesn't seem to work with pch on gcc
string(TOLOWER "${CMAKE_BUILD_TYPE}" lower_build_type)

option(LTO "Build using link-time-optimisations" OFF)
option(MSVC_PDB "Always generate PDB files" OFF)
option(ENABLE_TESTS "Build some unit tests" ON)
option(EXTRACT_DATA "Run the data extractor as part of the default target" ON)

set(CD_PATH ${CMAKE_SOURCE_DIR}/data/cd.iso CACHE STRING "Path to cd.iso (used
by test and extractor")

if (${EXTRACT_DATA} AND NOT EXISTS ${CD_PATH})
		message(FATAL_ERROR "CD_PATH \"${CD_PATH}\" points at non-existant file")
endif()

message("Using CD at \"${CD_PATH}\"")

set(CMAKE_C_FLAGS_SANITIZE "-O1 -g -fsanitize=address")
set(CMAKE_CXX_FLAGS_SANITIZE "-O1 -g -fsanitize=address")

set(CMAKE_C_FLAGS_QUICK "-O1 -g1")
set(CMAKE_CXX_FLAGS_QUICK "-O1 -g1")


CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden"
	CXX_COMPILER_SUPPORTS_HIDDEN_VISIBILITY)
CHECK_C_COMPILER_FLAG("-fvisibility=hidden"
	C_COMPILER_SUPPORTS_HIDDEN_VISIBILITY)

if (CXX_COMPILER_SUPPORTS_HIDDEN_VISIBILITY)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
endif()
if (C_COMPILER_SUPPORTS_HIDDEN_VISIBILITY)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
endif()

if (LTO)
	include(CheckIPOSupported)
	check_ipo_supported(RESULT result OUTPUT output)
	message("Enabling LTO")
	if (result)
			set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
			message("LTO supported")
	else()
		message(WARNING "LTO not supported by this compiler :" ${output})
	endif()
endif(LTO)

# MSVC has default flags that CMake doesn't set
if (MSVC)
	add_definitions(-DUNICODE -D_UNICODE)
	
	if (MSVC_VERSION GREATER_EQUAL 1910)
	    if (MSVC_VERSION EQUAL 1928)
		    # HACK - MSVC++ compiler 19.28 (shipped with visual studio 16.9) cause errors in <optional> and constexpr Colour with /permissive-
	        # See https://developercommunity2.visualstudio.com/t/Unexpected-error-C2131:-expression-did/1343697?entry=problem&ref=native&refTime=1615948128399&refUserId=1a6b34b3-01a5-4b5d-972d-b81d902f1e66
		else()
		    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-")
		    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /permissive-")
		endif()
	endif()
	if (MSVC_PDB)
		set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
		set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
	endif()
endif()
{'fraction_non_alphanumeric': 0.10940876055784718, 'fraction_numerical': 0.017285405617756825, 'mean_word_length': 6.7978560490045945, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, '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': '1492293', 'n_tokens_mistral': 2192, 'n_tokens_neox': 1986, 'n_words': 409}