BLT/CMakeLists.txt

91 lines
2.6 KiB
CMake
Raw Normal View History

2023-04-01 16:49:54 -04:00
cmake_minimum_required(VERSION 3.0)
2023-03-14 18:02:20 -04:00
project(BLT VERSION 0.5.2)
2022-12-23 13:50:27 -05:00
set(CMAKE_CXX_STANDARD 17)
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)
option(BUILD_TESTS "Build the BLT test set" OFF)
2023-04-08 12:44:31 -04:00
option(BLT_ENABLE_LOGGING "Enable blt::logging" ON)
2022-12-23 13:50:27 -05:00
2023-01-26 12:21:19 -05:00
if(${BUILD_STD} OR ${BUILD_PROFILING})
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})
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()
set(PROFILING_FILES "")
endif()
2023-01-26 00:59:36 -05:00
if(${BUILD_NBT})
file(GLOB_RECURSE NBT_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/blt/nbt/*.cpp")
else()
set(NBT_FILES "")
endif()
#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
configure_file(include/blt/config.h.in config/blt/config.h @ONLY)
2023-01-26 00:59:36 -05:00
add_library(BLT ${STD_FILES} ${PROFILING_FILES} ${NBT_FILES})
target_include_directories(BLT PUBLIC include/)
target_include_directories(BLT PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/config/)
if(${ZLIB_FOUND})
target_link_libraries(BLT PUBLIC ZLIB::ZLIB)
2023-01-16 14:09:27 -05:00
endif()
2023-04-05 17:21:19 -04:00
if(MSVC)
2023-04-07 00:02:21 -04:00
#target_compile_options(BLT PRIVATE /W4)
2023-04-05 17:21:19 -04:00
else()
# perhaps we should warn on usused variables, but BLT will have lots of them.
target_compile_options(BLT PRIVATE -Wall -Wextra -Wpedantic)
endif()
message("BLT ${CMAKE_PROJECT_VERSION} Successfully included!")
if(${BUILD_TESTS})
project(BLT_TESTS)
2023-04-07 00:02:21 -04:00
if(${CMAKE_BUILD_TYPE} MATCHES Debug AND LINUX)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()
2023-01-12 12:18:39 -05:00
file(GLOB_RECURSE TESTS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/tests/*.cpp")
add_executable(BLT_TESTS ${TESTS_FILES})
2023-04-05 17:21:19 -04:00
target_link_libraries(BLT_TESTS PUBLIC BLT)
if(MSVC)
2023-04-07 00:02:21 -04:00
#target_compile_options(BLT_TESTS PRIVATE /W4)
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
target_link_options(BLT_TESTS PRIVATE /DEBUG)
endif()
2023-04-05 17:21:19 -04:00
else()
target_compile_options(BLT_TESTS PRIVATE -Wall -Wextra -Wpedantic)
endif()
message("BLT tests included!")
2023-01-16 14:09:27 -05:00
endif()