cmake_minimum_required(VERSION 3.15.2)
# 设置项目名称与语言
project(GCTL_MESH VERSION 1.0)
# 添加配置配件编写的函数
include(CMakePackageConfigHelpers)

message(STATUS "Platform: " ${CMAKE_HOST_SYSTEM_NAME})
message(STATUS "Install prefix: " ${CMAKE_INSTALL_PREFIX})
message(STATUS "Processor: " ${CMAKE_HOST_SYSTEM_PROCESSOR})

find_package(GCTL REQUIRED)
find_package(GCTL_GRAPHIC REQUIRED)
message(STATUS "GCTL Version: " ${GCTL_VERSION})
message(STATUS "GCTL_GRAPHIC Version: " ${GCTL_GRAPHIC_VERSION})
#if(${GCTL_VERSION} LESS 1.0)
#    message(FATAL_ERROR "GCTL's version must be v1.0 or bigger.")
#endif()

option(GCTL_MESH_EXPRTK "Use the exprtk library." ON)
option(GCTL_MESH_WAVELIB "Use the WaveLib library" ON)
# 传递安装地址给编译期宏变量
option(GCTL_MESH_INSTALL_PREFIX "Pass the install directory." ON)
set(DIR_VAR ${CMAKE_INSTALL_PREFIX})

message(STATUS "[GCTL_MESH] Pass the install directory: " ${GCTL_MESH_INSTALL_PREFIX})
message(STATUS "[GCTL_MESH] Use the exprtk library: " ${GCTL_MESH_EXPRTK})
message(STATUS "[GCTL_MESH] Use the WaveLib library: " ${GCTL_MESH_WAVELIB})

if(GCTL_MESH_WAVELIB)
	if(NOT WaveLib_FOUND)
		find_package(WaveLib REQUIRED)
		message(STATUS "Found WaveLib")
		include_directories(${WaveLib_INC_DIR})
	endif()
endif()

# 加入一个头文件配置，让cmake对源码进行操作
configure_file(
	"${PROJECT_SOURCE_DIR}/config.h.in"
	"${PROJECT_SOURCE_DIR}/lib/mesh/gctl_mesh_config.h"
	)

# 添加库源文件地址
add_subdirectory(lib)
add_subdirectory(tool)
add_subdirectory(example)