cmake_minimum_required(VERSION 3.22)

project(Phoenix)

find_package(PhoenixCMake REQUIRED)

set(PROJECT_VERSION "2.3.1") # this line is updated by semantic release using regex

phoenix_base_project("PhoenixGenerator" "${PROJECT_VERSION}"
		"Set of tools to generate code"
		"https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS2/code-generator/PhoenixGenerator")

pull_extra_module("PhoenixCore" "https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS2/system/PhoenixCore.git")
pull_extra_module("PhoenixFileParser" "https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS2/config/PhoenixFileParser.git")
pull_extra_module("PhoenixToml" "https://gitlab.in2p3.fr/CTA-LAPP/PHOENIX_LIBS2/config/PhoenixToml.git")

phoenix_include_directories(
	${CMAKE_CURRENT_SOURCE_DIR}
	${CMAKE_CURRENT_BINARY_DIR}
	${CMAKE_CURRENT_SOURCE_DIR}/src
)


include(src/phoenix_create_trait_backend.cmake)
include_directories(
	${CMAKE_CURRENT_SOURCE_DIR}/src/Representation
	${CMAKE_CURRENT_SOURCE_DIR}/src/FrontEnd
	${CMAKE_CURRENT_SOURCE_DIR}/src/BackEnd
)
phoenix_add_subdirectory(src)
phoenix_add_subdirectory(share)

phoenix_create_find_full(PhoenixGenerator
	"simple_project_generator.h"
	"phoenix_generator;phoenix_generator_backend;${PHOENIX_GENERATOR_TRAIT_LIST_LIB};phoenix_generator_frontend;phoenix_generator_representation"
	""
	""
	PhoenixCore PhoenixFileParser PhoenixToml
)
#TODO : Here at some point we wille have a list of trait names to link and include automatically in the phoenix_generator_backend
#Something like set(PHOENIX_GENERATOR_TRAIT_NAME CppTraitSetter)
# or phoenix_add_trait_backend(CppTraitSetter CPP) and will update automatically PHOENIX_GENERATOR_TRAIT_LIST_LIB and PHOENIX_GENERATOR_TRAIT_INCLUDE

set(PHOENIX_GENERATOR_BASE_DEPENDENCIES phoenix_generator_backend phoenix_generator_frontend phoenix_generator_representation phoenix_toml phoenix_file_parser phoenix_core)

set(PHOENIX_GENERATOR_DEPENDENCIES
	phoenix_generator phoenix_generator_backend ${PHOENIX_GENERATOR_TRAIT_LIST_LIB} ${PHOENIX_GENERATOR_BASE_DEPENDENCIES}
)

# Copy share files to the build directory for tests that need them
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/share DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/TESTS)
phoenix_tests()
