Files
cpp-project-template/CMakeLists.txt

87 lines
1.8 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 3.10)
project(demo LANGUAGES C CXX)
2025-08-22 18:22:57 +08:00
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif()
if(CMAKE_CXX_COMPILER_ID
MATCHES
"Clang")
endif()
2025-08-25 11:21:22 +08:00
option(
WITH_MICROPROFILE
"with MicroProfile"
OFF)
option(
WITH_EXAMPLES
"with examples"
OFF)
2025-08-22 18:22:57 +08:00
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
include(CMakeDependentOption)
include(CheckCXXSourceCompiles)
2025-08-19 18:59:22 +08:00
include(cmake/generic.cmake)
2025-08-22 18:22:57 +08:00
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)
add_subdirectory(third_party/breakpad)
2025-08-25 12:01:16 +08:00
if(WITH_MICROPROFILE)
add_subdirectory(third_party/microprofile)
set(COMM_LINK_MICROPROFILE ON)
endif()
2025-08-25 11:21:22 +08:00
2025-08-22 18:22:57 +08:00
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)
2025-08-22 18:22:57 +08:00
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)
2025-08-25 12:01:16 +08:00
if(WITH_EXAMPLES)
cc_executable(microprofile_demo SRCS examples/microprofile_demo.cc)
endif()
enable_testing()
2025-08-22 18:22:57 +08:00
cc_test(
calc_test
SRCS src/calc_test.cc
DEPS PUBLIC
spdlog
oatpp)
cc_executable(
breakpad_test
SRCS src/breakpad_test.cc
DEPS PUBLIC breakpad)
cc_benchmark(
calc_benchmark
SRCS src/calc_benchmark.cc
DEPS PUBLIC
spdlog
oatpp)