<commit_before>cmake_minimum_required(VERSION 3.1)
project(inicpp)

set(SRC_DIR src)
set(INCLUDE_DIR include/inicpp)

set(SOURCE_FILES
	${INCLUDE_DIR}/config.h
	${SRC_DIR}/config.cpp
	${INCLUDE_DIR}/exception.h
	${INCLUDE_DIR}/option.h
	${SRC_DIR}/option.cpp
	${INCLUDE_DIR}/option_schema.h
	${SRC_DIR}/option_schema.cpp
	${INCLUDE_DIR}/parser.h
	${SRC_DIR}/parser.cpp
	${INCLUDE_DIR}/schema.h
	${SRC_DIR}/schema.cpp
	${INCLUDE_DIR}/section.h
	${SRC_DIR}/section.cpp
	${INCLUDE_DIR}/section_schema.h
	${SRC_DIR}/section_schema.cpp
	${INCLUDE_DIR}/types.h
	${INCLUDE_DIR}/string_utils.h
	${SRC_DIR}/string_utils.cpp
	${INCLUDE_DIR}/inicpp.h
	${INCLUDE_DIR}/dll.h
)

# Find header files in include directory
include_directories(${INCLUDE_DIR})

# Set options to disable build of shared and static library
option(BUILD_SHARED "Specifies if shared library is build." ON)
option(BUILD_STATIC "Specifies if static library is build." ON)

# Compile dynamic library
if(BUILD_SHARED)
	add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})
endif()

# Compile static library
if(BUILD_STATIC)
	add_library(${PROJECT_NAME}_static STATIC ${SOURCE_FILES})
endif()

# Use C++17 features
if(UNIX)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Wextra -Wdeprecated -Wconversion -Wold-style-cast -Wformat")
elseif(MSVC)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
endif()

# Set up google testing framework (not compile by default)
set(NO_GOOGLE_TEST OFF CACHE BOOL "Disable google testing framework.  Useful when buidling from a tarball since google testing framework support requires fetching of additional git submodules.")
if(NOT ${NO_GOOGLE_TEST})
	set(gtest_force_shared_crt ON CACHE BOOL "Use shared (DLL) run-time lib even when Google Test is built as static lib.")
	add_subdirectory(vendor/googletest EXCLUDE_FROM_ALL)
endif()

# Add our very own unit tests (not compile by default)
add_subdirectory(tests EXCLUDE_FROM_ALL)

# Add examples programs
add_subdirectory(examples EXCLUDE_FROM_ALL)

# MS Visual C++ specialities
if(MSVC)
	# set different preprocessor macros
	if(BUILD_SHARED)
		# set preprocessor macro for windows exporting of symbols
		set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS "INICPP_DLL;INICPP_EXPORT")
	endif()
endif()


# ========== Install targets - 'sudo make install' ==========
include(GNUInstallDirs)
include(InstallRequiredSystemLibraries)
if(UNIX)
	install(DIRECTORY ${INCLUDE_DIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
	if(BUILD_SHARED)
		install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library)
	endif()
	if(BUILD_STATIC)
		install(TARGETS ${PROJECT_NAME}_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library)<commit_msg>Configure tests and examples only when specified<commit_after>cmake_minimum_required(VERSION 3.1)
project(inicpp)

set(SRC_DIR src)
set(INCLUDE_DIR include/inicpp)

set(SOURCE_FILES
	${INCLUDE_DIR}/config.h
	${SRC_DIR}/config.cpp
	${INCLUDE_DIR}/exception.h
	${INCLUDE_DIR}/option.h
	${SRC_DIR}/option.cpp
	${INCLUDE_DIR}/option_schema.h
	${SRC_DIR}/option_schema.cpp
	${INCLUDE_DIR}/parser.h
	${SRC_DIR}/parser.cpp
	${INCLUDE_DIR}/schema.h
	${SRC_DIR}/schema.cpp
	${INCLUDE_DIR}/section.h
	${SRC_DIR}/section.cpp
	${INCLUDE_DIR}/section_schema.h
	${SRC_DIR}/section_schema.cpp
	${INCLUDE_DIR}/types.h
	${INCLUDE_DIR}/string_utils.h
	${SRC_DIR}/string_utils.cpp
	${INCLUDE_DIR}/inicpp.h
	${INCLUDE_DIR}/dll.h
)

# Find header files in include directory
include_directories(${INCLUDE_DIR})

# Set options to disable build of shared and static library
option(BUILD_SHARED "Specifies if shared library is build." ON)
option(BUILD_STATIC "Specifies if static library is build." ON)
option(INICPP_BUILD_TESTS "Specifies if tests should be built." OFF)
option(INICPP_BUILD_EXAMPLES "Specifies if examples should be built." OFF)

# Compile dynamic library
if(BUILD_SHARED)
	add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})
endif()

# Compile static library
if(BUILD_STATIC)
	add_library(${PROJECT_NAME}_static STATIC ${SOURCE_FILES})
endif()

# Use C++17 features
if(UNIX)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall -Wextra -Wdeprecated -Wconversion -Wold-style-cast -Wformat")
elseif(MSVC)
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
endif()

if(INICPP_BUILD_TESTS)
	# Set up google testing framework (not compile by default)
	set(NO_GOOGLE_TEST OFF CACHE BOOL "Disable google testing framework.  Useful when buidling from a tarball since google testing framework support requires fetching of additional git submodules.")
	if(NOT ${NO_GOOGLE_TEST})
		set(gtest_force_shared_crt ON CACHE BOOL "Use shared (DLL) run-time lib even when Google Test is built as static lib.")
		add_subdirectory(vendor/googletest)
	endif()

	# Add our very own unit tests (not compile by default)
	add_subdirectory(tests)
endif()

if(INICPP_BUILD_EXAMPLES)
	# Add examples programs
	add_subdirectory(examples)
endif()

# MS Visual C++ specialities
if(MSVC)
	# set different preprocessor macros
	if(BUILD_SHARED)
		# set preprocessor macro for windows exporting of symbols
		set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS "INICPP_DLL;INICPP_EXPORT")
	endif()
endif()


# ========== Install targets - 'sudo make install' ==========
include(GNUInstallDirs)
include(InstallRequiredSystemLibraries)
if(UNIX)
	install(DIRECTORY ${INCLUDE_DIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
	if(BUILD_SHARED)
		install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library)
	endif()
	if(BUILD_STATIC)
		install(TARGETS ${PROJECT_NAME}_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT library)
{'fraction_non_alphanumeric': 0.11324072445929312, 'fraction_numerical': 0.002813434148056972, 'mean_word_length': 6.686486486486486, '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': '2827309', 'n_tokens_mistral': 2095, 'n_tokens_neox': 1935, 'n_words': 466}