Files
cpp-project-template/CMakeLists.txt
tqcq cf49554574
Some checks failed
cpp-template / build (Debug, aarch64-linux-gnu) (push) Failing after 27s
cpp-template / build (Release, mipsel-linux-gnu) (push) Failing after 12m45s
cpp-template / build (Release, host.gcc) (push) Failing after 12m52s
cpp-template / build (Release, arm-linux-gnueabihf) (push) Failing after 12m55s
cpp-template / build (Release, aarch64-linux-gnu) (push) Failing after 13m1s
cpp-template / build (Debug, mipsel-linux-gnu) (push) Failing after 13m6s
cpp-template / build (Debug, host.gcc) (push) Failing after 13m11s
cpp-template / build (Debug, arm-linux-gnueabihf) (push) Failing after 13m19s
feat add tracy profiler
2025-08-25 15:52:04 +08:00

102 lines
2.1 KiB
CMake

cmake_minimum_required(VERSION 3.10)
project(demo LANGUAGES C CXX)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
if(CMAKE_CXX_COMPILER_ID
MATCHES
"Clang")
endif()
# option(
# WITH_MICROPROFILE
# "with MicroProfile"
# ON)
option(
WITH_EXAMPLES
"with examples"
OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include(CMakeDependentOption)
include(CheckCXXSourceCompiles)
include(cmake/generic.cmake)
include(cmake/CPM.cmake)
include(cmake/testing.cmake)
check_cxx_source_compiles(
"
#include <atomic>
int main() { std::atomic<int> a{1}; return 0;}
"
HAVE_ATOMIC)
check_cxx_source_compiles(
"
#include <pthread.h>
int main() { pthread_thread_t pid; return 0;}
"
HAVE_PTHREAD)
if(CMAKE_SYSTEM_PROCESSOR
MATCHES
"mips*")
link_libraries(atomic)
else()
add_subdirectory(third_party/breakpad)
endif()
if(WITH_MICROPROFILE)
add_subdirectory(third_party/microprofile)
set(COMM_LINK_MICROPROFILE ON)
endif()
CPMAddPackage(
NAME tracy
URI https://github.com/wolfpld/tracy
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/tracy
OPTIONS "TRACY_ENABLE ON" "TRACY_ON_DEMAND ON"
FORCE)
CPMAddPackage(
NAME oatpp
URI https://github.com/oatpp/oatpp/archive/refs/tags/1.3.1.zip
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/oatpp
OPTIONS "OATPP_INSTALL OFF"
"OATPP_BUILD_TESTS OFF"
$<$<COMM_LINK_ATOMIC>:"OATPP_LINK_ATOMIC ON">
FORCE)
CPMAddPackage(
NAME spdlog
URI https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.zip
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog
FORCE)
if(WITH_EXAMPLES)
# cc_executable(microprofile_demo SRCS examples/microprofile_demo.cc)
cc_executable(tracy_demo SRCS examples/tracy_demo.cc)
endif()
enable_testing()
cc_test(
calc_test
SRCS src/calc_test.cc
DEPS PUBLIC
spdlog
oatpp)
if(breakpd_ADDED)
cc_executable(
breakpad_test
SRCS src/breakpad_test.cc
DEPS PUBLIC breakpad)
endif()
cc_benchmark(
calc_benchmark
SRCS src/calc_benchmark.cc
DEPS PUBLIC
spdlog
oatpp)