| 1 |
cmake_minimum_required(VERSION 3.8) |
| 2 |
|
| 3 |
project(cpptrace-speedtest CXX) |
| 4 |
|
| 5 |
option(SPEEDTEST_DWARF4 "" OFF) |
| 6 |
option(SPEEDTEST_DWARF5 "" OFF) |
| 7 |
|
| 8 |
include(CheckCXXCompilerFlag) |
| 9 |
|
| 10 |
if(SPEEDTEST_DWARF4) |
| 11 |
check_cxx_compiler_flag("-gdwarf-4" HAS_DWARF4) |
| 12 |
if(HAS_DWARF4) |
| 13 |
add_compile_options("$<$<CONFIG:Debug>:-gdwarf-4>") |
| 14 |
#target_compile_options(speedtest PRIVATE "$<$<CONFIG:Debug>:-gdwarf-4>") |
| 15 |
#target_compile_options(googletest INTERFACE "$<$<CONFIG:Debug>:-gdwarf-4>") |
| 16 |
endif() |
| 17 |
endif() |
| 18 |
if(SPEEDTEST_DWARF5) |
| 19 |
check_cxx_compiler_flag("-gdwarf-5" HAS_DWARF5) |
| 20 |
if(HAS_DWARF5) |
| 21 |
add_compile_options("$<$<CONFIG:Debug>:-gdwarf-5>") |
| 22 |
#target_compile_options(speedtest PRIVATE "$<$<CONFIG:Debug>:-gdwarf-4>") |
| 23 |
#target_compile_options(googletest INTERFACE "$<$<CONFIG:Debug>:-gdwarf-4>") |
| 24 |
endif() |
| 25 |
endif() |
| 26 |
|
| 27 |
include(FetchContent) |
| 28 |
FetchContent_Declare( |
| 29 |
googletest |
| 30 |
DOWNLOAD_EXTRACT_TIMESTAMP On |
| 31 |
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip |
| 32 |
) |
| 33 |
# For Windows: Prevent overriding the parent project's compiler/linker settings |
| 34 |
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) |
| 35 |
FetchContent_MakeAvailable(googletest) |
| 36 |
|
| 37 |
set(cpptrace_DIR "../../build/foo/lib/cmake/cpptrace") |
| 38 |
set(libdwarf_DIR "../../build/foo/lib/cmake/libdwarf") |
| 39 |
set(zstd_DIR "../../build/foo/lib/cmake/zstd") |
| 40 |
find_package(cpptrace REQUIRED) |
| 41 |
|
| 42 |
add_executable(speedtest speedtest.cpp) |
| 43 |
target_compile_features(speedtest PRIVATE cxx_std_11) |
| 44 |
target_link_libraries( |
| 45 |
speedtest |
| 46 |
PRIVATE |
| 47 |
GTest::gtest_main |
| 48 |
cpptrace::cpptrace |
| 49 |
) |
| 50 |
|
| 51 |
if(WIN32) |
| 52 |
add_custom_command( |
| 53 |
TARGET speedtest POST_BUILD |
| 54 |
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_RUNTIME_DLLS:speedtest> $<TARGET_FILE_DIR:speedtest> |
| 55 |
COMMAND_EXPAND_LISTS |
| 56 |
) |
| 57 |
endif() |