mirror of
https://github.com/fraillt/bitsery.git
synced 2026-06-08 08:13:56 +00:00
58 lines
1.9 KiB
CMake
58 lines
1.9 KiB
CMake
cmake_minimum_required(VERSION 3.1)
|
|
project(bitsery
|
|
LANGUAGES CXX
|
|
VERSION 4.6.1)
|
|
|
|
#======== build options ===================================
|
|
option(BITSERY_BUILD_EXAMPLES "Build examples" OFF)
|
|
option(BITSERY_BUILD_TESTS "Build tests" OFF)
|
|
|
|
#============= setup target ======================
|
|
add_library(bitsery INTERFACE)
|
|
# create alias, so that user could always write target_link_libraries(... Bitsery::bitsery)
|
|
# despite of bitsery target is imported or not
|
|
add_library(Bitsery::bitsery ALIAS bitsery)
|
|
|
|
include(GNUInstallDirs)
|
|
target_include_directories(bitsery INTERFACE
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
|
target_compile_features(bitsery INTERFACE
|
|
cxx_auto_type
|
|
cxx_constexpr
|
|
cxx_lambdas
|
|
cxx_nullptr
|
|
cxx_variadic_templates)
|
|
|
|
#=============== setup installation =======================
|
|
include(CMakePackageConfigHelpers)
|
|
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/BitseryConfigVersion.cmake
|
|
COMPATIBILITY SameMajorVersion)
|
|
install(TARGETS bitsery
|
|
EXPORT bitseryTargets
|
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
install(EXPORT bitseryTargets
|
|
FILE "BitseryConfig.cmake"
|
|
NAMESPACE Bitsery::
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/bitsery)
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/BitseryConfigVersion.cmake
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/bitsery)
|
|
install(DIRECTORY include/bitsery
|
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
|
|
#================ handle sub-projects =====================
|
|
|
|
if (BITSERY_BUILD_EXAMPLES)
|
|
message("build bitsery examples")
|
|
add_subdirectory(examples)
|
|
else()
|
|
message("skip bitsery examples")
|
|
endif()
|
|
|
|
if (BITSERY_BUILD_TESTS)
|
|
message("build bitsery tests")
|
|
add_subdirectory(tests)
|
|
else()
|
|
message("skip bitsery tests")
|
|
endif()
|