Add CPM support
This commit is contained in:
parent
9982b60400
commit
a6d74aff8f
1 changed files with 32 additions and 3 deletions
|
@ -2,11 +2,35 @@ cmake_minimum_required(VERSION 3.27)
|
|||
project(utempl
|
||||
VERSION 0.1)
|
||||
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)
|
||||
set(BOOST_INCLUDE_LIBRARIES "pfr")
|
||||
option(CPM_USE_LOCAL_PACKAGES "Use local packages" ON)
|
||||
|
||||
|
||||
file(
|
||||
DOWNLOAD
|
||||
https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.40.0/CPM.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake
|
||||
EXPECTED_HASH
|
||||
SHA256=7b354f3a5976c4626c876850c93944e52c83ec59a159ae5de5be7983f0e17a2a
|
||||
)
|
||||
include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME Boost
|
||||
VERSION 1.85.0
|
||||
URL "https://github.com/boostorg/boost/releases/download/boost-1.85.0/boost-1.85.0-cmake.tar.xz"
|
||||
EXCLUDE_FROM_ALL ON
|
||||
OPTIONS "BOOST_SKIP_INSTALL_RULES OFF"
|
||||
)
|
||||
|
||||
CPMAddPackage("gh:fmtlib/fmt#10.2.1")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cmake_policy(SET CMP0079 NEW)
|
||||
|
||||
|
@ -16,8 +40,13 @@ target_include_directories(
|
|||
utempl
|
||||
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
target_link_libraries(utempl INTERFACE fmt::fmt-header-only ${Boost_LIBRARIES})
|
||||
|
||||
if(TARGET Boost::pfr)
|
||||
target_link_libraries(utempl INTERFACE fmt::fmt-header-only Boost::pfr)
|
||||
else()
|
||||
find_package(Boost 1.85.0 REQUIRED)
|
||||
target_link_libraries(utempl INTERFACE fmt::fmt-header-only ${Boost_LIBRARIES})
|
||||
endif()
|
||||
target_compile_features(utempl INTERFACE cxx_std_20)
|
||||
|
||||
install(TARGETS utempl
|
||||
|
|
Loading…
Reference in a new issue