nameof_module/CMakeLists.txt

50 lines
1.4 KiB
Text
Raw Normal View History

2019-03-12 13:55:56 +00:00
cmake_minimum_required(VERSION 3.6)
2018-03-26 12:02:43 +00:00
2019-04-18 17:00:59 +00:00
project(nameof VERSION "0.8.1" LANGUAGES CXX)
2018-09-04 14:41:01 +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})
2018-09-04 14:41:01 +00:00
if(NAMEOF_OPT_BUILD_EXAMPLES)
add_subdirectory(example)
endif()
2018-03-27 09:03:12 +00:00
2018-09-04 14:41:01 +00:00
if(NAMEOF_OPT_BUILD_TESTS)
enable_testing()
add_subdirectory(test)
endif()
2019-04-23 13:18:39 +00:00
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME}
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion)
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
PUBLIC_HEADER DESTINATION include
INCLUDES DESTINATION include)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION lib/cmake/${PROJECT_NAME})
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE ${PROJECT_NAME}::
DESTINATION lib/cmake/${PROJECT_NAME})
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include
DESTINATION include)