[DOCS]: Building & Using
This commit is contained in:
29
CMake/IAProjectConfig.cmake
Normal file
29
CMake/IAProjectConfig.cmake
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
macro(iacore_setup_project)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||||
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||||
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
add_compile_options(/W4)
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
add_compile_options(-Wno-c++98-compat -Wno-c++98-compat-pedantic)
|
||||||
|
endif()
|
||||||
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
|
||||||
|
add_compile_options(-Wall -Wextra -Wpedantic -Wno-language-extension-token)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64")
|
||||||
|
set(IACORE_ARCH_X64 TRUE CACHE INTERNAL "")
|
||||||
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|ARM64")
|
||||||
|
set(IACORE_ARCH_ARM64 TRUE CACHE INTERNAL "")
|
||||||
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "wasm32|emscripten")
|
||||||
|
set(IACORE_ARCH_WASM TRUE CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endmacro()
|
||||||
@ -1,72 +1,50 @@
|
|||||||
cmake_minimum_required(VERSION 3.28 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.28 FATAL_ERROR)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(IACORE_ROOT "${CMAKE_CURRENT_LIST_DIR}" CACHE INTERNAL "")
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(IACORE_TRIPLETS_DIR "${IACORE_ROOT}/CMake/Triplets" CACHE INTERNAL "")
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
||||||
|
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
if(IACORE_TRIPLETS_DIR)
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
list(APPEND VCPKG_OVERLAY_TRIPLETS "${IACORE_TRIPLETS_DIR}")
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
if(NOT CMAKE_CURRENT_LIST_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||||
|
set(VCPKG_OVERLAY_TRIPLETS "${VCPKG_OVERLAY_TRIPLETS}" PARENT_SCOPE)
|
||||||
project(IACore)
|
|
||||||
|
|
||||||
enable_language(C)
|
|
||||||
|
|
||||||
include(CMake/FindDeps.cmake)
|
|
||||||
|
|
||||||
# Default to ON if root, OFF if dependency
|
|
||||||
option(IACore_BUILD_TESTS "Build unit tests" ${PROJECT_IS_TOP_LEVEL})
|
|
||||||
|
|
||||||
message(STATUS "Configured IACore for Multi-Config (Debug/Release rules generated)")
|
|
||||||
|
|
||||||
message(STATUS "Detected Compiler ID: ${CMAKE_CXX_COMPILER_ID}")
|
|
||||||
# Check if the compiler is MSVC (cl.exe), but allow Clang acting like MSVC (clang-cl)
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
|
||||||
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
||||||
message(FATAL_ERROR
|
|
||||||
"\n\n"
|
|
||||||
"-------------------------------------------------------------\n"
|
|
||||||
"CRITICAL ERROR: Unsupported Compiler Detected (MSVC/cl.exe)\n"
|
|
||||||
"-------------------------------------------------------------\n"
|
|
||||||
"IACore requires GCC or Clang to compile.\n"
|
|
||||||
"For compiling with IACore on Windows, please use Clang Tools for MSVC.\n"
|
|
||||||
"-------------------------------------------------------------\n"
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64")
|
project(IACore LANGUAGES C CXX)
|
||||||
set(IACORE_ARCH_X64 TRUE)
|
|
||||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|ARM64")
|
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
||||||
set(IACORE_ARCH_ARM64 TRUE)
|
set(IACORE_IS_TOP_LEVEL ON)
|
||||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "wasm32|emscripten")
|
else()
|
||||||
set(IACORE_ARCH_WASM TRUE)
|
set(IACORE_IS_TOP_LEVEL OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(MSVC)
|
set(IACORE_CMAKE_DIR "${IACORE_ROOT}/CMake" CACHE INTERNAL "")
|
||||||
add_compile_options(/W4)
|
list(APPEND CMAKE_MODULE_PATH "${IACORE_CMAKE_DIR}")
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
||||||
add_compile_options(
|
|
||||||
-Wno-c++98-compat
|
|
||||||
-Wno-c++98-compat-pedantic
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
include(IAProjectConfig)
|
||||||
add_compile_options(
|
iacore_setup_project()
|
||||||
-Wall -Wextra -Wpedantic
|
|
||||||
-Wno-language-extension-token
|
message(STATUS "[IACore] Detected Compiler: ${CMAKE_CXX_COMPILER_ID}")
|
||||||
|
|
||||||
|
if (MSVC AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"\n-------------------------------------------------------------\n"
|
||||||
|
"CRITICAL ERROR: Unsupported Compiler (MSVC/cl.exe)\n"
|
||||||
|
"IACore requires GCC or Clang. On Windows, use 'Clang-cl' or MinGW.\n"
|
||||||
|
"-------------------------------------------------------------\n"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(Src/)
|
include(FindDeps)
|
||||||
|
|
||||||
|
option(IACore_BUILD_TESTS "Build unit tests" ${IACORE_IS_TOP_LEVEL})
|
||||||
|
|
||||||
|
add_subdirectory(Src)
|
||||||
|
|
||||||
if(IACore_BUILD_TESTS)
|
if(IACore_BUILD_TESTS)
|
||||||
add_subdirectory(Tests)
|
add_subdirectory(Tests)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Local Development Sandbox (Not tracked in git)
|
|
||||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Sandbox")
|
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Sandbox")
|
||||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/Sandbox")
|
add_subdirectory(Sandbox)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
43
Docs/BUILDING.md
Normal file
43
Docs/BUILDING.md
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
## 🛠️ Building IACore
|
||||||
|
|
||||||
|
IACore uses **CMake Presets** to manage toolchains and cross-compilation. This ensures that the correct compilers (Clang) and flags (AVX2/SIMD) are used automatically.
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
* CMake 3.28+
|
||||||
|
* Ninja Build System
|
||||||
|
* Vcpkg (Environment variable `VCPKG_ROOT` must be set)
|
||||||
|
* Clang / Clang-CL
|
||||||
|
|
||||||
|
### Build Instructions
|
||||||
|
|
||||||
|
**1. Configure**
|
||||||
|
Select the preset for your target platform.
|
||||||
|
```bash
|
||||||
|
# List available presets
|
||||||
|
cmake --list-presets
|
||||||
|
|
||||||
|
# Configure for your platform (e.g., windows-x64, linux-arm64, wasm)
|
||||||
|
cmake --preset windows-x64
|
||||||
|
```
|
||||||
|
|
||||||
|
**2. Build**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cmake --build --preset windows-x64
|
||||||
|
```
|
||||||
|
|
||||||
|
**3. Test (Optional)**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ctest --preset windows-x64
|
||||||
|
```
|
||||||
|
|
||||||
|
### Presets
|
||||||
|
|
||||||
|
|Preset |Description |Toolchain |
|
||||||
|
|-------------|------------------------------|------------------------------------|
|
||||||
|
|windows-x64 |Windows (Clang-CL) |CMake/Toolchains/windows-x64.cmake |
|
||||||
|
|linux-x64 |Linux (Clang) |CMake/Toolchains/linux-x64.cmake |
|
||||||
|
|wasm |WebAssembly (Emscripten) |CMake/Toolchains/wasm.cmake |
|
||||||
|
|windows-arm64|Windows on ARM (Cross-compile)|CMake/Toolchains/windows-arm64.cmake|
|
||||||
|
|linux-arm64 |Linux on ARM (Cross-compile) |CMake/Toolchains/linux-arm64.cmake |
|
||||||
26
Docs/USING.md
Normal file
26
Docs/USING.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
## 🚀 Using IACore in a New Project
|
||||||
|
|
||||||
|
IACore provides a CMake macro `iacore_setup_project()`, which standardizes your build environment. This macro automatically:
|
||||||
|
|
||||||
|
* Enforces C++20 standard.
|
||||||
|
* Sets warning levels (-Wall -Wextra -Wpedantic for Clang/GCC, /W4 for MSVC/Clang-CL).
|
||||||
|
* Detects the target architecture (x64, ARM64, WASM) and sets internal cache variables.
|
||||||
|
* Suppresses C++98 compatibility warnings when using Clang on Windows.
|
||||||
|
|
||||||
|
Example CMakeLists.txt
|
||||||
|
```cmake
|
||||||
|
cmake_minimum_required(VERSION 3.28)
|
||||||
|
project(MyGame)
|
||||||
|
|
||||||
|
add_subdirectory(external/IACore)
|
||||||
|
|
||||||
|
## Apply IACore's standard project configuration
|
||||||
|
# This applies C++20 and strict warning flags globally to your targets.
|
||||||
|
iacore_setup_project()
|
||||||
|
|
||||||
|
# Define your target(s)
|
||||||
|
add_executable(MyGame src/main.cpp)
|
||||||
|
|
||||||
|
# Link IACore
|
||||||
|
target_link_libraries(MyGame PRIVATE IACore)
|
||||||
|
```
|
||||||
49
README.md
49
README.md
@ -28,30 +28,6 @@ Originally developed as the internal core for IASoft (PVT) LTD., it is now open-
|
|||||||
* **📜 Logging:** Thread-safe, colored console and disk logging.
|
* **📜 Logging:** Thread-safe, colored console and disk logging.
|
||||||
* **⚡ Modern C++:** Heavily utilizes modern C++20 concepts, `std::span`, and `tl::expected` for error handling.
|
* **⚡ Modern C++:** Heavily utilizes modern C++20 concepts, `std::span`, and `tl::expected` for error handling.
|
||||||
|
|
||||||
## 🛠️ Integration
|
|
||||||
|
|
||||||
IACore is built with CMake. You can include it in your project via `FetchContent` or by adding it as a subdirectory.
|
|
||||||
|
|
||||||
**Note:** On Windows, you must have **VCPKG** installed and the `VCPKG_ROOT` environment variable set, for OpenSSL support.
|
|
||||||
|
|
||||||
### CMake Example
|
|
||||||
```cmake
|
|
||||||
add_subdirectory(IACore)
|
|
||||||
|
|
||||||
add_executable(MyApp Main.cpp)
|
|
||||||
target_link_libraries(MyApp PRIVATE IACore)
|
|
||||||
```
|
|
||||||
|
|
||||||
## 📦 Dependencies
|
|
||||||
IACore manages its own dependencies via CMake's FetchContent. You do not need to install these manually:
|
|
||||||
|
|
||||||
* **Networking:** `cpp-httplib`
|
|
||||||
* **Compression:** `zlib-ng` & `zstd`
|
|
||||||
* **Utilities:** `tl-expected` & `unordered_dense`
|
|
||||||
* **JSON:** `glaze`
|
|
||||||
|
|
||||||
**Note:** Following dependencies are not directly used by IACore, but bundles them (+ helper wrappers) for user convenience: `nlohmann_json`, `simdjson`, `pugixml`
|
|
||||||
|
|
||||||
## 💡 Usage Examples
|
## 💡 Usage Examples
|
||||||
### 1. IPC (Manager & Node)
|
### 1. IPC (Manager & Node)
|
||||||
IACore provides a manager/node architecture using shared memory.
|
IACore provides a manager/node architecture using shared memory.
|
||||||
@ -132,6 +108,20 @@ if (res) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## 🛠️ Integration
|
||||||
|
|
||||||
|
IACore is built with CMake. You can include it in your project via `FetchContent` or by adding it as a subdirectory.
|
||||||
|
|
||||||
|
**Note:** On Windows, you must have **VCPKG** installed and the `VCPKG_ROOT` environment variable set, for OpenSSL support.
|
||||||
|
|
||||||
|
### CMake Example
|
||||||
|
```cmake
|
||||||
|
add_subdirectory(IACore)
|
||||||
|
|
||||||
|
add_executable(MyApp Main.cpp)
|
||||||
|
target_link_libraries(MyApp PRIVATE IACore)
|
||||||
|
```
|
||||||
|
|
||||||
## 🤝 Contributing
|
## 🤝 Contributing
|
||||||
|
|
||||||
We welcome contributions from the community!
|
We welcome contributions from the community!
|
||||||
@ -147,6 +137,17 @@ Currently, **we are not accepting Pull Requests that modify the core source code
|
|||||||
|
|
||||||
If you find a critical bug in `Src/`, please open an **Issue** rather than a PR, and the core team will implement a fix ASAP.
|
If you find a critical bug in `Src/`, please open an **Issue** rather than a PR, and the core team will implement a fix ASAP.
|
||||||
|
|
||||||
|
## 📦 Dependencies
|
||||||
|
IACore manages its own dependencies via CMake's FetchContent. You do not need to install these manually:
|
||||||
|
|
||||||
|
* **JSON:** `glaze`
|
||||||
|
* **SIMD:** `google-highway`
|
||||||
|
* **Networking:** `cpp-httplib`
|
||||||
|
* **Compression:** `zlib-ng` & `zstd`
|
||||||
|
* **Utilities:** `tl-expected` & `unordered_dense`
|
||||||
|
|
||||||
|
**Note:** Following dependencies are not directly used by IACore, but bundles them (+ helper wrappers) for user convenience: `nlohmann_json`, `simdjson`, `pugixml`
|
||||||
|
|
||||||
## ⚖️ License
|
## ⚖️ License
|
||||||
|
|
||||||
This project is licensed under the Apache License Version 2.0.
|
This project is licensed under the Apache License Version 2.0.
|
||||||
|
|||||||
@ -78,7 +78,7 @@ if(IACORE_ARCH_X64)
|
|||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_compile_options(IACore INTERFACE /arch:AVX2)
|
target_compile_options(IACore INTERFACE /arch:AVX2)
|
||||||
else()
|
else()
|
||||||
target_compile_options(IACore INTERFACE -mavx2 -mfma)
|
target_compile_options(IACore INTERFACE -mavx2 -mfma -mpclmul -maes)
|
||||||
endif()
|
endif()
|
||||||
target_compile_definitions(IACore INTERFACE HWY_BASELINE_TARGETS=HWY_AVX2)
|
target_compile_definitions(IACore INTERFACE HWY_BASELINE_TARGETS=HWY_AVX2)
|
||||||
elseif(IACORE_ARCH_ARM64)
|
elseif(IACORE_ARCH_ARM64)
|
||||||
|
|||||||
Reference in New Issue
Block a user