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
# 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
#
#-------------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.5...3.16)
function (DoGroupSources curdir rootdir folder)
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()
project(boost_static_string VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
function (GroupSources curdir folder)
DoGroupSources (${curdir} ${curdir} ${folder})
endfunction()
set(BOOST_STATIC_STRING_IS_ROOT OFF)
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(BOOST_STATIC_STRING_IS_ROOT ON)
endif ()
#-------------------------------------------------------------------------------
#
# StaticString
#
#-------------------------------------------------------------------------------
if (BOOST_STATIC_STRING_IS_ROOT)
include(CTest)
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)
set (CMAKE_VERBOSE_MAKEFILE FALSE)
# Find boost
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 (
-D_WIN32_WINNT=0x0601
)
if (BOOST_STATIC_STRING_FIND_PACKAGE_BOOST)
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(
/permissive- # strict C++
/W4 # enable all warnings
/MP # Multi-processor compilation
# Sources
include(GNUInstallDirs)
file(GLOB_RECURSE BOOST_STATIC_STRING_HEADERS CONFIGURE_DEPENDS
include/boost/*.hpp
include/boost/*.ipp
include/boost/*.natvis
)
set (Boost_USE_STATIC_LIBS ON)
set (Boost_USE_STATIC_RUNTIME ON)
set_property(GLOBAL PROPERTY USE_FOLDERS 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")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ob2 /Oi /Ot /GL /MT")
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Oi /Ot /MT")
# Target
add_library(boost_static_string INTERFACE)
add_library(Boost::static_string ALIAS boost_static_string)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
target_compile_features(boost_static_string INTERFACE cxx_constexpr)
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
# since CMake sets it ON by default for that build type and it
# causes warnings
#
string (REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" replacement_flags
${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${replacement_flags})
if (BOOST_STATIC_STRING_FIND_PACKAGE_BOOST)
target_link_libraries(boost_static_string
INTERFACE
Boost::headers
)
else ()
target_link_libraries(boost_static_string
INTERFACE
Boost::assert
Boost::container_hash
Boost::static_assert
Boost::throw_exception
Boost::utility
)
endif ()
else()
set (THREADS_PREFER_PTHREAD_FLAG ON)
find_package (Threads)
if (BOOST_STATIC_STRING_INSTALL AND NOT BOOST_SUPERPROJECT_VERSION)
install(TARGETS boost_static_string
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
set( CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wpedantic -Wno-unused-parameter")
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/boost
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
# IDE sees the wrong file due to boost/ symlinks.
include_directories (include)
if (BOOST_STATIC_STRING_BUILD_TESTS)
add_subdirectory(test)
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
# 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
#
GroupSources (include/boost/static_string static_string)
GroupSources (test "/")
set(BOOST_STATIC_STRING_TESTS_FILES
CMakeLists.txt
Jamfile
constexpr_tests.hpp
compile_fail.hpp
static_string.cpp
)
add_executable (tests
${PROJECT_FILES}
Jamfile
static_string.cpp
)
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${BOOST_STATIC_STRING_TESTS_FILES})
add_executable(boost_static_string_tests ${BOOST_STATIC_STRING_TESTS_FILES})
target_link_libraries(tests
)
set_property(TARGET tests PROPERTY FOLDER "tests")
# The include dependencies are found in the CMakeLists.txt
# of the root project directory.
# See: BOOST_STATIC_STRING_UNIT_TEST_LIBRARIES
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)