<commit_before>cmake_minimum_required(VERSION 3.2)

project(Hypersomnia)

# Sanity logs.
message("CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
message("CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")

message("Hypersomnia project source dir: ${PROJECT_SOURCE_DIR}")
message("Hypersomnia project binary dir: ${PROJECT_BINARY_DIR}")
message("Hypersomnia current binary dir: ${CMAKE_CURRENT_BINARY_DIR}")

# Determine the used compiler.
# In case of MSVC, CMake sets the MSVC variable to ON on its own.

# Important note:
# MSVC build is currently hardcoded to be statically linked.

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
	message("Building with Clang.")
	set(CLANG ON)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
	message("Building with gcc.")
	set(GCC ON)
endif()

if(UNIX)
	message("Building for UNIX systems.")

	if(NOT ARCHITECTURE)
		message(FATAL_ERROR "Architecture type was not specified.")
	endif()

	if(${ARCHITECTURE} STREQUAL "x86")
		message("Building for x86 architecture.")
	elseif(${ARCHITECTURE} STREQUAL "x64")
		message("Building for x64 architecture.")
	else()
		message(FATAL_ERROR "Unknown architecture: ${ARCHITECTURE}")
	endif()

elseif(MSVC)
	message("Building for Windows systems.")
	# Unlike makefiles, architecture is determined by the generator used.
else()
	message(FATAL_ERROR "Unknown system.")
endif()

##################################################
### ALL CUSTOMIZABLE BUILD SWITCHES BEGIN HERE ###

# If it is your first time building Hypersomnia and you get some errors,
# you might want to try turning HYPERSOMNIA_BARE on to build the minimal possible working Hypersomnia runtime.
# Then, try to work from there.
# The game should still run, even not having these features, although obviously, you won't see or hear anything.

if(HYPERSOMNIA_BARE)
	message("Building Hypersomnia without... anything")
	
	set(DEFAULT_OPT OFF)
else()
	set(DEFAULT_OPT ON)
endif()

# In the future, the switches will also differ depending on whether the target application is a client or a server.
# If you're a developer, you might also want to disable some functionality to have faster builds for quicker iteration.

## These variables are used by the archiver to know which files are to be included with the executable,
## and also for Visual Studio to properly set the working directory.

set(HYPERSOMNIA_RESOURCES_FOLDER_NAME "hypersomnia")
set(HYPERSOMNIA_EXE_RESOURCES_DIR "${PROJECT_SOURCE_DIR}/${HYPERSOMNIA_RESOURCES_FOLDER_NAME}")

## Application packaging switches.
option(ADD_COMMAND_TO_ARCHIVE_BUILDS_IN_RELEASE "Add command to archive builds in Release." ${DEFAULT_OPT})
option(ADD_APPLICATION_ICON "Add application icon." ${DEFAULT_OPT})

## Hardcoded, relative paths for directories that the executable might use.

# From where will the game pull its official resources.

set(HYPERSOMNIA_OFFICIAL_CONTENT_DIR "content/official")

# Where the game will save logs.
# Deleting this folder will have no effect on the game.

set(HYPERSOMNIA_LOG_FILES_DIR "cache/log")

# Where the game will save neon maps and other regenerable content.
# Deleting this folder will have no effect on the game, except that some resources might take time to generate again.

set(HYPERSOMNIA_GENERATED_FILES_DIR "cache/gen")

# Where the game will save untitled works from editor, gui layouts, user config etc.
# Deleting this folder might possibly result in data loss, e.g. the untitled works and some user settings.

set(HYPERSOMNIA_LOCAL_FILES_DIR "cache/usr")

## Building switches for functionality using 3rdparty libraries.

option(BUILD_OPENAL "Build OpenAL Soft." ${DEFAULT_OPT})
option(BUILD_OPENGL "Build OpenGL-related code." ${DEFAULT_OPT})
option(BUILD_ENET "Build ENet networking library." ${DEFAULT_OPT})
option(BUILD_FREETYPE "Build FreeType library responsible for loading fonts." ${DEFAULT_OPT})
option(BUILD_WINDOW_FRAMEWORK "Build code specific to a given platfom, e.g. window management done by WinAPI." ${DEFAULT_OPT})
option(BUILD_HTTP_REQUESTS "Build simple http requests, e.g. for latest news bar in the main menu." ${DEFAULT_OPT})
option(BUILD_UNIT_TESTS "Build unit tests that are run on game startup." ${DEFAULT_OPT})
option(BUILD_SOUND_FORMAT_DECODERS "Build ogg and vorbis. If this is off, there is also no point in enabling OpenAL." ${DEFAULT_OPT})

## Switches for functionality originating from the Hypersomnia codebase.

option(BUILD_VERSION_FILE_GENERATOR "Build version file generator to generate commit information." ${DEFAULT_OPT})
option(BUILD_TEST_SCENES "Build unscripted test scenes hardcoded in C++." ${DEFAULT_OPT})
option(BUILD_PROPERTY_EDITOR "Build property editor code for the editor setup. Due to hardcore templates, this takes amazingly long time to build, so it makes sense to turn it off sometimes." ${DEFAULT_OPT})

set(BUILD_IN_CONSOLE_MODE OFF CACHE STRING "0")

## Build optimization switches.
## These may speed up build times.

option(GENERATE_DEBUG_INFORMATION "Generate source-level debug information. If 0, -g flag will be removed to speed up the build." ${DEFAULT_OPT})

## Runtime optimization switches.

# Don't happily turn everything ON because optimizations take a lot of build time,
# and you probably don't need the runtime to be as fast as light, at least for now.

option(ENABLE_LINK_TIME_OPTIMIZATION "Some ultra extra optimizations for Release builds. Takes a lot longer to build." OFF)

# If this variable is nonzero, the cosmos will use a statically allocated number
# of entities, drastically improving access performance. Might be very useful for a sever application.
# Pros: 
# 	+ Dereferencing entities with speed of light
# Cons:
#	- Compilation might be longer due to component includes needed everywhere
#	- Can't tweak maximum number of entities at runtime
#	- Even empty game worlds occupy as much space as those filled to the maximum

set(STATICALLY_ALLOCATE_ENTITIES "1" CACHE STRING "Statically allocate entities in the cosmos")

# If this variable is nonzero, the cosmos common will use a statically allocated number
# of entity flavours, drastically improving access performance. Might be very useful for a sever application.<commit_msg>ULTRA_OPTS switch<commit_after>cmake_minimum_required(VERSION 3.2)

project(Hypersomnia)

# Sanity logs.
message("CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
message("CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")

message("Hypersomnia project source dir: ${PROJECT_SOURCE_DIR}")
message("Hypersomnia project binary dir: ${PROJECT_BINARY_DIR}")
message("Hypersomnia current binary dir: ${CMAKE_CURRENT_BINARY_DIR}")

# Determine the used compiler.
# In case of MSVC, CMake sets the MSVC variable to ON on its own.

# Important note:
# MSVC build is currently hardcoded to be statically linked.

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
	message("Building with Clang.")
	set(CLANG ON)
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
	message("Building with gcc.")
	set(GCC ON)
endif()

if(UNIX)
	message("Building for UNIX systems.")

	if(NOT ARCHITECTURE)
		message(FATAL_ERROR "Architecture type was not specified.")
	endif()

	if(${ARCHITECTURE} STREQUAL "x86")
		message("Building for x86 architecture.")
	elseif(${ARCHITECTURE} STREQUAL "x64")
		message("Building for x64 architecture.")
	else()
		message(FATAL_ERROR "Unknown architecture: ${ARCHITECTURE}")
	endif()

elseif(MSVC)
	message("Building for Windows systems.")
	# Unlike makefiles, architecture is determined by the generator used.
else()
	message(FATAL_ERROR "Unknown system.")
endif()

##################################################
### ALL CUSTOMIZABLE BUILD SWITCHES BEGIN HERE ###

# If it is your first time building Hypersomnia and you get some errors,
# you might want to try turning HYPERSOMNIA_BARE on to build the minimal possible working Hypersomnia runtime.
# Then, try to work from there.
# The game should still run, even not having these features, although obviously, you won't see or hear anything.

if(HYPERSOMNIA_BARE)
	message("Building Hypersomnia without... anything")
	
	set(DEFAULT_OPT OFF)
else()
	set(DEFAULT_OPT ON)
endif()

# In the future, the switches will also differ depending on whether the target application is a client or a server.
# If you're a developer, you might also want to disable some functionality to have faster builds for quicker iteration.

## These variables are used by the archiver to know which files are to be included with the executable,
## and also for Visual Studio to properly set the working directory.

set(HYPERSOMNIA_RESOURCES_FOLDER_NAME "hypersomnia")
set(HYPERSOMNIA_EXE_RESOURCES_DIR "${PROJECT_SOURCE_DIR}/${HYPERSOMNIA_RESOURCES_FOLDER_NAME}")

## Application packaging switches.
option(ADD_COMMAND_TO_ARCHIVE_BUILDS_IN_RELEASE "Add command to archive builds in Release." ${DEFAULT_OPT})
option(ADD_APPLICATION_ICON "Add application icon." ${DEFAULT_OPT})

## Hardcoded, relative paths for directories that the executable might use.

# From where will the game pull its official resources.

set(HYPERSOMNIA_OFFICIAL_CONTENT_DIR "content/official")

# Where the game will save logs.
# Deleting this folder will have no effect on the game.

set(HYPERSOMNIA_LOG_FILES_DIR "cache/log")

# Where the game will save neon maps and other regenerable content.
# Deleting this folder will have no effect on the game, except that some resources might take time to generate again.

set(HYPERSOMNIA_GENERATED_FILES_DIR "cache/gen")

# Where the game will save untitled works from editor, gui layouts, user config etc.
# Deleting this folder might possibly result in data loss, e.g. the untitled works and some user settings.

set(HYPERSOMNIA_LOCAL_FILES_DIR "cache/usr")

## Building switches for functionality using 3rdparty libraries.

option(BUILD_OPENAL "Build OpenAL Soft." ${DEFAULT_OPT})
option(BUILD_OPENGL "Build OpenGL-related code." ${DEFAULT_OPT})
option(BUILD_ENET "Build ENet networking library." ${DEFAULT_OPT})
option(BUILD_FREETYPE "Build FreeType library responsible for loading fonts." ${DEFAULT_OPT})
option(BUILD_WINDOW_FRAMEWORK "Build code specific to a given platfom, e.g. window management done by WinAPI." ${DEFAULT_OPT})
option(BUILD_HTTP_REQUESTS "Build simple http requests, e.g. for latest news bar in the main menu." ${DEFAULT_OPT})
option(BUILD_UNIT_TESTS "Build unit tests that are run on game startup." ${DEFAULT_OPT})
option(BUILD_SOUND_FORMAT_DECODERS "Build ogg and vorbis. If this is off, there is also no point in enabling OpenAL." ${DEFAULT_OPT})

## Switches for functionality originating from the Hypersomnia codebase.

option(BUILD_VERSION_FILE_GENERATOR "Build version file generator to generate commit information." ${DEFAULT_OPT})
option(BUILD_TEST_SCENES "Build unscripted test scenes hardcoded in C++." ${DEFAULT_OPT})
option(BUILD_PROPERTY_EDITOR "Build property editor code for the editor setup. Due to hardcore templates, this takes amazingly long time to build, so it makes sense to turn it off sometimes." ${DEFAULT_OPT})

set(BUILD_IN_CONSOLE_MODE OFF CACHE STRING "0")

## Build optimization switches.
## These may speed up build times.

option(GENERATE_DEBUG_INFORMATION "Generate source-level debug information. If 0, -g flag will be removed to speed up the build." ${DEFAULT_OPT})

## Runtime optimization switches.

# Don't happily turn everything ON because optimizations take a lot of build time,
# and you probably don't need the runtime to be as fast as light, at least for now.

option(ENABLE_LINK_TIME_OPTIMIZATION "Some ultra extra optimizations for Release builds. Takes a lot longer to build." OFF)

if (ULTRA_OPTS)
	message("Enabling ultra optimizations.")
	set(ENABLE_LINK_TIME_OPTIMIZATION ON)
endif()

# If this variable is nonzero, the cosmos will use a statically allocated number
# of entities, drastically improving access performance. Might be very useful for a sever application.
# Pros: 
# 	+ Dereferencing entities with speed of light
# Cons:
#	- Compilation might be longer due to component includes needed everywhere
#	- Can't tweak maximum number of entities at runtime
#	- Even empty game worlds occupy as much space as those filled to the maximum

set(STATICALLY_ALLOCATE_ENTITIES "1" CACHE STRING "Statically allocate entities in the cosmos")

# If this variable is nonzero, the cosmos common will use a statically allocated number
# of entity flavours, drastically improving access performance. Might be very useful for a sever application.
{'fraction_non_alphanumeric': 0.08443548387096775, 'fraction_numerical': 0.0022580645161290325, 'mean_word_length': 5.739673913043478, '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': '3044756', 'n_tokens_mistral': 3743, 'n_tokens_neox': 3519, 'n_words': 1450}