<commit_before># Use this file to build GDK with CMake: http://cmake.org

project(sampgdk)
cmake_minimum_required(VERSION 2.8.6)

list(APPEND CMAKE_MODULE_PATH "${sampgdk_SOURCE_DIR}/cmake/Modules")

include(AmxConfig)
include(ParseVersionString)

include_directories("include")

set(SUBHOOK_STATIC TRUE)
add_definitions(-DSUBHOOK_STATIC)
add_subdirectory("lib/subhook")
include_directories("lib/subhook")
list(APPEND SAMPGDK_LINK_LIBRARIES subhook)

find_package(PythonInterp 2.6 REQUIRED)

function(run_python_script script input_file output_file)
	execute_process(WORKING_DIRECTORY ${sampgdk_SOURCE_DIR}
		COMMAND ${PYTHON_EXECUTABLE} ${script}
		INPUT_FILE ${input_file}
		OUTPUT_FILE ${output_file}
		ERROR_VARIABLE error)
	if(error)
		message(FATAL_ERROR ${error})
	endif()
endfunction()

file(MAKE_DIRECTORY "src/generated/")
run_python_script("scripts/generate_natives.py" "include/sampgdk/a_objects.h" "src/generated/a_objects-impl.c")
run_python_script("scripts/generate_natives.py" "include/sampgdk/a_players.h" "src/generated/a_players-impl.c")
run_python_script("scripts/generate_natives.py" "include/sampgdk/a_samp.h" "src/generated/a_samp-impl.c")
run_python_script("scripts/generate_natives.py" "include/sampgdk/a_vehicles.h" "src/generated/a_vehicles-impl.c")
run_python_script("scripts/generate_callback_handlers.py" "include/sampgdk/a_samp.h" "src/generated/callback-handlers.c")

file(MAKE_DIRECTORY "include/sampgdk/generated/")
run_python_script("scripts/generate_native_defs.py" "include/sampgdk/a_objects.h" "include/sampgdk/generated/a_objects-defs.h")
run_python_script("scripts/generate_native_defs.py" "include/sampgdk/a_players.h" "include/sampgdk/generated/a_players-defs.h")
run_python_script("scripts/generate_native_defs.py" "include/sampgdk/a_samp.h" "include/sampgdk/generated/a_samp-defs.h")
run_python_script("scripts/generate_native_defs.py" "include/sampgdk/a_vehicles.h" "include/sampgdk/generated/a_vehicles-defs.h")

set(SAMPGDK_HEADERS
	"include/sampgdk/sdk/amx/amx.h"
	"include/sampgdk/sdk/amx/getch.h"
	"include/sampgdk/sdk/amx/sclinux.h"
	"include/sampgdk/sdk/plugincommon.h"
	"include/sampgdk/a_objects.h"
	"include/sampgdk/a_players.h"
	"include/sampgdk/a_samp.h"
	"include/sampgdk/a_vehicles.h"
	"include/sampgdk/amx.h"
	"include/sampgdk/plugin.h"
	"include/sampgdk/config.h"
	"include/sampgdk/core.h"
	"include/sampgdk/export.h"
	"include/sampgdk/version.h"
)

set(SAMPGDK_SOURCES
	"src/sdk/amxplugin.c"
	"src/sdk/plugin.h"
	"src/a_objects.c"
	"src/a_players.c"
	"src/a_samp.c"
	"src/a_vehicles.c"
	"src/callback.c"
	"src/callback.h"
	"src/core.c"
	"src/fakeamx.c"
	"src/fakeamx.h"
	"src/native.c"
	"src/native.h"
	"src/plugin.c"
	"src/plugin.h"
	"src/sampgdk.rc"
	"src/timer.c"
	"src/timer.h"
	"src/util.c"
	"src/util.h"
	"src/version.c"
)

if(WIN32)
	list(APPEND SAMPGDK_SOURCES
		"src/plugin-win32.c"
		"src/timer-win32.c"
	)
elseif(UNIX)
	list(APPEND SAMPGDK_SOURCES
		"src/plugin-linux.c"
		"src/timer-linux.c"
	)
endif()

source_group("src" REGULAR_EXPRESSION "src/[^/\\]+\\..*")
source_group("src\\sdk" REGULAR_EXPRESSION "src/sdk/[^/\\]+\\..*")
source_group("include" REGULAR_EXPRESSION "include/sampgdk/[^/\\]+\\.h")
source_group("include\\sdk" REGULAR_EXPRESSION "include/sampgdk/sdk/[^/\\]+\\.h")
source_group("include\\sdk\\amx" REGULAR_EXPRESSION "include/sampgdk/sdk/amx/[^/\\]+\\.h")

add_library(sampgdk SHARED ${SAMPGDK_HEADERS} ${SAMPGDK_SOURCES})

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(TARGET sampgdk PROPERTY FOLDER "sampgdk")

