-
Notifications
You must be signed in to change notification settings - Fork 47
Description
message(STATUS "Using cmake version ${CMAKE_VERSION}")
You shouldn't unconditionally output status messages of this sort; do it only when your library is the root project. Think about what would happen if every library decides to output the CMake version; the user will get 200 messages telling him something he already knows.
cmake_minimum_required(VERSION 3.10...3.16)
What part requires CMake 3.10?
if(BOOST_SUPERPROJECT_VERSION)
project(boost_sort VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
else()
project(boost_sort LANGUAGES CXX)
endif()
The if is unnecessary and only makes things uglier. project(boost_sort LANGUAGES CXX) and project(boost_sort VERSION "" LANGUAGES CXX) are equivalent.
# Test coverage in stand-alone mode requires boost dependencies
if(BUILD_TESTING AND NOT BOOST_SUPERPROJECT_VERSION)
set(Boost_DEBUG ON)
find_package(Boost 1.85 REQUIRED COMPONENTS core range included_test_exec_monitor)
endif()
The condition is wrong; your library can be used via add_subdirectory without the superproject, in which case it shouldn't do this. (Add a cmake_subdir_test for this use case.) This should only be done when the library is the root project.
if(NOT BOOST_SUPERPROJECT_VERSION)
include(CTest)
enable_testing()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
add_dependencies(check tests)
endif()
Same here; this should only be done when the library is the root project, not when it's a subproject.