2023-07-29 17:24:28 -04:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
2023-11-22 23:25:29 -05:00
|
|
|
|
2023-12-18 23:16:34 -05:00
|
|
|
set(BLT_VERSION 0.10.1)
|
2023-11-22 23:25:29 -05:00
|
|
|
set(BLT_TEST_VERSION 0.0.1)
|
|
|
|
|
2024-01-08 08:58:14 -05:00
|
|
|
set(BLT_TARGET BLT)
|
|
|
|
|
2023-11-22 23:25:29 -05:00
|
|
|
project(BLT VERSION ${BLT_VERSION})
|
2022-12-23 13:50:27 -05:00
|
|
|
|
2023-11-22 23:06:29 -05:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2022-12-23 13:50:27 -05:00
|
|
|
|
2023-07-28 01:35:01 -04:00
|
|
|
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
|
|
|
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
|
|
|
option(ENABLE_TSAN "Enable the thread data race sanitizer" OFF)
|
2023-11-22 23:25:29 -05:00
|
|
|
|
2022-12-23 13:50:27 -05:00
|
|
|
option(BUILD_STD "Build the BLT standard utilities." ON)
|
|
|
|
option(BUILD_PROFILING "Build the BLT profiler extension" ON)
|
2023-01-26 00:59:36 -05:00
|
|
|
option(BUILD_NBT "Build the BLT NBT + eNBT extension" ON)
|
2023-07-29 02:03:28 -04:00
|
|
|
option(BUILD_PARSE "Build the BLT parsers" ON)
|
2023-11-22 23:25:29 -05:00
|
|
|
|
2023-01-11 18:56:42 -05:00
|
|
|
option(BUILD_TESTS "Build the BLT test set" OFF)
|
2023-11-22 23:25:29 -05:00
|
|
|
|
2023-07-21 22:45:23 -04:00
|
|
|
option(BLT_DISABLE_LOGGING "Disable blt::logging (all macros and will safely disable logging function!)" OFF)
|
|
|
|
option(BLT_DISABLE_TRACE "Disable blt::logging BLT_TRACE macro" OFF)
|
|
|
|
option(BLT_DISABLE_DEBUG "Disable blt::logging BLT_DEBUG macro" OFF)
|
|
|
|
option(BLT_DISABLE_INFO "Disable blt::logging BLT_INFO macro" OFF)
|
|
|
|
option(BLT_DISABLE_WARN "Disable blt::logging BLT_WARN macro" OFF)
|
|
|
|
option(BLT_DISABLE_ERROR "Disable blt::logging BLT_ERROR macro" OFF)
|
|
|
|
option(BLT_DISABLE_FATAL "Disable blt::logging BLT_FATAL macro" OFF)
|
2022-12-23 13:50:27 -05:00
|
|
|
|
2023-07-10 18:45:43 -04:00
|
|
|
configure_file(include/blt/config.h.in config/blt/config.h @ONLY)
|
|
|
|
|
2023-01-26 12:21:19 -05:00
|
|
|
if(${BUILD_STD} OR ${BUILD_PROFILING})
|
2023-11-22 19:17:15 -05:00
|
|
|
message("Building STD")
|
2022-12-25 23:25:32 -05:00
|
|
|
file(GLOB_RECURSE STD_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/blt/std/*.cpp")
|
2022-12-23 13:50:27 -05:00
|
|
|
else()
|
|
|
|
set(STD_FILES "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${BUILD_PROFILING})
|
2023-11-22 19:17:15 -05:00
|
|
|
message("Building Profiling")
|
2022-12-25 23:25:32 -05:00
|
|
|
file(GLOB_RECURSE PROFILING_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/blt/profiling/*.cpp")
|
2022-12-23 13:50:27 -05:00
|
|
|
else()
|
2023-11-22 19:17:15 -05:00
|
|
|
message("We are not building profiling")
|
2022-12-23 13:50:27 -05:00
|
|
|
set(PROFILING_FILES "")
|
|
|
|
endif()
|
|
|
|
|
2023-01-26 00:59:36 -05:00
|
|
|
if(${BUILD_NBT})
|
2023-11-22 19:17:15 -05:00
|
|
|
message("Building NBT")
|
2023-01-26 00:59:36 -05:00
|
|
|
file(GLOB_RECURSE NBT_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/blt/nbt/*.cpp")
|
|
|
|
else()
|
|
|
|
set(NBT_FILES "")
|
|
|
|
endif()
|
|
|
|
|
2023-07-29 02:03:28 -04:00
|
|
|
if(${BUILD_PARSE})
|
2023-11-22 19:17:15 -05:00
|
|
|
message("Building Parsers")
|
2023-07-29 02:03:28 -04:00
|
|
|
file(GLOB_RECURSE PARSE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/blt/parse/*.cpp")
|
|
|
|
else()
|
|
|
|
set(PARSE_FILES "")
|
|
|
|
endif()
|
|
|
|
|
2023-07-29 17:41:45 -04:00
|
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap)
|
|
|
|
message("Found Parallel Hashmaps")
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap)
|
2023-07-29 13:38:19 -04:00
|
|
|
endif()
|
|
|
|
|
2023-01-29 15:24:33 -05:00
|
|
|
#include zlib if the user has it.
|
|
|
|
find_package(ZLIB QUIET)
|
|
|
|
|
|
|
|
if (${ZLIB_FOUND})
|
|
|
|
include_directories(${ZLIB_INCLUDE_DIRS})
|
|
|
|
else()
|
|
|
|
message("ZLIB was not found, this is fine however if you wish you use gzip with NBT it is required.")
|
2022-12-27 00:51:37 -05:00
|
|
|
endif()
|
|
|
|
|
2022-12-27 00:59:49 -05:00
|
|
|
include_directories(include/)
|
2023-04-08 12:44:31 -04:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/config/)
|
2022-12-23 13:50:27 -05:00
|
|
|
|
2022-12-25 23:23:12 -05:00
|
|
|
message("Standard Files ${STD_FILES}")
|
|
|
|
message("Profiler Files ${PROFILING_FILES}")
|
|
|
|
message("Source: ${CMAKE_SOURCE_DIR}")
|
2022-12-25 23:24:58 -05:00
|
|
|
message("Current Source: ${CMAKE_CURRENT_SOURCE_DIR}")
|
2022-12-25 23:23:12 -05:00
|
|
|
|
2024-01-08 08:58:14 -05:00
|
|
|
add_library(${BLT_TARGET} SHARED ${STD_FILES} ${PROFILING_FILES} ${NBT_FILES} ${PARSE_FILES})
|
2023-01-26 00:59:36 -05:00
|
|
|
|
2024-01-08 09:17:17 -05:00
|
|
|
set_target_properties(${BLT_TARGET} PROPERTIES VERSION ${PROJECT_VERSION})
|
|
|
|
set_target_properties(${BLT_TARGET} PROPERTIES SOVERSION ${PROJECT_VERSION_MAJOR})
|
|
|
|
|
2024-01-08 08:58:14 -05:00
|
|
|
target_include_directories(${BLT_TARGET} PUBLIC include/)
|
|
|
|
target_include_directories(${BLT_TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/config/)
|
2023-01-29 15:24:33 -05:00
|
|
|
if(${ZLIB_FOUND})
|
2024-01-08 08:58:14 -05:00
|
|
|
target_link_libraries(${BLT_TARGET} PUBLIC ZLIB::ZLIB)
|
2023-01-16 14:09:27 -05:00
|
|
|
endif()
|
2023-07-29 17:41:45 -04:00
|
|
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap)
|
2023-07-29 13:38:19 -04:00
|
|
|
message("Including phmap")
|
2024-01-08 08:58:14 -05:00
|
|
|
target_include_directories(${BLT_TARGET} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/libraries/parallel-hashmap)
|
2023-07-29 13:38:19 -04:00
|
|
|
endif()
|
2023-01-29 15:24:33 -05:00
|
|
|
|
2023-04-05 17:21:19 -04:00
|
|
|
if(MSVC)
|
2024-01-08 08:58:14 -05:00
|
|
|
#target_compile_options(${BLT_TARGET} PRIVATE /W4)
|
2023-04-05 17:21:19 -04:00
|
|
|
else()
|
2023-07-28 01:35:01 -04:00
|
|
|
# perhaps we should warn on unused variables, but BLT will have lots of them.
|
2024-01-08 08:58:14 -05:00
|
|
|
target_compile_options(${BLT_TARGET} PRIVATE -Wall -Wextra -Wpedantic)
|
|
|
|
target_link_options(${BLT_TARGET} PUBLIC -rdynamic)
|
2023-04-05 17:21:19 -04:00
|
|
|
endif()
|
|
|
|
|
2023-01-05 01:52:56 -05:00
|
|
|
message("BLT ${CMAKE_PROJECT_VERSION} Successfully included!")
|
2023-01-11 18:56:42 -05:00
|
|
|
|
2024-01-08 09:17:17 -05:00
|
|
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message("Installing to ${CMAKE_INSTALL_LIBDIR} with headers at ${CMAKE_INSTALL_INCLUDEDIR}")
|
|
|
|
|
|
|
|
install(TARGETS ${BLT_TARGET}
|
|
|
|
CONFIGURATIONS RelWithDebInfo
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
|
|
|
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
|
|
|
2023-11-22 23:25:29 -05:00
|
|
|
if(${BUILD_TESTS})
|
|
|
|
message("Building test")
|
|
|
|
project(BLT_TESTS VERSION ${BLT_TEST_VERSION})
|
|
|
|
|
|
|
|
include_directories(tests/include)
|
|
|
|
|
|
|
|
file(GLOB_RECURSE TEST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/tests/src/*.cpp")
|
|
|
|
|
|
|
|
message("Using files ${TEST_FILES}")
|
|
|
|
|
|
|
|
add_executable(BLT_TESTS ${TEST_FILES})
|
|
|
|
|
|
|
|
target_link_libraries(BLT_TESTS BLT)
|
|
|
|
|
2023-12-29 01:07:08 -05:00
|
|
|
if(MSVC)
|
|
|
|
|
|
|
|
else()
|
|
|
|
target_compile_options(BLT_TESTS PRIVATE -Wall -Werror -Wpedantic -Wno-comment)
|
|
|
|
target_link_options(BLT_TESTS PRIVATE -Wall -Werror -Wpedantic -Wno-comment)
|
|
|
|
endif()
|
2023-11-22 23:25:29 -05:00
|
|
|
|
|
|
|
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")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
project(BLT)
|