69 lines
1.9 KiB
CMake
69 lines
1.9 KiB
CMake
cmake_minimum_required(VERSION 3.5)
|
|
project(
|
|
project-name
|
|
VERSION 0.0.0
|
|
DESCRIPTION ""
|
|
HOMEPAGE_URL ""
|
|
LANGUAGES C CXX)
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(DEFAULT_BUILD_TYPE "Release")
|
|
|
|
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
|
message(
|
|
STATUS
|
|
"Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
|
|
set(CMAKE_BUILD_TYPE
|
|
"${DEFAULT_BUILD_TYPE}"
|
|
CACHE STRING "Choose the type of build." FORCE)
|
|
# Set the possible values of build type for cmake-gui
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
|
|
"MinSizeRel" "RelWithDebInfo")
|
|
endif()
|
|
|
|
add_compile_options(
|
|
-Werror=switch-enum
|
|
-Wswitch-enum
|
|
-Wunused-variable
|
|
-fPIC
|
|
-fdata-sections
|
|
-ffunction-sections
|
|
-fno-omit-frame-pointer)
|
|
|
|
if(CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
|
|
add_compile_options(-mavx)
|
|
endif()
|
|
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
|
|
add_link_options(LINKER:--gc-sections)
|
|
endif()
|
|
|
|
add_subdirectory(third_party)
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
|
|
|
|
include(CTest)
|
|
include(doctest)
|
|
|
|
add_executable(mytest src/test.cpp)
|
|
target_include_directories(mytest PRIVATE include)
|
|
target_link_libraries(mytest PRIVATE doctest nanobench simdjson)
|
|
doctest_discover_tests(mytest)
|
|
|
|
include(CMakePushCheckState)
|
|
include(CheckCXXCompilerFlag)
|
|
cmake_push_check_state()
|
|
set(CMAKE_REQUIRED_LINK_OPTIONS -fsanitize=fuzzer-no-link)
|
|
check_cxx_compiler_flag(-fsanitize=fuzzer-no-link HAS_LIB_FUZZER)
|
|
cmake_pop_check_state()
|
|
|
|
if(HAS_LIB_FUZZER)
|
|
add_executable(fuzz src/fuzz.cpp)
|
|
target_include_directories(fuzz PRIVATE include)
|
|
target_link_libraries(fuzz PRIVATE simdjson)
|
|
target_compile_options(fuzz PRIVATE -fsanitize=fuzzer)
|
|
target_link_options(fuzz PRIVATE -fsanitize=fuzzer)
|
|
endif()
|
|
|
|
add_executable(validate src/validate.cpp)
|
|
target_include_directories(validate PRIVATE include)
|