utempl/CMakeLists.txt
2024-02-28 23:18:15 +00:00

32 lines
1.2 KiB
CMake

cmake_minimum_required(VERSION 3.27)
project(utempl)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(fmt REQUIRED)
find_package(Boost 1.84.0 REQUIRED)
set(CMAKE_CXX_STANDART 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CXX_EXTENSIONS NO)
add_library(utempl INTERFACE)
target_link_libraries(utempl INTERFACE fmt::fmt-header-only ${Boost_LIBRARIES})
if(ENABLE_TESTS)
find_package(GTest REQUIRED)
enable_testing()
file(GLOB SOURCES tests/* tests/*/* tests/*/*/*)
add_executable(utempl_tests ${SOURCES})
target_link_libraries(utempl_tests GTest::gtest_main utempl)
set_property(TARGET utempl_tests PROPERTY CXX_STANDARD 20)
include(GoogleTest)
gtest_discover_tests(utempl_tests)
endif()
if(ENABLE_EXAMPLES)
file(GLOB EXAMPLES_SRC "examples/src/*.cpp")
foreach(EXAMPLE_SRC ${EXAMPLES_SRC})
get_filename_component(EXAMPLE_NAME ${EXAMPLE_SRC} NAME_WE)
add_executable(${EXAMPLE_NAME} ${EXAMPLE_SRC})
target_link_libraries(${EXAMPLE_NAME} utempl)
set_property(TARGET ${EXAMPLE_NAME} PROPERTY CXX_STANDARD 20)
set_target_properties(${EXAMPLE_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/examples/")
endforeach()
endif()
target_include_directories(utempl INTERFACE include)