file(STRINGS "${sampgdk_SOURCE_DIR}/VERSION.txt" VERSION_txt LIMIT_COUNT 1)
list(GET VERSION_txt 0 SAMPGDK_VERSION_STRING)
set(SAMPGDK_VERSION_MAJOR 0)
set(SAMPGDK_VERSION_MINOR 0)
set(SAMPGDK_VERSION_PATCH 0)
set(SAMPGDK_VERSION_TWEAK 0)

parse_version_string(${SAMPGDK_VERSION_STRING} version)
list(LENGTH version length)
if(length GREATER 0)
	list(GET version 0 SAMPGDK_VERSION_MAJOR)
endif()
if(length GREATER 1)
	list(GET version 1 SAMPGDK_VERSION_MINOR)
endif()
if(length GREATER 2)
	list(GET version 2 SAMPGDK_VERSION_PATCH)
endif()
if(length GREATER 3)
	list(GET version 3 SAMPGDK_VERSION_TWEAK)
endif()

configure_file(
	"${sampgdk_SOURCE_DIR}/include/sampgdk/version.h.in"
	"${sampgdk_SOURCE_DIR}/include/sampgdk/version.h"
)

set_target_properties(sampgdk PROPERTIES DEBUG_POSTFIX "_d")
add_definitions(-DIN_SAMPGDK)

if(WIN32)
	set(DEF_FILE "${sampgdk_SOURCE_DIR}/src/sampgdk.def")
	if(MINGW)
		set_property(TARGET sampgdk APPEND_STRING PROPERTY 
			LINK_FLAGS " -Wl,--kill-at --def ${DEF_FILE}")
	else()
		set_property(TARGET sampgdk APPEND_STRING PROPERTY 
			LINK_FLAGS " /DEF:${DEF_FILE}")
	endif()
	set_target_properties(sampgdk PROPERTIES 
		PREFIX      ""
		OUTPUT_NAME "sampgdk${SAMPGDK_VERSION_MAJOR}")
endif()

if(UNIX OR MINGW)
	add_definitions(-DLINUX)
	set_target_properties(sampgdk PROPERTIES 
		VERSION   ${SAMPGDK_VERSION_STRING}
		SOVERSION ${SAMPGDK_VERSION_MAJOR}
	)
	if(MINGW)
		set_property(TARGET sampgdk APPEND_STRING PROPERTY
			LINK_FLAGS " -Wl,--export-all-symbols")
	else()<commit_msg>Fix LINUX being defined on MinGW<commit_after># Use this file to build GDK with CMake: http://cmake.org

project(sampgdk)
cmake_minimum_required(VERSION 2.8.6)

list(APPEND CMAKE_MODULE_PATH "${sampgdk_SOURCE_DIR}/cmake/Modules")

include(AmxConfig)
include(ParseVersionString)

include_directories("include")

set(SUBHOOK_STATIC TRUE)
add_definitions(-DSUBHOOK_STATIC)
add_subdirectory("lib/subhook")
include_directories("lib/subhook")
list(APPEND SAMPGDK_LINK_LIBRARIES subhook)

find_package(PythonInterp 2.6 REQUIRED)

function(run_python_script script input_file output_file)
	execute_process(WORKING_DIRECTORY ${sampgdk_SOURCE_DIR}
		COMMAND ${PYTHON_EXECUTABLE} ${script}
		INPUT_FILE ${input_file}
		OUTPUT_FILE ${output_file}
		ERROR_VARIABLE error)
	if(error)
		message(FATAL_ERROR ${error})
	endif()
endfunction()

file(MAKE_DIRECTORY "src/generated/")
run_python_script("scripts/generate_natives.py" "include/sampgdk/a_objects.h" "src/generated/a_objects-impl.c")
run_python_script("scripts/generate_natives.py" "include/sampgdk/a_players.h" "src/generated/a_players-impl.c")
run_python_script("scripts/generate_natives.py" "include/sampgdk/a_samp.h" "src/generated/a_samp-impl.c")
run_python_script("scripts/generate_natives.py" "include/sampgdk/a_vehicles.h" "src/generated/a_vehicles-impl.c")
run_python_script("scripts/generate_callback_handlers.py" "include/sampgdk/a_samp.h" "src/generated/callback-handlers.c")

file(MAKE_DIRECTORY "include/sampgdk/generated/")
run_python_script("scripts/generate_native_defs.py" "include/sampgdk/a_objects.h" "include/sampgdk/generated/a_objects-defs.h")
run_python_script("scripts/generate_native_defs.py" "include/sampgdk/a_players.h" "include/sampgdk/generated/a_players-defs.h")
run_python_script("scripts/generate_native_defs.py" "include/sampgdk/a_samp.h" "include/sampgdk/generated/a_samp-defs.h")
run_python_script("scripts/generate_native_defs.py" "include/sampgdk/a_vehicles.h" "include/sampgdk/generated/a_vehicles-defs.h")

