forked from boostorg/mp11
Update CMakeLists.txt acc. to latest superproject fashion
This commit is contained in:
@ -2,9 +2,9 @@
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
project(BoostMp11 VERSION 1.73.0 LANGUAGES CXX)
|
||||
project(boost_mp11 VERSION 1.73.0 LANGUAGES CXX)
|
||||
|
||||
add_library(boost_mp11 INTERFACE)
|
||||
set_property(TARGET boost_mp11 PROPERTY EXPORT_NAME mp11)
|
||||
@ -16,7 +16,9 @@ target_compile_features(boost_mp11 INTERFACE cxx_alias_templates cxx_variadic_te
|
||||
|
||||
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
|
||||
# --target check
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
# Testing
|
||||
|
||||
# `function` confuses FetchContent, sees empty CMAKE_CURRENT_LIST_DIR
|
||||
macro(fetch_and_include name)
|
||||
@ -33,39 +35,40 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
endmacro()
|
||||
|
||||
fetch_and_include(cmake/boost_fetch.cmake)
|
||||
fetch_and_include(cmake/boost_test.cmake)
|
||||
|
||||
boost_fetch(boostorg/assert TAG develop)
|
||||
boost_fetch(boostorg/config TAG develop)
|
||||
boost_fetch(boostorg/core TAG develop)
|
||||
|
||||
enable_testing()
|
||||
include(CTest)
|
||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
|
||||
|
||||
# --target install
|
||||
|
||||
set(CONFIG_INSTALL_DIR lib/cmake/${PROJECT_NAME}-${PROJECT_VERSION})
|
||||
|
||||
install(TARGETS boost_mp11 EXPORT ${PROJECT_NAME}Targets)
|
||||
install(EXPORT ${PROJECT_NAME}Targets DESTINATION ${CONFIG_INSTALL_DIR} NAMESPACE Boost:: FILE ${PROJECT_NAME}Config.cmake)
|
||||
|
||||
install(DIRECTORY include/ DESTINATION include)
|
||||
# Installation
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
set(LIB boost_mp11)
|
||||
set(CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${LIB}-${PROJECT_VERSION})
|
||||
|
||||
install(TARGETS ${LIB} EXPORT ${LIB}-targets)
|
||||
install(EXPORT ${LIB}-targets DESTINATION ${CONFIG_INSTALL_DIR} NAMESPACE Boost:: FILE ${LIB}-config.cmake)
|
||||
|
||||
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
# Mp11 is independent of 32/64, so this hack makes BoostMp11ConfigVersion.cmake skip the check
|
||||
set(OLD_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
|
||||
unset(CMAKE_SIZEOF_VOID_P)
|
||||
write_basic_package_version_file("${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" COMPATIBILITY AnyNewerVersion)
|
||||
write_basic_package_version_file("${PROJECT_BINARY_DIR}/${LIB}-config-version.cmake" COMPATIBILITY AnyNewerVersion)
|
||||
set(CMAKE_SIZEOF_VOID_P ${OLD_CMAKE_SIZEOF_VOID_P})
|
||||
|
||||
install(FILES "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" DESTINATION ${CONFIG_INSTALL_DIR})
|
||||
install(FILES "${PROJECT_BINARY_DIR}/${LIB}-config-version.cmake" DESTINATION ${CONFIG_INSTALL_DIR})
|
||||
|
||||
#export(EXPORT ${PROJECT_NAME}Targets NAMESPACE Boost:: FILE ${PROJECT_NAME}Config.cmake)
|
||||
|
||||
endif()
|
||||
|
||||
if(COMMAND boost_test)
|
||||
if(BUILD_TESTING)
|
||||
|
||||
add_subdirectory(test)
|
||||
|
||||
|
24
cmake/BoostMessage.cmake
Normal file
24
cmake/BoostMessage.cmake
Normal file
@ -0,0 +1,24 @@
|
||||
# Copyright 2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
function(boost_message type)
|
||||
|
||||
if(type STREQUAL "VERBOSE" OR type STREQUAL "DEBUG")
|
||||
if(Boost_${type})
|
||||
set(type STATUS)
|
||||
elseif(CMAKE_VERSION VERSION_LESS 3.15)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(m "")
|
||||
math(EXPR last "${ARGC}-1")
|
||||
|
||||
foreach(i RANGE 1 ${last})
|
||||
set(m "${m}${ARGV${i}}")
|
||||
endforeach()
|
||||
|
||||
message(${type} "${m}")
|
||||
|
||||
endfunction()
|
71
cmake/BoostTest.cmake
Normal file
71
cmake/BoostTest.cmake
Normal file
@ -0,0 +1,71 @@
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
function(boost_test)
|
||||
|
||||
cmake_parse_arguments(_ "" "TYPE;PREFIX;NAME" "SOURCES;LIBRARIES;ARGUMENTS" ${ARGN})
|
||||
|
||||
if(NOT __TYPE)
|
||||
set(__TYPE run)
|
||||
endif()
|
||||
|
||||
if(NOT __PREFIX)
|
||||
set(__PREFIX ${PROJECT_NAME})
|
||||
endif()
|
||||
|
||||
if(NOT __NAME)
|
||||
list(GET __SOURCES 0 __NAME)
|
||||
string(MAKE_C_IDENTIFIER ${__NAME} __NAME)
|
||||
endif()
|
||||
|
||||
set(__NAME ${__PREFIX}-${__NAME})
|
||||
|
||||
if(__TYPE STREQUAL "compile" OR __TYPE STREQUAL "compile-fail")
|
||||
|
||||
add_library(${__NAME} STATIC EXCLUDE_FROM_ALL ${__SOURCES})
|
||||
target_link_libraries(${__NAME} ${__LIBRARIES})
|
||||
|
||||
add_test(NAME compile-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${__NAME} --config $<CONFIG>)
|
||||
|
||||
if(__TYPE STREQUAL "compile-fail")
|
||||
set_tests_properties(compile-${__NAME} PROPERTIES WILL_FAIL TRUE)
|
||||
endif()
|
||||
|
||||
elseif(__TYPE STREQUAL "link")
|
||||
|
||||
add_executable(${__NAME} EXCLUDE_FROM_ALL ${__SOURCES})
|
||||
target_link_libraries(${__NAME} ${__LIBRARIES})
|
||||
|
||||
add_test(NAME link-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${__NAME} --config $<CONFIG>)
|
||||
|
||||
elseif(__TYPE STREQUAL "link-fail")
|
||||
|
||||
add_library(compile-${__NAME} STATIC EXCLUDE_FROM_ALL ${__SOURCES})
|
||||
target_link_libraries(compile-${__NAME} ${__LIBRARIES})
|
||||
|
||||
add_test(NAME compile-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target compile-${__NAME} --config $<CONFIG>)
|
||||
|
||||
add_executable(${__NAME} EXCLUDE_FROM_ALL ${__SOURCES})
|
||||
target_link_libraries(${__NAME} ${__LIBRARIES})
|
||||
|
||||
add_test(NAME link-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${__NAME} --config $<CONFIG>)
|
||||
set_tests_properties(link-${__NAME} PROPERTIES WILL_FAIL TRUE)
|
||||
|
||||
elseif(__TYPE STREQUAL "run" OR __TYPE STREQUAL "run-fail")
|
||||
|
||||
add_executable(${__NAME} EXCLUDE_FROM_ALL ${__SOURCES})
|
||||
target_link_libraries(${__NAME} ${__LIBRARIES})
|
||||
|
||||
add_test(NAME compile-${__NAME} COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target ${__NAME} --config $<CONFIG>)
|
||||
|
||||
add_test(NAME run-${__NAME} COMMAND ${__NAME} ${__ARGUMENTS})
|
||||
set_tests_properties(run-${__NAME} PROPERTIES DEPENDS compile-${__NAME})
|
||||
|
||||
if(__TYPE STREQUAL "run-fail")
|
||||
set_tests_properties(run-${__NAME} PROPERTIES WILL_FAIL TRUE)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
endfunction(boost_test)
|
43
cmake/BoostTestJamfile.cmake
Normal file
43
cmake/BoostTestJamfile.cmake
Normal file
@ -0,0 +1,43 @@
|
||||
# Copyright 2018, 2019 Peter Dimov
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
include(BoostTest)
|
||||
include(BoostMessage)
|
||||
|
||||
function(boost_test_jamfile)
|
||||
|
||||
cmake_parse_arguments(_ "" "FILE;PREFIX" "LIBRARIES" ${ARGN})
|
||||
|
||||
file(STRINGS ${__FILE} data)
|
||||
|
||||
set(types compile compile-fail link link-fail run run-fail)
|
||||
|
||||
foreach(line IN LISTS data)
|
||||
if(line)
|
||||
|
||||
string(REGEX MATCHALL "[^ ]+" ll ${line})
|
||||
|
||||
if(ll)
|
||||
list(GET ll 0 e0)
|
||||
|
||||
if(e0 IN_LIST types)
|
||||
|
||||
list(LENGTH ll lln)
|
||||
|
||||
if(NOT lln EQUAL 2)
|
||||
|
||||
boost_message(DEBUG "Jamfile line ignored: ${line}")
|
||||
|
||||
else()
|
||||
|
||||
list(GET ll 1 e1)
|
||||
boost_test(PREFIX ${__PREFIX} TYPE ${e0} SOURCES ${e1} LIBRARIES ${__LIBRARIES})
|
||||
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endforeach(line)
|
||||
|
||||
endfunction(boost_test_jamfile)
|
@ -2,5 +2,7 @@
|
||||
# Distributed under the Boost Software License, Version 1.0.
|
||||
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
include(BoostTestJamfile)
|
||||
|
||||
boost_test_jamfile(FILE Jamfile LIBRARIES Boost::mp11 Boost::core)
|
||||
boost_test(SOURCES check_cmake_version.cpp ARGUMENTS ${PROJECT_VERSION} LIBRARIES Boost::core Boost::config)
|
||||
|
Reference in New Issue
Block a user