# This file is automatically generated from cmake.toml - DO NOT EDIT
# See https://github.com/build-cpp/cmkr for more information

cmake_minimum_required(VERSION 3.15)

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
	message(FATAL_ERROR "In-tree builds are not supported. Run CMake from a separate directory: cmake -B build")
endif()

# Enable support for MSVC_RUNTIME_LIBRARY
cmake_policy(SET CMP0091 NEW)

set(CMKR_ROOT_PROJECT OFF)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
	set(CMKR_ROOT_PROJECT ON)

	# Bootstrap cmkr and automatically regenerate CMakeLists.txt
	include(cmkr.cmake OPTIONAL RESULT_VARIABLE CMKR_INCLUDE_RESULT)
	if(CMKR_INCLUDE_RESULT)
		cmkr()
	endif()

	# Enable folder support
	set_property(GLOBAL PROPERTY USE_FOLDERS ON)

	# Create a configure-time dependency on cmake.toml to improve IDE support
	set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS cmake.toml)
	if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
		set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
	endif()

endif()

# Options
option(LIBPL_ENABLE_CLI "" OFF)

project(PatternLanguage)

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
    add_compile_definitions(FMT_USE_CONSTEVAL=0)
endif()

include(FetchContent)

# Fix warnings about DOWNLOAD_EXTRACT_TIMESTAMP
if(POLICY CMP0135)
	cmake_policy(SET CMP0135 NEW)
endif()
message(STATUS "Fetching PatternLanguage (a9a93ab56b7808cb5d551ff94d7bad8a3c963618)...")
FetchContent_Declare(PatternLanguage
	GIT_REPOSITORY
		"https://github.com/WerWolv/PatternLanguage"
	GIT_TAG
		a9a93ab56b7808cb5d551ff94d7bad8a3c963618
)
FetchContent_MakeAvailable(PatternLanguage)

# Target: PatternLanguage
set(PatternLanguage_SOURCES
	cmake.toml
	"src/PatternLanguage.cpp"
	"src/PatternLanguage.h"
)

add_library(PatternLanguage SHARED)

target_sources(PatternLanguage PRIVATE ${PatternLanguage_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${PatternLanguage_SOURCES})

target_compile_features(PatternLanguage PUBLIC
	cxx_std_23
)

if(NOT TARGET libpl)
	message(FATAL_ERROR "Target \"libpl\" referenced by \"PatternLanguage\" does not exist!")
endif()

if(NOT TARGET libpl-gen)
	message(FATAL_ERROR "Target \"libpl-gen\" referenced by \"PatternLanguage\" does not exist!")
endif()

target_link_libraries(PatternLanguage PUBLIC
	libpl
	libpl-gen
	fmt::fmt-header-only
)

set_target_properties(PatternLanguage PROPERTIES
	OUTPUT_NAME
		PatternLanguage
	PREFIX
		""
	IMPORT_PREFIX
		""
)

# Target: example
set(example_SOURCES
	cmake.toml
	"src/example.cpp"
)

add_executable(example)

target_sources(example PRIVATE ${example_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${example_SOURCES})

if(NOT TARGET PatternLanguage)
	message(FATAL_ERROR "Target \"PatternLanguage\" referenced by \"example\" does not exist!")
endif()

target_link_libraries(example PRIVATE
	PatternLanguage
)

get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
	set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT example)
endif()
