Echo Writes Code

CMakeLists.txt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
include(CrucibleAddLibrary)
include(CrucibleAddTest)
include(CrucibleCheckRuntimeCapabilities)

# This is a special step for core only: detecting capabilities of the compilation target and adding
# preprocessor definitions to target_platform.hpp based on what we find
crucible_check_runtime_capabilities(CRUCIBLE_TARGET_PLATFORM_HAS)

configure_file(
  "${CMAKE_CURRENT_SOURCE_DIR}/include/crucible/core/target_platform.hpp.in"
  "${CMAKE_CURRENT_BINARY_DIR}/include/crucible/core/target_platform.hpp"
  NEWLINE_STYLE UNIX)

crucible_add_library(crucible-core)

# Also a special step for core only: we add CMAKE_CURRENT_BINARY_DIR to our include search path in
# order to find generated files, such as target_platform.hpp
target_include_directories(crucible-core PUBLIC
  "${CMAKE_CURRENT_BINARY_DIR}/include"
  "${CMAKE_CURRENT_SOURCE_DIR}/include")

target_sources(crucible-core PRIVATE
  source/crucible/core/backtrace.cpp
  source/crucible/core/bit_vector.cpp
  source/crucible/core/filesystem.cpp
  source/crucible/core/format.cpp
  source/crucible/core/none.cpp
  source/crucible/core/stack_frame.cpp
  source/crucible/core/terminate_handler.cpp)

if(UNIX)
  target_sources(crucible-core PRIVATE
    source/crucible/core/unix/backtrace.cpp
    source/crucible/core/unix/demangle.cpp
    source/crucible/core/unix/filesystem.cpp
    source/crucible/core/unix/system_error.cpp)
endif()

if(WIN32)
  target_sources(crucible-core PRIVATE
    source/crucible/core/windows/backtrace.cpp
    source/crucible/core/windows/filesystem.cpp
    source/crucible/core/windows/system_error.cpp
    source/crucible/core/windows/transcoding.cpp)
endif()

crucible_add_test(test-crucible-core)

target_link_libraries(test-crucible-core PRIVATE
  crucible-core
  crucible-testing)

target_sources(test-crucible-core PRIVATE
  tests/crucible/core/test_backtrace.cpp
  tests/crucible/core/test_bit_vector.cpp
  tests/crucible/core/test_error.cpp
  tests/crucible/core/test_format.cpp
  tests/crucible/core/test_memory.cpp
  tests/crucible/core/test_result.cpp
  tests/crucible/core/test_vector.cpp
  tests/main.cpp)

if(UNIX)
  target_sources(test-crucible-core PRIVATE
    tests/crucible/core/unix/test_backtrace.cpp
    tests/crucible/core/unix/test_filesystem.cpp)
endif()

if(WIN32)
  target_sources(test-crucible-core PRIVATE
    tests/crucible/core/unix/test_backtrace.cpp
    tests/crucible/core/unix/test_filesystem.cpp
    tests/crucible/core/unix/test_transcoding.cpp)
endif()