|
| 1 | +# |
| 2 | +# file: CMakeLists.txt |
| 3 | +# author: Sho Ikeda |
| 4 | +# |
| 5 | +# Copyright (c) 2026 Advanced Micro Devices, Inc. All Rights Reserved. |
| 6 | +# |
| 7 | +# SPDX-License-Identifier: MIT |
| 8 | +# |
| 9 | + |
| 10 | +cmake_minimum_required(VERSION 3.21) |
| 11 | + |
| 12 | +# CMake dependencies |
| 13 | +include(${CMAKE_CURRENT_LIST_DIR}/cmake/options.cmake) |
| 14 | +include(${CMAKE_CURRENT_LIST_DIR}/cmake/project.cmake) |
| 15 | +include(${CMAKE_CURRENT_LIST_DIR}/cmake/utility.cmake) |
| 16 | + |
| 17 | +set(project_desc "A minimal DirectX-based neural network library") |
| 18 | +project(MiniDxNN DESCRIPTION ${project_desc} VERSION 0.1.0 LANGUAGES CXX) |
| 19 | + |
| 20 | + # Configure project options (build flags, sanitizers, etc.) |
| 21 | + setProjectOptions() |
| 22 | + |
| 23 | + # Top-level project configuration |
| 24 | + # Only applied when MiniDxNN is the main project (not when included as a subproject) |
| 25 | + if(PROJECT_IS_TOP_LEVEL) |
| 26 | + # Configure available build types (multi-config generators like Visual Studio) |
| 27 | + set(CMAKE_CONFIGURATION_TYPES "Debug" "RelWithDebInfo" "Release") |
| 28 | + |
| 29 | + # Set default build type for single-config generators (Unix Makefiles, Ninja) |
| 30 | + if(NOT CMAKE_BUILD_TYPE) |
| 31 | + set(CMAKE_BUILD_TYPE "Debug") |
| 32 | + message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to Debug") |
| 33 | + endif() |
| 34 | + |
| 35 | + # Generate compile_commands.json for IDE integration and tools (clangd, clang-tidy, etc.) |
| 36 | + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 37 | + endif() |
| 38 | + |
| 39 | + # Build third-party dependencies |
| 40 | + add_subdirectory("${PROJECT_SOURCE_DIR}/third_party" "${PROJECT_BINARY_DIR}/third_party") |
| 41 | + |
| 42 | + # Configure MiniDxNN core library |
| 43 | + setMiniDxNNCore(minidxnn-core) |
| 44 | + checkTarget(minidxnn-core) |
| 45 | + |
| 46 | + # Configure and build examples |
| 47 | + if(PROJECT_IS_TOP_LEVEL AND MINIDXNN_BUILD_EXAMPLES) |
| 48 | + message(STATUS "Enable examples") |
| 49 | + add_subdirectory("${PROJECT_SOURCE_DIR}/example" "${PROJECT_BINARY_DIR}/example") |
| 50 | + endif() |
| 51 | + |
| 52 | + # Configure and build unit tests |
| 53 | + if(PROJECT_IS_TOP_LEVEL AND MINIDXNN_BUILD_TESTS) |
| 54 | + message(STATUS "Enable unittests") |
| 55 | + enable_testing() |
| 56 | + add_subdirectory("${PROJECT_SOURCE_DIR}/unittest" "${PROJECT_BINARY_DIR}/unittest") |
| 57 | + endif() |
0 commit comments