update CMakeLists.txt

fix #4
This commit is contained in:
alandefreitas
2022-10-31 21:35:37 -03:00
committed by Alan de Freitas
parent 7822f1b991
commit 3e9489a7af
2 changed files with 109 additions and 160 deletions

View File

@ -1,32 +1,5 @@
# Generated by `boostdep --cmake static_string`
# Copyright 2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_static_string VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_library(boost_static_string INTERFACE)
add_library(Boost::static_string ALIAS boost_static_string)
target_include_directories(boost_static_string INTERFACE include)
target_link_libraries(boost_static_string
INTERFACE
Boost::assert
Boost::container_hash
Boost::static_assert
Boost::throw_exception
Boost::utility
)
else()
# #
# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) # Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
# #
# Distributed under the Boost Software License, Version 1.0. (See accompanying # 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) # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -34,140 +7,111 @@ else()
# Official repository: https://github.com/boostorg/static_string # Official repository: https://github.com/boostorg/static_string
# #
#------------------------------------------------------------------------------- cmake_minimum_required(VERSION 3.5...3.16)
function (DoGroupSources curdir rootdir folder) project(boost_static_string VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
file (GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*)
foreach (child ${children})
if (IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})
DoGroupSources (${curdir}/${child} ${rootdir} ${folder})
elseif (${child} STREQUAL "CMakeLists.txt")
source_group("" FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
else()
string (REGEX REPLACE ^${rootdir} ${folder} groupname ${curdir})
string (REPLACE "/" "\\" groupname ${groupname})
source_group (${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
endif()
endforeach()
endfunction()
function (GroupSources curdir folder) set(BOOST_STATIC_STRING_IS_ROOT OFF)
DoGroupSources (${curdir} ${curdir} ${folder}) if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endfunction() set(BOOST_STATIC_STRING_IS_ROOT ON)
endif ()
#------------------------------------------------------------------------------- if (BOOST_STATIC_STRING_IS_ROOT)
# include(CTest)
# StaticString endif ()
#
#-------------------------------------------------------------------------------
set_property (GLOBAL PROPERTY USE_FOLDERS ON) # Options
if (NOT BOOST_SUPERPROJECT_VERSION)
option(BOOST_STATIC_STRING_INSTALL "Install boost::static_string files" ${BOOST_STATIC_STRING_IS_ROOT})
option(BOOST_STATIC_STRING_BUILD_TESTS "Build boost::static_string tests" ${BUILD_TESTING})
else ()
set(BOOST_STATIC_STRING_BUILD_TESTS ${BUILD_TESTING})
endif ()
if (MSVC) # Find boost
set (CMAKE_VERBOSE_MAKEFILE FALSE) if (BOOST_SUPERPROJECT_VERSION)
set(BOOST_STATIC_STRING_FIND_PACKAGE_BOOST OFF)
elseif (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeLists.txt" AND
EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../Jamroot" AND
EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../boost-build.jam" AND
EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../bootstrap.sh" AND
EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../libs")
set(BOOST_STATIC_STRING_FIND_PACKAGE_BOOST OFF)
else ()
set(BOOST_STATIC_STRING_FIND_PACKAGE_BOOST ON)
endif ()
add_definitions ( if (BOOST_STATIC_STRING_FIND_PACKAGE_BOOST)
-D_WIN32_WINNT=0x0601 find_package(Boost 1.78.0 REQUIRED COMPONENTS container)
) elseif (BOOST_STATIC_STRING_IS_ROOT)
set(BOOST_STATIC_STRING_UNIT_TEST_LIBRARIES core)
set(BOOST_INCLUDE_LIBRARIES static_string assert container_hash static_assert throw_exception utility ${BOOST_STATIC_STRING_UNIT_TEST_LIBRARIES})
set(BOOST_EXCLUDE_LIBRARIES static_string)
set(CMAKE_FOLDER Dependencies)
add_subdirectory(../.. Dependencies/boost EXCLUDE_FROM_ALL)
unset(CMAKE_FOLDER)
endif ()
add_compile_options( # Sources
/permissive- # strict C++ include(GNUInstallDirs)
/W4 # enable all warnings file(GLOB_RECURSE BOOST_STATIC_STRING_HEADERS CONFIGURE_DEPENDS
/MP # Multi-processor compilation include/boost/*.hpp
include/boost/*.ipp
include/boost/*.natvis
) )
set (Boost_USE_STATIC_LIBS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set (Boost_USE_STATIC_RUNTIME ON) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/include/boost PREFIX "" FILES ${BOOST_STATIC_STRING_HEADERS})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/src PREFIX "" FILES ${BOOST_STATIC_STRING_SOURCES})
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") # Target
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ob2 /Oi /Ot /GL /MT") add_library(boost_static_string INTERFACE)
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Oi /Ot /MT") add_library(Boost::static_string ALIAS boost_static_string)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") target_compile_features(boost_static_string INTERFACE cxx_constexpr)
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG") if (BOOST_SUPERPROJECT_VERSION)
target_include_directories(boost_static_string INTERFACE "${PROJECT_SOURCE_DIR}/include")
else ()
target_include_directories(boost_static_string
INTERFACE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
endif ()
# for RelWithDebInfo builds, disable incremental linking if (BOOST_STATIC_STRING_FIND_PACKAGE_BOOST)
# since CMake sets it ON by default for that build type and it target_link_libraries(boost_static_string
# causes warnings INTERFACE
# Boost::headers
string (REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" replacement_flags )
${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}) else ()
set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${replacement_flags}) target_link_libraries(boost_static_string
INTERFACE
Boost::assert
Boost::container_hash
Boost::static_assert
Boost::throw_exception
Boost::utility
)
endif ()
else() if (BOOST_STATIC_STRING_INSTALL AND NOT BOOST_SUPERPROJECT_VERSION)
set (THREADS_PREFER_PTHREAD_FLAG ON) install(TARGETS boost_static_string
find_package (Threads) RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
set( CMAKE_CXX_FLAGS install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/boost
"${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wpedantic -Wno-unused-parameter") DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.ipp"
)
endif ()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wrange-loop-analysis")
endif ()
endif()
# Must come before Boost includes, otherwise the if (BOOST_STATIC_STRING_BUILD_TESTS)
# IDE sees the wrong file due to boost/ symlinks. add_subdirectory(test)
include_directories (include) endif ()
#-------------------------------------------------------------------------------
#
# Boost
#
#-------------------------------------------------------------------------------
get_filename_component (BOOST_ROOT ../../ ABSOLUTE)
# VFALCO I want static but "b2 stage" builds a minimal set which excludes static
add_definitions (-DBOOST_ALL_STATIC_LINK=1)
include_directories (${BOOST_ROOT})
link_directories(${BOOST_ROOT}/stage/lib)
#-------------------------------------------------------------------------------
if ("${VARIANT}" STREQUAL "coverage")
if (MSVC)
else()
set (CMAKE_BUILD_TYPE DEBUG)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2 --coverage")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif()
elseif ("${VARIANT}" STREQUAL "ubasan")
if (MSVC)
else()
set (CMAKE_BUILD_TYPE RELWITHDEBINFO)
set (CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/tools/blacklist.supp")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined -fno-sanitize-recover=address,undefined")
endif()
elseif ("${VARIANT}" STREQUAL "debug")
set (CMAKE_BUILD_TYPE DEBUG)
elseif ("${VARIANT}" STREQUAL "release")
set (CMAKE_BUILD_TYPE RELEASE)
endif()
#-------------------------------------------------------------------------------
#GroupSources (test "/")
#-------------------------------------------------------------------------------
#
# Tests and examples
#
#include_directories (.)
file (GLOB_RECURSE PROJECT_FILES
${PROJECT_SOURCE_DIR}/include/boost/static_string/*.hpp
${PROJECT_SOURCE_DIR}/include/boost/static_string/*.ipp
)
add_subdirectory (test)
endif()

View File

@ -1,5 +1,5 @@
# #
# Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com) # Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com)
# #
# Distributed under the Boost Software License, Version 1.0. (See accompanying # 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) # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@ -7,16 +7,21 @@
# Official repository: https://github.com/boostorg/static_string # Official repository: https://github.com/boostorg/static_string
# #
GroupSources (include/boost/static_string static_string) set(BOOST_STATIC_STRING_TESTS_FILES
GroupSources (test "/") CMakeLists.txt
Jamfile
constexpr_tests.hpp
compile_fail.hpp
static_string.cpp
)
add_executable (tests source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${BOOST_STATIC_STRING_TESTS_FILES})
${PROJECT_FILES} add_executable(boost_static_string_tests ${BOOST_STATIC_STRING_TESTS_FILES})
Jamfile
static_string.cpp
)
target_link_libraries(tests # The include dependencies are found in the CMakeLists.txt
) # of the root project directory.
# See: BOOST_STATIC_STRING_UNIT_TEST_LIBRARIES
set_property(TARGET tests PROPERTY FOLDER "tests") target_link_libraries(boost_static_string_tests PRIVATE
Boost::static_string
Boost::core)
add_test(NAME boost_static_string_tests COMMAND boost_static_string_tests)