nameof_module/CMakeLists.txt

55 lines
1.6 KiB
Text
Raw Normal View History

2019-06-08 09:49:31 +00:00
cmake_minimum_required(VERSION 3.8)
2018-03-26 12:02:43 +00:00
2021-01-12 08:39:52 +00:00
project(nameof VERSION "0.10.0" LANGUAGES CXX)
2018-09-04 14:41:01 +00:00
2019-08-24 15:31:42 +00:00
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(IS_TOPLEVEL_PROJECT TRUE)
else()
set(IS_TOPLEVEL_PROJECT FALSE)
endif()
option(NAMEOF_OPT_BUILD_EXAMPLES "Build nameof examples" ${IS_TOPLEVEL_PROJECT})
option(NAMEOF_OPT_BUILD_TESTS "Build and perform nameof tests" ${IS_TOPLEVEL_PROJECT})
2020-12-29 18:45:54 +00:00
option(NAMEOF_OPT_INSTALL "Generate and install nameof target" ${IS_TOPLEVEL_PROJECT})
2018-09-04 14:41:01 +00:00
if(NAMEOF_OPT_BUILD_EXAMPLES)
2019-08-24 15:31:42 +00:00
add_subdirectory(example)
2018-09-04 14:41:01 +00:00
endif()
2018-03-27 09:03:12 +00:00
2018-09-04 14:41:01 +00:00
if(NAMEOF_OPT_BUILD_TESTS)
2019-08-24 15:31:42 +00:00
enable_testing()
add_subdirectory(test)
2018-09-04 14:41:01 +00:00
endif()
2019-04-23 13:18:39 +00:00
include(CMakePackageConfigHelpers)
add_library(${PROJECT_NAME} INTERFACE)
2019-06-08 09:49:31 +00:00
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
2019-04-23 13:18:39 +00:00
target_include_directories(${PROJECT_NAME}
2019-08-24 15:31:42 +00:00
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
2019-04-23 13:18:39 +00:00
write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake
2019-08-24 15:31:42 +00:00
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
2019-04-23 13:18:39 +00:00
2020-12-29 18:45:54 +00:00
if(NAMEOF_OPT_INSTALL)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Config)
2019-04-23 13:18:39 +00:00
2020-12-29 18:45:54 +00:00
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION lib/cmake/${PROJECT_NAME})
2019-04-23 13:18:39 +00:00
2020-12-29 18:45:54 +00:00
install(EXPORT ${PROJECT_NAME}Config
NAMESPACE ${PROJECT_NAME}::
DESTINATION lib/cmake/${PROJECT_NAME})
2019-04-23 13:18:39 +00:00
2020-12-29 18:45:54 +00:00
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include
DESTINATION .)
export(EXPORT ${PROJECT_NAME}Config
NAMESPACE ${PROJECT_NAME}::)
endif()