set(SAMPGDK_HEADERS
	"include/sampgdk/sdk/amx/amx.h"
	"include/sampgdk/sdk/amx/getch.h"
	"include/sampgdk/sdk/amx/sclinux.h"
	"include/sampgdk/sdk/plugincommon.h"
	"include/sampgdk/a_objects.h"
	"include/sampgdk/a_players.h"
	"include/sampgdk/a_samp.h"
	"include/sampgdk/a_vehicles.h"
	"include/sampgdk/amx.h"
	"include/sampgdk/plugin.h"
	"include/sampgdk/config.h"
	"include/sampgdk/core.h"
	"include/sampgdk/export.h"
	"include/sampgdk/version.h"
)

set(SAMPGDK_SOURCES
	"src/sdk/amxplugin.c"
	"src/sdk/plugin.h"
	"src/a_objects.c"
	"src/a_players.c"
	"src/a_samp.c"
	"src/a_vehicles.c"
	"src/callback.c"
	"src/callback.h"
	"src/core.c"
	"src/fakeamx.c"
	"src/fakeamx.h"
	"src/native.c"
	"src/native.h"
	"src/plugin.c"
	"src/plugin.h"
	"src/sampgdk.rc"
	"src/timer.c"
	"src/timer.h"
	"src/util.c"
	"src/util.h"
	"src/version.c"
)

if(WIN32)
	list(APPEND SAMPGDK_SOURCES
		"src/plugin-win32.c"
		"src/timer-win32.c"
	)
elseif(UNIX)
	list(APPEND SAMPGDK_SOURCES
		"src/plugin-linux.c"
		"src/timer-linux.c"
	)
endif()

source_group("src" REGULAR_EXPRESSION "src/[^/\\]+\\..*")
source_group("src\\sdk" REGULAR_EXPRESSION "src/sdk/[^/\\]+\\..*")
source_group("include" REGULAR_EXPRESSION "include/sampgdk/[^/\\]+\\.h")
source_group("include\\sdk" REGULAR_EXPRESSION "include/sampgdk/sdk/[^/\\]+\\.h")
source_group("include\\sdk\\amx" REGULAR_EXPRESSION "include/sampgdk/sdk/amx/[^/\\]+\\.h")

add_library(sampgdk SHARED ${SAMPGDK_HEADERS} ${SAMPGDK_SOURCES})

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(TARGET sampgdk PROPERTY FOLDER "sampgdk")

file(STRINGS "${sampgdk_SOURCE_DIR}/VERSION.txt" VERSION_txt LIMIT_COUNT 1)
list(GET VERSION_txt 0 SAMPGDK_VERSION_STRING)
set(SAMPGDK_VERSION_MAJOR 0)
set(SAMPGDK_VERSION_MINOR 0)
set(SAMPGDK_VERSION_PATCH 0)
set(SAMPGDK_VERSION_TWEAK 0)

parse_version_string(${SAMPGDK_VERSION_STRING} version)
list(LENGTH version length)
if(length GREATER 0)
	list(GET version 0 SAMPGDK_VERSION_MAJOR)
endif()
if(length GREATER 1)
	list(GET version 1 SAMPGDK_VERSION_MINOR)
endif()
if(length GREATER 2)
	list(GET version 2 SAMPGDK_VERSION_PATCH)
endif()
if(length GREATER 3)
	list(GET version 3 SAMPGDK_VERSION_TWEAK)
endif()

configure_file(
	"${sampgdk_SOURCE_DIR}/include/sampgdk/version.h.in"
	"${sampgdk_SOURCE_DIR}/include/sampgdk/version.h"
)

set_target_properties(sampgdk PROPERTIES DEBUG_POSTFIX "_d")
add_definitions(-DIN_SAMPGDK)

if(WIN32)
	set(DEF_FILE "${sampgdk_SOURCE_DIR}/src/sampgdk.def")
	if(MINGW)
		set_property(TARGET sampgdk APPEND_STRING PROPERTY 
			LINK_FLAGS " -Wl,--kill-at --def ${DEF_FILE}")
	else()
		set_property(TARGET sampgdk APPEND_STRING PROPERTY 
			LINK_FLAGS " /DEF:${DEF_FILE}")
	endif()
	set_target_properties(sampgdk PROPERTIES 
		PREFIX      ""
		OUTPUT_NAME "sampgdk${SAMPGDK_VERSION_MAJOR}")
endif()

if(UNIX OR MINGW)
	if(UNIX)
		add_definitions(-DLINUX)
	endif()
	set_target_properties(sampgdk PROPERTIES 
		VERSION   ${SAMPGDK_VERSION_STRING}
		SOVERSION ${SAMPGDK_VERSION_MAJOR}
	)
	if(MINGW)
		set_property(TARGET sampgdk APPEND_STRING PROPERTY
			LINK_FLAGS " -Wl,--export-all-symbols")
	else()
{'fraction_non_alphanumeric': 0.1434357403931641, 'fraction_numerical': 0.005334387039415193, 'mean_word_length': 6.288696904247661, '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': '5165601', 'n_tokens_mistral': 4476, 'n_tokens_neox': 4314, 'n_words': 532}