unicode, cmakes

v1
Brett 2024-02-24 03:30:31 -05:00
parent 384529333c
commit b4dbb6377e
5 changed files with 5883 additions and 68 deletions

View File

@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
include(cmake/color.cmake)
set(BLT_VERSION 0.11.3) set(BLT_VERSION 0.11.3)
set(BLT_TEST_VERSION 0.0.1) set(BLT_TEST_VERSION 0.0.1)
@ -30,38 +31,40 @@ option(BLT_DISABLE_FATAL "Disable blt::logging BLT_FATAL macro" OFF)
configure_file(include/blt/config.h.in config/blt/config.h @ONLY) configure_file(include/blt/config.h.in config/blt/config.h @ONLY)
message("Enabling library compilation")
if (${BUILD_STD} OR ${BUILD_PROFILING}) if (${BUILD_STD} OR ${BUILD_PROFILING})
message("Building STD") message("-- Building ${Yellow}standard${ColourReset} cxx files")
file(GLOB_RECURSE STD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/blt/std/*.cpp") file(GLOB_RECURSE STD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/blt/std/*.cpp")
else () else ()
set(STD_FILES "") set(STD_FILES "")
endif () endif ()
if (${BUILD_PROFILING}) if (${BUILD_PROFILING})
message("Building Profiling") message("-- Building ${Yellow}profiling${ColourReset} cxx files")
file(GLOB_RECURSE PROFILING_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/blt/profiling/*.cpp") file(GLOB_RECURSE PROFILING_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/blt/profiling/*.cpp")
else () else ()
message("We are not building profiling")
set(PROFILING_FILES "") set(PROFILING_FILES "")
endif () endif ()
if (${BUILD_FS}) if (${BUILD_FS})
message("Building FS") message("-- Building ${Yellow}filesystem${ColourReset} cxx files")
file(GLOB_RECURSE FS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/blt/fs/*.cpp") file(GLOB_RECURSE FS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/blt/fs/*.cpp")
else () else ()
set(FS_FILES "") set(FS_FILES "")
endif () endif ()
if (${BUILD_PARSE}) if (${BUILD_PARSE})
message("Building Parsers") message("-- Building ${Yellow}parser${ColourReset} cxx files")
file(GLOB_RECURSE PARSE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/blt/parse/*.cpp") file(GLOB_RECURSE PARSE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/blt/parse/*.cpp")
else () else ()
set(PARSE_FILES "") set(PARSE_FILES "")
endif () endif ()
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap) if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap)
message("Found Parallel Hashmaps") message("Found Parallel Hashmaps library, using ${Yellow}phmap${ColourReset} over ${Red}std::unordered_map${ColourReset}")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap)
else()
message("Parallel Hashmaps library not found! using ${Yellow}std::unordered_map${ColourReset}")
endif () endif ()
#include zlib if the user has it. #include zlib if the user has it.
@ -82,36 +85,25 @@ message("FS Files ${FS_FILES}")
message("Parser Files ${PARSE_FILES}") message("Parser Files ${PARSE_FILES}")
message("Source: ${CMAKE_SOURCE_DIR}") message("Source: ${CMAKE_SOURCE_DIR}")
message("Current Source: ${CMAKE_CURRENT_SOURCE_DIR}") message("Current Source: ${CMAKE_CURRENT_SOURCE_DIR}")
message("Binary: ${CMAKE_BINARY_DIR}")
message("Current Binary: ${CMAKE_CURRENT_BINARY_DIR}")
add_library(${BLT_TARGET} ${STD_FILES} ${PROFILING_FILES} ${FS_FILES} ${PARSE_FILES}) add_library(${BLT_TARGET} ${STD_FILES} ${PROFILING_FILES} ${FS_FILES} ${PARSE_FILES})
if (${ZLIB_FOUND}) if (${ZLIB_FOUND})
target_link_libraries(${BLT_TARGET} PUBLIC ZLIB::ZLIB) target_link_libraries(${BLT_TARGET} PUBLIC ZLIB::ZLIB)
endif () endif ()
if (!MSVC)
target_link_libraries(${BLT_TARGET} PUBLIC stdc++fs) include(cmake/warnings.cmake)
endif()
target_include_directories(${BLT_TARGET} PUBLIC include/) target_include_directories(${BLT_TARGET} PUBLIC include/)
target_include_directories(${BLT_TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/config/) target_include_directories(${BLT_TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/config/)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap) if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap)
message("Including phmap") message("Including Parallel Hashmap directory")
target_include_directories(${BLT_TARGET} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap) target_include_directories(${BLT_TARGET} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap)
endif () endif ()
if(MSVC) message("BLT ${Yellow}${BLT_VERSION}${ColourReset} Successfully included!")
#target_compile_options(${BLT_TARGET} PRIVATE /W4)
else()
# perhaps we should warn on unused variables, but BLT will have lots of them.
target_compile_options(${BLT_TARGET} PRIVATE -Wall -Wextra -Wpedantic)
target_link_options(${BLT_TARGET} PUBLIC -rdynamic)
endif()
message("BLT ${CMAKE_PROJECT_VERSION} Successfully included!")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
include(GNUInstallDirs)
endif()
message("Installing to ${CMAKE_INSTALL_LIBDIR} with headers at ${CMAKE_INSTALL_INCLUDEDIR}") message("Installing to ${CMAKE_INSTALL_LIBDIR} with headers at ${CMAKE_INSTALL_INCLUDEDIR}")
@ -125,7 +117,7 @@ endforeach ()
install(FILES ${CMAKE_BINARY_DIR}/config/blt/config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/blt/) install(FILES ${CMAKE_BINARY_DIR}/config/blt/config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/blt/)
set_target_properties(${BLT_TARGET} PROPERTIES VERSION ${PROJECT_VERSION}) set_target_properties(${BLT_TARGET} PROPERTIES VERSION ${BLT_VERSION})
set_target_properties(${BLT_TARGET} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR}) set_target_properties(${BLT_TARGET} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR})
install(TARGETS ${BLT_TARGET} install(TARGETS ${BLT_TARGET}
@ -134,7 +126,7 @@ install(TARGETS ${BLT_TARGET}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if (${BUILD_TESTS}) if (${BUILD_TESTS})
message("Building test") message("Building test version ${BLT_TEST_VERSION}")
project(BLT_TESTS VERSION ${BLT_TEST_VERSION}) project(BLT_TESTS VERSION ${BLT_TEST_VERSION})
include_directories(tests/include) include_directories(tests/include)
@ -147,27 +139,9 @@ if(${BUILD_TESTS})
target_link_libraries(BLT_TESTS BLT) target_link_libraries(BLT_TESTS BLT)
if(MSVC) include(cmake/warnings.cmake)
include(cmake/sanitizers.cmake)
else()
target_compile_options(BLT_TESTS PRIVATE -Wall -Werror -Wpedantic -Wno-comment)
target_link_options(BLT_TESTS PRIVATE -Wall -Werror -Wpedantic -Wno-comment)
endif()
if (${ENABLE_ADDRSAN} MATCHES ON)
target_compile_options(BLT_TESTS PRIVATE -fsanitize=address)
target_link_options(BLT_TESTS PRIVATE -fsanitize=address)
endif ()
if (${ENABLE_UBSAN} MATCHES ON)
target_compile_options(BLT_TESTS PRIVATE -fsanitize=undefined)
target_link_options(BLT_TESTS PRIVATE -fsanitize=undefined)
endif ()
if (${ENABLE_TSAN} MATCHES ON)
target_compile_options(BLT_TESTS PRIVATE -fsanitize=thread)
target_link_options(BLT_TESTS PRIVATE -fsanitize=thread)
endif ()
message("Built tests") message("Built tests")
endif () endif ()

19
cmake/color.cmake Normal file
View File

@ -0,0 +1,19 @@
if(NOT WIN32)
string(ASCII 27 Esc)
set(ColourReset "${Esc}[m")
set(ColourBold "${Esc}[1m")
set(Red "${Esc}[31m")
set(Green "${Esc}[32m")
set(Yellow "${Esc}[33m")
set(Blue "${Esc}[34m")
set(Magenta "${Esc}[35m")
set(Cyan "${Esc}[36m")
set(White "${Esc}[37m")
set(BoldRed "${Esc}[1;31m")
set(BoldGreen "${Esc}[1;32m")
set(BoldYellow "${Esc}[1;33m")
set(BoldBlue "${Esc}[1;34m")
set(BoldMagenta "${Esc}[1;35m")
set(BoldCyan "${Esc}[1;36m")
set(BoldWhite "${Esc}[1;37m")
endif()

58
cmake/sanitizers.cmake Normal file
View File

@ -0,0 +1,58 @@
include(cmake/color.cmake)
message("Enabling requested sanitizers for ${PROJECT_NAME}")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# using Clang
if (${ENABLE_ADDRSAN} MATCHES ON)
message("-- Using Clang address sanitizer")
target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=address)
target_link_options(${PROJECT_NAME} PRIVATE -fsanitize=address)
endif ()
if (${ENABLE_UBSAN} MATCHES ON)
message("-- Using Clang undefined behaviour sanitizer")
target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=undefined)
target_link_options(${PROJECT_NAME} PRIVATE -fsanitize=undefined)
endif ()
if (${ENABLE_TSAN} MATCHES ON)
message("-- Using Clang thread sanitizer")
target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=thread)
target_link_options(${PROJECT_NAME} PRIVATE -fsanitize=thread)
endif ()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
if (${ENABLE_ADDRSAN} MATCHES ON)
message("-- Using GCC address sanitizer")
target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=address)
target_link_options(${PROJECT_NAME} PRIVATE -fsanitize=address)
endif ()
if (${ENABLE_UBSAN} MATCHES ON)
message("-- Using GCC undefined behaviour sanitizer")
target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=undefined)
target_link_options(${PROJECT_NAME} PRIVATE -fsanitize=undefined)
endif ()
if (${ENABLE_TSAN} MATCHES ON)
message("-- Using GCC thread sanitizer")
target_compile_options(${PROJECT_NAME} PRIVATE -fsanitize=thread)
target_link_options(${PROJECT_NAME} PRIVATE -fsanitize=thread)
endif ()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# using Intel C++
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# using Visual Studio C++
if (${ENABLE_ADDRSAN} MATCHES ON)
message("-- Using GCC address sanitizer")
target_compile_options(${PROJECT_NAME} PRIVATE /fsanitize=address)
target_link_options(${PROJECT_NAME} PRIVATE /fsanitize=address)
endif ()
if (${ENABLE_UBSAN} MATCHES ON)
message("-- ${Red}Undefined behaviour sanitizer not supported on this platform${ColourReset}")
endif ()
if (${ENABLE_TSAN} MATCHES ON)
message("-- ${Red}Thread sanitizer not supported on this platform${ColourReset}")
endif ()
endif ()

28
cmake/warnings.cmake Normal file
View File

@ -0,0 +1,28 @@
include(cmake/color.cmake)
message("Enabling platform specific compile options for ${PROJECT_NAME}")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# using Clang
message("-- Clang Compile: ${Green}-Wall -Wextra -Wpedantic -Weverything -fdiagnostics-color=always${ColourReset}")
message("-- Clang Link: ${Green}-export_dynamic${ColourReset}")
message("-- Clang libs: ${Green}stdc++fs${ColourReset}")
target_compile_options(${PROJECT_NAME} PUBLIC -Wall -Wextra -Wpedantic -Weverything -fdiagnostics-color=always)
target_link_options(${PROJECT_NAME} PUBLIC -export_dynamic)
target_link_libraries(${PROJECT_NAME} PUBLIC stdc++fs)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
message("-- GCC Compile: ${Green}-Wall -Wextra -Wpedantic -fdiagnostics-color=always${ColourReset}")
message("-- GCC Link: ${Green}-rdynamic${ColourReset}")
message("-- GCC libs: ${Green}stdc++fs${ColourReset}")
target_compile_options(${PROJECT_NAME} PUBLIC -Wall -Wextra -Wpedantic -fdiagnostics-color=always)
target_link_options(${PROJECT_NAME} PUBLIC -rdynamic)
target_link_libraries(${PROJECT_NAME} PUBLIC stdc++fs)
include(GNUInstallDirs)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# using Intel C++
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# using Visual Studio C++
message("-- MSVC Compile: ${Green}/Wall${ColourReset}")
message("-- MSVC Link: ${Green}${ColourReset}")
message("-- MSVC libs: ${Green}${ColourReset}")
target_compile_options(${PROJECT_NAME} PUBLIC /Wall)
endif ()

5736
include/blt/unicode_emoji.h Normal file

File diff suppressed because it is too large Load Diff