|
| 1 | +# This file is part of the the DGF-SDK. |
| 2 | +# |
| 3 | +# Copyright (C) 2025 Advanced Micro Devices, Inc. |
| 4 | +# |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +# of this software and associated documentation files(the "Software"), to deal |
| 7 | +# in the Software without restriction, including without limitation the rights |
| 8 | +# to use, copy, modify, merge, publish, distribute, sublicense, and /or sell |
| 9 | +# copies of the Software, and to permit persons to whom the Software is |
| 10 | +# furnished to do so, subject to the following conditions : |
| 11 | +# |
| 12 | +# The above copyright notice and this permission notice shall be included in |
| 13 | +# all copies or substantial portions of the Software. |
| 14 | +# |
| 15 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 21 | +# THE SOFTWARE. |
| 22 | + |
| 23 | +cmake_minimum_required(VERSION 3.5) |
| 24 | +project(DGFSDK) |
| 25 | + |
| 26 | +# Check if DGF is used as main project or just consumed as libary with add_subdirectory |
| 27 | +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) |
| 28 | + set(DGF_IS_TOP_LEVEL ON) |
| 29 | +else() |
| 30 | + set(DGF_IS_TOP_LEVEL OFF) |
| 31 | +endif() |
| 32 | + |
| 33 | + |
| 34 | +if( DGF_IS_TOP_LEVEL ) |
| 35 | + message( STATUS "DGFSDK: Top-level build detected" ) |
| 36 | + |
| 37 | + # We're the root project, build everything |
| 38 | + set( DGF_BUILD_DGFLIB 1 ) |
| 39 | + set( DGF_BUILD_DGFBAKER 1 ) |
| 40 | + set( DGF_BUILD_DGFTESTER 1 ) |
| 41 | + set( DGF_BUILD_SAMPLES 1 ) |
| 42 | +else() |
| 43 | + |
| 44 | + # we're a client of somebody else's project, let them control what they want |
| 45 | + # by default, build only 'DGFLib' |
| 46 | + message( STATUS "DGFSDK: Library build detected" ) |
| 47 | + |
| 48 | + if( NOT DEFINED DGF_BUILD_DGFTESTER ) |
| 49 | + set( DGF_BUILD_DGFTESTER 0 ) |
| 50 | + message( STATUS "DGF_BUILD_DGFLIB not set, setting to ${DGF_BUILD_DGFTESTER}") |
| 51 | + endif() |
| 52 | + |
| 53 | + if( NOT DEFINED DGF_BUILD_SAMPLES ) |
| 54 | + set( DGF_BUILD_SAMPLES 0 ) |
| 55 | + message( STATUS "DGF_BUILD_SAMPLES not seat, setting to ${DGF_BUILD_SAMPLES}") |
| 56 | + endif() |
| 57 | + |
| 58 | + if( NOT DEFINED DGF_BUILD_DGFLIB ) |
| 59 | + set( DGF_BUILD_DGFLIB 1 ) |
| 60 | + message( STATUS "DGF_BUILD_DGFLIB not set, setting to ${DGF_BUILD_DGFLIB}") |
| 61 | + endif() |
| 62 | + |
| 63 | + if( NOT DEFINED DGF_BUILD_DGFBAKER ) |
| 64 | + set( DGF_BUILD_DGFBAKER 0 ) |
| 65 | + message( STATUS "DGF_BUILD_DGFBAKER not set, setting to ${DGF_BUILD_DGFBAKER}") |
| 66 | + endif() |
| 67 | +endif() |
| 68 | + |
| 69 | +# DGFTester and Samples depend on DGFBaker |
| 70 | +if( DGF_BUILD_SAMPLES OR DGF_BUILD_DGFTESTER ) |
| 71 | + set( DGF_BUILD_DGFBAKER 1 ) |
| 72 | + set( DGF_BUILD_DGFLIB 1 ) |
| 73 | +endif() |
| 74 | + |
| 75 | +# DGFBaker depends on DGFLib |
| 76 | +if( DGF_BUILD_DGFBAKER ) |
| 77 | + set( DGF_BUILD_DGFLIB 1 ) |
| 78 | +endif() |
| 79 | + |
| 80 | +add_subdirectory(external) |
| 81 | + |
| 82 | +if( DGF_BUILD_DGFLIB ) |
| 83 | + set( DGF_LIB_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/DGFLib ) |
| 84 | + add_subdirectory(DGFLib) |
| 85 | +endif() |
| 86 | +if( DGF_BUILD_DGFBAKER ) |
| 87 | + add_subdirectory(DGFBaker) |
| 88 | +endif() |
| 89 | +if( DGF_BUILD_DGFTESTER ) |
| 90 | + add_subdirectory(DGFTester) |
| 91 | +endif() |
| 92 | +if( DGF_BUILD_SAMPLES ) |
| 93 | + add_subdirectory(DGFSample) |
| 94 | +endif() |
0 commit comments