|
1 | 1 | cmake_minimum_required(VERSION 3.21) |
2 | | -include("cmake/common.cmake") |
| 2 | + |
| 3 | +include("res/cmake/common.cmake") |
| 4 | + |
3 | 5 | option(OBSE_SUPPORT_XBYAK "Enables trampoline support for Xbyak." OFF) |
| 6 | +option(REX_OPTION_INI "Enables ini config support for REX." OFF) |
| 7 | +option(REX_OPTION_JSON "Enables json config support for REX." OFF) |
| 8 | +option(REX_OPTION_TOML "Enables toml config support for REX." OFF) |
| 9 | + |
| 10 | +project( |
| 11 | + CommonLibOB64 |
| 12 | + LANGUAGES CXX |
| 13 | +) |
4 | 14 |
|
5 | | -project(umbrella) |
| 15 | +include(GNUInstallDirs) |
6 | 16 |
|
7 | 17 | if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") |
8 | 18 | message(FATAL_ERROR "in-source builds are not allowed") |
9 | 19 | endif() |
10 | 20 |
|
11 | | -function(conditionally_add_subdirectory SRC_DIR) |
12 | | - if(NOT TARGET "${SUBDIRECTORY}") |
13 | | - if("${ARGC}" GREATER 1) |
14 | | - add_subdirectory("${SRC_DIR}" "${ARGV1}") |
15 | | - else() |
16 | | - add_subdirectory("${SRC_DIR}") |
17 | | - endif() |
18 | | - endif() |
19 | | -endfunction() |
| 21 | +find_package(mmio REQUIRED CONFIG) |
| 22 | +find_package(spdlog REQUIRED CONFIG) |
| 23 | + |
| 24 | +include(res/cmake/sourcelist.cmake) |
| 25 | + |
| 26 | +source_group( |
| 27 | + TREE "${CMAKE_CURRENT_SOURCE_DIR}" |
| 28 | + FILES ${SOURCES} |
| 29 | +) |
| 30 | + |
| 31 | +add_library( |
| 32 | + "${PROJECT_NAME}" |
| 33 | + STATIC |
| 34 | + ${SOURCES} |
| 35 | + .clang-format |
| 36 | + res/commonlibob64.natvis |
| 37 | +) |
| 38 | + |
| 39 | +add_library("${PROJECT_NAME}::${PROJECT_NAME}" ALIAS "${PROJECT_NAME}") |
| 40 | + |
| 41 | +target_compile_definitions( |
| 42 | + "${PROJECT_NAME}" |
| 43 | + PUBLIC |
| 44 | + WINVER=0x0601 # windows 7, minimum supported version by fallout 4 |
| 45 | + _WIN32_WINNT=0x0601 |
| 46 | + "$<$<BOOL:${OBSE_SUPPORT_XBYAK}>:OBSE_SUPPORT_XBYAK=1>" |
| 47 | + "$<$<BOOL:${REX_OPTION_INI}>:REX_OPTION_INI=1>" |
| 48 | + "$<$<BOOL:${REX_OPTION_JSON}>:REX_OPTION_JSON=1>" |
| 49 | + "$<$<BOOL:${REX_OPTION_TOML}>:REX_OPTION_TOML=1>" |
| 50 | +) |
| 51 | + |
| 52 | +target_compile_features( |
| 53 | + "${PROJECT_NAME}" |
| 54 | + PUBLIC |
| 55 | + cxx_std_23 |
| 56 | +) |
| 57 | + |
| 58 | +if (MSVC) |
| 59 | + target_compile_options( |
| 60 | + "${PROJECT_NAME}" |
| 61 | + PRIVATE |
| 62 | + # warnings -> errors |
| 63 | + /we4715 # 'function' : not all control paths return a value |
| 64 | + |
| 65 | + # disable warnings |
| 66 | + /wd4061 # enumerator 'identifier' in switch of enum 'enumeration' is not explicitly handled by a case label |
| 67 | + /wd4200 # nonstandard extension used : zero-sized array in struct/union |
| 68 | + /wd4201 # nonstandard extension used : nameless struct/union |
| 69 | + /wd4264 # 'virtual_function' : no override available for virtual member function from base 'class'; function is hidden |
| 70 | + /wd4265 # 'type': class has virtual functions, but its non-trivial destructor is not virtual; instances of this class may not be destructed correctly |
| 71 | + /wd4266 # 'function' : no override available for virtual member function from base 'type'; function is hidden |
| 72 | + /wd4324 # 'struct_name' : structure was padded due to __declspec(align()) |
| 73 | + /wd4371 # 'classname': layout of class may have changed from a previous version of the compiler due to better packing of member 'member' |
| 74 | + /wd4514 # 'function' : unreferenced inline function has been removed |
| 75 | + /wd4582 # 'type': constructor is not implicitly called |
| 76 | + /wd4583 # 'type': destructor is not implicitly called |
| 77 | + /wd4623 # 'derived class' : default constructor was implicitly defined as deleted because a base class default constructor is inaccessible or deleted |
| 78 | + /wd4625 # 'derived class' : copy constructor was implicitly defined as deleted because a base class copy constructor is inaccessible or deleted |
| 79 | + /wd4626 # 'derived class' : assignment operator was implicitly defined as deleted because a base class assignment operator is inaccessible or deleted |
| 80 | + /wd4686 # 'user-defined type' : possible change in behavior, change in UDT return calling convention |
| 81 | + /wd4702 # unreachable code |
| 82 | + /wd4710 # 'function' : function not inlined |
| 83 | + /wd4711 # function 'function' selected for inline expansion |
| 84 | + /wd4820 # 'bytes' bytes padding added after construct 'member_name' |
| 85 | + /wd5026 # 'type': move constructor was implicitly defined as deleted |
| 86 | + /wd5027 # 'type': move assignment operator was implicitly defined as deleted |
| 87 | + /wd5045 # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified |
| 88 | + /wd5053 # support for 'explicit(<expr>)' in C++17 and earlier is a vendor extension |
| 89 | + /wd5204 # 'type-name': class has virtual functions, but its trivial destructor is not virtual; instances of objects derived from this class may not be destructed correctly |
| 90 | + /wd5220 # 'member': a non-static data member with a volatile qualified type no longer implies that compiler generated copy / move constructors and copy / move assignment operators are not trivial |
| 91 | + ) |
| 92 | +endif() |
| 93 | + |
| 94 | +target_include_directories( |
| 95 | + "${PROJECT_NAME}" |
| 96 | + PUBLIC |
| 97 | + "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>" |
| 98 | + "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" |
| 99 | +) |
| 100 | + |
| 101 | +target_link_libraries( |
| 102 | + "${PROJECT_NAME}" |
| 103 | + PUBLIC |
| 104 | + advapi32.lib |
| 105 | + bcrypt.lib |
| 106 | + d3d11.lib |
| 107 | + d3dcompiler.lib |
| 108 | + dbghelp.lib |
| 109 | + dxgi.lib |
| 110 | + mmio::mmio |
| 111 | + ole32.lib |
| 112 | + spdlog::spdlog |
| 113 | + version.lib |
| 114 | +) |
| 115 | + |
| 116 | +target_precompile_headers( |
| 117 | + "${PROJECT_NAME}" |
| 118 | + PRIVATE |
| 119 | + include/OBSE/Impl/PCH.h |
| 120 | +) |
| 121 | + |
| 122 | +install( |
| 123 | + TARGETS "${PROJECT_NAME}" |
| 124 | + EXPORT "${PROJECT_NAME}-targets" |
| 125 | +) |
| 126 | + |
| 127 | +install( |
| 128 | + EXPORT "${PROJECT_NAME}-targets" |
| 129 | + NAMESPACE "${PROJECT_NAME}::" |
| 130 | + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" |
| 131 | +) |
20 | 132 |
|
21 | | -include(CTest) |
| 133 | +configure_file( |
| 134 | + res/cmake/config.cmake.in |
| 135 | + "${PROJECT_NAME}Config.cmake" |
| 136 | + @ONLY |
| 137 | +) |
22 | 138 |
|
23 | | -list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") |
| 139 | +install( |
| 140 | + FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" |
| 141 | + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" |
| 142 | +) |
24 | 143 |
|
25 | | -conditionally_add_subdirectory(CommonLibOB64) |
| 144 | +install( |
| 145 | + DIRECTORY |
| 146 | + "include/OBSE" |
| 147 | + "include/RE" |
| 148 | + "include/REL" |
| 149 | + "include/REX" |
| 150 | + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" |
| 151 | +) |
0 commit comments